@bpmnkit/proxy 0.0.32 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![ai-assisted](https://img.shields.io/badge/AI--assisted-claude-8b5cf6?style=flat-square)](https://github.com/bpmnkit/monorepo)
10
10
  [![experimental](https://img.shields.io/badge/status-experimental-f59e0b?style=flat-square)](https://github.com/bpmnkit/monorepo)
11
11
 
12
- [Website](https://bpmnkit.com) · [Documentation](https://docs.bpmnkit.com) · [GitHub](https://github.com/bpmnkit/monorepo) · [Changelog](https://github.com/bpmnkit/monorepo/blob/main/apps/proxy/CHANGELOG.md)
12
+ [Website](https://bpmnkit.com) · [Documentation](https://bpmnkit.com/docs) · [GitHub](https://github.com/bpmnkit/monorepo) · [Changelog](https://github.com/bpmnkit/monorepo/blob/main/apps/proxy/CHANGELOG.md)
13
13
  </div>
14
14
 
15
15
  ---
@@ -80,10 +80,12 @@ curl -H "X-Profile: production" http://localhost:3033/api/v2/process-definitions
80
80
  | [`@bpmnkit/plugins`](https://www.npmjs.com/package/@bpmnkit/plugins) | 22 composable canvas plugins |
81
81
  | [`@bpmnkit/api`](https://www.npmjs.com/package/@bpmnkit/api) | Camunda 8 REST API TypeScript client |
82
82
  | [`@bpmnkit/ascii`](https://www.npmjs.com/package/@bpmnkit/ascii) | Render BPMN diagrams as Unicode ASCII art |
83
+ | [`@bpmnkit/docspack`](https://www.npmjs.com/package/@bpmnkit/docspack) | BPMN Kit docs as an offline docspack package for AI agents |
83
84
  | [`@bpmnkit/ui`](https://www.npmjs.com/package/@bpmnkit/ui) | Shared design tokens and UI components |
84
85
  | [`@bpmnkit/profiles`](https://www.npmjs.com/package/@bpmnkit/profiles) | Shared auth, profile storage, and client factories for CLI & proxy |
85
86
  | [`@bpmnkit/operate`](https://www.npmjs.com/package/@bpmnkit/operate) | Monitoring & operations frontend for Camunda clusters |
86
87
  | [`@bpmnkit/connector-gen`](https://www.npmjs.com/package/@bpmnkit/connector-gen) | Generate connector templates from OpenAPI specs |
88
+ | [`@bpmnkit/connectors`](https://www.npmjs.com/package/@bpmnkit/connectors) | Camunda 8 OOTB connector catalog and deterministic template application |
87
89
  | [`@bpmnkit/cli`](https://www.npmjs.com/package/@bpmnkit/cli) | Camunda 8 command-line interface (casen) |
88
90
  | [`@bpmnkit/patterns`](https://www.npmjs.com/package/@bpmnkit/patterns) | Domain process patterns for BPMNKit AIKit |
89
91
  | [`@bpmnkit/reebe-wasm`](https://www.npmjs.com/package/@bpmnkit/reebe-wasm) | WebAssembly BPMN engine for browser simulation |
@@ -0,0 +1,9 @@
1
+ export declare const supportsMcp = true;
2
+ interface Message {
3
+ role: string;
4
+ content: string;
5
+ }
6
+ export declare function available(): Promise<boolean>;
7
+ export declare function stream(messages: Message[], systemPrompt: string, mcpConfigFile: string | null, onToken: (text: string) => void): Promise<void>;
8
+ export {};
9
+ //# sourceMappingURL=claude.d.ts.map
@@ -0,0 +1,9 @@
1
+ export declare const supportsMcp = true;
2
+ interface Message {
3
+ role: string;
4
+ content: string;
5
+ }
6
+ export declare function available(): Promise<boolean>;
7
+ export declare function stream(messages: Message[], systemPrompt: string, mcpConfigFile: string | null, onToken: (text: string) => void): Promise<void>;
8
+ export {};
9
+ //# sourceMappingURL=copilot.d.ts.map
@@ -0,0 +1,9 @@
1
+ export declare const supportsMcp = false;
2
+ interface Message {
3
+ role: string;
4
+ content: string;
5
+ }
6
+ export declare function available(): Promise<boolean>;
7
+ export declare function stream(messages: Message[], systemPrompt: string, _mcpConfigFile: string | null, onToken: (text: string) => void): Promise<void>;
8
+ export {};
9
+ //# sourceMappingURL=gemini.d.ts.map
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AIKit MCP server — exposes BPMNKit capabilities as MCP tools for Claude Code skills.
4
+ *
5
+ * Tools:
6
+ * bpmn_create, bpmn_read, bpmn_update, bpmn_validate, bpmn_deploy,
7
+ * bpmn_simulate, bpmn_run_history,
8
+ * worker_list, worker_scaffold,
9
+ * form_create, dmn_create,
10
+ * pattern_list, pattern_get
11
+ *
12
+ * Usage:
13
+ * node dist/aikit-mcp.js
14
+ *
15
+ * Environment:
16
+ * BPMNKIT_PROXY_URL — proxy base URL (default: http://localhost:3033)
17
+ * ZEEBE_ADDRESS — Zeebe/reebe REST URL (default: http://localhost:26500)
18
+ * ZEEBE_CLIENT_ID — OAuth client ID (Camunda SaaS)
19
+ * ZEEBE_CLIENT_SECRET — OAuth client secret (Camunda SaaS)
20
+ */
21
+ export declare function handleCamundaSearch(code: string): Promise<string>;
22
+ export declare function handleCamundaExecute(code: string): Promise<string>;
23
+ //# sourceMappingURL=aikit-mcp.d.ts.map
package/dist/aikit-mcp.js CHANGED
@@ -483,6 +483,18 @@ async function toolBpmnSimulate(path, scenarios) {
483
483
  throw new Error(`File not found: ${path}`);
484
484
  const xml = readFileSync(absPath, "utf8");
485
485
  const defs = Bpmn.parse(xml);
486
+ if (scenarios.length > 0) {
487
+ const { Engine, runScenario } = await import("@bpmnkit/engine");
488
+ const results = [];
489
+ for (const scenario of scenarios) {
490
+ results.push(await runScenario(new Engine(), defs, scenario));
491
+ }
492
+ return JSON.stringify({
493
+ mode: "execution",
494
+ note: "Ran each scenario against the in-process TS engine (@bpmnkit/engine): mocked job workers, path/variable assertions. Sub-process tools inside an AI Agent sub-process are not individually executed — the sub-process is dispatched and mocked as a single job.",
495
+ results,
496
+ }, null, 2);
497
+ }
486
498
  // Collect all service task job types referenced in the diagram
487
499
  const referencedJobTypes = new Set();
488
500
  for (const proc of defs.processes) {
@@ -510,7 +522,8 @@ async function toolBpmnSimulate(path, scenarios) {
510
522
  const validationReport = optimize(defs);
511
523
  const errors = validationReport.findings.filter((f) => f.severity === "error");
512
524
  return JSON.stringify({
513
- note: "Phase 1: structural analysis. Full simulation (with process execution) coming in a future phase.",
525
+ mode: "structural",
526
+ note: "No scenarios provided — ran structural analysis only (validation findings + worker coverage). Pass `scenarios` to actually execute the process.",
514
527
  validation: {
515
528
  errors: errors.length,
516
529
  findings: errors.map((f) => ({ message: f.message, elementIds: f.elementIds })),
@@ -520,7 +533,6 @@ async function toolBpmnSimulate(path, scenarios) {
520
533
  covered: coveredWorkers.length,
521
534
  missing: missingWorkers,
522
535
  },
523
- scenariosRequested: scenarios.length,
524
536
  }, null, 2);
525
537
  }
526
538
  async function toolBpmnRunHistory(processId) {
@@ -741,15 +753,18 @@ const TOOLS = [
741
753
  },
742
754
  {
743
755
  name: "bpmn_simulate",
744
- description: "Analyse a BPMN process structurally: checks validation findings and worker coverage. " +
745
- "Full process execution simulation is planned for a future phase.",
756
+ description: "Run or analyse a BPMN process. With `scenarios`, actually executes each one against the " +
757
+ 'in-process TS engine (mocked job workers, path/variable assertions) — mode: "execution". ' +
758
+ "Without scenarios, runs structural analysis only (validation findings + worker coverage) — " +
759
+ 'mode: "structural". The response always reports which mode ran.',
746
760
  inputSchema: {
747
761
  type: "object",
748
762
  properties: {
749
763
  path: { type: "string", description: "Path to the .bpmn file" },
750
764
  scenarios: {
751
765
  type: "array",
752
- description: "Test scenarios (reserved for future use)",
766
+ description: "Test scenarios to execute: { id, name, processId?, inputs?, mocks?: " +
767
+ "{ [taskType]: { outputs?, error? } }, expect?: { path?, variables? } }",
753
768
  items: { type: "object" },
754
769
  },
755
770
  },
@@ -0,0 +1,7 @@
1
+ /**
2
+ * QuickJS bridge — exposes all @bpmnkit/core operations as globalThis.Bridge.* functions.
3
+ * Bundled as an IIFE (platform=neutral) and embedded in the Rust binaries via rquickjs.
4
+ * All inputs/outputs are JSON strings or primitives.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1,8 @@
1
+ export interface MethodSpec {
2
+ description: string;
3
+ endpoint: string;
4
+ params: string;
5
+ returns: string;
6
+ }
7
+ export declare const CAMUNDA_SPEC: Record<string, Record<string, MethodSpec>>;
8
+ //# sourceMappingURL=camunda-spec.d.ts.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export declare function startServer(port?: number): void;
3
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import http from "node:http";
4
4
  import { homedir, tmpdir } from "node:os";
5
5
  import { basename, dirname, extname, join, relative, sep } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
- import { Bpmn, applyOperations, compactify, expand, optimize } from "@bpmnkit/core";
7
+ import { Bpmn, applyBpmnOperations, compactify, expand, optimize } from "@bpmnkit/core";
8
8
  import { createClientFromProfile } from "@bpmnkit/profiles";
9
9
  import { getActiveName, getActiveProfile, getAuthHeader, getProfile, listProfiles, } from "@bpmnkit/profiles";
10
10
  import * as claude from "./adapters/claude.js";
@@ -979,12 +979,27 @@ const server = http.createServer(async (req, res) => {
979
979
  // Emits SSE: tokens (explanation) + ops event + xml event + done.
980
980
  if (url.pathname === "/improve" && req.method === "POST") {
981
981
  const body = await readBody(req);
982
- let context;
982
+ let definitions;
983
983
  let instruction;
984
984
  let backend;
985
985
  try {
986
986
  const parsed = JSON.parse(body);
987
- context = parsed.context;
987
+ // `xml` carries the whole model, so operations apply to it directly and
988
+ // nothing outside the compact projection is lost. `context` is the older
989
+ // contract, kept working for clients that have not been updated — it can
990
+ // only ever describe what compact models.
991
+ if (typeof parsed.xml === "string") {
992
+ definitions = Bpmn.parse(parsed.xml);
993
+ }
994
+ else if (parsed.context) {
995
+ console.warn("[server] /improve received compact context; send { xml } to keep pools, lanes and ioMapping detail");
996
+ definitions = expand(parsed.context);
997
+ }
998
+ else {
999
+ res.writeHead(400);
1000
+ res.end("Bad Request: send { xml } or { context }");
1001
+ return;
1002
+ }
988
1003
  instruction = parsed.instruction ?? null;
989
1004
  backend = parsed.backend ?? null;
990
1005
  }
@@ -1003,10 +1018,9 @@ const server = http.createServer(async (req, res) => {
1003
1018
  return;
1004
1019
  }
1005
1020
  // ── Phase 1: auto-fix ─────────────────────────────────────────────────
1006
- let fixedCompact = context;
1007
1021
  let autoFixCount = 0;
1008
1022
  try {
1009
- const defs = expand(context);
1023
+ const defs = definitions;
1010
1024
  const report = optimize(defs);
1011
1025
  const fixable = report.findings
1012
1026
  .filter((f) => f.applyFix)
@@ -1018,7 +1032,6 @@ const server = http.createServer(async (req, res) => {
1018
1032
  f.applyFix?.(defs);
1019
1033
  autoFixCount = fixable.length;
1020
1034
  if (autoFixCount > 0) {
1021
- fixedCompact = compactify(defs);
1022
1035
  console.log(`[server] /improve → auto-fixed ${autoFixCount} issue(s)`);
1023
1036
  }
1024
1037
  }
@@ -1028,7 +1041,7 @@ const server = http.createServer(async (req, res) => {
1028
1041
  // ── Phase 2: collect remaining findings ───────────────────────────────
1029
1042
  const findings = [];
1030
1043
  try {
1031
- const remaining = optimize(expand(fixedCompact));
1044
+ const remaining = optimize(definitions);
1032
1045
  for (const f of remaining.findings) {
1033
1046
  findings.push({
1034
1047
  category: f.category,
@@ -1051,7 +1064,9 @@ const server = http.createServer(async (req, res) => {
1051
1064
  // ── Phase 3: AI call — outputs explanation + ```json operations block ─
1052
1065
  const systemPrompt = buildImproveSystemPrompt();
1053
1066
  const improveCtx = {
1054
- compact: fixedCompact,
1067
+ // The prompt gets the compact view — that is what it is for. The
1068
+ // operations it produces are applied to the full model below.
1069
+ compact: compactify(definitions),
1055
1070
  findings,
1056
1071
  autoFixCount,
1057
1072
  instruction,
@@ -1078,13 +1093,24 @@ const server = http.createServer(async (req, res) => {
1078
1093
  res.write(`data: ${JSON.stringify({ type: "ops", ops, autoFixCount })}\n\n`);
1079
1094
  if (ops.length > 0 || autoFixCount > 0) {
1080
1095
  try {
1081
- const finalCompact = ops.length > 0 ? applyOperations(fixedCompact, ops) : fixedCompact;
1082
- const xml = Bpmn.export(expand(finalCompact));
1096
+ // Operations land on the full model, so anything the compact view in
1097
+ // the prompt could not describe survives the edit untouched.
1098
+ const edited = ops.length > 0
1099
+ ? applyBpmnOperations(definitions, ops, { strict: false })
1100
+ : { definitions, problems: [], applied: 0 };
1101
+ if (edited.problems.length > 0) {
1102
+ // An operation naming an element that does not exist used to be
1103
+ // skipped in silence; report it so the model can be corrected.
1104
+ const detail = edited.problems.map((p) => `[${p.index}] ${p.reason}`).join("; ");
1105
+ console.warn(`[server] /improve → ${edited.problems.length} operation(s) skipped: ${detail}`);
1106
+ res.write(`data: ${JSON.stringify({ type: "problems", problems: edited.problems })}\n\n`);
1107
+ }
1108
+ const xml = Bpmn.export(edited.definitions);
1083
1109
  res.write(`data: ${JSON.stringify({ type: "xml", xml })}\n\n`);
1084
- console.log(`[server] /improve → ${ops.length} ops applied, XML emitted`);
1110
+ console.log(`[server] /improve → ${edited.applied} ops applied, XML emitted`);
1085
1111
  }
1086
1112
  catch (err) {
1087
- console.error("[server] /improve expand failed:", String(err));
1113
+ console.error("[server] /improve apply failed:", String(err));
1088
1114
  res.write(`data: ${JSON.stringify({ type: "error", message: `Failed to apply operations: ${String(err)}` })}\n\n`);
1089
1115
  }
1090
1116
  }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Minimal stdio MCP server for BPMN/DMN/Form editing.
4
+ * Zero external dependencies — pure Node.js built-ins + @bpmnkit/core (workspace package).
5
+ *
6
+ * State is stored as the native model (BpmnDefinitions, DmnDefinitions, or FormDefinition)
7
+ * so core builder APIs produce the correct structure.
8
+ *
9
+ * Usage:
10
+ * node dist/mcp-server.js [--input <file>] [--output <file>]
11
+ *
12
+ * File type is detected from input file content:
13
+ * - DMN XML → DmnDefinitions
14
+ * - Form JSON → FormDefinition
15
+ * - BPMN XML → BpmnDefinitions (default)
16
+ */
17
+ export {};
18
+ //# sourceMappingURL=mcp-server.d.ts.map
@@ -17,7 +17,7 @@
17
17
  import { readFileSync, writeFileSync } from "node:fs";
18
18
  import { createInterface } from "node:readline";
19
19
  import vm from "node:vm";
20
- import { Bpmn, Dmn, Form, compactify, compactifyDmn, compactifyForm, expand, expandDmn, expandForm, layoutDmn, layoutProcess, } from "@bpmnkit/core";
20
+ import { Bpmn, Dmn, Form, compactify, compactifyDmn, compactifyForm, expand, expandDmn, expandForm, layoutDmn, layoutProcess, reconcileCompact, semanticHash, } from "@bpmnkit/core";
21
21
  import { handleSdkExecute, handleSdkSearch } from "./sdk-code-mode.js";
22
22
  // ── CLI args ──────────────────────────────────────────────────────────────────
23
23
  function getArg(flag) {
@@ -84,12 +84,27 @@ function buildBpmnDiagram(proc) {
84
84
  },
85
85
  };
86
86
  }
87
+ /**
88
+ * Writes the current model out.
89
+ *
90
+ * BPMN goes through the same check `writeBpmn` makes — serialise, parse back,
91
+ * compare the semantic hash — so a serialisation that lost something fails the
92
+ * tool call instead of quietly replacing the user's file. It cannot call
93
+ * `writeBpmn` itself: the code-mode bridge invokes tools synchronously inside a
94
+ * `vm` context, and that function is async. Adopting it here means giving the
95
+ * bridge an async path first.
96
+ */
87
97
  function saveState() {
88
98
  if (!outputFile)
89
99
  return;
90
100
  if (state.kind === "bpmn") {
91
101
  state.data.diagrams = state.data.processes.map((proc) => buildBpmnDiagram(proc));
92
- writeFileSync(outputFile, Bpmn.export(state.data));
102
+ const xml = Bpmn.export(state.data);
103
+ const expected = semanticHash(state.data);
104
+ if (semanticHash(Bpmn.parse(xml)) !== expected) {
105
+ throw new Error("Serialising the model did not reproduce it; nothing was written. This is a bug in @bpmnkit/core — please report the model that triggered it.");
106
+ }
107
+ writeFileSync(outputFile, xml);
93
108
  }
94
109
  else if (state.kind === "dmn") {
95
110
  const laid = layoutDmn(state.data);
@@ -537,7 +552,18 @@ function callTool(name, args) {
537
552
  state = { kind: "form", data: expandForm(raw) };
538
553
  }
539
554
  else {
540
- state = { kind: "bpmn", data: expand(raw) };
555
+ // Reconcile rather than expand. `expand` would rebuild the whole
556
+ // document from the compact view, discarding the pools, lanes, data
557
+ // wiring and Zeebe detail that view cannot describe; this applies the
558
+ // same input as changes to the model already loaded.
559
+ const result = reconcileCompact(state.data, raw, { strict: false });
560
+ state = { kind: "bpmn", data: result.definitions };
561
+ saveState();
562
+ return result.problems.length === 0
563
+ ? "Diagram updated."
564
+ : `Diagram updated, ${result.problems.length} change(s) skipped: ${result.problems
565
+ .map((problem) => problem.reason)
566
+ .join("; ")}`;
541
567
  }
542
568
  saveState();
543
569
  return "Diagram replaced.";
@@ -0,0 +1,55 @@
1
+ import type { CompactDiagram } from "@bpmnkit/core";
2
+ /** Short system prompt for MCP-capable adapters. The LLM uses tools instead of returning JSON blobs. */
3
+ export declare function buildMcpSystemPrompt(): string;
4
+ export interface FindingInfo {
5
+ category: string;
6
+ severity: string;
7
+ message: string;
8
+ suggestion: string;
9
+ elementIds: string[];
10
+ }
11
+ /** System prompt for the improve action with MCP tools. Passes pre-computed findings from core optimize(). */
12
+ export declare function buildMcpImprovePrompt(findings: FindingInfo[]): string;
13
+ /** System prompt for the explain action with MCP tools. */
14
+ export declare function buildMcpExplainPrompt(): string;
15
+ export declare function buildIncidentSystemPrompt(): string;
16
+ export interface IncidentContext {
17
+ errorType: string;
18
+ errorMessage: string;
19
+ elementId: string;
20
+ processDefinitionId: string;
21
+ processInstanceKey: string;
22
+ state: string;
23
+ creationTime?: string;
24
+ jobKey?: string;
25
+ }
26
+ export declare function buildIncidentUserMessage(incident: IncidentContext, variables: Array<{
27
+ name: string;
28
+ value?: string;
29
+ }>, processXml: string | null): string;
30
+ /**
31
+ * Minimal system prompt for the AI search endpoint.
32
+ * Instructs the model to output ONLY a JSON object (no prose) to keep token usage low.
33
+ */
34
+ export declare function buildSearchSystemPrompt(): string;
35
+ export interface OperateStats {
36
+ runningInstances: number;
37
+ activeIncidents: number;
38
+ pendingTasks: number;
39
+ deployedDefinitions: number;
40
+ activeJobs: number;
41
+ }
42
+ export declare function buildOperateChatSystemPrompt(stats: OperateStats | null): string;
43
+ export declare function buildImproveSystemPrompt(): string;
44
+ export interface ImproveContext {
45
+ compact: CompactDiagram;
46
+ findings: FindingInfo[];
47
+ autoFixCount: number;
48
+ instruction?: string | null;
49
+ }
50
+ export declare function buildImproveUserMessage(ctx: ImproveContext): string;
51
+ export declare function buildFormCreateSystemPrompt(taskName: string, taskContext: string): string;
52
+ export declare function buildDmnCreateSystemPrompt(decisionId: string, taskContext: string): string;
53
+ /** Full system prompt for non-MCP adapters that must return a CompactDiagram JSON block. */
54
+ export declare function buildSystemPrompt(context: unknown): string;
55
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1,25 @@
1
+ import type http from "node:http";
2
+ import type { WorkerJob } from "../worker.js";
3
+ /** Called before a job handler is invoked. */
4
+ export declare function onJobStart(job: WorkerJob): void;
5
+ /** Called after a job handler succeeds. */
6
+ export declare function onJobComplete(job: WorkerJob, outputs: Record<string, unknown>, durationMs: number): void;
7
+ /** Called after a job handler throws. */
8
+ export declare function onJobFail(job: WorkerJob, errorMessage: string, durationMs: number): void;
9
+ /** GET /run-history — list of runs, most recent first. */
10
+ export declare function handleGetRunHistory(req: http.IncomingMessage, res: http.ServerResponse): void;
11
+ /** GET /run-history/:id — single run with steps. */
12
+ export declare function handleGetRunHistoryDetail(req: http.IncomingMessage, res: http.ServerResponse, runId: string): void;
13
+ /** DELETE /run-history — clear all history. */
14
+ export declare function handleDeleteRunHistory(_req: http.IncomingMessage, res: http.ServerResponse): void;
15
+ /** Route matcher — returns the run ID if the URL matches /run-history/:id */
16
+ export declare function matchRunHistoryRoute(req: http.IncomingMessage): {
17
+ id: string;
18
+ } | null;
19
+ /** POST /run-history/:id/rerun — start a new process instance from a historical run. */
20
+ export declare function handleRerunHistory(req: http.IncomingMessage, res: http.ServerResponse, runId: string): Promise<void>;
21
+ /** Route matcher — returns run ID if URL matches /run-history/:id/rerun */
22
+ export declare function matchRerunHistoryRoute(req: http.IncomingMessage): {
23
+ id: string;
24
+ } | null;
25
+ //# sourceMappingURL=run-history.d.ts.map
@@ -0,0 +1,15 @@
1
+ export type HostFunction = (...args: unknown[]) => Promise<unknown>;
2
+ export interface SandboxContext {
3
+ /** JSON-serializable values injected as named globals */
4
+ data?: Record<string, unknown>;
5
+ /**
6
+ * Async host functions exposed as ivm.References.
7
+ * Inside the sandbox, call them with:
8
+ * await __name.apply(undefined, [...args], { result: { promise: true, copy: true } })
9
+ */
10
+ functions?: Record<string, HostFunction>;
11
+ /** JS injected before user code (e.g. proxy builders) */
12
+ bootstrap?: string;
13
+ }
14
+ export declare function runSandboxed(code: string, ctx: SandboxContext, timeoutMs?: number): Promise<unknown>;
15
+ //# sourceMappingURL=sandbox.d.ts.map
@@ -0,0 +1,3 @@
1
+ export declare function handleSdkSearch(code: string): string;
2
+ export declare function handleSdkExecute(code: string, xml?: string): string;
3
+ //# sourceMappingURL=sdk-code-mode.d.ts.map
@@ -0,0 +1,59 @@
1
+ export declare const SDK_SPEC: {
2
+ readonly functions: {
3
+ readonly "sdk.parse": {
4
+ readonly description: "Parse BPMN XML into a CompactDiagram JSON string.";
5
+ readonly params: "xml: string";
6
+ readonly returns: "string (CompactDiagram JSON)";
7
+ readonly example: "const compact = sdk.parse(xml)";
8
+ };
9
+ readonly "sdk.exportXml": {
10
+ readonly description: "Convert a CompactDiagram JSON string to BPMN XML with auto-layout applied.";
11
+ readonly params: "compactJson: string";
12
+ readonly returns: "string (BPMN XML)";
13
+ readonly example: "const xml = sdk.exportXml(compact)";
14
+ };
15
+ readonly "sdk.optimize": {
16
+ readonly description: "Run the pattern advisor on a CompactDiagram. Returns findings and an optimized diagram.";
17
+ readonly params: "compactJson: string";
18
+ readonly returns: "string (JSON: { diagram: CompactDiagram, findings: Finding[] })";
19
+ readonly example: "const { diagram, findings } = JSON.parse(sdk.optimize(compact))";
20
+ };
21
+ readonly "sdk.layout": {
22
+ readonly description: "Apply automatic ELK layout to a CompactDiagram. Returns updated CompactDiagram JSON.";
23
+ readonly params: "compactJson: string";
24
+ readonly returns: "string (CompactDiagram JSON)";
25
+ readonly example: "const laidOut = JSON.parse(sdk.layout(compact))";
26
+ };
27
+ readonly "sdk.analyzeVariables": {
28
+ readonly description: "Analyze FEEL variable flow across a process. Identifies undeclared inputs and output variable paths.";
29
+ readonly params: "compactJson: string";
30
+ readonly returns: "string (JSON: VariableFlowAnalysis)";
31
+ readonly example: "const analysis = JSON.parse(sdk.analyzeVariables(compact))";
32
+ };
33
+ };
34
+ readonly compactDiagram: {
35
+ readonly description: "Lightweight JSON representation of a BPMN diagram. Input/output format for all sdk functions.";
36
+ readonly shape: {
37
+ readonly processes: readonly [{
38
+ readonly id: "string — process id, e.g. 'order-flow'";
39
+ readonly name: "string? — display name";
40
+ readonly elements: readonly [{
41
+ readonly id: "string";
42
+ readonly type: "startEvent | endEvent | serviceTask | userTask | businessRuleTask | scriptTask | callActivity | exclusiveGateway | parallelGateway | inclusiveGateway | eventBasedGateway | subProcess | adHocSubProcess | intermediateThrowEvent | intermediateCatchEvent | boundaryEvent";
43
+ readonly name: "string?";
44
+ readonly jobType: "string? — Zeebe job worker type (serviceTask only)";
45
+ readonly decisionId: "string? — DMN decision id (businessRuleTask only)";
46
+ readonly formId: "string? — Camunda form id (userTask only)";
47
+ readonly calledElement: "string? — process id of called process (callActivity only)";
48
+ }];
49
+ readonly flows: readonly [{
50
+ readonly id: "string";
51
+ readonly sourceRef: "string — source element id";
52
+ readonly targetRef: "string — target element id";
53
+ readonly condition: "string? — FEEL expression (exclusive gateway outgoing flows only)";
54
+ }];
55
+ }];
56
+ };
57
+ };
58
+ };
59
+ //# sourceMappingURL=sdk-spec.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare function startFileWatchTrigger(): void;
2
+ //# sourceMappingURL=file-watcher.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { matchWebhookRoute, handleWebhook } from "./webhook.js";
2
+ export declare function startTriggers(): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare function startTimerTrigger(): void;
2
+ //# sourceMappingURL=timer.d.ts.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Webhook trigger — starts a process instance when `POST /webhooks/:processId`
3
+ * is called. The request body becomes the process variables.
4
+ *
5
+ * Optional security: set a `WEBHOOK_TOKEN` env var; the trigger then requires
6
+ * `Authorization: Bearer <token>` on incoming requests.
7
+ */
8
+ import type { IncomingMessage, ServerResponse } from "node:http";
9
+ /** Returns the processId if the request matches `POST /webhooks/:processId`. */
10
+ export declare function matchWebhookRoute(req: IncomingMessage): {
11
+ processId: string;
12
+ } | null;
13
+ export declare function handleWebhook(req: IncomingMessage, res: ServerResponse, processId: string): Promise<void>;
14
+ //# sourceMappingURL=webhook.d.ts.map
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Element template definitions for bpmnkit built-in workers.
3
+ * Served via GET /worker-templates — consumed by the Studio connector catalog.
4
+ *
5
+ * Follows the Camunda element template schema so they are compatible with
6
+ * the config-panel-bpmn template renderer.
7
+ */
8
+ export interface TemplateProperty {
9
+ id?: string;
10
+ label?: string;
11
+ description?: string;
12
+ type?: string;
13
+ value?: string | number | boolean;
14
+ optional?: boolean;
15
+ feel?: "optional" | "required" | "static";
16
+ group?: string;
17
+ choices?: Array<{
18
+ name: string;
19
+ value: string;
20
+ }>;
21
+ constraints?: {
22
+ notEmpty?: boolean;
23
+ };
24
+ binding: {
25
+ type: "zeebe:taskDefinition" | "zeebe:taskDefinition:type" | "zeebe:taskHeader" | "zeebe:input" | "zeebe:output" | "property";
26
+ property?: "type" | "retries";
27
+ key?: string;
28
+ name?: string;
29
+ source?: string;
30
+ };
31
+ condition?: {
32
+ property: string;
33
+ equals: string;
34
+ };
35
+ }
36
+ export interface ElementTemplate {
37
+ $schema?: string;
38
+ id: string;
39
+ name: string;
40
+ version: number;
41
+ description: string;
42
+ documentationRef?: string;
43
+ category: {
44
+ id: string;
45
+ name: string;
46
+ };
47
+ appliesTo: string[];
48
+ icon?: {
49
+ contents: string;
50
+ };
51
+ groups?: Array<{
52
+ id: string;
53
+ label: string;
54
+ }>;
55
+ properties: TemplateProperty[];
56
+ }
57
+ export declare const WORKER_TEMPLATES: ElementTemplate[];
58
+ //# sourceMappingURL=worker-templates.d.ts.map
@@ -0,0 +1,21 @@
1
+ export interface WorkerJob {
2
+ jobKey: string;
3
+ type: string;
4
+ processInstanceKey: string;
5
+ elementInstanceKey: string;
6
+ variables: Record<string, unknown>;
7
+ customHeaders: Record<string, string>;
8
+ }
9
+ /**
10
+ * Replace `{{varName}}` and `{{secrets.NAME}}` placeholders in a string.
11
+ * Secrets are read from `process.env` (proxy runs in Node.js).
12
+ */
13
+ export declare function interpolate(template: string, vars: Record<string, unknown>): string;
14
+ export declare const workerState: {
15
+ active: boolean;
16
+ pollCount: number;
17
+ jobTypes: string[];
18
+ lastError: string | null;
19
+ };
20
+ export declare function startWorkerDaemon(): void;
21
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { WorkerJob } from "../worker.js";
2
+ export declare const JOB_TYPE = "io.bpmnkit:cli:1";
3
+ /**
4
+ * CLI worker — runs a shell command and returns stdout/stderr/exitCode.
5
+ *
6
+ * Task headers:
7
+ * command (required) — shell command, supports {{varName}} and {{secrets.NAME}} interpolation
8
+ * cwd (optional) — working directory; default ~
9
+ * timeout (optional) — timeout in seconds; default 60
10
+ * ignoreExitCode (optional) — "true" to complete even on non-zero exit; default false
11
+ * resultVariable (optional) — if set, wraps result under this key; default outputs at root
12
+ */
13
+ export declare function handle(job: WorkerJob): Promise<Record<string, unknown>>;
14
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1,24 @@
1
+ import type { WorkerJob } from "../worker.js";
2
+ export declare const JOB_TYPE_FETCH = "io.bpmnkit:email:fetch:1";
3
+ export declare const JOB_TYPE_SEND = "io.bpmnkit:email:send:1";
4
+ /**
5
+ * Email fetch worker — connects via IMAP and retrieves messages.
6
+ *
7
+ * Task headers (all support {{secrets.X}} interpolation):
8
+ * imapHost, imapPort (default 993), imapUser, imapPassword, imapSecure (default "true")
9
+ * folder (default "INBOX"), limit (default 10), unreadOnly (default "true")
10
+ * resultVariable (default "emails")
11
+ */
12
+ export declare function handleFetch(job: WorkerJob): Promise<Record<string, unknown>>;
13
+ /**
14
+ * Email send worker — sends a message via SMTP using nodemailer.
15
+ *
16
+ * Task headers (support interpolation):
17
+ * smtpHost, smtpPort (default 587), smtpUser, smtpPassword, smtpSecure (default "false")
18
+ * from (optional, defaults to smtpUser)
19
+ *
20
+ * Input variables (job.variables, headers as fallback):
21
+ * to, subject, body
22
+ */
23
+ export declare function handleSend(job: WorkerJob): Promise<Record<string, unknown>>;
24
+ //# sourceMappingURL=email.d.ts.map
@@ -0,0 +1,30 @@
1
+ import type { WorkerJob } from "../worker.js";
2
+ export declare const JOB_TYPE_READ = "io.bpmnkit:fs:read:1";
3
+ export declare const JOB_TYPE_WRITE = "io.bpmnkit:fs:write:1";
4
+ export declare const JOB_TYPE_APPEND = "io.bpmnkit:fs:append:1";
5
+ export declare const JOB_TYPE_LIST = "io.bpmnkit:fs:list:1";
6
+ /**
7
+ * io.bpmnkit:fs:read:1
8
+ * Variables: path (string)
9
+ * Outputs: content (string)
10
+ */
11
+ export declare function handleRead(job: WorkerJob): Promise<Record<string, unknown>>;
12
+ /**
13
+ * io.bpmnkit:fs:write:1
14
+ * Variables: path (string), content (string)
15
+ * Outputs: bytesWritten (number)
16
+ */
17
+ export declare function handleWrite(job: WorkerJob): Promise<Record<string, unknown>>;
18
+ /**
19
+ * io.bpmnkit:fs:append:1
20
+ * Variables: path (string), content (string)
21
+ * Outputs: bytesWritten (number)
22
+ */
23
+ export declare function handleAppend(job: WorkerJob): Promise<Record<string, unknown>>;
24
+ /**
25
+ * io.bpmnkit:fs:list:1
26
+ * Variables: path (string)
27
+ * Outputs: files (string[])
28
+ */
29
+ export declare function handleList(job: WorkerJob): Promise<Record<string, unknown>>;
30
+ //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { WorkerJob } from "../worker.js";
2
+ export declare const JOB_TYPE = "io.bpmnkit:http:scrape:1";
3
+ /**
4
+ * HTTP scraper worker — fetches a URL and extracts text content.
5
+ *
6
+ * Task headers:
7
+ * url (required) — URL to fetch, supports {{varName}} interpolation
8
+ * timeout (optional) — timeout in seconds; default 30
9
+ * resultVariable (optional) — if set, wraps result under this key; default outputs at root
10
+ */
11
+ export declare function handle(job: WorkerJob): Promise<Record<string, unknown>>;
12
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { WorkerJob } from "../worker.js";
2
+ export declare const JOB_TYPE = "io.bpmnkit:js:1";
3
+ /**
4
+ * JavaScript eval worker — evaluates an expression with process variables in scope.
5
+ *
6
+ * Task headers:
7
+ * expression (required) — JS expression; receives `variables` object in scope
8
+ * resultVariable (optional) — variable name to store result; default "result"
9
+ *
10
+ * Example expression: variables.items.filter(x => x.score > 0.5).length
11
+ */
12
+ export declare function handle(job: WorkerJob): Promise<Record<string, unknown>>;
13
+ //# sourceMappingURL=js.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { WorkerJob } from "../worker.js";
2
+ export declare const JOB_TYPE = "io.bpmnkit:llm:1";
3
+ /**
4
+ * LLM worker — calls the first available LLM adapter with a prompt.
5
+ *
6
+ * Variables:
7
+ * prompt (required) — prompt text; supports {{varName}} interpolation
8
+ *
9
+ * Task headers:
10
+ * system (optional) — system prompt
11
+ * model (optional) — "claude" | "copilot" | "gemini"; auto-detects if omitted
12
+ * resultVariable (optional) — variable to store response; default "response"
13
+ */
14
+ export declare function handle(job: WorkerJob): Promise<Record<string, unknown>>;
15
+ //# sourceMappingURL=llm.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmnkit/proxy",
3
- "version": "0.0.32",
3
+ "version": "0.1.0",
4
4
  "description": "Local proxy server for BPMN Kit — AI bridge (SSE/MCP) and Camunda API proxy using stored CLI profiles",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,7 +18,8 @@
18
18
  "files": [
19
19
  "LICENSE",
20
20
  "README.md",
21
- "dist/**/*.js"
21
+ "dist/**/*.js",
22
+ "dist/**/*.d.ts"
22
23
  ],
23
24
  "engines": {
24
25
  "node": ">=20"
@@ -28,10 +29,11 @@
28
29
  "imapflow": "^1.2.18",
29
30
  "isolated-vm": "^7.0.0",
30
31
  "nodemailer": "^6.10.1",
31
- "@bpmnkit/api": "0.0.19",
32
- "@bpmnkit/core": "0.1.1",
33
- "@bpmnkit/patterns": "0.0.4",
34
- "@bpmnkit/profiles": "0.0.17"
32
+ "@bpmnkit/api": "0.0.20",
33
+ "@bpmnkit/core": "0.2.0",
34
+ "@bpmnkit/engine": "0.1.31",
35
+ "@bpmnkit/patterns": "0.0.5",
36
+ "@bpmnkit/profiles": "0.0.18"
35
37
  },
36
38
  "publishConfig": {
37
39
  "access": "public"