@desplega.ai/agent-swarm 2.5.2 → 2.5.4
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/{acp-adapter-csh0zz3b.js → acp-adapter-ek38cwsv.js} +5 -5
- package/dist/{actions-6xx079d1.js → actions-92mepq03.js} +19 -19
- package/dist/{amp-adapter-8n6f0hz8.js → amp-adapter-9gaxg015.js} +4 -4
- package/dist/{app-ft6r6v23.js → app-ctn8gsgx.js} +3 -3
- package/dist/{assistant-vt2cyfzd.js → assistant-zyr5kz47.js} +21 -21
- package/dist/{boot-reembed-tgrfy27t.js → boot-reembed-dwzfttdr.js} +1 -1
- package/dist/{boot-reembed-r3e808ky.js → boot-reembed-w75maga2.js} +1 -1
- package/dist/{boot-scrub-sweep-masdwxkm.js → boot-scrub-sweep-e9kq43kf.js} +3 -3
- package/dist/{boot-seeds-0n82qc7q.js → boot-seeds-x28v3fhb.js} +4 -4
- package/dist/{claude-adapter-s7j47k06.js → claude-adapter-f0afqnne.js} +5 -5
- package/dist/{claude-managed-adapter-gt6pa35d.js → claude-managed-adapter-x81a7r65.js} +3 -3
- package/dist/{claude-managed-setup-3hzrgrnk.js → claude-managed-setup-bqzwjd9x.js} +2 -2
- package/dist/{claude-sdk-session-0zrdzyx2.js → claude-sdk-session-7b7whkaq.js} +9307 -9254
- package/dist/{cli-a5ebc95n.js → cli-0shx9j93.js} +16 -13
- package/dist/{cli-4qkg9968.js → cli-19202kew.js} +4 -4
- package/dist/{cli-cyfgxnvb.js → cli-1r5ad7j5.js} +19 -17
- package/dist/{cli-jmcjbjkt.js → cli-25n3mv5d.js} +9 -7
- package/dist/cli-2655k16q.js +140 -0
- package/dist/{cli-wadzapwb.js → cli-277c31dw.js} +1 -1
- package/dist/{cli-n6kmqngw.js → cli-4b2z6n0m.js} +29 -7
- package/dist/{cli-7ccf7akh.js → cli-5bnsc0e1.js} +9 -7
- package/dist/{cli-qrjv7t18.js → cli-621ce7kw.js} +1 -1
- package/dist/{cli-xzge46sj.js → cli-64mh9mf3.js} +20 -6
- package/dist/{cli-b6tnjdvx.js → cli-6a1xg1p7.js} +6 -2
- package/dist/{cli-ydg6ep51.js → cli-6n8axjv1.js} +1 -1
- package/dist/{cli-e91vshb1.js → cli-7p4jxgtt.js} +5 -5
- package/dist/{cli-f3pfn4x3.js → cli-9j129brq.js} +9 -3
- package/dist/{cli-xw9q173h.js → cli-9s05422w.js} +1 -1
- package/dist/{cli-15xd0j7w.js → cli-abs8ndtr.js} +12 -12
- package/dist/{cli-h5d22pfs.js → cli-asq5ydm4.js} +219 -309
- package/dist/{cli-w9etnnxk.js → cli-bf8ma3f1.js} +120 -50
- package/dist/{cli-0vgy5wfw.js → cli-bvpgr9ny.js} +2 -2
- package/dist/{cli-3e9vs93g.js → cli-c61mbdds.js} +4 -4
- package/dist/{cli-e5bxnjps.js → cli-c952c7ac.js} +5 -5
- package/dist/{cli-p859hcc8.js → cli-dew6x255.js} +1 -1
- package/dist/{cli-tx00c0h6.js → cli-dqygeeh5.js} +17 -1
- package/dist/{cli-gpv60278.js → cli-e42vss7b.js} +2 -2
- package/dist/{cli-b63d08rs.js → cli-eftzyh9y.js} +1 -1
- package/dist/{cli-fgn7yg5r.js → cli-ethgy7ha.js} +1 -1
- package/dist/{cli-86zpfje5.js → cli-ff1tm9n9.js} +1 -1
- package/dist/{cli-cf63dnxj.js → cli-g9vd9ece.js} +37 -12
- package/dist/{cli-j3dwd4kz.js → cli-gbfxp48k.js} +770 -126
- package/dist/{cli-n2918sed.js → cli-gn5af0x5.js} +21 -21
- package/dist/{cli-d172svcw.js → cli-gwhjmh8g.js} +4 -4
- package/dist/{cli-stxdrqs2.js → cli-hh5we352.js} +24 -5
- package/dist/{cli-0ebey9hg.js → cli-j6rktc91.js} +1 -1
- package/dist/{cli-csh8fnbg.js → cli-jb30dzvk.js} +473 -58
- package/dist/{cli-vaxw3bg0.js → cli-jbnn4vxb.js} +3 -3
- package/dist/{cli-ha22h0eg.js → cli-k4tjsdx9.js} +45 -40
- package/dist/{cli-f55b6ky0.js → cli-m4ecdxvz.js} +40 -13
- package/dist/{cli-mntxtkhn.js → cli-mz9afxxf.js} +2 -1
- package/dist/{cli-ta8bd7th.js → cli-pzatvw94.js} +1 -1
- package/dist/{cli-3qv8naq8.js → cli-rr7zx19j.js} +1591 -353
- package/dist/{cli-b1tv22wr.js → cli-s682zgqz.js} +1 -1
- package/dist/{cli-bpbcpd8b.js → cli-sbwsxvtd.js} +1 -1
- package/dist/{cli-0xk505e8.js → cli-sxgtf5fw.js} +1 -1
- package/dist/{cli-6y43v79h.js → cli-tsma7p8v.js} +1 -1
- package/dist/{cli-edtm741g.js → cli-wghjkr0e.js} +5 -5
- package/dist/{cli-aaqnqpyw.js → cli-wx2nj19m.js} +30 -11
- package/dist/{cli-y3dzwyy3.js → cli-x0f2v69c.js} +180 -60
- package/dist/{cli-kcnwn85g.js → cli-xtrz6bzs.js} +7 -7
- package/dist/{cli-14v1sxxy.js → cli-xzfq4at3.js} +7 -7
- package/dist/cli.js +20 -20
- package/dist/{codex-adapter-brh2tcxr.js → codex-adapter-wch12q99.js} +3 -3
- package/dist/{codex-hook-e2he7aca.js → codex-hook-brpnycn5.js} +1 -1
- package/dist/{codex-session-runner-0dnj21qs.js → codex-session-runner-41pfcr95.js} +2 -2
- package/dist/{commands-1cnvseqx.js → commands-9849dkj6.js} +2 -2
- package/dist/{controller-kc7s9xhn.js → controller-ja0sd95p.js} +29 -3
- package/dist/{controllers-connect-jzx7t4bn.js → controllers-connect-xp05dj6x.js} +20 -20
- package/dist/{cursor-adapter-qpwp5sfg.js → cursor-adapter-623qxqew.js} +1 -2
- package/dist/{db-4vq88jkc.js → db-47vj40dy.js} +3 -3
- package/dist/{db-v5ytg5pw.js → db-w759qmx0.js} +2 -2
- package/dist/{dispatcher-trtcrqae.js → dispatcher-7b8e4z2j.js} +17 -17
- package/dist/{docker-nfy2gc8t.js → docker-s84hjs91.js} +2 -2
- package/dist/{dsh-adapter-f20xwn1z.js → dsh-adapter-2ezw3xea.js} +2 -3
- package/dist/{external-channel-n9bymc2n.js → external-channel-e2s028da.js} +2 -2
- package/dist/{grok-adapter-4kpmmnr6.js → grok-adapter-ys7gaqee.js} +6 -6
- package/dist/{handlers-ptsraqa8.js → handlers-wy1dr6ja.js} +20 -20
- package/dist/{heartbeat-60qtxtjf.js → heartbeat-w3mntghj.js} +20 -20
- package/dist/{hook-rbktcstg.js → hook-3jjywnpb.js} +9 -3
- package/dist/{hook-ngtvh729.js → hook-g7kvv6x9.js} +3 -2
- package/dist/{http-z8xy72gp.js → http-tkp7d4kb.js} +2984 -2483
- package/dist/{index-r70q0xjx.js → index-1ef1myq2.js} +17 -17
- package/dist/{index-a9nsavhx.js → index-3n8m9ea2.js} +1 -1
- package/dist/{index-cbxkmfc5.js → index-9pn1pfkf.js} +1 -1
- package/dist/{index-s193j5fh.js → index-nmm79qgr.js} +20 -20
- package/dist/{index-6srwvd5b.js → index-p4xfz37z.js} +1 -1
- package/dist/{index-06qkmcx6.js → index-q7m26kvs.js} +33 -23
- package/dist/{index-1cscynkb.js → index-xdaahthb.js} +17 -17
- package/dist/{keepalive-a9srcphj.js → keepalive-v4ta8wgg.js} +3 -3
- package/dist/{lead-3devneqy.js → lead-sawnyqxk.js} +35 -35
- package/dist/{maintenance-0er16h2y.js → maintenance-84n1ex21.js} +1 -1
- package/dist/{oauth-refresh-sweep-b65jcyw2.js → oauth-refresh-sweep-vjnnandw.js} +2 -2
- package/dist/{onboard-wqywz5py.js → onboard-sfmpe4np.js} +2 -2
- package/dist/{opencode-adapter-e56086m1.js → opencode-adapter-jmpst4q4.js} +4 -4
- package/dist/{otel-impl-vk32s884.js → otel-impl-v6cc0zve.js} +1 -1
- package/dist/{pi-mono-adapter-tzps8f38.js → pi-mono-adapter-fk8fkcf6.js} +33 -6
- package/dist/{pricing-refresh-t27anv4z.js → pricing-refresh-fsk1e1zc.js} +3 -3
- package/dist/{rbac-roles-452665y0.js → rbac-roles-prmkdnkw.js} +2 -2
- package/dist/{rbac-roles-bmcgsxjn.js → rbac-roles-zxmxqa39.js} +1 -1
- package/dist/{render-v2-0ttsk2j4.js → render-v2-pjwxvnkw.js} +3 -3
- package/dist/{resume-a26kvr41.js → resume-frdtgfa0.js} +9 -5
- package/dist/{session-access-dgh9nkwk.js → session-access-fpez4y5q.js} +4 -4
- package/dist/{setup-9vc9qahm.js → setup-mq6m3m8q.js} +1 -1
- package/dist/{work-objects-vn8nkxwn.js → work-objects-kfahhjsq.js} +20 -20
- package/dist/{worker-1x1h8vnm.js → worker-v5e5rxj3.js} +35 -35
- package/openapi.json +3078 -2424
- package/package.json +7 -7
- package/plugin/commands/create-pr.md +2 -2
- package/plugin/pi-skills/create-pr/SKILL.md +2 -2
- package/src/be/approval-config-question.ts +389 -0
- package/src/be/automation-preflight.ts +37 -3
- package/src/be/db/approvals.ts +48 -0
- package/src/be/db/session-tree.ts +73 -15
- package/src/be/db/skill-search.ts +87 -0
- package/src/be/db/tasks/read.ts +29 -2
- package/src/be/db/tasks/write.ts +15 -5
- package/src/be/db/workflow-idempotency.ts +183 -0
- package/src/be/db/workflow-runs.ts +366 -8
- package/src/be/db.ts +92 -22
- package/src/be/migrations/239_skills_fts.sql +40 -0
- package/src/be/migrations/240_workflow_run_parent_step_attempt.sql +37 -0
- package/src/be/migrations/241_skills_meta_fts.sql +39 -0
- package/src/be/migrations/242_workflow_idempotency_keys.sql +40 -0
- package/src/be/sealed-json.ts +1 -0
- package/src/be/seed-scripts/catalog/compound-insights.inline.ts +2 -2
- package/src/be/seed-scripts/catalog/compound-insights.ts +2 -2
- package/src/be/seed-skills/bundled-files.generated.json +1 -1
- package/src/be/sql-connections.ts +7 -1
- package/src/be/swarm-config-guard.ts +25 -0
- package/src/be/users.ts +9 -0
- package/src/commands/controller.ts +33 -0
- package/src/commands/runner.ts +6 -2
- package/src/extensions/apply-task-create.ts +57 -11
- package/src/extensions/catalog.generated.json +4 -4
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/contract.ts +25 -0
- package/src/extensions/dispatcher.ts +4 -0
- package/src/extensions/post-bridge.ts +8 -0
- package/src/hooks/context-bound-note.ts +196 -0
- package/src/hooks/hook.ts +12 -0
- package/src/http/approval-requests.ts +209 -38
- package/src/http/config.ts +70 -53
- package/src/http/idempotency-key.ts +117 -0
- package/src/http/sessions.ts +27 -2
- package/src/http/workflows.ts +129 -24
- package/src/integrations/chat-sdk/inbound.ts +5 -4
- package/src/prompts/context-bound-note.ts +48 -0
- package/src/prompts/session-templates.ts +25 -1
- package/src/providers/amp-adapter.ts +30 -8
- package/src/providers/claude-adapter.ts +29 -4
- package/src/providers/claude-managed-adapter.ts +26 -0
- package/src/providers/claude-sdk-session.ts +10 -0
- package/src/providers/claude-session-events.ts +13 -0
- package/src/providers/codex-adapter.ts +12 -0
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/providers/opencode-adapter.ts +18 -0
- package/src/providers/pi-mono-adapter.ts +35 -0
- package/src/runtime-providers/docker.ts +6 -2
- package/src/scripts-runtime/types/swarm-extension.d.ts +35 -0
- package/src/tests/amp-adapter.test.ts +97 -0
- package/src/tests/approval-config-question.test.ts +702 -0
- package/src/tests/approval-requests.test.ts +10 -7
- package/src/tests/approval-sweeps.test.ts +12 -6
- package/src/tests/base-prompt.test.ts +1 -1
- package/src/tests/chat-sdk-inbound.test.ts +20 -0
- package/src/tests/claude-hook-output.test.ts +79 -1
- package/src/tests/claude-managed-adapter.test.ts +275 -0
- package/src/tests/codex-adapter.test.ts +163 -0
- package/src/tests/context-bound-note.test.ts +269 -0
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/entrypoint-gitlab-credential-helper.test.ts +273 -0
- package/src/tests/extensions-example-comms-adherence-gate.test.ts +321 -12
- package/src/tests/extensions-pre-task.test.ts +273 -0
- package/src/tests/fetch-resolved-env.test.ts +17 -0
- package/src/tests/fixtures/extensions/record-blocks/hooks.ts +10 -0
- package/src/tests/fixtures/extensions/record-blocks/manifest.json +7 -0
- package/src/tests/fixtures/fake-amp.ts +22 -8
- package/src/tests/fixtures/held-template-render.ts +42 -0
- package/src/tests/fixtures/workflow-idempotency-trigger.child.ts +73 -0
- package/src/tests/list-endpoint-slimming.test.ts +33 -0
- package/src/tests/migration-240-workflow-run-parent-step-attempt.test.ts +55 -0
- package/src/tests/openapi-route-headers.test.ts +2 -0
- package/src/tests/opencode-adapter.test.ts +134 -0
- package/src/tests/pi-mono-adapter.test.ts +105 -0
- package/src/tests/prompt-template-session.test.ts +4 -3
- package/src/tests/runner-push-delivery.test.ts +25 -0
- package/src/tests/runtime-controller-liveness.test.ts +133 -0
- package/src/tests/runtime-providers-docker.test.ts +2 -0
- package/src/tests/script-connections.test.ts +9 -0
- package/src/tests/script-run-config-scope.test.ts +91 -3
- package/src/tests/session-logs.test.ts +70 -0
- package/src/tests/sessions-tree.test.ts +205 -1
- package/src/tests/skill-search-long-content.test.ts +193 -0
- package/src/tests/skill-search.test.ts +173 -22
- package/src/tests/workflow-cascade-cancel.test.ts +1169 -0
- package/src/tests/workflow-foreach-supersede-retry.test.ts +488 -0
- package/src/tests/workflow-idempotency.test.ts +915 -0
- package/src/tests/workflow-sub-workflow.test.ts +538 -1
- package/src/tools/request-human-input.ts +27 -5
- package/src/tools/workflows/cancel-workflow-run.ts +1 -1
- package/src/types.ts +7 -0
- package/src/utils/context-window.ts +8 -6
- package/src/workflows/approval-cancel.ts +15 -13
- package/src/workflows/approval-notifications.ts +15 -4
- package/src/workflows/checkpoint.ts +72 -35
- package/src/workflows/engine.ts +262 -93
- package/src/workflows/executors/base.ts +6 -0
- package/src/workflows/executors/foreach.ts +2 -2
- package/src/workflows/executors/human-in-the-loop.ts +25 -1
- package/src/workflows/executors/sub-workflow.ts +45 -16
- package/src/workflows/foreach-driver.ts +10 -3
- package/src/workflows/foreach-join.ts +29 -6
- package/src/workflows/recovery.ts +68 -1
- package/src/workflows/resume.ts +228 -77
- package/src/workflows/retry-poller.ts +74 -7
- package/src/workflows/task-step-routing.ts +29 -7
- package/templates/ai-toolbox.manifest.json +8 -8
- package/templates/community/open-prompt-showreel/PLAYBOOK.md +5 -6
- package/templates/community/open-prompt-showreel/lead-prompt.md +1 -1
- package/templates/community/open-prompt-showreel/skills/open-prompt-showreel/SKILL.md +4 -4
- package/templates/extensions/comms-adherence-gate/README.md +38 -13
- package/templates/extensions/comms-adherence-gate/hooks.ts +272 -69
- package/templates/extensions/comms-adherence-gate/manifest.json +2 -2
- package/templates/skills/agent-browser/SKILL.md +4 -4
- package/templates/skills/agent-browser/content.md +4 -4
- package/templates/skills/code-quality/config.json +1 -1
- package/templates/skills/code-quality/content.md +2 -2
- package/templates/skills/delegate-work/content.md +29 -25
- package/templates/skills/delegate-work/files/scripts/codex-exec.sh +5 -5
- package/templates/skills/qa/content.md +2 -2
- package/templates/skills/researching/content.md +2 -0
- package/templates/skills/turso-interaction/content.md +1 -1
- package/templates/skills/work-on-task/SKILL.md +1 -1
- package/templates/skills/work-on-task/content.md +1 -1
- package/templates/skills/workflow-iterate/content.md +8 -1
|
@@ -7,16 +7,14 @@ import {
|
|
|
7
7
|
buildClaudeShortnameMap,
|
|
8
8
|
init_src2
|
|
9
9
|
} from "./cli-nwyw3zhg.js";
|
|
10
|
+
import {
|
|
11
|
+
__esm
|
|
12
|
+
} from "./cli-242037k3.js";
|
|
10
13
|
|
|
11
14
|
// src/utils/context-window.ts
|
|
12
|
-
init_src2();
|
|
13
|
-
init_runtime_model_catalog();
|
|
14
|
-
var CONTEXT_FORMULA = "input-cache-output";
|
|
15
|
-
var DEFAULT_CONTEXT_WINDOW = 200000;
|
|
16
15
|
function stripAnthropicDateSuffix(model) {
|
|
17
16
|
return model.replace(/-(\d{8})$/, "");
|
|
18
17
|
}
|
|
19
|
-
var shortnameMap = null;
|
|
20
18
|
function resolveClaudeShortname(model) {
|
|
21
19
|
const section = runtimeCatalogSection("anthropic");
|
|
22
20
|
if (!shortnameMap || shortnameMap.section !== section) {
|
|
@@ -29,8 +27,11 @@ function catalogContext(provider, model) {
|
|
|
29
27
|
return typeof context === "number" && context > 0 ? context : undefined;
|
|
30
28
|
}
|
|
31
29
|
function getContextWindowSize(model) {
|
|
30
|
+
return getKnownContextWindowSize(model) ?? DEFAULT_CONTEXT_WINDOW;
|
|
31
|
+
}
|
|
32
|
+
function getKnownContextWindowSize(model) {
|
|
32
33
|
if (!model)
|
|
33
|
-
return
|
|
34
|
+
return;
|
|
34
35
|
const slash = model.indexOf("/");
|
|
35
36
|
if (slash > 0) {
|
|
36
37
|
const scoped = catalogContext(model.slice(0, slash), model.slice(slash + 1));
|
|
@@ -49,12 +50,9 @@ function getContextWindowSize(model) {
|
|
|
49
50
|
return dated;
|
|
50
51
|
}
|
|
51
52
|
const shortname = resolveClaudeShortname(model);
|
|
52
|
-
if (shortname)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return resolved;
|
|
56
|
-
}
|
|
57
|
-
return DEFAULT_CONTEXT_WINDOW;
|
|
53
|
+
if (shortname)
|
|
54
|
+
return catalogContext("anthropic", shortname);
|
|
55
|
+
return;
|
|
58
56
|
}
|
|
59
57
|
function computeContextUsedUnified(parts) {
|
|
60
58
|
return (parts.inputTokens ?? 0) + (parts.cacheReadTokens ?? 0) + (parts.cacheCreateTokens ?? 0) + (parts.outputTokens ?? 0);
|
|
@@ -67,5 +65,10 @@ function clampContextPercent(used, total) {
|
|
|
67
65
|
return null;
|
|
68
66
|
return Math.min(100, Math.max(0, raw));
|
|
69
67
|
}
|
|
68
|
+
var CONTEXT_FORMULA = "input-cache-output", DEFAULT_CONTEXT_WINDOW = 200000, shortnameMap = null;
|
|
69
|
+
var init_context_window = __esm(() => {
|
|
70
|
+
init_src2();
|
|
71
|
+
init_runtime_model_catalog();
|
|
72
|
+
});
|
|
70
73
|
|
|
71
|
-
export { CONTEXT_FORMULA, getContextWindowSize, computeContextUsedUnified, clampContextPercent };
|
|
74
|
+
export { CONTEXT_FORMULA, getContextWindowSize, getKnownContextWindowSize, computeContextUsedUnified, clampContextPercent, init_context_window };
|
|
@@ -15,17 +15,17 @@ import {
|
|
|
15
15
|
init_secret_registry,
|
|
16
16
|
upsertSwarmConfig2,
|
|
17
17
|
init_db3
|
|
18
|
-
} from "./cli-
|
|
18
|
+
} from "./cli-jb30dzvk.js";
|
|
19
19
|
import {
|
|
20
20
|
createRuntimeProvider,
|
|
21
21
|
init_runtime_providers
|
|
22
|
-
} from "./cli-
|
|
22
|
+
} from "./cli-dew6x255.js";
|
|
23
23
|
import {
|
|
24
24
|
closeSessionTokenConnections,
|
|
25
25
|
init_session_token_connections,
|
|
26
26
|
insertSessionToken,
|
|
27
27
|
init_users
|
|
28
|
-
} from "./cli-
|
|
28
|
+
} from "./cli-6a1xg1p7.js";
|
|
29
29
|
import {
|
|
30
30
|
RuntimeControllerCreateSchema,
|
|
31
31
|
RuntimeControllerUpdateSchema,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
RuntimePoolUpdateSchema,
|
|
34
34
|
RuntimePoolCreateAgentSchema,
|
|
35
35
|
init_types
|
|
36
|
-
} from "./cli-
|
|
36
|
+
} from "./cli-mz9afxxf.js";
|
|
37
37
|
import {
|
|
38
38
|
scrubSecrets,
|
|
39
39
|
registerVolatileSecret,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
CONTROLLER_COMMAND_TIMEOUT_MS,
|
|
5
5
|
RuntimeHandleSchema,
|
|
6
6
|
ControllerStatusResultSchema
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-6n8axjv1.js";
|
|
8
8
|
import {
|
|
9
9
|
getDbClient2,
|
|
10
10
|
isRuntimePoolsEnabled,
|
|
@@ -21,17 +21,11 @@ import {
|
|
|
21
21
|
upsertSwarmConfig2,
|
|
22
22
|
getResolvedConfig2,
|
|
23
23
|
init_db3
|
|
24
|
-
} from "./cli-
|
|
24
|
+
} from "./cli-jb30dzvk.js";
|
|
25
25
|
import {
|
|
26
|
-
runtimeStaleThresholdMinutes,
|
|
27
|
-
getRuntimeInstanceById,
|
|
28
|
-
insertProvisioningRuntime,
|
|
29
|
-
markRuntimeTerminated,
|
|
30
|
-
listRuntimeInstancesForAgent,
|
|
31
|
-
listRuntimeInstancesForPool,
|
|
32
26
|
createWorkerTaskFollowUp,
|
|
33
27
|
canClaim
|
|
34
|
-
} from "./cli-
|
|
28
|
+
} from "./cli-asq5ydm4.js";
|
|
35
29
|
import {
|
|
36
30
|
getRuntimeController2,
|
|
37
31
|
getRuntimeControllerTarget2,
|
|
@@ -42,14 +36,22 @@ import {
|
|
|
42
36
|
getPoolForAgent2,
|
|
43
37
|
resolvePoolDelivery2,
|
|
44
38
|
init_db
|
|
45
|
-
} from "./cli-
|
|
39
|
+
} from "./cli-19202kew.js";
|
|
46
40
|
import {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
runtimeStaleThresholdMinutes,
|
|
42
|
+
getRuntimeInstanceById,
|
|
43
|
+
insertProvisioningRuntime,
|
|
44
|
+
markRuntimeTerminated,
|
|
45
|
+
listRuntimeInstancesForAgent,
|
|
46
|
+
listRuntimeInstancesForPool
|
|
47
|
+
} from "./cli-gbfxp48k.js";
|
|
50
48
|
import {
|
|
51
49
|
isMultiRuntimeEnabled
|
|
52
50
|
} from "./cli-e8xyjvfc.js";
|
|
51
|
+
import {
|
|
52
|
+
workflowEventBus2,
|
|
53
|
+
init_event_bus
|
|
54
|
+
} from "./cli-dabehxhp.js";
|
|
53
55
|
import {
|
|
54
56
|
import_websocket
|
|
55
57
|
} from "./cli-b2mz5mjc.js";
|
|
@@ -57,16 +59,16 @@ import {
|
|
|
57
59
|
canProvisionKind,
|
|
58
60
|
createRuntimeProvider,
|
|
59
61
|
init_runtime_providers
|
|
60
|
-
} from "./cli-
|
|
62
|
+
} from "./cli-dew6x255.js";
|
|
61
63
|
import {
|
|
62
64
|
mintRuntimeToken,
|
|
63
65
|
init_users
|
|
64
|
-
} from "./cli-
|
|
66
|
+
} from "./cli-6a1xg1p7.js";
|
|
65
67
|
import {
|
|
66
68
|
TERMINAL_TASK_STATUSES,
|
|
67
69
|
isTerminalTaskStatus,
|
|
68
70
|
init_types
|
|
69
|
-
} from "./cli-
|
|
71
|
+
} from "./cli-mz9afxxf.js";
|
|
70
72
|
import {
|
|
71
73
|
init_zod
|
|
72
74
|
} from "./cli-4chz1hye.js";
|
|
@@ -522,7 +524,7 @@ async function recoverSessions(runtimeId, reason) {
|
|
|
522
524
|
}
|
|
523
525
|
if (!sessions.length)
|
|
524
526
|
return;
|
|
525
|
-
const { remediateTaskForDeadRuntime } = await import("./heartbeat-
|
|
527
|
+
const { remediateTaskForDeadRuntime } = await import("./heartbeat-w3mntghj.js");
|
|
526
528
|
for (const session of sessions) {
|
|
527
529
|
try {
|
|
528
530
|
const task = await getTaskById2(session.taskId);
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getContextWindowSize,
|
|
3
|
-
clampContextPercent
|
|
4
|
-
} from "./cli-a5ebc95n.js";
|
|
5
1
|
import {
|
|
6
2
|
swarmRuntimeInstanceId
|
|
7
3
|
} from "./cli-e8xyjvfc.js";
|
|
@@ -11,16 +7,21 @@ import {
|
|
|
11
7
|
import {
|
|
12
8
|
applyReasoningEffort
|
|
13
9
|
} from "./cli-bn0rewsy.js";
|
|
10
|
+
import {
|
|
11
|
+
getContextWindowSize,
|
|
12
|
+
clampContextPercent,
|
|
13
|
+
init_context_window
|
|
14
|
+
} from "./cli-0shx9j93.js";
|
|
14
15
|
import {
|
|
15
16
|
DEFAULT_MODEL_TIER_MAP,
|
|
16
17
|
init_types
|
|
17
|
-
} from "./cli-
|
|
18
|
+
} from "./cli-mz9afxxf.js";
|
|
18
19
|
import {
|
|
19
20
|
resolveTemplateFromCode,
|
|
20
21
|
resolveTemplateAsync,
|
|
21
22
|
init_resolver,
|
|
22
23
|
init_session_templates
|
|
23
|
-
} from "./cli-
|
|
24
|
+
} from "./cli-dqygeeh5.js";
|
|
24
25
|
import {
|
|
25
26
|
parseEnvFlag,
|
|
26
27
|
init_env_flag
|
|
@@ -40,10 +41,11 @@ init_src2();
|
|
|
40
41
|
init_session_templates();
|
|
41
42
|
init_resolver();
|
|
42
43
|
init_types();
|
|
44
|
+
init_context_window();
|
|
45
|
+
init_env_flag();
|
|
43
46
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
44
47
|
import { tmpdir } from "node:os";
|
|
45
48
|
import { join } from "node:path";
|
|
46
|
-
init_env_flag();
|
|
47
49
|
init_secret_scrubber();
|
|
48
50
|
var CURSOR_MCP_SERVER_NAME = "agent-swarm";
|
|
49
51
|
var NATIVE_SYSTEM_PROMPT_ENV = "CURSOR_NATIVE_SYSTEM_PROMPT";
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getKnownContextWindowSize,
|
|
3
|
+
clampContextPercent,
|
|
4
|
+
init_context_window
|
|
5
|
+
} from "./cli-0shx9j93.js";
|
|
6
|
+
import {
|
|
7
|
+
resolveTemplateFromCode,
|
|
8
|
+
resolveTemplateAsync,
|
|
9
|
+
init_resolver,
|
|
10
|
+
init_session_templates
|
|
11
|
+
} from "./cli-dqygeeh5.js";
|
|
12
|
+
|
|
13
|
+
// src/hooks/context-bound-note.ts
|
|
14
|
+
import { renameSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
16
|
+
|
|
17
|
+
// src/prompts/context-bound-note.ts
|
|
18
|
+
init_session_templates();
|
|
19
|
+
init_resolver();
|
|
20
|
+
var CONTEXT_BOUND_NOTE_TEMPLATE = "system.agent.context.bound_note";
|
|
21
|
+
function contextShare(contextTokens, model) {
|
|
22
|
+
if (!model)
|
|
23
|
+
return "";
|
|
24
|
+
try {
|
|
25
|
+
init_context_window();
|
|
26
|
+
const window = getKnownContextWindowSize(model);
|
|
27
|
+
const percent = clampContextPercent(contextTokens, window);
|
|
28
|
+
if (!window || percent === null)
|
|
29
|
+
return "";
|
|
30
|
+
return ` (${Math.round(percent)}% of the ${window.toLocaleString("en-US")}-token window)`;
|
|
31
|
+
} catch {
|
|
32
|
+
return "";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function renderContextBoundNote(contextTokens, model) {
|
|
36
|
+
const variables = {
|
|
37
|
+
contextTokens: Math.round(contextTokens).toLocaleString("en-US"),
|
|
38
|
+
contextShare: contextShare(contextTokens, model)
|
|
39
|
+
};
|
|
40
|
+
try {
|
|
41
|
+
const result = await resolveTemplateAsync(CONTEXT_BOUND_NOTE_TEMPLATE, variables);
|
|
42
|
+
return result.skipped ? "" : result.text;
|
|
43
|
+
} catch {
|
|
44
|
+
return resolveTemplateFromCode(CONTEXT_BOUND_NOTE_TEMPLATE, variables).text;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/hooks/context-bound-note.ts
|
|
49
|
+
function contextBoundNoteThreshold(env = process.env) {
|
|
50
|
+
const raw = env.CONTEXT_BOUND_NOTE_TOKENS?.trim();
|
|
51
|
+
if (!raw || !/^\d+$/.test(raw))
|
|
52
|
+
return 0;
|
|
53
|
+
const parsed = Number(raw);
|
|
54
|
+
return Number.isSafeInteger(parsed) ? parsed : 0;
|
|
55
|
+
}
|
|
56
|
+
function reachesThreshold(contextTokens, threshold) {
|
|
57
|
+
return threshold > 0 && typeof contextTokens === "number" && Number.isFinite(contextTokens) && contextTokens >= threshold;
|
|
58
|
+
}
|
|
59
|
+
async function deliverContextBoundNote(contextTokens, model, inject) {
|
|
60
|
+
try {
|
|
61
|
+
const note = await renderContextBoundNote(contextTokens, model);
|
|
62
|
+
if (note)
|
|
63
|
+
await inject(note);
|
|
64
|
+
} catch {}
|
|
65
|
+
}
|
|
66
|
+
function contextStatePath(taskFilePath) {
|
|
67
|
+
return `${taskFilePath}.context.json`;
|
|
68
|
+
}
|
|
69
|
+
function contextBoundNoteMarkerPath(taskFilePath) {
|
|
70
|
+
return `${taskFilePath}.bound-note`;
|
|
71
|
+
}
|
|
72
|
+
function recordContextState(taskFilePath, contextTokens, model) {
|
|
73
|
+
const path = contextStatePath(taskFilePath);
|
|
74
|
+
const tmp = `${path}.tmp`;
|
|
75
|
+
try {
|
|
76
|
+
writeFileSync(tmp, JSON.stringify({ contextTokens, model, updatedAt: new Date().toISOString() }));
|
|
77
|
+
renameSync(tmp, path);
|
|
78
|
+
} catch {}
|
|
79
|
+
}
|
|
80
|
+
async function claimContextBoundNote(taskFilePath, threshold) {
|
|
81
|
+
if (!taskFilePath || threshold <= 0)
|
|
82
|
+
return null;
|
|
83
|
+
let contextTokens;
|
|
84
|
+
let model;
|
|
85
|
+
try {
|
|
86
|
+
const state = JSON.parse(await readFile(contextStatePath(taskFilePath), "utf8"));
|
|
87
|
+
contextTokens = state?.contextTokens;
|
|
88
|
+
model = state?.model;
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
if (!reachesThreshold(contextTokens, threshold))
|
|
93
|
+
return null;
|
|
94
|
+
try {
|
|
95
|
+
await writeFile(contextBoundNoteMarkerPath(taskFilePath), new Date().toISOString(), {
|
|
96
|
+
flag: "wx"
|
|
97
|
+
});
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return { contextTokens, model: typeof model === "string" && model ? model : undefined };
|
|
102
|
+
}
|
|
103
|
+
async function injectClaimedContextBoundNote(taskFilePath, threshold, inject) {
|
|
104
|
+
const state = await claimContextBoundNote(taskFilePath, threshold).catch(() => null);
|
|
105
|
+
if (state)
|
|
106
|
+
await deliverContextBoundNote(state.contextTokens, state.model, inject);
|
|
107
|
+
}
|
|
108
|
+
function createContextBoundNote(options) {
|
|
109
|
+
let state = "idle";
|
|
110
|
+
let held = "";
|
|
111
|
+
const tryDeliver = async (note) => {
|
|
112
|
+
try {
|
|
113
|
+
if (!options.canDeliver()) {
|
|
114
|
+
held = note;
|
|
115
|
+
state = "held";
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
state = "done";
|
|
119
|
+
await options.inject(note);
|
|
120
|
+
} catch {}
|
|
121
|
+
};
|
|
122
|
+
return async (contextTokens) => {
|
|
123
|
+
if (state === "held")
|
|
124
|
+
return tryDeliver(held);
|
|
125
|
+
if (state !== "idle" || !reachesThreshold(contextTokens, options.threshold))
|
|
126
|
+
return;
|
|
127
|
+
state = "rendering";
|
|
128
|
+
let note = "";
|
|
129
|
+
try {
|
|
130
|
+
note = await renderContextBoundNote(contextTokens, options.model?.());
|
|
131
|
+
} catch {}
|
|
132
|
+
if (!note) {
|
|
133
|
+
state = "done";
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
await tryDeliver(note);
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export { contextBoundNoteThreshold, contextStatePath, contextBoundNoteMarkerPath, recordContextState, injectClaimedContextBoundNote, createContextBoundNote };
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Anthropic
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-rr7zx19j.js";
|
|
4
|
+
import {
|
|
5
|
+
contextBoundNoteThreshold,
|
|
6
|
+
createContextBoundNote
|
|
7
|
+
} from "./cli-2655k16q.js";
|
|
4
8
|
import {
|
|
5
9
|
checkToolLoop
|
|
6
10
|
} from "./cli-0726awxw.js";
|
|
7
|
-
import {
|
|
8
|
-
CONTEXT_FORMULA,
|
|
9
|
-
getContextWindowSize,
|
|
10
|
-
computeContextUsedUnified,
|
|
11
|
-
clampContextPercent
|
|
12
|
-
} from "./cli-a5ebc95n.js";
|
|
13
11
|
import {
|
|
14
12
|
readPkgVersion
|
|
15
13
|
} from "./cli-kr5tjjtz.js";
|
|
16
14
|
import {
|
|
17
15
|
createSwarmEventHandler
|
|
18
16
|
} from "./cli-4zsenjhy.js";
|
|
17
|
+
import {
|
|
18
|
+
CONTEXT_FORMULA,
|
|
19
|
+
getContextWindowSize,
|
|
20
|
+
computeContextUsedUnified,
|
|
21
|
+
clampContextPercent,
|
|
22
|
+
init_context_window
|
|
23
|
+
} from "./cli-0shx9j93.js";
|
|
19
24
|
import {
|
|
20
25
|
runtimeCatalogModel,
|
|
21
26
|
init_runtime_model_catalog
|
|
@@ -29,6 +34,7 @@ import {
|
|
|
29
34
|
} from "./cli-nwyw3zhg.js";
|
|
30
35
|
|
|
31
36
|
// src/providers/claude-managed-adapter.ts
|
|
37
|
+
init_context_window();
|
|
32
38
|
init_secret_scrubber();
|
|
33
39
|
|
|
34
40
|
// src/providers/claude-managed-models.ts
|
|
@@ -183,6 +189,9 @@ class ClaudeManagedSession {
|
|
|
183
189
|
taskId;
|
|
184
190
|
aborted = false;
|
|
185
191
|
settled = false;
|
|
192
|
+
lastRequestContextTokens;
|
|
193
|
+
observeContextBound;
|
|
194
|
+
openToolCalls = new Set;
|
|
186
195
|
constructor(client, sessionId, config, userMessageContent, seenEventIds = new Set) {
|
|
187
196
|
this.client = client;
|
|
188
197
|
this._sessionId = sessionId;
|
|
@@ -194,6 +203,12 @@ class ClaudeManagedSession {
|
|
|
194
203
|
this.completionPromise = new Promise((resolve) => {
|
|
195
204
|
this.resolveCompletion = resolve;
|
|
196
205
|
});
|
|
206
|
+
this.observeContextBound = createContextBoundNote({
|
|
207
|
+
threshold: contextBoundNoteThreshold(config.env ?? process.env),
|
|
208
|
+
model: () => this.cost.model,
|
|
209
|
+
canDeliver: () => !this.settled && !this.aborted && this.openToolCalls.size > 0,
|
|
210
|
+
inject: (note) => this.deliverSteering({ mode: "steer", text: note })
|
|
211
|
+
});
|
|
197
212
|
if (config.taskId && config.apiUrl && config.apiKey) {
|
|
198
213
|
const abortRef = { current: this.abortController };
|
|
199
214
|
const handler = createClaudeManagedSwarmEventHandler({
|
|
@@ -308,6 +323,8 @@ class ClaudeManagedSession {
|
|
|
308
323
|
case "agent.tool_use": {
|
|
309
324
|
const tu = event;
|
|
310
325
|
this.runToolLoopCheck(tu.name, tu.input);
|
|
326
|
+
this.openToolCalls.add(tu.id);
|
|
327
|
+
this.observeContextBound(this.lastRequestContextTokens);
|
|
311
328
|
this.emit({
|
|
312
329
|
type: "tool_start",
|
|
313
330
|
toolCallId: tu.id,
|
|
@@ -320,6 +337,8 @@ class ClaudeManagedSession {
|
|
|
320
337
|
const tu = event;
|
|
321
338
|
const fqToolName = `${tu.mcp_server_name}:${tu.name}`;
|
|
322
339
|
this.runToolLoopCheck(fqToolName, tu.input);
|
|
340
|
+
this.openToolCalls.add(tu.id);
|
|
341
|
+
this.observeContextBound(this.lastRequestContextTokens);
|
|
323
342
|
this.emit({
|
|
324
343
|
type: "tool_start",
|
|
325
344
|
toolCallId: tu.id,
|
|
@@ -330,6 +349,7 @@ class ClaudeManagedSession {
|
|
|
330
349
|
}
|
|
331
350
|
case "agent.tool_result": {
|
|
332
351
|
const tr = event;
|
|
352
|
+
this.openToolCalls.delete(tr.tool_use_id);
|
|
333
353
|
this.emit({
|
|
334
354
|
type: "tool_end",
|
|
335
355
|
toolCallId: tr.tool_use_id,
|
|
@@ -341,6 +361,7 @@ class ClaudeManagedSession {
|
|
|
341
361
|
}
|
|
342
362
|
case "agent.mcp_tool_result": {
|
|
343
363
|
const tr = event;
|
|
364
|
+
this.openToolCalls.delete(tr.mcp_tool_use_id);
|
|
344
365
|
this.emit({
|
|
345
366
|
type: "tool_end",
|
|
346
367
|
toolCallId: tr.mcp_tool_use_id,
|
|
@@ -372,6 +393,7 @@ class ClaudeManagedSession {
|
|
|
372
393
|
case "span.model_request_end": {
|
|
373
394
|
const sp = event;
|
|
374
395
|
const usage = sp.model_usage;
|
|
396
|
+
this.lastRequestContextTokens = usage.input_tokens + usage.cache_read_input_tokens + usage.cache_creation_input_tokens;
|
|
375
397
|
this.cost.inputTokens = (this.cost.inputTokens ?? 0) + usage.input_tokens;
|
|
376
398
|
this.cost.outputTokens = (this.cost.outputTokens ?? 0) + usage.output_tokens;
|
|
377
399
|
this.cost.cacheReadTokens = (this.cost.cacheReadTokens ?? 0) + usage.cache_read_input_tokens;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CONTEXT_FORMULA,
|
|
3
|
-
getContextWindowSize,
|
|
4
|
-
clampContextPercent
|
|
5
|
-
} from "./cli-a5ebc95n.js";
|
|
6
1
|
import {
|
|
7
2
|
swarmRuntimeInstanceId
|
|
8
3
|
} from "./cli-e8xyjvfc.js";
|
|
@@ -18,10 +13,16 @@ import {
|
|
|
18
13
|
reasoningCapability,
|
|
19
14
|
applyReasoningEffort
|
|
20
15
|
} from "./cli-bn0rewsy.js";
|
|
16
|
+
import {
|
|
17
|
+
CONTEXT_FORMULA,
|
|
18
|
+
getContextWindowSize,
|
|
19
|
+
clampContextPercent,
|
|
20
|
+
init_context_window
|
|
21
|
+
} from "./cli-0shx9j93.js";
|
|
21
22
|
import {
|
|
22
23
|
DEFAULT_MODEL_TIER_MAP,
|
|
23
24
|
init_types
|
|
24
|
-
} from "./cli-
|
|
25
|
+
} from "./cli-mz9afxxf.js";
|
|
25
26
|
import {
|
|
26
27
|
getOpenRouterBaseUrl,
|
|
27
28
|
getOpenRouterAttributionHeaders,
|
|
@@ -35,6 +36,7 @@ import {
|
|
|
35
36
|
|
|
36
37
|
// src/providers/dsh-adapter.ts
|
|
37
38
|
init_types();
|
|
39
|
+
init_context_window();
|
|
38
40
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
39
41
|
import { tmpdir } from "node:os";
|
|
40
42
|
import { join } from "node:path";
|
|
@@ -66,7 +68,7 @@ function addDshStepUsage(acc, step) {
|
|
|
66
68
|
// src/providers/dsh-adapter.ts
|
|
67
69
|
init_openrouter_base_url();
|
|
68
70
|
init_secret_scrubber();
|
|
69
|
-
var DSH_PACKAGE = "@deepseek-ai/dsh@0.2.1-rc.
|
|
71
|
+
var DSH_PACKAGE = "@deepseek-ai/dsh@0.2.1-rc.3";
|
|
70
72
|
function checkDshCredentials2(env) {
|
|
71
73
|
return env.DEEPSEEK_API_KEY?.trim() || env.OPENROUTER_API_KEY?.trim() ? { ready: true, missing: [], satisfiedBy: "env" } : {
|
|
72
74
|
ready: false,
|
|
@@ -5,10 +5,9 @@ import {
|
|
|
5
5
|
postRatings
|
|
6
6
|
} from "./cli-3h26v7yj.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "./cli-a5ebc95n.js";
|
|
8
|
+
contextBoundNoteThreshold,
|
|
9
|
+
createContextBoundNote
|
|
10
|
+
} from "./cli-2655k16q.js";
|
|
12
11
|
import {
|
|
13
12
|
SessionErrorTracker
|
|
14
13
|
} from "./cli-gx4rm0qx.js";
|
|
@@ -46,13 +45,19 @@ import {
|
|
|
46
45
|
import {
|
|
47
46
|
createSwarmEventHandler
|
|
48
47
|
} from "./cli-4zsenjhy.js";
|
|
48
|
+
import {
|
|
49
|
+
CONTEXT_FORMULA,
|
|
50
|
+
computeContextUsedUnified,
|
|
51
|
+
clampContextPercent,
|
|
52
|
+
init_context_window
|
|
53
|
+
} from "./cli-0shx9j93.js";
|
|
49
54
|
import {
|
|
50
55
|
hasCodexOAuthPoolSlots
|
|
51
56
|
} from "./cli-j4bwnpkm.js";
|
|
52
57
|
import {
|
|
53
58
|
DEFAULT_MODEL_TIER_MAP,
|
|
54
59
|
init_types
|
|
55
|
-
} from "./cli-
|
|
60
|
+
} from "./cli-mz9afxxf.js";
|
|
56
61
|
import {
|
|
57
62
|
runtimeCatalogModel,
|
|
58
63
|
init_runtime_model_catalog
|
|
@@ -60,7 +65,7 @@ import {
|
|
|
60
65
|
import {
|
|
61
66
|
init_package,
|
|
62
67
|
package_default
|
|
63
|
-
} from "./cli-
|
|
68
|
+
} from "./cli-xtrz6bzs.js";
|
|
64
69
|
import {
|
|
65
70
|
isEnvFlagEnabled,
|
|
66
71
|
isSessionSummarySkipped,
|
|
@@ -88,6 +93,7 @@ function codexUserHome() {
|
|
|
88
93
|
import { existsSync as nodeExistsSync } from "node:fs";
|
|
89
94
|
import { join as join2 } from "node:path";
|
|
90
95
|
init_api_key();
|
|
96
|
+
init_context_window();
|
|
91
97
|
init_env_flag();
|
|
92
98
|
init_secret_scrubber();
|
|
93
99
|
|
|
@@ -1048,6 +1054,7 @@ class CodexSession {
|
|
|
1048
1054
|
errorTracker = new SessionErrorTracker;
|
|
1049
1055
|
appliedReasoningEffort;
|
|
1050
1056
|
pendingResult = null;
|
|
1057
|
+
observeContextBound;
|
|
1051
1058
|
constructor(thread, config, resolvedModel, initialEvents = [], skillsDir, summarizeDeps = {}) {
|
|
1052
1059
|
this.thread = thread;
|
|
1053
1060
|
this.config = config;
|
|
@@ -1056,6 +1063,12 @@ class CodexSession {
|
|
|
1056
1063
|
this.skillsDir = skillsDir ?? process.env.CODEX_SKILLS_DIR ?? join2(codexUserHome(), ".codex", "skills");
|
|
1057
1064
|
this.summarizeDeps = summarizeDeps;
|
|
1058
1065
|
this.logFileHandle = Bun.file(config.logFile).writer();
|
|
1066
|
+
this.observeContextBound = createContextBoundNote({
|
|
1067
|
+
threshold: contextBoundNoteThreshold(config.env ?? process.env),
|
|
1068
|
+
model: () => this.resolvedModel,
|
|
1069
|
+
canDeliver: () => this.acceptsSteering && !this.settled && !this.aborted,
|
|
1070
|
+
inject: (note) => this.deliverSteering({ mode: "steer", text: note })
|
|
1071
|
+
});
|
|
1059
1072
|
const reasoningApplication = applyReasoningEffort("codex", resolvedModel, config.reasoningEffort);
|
|
1060
1073
|
this.appliedReasoningEffort = reasoningApplication.kind === "codex-config" ? config.reasoningEffort ?? null : null;
|
|
1061
1074
|
this.completionPromise = new Promise((resolve) => {
|
|
@@ -1361,6 +1374,7 @@ class CodexSession {
|
|
|
1361
1374
|
break;
|
|
1362
1375
|
case "context.updated":
|
|
1363
1376
|
this.emitContextUsage(event.usage, event.contextWindow ?? this.contextWindow);
|
|
1377
|
+
this.observeContextBound(event.usage.input_tokens);
|
|
1364
1378
|
break;
|
|
1365
1379
|
case "error": {
|
|
1366
1380
|
const { message } = this.formatTerminalError(event.message, event.codexErrorInfo);
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
validateRuntimeTokenTtlHours,
|
|
6
6
|
init_swarm_config_guard,
|
|
7
7
|
init_db3
|
|
8
|
-
} from "./cli-
|
|
8
|
+
} from "./cli-jb30dzvk.js";
|
|
9
9
|
import {
|
|
10
10
|
registerVolatileSecret,
|
|
11
11
|
unregisterVolatileSecret,
|
|
@@ -285,6 +285,10 @@ async function mintRuntimeToken(agentId, runtimeId, ttlMs = runtimeTokenTtlMs())
|
|
|
285
285
|
async function mintScriptRunToken(agentId, ttlMs) {
|
|
286
286
|
return await insertSessionToken(agentId, null, null, ttlMs, null, undefined, null, null, true);
|
|
287
287
|
}
|
|
288
|
+
async function isScriptRunToken(tokenId) {
|
|
289
|
+
const row = await getDbClient2().get("SELECT scriptRun FROM session_tokens WHERE id = ?", [tokenId]);
|
|
290
|
+
return row?.scriptRun === 1;
|
|
291
|
+
}
|
|
288
292
|
async function insertSessionToken(agentId, taskId, runtimeId, ttlMs, parentRuntimeId = null, expiresAtCeiling, controllerId = null, parentTokenId = null, scriptRun = false) {
|
|
289
293
|
const plaintext = `${SESSION_TOKEN_PREFIX}${base62(randomBytes(24))}`;
|
|
290
294
|
const tokenId = randomUUID().replace(/-/g, "");
|
|
@@ -449,4 +453,4 @@ var init_users = __esm(() => {
|
|
|
449
453
|
};
|
|
450
454
|
});
|
|
451
455
|
|
|
452
|
-
export { registerSessionTokenConnection, closeSessionTokenConnections, init_session_token_connections, findUserById, findUserByExternalId, findUserByEmail, findUsersByName, getUserIdentities, listUserEvents, listUserTokens, recordIdentityEvent, findOrCreateUserByEmail, linkIdentity, unlinkIdentity, mintToken, revokeToken, resolveUserByToken, InvalidRuntimeTokenError, mintSessionToken, mintRuntimeToken, mintScriptRunToken, insertSessionToken, revokeSessionToken, revokeRuntimeTokensForRuntime, AgentTokenExistsError, mintAgentToken, rotateAgentToken, revokeAgentTokens, resolveSessionToken, fingerprintApiKey, init_users };
|
|
456
|
+
export { registerSessionTokenConnection, closeSessionTokenConnections, init_session_token_connections, findUserById, findUserByExternalId, findUserByEmail, findUsersByName, getUserIdentities, listUserEvents, listUserTokens, recordIdentityEvent, findOrCreateUserByEmail, linkIdentity, unlinkIdentity, mintToken, revokeToken, resolveUserByToken, InvalidRuntimeTokenError, mintSessionToken, mintRuntimeToken, mintScriptRunToken, isScriptRunToken, insertSessionToken, revokeSessionToken, revokeRuntimeTokensForRuntime, AgentTokenExistsError, mintAgentToken, rotateAgentToken, revokeAgentTokens, resolveSessionToken, fingerprintApiKey, init_users };
|
|
@@ -40,14 +40,14 @@ import {
|
|
|
40
40
|
getResolvedConfig2,
|
|
41
41
|
getMcpServerById2,
|
|
42
42
|
init_db3
|
|
43
|
-
} from "./cli-
|
|
43
|
+
} from "./cli-jb30dzvk.js";
|
|
44
44
|
import {
|
|
45
45
|
generateRandomCodeVerifier,
|
|
46
46
|
generateRandomState,
|
|
47
47
|
calculatePKCECodeChallenge,
|
|
48
48
|
oauthAppRowToProviderConfig,
|
|
49
49
|
ensureAuthorizationTokenOrThrow
|
|
50
|
-
} from "./cli-
|
|
50
|
+
} from "./cli-tsma7p8v.js";
|
|
51
51
|
import {
|
|
52
52
|
detachedProcessGroup,
|
|
53
53
|
registerProcessGroup,
|
|
@@ -60,11 +60,11 @@ import {
|
|
|
60
60
|
mintScriptRunToken,
|
|
61
61
|
revokeSessionToken,
|
|
62
62
|
init_users
|
|
63
|
-
} from "./cli-
|
|
63
|
+
} from "./cli-6a1xg1p7.js";
|
|
64
64
|
import {
|
|
65
65
|
defaultAssetKey,
|
|
66
66
|
init_key
|
|
67
|
-
} from "./cli-
|
|
67
|
+
} from "./cli-mz9afxxf.js";
|
|
68
68
|
import {
|
|
69
69
|
init_zod
|
|
70
70
|
} from "./cli-4chz1hye.js";
|
|
@@ -176111,7 +176111,7 @@ async function resolveSqlDsn(connection, agentId) {
|
|
|
176111
176111
|
assertPostgresDsn(dsn);
|
|
176112
176112
|
return dsn;
|
|
176113
176113
|
}
|
|
176114
|
-
var asTemplate = (text) => Object.
|
|
176114
|
+
var asTemplate = (text) => Object.freeze(Object.defineProperty([text], "raw", { value: Object.freeze([text]) }));
|
|
176115
176115
|
var defaultExecutor = async (dsn, query, params, take) => {
|
|
176116
176116
|
const sql = new Bun.SQL({
|
|
176117
176117
|
adapter: "postgres",
|