@desplega.ai/agent-swarm 2.13.4 → 2.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-tbt61zkm.js +17 -0
- package/dist/{acp-targets-zrk9k0n7.js → acp-targets-w8dbs4nr.js} +7 -7
- package/dist/{actions-acqqj9jn.js → actions-8zrcbjrx.js} +26 -26
- package/dist/{agent-fs-provision-zmaykqnd.js → agent-fs-provision-cbt2ttds.js} +4 -4
- package/dist/{amp-adapter-a7ts8tmw.js → amp-adapter-8x6zp8w4.js} +2 -2
- package/dist/{anthropic-messages-88b7s3n9.js → anthropic-messages-vdd1zmha.js} +10 -10
- package/dist/{app-tmwa442h.js → app-zfa9dwjw.js} +6 -6
- package/dist/{approval-notifications-6psaaaye.js → approval-notifications-rv92zmza.js} +7 -7
- package/dist/{assistant-564v6emv.js → assistant-q7s7rm1q.js} +24 -24
- package/dist/{boot-args-schema-n099e0f2.js → boot-args-schema-g27kpzr1.js} +1 -1
- package/dist/{boot-reembed-epvg4fp9.js → boot-reembed-1mjs52nt.js} +1 -1
- package/dist/{boot-reembed-chx66qfk.js → boot-reembed-m62dpdkg.js} +1 -1
- package/dist/{boot-scrub-sweep-dhkfp0a7.js → boot-scrub-sweep-ss1vcamw.js} +2 -2
- package/dist/{boot-seeds-m74fc07r.js → boot-seeds-hwnvgbb3.js} +4 -4
- package/dist/{boxd-451q55ys.js → boxd-y0szhp0g.js} +1 -1
- package/dist/{claude-adapter-hw63yj3j.js → claude-adapter-0rjmbhjk.js} +7 -7
- package/dist/{claude-managed-adapter-z5s7fx6p.js → claude-managed-adapter-6k032agg.js} +3 -3
- package/dist/{claude-managed-setup-wee1762m.js → claude-managed-setup-6czvve8q.js} +4 -4
- package/dist/{claude-sdk-session-cktyqkpk.js → claude-sdk-session-pr0znb81.js} +12667 -11881
- package/dist/{cli-0fgvnb0x.js → cli-0qt3epg4.js} +3 -3
- package/dist/{cli-ka48vpev.js → cli-19d6v8er.js} +3 -3
- package/dist/{cli-zexwhj3f.js → cli-1jq2em7b.js} +3 -3
- package/dist/{cli-5rgm8p39.js → cli-2wzkvfgm.js} +2 -2
- package/dist/{cli-x2cem5vy.js → cli-34fygf87.js} +2 -2
- package/dist/{cli-tsc3pdfd.js → cli-3860pmrq.js} +3 -3
- package/dist/{cli-hhtbandk.js → cli-3vw6dd4g.js} +2 -2
- package/dist/{cli-qzz6tz8s.js → cli-4gaf3tx5.js} +1 -1
- package/dist/{cli-9ah37a8a.js → cli-55h8m1x3.js} +8 -5
- package/dist/{cli-7gbff32z.js → cli-5n9w2xzx.js} +1 -1
- package/dist/{cli-p436yrzp.js → cli-5tq15aa7.js} +1 -1
- package/dist/{cli-jyhbvdga.js → cli-5web09sb.js} +2 -2
- package/dist/{cli-3zrwrnz7.js → cli-69zzpjgh.js} +1 -1
- package/dist/{cli-7g3fg4gf.js → cli-6msnpj1z.js} +6 -6
- package/dist/{cli-azj9t1f9.js → cli-7r9tvk8v.js} +41 -3
- package/dist/{cli-4fpa0zns.js → cli-7ypg8hka.js} +3 -3
- package/dist/{cli-8cas2xvp.js → cli-887vhew6.js} +2 -2
- package/dist/{cli-t0jmkcah.js → cli-8pd1t17c.js} +7 -7
- package/dist/{cli-h9d3sdnc.js → cli-94mxerrp.js} +1 -1
- package/dist/{cli-bv4vvnmg.js → cli-9n6g14vs.js} +2 -2
- package/dist/{cli-5ashycw3.js → cli-abby987g.js} +2 -2
- package/dist/{cli-kj84fqxz.js → cli-avax5mp9.js} +1 -1
- package/dist/{cli-ea7nz50q.js → cli-b42yfn17.js} +11 -11
- package/dist/{cli-ysv0k1we.js → cli-b9ygp1kz.js} +1 -1
- package/dist/{cli-3bxrrh53.js → cli-bvamr9g0.js} +2 -2
- package/dist/{cli-gse7bp3z.js → cli-ced4azn1.js} +10 -9
- package/dist/{cli-7by7vp6m.js → cli-cmbb2t8a.js} +2 -2
- package/dist/{cli-0p76my9q.js → cli-cp163xga.js} +10 -10
- package/dist/{cli-jzerrzgc.js → cli-ebpq3c5z.js} +8 -8
- package/dist/{cli-p3knvk62.js → cli-ehg90jd1.js} +113 -39
- package/dist/{cli-jg5txpm6.js → cli-emdfd8fh.js} +75 -1
- package/dist/{cli-d5pc8ep0.js → cli-evy3egte.js} +7 -7
- package/dist/{cli-60dwk8tx.js → cli-ewk3sg68.js} +2 -2
- package/dist/{cli-nc4pbwmp.js → cli-f7b9nyvk.js} +4 -4
- package/dist/{cli-29h5239w.js → cli-f9xw9pr4.js} +4 -4
- package/dist/{cli-3tzmh38q.js → cli-ffn0a515.js} +7 -7
- package/dist/{cli-dqgnbnxs.js → cli-grbngev5.js} +6 -1
- package/dist/{cli-cq4am6vg.js → cli-hd5bm1e1.js} +4 -4
- package/dist/{cli-akm6y2a8.js → cli-htb5bpz2.js} +1 -1
- package/dist/{cli-tr19nyn9.js → cli-j69pzrrz.js} +6 -6
- package/dist/{cli-hdhpdrka.js → cli-jdq3jmny.js} +3 -3
- package/dist/{cli-ja450998.js → cli-ks06cd0n.js} +1 -1
- package/dist/{cli-pz1dp12c.js → cli-kwj3131p.js} +1 -1
- package/dist/{cli-1vmhnncj.js → cli-m8f4379k.js} +3 -3
- package/dist/{cli-jbrc98qb.js → cli-n79j1vxc.js} +2 -2
- package/dist/{cli-b768ek79.js → cli-nrt048ys.js} +1 -0
- package/dist/{cli-93n305hm.js → cli-pedm2kht.js} +1 -1
- package/dist/{cli-eds5xnsz.js → cli-phmy14hb.js} +2 -2
- package/dist/{cli-n1kjs58m.js → cli-prz1p3ft.js} +3 -3
- package/dist/{cli-pz1nq5xm.js → cli-q1h041y8.js} +3 -3
- package/dist/{cli-cah298e5.js → cli-q41qar56.js} +104 -119
- package/dist/{cli-4pbwg7sn.js → cli-qmx8bnt4.js} +1 -1
- package/dist/{cli-944w9wb4.js → cli-qrvk9nka.js} +18 -13
- package/dist/{cli-gtj12v95.js → cli-r3dxpmyt.js} +1 -1
- package/dist/{cli-phdzn699.js → cli-ryem5cfq.js} +7 -7
- package/dist/{cli-49aq3cyn.js → cli-s8dhq7rj.js} +4 -4
- package/dist/{cli-fkpnx3vf.js → cli-sejvnjvw.js} +3 -2
- package/dist/{cli-m1sns1da.js → cli-srre41gb.js} +2 -2
- package/dist/{cli-5rxsb3wq.js → cli-t0n9svkb.js} +3 -3
- package/dist/{cli-tzw1jr2t.js → cli-t879ww0y.js} +2 -2
- package/dist/{cli-xwsm6xkr.js → cli-tgc1kgg3.js} +1 -1
- package/dist/{cli-404am6f3.js → cli-tt7dkwjj.js} +6 -6
- package/dist/{cli-zjdhrzm0.js → cli-tvyt8w6n.js} +2 -2
- package/dist/{cli-hyqksecw.js → cli-v09eza21.js} +9 -9
- package/dist/{cli-rv3y60bt.js → cli-vbge4rsp.js} +4 -4
- package/dist/{cli-bzcwwebm.js → cli-vcpyttcw.js} +1 -1
- package/dist/{cli-904wk98s.js → cli-wzecestt.js} +338 -98
- package/dist/{cli-gkv0r2hq.js → cli-x2adbg4j.js} +70 -8
- package/dist/{cli-4q2c8rxw.js → cli-z3x7h79n.js} +12 -6
- package/dist/{cli-s33bzmk0.js → cli-z40t85ms.js} +1 -1
- package/dist/{cli-rmgvwcmy.js → cli-zbbtp02a.js} +98 -21
- package/dist/{cli-3xqad83h.js → cli-zntvmqmm.js} +1 -1
- package/dist/{cli-zhwjdhjr.js → cli-zxa1vmx7.js} +1 -1
- package/dist/{cli-50wa8k4h.js → cli-zy9bb22b.js} +1 -2
- package/dist/{cli-ts5yv7dn.js → cli-zzq96q57.js} +123 -33
- package/dist/cli.js +18 -18
- package/dist/{codex-adapter-2fs2c0n6.js → codex-adapter-bn7eaxk5.js} +6 -6
- package/dist/{codex-hook-jxjv6dy5.js → codex-hook-nnmezjg9.js} +2 -2
- package/dist/{codex-session-runner-r55tmx4c.js → codex-session-runner-j1e9hffc.js} +6 -6
- package/dist/{commands-0mxdy9x8.js → commands-amhpafrr.js} +3 -3
- package/dist/{controller-g3vkfhr4.js → controller-tw7g10j2.js} +3 -3
- package/dist/{controllers-connect-4wdmncqt.js → controllers-connect-2ssqz7f4.js} +23 -23
- package/dist/{core-gsvj5f3z.js → core-bwp98v4w.js} +21 -21
- package/dist/{cursor-adapter-t9qb96q2.js → cursor-adapter-d6knjmwa.js} +1 -1
- package/dist/{db-487vvyv9.js → db-fd6xxm77.js} +3 -3
- package/dist/{db-76p7w3gr.js → db-sc59379z.js} +2 -2
- package/dist/{dispatcher-64rp6w67.js → dispatcher-a2gdqz8c.js} +21 -21
- package/dist/{dsh-adapter-8abzqk5c.js → dsh-adapter-43ygwqn7.js} +1 -1
- package/dist/{e2b-dc8f6ctq.js → e2b-cn7cvjqy.js} +1 -1
- package/dist/{e2b-3ykbe805.js → e2b-qnxyfea6.js} +1 -1
- package/dist/{easter-egg-3d-jrrwyf55.js → easter-egg-3d-a0pphy71.js} +1 -1
- package/dist/{embedding-space-001hhhpk.js → embedding-space-qepzrach.js} +6 -6
- package/dist/{embeddings-esj19cnw.js → embeddings-d7vr881x.js} +1 -1
- package/dist/{execute-301hkxqg.js → execute-6afts2bn.js} +1 -1
- package/dist/{external-channel-w10e2j05.js → external-channel-881zq1x4.js} +2 -2
- package/dist/fx-adapter-cr2hq17y.js +20 -0
- package/dist/{grok-adapter-3a0ezfee.js → grok-adapter-ayddnbsc.js} +9 -9
- package/dist/handlers-7ghs84x2.js +41 -0
- package/dist/{heartbeat-tbrj7vhq.js → heartbeat-4c022m6a.js} +24 -24
- package/dist/{hook-3am1sq68.js → hook-4k84x499.js} +5 -5
- package/dist/{hook-tx917rqw.js → hook-a7eh6zty.js} +7 -7
- package/dist/{http-3rmemtqy.js → http-6aw5wanc.js} +180 -94
- package/dist/index-dtt0d634.js +44 -0
- package/dist/index-hmszyqkk.js +42 -0
- package/dist/index-j6rm1rtn.js +39 -0
- package/dist/{index-aetfyx6p.js → index-rwwhsmjg.js} +1 -1
- package/dist/{index-s7xtvc0f.js → index-xhad0n8m.js} +1 -1
- package/dist/{index-2jw11t8s.js → index-yq9hhhhy.js} +25 -25
- package/dist/{index-gfnq66t1.js → index-z2g9469g.js} +202 -17
- package/dist/{keepalive-9px3t7qj.js → keepalive-zhbmztqw.js} +4 -4
- package/dist/lead-g2j4q39z.js +83 -0
- package/dist/{maintenance-vwqjwst6.js → maintenance-rsp0591h.js} +1 -1
- package/dist/{node-2wfcey7d.js → node-0as4n1ef.js} +3 -3
- package/dist/{node-zd6shky9.js → node-dhxbt01p.js} +3 -3
- package/dist/{node-z67yjre7.js → node-rxte5hc6.js} +290 -70
- package/dist/{node-hjn5n1yp.js → node-t0ct2zpw.js} +3 -5
- package/dist/{oauth-refresh-sweep-yqry3wn4.js → oauth-refresh-sweep-w3cqmxq7.js} +3 -3
- package/dist/{object-webhooks-8s1wtths.js → object-webhooks-331hay92.js} +7 -7
- package/dist/{onboard-hb8czx0p.js → onboard-n2w80m2n.js} +3 -3
- package/dist/{opencode-adapter-djd6m6dk.js → opencode-adapter-z98127cz.js} +6 -6
- package/dist/{otel-impl-2ymwyczz.js → otel-impl-xsk35tvf.js} +1 -1
- package/dist/{pending-nxavtvx7.js → pending-2e6trkxd.js} +22 -22
- package/dist/{pi-mono-adapter-d2cpmcy4.js → pi-mono-adapter-wh6yndtm.js} +8 -8
- package/dist/{pricing-refresh-1yz8jkqv.js → pricing-refresh-9355dj1t.js} +2 -2
- package/dist/{rbac-roles-dbpx0x9v.js → rbac-roles-58y3m912.js} +3 -3
- package/dist/{rbac-roles-7s6m31xw.js → rbac-roles-8eajw4s6.js} +2 -2
- package/dist/{render-v2-7y20rjrn.js → render-v2-7gskkmd4.js} +6 -6
- package/dist/{resume-wz546x47.js → resume-0drnmpja.js} +9 -9
- package/dist/{runtime-cb5bd9tz.js → runtime-d2tcmqte.js} +1 -1
- package/dist/{session-access-4vcft8kq.js → session-access-0ztys6bd.js} +5 -5
- package/dist/{session-source-backfill-57b50tpw.js → session-source-backfill-cdm5s046.js} +2 -2
- package/dist/{setup-e1tevjyj.js → setup-pqwb9tcc.js} +1 -1
- package/dist/thread-buffer-epx3san4.js +42 -0
- package/dist/{tree-visibility-07wf1nct.js → tree-visibility-rwz67mje.js} +2 -2
- package/dist/{user-merge-jobs-n20qpv6s.js → user-merge-jobs-mxrhamwt.js} +3 -3
- package/dist/{virtual-modules-6fxmn1yv.js → virtual-modules-71y1gsmg.js} +3 -3
- package/dist/{work-objects-eg7y48pe.js → work-objects-3k4ykt9j.js} +24 -24
- package/dist/worker-09gqn9xy.js +83 -0
- package/dist/{worker-follow-up-jnvnnf2b.js → worker-follow-up-y0h64xpr.js} +21 -21
- package/openapi.json +387 -6
- package/package.json +4 -4
- package/src/apps/sync.ts +20 -5
- package/src/azure-devops/boards-sync.ts +1 -1
- package/src/be/db/slack-trees.ts +12 -1
- package/src/be/db/tasks/read.ts +25 -1
- package/src/be/db/tasks/write.ts +47 -12
- package/src/be/db/users/avatar.ts +12 -0
- package/src/be/db.ts +78 -5
- package/src/be/migrations/344_user_avatar.sql +4 -0
- package/src/be/migrations/345_task_status_kind.sql +6 -0
- package/src/be/primitives/object-embed.ts +2 -2
- package/src/be/primitives/objects.ts +2 -2
- package/src/be/runtime-pools/supervisor.ts +1 -0
- package/src/be/scripts/typecheck.ts +1 -1
- package/src/be/swarm-config-guard.ts +4 -0
- package/src/bitbucket/handlers.ts +1 -1
- package/src/commands/credential-outcome-report.ts +96 -0
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/runner.ts +49 -3
- package/src/event-waits/github.ts +39 -6
- package/src/event-waits/index.ts +4 -2
- package/src/event-waits/types.ts +10 -3
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/github/app.ts +177 -13
- package/src/github/handlers.ts +7 -2
- package/src/github/pull-request-state.ts +100 -11
- package/src/gitlab/handlers.ts +2 -2
- package/src/heartbeat/heartbeat.ts +6 -1
- package/src/http/api-keys.ts +26 -0
- package/src/http/asset-key-write.ts +45 -0
- package/src/http/assets.ts +4 -3
- package/src/http/github-token.ts +27 -6
- package/src/http/pages.ts +4 -10
- package/src/http/schedules.ts +6 -6
- package/src/http/sessions.ts +7 -2
- package/src/http/tasks.ts +23 -5
- package/src/http/users.ts +5 -0
- package/src/http/webhooks.ts +19 -1
- package/src/http/workflows.ts +5 -10
- package/src/integrations/chat-sdk/commands.ts +3 -1
- package/src/jira/sync.ts +1 -1
- package/src/linear/sync.ts +5 -3
- package/src/prompts/session-templates.ts +1 -0
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +5 -0
- package/src/providers/claude-sdk-session.ts +5 -0
- package/src/providers/runtime-dependencies.ts +1 -1
- package/src/scheduler/deferred-task-waits.ts +74 -13
- package/src/scripts-runtime/swarm-sdk.ts +8 -1
- package/src/scripts-runtime/types/stdlib.d.ts +8 -1
- package/src/scripts-runtime/types/swarm-extension.d.ts +19 -2
- package/src/scripts-runtime/types/swarm-sdk.d.ts +8 -1
- package/src/slack/actions.ts +1 -1
- package/src/slack/render-v2.ts +148 -7
- package/src/tests/api-drain-worker-e2e.test.ts +0 -2
- package/src/tests/approval-auto-cancellation-migration.test.ts +8 -19
- package/src/tests/approval-card-resolution.test.ts +2 -17
- package/src/tests/approval-requests-notifications.test.ts +41 -27
- package/src/tests/approval-requests.test.ts +137 -369
- package/src/tests/apps-sync-engine.test.ts +5 -3
- package/src/tests/apps-table-filters-migration.test.ts +44 -25
- package/src/tests/bitbucket-handlers.test.ts +2 -0
- package/src/tests/chat-sdk-commands.test.ts +1 -0
- package/src/tests/claude-adapter.test.ts +35 -0
- package/src/tests/codex-adapter.test.ts +3 -92
- package/src/tests/codex-gpt6-release.test.ts +0 -9
- package/src/tests/codex-oauth-credential-info.test.ts +35 -18
- package/src/tests/codex-oauth.test.ts +0 -6
- package/src/tests/codex-pool.test.ts +5 -214
- package/src/tests/codex-rate-limit-parse.test.ts +0 -7
- package/src/tests/codex-swarm-events.test.ts +11 -54
- package/src/tests/db-client-busy-retry.test.ts +49 -16
- package/src/tests/defer-task.test.ts +1 -0
- package/src/tests/e2e-shards.test.ts +9 -9
- package/src/tests/enabled-tools.test.ts +0 -2
- package/src/tests/fixtures/base-prompt-baseline.json +6 -6
- package/src/tests/github-app-worker-auth-helper.test.ts +147 -1
- package/src/tests/gitlab-handlers.test.ts +2 -0
- package/src/tests/heartbeat-jev-gate.test.ts +9 -241
- package/src/tests/heartbeat-reroute-decision.test.ts +2 -0
- package/src/tests/heartbeat-supersede-resume.test.ts +2 -0
- package/src/tests/heartbeat.test.ts +1 -0
- package/src/tests/key-usage-selection.test.ts +302 -0
- package/src/tests/memory-e2e.test.ts +34 -103
- package/src/tests/memory-key-paths.test.ts +5 -0
- package/src/tests/memory-rater-llm.test.ts +33 -149
- package/src/tests/memory-store.test.ts +24 -125
- package/src/tests/memory.test.ts +31 -100
- package/src/tests/merge-gate-detect-changes.test.ts +108 -2
- package/src/tests/otel-service-name.test.ts +0 -9
- package/src/tests/otel-session-cost-metrics.test.ts +1 -38
- package/src/tests/pool-session-logs.test.ts +8 -42
- package/src/tests/pre-push-affected-tests.test.ts +106 -0
- package/src/tests/prompt-template-session.test.ts +3 -0
- package/src/tests/runner-api-drain.test.ts +2 -17
- package/src/tests/runner-terminal-window-report.test.ts +132 -0
- package/src/tests/runtime-supervisor-failures.test.ts +1 -0
- package/src/tests/sandboxed-process.test.ts +26 -21
- package/src/tests/schedule-http-triage-tools.test.ts +12 -9
- package/src/tests/scheduled-tasks.test.ts +14 -51
- package/src/tests/script-executor-conformance.test.ts +4 -48
- package/src/tests/script-executor-quickjs-pool.test.ts +9 -7
- package/src/tests/script-native-startup.test.ts +21 -25
- package/src/tests/secret-rules.test.ts +4 -2
- package/src/tests/session-logs.test.ts +1 -260
- package/src/tests/slack-render-v2.test.ts +5 -148
- package/src/tests/task-cascade-fail.test.ts +1 -0
- package/src/tests/task-supersede-resume.test.ts +1 -0
- package/src/tests/test-proc.ts +5 -2
- package/src/tests/window-stream-reporter.test.ts +122 -0
- package/src/tests/workflow-agent-task-retry.test.ts +1 -3
- package/src/tests/workflow-cascade-cancel.test.ts +1 -0
- package/src/tests/workflow-retry-v2.test.ts +34 -43
- package/src/tests/workflow-retry-validation.test.ts +8 -48
- package/src/tests/worktree-reaper.test.ts +2 -2
- package/src/tools/cancel-task.ts +2 -2
- package/src/tools/defer-task.ts +7 -2
- package/src/tools/get-task-details.ts +8 -4
- package/src/tools/get-tasks.ts +13 -2
- package/src/tools/manage-user.ts +9 -0
- package/src/tools/store-progress.ts +5 -3
- package/src/types.ts +93 -0
- package/src/utils/constants.ts +12 -0
- package/src/utils/credentials.ts +42 -5
- package/src/utils/error-tracker.ts +6 -0
- package/src/utils/key-usage.ts +114 -0
- package/src/utils/sandboxed-process.ts +1 -0
- package/src/workflows/resume.ts +5 -2
- package/templates/skills/apps/SKILL.md +2 -0
- package/templates/skills/apps/content.md +2 -0
- package/templates/skills/boards-and-sheets/content.md +4 -2
- package/templates/skills/pages/content.md +7 -0
- package/templates/skills/swarm-docs/content.md +1 -0
- package/templates/skills/swarm-scripts/SKILL.md +1 -0
- package/templates/skills/swarm-scripts/content.md +1 -0
- package/dist/acp-adapter-mr4temec.js +0 -17
- package/dist/fx-adapter-4sjrbdne.js +0 -20
- package/dist/handlers-ef3k11hb.js +0 -41
- package/dist/index-e6bq0exk.js +0 -42
- package/dist/index-hf2k1vge.js +0 -39
- package/dist/index-taxmejj3.js +0 -44
- package/dist/lead-5vt6f174.js +0 -83
- package/dist/thread-buffer-686pa1p1.js +0 -42
- package/dist/worker-4vp616ms.js +0 -83
- package/src/tests/apps-table-selection-migration.test.ts +0 -95
- package/src/tests/extensions-example-heartbeat-remediate.test.ts +0 -69
- package/src/tests/extensions-example-rewrite-and-suppress.test.ts +0 -70
package/src/tests/memory.test.ts
CHANGED
|
@@ -292,26 +292,6 @@ describe("Memory System", () => {
|
|
|
292
292
|
});
|
|
293
293
|
|
|
294
294
|
describe("store.get (getMemoryById)", () => {
|
|
295
|
-
test("returns existing memory", async () => {
|
|
296
|
-
const created = await store.store({
|
|
297
|
-
agentId: agentA,
|
|
298
|
-
scope: "agent",
|
|
299
|
-
name: "Findable",
|
|
300
|
-
content: "Find me",
|
|
301
|
-
source: "manual",
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
const found = await store.get(created.id);
|
|
305
|
-
expect(found).not.toBeNull();
|
|
306
|
-
expect(found!.id).toBe(created.id);
|
|
307
|
-
expect(found!.name).toBe("Findable");
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
test("returns null for non-existent ID", async () => {
|
|
311
|
-
const found = await store.get("00000000-0000-0000-0000-000000000000");
|
|
312
|
-
expect(found).toBeNull();
|
|
313
|
-
});
|
|
314
|
-
|
|
315
295
|
test("updates accessedAt on retrieval", async () => {
|
|
316
296
|
const created = await store.store({
|
|
317
297
|
agentId: agentA,
|
|
@@ -321,16 +301,18 @@ describe("Memory System", () => {
|
|
|
321
301
|
source: "manual",
|
|
322
302
|
});
|
|
323
303
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
expect(
|
|
304
|
+
const stale = "2000-01-01T00:00:00.000Z";
|
|
305
|
+
await getDbClient().run("UPDATE agent_memory SET accessedAt = ? WHERE id = ?", [
|
|
306
|
+
stale,
|
|
307
|
+
created.id,
|
|
308
|
+
]);
|
|
309
|
+
const before = Date.now();
|
|
310
|
+
expect(await store.get(created.id)).not.toBeNull();
|
|
311
|
+
// get() returns the old row. Inspect the committed update without another access.
|
|
312
|
+
const persisted = await store.peek(created.id);
|
|
313
|
+
expect(persisted!.accessedAt).not.toBe(stale);
|
|
314
|
+
expect(Date.parse(persisted!.accessedAt)).toBeGreaterThanOrEqual(before);
|
|
315
|
+
expect(Date.parse(persisted!.accessedAt)).toBeLessThanOrEqual(Date.now());
|
|
334
316
|
});
|
|
335
317
|
});
|
|
336
318
|
|
|
@@ -344,20 +326,24 @@ describe("Memory System", () => {
|
|
|
344
326
|
source: "manual",
|
|
345
327
|
});
|
|
346
328
|
|
|
329
|
+
const unembedded = await getDbClient().get<{ embedding: Buffer | null }>(
|
|
330
|
+
"SELECT embedding FROM agent_memory WHERE id = ?",
|
|
331
|
+
[memory.id],
|
|
332
|
+
);
|
|
333
|
+
expect(unembedded!.embedding).toBeNull();
|
|
347
334
|
const embedding = new Float32Array([0.1, 0.2, 0.3, -0.5]);
|
|
348
335
|
await store.updateEmbedding(memory.id, embedding, "test-model");
|
|
349
336
|
|
|
350
337
|
// Read back the raw row to check embedding
|
|
351
|
-
const row = (await getDbClient().get<{ embedding: Buffer | null }>(
|
|
352
|
-
"SELECT embedding FROM agent_memory WHERE id = ?",
|
|
338
|
+
const row = (await getDbClient().get<{ embedding: Buffer | null; embeddingModel: string }>(
|
|
339
|
+
"SELECT embedding, embeddingModel FROM agent_memory WHERE id = ?",
|
|
353
340
|
[memory.id],
|
|
354
341
|
))!;
|
|
355
342
|
expect(row.embedding).not.toBeNull();
|
|
343
|
+
expect(row.embeddingModel).toBe("test-model");
|
|
356
344
|
|
|
357
345
|
const restored = deserializeEmbedding(row.embedding!);
|
|
358
|
-
expect(restored
|
|
359
|
-
expect(restored[0]).toBeCloseTo(0.1, 5);
|
|
360
|
-
expect(restored[3]).toBeCloseTo(-0.5, 5);
|
|
346
|
+
expect(restored).toEqual(embedding);
|
|
361
347
|
});
|
|
362
348
|
});
|
|
363
349
|
|
|
@@ -569,29 +555,6 @@ describe("Memory System", () => {
|
|
|
569
555
|
});
|
|
570
556
|
});
|
|
571
557
|
|
|
572
|
-
describe("store.delete (deleteMemory)", () => {
|
|
573
|
-
test("deletes existing memory", async () => {
|
|
574
|
-
const memory = await store.store({
|
|
575
|
-
agentId: agentA,
|
|
576
|
-
scope: "agent",
|
|
577
|
-
name: "To Delete",
|
|
578
|
-
content: "Delete me",
|
|
579
|
-
source: "manual",
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
const deleted = await store.delete(memory.id);
|
|
583
|
-
expect(deleted).toBe(true);
|
|
584
|
-
|
|
585
|
-
const found = await store.get(memory.id);
|
|
586
|
-
expect(found).toBeNull();
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
test("returns false for non-existent memory", async () => {
|
|
590
|
-
const deleted = await store.delete("00000000-0000-0000-0000-000000000000");
|
|
591
|
-
expect(deleted).toBe(false);
|
|
592
|
-
});
|
|
593
|
-
});
|
|
594
|
-
|
|
595
558
|
describe("store.deleteBySourcePath (deleteMemoriesBySourcePath)", () => {
|
|
596
559
|
test("deletes all chunks for a source path", async () => {
|
|
597
560
|
const path = "/workspace/personal/memory/to-reindex.md";
|
|
@@ -645,12 +608,20 @@ describe("Memory System", () => {
|
|
|
645
608
|
content: "Content",
|
|
646
609
|
source: "manual",
|
|
647
610
|
});
|
|
611
|
+
await store.store({
|
|
612
|
+
agentId: statsAgent,
|
|
613
|
+
scope: "agent",
|
|
614
|
+
name: "Stat 4",
|
|
615
|
+
content: "Content",
|
|
616
|
+
source: "task_completion",
|
|
617
|
+
});
|
|
648
618
|
|
|
649
619
|
const stats = await store.getStats(statsAgent);
|
|
650
|
-
expect(stats.total).toBe(
|
|
620
|
+
expect(stats.total).toBe(4);
|
|
651
621
|
expect(stats.bySource.manual).toBe(2);
|
|
652
622
|
expect(stats.bySource.file_index).toBe(1);
|
|
653
|
-
expect(stats.
|
|
623
|
+
expect(stats.bySource.task_completion).toBe(1);
|
|
624
|
+
expect(stats.byScope.agent).toBe(3);
|
|
654
625
|
expect(stats.byScope.swarm).toBe(1);
|
|
655
626
|
expect(stats.withEmbeddings).toBe(0);
|
|
656
627
|
expect(stats.expired).toBe(0);
|
|
@@ -768,45 +739,5 @@ describe("Memory System", () => {
|
|
|
768
739
|
expect(m.totalChunks).toBe(chunks.length);
|
|
769
740
|
}
|
|
770
741
|
});
|
|
771
|
-
|
|
772
|
-
test("memory created without embedding has null embedding in DB", async () => {
|
|
773
|
-
const memory = await store.store({
|
|
774
|
-
agentId: ingestAgent,
|
|
775
|
-
content: "No embedding needed",
|
|
776
|
-
name: "no-embed",
|
|
777
|
-
scope: "agent",
|
|
778
|
-
source: "manual",
|
|
779
|
-
});
|
|
780
|
-
|
|
781
|
-
const row = (await getDbClient().get<{ embedding: Buffer | null }>(
|
|
782
|
-
"SELECT embedding FROM agent_memory WHERE id = ?",
|
|
783
|
-
[memory.id],
|
|
784
|
-
))!;
|
|
785
|
-
expect(row.embedding).toBeNull();
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
test("store.updateEmbedding stores and retrieves correctly", async () => {
|
|
789
|
-
const memory = await store.store({
|
|
790
|
-
agentId: ingestAgent,
|
|
791
|
-
content: "Embed me",
|
|
792
|
-
name: "embed-update",
|
|
793
|
-
scope: "agent",
|
|
794
|
-
source: "manual",
|
|
795
|
-
});
|
|
796
|
-
|
|
797
|
-
const embedding = new Float32Array([0.5, -0.3, 0.8]);
|
|
798
|
-
await store.updateEmbedding(memory.id, embedding, "test-model");
|
|
799
|
-
|
|
800
|
-
const row = (await getDbClient().get<{ embedding: Buffer | null }>(
|
|
801
|
-
"SELECT embedding FROM agent_memory WHERE id = ?",
|
|
802
|
-
[memory.id],
|
|
803
|
-
))!;
|
|
804
|
-
expect(row.embedding).not.toBeNull();
|
|
805
|
-
|
|
806
|
-
const restored = deserializeEmbedding(row.embedding!);
|
|
807
|
-
expect(restored[0]).toBeCloseTo(0.5, 5);
|
|
808
|
-
expect(restored[1]).toBeCloseTo(-0.3, 5);
|
|
809
|
-
expect(restored[2]).toBeCloseTo(0.8, 5);
|
|
810
|
-
});
|
|
811
742
|
});
|
|
812
743
|
});
|
|
@@ -138,14 +138,19 @@ async function runStep(
|
|
|
138
138
|
return { stdout: res.stdout, outputs };
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/** Builds the repo and returns the change-flag step's flags. */
|
|
141
|
+
/** Builds the repo and returns the change-flag step's flags, for `event` when given. */
|
|
142
142
|
async function flagsFor(
|
|
143
143
|
files: string[],
|
|
144
144
|
change: (repo: string) => Promise<void>,
|
|
145
145
|
script?: string,
|
|
146
|
+
event?: string,
|
|
146
147
|
): Promise<Record<string, string>> {
|
|
147
148
|
const repo = await repoWith(files, change);
|
|
148
|
-
const { stdout, outputs } = await runStep(
|
|
149
|
+
const { stdout, outputs } = await runStep(
|
|
150
|
+
repo,
|
|
151
|
+
script ?? (await loadFlagStep()),
|
|
152
|
+
event ? { EVENT_NAME: event } : {},
|
|
153
|
+
);
|
|
149
154
|
expect(stdout).toContain("Changed files:");
|
|
150
155
|
return outputs;
|
|
151
156
|
}
|
|
@@ -244,6 +249,107 @@ describe("merge-gate detect-changes flags", () => {
|
|
|
244
249
|
);
|
|
245
250
|
});
|
|
246
251
|
|
|
252
|
+
/**
|
|
253
|
+
* Repo-relative src/ files the dashboard bundle reads: relative imports in apps/ui/src
|
|
254
|
+
* (tests excluded) and the `../../src/...` paths its vite configs name.
|
|
255
|
+
*/
|
|
256
|
+
async function dashboardSrcInputs(): Promise<string[]> {
|
|
257
|
+
const loaders = {
|
|
258
|
+
ts: new Bun.Transpiler({ loader: "ts" }),
|
|
259
|
+
tsx: new Bun.Transpiler({ loader: "tsx" }),
|
|
260
|
+
};
|
|
261
|
+
const uiRoot = join(REPO_ROOT, "apps/ui");
|
|
262
|
+
const found = new Set<string>();
|
|
263
|
+
const keep = (file: string, spec: string) => {
|
|
264
|
+
const rel = relative(REPO_ROOT, resolve(dirname(file), spec));
|
|
265
|
+
if (rel.startsWith("src/")) found.add(rel);
|
|
266
|
+
};
|
|
267
|
+
for await (const path of new Bun.Glob("src/**/*.{ts,tsx}").scan({ cwd: uiRoot })) {
|
|
268
|
+
if (/\.test\.tsx?$/.test(path)) continue;
|
|
269
|
+
const file = join(uiRoot, path);
|
|
270
|
+
const transpiler = path.endsWith(".tsx") ? loaders.tsx : loaders.ts;
|
|
271
|
+
for (const { path: spec } of transpiler.scanImports(await Bun.file(file).text())) {
|
|
272
|
+
if (spec.startsWith(".")) keep(file, spec);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
for await (const path of new Bun.Glob("vite*.config.ts").scan({ cwd: uiRoot })) {
|
|
276
|
+
const file = join(uiRoot, path);
|
|
277
|
+
for (const m of (await Bun.file(file).text()).matchAll(
|
|
278
|
+
/["'`]((?:\.\.\/)+src\/[^"'`]+)["'`]/g,
|
|
279
|
+
)) {
|
|
280
|
+
if (m[1]) keep(file, m[1]);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return [...found].sort();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
describe("merge-gate image builds on a pull request", () => {
|
|
287
|
+
const BASE_FILES = [
|
|
288
|
+
"src/be/db.ts",
|
|
289
|
+
"src/utils/task-citations.ts",
|
|
290
|
+
"scripts/e2e/scenarios/x.ts",
|
|
291
|
+
"scripts/init-local-postgres.sh",
|
|
292
|
+
"apps/ui/src/app.tsx",
|
|
293
|
+
"Dockerfile.worker",
|
|
294
|
+
"Dockerfile.ui",
|
|
295
|
+
"bun.lock",
|
|
296
|
+
".github/workflows/merge-gate.yml",
|
|
297
|
+
];
|
|
298
|
+
|
|
299
|
+
test.each([
|
|
300
|
+
// [changed file, event, docker, ui_image]
|
|
301
|
+
["src/be/db.ts", "pull_request", "false", "false"],
|
|
302
|
+
["src/be/db.ts", "merge_group", "true", "true"],
|
|
303
|
+
["scripts/e2e/scenarios/x.ts", "pull_request", "false", "false"],
|
|
304
|
+
["scripts/e2e/scenarios/x.ts", "merge_group", "true", "false"],
|
|
305
|
+
["scripts/init-local-postgres.sh", "pull_request", "true", "false"],
|
|
306
|
+
["Dockerfile.worker", "pull_request", "true", "false"],
|
|
307
|
+
["Dockerfile.ui", "pull_request", "false", "true"],
|
|
308
|
+
["bun.lock", "pull_request", "true", "true"],
|
|
309
|
+
["apps/ui/src/app.tsx", "pull_request", "false", "true"],
|
|
310
|
+
["src/utils/task-citations.ts", "pull_request", "false", "true"],
|
|
311
|
+
[".github/workflows/merge-gate.yml", "pull_request", "true", "true"],
|
|
312
|
+
])(
|
|
313
|
+
"%s on %s: docker=%s ui_image=%s",
|
|
314
|
+
async (path, event, docker, uiImage) => {
|
|
315
|
+
const flags = await flagsFor(BASE_FILES, edit(path), undefined, event);
|
|
316
|
+
expect(flags.docker).toBe(docker);
|
|
317
|
+
expect(flags.ui_image).toBe(uiImage);
|
|
318
|
+
},
|
|
319
|
+
CHILD_PROCESS_TEST_BUDGET_MS,
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
test(
|
|
323
|
+
"a source change next to an image input still builds on a pull request",
|
|
324
|
+
async () => {
|
|
325
|
+
const flags = await flagsFor(
|
|
326
|
+
BASE_FILES,
|
|
327
|
+
async (repo) => {
|
|
328
|
+
await edit("src/be/db.ts")(repo);
|
|
329
|
+
await edit("Dockerfile.worker")(repo);
|
|
330
|
+
},
|
|
331
|
+
undefined,
|
|
332
|
+
"pull_request",
|
|
333
|
+
);
|
|
334
|
+
expect(flags.docker).toBe("true");
|
|
335
|
+
},
|
|
336
|
+
CHILD_PROCESS_TEST_BUDGET_MS,
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
// The pull-request list names the src/ directories the dashboard imports. A new import
|
|
340
|
+
// from another directory must join it, or a pull request that breaks the bundle goes
|
|
341
|
+
// green until the merge queue.
|
|
342
|
+
test("the pull-request Dashboard Image list covers every src/ file the dashboard reads", async () => {
|
|
343
|
+
const step = await loadFlagStep();
|
|
344
|
+
const pattern = /UI_IMAGE=\$\(match '(\^src\/[^']+)'\)/.exec(step)?.[1];
|
|
345
|
+
expect(pattern).toBeDefined();
|
|
346
|
+
const inputs = await dashboardSrcInputs();
|
|
347
|
+
expect(inputs.length).toBeGreaterThan(0);
|
|
348
|
+
const covered = new RegExp(pattern as string);
|
|
349
|
+
expect(inputs.filter((file) => !covered.test(file))).toEqual([]);
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
247
353
|
describe("merge-gate unit-test scope", () => {
|
|
248
354
|
test(
|
|
249
355
|
"a leaf source change on a pull request runs only the affected tests",
|
|
@@ -38,15 +38,6 @@ describe("resolveServiceName", () => {
|
|
|
38
38
|
expect(resolveServiceName("lead")).toBe("agent-swarm");
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
test("a shared OTEL_SERVICE_NAME cannot collapse API and worker onto one name", () => {
|
|
42
|
-
// This is the SigNoz bug: compose sets OTEL_SERVICE_NAME=agent-swarm on
|
|
43
|
-
// both processes. The API role must still be distinguishable.
|
|
44
|
-
process.env.OTEL_SERVICE_NAME = "agent-swarm";
|
|
45
|
-
expect(resolveServiceName("api")).toBe("agent-swarm-api");
|
|
46
|
-
expect(resolveServiceName("worker")).toBe("agent-swarm");
|
|
47
|
-
expect(resolveServiceName("api")).not.toBe(resolveServiceName("worker"));
|
|
48
|
-
});
|
|
49
|
-
|
|
50
41
|
test("OTEL_SERVICE_NAME is treated as the base name for both roles", () => {
|
|
51
42
|
process.env.OTEL_SERVICE_NAME = "custom-swarm";
|
|
52
43
|
expect(resolveServiceName("api")).toBe("custom-swarm-api");
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// src/http/session-data.ts (recordSessionCost call) and src/otel.ts (facade).
|
|
3
|
-
//
|
|
4
|
-
// Coverage goals:
|
|
5
|
-
// 1. otel.ts recordSessionCost() is a no-op when OTEL_EXPORTER_OTLP_ENDPOINT is unset.
|
|
6
|
-
// 2. handleSessionData() forwards the recomputed totalCostUsd + costSource to
|
|
7
|
-
// recordSessionCost() — not the raw request value.
|
|
8
|
-
// 3. All six token classes map to the expected token_type keys.
|
|
9
|
-
// 4. harness / pricing-table / unpriced / zero-cost cases are all covered.
|
|
1
|
+
// Verify cost drift metrics and forwarding from the real session-data handler.
|
|
10
2
|
|
|
11
3
|
import { afterAll, afterEach, beforeAll, describe, expect, mock, test } from "bun:test";
|
|
12
4
|
import { unlink } from "node:fs/promises";
|
|
@@ -28,33 +20,6 @@ const driftCounterAddSpy = mock((..._args: unknown[]) => {});
|
|
|
28
20
|
const driftCounter = { add: driftCounterAddSpy } as unknown as Counter;
|
|
29
21
|
const metricCounter = { add: mock((..._args: unknown[]) => {}) } as unknown as Counter;
|
|
30
22
|
|
|
31
|
-
// ── 1. Verify the otel.ts facade is a no-op when OTEL is disabled ────────────
|
|
32
|
-
|
|
33
|
-
describe("otel.ts recordSessionCost — no-op when OTEL_EXPORTER_OTLP_ENDPOINT is unset", () => {
|
|
34
|
-
test("does not throw and is a no-op without OTEL_EXPORTER_OTLP_ENDPOINT", async () => {
|
|
35
|
-
// The test environment never sets OTEL_EXPORTER_OTLP_ENDPOINT, so the
|
|
36
|
-
// facade's `enabled` flag is false and realRecordSessionCost is undefined.
|
|
37
|
-
const { recordSessionCost } = await import("../otel");
|
|
38
|
-
expect(() =>
|
|
39
|
-
recordSessionCost({
|
|
40
|
-
totalCostUsd: 0.05,
|
|
41
|
-
harness: "claude",
|
|
42
|
-
model: "claude-sonnet-4-6",
|
|
43
|
-
costSource: "harness",
|
|
44
|
-
isError: false,
|
|
45
|
-
tokens: {
|
|
46
|
-
input: 100,
|
|
47
|
-
output: 50,
|
|
48
|
-
cacheRead: 0,
|
|
49
|
-
cacheWrite: 0,
|
|
50
|
-
reasoning: 0,
|
|
51
|
-
thinking: 0,
|
|
52
|
-
},
|
|
53
|
-
}),
|
|
54
|
-
).not.toThrow();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
23
|
describe("otel-impl cost drift metric", () => {
|
|
59
24
|
test("records absolute drift with direction and cost dimensions", () => {
|
|
60
25
|
driftCounterAddSpy.mockClear();
|
|
@@ -135,8 +100,6 @@ describe("otel-impl cost drift metric", () => {
|
|
|
135
100
|
});
|
|
136
101
|
});
|
|
137
102
|
|
|
138
|
-
// ── 2-4. handleSessionData() → recordSessionCost() integration ───────────────
|
|
139
|
-
|
|
140
103
|
const recordSessionCostSpy = mock((_m: SessionCostMetric) => {});
|
|
141
104
|
|
|
142
105
|
// `mock.module` is process-global and is never auto-restored, so it leaks into
|
|
@@ -56,23 +56,6 @@ describe("reassociateSessionLogs", () => {
|
|
|
56
56
|
// Verify no logs remain under random UUID
|
|
57
57
|
const oldLogs = await getSessionLogsByTaskId(randomUuid);
|
|
58
58
|
expect(oldLogs.length).toBe(0);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("is idempotent — second call returns 0 changes", async () => {
|
|
62
|
-
const runnerSessionId = "runner-sess-2";
|
|
63
|
-
const randomUuid = crypto.randomUUID();
|
|
64
|
-
const realTaskId = crypto.randomUUID();
|
|
65
|
-
|
|
66
|
-
await createSessionLogs({
|
|
67
|
-
taskId: randomUuid,
|
|
68
|
-
sessionId: runnerSessionId,
|
|
69
|
-
iteration: 1,
|
|
70
|
-
cli: "claude",
|
|
71
|
-
lines: ["line a"],
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const first = await reassociateSessionLogs(runnerSessionId, realTaskId);
|
|
75
|
-
expect(first).toBe(1);
|
|
76
59
|
|
|
77
60
|
const second = await reassociateSessionLogs(runnerSessionId, realTaskId);
|
|
78
61
|
expect(second).toBe(0);
|
|
@@ -114,30 +97,11 @@ describe("reassociateSessionLogs", () => {
|
|
|
114
97
|
});
|
|
115
98
|
|
|
116
99
|
describe("pool task claim flow", () => {
|
|
117
|
-
test("active
|
|
100
|
+
test("reassociates pool logs through active-session lookup and repeated calls", async () => {
|
|
118
101
|
const agentId = crypto.randomUUID();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const session = await insertActiveSession({
|
|
122
|
-
agentId,
|
|
123
|
-
taskId: "effective-task-id",
|
|
124
|
-
triggerType: "pool_tasks_available",
|
|
125
|
-
runnerSessionId: "runner-sess-4",
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
expect(session.runnerSessionId).toBe("runner-sess-4");
|
|
129
|
-
|
|
130
|
-
// Verify it can be retrieved
|
|
131
|
-
const sessions = await getActiveSessions(agentId);
|
|
132
|
-
const found = sessions.find((s) => s.runnerSessionId === "runner-sess-4");
|
|
133
|
-
expect(found).toBeDefined();
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test("end-to-end: pool task logs are reassociated after claim", async () => {
|
|
137
|
-
const agentId = crypto.randomUUID();
|
|
138
|
-
const runnerSessionId = "runner-sess-e2e";
|
|
102
|
+
const runnerSessionId = "runner-sess-flow";
|
|
139
103
|
const effectiveTaskId = crypto.randomUUID();
|
|
140
|
-
await createAgent({ id: agentId, name: "
|
|
104
|
+
await createAgent({ id: agentId, name: "Pool Flow Agent", isLead: false, status: "idle" });
|
|
141
105
|
|
|
142
106
|
// 1. Create an unassigned task (pool task)
|
|
143
107
|
const task = await createTaskExtended("Test pool task", {
|
|
@@ -146,13 +110,15 @@ describe("pool task claim flow", () => {
|
|
|
146
110
|
expect(task.agentId).toBeNull();
|
|
147
111
|
|
|
148
112
|
// 2. Simulate runner creating active session with runnerSessionId
|
|
149
|
-
await insertActiveSession({
|
|
113
|
+
const session = await insertActiveSession({
|
|
150
114
|
agentId,
|
|
151
115
|
taskId: effectiveTaskId,
|
|
152
116
|
triggerType: "pool_tasks_available",
|
|
153
117
|
runnerSessionId,
|
|
154
118
|
});
|
|
155
119
|
|
|
120
|
+
expect(session.runnerSessionId).toBe(runnerSessionId);
|
|
121
|
+
|
|
156
122
|
// 3. Simulate session logs being flushed with the random effectiveTaskId
|
|
157
123
|
await createSessionLogs({
|
|
158
124
|
taskId: effectiveTaskId,
|
|
@@ -179,7 +145,7 @@ describe("pool task claim flow", () => {
|
|
|
179
145
|
expect(afterClaim.length).toBe(3);
|
|
180
146
|
|
|
181
147
|
// 7. Simulate more logs arriving after claim (with old effectiveTaskId)
|
|
182
|
-
//
|
|
148
|
+
// A later reassociation call must include these rows.
|
|
183
149
|
await createSessionLogs({
|
|
184
150
|
taskId: effectiveTaskId,
|
|
185
151
|
sessionId: runnerSessionId,
|
|
@@ -188,7 +154,7 @@ describe("pool task claim flow", () => {
|
|
|
188
154
|
lines: ["Working on the task now..."],
|
|
189
155
|
});
|
|
190
156
|
|
|
191
|
-
// 8.
|
|
157
|
+
// 8. Repeat the database call to include late arrivals.
|
|
192
158
|
const reinforceCount = await reassociateSessionLogs(runnerSessionId, task.id);
|
|
193
159
|
expect(reinforceCount).toBe(1);
|
|
194
160
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { mkdtemp, readdir, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
|
|
6
|
+
// Runs scripts/pre-push-affected-tests.ts against this checkout, so the controls
|
|
7
|
+
// below use files that exist in the repo.
|
|
8
|
+
const REPO_ROOT = resolve(import.meta.dir, "../..");
|
|
9
|
+
const SELECTOR = join(REPO_ROOT, "scripts/pre-push-affected-tests.ts");
|
|
10
|
+
const SELECTOR_BUDGET_MS = 30_000;
|
|
11
|
+
|
|
12
|
+
async function select(...changed: string[]): Promise<string[]> {
|
|
13
|
+
const out = await Bun.$`bun ${SELECTOR} ${changed}`.cwd(REPO_ROOT).quiet().text();
|
|
14
|
+
return out.split("\n").filter(Boolean);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe("pre-push affected-test selector", () => {
|
|
18
|
+
test(
|
|
19
|
+
"a changed test selects itself; a deleted one selects nothing",
|
|
20
|
+
async () => {
|
|
21
|
+
expect(await select("src/tests/pre-push-affected-tests.test.ts")).toEqual([
|
|
22
|
+
"./src/tests/pre-push-affected-tests.test.ts",
|
|
23
|
+
]);
|
|
24
|
+
expect(await select("src/tests/does-not-exist.test.ts")).toEqual([]);
|
|
25
|
+
},
|
|
26
|
+
SELECTOR_BUDGET_MS,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
test(
|
|
30
|
+
"a hub file stays within the budget and keeps its named tests",
|
|
31
|
+
async () => {
|
|
32
|
+
// src/utils/secret-scrubber.ts reaches ~870 test files through the import graph.
|
|
33
|
+
const picked = await select("src/utils/secret-scrubber.ts");
|
|
34
|
+
expect(picked.length).toBeGreaterThan(0);
|
|
35
|
+
expect(picked.length).toBeLessThanOrEqual(40);
|
|
36
|
+
expect(picked).toContain("./src/tests/secret-scrubber.test.ts");
|
|
37
|
+
},
|
|
38
|
+
SELECTOR_BUDGET_MS,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
test(
|
|
42
|
+
"a level past the budget fills the budget instead of dropping its tests",
|
|
43
|
+
async () => {
|
|
44
|
+
// Fixture repo: src/types.ts has more direct test importers than the budget,
|
|
45
|
+
// and src/mid.ts (which imports types) reaches a second level past what is left.
|
|
46
|
+
const dir = await mkdtemp(join(tmpdir(), "affected-tests-"));
|
|
47
|
+
try {
|
|
48
|
+
await Bun.write(join(dir, "scripts/pre-push-affected-tests.ts"), Bun.file(SELECTOR));
|
|
49
|
+
await Bun.write(join(dir, "src/types.ts"), "export const value = 1;\n");
|
|
50
|
+
await Bun.write(join(dir, "src/hub.ts"), "export const hub = 1;\n");
|
|
51
|
+
await Bun.write(join(dir, "src/mid.ts"), 'export { value } from "./types";\n');
|
|
52
|
+
const write = (name: string, from: string) =>
|
|
53
|
+
Bun.write(join(dir, "tests", name), `import "../src/${from}";\n`);
|
|
54
|
+
for (let i = 0; i < 6; i++) await write(`edge-${i}.test.ts`, "hub");
|
|
55
|
+
for (let i = 0; i < 2; i++) await write(`direct-${i}.test.ts`, "types");
|
|
56
|
+
for (let i = 0; i < 6; i++) await write(`deep-${i}.test.ts`, "mid");
|
|
57
|
+
await write("types-mid.test.ts", "mid");
|
|
58
|
+
await Bun.$`git init -q && git add -A`.cwd(dir).quiet();
|
|
59
|
+
|
|
60
|
+
const run = async (file: string) =>
|
|
61
|
+
(
|
|
62
|
+
await Bun.$`bun scripts/pre-push-affected-tests.ts ${file}`
|
|
63
|
+
.cwd(dir)
|
|
64
|
+
.env({ ...process.env, PRE_PUSH_TESTS_BUDGET: "5" })
|
|
65
|
+
.quiet()
|
|
66
|
+
.text()
|
|
67
|
+
)
|
|
68
|
+
.split("\n")
|
|
69
|
+
.filter(Boolean);
|
|
70
|
+
|
|
71
|
+
// First level alone passes the budget: a stable nonempty sample, not zero.
|
|
72
|
+
const hub = await run("src/hub.ts");
|
|
73
|
+
expect(hub).toEqual([0, 1, 2, 3, 4].map((i) => `./tests/edge-${i}.test.ts`));
|
|
74
|
+
expect(await run("src/hub.ts")).toEqual(hub);
|
|
75
|
+
|
|
76
|
+
// Lower level kept, named test kept, the rest of the overflowing level fills to 5.
|
|
77
|
+
expect(await run("src/types.ts")).toEqual([
|
|
78
|
+
"./tests/deep-0.test.ts",
|
|
79
|
+
"./tests/deep-1.test.ts",
|
|
80
|
+
"./tests/direct-0.test.ts",
|
|
81
|
+
"./tests/direct-1.test.ts",
|
|
82
|
+
"./tests/types-mid.test.ts",
|
|
83
|
+
]);
|
|
84
|
+
} finally {
|
|
85
|
+
await rm(dir, { recursive: true, force: true });
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
SELECTOR_BUDGET_MS,
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
test(
|
|
92
|
+
"a migration selects every migration test",
|
|
93
|
+
async () => {
|
|
94
|
+
const migrations = (await readdir(join(REPO_ROOT, "src/be/migrations"))).filter((f) =>
|
|
95
|
+
f.endsWith(".sql"),
|
|
96
|
+
);
|
|
97
|
+
const picked = await select(`src/be/migrations/${migrations[0]}`);
|
|
98
|
+
const migrationTests = (await readdir(join(REPO_ROOT, "src/tests"))).filter(
|
|
99
|
+
(f) => f.includes("migration") && f.endsWith(".test.ts"),
|
|
100
|
+
);
|
|
101
|
+
expect(migrationTests.length).toBeGreaterThan(0);
|
|
102
|
+
for (const t of migrationTests) expect(picked).toContain(`./src/tests/${t}`);
|
|
103
|
+
},
|
|
104
|
+
SELECTOR_BUDGET_MS,
|
|
105
|
+
);
|
|
106
|
+
});
|
|
@@ -314,6 +314,7 @@ describe("Session templates: MUST pointers", () => {
|
|
|
314
314
|
expect(result.text).toContain(
|
|
315
315
|
"a `card` on `slack-reply` or `chat-reply` (max 1 table of 100 rows, 2 charts), not a file or Page. Bigger or document-shaped: agent-fs.",
|
|
316
316
|
);
|
|
317
|
+
expect(result.text).toContain("See the `boards-and-sheets` skill.");
|
|
317
318
|
expect(result.unresolved).toEqual([]);
|
|
318
319
|
});
|
|
319
320
|
|
|
@@ -321,6 +322,8 @@ describe("Session templates: MUST pointers", () => {
|
|
|
321
322
|
const result = resolveTemplate("system.agent.outputs.no_agent_fs", {});
|
|
322
323
|
expect(result.text).toContain("make a Page only when the requester asks for one");
|
|
323
324
|
expect(result.text).not.toContain("drive path");
|
|
325
|
+
// Sheets and boards are agent-fs files, so this variant does not route to them.
|
|
326
|
+
expect(result.text).not.toContain("boards-and-sheets");
|
|
324
327
|
expect(result.text).toContain("Bigger or document-shaped: a Markdown attachment.");
|
|
325
328
|
});
|
|
326
329
|
});
|
|
@@ -131,9 +131,6 @@ function setup(taskCount = 1) {
|
|
|
131
131
|
return { state, sessions, tasks };
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
/** Let the fire-and-forget `session.abort` microtask run. */
|
|
135
|
-
const flush = () => Bun.sleep(5);
|
|
136
|
-
|
|
137
134
|
describe("applyApiDrainSignal", () => {
|
|
138
135
|
test("a draining answer sets the state and a clean answer clears it", () => {
|
|
139
136
|
const { state } = setup(0);
|
|
@@ -203,8 +200,8 @@ describe("pollForTrigger", () => {
|
|
|
203
200
|
describe("handOffTasksForApiDrain", () => {
|
|
204
201
|
test("supersedes with the graceful_shutdown reason and aborts the session once", async () => {
|
|
205
202
|
const { state, sessions, tasks } = setup(2);
|
|
206
|
-
await handOffTasksForApiDrain(state, "worker", apiConfig());
|
|
207
|
-
|
|
203
|
+
for (let i = 0; i < 4; i++) await handOffTasksForApiDrain(state, "worker", apiConfig());
|
|
204
|
+
expect(supersedeCalls()).toHaveLength(2);
|
|
208
205
|
|
|
209
206
|
for (const [i, task] of tasks.entries()) {
|
|
210
207
|
const call = supersedeCalls().find((r) => r.path === `/api/tasks/${task.taskId}/supersede`);
|
|
@@ -216,21 +213,12 @@ describe("handOffTasksForApiDrain", () => {
|
|
|
216
213
|
}
|
|
217
214
|
});
|
|
218
215
|
|
|
219
|
-
test("hands off once: later passes make no call for an answered task", async () => {
|
|
220
|
-
const { state, sessions } = setup(1);
|
|
221
|
-
for (let i = 0; i < 4; i++) await handOffTasksForApiDrain(state, "worker", apiConfig());
|
|
222
|
-
await flush();
|
|
223
|
-
expect(supersedeCalls()).toHaveLength(1);
|
|
224
|
-
expect(sessions[0]?.abortReasons).toHaveLength(1);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
216
|
test("a failed call leaves the task running and retries up to the cap", async () => {
|
|
228
217
|
stub.supersede = [{ status: 503, body: { error: "unavailable" } }];
|
|
229
218
|
const { state, sessions, tasks } = setup(1);
|
|
230
219
|
for (let i = 0; i < API_DRAIN_HANDOFF_MAX_ATTEMPTS + 3; i++) {
|
|
231
220
|
await handOffTasksForApiDrain(state, "worker", apiConfig());
|
|
232
221
|
}
|
|
233
|
-
await flush();
|
|
234
222
|
expect(supersedeCalls()).toHaveLength(API_DRAIN_HANDOFF_MAX_ATTEMPTS);
|
|
235
223
|
expect(sessions[0]?.abortReasons).toEqual([]);
|
|
236
224
|
expect(tasks[0]?.serverTerminalStatus).toBeUndefined();
|
|
@@ -242,7 +230,6 @@ describe("handOffTasksForApiDrain", () => {
|
|
|
242
230
|
const { state, sessions } = setup(1);
|
|
243
231
|
await handOffTasksForApiDrain(state, "worker", apiConfig());
|
|
244
232
|
await handOffTasksForApiDrain(state, "worker", apiConfig());
|
|
245
|
-
await flush();
|
|
246
233
|
expect(supersedeCalls()).toHaveLength(2);
|
|
247
234
|
expect(sessions[0]?.abortReasons).toEqual(["graceful_shutdown"]);
|
|
248
235
|
});
|
|
@@ -253,7 +240,6 @@ describe("handOffTasksForApiDrain", () => {
|
|
|
253
240
|
];
|
|
254
241
|
const { state, sessions, tasks } = setup(1);
|
|
255
242
|
await handOffTasksForApiDrain(state, "worker", apiConfig());
|
|
256
|
-
await flush();
|
|
257
243
|
expect(tasks[0]?.serverTerminalStatus).toBe("failed");
|
|
258
244
|
expect(sessions[0]?.abortReasons).toEqual(["graceful_shutdown"]);
|
|
259
245
|
});
|
|
@@ -269,7 +255,6 @@ describe("handOffTasksForApiDrain", () => {
|
|
|
269
255
|
const { state, sessions, tasks } = setup(1);
|
|
270
256
|
await handOffTasksForApiDrain(state, "worker", apiConfig());
|
|
271
257
|
await handOffTasksForApiDrain(state, "worker", apiConfig());
|
|
272
|
-
await flush();
|
|
273
258
|
expect(supersedeCalls()).toHaveLength(1);
|
|
274
259
|
expect(sessions[0]?.abortReasons).toEqual([]);
|
|
275
260
|
expect(tasks[0]?.serverTerminalStatus).toBeUndefined();
|