@desplega.ai/agent-swarm 1.136.0 → 1.138.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 +12 -3
- package/dist/acp-adapter-6nttxe2q.js +4787 -0
- package/dist/{actions-agcbc8nd.js → actions-z9dzgh3f.js} +7 -8
- package/dist/{app-g2s78xya.js → app-wb6bc7tt.js} +4 -5
- package/dist/{assistant-yd3jkb9d.js → assistant-08pd6pgy.js} +9 -10
- package/dist/{boot-reembed-6spqw4q0.js → boot-reembed-hstr4e2c.js} +4 -4
- package/dist/{boot-reembed-b22s9w5x.js → boot-reembed-y7p7qjbf.js} +5 -5
- package/dist/{boot-scrub-logs-6h3cqkc0.js → boot-scrub-logs-azbnxwhn.js} +3 -3
- package/dist/{claude-adapter-ng5y8zd7.js → claude-adapter-rwaq6eda.js} +10 -9
- package/dist/{claude-managed-adapter-5zr3n86v.js → claude-managed-adapter-vtseey1x.js} +3 -3
- package/dist/{cli-qckgdqmr.js → cli-005yr57a.js} +2 -2
- package/dist/{cli-54ht104h.js → cli-0cka8dnm.js} +3 -3
- package/dist/{cli-gpdtxzar.js → cli-23cpnqk9.js} +1 -1
- package/dist/{cli-qhfkxrpg.js → cli-2ypjdmqg.js} +223 -474
- package/dist/{cli-bnq8h7ea.js → cli-3719ggyf.js} +17 -10
- package/dist/cli-390sgxn5.js +257 -0
- package/dist/{cli-z6e8eqrm.js → cli-47esr8ht.js} +2 -2
- package/dist/{cli-jjhnma34.js → cli-4jaj24py.js} +248 -101
- package/dist/{cli-6gwgzdgw.js → cli-69377c2a.js} +5 -5
- package/dist/{cli-ads0hfw2.js → cli-6v4d8r8c.js} +205 -75
- package/dist/{cli-mgef08pc.js → cli-8rtyss6g.js} +1 -1
- package/dist/{cli-35jknh9e.js → cli-9w7vsmbm.js} +5 -5
- package/dist/{cli-m3z53bed.js → cli-b4zdc3x6.js} +1 -1
- package/dist/{cli-fpjmcbhz.js → cli-ba87cw29.js} +4 -4
- package/dist/{cli-4gzv54ss.js → cli-bzk75kdc.js} +43 -11
- package/dist/{cli-d5ygfv18.js → cli-cywkhzqs.js} +35 -11
- package/dist/{cli-0crn5kaz.js → cli-d62cd9qs.js} +16 -4
- package/dist/{cli-5bnz1t86.js → cli-f9skf1v7.js} +51 -7
- package/dist/{cli-06ghj6pe.js → cli-fytpjraz.js} +4 -4
- package/dist/{cli-j7qp8gtf.js → cli-h7c5dam1.js} +16 -11
- package/dist/{cli-4r4jkqep.js → cli-kkn46gfr.js} +9 -3
- package/dist/{cli-tmn19cdz.js → cli-kq9htgbr.js} +415 -62
- package/dist/{cli-8v57p983.js → cli-pkmqqxp8.js} +45 -69
- package/dist/{cli-84vrhesc.js → cli-qf34ej1d.js} +1 -1
- package/dist/{cli-v3qda694.js → cli-rnyttbh0.js} +0 -5
- package/dist/cli-rx5cxzn2.js +7 -0
- package/dist/{cli-cw70hymf.js → cli-s25avqg9.js} +2 -0
- package/dist/{cli-tee8w7tq.js → cli-s6t1qv67.js} +15 -10
- package/dist/{cli-68vayryq.js → cli-tb4csb08.js} +2 -2
- package/dist/{cli-y16cesaq.js → cli-vy48y9bx.js} +2 -2
- package/dist/{cli-3y553gws.js → cli-y294regh.js} +1 -1
- package/dist/{cli-spf767vc.js → cli-y43043ws.js} +1 -1
- package/dist/{cli-hz5hp6wn.js → cli-yh2eybyt.js} +1 -1
- package/dist/{cli-edwrx42s.js → cli-zmyxt25p.js} +5 -5
- package/dist/cli.js +40 -18
- package/dist/{codex-adapter-kw11ps3j.js → codex-adapter-yzep6mvb.js} +7 -6
- package/dist/{codex-session-runner-sffb69v7.js → codex-session-runner-25e8tn72.js} +7 -6
- package/dist/{commands-0xxp4tz8.js → commands-0vv72d6a.js} +3 -3
- package/dist/{db-0npp39zd.js → db-x61ncfa1.js} +19 -3
- package/dist/{google-generative-ai-6xxdj4t3.js → google-generative-ai-zyhy3dab.js} +1 -1
- package/dist/{google-vertex-zma18wb0.js → google-vertex-t25h65yd.js} +1 -1
- package/dist/{handlers-5p7a1jx6.js → handlers-fwdcaahf.js} +9 -10
- package/dist/{hook-jjpxn4se.js → hook-mpwfgynm.js} +6 -5
- package/dist/{hook-hpefr0a8.js → hook-x18504ja.js} +8 -7
- package/dist/{http-wfp33653.js → http-83m6qdds.js} +590 -192
- package/dist/{index-pe58mf1r.js → index-1nsdwvn5.js} +2 -1
- package/dist/{index-17h657rg.js → index-38f98ck3.js} +9 -9
- package/dist/{index-m2p7ctyh.js → index-7kxvtd38.js} +24 -12
- package/dist/{index-racb4wfq.js → index-a4naswjn.js} +23 -10
- package/dist/{index-p13cfsc2.js → index-agykc6k2.js} +2 -1
- package/dist/{index-zh66wm65.js → index-dawtzfhw.js} +22 -9
- package/dist/{keepalive-wxjd633a.js → keepalive-y0m8g5wn.js} +5 -5
- package/dist/{lead-359ec2z0.js → lead-ka18ef6a.js} +36 -36
- package/dist/{maintenance-rr03qjtb.js → maintenance-x585p56c.js} +5 -5
- package/dist/{oauth-refresh-sweep-jwj22yb8.js → oauth-refresh-sweep-kdm9vj7a.js} +4 -4
- package/dist/{onboard-asnhchcv.js → onboard-5v229nvt.js} +664 -248
- package/dist/{opencode-adapter-sx38y7f7.js → opencode-adapter-46nnmnvv.js} +3 -3
- package/dist/{otel-impl-54cra6mw.js → otel-impl-k47aj4sd.js} +73 -4
- package/dist/{pi-mono-adapter-29g7axgj.js → pi-mono-adapter-wawfj09v.js} +42 -40
- package/dist/{pricing-refresh-mkyy7c2y.js → pricing-refresh-ky2gjp05.js} +5 -5
- package/dist/{rbac-roles-kb3afm95.js → rbac-roles-0j0f7s8r.js} +4 -4
- package/dist/{rbac-roles-ak56tr75.js → rbac-roles-az4wc15e.js} +3 -3
- package/dist/{render-v2-434asg49.js → render-v2-seyxq61z.js} +4 -5
- package/dist/{seed-pricing-nbmd7ah8.js → seed-pricing-fev611hx.js} +4 -4
- package/dist/{setup-wh4qmjs4.js → setup-hy404zwh.js} +2 -2
- package/dist/{worker-j1d27tjv.js → worker-g1j5hn16.js} +36 -36
- package/openapi.json +197 -27
- package/package.json +9 -3
- package/src/be/db-client.ts +58 -5
- package/src/be/db-retention.ts +550 -121
- package/src/be/db.ts +367 -55
- package/src/be/memory/raters/retrieval.ts +40 -0
- package/src/be/migrations/140_approval_request_cancelled_status.sql +64 -0
- package/src/be/pricing-normalize.ts +3 -0
- package/src/be/script-connections.ts +26 -6
- package/src/be/seed-pricing.ts +18 -8
- package/src/be/swarm-config-guard.ts +33 -0
- package/src/cli.tsx +20 -1
- package/src/commands/onboard/compose-generator.ts +63 -7
- package/src/commands/onboard/env-generator.ts +32 -4
- package/src/commands/onboard/manifest.ts +4 -1
- package/src/commands/onboard/non-interactive.ts +159 -0
- package/src/commands/onboard/steps/generate.tsx +1 -34
- package/src/commands/onboard/steps/harness-credentials.tsx +181 -1
- package/src/commands/onboard/steps/harness.tsx +20 -6
- package/src/commands/onboard/steps/review.tsx +3 -2
- package/src/commands/onboard/types.ts +48 -1
- package/src/commands/onboard.tsx +18 -13
- package/src/commands/provider-credentials.ts +17 -3
- package/src/commands/runner.ts +1 -0
- package/src/heartbeat/heartbeat.ts +47 -7
- package/src/http/approval-requests.ts +53 -8
- package/src/http/index.ts +9 -1
- package/src/http/mcp-servers.ts +2 -0
- package/src/http/memory.ts +27 -1
- package/src/http/oauth-callback.ts +33 -0
- package/src/http/repos.ts +6 -0
- package/src/http/script-connections.ts +77 -0
- package/src/http/session-data.ts +5 -1
- package/src/http/stats.ts +21 -30
- package/src/http/tasks.ts +10 -0
- package/src/oauth/presets.ts +29 -0
- package/src/otel-impl.ts +96 -1
- package/src/otel.ts +34 -0
- package/src/prompts/memories.ts +2 -2
- package/src/providers/acp-adapter.ts +325 -0
- package/src/providers/acp-swarm-events.ts +113 -0
- package/src/providers/acp-targets.ts +103 -0
- package/src/providers/claude-managed-models.ts +17 -1
- package/src/providers/codex-adapter.ts +3 -3
- package/src/providers/codex-oauth/auth-json-fs.ts +2 -2
- package/src/providers/codex-oauth/home.ts +13 -0
- package/src/providers/index.ts +5 -1
- package/src/providers/types.ts +1 -1
- package/src/server-user.ts +1 -0
- package/src/slack/app.ts +5 -1
- package/src/tasks/worker-follow-up.ts +78 -7
- package/src/telemetry.ts +151 -0
- package/src/tests/acp-adapter.test.ts +192 -0
- package/src/tests/acp-swarm-events.test.ts +132 -0
- package/src/tests/agents-list-model-display.test.ts +20 -0
- package/src/tests/approval-cancellation-migration.test.ts +134 -0
- package/src/tests/approval-requests.test.ts +456 -2
- package/src/tests/apps-spike2.test.ts +4 -1
- package/src/tests/apps-sync-engine.test.ts +22 -18
- package/src/tests/claude-managed-adapter.test.ts +12 -0
- package/src/tests/codex-oauth-auth-json-fs.test.ts +19 -0
- package/src/tests/connection-embedded-auth.test.ts +4 -1
- package/src/tests/context-window.test.ts +2 -0
- package/src/tests/credential-check.test.ts +6 -0
- package/src/tests/db-client-busy-retry.test.ts +18 -0
- package/src/tests/db-client.test.ts +23 -0
- package/src/tests/db-retention-telemetry.test.ts +569 -0
- package/src/tests/db-retention.test.ts +456 -117
- package/src/tests/heartbeat.test.ts +140 -0
- package/src/tests/memory-http-recall-gating.test.ts +120 -13
- package/src/tests/memory-store.test.ts +41 -0
- package/src/tests/migration-046-budgets.test.ts +27 -5
- package/src/tests/oauth-presets.test.ts +17 -5
- package/src/tests/onboard-compose.test.ts +99 -0
- package/src/tests/onboard-env.test.ts +43 -0
- package/src/tests/onboard-manifest.test.ts +17 -1
- package/src/tests/onboard-non-interactive.test.ts +89 -0
- package/src/tests/pool-affinity.test.ts +100 -0
- package/src/tests/promote-draft-task-route.test.ts +32 -1
- package/src/tests/sandbox-spawn-test-helpers.ts +3 -0
- package/src/tests/sandboxed-process.test.ts +2 -2
- package/src/tests/schedule-target-type.test.ts +6 -3
- package/src/tests/script-connections-http.test.ts +4 -3
- package/src/tests/script-connections.test.ts +6 -1
- package/src/tests/script-workflows-runtime-e2e.test.ts +36 -28
- package/src/tests/scripts-external-api.test.ts +8 -5
- package/src/tests/scripts-http.test.ts +6 -3
- package/src/tests/scripts-mcp-e2e.test.ts +65 -60
- package/src/tests/scripts-retention.test.ts +6 -3
- package/src/tests/scripts-runtime-identity.test.ts +4 -2
- package/src/tests/scripts-runtime.test.ts +18 -16
- package/src/tests/session-costs-model-key-normalize.test.ts +2 -0
- package/src/tests/slack-read-boundaries.test.ts +3 -1
- package/src/tests/task-lifecycle-telemetry.test.ts +1 -0
- package/src/tests/task-tools-ctx.test.ts +88 -1
- package/src/tests/telemetry-init.test.ts +61 -0
- package/src/tests/tool-annotations.test.ts +4 -1
- package/src/tests/vendored-openapi.test.ts +15 -2
- package/src/tests/workflow-e2e.test.ts +4 -1
- package/src/tests/workflow-engine-v2.test.ts +5 -2
- package/src/tests/workflow-executors.test.ts +24 -19
- package/src/tests/workflow-http-v2.test.ts +17 -2
- package/src/tests/workflow-llm.test.ts +57 -0
- package/src/tests/workflow-retry-v2.test.ts +142 -1
- package/src/tests/workflow-swarm-script.test.ts +20 -17
- package/src/tools/get-task-details.ts +1 -0
- package/src/tools/mcp-servers/mcp-server-create.ts +7 -1
- package/src/tools/memory-search.ts +27 -2
- package/src/tools/send-task.ts +28 -10
- package/src/tools/task-action.ts +13 -5
- package/src/types.ts +31 -2
- package/src/utils/context-window.ts +2 -0
- package/src/workflows/approval-notifications.ts +72 -0
- package/src/workflows/checkpoint.ts +16 -9
- package/src/workflows/completed-step-routing.ts +31 -0
- package/src/workflows/engine.ts +59 -43
- package/src/workflows/executors/human-in-the-loop.ts +38 -4
- package/src/workflows/executors/raw-llm.ts +8 -6
- package/src/workflows/executors/validate.ts +6 -5
- package/src/workflows/executors/workflow-llm.ts +35 -0
- package/src/workflows/resume.ts +90 -13
- package/src/workflows/retry-poller.ts +8 -1
- package/vendored-openapi/README.md +4 -2
- package/vendored-openapi/manifest.json +33 -0
- package/vendored-openapi/microsoft-graph.json +781 -0
- package/dist/cli-5tnr64pm.js +0 -29
- package/dist/{anthropic-messages-pm7pp23c.js → anthropic-messages-tvgm75yc.js} +3 -3
- package/dist/{azure-openai-responses-cwesc845.js → azure-openai-responses-hed7waek.js} +4 -4
- package/dist/{cli-s9gpxh9q.js → cli-5kmzp1wx.js} +0 -0
- package/dist/{cli-s73zwwqn.js → cli-xjx3fbtn.js} +4 -4
- package/dist/{openai-codex-responses-xxca1qr1.js → openai-codex-responses-gv3n8rg0.js} +3 -3
- package/dist/{openai-completions-yzftqrft.js → openai-completions-dkrj9433.js} +8 -8
- package/dist/{openai-responses-e4dcwm9g.js → openai-responses-spk6t7kh.js} +11 -11
- package/dist/{openrouter-images-asqqnbvh.js → openrouter-images-71hthwh9.js} +3 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
McpHttpClient
|
|
3
3
|
} from "./cli-epan13p1.js";
|
|
4
|
+
import {
|
|
5
|
+
embedScript
|
|
6
|
+
} from "./cli-005yr57a.js";
|
|
4
7
|
import {
|
|
5
8
|
getApiKey
|
|
6
9
|
} from "./cli-f14fvzag.js";
|
|
7
|
-
import {
|
|
8
|
-
embedScript
|
|
9
|
-
} from "./cli-qckgdqmr.js";
|
|
10
10
|
import {
|
|
11
11
|
calculatePKCECodeChallenge,
|
|
12
12
|
ensureAuthorizationTokenOrThrow,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
oauthAppRowToProviderConfig,
|
|
19
19
|
updateAuthorizationTokens,
|
|
20
20
|
upsertAuthorization
|
|
21
|
-
} from "./cli-
|
|
21
|
+
} from "./cli-b4zdc3x6.js";
|
|
22
22
|
import {
|
|
23
23
|
CredentialBroker,
|
|
24
24
|
DEFAULT_CREDENTIAL_BINDINGS,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
normalizeDateRequired,
|
|
40
40
|
placeholderForConfigKey,
|
|
41
41
|
upsertSwarmConfig
|
|
42
|
-
} from "./cli-
|
|
42
|
+
} from "./cli-kq9htgbr.js";
|
|
43
43
|
import {
|
|
44
44
|
init_env_flag,
|
|
45
45
|
isEnvFlagEnabled
|
|
@@ -47,6 +47,9 @@ import {
|
|
|
47
47
|
import {
|
|
48
48
|
init_zod
|
|
49
49
|
} from "./cli-s35981d0.js";
|
|
50
|
+
import {
|
|
51
|
+
exports_external
|
|
52
|
+
} from "./cli-pqv5gvyf.js";
|
|
50
53
|
import {
|
|
51
54
|
init_secret_scrubber,
|
|
52
55
|
refreshSecretScrubberCache,
|
|
@@ -54,9 +57,6 @@ import {
|
|
|
54
57
|
scrubObject,
|
|
55
58
|
scrubSecrets
|
|
56
59
|
} from "./cli-mkq1rk7b.js";
|
|
57
|
-
import {
|
|
58
|
-
exports_external
|
|
59
|
-
} from "./cli-pqv5gvyf.js";
|
|
60
60
|
import {
|
|
61
61
|
__commonJS,
|
|
62
62
|
__require,
|
|
@@ -170054,9 +170054,16 @@ async function disableCredentialBinding(id, userId) {
|
|
|
170054
170054
|
const row = await getDbClient().get(`UPDATE script_credential_bindings SET active = 0, updated_at = ?, updated_by = ? WHERE id = ? RETURNING *`, [new Date().toISOString(), userId ?? null, id]);
|
|
170055
170055
|
return row ? bindingFromRow(row) : null;
|
|
170056
170056
|
}
|
|
170057
|
+
function filterScriptConnections(rows, context) {
|
|
170058
|
+
return rows.map(connectionFromRow).filter((connection) => !context?.kind || connection.kind === context.kind).filter((connection) => context?.includeDisabled || connection.enabled).filter((connection) => !context || context.allScopes === true || applies(connection.scope, connection.scopeId, context));
|
|
170059
|
+
}
|
|
170057
170060
|
function listScriptConnections(context) {
|
|
170058
170061
|
const rows = getDb().prepare("SELECT * FROM script_connections ORDER BY slug ASC").all();
|
|
170059
|
-
return rows
|
|
170062
|
+
return filterScriptConnections(rows, context);
|
|
170063
|
+
}
|
|
170064
|
+
async function listScriptConnectionsAsync(context) {
|
|
170065
|
+
const rows = await getDbClient().query("SELECT * FROM script_connections ORDER BY slug ASC");
|
|
170066
|
+
return filterScriptConnections(rows, context);
|
|
170060
170067
|
}
|
|
170061
170068
|
async function getScriptConnectionById(id) {
|
|
170062
170069
|
const row = await getDbClient().get("SELECT * FROM script_connections WHERE id = ?", [id]);
|
|
@@ -172025,4 +172032,4 @@ async function buildScriptCredentialBindings(input) {
|
|
|
172025
172032
|
return (await buildScriptCredentialBindingsWithFailures(input)).egressSecrets;
|
|
172026
172033
|
}
|
|
172027
172034
|
|
|
172028
|
-
export { MIN_SCRIPT_WALL_CLOCK_MS, SCRIPT_LONG_TIMEOUT_HINT_MS, MAX_SCRIPT_WALL_CLOCK_MS, DEFAULT_SCRIPT_RESOURCES, isInvalidClientError, assertUrlSafe, publicEndpointSsrfOptions, discoverProtectedResourceMetadata, discoverAuthorizationServerMetadata, normalizeTokenEndpointAuthMethod, resolveAdvertisedTokenEndpointAuthMethod, authMethodForStoredClient, selectDcrTokenEndpointAuthMethod, registerClient, buildAuthorizeUrl, exchangeCodeForTokens, refreshMcpToken, revokeMcpToken, computeExpiresAt, getMcpOAuthToken, findReusableMcpOAuthClient, invalidateMcpOAuthClient, upsertMcpOAuthToken, applyMcpOAuthRefresh, markMcpOAuthTokenStatus, deleteMcpOAuthToken, insertMcpOAuthPending, consumeMcpOAuthPending, gcMcpOAuthPending, setMcpServerAuthMethod, ensureMcpToken, callMcpServerTool, listVendoredOpenapiEntries, ConnectionAuthInputSchema, connectionAuthSummary, listRelationalCredentialBindings, upsertCredentialBinding, disableCredentialBinding, listScriptConnections, getScriptConnectionById, ScriptConnectionConflictError, connectionAuthInputFromFlat, upsertScriptConnection, refreshScriptConnection, setScriptConnectionEnabled, getScriptApiConnectionDescriptors, getScriptMcpConnectionDescriptors, getScriptApiTypes, getScriptMcpTypes, upsertScriptByName, getScript, getScriptById, getScriptVersion, listScripts, listScriptVersions, deleteScript, touchScratchScriptLastUsed, restoreScratchScriptLastUsedIfUnchanged, createScriptApi, listScriptApisForScript, getScriptApiById, getScriptApiSecret, updateScriptApi, rotateScriptApiSecret, deleteScriptApi, recordScriptApiUsage, buildSandboxedCommand, sandboxSpawnEnv, createCappedStreamState, snapshotCapped, readStreamCapped, require_typescript, validateScriptImports, runScript, oauthAppToProviderConfig, getOAuthProviderConfig, getOAuthBindingTokenStatus, buildScriptCredentialBindingsWithFailures, buildScriptCredentialBindings };
|
|
172035
|
+
export { MIN_SCRIPT_WALL_CLOCK_MS, SCRIPT_LONG_TIMEOUT_HINT_MS, MAX_SCRIPT_WALL_CLOCK_MS, DEFAULT_SCRIPT_RESOURCES, isInvalidClientError, assertUrlSafe, publicEndpointSsrfOptions, discoverProtectedResourceMetadata, discoverAuthorizationServerMetadata, normalizeTokenEndpointAuthMethod, resolveAdvertisedTokenEndpointAuthMethod, authMethodForStoredClient, selectDcrTokenEndpointAuthMethod, registerClient, buildAuthorizeUrl, exchangeCodeForTokens, refreshMcpToken, revokeMcpToken, computeExpiresAt, getMcpOAuthToken, findReusableMcpOAuthClient, invalidateMcpOAuthClient, upsertMcpOAuthToken, applyMcpOAuthRefresh, markMcpOAuthTokenStatus, deleteMcpOAuthToken, insertMcpOAuthPending, consumeMcpOAuthPending, gcMcpOAuthPending, setMcpServerAuthMethod, ensureMcpToken, callMcpServerTool, listVendoredOpenapiEntries, ConnectionAuthInputSchema, connectionAuthSummary, listRelationalCredentialBindings, getCredentialBindingById, findCredentialBindingByIdentity, upsertCredentialBinding, disableCredentialBinding, listScriptConnections, listScriptConnectionsAsync, getScriptConnectionById, ScriptConnectionConflictError, connectionAuthInputFromFlat, upsertScriptConnection, refreshScriptConnection, setScriptConnectionEnabled, getScriptApiConnectionDescriptors, getScriptMcpConnectionDescriptors, getScriptApiTypes, getScriptMcpTypes, upsertScriptByName, getScript, getScriptById, getScriptVersion, listScripts, listScriptVersions, deleteScript, touchScratchScriptLastUsed, restoreScratchScriptLastUsedIfUnchanged, createScriptApi, listScriptApisForScript, getScriptApiById, getScriptApiSecret, updateScriptApi, rotateScriptApiSecret, deleteScriptApi, recordScriptApiUsage, buildSandboxedCommand, sandboxSpawnEnv, createCappedStreamState, snapshotCapped, readStreamCapped, require_typescript, validateScriptImports, runScript, oauthAppToProviderConfig, getOAuthProviderConfig, getOAuthBindingTokenStatus, buildScriptCredentialBindingsWithFailures, buildScriptCredentialBindings };
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BASE_SUMMARIZE_PROMPT,
|
|
3
|
+
SummaryWithRatingsSchema,
|
|
4
|
+
buildSummaryWithRatingsPrompt
|
|
5
|
+
} from "./cli-8p37s71j.js";
|
|
6
|
+
import {
|
|
7
|
+
complete,
|
|
8
|
+
exports_typebox,
|
|
9
|
+
getBuiltinModel,
|
|
10
|
+
parseModelStr,
|
|
11
|
+
resolveCredential
|
|
12
|
+
} from "./cli-2ypjdmqg.js";
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_OPENROUTER_BASE_URL,
|
|
15
|
+
getOpenRouterBaseUrl
|
|
16
|
+
} from "./cli-3dpj7atn.js";
|
|
17
|
+
import {
|
|
18
|
+
init_zod
|
|
19
|
+
} from "./cli-s35981d0.js";
|
|
20
|
+
import {
|
|
21
|
+
exports_external
|
|
22
|
+
} from "./cli-pqv5gvyf.js";
|
|
23
|
+
import {
|
|
24
|
+
init_secret_scrubber,
|
|
25
|
+
scrubSecrets
|
|
26
|
+
} from "./cli-mkq1rk7b.js";
|
|
27
|
+
|
|
28
|
+
// src/utils/internal-ai/complete-structured.ts
|
|
29
|
+
init_zod();
|
|
30
|
+
init_secret_scrubber();
|
|
31
|
+
var CLAUDE_CLI_TIMEOUT_MS = 30000;
|
|
32
|
+
function stripJsonFences(raw) {
|
|
33
|
+
const trimmed = raw.trim();
|
|
34
|
+
const fenced = trimmed.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/i);
|
|
35
|
+
return fenced?.[1] ? fenced[1].trim() : trimmed;
|
|
36
|
+
}
|
|
37
|
+
function parseJsonText(raw) {
|
|
38
|
+
try {
|
|
39
|
+
return JSON.parse(stripJsonFences(raw));
|
|
40
|
+
} catch {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function errorMessage(err) {
|
|
45
|
+
const message = err instanceof Error ? err.message : String(err ?? "unknown error");
|
|
46
|
+
return message.replace(/\s+/g, " ");
|
|
47
|
+
}
|
|
48
|
+
async function defaultSpawnClaudeCli(prompt, model, signal, jsonSchema) {
|
|
49
|
+
const useClaudeBridge = ["true", "1"].includes((process.env.SWARM_USE_CLAUDE_BRIDGE ?? "").trim().toLowerCase());
|
|
50
|
+
const claudeBinaryRaw = useClaudeBridge ? "claude-bridge" : (process.env.CLAUDE_BINARY ?? "claude").trim();
|
|
51
|
+
const claudeBinaryArgv = (claudeBinaryRaw || "claude").split(/\s+/);
|
|
52
|
+
const cmd = [...claudeBinaryArgv, "-p", "--model", model, "--output-format", "json"];
|
|
53
|
+
if (jsonSchema) {
|
|
54
|
+
cmd.push("--json-schema", JSON.stringify(jsonSchema));
|
|
55
|
+
}
|
|
56
|
+
const env = { ...process.env };
|
|
57
|
+
if (!env.CLAUDE_CODE_OAUTH_TOKEN && env.AGENT_SWARM_CLAUDE_OAUTH_TOKEN) {
|
|
58
|
+
env.CLAUDE_CODE_OAUTH_TOKEN = env.AGENT_SWARM_CLAUDE_OAUTH_TOKEN;
|
|
59
|
+
}
|
|
60
|
+
env.SKIP_SESSION_SUMMARY = "1";
|
|
61
|
+
const proc = Bun.spawn({
|
|
62
|
+
cmd,
|
|
63
|
+
env,
|
|
64
|
+
stdin: "pipe",
|
|
65
|
+
stdout: "pipe",
|
|
66
|
+
stderr: "pipe"
|
|
67
|
+
});
|
|
68
|
+
const timeout = setTimeout(() => {
|
|
69
|
+
try {
|
|
70
|
+
proc.kill();
|
|
71
|
+
} catch {}
|
|
72
|
+
}, CLAUDE_CLI_TIMEOUT_MS);
|
|
73
|
+
const abortHandler = () => {
|
|
74
|
+
try {
|
|
75
|
+
proc.kill();
|
|
76
|
+
} catch {}
|
|
77
|
+
};
|
|
78
|
+
signal?.addEventListener("abort", abortHandler, { once: true });
|
|
79
|
+
try {
|
|
80
|
+
proc.stdin.write(prompt);
|
|
81
|
+
await proc.stdin.end();
|
|
82
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
83
|
+
new Response(proc.stdout).text(),
|
|
84
|
+
new Response(proc.stderr).text(),
|
|
85
|
+
proc.exited
|
|
86
|
+
]);
|
|
87
|
+
if (exitCode !== 0) {
|
|
88
|
+
console.error(`internal-ai: claude -p exited ${exitCode}; stderr=${stderr.slice(0, 500)}`);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const envelope = JSON.parse(stdout);
|
|
92
|
+
if (jsonSchema && envelope.structured_output !== undefined) {
|
|
93
|
+
return JSON.stringify(envelope.structured_output);
|
|
94
|
+
}
|
|
95
|
+
return envelope.result ?? stdout;
|
|
96
|
+
} catch {
|
|
97
|
+
return stdout;
|
|
98
|
+
}
|
|
99
|
+
} finally {
|
|
100
|
+
clearTimeout(timeout);
|
|
101
|
+
signal?.removeEventListener("abort", abortHandler);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function completeStructured(opts) {
|
|
105
|
+
const retries = opts.retries ?? 3;
|
|
106
|
+
const callerTag = opts.callerTag ?? "<unset>";
|
|
107
|
+
let cred;
|
|
108
|
+
if (opts._credentialOverride) {
|
|
109
|
+
cred = opts._credentialOverride;
|
|
110
|
+
} else {
|
|
111
|
+
const resolver = opts._resolveCredential ?? resolveCredential;
|
|
112
|
+
cred = await resolver({
|
|
113
|
+
env: opts.env ?? process.env,
|
|
114
|
+
apiUrl: opts.apiUrl,
|
|
115
|
+
apiKey: opts.apiKey,
|
|
116
|
+
callerTag: opts.callerTag
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (!cred) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
console.log(`internal-ai: kind=${cred.kind} callerTag=${callerTag}`);
|
|
123
|
+
if (cred.kind === "claude-cli") {
|
|
124
|
+
const spawn = opts._spawnClaudeCli ?? defaultSpawnClaudeCli;
|
|
125
|
+
const jsonSchema = exports_external.toJSONSchema(opts.zodSchema);
|
|
126
|
+
const schemaStr = JSON.stringify(jsonSchema);
|
|
127
|
+
const claudeUserPrompt = `${opts.userPrompt}
|
|
128
|
+
|
|
129
|
+
Respond with ONLY a JSON object (no prose, no code fences) matching this schema:
|
|
130
|
+
${schemaStr}`;
|
|
131
|
+
let lastErr2 = null;
|
|
132
|
+
for (let attempt = 0;attempt < retries; attempt++) {
|
|
133
|
+
try {
|
|
134
|
+
const raw = await spawn(`${opts.systemPrompt}
|
|
135
|
+
|
|
136
|
+
${claudeUserPrompt}`, cred.modelDefault, opts.signal, jsonSchema);
|
|
137
|
+
let parsedJson;
|
|
138
|
+
try {
|
|
139
|
+
parsedJson = JSON.parse(stripJsonFences(raw));
|
|
140
|
+
} catch (err) {
|
|
141
|
+
lastErr2 = err;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const validated = opts.zodSchema.safeParse(parsedJson);
|
|
145
|
+
if (validated.success) {
|
|
146
|
+
return validated.data;
|
|
147
|
+
}
|
|
148
|
+
lastErr2 = validated.error;
|
|
149
|
+
} catch (err) {
|
|
150
|
+
lastErr2 = err;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
console.error(scrubSecrets(`internal-ai: structured output failed after ${retries} retries (callerTag=${callerTag} kind=${cred.kind}): ${errorMessage(lastErr2)}`));
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const [provider, modelId] = parseModelStr(cred.modelDefault);
|
|
157
|
+
let model;
|
|
158
|
+
try {
|
|
159
|
+
model = getBuiltinModel(provider, modelId);
|
|
160
|
+
} catch (err) {
|
|
161
|
+
console.error(`internal-ai: getModel(${provider}, ${modelId}) threw (callerTag=${callerTag})`, err);
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
const openRouterBaseUrl = getOpenRouterBaseUrl(opts.env ?? process.env);
|
|
165
|
+
if (provider === "openrouter" && openRouterBaseUrl !== DEFAULT_OPENROUTER_BASE_URL) {
|
|
166
|
+
model = { ...model, baseUrl: openRouterBaseUrl };
|
|
167
|
+
}
|
|
168
|
+
const completeFn = opts._complete ?? complete;
|
|
169
|
+
const toolChoice = model.api === "anthropic-messages" ? { type: "tool", name: opts.toolName } : "required";
|
|
170
|
+
let userPrompt = opts.userPrompt;
|
|
171
|
+
let lastErr = null;
|
|
172
|
+
for (let attempt = 0;attempt < retries; attempt++) {
|
|
173
|
+
try {
|
|
174
|
+
const msg = await completeFn(model, {
|
|
175
|
+
systemPrompt: opts.systemPrompt,
|
|
176
|
+
messages: [{ role: "user", content: userPrompt, timestamp: Date.now() }],
|
|
177
|
+
tools: [
|
|
178
|
+
{
|
|
179
|
+
name: opts.toolName,
|
|
180
|
+
description: opts.toolDescription,
|
|
181
|
+
parameters: opts.toolSchema
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}, { apiKey: cred.apiKey, signal: opts.signal, toolChoice });
|
|
185
|
+
const toolCall = msg.content.find((c) => c.type === "toolCall" && c.name === opts.toolName);
|
|
186
|
+
if (!toolCall) {
|
|
187
|
+
const assistantText = msg.content.filter((content) => content.type === "text").map((content) => content.text).join(`
|
|
188
|
+
`);
|
|
189
|
+
if (assistantText) {
|
|
190
|
+
const parsedText = parseJsonText(assistantText);
|
|
191
|
+
if (parsedText !== undefined) {
|
|
192
|
+
const validatedText = opts.zodSchema.safeParse(parsedText);
|
|
193
|
+
if (validatedText.success) {
|
|
194
|
+
return validatedText.data;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
userPrompt = `${userPrompt}
|
|
199
|
+
|
|
200
|
+
You did not call the ${opts.toolName} tool. You MUST call it with the requested arguments.`;
|
|
201
|
+
lastErr = new Error("no tool call in response");
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const validated = opts.zodSchema.safeParse(toolCall.arguments);
|
|
205
|
+
if (validated.success) {
|
|
206
|
+
return validated.data;
|
|
207
|
+
}
|
|
208
|
+
userPrompt = `${userPrompt}
|
|
209
|
+
|
|
210
|
+
The ${opts.toolName} arguments did not validate: ${validated.error.message}. Please retry with correct arguments.`;
|
|
211
|
+
lastErr = validated.error;
|
|
212
|
+
} catch (err) {
|
|
213
|
+
lastErr = err;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
console.error(scrubSecrets(`internal-ai: structured output failed after ${retries} retries (callerTag=${callerTag} kind=${cred.kind}): ${errorMessage(lastErr)}`));
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// src/utils/internal-ai/summarize-session.ts
|
|
221
|
+
var summaryToolSchema = exports_typebox.Object({
|
|
222
|
+
summary: exports_typebox.String(),
|
|
223
|
+
ratings: exports_typebox.Array(exports_typebox.Object({
|
|
224
|
+
id: exports_typebox.String({ minLength: 1 }),
|
|
225
|
+
score: exports_typebox.Number({ minimum: 0, maximum: 1 }),
|
|
226
|
+
reasoning: exports_typebox.String({ minLength: 1, maxLength: 500 }),
|
|
227
|
+
referencesSource: exports_typebox.Optional(exports_typebox.String({ minLength: 1, maxLength: 512 }))
|
|
228
|
+
}))
|
|
229
|
+
});
|
|
230
|
+
async function summarizeSession(opts) {
|
|
231
|
+
if (opts.transcript.length <= 100)
|
|
232
|
+
return null;
|
|
233
|
+
const taskLine = opts.taskContext.prompt ? `
|
|
234
|
+
Task: ${opts.taskContext.prompt}` : "";
|
|
235
|
+
const basePrompt = `${BASE_SUMMARIZE_PROMPT}${taskLine}
|
|
236
|
+
|
|
237
|
+
Transcript:
|
|
238
|
+
${opts.transcript}`;
|
|
239
|
+
const userPrompt = buildSummaryWithRatingsPrompt(basePrompt, opts.retrievals);
|
|
240
|
+
const runner = opts._completeStructured ?? completeStructured;
|
|
241
|
+
return await runner({
|
|
242
|
+
zodSchema: SummaryWithRatingsSchema,
|
|
243
|
+
toolSchema: summaryToolSchema,
|
|
244
|
+
toolName: "record_session_summary",
|
|
245
|
+
toolDescription: "Record the high-value learnings extracted from this session, plus per-memory ratings of any retrievals.",
|
|
246
|
+
systemPrompt: "You are an expert at extracting durable, generalizable learnings from agent sessions.",
|
|
247
|
+
userPrompt,
|
|
248
|
+
callerTag: `session-summary:${opts.harness}`,
|
|
249
|
+
apiUrl: opts.apiUrl,
|
|
250
|
+
apiKey: opts.apiKey,
|
|
251
|
+
env: opts.env,
|
|
252
|
+
signal: opts.signal,
|
|
253
|
+
retries: 3,
|
|
254
|
+
...opts._credentialOverride ? { _credentialOverride: opts._credentialOverride } : {}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
export { summarizeSession };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildModelsDevSeedRows,
|
|
3
3
|
loadModelsDevCache
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-s6t1qv67.js";
|
|
5
5
|
import {
|
|
6
6
|
createLogEntry,
|
|
7
7
|
getActivePricingRow,
|
|
8
8
|
getDbClient,
|
|
9
9
|
init_db,
|
|
10
10
|
insertPricingRow
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-kq9htgbr.js";
|
|
12
12
|
import {
|
|
13
13
|
init_secret_scrubber,
|
|
14
14
|
scrubSecrets
|