@desplega.ai/agent-swarm 2.3.0 → 2.4.1
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 +1 -0
- package/dist/{acp-adapter-v85a2bqy.js → acp-adapter-zvzr538d.js} +9 -9
- package/dist/{actions-zgcxfspj.js → actions-jhtqdw69.js} +21 -19
- package/dist/{amp-adapter-jw9xfz42.js → amp-adapter-bd84rhs2.js} +4 -4
- package/dist/{app-4e1s4675.js → app-kreq1gwg.js} +3 -3
- package/dist/{assistant-v238n9dk.js → assistant-3k22sbsq.js} +23 -21
- package/dist/{boot-reembed-p666cw5n.js → boot-reembed-e53x6b9v.js} +1 -1
- package/dist/{boot-reembed-w6pm64j4.js → boot-reembed-f6z923ny.js} +1 -1
- package/dist/{boot-scrub-sweep-jcyjagn3.js → boot-scrub-sweep-0538vsb7.js} +4 -4
- package/dist/{boot-seeds-gbedmamp.js → boot-seeds-6wxqkfk2.js} +4 -4
- package/dist/{claude-adapter-q7wspzt8.js → claude-adapter-gfts5044.js} +9 -9
- package/dist/{claude-managed-adapter-n7ahjyx6.js → claude-managed-adapter-h2y889ge.js} +3 -3
- package/dist/{claude-managed-setup-wza784fb.js → claude-managed-setup-h00hsgtz.js} +2 -2
- package/dist/{claude-sdk-session-yf400ptr.js → claude-sdk-session-56besmfz.js} +13 -13
- package/dist/{cli-65q70v2v.js → cli-0bh477zn.js} +33 -6
- package/dist/{cli-4ync7m60.js → cli-0ebey9hg.js} +1 -1
- package/dist/{cli-665j3feb.js → cli-0xk505e8.js} +1 -1
- package/dist/{cli-7gh7020n.js → cli-1dmcq2eh.js} +1 -1
- package/dist/{cli-gzvb3d4a.js → cli-1jx0srjt.js} +3 -3
- package/dist/{cli-zj4d6afs.js → cli-1pa3rz69.js} +21 -6
- package/dist/{cli-7ayprxp7.js → cli-2dfbv8qr.js} +8 -0
- package/dist/{cli-30m5q8mc.js → cli-3kh4kpqy.js} +6 -6
- package/dist/{cli-qrwp40st.js → cli-3p8fqcnh.js} +2 -2
- package/dist/{cli-y3dvz6ge.js → cli-3r448dqn.js} +3 -3
- package/dist/{cli-a17tzmn0.js → cli-3tnpj2bh.js} +7 -7
- package/dist/{cli-ea7chd26.js → cli-471qk6s2.js} +93 -46
- package/dist/{cli-a49vpbf3.js → cli-5kqnemen.js} +1 -1
- package/dist/{cli-0rh20bp3.js → cli-6ncjvx55.js} +3 -3
- package/dist/{cli-fb6t92v8.js → cli-6x9ma5w5.js} +1 -1
- package/dist/{cli-k28p6xh7.js → cli-7225gwj7.js} +2 -2
- package/dist/{cli-8cvvytad.js → cli-8nyhf7za.js} +3 -3
- package/dist/{cli-e09hj50q.js → cli-8wkb09q5.js} +11 -11
- package/dist/{cli-j0v75y13.js → cli-a0kcty51.js} +4 -4
- package/dist/{cli-zes4tsbb.js → cli-a4gvwttf.js} +4 -4
- package/dist/{cli-jhp7w1fy.js → cli-a5ebc95n.js} +2 -2
- package/dist/{cli-5d1m1qca.js → cli-ash6xxk7.js} +2 -2
- package/dist/{cli-fp4xbw07.js → cli-axh29tyr.js} +14 -12
- package/dist/{cli-p22zdvnt.js → cli-bn0rewsy.js} +3 -3
- package/dist/{cli-hz64bcnj.js → cli-bn5kevnf.js} +11 -373
- package/dist/{cli-8jtrekpy.js → cli-d2mb5s8a.js} +7 -7
- package/dist/{cli-c5sbmw1v.js → cli-d82btycs.js} +94 -15
- package/dist/{cli-vjfpshn3.js → cli-ejs3m1sx.js} +1 -1
- package/dist/{cli-yv0vgscc.js → cli-fpmsqq59.js} +18 -2
- package/dist/cli-fz9kewbh.js +382 -0
- package/dist/{cli-4s1kqrqg.js → cli-g0hgtz4p.js} +6 -6
- package/dist/{cli-hn3pftj2.js → cli-gf0kfg81.js} +7 -7
- package/dist/{cli-d43xqzbe.js → cli-hqhzg1qq.js} +2 -2
- package/dist/{cli-azs9bhc5.js → cli-j4rqdf2n.js} +2 -2
- package/dist/{cli-wtg6edvd.js → cli-jh0qcrga.js} +1 -1
- package/dist/{cli-kqypty34.js → cli-k9z4zd4p.js} +6 -5
- package/dist/{cli-jhmjwqcg.js → cli-kmqgmcnb.js} +47 -14
- package/dist/{cli-8qsx817b.js → cli-kr2pmfqx.js} +583 -769
- package/dist/{cli-4g629sgr.js → cli-m2qgh5sv.js} +20 -1
- package/dist/{cli-9e9kjqsj.js → cli-mfe7f7b5.js} +2 -2
- package/dist/{cli-x3en6ct3.js → cli-nwyw3zhg.js} +1 -1
- package/dist/{cli-6vcyw6v7.js → cli-nx462e4v.js} +5 -3
- package/dist/{cli-tr24eeny.js → cli-p0rakbrk.js} +9 -9
- package/dist/{cli-4hmaheb6.js → cli-p6argxh9.js} +9 -9
- package/dist/{cli-3avfh5az.js → cli-pemywhfq.js} +2 -2
- package/dist/{cli-etvn5ej2.js → cli-pnp2j5zg.js} +2 -2
- package/dist/{cli-wk8ccrz6.js → cli-pw7v69vp.js} +2 -2
- package/dist/{cli-ka01m5rb.js → cli-rdq7tzwm.js} +17 -14
- package/dist/{cli-re4wkbzx.js → cli-rqqsfz30.js} +677 -104
- package/dist/{cli-xgn4rwyv.js → cli-s48yvzb8.js} +4 -4
- package/dist/{cli-zv4vy2b0.js → cli-s95dknxh.js} +1 -1
- package/dist/{cli-g6p7c2my.js → cli-sjyetj21.js} +2 -2
- package/dist/{cli-rdr166ht.js → cli-smvcw9z5.js} +1 -1
- package/dist/{cli-fhvqt2fp.js → cli-sv5gb0yb.js} +1 -1
- package/dist/{cli-yv3n83x8.js → cli-syhq378v.js} +2 -2
- package/dist/{cli-q1812jbw.js → cli-tbhwrxpt.js} +9 -9
- package/dist/{cli-w7z94e6c.js → cli-tx00c0h6.js} +4 -2
- package/dist/{cli-dxwh4j32.js → cli-vy0fay6k.js} +46 -37
- package/dist/{cli-ptkpaqfy.js → cli-wt645v7q.js} +1 -1
- package/dist/{cli-ppapy34w.js → cli-wxbn3yfx.js} +2 -2
- package/dist/{cli-cby329ny.js → cli-x5mq1fyq.js} +3 -3
- package/dist/{cli-rc3r0bnh.js → cli-xbzvet96.js} +6 -6
- package/dist/{cli-4mkvwgzr.js → cli-xf234ws8.js} +1 -1
- package/dist/{cli-6p7ddg72.js → cli-xftrvxag.js} +5 -5
- package/dist/cli-z071fb95.js +848 -0
- package/dist/{cli-1v8w782f.js → cli-z1ew8vbq.js} +14 -7
- package/dist/{cli-9td5ss65.js → cli-zfg9enh9.js} +3 -3
- package/dist/{cli-yxqag76b.js → cli-zw88zjba.js} +1 -1
- package/dist/cli.js +19 -19
- package/dist/{codex-adapter-nhjj2veb.js → codex-adapter-p6rmm7vv.js} +6 -6
- package/dist/{codex-hook-x6tm6y5m.js → codex-hook-x7nejyrr.js} +8 -5
- package/dist/{codex-login-35p4sk85.js → codex-login-m819c41r.js} +1 -1
- package/dist/{codex-session-runner-6hggrjbx.js → codex-session-runner-8vd5t9t0.js} +7 -7
- package/dist/{commands-mrw1ph2w.js → commands-7ems2p13.js} +2 -2
- package/dist/{controller-pt1zam5w.js → controller-m263fg43.js} +4 -4
- package/dist/{controllers-connect-ymw5541d.js → controllers-connect-bg33ae53.js} +28 -24
- package/dist/{cursor-adapter-cf4zh5x0.js → cursor-adapter-cz6nm6mj.js} +3 -3
- package/dist/{db-hy80219q.js → db-w505dwa8.js} +2 -2
- package/dist/{db-hhpy6m4x.js → db-ys2rbdft.js} +3 -2
- package/dist/{devin-adapter-7egzmt0k.js → devin-adapter-zgqadvnm.js} +1 -1
- package/dist/{dispatcher-6pdjtkr1.js → dispatcher-0s0mckqr.js} +20 -18
- package/dist/{docker-njavd3fb.js → docker-fkgtr75t.js} +2 -2
- package/dist/{dsh-adapter-fbx06re2.js → dsh-adapter-3n3net33.js} +3 -3
- package/dist/{e2b-5r6a5jeb.js → e2b-7am6tmq6.js} +2 -2
- package/dist/{e2b-pw1nvtmh.js → e2b-thdcxtjd.js} +2 -2
- package/dist/{easter-egg-3d-6hg2r942.js → easter-egg-3d-5cgynaja.js} +1 -1
- package/dist/{event-bus-101fenkh.js → event-bus-9vpk8gmq.js} +1 -1
- package/dist/{execute-bcqc69a5.js → execute-t4e6m3rw.js} +1 -1
- package/dist/{external-channel-j6vb6ya1.js → external-channel-5b23fv8z.js} +2 -2
- package/dist/{google-generative-ai-phpmwxvg.js → google-generative-ai-bmq8gkf3.js} +1 -1
- package/dist/{google-vertex-es9ybgdy.js → google-vertex-b1rvp52s.js} +1 -1
- package/dist/{grok-adapter-1193sprp.js → grok-adapter-q9fghe5q.js} +10 -10
- package/dist/handlers-mqrym347.js +39 -0
- package/dist/{heartbeat-h1w1ktce.js → heartbeat-tww6yx1w.js} +23 -21
- package/dist/{hook-ejja4bpe.js → hook-dx0pkvar.js} +16 -9
- package/dist/{hook-skrbja18.js → hook-pvmh9b6m.js} +6 -6
- package/dist/{http-mzh41mfj.js → http-k2ejbt05.js} +975 -292
- package/dist/{index-6rmnn89d.js → index-2z710v4x.js} +10 -10
- package/dist/{index-xmmkyx82.js → index-dgz61nff.js} +20 -18
- package/dist/{index-wgsw9xcz.js → index-g6tbb6ve.js} +1 -1
- package/dist/index-h2ek08d6.js +40 -0
- package/dist/index-pqfwh9nn.js +41 -0
- package/dist/{index-epr2gnbw.js → index-x5aktmp8.js} +1 -1
- package/dist/{index-x0q2a4f9.js → index-ysd45kgc.js} +1 -1
- package/dist/{index-g909y089.js → index-zgvqzjsw.js} +8 -8
- package/dist/{keepalive-4djvbm2j.js → keepalive-nhvpw10z.js} +4 -4
- package/dist/lead-jb6sf69z.js +78 -0
- package/dist/{maintenance-f3xhnjsm.js → maintenance-agakc519.js} +1 -1
- package/dist/{oauth-refresh-sweep-fpd6x6rw.js → oauth-refresh-sweep-4dcbhtn0.js} +3 -3
- package/dist/{onboard-196tjgyn.js → onboard-4n2kwa4v.js} +3 -3
- package/dist/{opencode-adapter-eeesgfqk.js → opencode-adapter-3s7ax02e.js} +7 -7
- package/dist/{otel-impl-g8fh4c21.js → otel-impl-tfa12080.js} +2 -2
- package/dist/{pi-mono-adapter-zasp3ze3.js → pi-mono-adapter-ytp7gz8b.js} +24 -13
- package/dist/{pricing-refresh-sdcf5yaz.js → pricing-refresh-3cqx3f3x.js} +3 -3
- package/dist/{rbac-roles-bsp5657v.js → rbac-roles-9fae5rnv.js} +5 -3
- package/dist/{rbac-roles-2x4g1wb5.js → rbac-roles-y6zbfzve.js} +2 -2
- package/dist/{render-v2-0pyb39bb.js → render-v2-emawjvc4.js} +3 -3
- package/dist/{resume-a86tkj6r.js → resume-zhgts7h7.js} +10 -8
- package/dist/{runtime-ar8310ba.js → runtime-xe3aqy4x.js} +1 -1
- package/dist/session-access-cm823e06.js +25 -0
- package/dist/{setup-ypbzcapd.js → setup-tkp99w1e.js} +1 -1
- package/dist/{virtual-modules-wzk6jf3a.js → virtual-modules-4r3zkc20.js} +2 -2
- package/dist/{work-objects-yjp8de12.js → work-objects-f722h263.js} +23 -21
- package/dist/worker-p7f336rq.js +78 -0
- package/dist/{x-8ewt8gxn.js → x-y45mthwn.js} +2 -2
- package/openapi.json +1086 -305
- package/package.json +2 -2
- package/src/apps/action-caller.ts +6 -0
- package/src/apps/action-runner.ts +146 -0
- package/src/apps/row-store.ts +4 -2
- package/src/apps/script-types.ts +17 -4
- package/src/be/db/active-sessions.ts +5 -0
- package/src/be/db/session-visibility.ts +29 -0
- package/src/be/db/tasks/read.ts +61 -3
- package/src/be/db/tasks/write.ts +15 -6
- package/src/be/db.ts +106 -37
- package/src/be/events.ts +11 -0
- package/src/be/fleet-benchmark-stats.ts +10 -5
- package/src/be/migrations/230_session_shares.sql +23 -0
- package/src/be/models-catalog.ts +4 -0
- package/src/be/onboarding.ts +6 -0
- package/src/be/rbac-roles.ts +2 -0
- package/src/be/scripts/typecheck.ts +13 -0
- package/src/be/session-shares.ts +244 -0
- package/src/be/swarm-config-guard.ts +33 -3
- package/src/be/telemetry-enable.ts +1 -1
- package/src/commands/provider-credentials.ts +12 -2
- package/src/commands/runner.ts +14 -0
- package/src/heartbeat/heartbeat.ts +2 -2
- package/src/hooks/codex-hook.ts +6 -2
- package/src/hooks/hook.ts +7 -0
- package/src/hooks/pr-body-guard.ts +38 -11
- package/src/hooks/pr-room-guard.ts +88 -0
- package/src/http/active-sessions.ts +13 -2
- package/src/http/agents.ts +11 -3
- package/src/http/all-routes.ts +1 -0
- package/src/http/api-keys.ts +3 -1
- package/src/http/approval-requests.ts +2 -1
- package/src/http/apps.ts +118 -190
- package/src/http/config.ts +3 -0
- package/src/http/context.ts +2 -0
- package/src/http/core.ts +39 -2
- package/src/http/events.ts +6 -2
- package/src/http/favorite-owner.ts +1 -1
- package/src/http/fleet-benchmark.ts +79 -30
- package/src/http/fs.ts +38 -3
- package/src/http/global-config.ts +7 -0
- package/src/http/index.ts +3 -1
- package/src/http/memory.ts +3 -1
- package/src/http/ranking.ts +351 -0
- package/src/http/realtime.ts +26 -21
- package/src/http/route-def.ts +77 -11
- package/src/http/script-runs.ts +2 -1
- package/src/http/scripts.ts +8 -0
- package/src/http/session-access.ts +179 -0
- package/src/http/session-data.ts +10 -2
- package/src/http/sessions.ts +212 -12
- package/src/http/stats.ts +7 -3
- package/src/http/tasks.ts +85 -8
- package/src/http/telemetry-ui.ts +1 -1
- package/src/http/used-by.ts +64 -20
- package/src/http/users.ts +2 -2
- package/src/prompts/session-templates.ts +3 -1
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/pi-mono-adapter.ts +15 -0
- package/src/providers/reasoning-effort.ts +2 -1
- package/src/providers/types.ts +2 -0
- package/src/ranking/telemetry-ranking.ts +119 -0
- package/src/ranking/usage.ts +57 -0
- package/src/rbac/admission.ts +22 -7
- package/src/rbac/legacy-policy.ts +2 -0
- package/src/rbac/permissions.ts +9 -0
- package/src/realtime/auth.ts +69 -0
- package/src/realtime/tickets.ts +4 -1
- package/src/realtime/transport.ts +77 -9
- package/src/scripts-runtime/sdk-allowlist.ts +7 -0
- package/src/scripts-runtime/types/stdlib.d.ts +31 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +31 -0
- package/src/server.ts +4 -0
- package/src/slack/blocks.ts +18 -0
- package/src/slack/dm.ts +29 -0
- package/src/telemetry-context.ts +19 -1
- package/src/telemetry-contract/EVENTS.md +45 -8
- package/src/telemetry-contract/SOURCE.json +38 -4
- package/src/telemetry-contract/catalog.json +294 -5
- package/src/telemetry-contract/ranking/fixtures/expected.json +30 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/bad-category.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/bad-claim.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/blank-description.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/blank-name.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/description-too-long.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/domain-uppercase.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/domain-with-scheme.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/domain-with-www.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/http-source-url.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/missing-description.json +10 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/missing-version.json +10 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/name-not-string.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/name-too-long.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/not-object.json +1 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/null.json +1 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/other-with-subcategory.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/oversize.json +1 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/short-claim.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/subcategory-other-category.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/trailing-data.json +1 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/unknown-field.json +12 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/unsupported-version.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/updated-at-not-date.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/updated-at-offset.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/invalid/wrong-case-field.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/valid/category-without-subcategory.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/valid/full.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/valid/minimal.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/valid/no-claim.json +10 -0
- package/src/telemetry-contract/ranking/fixtures/valid/padded-text.json +11 -0
- package/src/telemetry-contract/ranking/fixtures/valid/unicode-name.json +11 -0
- package/src/telemetry-contract/ranking/listing.v1.schema.json +61 -0
- package/src/telemetry-contract/ranking/taxonomy.json +8 -0
- package/src/telemetry-contract/ranking-taxonomy.gen.ts +11 -0
- package/src/telemetry-contract/types.gen.ts +963 -58
- package/src/telemetry-identity.ts +47 -9
- package/src/telemetry-snapshot.ts +9 -1
- package/src/telemetry-ui-events.ts +9 -2
- package/src/telemetry.ts +40 -5
- package/src/tests/app-action-run-tool.test.ts +178 -0
- package/src/tests/app-row-tools.test.ts +360 -0
- package/src/tests/apps-rbac.test.ts +189 -2
- package/src/tests/apps-script-types.test.ts +16 -3
- package/src/tests/credential-check.test.ts +38 -0
- package/src/tests/db-extraction-contract.test.ts +1 -0
- package/src/tests/db-task-read-contract.test.ts +1 -0
- package/src/tests/docs-index-footprint.test.js +2 -2
- package/src/tests/fleet-benchmark.test.ts +122 -2
- package/src/tests/http-users.test.ts +62 -1
- package/src/tests/model-catalog-table.test.ts +63 -0
- package/src/tests/model-profiles-api.test.ts +19 -7
- package/src/tests/models-catalog.test.ts +50 -0
- package/src/tests/onboarding.test.ts +21 -0
- package/src/tests/org-identity.test.ts +44 -0
- package/src/tests/org-website.test.ts +62 -0
- package/src/tests/pi-mono-adapter.test.ts +23 -0
- package/src/tests/pr-body-leaks.test.ts +4 -0
- package/src/tests/pr-room-guard.test.ts +242 -0
- package/src/tests/ranking-listing.test.ts +97 -0
- package/src/tests/ranking-route.test.ts +321 -0
- package/src/tests/ranking-usage.test.ts +50 -0
- package/src/tests/rbac-admission-e2e.test.ts +8 -0
- package/src/tests/rbac-admission.test.ts +38 -0
- package/src/tests/rbac-charact-http.test.ts +4 -3
- package/src/tests/rbac-engine.test.ts +2 -0
- package/src/tests/rbac-roles.test.ts +2 -0
- package/src/tests/realtime-room-surfaces.test.ts +3 -1
- package/src/tests/realtime-session-join-race.test.ts +142 -0
- package/src/tests/realtime-tickets.test.ts +24 -17
- package/src/tests/realtime-transport.test.ts +91 -0
- package/src/tests/reasoning-effort.test.ts +39 -3
- package/src/tests/runner-harness-telemetry-env.test.ts +56 -1
- package/src/tests/session-route-posture.test.ts +639 -0
- package/src/tests/session-sharing-routes.test.ts +282 -0
- package/src/tests/session-sharing.test.ts +526 -0
- package/src/tests/sessions-detail-batch.test.ts +7 -1
- package/src/tests/slack-tool-blocks.test.ts +101 -0
- package/src/tests/slack-update.test.ts +55 -0
- package/src/tests/slack-user-dm.test.ts +177 -0
- package/src/tests/swarm-tool-result-gate.test.ts +2 -4
- package/src/tests/telemetry-context.test.ts +128 -2
- package/src/tests/telemetry-ui-route.test.ts +123 -0
- package/src/tests/tool-annotations.test.ts +3 -2
- package/src/tests/used-by-route.test.ts +153 -9
- package/src/tests/workflow-agent-task-retry.test.ts +130 -4
- package/src/tests/workflow-wait-recovery.test.ts +116 -4
- package/src/tools/app-action-run.ts +63 -0
- package/src/tools/app-rows.ts +234 -0
- package/src/tools/model-catalog/index.ts +1 -1
- package/src/tools/slack-post.ts +18 -12
- package/src/tools/slack-read.ts +13 -1
- package/src/tools/slack-reply.ts +7 -10
- package/src/tools/slack-start-thread.ts +18 -11
- package/src/tools/slack-update.ts +2 -9
- package/src/tools/tool-config.ts +8 -0
- package/src/tools/utils.ts +1 -1
- package/src/tools/workflows/retry-workflow-run.ts +1 -1
- package/src/types.ts +52 -0
- package/src/utils/company-profile.ts +24 -0
- package/src/utils/org-identity.ts +33 -0
- package/src/utils/org-website.ts +58 -21
- package/src/workflows/recovery.ts +10 -22
- package/src/workflows/resume.ts +16 -0
- package/src/workflows/task-step-routing.ts +47 -7
- package/templates/skills/apps/SKILL.md +58 -2
- package/templates/skills/apps/content.md +58 -2
- package/dist/handlers-tb3xgjnm.js +0 -37
- package/dist/index-nyfcdpky.js +0 -39
- package/dist/index-vjn3wbzf.js +0 -38
- package/dist/lead-61kqp604.js +0 -76
- package/dist/worker-4ptnn1ge.js +0 -76
- package/dist/{cli-n5mrsg0f.js → cli-60cgh1rv.js} +3 -3
|
@@ -379,7 +379,10 @@ var SHORT_FLAGS = {
|
|
|
379
379
|
m: "milestone",
|
|
380
380
|
p: "project",
|
|
381
381
|
r: "reviewer",
|
|
382
|
-
T: "template"
|
|
382
|
+
T: "template",
|
|
383
|
+
e: "editor",
|
|
384
|
+
f: "fill",
|
|
385
|
+
w: "web"
|
|
383
386
|
};
|
|
384
387
|
function parseGhArgs(args) {
|
|
385
388
|
const parsed = { positionals: [], flags: [] };
|
|
@@ -824,14 +827,18 @@ function parseWithState(command, initial, initialFlags) {
|
|
|
824
827
|
bodyFiles.push(expanded);
|
|
825
828
|
}
|
|
826
829
|
found.push({
|
|
830
|
+
action,
|
|
827
831
|
cwd: wrapperFlags || dirUnknown ? null : state.dir,
|
|
828
832
|
repos: [...new Set(repos)],
|
|
833
|
+
resolvedRepos: repos.map(expand),
|
|
829
834
|
alsoCheckout,
|
|
830
835
|
unknownTarget,
|
|
831
836
|
texts: [...inline, ...fromStdin ? stdin : []],
|
|
837
|
+
bodyTexts: [...values("body"), ...fromStdin ? stdin : []].map(expand),
|
|
832
838
|
bodyFiles,
|
|
833
839
|
unresolvedBodyFiles,
|
|
834
|
-
opaqueBody: inline.some((value) => value.endsWith("$")) || action === "edit" && target?.endsWith("$") === true || fromStdin && stdin.length === 0 && args.stdinFile === undefined
|
|
840
|
+
opaqueBody: inline.some((value) => value.endsWith("$")) || action === "edit" && target?.endsWith("$") === true || fromStdin && stdin.length === 0 && args.stdinFile === undefined,
|
|
841
|
+
externalBody: values("fill", "fill-first", "fill-verbose", "template", "editor", "web", "recover").length > 0
|
|
835
842
|
});
|
|
836
843
|
};
|
|
837
844
|
const segments = tokenizeShell(command);
|
|
@@ -849,6 +856,21 @@ function parseWithState(command, initial, initialFlags) {
|
|
|
849
856
|
return found;
|
|
850
857
|
}
|
|
851
858
|
var BLOCK_ADVICE = "Paraphrase the motivation ('a maintainer asked for X') and link only public sources (Fixes #N, a public PR or issue). Task, session, agent-fs and Slack permalinks go only under '## Swarm provenance'. Bare Slack ids, ts values and private-chat quotes are blocked everywhere.";
|
|
859
|
+
async function readGhPrBodyFiles(call, readFile) {
|
|
860
|
+
const texts = [];
|
|
861
|
+
let unreadable = call.unresolvedBodyFiles[0];
|
|
862
|
+
for (const bodyFile of call.bodyFiles) {
|
|
863
|
+
try {
|
|
864
|
+
const base = isAbsolute(bodyFile) ? "/" : call.cwd;
|
|
865
|
+
if (base === null)
|
|
866
|
+
throw new Error("unknown working directory");
|
|
867
|
+
texts.push(await readFile(resolve(base, bodyFile)));
|
|
868
|
+
} catch {
|
|
869
|
+
unreadable ??= bodyFile;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return { texts, unreadable };
|
|
873
|
+
}
|
|
852
874
|
async function checkGhPrCommand(command, cwd, deps) {
|
|
853
875
|
if (!/\bgh\b[\s\S]*\bpr\b/.test(command))
|
|
854
876
|
return null;
|
|
@@ -858,18 +880,10 @@ async function checkGhPrCommand(command, cwd, deps) {
|
|
|
858
880
|
for (const leak of findPrBodyLeaks(text))
|
|
859
881
|
leaks.add(leak);
|
|
860
882
|
}
|
|
861
|
-
|
|
862
|
-
for (const
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
if (base === null)
|
|
866
|
-
throw new Error("unknown working directory");
|
|
867
|
-
for (const leak of findPrBodyLeaks(await deps.readFile(resolve(base, bodyFile)))) {
|
|
868
|
-
leaks.add(leak);
|
|
869
|
-
}
|
|
870
|
-
} catch {
|
|
871
|
-
unreadable ??= bodyFile;
|
|
872
|
-
}
|
|
883
|
+
const { texts, unreadable } = await readGhPrBodyFiles(call, deps.readFile);
|
|
884
|
+
for (const text of texts) {
|
|
885
|
+
for (const leak of findPrBodyLeaks(text))
|
|
886
|
+
leaks.add(leak);
|
|
873
887
|
}
|
|
874
888
|
if (leaks.size === 0 && unreadable === undefined)
|
|
875
889
|
continue;
|
|
@@ -940,4 +954,69 @@ async function guardGhPrBody(toolInput, cwd, deps = defaultPrBodyGuardDeps()) {
|
|
|
940
954
|
}
|
|
941
955
|
}
|
|
942
956
|
|
|
943
|
-
|
|
957
|
+
// src/hooks/pr-room-guard.ts
|
|
958
|
+
var BLOCK_REASON = 'This repo uses PR rooms. Create the room first with the pr-room skill (app action createRoom). Then pass the returned prBody with --body-file. The body must contain the line "PR room: prr-...".';
|
|
959
|
+
var ROOM_LINE = /^PR room: prr-[a-z2-7]{10}\b/m;
|
|
960
|
+
var REMOTE_LOOKUP_TIMEOUT_MS = 5000;
|
|
961
|
+
async function gitRemoteOrigin(cwd, timeoutMs = REMOTE_LOOKUP_TIMEOUT_MS) {
|
|
962
|
+
const proc = Bun.spawn(["git", "-C", cwd, "config", "--get", "remote.origin.url"], {
|
|
963
|
+
stdout: "pipe",
|
|
964
|
+
stderr: "ignore",
|
|
965
|
+
stdin: "ignore",
|
|
966
|
+
timeout: timeoutMs,
|
|
967
|
+
killSignal: "SIGKILL"
|
|
968
|
+
});
|
|
969
|
+
const [out, code] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
|
|
970
|
+
if (code !== 0)
|
|
971
|
+
throw new Error("Cannot resolve checkout remote");
|
|
972
|
+
return out.trim();
|
|
973
|
+
}
|
|
974
|
+
var defaultDeps = () => ({
|
|
975
|
+
env: process.env,
|
|
976
|
+
readFile: (path) => Bun.file(path).text(),
|
|
977
|
+
remoteOrigin: (cwd) => gitRemoteOrigin(cwd)
|
|
978
|
+
});
|
|
979
|
+
function repoFromRemote(remote) {
|
|
980
|
+
const match = /^(?:https?:\/\/[^/]+\/|ssh:\/\/[^/]+\/|[^\s/@:]+@[^\s/:]+:)([^/\s]+)\/([^/\s]+?)\/?$/.exec(remote.trim());
|
|
981
|
+
return match ? `${match[1]}/${match[2]?.replace(/\.git$/, "")}`.toLowerCase() : undefined;
|
|
982
|
+
}
|
|
983
|
+
async function guardGhPrRoom(toolInput, cwd, deps = defaultDeps()) {
|
|
984
|
+
try {
|
|
985
|
+
const repos = new Set((deps.env.PR_ROOM_REPOS ?? "").split(",").map((repo) => repo.trim().toLowerCase()).filter(Boolean));
|
|
986
|
+
if (repos.size === 0)
|
|
987
|
+
return null;
|
|
988
|
+
const command = shellCommandOf(toolInput);
|
|
989
|
+
if (command === null)
|
|
990
|
+
return null;
|
|
991
|
+
for (const call of parseGhPrCommands(command, cwd, deps.env)) {
|
|
992
|
+
if (call.action !== "create" || call.unknownTarget || call.cwd === null)
|
|
993
|
+
continue;
|
|
994
|
+
if (call.opaqueBody || call.externalBody || call.bodyTexts.includes(null))
|
|
995
|
+
continue;
|
|
996
|
+
const targets = [...call.resolvedRepos];
|
|
997
|
+
if (targets.includes(null))
|
|
998
|
+
continue;
|
|
999
|
+
if (targets.length === 0 || call.alsoCheckout) {
|
|
1000
|
+
try {
|
|
1001
|
+
const repo = repoFromRemote(await deps.remoteOrigin(call.cwd));
|
|
1002
|
+
if (!repo)
|
|
1003
|
+
continue;
|
|
1004
|
+
targets.push(repo);
|
|
1005
|
+
} catch {
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
if (!targets.every((repo) => repo !== null && repos.has(repo.trim().toLowerCase())))
|
|
1010
|
+
continue;
|
|
1011
|
+
const body = await readGhPrBodyFiles(call, deps.readFile);
|
|
1012
|
+
if (body.unreadable !== undefined)
|
|
1013
|
+
continue;
|
|
1014
|
+
const texts = [...call.bodyTexts, ...body.texts];
|
|
1015
|
+
if (!texts.some((text) => text !== null && ROOM_LINE.test(text)))
|
|
1016
|
+
return BLOCK_REASON;
|
|
1017
|
+
}
|
|
1018
|
+
} catch {}
|
|
1019
|
+
return null;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
export { guardGhPrBody, guardGhPrRoom };
|
|
@@ -1637,7 +1637,7 @@ function checkExtensionInstallSource(body, ctx) {
|
|
|
1637
1637
|
ctx.addIssue({ code: "custom", path: ["files"], message: "files is required with manifest" });
|
|
1638
1638
|
}
|
|
1639
1639
|
}
|
|
1640
|
-
var AssetKeySchema, AssetEntityTypeSchema, AssetProviderRefSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, RoutingReasonSchema, RoutingSourceSchema, ProviderNameSchema, ModelProfileNameSchema, ModelProfileSchema, SteerModeSchema, SteeringStatusSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, PROVIDER_STEER_CAPABILITIES, FollowUpConfigSchema, RoutingAffinitySchema, AgentTaskSchema, CreateTaskOptionsSchema, TaskAttachmentKindSchema, SERVER_GENERATED_ATTACHMENT_CAPABILITY = "_agentSwarmGeneratedBy", attachmentCapabilitiesSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, UserCommsPrefsSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AcpSessionConfigSelectValueSchema, AcpSessionConfigSelectGroupSchema, AcpSessionConfigOptionSchema, AgentAcpStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, AutomationIntegrationIdSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, REPO_GUIDELINES_MAX_ENTRIES = 50, RepoGuidelinesInputSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, WorkerNudgeSchema, RuntimeInstanceStatusSchema, RuntimeProviderKindSchema, DeliveryModeSchema, PoolLifecycleSchema, RuntimeResourcesSchema, RuntimeControllerCreateSchema, RuntimeControllerUpdateSchema, RuntimeControllerSchema, RuntimePoolCreateSchema, RuntimePoolUpdateSchema, RuntimePoolSchema, RuntimePoolCreateAgentSchema, RuntimeInstanceSchema, RetryPolicySchema, ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, WebhookVerificationSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, WorkflowRunParentSchema, WorkflowRunSummarySchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ExtensionNameSchema, SemverSchema, ExtensionBundlePathSchema, ExtensionAssetNameSchema, ExtensionScriptAssetSchema, ExtensionScheduleAssetSchema, ExtensionWorkflowAssetSchema, ExtensionSkillAssetSchema, ExtensionWorkflowFileSchema, ExtensionManifestSchema, ExtensionStatusSchema, ExtensionSchema, ExtensionFileSchema, ExtensionVersionSchema, ExtensionRunSchema, ExtensionInstallBodySchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
|
|
1640
|
+
var AssetKeySchema, AssetEntityTypeSchema, AssetProviderRefSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, RoutingReasonSchema, RoutingSourceSchema, ProviderNameSchema, ModelProfileNameSchema, ModelProfileSchema, SessionShareAccessSchema, SessionAccessSchema, SessionOwnerSchema, SessionSharesSchema, SessionSharesUpdateSchema, SteerModeSchema, SteeringStatusSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, PROVIDER_STEER_CAPABILITIES, FollowUpConfigSchema, RoutingAffinitySchema, AgentTaskSchema, CreateTaskOptionsSchema, TaskAttachmentKindSchema, SERVER_GENERATED_ATTACHMENT_CAPABILITY = "_agentSwarmGeneratedBy", attachmentCapabilitiesSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, UserCommsPrefsSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AgentOpencodeGoStatusSchema, AcpSessionConfigSelectValueSchema, AcpSessionConfigSelectGroupSchema, AcpSessionConfigOptionSchema, AgentAcpStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, AutomationIntegrationIdSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, REPO_GUIDELINES_MAX_ENTRIES = 50, RepoGuidelinesInputSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, WorkerNudgeSchema, RuntimeInstanceStatusSchema, RuntimeProviderKindSchema, DeliveryModeSchema, PoolLifecycleSchema, RuntimeResourcesSchema, RuntimeControllerCreateSchema, RuntimeControllerUpdateSchema, RuntimeControllerSchema, RuntimePoolCreateSchema, RuntimePoolUpdateSchema, RuntimePoolSchema, RuntimePoolCreateAgentSchema, RuntimeInstanceSchema, RetryPolicySchema, SUPERSEDED_WORKFLOW_TASK_REASON = "superseded_workflow_task", ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, WebhookVerificationSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, WorkflowRunParentSchema, WorkflowRunSummarySchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ExtensionNameSchema, SemverSchema, ExtensionBundlePathSchema, ExtensionAssetNameSchema, ExtensionScriptAssetSchema, ExtensionScheduleAssetSchema, ExtensionWorkflowAssetSchema, ExtensionSkillAssetSchema, ExtensionWorkflowFileSchema, ExtensionManifestSchema, ExtensionStatusSchema, ExtensionSchema, ExtensionFileSchema, ExtensionVersionSchema, ExtensionRunSchema, ExtensionInstallBodySchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
|
|
1641
1641
|
var init_types = __esm(() => {
|
|
1642
1642
|
init_key();
|
|
1643
1643
|
init_bundle_path();
|
|
@@ -1855,6 +1855,17 @@ var init_types = __esm(() => {
|
|
|
1855
1855
|
createdAt: string2(),
|
|
1856
1856
|
lastUpdatedAt: string2()
|
|
1857
1857
|
});
|
|
1858
|
+
SessionShareAccessSchema = _enum2(["read", "write"]);
|
|
1859
|
+
SessionAccessSchema = _enum2(["owner", "write", "read"]);
|
|
1860
|
+
SessionOwnerSchema = object2({ id: string2(), name: string2() }).openapi("SessionOwner");
|
|
1861
|
+
SessionSharesSchema = object2({
|
|
1862
|
+
everyone: _enum2(["none", "read", "write"]),
|
|
1863
|
+
users: array2(object2({ userId: string2(), access: SessionShareAccessSchema, createdAt: string2() }))
|
|
1864
|
+
}).openapi("SessionShares");
|
|
1865
|
+
SessionSharesUpdateSchema = object2({
|
|
1866
|
+
everyone: _enum2(["none", "read", "write"]),
|
|
1867
|
+
users: array2(object2({ userId: string2().min(1), access: SessionShareAccessSchema })).max(500)
|
|
1868
|
+
});
|
|
1858
1869
|
SteerModeSchema = _enum2(["steer", "queue"]);
|
|
1859
1870
|
SteeringStatusSchema = _enum2([
|
|
1860
1871
|
"pending",
|
|
@@ -2254,6 +2265,10 @@ var init_types = __esm(() => {
|
|
|
2254
2265
|
models: array2(object2({ id: string2(), name: string2() })).default([]),
|
|
2255
2266
|
error: string2().optional()
|
|
2256
2267
|
}).openapi("AgentBedrockStatus");
|
|
2268
|
+
AgentOpencodeGoStatusSchema = object2({
|
|
2269
|
+
probedAt: number2(),
|
|
2270
|
+
models: array2(string2()).default([])
|
|
2271
|
+
}).openapi("AgentOpencodeGoStatus");
|
|
2257
2272
|
AcpSessionConfigSelectValueSchema = object2({
|
|
2258
2273
|
value: string2(),
|
|
2259
2274
|
name: string2(),
|
|
@@ -2298,6 +2313,7 @@ var init_types = __esm(() => {
|
|
|
2298
2313
|
reportedAt: number2(),
|
|
2299
2314
|
reportKind: _enum2(["boot", "post_task"]).default("boot"),
|
|
2300
2315
|
bedrock: AgentBedrockStatusSchema.nullable().default(null),
|
|
2316
|
+
opencodeGo: AgentOpencodeGoStatusSchema.nullable().default(null),
|
|
2301
2317
|
acp: AgentAcpStatusSchema.nullable().default(null)
|
|
2302
2318
|
}).openapi("AgentCredStatus");
|
|
2303
2319
|
AgentWithTasksSchema = AgentSchema.extend({
|
|
@@ -3632,4 +3648,4 @@ var init_types = __esm(() => {
|
|
|
3632
3648
|
}).openapi("KvEntry");
|
|
3633
3649
|
});
|
|
3634
3650
|
|
|
3635
|
-
export { normalizeAssetKey, defaultAssetKey, parseAssetKey, isCanonicalAssetKey, canWriteAssetKey, init_key, isSafeBundlePath, init_bundle_path, $OpenAPIRegistry, $OpenApiGeneratorV31, init_dist, init_zod_openapi, AssetKeySchema, AssetEntityTypeSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, DEFAULT_MODEL_TIER_MAP, parseModelTier, splitLegacyModelAlias, parseWorkerModelTierOverrides, resolveTaskModelSelection, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, isTerminalTaskStatus, AgentTaskSourceSchema, RoutingReasonSchema, ProviderNameSchema, ModelProfileNameSchema, ModelProfileSchema, SteerModeSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, PROVIDER_STEER_CAPABILITIES, FollowUpConfigSchema, RoutingAffinitySchema, AgentTaskSchema, CreateTaskOptionsSchema, SERVER_GENERATED_ATTACHMENT_CAPABILITY, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, UserCommsPrefsSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentLatestModelSchema, AgentAcpStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, VersionableFieldSchema, ChannelTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, AutomationIntegrationIdSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesInputSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, WorkerNudgeSchema, RuntimeProviderKindSchema, DeliveryModeSchema, RuntimeControllerCreateSchema, RuntimeControllerUpdateSchema, RuntimeControllerSchema, RuntimePoolCreateSchema, RuntimePoolUpdateSchema, RuntimePoolSchema, RuntimePoolCreateAgentSchema, RuntimeInstanceSchema, RetryPolicySchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSchema, PageVersionSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, WorkflowRunParentSchema, WorkflowRunSummarySchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ExtensionWorkflowFileSchema, ExtensionManifestSchema, ExtensionSchema, ExtensionVersionSchema, ExtensionRunSchema, checkExtensionInstallSource, ExtensionInstallBodySchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types };
|
|
3651
|
+
export { normalizeAssetKey, defaultAssetKey, parseAssetKey, isCanonicalAssetKey, canWriteAssetKey, init_key, isSafeBundlePath, init_bundle_path, $OpenAPIRegistry, $OpenApiGeneratorV31, init_dist, init_zod_openapi, AssetKeySchema, AssetEntityTypeSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, DEFAULT_MODEL_TIER_MAP, parseModelTier, splitLegacyModelAlias, parseWorkerModelTierOverrides, resolveTaskModelSelection, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, isTerminalTaskStatus, AgentTaskSourceSchema, RoutingReasonSchema, ProviderNameSchema, ModelProfileNameSchema, ModelProfileSchema, SessionAccessSchema, SessionOwnerSchema, SessionSharesSchema, SessionSharesUpdateSchema, SteerModeSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, PROVIDER_STEER_CAPABILITIES, FollowUpConfigSchema, RoutingAffinitySchema, AgentTaskSchema, CreateTaskOptionsSchema, SERVER_GENERATED_ATTACHMENT_CAPABILITY, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, UserCommsPrefsSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentLatestModelSchema, AgentAcpStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, VersionableFieldSchema, ChannelTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, AutomationIntegrationIdSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesInputSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, WorkerNudgeSchema, RuntimeProviderKindSchema, DeliveryModeSchema, RuntimeControllerCreateSchema, RuntimeControllerUpdateSchema, RuntimeControllerSchema, RuntimePoolCreateSchema, RuntimePoolUpdateSchema, RuntimePoolSchema, RuntimePoolCreateAgentSchema, RuntimeInstanceSchema, RetryPolicySchema, SUPERSEDED_WORKFLOW_TASK_REASON, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSchema, PageVersionSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, WorkflowRunParentSchema, WorkflowRunSummarySchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ExtensionWorkflowFileSchema, ExtensionManifestSchema, ExtensionSchema, ExtensionVersionSchema, ExtensionRunSchema, checkExtensionInstallSource, ExtensionInstallBodySchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types };
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDbClient2,
|
|
3
|
+
scheduleOrgDomainRecompute,
|
|
4
|
+
init_telemetry_identity,
|
|
5
|
+
validateRuntimeTokenTtlHours,
|
|
6
|
+
init_swarm_config_guard,
|
|
7
|
+
init_db3
|
|
8
|
+
} from "./cli-rqqsfz30.js";
|
|
9
|
+
import {
|
|
10
|
+
unregisterVolatileSecret,
|
|
11
|
+
init_secret_scrubber
|
|
12
|
+
} from "./cli-xf234ws8.js";
|
|
13
|
+
import {
|
|
14
|
+
__esm
|
|
15
|
+
} from "./cli-242037k3.js";
|
|
16
|
+
|
|
17
|
+
// src/utils/session-token-connections.ts
|
|
18
|
+
function registerSessionTokenConnection(tokenId, close) {
|
|
19
|
+
let callbacks = connections.get(tokenId);
|
|
20
|
+
if (!callbacks) {
|
|
21
|
+
callbacks = new Set;
|
|
22
|
+
connections.set(tokenId, callbacks);
|
|
23
|
+
}
|
|
24
|
+
callbacks.add(close);
|
|
25
|
+
return () => {
|
|
26
|
+
callbacks.delete(close);
|
|
27
|
+
if (callbacks.size === 0)
|
|
28
|
+
connections.delete(tokenId);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function closeSessionTokenConnections(tokenIds) {
|
|
32
|
+
for (const tokenId of tokenIds) {
|
|
33
|
+
for (const close of connections.get(tokenId) ?? [])
|
|
34
|
+
close();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
var connections;
|
|
38
|
+
var init_session_token_connections = __esm(() => {
|
|
39
|
+
connections = new Map;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// src/be/users.ts
|
|
43
|
+
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
44
|
+
function actorString(actor) {
|
|
45
|
+
return `${actor.kind}:${actor.id}`;
|
|
46
|
+
}
|
|
47
|
+
function rowToUser(row) {
|
|
48
|
+
return {
|
|
49
|
+
id: row.id,
|
|
50
|
+
name: row.name,
|
|
51
|
+
email: row.email ?? undefined,
|
|
52
|
+
role: row.role ?? undefined,
|
|
53
|
+
notes: row.notes ?? undefined,
|
|
54
|
+
emailAliases: row.emailAliases ? JSON.parse(row.emailAliases) : [],
|
|
55
|
+
preferredChannel: row.preferredChannel ?? "slack",
|
|
56
|
+
timezone: row.timezone ?? undefined,
|
|
57
|
+
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
|
|
58
|
+
dailyBudgetUsd: row.dailyBudgetUsd ?? null,
|
|
59
|
+
status: row.status ?? "active",
|
|
60
|
+
createdAt: row.createdAt,
|
|
61
|
+
lastUpdatedAt: row.lastUpdatedAt
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function findUserById(id) {
|
|
65
|
+
const row = await getDbClient2().get("SELECT * FROM users WHERE id = ?", [id]);
|
|
66
|
+
return row ? rowToUser(row) : null;
|
|
67
|
+
}
|
|
68
|
+
async function findUserByExternalId(kind, externalId) {
|
|
69
|
+
const row = await getDbClient2().get(`SELECT u.* FROM users u
|
|
70
|
+
INNER JOIN user_external_ids x ON x.userId = u.id
|
|
71
|
+
WHERE x.kind = ? AND x.externalId = ?`, [kind, externalId]);
|
|
72
|
+
return row ? rowToUser(row) : null;
|
|
73
|
+
}
|
|
74
|
+
async function findUserByEmail(email) {
|
|
75
|
+
const lower = email.toLowerCase();
|
|
76
|
+
const db = getDbClient2();
|
|
77
|
+
const primary = await db.get("SELECT * FROM users WHERE LOWER(email) = LOWER(?)", [
|
|
78
|
+
email
|
|
79
|
+
]);
|
|
80
|
+
if (primary)
|
|
81
|
+
return rowToUser(primary);
|
|
82
|
+
const aliasRows = await db.query("SELECT * FROM users WHERE emailAliases IS NOT NULL AND emailAliases != '[]'");
|
|
83
|
+
for (const r of aliasRows) {
|
|
84
|
+
const aliases = r.emailAliases ? JSON.parse(r.emailAliases) : [];
|
|
85
|
+
if (aliases.some((a) => a.toLowerCase() === lower)) {
|
|
86
|
+
return rowToUser(r);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
async function findUsersByName(name) {
|
|
92
|
+
const trimmed = name.trim();
|
|
93
|
+
if (!trimmed)
|
|
94
|
+
return [];
|
|
95
|
+
const client = getDbClient2();
|
|
96
|
+
const exact = await client.query("SELECT * FROM users WHERE LOWER(name) = LOWER(?)", [
|
|
97
|
+
trimmed
|
|
98
|
+
]);
|
|
99
|
+
if (exact.length > 0)
|
|
100
|
+
return exact.map(rowToUser);
|
|
101
|
+
const firstToken = trimmed.split(/\s+/)[0] ?? trimmed;
|
|
102
|
+
const prefixed = await client.query("SELECT * FROM users WHERE LOWER(name) LIKE LOWER(?) || '%'", [firstToken]);
|
|
103
|
+
return prefixed.map(rowToUser);
|
|
104
|
+
}
|
|
105
|
+
async function getUserIdentities(userId) {
|
|
106
|
+
return getDbClient2().query("SELECT kind, externalId FROM user_external_ids WHERE userId = ? ORDER BY kind, externalId", [userId]);
|
|
107
|
+
}
|
|
108
|
+
function rowToEvent(row) {
|
|
109
|
+
return {
|
|
110
|
+
id: row.id,
|
|
111
|
+
userId: row.userId,
|
|
112
|
+
eventType: row.eventType,
|
|
113
|
+
actor: row.actor,
|
|
114
|
+
before: row.beforeJson == null ? null : JSON.parse(row.beforeJson),
|
|
115
|
+
after: row.afterJson == null ? null : JSON.parse(row.afterJson),
|
|
116
|
+
createdAt: row.createdAt
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
async function listUserEvents(userId, opts = {}) {
|
|
120
|
+
const limit = Math.max(1, Math.min(opts.limit ?? 50, 200));
|
|
121
|
+
const before = opts.before;
|
|
122
|
+
const client = getDbClient2();
|
|
123
|
+
if (before) {
|
|
124
|
+
const rows = await client.query(`SELECT id, userId, eventType, actor, beforeJson, afterJson, createdAt
|
|
125
|
+
FROM user_identity_events
|
|
126
|
+
WHERE userId = ? AND createdAt < ?
|
|
127
|
+
ORDER BY createdAt DESC, rowid DESC
|
|
128
|
+
LIMIT ?`, [userId, before, limit]);
|
|
129
|
+
return rows.map(rowToEvent);
|
|
130
|
+
}
|
|
131
|
+
const rows = await client.query(`SELECT id, userId, eventType, actor, beforeJson, afterJson, createdAt
|
|
132
|
+
FROM user_identity_events
|
|
133
|
+
WHERE userId = ?
|
|
134
|
+
ORDER BY createdAt DESC, rowid DESC
|
|
135
|
+
LIMIT ?`, [userId, limit]);
|
|
136
|
+
return rows.map(rowToEvent);
|
|
137
|
+
}
|
|
138
|
+
async function listUserTokens(userId) {
|
|
139
|
+
return getDbClient2().query(`SELECT id, userId, label, tokenPreview, createdAt, lastUsedAt, revokedAt
|
|
140
|
+
FROM user_tokens
|
|
141
|
+
WHERE userId = ?
|
|
142
|
+
ORDER BY createdAt DESC`, [userId]);
|
|
143
|
+
}
|
|
144
|
+
async function recordIdentityEvent(userId, eventType, actor, before, after) {
|
|
145
|
+
await getDbClient2().run(`INSERT INTO user_identity_events (id, userId, eventType, actor, beforeJson, afterJson, createdAt)
|
|
146
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`, [
|
|
147
|
+
randomUUID().replace(/-/g, ""),
|
|
148
|
+
userId,
|
|
149
|
+
eventType,
|
|
150
|
+
actorString(actor),
|
|
151
|
+
before == null ? null : JSON.stringify(before),
|
|
152
|
+
after == null ? null : JSON.stringify(after),
|
|
153
|
+
new Date().toISOString()
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
async function findOrCreateUserByEmail(email, hints, actor) {
|
|
157
|
+
const existing = await findUserByEmail(email);
|
|
158
|
+
if (existing) {
|
|
159
|
+
await recordIdentityEvent(existing.id, "auto_merge", actor, null, { email, hints });
|
|
160
|
+
return { user: existing, created: false };
|
|
161
|
+
}
|
|
162
|
+
const id = randomUUID().replace(/-/g, "");
|
|
163
|
+
const now = new Date().toISOString();
|
|
164
|
+
const name = hints.name?.trim() || email.split("@")[0] || email;
|
|
165
|
+
const created = await getDbClient2().transaction(async (tx) => {
|
|
166
|
+
await tx.run(`INSERT INTO users (id, name, email, role, notes, emailAliases, preferredChannel, timezone, createdAt, lastUpdatedAt, status)
|
|
167
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'active')`, [
|
|
168
|
+
id,
|
|
169
|
+
name,
|
|
170
|
+
email,
|
|
171
|
+
hints.role ?? null,
|
|
172
|
+
hints.notes ?? null,
|
|
173
|
+
"[]",
|
|
174
|
+
hints.preferredChannel ?? "slack",
|
|
175
|
+
null,
|
|
176
|
+
now,
|
|
177
|
+
now
|
|
178
|
+
]);
|
|
179
|
+
const row = await tx.get("SELECT * FROM users WHERE id = ?", [id]);
|
|
180
|
+
if (!row)
|
|
181
|
+
throw new Error("Failed to create user");
|
|
182
|
+
await recordIdentityEvent(id, "identity_added", actor, null, { email, name });
|
|
183
|
+
return rowToUser(row);
|
|
184
|
+
});
|
|
185
|
+
getDbClient2().afterCommit(scheduleOrgDomainRecompute);
|
|
186
|
+
return { user: created, created: true };
|
|
187
|
+
}
|
|
188
|
+
async function linkIdentity(userId, kind, externalId, actor) {
|
|
189
|
+
await getDbClient2().transaction(async (tx) => {
|
|
190
|
+
await tx.run("INSERT INTO user_external_ids (userId, kind, externalId) VALUES (?, ?, ?)", [
|
|
191
|
+
userId,
|
|
192
|
+
kind,
|
|
193
|
+
externalId
|
|
194
|
+
]);
|
|
195
|
+
await recordIdentityEvent(userId, "identity_added", actor, null, { kind, externalId });
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
async function unlinkIdentity(userId, kind, externalId, actor) {
|
|
199
|
+
await getDbClient2().transaction(async (tx) => {
|
|
200
|
+
await tx.run("DELETE FROM user_external_ids WHERE userId = ? AND kind = ? AND externalId = ?", [
|
|
201
|
+
userId,
|
|
202
|
+
kind,
|
|
203
|
+
externalId
|
|
204
|
+
]);
|
|
205
|
+
await recordIdentityEvent(userId, "identity_removed", actor, { kind, externalId }, null);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function base62(bytes) {
|
|
209
|
+
const alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
210
|
+
let out = "";
|
|
211
|
+
for (const b of bytes) {
|
|
212
|
+
out += alphabet[b % 62];
|
|
213
|
+
}
|
|
214
|
+
return out;
|
|
215
|
+
}
|
|
216
|
+
function sha256Hex(input) {
|
|
217
|
+
return createHash("sha256").update(input).digest("hex");
|
|
218
|
+
}
|
|
219
|
+
async function mintToken(userId, label, actor, options = {}) {
|
|
220
|
+
const plaintext = `${TOKEN_PREFIX}${base62(randomBytes(24))}`;
|
|
221
|
+
const tokenId = randomUUID().replace(/-/g, "");
|
|
222
|
+
const hash = sha256Hex(plaintext);
|
|
223
|
+
const preview = plaintext.slice(-4);
|
|
224
|
+
const now = new Date().toISOString();
|
|
225
|
+
await getDbClient2().transaction(async (tx) => {
|
|
226
|
+
await tx.run(`INSERT INTO user_tokens (id, userId, label, tokenHash, tokenPreview, createdAt)
|
|
227
|
+
VALUES (?, ?, ?, ?, ?, ?)`, [tokenId, userId, label, hash, preview, now]);
|
|
228
|
+
await recordIdentityEvent(userId, "token_minted", actor, null, {
|
|
229
|
+
tokenId,
|
|
230
|
+
label,
|
|
231
|
+
preview,
|
|
232
|
+
...options.source ? { source: options.source } : {}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
return { tokenId, plaintext };
|
|
236
|
+
}
|
|
237
|
+
async function revokeToken(tokenId, actor) {
|
|
238
|
+
await getDbClient2().transaction(async (tx) => {
|
|
239
|
+
const row = await tx.get("SELECT userId, label, tokenPreview FROM user_tokens WHERE id = ?", [tokenId]);
|
|
240
|
+
if (!row) {
|
|
241
|
+
throw new Error(`Token not found: ${tokenId}`);
|
|
242
|
+
}
|
|
243
|
+
await tx.run("UPDATE user_tokens SET revokedAt = ? WHERE id = ?", [
|
|
244
|
+
new Date().toISOString(),
|
|
245
|
+
tokenId
|
|
246
|
+
]);
|
|
247
|
+
await recordIdentityEvent(row.userId, "token_revoked", actor, { tokenId, label: row.label, preview: row.tokenPreview }, null);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
async function resolveUserByToken(plaintext) {
|
|
251
|
+
const hash = sha256Hex(plaintext);
|
|
252
|
+
const client = getDbClient2();
|
|
253
|
+
const row = await client.get("SELECT id, userId, revokedAt FROM user_tokens WHERE tokenHash = ?", [hash]);
|
|
254
|
+
if (!row || row.revokedAt !== null)
|
|
255
|
+
return null;
|
|
256
|
+
try {
|
|
257
|
+
await client.run("UPDATE user_tokens SET lastUsedAt = ? WHERE id = ?", [
|
|
258
|
+
new Date().toISOString(),
|
|
259
|
+
row.id
|
|
260
|
+
]);
|
|
261
|
+
} catch {}
|
|
262
|
+
return findUserById(row.userId);
|
|
263
|
+
}
|
|
264
|
+
async function mintSessionToken(agentId, taskId, ttlMs, parent) {
|
|
265
|
+
if (parent) {
|
|
266
|
+
return await getDbClient2().transaction(async (client) => {
|
|
267
|
+
const row = await client.get(`SELECT expiresAt FROM session_tokens WHERE id = ? AND agentId = ? AND runtimeId = ?
|
|
268
|
+
AND revokedAt IS NULL AND expiresAt > ?`, [parent.tokenId, agentId, parent.runtimeId, new Date().toISOString()]);
|
|
269
|
+
if (!row)
|
|
270
|
+
throw new InvalidRuntimeTokenError;
|
|
271
|
+
return await insertSessionToken(agentId, taskId, null, ttlMs, parent.runtimeId, row.expiresAt);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return await insertSessionToken(agentId, taskId, null, ttlMs);
|
|
275
|
+
}
|
|
276
|
+
function runtimeTokenTtlMs() {
|
|
277
|
+
const hours = process.env.RUNTIME_TOKEN_TTL_HOURS ?? "168";
|
|
278
|
+
return (validateRuntimeTokenTtlHours(hours) === null ? Number(hours) : 168) * 60 * 60 * 1000;
|
|
279
|
+
}
|
|
280
|
+
async function mintRuntimeToken(agentId, runtimeId, ttlMs = runtimeTokenTtlMs()) {
|
|
281
|
+
return await insertSessionToken(agentId, null, runtimeId, ttlMs);
|
|
282
|
+
}
|
|
283
|
+
async function insertSessionToken(agentId, taskId, runtimeId, ttlMs, parentRuntimeId = null, expiresAtCeiling, controllerId = null) {
|
|
284
|
+
const plaintext = `${SESSION_TOKEN_PREFIX}${base62(randomBytes(24))}`;
|
|
285
|
+
const tokenId = randomUUID().replace(/-/g, "");
|
|
286
|
+
const hash = sha256Hex(plaintext);
|
|
287
|
+
const preview = plaintext.slice(-4);
|
|
288
|
+
const now = new Date;
|
|
289
|
+
const expiresAt = new Date(Math.min(now.getTime() + ttlMs, expiresAtCeiling ? Date.parse(expiresAtCeiling) : Infinity)).toISOString();
|
|
290
|
+
await getDbClient2().run(`INSERT INTO session_tokens
|
|
291
|
+
(id, tokenHash, tokenPreview, agentId, taskId, runtimeId, parentRuntimeId, expiresAt, createdAt, controllerId)
|
|
292
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
293
|
+
tokenId,
|
|
294
|
+
hash,
|
|
295
|
+
preview,
|
|
296
|
+
agentId,
|
|
297
|
+
taskId,
|
|
298
|
+
runtimeId,
|
|
299
|
+
parentRuntimeId,
|
|
300
|
+
expiresAt,
|
|
301
|
+
now.toISOString(),
|
|
302
|
+
controllerId
|
|
303
|
+
]);
|
|
304
|
+
return { tokenId, plaintext };
|
|
305
|
+
}
|
|
306
|
+
async function revokeSessionToken(tokenId) {
|
|
307
|
+
await getDbClient2().transaction(async (client) => {
|
|
308
|
+
const row = await client.get("SELECT runtimeId FROM session_tokens WHERE id = ?", [tokenId]);
|
|
309
|
+
if (row?.runtimeId) {
|
|
310
|
+
await revokeRuntimeTokensForRuntime(row.runtimeId);
|
|
311
|
+
} else {
|
|
312
|
+
await client.run("UPDATE session_tokens SET revokedAt = ? WHERE id = ? AND revokedAt IS NULL", [new Date().toISOString(), tokenId]);
|
|
313
|
+
getDbClient2().afterCommit(() => closeSessionTokenConnections([tokenId]));
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
async function revokeRuntimeTokensForRuntime(runtimeId) {
|
|
318
|
+
await getDbClient2().transaction(async (client) => {
|
|
319
|
+
const rows = await client.query("SELECT id FROM session_tokens WHERE runtimeId = ? OR parentRuntimeId = ?", [runtimeId, runtimeId]);
|
|
320
|
+
await client.run(`UPDATE session_tokens SET revokedAt = ?
|
|
321
|
+
WHERE (runtimeId = ? OR parentRuntimeId = ?) AND revokedAt IS NULL`, [new Date().toISOString(), runtimeId, runtimeId]);
|
|
322
|
+
getDbClient2().afterCommit(() => {
|
|
323
|
+
unregisterVolatileSecret(`runtime:${runtimeId}`);
|
|
324
|
+
closeSessionTokenConnections(rows.map((row) => row.id));
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
async function resolveSessionToken(plaintext, options = {}) {
|
|
329
|
+
if (!plaintext.startsWith(SESSION_TOKEN_PREFIX))
|
|
330
|
+
return null;
|
|
331
|
+
const hash = sha256Hex(plaintext);
|
|
332
|
+
const client = getDbClient2();
|
|
333
|
+
const row = await client.get(`SELECT s.id, s.agentId, s.taskId, s.runtimeId, s.controllerId, s.expiresAt, s.revokedAt,
|
|
334
|
+
c.placement FROM session_tokens s LEFT JOIN runtime_controllers c ON c.id = s.controllerId
|
|
335
|
+
WHERE s.tokenHash = ?`, [hash]);
|
|
336
|
+
if (!row || row.revokedAt !== null)
|
|
337
|
+
return null;
|
|
338
|
+
if (new Date(row.expiresAt) <= new Date)
|
|
339
|
+
return null;
|
|
340
|
+
if (row.controllerId !== null) {
|
|
341
|
+
return row.placement === "remote" ? {
|
|
342
|
+
kind: "controller",
|
|
343
|
+
controllerId: row.controllerId,
|
|
344
|
+
tokenId: row.id,
|
|
345
|
+
expiresAt: row.expiresAt
|
|
346
|
+
} : null;
|
|
347
|
+
}
|
|
348
|
+
if (options.touch !== false) {
|
|
349
|
+
try {
|
|
350
|
+
await client.run("UPDATE session_tokens SET lastUsedAt = ? WHERE id = ?", [
|
|
351
|
+
new Date().toISOString(),
|
|
352
|
+
row.id
|
|
353
|
+
]);
|
|
354
|
+
} catch {}
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
kind: "agent",
|
|
358
|
+
tokenId: row.id,
|
|
359
|
+
agentId: row.agentId,
|
|
360
|
+
taskId: row.taskId,
|
|
361
|
+
runtimeId: row.runtimeId,
|
|
362
|
+
expiresAt: row.expiresAt
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
function fingerprintApiKey(rawKey) {
|
|
366
|
+
return `op:${sha256Hex(rawKey).slice(0, 16)}`;
|
|
367
|
+
}
|
|
368
|
+
var TOKEN_PREFIX = "aswt_", SESSION_TOKEN_PREFIX = "aseph_", InvalidRuntimeTokenError;
|
|
369
|
+
var init_users = __esm(() => {
|
|
370
|
+
init_telemetry_identity();
|
|
371
|
+
init_secret_scrubber();
|
|
372
|
+
init_session_token_connections();
|
|
373
|
+
init_db3();
|
|
374
|
+
init_swarm_config_guard();
|
|
375
|
+
InvalidRuntimeTokenError = class InvalidRuntimeTokenError extends Error {
|
|
376
|
+
constructor() {
|
|
377
|
+
super("Runtime token is no longer valid");
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
export { registerSessionTokenConnection, closeSessionTokenConnections, init_session_token_connections, findUserById, findUserByExternalId, findUserByEmail, findUsersByName, getUserIdentities, listUserEvents, listUserTokens, recordIdentityEvent, findOrCreateUserByEmail, linkIdentity, unlinkIdentity, mintToken, revokeToken, resolveUserByToken, InvalidRuntimeTokenError, mintSessionToken, mintRuntimeToken, insertSessionToken, revokeSessionToken, revokeRuntimeTokensForRuntime, resolveSessionToken, fingerprintApiKey, init_users };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getContextWindowSize,
|
|
3
3
|
clampContextPercent
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-a5ebc95n.js";
|
|
5
5
|
import {
|
|
6
6
|
swarmRuntimeInstanceId
|
|
7
7
|
} from "./cli-7a91w22y.js";
|
|
@@ -10,17 +10,17 @@ import {
|
|
|
10
10
|
} from "./cli-jc1g9ndz.js";
|
|
11
11
|
import {
|
|
12
12
|
applyReasoningEffort
|
|
13
|
-
} from "./cli-
|
|
13
|
+
} from "./cli-bn0rewsy.js";
|
|
14
14
|
import {
|
|
15
15
|
DEFAULT_MODEL_TIER_MAP,
|
|
16
16
|
init_types
|
|
17
|
-
} from "./cli-
|
|
17
|
+
} from "./cli-fpmsqq59.js";
|
|
18
18
|
import {
|
|
19
19
|
resolveTemplateFromCode,
|
|
20
20
|
resolveTemplateAsync,
|
|
21
21
|
init_resolver,
|
|
22
22
|
init_session_templates
|
|
23
|
-
} from "./cli-
|
|
23
|
+
} from "./cli-tx00c0h6.js";
|
|
24
24
|
import {
|
|
25
25
|
parseEnvFlag,
|
|
26
26
|
init_env_flag
|
|
@@ -29,11 +29,11 @@ import {
|
|
|
29
29
|
scrubSecrets,
|
|
30
30
|
registerVolatileSecret,
|
|
31
31
|
init_secret_scrubber
|
|
32
|
-
} from "./cli-
|
|
32
|
+
} from "./cli-xf234ws8.js";
|
|
33
33
|
import {
|
|
34
34
|
cursorCatalogRef,
|
|
35
35
|
init_src2
|
|
36
|
-
} from "./cli-
|
|
36
|
+
} from "./cli-nwyw3zhg.js";
|
|
37
37
|
|
|
38
38
|
// src/providers/cursor-adapter.ts
|
|
39
39
|
init_src2();
|