@desplega.ai/agent-swarm 1.119.4 → 1.119.6

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 (91) hide show
  1. package/dist/{actions-cvcf510b.js → actions-qe5zjcbr.js} +5 -5
  2. package/dist/{anthropic-messages-kq3pjhbp.js → anthropic-messages-qjxzsabf.js} +94 -46
  3. package/dist/{app-05ksvyna.js → app-31x7k3vj.js} +3 -3
  4. package/dist/{assistant-wqr7nmqv.js → assistant-4crt9dve.js} +8 -8
  5. package/dist/{azure-openai-responses-f57n5qy7.js → azure-openai-responses-ntfd05zd.js} +10 -7
  6. package/dist/{boot-reembed-v0q84hej.js → boot-reembed-8g69ttz4.js} +3 -3
  7. package/dist/{boot-reembed-dx3zweeh.js → boot-reembed-q648j733.js} +4 -4
  8. package/dist/{boot-scrub-logs-3am4xegg.js → boot-scrub-logs-sfmzd2hj.js} +2 -2
  9. package/dist/{claude-adapter-3csn5bks.js → claude-adapter-9n3nzt65.js} +2 -2
  10. package/dist/{claude-managed-adapter-kysmkz89.js → claude-managed-adapter-pv2nbqy4.js} +2 -2
  11. package/dist/{cli-m6pzzhqr.js → cli-1arw00dp.js} +251 -122
  12. package/dist/{cli-pc276yqz.js → cli-2gv8ygwr.js} +1 -1
  13. package/dist/{cli-rk6fkhkk.js → cli-433c0f4b.js} +5 -5
  14. package/dist/{cli-kmtp1rg9.js → cli-4s84mw72.js} +2 -2
  15. package/dist/{cli-ttb3pty1.js → cli-59jy217p.js} +16 -16
  16. package/dist/{cli-qfp17rw8.js → cli-6rvm3jkk.js} +1 -1
  17. package/dist/{cli-bzjncaf6.js → cli-8hhms4hp.js} +1 -1
  18. package/dist/{cli-h1bffz9b.js → cli-96feg24n.js} +1 -1
  19. package/dist/{cli-0y66mw72.js → cli-bpvgs2y6.js} +2 -2
  20. package/dist/{cli-jfc1jm13.js → cli-d1reabed.js} +1 -1
  21. package/dist/{cli-dh9eb7tt.js → cli-da3x3btq.js} +5 -3
  22. package/dist/{cli-bsyka9ta.js → cli-e0y603nn.js} +30 -16
  23. package/dist/{cli-chfh8r6f.js → cli-fkxxh5d4.js} +2 -2
  24. package/dist/{cli-7mvmqemc.js → cli-g6qz2kts.js} +1 -1
  25. package/dist/{cli-pyagab0x.js → cli-gdqdkr3j.js} +2 -2
  26. package/dist/{cli-67e8g7bj.js → cli-gg5bd32n.js} +4 -4
  27. package/dist/{cli-zrxpz200.js → cli-h6cf69x5.js} +1 -1
  28. package/dist/{cli-xw7p4wkq.js → cli-mg280wsv.js} +1 -1
  29. package/dist/{cli-hcpm1e90.js → cli-n61x2aph.js} +2488 -18718
  30. package/dist/{cli-4xtzqzv4.js → cli-ner6af7m.js} +18 -18
  31. package/dist/{cli-zm2jjaq6.js → cli-pasyk3vc.js} +6 -6
  32. package/dist/{cli-758zm6xy.js → cli-q8dway4w.js} +1 -1
  33. package/dist/cli-qs7nb3zn.js +76 -0
  34. package/dist/{cli-fhmhjjh4.js → cli-qw1ccvxm.js} +8 -7
  35. package/dist/{cli-8jjrc3ww.js → cli-r93nz80j.js} +1 -1
  36. package/dist/{cli-cs5g429e.js → cli-sbkwvn5e.js} +1 -1
  37. package/dist/cli-v1mwc5v2.js +68 -0
  38. package/dist/cli-vfcth11k.js +36 -0
  39. package/dist/{cli-k0x0fvh5.js → cli-vg1jxfqz.js} +5 -5
  40. package/dist/{cli-qe43w9a5.js → cli-vx0y68jv.js} +2 -2
  41. package/dist/{cli-kc3h8mnm.js → cli-w6rhc30s.js} +1 -1
  42. package/dist/{cli-sdpnhajn.js → cli-wr706gez.js} +56 -7
  43. package/dist/{cli-1c5zhw9z.js → cli-wxbnjgce.js} +3 -3
  44. package/dist/{cli-0qy7bk86.js → cli-xeatwfbe.js} +25 -16
  45. package/dist/{cli-hx1dcevq.js → cli-z9gzq07x.js} +1 -23
  46. package/dist/cli.js +21 -20
  47. package/dist/{codex-adapter-efskwfc4.js → codex-adapter-6j2b38tg.js} +8 -6
  48. package/dist/{codex-session-runner-n7ad0jdv.js → codex-session-runner-vz215wgw.js} +8 -6
  49. package/dist/{commands-3ke60h4e.js → commands-6xr20jbe.js} +2 -2
  50. package/dist/{db-a1e1nj43.js → db-1mmvk1z4.js} +2 -2
  51. package/dist/{google-generative-ai-hyrra2jm.js → google-generative-ai-n1d3xt4n.js} +9 -7
  52. package/dist/{google-vertex-9hhq68sw.js → google-vertex-mxst23gy.js} +9 -7
  53. package/dist/{handlers-d86a4ypy.js → handlers-xvrknk8w.js} +8 -8
  54. package/dist/{hook-teegt6h5.js → hook-qm7he8wn.js} +7 -5
  55. package/dist/{http-64jvxqnz.js → http-hj08zq67.js} +39 -38
  56. package/dist/{index-z39ch6n5.js → index-688jph6a.js} +9 -9
  57. package/dist/{index-a95n0ay5.js → index-etz7d8md.js} +8 -8
  58. package/dist/{index-hb9j1aqr.js → index-gze4fg2w.js} +6 -6
  59. package/dist/{index-bndzxk11.js → index-wj8dfpwh.js} +10 -10
  60. package/dist/{keepalive-ab1qpqrm.js → keepalive-94wn9yxw.js} +4 -4
  61. package/dist/{lead-852gtrsa.js → lead-rvcqkp11.js} +32 -30
  62. package/dist/{maintenance-fke93wqq.js → maintenance-qhfc4dnp.js} +4 -4
  63. package/dist/{mistral-conversations-tn4sj5qv.js → mistral-conversations-ykcg66za.js} +5 -3
  64. package/dist/{oauth-refresh-sweep-a139pm5w.js → oauth-refresh-sweep-rj8wgvsw.js} +3 -3
  65. package/dist/{onboard-vcd22m9e.js → onboard-8bv8q1wc.js} +2 -2
  66. package/dist/{openai-codex-responses-bex0bpn6.js → openai-codex-responses-zy0907j9.js} +68 -39
  67. package/dist/{openai-completions-gygw5cxt.js → openai-completions-xk4p56n9.js} +73 -14
  68. package/dist/{openai-responses-8c0dgmty.js → openai-responses-4gv3ca5d.js} +38 -16
  69. package/dist/{opencode-adapter-p6bxnbm4.js → opencode-adapter-5bwzvbwj.js} +2 -2
  70. package/dist/{otel-impl-88egk5hc.js → otel-impl-1kf6fr2m.js} +1 -1
  71. package/dist/pi-messages-zb8v76wx.js +313 -0
  72. package/dist/{pi-mono-adapter-erghwha0.js → pi-mono-adapter-9sg69kg3.js} +15711 -12608
  73. package/dist/{pricing-refresh-bbg7s7qs.js → pricing-refresh-e84tar2s.js} +4 -4
  74. package/dist/{rbac-roles-kc9t08gp.js → rbac-roles-atytq5ch.js} +3 -3
  75. package/dist/{rbac-roles-e169ndy2.js → rbac-roles-pg0zvnwn.js} +2 -2
  76. package/dist/{seed-pricing-3zhtw483.js → seed-pricing-xd6nxq7k.js} +3 -3
  77. package/dist/{setup-6m99ne8y.js → setup-4z389yk0.js} +2 -2
  78. package/dist/{worker-pwg46aav.js → worker-m61r0t7m.js} +32 -30
  79. package/openapi.json +1 -1
  80. package/package.json +6 -6
  81. package/src/providers/pi-mono-adapter.ts +14 -20
  82. package/src/tests/internal-ai/credentials.test.ts +22 -0
  83. package/src/tests/pi-mono-adapter.test.ts +28 -20
  84. package/src/tests/scripts-only-gating.test.ts +93 -31
  85. package/src/tests/workflow-engine-v2.test.ts +26 -0
  86. package/src/utils/internal-ai/credentials.ts +53 -5
  87. package/src/workflows/engine.ts +12 -2
  88. package/dist/{cli-sznberje.js → cli-2r7s8jhp.js} +3 -3
  89. package/dist/{cli-bc89my0z.js → cli-branks1w.js} +3 -3
  90. package/dist/{cli-mnbgv3w7.js → cli-mw3xpgwb.js} +3 -3
  91. package/dist/{openrouter-images-537nmn1r.js → openrouter-images-4fsrrzes.js} +3 -3
@@ -13,17 +13,17 @@ import {
13
13
  ensure,
14
14
  require_dist,
15
15
  runScheduleNow
16
- } from "./cli-67e8g7bj.js";
16
+ } from "./cli-gg5bd32n.js";
17
17
  import {
18
18
  startPricingRefreshLoop
19
- } from "./cli-chfh8r6f.js";
19
+ } from "./cli-fkxxh5d4.js";
20
20
  import {
21
21
  seedPricingFromModelsDev
22
- } from "./cli-h1bffz9b.js";
22
+ } from "./cli-96feg24n.js";
23
23
  import {
24
24
  ensureRbacSeedsSynced,
25
25
  getUserGrant
26
- } from "./cli-pc276yqz.js";
26
+ } from "./cli-2gv8ygwr.js";
27
27
  import {
28
28
  can,
29
29
  decideAdmission,
@@ -43,7 +43,7 @@ import {
43
43
  repointTrackerSyncBySwarmId,
44
44
  updateTrackerSync,
45
45
  updateTrackerSyncSwarmId
46
- } from "./cli-qfp17rw8.js";
46
+ } from "./cli-6rvm3jkk.js";
47
47
  import {
48
48
  TriggerSchemaError,
49
49
  applyDefinitionPatch,
@@ -57,7 +57,7 @@ import {
57
57
  startWorkflowExecution,
58
58
  validateDefinition,
59
59
  validateJsonSchema
60
- } from "./cli-fhmhjjh4.js";
60
+ } from "./cli-qw1ccvxm.js";
61
61
  import {
62
62
  getApiKey
63
63
  } from "./cli-f14fvzag.js";
@@ -68,7 +68,7 @@ import {
68
68
  getOAuthApp,
69
69
  getOAuthTokens,
70
70
  upsertOAuthApp
71
- } from "./cli-bzjncaf6.js";
71
+ } from "./cli-8hhms4hp.js";
72
72
  import {
73
73
  CREDENTIAL_BINDINGS_CONFIG_KEY,
74
74
  CredentialBindingSchema,
@@ -85,7 +85,7 @@ import {
85
85
  setScriptConnectionEnabled,
86
86
  upsertCredentialBinding,
87
87
  upsertScriptConnection
88
- } from "./cli-0y66mw72.js";
88
+ } from "./cli-bpvgs2y6.js";
89
89
  import {
90
90
  CANDIDATE_SET_MULTIPLIER,
91
91
  computeScore,
@@ -97,7 +97,7 @@ import {
97
97
  isGraphExpansionEnabled,
98
98
  rerank,
99
99
  rowToCandidate
100
- } from "./cli-8jjrc3ww.js";
100
+ } from "./cli-r93nz80j.js";
101
101
  import {
102
102
  ZodFirstPartyTypeKind,
103
103
  objectType
@@ -106,12 +106,12 @@ import {
106
106
  createAdditiveBuffer,
107
107
  extractSlackMessageText,
108
108
  parseSlackTs
109
- } from "./cli-jfc1jm13.js";
109
+ } from "./cli-d1reabed.js";
110
110
  import {
111
111
  getSlackApp,
112
112
  startSlackApp,
113
113
  stopSlackApp
114
- } from "./cli-k0x0fvh5.js";
114
+ } from "./cli-vg1jxfqz.js";
115
115
  import {
116
116
  findOrCreateUserByEmail,
117
117
  findUserByExternalId,
@@ -127,10 +127,10 @@ import {
127
127
  resolveIdentityByEmail,
128
128
  resolveUserByToken,
129
129
  unlinkIdentity
130
- } from "./cli-cs5g429e.js";
130
+ } from "./cli-sbkwvn5e.js";
131
131
  import {
132
132
  createTaskWithSiblingAwareness
133
- } from "./cli-758zm6xy.js";
133
+ } from "./cli-q8dway4w.js";
134
134
  import {
135
135
  markdownToSlack
136
136
  } from "./cli-ma04faw5.js";
@@ -377,7 +377,7 @@ import {
377
377
  upsertService,
378
378
  upsertSwarmConfig,
379
379
  validateConfigValue
380
- } from "./cli-7mvmqemc.js";
380
+ } from "./cli-g6qz2kts.js";
381
381
  import {
382
382
  init_zod
383
383
  } from "./cli-bw80ck94.js";
@@ -422,7 +422,7 @@ import {
422
422
  import {
423
423
  init_package,
424
424
  package_default
425
- } from "./cli-zm2jjaq6.js";
425
+ } from "./cli-pasyk3vc.js";
426
426
  import {
427
427
  init_secret_scrubber,
428
428
  refreshSecretScrubberCache,
@@ -19710,7 +19710,7 @@ async function initOtel(serviceRole = process.env.AGENT_ROLE || "api") {
19710
19710
  return;
19711
19711
  initialized2 = true;
19712
19712
  try {
19713
- const impl = await import("./otel-impl-88egk5hc.js");
19713
+ const impl = await import("./otel-impl-1kf6fr2m.js");
19714
19714
  await impl.boot(serviceRole);
19715
19715
  realWithSpan = impl.withSpan;
19716
19716
  realStartSpan = impl.startSpan;
@@ -34997,7 +34997,7 @@ async function notifySlack(text) {
34997
34997
  return;
34998
34998
  }
34999
34999
  try {
35000
- const { getSlackApp: getSlackApp2 } = await import("./app-05ksvyna.js");
35000
+ const { getSlackApp: getSlackApp2 } = await import("./app-31x7k3vj.js");
35001
35001
  const app = getSlackApp2();
35002
35002
  if (!app) {
35003
35003
  console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
@@ -35066,7 +35066,7 @@ async function deleteJiraWebhook(webhookId) {
35066
35066
  console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
35067
35067
  }
35068
35068
  async function overwriteWebhookIds(next) {
35069
- const { getDb: getDb2 } = await import("./db-a1e1nj43.js");
35069
+ const { getDb: getDb2 } = await import("./db-1mmvk1z4.js");
35070
35070
  const db = getDb2();
35071
35071
  const txn = db.transaction(() => {
35072
35072
  const row = db.query("SELECT metadata FROM oauth_apps WHERE provider = 'jira'").get();
@@ -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.119.4",
10
+ version: "1.119.6",
11
11
  description: "Multi-agent orchestration for Claude Code, Codex, Gemini CLI, and other AI coding assistants",
12
12
  license: "MIT",
13
13
  author: "desplega.sh <contact@desplega.sh>",
@@ -147,14 +147,14 @@ var init_package = __esm(() => {
147
147
  "@aws-sdk/client-bedrock": "3.1048.0",
148
148
  "@desplega.ai/business-use": "^0.4.2",
149
149
  "@desplega.ai/localtunnel": "^2.2.0",
150
- "@earendil-works/pi-agent-core": "^0.80.3",
151
- "@earendil-works/pi-ai": "^0.80.3",
152
- "@earendil-works/pi-coding-agent": "^0.80.3",
150
+ "@earendil-works/pi-agent-core": "^0.81.1",
151
+ "@earendil-works/pi-ai": "^0.81.1",
152
+ "@earendil-works/pi-coding-agent": "^0.81.1",
153
153
  "@inkjs/ui": "^2.0.0",
154
154
  "@linear/sdk": "^77.0.0",
155
155
  "@modelcontextprotocol/sdk": "^1.25.1",
156
- "@openai/codex-sdk": "^0.144.1",
157
- "@opencode-ai/sdk": "^1.17.15",
156
+ "@openai/codex-sdk": "^0.145.0",
157
+ "@opencode-ai/sdk": "^1.18.4",
158
158
  "@openfort/openfort-node": "^0.9.1",
159
159
  "@opentelemetry/api": "^1.9.1",
160
160
  "@opentelemetry/exporter-metrics-otlp-http": "^0.218.0",
@@ -3,7 +3,7 @@ import {
3
3
  getAgentById,
4
4
  getInProgressTasksByContextKey,
5
5
  init_db
6
- } from "./cli-7mvmqemc.js";
6
+ } from "./cli-g6qz2kts.js";
7
7
 
8
8
  // src/tasks/sibling-awareness.ts
9
9
  init_db();
@@ -0,0 +1,76 @@
1
+ // node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js
2
+ class EventStream {
3
+ queue = [];
4
+ waiting = [];
5
+ done = false;
6
+ finalResultPromise;
7
+ resolveFinalResult;
8
+ isComplete;
9
+ extractResult;
10
+ constructor(isComplete, extractResult) {
11
+ this.isComplete = isComplete;
12
+ this.extractResult = extractResult;
13
+ this.finalResultPromise = new Promise((resolve) => {
14
+ this.resolveFinalResult = resolve;
15
+ });
16
+ }
17
+ push(event) {
18
+ if (this.done)
19
+ return;
20
+ if (this.isComplete(event)) {
21
+ this.done = true;
22
+ this.resolveFinalResult(this.extractResult(event));
23
+ }
24
+ const waiter = this.waiting.shift();
25
+ if (waiter) {
26
+ waiter({ value: event, done: false });
27
+ } else {
28
+ this.queue.push(event);
29
+ }
30
+ }
31
+ end(result) {
32
+ this.done = true;
33
+ if (result !== undefined) {
34
+ this.resolveFinalResult(result);
35
+ }
36
+ while (this.waiting.length > 0) {
37
+ const waiter = this.waiting.shift();
38
+ waiter({ value: undefined, done: true });
39
+ }
40
+ }
41
+ async* [Symbol.asyncIterator]() {
42
+ while (true) {
43
+ if (this.queue.length > 0) {
44
+ yield this.queue.shift();
45
+ } else if (this.done) {
46
+ return;
47
+ } else {
48
+ const result = await new Promise((resolve) => this.waiting.push(resolve));
49
+ if (result.done)
50
+ return;
51
+ yield result.value;
52
+ }
53
+ }
54
+ }
55
+ result() {
56
+ return this.finalResultPromise;
57
+ }
58
+ }
59
+
60
+ class AssistantMessageEventStream extends EventStream {
61
+ constructor() {
62
+ super((event) => event.type === "done" || event.type === "error", (event) => {
63
+ if (event.type === "done") {
64
+ return event.message;
65
+ } else if (event.type === "error") {
66
+ return event.error;
67
+ }
68
+ throw new Error("Unexpected event type for final result");
69
+ });
70
+ }
71
+ }
72
+ function createAssistantMessageEventStream() {
73
+ return new AssistantMessageEventStream;
74
+ }
75
+
76
+ export { EventStream, AssistantMessageEventStream, createAssistantMessageEventStream };
@@ -7,7 +7,7 @@ import {
7
7
  getOAuthTokens,
8
8
  isTokenExpiringSoon,
9
9
  oauthAppRowToProviderConfig
10
- } from "./cli-bzjncaf6.js";
10
+ } from "./cli-8hhms4hp.js";
11
11
  import {
12
12
  CredentialBroker,
13
13
  DEFAULT_CREDENTIAL_BINDINGS,
@@ -18,10 +18,10 @@ import {
18
18
  getScriptVersion,
19
19
  listRelationalCredentialBindings,
20
20
  validateScriptImports
21
- } from "./cli-0y66mw72.js";
21
+ } from "./cli-bpvgs2y6.js";
22
22
  import {
23
23
  withSiblingAwareness
24
- } from "./cli-758zm6xy.js";
24
+ } from "./cli-q8dway4w.js";
25
25
  import {
26
26
  getAppUrl
27
27
  } from "./cli-dh55d5fg.js";
@@ -72,7 +72,7 @@ import {
72
72
  updateWorkflowRun,
73
73
  updateWorkflowRunStep,
74
74
  workflowContextKey
75
- } from "./cli-7mvmqemc.js";
75
+ } from "./cli-g6qz2kts.js";
76
76
  import {
77
77
  init_zod
78
78
  } from "./cli-bw80ck94.js";
@@ -939,7 +939,8 @@ async function executeStep(def, runId, ctx, node, registry, workflowId, secretKe
939
939
  dryRun: false,
940
940
  requestedByUserId: options.requestedByUserId
941
941
  };
942
- const timeoutMs = typeof node.config?.timeoutMs === "number" ? node.config.timeoutMs : DEFAULT_TIMEOUT_MS;
942
+ const configuredTimeoutMs = typeof node.config?.timeoutMs === "number" ? node.config.timeoutMs : node.type === "script" && typeof node.config?.timeout === "number" ? node.config.timeout : undefined;
943
+ const timeoutMs = configuredTimeoutMs ?? DEFAULT_TIMEOUT_MS;
943
944
  let result;
944
945
  try {
945
946
  result = await Promise.race([
@@ -2617,7 +2618,7 @@ class HumanInTheLoopExecutor extends BaseExecutor {
2617
2618
  }
2618
2619
  if (notification.channel === "slack") {
2619
2620
  try {
2620
- const { getSlackApp } = await import("./app-05ksvyna.js");
2621
+ const { getSlackApp } = await import("./app-31x7k3vj.js");
2621
2622
  const slackApp = getSlackApp();
2622
2623
  if (!slackApp) {
2623
2624
  console.warn("[HITL] Slack not initialized — cannot send notification");
@@ -2731,7 +2732,7 @@ class NotifyExecutor extends BaseExecutor {
2731
2732
  }
2732
2733
  }
2733
2734
  case "slack": {
2734
- const { getSlackApp } = await import("./app-05ksvyna.js");
2735
+ const { getSlackApp } = await import("./app-31x7k3vj.js");
2735
2736
  const app = getSlackApp();
2736
2737
  if (!app) {
2737
2738
  return {
@@ -6,7 +6,7 @@ import {
6
6
  getDb,
7
7
  init_db,
8
8
  isSqliteVecAvailable
9
- } from "./cli-7mvmqemc.js";
9
+ } from "./cli-g6qz2kts.js";
10
10
  import {
11
11
  __esm,
12
12
  __export,
@@ -4,7 +4,7 @@ import {
4
4
  incrKv,
5
5
  init_db,
6
6
  upsertKv
7
- } from "./cli-7mvmqemc.js";
7
+ } from "./cli-g6qz2kts.js";
8
8
 
9
9
  // src/be/users.ts
10
10
  init_db();
@@ -0,0 +1,68 @@
1
+ // node_modules/@earendil-works/pi-ai/dist/session-resources.js
2
+ var sessionResourceCleanups = new Set;
3
+ function registerSessionResourceCleanup(cleanup) {
4
+ sessionResourceCleanups.add(cleanup);
5
+ return () => {
6
+ sessionResourceCleanups.delete(cleanup);
7
+ };
8
+ }
9
+ function cleanupSessionResources(sessionId) {
10
+ const errors = [];
11
+ for (const cleanup of sessionResourceCleanups) {
12
+ try {
13
+ cleanup(sessionId);
14
+ } catch (error) {
15
+ errors.push(error);
16
+ }
17
+ }
18
+ if (errors.length > 0) {
19
+ throw new AggregateError(errors, "Failed to cleanup session resources");
20
+ }
21
+ }
22
+
23
+ // node_modules/@earendil-works/pi-ai/dist/utils/uuid.js
24
+ var lastTimestamp = -Infinity;
25
+ var sequence = 0;
26
+ function fillRandomBytes(bytes) {
27
+ if (globalThis.crypto?.getRandomValues) {
28
+ globalThis.crypto.getRandomValues(bytes);
29
+ return;
30
+ }
31
+ for (let i = 0;i < bytes.length; i++) {
32
+ bytes[i] = Math.floor(Math.random() * 256);
33
+ }
34
+ }
35
+ function uuidv7() {
36
+ const random = new Uint8Array(16);
37
+ fillRandomBytes(random);
38
+ const timestamp = Date.now();
39
+ if (timestamp > lastTimestamp) {
40
+ sequence = random[6] * 16777216 + random[7] * 65536 + random[8] * 256 + random[9];
41
+ lastTimestamp = timestamp;
42
+ } else {
43
+ sequence = sequence + 1 >>> 0;
44
+ if (sequence === 0)
45
+ lastTimestamp++;
46
+ }
47
+ const bytes = new Uint8Array(16);
48
+ bytes[0] = lastTimestamp / 1099511627776 & 255;
49
+ bytes[1] = lastTimestamp / 4294967296 & 255;
50
+ bytes[2] = lastTimestamp / 16777216 & 255;
51
+ bytes[3] = lastTimestamp / 65536 & 255;
52
+ bytes[4] = lastTimestamp / 256 & 255;
53
+ bytes[5] = lastTimestamp & 255;
54
+ bytes[6] = 112 | sequence >>> 28 & 15;
55
+ bytes[7] = sequence >>> 20 & 255;
56
+ bytes[8] = 128 | sequence >>> 14 & 63;
57
+ bytes[9] = sequence >>> 6 & 255;
58
+ bytes[10] = (sequence & 63) << 2 | random[10] & 3;
59
+ bytes[11] = random[11];
60
+ bytes[12] = random[12];
61
+ bytes[13] = random[13];
62
+ bytes[14] = random[14];
63
+ bytes[15] = random[15];
64
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
65
+ return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10, 16).join("")}`;
66
+ }
67
+
68
+ export { registerSessionResourceCleanup, cleanupSessionResources, uuidv7 };
@@ -0,0 +1,36 @@
1
+ // node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js
2
+ var identityToolName = (name) => name;
3
+ function splitDeferredTools(context, enabled, normalizeName = identityToolName) {
4
+ const uniqueTools = new Map;
5
+ for (const tool of context.tools ?? [])
6
+ uniqueTools.set(normalizeName(tool.name), tool);
7
+ if (!enabled)
8
+ return { immediate: [...uniqueTools.values()], deferred: new Map };
9
+ const deferredNames = new Set;
10
+ const usedNames = new Set;
11
+ for (const message of context.messages) {
12
+ if (message.role === "assistant") {
13
+ for (const block of message.content) {
14
+ if (block.type === "toolCall")
15
+ usedNames.add(normalizeName(block.name));
16
+ }
17
+ } else if (message.role === "toolResult") {
18
+ for (const name of message.addedToolNames ?? []) {
19
+ const normalizedName = normalizeName(name);
20
+ if (!usedNames.has(normalizedName))
21
+ deferredNames.add(normalizedName);
22
+ }
23
+ }
24
+ }
25
+ const immediate = [];
26
+ const deferred = new Map;
27
+ for (const [name, tool] of uniqueTools) {
28
+ if (deferredNames.has(name))
29
+ deferred.set(name, tool);
30
+ else
31
+ immediate.push(tool);
32
+ }
33
+ return { immediate, deferred };
34
+ }
35
+
36
+ export { splitDeferredTools };
@@ -27,7 +27,7 @@ import {
27
27
  getTaskById,
28
28
  init_db,
29
29
  setSlackMessageTracking
30
- } from "./cli-7mvmqemc.js";
30
+ } from "./cli-g6qz2kts.js";
31
31
  import {
32
32
  require_receiver,
33
33
  require_sender,
@@ -55073,13 +55073,13 @@ async function initSlackApp() {
55073
55073
  socketMode: true,
55074
55074
  logLevel: import_bolt.LogLevel.DEBUG
55075
55075
  });
55076
- const { registerMessageHandler } = await import("./handlers-d86a4ypy.js");
55077
- const { registerCommandHandler } = await import("./commands-3ke60h4e.js");
55078
- const { registerActionHandlers } = await import("./actions-cvcf510b.js");
55076
+ const { registerMessageHandler } = await import("./handlers-xvrknk8w.js");
55077
+ const { registerCommandHandler } = await import("./commands-6xr20jbe.js");
55078
+ const { registerActionHandlers } = await import("./actions-qe5zjcbr.js");
55079
55079
  registerMessageHandler(app);
55080
55080
  registerCommandHandler(app);
55081
55081
  registerActionHandlers(app);
55082
- const { createAssistant } = await import("./assistant-wqr7nmqv.js");
55082
+ const { createAssistant } = await import("./assistant-4crt9dve.js");
55083
55083
  app.assistant(createAssistant());
55084
55084
  return app;
55085
55085
  }
@@ -2,7 +2,7 @@ import {
2
2
  getScriptApiTypes,
3
3
  getScriptMcpTypes,
4
4
  require_typescript
5
- } from "./cli-0y66mw72.js";
5
+ } from "./cli-bpvgs2y6.js";
6
6
  import {
7
7
  deleteSwarmConfigByKey,
8
8
  getAgentById,
@@ -11,7 +11,7 @@ import {
11
11
  getSwarmConfigs,
12
12
  init_db,
13
13
  upsertSwarmConfig
14
- } from "./cli-7mvmqemc.js";
14
+ } from "./cli-g6qz2kts.js";
15
15
  import {
16
16
  init_secret_scrubber,
17
17
  scrubSecrets
@@ -8,7 +8,7 @@ import {
8
8
  } from "./cli-4w4fmq9x.js";
9
9
  import {
10
10
  transformMessages
11
- } from "./cli-bsyka9ta.js";
11
+ } from "./cli-e0y603nn.js";
12
12
  import {
13
13
  sanitizeSurrogates
14
14
  } from "./cli-y2apkfe2.js";
@@ -6,13 +6,13 @@ import {
6
6
  } from "./cli-zyxs93y9.js";
7
7
  import {
8
8
  transformMessages
9
- } from "./cli-bsyka9ta.js";
9
+ } from "./cli-e0y603nn.js";
10
10
  import {
11
11
  sanitizeSurrogates
12
12
  } from "./cli-y2apkfe2.js";
13
13
  import {
14
14
  calculateCost
15
- } from "./cli-m6pzzhqr.js";
15
+ } from "./cli-1arw00dp.js";
16
16
 
17
17
  // node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js
18
18
  function encodeTextSignatureV1(id, phase) {
@@ -39,6 +39,7 @@ function parseTextSignature(signature) {
39
39
  }
40
40
  function convertResponsesMessages(model, context, allowedToolCallProviders, options) {
41
41
  const messages = [];
42
+ const loadedToolNames = new Set;
42
43
  const normalizeIdPart = (part) => {
43
44
  const sanitized = part.replace(/[^a-zA-Z0-9_-]/g, "_");
44
45
  const normalized = sanitized.length > 64 ? sanitized.slice(0, 64) : sanitized;
@@ -176,13 +177,39 @@ function convertResponsesMessages(model, context, allowedToolCallProviders, opti
176
177
  }
177
178
  output = contentParts;
178
179
  } else {
179
- output = sanitizeSurrogates(hasText ? textResult : "(see attached image)");
180
+ output = sanitizeSurrogates(hasText ? textResult : hasImages ? "(see attached image)" : "(no tool output)");
180
181
  }
181
182
  messages.push({
182
183
  type: "function_call_output",
183
184
  call_id: callId,
184
185
  output
185
186
  });
187
+ const deferredTools = [];
188
+ for (const name of msg.addedToolNames ?? []) {
189
+ const tool = options?.deferredTools?.get(name);
190
+ if (!tool || loadedToolNames.has(name))
191
+ continue;
192
+ loadedToolNames.add(name);
193
+ deferredTools.push(tool);
194
+ }
195
+ if (deferredTools.length > 0) {
196
+ const names = deferredTools.map((tool) => tool.name);
197
+ const searchCallId = `pi_tool_load_${shortHash(`${msg.toolCallId}:${names.join(",")}`)}`;
198
+ messages.push({
199
+ type: "tool_search_call",
200
+ call_id: searchCallId,
201
+ execution: "client",
202
+ status: "completed",
203
+ arguments: { query: names.join(" "), limit: names.length }
204
+ });
205
+ messages.push({
206
+ type: "tool_search_output",
207
+ call_id: searchCallId,
208
+ execution: "client",
209
+ status: "completed",
210
+ tools: convertResponsesTools(deferredTools, { deferLoading: true })
211
+ });
212
+ }
186
213
  }
187
214
  msgIndex++;
188
215
  }
@@ -195,12 +222,14 @@ function convertResponsesTools(tools, options) {
195
222
  name: tool.name,
196
223
  description: tool.description,
197
224
  parameters: tool.parameters,
198
- strict
225
+ strict,
226
+ ...options?.deferLoading ? { defer_loading: true } : {}
199
227
  }));
200
228
  }
201
229
  async function processResponsesStream(openaiStream, output, stream, model, options) {
202
230
  let sawTerminalResponseEvent = false;
203
231
  const outputSlots = new Map;
232
+ const reasoningBlocksById = new Map;
204
233
  const getSlot = (outputIndex, type) => {
205
234
  const slot = outputSlots.get(outputIndex);
206
235
  return slot?.type === type ? slot : undefined;
@@ -249,18 +278,37 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
249
278
  const getOrCreateSlot = (outputIndex, item) => {
250
279
  return outputSlots.get(outputIndex) ?? createSlot(outputIndex, item);
251
280
  };
281
+ const backfillReasoningSignatures = (responseOutput) => {
282
+ for (const item of responseOutput) {
283
+ if (item.type !== "reasoning" || !item.encrypted_content)
284
+ continue;
285
+ const block = reasoningBlocksById.get(item.id);
286
+ if (!block?.thinkingSignature)
287
+ continue;
288
+ const storedItem = JSON.parse(block.thinkingSignature);
289
+ if (storedItem.encrypted_content)
290
+ continue;
291
+ block.thinkingSignature = JSON.stringify({
292
+ ...storedItem,
293
+ encrypted_content: item.encrypted_content
294
+ });
295
+ }
296
+ };
252
297
  const finalizeResponse = (response) => {
253
298
  sawTerminalResponseEvent = true;
299
+ backfillReasoningSignatures(response.output ?? []);
254
300
  if (response?.id) {
255
301
  output.responseId = response.id;
256
302
  }
257
303
  if (response?.usage) {
258
- const cachedTokens = response.usage.input_tokens_details?.cached_tokens || 0;
304
+ const inputDetails = response.usage.input_tokens_details;
305
+ const cachedTokens = inputDetails?.cached_tokens || 0;
306
+ const cacheWriteTokens = inputDetails?.cache_write_tokens || 0;
259
307
  output.usage = {
260
- input: (response.usage.input_tokens || 0) - cachedTokens,
308
+ input: Math.max(0, (response.usage.input_tokens || 0) - cachedTokens - cacheWriteTokens),
261
309
  output: response.usage.output_tokens || 0,
262
310
  cacheRead: cachedTokens,
263
- cacheWrite: 0,
311
+ cacheWrite: cacheWriteTokens,
264
312
  reasoning: response.usage.output_tokens_details?.reasoning_tokens || 0,
265
313
  totalTokens: response.usage.total_tokens || 0,
266
314
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
@@ -382,6 +430,7 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
382
430
  `) || "";
383
431
  slot.block.thinking = summaryText || contentText || slot.block.thinking;
384
432
  slot.block.thinkingSignature = JSON.stringify(item);
433
+ reasoningBlocksById.set(item.id, slot.block);
385
434
  stream.push({
386
435
  type: "thinking_end",
387
436
  contentIndex: slot.contentIndex,
@@ -7,11 +7,11 @@ import {
7
7
  getPinCandidateAgent,
8
8
  getResumeGeneration,
9
9
  repointTrackerSyncBySwarmId
10
- } from "./cli-qfp17rw8.js";
10
+ } from "./cli-6rvm3jkk.js";
11
11
  import {
12
12
  getExecutorRegistry,
13
13
  recoverIncompleteRuns
14
- } from "./cli-fhmhjjh4.js";
14
+ } from "./cli-qw1ccvxm.js";
15
15
  import {
16
16
  MAX_EMPTY_POLLS,
17
17
  assignUnassignedTaskPending,
@@ -51,7 +51,7 @@ import {
51
51
  resolveTemplate,
52
52
  supersedeTask,
53
53
  updateAgentStatus
54
- } from "./cli-7mvmqemc.js";
54
+ } from "./cli-g6qz2kts.js";
55
55
 
56
56
  // src/heartbeat/heartbeat.ts
57
57
  init_db();