@desplega.ai/agent-swarm 1.120.0 → 1.121.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 +2 -2
- package/dist/{actions-rym7jyg2.js → actions-mwshtkf7.js} +6 -6
- package/dist/{anthropic-messages-qjxzsabf.js → anthropic-messages-4gn944cn.js} +29 -13
- package/dist/{app-ss3a0nfj.js → app-skbty91x.js} +4 -4
- package/dist/{assistant-8sd2b21b.js → assistant-tg7dhfj8.js} +13 -13
- package/dist/{azure-openai-responses-ntfd05zd.js → azure-openai-responses-79zc0wyy.js} +28 -13
- package/dist/{boot-reembed-eh18r04f.js → boot-reembed-ntjmeyh2.js} +4 -4
- package/dist/{boot-reembed-7bs0d0sj.js → boot-reembed-q5x0xpcp.js} +5 -5
- package/dist/{boot-scrub-logs-v8ch000n.js → boot-scrub-logs-5gznsfbe.js} +4 -4
- package/dist/{claude-adapter-9n3nzt65.js → claude-adapter-vxvcym3r.js} +3 -3
- package/dist/{claude-managed-adapter-pv2nbqy4.js → claude-managed-adapter-g807894s.js} +2 -2
- package/dist/{cli-py8z9bjq.js → cli-072t49hf.js} +9 -9
- package/dist/{cli-383wyw2f.js → cli-0df2g86x.js} +61 -17
- package/dist/{cli-84j2vp67.js → cli-1728qh70.js} +1 -1
- package/dist/{cli-kyqs14qe.js → cli-3b1ayz83.js} +5 -5
- package/dist/{cli-0ap79nha.js → cli-3fxqwfh3.js} +1 -1
- package/dist/{cli-w6rhc30s.js → cli-3jrdwnn9.js} +20 -5
- package/dist/{cli-gq12jc1m.js → cli-46etyprn.js} +7 -5
- package/dist/{cli-j59bj3vs.js → cli-4pfweq4x.js} +8 -8
- package/dist/{cli-2r7s8jhp.js → cli-5c4327dx.js} +7 -1
- package/dist/{cli-4cb3p8pj.js → cli-5hpvd15x.js} +2 -2
- package/dist/{cli-branks1w.js → cli-6s3ytc5x.js} +1 -1
- package/dist/{cli-da3x3btq.js → cli-7pt9sc83.js} +2 -2
- package/dist/{cli-n745f8e5.js → cli-7pzae66m.js} +1 -1
- package/dist/{cli-qs7nb3zn.js → cli-8wrympd7.js} +27 -1
- package/dist/{cli-zxnp21rf.js → cli-95rbe11h.js} +13 -13
- package/dist/{cli-v65h59hn.js → cli-agdrxyex.js} +1 -1
- package/dist/{cli-wr706gez.js → cli-av2s7my4.js} +167 -66
- package/dist/{cli-t91zbm2s.js → cli-avw9ev3x.js} +55 -21
- package/dist/{cli-shdvvj0n.js → cli-b2mqkg1h.js} +2 -2
- package/dist/{cli-1arw00dp.js → cli-ccjwgarc.js} +12 -3
- package/dist/{cli-pscrc6tw.js → cli-ch7t5v7n.js} +5 -0
- package/dist/{cli-tghre7g6.js → cli-cw70hymf.js} +1 -0
- package/dist/{cli-n61x2aph.js → cli-dmzv0986.js} +816 -1335
- package/dist/{cli-0kkggfr9.js → cli-g9vva2qh.js} +2 -2
- package/dist/{cli-dnx98dwa.js → cli-gdpx70nc.js} +38185 -38141
- package/dist/{cli-vmhqfnp1.js → cli-ghq3v4c9.js} +2 -2
- package/dist/{cli-w5em21am.js → cli-ky8esb8t.js} +3 -3
- package/dist/{cli-f6c6y7fw.js → cli-nf7sadev.js} +2 -2
- package/dist/{cli-zxeb2qe3.js → cli-p9w7kb3h.js} +1 -1
- package/dist/{cli-xeatwfbe.js → cli-ry656xem.js} +24 -17
- package/dist/{cli-th08nm8p.js → cli-s8bdcke2.js} +1 -1
- package/dist/cli-s8s499xy.js +81 -0
- package/dist/{cli-d2eyq90a.js → cli-srjqn7fd.js} +1 -1
- package/dist/{cli-gad984jj.js → cli-tv7vekye.js} +1 -1
- package/dist/{cli-kyfx7z3d.js → cli-vg3zrw6h.js} +4 -4
- package/dist/{cli-sbh0b9r1.js → cli-vp9r4ap4.js} +5 -4
- package/dist/{cli-mg280wsv.js → cli-we156bmz.js} +1 -1
- package/dist/{cli-e0y603nn.js → cli-x0e0yvnq.js} +101 -1
- package/dist/{cli-mw3xpgwb.js → cli-x4apc9t3.js} +4 -4
- package/dist/cli.js +23 -21
- package/dist/{codex-adapter-6j2b38tg.js → codex-adapter-mmy741zd.js} +8 -9
- package/dist/{codex-session-runner-vz215wgw.js → codex-session-runner-sazmx9zt.js} +8 -9
- package/dist/{commands-w1swgcgg.js → commands-cxxye5e4.js} +3 -3
- package/dist/{db-yv6y0fxw.js → db-ab1954b7.js} +5 -3
- package/dist/{google-generative-ai-n1d3xt4n.js → google-generative-ai-wwa2ked5.js} +14 -18
- package/dist/{google-vertex-mxst23gy.js → google-vertex-71xmdd7n.js} +14 -18
- package/dist/{handlers-yjyafdwk.js → handlers-fmfe2343.js} +13 -13
- package/dist/{hook-6nvc6p19.js → hook-ygnw3cvt.js} +7 -8
- package/dist/{http-g6j8rc6h.js → http-kactcc0z.js} +142 -64
- package/dist/{index-b2rarbkn.js → index-6erq0wvk.js} +11 -11
- package/dist/{index-7betnvg6.js → index-g86j2yt5.js} +9 -9
- package/dist/{index-64th6eqs.js → index-gmzs6a2q.js} +10 -10
- package/dist/{index-cbknx39k.js → index-hmp82wn0.js} +12 -12
- package/dist/{keepalive-j8c99r3m.js → keepalive-3cvt26dw.js} +6 -6
- package/dist/{lead-8xe71m3s.js → lead-ysf26cjr.js} +30 -31
- package/dist/{maintenance-eqnmrwb2.js → maintenance-9npwptbb.js} +5 -5
- package/dist/{mistral-conversations-ykcg66za.js → mistral-conversations-26ya4yah.js} +17 -13
- package/dist/{oauth-refresh-sweep-c5dy1653.js → oauth-refresh-sweep-0r2v76vw.js} +6 -6
- package/dist/{onboard-4avg01c1.js → onboard-ddb1674a.js} +2 -2
- package/dist/{openai-codex-responses-zy0907j9.js → openai-codex-responses-6rr2ye0s.js} +78 -38
- package/dist/{openai-completions-xk4p56n9.js → openai-completions-zfa9nkvt.js} +130 -33
- package/dist/{openai-responses-4gv3ca5d.js → openai-responses-9wmdks0g.js} +38 -14
- package/dist/{opencode-adapter-5bwzvbwj.js → opencode-adapter-h6rkxwrk.js} +2 -2
- package/dist/{openrouter-images-4fsrrzes.js → openrouter-images-dgq98729.js} +10 -3
- package/dist/{otel-impl-z4cwkp40.js → otel-impl-b43bkq8e.js} +4 -4
- package/dist/{pi-messages-zb8v76wx.js → pi-messages-nzjbbz47.js} +4 -6
- package/dist/{pi-mono-adapter-9sg69kg3.js → pi-mono-adapter-ke789738.js} +2328 -1281
- package/dist/{pricing-refresh-dts9429d.js → pricing-refresh-2rqf114z.js} +5 -5
- package/dist/{rbac-roles-4f64wch6.js → rbac-roles-5wkhc8xv.js} +4 -4
- package/dist/{rbac-roles-24cvsejy.js → rbac-roles-6vtafvzb.js} +3 -3
- package/dist/{seed-pricing-74ph9wap.js → seed-pricing-23wrb873.js} +4 -4
- package/dist/{setup-9q0n8rvd.js → setup-6rny4fk6.js} +2 -2
- package/dist/{worker-x7g344z8.js → worker-yapewe14.js} +30 -31
- package/openapi.json +169 -85
- package/package.json +7 -5
- package/plugin/commands/swarm-chat.md +2 -0
- package/plugin/pi-skills/swarm-chat/SKILL.md +2 -0
- package/src/be/db.ts +61 -5
- package/src/be/migrations/119_agent_avatar.sql +7 -0
- package/src/be/migrations/120_task_title.sql +3 -0
- package/src/be/scripts/typecheck.ts +3 -2
- package/src/be/seed-capabilities.ts +62 -0
- package/src/be/seed-pricing.ts +1 -1
- package/src/be/seed-scripts/catalog/ops-catalog-audit.inline.ts +1 -1
- package/src/be/seed-scripts/catalog/ops-catalog-audit.ts +1 -1
- package/src/commands/runner.ts +69 -6
- package/src/http/agents.ts +23 -5
- package/src/http/core.ts +8 -5
- package/src/http/index.ts +11 -0
- package/src/http/mcp-bridge.ts +5 -2
- package/src/http/poll.ts +5 -1
- package/src/http/sessions.ts +1 -1
- package/src/http/tasks.ts +35 -0
- package/src/prompts/base-prompt.ts +48 -4
- package/src/prompts/session-templates.ts +13 -1
- package/src/providers/claude-managed-models.ts +8 -0
- package/src/scripts-runtime/types/stdlib.d.ts +11 -0
- package/src/server.ts +230 -126
- package/src/tests/agent-avatar-resolution.test.ts +123 -0
- package/src/tests/agents-list-model-display.test.ts +10 -0
- package/src/tests/base-prompt.test.ts +72 -0
- package/src/tests/claude-managed-adapter.test.ts +6 -0
- package/src/tests/context-window.test.ts +1 -0
- package/src/tests/list-endpoint-slimming.test.ts +45 -0
- package/src/tests/prompt-template-session.test.ts +6 -5
- package/src/tests/script-connections.test.ts +1 -0
- package/src/tests/sdk-allowlist.test.ts +4 -1
- package/src/tests/seed-capabilities.test.ts +92 -0
- package/src/tests/session-costs-model-key-normalize.test.ts +1 -0
- package/src/tests/sessions.test.ts +46 -0
- package/src/tests/task-title-route.test.ts +106 -0
- package/src/tests/tool-annotations.test.ts +6 -3
- package/src/tools/update-profile.ts +15 -5
- package/src/types.ts +29 -0
- package/src/utils/context-window.ts +1 -0
- package/dist/cli-z9gzq07x.js +0 -27
- package/dist/{otel-g299k41b.js → otel-63jr5v38.js} +1 -1
|
@@ -5,14 +5,18 @@ import {
|
|
|
5
5
|
parseStreamingJson
|
|
6
6
|
} from "./cli-zyxs93y9.js";
|
|
7
7
|
import {
|
|
8
|
+
appendGrammarToolInputJsonDelta,
|
|
9
|
+
getGrammarToolInput,
|
|
10
|
+
resolveGrammarConstrainedSampling,
|
|
11
|
+
resolveJsonSchemaStrictSampling,
|
|
8
12
|
transformMessages
|
|
9
|
-
} from "./cli-
|
|
13
|
+
} from "./cli-x0e0yvnq.js";
|
|
10
14
|
import {
|
|
11
15
|
sanitizeSurrogates
|
|
12
16
|
} from "./cli-y2apkfe2.js";
|
|
13
17
|
import {
|
|
14
18
|
calculateCost
|
|
15
|
-
} from "./cli-
|
|
19
|
+
} from "./cli-ccjwgarc.js";
|
|
16
20
|
|
|
17
21
|
// node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js
|
|
18
22
|
function encodeTextSignatureV1(id, phase) {
|
|
@@ -37,6 +41,27 @@ function parseTextSignature(signature) {
|
|
|
37
41
|
}
|
|
38
42
|
return { id: signature };
|
|
39
43
|
}
|
|
44
|
+
function convertToolResultOutput(model, content) {
|
|
45
|
+
const textResult = content.filter((c) => c.type === "text").map((c) => c.text).join(`
|
|
46
|
+
`);
|
|
47
|
+
const images = content.filter((c) => c.type === "image");
|
|
48
|
+
const hasText = textResult.length > 0;
|
|
49
|
+
if (images.length === 0 || !model.input.includes("image")) {
|
|
50
|
+
return sanitizeSurrogates(hasText ? textResult : images.length > 0 ? "(see attached image)" : "(no tool output)");
|
|
51
|
+
}
|
|
52
|
+
const output = [];
|
|
53
|
+
if (hasText) {
|
|
54
|
+
output.push({ type: "input_text", text: sanitizeSurrogates(textResult) });
|
|
55
|
+
}
|
|
56
|
+
for (const image of images) {
|
|
57
|
+
output.push({
|
|
58
|
+
type: "input_image",
|
|
59
|
+
detail: "auto",
|
|
60
|
+
image_url: `data:${image.mimeType};base64,${image.data}`
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return output;
|
|
64
|
+
}
|
|
40
65
|
function convertResponsesMessages(model, context, allowedToolCallProviders, options) {
|
|
41
66
|
const messages = [];
|
|
42
67
|
const loadedToolNames = new Set;
|
|
@@ -135,55 +160,49 @@ function convertResponsesMessages(model, context, allowedToolCallProviders, opti
|
|
|
135
160
|
} else if (block.type === "toolCall") {
|
|
136
161
|
const toolCall = block;
|
|
137
162
|
const [callId, itemIdRaw] = toolCall.id.split("|");
|
|
163
|
+
const customInputProperty = options?.grammarToolInputProperties?.get(toolCall.name);
|
|
138
164
|
let itemId = itemIdRaw;
|
|
139
|
-
if (isDifferentModel && itemId?.startsWith("fc_")) {
|
|
165
|
+
if (isDifferentModel && itemId?.startsWith("fc_") || customInputProperty === undefined && !itemId?.startsWith("fc_")) {
|
|
140
166
|
itemId = undefined;
|
|
141
167
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
168
|
+
if (customInputProperty !== undefined) {
|
|
169
|
+
output.push({
|
|
170
|
+
type: "custom_tool_call",
|
|
171
|
+
id: itemId,
|
|
172
|
+
call_id: callId,
|
|
173
|
+
name: toolCall.name,
|
|
174
|
+
input: sanitizeSurrogates(getGrammarToolInput(toolCall.name, toolCall.arguments, customInputProperty))
|
|
175
|
+
});
|
|
176
|
+
} else {
|
|
177
|
+
output.push({
|
|
178
|
+
type: "function_call",
|
|
179
|
+
id: itemId,
|
|
180
|
+
call_id: callId,
|
|
181
|
+
name: toolCall.name,
|
|
182
|
+
arguments: JSON.stringify(toolCall.arguments)
|
|
183
|
+
});
|
|
184
|
+
}
|
|
149
185
|
}
|
|
150
186
|
}
|
|
151
187
|
if (output.length === 0)
|
|
152
188
|
continue;
|
|
153
189
|
messages.push(...output);
|
|
154
190
|
} else if (msg.role === "toolResult") {
|
|
155
|
-
const textResult = msg.content.filter((c) => c.type === "text").map((c) => c.text).join(`
|
|
156
|
-
`);
|
|
157
|
-
const hasImages = msg.content.some((c) => c.type === "image");
|
|
158
|
-
const hasText = textResult.length > 0;
|
|
159
191
|
const [callId] = msg.toolCallId.split("|");
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
for (const block of msg.content) {
|
|
170
|
-
if (block.type === "image") {
|
|
171
|
-
contentParts.push({
|
|
172
|
-
type: "input_image",
|
|
173
|
-
detail: "auto",
|
|
174
|
-
image_url: `data:${block.mimeType};base64,${block.data}`
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
output = contentParts;
|
|
192
|
+
const output = convertToolResultOutput(model, msg.content);
|
|
193
|
+
if (options?.grammarToolInputProperties?.has(msg.toolName)) {
|
|
194
|
+
messages.push({
|
|
195
|
+
type: "custom_tool_call_output",
|
|
196
|
+
call_id: callId,
|
|
197
|
+
output
|
|
198
|
+
});
|
|
179
199
|
} else {
|
|
180
|
-
|
|
200
|
+
messages.push({
|
|
201
|
+
type: "function_call_output",
|
|
202
|
+
call_id: callId,
|
|
203
|
+
output
|
|
204
|
+
});
|
|
181
205
|
}
|
|
182
|
-
messages.push({
|
|
183
|
-
type: "function_call_output",
|
|
184
|
-
call_id: callId,
|
|
185
|
-
output
|
|
186
|
-
});
|
|
187
206
|
const deferredTools = [];
|
|
188
207
|
for (const name of msg.addedToolNames ?? []) {
|
|
189
208
|
const tool = options?.deferredTools?.get(name);
|
|
@@ -207,7 +226,10 @@ function convertResponsesMessages(model, context, allowedToolCallProviders, opti
|
|
|
207
226
|
call_id: searchCallId,
|
|
208
227
|
execution: "client",
|
|
209
228
|
status: "completed",
|
|
210
|
-
tools: convertResponsesTools(deferredTools, {
|
|
229
|
+
tools: convertResponsesTools(deferredTools, {
|
|
230
|
+
...options?.toolOptions,
|
|
231
|
+
deferLoading: true
|
|
232
|
+
})
|
|
211
233
|
});
|
|
212
234
|
}
|
|
213
235
|
}
|
|
@@ -216,15 +238,52 @@ function convertResponsesMessages(model, context, allowedToolCallProviders, opti
|
|
|
216
238
|
return messages;
|
|
217
239
|
}
|
|
218
240
|
function convertResponsesTools(tools, options) {
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
241
|
+
const defaultStrict = options?.strict === undefined ? false : options.strict;
|
|
242
|
+
const supportsStrictMode = options?.supportsStrictMode ?? true;
|
|
243
|
+
const supportsOpenAIGrammarTools = options?.supportsOpenAIGrammarTools ?? false;
|
|
244
|
+
return tools.map((tool) => {
|
|
245
|
+
const grammar = resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools);
|
|
246
|
+
if (grammar) {
|
|
247
|
+
return {
|
|
248
|
+
type: "custom",
|
|
249
|
+
name: tool.name,
|
|
250
|
+
description: tool.description,
|
|
251
|
+
format: {
|
|
252
|
+
type: "grammar",
|
|
253
|
+
syntax: grammar.format,
|
|
254
|
+
definition: grammar.definition
|
|
255
|
+
},
|
|
256
|
+
...options?.deferLoading ? { defer_loading: true } : {}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
const constrainedStrict = resolveJsonSchemaStrictSampling(tool, supportsStrictMode);
|
|
260
|
+
const functionTool = {
|
|
261
|
+
type: "function",
|
|
262
|
+
name: tool.name,
|
|
263
|
+
description: tool.description,
|
|
264
|
+
parameters: tool.parameters,
|
|
265
|
+
...options?.deferLoading ? { defer_loading: true } : {}
|
|
266
|
+
};
|
|
267
|
+
if (supportsStrictMode) {
|
|
268
|
+
functionTool.strict = constrainedStrict ?? defaultStrict;
|
|
269
|
+
}
|
|
270
|
+
return functionTool;
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function getCustomToolCallInput(block) {
|
|
274
|
+
const property = block.customInput?.property;
|
|
275
|
+
if (property === undefined)
|
|
276
|
+
return "";
|
|
277
|
+
const value = block.arguments[property];
|
|
278
|
+
return typeof value === "string" ? value : "";
|
|
279
|
+
}
|
|
280
|
+
function appendCustomToolCallInput(block, nextInput, close) {
|
|
281
|
+
const customInput = block.customInput;
|
|
282
|
+
if (!customInput)
|
|
283
|
+
return;
|
|
284
|
+
const delta = appendGrammarToolInputJsonDelta(customInput.jsonBuffer, customInput.property, nextInput, close);
|
|
285
|
+
block.arguments = { [customInput.property]: nextInput };
|
|
286
|
+
return delta;
|
|
228
287
|
}
|
|
229
288
|
async function processResponsesStream(openaiStream, output, stream, model, options) {
|
|
230
289
|
let sawTerminalResponseEvent = false;
|
|
@@ -234,6 +293,16 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
234
293
|
const slot = outputSlots.get(outputIndex);
|
|
235
294
|
return slot?.type === type ? slot : undefined;
|
|
236
295
|
};
|
|
296
|
+
const pushToolCallDelta = (slot, delta) => {
|
|
297
|
+
if (delta === undefined)
|
|
298
|
+
return;
|
|
299
|
+
stream.push({
|
|
300
|
+
type: "toolcall_delta",
|
|
301
|
+
contentIndex: slot.contentIndex,
|
|
302
|
+
delta,
|
|
303
|
+
partial: output
|
|
304
|
+
});
|
|
305
|
+
};
|
|
237
306
|
const createSlot = (outputIndex, item) => {
|
|
238
307
|
if (item.type === "reasoning") {
|
|
239
308
|
const block = { type: "thinking", thinking: "" };
|
|
@@ -273,6 +342,29 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
273
342
|
stream.push({ type: "toolcall_start", contentIndex: slot.contentIndex, partial: output });
|
|
274
343
|
return slot;
|
|
275
344
|
}
|
|
345
|
+
if (item.type === "custom_tool_call") {
|
|
346
|
+
const inputProperty = options?.grammarToolInputProperties?.get(item.name) ?? "input";
|
|
347
|
+
const input = item.input || "";
|
|
348
|
+
const block = {
|
|
349
|
+
type: "toolCall",
|
|
350
|
+
id: `${item.call_id}|${item.id}`,
|
|
351
|
+
name: item.name,
|
|
352
|
+
arguments: { [inputProperty]: input },
|
|
353
|
+
customInput: {
|
|
354
|
+
property: inputProperty,
|
|
355
|
+
jsonBuffer: { input: "", started: false, closed: false }
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
output.content.push(block);
|
|
359
|
+
const slot = {
|
|
360
|
+
type: "toolCall",
|
|
361
|
+
block,
|
|
362
|
+
contentIndex: output.content.length - 1
|
|
363
|
+
};
|
|
364
|
+
outputSlots.set(outputIndex, slot);
|
|
365
|
+
stream.push({ type: "toolcall_start", contentIndex: slot.contentIndex, partial: output });
|
|
366
|
+
return slot;
|
|
367
|
+
}
|
|
276
368
|
return;
|
|
277
369
|
};
|
|
278
370
|
const getOrCreateSlot = (outputIndex, item) => {
|
|
@@ -390,34 +482,33 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
390
482
|
});
|
|
391
483
|
} else if (event.type === "response.function_call_arguments.delta") {
|
|
392
484
|
const slot = getSlot(event.output_index, "toolCall");
|
|
393
|
-
if (!slot)
|
|
485
|
+
if (!slot || slot.block.partialJson === undefined)
|
|
394
486
|
continue;
|
|
395
487
|
slot.block.partialJson += event.delta;
|
|
396
488
|
slot.block.arguments = parseStreamingJson(slot.block.partialJson);
|
|
397
|
-
|
|
398
|
-
type: "toolcall_delta",
|
|
399
|
-
contentIndex: slot.contentIndex,
|
|
400
|
-
delta: event.delta,
|
|
401
|
-
partial: output
|
|
402
|
-
});
|
|
489
|
+
pushToolCallDelta(slot, event.delta);
|
|
403
490
|
} else if (event.type === "response.function_call_arguments.done") {
|
|
404
491
|
const slot = getSlot(event.output_index, "toolCall");
|
|
405
|
-
if (!slot)
|
|
492
|
+
if (!slot || slot.block.partialJson === undefined)
|
|
406
493
|
continue;
|
|
407
494
|
const previousPartialJson = slot.block.partialJson;
|
|
408
495
|
slot.block.partialJson = event.arguments;
|
|
409
496
|
slot.block.arguments = parseStreamingJson(slot.block.partialJson);
|
|
410
497
|
if (event.arguments.startsWith(previousPartialJson)) {
|
|
411
498
|
const delta = event.arguments.slice(previousPartialJson.length);
|
|
412
|
-
if (delta.length > 0)
|
|
413
|
-
|
|
414
|
-
type: "toolcall_delta",
|
|
415
|
-
contentIndex: slot.contentIndex,
|
|
416
|
-
delta,
|
|
417
|
-
partial: output
|
|
418
|
-
});
|
|
419
|
-
}
|
|
499
|
+
if (delta.length > 0)
|
|
500
|
+
pushToolCallDelta(slot, delta);
|
|
420
501
|
}
|
|
502
|
+
} else if (event.type === "response.custom_tool_call_input.delta") {
|
|
503
|
+
const slot = getSlot(event.output_index, "toolCall");
|
|
504
|
+
if (!slot || !slot.block.customInput)
|
|
505
|
+
continue;
|
|
506
|
+
pushToolCallDelta(slot, appendCustomToolCallInput(slot.block, getCustomToolCallInput(slot.block) + event.delta, false));
|
|
507
|
+
} else if (event.type === "response.custom_tool_call_input.done") {
|
|
508
|
+
const slot = getSlot(event.output_index, "toolCall");
|
|
509
|
+
if (!slot || !slot.block.customInput)
|
|
510
|
+
continue;
|
|
511
|
+
pushToolCallDelta(slot, appendCustomToolCallInput(slot.block, event.input, true));
|
|
421
512
|
} else if (event.type === "response.output_item.done") {
|
|
422
513
|
const item = event.item;
|
|
423
514
|
const slot = getOrCreateSlot(event.output_index, item);
|
|
@@ -448,7 +539,7 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
448
539
|
partial: output
|
|
449
540
|
});
|
|
450
541
|
outputSlots.delete(event.output_index);
|
|
451
|
-
} else if (item.type === "function_call" && slot?.type === "toolCall") {
|
|
542
|
+
} else if (item.type === "function_call" && slot?.type === "toolCall" && slot.block.partialJson !== undefined) {
|
|
452
543
|
slot.block.arguments = parseStreamingJson(item.arguments || slot.block.partialJson || "{}");
|
|
453
544
|
delete slot.block.partialJson;
|
|
454
545
|
stream.push({
|
|
@@ -458,6 +549,16 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
458
549
|
partial: output
|
|
459
550
|
});
|
|
460
551
|
outputSlots.delete(event.output_index);
|
|
552
|
+
} else if (item.type === "custom_tool_call" && slot?.type === "toolCall" && slot.block.customInput) {
|
|
553
|
+
pushToolCallDelta(slot, appendCustomToolCallInput(slot.block, item.input ?? getCustomToolCallInput(slot.block), true));
|
|
554
|
+
delete slot.block.customInput;
|
|
555
|
+
stream.push({
|
|
556
|
+
type: "toolcall_end",
|
|
557
|
+
contentIndex: slot.contentIndex,
|
|
558
|
+
toolCall: slot.block,
|
|
559
|
+
partial: output
|
|
560
|
+
});
|
|
561
|
+
outputSlots.delete(event.output_index);
|
|
461
562
|
}
|
|
462
563
|
} else if (event.type === "response.completed" || event.type === "response.incomplete") {
|
|
463
564
|
finalizeResponse(event.response);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
checkCodexCredentials
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-7pt9sc83.js";
|
|
4
4
|
import {
|
|
5
5
|
checkClaudeManagedCredentials
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-5c4327dx.js";
|
|
7
7
|
import {
|
|
8
8
|
checkDevinCredentials
|
|
9
9
|
} from "./cli-tyfxrrdd.js";
|
|
10
10
|
import {
|
|
11
11
|
checkOpencodeCredentials
|
|
12
|
-
} from "./cli-
|
|
12
|
+
} from "./cli-6s3ytc5x.js";
|
|
13
13
|
import {
|
|
14
14
|
initOtel,
|
|
15
15
|
injectTraceContext,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
withSpan,
|
|
20
20
|
withSpanContext,
|
|
21
21
|
writeSkillsToFilesystem
|
|
22
|
-
} from "./cli-
|
|
22
|
+
} from "./cli-gdpx70nc.js";
|
|
23
23
|
import {
|
|
24
24
|
authJsonToCredentialSelection,
|
|
25
25
|
credentialsToAuthJson,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from "./cli-tk9vyqzh.js";
|
|
28
28
|
import {
|
|
29
29
|
checkClaudeCredentials
|
|
30
|
-
} from "./cli-
|
|
30
|
+
} from "./cli-x4apc9t3.js";
|
|
31
31
|
import {
|
|
32
32
|
MAX_RATE_LIMIT_RESET_MS,
|
|
33
33
|
isCodexCreditsExhaustedMessage,
|
|
@@ -37,14 +37,14 @@ import {
|
|
|
37
37
|
} from "./cli-psrqtw2m.js";
|
|
38
38
|
import {
|
|
39
39
|
getContextWindowSize
|
|
40
|
-
} from "./cli-
|
|
40
|
+
} from "./cli-cw70hymf.js";
|
|
41
41
|
import {
|
|
42
42
|
ensure,
|
|
43
43
|
initialize
|
|
44
|
-
} from "./cli-
|
|
44
|
+
} from "./cli-vg3zrw6h.js";
|
|
45
45
|
import {
|
|
46
46
|
validateJsonSchema
|
|
47
|
-
} from "./cli-
|
|
47
|
+
} from "./cli-95rbe11h.js";
|
|
48
48
|
import {
|
|
49
49
|
getApiKey
|
|
50
50
|
} from "./cli-f14fvzag.js";
|
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
resolveTaskModelSelection,
|
|
81
81
|
resolveTemplateAsync,
|
|
82
82
|
telemetry
|
|
83
|
-
} from "./cli-
|
|
83
|
+
} from "./cli-0df2g86x.js";
|
|
84
84
|
import {
|
|
85
85
|
init_credentials,
|
|
86
86
|
resolveCredentialPools
|
|
@@ -137,17 +137,22 @@ var getBasePrompt = async (args) => {
|
|
|
137
137
|
${scriptsOnlyResult.text}`;
|
|
138
138
|
}
|
|
139
139
|
const slackPromptToolsEnabled = areSlackPromptToolsEnabled();
|
|
140
|
-
|
|
140
|
+
const serverHasCapability = (cap, whenUnknown) => args.serverCapabilities ? args.serverCapabilities.includes(cap) : whenUnknown;
|
|
141
|
+
if (hasMcp && slackPromptToolsEnabled && !scriptsOnlyMode && serverHasCapability("slack", true)) {
|
|
141
142
|
const slackResult = await resolveTemplateAsync("system.agent.slack", {});
|
|
142
143
|
prompt += slackResult.text;
|
|
143
144
|
}
|
|
144
|
-
if (role !== "lead" && args.slackContext && hasMcp && slackPromptToolsEnabled) {
|
|
145
|
+
if (role !== "lead" && args.slackContext && hasMcp && slackPromptToolsEnabled && (scriptsOnlyMode || serverHasCapability("slack", true))) {
|
|
145
146
|
const slackResult = await resolveTemplateAsync(scriptsOnlyMode ? "system.agent.scripts_only_mode.slack" : "system.agent.worker.slack", {
|
|
146
147
|
slackChannelId: args.slackContext.channelId,
|
|
147
148
|
slackThreadTs: args.slackContext.threadTs ?? ""
|
|
148
149
|
});
|
|
149
150
|
prompt += slackResult.text;
|
|
150
151
|
}
|
|
152
|
+
if (hasMcp && !scriptsOnlyMode && serverHasCapability("messaging", true)) {
|
|
153
|
+
const messagingResult = await resolveTemplateAsync("system.agent.messaging", {});
|
|
154
|
+
prompt += messagingResult.text;
|
|
155
|
+
}
|
|
151
156
|
if (!hasLocalEnv) {
|
|
152
157
|
prompt += `
|
|
153
158
|
|
|
@@ -311,7 +316,7 @@ Do NOT use \`--no-verify\` or any flag that bypasses git hooks.
|
|
|
311
316
|
});
|
|
312
317
|
conditionalSuffix += agentFsResult.text;
|
|
313
318
|
}
|
|
314
|
-
if (!args.capabilities || args.capabilities.includes("services")) {
|
|
319
|
+
if (args.serverCapabilities ? args.serverCapabilities.includes("services") : !args.capabilities || args.capabilities.includes("services")) {
|
|
315
320
|
const servicesResult = await resolveTemplateAsync("system.agent.services", {
|
|
316
321
|
agentId,
|
|
317
322
|
swarmUrl
|
|
@@ -449,19 +454,19 @@ async function materializeCodexAuthJson(_slot, creds, deps = {}) {
|
|
|
449
454
|
async function createProviderAdapter(provider) {
|
|
450
455
|
switch (provider) {
|
|
451
456
|
case "claude": {
|
|
452
|
-
const { ClaudeAdapter } = await import("./claude-adapter-
|
|
457
|
+
const { ClaudeAdapter } = await import("./claude-adapter-vxvcym3r.js");
|
|
453
458
|
return new ClaudeAdapter;
|
|
454
459
|
}
|
|
455
460
|
case "pi": {
|
|
456
|
-
const { PiMonoAdapter } = await import("./pi-mono-adapter-
|
|
461
|
+
const { PiMonoAdapter } = await import("./pi-mono-adapter-ke789738.js");
|
|
457
462
|
return new PiMonoAdapter;
|
|
458
463
|
}
|
|
459
464
|
case "codex": {
|
|
460
|
-
const { CodexAdapter } = await import("./codex-adapter-
|
|
465
|
+
const { CodexAdapter } = await import("./codex-adapter-mmy741zd.js");
|
|
461
466
|
return new CodexAdapter;
|
|
462
467
|
}
|
|
463
468
|
case "claude-managed": {
|
|
464
|
-
const { ClaudeManagedAdapter } = await import("./claude-managed-adapter-
|
|
469
|
+
const { ClaudeManagedAdapter } = await import("./claude-managed-adapter-g807894s.js");
|
|
465
470
|
return new ClaudeManagedAdapter;
|
|
466
471
|
}
|
|
467
472
|
case "devin": {
|
|
@@ -469,7 +474,7 @@ async function createProviderAdapter(provider) {
|
|
|
469
474
|
return new DevinAdapter;
|
|
470
475
|
}
|
|
471
476
|
case "opencode": {
|
|
472
|
-
const { OpencodeAdapter } = await import("./opencode-adapter-
|
|
477
|
+
const { OpencodeAdapter } = await import("./opencode-adapter-h6rkxwrk.js");
|
|
473
478
|
return new OpencodeAdapter;
|
|
474
479
|
}
|
|
475
480
|
default:
|
|
@@ -1117,7 +1122,7 @@ async function checkProviderCredentials(provider, env, opts) {
|
|
|
1117
1122
|
case "opencode":
|
|
1118
1123
|
return checkOpencodeCredentials(env, opts);
|
|
1119
1124
|
case "pi": {
|
|
1120
|
-
const { checkPiMonoCredentials } = await import("./pi-mono-adapter-
|
|
1125
|
+
const { checkPiMonoCredentials } = await import("./pi-mono-adapter-ke789738.js");
|
|
1121
1126
|
return checkPiMonoCredentials(env, opts);
|
|
1122
1127
|
}
|
|
1123
1128
|
default:
|
|
@@ -2815,6 +2820,14 @@ async function registerAgent(opts) {
|
|
|
2815
2820
|
const error = await response.text();
|
|
2816
2821
|
throw new Error(`Failed to register agent: ${response.status} ${error}`);
|
|
2817
2822
|
}
|
|
2823
|
+
try {
|
|
2824
|
+
const body = await response.json();
|
|
2825
|
+
const caps = body.enabledCapabilities;
|
|
2826
|
+
if (Array.isArray(caps) && caps.every((c2) => typeof c2 === "string")) {
|
|
2827
|
+
return { serverCapabilities: caps };
|
|
2828
|
+
}
|
|
2829
|
+
} catch {}
|
|
2830
|
+
return {};
|
|
2818
2831
|
}
|
|
2819
2832
|
async function pollForTrigger(opts) {
|
|
2820
2833
|
if (!isPollTracingEnabled()) {
|
|
@@ -4039,6 +4052,7 @@ async function runAgent(config, opts) {
|
|
|
4039
4052
|
role
|
|
4040
4053
|
});
|
|
4041
4054
|
let capabilities = config.capabilities;
|
|
4055
|
+
let serverCapabilities;
|
|
4042
4056
|
let agentSoulMd;
|
|
4043
4057
|
let agentIdentityMd;
|
|
4044
4058
|
let agentSetupScript;
|
|
@@ -4058,6 +4072,7 @@ async function runAgent(config, opts) {
|
|
|
4058
4072
|
agentId,
|
|
4059
4073
|
swarmUrl,
|
|
4060
4074
|
capabilities,
|
|
4075
|
+
serverCapabilities,
|
|
4061
4076
|
traits,
|
|
4062
4077
|
provider: adapter.name,
|
|
4063
4078
|
scriptsOnly: resolvedScriptsOnly,
|
|
@@ -4156,6 +4171,8 @@ ${additionalSystemPrompt}` : basePrompt;
|
|
|
4156
4171
|
let cachedCredHarnessProvider = null;
|
|
4157
4172
|
let lastHarnessReconcileAt = 0;
|
|
4158
4173
|
const HARNESS_RECONCILE_INTERVAL_MS = 1e4;
|
|
4174
|
+
let lastServerCapsRefreshAt = 0;
|
|
4175
|
+
const SERVER_CAPS_REFRESH_INTERVAL_MS = 300000;
|
|
4159
4176
|
let lastBedrockRefreshAt = 0;
|
|
4160
4177
|
const BEDROCK_REFRESH_INTERVAL_MS = 5 * 60 * 1000;
|
|
4161
4178
|
const apiConfig = { apiUrl, apiKey, agentId };
|
|
@@ -4208,9 +4225,22 @@ ${additionalSystemPrompt}` : basePrompt;
|
|
|
4208
4225
|
}
|
|
4209
4226
|
return { agentVisibleChanged };
|
|
4210
4227
|
};
|
|
4228
|
+
const applyServerCapabilities = async (next) => {
|
|
4229
|
+
if (!next)
|
|
4230
|
+
return;
|
|
4231
|
+
const changed = !serverCapabilities || next.length !== serverCapabilities.length || next.some((c2) => !serverCapabilities?.includes(c2));
|
|
4232
|
+
serverCapabilities = next;
|
|
4233
|
+
if (changed) {
|
|
4234
|
+
basePrompt = await buildSystemPrompt();
|
|
4235
|
+
resolvedSystemPrompt = additionalSystemPrompt ? `${basePrompt}
|
|
4236
|
+
|
|
4237
|
+
${additionalSystemPrompt}` : basePrompt;
|
|
4238
|
+
console.log(`[${role}] [config] Server capabilities updated (${next.length} flags) — system prompt rebuilt`);
|
|
4239
|
+
}
|
|
4240
|
+
};
|
|
4211
4241
|
const reregisterAgent = async () => {
|
|
4212
4242
|
try {
|
|
4213
|
-
await registerAgent({
|
|
4243
|
+
const reg = await registerAgent({
|
|
4214
4244
|
apiUrl,
|
|
4215
4245
|
apiKey,
|
|
4216
4246
|
agentId,
|
|
@@ -4221,12 +4251,14 @@ ${additionalSystemPrompt}` : basePrompt;
|
|
|
4221
4251
|
maxTasks: state.maxConcurrent,
|
|
4222
4252
|
harnessProvider: state.harnessProvider
|
|
4223
4253
|
});
|
|
4254
|
+
lastServerCapsRefreshAt = Date.now();
|
|
4255
|
+
await applyServerCapabilities(reg.serverCapabilities);
|
|
4224
4256
|
} catch (err) {
|
|
4225
4257
|
console.warn(`[${role}] [config] Re-register failed (non-fatal): ${err}`);
|
|
4226
4258
|
}
|
|
4227
4259
|
};
|
|
4228
4260
|
try {
|
|
4229
|
-
await registerAgent({
|
|
4261
|
+
const reg = await registerAgent({
|
|
4230
4262
|
apiUrl,
|
|
4231
4263
|
apiKey,
|
|
4232
4264
|
agentId,
|
|
@@ -4237,6 +4269,8 @@ ${additionalSystemPrompt}` : basePrompt;
|
|
|
4237
4269
|
maxTasks: maxConcurrent,
|
|
4238
4270
|
harnessProvider: bootProvider
|
|
4239
4271
|
});
|
|
4272
|
+
lastServerCapsRefreshAt = Date.now();
|
|
4273
|
+
await applyServerCapabilities(reg.serverCapabilities);
|
|
4240
4274
|
console.log(`[${role}] Registered as "${agentName}" (ID: ${agentId})`);
|
|
4241
4275
|
} catch (error) {
|
|
4242
4276
|
console.error(`[${role}] Failed to register: ${error}`);
|
|
@@ -4666,7 +4700,7 @@ ${additionalSystemPrompt}` : basePrompt;
|
|
|
4666
4700
|
configValue: scriptsOnlyConfigValue
|
|
4667
4701
|
});
|
|
4668
4702
|
const { agentVisibleChanged } = await applySwarmConfigDrift(freshEnv, resolvedProvider, nextScriptsOnly);
|
|
4669
|
-
if (agentVisibleChanged) {
|
|
4703
|
+
if (agentVisibleChanged || Date.now() - lastServerCapsRefreshAt > SERVER_CAPS_REFRESH_INTERVAL_MS) {
|
|
4670
4704
|
await reregisterAgent();
|
|
4671
4705
|
}
|
|
4672
4706
|
} catch (err) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildModelsDevSeedRows
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-ghq3v4c9.js";
|
|
4
4
|
import {
|
|
5
5
|
createLogEntry,
|
|
6
6
|
getActivePricingRow,
|
|
7
7
|
getDb,
|
|
8
8
|
init_db,
|
|
9
9
|
insertPricingRow
|
|
10
|
-
} from "./cli-
|
|
10
|
+
} from "./cli-0df2g86x.js";
|
|
11
11
|
import {
|
|
12
12
|
init_secret_scrubber,
|
|
13
13
|
scrubSecrets
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AssistantMessageEventStream
|
|
3
|
-
|
|
2
|
+
AssistantMessageEventStream,
|
|
3
|
+
formatThrownValue
|
|
4
|
+
} from "./cli-8wrympd7.js";
|
|
4
5
|
|
|
5
6
|
// node_modules/@earendil-works/pi-ai/dist/api/lazy.js
|
|
6
7
|
function createSetupErrorMessage(model, error) {
|
|
@@ -124,11 +125,19 @@ class InMemoryCredentialStore {
|
|
|
124
125
|
class ModelsError extends Error {
|
|
125
126
|
code;
|
|
126
127
|
constructor(code, message, options) {
|
|
127
|
-
super(message, options);
|
|
128
|
+
super(withCauseDetail(message, options?.cause), options);
|
|
128
129
|
this.name = "ModelsError";
|
|
129
130
|
this.code = code;
|
|
130
131
|
}
|
|
131
132
|
}
|
|
133
|
+
function withCauseDetail(message, cause) {
|
|
134
|
+
if (cause === undefined || cause === null)
|
|
135
|
+
return message;
|
|
136
|
+
const detail = formatThrownValue(cause).trim();
|
|
137
|
+
if (!detail || message.includes(detail))
|
|
138
|
+
return message;
|
|
139
|
+
return `${message}: ${detail}`;
|
|
140
|
+
}
|
|
132
141
|
async function resolveProviderAuth(provider, credentials, authContext, overrides) {
|
|
133
142
|
const requestAuthContext = overrides?.env ? overlayEnvAuthContext(authContext, overrides.env) : authContext;
|
|
134
143
|
if (overrides?.apiKey !== undefined && provider.auth.apiKey) {
|
|
@@ -43,10 +43,15 @@ function pickBodyText(error) {
|
|
|
43
43
|
const responseBody = error.$response?.body;
|
|
44
44
|
if (typeof responseBody === "string")
|
|
45
45
|
return responseBody;
|
|
46
|
+
if (isReadableStreamLike(responseBody))
|
|
47
|
+
return;
|
|
46
48
|
if (isNonEmptyObject(responseBody))
|
|
47
49
|
return safeJsonStringify(responseBody);
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
52
|
+
function isReadableStreamLike(value) {
|
|
53
|
+
return typeof value === "object" && value !== null && "pipe" in value && typeof value.pipe === "function";
|
|
54
|
+
}
|
|
50
55
|
function isNonEmptyObject(value) {
|
|
51
56
|
return typeof value === "object" && value !== null && Object.keys(value).length > 0;
|
|
52
57
|
}
|