@desplega.ai/agent-swarm 2.8.1 → 2.8.3
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-xq6s2z6t.js +14 -0
- package/dist/{actions-pwjpn0j6.js → actions-ewz7bp4g.js} +20 -19
- package/dist/{amp-adapter-cq9jgj6x.js → amp-adapter-f25tqhnf.js} +3 -3
- package/dist/{app-cnfffgwg.js → app-mkptw0k7.js} +4 -4
- package/dist/{assistant-kpn317y1.js → assistant-c47rfe77.js} +23 -22
- package/dist/{boot-args-schema-pbbnhmc3.js → boot-args-schema-4vb0xsat.js} +1 -1
- package/dist/{boot-reembed-9m0ysxma.js → boot-reembed-1ghy2sab.js} +1 -1
- package/dist/{boot-reembed-majbn53m.js → boot-reembed-htr73hbs.js} +1 -1
- package/dist/{boot-scrub-sweep-app8g8ym.js → boot-scrub-sweep-yrytg42z.js} +4 -4
- package/dist/{boot-seeds-pbtmvcjm.js → boot-seeds-n2b3dx4e.js} +4 -4
- package/dist/{boxd-qbkxy6ap.js → boxd-jmfqgkqa.js} +2 -2
- package/dist/{claude-adapter-wn1g3qp5.js → claude-adapter-r33pqnzx.js} +8 -9
- package/dist/{claude-managed-adapter-jh6c523j.js → claude-managed-adapter-hddmxjyj.js} +4 -4
- package/dist/{claude-managed-setup-pd47nzch.js → claude-managed-setup-hfvry1bd.js} +5 -5
- package/dist/{claude-sdk-session-3a2a6589.js → claude-sdk-session-0hamqzc7.js} +10 -11
- package/dist/{cli-v1dv1r37.js → cli-0bcgyj5b.js} +74 -3
- package/dist/{cli-a3b239vq.js → cli-0vksaxvr.js} +2 -2
- package/dist/{cli-mrt48bx7.js → cli-15204js0.js} +1 -1
- package/dist/{cli-8aes17e4.js → cli-1m96dc36.js} +3 -3
- package/dist/{cli-2r0jcc3k.js → cli-2d0cghfn.js} +1 -1
- package/dist/{cli-wk18cm92.js → cli-4ax9mvvg.js} +4 -4
- package/dist/{cli-9wngrawf.js → cli-4dpkjc2e.js} +6 -6
- package/dist/{cli-x1wa213s.js → cli-4e1hfbpq.js} +5 -5
- package/dist/{cli-7349va39.js → cli-500c09j9.js} +921 -431
- package/dist/{cli-m4dqmnbp.js → cli-54qr8mcd.js} +2 -2
- package/dist/{cli-m88rpzkh.js → cli-5a7szzfh.js} +2 -2
- package/dist/{cli-bst1vp7e.js → cli-5y2fvw4z.js} +13 -5
- package/dist/{cli-vj75tyaw.js → cli-6yygkr0w.js} +7 -7
- package/dist/{cli-7b8sbmag.js → cli-7c5tgqhf.js} +5 -5
- package/dist/{cli-2gxeg5gr.js → cli-8476gtwf.js} +1 -1
- package/dist/{cli-yncmerje.js → cli-922z7gwm.js} +4 -4
- package/dist/{cli-jrzkw01m.js → cli-93t5s4zq.js} +2 -2
- package/dist/{cli-sn7rtnj4.js → cli-9zmb7ptc.js} +9 -9
- package/dist/{cli-tk7cjj8h.js → cli-am1ptset.js} +3 -3
- package/dist/{cli-cyhbbd1z.js → cli-awwptga4.js} +1 -1
- package/dist/{cli-89cqnasv.js → cli-bhsfbmk8.js} +19 -7
- package/dist/{cli-9vhebtjz.js → cli-bj6qhgte.js} +15 -32
- package/dist/{cli-g70vxtjh.js → cli-c0xjnr8z.js} +2 -2
- package/dist/{cli-vqptjbr7.js → cli-c3ng0mb4.js} +14 -14
- package/dist/{cli-re4raaj0.js → cli-c71n3bxq.js} +11 -6
- package/dist/{cli-7p1kvkck.js → cli-crpf163n.js} +25 -18
- package/dist/{cli-k0wwfqbg.js → cli-dns0y538.js} +4 -0
- package/dist/{cli-d3p5vwbk.js → cli-dpsfwh7n.js} +13 -21
- package/dist/{cli-xzm9vcfg.js → cli-dtdht77h.js} +2 -2
- package/dist/{cli-bb431xey.js → cli-e2w34h6z.js} +231 -68
- package/dist/{cli-eddnyg3t.js → cli-emekyyhr.js} +1 -1
- package/dist/{cli-d84byzn8.js → cli-f1kwb5fc.js} +109 -33
- package/dist/{cli-0jzra9ad.js → cli-gn9y6fn7.js} +2 -2
- package/dist/{cli-tqegb8eq.js → cli-gpz1d0t2.js} +4 -4
- package/dist/{cli-7w69ne2f.js → cli-h9yy18gy.js} +239 -67
- package/dist/{cli-m5akxq8q.js → cli-j8cjdzan.js} +1 -1
- package/dist/{cli-m9s2qff2.js → cli-jg5txpm6.js} +187 -93
- package/dist/{cli-k26bkr9t.js → cli-k2rw11py.js} +3 -3
- package/dist/{cli-93k32c37.js → cli-k96cecs7.js} +377 -61
- package/dist/{cli-3vjhs18n.js → cli-kd56bmk4.js} +1 -1
- package/dist/{cli-k0615eh8.js → cli-kmemts3w.js} +13 -13
- package/dist/{cli-pcad4cb1.js → cli-knva3nmx.js} +2 -2
- package/dist/{cli-b085njxz.js → cli-kw44j53p.js} +15 -14
- package/dist/{cli-bsywb58a.js → cli-mdpbjnzq.js} +10 -10
- package/dist/{cli-syybb0p1.js → cli-me0r8gzr.js} +35 -76
- package/dist/{cli-4r05hnqa.js → cli-mwwmka77.js} +15 -15
- package/dist/{cli-1xh9a7hn.js → cli-n5t077me.js} +2 -2
- package/dist/{cli-rvhdmjvt.js → cli-nx2n3z6p.js} +1 -1
- package/dist/{cli-28fq781p.js → cli-pe4d96rb.js} +1 -1
- package/dist/{cli-3rkdne1h.js → cli-pxwtcgcp.js} +2 -2
- package/dist/{cli-zcsw143p.js → cli-qmqt520k.js} +2 -2
- package/dist/{cli-2zp0et3v.js → cli-qps8je6j.js} +70 -19
- package/dist/{cli-xae4g51r.js → cli-rh15cakt.js} +1 -1
- package/dist/{cli-k93bq1wq.js → cli-rjvsf9qa.js} +5 -5
- package/dist/{cli-6mma83xa.js → cli-rqfvkx5t.js} +7 -7
- package/dist/{cli-dy32zecz.js → cli-s7zz734a.js} +1 -1
- package/dist/{cli-yn2bbre9.js → cli-s8p8hhty.js} +2 -2
- package/dist/{cli-vbh10fqa.js → cli-sdvcrq5x.js} +5 -5
- package/dist/{cli-b5rs97a6.js → cli-sg27rk2t.js} +5 -5
- package/dist/{cli-d6521kb5.js → cli-skmhsnqh.js} +1 -1
- package/dist/{cli-5mrq3ake.js → cli-t4dv07kr.js} +1 -1
- package/dist/{cli-hxpyc9sn.js → cli-t5ys4ebm.js} +3 -3
- package/dist/{cli-qmqk2yc2.js → cli-tas6ckky.js} +2 -2
- package/dist/{cli-p1w18yhx.js → cli-tf79ryyy.js} +1 -1
- package/dist/{cli-kc7v1nfv.js → cli-tnzebztn.js} +1 -1
- package/dist/{cli-gax7fk3t.js → cli-vx421edw.js} +3 -3
- package/dist/{cli-kchjb7qy.js → cli-x3ex5bqf.js} +1 -1
- package/dist/cli-yss07azk.js +142 -0
- package/dist/{cli-0ntbxyaa.js → cli-z8cvws4c.js} +363 -47
- package/dist/{cli-tacge1w0.js → cli-zdaypkq9.js} +146 -52
- package/dist/{cli-b8e9nb04.js → cli-zeaehgyd.js} +2 -2
- package/dist/{cli-jcpr5smb.js → cli-ztq5z4e1.js} +4 -4
- package/dist/cli.js +21 -21
- package/dist/{codex-adapter-nha71q3n.js → codex-adapter-2brxx5ta.js} +7 -8
- package/dist/{codex-hook-h3vk6xzr.js → codex-hook-c930c3ea.js} +2 -2
- package/dist/{codex-login-bcda78ge.js → codex-login-cbrs1h5w.js} +1 -1
- package/dist/{codex-session-runner-ak9x1k1h.js → codex-session-runner-y9anfj0r.js} +8 -9
- package/dist/{commands-f587qpq8.js → commands-wn9q06qr.js} +3 -3
- package/dist/{controller-hxx8wwy1.js → controller-fw608czd.js} +4 -4
- package/dist/{controllers-connect-k5sg9m9h.js → controllers-connect-63j5rdcm.js} +20 -20
- package/dist/{cursor-adapter-n5nc3mfe.js → cursor-adapter-6mb9jme8.js} +2 -2
- package/dist/{db-nzf8zb5z.js → db-0m6v5tq4.js} +3 -3
- package/dist/{db-amm8w15a.js → db-y4wfrzbm.js} +4 -2
- package/dist/{devin-adapter-xedz98zv.js → devin-adapter-r0yx3gv8.js} +1 -1
- package/dist/{dispatcher-89zrts8f.js → dispatcher-9tq2zzdj.js} +17 -17
- package/dist/{docker-866qpzt9.js → docker-j75atvpt.js} +2 -2
- package/dist/{dsh-adapter-nrhbrjz8.js → dsh-adapter-t09sv4tq.js} +2 -2
- package/dist/{e2b-s16txnpx.js → e2b-7s9dscap.js} +3 -3
- package/dist/{e2b-jkwfhbcv.js → e2b-a7vzs2vj.js} +3 -3
- package/dist/{easter-egg-3d-533knw22.js → easter-egg-3d-fbwvmwhe.js} +1 -1
- package/dist/{embedding-space-ezwenjmj.js → embedding-space-wh8de1t9.js} +6 -6
- package/dist/{embeddings-np74ht6g.js → embeddings-3hpbdtjr.js} +1 -1
- package/dist/{event-bus-e66gh7cc.js → event-bus-tr6h3gv8.js} +1 -1
- package/dist/{execute-b3mrb1mv.js → execute-4bdf8sdy.js} +1 -1
- package/dist/{external-channel-z46yx9d7.js → external-channel-ts2fwqh0.js} +2 -2
- package/dist/fx-adapter-1rnxnf56.js +17 -0
- package/dist/grok-adapter-efhmf1r8.js +17 -0
- package/dist/handlers-anrr3py9.js +32 -0
- package/dist/{heartbeat-dt9qw9c8.js → heartbeat-2ze5fzpc.js} +20 -20
- package/dist/{hook-8k6fbz9b.js → hook-ca54yd4s.js} +5 -5
- package/dist/{hook-jgcgygex.js → hook-gaehe2w5.js} +8 -8
- package/dist/{http-haw4r8ne.js → http-jfg8t2yk.js} +3839 -122
- package/dist/{index-tvfafeyy.js → index-3gv6sc4z.js} +1 -1
- package/dist/{index-tez78qj3.js → index-3yvzbhxd.js} +100 -23
- package/dist/index-8w2aznds.js +33 -0
- package/dist/{index-5gk12my8.js → index-csgrxedz.js} +1 -1
- package/dist/index-qnjvr362.js +37 -0
- package/dist/index-yzxd3sn9.js +32 -0
- package/dist/{keepalive-xn6s7rmg.js → keepalive-k2a3qe73.js} +4 -4
- package/dist/lead-zhxqbfdv.js +69 -0
- package/dist/{maintenance-vdts800b.js → maintenance-gb5sd5nc.js} +1 -1
- package/dist/{node-4c5jqxr3.js → node-7qsx5kvm.js} +1 -1
- package/dist/{oauth-refresh-sweep-094c8wfk.js → oauth-refresh-sweep-y7rm6bkb.js} +3 -3
- package/dist/{onboard-v99eh56m.js → onboard-jmc5qerv.js} +4 -4
- package/dist/{opencode-adapter-dsagkhtw.js → opencode-adapter-7eade9ev.js} +6 -7
- package/dist/{otel-impl-q7yr9yp0.js → otel-impl-8j1xhxqd.js} +2 -2
- package/dist/{pi-mono-adapter-546cd1cc.js → pi-mono-adapter-yqmaf32x.js} +14 -13
- package/dist/{pricing-refresh-7dh2yase.js → pricing-refresh-1nj722h6.js} +2 -2
- package/dist/{rbac-roles-mdmc96p4.js → rbac-roles-b1mtr6dr.js} +3 -3
- package/dist/{rbac-roles-npbmdh77.js → rbac-roles-n1f3frk1.js} +2 -2
- package/dist/{render-v2-twhhwmms.js → render-v2-1gfpd8rj.js} +4 -4
- package/dist/{resume-5gsrjd5e.js → resume-w1s1eh5v.js} +7 -7
- package/dist/{runtime-1hv06jsn.js → runtime-84g5egsc.js} +1 -1
- package/dist/{session-access-m191x30x.js → session-access-y6z1txk4.js} +4 -4
- package/dist/{session-source-backfill-nt923ask.js → session-source-backfill-gxxwfh12.js} +3 -3
- package/dist/{setup-wv467afy.js → setup-r91gstyk.js} +1 -1
- package/dist/{virtual-modules-gazyapte.js → virtual-modules-cgnj6kme.js} +3 -3
- package/dist/{work-objects-8zkrpy13.js → work-objects-qcxzg61c.js} +20 -20
- package/dist/worker-7j2907g6.js +69 -0
- package/dist/{worker-follow-up-cecqszem.js → worker-follow-up-y2d2h7km.js} +19 -17
- package/dist/{x-2fyrt5pp.js → x-qhxq2ama.js} +2 -2
- package/openapi.json +2908 -351
- package/package.json +4 -4
- package/src/apps/catalog.generated.json +120 -1
- package/src/apps/definition.ts +38 -11
- package/src/apps/page-validator.ts +88 -0
- package/src/be/db/model-profiles.ts +110 -11
- package/src/be/db/tasks/read.ts +53 -0
- package/src/be/db/workflow-run-definitions.ts +19 -8
- package/src/be/db-client.ts +43 -5
- package/src/be/db.ts +40 -9
- package/src/be/migrations/284_model_profile_fallbacks.sql +9 -0
- package/src/be/migrations/289_automation_savings_daily.sql +47 -0
- package/src/be/migrations/291_task_slack_participants.sql +4 -0
- package/src/be/migrations/293_savings_component_links.sql +58 -0
- package/src/be/migrations/296_automation_savings_daily_read_index.sql +6 -0
- package/src/be/model-profile-check.ts +53 -20
- package/src/be/runtime-pools/routing.ts +1 -0
- package/src/be/savings/calibrate.ts +468 -0
- package/src/be/savings/compute.ts +677 -0
- package/src/be/savings/model.ts +674 -0
- package/src/be/savings/read.ts +1500 -0
- package/src/be/savings/rollup.ts +571 -0
- package/src/be/scripts/run-credential.ts +15 -3
- package/src/be/scripts/typecheck.ts +91 -4
- package/src/be/seed/agent-fs-provision.ts +48 -11
- package/src/be/seed/workflows-seeder.ts +67 -23
- package/src/be/seed-scripts/catalog/dreaming-learnings.ts +10 -2
- package/src/be/seed-scripts/catalog/dreaming-memtax-create.ts +70 -4
- package/src/be/skill-parser.ts +19 -7
- package/src/be/swarm-config-guard.ts +8 -0
- package/src/be/users.ts +29 -2
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/provider-error-class.ts +97 -0
- package/src/commands/runner.ts +258 -58
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/http/all-routes.ts +2 -0
- package/src/http/fs.ts +8 -2
- package/src/http/index.ts +11 -0
- package/src/http/model-profiles.ts +43 -10
- package/src/http/poll.ts +15 -1
- package/src/http/requested-by.ts +97 -1
- package/src/http/savings-calibration.ts +277 -0
- package/src/http/savings.ts +849 -0
- package/src/http/scripts.ts +26 -15
- package/src/http/tasks.ts +89 -9
- package/src/http/trackers/authorize-gate.ts +41 -0
- package/src/http/trackers/jira.ts +26 -4
- package/src/http/trackers/linear.ts +26 -4
- package/src/integrations/chat-sdk/limits.ts +6 -1
- package/src/jira/oauth.ts +7 -1
- package/src/linear/README.md +2 -1
- package/src/linear/oauth.ts +7 -1
- package/src/prompts/session-templates.ts +80 -3
- package/src/providers/acp-targets.ts +1 -1
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +0 -20
- package/src/providers/claude-flag-settings.ts +12 -10
- package/src/providers/codex-adapter.ts +12 -34
- package/src/providers/opencode-adapter.ts +34 -12
- package/src/providers/pi-mono-adapter.ts +6 -5
- package/src/providers/types.ts +7 -0
- package/src/scheduler/scheduler.ts +20 -14
- package/src/scripts-runtime/ctx.ts +1 -1
- package/src/scripts-runtime/executors/quickjs-bundle.ts +1 -0
- package/src/scripts-runtime/executors/quickjs-prelude.ts +162 -2
- package/src/scripts-runtime/executors/quickjs-runner.ts +4 -1
- package/src/scripts-runtime/sdk-allowlist.ts +11 -1
- package/src/scripts-runtime/stdlib/fetch.ts +113 -15
- package/src/scripts-runtime/stdlib/index.ts +3 -1
- package/src/scripts-runtime/stdlib/retry.ts +174 -0
- package/src/scripts-runtime/swarm-sdk.ts +192 -17
- package/src/scripts-runtime/types/stdlib.d.ts +95 -4
- package/src/scripts-runtime/types/swarm-extension.d.ts +60 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +69 -2
- package/src/slack/actions.ts +1 -0
- package/src/slack/assistant.ts +2 -0
- package/src/slack/enrich.ts +144 -50
- package/src/slack/handlers.ts +37 -95
- package/src/slack/templates.ts +9 -0
- package/src/slack/thread-buffer.ts +45 -71
- package/src/slack/thread-participants.ts +187 -0
- package/src/tasks/worker-follow-up.ts +142 -3
- package/src/tests/agent-fs-provision-seeder.test.ts +81 -0
- package/src/tests/apps-chart-shell.test.ts +170 -0
- package/src/tests/apps-icon.test.ts +156 -2
- package/src/tests/base-prompt.test.ts +5 -4
- package/src/tests/chat-sdk-relay.test.ts +12 -0
- package/src/tests/claude-adapter-binary.test.ts +7 -1
- package/src/tests/claude-adapter.test.ts +10 -64
- package/src/tests/claude-flag-settings.test.ts +15 -11
- package/src/tests/claude-hook-credentials.test.ts +0 -1
- package/src/tests/claude-sdk-lifecycle.test.ts +5 -1
- package/src/tests/codex-adapter.test.ts +28 -78
- package/src/tests/comb-default.test.ts +6 -0
- package/src/tests/core-auth.test.ts +7 -6
- package/src/tests/create-task-vcs-repo.test.ts +136 -0
- package/src/tests/db-client-busy-retry.test.ts +58 -6
- package/src/tests/db-task-read-contract.test.ts +2 -0
- package/src/tests/db-task-write-contract.test.ts +1 -0
- package/src/tests/deploy-guard.test.ts +154 -0
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/dreaming-learnings.test.ts +104 -0
- package/src/tests/extensions-pre-task.test.ts +4 -2
- package/src/tests/fetch-resolved-env.test.ts +47 -1
- package/src/tests/fixtures/app-shell-charts-definition.json.txt +180 -0
- package/src/tests/model-profile-fallbacks.test.ts +482 -0
- package/src/tests/model-profiles-api.test.ts +1 -0
- package/src/tests/opencode-adapter.test.ts +53 -6
- package/src/tests/pi-mono-session-cost-on-abort.test.ts +115 -0
- package/src/tests/prompt-template-session.test.ts +17 -1
- package/src/tests/provider-error-class.test.ts +174 -0
- package/src/tests/runner-provider-fallback.test.ts +197 -0
- package/src/tests/runner-requester-profile.test.ts +139 -1
- package/src/tests/savings-calibration-api.test.ts +264 -0
- package/src/tests/savings-calibration.test.ts +201 -0
- package/src/tests/savings-compound.test.ts +774 -0
- package/src/tests/savings-compute.test.ts +215 -0
- package/src/tests/savings-fleet-latency.test.ts +143 -0
- package/src/tests/savings-fleet-read.test.ts +195 -0
- package/src/tests/savings-fleet-scale.test.ts +222 -0
- package/src/tests/savings-model.test.ts +499 -0
- package/src/tests/savings-read.test.ts +367 -0
- package/src/tests/savings-rollup.test.ts +766 -0
- package/src/tests/savings-scripts.test.ts +611 -0
- package/src/tests/script-connections.test.ts +4 -0
- package/src/tests/script-executor-conformance.test.ts +444 -0
- package/src/tests/scripts-http.test.ts +55 -0
- package/src/tests/scripts-runtime-fetch.test.ts +2 -2
- package/src/tests/sdk-allowlist.test.ts +40 -0
- package/src/tests/secret-rules.test.ts +124 -1
- package/src/tests/secret-scrubber.test.ts +1 -1
- package/src/tests/seed-workflows.test.ts +167 -11
- package/src/tests/skill-parser.test.ts +45 -0
- package/src/tests/slack-dm-implicit-mention.test.ts +20 -1
- package/src/tests/slack-identity-resolution.test.ts +23 -0
- package/src/tests/slack-inbound-files.test.ts +2 -1
- package/src/tests/slack-thread-participants.test.ts +429 -0
- package/src/tests/tool-annotations.test.ts +30 -0
- package/src/tests/tracker-oauth-authorize-auth.test.ts +262 -0
- package/src/tests/workflow-definition-pinning.test.ts +128 -3
- package/src/tests/workflow-script-principal.test.ts +94 -4
- package/src/tools/app-upsert.ts +1 -1
- package/src/tools/model-profiles/list-model-profiles.ts +4 -2
- package/src/tools/update-profile.ts +1 -1
- package/src/types.ts +146 -33
- package/src/utils/constants.ts +2 -0
- package/src/utils/mcp-server-fetcher.test.ts +89 -0
- package/src/utils/mcp-server-fetcher.ts +13 -5
- package/src/utils/request-auth-context.ts +24 -0
- package/src/utils/secret-rules.generated.ts +1 -1
- package/src/utils/secret-scrubber.ts +154 -29
- package/src/workflows/executors/swarm-script.ts +23 -19
- package/templates/skills/apps/SKILL.md +62 -3
- package/templates/skills/apps/content.md +62 -3
- package/templates/skills/swarm-docs/content.md +2 -0
- package/templates/skills/swarm-scripts/SKILL.md +5 -4
- package/templates/skills/swarm-scripts/content.md +5 -4
- package/templates/skills/work-on-task/SKILL.md +1 -1
- package/templates/skills/work-on-task/content.md +1 -1
- package/templates/workflows/dreaming/content.md +1 -1
- package/dist/acp-adapter-pdy3qsvg.js +0 -15
- package/dist/cli-4bd1rck6.js +0 -4
- package/dist/cli-jywyhqws.js +0 -104
- package/dist/fx-adapter-3q12snn6.js +0 -18
- package/dist/grok-adapter-ahb1w033.js +0 -18
- package/dist/handlers-vbww69re.js +0 -32
- package/dist/index-4xwaf5th.js +0 -32
- package/dist/index-f0hcrs8e.js +0 -33
- package/dist/index-s4ewdma4.js +0 -37
- package/dist/lead-6ygbfhbh.js +0 -70
- package/dist/worker-mz5z7kj0.js +0 -70
- package/src/providers/ctx-mode-env.ts +0 -10
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { randomBytes } from "node:crypto";
|
|
3
|
-
import { convertGoRegex, stripKeyPrefix } from "../../scripts/gen-secret-rules";
|
|
3
|
+
import { anchorAlternation, convertGoRegex, stripKeyPrefix } from "../../scripts/gen-secret-rules";
|
|
4
4
|
import { GITLEAKS_RULES } from "../utils/secret-rules.generated";
|
|
5
5
|
import {
|
|
6
6
|
clearVolatileSecretsForTesting,
|
|
7
7
|
scrubSecrets,
|
|
8
8
|
setGitleaksPassEnabledForTesting,
|
|
9
|
+
takePass2SweepCountForTesting,
|
|
9
10
|
} from "../utils/secret-scrubber";
|
|
10
11
|
import { buildNegatives, buildPositives } from "./fixtures/secret-corpus";
|
|
11
12
|
import { randomToken } from "./synthetic-secret-helpers";
|
|
@@ -54,6 +55,54 @@ describe("convertGoRegex", () => {
|
|
|
54
55
|
});
|
|
55
56
|
});
|
|
56
57
|
|
|
58
|
+
describe("anchorAlternation", () => {
|
|
59
|
+
test("anchors a ^a|b$ alternation as a whole", () => {
|
|
60
|
+
expect(anchorAlternation({ source: "^true|false|null$", flags: "i" })).toEqual({
|
|
61
|
+
source: "^(?:true|false|null)$",
|
|
62
|
+
flags: "i",
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("splits only on top-level pipes, not escaped, grouped or in a class", () => {
|
|
67
|
+
expect(anchorAlternation({ source: String.raw`^a|[|](b|c)|d\|e$`, flags: "" }).source).toBe(
|
|
68
|
+
String.raw`^(?:a|[|](b|c)|d\|e)$`,
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("leaves single, grouped and uniformly anchored alternations alone", () => {
|
|
73
|
+
for (const source of ["^abc$", "^(?:a|b)$", "^a$|^b$", "a|b"]) {
|
|
74
|
+
expect(anchorAlternation({ source, flags: "" }).source).toBe(source);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("rejects any other mix of anchored and unanchored branches", () => {
|
|
79
|
+
expect(() => anchorAlternation({ source: "^a|b", flags: "" })).toThrow(/mixes anchored/);
|
|
80
|
+
expect(() => anchorAlternation({ source: "a|^b$", flags: "" })).toThrow(/mixes anchored/);
|
|
81
|
+
expect(() => anchorAlternation({ source: String.raw`^a|b\$`, flags: "" })).toThrow(
|
|
82
|
+
/mixes anchored/,
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("every generated allowlist regex is already anchored as a whole", () => {
|
|
87
|
+
const sources = [
|
|
88
|
+
...GITLEAKS_RULES.globalAllowlist.regexes,
|
|
89
|
+
...GITLEAKS_RULES.rules.flatMap((r) => (r.allowlists ?? []).flatMap((l) => l.regexes)),
|
|
90
|
+
];
|
|
91
|
+
expect(sources.length).toBeGreaterThan(10);
|
|
92
|
+
for (const re of sources) expect(anchorAlternation(re)).toEqual(re);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("the global allowlist still allows the bare values true, false and null", () => {
|
|
96
|
+
const res = GITLEAKS_RULES.globalAllowlist.regexes.map((r) => new RegExp(r.source, r.flags));
|
|
97
|
+
for (const value of ["true", "FALSE", "Null"]) {
|
|
98
|
+
expect(res.some((re) => re.test(value))).toBe(true);
|
|
99
|
+
}
|
|
100
|
+
for (const value of ["truex", "xfalse", "nullx", "afalseb"]) {
|
|
101
|
+
expect(res.some((re) => re.test(value))).toBe(false);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
57
106
|
describe("generated gitleaks rules", () => {
|
|
58
107
|
test("every rule compiles under Bun and has a keyword", () => {
|
|
59
108
|
expect(GITLEAKS_RULES.rules.length).toBeGreaterThan(200);
|
|
@@ -149,6 +198,80 @@ describe("secret corpus", () => {
|
|
|
149
198
|
}
|
|
150
199
|
});
|
|
151
200
|
|
|
201
|
+
test("redacts a secret that contains true, false or null", () => {
|
|
202
|
+
// The global allowlist was `^true|false|null$`: it allowed any secret
|
|
203
|
+
// containing "false", starting with "true" or ending with "null".
|
|
204
|
+
const lowerAlnum = (len: number) =>
|
|
205
|
+
randomToken(len * 2)
|
|
206
|
+
.toLowerCase()
|
|
207
|
+
.slice(0, len);
|
|
208
|
+
const words = ["true", "FALsE", "nULL", "True", "false", "Null"];
|
|
209
|
+
const cases: { text: string; secret: string; rule: string }[] = [];
|
|
210
|
+
for (const word of words) {
|
|
211
|
+
// The vault secret starts with `hvs.`, so the word goes mid and end.
|
|
212
|
+
for (const at of [31, 96 - word.length]) {
|
|
213
|
+
const tail = randomToken(96);
|
|
214
|
+
const secret = ["hvs", ".", tail.slice(0, at), word, tail.slice(at + word.length)].join("");
|
|
215
|
+
cases.push({ text: `token ${secret} end`, secret, rule: "vault-service-token" });
|
|
216
|
+
}
|
|
217
|
+
for (const at of [0, 14, 32 - word.length]) {
|
|
218
|
+
const body = lowerAlnum(32);
|
|
219
|
+
const secret = [body.slice(0, at), word, body.slice(at + word.length)].join("");
|
|
220
|
+
cases.push({ text: `droneci: ${secret}`, secret, rule: "droneci-access-token" });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
for (const { text, secret, rule } of cases) {
|
|
224
|
+
const out = scrubSecrets(text);
|
|
225
|
+
expect(out, `${rule} ${secret.slice(0, 8)}…`).not.toContain(secret);
|
|
226
|
+
expect(out).toContain(`[REDACTED:gitleaks:${rule}]`);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test("a vendor secret wins over a structural rule matching inside it", () => {
|
|
231
|
+
// A Heroku v2 key (`HRKU-AA` + 58 URL-safe chars) whose tail embeds
|
|
232
|
+
// `-sk-` + 20 alnum: pass 2's sk_key matched the tail first, and pass 5
|
|
233
|
+
// then missed the key, leaving its prefix in the output.
|
|
234
|
+
const heroku = () => ["HRKU", "-AA", randomToken(14), "-sk-", randomToken(40)].join("");
|
|
235
|
+
const bareSk = ["sk", randomToken(32)].join("-");
|
|
236
|
+
const a = heroku();
|
|
237
|
+
const b = heroku();
|
|
238
|
+
expect(a.length).toBe(65);
|
|
239
|
+
expect(scrubSecrets(`the response included ${a} in its body`)).toBe(
|
|
240
|
+
"the response included [REDACTED:gitleaks:heroku-api-key-v2] in its body",
|
|
241
|
+
);
|
|
242
|
+
// Two covered keys and an uncovered sk- key in one text keep their own labels.
|
|
243
|
+
expect(scrubSecrets(`${a} ${bareSk}\n${b}`)).toBe(
|
|
244
|
+
"[REDACTED:gitleaks:heroku-api-key-v2] [REDACTED:sk_key]\n[REDACTED:gitleaks:heroku-api-key-v2]",
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
test("pass 2 sweeps gitleaks once per call, however many rules hit", () => {
|
|
249
|
+
const heroku = () => ["HRKU", "-AA", randomToken(14), "-sk-", randomToken(40)].join("");
|
|
250
|
+
const a = heroku();
|
|
251
|
+
const b = heroku();
|
|
252
|
+
// Hits of several structural rules ahead of each key shift its offsets.
|
|
253
|
+
const text = [
|
|
254
|
+
["lin", "api", randomToken(24)].join("_"),
|
|
255
|
+
a,
|
|
256
|
+
["AKIA", "Q7RW3MZPXK5TB2NH"].join(""),
|
|
257
|
+
["sk", randomToken(32)].join("-"),
|
|
258
|
+
b,
|
|
259
|
+
["xai", randomToken(48)].join("-"),
|
|
260
|
+
].join(" ");
|
|
261
|
+
takePass2SweepCountForTesting();
|
|
262
|
+
expect(scrubSecrets(text)).toBe(
|
|
263
|
+
[
|
|
264
|
+
"[REDACTED:linear_api]",
|
|
265
|
+
"[REDACTED:gitleaks:heroku-api-key-v2]",
|
|
266
|
+
"[REDACTED:aws_access_key]",
|
|
267
|
+
"[REDACTED:sk_key]",
|
|
268
|
+
"[REDACTED:gitleaks:heroku-api-key-v2]",
|
|
269
|
+
"[REDACTED:xai_key]",
|
|
270
|
+
].join(" "),
|
|
271
|
+
);
|
|
272
|
+
expect(takePass2SweepCountForTesting()).toBe(1);
|
|
273
|
+
});
|
|
274
|
+
|
|
152
275
|
test("redacts a token whose last character is a dash or equals sign", () => {
|
|
153
276
|
// `\b` after a trailing `-` backtracks one character and leaves it behind.
|
|
154
277
|
const tokens = [
|
|
@@ -118,7 +118,7 @@ describe("scrubSecrets — env-based replacement", () => {
|
|
|
118
118
|
version: SCRUBBER_RULES_VERSION,
|
|
119
119
|
keyVars: [...openAICompatibleKeyVars()].sort(),
|
|
120
120
|
}).toEqual({
|
|
121
|
-
version:
|
|
121
|
+
version: 12,
|
|
122
122
|
keyVars: ["AI_GATEWAY_API_KEY", "HELMCODE_API_KEY", "HELMCODE_API_NAN", "NAN_API_KEY"],
|
|
123
123
|
});
|
|
124
124
|
});
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
2
|
import { unlink } from "node:fs/promises";
|
|
3
|
-
import { closeDb, initDb, listWorkflows, updateWorkflow } from "../be/db";
|
|
3
|
+
import { closeDb, computeContentHash, initDb, listWorkflows, updateWorkflow } from "../be/db";
|
|
4
4
|
import { getSeedState, runSeeder } from "../be/seed";
|
|
5
|
+
import { recordSeedState } from "../be/seed/state-db";
|
|
5
6
|
import {
|
|
7
|
+
canonicalJson,
|
|
6
8
|
createWorkflowsSeeder,
|
|
7
9
|
loadSeedWorkflows,
|
|
10
|
+
seededWorkflowState,
|
|
8
11
|
type WorkflowTemplateSource,
|
|
9
12
|
} from "../be/seed/workflows-seeder";
|
|
13
|
+
import { snapshotAndUpdateWorkflow } from "../workflows/version";
|
|
10
14
|
|
|
11
15
|
const TEST_DB_PATH = "./test-seed-workflows.sqlite";
|
|
12
16
|
|
|
@@ -20,7 +24,11 @@ async function removeDbFiles(): Promise<void> {
|
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
function workflowSource(
|
|
27
|
+
function workflowSource(
|
|
28
|
+
template = "Do the work.",
|
|
29
|
+
description = "Seeded workflow.",
|
|
30
|
+
input: Record<string, string> = { channel: "" },
|
|
31
|
+
) {
|
|
24
32
|
return {
|
|
25
33
|
config: JSON.stringify({
|
|
26
34
|
name: "test-seeded-workflow",
|
|
@@ -31,10 +39,43 @@ function workflowSource(template = "Do the work.", description = "Seeded workflo
|
|
|
31
39
|
}),
|
|
32
40
|
content: `# Test\n\n\`\`\`json\n${JSON.stringify({
|
|
33
41
|
nodes: [{ id: "work", type: "agent-task", config: { template } }],
|
|
42
|
+
input,
|
|
34
43
|
})}\n\`\`\``,
|
|
35
44
|
} satisfies WorkflowTemplateSource;
|
|
36
45
|
}
|
|
37
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Overwrite the recorded seed state with the hash older releases stored: the
|
|
49
|
+
* whole template workflow, operator settings included.
|
|
50
|
+
*/
|
|
51
|
+
async function recordLegacySeedState(source: WorkflowTemplateSource): Promise<void> {
|
|
52
|
+
const [workflow] = loadSeedWorkflows([source]);
|
|
53
|
+
await recordSeedState("workflow", workflow!.name, computeContentHash(canonicalJson(workflow)));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A real node edit on top of operator settings. */
|
|
57
|
+
const NODE_EDIT = {
|
|
58
|
+
nodes: [{ id: "ui-edit", type: "agent-task", config: { template: "Edited." } }],
|
|
59
|
+
onNodeFailure: "fail",
|
|
60
|
+
} as const;
|
|
61
|
+
|
|
62
|
+
/** Operator settings, made the way the update-workflow tool makes them. */
|
|
63
|
+
async function tuneSettings(id: string): Promise<void> {
|
|
64
|
+
await snapshotAndUpdateWorkflow(id, {
|
|
65
|
+
input: { channel: "C123" },
|
|
66
|
+
enabled: true,
|
|
67
|
+
description: "Tuned by the operator.",
|
|
68
|
+
cooldown: { hours: 22, from: "start" },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const TUNED = {
|
|
73
|
+
input: { channel: "C123" },
|
|
74
|
+
enabled: true,
|
|
75
|
+
description: "Tuned by the operator.",
|
|
76
|
+
cooldown: { hours: 22, from: "start" },
|
|
77
|
+
};
|
|
78
|
+
|
|
38
79
|
/** A zero-config candidate: no requires, no placeholders — eligible for auto-enable. */
|
|
39
80
|
function zeroConfigWorkflowSource(opts?: {
|
|
40
81
|
name?: string;
|
|
@@ -175,21 +216,135 @@ describe("workflows seeder", () => {
|
|
|
175
216
|
expect(second).toMatchObject({ skippedUnchanged: 1, updated: 0, failed: [] });
|
|
176
217
|
});
|
|
177
218
|
|
|
178
|
-
test("
|
|
219
|
+
test("an input-only edit still gets the template update and keeps the live input", async () => {
|
|
220
|
+
await runSeeder(createWorkflowsSeeder([workflowSource()]), { quiet: true });
|
|
221
|
+
const seeded = await getWorkflow();
|
|
222
|
+
await snapshotAndUpdateWorkflow(seeded!.id, { input: { channel: "C123" } });
|
|
223
|
+
|
|
224
|
+
const update = createWorkflowsSeeder([workflowSource("Source update.")]);
|
|
225
|
+
const result = await runSeeder(update, { quiet: true });
|
|
226
|
+
expect(result).toMatchObject({ updated: 1, skippedUserModified: 0, failed: [] });
|
|
227
|
+
const live = await getWorkflow();
|
|
228
|
+
expect(live?.definition.nodes[0]?.config.template).toBe("Source update.");
|
|
229
|
+
expect(live?.input).toEqual({ channel: "C123" });
|
|
230
|
+
expect((await getSeedState("workflow", live!.name))?.seededHash).toBe(
|
|
231
|
+
update.items()[0]!.contentHash,
|
|
232
|
+
);
|
|
233
|
+
expect(await seededWorkflowState(live!)).toBe("pristine");
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test("a template update keeps every operator setting", async () => {
|
|
237
|
+
await runSeeder(createWorkflowsSeeder([workflowSource()]), { quiet: true });
|
|
238
|
+
await tuneSettings((await getWorkflow())!.id);
|
|
239
|
+
|
|
240
|
+
const result = await runSeeder(
|
|
241
|
+
createWorkflowsSeeder([workflowSource("Source update.", "New template description.")]),
|
|
242
|
+
{ quiet: true },
|
|
243
|
+
);
|
|
244
|
+
expect(result).toMatchObject({ updated: 1, failed: [] });
|
|
245
|
+
const live = await getWorkflow();
|
|
246
|
+
expect(live).toMatchObject(TUNED);
|
|
247
|
+
expect(live?.definition.nodes[0]?.config.template).toBe("Source update.");
|
|
248
|
+
expect(await seededWorkflowState(live!)).toBe("pristine");
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
test("a template update adds new input keys without touching live values", async () => {
|
|
252
|
+
await runSeeder(createWorkflowsSeeder([workflowSource()]), { quiet: true });
|
|
253
|
+
await snapshotAndUpdateWorkflow((await getWorkflow())!.id, { input: { channel: "C123" } });
|
|
254
|
+
|
|
255
|
+
await runSeeder(
|
|
256
|
+
createWorkflowsSeeder([
|
|
257
|
+
workflowSource("Source update.", undefined, { channel: "", newKey: "default" }),
|
|
258
|
+
]),
|
|
259
|
+
{ quiet: true },
|
|
260
|
+
);
|
|
261
|
+
expect((await getWorkflow())?.input).toEqual({ channel: "C123", newKey: "default" });
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test("preserves a node edit made together with operator settings", async () => {
|
|
179
265
|
await runSeeder(createWorkflowsSeeder([workflowSource()]), { quiet: true });
|
|
180
266
|
const seeded = await getWorkflow();
|
|
181
|
-
await
|
|
267
|
+
await tuneSettings(seeded!.id);
|
|
268
|
+
await snapshotAndUpdateWorkflow(seeded!.id, { definition: NODE_EDIT });
|
|
182
269
|
|
|
183
270
|
const result = await runSeeder(createWorkflowsSeeder([workflowSource("Source update.")]), {
|
|
184
271
|
quiet: true,
|
|
185
272
|
});
|
|
186
|
-
expect(result
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
273
|
+
expect(result).toMatchObject({ updated: 0, skippedUserModified: 1, failed: [] });
|
|
274
|
+
const live = await getWorkflow();
|
|
275
|
+
expect(live?.definition.nodes[0]?.id).toBe("ui-edit");
|
|
276
|
+
expect(await seededWorkflowState(live!)).toBe("edited");
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
describe("legacy whole-workflow seed state", () => {
|
|
280
|
+
test("an input-only edit with a seeded snapshot gets the update and the state migrates", async () => {
|
|
281
|
+
await runSeeder(createWorkflowsSeeder([workflowSource()]), { quiet: true });
|
|
282
|
+
await recordLegacySeedState(workflowSource());
|
|
283
|
+
await tuneSettings((await getWorkflow())!.id);
|
|
284
|
+
// Before the update the workflow still reads pristine (the scheduler's view).
|
|
285
|
+
expect(await seededWorkflowState((await getWorkflow())!)).toBe("pristine");
|
|
286
|
+
|
|
287
|
+
const update = createWorkflowsSeeder([workflowSource("Source update.")]);
|
|
288
|
+
const result = await runSeeder(update, { quiet: true });
|
|
289
|
+
expect(result).toMatchObject({ updated: 1, skippedUserModified: 0, failed: [] });
|
|
290
|
+
const live = await getWorkflow();
|
|
291
|
+
expect(live).toMatchObject(TUNED);
|
|
292
|
+
expect(live?.definition.nodes[0]?.config.template).toBe("Source update.");
|
|
293
|
+
expect((await getSeedState("workflow", live!.name))?.seededHash).toBe(
|
|
294
|
+
update.items()[0]!.contentHash,
|
|
295
|
+
);
|
|
296
|
+
expect(await seededWorkflowState(live!)).toBe("pristine");
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
test("an untouched workflow gets the update", async () => {
|
|
300
|
+
await runSeeder(createWorkflowsSeeder([workflowSource()]), { quiet: true });
|
|
301
|
+
await recordLegacySeedState(workflowSource());
|
|
302
|
+
|
|
303
|
+
const result = await runSeeder(createWorkflowsSeeder([workflowSource("Source update.")]), {
|
|
304
|
+
quiet: true,
|
|
305
|
+
});
|
|
306
|
+
expect(result).toMatchObject({ updated: 1, failed: [] });
|
|
307
|
+
expect((await getWorkflow())?.definition.nodes[0]?.config.template).toBe("Source update.");
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
test("a node edit is preserved", async () => {
|
|
311
|
+
await runSeeder(createWorkflowsSeeder([workflowSource()]), { quiet: true });
|
|
312
|
+
await recordLegacySeedState(workflowSource());
|
|
313
|
+
const seeded = await getWorkflow();
|
|
314
|
+
await snapshotAndUpdateWorkflow(seeded!.id, {
|
|
315
|
+
input: { channel: "C123" },
|
|
316
|
+
definition: NODE_EDIT,
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
const result = await runSeeder(createWorkflowsSeeder([workflowSource("Source update.")]), {
|
|
320
|
+
quiet: true,
|
|
321
|
+
});
|
|
322
|
+
expect(result).toMatchObject({ updated: 0, skippedUserModified: 1, failed: [] });
|
|
323
|
+
expect((await getWorkflow())?.definition.nodes[0]?.id).toBe("ui-edit");
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
test("a settings edit with no seeded snapshot is preserved", async () => {
|
|
327
|
+
await runSeeder(createWorkflowsSeeder([workflowSource()]), { quiet: true });
|
|
328
|
+
await recordLegacySeedState(workflowSource());
|
|
329
|
+
await updateWorkflow((await getWorkflow())!.id, { input: { channel: "C123" } });
|
|
330
|
+
|
|
331
|
+
const result = await runSeeder(createWorkflowsSeeder([workflowSource("Source update.")]), {
|
|
332
|
+
quiet: true,
|
|
333
|
+
});
|
|
334
|
+
expect(result).toMatchObject({ updated: 0, skippedUserModified: 1, failed: [] });
|
|
335
|
+
expect(await seededWorkflowState((await getWorkflow())!)).toBe("edited");
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
test("a workflow already matching the template re-baselines to the new hash", async () => {
|
|
339
|
+
const seeder = createWorkflowsSeeder([workflowSource()]);
|
|
340
|
+
await runSeeder(seeder, { quiet: true });
|
|
341
|
+
await recordLegacySeedState(workflowSource());
|
|
342
|
+
|
|
343
|
+
const result = await runSeeder(seeder, { quiet: true });
|
|
344
|
+
expect(result).toMatchObject({ skippedUnchanged: 1, updated: 0, failed: [] });
|
|
345
|
+
expect((await getSeedState("workflow", "test-seeded-workflow"))?.seededHash).toBe(
|
|
346
|
+
seeder.items()[0]!.contentHash,
|
|
347
|
+
);
|
|
193
348
|
});
|
|
194
349
|
});
|
|
195
350
|
|
|
@@ -208,6 +363,7 @@ describe("workflows seeder", () => {
|
|
|
208
363
|
});
|
|
209
364
|
expect(result.skippedUserModified).toBe(1);
|
|
210
365
|
expect((await getWorkflow())?.definition.nodes[0]?.id).toBe("ui-edit");
|
|
366
|
+
expect(await seededWorkflowState((await getWorkflow())!)).toBe("edited");
|
|
211
367
|
});
|
|
212
368
|
|
|
213
369
|
test("updates a pristine workflow when its template changes", async () => {
|
|
@@ -5,6 +5,51 @@ import { parseSkillContent } from "../be/skill-parser";
|
|
|
5
5
|
// ─── Valid Parsing ──────────────────────────────────────────────────────────
|
|
6
6
|
|
|
7
7
|
describe("parseSkillContent — valid inputs", () => {
|
|
8
|
+
test.each([">", "|", ">-", "|-", ">+", "|+"])("parses ponytail block description %s", (style) => {
|
|
9
|
+
const lines = [
|
|
10
|
+
"Lazy senior dev mode: the smallest change that fully solves the task, and a",
|
|
11
|
+
"reply a busy human understands in one read. Use on any coding task (writing,",
|
|
12
|
+
"fixing, refactoring, reviewing, choosing dependencies) and when the user says",
|
|
13
|
+
'"ponytail", "be lazy", "simplest solution", "yagni", or complains about',
|
|
14
|
+
"over-engineering or bloat. Levels: lite, full (default), ultra.",
|
|
15
|
+
];
|
|
16
|
+
const content = `---
|
|
17
|
+
name: ponytail
|
|
18
|
+
description: ${style}
|
|
19
|
+
${lines.map((line) => ` ${line}`).join("\n")}
|
|
20
|
+
argument-hint: "[lite|full|ultra|off]"
|
|
21
|
+
license: MIT
|
|
22
|
+
---
|
|
23
|
+
# Ponytail`;
|
|
24
|
+
|
|
25
|
+
const result = parseSkillContent(content);
|
|
26
|
+
const separator = style.startsWith(">") ? " " : "\n";
|
|
27
|
+
expect(result.description).toBe(lines.join(separator) + (style.endsWith("-") ? "" : "\n"));
|
|
28
|
+
expect(result.name).toBe("ponytail");
|
|
29
|
+
expect(result.body).toBe("# Ponytail");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
for (const style of ["|", ">", "|-", ">-", "|+", ">+"]) {
|
|
33
|
+
test.each([0, 2])(`preserves following metadata with ${style} at indentation %i`, (indent) => {
|
|
34
|
+
const padding = " ".repeat(indent);
|
|
35
|
+
const result = parseSkillContent(
|
|
36
|
+
`---\n${padding}name: test\n${padding}description: ${style}\n${padding} Hello\n${padding} model: part of the description\n\n${padding}model: opus\n${padding}effort: high\n---\nBody`,
|
|
37
|
+
);
|
|
38
|
+
const ending = style.endsWith("-") ? "" : style.endsWith("+") ? "\n\n" : "\n";
|
|
39
|
+
expect(result.description).toBe(`Hello\n model: part of the description${ending}`);
|
|
40
|
+
expect(result.model).toBe("opus");
|
|
41
|
+
expect(result.effort).toBe("high");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test.each([false, true])(`honors ${style} trailing blank lines, last field: %s`, (last) => {
|
|
45
|
+
const result = parseSkillContent(
|
|
46
|
+
`---\nname: test\ndescription: ${style}\n Hello\n world\n\n\n${last ? "" : "model: opus\n"}---\nBody`,
|
|
47
|
+
);
|
|
48
|
+
const ending = style.endsWith("-") ? "" : style.endsWith("+") ? "\n\n\n" : "\n";
|
|
49
|
+
expect(result.description).toBe(`Hello${style.startsWith(">") ? " " : "\n"}world${ending}`);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
8
53
|
test("parses minimal frontmatter with body", () => {
|
|
9
54
|
const content = `---
|
|
10
55
|
name: my-skill
|
|
@@ -34,6 +34,7 @@ type MessageEventArg = {
|
|
|
34
34
|
user?: string;
|
|
35
35
|
subtype?: string;
|
|
36
36
|
thread_ts?: string;
|
|
37
|
+
user_team?: string;
|
|
37
38
|
files?: Array<{ id: string; name: string; mimetype: string; size: number }>;
|
|
38
39
|
};
|
|
39
40
|
|
|
@@ -54,6 +55,7 @@ const mockClient = {
|
|
|
54
55
|
let createTaskSpy: any;
|
|
55
56
|
let getAllAgentsSpy: any;
|
|
56
57
|
let fetchSlackFilesSpy: any;
|
|
58
|
+
let resolveUserSpy: any;
|
|
57
59
|
const spies: any[] = [];
|
|
58
60
|
let handler: (args: HandlerArgs) => Promise<void>;
|
|
59
61
|
let resetCaches: () => void;
|
|
@@ -102,6 +104,9 @@ beforeAll(async () => {
|
|
|
102
104
|
createTaskSpy = spyOn(siblingAwarenessModule, "createTaskWithSiblingAwareness");
|
|
103
105
|
getAllAgentsSpy = spyOn(dbModule, "getAllAgents");
|
|
104
106
|
fetchSlackFilesSpy = spyOn(inboundFilesModule, "fetchSlackFiles");
|
|
107
|
+
resolveUserSpy = spyOn(slackEnrichModule, "resolveSlackUserId").mockImplementation(
|
|
108
|
+
async () => undefined,
|
|
109
|
+
);
|
|
105
110
|
spies.push(
|
|
106
111
|
createTaskSpy,
|
|
107
112
|
getAllAgentsSpy,
|
|
@@ -113,7 +118,7 @@ beforeAll(async () => {
|
|
|
113
118
|
),
|
|
114
119
|
spyOn(dbModule, "getMostRecentTaskInThread").mockImplementation(async () => null),
|
|
115
120
|
spyOn(dbModule, "getTasksByAgentId").mockImplementation(async () => []),
|
|
116
|
-
|
|
121
|
+
resolveUserSpy,
|
|
117
122
|
spyOn(slackEnrichModule, "enrichSlackUserEmail").mockImplementation(async () => null),
|
|
118
123
|
spyOn(slackEventDedupModule, "wasEventSeen").mockImplementation(() => false),
|
|
119
124
|
);
|
|
@@ -158,6 +163,20 @@ describe("registerMessageHandler — top-level 1:1 DM is addressed to the bot",
|
|
|
158
163
|
expect(options).toMatchObject({ agentId: LEAD.id, slackTriggerMessageTs: ts });
|
|
159
164
|
});
|
|
160
165
|
|
|
166
|
+
test("passes the sender's Slack team to the requester resolver", async () => {
|
|
167
|
+
// A Slack Connect sender: without userTeam the resolver cannot tell them
|
|
168
|
+
// from a member, and a company-domain email would create a member row.
|
|
169
|
+
await deliver({
|
|
170
|
+
channel: "D_DM_IMPLICIT",
|
|
171
|
+
channel_type: "im",
|
|
172
|
+
text: "hello from another workspace",
|
|
173
|
+
user_team: "T_OTHER_WORKSPACE",
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
expect(resolveUserSpy).toHaveBeenCalledTimes(1);
|
|
177
|
+
expect(resolveUserSpy.mock.calls[0][2]).toMatchObject({ userTeam: "T_OTHER_WORKSPACE" });
|
|
178
|
+
});
|
|
179
|
+
|
|
161
180
|
test("untagged top-level DM creates a Lead task when no agent is online", async () => {
|
|
162
181
|
getAllAgentsSpy.mockImplementation(async () => []);
|
|
163
182
|
const { outcome } = await deliver({
|
|
@@ -87,14 +87,20 @@ function cleanupDb() {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
// The cascade creates users only for company-domain emails.
|
|
91
|
+
const priorCompanyDomains = process.env.COMPANY_EMAIL_DOMAINS;
|
|
92
|
+
|
|
90
93
|
beforeAll(() => {
|
|
91
94
|
cleanupDb();
|
|
92
95
|
initDb(TEST_DB_PATH);
|
|
96
|
+
process.env.COMPANY_EMAIL_DOMAINS = "example.com";
|
|
93
97
|
});
|
|
94
98
|
|
|
95
99
|
afterAll(() => {
|
|
96
100
|
closeDb();
|
|
97
101
|
cleanupDb();
|
|
102
|
+
if (priorCompanyDomains === undefined) delete process.env.COMPANY_EMAIL_DOMAINS;
|
|
103
|
+
else process.env.COMPANY_EMAIL_DOMAINS = priorCompanyDomains;
|
|
98
104
|
});
|
|
99
105
|
|
|
100
106
|
beforeEach(async () => {
|
|
@@ -286,6 +292,23 @@ describe("resolveSlackUserId — three-step cascade", () => {
|
|
|
286
292
|
expect(await identityEventTypes("existing-id")).toEqual(["auto_merge", "identity_added"]);
|
|
287
293
|
});
|
|
288
294
|
|
|
295
|
+
test("with no company domains configured, an email creates no user", async () => {
|
|
296
|
+
process.env.COMPANY_EMAIL_DOMAINS = "";
|
|
297
|
+
try {
|
|
298
|
+
const { client } = makeMockClient({
|
|
299
|
+
U_NODOMAIN: { user: { profile: { email: "someone@example.com", real_name: "Someone" } } },
|
|
300
|
+
});
|
|
301
|
+
const userId = await resolveSlackUserId(client, "U_NODOMAIN", {
|
|
302
|
+
sampleEventType: "message",
|
|
303
|
+
sampleContext: "hi",
|
|
304
|
+
});
|
|
305
|
+
expect(userId).toBeUndefined();
|
|
306
|
+
expect(await countUsers()).toBe(0);
|
|
307
|
+
} finally {
|
|
308
|
+
process.env.COMPANY_EMAIL_DOMAINS = "example.com";
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
289
312
|
test("concurrent alias enrollment returns the external-ID winner", async () => {
|
|
290
313
|
const { client } = makeMockClient({
|
|
291
314
|
U_RACE: { user: { profile: { email: "racer@example.com", real_name: "Racer" } } },
|
|
@@ -1034,8 +1034,9 @@ describe("Slack ingress with files", () => {
|
|
|
1034
1034
|
],
|
|
1035
1035
|
);
|
|
1036
1036
|
const task = await followUp();
|
|
1037
|
+
// Rows after the first are indented as continuation lines of the author line.
|
|
1037
1038
|
expect(task.task).toContain(
|
|
1038
|
-
"| Acme | /casos-de-exito/acme |\n| --- | --- |\n| Globex | /casos-de-exito/globex |",
|
|
1039
|
+
"| Acme | /casos-de-exito/acme |\n | --- | --- |\n | Globex | /casos-de-exito/globex |",
|
|
1039
1040
|
);
|
|
1040
1041
|
expect(task.task).not.toContain("!now");
|
|
1041
1042
|
});
|