@desplega.ai/agent-swarm 1.119.3 → 1.119.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{actions-kd321p1j.js → actions-xqb0w6as.js} +5 -5
- package/dist/{anthropic-messages-kq3pjhbp.js → anthropic-messages-qjxzsabf.js} +94 -46
- package/dist/{app-p1gqacgd.js → app-qv9sy539.js} +3 -3
- package/dist/{assistant-6w0zb089.js → assistant-54jkns28.js} +8 -8
- package/dist/{azure-openai-responses-f57n5qy7.js → azure-openai-responses-ntfd05zd.js} +10 -7
- package/dist/{boot-reembed-zktmj8zt.js → boot-reembed-m3cpwet0.js} +4 -4
- package/dist/{boot-reembed-7gy85nnp.js → boot-reembed-s0mftrn2.js} +3 -3
- package/dist/{boot-scrub-logs-d8n8pcgr.js → boot-scrub-logs-btj144vd.js} +2 -2
- package/dist/{claude-adapter-3csn5bks.js → claude-adapter-9n3nzt65.js} +2 -2
- package/dist/{claude-managed-adapter-kysmkz89.js → claude-managed-adapter-pv2nbqy4.js} +2 -2
- package/dist/{cli-e5hdn9nx.js → cli-150bvqyw.js} +1 -1
- package/dist/{cli-m6pzzhqr.js → cli-1arw00dp.js} +251 -122
- package/dist/{cli-g5a31r9y.js → cli-3brg2qy0.js} +2 -2
- package/dist/{cli-9y4z25ke.js → cli-4ntm7f2r.js} +1 -1
- package/dist/{cli-get7n46a.js → cli-4yby3gz2.js} +1 -1
- package/dist/{cli-cx30v78p.js → cli-5sexkty0.js} +6 -6
- package/dist/{cli-6expbmb3.js → cli-65anxt77.js} +1 -1
- package/dist/{cli-gzng1fst.js → cli-7h1sce5x.js} +9 -7
- package/dist/{cli-xgefj1nz.js → cli-9rrpjvan.js} +2 -2
- package/dist/{cli-emgzr4ja.js → cli-ctdx3h19.js} +5 -5
- package/dist/{cli-dh9eb7tt.js → cli-da3x3btq.js} +5 -3
- package/dist/{cli-bsyka9ta.js → cli-e0y603nn.js} +30 -16
- package/dist/{cli-8y1kmyn7.js → cli-hc543pgg.js} +2 -2
- package/dist/{cli-z612d1nc.js → cli-hjpdm93t.js} +1 -1
- package/dist/{cli-yzxg93ma.js → cli-jcp7f17k.js} +4 -4
- package/dist/{cli-7yfmb4ne.js → cli-m0aghjk5.js} +1 -1
- package/dist/{cli-xw7p4wkq.js → cli-mg280wsv.js} +1 -1
- package/dist/{cli-hcpm1e90.js → cli-n61x2aph.js} +2488 -18718
- package/dist/{cli-9aqtt1dn.js → cli-qh6dfg7b.js} +5 -5
- package/dist/cli-qs7nb3zn.js +76 -0
- package/dist/{cli-y82m27mq.js → cli-rp04sjbc.js} +1 -1
- package/dist/{cli-j5da6jb2.js → cli-sjvxb0ys.js} +19 -30
- package/dist/{cli-eb3s7zwh.js → cli-tznnqgnf.js} +18 -18
- package/dist/cli-v1mwc5v2.js +68 -0
- package/dist/cli-vfcth11k.js +36 -0
- package/dist/{cli-kc3h8mnm.js → cli-w6rhc30s.js} +1 -1
- package/dist/{cli-j2vpt4hd.js → cli-w9jp9sc4.js} +16 -16
- package/dist/{cli-p4yn675m.js → cli-wbrj97j4.js} +1 -1
- package/dist/{cli-td2x0s9b.js → cli-wejdajv9.js} +1 -1
- package/dist/{cli-527y7yzc.js → cli-wqfxznva.js} +3 -3
- package/dist/{cli-sdpnhajn.js → cli-wr706gez.js} +56 -7
- package/dist/{cli-0qy7bk86.js → cli-xeatwfbe.js} +25 -16
- package/dist/{cli-3sew4a9j.js → cli-xv365pmn.js} +1 -1
- package/dist/{cli-hx1dcevq.js → cli-z9gzq07x.js} +1 -23
- package/dist/{cli-j6n9at34.js → cli-zn7x1nkq.js} +2 -2
- package/dist/cli.js +21 -20
- package/dist/{codex-adapter-efskwfc4.js → codex-adapter-6j2b38tg.js} +8 -6
- package/dist/{codex-session-runner-n7ad0jdv.js → codex-session-runner-vz215wgw.js} +8 -6
- package/dist/{commands-14gkjns3.js → commands-jc6a4g7b.js} +2 -2
- package/dist/{db-c9wx8pbf.js → db-5gntqs7z.js} +2 -2
- package/dist/{google-generative-ai-hyrra2jm.js → google-generative-ai-n1d3xt4n.js} +9 -7
- package/dist/{google-vertex-9hhq68sw.js → google-vertex-mxst23gy.js} +9 -7
- package/dist/{handlers-m9jxp50r.js → handlers-jtjhcfec.js} +8 -8
- package/dist/{hook-mm8mj3cp.js → hook-d3yspdv9.js} +7 -5
- package/dist/{http-hhmh7m51.js → http-vf5qsq5m.js} +39 -38
- package/dist/{index-basky7qw.js → index-9t676t5s.js} +10 -10
- package/dist/{index-vmcp507g.js → index-be74p0aj.js} +8 -8
- package/dist/{index-9h6qre5v.js → index-dh8vf4p5.js} +6 -6
- package/dist/{index-ep25fyer.js → index-krp5s3s3.js} +9 -9
- package/dist/{keepalive-70mwsyhb.js → keepalive-p5m5d3g9.js} +4 -4
- package/dist/{lead-pshn5w58.js → lead-z4z70dn3.js} +32 -30
- package/dist/{maintenance-rbjav7ey.js → maintenance-n67pnrp0.js} +4 -4
- package/dist/{mistral-conversations-tn4sj5qv.js → mistral-conversations-ykcg66za.js} +5 -3
- package/dist/{oauth-refresh-sweep-dfbd7yw0.js → oauth-refresh-sweep-ygx2e3hv.js} +3 -3
- package/dist/{onboard-g8911158.js → onboard-76fn6mr2.js} +2 -2
- package/dist/{openai-codex-responses-bex0bpn6.js → openai-codex-responses-zy0907j9.js} +68 -39
- package/dist/{openai-completions-gygw5cxt.js → openai-completions-xk4p56n9.js} +73 -14
- package/dist/{openai-responses-8c0dgmty.js → openai-responses-4gv3ca5d.js} +38 -16
- package/dist/{opencode-adapter-p6bxnbm4.js → opencode-adapter-5bwzvbwj.js} +2 -2
- package/dist/{otel-impl-qw4pakj6.js → otel-impl-d9vmbspk.js} +1 -1
- package/dist/pi-messages-zb8v76wx.js +313 -0
- package/dist/{pi-mono-adapter-erghwha0.js → pi-mono-adapter-9sg69kg3.js} +15711 -12608
- package/dist/{pricing-refresh-7ra0g3az.js → pricing-refresh-wn1gbbnc.js} +4 -4
- package/dist/{rbac-roles-ksnmkjzf.js → rbac-roles-gzzmwqyj.js} +2 -2
- package/dist/{rbac-roles-s0esm5k6.js → rbac-roles-xz80cgy4.js} +3 -3
- package/dist/{seed-pricing-jd8zj8k7.js → seed-pricing-yr9dg75w.js} +3 -3
- package/dist/{setup-z2s4vqf3.js → setup-g15twpgb.js} +2 -2
- package/dist/{worker-xse3rpzd.js → worker-jdsz3va6.js} +32 -30
- package/openapi.json +1 -1
- package/package.json +6 -6
- package/src/be/script-credential-broker.ts +12 -26
- package/src/providers/pi-mono-adapter.ts +14 -20
- package/src/scripts-runtime/credential-broker/broker.ts +15 -4
- package/src/scripts-runtime/credential-broker/index.ts +1 -0
- package/src/scripts-runtime/credential-broker/types.ts +1 -0
- package/src/scripts-runtime/egress-secrets.ts +2 -2
- package/src/scripts-runtime/loader.ts +3 -3
- package/src/tests/credential-broker.test.ts +130 -3
- package/src/tests/internal-ai/credentials.test.ts +22 -0
- package/src/tests/pi-mono-adapter.test.ts +28 -20
- package/src/tests/scripts-runtime-secret-egress.test.ts +4 -4
- package/src/tests/workflow-engine-v2.test.ts +26 -0
- package/src/utils/internal-ai/credentials.ts +53 -5
- package/src/workflows/engine.ts +12 -2
- package/dist/{cli-sznberje.js → cli-2r7s8jhp.js} +3 -3
- package/dist/{cli-bc89my0z.js → cli-branks1w.js} +3 -3
- package/dist/{cli-mnbgv3w7.js → cli-mw3xpgwb.js} +3 -3
- package/dist/{openrouter-images-537nmn1r.js → openrouter-images-4fsrrzes.js} +3 -3
|
@@ -1,77 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
AssistantMessageEventStream
|
|
3
|
+
} from "./cli-qs7nb3zn.js";
|
|
75
4
|
|
|
76
5
|
// node_modules/@earendil-works/pi-ai/dist/api/lazy.js
|
|
77
6
|
function createSetupErrorMessage(model, error) {
|
|
@@ -94,19 +23,18 @@ function createSetupErrorMessage(model, error) {
|
|
|
94
23
|
timestamp: Date.now()
|
|
95
24
|
};
|
|
96
25
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
target.
|
|
103
|
-
}
|
|
26
|
+
function hasResult(source) {
|
|
27
|
+
return typeof source.result === "function";
|
|
28
|
+
}
|
|
29
|
+
async function forwardStream(target, source) {
|
|
30
|
+
for await (const event of source) {
|
|
31
|
+
target.push(event);
|
|
32
|
+
}
|
|
33
|
+
target.end(hasResult(source) ? await source.result() : undefined);
|
|
104
34
|
}
|
|
105
35
|
function lazyStream(model, setup) {
|
|
106
36
|
const outer = new AssistantMessageEventStream;
|
|
107
|
-
setup().then((inner) => {
|
|
108
|
-
forwardStream(outer, inner);
|
|
109
|
-
}).catch((error) => {
|
|
37
|
+
setup().then((inner) => forwardStream(outer, inner)).catch((error) => {
|
|
110
38
|
const message = createSetupErrorMessage(model, error);
|
|
111
39
|
outer.push({ type: "error", reason: "error", error: message });
|
|
112
40
|
outer.end(message);
|
|
@@ -173,6 +101,9 @@ class InMemoryCredentialStore {
|
|
|
173
101
|
async read(providerId) {
|
|
174
102
|
return this.credentials.get(providerId);
|
|
175
103
|
}
|
|
104
|
+
async list() {
|
|
105
|
+
return [...this.credentials].map(([providerId, credential]) => ({ providerId, type: credential.type }));
|
|
106
|
+
}
|
|
176
107
|
modify(providerId, fn) {
|
|
177
108
|
return this.enqueue(providerId, async () => {
|
|
178
109
|
const current = this.credentials.get(providerId);
|
|
@@ -198,10 +129,10 @@ class ModelsError extends Error {
|
|
|
198
129
|
this.code = code;
|
|
199
130
|
}
|
|
200
131
|
}
|
|
201
|
-
async function resolveProviderAuth(provider,
|
|
132
|
+
async function resolveProviderAuth(provider, credentials, authContext, overrides) {
|
|
202
133
|
const requestAuthContext = overrides?.env ? overlayEnvAuthContext(authContext, overrides.env) : authContext;
|
|
203
134
|
if (overrides?.apiKey !== undefined && provider.auth.apiKey) {
|
|
204
|
-
return resolveApiKey(requestAuthContext, provider.auth.apiKey,
|
|
135
|
+
return resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, {
|
|
205
136
|
type: "api_key",
|
|
206
137
|
key: overrides.apiKey,
|
|
207
138
|
env: overrides.env
|
|
@@ -214,11 +145,11 @@ async function resolveProviderAuth(provider, model, credentials, authContext, ov
|
|
|
214
145
|
}
|
|
215
146
|
if (stored.type === "api_key" && provider.auth.apiKey) {
|
|
216
147
|
const credential = overrides?.env ? { ...stored, env: { ...stored.env, ...overrides.env } } : stored;
|
|
217
|
-
return resolveApiKey(requestAuthContext, provider.auth.apiKey,
|
|
148
|
+
return resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, credential);
|
|
218
149
|
}
|
|
219
150
|
return;
|
|
220
151
|
}
|
|
221
|
-
return provider.auth.apiKey ? resolveApiKey(requestAuthContext, provider.auth.apiKey,
|
|
152
|
+
return provider.auth.apiKey ? resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, undefined) : undefined;
|
|
222
153
|
}
|
|
223
154
|
function overlayEnvAuthContext(base, env) {
|
|
224
155
|
return {
|
|
@@ -257,11 +188,11 @@ async function resolveStoredOAuth(credentials, providerId, oauth, stored) {
|
|
|
257
188
|
throw new ModelsError("oauth", `OAuth auth derivation failed for ${providerId}`, { cause: error });
|
|
258
189
|
}
|
|
259
190
|
}
|
|
260
|
-
async function resolveApiKey(authContext, apiKey,
|
|
191
|
+
async function resolveApiKey(authContext, apiKey, providerId, credential) {
|
|
261
192
|
try {
|
|
262
|
-
return await apiKey.resolve({
|
|
193
|
+
return await apiKey.resolve({ ctx: authContext, credential });
|
|
263
194
|
} catch (error) {
|
|
264
|
-
throw new ModelsError("auth", `API key auth failed for provider ${
|
|
195
|
+
throw new ModelsError("auth", `API key auth failed for provider ${providerId}`, { cause: error });
|
|
265
196
|
}
|
|
266
197
|
}
|
|
267
198
|
async function readCredential(credentials, providerId) {
|
|
@@ -272,13 +203,45 @@ async function readCredential(credentials, providerId) {
|
|
|
272
203
|
}
|
|
273
204
|
}
|
|
274
205
|
|
|
206
|
+
// node_modules/@earendil-works/pi-ai/dist/models-store.js
|
|
207
|
+
class InMemoryModelsStore {
|
|
208
|
+
entries = new Map;
|
|
209
|
+
async read(providerId) {
|
|
210
|
+
const entry = this.entries.get(providerId);
|
|
211
|
+
return entry ? structuredClone(entry) : undefined;
|
|
212
|
+
}
|
|
213
|
+
async write(providerId, entry) {
|
|
214
|
+
this.entries.set(providerId, structuredClone(entry));
|
|
215
|
+
}
|
|
216
|
+
async delete(providerId) {
|
|
217
|
+
this.entries.delete(providerId);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
275
221
|
// node_modules/@earendil-works/pi-ai/dist/models.js
|
|
222
|
+
function mergeHeaders(base, override) {
|
|
223
|
+
if (!base && !override)
|
|
224
|
+
return;
|
|
225
|
+
const merged = { ...base };
|
|
226
|
+
for (const [name, value] of Object.entries(override ?? {})) {
|
|
227
|
+
const lowerName = name.toLowerCase();
|
|
228
|
+
for (const existingName of Object.keys(merged)) {
|
|
229
|
+
if (existingName.toLowerCase() === lowerName)
|
|
230
|
+
delete merged[existingName];
|
|
231
|
+
}
|
|
232
|
+
merged[name] = value;
|
|
233
|
+
}
|
|
234
|
+
return merged;
|
|
235
|
+
}
|
|
236
|
+
|
|
276
237
|
class ModelsImpl {
|
|
277
238
|
providers = new Map;
|
|
278
239
|
credentials;
|
|
240
|
+
modelsStore;
|
|
279
241
|
authContext;
|
|
280
242
|
constructor(options) {
|
|
281
243
|
this.credentials = options?.credentials ?? new InMemoryCredentialStore;
|
|
244
|
+
this.modelsStore = options?.modelsStore ?? new InMemoryModelsStore;
|
|
282
245
|
this.authContext = options?.authContext ?? defaultProviderAuthContext();
|
|
283
246
|
}
|
|
284
247
|
setProvider(provider) {
|
|
@@ -318,27 +281,156 @@ class ModelsImpl {
|
|
|
318
281
|
getModel(provider, id) {
|
|
319
282
|
return this.getModels(provider).find((model) => model.id === id);
|
|
320
283
|
}
|
|
321
|
-
async refresh(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
284
|
+
async refresh(options = {}) {
|
|
285
|
+
const allowNetwork = options.allowNetwork ?? true;
|
|
286
|
+
const errors = new Map;
|
|
287
|
+
const refreshable = Array.from(this.providers.values()).filter((provider) => provider.refreshModels !== undefined);
|
|
288
|
+
await Promise.all(refreshable.map(async (provider) => {
|
|
289
|
+
if (options.signal?.aborted)
|
|
325
290
|
return;
|
|
291
|
+
const store = {
|
|
292
|
+
read: () => this.modelsStore.read(provider.id),
|
|
293
|
+
write: (entry) => this.modelsStore.write(provider.id, entry),
|
|
294
|
+
delete: () => this.modelsStore.delete(provider.id)
|
|
295
|
+
};
|
|
296
|
+
let stored;
|
|
326
297
|
try {
|
|
327
|
-
await
|
|
298
|
+
stored = await this.readCredential(provider.id);
|
|
299
|
+
const credential = await this.resolveRefreshCredential(provider, stored, allowNetwork, options.signal);
|
|
300
|
+
if (!credential)
|
|
301
|
+
return;
|
|
302
|
+
await provider.refreshModels({
|
|
303
|
+
credential,
|
|
304
|
+
store,
|
|
305
|
+
allowNetwork,
|
|
306
|
+
force: options.force,
|
|
307
|
+
signal: options.signal
|
|
308
|
+
});
|
|
328
309
|
} catch (error) {
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
|
|
310
|
+
if (!options.signal?.aborted) {
|
|
311
|
+
errors.set(provider.id, error instanceof Error ? error : new ModelsError("model_source", `Model refresh failed for ${provider.id}`, { cause: error }));
|
|
312
|
+
}
|
|
313
|
+
try {
|
|
314
|
+
await provider.refreshModels({
|
|
315
|
+
credential: stored,
|
|
316
|
+
store,
|
|
317
|
+
allowNetwork: false,
|
|
318
|
+
signal: options.signal
|
|
319
|
+
});
|
|
320
|
+
} catch {}
|
|
332
321
|
}
|
|
322
|
+
}));
|
|
323
|
+
return { aborted: options.signal?.aborted ?? false, errors };
|
|
324
|
+
}
|
|
325
|
+
async resolveRefreshCredential(provider, stored, allowNetwork, signal) {
|
|
326
|
+
if (stored?.type === "oauth") {
|
|
327
|
+
const oauth = provider.auth.oauth;
|
|
328
|
+
if (!oauth)
|
|
329
|
+
return;
|
|
330
|
+
if (!allowNetwork || Date.now() < stored.expires)
|
|
331
|
+
return stored;
|
|
332
|
+
if (signal?.aborted)
|
|
333
|
+
return;
|
|
334
|
+
const post = await this.credentials.modify(provider.id, async (current) => {
|
|
335
|
+
if (current?.type !== "oauth" || Date.now() < current.expires)
|
|
336
|
+
return;
|
|
337
|
+
return oauth.refresh(current, signal);
|
|
338
|
+
});
|
|
339
|
+
return post?.type === "oauth" ? post : undefined;
|
|
340
|
+
}
|
|
341
|
+
const apiKey = provider.auth.apiKey;
|
|
342
|
+
if (!apiKey)
|
|
333
343
|
return;
|
|
344
|
+
const credential = stored?.type === "api_key" ? stored : undefined;
|
|
345
|
+
const result = await apiKey.resolve({ ctx: this.authContext, credential });
|
|
346
|
+
if (!result)
|
|
347
|
+
return;
|
|
348
|
+
return { type: "api_key", key: result.auth.apiKey, env: result.env };
|
|
349
|
+
}
|
|
350
|
+
async readCredential(providerId) {
|
|
351
|
+
try {
|
|
352
|
+
return await this.credentials.read(providerId);
|
|
353
|
+
} catch (error) {
|
|
354
|
+
throw new ModelsError("auth", `Credential store read failed for ${providerId}`, { cause: error });
|
|
334
355
|
}
|
|
335
|
-
await Promise.allSettled(Array.from(this.providers.values(), async (entry) => entry.refreshModels?.()));
|
|
336
356
|
}
|
|
337
|
-
async
|
|
338
|
-
|
|
357
|
+
async checkProviderAuth(provider, credential) {
|
|
358
|
+
if (credential?.type === "oauth") {
|
|
359
|
+
return provider.auth.oauth ? { source: "OAuth", type: "oauth" } : undefined;
|
|
360
|
+
}
|
|
361
|
+
const apiKey = provider.auth.apiKey;
|
|
362
|
+
if (!apiKey)
|
|
363
|
+
return;
|
|
364
|
+
if (apiKey.check) {
|
|
365
|
+
try {
|
|
366
|
+
return await apiKey.check({
|
|
367
|
+
ctx: this.authContext,
|
|
368
|
+
credential: credential?.type === "api_key" ? credential : undefined
|
|
369
|
+
});
|
|
370
|
+
} catch (error) {
|
|
371
|
+
throw new ModelsError("auth", `API key auth check failed for provider ${provider.id}`, { cause: error });
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const resolution = await resolveProviderAuth(provider, this.credentials, this.authContext);
|
|
375
|
+
return resolution ? { source: resolution.source, type: "api_key" } : undefined;
|
|
376
|
+
}
|
|
377
|
+
async checkAuth(providerId) {
|
|
378
|
+
const provider = this.providers.get(providerId);
|
|
379
|
+
if (!provider)
|
|
380
|
+
return;
|
|
381
|
+
return this.checkProviderAuth(provider, await this.readCredential(providerId));
|
|
382
|
+
}
|
|
383
|
+
async getAvailable(providerId) {
|
|
384
|
+
const providers = providerId ? [this.providers.get(providerId)].filter((entry) => entry !== undefined) : this.getProviders();
|
|
385
|
+
const checks = await Promise.all(providers.map(async (provider) => {
|
|
386
|
+
const credential = await this.readCredential(provider.id);
|
|
387
|
+
return { provider, credential, auth: await this.checkProviderAuth(provider, credential) };
|
|
388
|
+
}));
|
|
389
|
+
return checks.flatMap(({ provider, credential, auth }) => {
|
|
390
|
+
if (!auth)
|
|
391
|
+
return [];
|
|
392
|
+
const models = provider.getModels();
|
|
393
|
+
return provider.filterModels?.(models, credential) ?? models;
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
async getAuth(providerOrModel, overrides) {
|
|
397
|
+
const providerId = typeof providerOrModel === "string" ? providerOrModel : providerOrModel.provider;
|
|
398
|
+
const provider = this.providers.get(providerId);
|
|
339
399
|
if (!provider)
|
|
340
400
|
return;
|
|
341
|
-
|
|
401
|
+
const result = await resolveProviderAuth(provider, this.credentials, this.authContext, overrides);
|
|
402
|
+
if (!result || typeof providerOrModel === "string" || !providerOrModel.headers)
|
|
403
|
+
return result;
|
|
404
|
+
return {
|
|
405
|
+
...result,
|
|
406
|
+
auth: {
|
|
407
|
+
...result.auth,
|
|
408
|
+
headers: mergeHeaders(result.auth.headers, providerOrModel.headers)
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
async login(providerId, type, interaction) {
|
|
413
|
+
const provider = this.providers.get(providerId);
|
|
414
|
+
if (!provider)
|
|
415
|
+
throw new ModelsError("provider", `Unknown provider: ${providerId}`);
|
|
416
|
+
const method = type === "oauth" ? provider.auth.oauth : provider.auth.apiKey;
|
|
417
|
+
if (!method?.login) {
|
|
418
|
+
throw new ModelsError("auth", `${provider.name} does not support ${type} login`);
|
|
419
|
+
}
|
|
420
|
+
const credential = await method.login(interaction);
|
|
421
|
+
try {
|
|
422
|
+
await this.credentials.modify(providerId, async () => credential);
|
|
423
|
+
} catch (error) {
|
|
424
|
+
throw new ModelsError("auth", `Credential store modify failed for ${providerId}`, { cause: error });
|
|
425
|
+
}
|
|
426
|
+
return credential;
|
|
427
|
+
}
|
|
428
|
+
async logout(providerId) {
|
|
429
|
+
try {
|
|
430
|
+
await this.credentials.delete(providerId);
|
|
431
|
+
} catch (error) {
|
|
432
|
+
throw new ModelsError("auth", `Credential store delete failed for ${providerId}`, { cause: error });
|
|
433
|
+
}
|
|
342
434
|
}
|
|
343
435
|
requireProvider(model) {
|
|
344
436
|
const provider = this.providers.get(model.provider);
|
|
@@ -348,18 +440,23 @@ class ModelsImpl {
|
|
|
348
440
|
return provider;
|
|
349
441
|
}
|
|
350
442
|
async applyAuth(model, options) {
|
|
351
|
-
|
|
443
|
+
this.requireProvider(model);
|
|
444
|
+
const resolution = await this.getAuth(model, {
|
|
352
445
|
apiKey: options?.apiKey,
|
|
353
446
|
env: options?.env
|
|
354
447
|
});
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
const
|
|
448
|
+
if (!resolution) {
|
|
449
|
+
throw new ModelsError("auth", `Provider is not configured: ${model.provider}`);
|
|
450
|
+
}
|
|
451
|
+
const auth = resolution.auth;
|
|
359
452
|
const apiKey = options?.apiKey ?? auth.apiKey;
|
|
360
|
-
|
|
453
|
+
let headers = mergeHeaders(auth.headers, options?.headers);
|
|
454
|
+
if (options?.transformHeaders)
|
|
455
|
+
headers = await options.transformHeaders(headers ?? {});
|
|
361
456
|
const env = resolution.env || options?.env ? { ...resolution.env ?? {}, ...options?.env ?? {} } : undefined;
|
|
362
|
-
const
|
|
457
|
+
const requestModel = auth.baseUrl ? { ...model, baseUrl: auth.baseUrl } : model;
|
|
458
|
+
const { transformHeaders: _transformHeaders, ...providerOptions } = options ?? {};
|
|
459
|
+
const requestOptions = { ...providerOptions, apiKey, headers, env };
|
|
363
460
|
return { requestModel, requestOptions };
|
|
364
461
|
}
|
|
365
462
|
stream(model, context, options) {
|
|
@@ -387,9 +484,21 @@ function createModels(options) {
|
|
|
387
484
|
return new ModelsImpl(options);
|
|
388
485
|
}
|
|
389
486
|
function createProvider(input) {
|
|
390
|
-
|
|
487
|
+
const baselineModels = input.models;
|
|
488
|
+
let dynamicModels = [];
|
|
391
489
|
let inflightRefresh;
|
|
392
|
-
const
|
|
490
|
+
const fetchModels = input.fetchModels;
|
|
491
|
+
const currentModels = () => {
|
|
492
|
+
const merged = [...baselineModels];
|
|
493
|
+
for (const model of dynamicModels) {
|
|
494
|
+
const index = merged.findIndex((entry) => entry.id === model.id);
|
|
495
|
+
if (index >= 0)
|
|
496
|
+
merged[index] = model;
|
|
497
|
+
else
|
|
498
|
+
merged.push(model);
|
|
499
|
+
}
|
|
500
|
+
return merged;
|
|
501
|
+
};
|
|
393
502
|
const single = typeof input.api.stream === "function" ? input.api : undefined;
|
|
394
503
|
const byApi = single ? undefined : input.api;
|
|
395
504
|
const apiFor = (model) => single ?? byApi?.[model.api];
|
|
@@ -408,17 +517,28 @@ function createProvider(input) {
|
|
|
408
517
|
baseUrl: input.baseUrl,
|
|
409
518
|
headers: input.headers,
|
|
410
519
|
auth: input.auth,
|
|
411
|
-
getModels:
|
|
412
|
-
refreshModels:
|
|
520
|
+
getModels: currentModels,
|
|
521
|
+
refreshModels: fetchModels ? (context) => {
|
|
413
522
|
inflightRefresh ??= (async () => {
|
|
414
523
|
try {
|
|
415
|
-
|
|
524
|
+
const stored = await context.store.read();
|
|
525
|
+
if (stored) {
|
|
526
|
+
dynamicModels = stored.models.filter((model) => model.provider === input.id).map((model) => model);
|
|
527
|
+
}
|
|
528
|
+
if (!context.allowNetwork || context.signal?.aborted)
|
|
529
|
+
return;
|
|
530
|
+
const refreshed = await fetchModels(context);
|
|
531
|
+
if (context.signal?.aborted)
|
|
532
|
+
return;
|
|
533
|
+
dynamicModels = refreshed;
|
|
534
|
+
await context.store.write({ models: refreshed, checkedAt: Date.now() });
|
|
416
535
|
} finally {
|
|
417
536
|
inflightRefresh = undefined;
|
|
418
537
|
}
|
|
419
538
|
})();
|
|
420
539
|
return inflightRefresh;
|
|
421
540
|
} : undefined,
|
|
541
|
+
filterModels: input.filterModels,
|
|
422
542
|
stream: (model, context, options) => dispatch(model, (streams) => streams.stream(model, context, options)),
|
|
423
543
|
streamSimple: (model, context, options) => dispatch(model, (streams) => streams.streamSimple(model, context, options))
|
|
424
544
|
};
|
|
@@ -427,16 +547,25 @@ function hasApi(model, api) {
|
|
|
427
547
|
return model.api === api;
|
|
428
548
|
}
|
|
429
549
|
function calculateCost(model, usage) {
|
|
550
|
+
const inputTokens = usage.input + usage.cacheRead + usage.cacheWrite;
|
|
551
|
+
let rates = model.cost;
|
|
552
|
+
let matchedThreshold = -1;
|
|
553
|
+
for (const tier of model.cost.tiers ?? []) {
|
|
554
|
+
if (inputTokens > tier.inputTokensAbove && tier.inputTokensAbove > matchedThreshold) {
|
|
555
|
+
rates = tier;
|
|
556
|
+
matchedThreshold = tier.inputTokensAbove;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
430
559
|
const longWrite = usage.cacheWrite1h ?? 0;
|
|
431
560
|
const shortWrite = usage.cacheWrite - longWrite;
|
|
432
|
-
usage.cost.input =
|
|
433
|
-
usage.cost.output =
|
|
434
|
-
usage.cost.cacheRead =
|
|
435
|
-
usage.cost.cacheWrite = (
|
|
561
|
+
usage.cost.input = rates.input / 1e6 * usage.input;
|
|
562
|
+
usage.cost.output = rates.output / 1e6 * usage.output;
|
|
563
|
+
usage.cost.cacheRead = rates.cacheRead / 1e6 * usage.cacheRead;
|
|
564
|
+
usage.cost.cacheWrite = (rates.cacheWrite * shortWrite + rates.input * 2 * longWrite) / 1e6;
|
|
436
565
|
usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
|
|
437
566
|
return usage.cost;
|
|
438
567
|
}
|
|
439
|
-
var EXTENDED_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
568
|
+
var EXTENDED_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
440
569
|
function getSupportedThinkingLevels(model) {
|
|
441
570
|
if (!model.reasoning)
|
|
442
571
|
return ["off"];
|
|
@@ -444,7 +573,7 @@ function getSupportedThinkingLevels(model) {
|
|
|
444
573
|
const mapped = model.thinkingLevelMap?.[level];
|
|
445
574
|
if (mapped === null)
|
|
446
575
|
return false;
|
|
447
|
-
if (level === "xhigh")
|
|
576
|
+
if (level === "xhigh" || level === "max")
|
|
448
577
|
return mapped !== undefined;
|
|
449
578
|
return true;
|
|
450
579
|
});
|
|
@@ -474,4 +603,4 @@ function modelsAreEqual(a, b) {
|
|
|
474
603
|
return a.id === b.id && a.provider === b.provider;
|
|
475
604
|
}
|
|
476
605
|
|
|
477
|
-
export {
|
|
606
|
+
export { lazyStream, lazyApi, defaultProviderAuthContext, InMemoryCredentialStore, ModelsError, resolveProviderAuth, InMemoryModelsStore, createModels, createProvider, hasApi, calculateCost, getSupportedThinkingLevels, clampThinkingLevel, modelsAreEqual };
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getScriptApiTypes,
|
|
3
3
|
getScriptMcpTypes,
|
|
4
4
|
require_typescript
|
|
5
|
-
} from "./cli-
|
|
5
|
+
} from "./cli-7h1sce5x.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-
|
|
14
|
+
} from "./cli-rp04sjbc.js";
|
|
15
15
|
import {
|
|
16
16
|
init_secret_scrubber,
|
|
17
17
|
scrubSecrets
|
|
@@ -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.
|
|
10
|
+
version: "1.119.5",
|
|
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.
|
|
151
|
-
"@earendil-works/pi-ai": "^0.
|
|
152
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
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.
|
|
157
|
-
"@opencode-ai/sdk": "^1.
|
|
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
|
} from "./cli-jkhwmmgg.js";
|
|
4
4
|
import {
|
|
5
5
|
embedScript
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-9rrpjvan.js";
|
|
7
7
|
import {
|
|
8
8
|
calculatePKCECodeChallenge,
|
|
9
9
|
generateRandomCodeVerifier,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
init_date_utils,
|
|
23
23
|
init_db,
|
|
24
24
|
normalizeDateRequired
|
|
25
|
-
} from "./cli-
|
|
25
|
+
} from "./cli-rp04sjbc.js";
|
|
26
26
|
import {
|
|
27
27
|
init_zod
|
|
28
28
|
} from "./cli-bw80ck94.js";
|
|
@@ -169081,14 +169081,16 @@ function bindingHasPlaceholder(binding) {
|
|
|
169081
169081
|
|
|
169082
169082
|
class CredentialBroker {
|
|
169083
169083
|
store;
|
|
169084
|
-
|
|
169084
|
+
resolveConfigCredential;
|
|
169085
169085
|
defaults;
|
|
169086
|
-
|
|
169086
|
+
resolveOAuthCredential;
|
|
169087
|
+
constructor(store, resolveConfigCredential, defaults = [], resolveOAuthCredential) {
|
|
169087
169088
|
this.store = store;
|
|
169088
|
-
this.
|
|
169089
|
+
this.resolveConfigCredential = resolveConfigCredential;
|
|
169089
169090
|
this.defaults = defaults;
|
|
169091
|
+
this.resolveOAuthCredential = resolveOAuthCredential;
|
|
169090
169092
|
}
|
|
169091
|
-
resolveBindings(context) {
|
|
169093
|
+
async resolveBindings(context) {
|
|
169092
169094
|
const merged = [...this.defaults, ...this.store.listActiveBindings(context)];
|
|
169093
169095
|
const resolved = [];
|
|
169094
169096
|
const seen = new Set;
|
|
@@ -169097,7 +169099,7 @@ class CredentialBroker {
|
|
|
169097
169099
|
continue;
|
|
169098
169100
|
if (!bindingHasPlaceholder(binding))
|
|
169099
169101
|
continue;
|
|
169100
|
-
const value = this.
|
|
169102
|
+
const value = binding.authKind === "oauth" ? binding.oauthProvider ? await this.resolveOAuthCredential?.(binding.oauthProvider) : undefined : this.resolveConfigCredential(binding.configKey);
|
|
169101
169103
|
if (!value)
|
|
169102
169104
|
continue;
|
|
169103
169105
|
const dedupeKey = [
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
getEmbeddingProvider,
|
|
5
5
|
init_embedding,
|
|
6
6
|
serializeEmbedding
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-65anxt77.js";
|
|
8
8
|
import {
|
|
9
9
|
getDb,
|
|
10
10
|
init_db
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-rp04sjbc.js";
|
|
12
12
|
import {
|
|
13
13
|
init_secret_scrubber,
|
|
14
14
|
scrubSecrets
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
getTaskById,
|
|
28
28
|
init_db,
|
|
29
29
|
setSlackMessageTracking
|
|
30
|
-
} from "./cli-
|
|
30
|
+
} from "./cli-rp04sjbc.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-
|
|
55077
|
-
const { registerCommandHandler } = await import("./commands-
|
|
55078
|
-
const { registerActionHandlers } = await import("./actions-
|
|
55076
|
+
const { registerMessageHandler } = await import("./handlers-jtjhcfec.js");
|
|
55077
|
+
const { registerCommandHandler } = await import("./commands-jc6a4g7b.js");
|
|
55078
|
+
const { registerActionHandlers } = await import("./actions-xqb0w6as.js");
|
|
55079
55079
|
registerMessageHandler(app);
|
|
55080
55080
|
registerCommandHandler(app);
|
|
55081
55081
|
registerActionHandlers(app);
|
|
55082
|
-
const { createAssistant } = await import("./assistant-
|
|
55082
|
+
const { createAssistant } = await import("./assistant-54jkns28.js");
|
|
55083
55083
|
app.assistant(createAssistant());
|
|
55084
55084
|
return app;
|
|
55085
55085
|
}
|