@bpmnkit/proxy 0.0.12 → 0.0.13

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/dist/index.js CHANGED
@@ -643,6 +643,14 @@ const server = http.createServer(async (req, res) => {
643
643
  }
644
644
  }
645
645
  // Step 3: Execute search against Camunda
646
+ // Coerce variables filter.value to JSON-serialized string form.
647
+ // The Camunda API stores variable values as JSON strings (e.g. "3355" for the number 3355).
648
+ // If the AI emits a number or boolean, stringify it to match the stored representation.
649
+ if (spec.endpoint === "variables" &&
650
+ spec.filter.value !== undefined &&
651
+ typeof spec.filter.value !== "string") {
652
+ spec.filter.value = JSON.stringify(spec.filter.value);
653
+ }
646
654
  const finalSpec = spec;
647
655
  let items = [];
648
656
  let total = 0;
@@ -657,6 +665,44 @@ const server = http.createServer(async (req, res) => {
657
665
  const result = (await r.json());
658
666
  items = result.items ?? [];
659
667
  total = result.page?.totalItems ?? items.length;
668
+ // Enrich variable results with instance startDate (best-effort, single batch request)
669
+ const keys = [
670
+ ...new Set(items
671
+ .map((v) => v.processInstanceKey)
672
+ .filter((k) => typeof k === "string")),
673
+ ];
674
+ if (keys.length > 0) {
675
+ try {
676
+ const ir = await fetch(`${baseUrl}/process-instances/search`, {
677
+ method: "POST",
678
+ headers: apiHeaders,
679
+ body: JSON.stringify({
680
+ filter: { processInstanceKey: { $in: keys } },
681
+ page: { limit: keys.length },
682
+ }),
683
+ });
684
+ if (ir.ok) {
685
+ const instResult = (await ir.json());
686
+ const instMap = new Map((instResult.items ?? []).map((inst) => [inst.processInstanceKey, inst]));
687
+ items = items.map((v) => {
688
+ const inst = instMap.get(v.processInstanceKey);
689
+ return {
690
+ ...v,
691
+ instanceStartDate: inst?.startDate ?? null,
692
+ instanceProcessName: inst?.processDefinitionName ?? null,
693
+ instanceProcessId: inst?.processDefinitionId ?? null,
694
+ instanceState: inst?.state ?? null,
695
+ instanceIsSubprocess: inst != null &&
696
+ inst.parentProcessInstanceKey != null &&
697
+ inst.parentProcessInstanceKey !== "",
698
+ };
699
+ });
700
+ }
701
+ }
702
+ catch {
703
+ // Enrichment is best-effort; variable results are still returned
704
+ }
705
+ }
660
706
  }
661
707
  }
662
708
  else {
package/dist/prompt.js CHANGED
@@ -193,12 +193,15 @@ export function buildSearchSystemPrompt() {
193
193
  "",
194
194
  'Variable filter fields (endpoint "variables"):',
195
195
  " name: string (exact variable name)",
196
- ' value: any (JSON-serialized: "hello", 42, true)',
196
+ ' value: string (JSON-serialized form — number 3355 → "3355", boolean true → "true", string hello → "\\"hello\\"")',
197
197
  " processInstanceKey: string",
198
198
  " isTruncated: boolean",
199
199
  " tenantId: string",
200
200
  "",
201
- 'Use "instances" for process instance queries. Use "variables" for variable/value queries.',
201
+ 'Use "instances" for queries about process state, definition, incidents, or dates.',
202
+ 'Use "variables" whenever a variable name or value is mentioned — even if phrased as "instances with variable X" or "find instances where variable Y equals Z" (the instances endpoint has no variable filter; use variables instead).',
203
+ "",
204
+ 'Example: "find instances with the variable value 3355" → {"endpoint":"variables","filter":{"value":"3355"}}',
202
205
  "Omit filter fields that are not relevant. Output ONLY the JSON object.",
203
206
  ].join("\n");
204
207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmnkit/proxy",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
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": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@bpmnkit/api": "0.0.12",
20
- "@bpmnkit/core": "0.0.12",
20
+ "@bpmnkit/core": "0.0.13",
21
21
  "@bpmnkit/profiles": "0.0.9"
22
22
  },
23
23
  "publishConfig": {