@desplega.ai/agent-swarm 1.130.0 → 1.131.1

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.
Files changed (138) hide show
  1. package/README.md +1 -1
  2. package/dist/{actions-73ee723n.js → actions-jgcy477k.js} +7 -7
  3. package/dist/{anthropic-messages-3xgme8my.js → anthropic-messages-rjmd2e7n.js} +5 -5
  4. package/dist/{app-hz5c2xay.js → app-5da78bd4.js} +4 -4
  5. package/dist/{assistant-08mr16yp.js → assistant-f2vkk1hj.js} +9 -9
  6. package/dist/{azure-openai-responses-xa4sh9f6.js → azure-openai-responses-c0yjmbfd.js} +8 -5
  7. package/dist/{boot-reembed-5bgan3cd.js → boot-reembed-q7mp8hcr.js} +4 -4
  8. package/dist/{boot-reembed-z7ykyeq8.js → boot-reembed-xmw8wcx6.js} +5 -5
  9. package/dist/{boot-scrub-logs-b2rjk8mv.js → boot-scrub-logs-dsqrv79n.js} +3 -3
  10. package/dist/{claude-adapter-qr0k17km.js → claude-adapter-q6x7yspx.js} +6 -6
  11. package/dist/{claude-managed-adapter-gv19tdew.js → claude-managed-adapter-wsg37bt8.js} +1 -1
  12. package/dist/{cli-vr2f46zj.js → cli-114fvtmj.js} +1 -1
  13. package/dist/{cli-mhr8tq3v.js → cli-2f07m0xr.js} +1 -1
  14. package/dist/{cli-mgerp0vs.js → cli-2rk0cx7s.js} +2 -2
  15. package/dist/{cli-tfw3c0y1.js → cli-3ty0t082.js} +2 -2
  16. package/dist/{cli-fs153s3x.js → cli-4rkfg1wx.js} +3 -3
  17. package/dist/{cli-s18zzkfp.js → cli-50vbt00w.js} +44 -7
  18. package/dist/{cli-vgexpfsr.js → cli-57khth04.js} +6 -3
  19. package/dist/{cli-n9yxcnvk.js → cli-5n6e5yfn.js} +29 -7
  20. package/dist/{cli-q8zwffx0.js → cli-6dp3ydxa.js} +158 -39
  21. package/dist/{cli-r62me33w.js → cli-6dpytdr2.js} +2 -2
  22. package/dist/{cli-ch7t5v7n.js → cli-6map995v.js} +9 -4
  23. package/dist/{cli-326083vb.js → cli-6pcz9h15.js} +14 -14
  24. package/dist/{cli-h3e66g5b.js → cli-793jvbsh.js} +1 -1
  25. package/dist/{cli-yj7z99vp.js → cli-7dm2zqy2.js} +2 -2
  26. package/dist/{cli-t5tsq67k.js → cli-9dr5qzc0.js} +39 -4
  27. package/dist/{cli-m8fs5ttq.js → cli-aca5pz9f.js} +1 -1
  28. package/dist/{cli-w10fkrf1.js → cli-akdvwc9v.js} +354 -115
  29. package/dist/{cli-hntzdchd.js → cli-bqw0mt1n.js} +1 -1
  30. package/dist/{cli-7v5dhmc8.js → cli-ccf9vy7q.js} +6 -6
  31. package/dist/{cli-6nh2qxvh.js → cli-darcwax3.js} +1 -1
  32. package/dist/{cli-xg2eezyv.js → cli-f1am9szv.js} +1 -1
  33. package/dist/{cli-1px8pn1s.js → cli-g1re8r05.js} +2 -2
  34. package/dist/{cli-z9q7pb38.js → cli-g74vpjp2.js} +4 -4
  35. package/dist/{cli-brebbsen.js → cli-gecy3z2s.js} +20 -8
  36. package/dist/{cli-epsvdckx.js → cli-gm9cbhbq.js} +20 -10
  37. package/dist/{cli-xdrmxvd4.js → cli-jbcva0xj.js} +55 -11
  38. package/dist/{cli-haanc4qd.js → cli-jevgrb4w.js} +22 -22
  39. package/dist/{cli-e5p3es48.js → cli-kd1ck4rx.js} +1 -1
  40. package/dist/{cli-1mj7yz1r.js → cli-nrkkknat.js} +1 -1
  41. package/dist/{cli-2pa5w9b6.js → cli-pxfxkx5m.js} +1 -1
  42. package/dist/{cli-qcsjdppx.js → cli-rgrfzg8z.js} +7 -7
  43. package/dist/{cli-mf009e0j.js → cli-se2p6rkb.js} +1 -1
  44. package/dist/{cli-tp519bjz.js → cli-sy7jk3tx.js} +2 -2
  45. package/dist/{cli-qbb2ten8.js → cli-t8d349cy.js} +2 -2
  46. package/dist/{cli-s21zzx4b.js → cli-w2wxd56v.js} +448 -184
  47. package/dist/{cli-qmdnhpej.js → cli-wz9115x0.js} +17 -7
  48. package/dist/{cli-4n4mdv21.js → cli-xpxde7rm.js} +7 -3
  49. package/dist/{cli-dakxgk70.js → cli-ycrnynpw.js} +4 -4
  50. package/dist/{cli-73bvdyxr.js → cli-ygrbmjja.js} +6 -6
  51. package/dist/cli.js +22 -22
  52. package/dist/{codex-adapter-6pc50x9q.js → codex-adapter-htjkn22b.js} +4 -4
  53. package/dist/{codex-hook-amndawyb.js → codex-hook-hq54t9ft.js} +2 -2
  54. package/dist/{codex-session-runner-tpg8hyj7.js → codex-session-runner-wjfc7smz.js} +4 -4
  55. package/dist/{commands-yfpwt11g.js → commands-xhrfwqsk.js} +3 -3
  56. package/dist/{db-jn499nmp.js → db-anvwb22f.js} +3 -3
  57. package/dist/{google-generative-ai-txgg2q58.js → google-generative-ai-hysrd8qx.js} +7 -5
  58. package/dist/{google-vertex-t663s1c3.js → google-vertex-p5arrga0.js} +7 -5
  59. package/dist/{handlers-eev4nng0.js → handlers-b9kbc621.js} +9 -9
  60. package/dist/{hook-9fkwkf3m.js → hook-cgk4wxmx.js} +5 -5
  61. package/dist/{hook-sn7pj75w.js → hook-xkvn6c5h.js} +4 -4
  62. package/dist/{http-xdbbtmhx.js → http-9xh6ta4r.js} +324 -82
  63. package/dist/{index-9vnkprkh.js → index-25wjsdv2.js} +10 -10
  64. package/dist/{index-5fdsemf0.js → index-eaxyqcmj.js} +155 -37
  65. package/dist/{index-fnack5vh.js → index-vg4snay4.js} +11 -11
  66. package/dist/{index-c0qedjh6.js → index-ywds4812.js} +9 -9
  67. package/dist/{keepalive-fc7a2hw9.js → keepalive-vc7s2aa6.js} +5 -5
  68. package/dist/{lead-1fva34y9.js → lead-r2yqfmx7.js} +29 -29
  69. package/dist/{maintenance-0rdb12vf.js → maintenance-mw70k468.js} +5 -5
  70. package/dist/{mistral-conversations-4swenhmf.js → mistral-conversations-81fwav0j.js} +2 -2
  71. package/dist/{oauth-refresh-sweep-f9rptqbt.js → oauth-refresh-sweep-yecgjpk4.js} +4 -4
  72. package/dist/{onboard-9zn0fx2m.js → onboard-xj0f73f9.js} +2 -2
  73. package/dist/{openai-codex-responses-xetseqvt.js → openai-codex-responses-5g27pd6f.js} +43 -23
  74. package/dist/{openai-completions-5r2g5axa.js → openai-completions-3vkmfz2a.js} +55 -11
  75. package/dist/{openai-responses-ce67hd23.js → openai-responses-dg4t7j7a.js} +8 -5
  76. package/dist/{openrouter-images-pzfp22jb.js → openrouter-images-g3gm8931.js} +1 -1
  77. package/dist/{otel-impl-thnttmbn.js → otel-impl-nxg0n0b3.js} +1 -1
  78. package/dist/{pi-mono-adapter-bpfrn6d7.js → pi-mono-adapter-4g5kby31.js} +17114 -7514
  79. package/dist/{pricing-refresh-n0ve0kh6.js → pricing-refresh-2cn6effr.js} +5 -5
  80. package/dist/{rbac-roles-w45bhahg.js → rbac-roles-1hcxdtg7.js} +4 -4
  81. package/dist/{rbac-roles-bbwb4wrm.js → rbac-roles-vynday5g.js} +5 -5
  82. package/dist/{render-v2-d675cp9r.js → render-v2-tc0bh8kk.js} +4 -4
  83. package/dist/{seed-pricing-47q77nw4.js → seed-pricing-8kceb43f.js} +4 -4
  84. package/dist/{setup-3vnv2m43.js → setup-46xtgq3c.js} +2 -2
  85. package/dist/{worker-7shsr8hk.js → worker-qrbz6hmv.js} +29 -29
  86. package/openapi.json +342 -10
  87. package/package.json +6 -6
  88. package/src/apps/store.ts +13 -4
  89. package/src/assets/key.ts +8 -1
  90. package/src/be/asset-key-audit.ts +3 -1
  91. package/src/be/db-queries/mcp-oauth.ts +26 -0
  92. package/src/be/db.ts +42 -1
  93. package/src/be/migrations/129_asset_keys_apps_scripts.sql +161 -0
  94. package/src/be/migrations/130_scratch_script_retention_grace.sql +6 -0
  95. package/src/be/scripts/db.ts +48 -3
  96. package/src/be/scripts/retention.ts +164 -0
  97. package/src/be/scripts/run-saved.ts +16 -1
  98. package/src/be/seed-skills/index.ts +7 -0
  99. package/src/http/assets.ts +120 -29
  100. package/src/http/index.ts +5 -0
  101. package/src/http/mcp-oauth.ts +69 -1
  102. package/src/http/scripts.ts +21 -3
  103. package/src/http/users.ts +45 -0
  104. package/src/http/x.ts +14 -0
  105. package/src/oauth/ensure-mcp-token.ts +7 -1
  106. package/src/oauth/mcp-wrapper.ts +247 -24
  107. package/src/providers/claude-managed-models.ts +34 -10
  108. package/src/providers/pi-mono-adapter.ts +1 -1
  109. package/src/tests/asset-key-api.test.ts +48 -2
  110. package/src/tests/asset-key-invariants.test.ts +92 -0
  111. package/src/tests/asset-key-migration.test.ts +174 -8
  112. package/src/tests/asset-key-normalization.test.ts +2 -0
  113. package/src/tests/claude-managed-adapter.test.ts +38 -7
  114. package/src/tests/mcp-oauth-dcr-reuse.test.ts +95 -0
  115. package/src/tests/mcp-oauth-ensure-token.test.ts +23 -0
  116. package/src/tests/mcp-oauth-manual-client.test.ts +135 -2
  117. package/src/tests/mcp-oauth-wrapper.test.ts +380 -0
  118. package/src/tests/rbac-admission-e2e.test.ts +68 -0
  119. package/src/tests/sandboxed-process.test.ts +45 -0
  120. package/src/tests/script-connections.test.ts +4 -0
  121. package/src/tests/scripts-external-api.test.ts +8 -3
  122. package/src/tests/scripts-http.test.ts +12 -0
  123. package/src/tests/scripts-retention.test.ts +384 -0
  124. package/src/tests/whoami-route.test.ts +127 -0
  125. package/src/tests/workflow-engine-v2.test.ts +80 -7
  126. package/src/tests/workflow-swarm-script.test.ts +118 -5
  127. package/src/tools/workflows/create-workflow.ts +4 -1
  128. package/src/types.ts +18 -5
  129. package/src/utils/sandboxed-process.ts +40 -14
  130. package/src/utils/template.ts +8 -1
  131. package/src/workflows/engine.ts +27 -4
  132. package/src/workflows/executors/swarm-script.ts +52 -1
  133. package/src/workflows/retry-poller.ts +19 -2
  134. package/templates/schedules/daily-compounding-reflection/content.md +12 -3
  135. package/templates/skills/asset-namespaces/content.md +2 -2
  136. package/templates/skills/scheduled-task-resilience/SKILL.md +102 -0
  137. package/templates/skills/scheduled-task-resilience/config.json +14 -0
  138. package/templates/skills/scheduled-task-resilience/content.md +97 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_env_flag,
3
3
  isEnvFlagEnabled
4
- } from "./cli-4n4mdv21.js";
4
+ } from "./cli-xpxde7rm.js";
5
5
  import {
6
6
  init_zod
7
7
  } from "./cli-zsspvvm2.js";
@@ -7,7 +7,7 @@ var package_default;
7
7
  var init_package = __esm(() => {
8
8
  package_default = {
9
9
  name: "@desplega.ai/agent-swarm",
10
- version: "1.130.0",
10
+ version: "1.131.1",
11
11
  description: "agent-swarm.dev — an open-source operating system for AI work: a lead agent breaks goals into tasks, routes them to specialized workers such as Claude Code or Codex, runs each worker in an isolated container, and preserves shared memory, tools, schedules, and review gates so delegated work compounds across sessions.",
12
12
  keywords: [
13
13
  "agent-swarm.dev",
@@ -176,14 +176,14 @@ var init_package = __esm(() => {
176
176
  "@aws-sdk/client-bedrock": "3.1048.0",
177
177
  "@desplega.ai/business-use": "^0.4.2",
178
178
  "@desplega.ai/localtunnel": "^2.2.0",
179
- "@earendil-works/pi-agent-core": "^0.83.0",
180
- "@earendil-works/pi-ai": "^0.83.0",
181
- "@earendil-works/pi-coding-agent": "^0.83.0",
179
+ "@earendil-works/pi-agent-core": "^0.84.1",
180
+ "@earendil-works/pi-ai": "^0.84.1",
181
+ "@earendil-works/pi-coding-agent": "^0.84.1",
182
182
  "@inkjs/ui": "^2.0.0",
183
183
  "@linear/sdk": "^77.0.0",
184
184
  "@modelcontextprotocol/sdk": "^1.25.1",
185
- "@openai/codex-sdk": "^0.146.0",
186
- "@opencode-ai/sdk": "^1.18.13",
185
+ "@openai/codex-sdk": "^0.147.0",
186
+ "@opencode-ai/sdk": "^1.18.16",
187
187
  "@openfort/openfort-node": "^0.9.1",
188
188
  "@opentelemetry/api": "^1.9.1",
189
189
  "@opentelemetry/exporter-metrics-otlp-http": "^0.218.0",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  lazyApi
3
- } from "./cli-w10fkrf1.js";
3
+ } from "./cli-akdvwc9v.js";
4
4
 
5
5
  // node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.js
6
6
  var __rewriteRelativeImportExtension = function(path, preserveJsx) {
@@ -2,7 +2,7 @@ import {
2
2
  init_resolver,
3
3
  init_session_templates,
4
4
  resolveTemplateAsync
5
- } from "./cli-4n4mdv21.js";
5
+ } from "./cli-xpxde7rm.js";
6
6
 
7
7
  // src/prompts/steering-delivery.ts
8
8
  init_session_templates();
@@ -4,11 +4,11 @@ import {
4
4
  getEmbeddingProvider,
5
5
  init_embedding,
6
6
  serializeEmbedding
7
- } from "./cli-mf009e0j.js";
7
+ } from "./cli-se2p6rkb.js";
8
8
  import {
9
9
  getDb,
10
10
  init_db
11
- } from "./cli-s18zzkfp.js";
11
+ } from "./cli-50vbt00w.js";
12
12
  import {
13
13
  init_secret_scrubber,
14
14
  scrubSecrets
@@ -7,11 +7,11 @@ import {
7
7
  getPinCandidateAgent,
8
8
  getResumeGeneration,
9
9
  repointTrackerSyncBySwarmId
10
- } from "./cli-tfw3c0y1.js";
10
+ } from "./cli-3ty0t082.js";
11
11
  import {
12
12
  getExecutorRegistry,
13
13
  recoverIncompleteRuns
14
- } from "./cli-xdrmxvd4.js";
14
+ } from "./cli-jbcva0xj.js";
15
15
  import {
16
16
  MAX_EMPTY_POLLS,
17
17
  assignUnassignedTaskPending,
@@ -51,13 +51,13 @@ import {
51
51
  releaseStaleReviewingTasks,
52
52
  supersedeTask,
53
53
  updateAgentStatus
54
- } from "./cli-s18zzkfp.js";
54
+ } from "./cli-50vbt00w.js";
55
55
  import {
56
56
  init_registry,
57
57
  init_resolver,
58
58
  registerTemplate,
59
59
  resolveTemplate
60
- } from "./cli-4n4mdv21.js";
60
+ } from "./cli-xpxde7rm.js";
61
61
  import {
62
62
  init_secret_scrubber,
63
63
  scrubSecrets
@@ -4,13 +4,17 @@ import {
4
4
  getScriptById,
5
5
  getScriptMcpConnectionDescriptors,
6
6
  listScriptConnections,
7
- runScript
8
- } from "./cli-q8zwffx0.js";
7
+ restoreScratchScriptLastUsedIfUnchanged,
8
+ runScript,
9
+ touchScratchScriptLastUsed
10
+ } from "./cli-6dp3ydxa.js";
9
11
  import {
12
+ defaultAssetKey,
10
13
  getDb,
11
14
  getLeadAgent,
12
- init_db
13
- } from "./cli-s18zzkfp.js";
15
+ init_db,
16
+ init_key
17
+ } from "./cli-50vbt00w.js";
14
18
  import {
15
19
  init_zod
16
20
  } from "./cli-zsspvvm2.js";
@@ -34,10 +38,11 @@ function getSavedScriptOwnerAgentId(script) {
34
38
  return script.scopeId ?? script.createdByAgentId;
35
39
  }
36
40
  async function runSavedScriptAsAgent(args) {
41
+ const runStartTouch = args.script.isScratch ? touchScratchScriptLastUsed(args.script.id) : null;
37
42
  const credentials = await buildScriptCredentialBindingsWithFailures({
38
43
  agentId: args.agentId
39
44
  });
40
- return runScript({
45
+ const output = await runScript({
41
46
  source: args.script.source,
42
47
  args: args.input,
43
48
  fsMode: args.script.fsMode,
@@ -47,6 +52,12 @@ async function runSavedScriptAsAgent(args) {
47
52
  apiConnections: getScriptApiConnectionDescriptors({ agentId: args.agentId }),
48
53
  mcpConnections: getScriptMcpConnectionDescriptors({ agentId: args.agentId })
49
54
  });
55
+ if (output.exitCode === 0 && !output.error && !output.runtimeError) {
56
+ touchScratchScriptLastUsed(args.script.id);
57
+ } else if (runStartTouch) {
58
+ restoreScratchScriptLastUsedIfUnchanged(args.script.id, args.script.updatedAt, runStartTouch);
59
+ }
60
+ return output;
50
61
  }
51
62
 
52
63
  // src/apps/definition.ts
@@ -2872,6 +2883,7 @@ function applyAppDefinitionPatch(stored, patch) {
2872
2883
  }
2873
2884
 
2874
2885
  // src/apps/store.ts
2886
+ init_key();
2875
2887
  init_db();
2876
2888
 
2877
2889
  // src/apps/format-upgrades.ts
@@ -2995,9 +3007,9 @@ function nextTimestamp(previous) {
2995
3007
  function createApp(input) {
2996
3008
  const id = input.id ?? crypto.randomUUID();
2997
3009
  const now = nextTimestamp();
2998
- const row = getDb().prepare(`INSERT INTO apps (id, name, description, definition, created_at, updated_at)
2999
- VALUES (?, ?, ?, ?, ?, ?)
3000
- RETURNING id, name, description, definition, created_at, updated_at`).get(id, input.name, input.description ?? null, encodeDefinition(input.definition), now, now);
3010
+ const row = getDb().prepare(`INSERT INTO apps (id, name, description, definition, created_at, updated_at, "key")
3011
+ VALUES (?, ?, ?, ?, ?, ?, ?)
3012
+ RETURNING id, name, description, definition, created_at, updated_at`).get(id, input.name, input.description ?? null, encodeDefinition(input.definition), now, now, defaultAssetKey("app", id));
3001
3013
  if (!row)
3002
3014
  throw new Error("Failed to create app");
3003
3015
  return decodeApp(row);
@@ -10,13 +10,13 @@ import {
10
10
  resolveGrammarConstrainedSampling,
11
11
  resolveJsonSchemaStrictSampling,
12
12
  transformMessages
13
- } from "./cli-vgexpfsr.js";
13
+ } from "./cli-57khth04.js";
14
14
  import {
15
15
  sanitizeSurrogates
16
16
  } from "./cli-y2apkfe2.js";
17
17
  import {
18
18
  calculateCost
19
- } from "./cli-w10fkrf1.js";
19
+ } from "./cli-akdvwc9v.js";
20
20
 
21
21
  // node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js
22
22
  function encodeTextSignatureV1(id, phase) {
@@ -418,8 +418,12 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
418
418
  options.applyServiceTierPricing(output.usage, serviceTier);
419
419
  }
420
420
  const status = response?.status;
421
- output.rawStopReason = status;
422
- output.stopReason = mapStopReason(status);
421
+ const incompleteDetails = response?.incomplete_details;
422
+ const incompleteReason = typeof incompleteDetails?.reason === "string" ? incompleteDetails.reason : undefined;
423
+ output.rawStopReason = incompleteReason ? `${status}.${incompleteReason}` : status;
424
+ const mappedStop = mapStopReason(status, incompleteReason);
425
+ output.stopReason = mappedStop.stopReason;
426
+ output.errorMessage = mappedStop.errorMessage;
423
427
  if (output.content.some((b) => b.type === "toolCall") && output.stopReason === "stop") {
424
428
  output.stopReason = "toolUse";
425
429
  }
@@ -586,20 +590,26 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
586
590
  throw new Error("OpenAI Responses stream ended before a terminal response event");
587
591
  }
588
592
  }
589
- function mapStopReason(status) {
593
+ function mapStopReason(status, incompleteReason) {
590
594
  if (!status)
591
- return "stop";
595
+ return { stopReason: "stop" };
592
596
  switch (status) {
593
597
  case "completed":
594
- return "stop";
598
+ return { stopReason: "stop" };
595
599
  case "incomplete":
596
- return "length";
600
+ if (incompleteReason === "max_output_tokens") {
601
+ return { stopReason: "length" };
602
+ }
603
+ return {
604
+ stopReason: "error",
605
+ errorMessage: incompleteReason ? `Response incomplete: ${incompleteReason}` : "Response incomplete without a provider reason"
606
+ };
597
607
  case "failed":
598
608
  case "cancelled":
599
- return "error";
609
+ return { stopReason: "error" };
600
610
  case "in_progress":
601
611
  case "queued":
602
- return "stop";
612
+ return { stopReason: "stop" };
603
613
  default: {
604
614
  const _exhaustive = status;
605
615
  throw new Error(`Unhandled stop reason: ${_exhaustive}`);
@@ -13,13 +13,15 @@ import {
13
13
  getScriptMcpConnectionDescriptors,
14
14
  getScriptVersion,
15
15
  readStreamCapped,
16
+ restoreScratchScriptLastUsedIfUnchanged,
16
17
  runScript,
17
18
  sandboxSpawnEnv,
18
- snapshotCapped
19
- } from "./cli-q8zwffx0.js";
19
+ snapshotCapped,
20
+ touchScratchScriptLastUsed
21
+ } from "./cli-6dp3ydxa.js";
20
22
  import {
21
23
  withSiblingAwareness
22
- } from "./cli-mhr8tq3v.js";
24
+ } from "./cli-2f07m0xr.js";
23
25
  import {
24
26
  FollowUpConfigSchema,
25
27
  ModelTierSchema,
@@ -64,12 +66,13 @@ import {
64
66
  updateWorkflowRun,
65
67
  updateWorkflowRunStep,
66
68
  workflowContextKey
67
- } from "./cli-s18zzkfp.js";
69
+ } from "./cli-50vbt00w.js";
68
70
  import {
69
71
  deepInterpolate,
72
+ findInterpolationTokens,
70
73
  init_template,
71
74
  interpolate
72
- } from "./cli-4n4mdv21.js";
75
+ } from "./cli-xpxde7rm.js";
73
76
  import {
74
77
  getAppUrl,
75
78
  init_constants
@@ -1079,9 +1082,18 @@ async function executeStep(def, runId, ctx, node, registry, workflowId, secretKe
1079
1082
  throw new Error(errorMsg);
1080
1083
  }
1081
1084
  }
1082
- const { value: interpolatedValue, unresolved } = interpolateNodeConfig(node, interpolationCtx);
1085
+ const {
1086
+ value: interpolatedValue,
1087
+ unresolved,
1088
+ scriptBodyUnresolved
1089
+ } = interpolateNodeConfig(node, interpolationCtx);
1083
1090
  const interpolatedConfig = interpolatedValue;
1084
1091
  const executionCtx = { ...ctx, ...interpolationCtx };
1092
+ if (scriptBodyUnresolved && scriptBodyUnresolved.length > 0) {
1093
+ const errorMsg = scriptBodyInterpolationError(node.id, scriptBodyUnresolved);
1094
+ checkpointStepFailure(runId, stepId, errorMsg, 0);
1095
+ return { outcome: "failed", successors: [] };
1096
+ }
1085
1097
  if (unresolved.length > 0) {
1086
1098
  console.warn(`[workflow] Step ${node.id}: unresolved interpolation tokens: ${unresolved.join(", ")}`);
1087
1099
  updateWorkflowRunStep(stepId, {
@@ -1267,9 +1279,10 @@ function interpolateNodeConfig(node, interpolationCtx) {
1267
1279
  return {
1268
1280
  value: {
1269
1281
  ...restResult.value,
1270
- script: scriptResult.value
1282
+ script: scriptResult.unresolved.length > 0 ? script : scriptResult.value
1271
1283
  },
1272
- unresolved: [...restResult.unresolved, ...scriptResult.unresolved]
1284
+ unresolved: [...restResult.unresolved, ...scriptResult.unresolved],
1285
+ scriptBodyUnresolved: scriptResult.unresolved
1273
1286
  };
1274
1287
  }
1275
1288
  if (node.type !== "swarm-script" || !Object.hasOwn(node.config, "args")) {
@@ -1286,6 +1299,10 @@ function interpolateNodeConfig(node, interpolationCtx) {
1286
1299
  unresolved: [...configResult.unresolved, ...argsResult.unresolved]
1287
1300
  };
1288
1301
  }
1302
+ function scriptBodyInterpolationError(nodeId, tokens) {
1303
+ const renderedTokens = [...new Set(tokens)].map((token) => `{{${token}}}`).join(", ");
1304
+ return `Script body interpolation failed for node "${nodeId}": unresolved or disallowed token(s): ${renderedTokens}. ` + "Executable source may interpolate only input, workflow, swarm, or run values. " + "Pass dynamic trigger or upstream values through config.args and read them from argv.";
1305
+ }
1289
1306
  function timeoutPromise(ms) {
1290
1307
  return new Promise((_, reject) => {
1291
1308
  setTimeout(() => reject(new Error(`Step timed out after ${ms}ms`)), ms);
@@ -2225,7 +2242,11 @@ function startRetryPoller(registry, intervalMs = 5000) {
2225
2242
  if (!("run" in ctx))
2226
2243
  ctx.run = { id: run.id };
2227
2244
  const inputCtx = buildNodeInterpolationCtx(node, ctx);
2228
- const { value: interpolatedValue } = interpolateNodeConfig(node, inputCtx);
2245
+ const { value: interpolatedValue, scriptBodyUnresolved } = interpolateNodeConfig(node, inputCtx);
2246
+ if (scriptBodyUnresolved && scriptBodyUnresolved.length > 0) {
2247
+ checkpointStepFailure(run.id, step.id, scriptBodyInterpolationError(node.id, scriptBodyUnresolved), step.retryCount);
2248
+ continue;
2249
+ }
2229
2250
  const interpolatedConfig = interpolatedValue;
2230
2251
  const executor = registry.get(node.type);
2231
2252
  const meta = {
@@ -3073,7 +3094,7 @@ class HumanInTheLoopExecutor extends BaseExecutor {
3073
3094
  }
3074
3095
  if (notification.channel === "slack") {
3075
3096
  try {
3076
- const { getSlackApp } = await import("./app-hz5c2xay.js");
3097
+ const { getSlackApp } = await import("./app-5da78bd4.js");
3077
3098
  const slackApp = getSlackApp();
3078
3099
  if (!slackApp) {
3079
3100
  console.warn("[HITL] Slack not initialized — cannot send notification");
@@ -3189,7 +3210,7 @@ class NotifyExecutor extends BaseExecutor {
3189
3210
  }
3190
3211
  }
3191
3212
  case "slack": {
3192
- const { getSlackApp } = await import("./app-hz5c2xay.js");
3213
+ const { getSlackApp } = await import("./app-5da78bd4.js");
3193
3214
  const app = getSlackApp();
3194
3215
  if (!app) {
3195
3216
  return {
@@ -3538,6 +3559,7 @@ class ScriptExecutor extends BaseExecutor {
3538
3559
 
3539
3560
  // src/workflows/executors/swarm-script.ts
3540
3561
  init_zod();
3562
+ init_template();
3541
3563
  var SWARM_SCRIPT_DEFAULT_TIMEOUT_MS = DEFAULT_SCRIPT_RESOURCES.wallClockMs;
3542
3564
  var SWARM_SCRIPT_MIN_TIMEOUT_MS = MIN_SCRIPT_WALL_CLOCK_MS;
3543
3565
  var SWARM_SCRIPT_MAX_TIMEOUT_MS = MAX_SCRIPT_WALL_CLOCK_MS;
@@ -3560,6 +3582,14 @@ var SwarmScriptOutputSchema = exports_external.object({
3560
3582
  contentHash: exports_external.string(),
3561
3583
  version: exports_external.number()
3562
3584
  });
3585
+ var WORKFLOW_INTERPOLATION_ROOTS = new Set(["trigger", "input", "workflow", "swarm", "run"]);
3586
+ function findWorkflowSourceTokens(source, inputCtx) {
3587
+ const roots = new Set([...WORKFLOW_INTERPOLATION_ROOTS, ...Object.keys(inputCtx ?? {})]);
3588
+ return findInterpolationTokens(source).filter((token) => {
3589
+ const root = token.split(".")[0];
3590
+ return root !== undefined && roots.has(root);
3591
+ });
3592
+ }
3563
3593
 
3564
3594
  class SwarmScriptExecutor extends BaseExecutor {
3565
3595
  type = "swarm-script";
@@ -3579,6 +3609,15 @@ class SwarmScriptExecutor extends BaseExecutor {
3579
3609
  if (!resolved.ok) {
3580
3610
  return { status: "failed", error: resolved.error };
3581
3611
  }
3612
+ const sourceTokens = findWorkflowSourceTokens(resolved.source, meta.inputCtx);
3613
+ if (sourceTokens.length > 0) {
3614
+ const renderedTokens = [...new Set(sourceTokens)].map((token) => `{{${token}}}`).join(", ");
3615
+ return {
3616
+ status: "failed",
3617
+ error: `swarm-script body interpolation failed for node "${meta.nodeId}": unresolved token(s): ${renderedTokens}. ` + "Named script source is not workflow-interpolated; pass dynamic values through config.args and read them from args."
3618
+ };
3619
+ }
3620
+ const runStartTouch = resolved.script.isScratch ? touchScratchScriptLastUsed(resolved.script.id) : null;
3582
3621
  const credentials = await buildScriptCredentialBindingsWithFailures({
3583
3622
  agentId: agentId ?? undefined
3584
3623
  });
@@ -3593,6 +3632,11 @@ class SwarmScriptExecutor extends BaseExecutor {
3593
3632
  mcpConnections: getScriptMcpConnectionDescriptors({ agentId: agentId ?? undefined }),
3594
3633
  timeoutMs: config.timeoutMs
3595
3634
  });
3635
+ if (output.exitCode === 0 && !output.error && !output.runtimeError) {
3636
+ touchScratchScriptLastUsed(resolved.script.id);
3637
+ } else if (resolved.script.isScratch && runStartTouch) {
3638
+ restoreScratchScriptLastUsedIfUnchanged(resolved.script.id, resolved.script.updatedAt, runStartTouch);
3639
+ }
3596
3640
  const workflowOutput = {
3597
3641
  result: output.result,
3598
3642
  stdout: output.stdout,
@@ -22,28 +22,28 @@ import {
22
22
  repointTrackerSyncBySwarmId,
23
23
  updateTrackerSync,
24
24
  updateTrackerSyncSwarmId
25
- } from "./cli-tfw3c0y1.js";
25
+ } from "./cli-3ty0t082.js";
26
26
  import {
27
27
  calculateNextRun,
28
28
  ensure,
29
29
  require_dist,
30
30
  runScheduleNow
31
- } from "./cli-dakxgk70.js";
31
+ } from "./cli-ycrnynpw.js";
32
32
  import {
33
33
  startPricingRefreshLoop
34
- } from "./cli-qbb2ten8.js";
34
+ } from "./cli-t8d349cy.js";
35
35
  import {
36
36
  seedPricingFromModelsDev
37
- } from "./cli-vr2f46zj.js";
37
+ } from "./cli-114fvtmj.js";
38
38
  import {
39
39
  ensureRbacSeedsSynced,
40
40
  getUserGrant
41
- } from "./cli-tp519bjz.js";
41
+ } from "./cli-sy7jk3tx.js";
42
42
  import {
43
43
  can,
44
44
  decideAdmission,
45
45
  isRbacEnabled
46
- } from "./cli-hntzdchd.js";
46
+ } from "./cli-bqw0mt1n.js";
47
47
  import {
48
48
  AppDefinitionSchema,
49
49
  AppElementsSchema,
@@ -65,7 +65,7 @@ import {
65
65
  runSavedScriptAsAgent,
66
66
  updateApp,
67
67
  upgradeAppDefinition
68
- } from "./cli-brebbsen.js";
68
+ } from "./cli-gecy3z2s.js";
69
69
  import {
70
70
  TriggerSchemaError,
71
71
  applyDefinitionPatch,
@@ -78,7 +78,7 @@ import {
78
78
  startWorkflowExecution,
79
79
  validateDefinition,
80
80
  validateJsonSchema
81
- } from "./cli-xdrmxvd4.js";
81
+ } from "./cli-jbcva0xj.js";
82
82
  import {
83
83
  ConnectionAuthInputSchema,
84
84
  SCRIPT_LONG_TIMEOUT_HINT_MS,
@@ -97,7 +97,7 @@ import {
97
97
  setScriptConnectionEnabled,
98
98
  upsertCredentialBinding,
99
99
  upsertScriptConnection
100
- } from "./cli-q8zwffx0.js";
100
+ } from "./cli-6dp3ydxa.js";
101
101
  import {
102
102
  getApiKey
103
103
  } from "./cli-f14fvzag.js";
@@ -112,7 +112,7 @@ import {
112
112
  isGraphExpansionEnabled,
113
113
  rerank,
114
114
  rowToCandidate
115
- } from "./cli-mf009e0j.js";
115
+ } from "./cli-se2p6rkb.js";
116
116
  import {
117
117
  buildAuthorizationUrl,
118
118
  createOAuthApp,
@@ -127,7 +127,7 @@ import {
127
127
  listAuthorizationsForApp,
128
128
  onAuthorizationRefreshed,
129
129
  upsertOAuthApp
130
- } from "./cli-1mj7yz1r.js";
130
+ } from "./cli-nrkkknat.js";
131
131
  import {
132
132
  ZodFirstPartyTypeKind,
133
133
  objectType
@@ -136,7 +136,7 @@ import {
136
136
  createAdditiveBuffer,
137
137
  extractSlackMessageText,
138
138
  parseSlackTs
139
- } from "./cli-r62me33w.js";
139
+ } from "./cli-6dpytdr2.js";
140
140
  import {
141
141
  findOrCreateUserByEmail,
142
142
  findUserByExternalId,
@@ -152,10 +152,10 @@ import {
152
152
  resolveIdentityByEmail,
153
153
  resolveUserByToken,
154
154
  unlinkIdentity
155
- } from "./cli-m8fs5ttq.js";
155
+ } from "./cli-aca5pz9f.js";
156
156
  import {
157
157
  createTaskWithSiblingAwareness
158
- } from "./cli-mhr8tq3v.js";
158
+ } from "./cli-2f07m0xr.js";
159
159
  import {
160
160
  getAgentDisplayName,
161
161
  getAgentEmoji,
@@ -164,7 +164,7 @@ import {
164
164
  markdownToSlack,
165
165
  startSlackApp,
166
166
  stopSlackApp
167
- } from "./cli-qcsjdppx.js";
167
+ } from "./cli-rgrfzg8z.js";
168
168
  import {
169
169
  $OpenAPIRegistry,
170
170
  $OpenApiGeneratorV31,
@@ -410,7 +410,7 @@ import {
410
410
  upsertService,
411
411
  upsertSwarmConfig,
412
412
  validateConfigValue
413
- } from "./cli-s18zzkfp.js";
413
+ } from "./cli-50vbt00w.js";
414
414
  import {
415
415
  getTemplateDefinition,
416
416
  init_env_flag,
@@ -422,7 +422,7 @@ import {
422
422
  parseEnvFlag,
423
423
  registerTemplate,
424
424
  resolveTemplate
425
- } from "./cli-4n4mdv21.js";
425
+ } from "./cli-xpxde7rm.js";
426
426
  import {
427
427
  MAX_PROFILE_FILE_LENGTH,
428
428
  getAppUrl,
@@ -444,7 +444,7 @@ import {
444
444
  import {
445
445
  init_package,
446
446
  package_default
447
- } from "./cli-7v5dhmc8.js";
447
+ } from "./cli-ccf9vy7q.js";
448
448
  import {
449
449
  $ZodObject,
450
450
  $ZodType,
@@ -22901,7 +22901,7 @@ async function notifySlack(text) {
22901
22901
  return;
22902
22902
  }
22903
22903
  try {
22904
- const { getSlackApp: getSlackApp2 } = await import("./app-hz5c2xay.js");
22904
+ const { getSlackApp: getSlackApp2 } = await import("./app-5da78bd4.js");
22905
22905
  const app = getSlackApp2();
22906
22906
  if (!app) {
22907
22907
  console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
@@ -22972,7 +22972,7 @@ async function deleteJiraWebhook(webhookId) {
22972
22972
  console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
22973
22973
  }
22974
22974
  async function overwriteWebhookIds(next) {
22975
- const { getDb: getDb2 } = await import("./db-jn499nmp.js");
22975
+ const { getDb: getDb2 } = await import("./db-anvwb22f.js");
22976
22976
  const db = getDb2();
22977
22977
  const txn = db.transaction(() => {
22978
22978
  const row = db.query("SELECT metadata FROM oauth_apps WHERE provider = 'jira'").get();
@@ -96516,7 +96516,7 @@ async function initOtel(serviceRole = process.env.AGENT_ROLE || "api") {
96516
96516
  return;
96517
96517
  initialized6 = true;
96518
96518
  try {
96519
- const impl = await import("./otel-impl-thnttmbn.js");
96519
+ const impl = await import("./otel-impl-nxg0n0b3.js");
96520
96520
  await impl.boot(serviceRole);
96521
96521
  realWithSpan = impl.withSpan;
96522
96522
  realStartSpan = impl.startSpan;
@@ -113231,7 +113231,7 @@ var registerCreateWorkflowTool = (server) => {
113231
113231
  annotations: { destructiveHint: false },
113232
113232
  description: `Create a new automation workflow. Key concepts:
113233
113233
  ` + `- Nodes are linked via 'next' (string or port-based record).
113234
- ` + "- CROSS-NODE DATA: To use output from an upstream node, you MUST declare an 'inputs' mapping on the downstream node. " + 'Example: inputs: { "cityData": "generate-city" } → then use {{cityData.taskOutput.field}} in config templates. ' + `Without 'inputs', only 'trigger' and workflow-level 'input' are available for interpolation.
113234
+ ` + "- CROSS-NODE DATA: To use output from an upstream node, you MUST declare an 'inputs' mapping on the downstream node. " + 'Example: inputs: { "cityData": "generate-city" } → then use {{cityData.taskOutput.field}} in config templates. ' + "Without 'inputs', built-in trigger/input/workflow/swarm/run context remains available, but upstream outputs do not. " + "Agent-task templates may interpolate trigger and declared upstream aliases. SECURITY: executable source for script/swarm-script nodes does not: " + "inline script source allows only input/workflow/swarm/run values, while named swarm-script source is not workflow-interpolated. " + `Pass dynamic trigger or upstream values through config.args (argv for inline scripts; the args object for swarm-script).
113235
113235
  ` + "- STRUCTURED OUTPUT: For agent-task nodes, put outputSchema inside 'config' to validate the agent's raw JSON output. " + `Node-level outputSchema validates the executor's return ({taskId, taskOutput}), which is different.
113236
113236
  ` + `- Agent-task config: { template, outputSchema?, agentId?, tags?, priority?, dir?, vcsRepo?, model? }.
113237
113237
  ` + "- FOREACH NODE: type 'foreach' fans out one agent-task per item. Config: " + "{ over: <array or exact {{input}} token>, itemKey: <property name>, body: { type: 'agent-task', config: {...} } }. " + "The body config is interpolated once per item with {{item.*}} and {{index}}. Child steps use synthetic IDs " + "'<foreachNodeId>#<itemKey>'; the parent waits for every child and exposes one aggregate result to successors. " + `concurrency is not supported in v1; use definition-level onNodeFailure: 'continue' to aggregate failed children.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runStopHookSessionSummarySubprocess
3
- } from "./cli-mgerp0vs.js";
3
+ } from "./cli-2rk0cx7s.js";
4
4
  import {
5
5
  SessionErrorTracker,
6
6
  buildOtelTraceparentEnv,
@@ -7,7 +7,7 @@ import {
7
7
  init_date_utils,
8
8
  init_db,
9
9
  normalizeDateRequired
10
- } from "./cli-s18zzkfp.js";
10
+ } from "./cli-50vbt00w.js";
11
11
  import {
12
12
  init_secret_scrubber,
13
13
  registerVolatileSecret,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_package,
3
3
  package_default
4
- } from "./cli-7v5dhmc8.js";
4
+ } from "./cli-ccf9vy7q.js";
5
5
 
6
6
  // src/commands/shared/client-config.ts
7
7
  init_package();
@@ -37,11 +37,11 @@ import {
37
37
  setSlackMessageTracking,
38
38
  slackContextKey,
39
39
  updateSlackMessageRecord
40
- } from "./cli-s18zzkfp.js";
40
+ } from "./cli-50vbt00w.js";
41
41
  import {
42
42
  init_env_flag,
43
43
  isEnvFlagEnabled
44
- } from "./cli-4n4mdv21.js";
44
+ } from "./cli-xpxde7rm.js";
45
45
  import {
46
46
  getAppUrl,
47
47
  init_constants
@@ -55420,13 +55420,13 @@ async function initSlackApp() {
55420
55420
  socketMode: true,
55421
55421
  logLevel: import_bolt.LogLevel.DEBUG
55422
55422
  });
55423
- const { registerMessageHandler } = await import("./handlers-eev4nng0.js");
55424
- const { registerCommandHandler } = await import("./commands-yfpwt11g.js");
55425
- const { registerActionHandlers } = await import("./actions-73ee723n.js");
55423
+ const { registerMessageHandler } = await import("./handlers-b9kbc621.js");
55424
+ const { registerCommandHandler } = await import("./commands-xhrfwqsk.js");
55425
+ const { registerActionHandlers } = await import("./actions-jgcy477k.js");
55426
55426
  registerMessageHandler(app);
55427
55427
  registerCommandHandler(app);
55428
55428
  registerActionHandlers(app);
55429
- const { createAssistant } = await import("./assistant-08mr16yp.js");
55429
+ const { createAssistant } = await import("./assistant-f2vkk1hj.js");
55430
55430
  app.assistant(createAssistant());
55431
55431
  return app;
55432
55432
  }
@@ -55435,7 +55435,7 @@ async function startSlackApp() {
55435
55435
  await initSlackApp();
55436
55436
  }
55437
55437
  if (app) {
55438
- const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-d675cp9r.js");
55438
+ const { isSlackRenderV2Enabled: isSlackRenderV2Enabled2 } = await import("./render-v2-tc0bh8kk.js");
55439
55439
  if (isSlackRenderV2Enabled2())
55440
55440
  ensureSlackRenderV2Activation();
55441
55441
  await app.start();
@@ -6,7 +6,7 @@ import {
6
6
  getDb,
7
7
  init_db,
8
8
  isSqliteVecAvailable
9
- } from "./cli-s18zzkfp.js";
9
+ } from "./cli-50vbt00w.js";
10
10
  import {
11
11
  __esm,
12
12
  __export,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  PermissionVerbSchema
3
- } from "./cli-hntzdchd.js";
3
+ } from "./cli-bqw0mt1n.js";
4
4
  import {
5
5
  getDb,
6
6
  init_db
7
- } from "./cli-s18zzkfp.js";
7
+ } from "./cli-50vbt00w.js";
8
8
 
9
9
  // src/be/rbac-roles.ts
10
10
  init_db();