@bpmnkit/proxy 0.0.14 → 0.0.16

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
@@ -86,6 +86,8 @@ curl -H "X-Profile: production" http://localhost:3033/api/v2/process-definitions
86
86
  | [`@bpmnkit/cli-sdk`](https://www.npmjs.com/package/@bpmnkit/cli-sdk) | Plugin authoring SDK for the casen CLI |
87
87
  | [`@bpmnkit/create-casen-plugin`](https://www.npmjs.com/package/@bpmnkit/create-casen-plugin) | Scaffold a new casen CLI plugin in seconds |
88
88
  | [`@bpmnkit/casen-report`](https://www.npmjs.com/package/@bpmnkit/casen-report) | HTML reports from Camunda 8 incident and SLA data |
89
+ | [`@bpmnkit/casen-worker-http`](https://www.npmjs.com/package/@bpmnkit/casen-worker-http) | Example HTTP worker plugin — completes jobs with live JSONPlaceholder API data |
90
+ | [`@bpmnkit/casen-worker-ai`](https://www.npmjs.com/package/@bpmnkit/casen-worker-ai) | AI task worker — classify, summarize, extract, and decide using Claude |
89
91
 
90
92
  ## License
91
93
 
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { getActiveName, getActiveProfile, getAuthHeader, getProfile, listProfile
10
10
  import * as claude from "./adapters/claude.js";
11
11
  import * as copilot from "./adapters/copilot.js";
12
12
  import * as gemini from "./adapters/gemini.js";
13
- import { buildIncidentSystemPrompt, buildIncidentUserMessage, buildMcpExplainPrompt, buildMcpImprovePrompt, buildMcpSystemPrompt, buildSearchSystemPrompt, buildSystemPrompt, } from "./prompt.js";
13
+ import { buildIncidentSystemPrompt, buildIncidentUserMessage, buildMcpExplainPrompt, buildMcpImprovePrompt, buildMcpSystemPrompt, buildOperateChatSystemPrompt, buildSearchSystemPrompt, buildSystemPrompt, } from "./prompt.js";
14
14
  const PORT = process.env.AI_SERVER_PORT ? Number(process.env.AI_SERVER_PORT) : 3033;
15
15
  // Resolve the compiled mcp-server entry point relative to this file.
16
16
  // When bundled as bundle.cjs, import.meta.url ends with .cjs → use mcp-server.cjs.
@@ -731,6 +731,47 @@ const server = http.createServer(async (req, res) => {
731
731
  res.end(JSON.stringify({ endpoint: finalSpec.endpoint, filter: finalSpec.filter, items, total }));
732
732
  return;
733
733
  }
734
+ // ── POST /operate/chat — operations-context AI chat ──────────────────────────
735
+ if (url.pathname === "/operate/chat" && req.method === "POST") {
736
+ const body = await readBody(req);
737
+ let messages;
738
+ let stats;
739
+ try {
740
+ const parsed = JSON.parse(body);
741
+ messages = parsed.messages;
742
+ stats = parsed.stats ?? null;
743
+ }
744
+ catch {
745
+ res.writeHead(400);
746
+ res.end("Bad Request");
747
+ return;
748
+ }
749
+ const available = await detectAll();
750
+ const detected = available[0];
751
+ if (!detected) {
752
+ res.writeHead(503);
753
+ res.end("No AI adapter available. Install claude, copilot, or gemini.");
754
+ return;
755
+ }
756
+ console.log(`[server] /operate/chat → adapter: ${detected.name}`);
757
+ res.writeHead(200, {
758
+ "Content-Type": "text/event-stream",
759
+ "Cache-Control": "no-cache",
760
+ Connection: "keep-alive",
761
+ });
762
+ const systemPrompt = buildOperateChatSystemPrompt(stats);
763
+ try {
764
+ await detected.adapter.stream(messages, systemPrompt, null, (token) => {
765
+ res.write(`data: ${JSON.stringify({ type: "token", text: token })}\n\n`);
766
+ });
767
+ }
768
+ catch (err) {
769
+ res.write(`data: ${JSON.stringify({ type: "error", message: String(err) })}\n\n`);
770
+ }
771
+ res.write(`data: ${JSON.stringify({ type: "done" })}\n\n`);
772
+ res.end();
773
+ return;
774
+ }
734
775
  // ── ALL /api/* — transparent Camunda API proxy ─────────────────────────────
735
776
  if (url.pathname.startsWith("/api/")) {
736
777
  const profileName = req.headers["x-profile"];
package/dist/prompt.js CHANGED
@@ -205,6 +205,23 @@ export function buildSearchSystemPrompt() {
205
205
  "Omit filter fields that are not relevant. Output ONLY the JSON object.",
206
206
  ].join("\n");
207
207
  }
208
+ export function buildOperateChatSystemPrompt(stats) {
209
+ const lines = [
210
+ "You are an operations assistant for Camunda 8 process automation.",
211
+ "Help operators understand what is running in their cluster and what actions to take.",
212
+ "Be concise, actionable, and prioritize incidents (they block process execution).",
213
+ "Use markdown for formatting. Keep responses short unless detail is specifically requested.",
214
+ "",
215
+ ];
216
+ if (stats) {
217
+ lines.push("## Current cluster state", `- Running instances: ${stats.runningInstances}`, `- Active incidents: ${stats.activeIncidents}`, `- Pending user tasks: ${stats.pendingTasks}`, `- Deployed process definitions: ${stats.deployedDefinitions}`, `- Active jobs: ${stats.activeJobs}`, "");
218
+ if (stats.activeIncidents > 0) {
219
+ lines.push(`There are ${stats.activeIncidents} active incident(s) — these are blocking process execution.`, "When asked what to do next, prioritize resolving incidents first.", "");
220
+ }
221
+ }
222
+ lines.push("## Available actions (user performs these in the UI)", "- View and cancel running instances → Instances page", "- View and retry failed incidents → Incidents page", "- Claim and complete user tasks → Tasks page", "- Start new process instances → Definitions page → Start Instance button", "- Deploy new processes → Models page → Deploy button", "", "When asked to do something, explain which UI page to visit and what to click.", "If asked about a specific instance/incident/task, say you can only see aggregate counts unless you query for details.");
223
+ return lines.join("\n");
224
+ }
208
225
  // ── Fallback prompt builders (for non-MCP adapters like Gemini) ───────────────
209
226
  /** Full system prompt for non-MCP adapters that must return a CompactDiagram JSON block. */
210
227
  export function buildSystemPrompt(context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmnkit/proxy",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
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.13",
20
- "@bpmnkit/core": "0.0.14",
20
+ "@bpmnkit/core": "0.0.15",
21
21
  "@bpmnkit/profiles": "0.0.10"
22
22
  },
23
23
  "publishConfig": {