open-index/open-npm huggingface dataset:
npm package: @petriflow/engine
Description: Petri net workflow engine with guards, executors, timeouts, persistence, and scheduling. Extends [petri-ts](https://github.com/joshuaisaact/petri-ts) with runtime capabilities for building stateful workflows.
Latest version: 0.3.0

# @petriflow/engine

Petri net workflow engine with guards, executors, timeouts, persistence, and scheduling. Extends [petri-ts](https://github.com/joshuaisaact/petri-ts) with runtime capabilities for building stateful workflows.

Used by [`@petriflow/gate`](../gate) (tool access control) and [`@petriflow/rules`](../rules) (declarative DSL).

## Install

```bash
npm install @petriflow/engine
```

## Usage

```typescript
import { defineWorkflow, toNet, analyse } from "@petriflow/engine";

const workflow = defineWorkflow({
  name: "order",
  places: ["pending", "approved", "shipped"] as const,
  initialMarking: { pending: 1, approved: 0, shipped: 0 },
  transitions: [
    {
      name: "approve",
      inputs: ["pending"],
      outputs: ["approved"],
      guard: (marking) => marking.pending > 0,
    },
    {
      name: "ship",
      inputs: ["approved"],
      outputs: ["shipped"],
    },
  ],
});

// Analyse reachable states, deadlocks, invariants
const result = analyse(workflow);
console.log(result.reachableStates); // 3
console.log(result.deadlockFree);   // false (shipped is terminal)

// Strip extensions for pure petri-ts analysis
const net = toNet(workflow);
```

## Exports

| Export path | Description |
|---|---|
| `@petriflow/engine` | Core engine: workflow definition, guards, executors, scheduling, persistence |
| `@petriflow/engine/analyse` | `analyse()` — reachable states, deadlock detection, invariant checking |
| `@petriflow/engine/workflow` | `defineWorkflow()`, `toNet()` |
| `@petriflow/engine/types` | TypeScript types only |
| `@petriflow/engine/decision` | Decision provider types for human-in-the-loop |

All petri-ts functions and types are re-exported from the main entry point (`canFire`, `fire`, `reachableStates`, `Marking`, `Transition`, etc.).

## Key concepts

**WorkflowTransition** — extends petri-ts `Transition` with optional `guard`, `execute`, `timeout`, and `config` fields. The intersection type (`Transition & { ... }`) ensures structural compatibility with all petri-ts functions — no adapters needed.

**`toNet()`** — strips guard/execute/timeout extensions, returning a plain `PetriNet` for pure analysis with petri-ts functions like `reachableStates()` and `isDeadlockFree()`.

**Persistence** — SQLite adapter via `bun:sqlite` for saving/loading workflow instances, transition history, and timeout entries.

**Scheduler** — tick-based execution loop with re-entrancy protection, timeout handling, and event hooks.

## Tests

```bash
bun test packages/engine
```
npm package: @petriflow/vercel-ai
Description: Petri net gating adapter for the [Vercel AI SDK](https://sdk.vercel.ai/) (v6+). Wraps tool definitions so each `execute` call is gated by `@petriflow/gate`.
Latest version: 0.4.0

# @petriflow/vercel-ai

Petri net gating adapter for the [Vercel AI SDK](https://sdk.vercel.ai/) (v6+). Wraps tool definitions so each `execute` call is gated by `@petriflow/gate`.

## Install

```bash
bun add @petriflow/vercel-ai
# or
npm install @petriflow/vercel-ai
```

Peer dependency: `ai` ^6.0.0

## Usage

```ts
import { loadRules } from '@petriflow/rules';
import { createPetriflowGate } from '@petriflow/vercel-ai';
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';

const { nets } = await loadRules('./safety.rules');
const gate = createPetriflowGate(nets);

const result = await generateText({
  model: openai('gpt-4o'),
  tools: gate.wrapTools({ weather: weatherTool, bash: bashTool }),
  system: gate.systemPrompt(),
  prompt: 'What is the weather?',
});
```

### With `streamText`

```ts
import { streamText } from 'ai';

const result = streamText({
  model: openai('gpt-4o'),
  tools: gate.wrapTools(myTools),
  system: gate.systemPrompt(),
  prompt: '...',
});
```

### Manual confirmation

```ts
const gate = createPetriflowGate(nets, {
  confirm: async (title, msg) => {
    // Show a dialog, return true/false
    return showConfirmDialog(title, msg);
  },
});
```

### Registry mode (dynamic nets)

```ts
const gate = createPetriflowGate({
  registry: { safety: safetyNet, deploy: deployNet },
  active: ['safety'],
});

gate.addNet('deploy');    // activate a registered net
gate.removeNet('safety'); // deactivate (state preserved)
```

### Shadow mode

```ts
const gate = createPetriflowGate(nets, {
  mode: 'shadow',
  onDecision: (event, decision) => {
    console.log('Would have blocked:', event.toolName, decision);
  },
});
```

## API

| Method | Description |
|--------|-------------|
| `createPetriflowGate(nets, opts?)` | Create a gate instance from nets or a registry config |
| `gate.wrapTools(tools)` | Wrap tool definitions with gate logic |
| `gate.systemPrompt()` | Get system prompt with net status |
| `gate.formatStatus()` | Get current marking for all nets |
| `gate.addNet(name)` | Activate a registered net (registry mode) |
| `gate.removeNet(name)` | Deactivate a net (registry mode) |
| `gate.manager` | Access the underlying `GateManager` |

## Bundled net

```ts
import { vercelAiToolApprovalNet } from '@petriflow/vercel-ai/nets/tool-approval';
```

A generic tool-approval net with `readData`/`fetchData` as free tools and `writeData`/`sendEmail` as gated tools.

## How it works

```
User's tools ──→ gate.wrapTools() ──→ Gated tools ──→ generateText/streamText
                      │
                      ▼
              Each tool.execute is replaced:
              1. manager.handleToolCall()  → block or allow
              2. original execute()        → run the tool
              3. manager.handleToolResult() → resolve deferreds
```

Blocked tools throw `ToolCallBlockedError`, which the SDK reports as `tool-error` to the model.
npm package: @petristation/renewjs
Description: Parser for .rnw files
Author: Laszlo Korte
Latest version: 2.0.3

# Renew File Parser

![Project Logo](./images/logo.svg)

A parser for the .rnw file format used by [Renew](//www.renew.de).

[![NPM](https://img.shields.io/npm/v/@petristation/renewjs.svg)](https://www.npmjs.com/package/@petristation/renewjs)

Used in [PetriStation](//www.petristation.net) to import Renew files.

## Tests

Run tests on over 1000 `.rnw` example files via `node tests/test.js` or `npm test`:

```
$ npm test

> @petristation/renewjs@1.0.4 test
> node ./tests/test.js

........................................................................
........................................................................
........................................................................
.............................................................SS.........
........................................................................
........................................................................
........................................................................
........................................................................
................................................................S.......
........................................................................
........................................................................
........................................................................
........................................................................
........................................................................
........................................................................
........................................................................
...............................................................
```

---

[www.laszlokorte.de](//www.laszlokorte.de)
npm package: @petritapanilahdelma/llm-component-cli
Description: CLI for validating, migrating, and scaffolding LLM component schemas.
Latest version: 1.2.0

# @petritapanilahdelma/llm-component-cli

CLI for validating, migrating, and scaffolding LLM component schemas.

## Install

```bash
npm install -D @petritapanilahdelma/llm-component-cli
```

## Commands

```bash
llm-component-schema validate schema.json
llm-component-schema drift-check --root . --out dist/schema-drift-report.json
llm-component-schema migrate --from v1 --to v2 --input v1.json --output v2.json
llm-component-schema init Button --style tailwind --target examples/generated/components
```

## Notes

- `validate` runs strict structure checks plus JSON contract validation.
- `drift-check` compares schema props against component props and Storybook args.
- `migrate` currently supports `v1 -> v2`.
- `init` creates a full component starter with schema, stories, test, and Code Connect stub.
npm package: @petritapanilahdelma/llm-component-contracts
Description: Versioned JSON contracts and templates for LLM component schemas.
Latest version: 1.2.0

# @petritapanilahdelma/llm-component-contracts

Versioned JSON contracts and templates for the LLM component schema standard.

## Install

```bash
npm install @petritapanilahdelma/llm-component-contracts
```

## Usage

```js
import { schemas, schemaPaths, migrateV1ToV2 } from "@petritapanilahdelma/llm-component-contracts";

console.log(schemas.contracts.v1.title);
console.log(schemaPaths.templates.base);
```

## Exports

- `schemas.contracts.v1`
- `schemas.contracts.v2`
- `schemas.templates.base`
- `schemas.templates.tailwind`
- `schemaPaths` for absolute file paths to each shipped JSON file
- `migrateV1ToV2(schema)` helper