@desplega.ai/agent-swarm 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-bht22g3k.js +16 -0
- package/dist/{acp-targets-swxq55dr.js → acp-targets-arrwv4f0.js} +7 -7
- package/dist/{actions-pb678g3e.js → actions-y0d2n1c2.js} +102 -21
- package/dist/{agent-fs-provision-dmhnc38q.js → agent-fs-provision-tpj7sktd.js} +4 -4
- package/dist/{amp-adapter-3pa66q27.js → amp-adapter-vmmnmw8d.js} +2 -2
- package/dist/{anthropic-messages-x2cp5fvf.js → anthropic-messages-zdca3gv1.js} +22 -22
- package/dist/{app-17d12ev4.js → app-wb7w45dq.js} +6 -3
- package/dist/{approval-notifications-h7vd9pmg.js → approval-notifications-7mqr6vbd.js} +8 -5
- package/dist/{assistant-t7k39ree.js → assistant-gf60454p.js} +23 -21
- package/dist/{boot-args-schema-0gqmkfbe.js → boot-args-schema-qxmd59sr.js} +1 -1
- package/dist/{boot-reembed-f064w382.js → boot-reembed-5tmeskj2.js} +1 -1
- package/dist/{boot-reembed-n6anc01d.js → boot-reembed-wb44vc3s.js} +1 -1
- package/dist/boot-scrub-sweep-25bxhnw4.js +9 -0
- package/dist/{boot-seeds-f99fjs5q.js → boot-seeds-nj9za0vk.js} +4 -4
- package/dist/{claude-adapter-gvznwxgc.js → claude-adapter-d3krpdyb.js} +7 -7
- package/dist/{claude-managed-adapter-pbrbvc64.js → claude-managed-adapter-t8nfgcgz.js} +2 -2
- package/dist/{claude-managed-setup-kdxttvc3.js → claude-managed-setup-7y4pwd81.js} +3 -3
- package/dist/{claude-sdk-session-0t2teq6n.js → claude-sdk-session-d138zy0e.js} +7 -7
- package/dist/{cli-6dp0jkfj.js → cli-01k6wpr9.js} +4 -4
- package/dist/{cli-c07v0qfa.js → cli-124ntmf0.js} +83 -74
- package/dist/{cli-1tvdx9t5.js → cli-2rnd5j3t.js} +1 -1
- package/dist/{cli-4ghh072d.js → cli-2spnz7ye.js} +36 -36
- package/dist/{cli-dd37e0cm.js → cli-2v2zdm0a.js} +1 -1
- package/dist/{cli-aa8s22gn.js → cli-3aaeb78m.js} +195 -186
- package/dist/{cli-8x8y70av.js → cli-3caf7pmg.js} +2 -2
- package/dist/{cli-jd3kxppb.js → cli-3et6fmfe.js} +1 -1
- package/dist/{cli-kaa4bd7x.js → cli-3f8zbtqa.js} +9 -8
- package/dist/{cli-57pvhnyt.js → cli-43evxwj4.js} +1 -1
- package/dist/cli-43ms35q9.js +270 -0
- package/dist/cli-47hz21se.js +25584 -0
- package/dist/{cli-n515ex5z.js → cli-4ymxrwg5.js} +16 -16
- package/dist/{cli-2tnbc3gw.js → cli-539h29es.js} +2379 -66
- package/dist/{cli-rts1qvb4.js → cli-5qhfv9rw.js} +2 -2
- package/dist/{cli-faf46gdq.js → cli-6037prsx.js} +10 -10
- package/dist/{cli-bk9v1xrv.js → cli-6cwr32fe.js} +25 -25
- package/dist/{cli-812paz57.js → cli-6ehs4mta.js} +18 -2
- package/dist/{cli-95930z69.js → cli-6ym4jhzp.js} +2 -2
- package/dist/{cli-zg3z63x3.js → cli-7mv4h3sn.js} +1 -1
- package/dist/{cli-9a2rtd77.js → cli-7r162fxe.js} +24 -15
- package/dist/{cli-eg437b5p.js → cli-7sf9sb0w.js} +2 -1
- package/dist/{cli-vw5x18yj.js → cli-8st34zhr.js} +20 -10
- package/dist/{cli-fgphc007.js → cli-91pkxres.js} +1 -1
- package/dist/{cli-2kg31ted.js → cli-9fjr27ez.js} +11 -11
- package/dist/{cli-wr1h0k28.js → cli-9w8712tq.js} +617 -278
- package/dist/cli-aw83sr40.js +98 -0
- package/dist/{cli-ssvdrk4y.js → cli-b6px1k1q.js} +1 -1
- package/dist/{cli-w7dxb2fj.js → cli-cc93xzes.js} +6 -6
- package/dist/{cli-js8zrfyg.js → cli-fcfbct2j.js} +5 -5
- package/dist/{cli-3zxdz9r7.js → cli-fq2rr3jb.js} +6 -6
- package/dist/{boot-scrub-sweep-ejd5dnrz.js → cli-had1p04a.js} +8 -9
- package/dist/{cli-7cgf614g.js → cli-j6te8keb.js} +5 -5
- package/dist/{cli-25nstr34.js → cli-jrbq4djp.js} +1 -1
- package/dist/{cli-pz1c00aa.js → cli-k3q2va86.js} +2 -2
- package/dist/{cli-nhq5js1b.js → cli-k5yewqgd.js} +3 -3
- package/dist/cli-kbtzfrxj.js +404 -0
- package/dist/{cli-dx439zpg.js → cli-kpgcm7xy.js} +13 -1
- package/dist/{cli-mc1fx4xd.js → cli-m9cvf7vs.js} +10 -10
- package/dist/{cli-kmvcm34h.js → cli-md50mj0r.js} +2 -2
- package/dist/{cli-q8cfh1t9.js → cli-mk7c5ac4.js} +1 -1
- package/dist/cli-mys27d03.js +321 -0
- package/dist/{cli-spzkdgtg.js → cli-n3qe7tyr.js} +172 -168
- package/dist/{cli-7akn6ze9.js → cli-nh7x3133.js} +7 -28
- package/dist/{cli-fnh4b12r.js → cli-nstkanmx.js} +6 -6
- package/dist/{cli-g3zzby8t.js → cli-nv4xsvmk.js} +5 -5
- package/dist/{cli-sn4pc4qx.js → cli-p0c3vtch.js} +2 -2
- package/dist/{cli-5ntc4we6.js → cli-p0n7b5rz.js} +859 -2058
- package/dist/{cli-pn1v1pb0.js → cli-psffsanb.js} +3 -2
- package/dist/{cli-svc803vq.js → cli-q5srsxq2.js} +15 -15
- package/dist/{cli-nmcpzbty.js → cli-qrta34nb.js} +4 -4
- package/dist/{cli-k09cxm6m.js → cli-qx4f057j.js} +2 -2
- package/dist/{cli-eepnpee7.js → cli-s1khw52h.js} +12 -12
- package/dist/{cli-h474mvp5.js → cli-s1zqk1aj.js} +21 -11
- package/dist/{cli-8axx8vnw.js → cli-sb4426be.js} +10 -10
- package/dist/{cli-kqh27v2y.js → cli-th1dkc2v.js} +1 -1
- package/dist/{cli-cw7mc1je.js → cli-tr27kwyg.js} +3 -3
- package/dist/{cli-5kcmxwxv.js → cli-tvgqesec.js} +7 -5
- package/dist/{cli-a9hfzg2r.js → cli-ty3gha1p.js} +6 -6
- package/dist/{cli-fjggej24.js → cli-v46zsvqk.js} +1 -1
- package/dist/{cli-5gygrr67.js → cli-v8z0yga9.js} +4 -4
- package/dist/{cli-k7pt28ad.js → cli-vfqvrd82.js} +5 -5
- package/dist/{cli-vvgaz8t6.js → cli-vq2eg24x.js} +2 -2
- package/dist/{cli-pwsax0vp.js → cli-vsw91x06.js} +23 -22
- package/dist/{cli-7fx9jyfs.js → cli-w1q68d8x.js} +67 -11
- package/dist/{cli-c5cspahx.js → cli-wafmk3fn.js} +45 -20
- package/dist/{cli-ymct0ycy.js → cli-wwp1bd3n.js} +5495 -5095
- package/dist/{cli-me4maa4j.js → cli-y4ccxtz5.js} +45 -9
- package/dist/{cli-m1fbz2wj.js → cli-y8p78ekx.js} +178 -19
- package/dist/{cli-nr46j5pw.js → cli-z0m452jr.js} +1 -1
- package/dist/{cli-gddgcnav.js → cli-zeh2mhkg.js} +1 -1
- package/dist/{cli-e9973bf0.js → cli-zk7v5s89.js} +2 -2
- package/dist/cli.js +24 -23
- package/dist/{cloudflare-workers-ai-system-one-9y1zx3pt.js → cloudflare-workers-ai-system-one-4aysy6rh.js} +2 -2
- package/dist/{codex-adapter-44yq2fkn.js → codex-adapter-exfdbj73.js} +6 -6
- package/dist/{codex-hook-h1zb7cfk.js → codex-hook-59atdwd8.js} +1 -1
- package/dist/{codex-login-cdyrr5y1.js → codex-login-a239g1ah.js} +1 -1
- package/dist/{codex-session-runner-zbh26gbw.js → codex-session-runner-xhznc4g3.js} +6 -6
- package/dist/{commands-54f02v5b.js → commands-d8g349v4.js} +3 -3
- package/dist/{controller-9gpwcdek.js → controller-mwgdmb8y.js} +6 -3
- package/dist/{controllers-connect-61re6k1n.js → controllers-connect-5v7qx04j.js} +22 -20
- package/dist/core-sxy4epp2.js +38 -0
- package/dist/{cursor-adapter-7e4g81vd.js → cursor-adapter-p2q5h35d.js} +1 -1
- package/dist/{db-wnh0qjy1.js → db-qpganbeb.js} +3 -3
- package/dist/{db-dg2gc7fd.js → db-wcw0b2j8.js} +8 -2
- package/dist/{dispatcher-jrm24r43.js → dispatcher-8d8s49yz.js} +20 -18
- package/dist/{docker-9aq30pp2.js → docker-09tkkg0n.js} +42 -3
- package/dist/{dsh-adapter-1yqk267c.js → dsh-adapter-me0twn13.js} +1 -1
- package/dist/{easter-egg-3d-r4h9cs9m.js → easter-egg-3d-wv7w5ty6.js} +1 -1
- package/dist/{embedding-space-bafjr5f7.js → embedding-space-e48xchqa.js} +6 -6
- package/dist/{embeddings-7xmgqe0e.js → embeddings-tgq2afbq.js} +1 -1
- package/dist/{execute-d6jg5ns0.js → execute-8rhwrk7f.js} +1 -1
- package/dist/{external-channel-frq1xvq2.js → external-channel-8bt3j2pm.js} +2 -2
- package/dist/fx-adapter-adtdb3jb.js +19 -0
- package/dist/{google-generative-ai-hh7strj3.js → google-generative-ai-bh0djqjp.js} +5 -5
- package/dist/{google-vertex-fy5bw2pm.js → google-vertex-prjbw8dj.js} +9 -9
- package/dist/grok-adapter-accnn9km.js +19 -0
- package/dist/handlers-1x77561e.js +35 -0
- package/dist/{heartbeat-6bpa611t.js → heartbeat-x0056ra5.js} +23 -21
- package/dist/{hook-hvm5nf46.js → hook-a7vmn2st.js} +5 -5
- package/dist/{hook-w12k146y.js → hook-mrd2ayxv.js} +6 -6
- package/dist/{http-43tthdvs.js → http-ym9c5svp.js} +1335 -363
- package/dist/{index-fn054vsf.js → index-01ns1pkw.js} +1 -1
- package/dist/{index-1f0vypbg.js → index-0h6qd4p1.js} +34 -24
- package/dist/index-48qzcqzj.js +35 -0
- package/dist/{index-4b1q8kan.js → index-4k7m5dgj.js} +629 -354
- package/dist/index-620y7jzq.js +15 -0
- package/dist/{index-cret47a5.js → index-8p0j4h4j.js} +506 -43
- package/dist/{index-m5gx1xd6.js → index-9myfj74s.js} +40 -40
- package/dist/{index-bs7gw5fd.js → index-b5wgnm78.js} +44 -44
- package/dist/{index-ftywhyr0.js → index-ny60jcat.js} +394 -66
- package/dist/{index-tx9mc2ap.js → index-p46tvwtx.js} +24 -22
- package/dist/{index-585gyczt.js → index-pe3d8jfy.js} +3 -3
- package/dist/index-rkvaambe.js +36 -0
- package/dist/{index-mhq4sh5w.js → index-x6azjwm8.js} +1 -1
- package/dist/index-xj1mq27m.js +40 -0
- package/dist/k8s-m56sw868.js +217 -0
- package/dist/{keepalive-rk0j0jvh.js → keepalive-7yxg8z4c.js} +3 -3
- package/dist/lead-enzn86bz.js +74 -0
- package/dist/{maintenance-g6z6kaxw.js → maintenance-6tefxmk1.js} +1 -1
- package/dist/{node-jftbyawr.js → node-2wfcey7d.js} +1 -1
- package/dist/{oauth-refresh-sweep-2k3g2q4w.js → oauth-refresh-sweep-70cavc3a.js} +2 -2
- package/dist/{onboard-6fdbvh3v.js → onboard-fja65z08.js} +5 -5
- package/dist/{openai-decisions-q3hh60wr.js → openai-decisions-ytp6w6xh.js} +1 -1
- package/dist/{opencode-adapter-fdbsvts7.js → opencode-adapter-hakkm7yh.js} +6 -6
- package/dist/{otel-impl-rvwtc09q.js → otel-impl-7zhnt6gj.js} +1 -1
- package/dist/{pending-sqkrb836.js → pending-h01yzpx4.js} +21 -19
- package/dist/{pi-mono-adapter-asqayqcg.js → pi-mono-adapter-f52hz743.js} +40 -13
- package/dist/{pricing-refresh-f5tkgmw2.js → pricing-refresh-fzxvk2zf.js} +2 -2
- package/dist/{rbac-roles-06s555fa.js → rbac-roles-9v6vhgbs.js} +3 -3
- package/dist/{rbac-roles-szxsg8t1.js → rbac-roles-hfgh8sba.js} +2 -2
- package/dist/{render-v2-103p266q.js → render-v2-1rgspxzf.js} +6 -3
- package/dist/{resume-v7kjewt9.js → resume-tqy61x24.js} +10 -7
- package/dist/{runtime-f1gmk0b7.js → runtime-exkxyx5f.js} +1 -1
- package/dist/{session-access-6shev8ts.js → session-access-3act7vt4.js} +4 -4
- package/dist/{session-source-backfill-bd7spzjd.js → session-source-backfill-82qe7fqq.js} +3 -3
- package/dist/{setup-kmxmztdb.js → setup-ry1vfdef.js} +1 -1
- package/dist/thread-buffer-3x93yexa.js +38 -0
- package/dist/{typesafe-system-one-f2en2knd.js → typesafe-system-one-vcfj2ak8.js} +2 -2
- package/dist/user-merge-jobs-bx6bf7db.js +22 -0
- package/dist/{virtual-modules-57eje5wy.js → virtual-modules-s0rjzcqq.js} +3 -3
- package/dist/{work-objects-zr47ygmf.js → work-objects-z2e5tv03.js} +29 -23
- package/dist/{worker-follow-up-grrr3fda.js → worker-follow-up-y3xeg89w.js} +20 -18
- package/dist/worker-zfcv2wbf.js +74 -0
- package/openapi.json +2763 -147
- package/package.json +9 -8
- package/src/apps/catalog.generated.json +43 -3
- package/src/apps/page-validator.ts +27 -0
- package/src/be/boot-seeds.ts +7 -1
- package/src/be/db/model-groups.ts +238 -0
- package/src/be/db/model-profiles.ts +28 -7
- package/src/be/db/session-costs.ts +225 -0
- package/src/be/db/session-log-reasoning.ts +36 -0
- package/src/be/db/tasks/read.ts +8 -3
- package/src/be/db/tasks/write.ts +34 -1
- package/src/be/db/user-references.ts +75 -0
- package/src/be/db/users/references.ts +185 -0
- package/src/be/db-client.ts +70 -19
- package/src/be/db.ts +232 -361
- package/src/be/key-window-usage.ts +386 -0
- package/src/be/memory/demotion-evidence.ts +34 -0
- package/src/be/memory/reranker.ts +34 -12
- package/src/be/memory/review-recall-filter.ts +83 -0
- package/src/be/memory/search-candidates.ts +19 -6
- package/src/be/memory/types.ts +11 -0
- package/src/be/migrations/303_task_ui_specs.sql +28 -0
- package/src/be/migrations/306_provider_account_telemetry.sql +1 -0
- package/src/be/migrations/307_session_cost_credential_attribution.sql +23 -0
- package/src/be/migrations/310_session_logs_reasoning.sql +12 -0
- package/src/be/migrations/312_task_ui_action_runs_repeatable.sql +6 -0
- package/src/be/migrations/314_model_groups.sql +85 -0
- package/src/be/migrations/318_superseded_workflow_cut_backfill.sql +22 -0
- package/src/be/migrations/319_user_fk_indexes.sql +153 -0
- package/src/be/migrations/320_session_costs_kind.sql +4 -0
- package/src/be/migrations/321_user_merge_jobs.sql +52 -0
- package/src/be/pricing-normalize.ts +2 -0
- package/src/be/rbac-roles.ts +6 -4
- package/src/be/runtime-pools/db.ts +23 -5
- package/src/be/runtime-pools/supervisor.ts +15 -1
- package/src/be/scripts/db.ts +11 -0
- package/src/be/scripts/typecheck.ts +2 -0
- package/src/be/seed-model-groups.ts +86 -0
- package/src/be/seed-model-profiles.ts +20 -13
- package/src/be/seed-scripts/catalog/boot-triage.inline.ts +1 -0
- package/src/be/seed-scripts/catalog/boot-triage.ts +1 -0
- package/src/be/seed-scripts/catalog/dreaming-gather.ts +165 -1
- package/src/be/seed-scripts/catalog/wait-for-task.ts +5 -1
- package/src/be/seed-skills/index.ts +3 -0
- package/src/be/swarm-config-guard.ts +58 -1
- package/src/be/task-ui-spec.ts +259 -0
- package/src/be/user-merge-jobs.ts +564 -0
- package/src/be/users.ts +41 -23
- package/src/commands/controller.ts +3 -0
- package/src/commands/credential-outcome-report.ts +13 -3
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/onboard/compose-generator.ts +1 -1
- package/src/commands/onboard/env-generator.ts +1 -1
- package/src/commands/provider-credentials.ts +1 -1
- package/src/commands/rate-limit-outcome.ts +6 -0
- package/src/commands/runner.ts +34 -53
- package/src/extensions/catalog.generated.json +3 -3
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/contract.ts +15 -0
- package/src/extensions/dispatcher.ts +14 -4
- package/src/github/handlers.ts +57 -0
- package/src/github/types.ts +4 -0
- package/src/http/all-routes.ts +2 -0
- package/src/http/api-keys.ts +258 -30
- package/src/http/approval-requests.ts +5 -1
- package/src/http/auth.ts +3 -1
- package/src/http/config.ts +34 -1
- package/src/http/index.ts +13 -0
- package/src/http/memory.ts +19 -6
- package/src/http/model-groups.ts +277 -0
- package/src/http/model-profiles.ts +30 -13
- package/src/http/session-data.ts +74 -23
- package/src/http/sessions.ts +6 -2
- package/src/http/tasks.ts +140 -5
- package/src/http/tool-hooks.ts +140 -0
- package/src/http/users.ts +142 -19
- package/src/http/workflows.ts +19 -1
- package/src/integrations/chat-sdk/inbound.ts +8 -2
- package/src/integrations/chat-sdk/limits.ts +8 -3
- package/src/integrations/chat-sdk/relay.ts +87 -0
- package/src/jira/outbound.ts +5 -3
- package/src/linear/outbound.ts +5 -1
- package/src/prompts/base-prompt.ts +8 -0
- package/src/prompts/session-templates.ts +19 -2
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +27 -4
- package/src/providers/claude-flag-settings.ts +39 -1
- package/src/providers/codex-adapter.ts +85 -3
- package/src/providers/codex-app-server.ts +9 -5
- package/src/providers/codex-oauth/auth-json.ts +1 -0
- package/src/providers/pi-mono-adapter.ts +35 -2
- package/src/providers/pricing-sources.md +41 -0
- package/src/providers/types.ts +11 -0
- package/src/rbac/legacy-policy.ts +1 -0
- package/src/rbac/permissions.ts +5 -0
- package/src/runtime-providers/docker.ts +65 -1
- package/src/runtime-providers/index.ts +7 -5
- package/src/runtime-providers/k8s.ts +250 -0
- package/src/scheduler/deferred-task-waits.ts +18 -5
- package/src/scripts-runtime/types/stdlib.d.ts +2 -0
- package/src/scripts-runtime/types/swarm-extension.d.ts +24 -9
- package/src/scripts-runtime/types/swarm-sdk.d.ts +2 -0
- package/src/slack/actions.ts +79 -0
- package/src/slack/app.ts +22 -15
- package/src/slack/blocks.ts +23 -2
- package/src/slack/inbound-files.ts +2 -0
- package/src/slack/render-v2.ts +154 -23
- package/src/slack/responses.ts +3 -2
- package/src/slack/work-objects.ts +4 -1
- package/src/tasks/errors.ts +5 -0
- package/src/tests/acp-adapter.test.ts +30 -6
- package/src/tests/api-key-tracking.test.ts +0 -72
- package/src/tests/api-keys-status-model-limits.test.ts +93 -1
- package/src/tests/api-keys-validation.test.ts +42 -0
- package/src/tests/approval-card-resolution.test.ts +7 -1
- package/src/tests/approval-requests-notifications.test.ts +11 -1
- package/src/tests/apps-catalog-page-frame.test.ts +49 -0
- package/src/tests/apps-session-thread.test.ts +79 -0
- package/src/tests/base-prompt.test.ts +111 -5
- package/src/tests/chat-sdk-relay.test.ts +170 -2
- package/src/tests/check-pr-body.test.ts +43 -0
- package/src/tests/claude-adapter-binary.test.ts +67 -6
- package/src/tests/claude-flag-settings.test.ts +29 -0
- package/src/tests/claude-sdk-lifecycle.test.ts +5 -0
- package/src/tests/codex-adapter.test.ts +340 -2
- package/src/tests/codex-app-server.test.ts +16 -0
- package/src/tests/codex-oauth.test.ts +3 -1
- package/src/tests/codex-rate-limits.test.ts +384 -0
- package/src/tests/credential-check.test.ts +14 -6
- package/src/tests/credential-outcome-report.test.ts +20 -0
- package/src/tests/db-client.test.ts +146 -0
- package/src/tests/db-task-read-contract.test.ts +3 -0
- package/src/tests/db-task-write-contract.test.ts +4 -0
- package/src/tests/deferred-task-wake.test.ts +63 -1
- package/src/tests/deploy-guard.test.ts +7 -7
- package/src/tests/deploy-select.test.ts +83 -0
- package/src/tests/docker-isolation-config-guard.test.ts +29 -0
- package/src/tests/docs-index-footprint.test.js +11 -3
- package/src/tests/dreaming-gather-corrections.test.ts +467 -0
- package/src/tests/e2e-visuals-comment.test.ts +82 -0
- package/src/tests/e2e-visuals-verify-pr.test.ts +138 -0
- package/src/tests/event-loop-lag.test.ts +9 -7
- package/src/tests/extensions-example-sql-admin-only.test.ts +7 -4
- package/src/tests/fixtures/extensions/native-tool-recorder/hooks.ts +26 -0
- package/src/tests/fixtures/extensions/native-tool-recorder/manifest.json +10 -0
- package/src/tests/fixtures/onboard/content.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/content.env.txt +1 -1
- package/src/tests/fixtures/onboard/dev.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/dev.env.txt +1 -1
- package/src/tests/fixtures/onboard/full-all.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/full-all.env.txt +1 -1
- package/src/tests/fixtures/onboard/full.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/full.env.txt +1 -1
- package/src/tests/fixtures/onboard/research.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/research.env.txt +1 -1
- package/src/tests/fixtures/onboard/solo.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/solo.env.txt +1 -1
- package/src/tests/fixtures/ui-spec-slack/deploys.json +121 -0
- package/src/tests/fixtures/ui-spec-slack/incident.json +183 -0
- package/src/tests/fixtures/ui-spec-slack/three-charts-stale.json +196 -0
- package/src/tests/fixtures/ui-spec-slack/video-rejected-by-slack.json +183 -0
- package/src/tests/fixtures/ui-spec-slack/video.json +446 -0
- package/src/tests/github-event-filter.test.ts +8 -0
- package/src/tests/github-handlers-inline-comments.test.ts +2 -0
- package/src/tests/github-handlers-reactions.test.ts +4 -0
- package/src/tests/github-handlers.test.ts +3 -0
- package/src/tests/github-sender-trust.test.ts +223 -0
- package/src/tests/gitleaks-download-retry.test.ts +85 -0
- package/src/tests/http-users.test.ts +142 -41
- package/src/tests/human-thread-routing.test.ts +187 -0
- package/src/tests/jira-outbound-sync.test.ts +33 -1
- package/src/tests/k8s-pool-smoke.test.ts +190 -0
- package/src/tests/key-window-usage.test.ts +846 -0
- package/src/tests/linear-outbound-sync.test.ts +30 -1
- package/src/tests/memory-rater-store.test.ts +35 -1
- package/src/tests/memory-reranker.test.ts +39 -4
- package/src/tests/memory-review-recall-filter.test.ts +205 -0
- package/src/tests/migration-318-superseded-workflow-cut-backfill.test.ts +74 -0
- package/src/tests/model-groups-api.test.ts +415 -0
- package/src/tests/model-profiles-api.test.ts +1 -0
- package/src/tests/operator-granted-credentials.test.ts +7 -2
- package/src/tests/operator-granted-role-wire.test.ts +2 -1
- package/src/tests/pi-mono-adapter.test.ts +79 -0
- package/src/tests/preload-env.test.ts +2 -0
- package/src/tests/preload.ts +3 -1
- package/src/tests/prompt-template-session.test.ts +4 -3
- package/src/tests/provider-quota-persistence.test.ts +362 -0
- package/src/tests/rate-limit-event.test.ts +22 -0
- package/src/tests/rbac-engine.test.ts +1 -0
- package/src/tests/reasoning-events.test.ts +164 -0
- package/src/tests/routing-affinity-inventory.test.ts +22 -0
- package/src/tests/runtime-k8s-pools.test.ts +142 -0
- package/src/tests/runtime-pools-db.test.ts +42 -2
- package/src/tests/runtime-pools-http.test.ts +47 -2
- package/src/tests/runtime-provider-registration.test.ts +5 -14
- package/src/tests/runtime-providers-docker.test.ts +91 -0
- package/src/tests/runtime-providers-k8s.test.ts +303 -0
- package/src/tests/script-connections.test.ts +18 -1
- package/src/tests/secret-canary-sweep.test.ts +41 -5
- package/src/tests/seed-scripts.test.ts +23 -0
- package/src/tests/session-cost-attribution.test.ts +748 -0
- package/src/tests/session-costs.test.ts +14 -15
- package/src/tests/session-logs.test.ts +83 -0
- package/src/tests/sessions-detail-batch.test.ts +7 -0
- package/src/tests/short-id.test.ts +23 -0
- package/src/tests/slack-blocks.test.ts +69 -0
- package/src/tests/slack-render-v2.test.ts +411 -0
- package/src/tests/slack-start-reload-race.test.ts +67 -0
- package/src/tests/spec-base-url.test.ts +13 -1
- package/src/tests/subscription-plans.test.ts +20 -1
- package/src/tests/system-one-decide-session-cost.test.ts +196 -0
- package/src/tests/task-ui-action-route.test.ts +249 -0
- package/src/tests/task-ui-actions.test.ts +195 -0
- package/src/tests/task-ui-script-actions.test.ts +517 -0
- package/src/tests/task-ui-spec-fallback.test.ts +65 -0
- package/src/tests/task-ui-spec.test.ts +368 -0
- package/src/tests/tool-hooks-http.test.ts +187 -0
- package/src/tests/ui-spec-script-actions-config.test.ts +196 -0
- package/src/tests/user-delete-perf.test.ts +321 -0
- package/src/tests/user-merge-jobs.test.ts +680 -0
- package/src/tests/vcs-provider.test.ts +25 -5
- package/src/tests/vendored-openapi.test.ts +13 -1
- package/src/tests/workflow-agent-task-retry.test.ts +96 -1
- package/src/tests/workflow-foreach-supersede-retry.test.ts +10 -0
- package/src/tests/workflow-http-v2.test.ts +27 -0
- package/src/tests/workflow-replay.test.ts +10 -1
- package/src/tests/workflow-triggers-v2.test.ts +128 -0
- package/src/tests/workflow-wait-event.test.ts +109 -1
- package/src/tools/defer-task.ts +1 -1
- package/src/tools/memory-search.ts +14 -3
- package/src/tools/store-progress.ts +69 -3
- package/src/tools/swarm-config/delete-config.ts +12 -1
- package/src/tools/swarm-config/set-config.ts +8 -0
- package/src/tools/system-one-decide.ts +113 -3
- package/src/tools/utils.ts +4 -1
- package/src/tools/workflows/create-workflow.ts +2 -0
- package/src/tools/workflows/update-workflow.ts +3 -1
- package/src/types.ts +93 -4
- package/src/ui-spec/actions.ts +112 -0
- package/src/ui-spec/fallback.ts +19 -0
- package/src/ui-spec/schema.ts +38 -0
- package/src/ui-spec/script-actions.ts +340 -0
- package/src/ui-spec/script-allowlist.ts +48 -0
- package/src/ui-spec/slack.ts +17 -0
- package/src/ui-spec/validate.ts +169 -0
- package/src/utils/codex-rate-limits.ts +159 -0
- package/src/utils/credentials.ts +2 -0
- package/src/utils/error-tracker.ts +19 -0
- package/src/utils/provider-account-telemetry.ts +331 -0
- package/src/utils/reasoning-events.ts +107 -0
- package/src/utils/short-id.ts +20 -14
- package/src/utils/subscription-plans.ts +11 -59
- package/src/utils/task-ui-spec.ts +79 -0
- package/src/vcs/index.ts +12 -2
- package/src/workflows/executors/system-one-decision.ts +2 -2
- package/src/workflows/resume.ts +3 -2
- package/src/workflows/task-step-routing.ts +38 -13
- package/src/workflows/triggers.ts +35 -3
- package/templates/extensions/manifest.schema.json +13 -0
- package/templates/extensions/sql-admin-only/README.md +2 -1
- package/templates/extensions/sql-admin-only/hooks.ts +7 -3
- package/templates/extensions/sql-admin-only/manifest.json +1 -1
- package/templates/skills/apps/SKILL.md +32 -5
- package/templates/skills/apps/content.md +32 -5
- package/templates/skills/swarm-docs/content.md +2 -0
- package/templates/skills/ui-spec/config.json +14 -0
- package/templates/skills/ui-spec/content.md +133 -0
- package/templates/workflows/dreaming/content.md +1 -1
- package/dist/acp-adapter-jqn86aam.js +0 -16
- package/dist/cli-7831nhaw.js +0 -93
- package/dist/cli-srtkr1h2.js +0 -12078
- package/dist/fx-adapter-0zrkfbkd.js +0 -19
- package/dist/grok-adapter-3db1c538.js +0 -19
- package/dist/handlers-k22n8mnn.js +0 -33
- package/dist/index-8xcyd3mc.js +0 -33
- package/dist/index-9sy2bh6n.js +0 -38
- package/dist/index-b24j7t2m.js +0 -12797
- package/dist/index-wjd56k1v.js +0 -34
- package/dist/lead-atxf3q6e.js +0 -72
- package/dist/thread-buffer-4yz236d0.js +0 -36
- package/dist/worker-p4hbtcy3.js +0 -72
- package/dist/{azure-openai-responses-590s1eea.js → azure-openai-responses-b3y7fz36.js} +8 -8
- package/dist/{cli-j49yqpvh.js → cli-7evph51z.js} +3 -3
- package/dist/{cli-g0vv9dg4.js → cli-8y43jx2r.js} +8 -8
- package/dist/{cli-m0cy2vyf.js → cli-k6nejceb.js} +4 -4
- package/dist/{mistral-conversations-0c30em7t.js → mistral-conversations-tm2vd4gc.js} +8 -8
- package/dist/{openai-codex-responses-bkcd8pjj.js → openai-codex-responses-sxjv60xx.js} +4 -4
- package/dist/{openai-completions-f3n69rep.js → openai-completions-0c7qnhsx.js} +20 -20
- package/dist/{openai-responses-gbh0wfqe.js → openai-responses-a7h29chp.js} +15 -15
- package/dist/{pi-messages-zebyt7gb.js → pi-messages-2j0fpqwq.js} +5 -5
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CredentialBindingSchema,
|
|
3
|
+
placeholderForConfigKey,
|
|
4
|
+
assertUrlSafe,
|
|
5
|
+
init_credential_broker,
|
|
6
|
+
withLoopPath,
|
|
7
|
+
bindLoopPath,
|
|
8
|
+
init_event_loop_lag,
|
|
9
|
+
isInTransaction,
|
|
10
|
+
init_db_client,
|
|
11
|
+
breaksJsonValidity,
|
|
12
|
+
init_scrub_json,
|
|
13
|
+
init_templates3,
|
|
14
|
+
resolveSqliteVecExtensionPath2,
|
|
15
|
+
initDb2,
|
|
16
|
+
getDb2,
|
|
17
|
+
getDbClient2,
|
|
18
|
+
init_runtime2,
|
|
19
|
+
insertSessionCost2,
|
|
2
20
|
chatSdkContextKey,
|
|
3
21
|
chatThreadOfContextKey,
|
|
4
22
|
agentmailContextKey,
|
|
@@ -19,6 +37,8 @@ import {
|
|
|
19
37
|
sessionSourceKey,
|
|
20
38
|
sourceOfKey,
|
|
21
39
|
init_source_key,
|
|
40
|
+
TaskCreationBlockedError,
|
|
41
|
+
init_errors2,
|
|
22
42
|
checkSlackRoutingCoherence,
|
|
23
43
|
init_slack_routing,
|
|
24
44
|
beginRequestAuthScope,
|
|
@@ -34,23 +54,6 @@ import {
|
|
|
34
54
|
track,
|
|
35
55
|
telemetry,
|
|
36
56
|
init_telemetry,
|
|
37
|
-
CredentialBindingSchema,
|
|
38
|
-
placeholderForConfigKey,
|
|
39
|
-
assertUrlSafe,
|
|
40
|
-
init_credential_broker,
|
|
41
|
-
withLoopPath,
|
|
42
|
-
bindLoopPath,
|
|
43
|
-
init_event_loop_lag,
|
|
44
|
-
isInTransaction,
|
|
45
|
-
init_db_client,
|
|
46
|
-
breaksJsonValidity,
|
|
47
|
-
init_scrub_json,
|
|
48
|
-
init_templates3,
|
|
49
|
-
resolveSqliteVecExtensionPath2,
|
|
50
|
-
initDb2,
|
|
51
|
-
getDb2,
|
|
52
|
-
getDbClient2,
|
|
53
|
-
init_runtime2,
|
|
54
57
|
isRbacEnabled,
|
|
55
58
|
decideAdmission,
|
|
56
59
|
grantLeadEquivalence,
|
|
@@ -64,6 +67,9 @@ import {
|
|
|
64
67
|
firstIssueText,
|
|
65
68
|
isAdapterEntryEnabled,
|
|
66
69
|
init_schema,
|
|
70
|
+
UI_SPEC_SCRIPT_ACTIONS_KEY,
|
|
71
|
+
parseScriptActionAllowlist,
|
|
72
|
+
init_script_allowlist,
|
|
67
73
|
API_DRAIN_MAX_MS_LIMIT,
|
|
68
74
|
init_api_drain2,
|
|
69
75
|
parseEnabledTools,
|
|
@@ -73,6 +79,8 @@ import {
|
|
|
73
79
|
init_follow_up_gate_schedule_ids,
|
|
74
80
|
isInternalConfigKey,
|
|
75
81
|
internalConfigKeyError,
|
|
82
|
+
isHumanOnlyConfigKey,
|
|
83
|
+
humanOnlyConfigKeyError,
|
|
76
84
|
isReservedConfigKey,
|
|
77
85
|
reservedKeyError,
|
|
78
86
|
validateConfigValue,
|
|
@@ -130,6 +138,9 @@ import {
|
|
|
130
138
|
computeScore,
|
|
131
139
|
rerank,
|
|
132
140
|
init_reranker,
|
|
141
|
+
isReviewTaskId,
|
|
142
|
+
dropReviewTaskCompletions,
|
|
143
|
+
init_review_recall_filter,
|
|
133
144
|
searchMemoryCandidates,
|
|
134
145
|
init_search_candidates,
|
|
135
146
|
rowToCandidate,
|
|
@@ -141,6 +152,7 @@ import {
|
|
|
141
152
|
init_embeddings,
|
|
142
153
|
upsertScriptByName,
|
|
143
154
|
getScript,
|
|
155
|
+
getGlobalScriptContentHashes,
|
|
144
156
|
getScriptById,
|
|
145
157
|
getScriptVersion,
|
|
146
158
|
deleteScript,
|
|
@@ -158,6 +170,8 @@ import {
|
|
|
158
170
|
init_oauth,
|
|
159
171
|
taskModelPin,
|
|
160
172
|
init_model_pin,
|
|
173
|
+
normalizeModelKey,
|
|
174
|
+
init_pricing_normalize,
|
|
161
175
|
upsertModelCatalogOverlay,
|
|
162
176
|
init_model_catalog_store,
|
|
163
177
|
explicitModelErrorForAgent,
|
|
@@ -204,6 +218,8 @@ import {
|
|
|
204
218
|
carryUnhandledSteering,
|
|
205
219
|
requestSteering,
|
|
206
220
|
init_steering2,
|
|
221
|
+
onTaskStarted,
|
|
222
|
+
init_task_lifecycle_events,
|
|
207
223
|
computeContentHash2,
|
|
208
224
|
getContextVersion2,
|
|
209
225
|
getContextVersionHistory2,
|
|
@@ -211,8 +227,6 @@ import {
|
|
|
211
227
|
assertAssetKeyMovesAllowed2,
|
|
212
228
|
moveSessionChains,
|
|
213
229
|
init_session_moves,
|
|
214
|
-
onTaskStarted,
|
|
215
|
-
init_task_lifecycle_events,
|
|
216
230
|
getPendingTaskForAgent2,
|
|
217
231
|
startTask2,
|
|
218
232
|
updateTaskClaudeSessionId2,
|
|
@@ -367,6 +381,7 @@ import {
|
|
|
367
381
|
deleteUser2,
|
|
368
382
|
getRootTaskChain2,
|
|
369
383
|
getBudget2,
|
|
384
|
+
getActivePricingRow2,
|
|
370
385
|
getDailySpendForAgent2,
|
|
371
386
|
getDailySpendGlobal2,
|
|
372
387
|
getDailySpendForUser2,
|
|
@@ -385,23 +400,23 @@ import {
|
|
|
385
400
|
recordInlineScriptRun2,
|
|
386
401
|
exports_db,
|
|
387
402
|
init_db4
|
|
388
|
-
} from "./cli-
|
|
403
|
+
} from "./cli-wwp1bd3n.js";
|
|
389
404
|
import {
|
|
390
405
|
assertMayActOnOperatorGrantedTarget2,
|
|
391
406
|
getUserGrant2,
|
|
392
407
|
init_rbac_roles
|
|
393
|
-
} from "./cli-
|
|
408
|
+
} from "./cli-vfqvrd82.js";
|
|
394
409
|
import {
|
|
395
410
|
ensurePricingSeeded2,
|
|
396
411
|
ensureRbacSeeded2,
|
|
397
412
|
ensureModelProfilesSeeded2,
|
|
398
413
|
init_boot_seeds
|
|
399
|
-
} from "./cli-
|
|
414
|
+
} from "./cli-mys27d03.js";
|
|
400
415
|
import {
|
|
401
416
|
requestModelCatalogRefresh2,
|
|
402
417
|
startPricingRefreshLoop2,
|
|
403
418
|
init_pricing_refresh
|
|
404
|
-
} from "./cli-
|
|
419
|
+
} from "./cli-th1dkc2v.js";
|
|
405
420
|
import {
|
|
406
421
|
workflowEventBus2,
|
|
407
422
|
init_event_bus
|
|
@@ -414,7 +429,11 @@ import {
|
|
|
414
429
|
externalChannelToolError2,
|
|
415
430
|
getChannelBlockReason2,
|
|
416
431
|
init_external_channel
|
|
417
|
-
} from "./cli-
|
|
432
|
+
} from "./cli-mk7c5ac4.js";
|
|
433
|
+
import {
|
|
434
|
+
tableToAscii2,
|
|
435
|
+
init_dist8
|
|
436
|
+
} from "./cli-9w8712tq.js";
|
|
418
437
|
import {
|
|
419
438
|
noteSlackInboundSideEffect,
|
|
420
439
|
init_inbound_dispatch,
|
|
@@ -444,8 +463,28 @@ import {
|
|
|
444
463
|
getTaskCitations,
|
|
445
464
|
hasTaskCitationCheckRefusal,
|
|
446
465
|
init_task_citations2,
|
|
466
|
+
getTaskUiSpec,
|
|
467
|
+
upsertTaskUiSpec,
|
|
468
|
+
acquireTaskUiScriptActionRun,
|
|
469
|
+
finishTaskUiScriptActionRun,
|
|
470
|
+
hasTaskUiSpecCheckRefusal,
|
|
471
|
+
init_task_ui_spec,
|
|
472
|
+
standardComponentDefinitions,
|
|
473
|
+
CardSpecError,
|
|
474
|
+
toCard,
|
|
475
|
+
init_dist5,
|
|
476
|
+
UI_SPEC_MAX_ACTIONS,
|
|
477
|
+
TASK_UI_SPEC_UPDATED_EVENT,
|
|
478
|
+
UI_SPEC_ACTION_ID,
|
|
479
|
+
UI_SPEC_CARD_LIMITS,
|
|
480
|
+
UI_SPEC_SCRIPT_ARGS_MAX_BYTES,
|
|
481
|
+
init_task_ui_spec2,
|
|
482
|
+
validateTaskUiSpec,
|
|
483
|
+
init_validate2,
|
|
447
484
|
ensure,
|
|
448
485
|
init_business_use,
|
|
486
|
+
withUiSpecFallback,
|
|
487
|
+
init_fallback,
|
|
449
488
|
getAgentDisplayName,
|
|
450
489
|
getAgentSlackIcon,
|
|
451
490
|
init_responses,
|
|
@@ -453,7 +492,7 @@ import {
|
|
|
453
492
|
startSlackApp2,
|
|
454
493
|
stopSlackAppUnderLifecycleLock2,
|
|
455
494
|
init_app3
|
|
456
|
-
} from "./cli-
|
|
495
|
+
} from "./cli-539h29es.js";
|
|
457
496
|
import {
|
|
458
497
|
AGENT_MAX_TASKS_CONFIG_KEY,
|
|
459
498
|
resetAgentMaxTasksMirror,
|
|
@@ -474,7 +513,7 @@ import {
|
|
|
474
513
|
postApprovalCancellationUpdates2,
|
|
475
514
|
createApprovalFollowUpTask2,
|
|
476
515
|
init_approval_notifications
|
|
477
|
-
} from "./cli-
|
|
516
|
+
} from "./cli-cc93xzes.js";
|
|
478
517
|
import {
|
|
479
518
|
shapeApprovalResolution,
|
|
480
519
|
init_approval_resolution,
|
|
@@ -498,7 +537,7 @@ import {
|
|
|
498
537
|
resumeFromChildRun2,
|
|
499
538
|
initWaitBusSubscriptions2,
|
|
500
539
|
init_resume
|
|
501
|
-
} from "./cli-
|
|
540
|
+
} from "./cli-7r162fxe.js";
|
|
502
541
|
import {
|
|
503
542
|
FilesError,
|
|
504
543
|
providerPath,
|
|
@@ -509,14 +548,10 @@ import {
|
|
|
509
548
|
getFileStorageProvider2,
|
|
510
549
|
init_registry2
|
|
511
550
|
} from "./cli-7cp6aa1q.js";
|
|
512
|
-
import {
|
|
513
|
-
tableToAscii2,
|
|
514
|
-
init_dist4
|
|
515
|
-
} from "./cli-wr1h0k28.js";
|
|
516
551
|
import {
|
|
517
552
|
getRuntimePool2,
|
|
518
553
|
init_db2
|
|
519
|
-
} from "./cli-
|
|
554
|
+
} from "./cli-s1zqk1aj.js";
|
|
520
555
|
import {
|
|
521
556
|
duplicateGuardedQueryKey,
|
|
522
557
|
parseQueryParams,
|
|
@@ -552,7 +587,7 @@ import {
|
|
|
552
587
|
findRoute,
|
|
553
588
|
route,
|
|
554
589
|
init_route_def
|
|
555
|
-
} from "./cli-
|
|
590
|
+
} from "./cli-nstkanmx.js";
|
|
556
591
|
import {
|
|
557
592
|
COMPOSIO_HTTP_METHODS,
|
|
558
593
|
executeComposioRequest,
|
|
@@ -654,7 +689,7 @@ import {
|
|
|
654
689
|
init_typecheck,
|
|
655
690
|
parseSkillContent,
|
|
656
691
|
init_skill_parser
|
|
657
|
-
} from "./cli-
|
|
692
|
+
} from "./cli-w1q68d8x.js";
|
|
658
693
|
import {
|
|
659
694
|
detachedProcessGroup,
|
|
660
695
|
registerProcessGroup,
|
|
@@ -669,24 +704,16 @@ import {
|
|
|
669
704
|
ensureToken,
|
|
670
705
|
ensureTokenOrThrow,
|
|
671
706
|
init_ensure_token
|
|
672
|
-
} from "./cli-
|
|
673
|
-
import {
|
|
674
|
-
require_fast_deep_equal
|
|
675
|
-
} from "./cli-bhp11egn.js";
|
|
676
|
-
import {
|
|
677
|
-
ZodFirstPartyTypeKind,
|
|
678
|
-
objectType,
|
|
679
|
-
init_v3
|
|
680
|
-
} from "./cli-ytyvpye5.js";
|
|
681
|
-
import {
|
|
682
|
-
init_v4
|
|
683
|
-
} from "./cli-3kd08rej.js";
|
|
707
|
+
} from "./cli-2rnd5j3t.js";
|
|
684
708
|
import {
|
|
685
709
|
SLACK_LEAVE_THREAD_DISABLE,
|
|
686
710
|
isSlackLeaveThreadDisabled,
|
|
687
711
|
leaveSlackThread,
|
|
688
712
|
init_left_threads
|
|
689
|
-
} from "./cli-
|
|
713
|
+
} from "./cli-jrbq4djp.js";
|
|
714
|
+
import {
|
|
715
|
+
require_fast_deep_equal
|
|
716
|
+
} from "./cli-bhp11egn.js";
|
|
690
717
|
import {
|
|
691
718
|
notifyAutomationPreflightFailure,
|
|
692
719
|
init_automation_preflight_alert,
|
|
@@ -761,11 +788,19 @@ import {
|
|
|
761
788
|
validateDefinition,
|
|
762
789
|
applyDefinitionPatch,
|
|
763
790
|
init_definition2
|
|
764
|
-
} from "./cli-
|
|
791
|
+
} from "./cli-q5srsxq2.js";
|
|
765
792
|
import {
|
|
766
793
|
isMultiRuntimeEnabled,
|
|
767
794
|
init_multi_runtime2
|
|
768
795
|
} from "./cli-mdb054w3.js";
|
|
796
|
+
import {
|
|
797
|
+
ZodFirstPartyTypeKind,
|
|
798
|
+
objectType,
|
|
799
|
+
init_v3
|
|
800
|
+
} from "./cli-ytyvpye5.js";
|
|
801
|
+
import {
|
|
802
|
+
init_v4
|
|
803
|
+
} from "./cli-3kd08rej.js";
|
|
769
804
|
import {
|
|
770
805
|
require_dist2
|
|
771
806
|
} from "./cli-xf1wn5ns.js";
|
|
@@ -776,11 +811,11 @@ import {
|
|
|
776
811
|
import {
|
|
777
812
|
canProvisionKind,
|
|
778
813
|
init_runtime_providers
|
|
779
|
-
} from "./cli-
|
|
814
|
+
} from "./cli-tvgqesec.js";
|
|
780
815
|
import {
|
|
781
816
|
publicEndpointSsrfOptions,
|
|
782
817
|
init_mcp_wrapper
|
|
783
|
-
} from "./cli-
|
|
818
|
+
} from "./cli-2v2zdm0a.js";
|
|
784
819
|
import {
|
|
785
820
|
findUserById,
|
|
786
821
|
findUserByExternalId,
|
|
@@ -795,7 +830,20 @@ import {
|
|
|
795
830
|
resolveSessionToken,
|
|
796
831
|
fingerprintApiKey,
|
|
797
832
|
init_users
|
|
798
|
-
} from "./cli-
|
|
833
|
+
} from "./cli-vsw91x06.js";
|
|
834
|
+
import {
|
|
835
|
+
resolveGitHubHost,
|
|
836
|
+
getGitHubLinkConfig,
|
|
837
|
+
getGitHubGraphqlUrl,
|
|
838
|
+
githubApiUrl,
|
|
839
|
+
init_github_host
|
|
840
|
+
} from "./cli-9ttx00s3.js";
|
|
841
|
+
import {
|
|
842
|
+
AMP_ESTIMATE_MODELS,
|
|
843
|
+
ampBillsCacheWrites,
|
|
844
|
+
resolveAmpModel,
|
|
845
|
+
init_amp_models
|
|
846
|
+
} from "./cli-zeh2mhkg.js";
|
|
799
847
|
import {
|
|
800
848
|
normalizeAssetKey,
|
|
801
849
|
defaultAssetKey,
|
|
@@ -815,7 +863,7 @@ import {
|
|
|
815
863
|
init_import,
|
|
816
864
|
$OpenAPIRegistry,
|
|
817
865
|
$OpenApiGeneratorV31,
|
|
818
|
-
|
|
866
|
+
init_dist9,
|
|
819
867
|
init_zod_openapi,
|
|
820
868
|
AssetKeySchema,
|
|
821
869
|
ModelTierSchema,
|
|
@@ -845,6 +893,7 @@ import {
|
|
|
845
893
|
AgentMemorySourceSchema,
|
|
846
894
|
RuntimePoolUpdateSchema,
|
|
847
895
|
RuntimePoolCreateAgentSchema,
|
|
896
|
+
SUPERSEDED_WORKFLOW_TASK_REASON,
|
|
848
897
|
WorkflowDefinitionSchema,
|
|
849
898
|
WorkflowNodePatchSchema,
|
|
850
899
|
TriggerConfigSchema,
|
|
@@ -866,14 +915,7 @@ import {
|
|
|
866
915
|
KvNamespaceSchema,
|
|
867
916
|
KvKeySchema,
|
|
868
917
|
init_types5
|
|
869
|
-
} from "./cli-
|
|
870
|
-
import {
|
|
871
|
-
resolveGitHubHost,
|
|
872
|
-
getGitHubLinkConfig,
|
|
873
|
-
getGitHubGraphqlUrl,
|
|
874
|
-
githubApiUrl,
|
|
875
|
-
init_github_host
|
|
876
|
-
} from "./cli-9ttx00s3.js";
|
|
918
|
+
} from "./cli-y4ccxtz5.js";
|
|
877
919
|
import {
|
|
878
920
|
generateDefaultClaudeMd2,
|
|
879
921
|
generateDefaultSoulMd2,
|
|
@@ -884,20 +926,20 @@ import {
|
|
|
884
926
|
init_task_attachment_links,
|
|
885
927
|
contentSha256,
|
|
886
928
|
init_profile_sync
|
|
887
|
-
} from "./cli-
|
|
929
|
+
} from "./cli-3aaeb78m.js";
|
|
930
|
+
import {
|
|
931
|
+
isSteeringEnabled2,
|
|
932
|
+
init_steering_enabled
|
|
933
|
+
} from "./cli-4sydckyj.js";
|
|
888
934
|
import {
|
|
889
935
|
getSlackConfiguration,
|
|
890
936
|
isSlackConfigured,
|
|
891
937
|
init_config4
|
|
892
938
|
} from "./cli-eetzmsy5.js";
|
|
893
|
-
import {
|
|
894
|
-
isSteeringEnabled2,
|
|
895
|
-
init_steering_enabled
|
|
896
|
-
} from "./cli-4sydckyj.js";
|
|
897
939
|
import {
|
|
898
940
|
selectCredential,
|
|
899
941
|
init_credentials2
|
|
900
|
-
} from "./cli-
|
|
942
|
+
} from "./cli-psffsanb.js";
|
|
901
943
|
import {
|
|
902
944
|
findInterpolationTokens,
|
|
903
945
|
interpolate,
|
|
@@ -907,7 +949,7 @@ import {
|
|
|
907
949
|
init_registry3,
|
|
908
950
|
resolveTemplate,
|
|
909
951
|
init_resolver
|
|
910
|
-
} from "./cli-
|
|
952
|
+
} from "./cli-6ehs4mta.js";
|
|
911
953
|
import {
|
|
912
954
|
init_zod
|
|
913
955
|
} from "./cli-zcfpsfzf.js";
|
|
@@ -924,7 +966,6 @@ import {
|
|
|
924
966
|
unknown,
|
|
925
967
|
array2,
|
|
926
968
|
object2,
|
|
927
|
-
strictObject2,
|
|
928
969
|
looseObject,
|
|
929
970
|
union3,
|
|
930
971
|
discriminatedUnion,
|
|
@@ -934,7 +975,6 @@ import {
|
|
|
934
975
|
literal2,
|
|
935
976
|
ZodOptional,
|
|
936
977
|
optional2,
|
|
937
|
-
lazy,
|
|
938
978
|
custom,
|
|
939
979
|
preprocess,
|
|
940
980
|
ZodIssueCode,
|
|
@@ -962,7 +1002,7 @@ import {
|
|
|
962
1002
|
import {
|
|
963
1003
|
init_package,
|
|
964
1004
|
package_default
|
|
965
|
-
} from "./cli-
|
|
1005
|
+
} from "./cli-3f8zbtqa.js";
|
|
966
1006
|
import {
|
|
967
1007
|
getNodeEnv,
|
|
968
1008
|
isDevOrTestNodeEnv,
|
|
@@ -20340,7 +20380,7 @@ function startRetryPoller(registry, intervalMs = 5000) {
|
|
|
20340
20380
|
if (!waiting)
|
|
20341
20381
|
continue;
|
|
20342
20382
|
if (result.waitFor === "workflow.child.finished") {
|
|
20343
|
-
const { resumeFromChildRun } = await import("./resume-
|
|
20383
|
+
const { resumeFromChildRun } = await import("./resume-tqy61x24.js");
|
|
20344
20384
|
await resumeFromChildRun(step.id, registry);
|
|
20345
20385
|
}
|
|
20346
20386
|
} else {
|
|
@@ -20552,6 +20592,12 @@ async function verifyWebhookRequest(trigger, rawBody, headers) {
|
|
|
20552
20592
|
throw new WebhookError("Invalid signature", 401);
|
|
20553
20593
|
}
|
|
20554
20594
|
}
|
|
20595
|
+
function filteredWebhookEvent(trigger, headers) {
|
|
20596
|
+
if (!trigger.events || trigger.events.length === 0)
|
|
20597
|
+
return;
|
|
20598
|
+
const event = getHeader(headers, trigger.eventHeader || DEFAULT_EVENT_HEADER) ?? null;
|
|
20599
|
+
return event !== null && trigger.events.includes(event) ? undefined : event;
|
|
20600
|
+
}
|
|
20555
20601
|
async function handleWebhookTrigger(workflowId, payload, headers, registry, options = {}) {
|
|
20556
20602
|
const workflow = await getWorkflow2(workflowId);
|
|
20557
20603
|
if (!workflow) {
|
|
@@ -20567,6 +20613,10 @@ async function handleWebhookTrigger(workflowId, payload, headers, registry, opti
|
|
|
20567
20613
|
}
|
|
20568
20614
|
} else {
|
|
20569
20615
|
await verifyWebhookRequest(webhookTrigger, typeof payload === "string" ? payload : JSON.stringify(payload), headers);
|
|
20616
|
+
const filtered = filteredWebhookEvent(webhookTrigger, headers);
|
|
20617
|
+
if (filtered !== undefined) {
|
|
20618
|
+
return { skipped: true, reason: "event-not-allowed", event: filtered };
|
|
20619
|
+
}
|
|
20570
20620
|
}
|
|
20571
20621
|
const triggerData = parseTriggerPayload(payload);
|
|
20572
20622
|
const runId = await startWorkflowExecution2(workflow, triggerData, registry, {
|
|
@@ -20717,7 +20767,7 @@ function timingSafeEqualHex(providedHex, expected) {
|
|
|
20717
20767
|
return false;
|
|
20718
20768
|
}
|
|
20719
20769
|
}
|
|
20720
|
-
var DEFAULT_HMAC_HEADER = "X-Hub-Signature-256", FALLBACK_HMAC_HEADERS, STANDARD_WEBHOOK_SECRET_PREFIX = "whsec_", WebhookError;
|
|
20770
|
+
var DEFAULT_HMAC_HEADER = "X-Hub-Signature-256", FALLBACK_HMAC_HEADERS, DEFAULT_EVENT_HEADER = "X-GitHub-Event", STANDARD_WEBHOOK_SECRET_PREFIX = "whsec_", WebhookError;
|
|
20721
20771
|
var init_triggers = __esm(() => {
|
|
20722
20772
|
init_db4();
|
|
20723
20773
|
init_engine();
|
|
@@ -20810,21 +20860,6 @@ var init_wait_poller = __esm(() => {
|
|
|
20810
20860
|
init_resume();
|
|
20811
20861
|
});
|
|
20812
20862
|
|
|
20813
|
-
// src/tasks/errors.ts
|
|
20814
|
-
var TaskCreationBlockedError;
|
|
20815
|
-
var init_errors = __esm(() => {
|
|
20816
|
-
TaskCreationBlockedError = class TaskCreationBlockedError extends Error {
|
|
20817
|
-
reason;
|
|
20818
|
-
extension;
|
|
20819
|
-
constructor(reason, extension) {
|
|
20820
|
-
super(reason);
|
|
20821
|
-
this.reason = reason;
|
|
20822
|
-
this.extension = extension;
|
|
20823
|
-
this.name = "TaskCreationBlockedError";
|
|
20824
|
-
}
|
|
20825
|
-
};
|
|
20826
|
-
});
|
|
20827
|
-
|
|
20828
20863
|
// src/workflows/executors/agent-task.ts
|
|
20829
20864
|
var AgentTaskConfigSchema, AgentTaskOutputSchema, AgentTaskExecutor;
|
|
20830
20865
|
var init_agent_task = __esm(() => {
|
|
@@ -20833,7 +20868,7 @@ var init_agent_task = __esm(() => {
|
|
|
20833
20868
|
init_model_validation2();
|
|
20834
20869
|
init_apply_task_create();
|
|
20835
20870
|
init_context_key();
|
|
20836
|
-
|
|
20871
|
+
init_errors2();
|
|
20837
20872
|
init_types5();
|
|
20838
20873
|
init_base();
|
|
20839
20874
|
AgentTaskConfigSchema = object2({
|
|
@@ -21086,7 +21121,7 @@ var init_notify = __esm(() => {
|
|
|
21086
21121
|
}
|
|
21087
21122
|
}
|
|
21088
21123
|
case "slack": {
|
|
21089
|
-
const { getSlackApp } = await import("./app-
|
|
21124
|
+
const { getSlackApp } = await import("./app-wb7w45dq.js");
|
|
21090
21125
|
let app = getSlackApp();
|
|
21091
21126
|
if (!app) {
|
|
21092
21127
|
if (!isSlackConfigured()) {
|
|
@@ -21219,7 +21254,7 @@ var init_property_match = __esm(() => {
|
|
|
21219
21254
|
async function executeRawLlm(config) {
|
|
21220
21255
|
let modelName = config.model ?? "google/gemini-3-flash-preview";
|
|
21221
21256
|
try {
|
|
21222
|
-
const { createOpenAI } = await import("./index-
|
|
21257
|
+
const { createOpenAI } = await import("./index-9myfj74s.js");
|
|
21223
21258
|
const llmConfig = await resolveWorkflowLlmConfig(config.model);
|
|
21224
21259
|
modelName = llmConfig.model;
|
|
21225
21260
|
const provider = createOpenAI({
|
|
@@ -21229,7 +21264,7 @@ async function executeRawLlm(config) {
|
|
|
21229
21264
|
});
|
|
21230
21265
|
const model = provider(llmConfig.model);
|
|
21231
21266
|
if (config.schema) {
|
|
21232
|
-
const { generateObject, jsonSchema } = await import("./index-
|
|
21267
|
+
const { generateObject, jsonSchema } = await import("./index-b5wgnm78.js");
|
|
21233
21268
|
const { object } = await generateObject({
|
|
21234
21269
|
model,
|
|
21235
21270
|
schema: jsonSchema(config.schema),
|
|
@@ -21243,7 +21278,7 @@ async function executeRawLlm(config) {
|
|
|
21243
21278
|
output: { result: object, model: modelName }
|
|
21244
21279
|
};
|
|
21245
21280
|
}
|
|
21246
|
-
const { generateText } = await import("./index-
|
|
21281
|
+
const { generateText } = await import("./index-b5wgnm78.js");
|
|
21247
21282
|
const { text } = await generateText({
|
|
21248
21283
|
model,
|
|
21249
21284
|
prompt: config.prompt
|
|
@@ -21724,7 +21759,7 @@ function validateJsonSchemaBasic(value, schema) {
|
|
|
21724
21759
|
return errors;
|
|
21725
21760
|
}
|
|
21726
21761
|
var ValidateConfigSchema, ValidateOutputSchema, ValidateExecutor;
|
|
21727
|
-
var
|
|
21762
|
+
var init_validate3 = __esm(() => {
|
|
21728
21763
|
init_zod();
|
|
21729
21764
|
init_base();
|
|
21730
21765
|
init_workflow_llm();
|
|
@@ -21803,8 +21838,8 @@ var init_validate2 = __esm(() => {
|
|
|
21803
21838
|
const interpolatedPrompt = this.deps.interpolate(prompt, context);
|
|
21804
21839
|
const outputStr = typeof targetOutput === "string" ? targetOutput : JSON.stringify(targetOutput);
|
|
21805
21840
|
try {
|
|
21806
|
-
const { createOpenAI } = await import("./index-
|
|
21807
|
-
const { generateObject, jsonSchema } = await import("./index-
|
|
21841
|
+
const { createOpenAI } = await import("./index-9myfj74s.js");
|
|
21842
|
+
const { generateObject, jsonSchema } = await import("./index-b5wgnm78.js");
|
|
21808
21843
|
const llmConfig = await resolveWorkflowLlmConfig();
|
|
21809
21844
|
const provider = createOpenAI({
|
|
21810
21845
|
baseURL: llmConfig.baseURL,
|
|
@@ -21963,7 +21998,7 @@ var init_registry = __esm(() => {
|
|
|
21963
21998
|
init_swarm_script();
|
|
21964
21999
|
init_system_one_decision();
|
|
21965
22000
|
init_system_one_extraction();
|
|
21966
|
-
|
|
22001
|
+
init_validate3();
|
|
21967
22002
|
init_vcs();
|
|
21968
22003
|
init_wait();
|
|
21969
22004
|
});
|
|
@@ -22109,7 +22144,7 @@ async function resolveWaitCause(scheduleId, reason) {
|
|
|
22109
22144
|
return;
|
|
22110
22145
|
if (reason === "ceiling")
|
|
22111
22146
|
return { wait, cause: "ceiling expired", matchedTaskIds: [] };
|
|
22112
|
-
const members = await client.query(`SELECT m.taskId,
|
|
22147
|
+
const members = await client.query(`SELECT m.taskId, ${WAIT_MEMBER_STATUS_SQL} AS taskStatus, EXISTS (
|
|
22113
22148
|
SELECT 1 FROM scheduled_tasks d
|
|
22114
22149
|
WHERE d.parentTaskId = t.id AND d.taskType = 'deferred' AND d.enabled = 1
|
|
22115
22150
|
) AS deferred
|
|
@@ -22226,16 +22261,17 @@ async function reconcileDeferredTaskWaits(taskId) {
|
|
|
22226
22261
|
});
|
|
22227
22262
|
return reconcileDeferredTaskWaits();
|
|
22228
22263
|
}
|
|
22229
|
-
const rows = await client.query(`SELECT DISTINCT w.*,
|
|
22264
|
+
const rows = await client.query(`SELECT DISTINCT w.*, ${WAIT_MEMBER_STATUS_SQL} AS taskStatus FROM deferred_task_waits w
|
|
22230
22265
|
JOIN deferred_task_wait_members m ON m.scheduleId = w.scheduleId
|
|
22231
22266
|
JOIN agent_tasks t ON t.id = m.taskId
|
|
22232
22267
|
JOIN scheduled_tasks s ON s.id = w.scheduleId
|
|
22233
|
-
WHERE w.status = 'pending' AND s.enabled = 1
|
|
22268
|
+
WHERE w.status = 'pending' AND s.enabled = 1
|
|
22269
|
+
AND ${WAIT_MEMBER_STATUS_SQL} IN ('completed', 'failed', 'cancelled', 'skipped')
|
|
22234
22270
|
AND NOT EXISTS (
|
|
22235
22271
|
SELECT 1 FROM scheduled_tasks d
|
|
22236
22272
|
WHERE d.parentTaskId = t.id AND d.taskType = 'deferred' AND d.enabled = 1
|
|
22237
22273
|
)
|
|
22238
|
-
AND (w.eventName = 'settled' OR w.eventName = 'task.' ||
|
|
22274
|
+
AND (w.eventName = 'settled' OR w.eventName = 'task.' || ${WAIT_MEMBER_STATUS_SQL})
|
|
22239
22275
|
${taskId ? "AND m.taskId = ?" : ""}`, taskId ? [taskId] : []);
|
|
22240
22276
|
for (const row of rows) {
|
|
22241
22277
|
try {
|
|
@@ -22281,11 +22317,15 @@ function stopDeferredTaskWaits() {
|
|
|
22281
22317
|
workflowEventBus2.off("task.superseded", onTaskEvent);
|
|
22282
22318
|
workflowEventBus2.off("task.created", onTaskEvent);
|
|
22283
22319
|
}
|
|
22284
|
-
var DEFERRED_WAIT_WOKE_EVENT = "task_deferred_wait_woke", SPENT_DEFERRED_SCHEDULE_RETENTION_MS;
|
|
22320
|
+
var WAIT_MEMBER_STATUS_SQL, DEFERRED_WAIT_WOKE_EVENT = "task_deferred_wait_woke", SPENT_DEFERRED_SCHEDULE_RETENTION_MS;
|
|
22285
22321
|
var init_deferred_task_waits = __esm(() => {
|
|
22286
22322
|
init_db4();
|
|
22323
|
+
init_types5();
|
|
22287
22324
|
init_event_bus();
|
|
22288
22325
|
init_schedule_task();
|
|
22326
|
+
WAIT_MEMBER_STATUS_SQL = `CASE
|
|
22327
|
+
WHEN t.status = 'superseded' AND t.failureReason = '${SUPERSEDED_WORKFLOW_TASK_REASON}' THEN 'failed'
|
|
22328
|
+
ELSE t.status END`;
|
|
22289
22329
|
SPENT_DEFERRED_SCHEDULE_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
|
|
22290
22330
|
});
|
|
22291
22331
|
|
|
@@ -24510,7 +24550,7 @@ function setPreloadedTools(server, names) {
|
|
|
24510
24550
|
async function applyPreToolCall(name, args, requestInfo, inputSchema) {
|
|
24511
24551
|
if (requestInfo.callOrigin !== "mcp")
|
|
24512
24552
|
return { args };
|
|
24513
|
-
const dispatcher = await import("./dispatcher-
|
|
24553
|
+
const dispatcher = await import("./dispatcher-8d8s49yz.js");
|
|
24514
24554
|
const result = await dispatcher.dispatchPre("pre.tool.call", { tool: name, args, requestInfo }, inputSchema ? {
|
|
24515
24555
|
validateModify: async (data) => {
|
|
24516
24556
|
const schema = normalizeObjectSchema(inputSchema) ?? inputSchema;
|
|
@@ -26806,8 +26846,14 @@ function positiveEnv(name, fallback) {
|
|
|
26806
26846
|
const value = Number(process.env[name]);
|
|
26807
26847
|
return Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
|
|
26808
26848
|
}
|
|
26809
|
-
function
|
|
26810
|
-
|
|
26849
|
+
function toolSourceOf(event, payload) {
|
|
26850
|
+
if (event !== "pre.tool.call" && event !== "post.tool.call")
|
|
26851
|
+
return;
|
|
26852
|
+
return stringField(payload, "requestInfo", "callOrigin") === "native" ? "native" : "mcp";
|
|
26853
|
+
}
|
|
26854
|
+
function handlersFor(event, payload, opts) {
|
|
26855
|
+
const toolSource = toolSourceOf(event, payload);
|
|
26856
|
+
return [...registry2.values()].filter((loaded) => loaded.record.id !== opts?.skipExtensionId).filter((loaded) => !toolSource || (loaded.manifest.toolSources ?? ["mcp"]).includes(toolSource)).flatMap((loaded) => loaded.handlers.filter((handler) => handler.event === event).map((handler) => ({ loaded, handler }))).sort((a, b) => a.handler.priority - b.handler.priority || a.loaded.record.name.localeCompare(b.loaded.record.name));
|
|
26811
26857
|
}
|
|
26812
26858
|
function snippet(text, max = 80) {
|
|
26813
26859
|
const flat = String(text ?? "").replace(/\s+/g, " ").trim();
|
|
@@ -27020,7 +27066,7 @@ async function dispatchPre2(event, payload, opts) {
|
|
|
27020
27066
|
let currentPayload = { ...payload };
|
|
27021
27067
|
const mergedData = {};
|
|
27022
27068
|
let modified = false;
|
|
27023
|
-
for (const { loaded, handler } of handlersFor(event, opts)) {
|
|
27069
|
+
for (const { loaded, handler } of handlersFor(event, payload, opts)) {
|
|
27024
27070
|
if (!isRegistered2(loaded.record.id))
|
|
27025
27071
|
continue;
|
|
27026
27072
|
const run = await runHandler(loaded, handler, event, currentPayload);
|
|
@@ -27082,7 +27128,7 @@ async function dispatchPre2(event, payload, opts) {
|
|
|
27082
27128
|
return modified ? { action: "modify", data: mergedData } : { action: "continue" };
|
|
27083
27129
|
}
|
|
27084
27130
|
async function dispatchPost2(event, payload, opts) {
|
|
27085
|
-
for (const { loaded, handler } of handlersFor(event, opts)) {
|
|
27131
|
+
for (const { loaded, handler } of handlersFor(event, payload, opts)) {
|
|
27086
27132
|
if (!isRegistered2(loaded.record.id))
|
|
27087
27133
|
continue;
|
|
27088
27134
|
const run = await runHandler(loaded, handler, event, payload);
|
|
@@ -27441,7 +27487,7 @@ async function createTaskWithSiblingAwareness(description, options, args = {}) {
|
|
|
27441
27487
|
var init_sibling_awareness = __esm(() => {
|
|
27442
27488
|
init_db4();
|
|
27443
27489
|
init_apply_task_create();
|
|
27444
|
-
|
|
27490
|
+
init_errors2();
|
|
27445
27491
|
init_sibling_block();
|
|
27446
27492
|
});
|
|
27447
27493
|
|
|
@@ -30547,6 +30593,18 @@ async function resolveGitHubSender(login, sampleEventType, sampleContext) {
|
|
|
30547
30593
|
await incrKv2(UNMAPPED_NAMESPACE3, `${login}:count`, 1);
|
|
30548
30594
|
return;
|
|
30549
30595
|
}
|
|
30596
|
+
function isTrustedGitHubSender(login, requestedByUserId, content) {
|
|
30597
|
+
if (requestedByUserId || isBotAssignee(login))
|
|
30598
|
+
return true;
|
|
30599
|
+
const normalized = login.toLowerCase();
|
|
30600
|
+
const allowed = (process.env.GITHUB_ALLOWED_SENDERS ?? "").split(",").map((name) => name.trim().toLowerCase()).filter(Boolean);
|
|
30601
|
+
if (allowed.includes(normalized))
|
|
30602
|
+
return true;
|
|
30603
|
+
return content.user.login.toLowerCase() === normalized && TRUSTED_AUTHOR_ASSOCIATIONS.has(content.author_association ?? "");
|
|
30604
|
+
}
|
|
30605
|
+
function logUntrustedSender(eventType, login, repo, number) {
|
|
30606
|
+
console.log(`[GitHub] Skipped ${eventType} by ${login} on ${repo}#${number}: ${UNTRUSTED_SENDER_REASON}`);
|
|
30607
|
+
}
|
|
30550
30608
|
async function handlePullRequest(event) {
|
|
30551
30609
|
const {
|
|
30552
30610
|
action,
|
|
@@ -30760,6 +30818,10 @@ async function handlePullRequest(event) {
|
|
|
30760
30818
|
if (!hasMention) {
|
|
30761
30819
|
return { created: false };
|
|
30762
30820
|
}
|
|
30821
|
+
if (!isTrustedGitHubSender(sender.login, requestedByUserId, pr)) {
|
|
30822
|
+
logUntrustedSender(`pull_request.${action}`, sender.login, repository.full_name, pr.number);
|
|
30823
|
+
return { created: false };
|
|
30824
|
+
}
|
|
30763
30825
|
const eventKey = `pr:${repository.full_name}:${pr.number}:${action}`;
|
|
30764
30826
|
if (isDuplicate4(eventKey)) {
|
|
30765
30827
|
return { created: false };
|
|
@@ -30924,6 +30986,10 @@ async function handleIssue(event) {
|
|
|
30924
30986
|
if (!hasMention) {
|
|
30925
30987
|
return { created: false };
|
|
30926
30988
|
}
|
|
30989
|
+
if (!isTrustedGitHubSender(sender.login, requestedByUserId, issue)) {
|
|
30990
|
+
logUntrustedSender(`issues.${action}`, sender.login, repository.full_name, issue.number);
|
|
30991
|
+
return { created: false };
|
|
30992
|
+
}
|
|
30927
30993
|
const eventKey = `issue:${repository.full_name}:${issue.number}:${action}`;
|
|
30928
30994
|
if (isDuplicate4(eventKey)) {
|
|
30929
30995
|
return { created: false };
|
|
@@ -30978,6 +31044,9 @@ async function handleComment(event, eventType) {
|
|
|
30978
31044
|
if (!detectMention3(comment.body)) {
|
|
30979
31045
|
return skip("no bot mention");
|
|
30980
31046
|
}
|
|
31047
|
+
if (!isTrustedGitHubSender(sender.login, requestedByUserId, comment)) {
|
|
31048
|
+
return skip(UNTRUSTED_SENDER_REASON);
|
|
31049
|
+
}
|
|
30981
31050
|
const eventKey = `comment:${repository.full_name}:${comment.id}`;
|
|
30982
31051
|
if (isDuplicate4(eventKey)) {
|
|
30983
31052
|
return skip("duplicate delivery");
|
|
@@ -31209,6 +31278,10 @@ async function handlePullRequestReview(event) {
|
|
|
31209
31278
|
if (action !== "submitted") {
|
|
31210
31279
|
return { created: false };
|
|
31211
31280
|
}
|
|
31281
|
+
if (!isTrustedGitHubSender(sender.login, requestedByUserId, review)) {
|
|
31282
|
+
logUntrustedSender("pull_request_review", sender.login, repository.full_name, pr.number);
|
|
31283
|
+
return { created: false };
|
|
31284
|
+
}
|
|
31212
31285
|
const eventKey = `pr-review:${repository.full_name}:${pr.number}:${review.id}`;
|
|
31213
31286
|
if (isDuplicate4(eventKey)) {
|
|
31214
31287
|
return { created: false };
|
|
@@ -31305,7 +31378,7 @@ async function handleWorkflowRun(event) {
|
|
|
31305
31378
|
console.log(`[GitHub:suppressed] workflow_run.${action} (${conclusion}) on ${repository.full_name} — CI events disabled by default`);
|
|
31306
31379
|
return { created: false };
|
|
31307
31380
|
}
|
|
31308
|
-
var processedEvents4, EVENT_TTL2 = 60000, cancelOnUnassignEnabled = () => cancelFlagEnabled("github.cancelOnUnassign"), cancelOnReviewRequestRemovedEnabled = () => cancelFlagEnabled("github.cancelOnReviewRequestRemoved"), UNMAPPED_NAMESPACE3 = "integration:unmapped:github", UNMAPPED_TTL_MS3, REVIEW_COMMENTS_EMPTY_RETRY_DELAYS_MS, defaultReviewCommentsRetryDelay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), reviewCommentsRetryDelay, PR_REVIEW_ACTION_ITEMS_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
|
|
31381
|
+
var processedEvents4, EVENT_TTL2 = 60000, cancelOnUnassignEnabled = () => cancelFlagEnabled("github.cancelOnUnassign"), cancelOnReviewRequestRemovedEnabled = () => cancelFlagEnabled("github.cancelOnReviewRequestRemoved"), UNMAPPED_NAMESPACE3 = "integration:unmapped:github", UNMAPPED_TTL_MS3, TRUSTED_AUTHOR_ASSOCIATIONS, UNTRUSTED_SENDER_REASON = "sender is not a linked user, an allowed sender, or a repo owner, member or collaborator", REVIEW_COMMENTS_EMPTY_RETRY_DELAYS_MS, defaultReviewCommentsRetryDelay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), reviewCommentsRetryDelay, PR_REVIEW_ACTION_ITEMS_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
|
|
31309
31382
|
repository(owner: $owner, name: $name) {
|
|
31310
31383
|
pullRequest(number: $number) {
|
|
31311
31384
|
mergeStateStatus
|
|
@@ -31330,6 +31403,7 @@ var init_handlers4 = __esm(() => {
|
|
|
31330
31403
|
init_templates7();
|
|
31331
31404
|
processedEvents4 = new Map;
|
|
31332
31405
|
UNMAPPED_TTL_MS3 = 30 * 24 * 60 * 60 * 1000;
|
|
31406
|
+
TRUSTED_AUTHOR_ASSOCIATIONS = new Set(["OWNER", "MEMBER", "COLLABORATOR"]);
|
|
31333
31407
|
REVIEW_COMMENTS_EMPTY_RETRY_DELAYS_MS = [1500, 3000, 3000];
|
|
31334
31408
|
reviewCommentsRetryDelay = defaultReviewCommentsRetryDelay;
|
|
31335
31409
|
});
|
|
@@ -32258,7 +32332,7 @@ async function loadAdapter(name, config, logger) {
|
|
|
32258
32332
|
const base = { ...config, apiUrl, logger };
|
|
32259
32333
|
switch (name) {
|
|
32260
32334
|
case "telegram": {
|
|
32261
|
-
const { TelegramAdapter } = await import("./index-
|
|
32335
|
+
const { TelegramAdapter } = await import("./index-8p0j4h4j.js");
|
|
32262
32336
|
|
|
32263
32337
|
class SwarmTelegramAdapter extends TelegramAdapter {
|
|
32264
32338
|
isBotMentioned(message, text) {
|
|
@@ -32272,7 +32346,7 @@ async function loadAdapter(name, config, logger) {
|
|
|
32272
32346
|
});
|
|
32273
32347
|
}
|
|
32274
32348
|
case "slack": {
|
|
32275
|
-
const { createSlackAdapter } = await import("./index-
|
|
32349
|
+
const { createSlackAdapter } = await import("./index-620y7jzq.js");
|
|
32276
32350
|
return createSlackAdapter({
|
|
32277
32351
|
...base,
|
|
32278
32352
|
signingSecret: config.signingSecret ?? "",
|
|
@@ -32282,7 +32356,7 @@ async function loadAdapter(name, config, logger) {
|
|
|
32282
32356
|
});
|
|
32283
32357
|
}
|
|
32284
32358
|
case "discord": {
|
|
32285
|
-
const { createDiscordAdapter } = await import("./index-
|
|
32359
|
+
const { createDiscordAdapter } = await import("./index-0h6qd4p1.js");
|
|
32286
32360
|
return createDiscordAdapter({
|
|
32287
32361
|
...base,
|
|
32288
32362
|
logger: withInfoFilter(logger, keepDiscordInfoLine),
|
|
@@ -32291,7 +32365,7 @@ async function loadAdapter(name, config, logger) {
|
|
|
32291
32365
|
});
|
|
32292
32366
|
}
|
|
32293
32367
|
case "teams": {
|
|
32294
|
-
const { createTeamsAdapter } = await import("./index-
|
|
32368
|
+
const { createTeamsAdapter } = await import("./index-4k7m5dgj.js");
|
|
32295
32369
|
const { teamsWebhookVerifier, teamsToken } = getChatSdkTestHooks();
|
|
32296
32370
|
return createTeamsAdapter({
|
|
32297
32371
|
...base,
|
|
@@ -32500,7 +32574,7 @@ async function readPersistedThreadHistory(threadId) {
|
|
|
32500
32574
|
const rows = await new SqliteChatState().getList(`${SDK_THREAD_HISTORY_PREFIX}${threadId}`);
|
|
32501
32575
|
if (rows.length === 0)
|
|
32502
32576
|
return [];
|
|
32503
|
-
const { Message: MessageClass } = await import("./index-
|
|
32577
|
+
const { Message: MessageClass } = await import("./index-pe3d8jfy.js");
|
|
32504
32578
|
return rows.map((row) => MessageClass.fromJSON(row));
|
|
32505
32579
|
}
|
|
32506
32580
|
var SDK_THREAD_HISTORY_PREFIX = "msg-history:";
|
|
@@ -33580,7 +33654,7 @@ function render(node) {
|
|
|
33580
33654
|
}
|
|
33581
33655
|
}
|
|
33582
33656
|
var init_message_text2 = __esm(() => {
|
|
33583
|
-
|
|
33657
|
+
init_dist8();
|
|
33584
33658
|
});
|
|
33585
33659
|
|
|
33586
33660
|
// src/integrations/chat-sdk/limits.ts
|
|
@@ -33608,9 +33682,11 @@ function splitChatMessage(text, limit) {
|
|
|
33608
33682
|
if (code >= 55296 && code <= 56319) {
|
|
33609
33683
|
cut = cut > 1 ? cut - 1 : cut + 1;
|
|
33610
33684
|
}
|
|
33685
|
+
} else {
|
|
33686
|
+
cut += 1;
|
|
33611
33687
|
}
|
|
33612
|
-
chunks.push(rest.slice(0, cut)
|
|
33613
|
-
rest = rest.slice(cut)
|
|
33688
|
+
chunks.push(rest.slice(0, cut));
|
|
33689
|
+
rest = rest.slice(cut);
|
|
33614
33690
|
}
|
|
33615
33691
|
if (rest.length > 0 || chunks.length === 0)
|
|
33616
33692
|
chunks.push(rest);
|
|
@@ -34559,7 +34635,7 @@ async function flushChatThread(threadId, items, immediate) {
|
|
|
34559
34635
|
stopTypingKeepalive(threadId);
|
|
34560
34636
|
await clearChatMessageReactions(adapter, threadId, reacted);
|
|
34561
34637
|
try {
|
|
34562
|
-
const
|
|
34638
|
+
const result = await handleWebhookTrigger(target.workflowId, {
|
|
34563
34639
|
adapter,
|
|
34564
34640
|
channelId: first.channelId,
|
|
34565
34641
|
threadId,
|
|
@@ -34569,7 +34645,11 @@ async function flushChatThread(threadId, items, immediate) {
|
|
|
34569
34645
|
text: rawText,
|
|
34570
34646
|
messageIds: items.map((item) => item.messageId)
|
|
34571
34647
|
}, {}, getExecutorRegistry2(), { alreadyAuthenticated: true });
|
|
34572
|
-
|
|
34648
|
+
if (result.skipped) {
|
|
34649
|
+
console.warn(`[chat-sdk] ${threadId}: workflow webhook trigger skipped (${result.reason})`);
|
|
34650
|
+
return;
|
|
34651
|
+
}
|
|
34652
|
+
console.log(`[chat-sdk] ${threadId}: started workflow run ${result.runId}`);
|
|
34573
34653
|
await subscribe(thread);
|
|
34574
34654
|
} catch (error) {
|
|
34575
34655
|
console.error(`[chat-sdk] ${threadId}: workflow dispatch failed: ${errorMessage(error)}`);
|
|
@@ -34689,7 +34769,7 @@ var init_inbound = __esm(() => {
|
|
|
34689
34769
|
init_dispatcher();
|
|
34690
34770
|
init_resolver();
|
|
34691
34771
|
init_context_key();
|
|
34692
|
-
|
|
34772
|
+
init_errors2();
|
|
34693
34773
|
init_secret_scrubber();
|
|
34694
34774
|
init_workflows();
|
|
34695
34775
|
init_event_bus();
|
|
@@ -34918,6 +34998,65 @@ ${piece}
|
|
|
34918
34998
|
${block}` : block;
|
|
34919
34999
|
});
|
|
34920
35000
|
}
|
|
35001
|
+
function withoutCallbackButtons(children) {
|
|
35002
|
+
return children.flatMap((child) => {
|
|
35003
|
+
if (child.type === "section") {
|
|
35004
|
+
return [{ ...child, children: withoutCallbackButtons(child.children) }];
|
|
35005
|
+
}
|
|
35006
|
+
if (child.type !== "actions")
|
|
35007
|
+
return [child];
|
|
35008
|
+
const kept = child.children.filter((element) => element.type !== "button");
|
|
35009
|
+
return kept.length ? [{ ...child, children: kept }] : [];
|
|
35010
|
+
});
|
|
35011
|
+
}
|
|
35012
|
+
async function chatRelayUiSpec(taskId) {
|
|
35013
|
+
if (!isEnvFlagEnabled("UI_SPEC_ENABLED", false))
|
|
35014
|
+
return null;
|
|
35015
|
+
const stored = await getTaskUiSpec(taskId);
|
|
35016
|
+
if (!stored)
|
|
35017
|
+
return null;
|
|
35018
|
+
try {
|
|
35019
|
+
const card = toCard(stored.spec, {
|
|
35020
|
+
limits: UI_SPEC_CARD_LIMITS
|
|
35021
|
+
});
|
|
35022
|
+
return {
|
|
35023
|
+
card: { ...card, children: withoutCallbackButtons(card.children) },
|
|
35024
|
+
fallbackText: stored.fallbackText
|
|
35025
|
+
};
|
|
35026
|
+
} catch (error) {
|
|
35027
|
+
if (!(error instanceof CardSpecError))
|
|
35028
|
+
throw error;
|
|
35029
|
+
console.warn(`[chat-sdk] stored uiSpec for task ${taskId} no longer renders: ${error.issues.join(" | ")}`);
|
|
35030
|
+
return { card: null, fallbackText: stored.fallbackText };
|
|
35031
|
+
}
|
|
35032
|
+
}
|
|
35033
|
+
async function postChatRelayCard(adapter, threadId, task) {
|
|
35034
|
+
let uiSpec;
|
|
35035
|
+
try {
|
|
35036
|
+
uiSpec = await chatRelayUiSpec(task.id);
|
|
35037
|
+
} catch (error) {
|
|
35038
|
+
console.error(`[chat-sdk] uiSpec of task ${task.id} unreadable: ${errorMessage(error)}`);
|
|
35039
|
+
return;
|
|
35040
|
+
}
|
|
35041
|
+
if (!uiSpec)
|
|
35042
|
+
return;
|
|
35043
|
+
if (uiSpec.card) {
|
|
35044
|
+
try {
|
|
35045
|
+
await postChatMessage({ adapter, threadId, text: [], card: uiSpec.card, taskId: task.id });
|
|
35046
|
+
return;
|
|
35047
|
+
} catch (error) {
|
|
35048
|
+
console.warn(`[chat-sdk] Card post of task ${task.id} failed: ${errorMessage(error)}`);
|
|
35049
|
+
}
|
|
35050
|
+
}
|
|
35051
|
+
if (!uiSpec.fallbackText)
|
|
35052
|
+
return;
|
|
35053
|
+
try {
|
|
35054
|
+
const text = scrubSecrets(uiSpec.fallbackText);
|
|
35055
|
+
await postChatMessage({ adapter, threadId, text, taskId: task.id });
|
|
35056
|
+
} catch (error) {
|
|
35057
|
+
console.error(`[chat-sdk] Card fallback of task ${task.id} failed: ${errorMessage(error)}`);
|
|
35058
|
+
}
|
|
35059
|
+
}
|
|
34921
35060
|
async function processPendingChatRelays(now = Date.now(), signal) {
|
|
34922
35061
|
const retired = await giveUpStaleChatRelays2(now, RELAY_GIVE_UP_AFTER_MS);
|
|
34923
35062
|
if (retired > 0)
|
|
@@ -34956,6 +35095,7 @@ async function processPendingChatRelays(now = Date.now(), signal) {
|
|
|
34956
35095
|
files: await taskOutputChatFiles(task.id),
|
|
34957
35096
|
replyToMessageId: task.mentionMessageId
|
|
34958
35097
|
});
|
|
35098
|
+
await postChatRelayCard(target.adapter, target.threadId, task);
|
|
34959
35099
|
stopTypingKeepalive(target.threadId);
|
|
34960
35100
|
await markChatRelayDelivered2(task.id, now);
|
|
34961
35101
|
console.log(`[chat-sdk] Relayed ${task.status} task ${task.id} to ${target.adapter}`);
|
|
@@ -35022,10 +35162,14 @@ async function stopChatRelayWatcher() {
|
|
|
35022
35162
|
}
|
|
35023
35163
|
var RELAY_GIVE_UP_AFTER_MS, SWEEP_EVERY_N_TICKS = 20, EARLY_TICK_DEBOUNCE_MS = 250, TELEGRAM_FOLD_CHARS = 1000, FOLD_LEAD_MAX_CHARS = 280, FOLD_MARKUP_CHARS = 80, interval, earlyTick, processing, stopController, tickCount = 0, TERMINAL_EVENTS;
|
|
35024
35164
|
var init_relay = __esm(() => {
|
|
35165
|
+
init_dist5();
|
|
35025
35166
|
init_db4();
|
|
35167
|
+
init_task_ui_spec();
|
|
35026
35168
|
init_reaction_events();
|
|
35027
35169
|
init_context_key();
|
|
35170
|
+
init_env_flag();
|
|
35028
35171
|
init_secret_scrubber();
|
|
35172
|
+
init_task_ui_spec2();
|
|
35029
35173
|
init_event_bus();
|
|
35030
35174
|
init_commands();
|
|
35031
35175
|
init_limits();
|
|
@@ -35124,7 +35268,7 @@ async function startChatSdk() {
|
|
|
35124
35268
|
for (const [name, reason] of Object.entries(config.incomplete ?? {})) {
|
|
35125
35269
|
console.warn(`[chat-sdk] ${name} not started, incomplete: ${scrubSecrets(reason)}`);
|
|
35126
35270
|
}
|
|
35127
|
-
const { Chat: ChatClass } = await import("./index-
|
|
35271
|
+
const { Chat: ChatClass } = await import("./index-pe3d8jfy.js");
|
|
35128
35272
|
const state = new SqliteChatState;
|
|
35129
35273
|
startChatRelayWatcher();
|
|
35130
35274
|
await Promise.all(CHAT_SDK_ADAPTER_NAMES.map(async (name) => {
|
|
@@ -35498,9 +35642,9 @@ async function handleTaskCompleted(data) {
|
|
|
35498
35642
|
return;
|
|
35499
35643
|
const trimmed = (output ?? "").slice(0, OUTPUT_TRUNCATE_CHARS);
|
|
35500
35644
|
const ellipsized = output && output.length > OUTPUT_TRUNCATE_CHARS ? `${trimmed}…` : trimmed;
|
|
35501
|
-
const body = ellipsized ? `✅ Swarm task completed.
|
|
35645
|
+
const body = await withUiSpecFallback(taskId, ellipsized ? `✅ Swarm task completed.
|
|
35502
35646
|
|
|
35503
|
-
${ellipsized}` : "✅ Swarm task completed.";
|
|
35647
|
+
${ellipsized}` : "✅ Swarm task completed.");
|
|
35504
35648
|
await postLifecycleComment(taskId, "task.completed", body);
|
|
35505
35649
|
}
|
|
35506
35650
|
async function handleTaskFailed(data) {
|
|
@@ -35558,6 +35702,7 @@ function shouldSkipForLoopPrevention(sync) {
|
|
|
35558
35702
|
var subscribed3 = false, LOOP_PREVENTION_WINDOW_MS = 5000, OUTPUT_TRUNCATE_CHARS = 4000, onTaskCreated2, onTaskCompleted3, onTaskFailed2, onTaskCancelled2;
|
|
35559
35703
|
var init_outbound3 = __esm(() => {
|
|
35560
35704
|
init_tracker();
|
|
35705
|
+
init_fallback();
|
|
35561
35706
|
init_secret_scrubber();
|
|
35562
35707
|
init_event_bus();
|
|
35563
35708
|
init_client2();
|
|
@@ -36032,7 +36177,7 @@ async function notifySlack(text) {
|
|
|
36032
36177
|
return;
|
|
36033
36178
|
}
|
|
36034
36179
|
try {
|
|
36035
|
-
const { getSlackApp } = await import("./app-
|
|
36180
|
+
const { getSlackApp } = await import("./app-wb7w45dq.js");
|
|
36036
36181
|
const app = getSlackApp();
|
|
36037
36182
|
if (!app) {
|
|
36038
36183
|
console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
|
|
@@ -36103,7 +36248,7 @@ async function deleteJiraWebhook(webhookId) {
|
|
|
36103
36248
|
console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
|
|
36104
36249
|
}
|
|
36105
36250
|
async function overwriteWebhookIds(next) {
|
|
36106
|
-
const { getDbClient } = await import("./db-
|
|
36251
|
+
const { getDbClient } = await import("./db-wcw0b2j8.js");
|
|
36107
36252
|
await getDbClient().transaction(async (tx) => {
|
|
36108
36253
|
const row = await tx.get("SELECT metadata FROM oauth_apps WHERE provider = 'jira'");
|
|
36109
36254
|
if (!row) {
|
|
@@ -108693,7 +108838,7 @@ async function handleTaskCompleted2(data) {
|
|
|
108693
108838
|
if (shouldSkipForLoopPrevention2(sync))
|
|
108694
108839
|
return;
|
|
108695
108840
|
const sessionId = taskSessionMap.get(taskId);
|
|
108696
|
-
const body = output?.trim() ? formatLinearOutcomeBody(output, taskId) : "Task completed.";
|
|
108841
|
+
const body = output?.trim() ? formatLinearOutcomeBody(await withUiSpecFallback(taskId, output), taskId) : await withUiSpecFallback(taskId, "Task completed.");
|
|
108697
108842
|
if (sessionId) {
|
|
108698
108843
|
endAgentSession(sessionId, body, "response").catch((err) => {
|
|
108699
108844
|
console.error(`[Linear Outbound] Failed to end AgentSession for task ${taskId}:`, err);
|
|
@@ -108808,6 +108953,7 @@ var subscribed4 = false, LOOP_PREVENTION_WINDOW_MS2 = 5000, onTaskCreated3, onTa
|
|
|
108808
108953
|
var init_outbound4 = __esm(() => {
|
|
108809
108954
|
init_tracker();
|
|
108810
108955
|
init_ensure_token();
|
|
108956
|
+
init_fallback();
|
|
108811
108957
|
init_secret_scrubber();
|
|
108812
108958
|
init_event_bus();
|
|
108813
108959
|
init_client3();
|
|
@@ -109422,7 +109568,7 @@ async function resolveHttpRequestAuth(req, apiKey, options = {}) {
|
|
|
109422
109568
|
return null;
|
|
109423
109569
|
}
|
|
109424
109570
|
function isActiveUser(user) {
|
|
109425
|
-
return !!user && user.status === "active";
|
|
109571
|
+
return !!user && user.status === "active" && !user.mergedIntoUserId;
|
|
109426
109572
|
}
|
|
109427
109573
|
var init_auth = __esm(() => {
|
|
109428
109574
|
init_db4();
|
|
@@ -109544,7 +109690,7 @@ var ErrorResponseSchema, cachedSpec = null, SCALAR_HTML = `<!DOCTYPE html>
|
|
|
109544
109690
|
</body>
|
|
109545
109691
|
</html>`;
|
|
109546
109692
|
var init_openapi = __esm(() => {
|
|
109547
|
-
|
|
109693
|
+
init_dist9();
|
|
109548
109694
|
init_constants3();
|
|
109549
109695
|
init_zod_openapi();
|
|
109550
109696
|
init_route_def();
|
|
@@ -109552,11 +109698,11 @@ var init_openapi = __esm(() => {
|
|
|
109552
109698
|
});
|
|
109553
109699
|
|
|
109554
109700
|
// src/http/core.ts
|
|
109555
|
-
function
|
|
109701
|
+
function getDeploymentEnvValue2(key) {
|
|
109556
109702
|
const tracked = injectedEnvOriginals.get(key);
|
|
109557
109703
|
return tracked && process.env[key] === tracked.injected ? tracked.original : process.env[key];
|
|
109558
109704
|
}
|
|
109559
|
-
async function
|
|
109705
|
+
async function loadGlobalConfigsIntoEnv2(override = false) {
|
|
109560
109706
|
const globalConfigs = await getInjectableGlobalConfigs2();
|
|
109561
109707
|
const updated = [];
|
|
109562
109708
|
const liveKeys = new Set;
|
|
@@ -109594,13 +109740,13 @@ async function loadGlobalConfigsIntoEnv(override = false) {
|
|
|
109594
109740
|
}
|
|
109595
109741
|
return updated;
|
|
109596
109742
|
}
|
|
109597
|
-
async function
|
|
109743
|
+
async function reloadGlobalConfigsAndIntegrations2() {
|
|
109598
109744
|
return runWithoutRequestAuth(() => runSlackLifecycleExclusive(() => reloadGlobalConfigsAndIntegrationsInner()));
|
|
109599
109745
|
}
|
|
109600
109746
|
async function reloadGlobalConfigsAndIntegrationsInner() {
|
|
109601
|
-
const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-
|
|
109747
|
+
const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-01ns1pkw.js");
|
|
109602
109748
|
const wasEmbeddingsConfigured = getEmbeddingProvider().isConfigured();
|
|
109603
|
-
const updated = await
|
|
109749
|
+
const updated = await loadGlobalConfigsIntoEnv2(true);
|
|
109604
109750
|
await syncTelemetryEnabled("settings").catch((err) => {
|
|
109605
109751
|
console.error("[config-reload] telemetry re-init failed (non-fatal):", err);
|
|
109606
109752
|
});
|
|
@@ -109614,7 +109760,7 @@ async function reloadGlobalConfigsAndIntegrationsInner() {
|
|
|
109614
109760
|
integrations.push("embeddings");
|
|
109615
109761
|
}
|
|
109616
109762
|
if (isEmbeddingsConfigured) {
|
|
109617
|
-
import("./embedding-space-
|
|
109763
|
+
import("./embedding-space-e48xchqa.js").then(({ runEmbeddingMaintenance }) => runEmbeddingMaintenance({ backfill: !wasEmbeddingsConfigured })).catch((err) => {
|
|
109618
109764
|
console.error("[config-reload] embedding maintenance failed (non-fatal):", err);
|
|
109619
109765
|
});
|
|
109620
109766
|
}
|
|
@@ -109657,7 +109803,7 @@ async function reloadGlobalConfigsAndIntegrationsInner() {
|
|
|
109657
109803
|
integrationsReinitialized: integrations
|
|
109658
109804
|
};
|
|
109659
109805
|
}
|
|
109660
|
-
function
|
|
109806
|
+
function scheduleIntegrationsReload2(delayMs = AUTO_RELOAD_DEBOUNCE_MS) {
|
|
109661
109807
|
if (inFlightReload) {
|
|
109662
109808
|
reloadRerunRequested = true;
|
|
109663
109809
|
return;
|
|
@@ -109668,7 +109814,7 @@ function scheduleIntegrationsReload(delayMs = AUTO_RELOAD_DEBOUNCE_MS) {
|
|
|
109668
109814
|
pendingReloadTimer = setTimeout(() => {
|
|
109669
109815
|
pendingReloadTimer = null;
|
|
109670
109816
|
autoReloadInvocations += 1;
|
|
109671
|
-
inFlightReload =
|
|
109817
|
+
inFlightReload = reloadGlobalConfigsAndIntegrations2().then((r) => {
|
|
109672
109818
|
console.log(`[auto-reload] Loaded ${r.configsLoaded} config(s), re-initialized: ${r.integrationsReinitialized.join(", ") || "none"}`);
|
|
109673
109819
|
return r;
|
|
109674
109820
|
}).catch((err) => {
|
|
@@ -109679,7 +109825,7 @@ function scheduleIntegrationsReload(delayMs = AUTO_RELOAD_DEBOUNCE_MS) {
|
|
|
109679
109825
|
inFlightReload = null;
|
|
109680
109826
|
if (reloadRerunRequested) {
|
|
109681
109827
|
reloadRerunRequested = false;
|
|
109682
|
-
|
|
109828
|
+
scheduleIntegrationsReload2(delayMs);
|
|
109683
109829
|
}
|
|
109684
109830
|
});
|
|
109685
109831
|
}, delayMs);
|
|
@@ -109688,7 +109834,7 @@ function singleHeader2(req, name) {
|
|
|
109688
109834
|
const raw = req.headers[name];
|
|
109689
109835
|
return Array.isArray(raw) ? raw[0] : raw;
|
|
109690
109836
|
}
|
|
109691
|
-
async function
|
|
109837
|
+
async function handleCore2(req, res, myAgentId, apiKey) {
|
|
109692
109838
|
beginRequestAuthScope();
|
|
109693
109839
|
let auth = await resolveHttpRequestAuth(req, apiKey);
|
|
109694
109840
|
if (auth?.kind === "controller") {
|
|
@@ -109824,7 +109970,7 @@ async function handleCore(req, res, myAgentId, apiKey) {
|
|
|
109824
109970
|
}
|
|
109825
109971
|
if (req.method === "POST" && req.url === "/internal/reload-config") {
|
|
109826
109972
|
try {
|
|
109827
|
-
const result = await
|
|
109973
|
+
const result = await reloadGlobalConfigsAndIntegrations2();
|
|
109828
109974
|
console.log(`[reload-config] Loaded ${result.configsLoaded} config(s), re-initialized: ${result.integrationsReinitialized.join(", ") || "none"}`);
|
|
109829
109975
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
109830
109976
|
res.end(JSON.stringify({ success: true, ...result }));
|
|
@@ -115395,1903 +115541,6 @@ var init_chat_open_dm = __esm(() => {
|
|
|
115395
115541
|
init_utils();
|
|
115396
115542
|
});
|
|
115397
115543
|
|
|
115398
|
-
// node_modules/@json-render/chat/node_modules/@json-render/core/dist/chunk-FVP4K5MD.mjs
|
|
115399
|
-
function unescapeJsonPointer(token) {
|
|
115400
|
-
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
115401
|
-
}
|
|
115402
|
-
function parseJsonPointer(path) {
|
|
115403
|
-
const raw = path.startsWith("/") ? path.slice(1).split("/") : path.split("/");
|
|
115404
|
-
return raw.map(unescapeJsonPointer);
|
|
115405
|
-
}
|
|
115406
|
-
function getByPath(obj, path) {
|
|
115407
|
-
if (!path || path === "/") {
|
|
115408
|
-
return obj;
|
|
115409
|
-
}
|
|
115410
|
-
const segments = parseJsonPointer(path);
|
|
115411
|
-
let current = obj;
|
|
115412
|
-
for (const segment of segments) {
|
|
115413
|
-
if (current === null || current === undefined) {
|
|
115414
|
-
return;
|
|
115415
|
-
}
|
|
115416
|
-
if (Array.isArray(current)) {
|
|
115417
|
-
const index = parseInt(segment, 10);
|
|
115418
|
-
current = current[index];
|
|
115419
|
-
} else if (typeof current === "object" && Object.hasOwn(current, segment)) {
|
|
115420
|
-
current = current[segment];
|
|
115421
|
-
} else {
|
|
115422
|
-
return;
|
|
115423
|
-
}
|
|
115424
|
-
}
|
|
115425
|
-
return current;
|
|
115426
|
-
}
|
|
115427
|
-
function resolveRepeatStatePath(statePath, repeatBasePath) {
|
|
115428
|
-
if (typeof statePath === "string") {
|
|
115429
|
-
return statePath;
|
|
115430
|
-
}
|
|
115431
|
-
if (repeatBasePath == null) {
|
|
115432
|
-
return;
|
|
115433
|
-
}
|
|
115434
|
-
if (statePath.$item === "" || statePath.$item === "/") {
|
|
115435
|
-
return repeatBasePath;
|
|
115436
|
-
}
|
|
115437
|
-
return joinStatePath(repeatBasePath, statePath.$item);
|
|
115438
|
-
}
|
|
115439
|
-
function resolveRepeatItemStatePath(statePath, index) {
|
|
115440
|
-
return joinStatePath(statePath, String(index));
|
|
115441
|
-
}
|
|
115442
|
-
function joinStatePath(basePath, childPath) {
|
|
115443
|
-
const child = childPath.startsWith("/") ? childPath.slice(1) : childPath;
|
|
115444
|
-
if (basePath === "" || basePath === "/") {
|
|
115445
|
-
return `/${child}`;
|
|
115446
|
-
}
|
|
115447
|
-
return `${basePath}/${child}`;
|
|
115448
|
-
}
|
|
115449
|
-
var DynamicValueSchema, DynamicStringSchema, DynamicNumberSchema, DynamicBooleanSchema, SPEC_DATA_PART = "spec", SPEC_DATA_PART_TYPE;
|
|
115450
|
-
var init_chunk_FVP4K5MD = __esm(() => {
|
|
115451
|
-
init_zod();
|
|
115452
|
-
DynamicValueSchema = union3([
|
|
115453
|
-
string2(),
|
|
115454
|
-
number2(),
|
|
115455
|
-
boolean(),
|
|
115456
|
-
_null(),
|
|
115457
|
-
object2({ $state: string2() })
|
|
115458
|
-
]);
|
|
115459
|
-
DynamicStringSchema = union3([
|
|
115460
|
-
string2(),
|
|
115461
|
-
object2({ $state: string2() })
|
|
115462
|
-
]);
|
|
115463
|
-
DynamicNumberSchema = union3([
|
|
115464
|
-
number2(),
|
|
115465
|
-
object2({ $state: string2() })
|
|
115466
|
-
]);
|
|
115467
|
-
DynamicBooleanSchema = union3([
|
|
115468
|
-
boolean(),
|
|
115469
|
-
object2({ $state: string2() })
|
|
115470
|
-
]);
|
|
115471
|
-
SPEC_DATA_PART_TYPE = `data-${SPEC_DATA_PART}`;
|
|
115472
|
-
});
|
|
115473
|
-
|
|
115474
|
-
// node_modules/@json-render/chat/node_modules/@json-render/core/dist/index.mjs
|
|
115475
|
-
function conditionUsesItemScope(condition) {
|
|
115476
|
-
if (condition === undefined || typeof condition === "boolean")
|
|
115477
|
-
return false;
|
|
115478
|
-
if (Array.isArray(condition))
|
|
115479
|
-
return condition.some(conditionUsesItemScope);
|
|
115480
|
-
if (typeof condition !== "object" || condition === null)
|
|
115481
|
-
return false;
|
|
115482
|
-
if ("$item" in condition || "$index" in condition)
|
|
115483
|
-
return true;
|
|
115484
|
-
if ("$and" in condition)
|
|
115485
|
-
return condition.$and.some(conditionUsesItemScope);
|
|
115486
|
-
if ("$or" in condition)
|
|
115487
|
-
return condition.$or.some(conditionUsesItemScope);
|
|
115488
|
-
return false;
|
|
115489
|
-
}
|
|
115490
|
-
function splitRepeatVisibility(condition) {
|
|
115491
|
-
if (condition === undefined || !conditionUsesItemScope(condition)) {
|
|
115492
|
-
return { container: condition, itemFilter: undefined };
|
|
115493
|
-
}
|
|
115494
|
-
const partition = (parts) => {
|
|
115495
|
-
const container = parts.filter((part) => !conditionUsesItemScope(part));
|
|
115496
|
-
const item = parts.filter((part) => conditionUsesItemScope(part));
|
|
115497
|
-
return {
|
|
115498
|
-
container: container.length > 0 ? { $and: container } : undefined,
|
|
115499
|
-
itemFilter: item.length > 0 ? { $and: item } : undefined
|
|
115500
|
-
};
|
|
115501
|
-
};
|
|
115502
|
-
if (Array.isArray(condition))
|
|
115503
|
-
return partition(condition);
|
|
115504
|
-
if (typeof condition === "object" && condition !== null && "$and" in condition) {
|
|
115505
|
-
return partition(condition.$and);
|
|
115506
|
-
}
|
|
115507
|
-
return { container: undefined, itemFilter: condition };
|
|
115508
|
-
}
|
|
115509
|
-
function resolveComparisonValue(value, ctx) {
|
|
115510
|
-
if (typeof value === "object" && value !== null) {
|
|
115511
|
-
if ("$state" in value && typeof value.$state === "string") {
|
|
115512
|
-
return getByPath(ctx.stateModel, value.$state);
|
|
115513
|
-
}
|
|
115514
|
-
}
|
|
115515
|
-
return value;
|
|
115516
|
-
}
|
|
115517
|
-
function isItemCondition(cond) {
|
|
115518
|
-
return "$item" in cond;
|
|
115519
|
-
}
|
|
115520
|
-
function isIndexCondition(cond) {
|
|
115521
|
-
return "$index" in cond;
|
|
115522
|
-
}
|
|
115523
|
-
function resolveConditionValue(cond, ctx) {
|
|
115524
|
-
if (isIndexCondition(cond)) {
|
|
115525
|
-
return ctx.repeatIndex;
|
|
115526
|
-
}
|
|
115527
|
-
if (isItemCondition(cond)) {
|
|
115528
|
-
if (ctx.repeatItem === undefined)
|
|
115529
|
-
return;
|
|
115530
|
-
return cond.$item === "" ? ctx.repeatItem : getByPath(ctx.repeatItem, cond.$item);
|
|
115531
|
-
}
|
|
115532
|
-
return getByPath(ctx.stateModel, cond.$state);
|
|
115533
|
-
}
|
|
115534
|
-
function evaluateCondition2(cond, ctx) {
|
|
115535
|
-
const value = resolveConditionValue(cond, ctx);
|
|
115536
|
-
let result;
|
|
115537
|
-
if (cond.eq !== undefined) {
|
|
115538
|
-
const rhs = resolveComparisonValue(cond.eq, ctx);
|
|
115539
|
-
result = value === rhs;
|
|
115540
|
-
} else if (cond.neq !== undefined) {
|
|
115541
|
-
const rhs = resolveComparisonValue(cond.neq, ctx);
|
|
115542
|
-
result = value !== rhs;
|
|
115543
|
-
} else if (cond.gt !== undefined) {
|
|
115544
|
-
const rhs = resolveComparisonValue(cond.gt, ctx);
|
|
115545
|
-
result = typeof value === "number" && typeof rhs === "number" ? value > rhs : false;
|
|
115546
|
-
} else if (cond.gte !== undefined) {
|
|
115547
|
-
const rhs = resolveComparisonValue(cond.gte, ctx);
|
|
115548
|
-
result = typeof value === "number" && typeof rhs === "number" ? value >= rhs : false;
|
|
115549
|
-
} else if (cond.lt !== undefined) {
|
|
115550
|
-
const rhs = resolveComparisonValue(cond.lt, ctx);
|
|
115551
|
-
result = typeof value === "number" && typeof rhs === "number" ? value < rhs : false;
|
|
115552
|
-
} else if (cond.lte !== undefined) {
|
|
115553
|
-
const rhs = resolveComparisonValue(cond.lte, ctx);
|
|
115554
|
-
result = typeof value === "number" && typeof rhs === "number" ? value <= rhs : false;
|
|
115555
|
-
} else {
|
|
115556
|
-
result = Boolean(value);
|
|
115557
|
-
}
|
|
115558
|
-
return cond.not === true ? !result : result;
|
|
115559
|
-
}
|
|
115560
|
-
function isAndCondition(condition) {
|
|
115561
|
-
return typeof condition === "object" && condition !== null && !Array.isArray(condition) && "$and" in condition;
|
|
115562
|
-
}
|
|
115563
|
-
function isOrCondition(condition) {
|
|
115564
|
-
return typeof condition === "object" && condition !== null && !Array.isArray(condition) && "$or" in condition;
|
|
115565
|
-
}
|
|
115566
|
-
function evaluateVisibility(condition, ctx) {
|
|
115567
|
-
if (condition === undefined) {
|
|
115568
|
-
return true;
|
|
115569
|
-
}
|
|
115570
|
-
if (typeof condition === "boolean") {
|
|
115571
|
-
return condition;
|
|
115572
|
-
}
|
|
115573
|
-
if (Array.isArray(condition)) {
|
|
115574
|
-
return condition.every((c) => evaluateCondition2(c, ctx));
|
|
115575
|
-
}
|
|
115576
|
-
if (isAndCondition(condition)) {
|
|
115577
|
-
return condition.$and.every((child) => evaluateVisibility(child, ctx));
|
|
115578
|
-
}
|
|
115579
|
-
if (isOrCondition(condition)) {
|
|
115580
|
-
return condition.$or.some((child) => evaluateVisibility(child, ctx));
|
|
115581
|
-
}
|
|
115582
|
-
return evaluateCondition2(condition, ctx);
|
|
115583
|
-
}
|
|
115584
|
-
function findDirective(value, directives) {
|
|
115585
|
-
if (!directives || directives.size === 0)
|
|
115586
|
-
return;
|
|
115587
|
-
let match;
|
|
115588
|
-
for (const [key, def] of directives) {
|
|
115589
|
-
if (key in value) {
|
|
115590
|
-
if (match) {
|
|
115591
|
-
throw new Error(`Ambiguous directive: object has multiple directive keys ("${match.name}" and "${key}")`);
|
|
115592
|
-
}
|
|
115593
|
-
match = def;
|
|
115594
|
-
}
|
|
115595
|
-
}
|
|
115596
|
-
return match;
|
|
115597
|
-
}
|
|
115598
|
-
function isStateExpression(value) {
|
|
115599
|
-
return typeof value === "object" && value !== null && "$state" in value && typeof value.$state === "string";
|
|
115600
|
-
}
|
|
115601
|
-
function isItemExpression(value) {
|
|
115602
|
-
return typeof value === "object" && value !== null && "$item" in value && typeof value.$item === "string";
|
|
115603
|
-
}
|
|
115604
|
-
function isIndexExpression(value) {
|
|
115605
|
-
return typeof value === "object" && value !== null && "$index" in value && value.$index === true;
|
|
115606
|
-
}
|
|
115607
|
-
function isBindStateExpression(value) {
|
|
115608
|
-
return typeof value === "object" && value !== null && "$bindState" in value && typeof value.$bindState === "string";
|
|
115609
|
-
}
|
|
115610
|
-
function isBindItemExpression(value) {
|
|
115611
|
-
return typeof value === "object" && value !== null && "$bindItem" in value && typeof value.$bindItem === "string";
|
|
115612
|
-
}
|
|
115613
|
-
function isCondExpression(value) {
|
|
115614
|
-
return typeof value === "object" && value !== null && "$cond" in value && "$then" in value && "$else" in value;
|
|
115615
|
-
}
|
|
115616
|
-
function isComputedExpression(value) {
|
|
115617
|
-
return typeof value === "object" && value !== null && "$computed" in value && typeof value.$computed === "string";
|
|
115618
|
-
}
|
|
115619
|
-
function isTemplateExpression(value) {
|
|
115620
|
-
return typeof value === "object" && value !== null && "$template" in value && typeof value.$template === "string";
|
|
115621
|
-
}
|
|
115622
|
-
function resolveBindItemPath(itemPath, ctx) {
|
|
115623
|
-
if (ctx.repeatBasePath == null) {
|
|
115624
|
-
console.warn(`$bindItem used outside repeat scope: "${itemPath}"`);
|
|
115625
|
-
return;
|
|
115626
|
-
}
|
|
115627
|
-
if (itemPath === "")
|
|
115628
|
-
return ctx.repeatBasePath;
|
|
115629
|
-
return ctx.repeatBasePath + "/" + itemPath;
|
|
115630
|
-
}
|
|
115631
|
-
function resolvePropValue(value, ctx) {
|
|
115632
|
-
if (value === null || value === undefined) {
|
|
115633
|
-
return value;
|
|
115634
|
-
}
|
|
115635
|
-
if (isStateExpression(value)) {
|
|
115636
|
-
return getByPath(ctx.stateModel, value.$state);
|
|
115637
|
-
}
|
|
115638
|
-
if (isItemExpression(value)) {
|
|
115639
|
-
if (ctx.repeatItem === undefined)
|
|
115640
|
-
return;
|
|
115641
|
-
return value.$item === "" ? ctx.repeatItem : getByPath(ctx.repeatItem, value.$item);
|
|
115642
|
-
}
|
|
115643
|
-
if (isIndexExpression(value)) {
|
|
115644
|
-
return ctx.repeatIndex;
|
|
115645
|
-
}
|
|
115646
|
-
if (isBindStateExpression(value)) {
|
|
115647
|
-
return getByPath(ctx.stateModel, value.$bindState);
|
|
115648
|
-
}
|
|
115649
|
-
if (isBindItemExpression(value)) {
|
|
115650
|
-
const resolvedPath = resolveBindItemPath(value.$bindItem, ctx);
|
|
115651
|
-
if (resolvedPath === undefined)
|
|
115652
|
-
return;
|
|
115653
|
-
return getByPath(ctx.stateModel, resolvedPath);
|
|
115654
|
-
}
|
|
115655
|
-
if (isCondExpression(value)) {
|
|
115656
|
-
const result = evaluateVisibility(value.$cond, ctx);
|
|
115657
|
-
return resolvePropValue(result ? value.$then : value.$else, ctx);
|
|
115658
|
-
}
|
|
115659
|
-
if (isComputedExpression(value)) {
|
|
115660
|
-
const fn = ctx.functions?.[value.$computed];
|
|
115661
|
-
if (!fn) {
|
|
115662
|
-
if (!warnedComputedFns.has(value.$computed)) {
|
|
115663
|
-
if (warnedComputedFns.size < WARNED_COMPUTED_MAX) {
|
|
115664
|
-
warnedComputedFns.add(value.$computed);
|
|
115665
|
-
}
|
|
115666
|
-
console.warn(`Unknown $computed function: "${value.$computed}"`);
|
|
115667
|
-
}
|
|
115668
|
-
return;
|
|
115669
|
-
}
|
|
115670
|
-
const resolvedArgs = {};
|
|
115671
|
-
if (value.args) {
|
|
115672
|
-
for (const [key, arg] of Object.entries(value.args)) {
|
|
115673
|
-
resolvedArgs[key] = resolvePropValue(arg, ctx);
|
|
115674
|
-
}
|
|
115675
|
-
}
|
|
115676
|
-
return fn(resolvedArgs);
|
|
115677
|
-
}
|
|
115678
|
-
if (isTemplateExpression(value)) {
|
|
115679
|
-
return value.$template.replace(/\$\{([^}]+)\}/g, (_match, rawPath) => {
|
|
115680
|
-
if (rawPath.startsWith("/")) {
|
|
115681
|
-
const resolved2 = getByPath(ctx.stateModel, rawPath);
|
|
115682
|
-
return resolved2 != null ? String(resolved2) : "";
|
|
115683
|
-
}
|
|
115684
|
-
if (ctx.repeatItem !== undefined) {
|
|
115685
|
-
const fromItem = getByPath(ctx.repeatItem, rawPath);
|
|
115686
|
-
if (fromItem != null)
|
|
115687
|
-
return String(fromItem);
|
|
115688
|
-
}
|
|
115689
|
-
const resolved = getByPath(ctx.stateModel, "/" + rawPath);
|
|
115690
|
-
return resolved != null ? String(resolved) : "";
|
|
115691
|
-
});
|
|
115692
|
-
}
|
|
115693
|
-
if (Array.isArray(value)) {
|
|
115694
|
-
return value.map((item) => resolvePropValue(item, ctx));
|
|
115695
|
-
}
|
|
115696
|
-
if (typeof value === "object") {
|
|
115697
|
-
const directive = findDirective(value, ctx.directives);
|
|
115698
|
-
if (directive) {
|
|
115699
|
-
return directive.resolve(value, ctx);
|
|
115700
|
-
}
|
|
115701
|
-
const resolved = {};
|
|
115702
|
-
for (const [key, val] of Object.entries(value)) {
|
|
115703
|
-
resolved[key] = resolvePropValue(val, ctx);
|
|
115704
|
-
}
|
|
115705
|
-
return resolved;
|
|
115706
|
-
}
|
|
115707
|
-
return value;
|
|
115708
|
-
}
|
|
115709
|
-
function resolveElementProps(props, ctx) {
|
|
115710
|
-
const resolved = {};
|
|
115711
|
-
for (const [key, value] of Object.entries(props)) {
|
|
115712
|
-
resolved[key] = resolvePropValue(value, ctx);
|
|
115713
|
-
}
|
|
115714
|
-
return resolved;
|
|
115715
|
-
}
|
|
115716
|
-
function normalizeModes(config) {
|
|
115717
|
-
if (!config?.modes?.length)
|
|
115718
|
-
return DEFAULT_MODES;
|
|
115719
|
-
return config.modes;
|
|
115720
|
-
}
|
|
115721
|
-
function jsonPatchInstructions() {
|
|
115722
|
-
return [
|
|
115723
|
-
"PATCH MODE (RFC 6902 JSON Patch):",
|
|
115724
|
-
"Output one JSON object per line. Each line is a patch operation.",
|
|
115725
|
-
'- Add: {"op":"add","path":"/elements/new-key","value":{...}}',
|
|
115726
|
-
'- Replace: {"op":"replace","path":"/elements/existing-key","value":{...}}',
|
|
115727
|
-
'- Remove: {"op":"remove","path":"/elements/old-key"}',
|
|
115728
|
-
"Only output patches for what needs to change."
|
|
115729
|
-
].join(`
|
|
115730
|
-
`);
|
|
115731
|
-
}
|
|
115732
|
-
function jsonMergeInstructions() {
|
|
115733
|
-
return [
|
|
115734
|
-
"MERGE MODE (RFC 7396 JSON Merge Patch):",
|
|
115735
|
-
"Output a single JSON object on one line with __json_edit set to true.",
|
|
115736
|
-
"Include only the keys that changed. Unmentioned keys are preserved.",
|
|
115737
|
-
"Set a key to null to delete it.",
|
|
115738
|
-
"",
|
|
115739
|
-
"Example (update a title and add an element):",
|
|
115740
|
-
'{"__json_edit":true,"elements":{"main":{"props":{"title":"New Title"}},"new-el":{"type":"Card","props":{},"children":[]}}}',
|
|
115741
|
-
"",
|
|
115742
|
-
"Example (delete an element):",
|
|
115743
|
-
'{"__json_edit":true,"elements":{"old-widget":null}}'
|
|
115744
|
-
].join(`
|
|
115745
|
-
`);
|
|
115746
|
-
}
|
|
115747
|
-
function jsonDiffInstructions() {
|
|
115748
|
-
return [
|
|
115749
|
-
"DIFF MODE (unified diff):",
|
|
115750
|
-
"Output a unified diff inside a ```diff code fence.",
|
|
115751
|
-
"The diff applies against the JSON-serialized current spec.",
|
|
115752
|
-
"",
|
|
115753
|
-
"Example:",
|
|
115754
|
-
"```diff",
|
|
115755
|
-
"--- a/spec.json",
|
|
115756
|
-
"+++ b/spec.json",
|
|
115757
|
-
"@@ -3,1 +3,1 @@",
|
|
115758
|
-
'- "title": "Login"',
|
|
115759
|
-
'+ "title": "Welcome Back"',
|
|
115760
|
-
"```"
|
|
115761
|
-
].join(`
|
|
115762
|
-
`);
|
|
115763
|
-
}
|
|
115764
|
-
function yamlPatchInstructions() {
|
|
115765
|
-
return [
|
|
115766
|
-
"PATCH MODE (RFC 6902 JSON Patch):",
|
|
115767
|
-
"Output RFC 6902 JSON Patch lines inside a ```yaml-patch code fence.",
|
|
115768
|
-
"Each line is one JSON patch operation.",
|
|
115769
|
-
"",
|
|
115770
|
-
"Example:",
|
|
115771
|
-
"```yaml-patch",
|
|
115772
|
-
'{"op":"replace","path":"/elements/main/props/title","value":"New Title"}',
|
|
115773
|
-
'{"op":"add","path":"/elements/new-el","value":{"type":"Card","props":{},"children":[]}}',
|
|
115774
|
-
"```"
|
|
115775
|
-
].join(`
|
|
115776
|
-
`);
|
|
115777
|
-
}
|
|
115778
|
-
function yamlMergeInstructions() {
|
|
115779
|
-
return [
|
|
115780
|
-
"MERGE MODE (RFC 7396 JSON Merge Patch):",
|
|
115781
|
-
"Output only the changed parts in a ```yaml-edit code fence.",
|
|
115782
|
-
"Uses deep merge semantics: only keys you include are updated. Unmentioned elements and props are preserved.",
|
|
115783
|
-
"Set a key to null to delete it.",
|
|
115784
|
-
"",
|
|
115785
|
-
"Example edit (update title, add a new element):",
|
|
115786
|
-
"```yaml-edit",
|
|
115787
|
-
"elements:",
|
|
115788
|
-
" main:",
|
|
115789
|
-
" props:",
|
|
115790
|
-
" title: Updated Title",
|
|
115791
|
-
" new-chart:",
|
|
115792
|
-
" type: Card",
|
|
115793
|
-
" props: {}",
|
|
115794
|
-
" children: []",
|
|
115795
|
-
"```",
|
|
115796
|
-
"",
|
|
115797
|
-
"Example deletion:",
|
|
115798
|
-
"```yaml-edit",
|
|
115799
|
-
"elements:",
|
|
115800
|
-
" old-widget: null",
|
|
115801
|
-
"```"
|
|
115802
|
-
].join(`
|
|
115803
|
-
`);
|
|
115804
|
-
}
|
|
115805
|
-
function yamlDiffInstructions() {
|
|
115806
|
-
return [
|
|
115807
|
-
"DIFF MODE (unified diff):",
|
|
115808
|
-
"Output a unified diff inside a ```diff code fence.",
|
|
115809
|
-
"The diff applies against the YAML-serialized current spec.",
|
|
115810
|
-
"",
|
|
115811
|
-
"Example:",
|
|
115812
|
-
"```diff",
|
|
115813
|
-
"--- a/spec.yaml",
|
|
115814
|
-
"+++ b/spec.yaml",
|
|
115815
|
-
"@@ -6,1 +6,1 @@",
|
|
115816
|
-
"- title: Login",
|
|
115817
|
-
"+ title: Welcome Back",
|
|
115818
|
-
"```"
|
|
115819
|
-
].join(`
|
|
115820
|
-
`);
|
|
115821
|
-
}
|
|
115822
|
-
function modeSelectionGuidance(modes) {
|
|
115823
|
-
if (modes.length === 1)
|
|
115824
|
-
return "";
|
|
115825
|
-
const parts = ["Choose the best edit strategy for the requested change:"];
|
|
115826
|
-
if (modes.includes("patch")) {
|
|
115827
|
-
parts.push("- PATCH: best for precise, targeted single-field updates");
|
|
115828
|
-
}
|
|
115829
|
-
if (modes.includes("merge")) {
|
|
115830
|
-
parts.push("- MERGE: best for structural changes (add/remove elements, reparent children, update multiple props at once)");
|
|
115831
|
-
}
|
|
115832
|
-
if (modes.includes("diff")) {
|
|
115833
|
-
parts.push("- DIFF: best for small text-level changes when you can see the exact lines to change");
|
|
115834
|
-
}
|
|
115835
|
-
return parts.join(`
|
|
115836
|
-
`);
|
|
115837
|
-
}
|
|
115838
|
-
function buildEditInstructions(config, format) {
|
|
115839
|
-
const modes = normalizeModes(config);
|
|
115840
|
-
const sections = [];
|
|
115841
|
-
sections.push("EDITING EXISTING SPECS:");
|
|
115842
|
-
sections.push("");
|
|
115843
|
-
const guidance = modeSelectionGuidance(modes);
|
|
115844
|
-
if (guidance) {
|
|
115845
|
-
sections.push(guidance);
|
|
115846
|
-
sections.push("");
|
|
115847
|
-
}
|
|
115848
|
-
for (const mode of modes) {
|
|
115849
|
-
if (format === "json") {
|
|
115850
|
-
switch (mode) {
|
|
115851
|
-
case "patch":
|
|
115852
|
-
sections.push(jsonPatchInstructions());
|
|
115853
|
-
break;
|
|
115854
|
-
case "merge":
|
|
115855
|
-
sections.push(jsonMergeInstructions());
|
|
115856
|
-
break;
|
|
115857
|
-
case "diff":
|
|
115858
|
-
sections.push(jsonDiffInstructions());
|
|
115859
|
-
break;
|
|
115860
|
-
}
|
|
115861
|
-
} else {
|
|
115862
|
-
switch (mode) {
|
|
115863
|
-
case "patch":
|
|
115864
|
-
sections.push(yamlPatchInstructions());
|
|
115865
|
-
break;
|
|
115866
|
-
case "merge":
|
|
115867
|
-
sections.push(yamlMergeInstructions());
|
|
115868
|
-
break;
|
|
115869
|
-
case "diff":
|
|
115870
|
-
sections.push(yamlDiffInstructions());
|
|
115871
|
-
break;
|
|
115872
|
-
}
|
|
115873
|
-
}
|
|
115874
|
-
sections.push("");
|
|
115875
|
-
}
|
|
115876
|
-
return sections.join(`
|
|
115877
|
-
`);
|
|
115878
|
-
}
|
|
115879
|
-
function createBuilder() {
|
|
115880
|
-
return {
|
|
115881
|
-
string: () => ({ kind: "string" }),
|
|
115882
|
-
number: () => ({ kind: "number" }),
|
|
115883
|
-
boolean: () => ({ kind: "boolean" }),
|
|
115884
|
-
array: (item) => ({ kind: "array", inner: item }),
|
|
115885
|
-
object: (shape) => ({ kind: "object", inner: shape }),
|
|
115886
|
-
record: (value) => ({ kind: "record", inner: value }),
|
|
115887
|
-
any: () => ({ kind: "any" }),
|
|
115888
|
-
zod: () => ({ kind: "zod" }),
|
|
115889
|
-
ref: (path) => ({ kind: "ref", inner: path }),
|
|
115890
|
-
propsOf: (path) => ({ kind: "propsOf", inner: path }),
|
|
115891
|
-
map: (entryShape) => ({ kind: "map", inner: entryShape }),
|
|
115892
|
-
optional: () => ({ optional: true })
|
|
115893
|
-
};
|
|
115894
|
-
}
|
|
115895
|
-
function defineSchema(builder, options) {
|
|
115896
|
-
const s = createBuilder();
|
|
115897
|
-
const definition = builder(s);
|
|
115898
|
-
return {
|
|
115899
|
-
definition,
|
|
115900
|
-
promptTemplate: options?.promptTemplate,
|
|
115901
|
-
defaultRules: options?.defaultRules,
|
|
115902
|
-
builtInActions: options?.builtInActions,
|
|
115903
|
-
createCatalog(catalog) {
|
|
115904
|
-
return createCatalogFromSchema(this, catalog);
|
|
115905
|
-
}
|
|
115906
|
-
};
|
|
115907
|
-
}
|
|
115908
|
-
function createCatalogFromSchema(schema, catalogData) {
|
|
115909
|
-
const components = catalogData.components;
|
|
115910
|
-
const actions = catalogData.actions;
|
|
115911
|
-
const componentNames = components ? Object.keys(components) : [];
|
|
115912
|
-
const actionNames = actions ? Object.keys(actions) : [];
|
|
115913
|
-
const zodSchema = buildZodSchemaFromDefinition(schema.definition, catalogData);
|
|
115914
|
-
return {
|
|
115915
|
-
schema,
|
|
115916
|
-
data: catalogData,
|
|
115917
|
-
componentNames,
|
|
115918
|
-
actionNames,
|
|
115919
|
-
prompt(options = {}) {
|
|
115920
|
-
return generatePrompt(this, options);
|
|
115921
|
-
},
|
|
115922
|
-
jsonSchema(options = {}) {
|
|
115923
|
-
return zodToJsonSchema3(zodSchema, options.strict ?? false);
|
|
115924
|
-
},
|
|
115925
|
-
validate(spec) {
|
|
115926
|
-
const result = zodSchema.safeParse(spec);
|
|
115927
|
-
if (result.success) {
|
|
115928
|
-
return {
|
|
115929
|
-
success: true,
|
|
115930
|
-
data: result.data
|
|
115931
|
-
};
|
|
115932
|
-
}
|
|
115933
|
-
return { success: false, error: result.error };
|
|
115934
|
-
},
|
|
115935
|
-
zodSchema() {
|
|
115936
|
-
return zodSchema;
|
|
115937
|
-
},
|
|
115938
|
-
get _specType() {
|
|
115939
|
-
throw new Error("_specType is only for type inference");
|
|
115940
|
-
}
|
|
115941
|
-
};
|
|
115942
|
-
}
|
|
115943
|
-
function buildZodSchemaFromDefinition(definition, catalogData) {
|
|
115944
|
-
return buildZodType(definition.spec, catalogData);
|
|
115945
|
-
}
|
|
115946
|
-
function buildZodType(schemaType, catalogData) {
|
|
115947
|
-
switch (schemaType.kind) {
|
|
115948
|
-
case "string":
|
|
115949
|
-
return string2();
|
|
115950
|
-
case "number":
|
|
115951
|
-
return number2();
|
|
115952
|
-
case "boolean":
|
|
115953
|
-
return boolean();
|
|
115954
|
-
case "any":
|
|
115955
|
-
return any();
|
|
115956
|
-
case "array": {
|
|
115957
|
-
const inner = buildZodType(schemaType.inner, catalogData);
|
|
115958
|
-
return array2(inner);
|
|
115959
|
-
}
|
|
115960
|
-
case "object": {
|
|
115961
|
-
const shape = schemaType.inner;
|
|
115962
|
-
const zodShape = {};
|
|
115963
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
115964
|
-
let zodType = buildZodType(value, catalogData);
|
|
115965
|
-
if (value.optional) {
|
|
115966
|
-
zodType = zodType.optional();
|
|
115967
|
-
}
|
|
115968
|
-
zodShape[key] = zodType;
|
|
115969
|
-
}
|
|
115970
|
-
return object2(zodShape);
|
|
115971
|
-
}
|
|
115972
|
-
case "record": {
|
|
115973
|
-
const inner = buildZodType(schemaType.inner, catalogData);
|
|
115974
|
-
return record2(string2(), inner);
|
|
115975
|
-
}
|
|
115976
|
-
case "ref": {
|
|
115977
|
-
const path = schemaType.inner;
|
|
115978
|
-
const keys = getKeysFromPath(path, catalogData);
|
|
115979
|
-
if (keys.length === 0) {
|
|
115980
|
-
return string2();
|
|
115981
|
-
}
|
|
115982
|
-
if (keys.length === 1) {
|
|
115983
|
-
return literal2(keys[0]);
|
|
115984
|
-
}
|
|
115985
|
-
return _enum2(keys);
|
|
115986
|
-
}
|
|
115987
|
-
case "propsOf": {
|
|
115988
|
-
const path = schemaType.inner;
|
|
115989
|
-
const propsSchemas = getPropsFromPath(path, catalogData);
|
|
115990
|
-
if (propsSchemas.length === 0) {
|
|
115991
|
-
return record2(string2(), unknown());
|
|
115992
|
-
}
|
|
115993
|
-
if (propsSchemas.length === 1) {
|
|
115994
|
-
return propsSchemas[0];
|
|
115995
|
-
}
|
|
115996
|
-
return record2(string2(), unknown());
|
|
115997
|
-
}
|
|
115998
|
-
default:
|
|
115999
|
-
return unknown();
|
|
116000
|
-
}
|
|
116001
|
-
}
|
|
116002
|
-
function getKeysFromPath(path, catalogData) {
|
|
116003
|
-
const parts = path.split(".");
|
|
116004
|
-
let current = { catalog: catalogData };
|
|
116005
|
-
for (const part of parts) {
|
|
116006
|
-
if (current && typeof current === "object") {
|
|
116007
|
-
current = current[part];
|
|
116008
|
-
} else {
|
|
116009
|
-
return [];
|
|
116010
|
-
}
|
|
116011
|
-
}
|
|
116012
|
-
if (current && typeof current === "object") {
|
|
116013
|
-
return Object.keys(current);
|
|
116014
|
-
}
|
|
116015
|
-
return [];
|
|
116016
|
-
}
|
|
116017
|
-
function getPropsFromPath(path, catalogData) {
|
|
116018
|
-
const parts = path.split(".");
|
|
116019
|
-
let current = { catalog: catalogData };
|
|
116020
|
-
for (const part of parts) {
|
|
116021
|
-
if (current && typeof current === "object") {
|
|
116022
|
-
current = current[part];
|
|
116023
|
-
} else {
|
|
116024
|
-
return [];
|
|
116025
|
-
}
|
|
116026
|
-
}
|
|
116027
|
-
if (current && typeof current === "object") {
|
|
116028
|
-
return Object.values(current).map((entry) => entry.props).filter((props) => props !== undefined);
|
|
116029
|
-
}
|
|
116030
|
-
return [];
|
|
116031
|
-
}
|
|
116032
|
-
function generatePrompt(catalog, options) {
|
|
116033
|
-
if (catalog.schema.promptTemplate) {
|
|
116034
|
-
const context = {
|
|
116035
|
-
catalog: catalog.data,
|
|
116036
|
-
componentNames: catalog.componentNames,
|
|
116037
|
-
actionNames: catalog.actionNames,
|
|
116038
|
-
options,
|
|
116039
|
-
formatZodType
|
|
116040
|
-
};
|
|
116041
|
-
return catalog.schema.promptTemplate(context);
|
|
116042
|
-
}
|
|
116043
|
-
const {
|
|
116044
|
-
system = "You are a UI generator that outputs JSON.",
|
|
116045
|
-
customRules = [],
|
|
116046
|
-
mode: rawMode = "standalone"
|
|
116047
|
-
} = options;
|
|
116048
|
-
const mode = rawMode === "chat" ? (console.warn('[json-render] mode "chat" is deprecated, use "inline" instead'), "inline") : rawMode === "generate" ? (console.warn('[json-render] mode "generate" is deprecated, use "standalone" instead'), "standalone") : rawMode;
|
|
116049
|
-
const lines = [];
|
|
116050
|
-
lines.push(system);
|
|
116051
|
-
lines.push("");
|
|
116052
|
-
if (mode === "inline") {
|
|
116053
|
-
lines.push("OUTPUT FORMAT (text + JSONL, RFC 6902 JSON Patch):");
|
|
116054
|
-
lines.push("You respond conversationally. When generating UI, first write a brief explanation (1-3 sentences), then output JSONL patch lines wrapped in a ```spec code fence.");
|
|
116055
|
-
lines.push("The JSONL lines use RFC 6902 JSON Patch operations to build a UI tree. Always wrap them in a ```spec fence block:");
|
|
116056
|
-
lines.push(" ```spec");
|
|
116057
|
-
lines.push(' {"op":"add","path":"/root","value":"main"}');
|
|
116058
|
-
lines.push(' {"op":"add","path":"/elements/main","value":{"type":"Card","props":{"title":"Hello"},"children":[]}}');
|
|
116059
|
-
lines.push(" ```");
|
|
116060
|
-
lines.push("If the user's message does not require a UI (e.g. a greeting or clarifying question), respond with text only — no JSONL.");
|
|
116061
|
-
} else {
|
|
116062
|
-
lines.push("OUTPUT FORMAT (JSONL, RFC 6902 JSON Patch):");
|
|
116063
|
-
lines.push("Output JSONL (one JSON object per line) using RFC 6902 JSON Patch operations to build a UI tree.");
|
|
116064
|
-
}
|
|
116065
|
-
lines.push("Each line is a JSON patch operation (add, remove, replace). Start with /root, then stream /elements and /state patches interleaved so the UI fills in progressively as it streams.");
|
|
116066
|
-
lines.push("");
|
|
116067
|
-
lines.push("Example output (each line is a separate JSON object):");
|
|
116068
|
-
lines.push("");
|
|
116069
|
-
const allComponents = catalog.data.components;
|
|
116070
|
-
const specDefinition = catalog.schema.definition.spec;
|
|
116071
|
-
const specShape = specDefinition.kind === "object" ? specDefinition.inner : undefined;
|
|
116072
|
-
const elementsDefinition = specShape?.elements;
|
|
116073
|
-
const elementDefinition = elementsDefinition?.kind === "record" ? elementsDefinition.inner : undefined;
|
|
116074
|
-
const elementShape = elementDefinition?.kind === "object" ? elementDefinition.inner : undefined;
|
|
116075
|
-
const supportsNamedSlots = elementShape?.slots !== undefined;
|
|
116076
|
-
const cn = catalog.componentNames;
|
|
116077
|
-
const comp1 = cn[0] || "Component";
|
|
116078
|
-
const comp2 = cn.length > 1 ? cn[1] : comp1;
|
|
116079
|
-
const comp1Def = allComponents?.[comp1];
|
|
116080
|
-
const comp2Def = allComponents?.[comp2];
|
|
116081
|
-
const comp1Props = comp1Def ? getExampleProps(comp1Def) : {};
|
|
116082
|
-
const comp2Props = comp2Def ? getExampleProps(comp2Def) : {};
|
|
116083
|
-
const dynamicPropName = comp2Def?.props ? findFirstStringProp(comp2Def.props) : null;
|
|
116084
|
-
const dynamicProps = dynamicPropName ? { ...comp2Props, [dynamicPropName]: { $item: "title" } } : comp2Props;
|
|
116085
|
-
const exampleOutput = [
|
|
116086
|
-
JSON.stringify({ op: "add", path: "/root", value: "main" }),
|
|
116087
|
-
JSON.stringify({
|
|
116088
|
-
op: "add",
|
|
116089
|
-
path: "/elements/main",
|
|
116090
|
-
value: {
|
|
116091
|
-
type: comp1,
|
|
116092
|
-
props: comp1Props,
|
|
116093
|
-
children: ["child-1", "list"]
|
|
116094
|
-
}
|
|
116095
|
-
}),
|
|
116096
|
-
JSON.stringify({
|
|
116097
|
-
op: "add",
|
|
116098
|
-
path: "/elements/child-1",
|
|
116099
|
-
value: { type: comp2, props: comp2Props, children: [] }
|
|
116100
|
-
}),
|
|
116101
|
-
JSON.stringify({
|
|
116102
|
-
op: "add",
|
|
116103
|
-
path: "/elements/list",
|
|
116104
|
-
value: {
|
|
116105
|
-
type: comp1,
|
|
116106
|
-
props: comp1Props,
|
|
116107
|
-
repeat: { statePath: "/items", key: "id" },
|
|
116108
|
-
children: ["item"]
|
|
116109
|
-
}
|
|
116110
|
-
}),
|
|
116111
|
-
JSON.stringify({
|
|
116112
|
-
op: "add",
|
|
116113
|
-
path: "/elements/item",
|
|
116114
|
-
value: { type: comp2, props: dynamicProps, children: [] }
|
|
116115
|
-
}),
|
|
116116
|
-
JSON.stringify({ op: "add", path: "/state/items", value: [] }),
|
|
116117
|
-
JSON.stringify({
|
|
116118
|
-
op: "add",
|
|
116119
|
-
path: "/state/items/0",
|
|
116120
|
-
value: { id: "1", title: "First Item" }
|
|
116121
|
-
}),
|
|
116122
|
-
JSON.stringify({
|
|
116123
|
-
op: "add",
|
|
116124
|
-
path: "/state/items/1",
|
|
116125
|
-
value: { id: "2", title: "Second Item" }
|
|
116126
|
-
})
|
|
116127
|
-
].join(`
|
|
116128
|
-
`);
|
|
116129
|
-
lines.push(`${exampleOutput}
|
|
116130
|
-
|
|
116131
|
-
Note: state patches appear right after the elements that use them, so the UI fills in as it streams. ONLY use component types from the AVAILABLE COMPONENTS list below.`);
|
|
116132
|
-
lines.push("");
|
|
116133
|
-
lines.push("INITIAL STATE:");
|
|
116134
|
-
lines.push("Specs include a /state field to seed the state model. Components with { $bindState } or { $bindItem } read from and write to this state, and $state expressions read from it.");
|
|
116135
|
-
lines.push("CRITICAL: You MUST include state patches whenever your UI displays data via $state, $bindState, $bindItem, $item, or $index expressions, or uses repeat to iterate over arrays. Without state, these references resolve to nothing and repeat lists render zero items.");
|
|
116136
|
-
lines.push("Output state patches right after the elements that reference them, so the UI fills in progressively as it streams.");
|
|
116137
|
-
lines.push("Stream state progressively - output one patch per array item instead of one giant blob:");
|
|
116138
|
-
lines.push(' For arrays: {"op":"add","path":"/state/posts/0","value":{"id":"1","title":"First Post",...}} then /state/posts/1, /state/posts/2, etc.');
|
|
116139
|
-
lines.push(' For scalars: {"op":"add","path":"/state/newTodoText","value":""}');
|
|
116140
|
-
lines.push(' Initialize the array first if needed: {"op":"add","path":"/state/posts","value":[]}');
|
|
116141
|
-
lines.push('When content comes from the state model, use { "$state": "/some/path" } dynamic props to display it instead of hardcoding the same value in both state and props. The state model is the single source of truth.');
|
|
116142
|
-
lines.push("Include realistic sample data in state. For blogs: 3-4 posts with titles, excerpts, authors, dates. For product lists: 3-5 items with names, prices, descriptions. Never leave arrays empty.");
|
|
116143
|
-
lines.push("");
|
|
116144
|
-
lines.push("DYNAMIC LISTS (repeat field):");
|
|
116145
|
-
lines.push('Any element can have a top-level "repeat" field to render its children once per item in a state array: { "repeat": { "statePath": "/arrayPath", "key": "id" } }.');
|
|
116146
|
-
lines.push('The element itself renders once (as the container), and its children are expanded once per array item. "statePath" is the state array path. "key" is an optional field name on each item for stable React keys.');
|
|
116147
|
-
lines.push('For nested lists, an inner repeat can read an array from the enclosing item with { "statePath": { "$item": "field" } }. This form is valid only inside another repeat. Use an empty field to repeat over the enclosing item itself.');
|
|
116148
|
-
lines.push(`Example: ${JSON.stringify({ type: comp1, props: comp1Props, repeat: { statePath: "/todos", key: "id" }, children: ["todo-item"] })}`);
|
|
116149
|
-
lines.push('Inside children of a repeated element, use { "$item": "field" } to read a field from the current item, and { "$index": true } to get the current array index. For two-way binding to an item field use { "$bindItem": "completed" } on the appropriate prop.');
|
|
116150
|
-
lines.push("ALWAYS use the repeat field for lists backed by state arrays. NEVER hardcode individual elements for each array item.");
|
|
116151
|
-
lines.push('IMPORTANT: "repeat" is a top-level field on the element (sibling of type/props/children), NOT inside props.');
|
|
116152
|
-
lines.push("");
|
|
116153
|
-
lines.push("ARRAY STATE ACTIONS:");
|
|
116154
|
-
lines.push('Use action "pushState" to append items to arrays. Params: { statePath: "/arrayPath", value: { ...item }, clearStatePath: "/inputPath" }.');
|
|
116155
|
-
lines.push('Values inside pushState can contain { "$state": "/statePath" } references to read current state (e.g. the text from an input field).');
|
|
116156
|
-
lines.push('Use "$id" inside a pushState value to auto-generate a unique ID.');
|
|
116157
|
-
lines.push('Example: on: { "press": { "action": "pushState", "params": { "statePath": "/todos", "value": { "id": "$id", "title": { "$state": "/newTodoText" }, "completed": false }, "clearStatePath": "/newTodoText" } } }');
|
|
116158
|
-
lines.push(`Use action "removeState" to remove items from arrays by index. Params: { statePath: "/arrayPath", index: N }. Inside a repeated element's children, use { "$index": true } for the current item index. Action params support the same expressions as props: { "$item": "field" } resolves to the absolute state path, { "$index": true } resolves to the index number, and { "$state": "/path" } reads a value from state.`);
|
|
116159
|
-
lines.push("For lists where users can add/remove items (todos, carts, etc.), use pushState and removeState instead of hardcoding with setState.");
|
|
116160
|
-
lines.push("");
|
|
116161
|
-
lines.push('IMPORTANT: State paths use RFC 6901 JSON Pointer syntax (e.g. "/todos/0/title"). Do NOT use JavaScript-style dot notation (e.g. "/todos.length" is WRONG). To generate unique IDs for new items, use "$id" instead of trying to read array length.');
|
|
116162
|
-
lines.push("");
|
|
116163
|
-
const components = allComponents;
|
|
116164
|
-
if (components) {
|
|
116165
|
-
lines.push(`AVAILABLE COMPONENTS (${catalog.componentNames.length}):`);
|
|
116166
|
-
lines.push("");
|
|
116167
|
-
for (const [name, def] of Object.entries(components)) {
|
|
116168
|
-
const propsStr = def.props ? formatZodType(def.props) : "{}";
|
|
116169
|
-
const slotNames = def.slots ?? [];
|
|
116170
|
-
const namedSlotNames = slotNames.filter((slot) => slot !== "default");
|
|
116171
|
-
const acceptsChildren = slotNames.includes("default");
|
|
116172
|
-
const slotsStr = supportsNamedSlots ? [
|
|
116173
|
-
acceptsChildren ? "accepts children" : "",
|
|
116174
|
-
namedSlotNames.length > 0 ? `slots: ${namedSlotNames.join(", ")}` : ""
|
|
116175
|
-
].filter(Boolean).join("; ") : slotNames.length > 0 ? "accepts children" : "";
|
|
116176
|
-
const slotsSuffix = slotsStr ? ` [${slotsStr}]` : "";
|
|
116177
|
-
const eventsStr = def.events && def.events.length > 0 ? ` [events: ${def.events.join(", ")}]` : "";
|
|
116178
|
-
const descStr = def.description ? ` - ${def.description}` : "";
|
|
116179
|
-
lines.push(`- ${name}: ${propsStr}${descStr}${slotsSuffix}${eventsStr}`);
|
|
116180
|
-
}
|
|
116181
|
-
lines.push("");
|
|
116182
|
-
}
|
|
116183
|
-
const actions = catalog.data.actions;
|
|
116184
|
-
const builtInActions = catalog.schema.builtInActions ?? [];
|
|
116185
|
-
const hasCustomActions = actions && catalog.actionNames.length > 0;
|
|
116186
|
-
const hasBuiltInActions = builtInActions.length > 0;
|
|
116187
|
-
if (hasCustomActions || hasBuiltInActions) {
|
|
116188
|
-
lines.push("AVAILABLE ACTIONS:");
|
|
116189
|
-
lines.push("");
|
|
116190
|
-
for (const action2 of builtInActions) {
|
|
116191
|
-
lines.push(`- ${action2.name}: ${action2.description} [built-in]`);
|
|
116192
|
-
}
|
|
116193
|
-
if (hasCustomActions) {
|
|
116194
|
-
for (const [name, def] of Object.entries(actions)) {
|
|
116195
|
-
lines.push(`- ${name}${def.description ? `: ${def.description}` : ""}`);
|
|
116196
|
-
}
|
|
116197
|
-
}
|
|
116198
|
-
lines.push("");
|
|
116199
|
-
}
|
|
116200
|
-
lines.push("EVENTS (the `on` field):");
|
|
116201
|
-
lines.push("Elements can have an optional `on` field to bind events to actions. The `on` field is a top-level field on the element (sibling of type/props/children), NOT inside props.");
|
|
116202
|
-
lines.push('Each key in `on` is an event name (from the component\'s supported events), and the value is an action binding: `{ "action": "<actionName>", "params": { ... } }`.');
|
|
116203
|
-
lines.push("");
|
|
116204
|
-
lines.push("Example:");
|
|
116205
|
-
lines.push(` ${JSON.stringify({ type: comp1, props: comp1Props, on: { press: { action: "setState", params: { statePath: "/saved", value: true } } }, children: [] })}`);
|
|
116206
|
-
lines.push("");
|
|
116207
|
-
lines.push('Action params can use dynamic references to read from state: { "$state": "/statePath" }.');
|
|
116208
|
-
lines.push("IMPORTANT: Do NOT put action/actionParams inside props. Always use the `on` field for event bindings.");
|
|
116209
|
-
lines.push("");
|
|
116210
|
-
lines.push("VISIBILITY CONDITIONS:");
|
|
116211
|
-
lines.push("Elements can have an optional `visible` field to conditionally show/hide based on state. IMPORTANT: `visible` is a top-level field on the element object (sibling of type/props/children), NOT inside props.");
|
|
116212
|
-
lines.push(`Correct: ${JSON.stringify({ type: comp1, props: comp1Props, visible: { $state: "/activeTab", eq: "home" }, children: ["..."] })}`);
|
|
116213
|
-
lines.push('- `{ "$state": "/path" }` - visible when state at path is truthy');
|
|
116214
|
-
lines.push('- `{ "$state": "/path", "not": true }` - visible when state at path is falsy');
|
|
116215
|
-
lines.push('- `{ "$state": "/path", "eq": "value" }` - visible when state equals value');
|
|
116216
|
-
lines.push('- `{ "$state": "/path", "neq": "value" }` - visible when state does not equal value');
|
|
116217
|
-
lines.push('- `{ "$state": "/path", "gt": N }` / `gte` / `lt` / `lte` - numeric comparisons');
|
|
116218
|
-
lines.push("- Use ONE operator per condition (eq, neq, gt, gte, lt, lte). Do not combine multiple operators.");
|
|
116219
|
-
lines.push('- Any condition can add `"not": true` to invert its result');
|
|
116220
|
-
lines.push("- `[condition, condition]` - all conditions must be true (implicit AND)");
|
|
116221
|
-
lines.push('- `{ "$and": [condition, condition] }` - explicit AND (use when nesting inside $or)');
|
|
116222
|
-
lines.push('- `{ "$or": [condition, condition] }` - at least one must be true (OR)');
|
|
116223
|
-
lines.push("- `true` / `false` - always visible/hidden");
|
|
116224
|
-
lines.push("");
|
|
116225
|
-
lines.push("Use a component with on.press bound to setState to update state and drive visibility.");
|
|
116226
|
-
lines.push(`Example: A ${comp1} with on: { "press": { "action": "setState", "params": { "statePath": "/activeTab", "value": "home" } } } sets state, then a container with visible: { "$state": "/activeTab", "eq": "home" } shows only when that tab is active.`);
|
|
116227
|
-
lines.push("");
|
|
116228
|
-
lines.push('For tab patterns where the first/default tab should be visible when no tab is selected yet, use $or to handle both cases: visible: { "$or": [{ "$state": "/activeTab", "eq": "home" }, { "$state": "/activeTab", "not": true }] }. This ensures the first tab is visible both when explicitly selected AND when /activeTab is not yet set.');
|
|
116229
|
-
lines.push("");
|
|
116230
|
-
lines.push("DYNAMIC PROPS:");
|
|
116231
|
-
lines.push("Any prop value can be a dynamic expression that resolves based on state. Three forms are supported:");
|
|
116232
|
-
lines.push("");
|
|
116233
|
-
lines.push('1. Read-only state: `{ "$state": "/statePath" }` - resolves to the value at that state path (one-way read).');
|
|
116234
|
-
lines.push(' Example: `"color": { "$state": "/theme/primary" }` reads the color from state.');
|
|
116235
|
-
lines.push("");
|
|
116236
|
-
lines.push('2. Two-way binding: `{ "$bindState": "/statePath" }` - resolves to the value at the state path AND enables write-back. Use on form input props (value, checked, pressed, etc.).');
|
|
116237
|
-
lines.push(' Example: `"value": { "$bindState": "/form/email" }` binds the input value to /form/email.');
|
|
116238
|
-
lines.push(' Inside repeat scopes: `"checked": { "$bindItem": "completed" }` binds to the current item\'s completed field.');
|
|
116239
|
-
lines.push("");
|
|
116240
|
-
lines.push('3. Conditional: `{ "$cond": <condition>, "$then": <value>, "$else": <value> }` - evaluates the condition (same syntax as visibility conditions) and picks the matching value.');
|
|
116241
|
-
lines.push(' Example: `"color": { "$cond": { "$state": "/activeTab", "eq": "home" }, "$then": "#007AFF", "$else": "#8E8E93" }`');
|
|
116242
|
-
lines.push("");
|
|
116243
|
-
lines.push("Use $bindState for form inputs (text fields, checkboxes, selects, sliders, etc.) and $state for read-only data display. Inside repeat scopes, use $bindItem for form inputs bound to the current item. Use dynamic props instead of duplicating elements with opposing visible conditions when only prop values differ.");
|
|
116244
|
-
lines.push("");
|
|
116245
|
-
lines.push('4. Template: `{ "$template": "Hello, ${/name}!" }` - interpolates references in the string. Absolute paths like `${/path}` resolve against the state model. Bare names like `${field}` resolve against the current repeat item first, then fall back to the state model at `/<field>`.');
|
|
116246
|
-
lines.push(' Example: `"label": { "$template": "Items: ${/cart/count} | Total: ${/cart/total}" }` renders "Items: 3 | Total: 42.00" when /cart/count is 3 and /cart/total is 42.00. Inside a repeat, `{ "$template": "${name} - ${email}" }` reads name and email from each item.');
|
|
116247
|
-
lines.push("");
|
|
116248
|
-
const catalogFunctions = catalog.data.functions;
|
|
116249
|
-
if (catalogFunctions && Object.keys(catalogFunctions).length > 0) {
|
|
116250
|
-
lines.push('5. Computed: `{ "$computed": "<functionName>", "args": { "key": <expression> } }` - calls a registered function with resolved args and returns the result.');
|
|
116251
|
-
lines.push(' Example: `"value": { "$computed": "fullName", "args": { "first": { "$state": "/form/firstName" }, "last": { "$state": "/form/lastName" } } }`');
|
|
116252
|
-
lines.push(" Available functions:");
|
|
116253
|
-
for (const name of Object.keys(catalogFunctions)) {
|
|
116254
|
-
lines.push(` - ${name}`);
|
|
116255
|
-
}
|
|
116256
|
-
lines.push("");
|
|
116257
|
-
}
|
|
116258
|
-
const directives = options.directives;
|
|
116259
|
-
if (directives && directives.length > 0) {
|
|
116260
|
-
lines.push("CUSTOM DYNAMIC VALUES:");
|
|
116261
|
-
lines.push("");
|
|
116262
|
-
for (const d of directives) {
|
|
116263
|
-
const desc = d.description ? ` (${d.description})` : "";
|
|
116264
|
-
lines.push(`- ${d.name}${desc}: ${formatZodType(d.schema)}`);
|
|
116265
|
-
}
|
|
116266
|
-
lines.push("");
|
|
116267
|
-
lines.push("Directives compose: any value field can contain another directive or a $state expression, resolved inside-out.");
|
|
116268
|
-
lines.push("");
|
|
116269
|
-
}
|
|
116270
|
-
const hasChecksComponents = allComponents ? Object.entries(allComponents).some(([, def]) => {
|
|
116271
|
-
if (!def.props)
|
|
116272
|
-
return false;
|
|
116273
|
-
const formatted = formatZodType(def.props);
|
|
116274
|
-
return formatted.includes("checks");
|
|
116275
|
-
}) : false;
|
|
116276
|
-
if (hasChecksComponents) {
|
|
116277
|
-
lines.push("VALIDATION:");
|
|
116278
|
-
lines.push("Form components that accept a `checks` prop support client-side validation.");
|
|
116279
|
-
lines.push('Each check is an object: { "type": "<name>", "message": "...", "args": { ... } }');
|
|
116280
|
-
lines.push("");
|
|
116281
|
-
lines.push("Built-in validation types:");
|
|
116282
|
-
lines.push(" - required — value must be non-empty");
|
|
116283
|
-
lines.push(" - email — valid email format");
|
|
116284
|
-
lines.push(' - minLength — minimum string length (args: { "min": N })');
|
|
116285
|
-
lines.push(' - maxLength — maximum string length (args: { "max": N })');
|
|
116286
|
-
lines.push(' - pattern — match a regex (args: { "pattern": "regex" })');
|
|
116287
|
-
lines.push(' - min — minimum numeric value (args: { "min": N })');
|
|
116288
|
-
lines.push(' - max — maximum numeric value (args: { "max": N })');
|
|
116289
|
-
lines.push(" - numeric — value must be a number");
|
|
116290
|
-
lines.push(" - url — valid URL format");
|
|
116291
|
-
lines.push(' - matches — must equal another field (args: { "other": { "$state": "/path" } })');
|
|
116292
|
-
lines.push(' - equalTo — alias for matches (args: { "other": { "$state": "/path" } })');
|
|
116293
|
-
lines.push(' - lessThan — value must be less than another field (args: { "other": { "$state": "/path" } })');
|
|
116294
|
-
lines.push(' - greaterThan — value must be greater than another field (args: { "other": { "$state": "/path" } })');
|
|
116295
|
-
lines.push(' - requiredIf — required only when another field is truthy (args: { "field": { "$state": "/path" } })');
|
|
116296
|
-
lines.push("");
|
|
116297
|
-
lines.push("Example:");
|
|
116298
|
-
lines.push(' "checks": [{ "type": "required", "message": "Email is required" }, { "type": "email", "message": "Invalid email" }]');
|
|
116299
|
-
lines.push("");
|
|
116300
|
-
lines.push("IMPORTANT: When using checks, the component must also have a { $bindState } or { $bindItem } on its value/checked prop for two-way binding.");
|
|
116301
|
-
lines.push("Always include validation checks on form inputs for a good user experience (e.g. required, email, minLength).");
|
|
116302
|
-
lines.push("");
|
|
116303
|
-
}
|
|
116304
|
-
if (hasCustomActions || hasBuiltInActions) {
|
|
116305
|
-
lines.push("STATE WATCHERS:");
|
|
116306
|
-
lines.push("Elements can have an optional `watch` field to react to state changes and trigger actions. The `watch` field is a top-level field on the element (sibling of type/props/children), NOT inside props.");
|
|
116307
|
-
lines.push("Maps state paths (JSON Pointers) to action bindings. When the value at a watched path changes, the bound actions fire automatically.");
|
|
116308
|
-
lines.push("");
|
|
116309
|
-
lines.push("Example (cascading select — country changes trigger city loading):");
|
|
116310
|
-
lines.push(` ${JSON.stringify({ type: "Select", props: { value: { $bindState: "/form/country" }, options: ["US", "Canada", "UK"] }, watch: { "/form/country": { action: "loadCities", params: { country: { $state: "/form/country" } } } }, children: [] })}`);
|
|
116311
|
-
lines.push("");
|
|
116312
|
-
lines.push("Use `watch` for cascading dependencies where changing one field should trigger side effects (loading data, resetting dependent fields, computing derived values).");
|
|
116313
|
-
lines.push("IMPORTANT: `watch` is a top-level field on the element (sibling of type/props/children), NOT inside props. Watchers only fire when the value changes, not on initial render.");
|
|
116314
|
-
lines.push("");
|
|
116315
|
-
}
|
|
116316
|
-
const editModes = options.editModes;
|
|
116317
|
-
if (editModes && editModes.length > 0) {
|
|
116318
|
-
lines.push(buildEditInstructions({ modes: editModes }, "json"));
|
|
116319
|
-
}
|
|
116320
|
-
lines.push("RULES:");
|
|
116321
|
-
const baseRules = mode === "inline" ? [
|
|
116322
|
-
"When generating UI, wrap all JSONL patches in a ```spec code fence - one JSON object per line inside the fence",
|
|
116323
|
-
"Write a brief conversational response before any JSONL output",
|
|
116324
|
-
'First set root: {"op":"add","path":"/root","value":"<root-key>"}',
|
|
116325
|
-
'Then add each element: {"op":"add","path":"/elements/<key>","value":{...}}',
|
|
116326
|
-
"Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.",
|
|
116327
|
-
"ONLY use components listed above",
|
|
116328
|
-
"Each element value needs: type, props, children (array of child keys)",
|
|
116329
|
-
"Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"
|
|
116330
|
-
] : [
|
|
116331
|
-
"Output ONLY JSONL patches - one JSON object per line, no markdown, no code fences",
|
|
116332
|
-
'First set root: {"op":"add","path":"/root","value":"<root-key>"}',
|
|
116333
|
-
'Then add each element: {"op":"add","path":"/elements/<key>","value":{...}}',
|
|
116334
|
-
"Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.",
|
|
116335
|
-
"ONLY use components listed above",
|
|
116336
|
-
"Each element value needs: type, props, children (array of child keys)",
|
|
116337
|
-
"Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"
|
|
116338
|
-
];
|
|
116339
|
-
const schemaRules = catalog.schema.defaultRules ?? [];
|
|
116340
|
-
const allRules = [...baseRules, ...schemaRules, ...customRules];
|
|
116341
|
-
allRules.forEach((rule, i) => {
|
|
116342
|
-
lines.push(`${i + 1}. ${rule}`);
|
|
116343
|
-
});
|
|
116344
|
-
return lines.join(`
|
|
116345
|
-
`);
|
|
116346
|
-
}
|
|
116347
|
-
function getExampleProps(def) {
|
|
116348
|
-
if (def.example && Object.keys(def.example).length > 0) {
|
|
116349
|
-
return def.example;
|
|
116350
|
-
}
|
|
116351
|
-
if (def.props) {
|
|
116352
|
-
return generateExamplePropsFromZod(def.props);
|
|
116353
|
-
}
|
|
116354
|
-
return {};
|
|
116355
|
-
}
|
|
116356
|
-
function generateExamplePropsFromZod(schema) {
|
|
116357
|
-
if (!schema || !schema._def)
|
|
116358
|
-
return {};
|
|
116359
|
-
const def = schema._def;
|
|
116360
|
-
const typeName = getZodTypeName(schema);
|
|
116361
|
-
if (typeName !== "ZodObject" && typeName !== "object")
|
|
116362
|
-
return {};
|
|
116363
|
-
const shape = typeof def.shape === "function" ? def.shape() : def.shape;
|
|
116364
|
-
if (!shape)
|
|
116365
|
-
return {};
|
|
116366
|
-
const result = {};
|
|
116367
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
116368
|
-
const innerTypeName = getZodTypeName(value);
|
|
116369
|
-
if (innerTypeName === "ZodOptional" || innerTypeName === "optional" || innerTypeName === "ZodNullable" || innerTypeName === "nullable") {
|
|
116370
|
-
continue;
|
|
116371
|
-
}
|
|
116372
|
-
result[key] = generateExampleValue(value);
|
|
116373
|
-
}
|
|
116374
|
-
return result;
|
|
116375
|
-
}
|
|
116376
|
-
function generateExampleValue(schema) {
|
|
116377
|
-
if (!schema || !schema._def)
|
|
116378
|
-
return "...";
|
|
116379
|
-
const def = schema._def;
|
|
116380
|
-
const typeName = getZodTypeName(schema);
|
|
116381
|
-
switch (typeName) {
|
|
116382
|
-
case "ZodString":
|
|
116383
|
-
case "string":
|
|
116384
|
-
return "example";
|
|
116385
|
-
case "ZodNumber":
|
|
116386
|
-
case "number":
|
|
116387
|
-
return 0;
|
|
116388
|
-
case "ZodBoolean":
|
|
116389
|
-
case "boolean":
|
|
116390
|
-
return true;
|
|
116391
|
-
case "ZodLiteral":
|
|
116392
|
-
case "literal":
|
|
116393
|
-
return def.value;
|
|
116394
|
-
case "ZodEnum":
|
|
116395
|
-
case "enum": {
|
|
116396
|
-
if (Array.isArray(def.values) && def.values.length > 0)
|
|
116397
|
-
return def.values[0];
|
|
116398
|
-
if (def.entries && typeof def.entries === "object") {
|
|
116399
|
-
const values = Object.values(def.entries);
|
|
116400
|
-
return values.length > 0 ? values[0] : "example";
|
|
116401
|
-
}
|
|
116402
|
-
return "example";
|
|
116403
|
-
}
|
|
116404
|
-
case "ZodOptional":
|
|
116405
|
-
case "optional":
|
|
116406
|
-
case "ZodNullable":
|
|
116407
|
-
case "nullable":
|
|
116408
|
-
case "ZodDefault":
|
|
116409
|
-
case "default": {
|
|
116410
|
-
const inner = def.innerType ?? def.wrapped;
|
|
116411
|
-
return inner ? generateExampleValue(inner) : null;
|
|
116412
|
-
}
|
|
116413
|
-
case "ZodArray":
|
|
116414
|
-
case "array":
|
|
116415
|
-
return [];
|
|
116416
|
-
case "ZodObject":
|
|
116417
|
-
case "object":
|
|
116418
|
-
return generateExamplePropsFromZod(schema);
|
|
116419
|
-
case "ZodUnion":
|
|
116420
|
-
case "union": {
|
|
116421
|
-
const options = def.options;
|
|
116422
|
-
return options && options.length > 0 ? generateExampleValue(options[0]) : "...";
|
|
116423
|
-
}
|
|
116424
|
-
default:
|
|
116425
|
-
return "...";
|
|
116426
|
-
}
|
|
116427
|
-
}
|
|
116428
|
-
function findFirstStringProp(schema) {
|
|
116429
|
-
if (!schema || !schema._def)
|
|
116430
|
-
return null;
|
|
116431
|
-
const def = schema._def;
|
|
116432
|
-
const typeName = getZodTypeName(schema);
|
|
116433
|
-
if (typeName !== "ZodObject" && typeName !== "object")
|
|
116434
|
-
return null;
|
|
116435
|
-
const shape = typeof def.shape === "function" ? def.shape() : def.shape;
|
|
116436
|
-
if (!shape)
|
|
116437
|
-
return null;
|
|
116438
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
116439
|
-
const innerTypeName = getZodTypeName(value);
|
|
116440
|
-
if (innerTypeName === "ZodOptional" || innerTypeName === "optional" || innerTypeName === "ZodNullable" || innerTypeName === "nullable") {
|
|
116441
|
-
continue;
|
|
116442
|
-
}
|
|
116443
|
-
if (innerTypeName === "ZodString" || innerTypeName === "string") {
|
|
116444
|
-
return key;
|
|
116445
|
-
}
|
|
116446
|
-
}
|
|
116447
|
-
return null;
|
|
116448
|
-
}
|
|
116449
|
-
function getZodTypeName(schema) {
|
|
116450
|
-
if (!schema || !schema._def)
|
|
116451
|
-
return "";
|
|
116452
|
-
const def = schema._def;
|
|
116453
|
-
return def.typeName ?? def.type ?? "";
|
|
116454
|
-
}
|
|
116455
|
-
function formatZodType(schema) {
|
|
116456
|
-
if (!schema || !schema._def)
|
|
116457
|
-
return "unknown";
|
|
116458
|
-
const def = schema._def;
|
|
116459
|
-
const typeName = getZodTypeName(schema);
|
|
116460
|
-
switch (typeName) {
|
|
116461
|
-
case "ZodString":
|
|
116462
|
-
case "string":
|
|
116463
|
-
return "string";
|
|
116464
|
-
case "ZodNumber":
|
|
116465
|
-
case "number":
|
|
116466
|
-
return "number";
|
|
116467
|
-
case "ZodBoolean":
|
|
116468
|
-
case "boolean":
|
|
116469
|
-
return "boolean";
|
|
116470
|
-
case "ZodLiteral":
|
|
116471
|
-
case "literal": {
|
|
116472
|
-
const litValues = def.values;
|
|
116473
|
-
const litValue = litValues?.[0] ?? def.value;
|
|
116474
|
-
return JSON.stringify(litValue);
|
|
116475
|
-
}
|
|
116476
|
-
case "ZodEnum":
|
|
116477
|
-
case "enum": {
|
|
116478
|
-
let values;
|
|
116479
|
-
if (Array.isArray(def.values)) {
|
|
116480
|
-
values = def.values;
|
|
116481
|
-
} else if (def.entries && typeof def.entries === "object") {
|
|
116482
|
-
values = Object.values(def.entries);
|
|
116483
|
-
} else {
|
|
116484
|
-
return "enum";
|
|
116485
|
-
}
|
|
116486
|
-
return values.map((v) => `"${v}"`).join(" | ");
|
|
116487
|
-
}
|
|
116488
|
-
case "ZodArray":
|
|
116489
|
-
case "array": {
|
|
116490
|
-
const inner = typeof def.element === "object" ? def.element : typeof def.type === "object" ? def.type : undefined;
|
|
116491
|
-
return inner ? `Array<${formatZodType(inner)}>` : "Array<unknown>";
|
|
116492
|
-
}
|
|
116493
|
-
case "ZodObject":
|
|
116494
|
-
case "object": {
|
|
116495
|
-
const shape = typeof def.shape === "function" ? def.shape() : def.shape;
|
|
116496
|
-
if (!shape)
|
|
116497
|
-
return "object";
|
|
116498
|
-
const props = Object.entries(shape).map(([key, value]) => {
|
|
116499
|
-
const innerTypeName = getZodTypeName(value);
|
|
116500
|
-
const isOptional = innerTypeName === "ZodOptional" || innerTypeName === "ZodNullable" || innerTypeName === "optional" || innerTypeName === "nullable";
|
|
116501
|
-
return `${key}${isOptional ? "?" : ""}: ${formatZodType(value)}`;
|
|
116502
|
-
}).join(", ");
|
|
116503
|
-
return `{ ${props} }`;
|
|
116504
|
-
}
|
|
116505
|
-
case "ZodOptional":
|
|
116506
|
-
case "optional":
|
|
116507
|
-
case "ZodNullable":
|
|
116508
|
-
case "nullable": {
|
|
116509
|
-
const inner = def.innerType ?? def.wrapped;
|
|
116510
|
-
return inner ? formatZodType(inner) : "unknown";
|
|
116511
|
-
}
|
|
116512
|
-
case "ZodUnion":
|
|
116513
|
-
case "union": {
|
|
116514
|
-
const options = def.options;
|
|
116515
|
-
return options ? options.map((opt) => formatZodType(opt)).join(" | ") : "unknown";
|
|
116516
|
-
}
|
|
116517
|
-
case "ZodRecord":
|
|
116518
|
-
case "record": {
|
|
116519
|
-
const keyType = def.keyType ?? undefined;
|
|
116520
|
-
const valueType = def.valueType ?? def.element ?? undefined;
|
|
116521
|
-
const keyStr = keyType ? formatZodType(keyType) : "string";
|
|
116522
|
-
const valueStr = valueType ? formatZodType(valueType) : "unknown";
|
|
116523
|
-
return `Record<${keyStr}, ${valueStr}>`;
|
|
116524
|
-
}
|
|
116525
|
-
case "ZodDefault":
|
|
116526
|
-
case "default": {
|
|
116527
|
-
const inner = def.innerType ?? def.wrapped;
|
|
116528
|
-
return inner ? formatZodType(inner) : "unknown";
|
|
116529
|
-
}
|
|
116530
|
-
default:
|
|
116531
|
-
return "unknown";
|
|
116532
|
-
}
|
|
116533
|
-
}
|
|
116534
|
-
function zodTypeName(def) {
|
|
116535
|
-
if (typeof def.type === "string")
|
|
116536
|
-
return def.type;
|
|
116537
|
-
if (typeof def.typeName === "string")
|
|
116538
|
-
return def.typeName;
|
|
116539
|
-
return "";
|
|
116540
|
-
}
|
|
116541
|
-
function normalizeTypeName(raw) {
|
|
116542
|
-
if (raw.startsWith("Zod")) {
|
|
116543
|
-
return raw.slice(3).toLowerCase();
|
|
116544
|
-
}
|
|
116545
|
-
return raw.toLowerCase();
|
|
116546
|
-
}
|
|
116547
|
-
function zodToJsonSchema3(schema, strict = false) {
|
|
116548
|
-
const def = schema._def;
|
|
116549
|
-
const kind = normalizeTypeName(zodTypeName(def));
|
|
116550
|
-
switch (kind) {
|
|
116551
|
-
case "string":
|
|
116552
|
-
return { type: "string" };
|
|
116553
|
-
case "number":
|
|
116554
|
-
return { type: "number" };
|
|
116555
|
-
case "boolean":
|
|
116556
|
-
return { type: "boolean" };
|
|
116557
|
-
case "literal": {
|
|
116558
|
-
const values = def.values;
|
|
116559
|
-
const value = values ? values[0] : def.value;
|
|
116560
|
-
return { const: value };
|
|
116561
|
-
}
|
|
116562
|
-
case "enum": {
|
|
116563
|
-
const entries = def.entries;
|
|
116564
|
-
const values = entries ? Object.values(entries) : def.values;
|
|
116565
|
-
return { enum: values ?? [] };
|
|
116566
|
-
}
|
|
116567
|
-
case "array": {
|
|
116568
|
-
const inner = def.element ?? def.type;
|
|
116569
|
-
return {
|
|
116570
|
-
type: "array",
|
|
116571
|
-
items: inner ? zodToJsonSchema3(inner, strict) : {}
|
|
116572
|
-
};
|
|
116573
|
-
}
|
|
116574
|
-
case "object": {
|
|
116575
|
-
const rawShape = def.shape;
|
|
116576
|
-
const shape = typeof rawShape === "function" ? rawShape() : rawShape;
|
|
116577
|
-
if (!shape) {
|
|
116578
|
-
if (strict) {
|
|
116579
|
-
return {
|
|
116580
|
-
type: "object",
|
|
116581
|
-
properties: {},
|
|
116582
|
-
required: [],
|
|
116583
|
-
additionalProperties: false
|
|
116584
|
-
};
|
|
116585
|
-
}
|
|
116586
|
-
return { type: "object" };
|
|
116587
|
-
}
|
|
116588
|
-
const properties = {};
|
|
116589
|
-
const required = [];
|
|
116590
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
116591
|
-
const innerDef = value._def;
|
|
116592
|
-
const innerKind = normalizeTypeName(zodTypeName(innerDef));
|
|
116593
|
-
const isOptional = innerKind === "optional" || innerKind === "nullable";
|
|
116594
|
-
if (strict) {
|
|
116595
|
-
required.push(key);
|
|
116596
|
-
if (isOptional) {
|
|
116597
|
-
const unwrapped = zodToJsonSchema3(value, strict);
|
|
116598
|
-
properties[key] = { anyOf: [unwrapped, { type: "null" }] };
|
|
116599
|
-
} else {
|
|
116600
|
-
properties[key] = zodToJsonSchema3(value, strict);
|
|
116601
|
-
}
|
|
116602
|
-
} else {
|
|
116603
|
-
properties[key] = zodToJsonSchema3(value);
|
|
116604
|
-
if (!isOptional) {
|
|
116605
|
-
required.push(key);
|
|
116606
|
-
}
|
|
116607
|
-
}
|
|
116608
|
-
}
|
|
116609
|
-
return {
|
|
116610
|
-
type: "object",
|
|
116611
|
-
properties,
|
|
116612
|
-
required: required.length > 0 ? required : undefined,
|
|
116613
|
-
additionalProperties: false
|
|
116614
|
-
};
|
|
116615
|
-
}
|
|
116616
|
-
case "record": {
|
|
116617
|
-
const valueType = def.valueType;
|
|
116618
|
-
if (strict) {
|
|
116619
|
-
return {
|
|
116620
|
-
type: "object",
|
|
116621
|
-
properties: {},
|
|
116622
|
-
required: [],
|
|
116623
|
-
additionalProperties: false
|
|
116624
|
-
};
|
|
116625
|
-
}
|
|
116626
|
-
return {
|
|
116627
|
-
type: "object",
|
|
116628
|
-
additionalProperties: valueType ? zodToJsonSchema3(valueType) : true
|
|
116629
|
-
};
|
|
116630
|
-
}
|
|
116631
|
-
case "optional":
|
|
116632
|
-
case "nullable": {
|
|
116633
|
-
const inner = def.innerType;
|
|
116634
|
-
return inner ? zodToJsonSchema3(inner, strict) : {};
|
|
116635
|
-
}
|
|
116636
|
-
case "union": {
|
|
116637
|
-
const options = def.options;
|
|
116638
|
-
return options ? { anyOf: options.map((o) => zodToJsonSchema3(o, strict)) } : {};
|
|
116639
|
-
}
|
|
116640
|
-
case "any":
|
|
116641
|
-
case "unknown":
|
|
116642
|
-
if (strict) {
|
|
116643
|
-
return {
|
|
116644
|
-
type: "object",
|
|
116645
|
-
properties: {},
|
|
116646
|
-
required: [],
|
|
116647
|
-
additionalProperties: false
|
|
116648
|
-
};
|
|
116649
|
-
}
|
|
116650
|
-
return {};
|
|
116651
|
-
default:
|
|
116652
|
-
return {};
|
|
116653
|
-
}
|
|
116654
|
-
}
|
|
116655
|
-
var numericOrStateRef, comparisonOps, StateConditionSchema, ItemConditionSchema, IndexConditionSchema, SingleConditionSchema, VisibilityConditionSchema, StrictSingleConditionSchema, VisibilityConditionStrictSchema, WARNED_COMPUTED_MAX = 100, warnedComputedFns, ActionConfirmSchema, ActionOnSuccessSchema, ActionOnErrorSchema, ActionBindingSchema, ValidationCheckSchema, ValidationConfigSchema, DEFAULT_MODES, seedSchema, compositionActionSchema, probability, responseSchema;
|
|
116656
|
-
var init_dist2 = __esm(() => {
|
|
116657
|
-
init_chunk_FVP4K5MD();
|
|
116658
|
-
init_zod();
|
|
116659
|
-
init_zod();
|
|
116660
|
-
init_zod();
|
|
116661
|
-
init_zod();
|
|
116662
|
-
init_zod();
|
|
116663
|
-
init_zod();
|
|
116664
|
-
init_zod();
|
|
116665
|
-
numericOrStateRef = union3([
|
|
116666
|
-
number2(),
|
|
116667
|
-
object2({ $state: string2() })
|
|
116668
|
-
]);
|
|
116669
|
-
comparisonOps = {
|
|
116670
|
-
eq: unknown().optional(),
|
|
116671
|
-
neq: unknown().optional(),
|
|
116672
|
-
gt: numericOrStateRef.optional(),
|
|
116673
|
-
gte: numericOrStateRef.optional(),
|
|
116674
|
-
lt: numericOrStateRef.optional(),
|
|
116675
|
-
lte: numericOrStateRef.optional(),
|
|
116676
|
-
not: literal2(true).optional()
|
|
116677
|
-
};
|
|
116678
|
-
StateConditionSchema = object2({
|
|
116679
|
-
$state: string2(),
|
|
116680
|
-
...comparisonOps
|
|
116681
|
-
});
|
|
116682
|
-
ItemConditionSchema = object2({
|
|
116683
|
-
$item: string2(),
|
|
116684
|
-
...comparisonOps
|
|
116685
|
-
});
|
|
116686
|
-
IndexConditionSchema = object2({
|
|
116687
|
-
$index: literal2(true),
|
|
116688
|
-
...comparisonOps
|
|
116689
|
-
});
|
|
116690
|
-
SingleConditionSchema = union3([
|
|
116691
|
-
StateConditionSchema,
|
|
116692
|
-
ItemConditionSchema,
|
|
116693
|
-
IndexConditionSchema
|
|
116694
|
-
]);
|
|
116695
|
-
VisibilityConditionSchema = lazy(() => union3([
|
|
116696
|
-
boolean(),
|
|
116697
|
-
SingleConditionSchema,
|
|
116698
|
-
array2(SingleConditionSchema),
|
|
116699
|
-
object2({ $and: array2(VisibilityConditionSchema) }),
|
|
116700
|
-
object2({ $or: array2(VisibilityConditionSchema) })
|
|
116701
|
-
]));
|
|
116702
|
-
StrictSingleConditionSchema = union3([
|
|
116703
|
-
strictObject2({ $state: string2(), ...comparisonOps }),
|
|
116704
|
-
strictObject2({ $item: string2(), ...comparisonOps }),
|
|
116705
|
-
strictObject2({ $index: literal2(true), ...comparisonOps })
|
|
116706
|
-
]);
|
|
116707
|
-
VisibilityConditionStrictSchema = lazy(() => union3([
|
|
116708
|
-
boolean(),
|
|
116709
|
-
StrictSingleConditionSchema,
|
|
116710
|
-
array2(StrictSingleConditionSchema),
|
|
116711
|
-
strictObject2({ $and: array2(VisibilityConditionStrictSchema) }),
|
|
116712
|
-
strictObject2({ $or: array2(VisibilityConditionStrictSchema) })
|
|
116713
|
-
]));
|
|
116714
|
-
warnedComputedFns = /* @__PURE__ */ new Set;
|
|
116715
|
-
ActionConfirmSchema = object2({
|
|
116716
|
-
title: string2(),
|
|
116717
|
-
message: string2(),
|
|
116718
|
-
confirmLabel: string2().optional(),
|
|
116719
|
-
cancelLabel: string2().optional(),
|
|
116720
|
-
variant: _enum2(["default", "danger"]).optional()
|
|
116721
|
-
});
|
|
116722
|
-
ActionOnSuccessSchema = union3([
|
|
116723
|
-
object2({ navigate: string2() }),
|
|
116724
|
-
object2({ set: record2(string2(), unknown()) }),
|
|
116725
|
-
object2({
|
|
116726
|
-
action: string2(),
|
|
116727
|
-
params: record2(string2(), DynamicValueSchema).optional()
|
|
116728
|
-
})
|
|
116729
|
-
]);
|
|
116730
|
-
ActionOnErrorSchema = union3([
|
|
116731
|
-
object2({ set: record2(string2(), unknown()) }),
|
|
116732
|
-
object2({
|
|
116733
|
-
action: string2(),
|
|
116734
|
-
params: record2(string2(), DynamicValueSchema).optional()
|
|
116735
|
-
})
|
|
116736
|
-
]);
|
|
116737
|
-
ActionBindingSchema = object2({
|
|
116738
|
-
action: string2(),
|
|
116739
|
-
params: record2(string2(), DynamicValueSchema).optional(),
|
|
116740
|
-
confirm: ActionConfirmSchema.optional(),
|
|
116741
|
-
onSuccess: ActionOnSuccessSchema.optional(),
|
|
116742
|
-
onError: ActionOnErrorSchema.optional(),
|
|
116743
|
-
preventDefault: boolean().optional()
|
|
116744
|
-
});
|
|
116745
|
-
ValidationCheckSchema = object2({
|
|
116746
|
-
type: string2(),
|
|
116747
|
-
args: record2(string2(), DynamicValueSchema).optional(),
|
|
116748
|
-
message: string2()
|
|
116749
|
-
});
|
|
116750
|
-
ValidationConfigSchema = object2({
|
|
116751
|
-
checks: array2(ValidationCheckSchema).optional(),
|
|
116752
|
-
validateOn: _enum2(["change", "blur", "submit"]).optional(),
|
|
116753
|
-
enabled: VisibilityConditionSchema.optional()
|
|
116754
|
-
});
|
|
116755
|
-
DEFAULT_MODES = ["patch"];
|
|
116756
|
-
seedSchema = object2({
|
|
116757
|
-
root: string2().min(1),
|
|
116758
|
-
elements: record2(string2(), object2({
|
|
116759
|
-
type: string2(),
|
|
116760
|
-
props: record2(string2(), unknown()),
|
|
116761
|
-
children: array2(string2()).optional(),
|
|
116762
|
-
slots: record2(string2(), array2(string2())).optional(),
|
|
116763
|
-
on: record2(string2(), unknown()).optional(),
|
|
116764
|
-
visible: unknown().optional()
|
|
116765
|
-
}).strict()),
|
|
116766
|
-
state: record2(string2(), unknown()).optional()
|
|
116767
|
-
}).strict();
|
|
116768
|
-
compositionActionSchema = ActionBindingSchema.extend({
|
|
116769
|
-
params: record2(string2(), unknown()).optional(),
|
|
116770
|
-
onSuccess: unknown().optional(),
|
|
116771
|
-
onError: unknown().optional()
|
|
116772
|
-
}).strict();
|
|
116773
|
-
probability = number2().min(0).max(1);
|
|
116774
|
-
responseSchema = object2({
|
|
116775
|
-
answers: record2(string2(), object2({ type: literal2("choice"), choice: string2() })),
|
|
116776
|
-
providerMetadata: object2({
|
|
116777
|
-
typesafe: object2({ confidence: record2(string2(), probability) }).optional()
|
|
116778
|
-
}).optional(),
|
|
116779
|
-
usage: object2({ inputTokens: number2().int().nonnegative().optional() }).optional()
|
|
116780
|
-
});
|
|
116781
|
-
});
|
|
116782
|
-
|
|
116783
|
-
// node_modules/@json-render/chat/dist/index.mjs
|
|
116784
|
-
function normalizeTableRows(props) {
|
|
116785
|
-
if (!Array.isArray(props.rows) || !Array.isArray(props.headers))
|
|
116786
|
-
return props;
|
|
116787
|
-
const headers = props.headers.map((h) => normalizeKey(String(h)));
|
|
116788
|
-
const rows = props.rows.map((row) => {
|
|
116789
|
-
if (!row || typeof row !== "object" || Array.isArray(row))
|
|
116790
|
-
return row;
|
|
116791
|
-
const entries = Object.entries(row).map(([k, v]) => [normalizeKey(k), v]);
|
|
116792
|
-
const byKey = new Map(entries);
|
|
116793
|
-
const unmatched = entries.filter(([k]) => !headers.includes(k));
|
|
116794
|
-
const rest = [
|
|
116795
|
-
...unmatched.filter(([k]) => !ID_KEYS.has(k)),
|
|
116796
|
-
...unmatched.filter(([k]) => ID_KEYS.has(k))
|
|
116797
|
-
];
|
|
116798
|
-
return headers.map((h) => byKey.has(h) ? byKey.get(h) : rest.shift()?.[1]);
|
|
116799
|
-
});
|
|
116800
|
-
return { ...props, rows };
|
|
116801
|
-
}
|
|
116802
|
-
function validateProps(elements, defs) {
|
|
116803
|
-
const issues = [];
|
|
116804
|
-
for (const [key, el] of Object.entries(elements)) {
|
|
116805
|
-
const def = defs[el.type];
|
|
116806
|
-
if (!def) {
|
|
116807
|
-
issues.push(`${key}: unknown component "${el.type}"`);
|
|
116808
|
-
continue;
|
|
116809
|
-
}
|
|
116810
|
-
const props = el.type === "Table" ? normalizeTableRows(el.props ?? {}) : el.props ?? {};
|
|
116811
|
-
const parsed = def.props.safeParse(props);
|
|
116812
|
-
if (!parsed.success) {
|
|
116813
|
-
for (const issue of parsed.error.issues)
|
|
116814
|
-
issues.push(`${key}.props.${issue.path.join(".")}: ${issue.message}`);
|
|
116815
|
-
} else {
|
|
116816
|
-
el.props = parsed.data;
|
|
116817
|
-
}
|
|
116818
|
-
}
|
|
116819
|
-
return issues;
|
|
116820
|
-
}
|
|
116821
|
-
function validateStructure(spec, elements, defs) {
|
|
116822
|
-
const issues = [];
|
|
116823
|
-
const root = elements[spec.root];
|
|
116824
|
-
if (!root)
|
|
116825
|
-
issues.push(`root "${spec.root}" is not an element`);
|
|
116826
|
-
else if (root.type !== "Card")
|
|
116827
|
-
issues.push("root must be a Card");
|
|
116828
|
-
for (const [key, el] of Object.entries(elements)) {
|
|
116829
|
-
if (el.children.length && !defs[el.type]?.slots?.length)
|
|
116830
|
-
issues.push(`${key}: ${el.type} cannot have children`);
|
|
116831
|
-
for (const childKey of el.children) {
|
|
116832
|
-
const child = elements[childKey];
|
|
116833
|
-
if (!child) {
|
|
116834
|
-
issues.push(`${key}: missing child "${childKey}"`);
|
|
116835
|
-
continue;
|
|
116836
|
-
}
|
|
116837
|
-
if (el.type === "Fields" && child.type !== "Field")
|
|
116838
|
-
issues.push(`${key}: Fields only holds Field elements`);
|
|
116839
|
-
if (el.type === "Actions" && !["Button", "LinkButton"].includes(child.type))
|
|
116840
|
-
issues.push(`${key}: Actions only holds Button and LinkButton elements`);
|
|
116841
|
-
}
|
|
116842
|
-
if (el.type === "Table") {
|
|
116843
|
-
const width = el.props.headers.length;
|
|
116844
|
-
el.props.rows.forEach((row, i) => {
|
|
116845
|
-
if (row.length !== width)
|
|
116846
|
-
issues.push(`${key}: row ${i} has ${row.length} cells, expected ${width}`);
|
|
116847
|
-
});
|
|
116848
|
-
}
|
|
116849
|
-
if (el.type === "Chart" && el.props.chart.type !== "pie") {
|
|
116850
|
-
const count = el.props.chart.categories.length;
|
|
116851
|
-
for (const series of el.props.chart.series)
|
|
116852
|
-
if (series.values.length !== count)
|
|
116853
|
-
issues.push(`${key}: series "${series.name}" has ${series.values.length} values, expected ${count}`);
|
|
116854
|
-
}
|
|
116855
|
-
}
|
|
116856
|
-
return issues;
|
|
116857
|
-
}
|
|
116858
|
-
function validateLimits(elements, limits) {
|
|
116859
|
-
const issues = [];
|
|
116860
|
-
const all = Object.entries(elements);
|
|
116861
|
-
const count = (type) => all.filter(([, el]) => el.type === type).length;
|
|
116862
|
-
const over = (value, max) => max !== undefined && value > max;
|
|
116863
|
-
if (over(count("Table"), limits.tables))
|
|
116864
|
-
issues.push(`at most ${limits.tables} Table per message`);
|
|
116865
|
-
if (over(count("Chart"), limits.charts))
|
|
116866
|
-
issues.push(`at most ${limits.charts} Chart per message`);
|
|
116867
|
-
for (const [key, el] of all) {
|
|
116868
|
-
const p = el.props;
|
|
116869
|
-
if (el.type === "Fields" && over(el.children.length, limits.fields))
|
|
116870
|
-
issues.push(`${key}: at most ${limits.fields} fields`);
|
|
116871
|
-
if (el.type === "Table") {
|
|
116872
|
-
if (over(p.rows.length + 1, limits.tableRows))
|
|
116873
|
-
issues.push(`${key}: at most ${limits.tableRows} rows including the header`);
|
|
116874
|
-
if (over(p.headers.length, limits.tableColumns))
|
|
116875
|
-
issues.push(`${key}: at most ${limits.tableColumns} columns`);
|
|
116876
|
-
}
|
|
116877
|
-
if (el.type === "Chart") {
|
|
116878
|
-
const c = p.chart;
|
|
116879
|
-
if (over(p.title.length, limits.chartTitle))
|
|
116880
|
-
issues.push(`${key}: title longer than ${limits.chartTitle} characters`);
|
|
116881
|
-
const labels = c.type === "pie" ? c.segments.map((s) => s.label) : [...c.categories, ...c.series.map((s) => s.name)];
|
|
116882
|
-
for (const label of labels)
|
|
116883
|
-
if (over(label.length, limits.chartLabel))
|
|
116884
|
-
issues.push(`${key}: label "${label}" longer than ${limits.chartLabel} characters`);
|
|
116885
|
-
const groups = c.type === "pie" ? c.segments.length : c.series.length;
|
|
116886
|
-
if (over(groups, limits.chartSeries))
|
|
116887
|
-
issues.push(`${key}: at most ${limits.chartSeries} series or segments`);
|
|
116888
|
-
if (c.type !== "pie" && over(c.categories.length, limits.chartPoints))
|
|
116889
|
-
issues.push(`${key}: at most ${limits.chartPoints} categories`);
|
|
116890
|
-
}
|
|
116891
|
-
}
|
|
116892
|
-
return issues;
|
|
116893
|
-
}
|
|
116894
|
-
function toChild(key, elements) {
|
|
116895
|
-
const el = elements[key];
|
|
116896
|
-
const p = el.props;
|
|
116897
|
-
const children = () => el.children.map((k) => elements[k]);
|
|
116898
|
-
switch (el.type) {
|
|
116899
|
-
case "Section":
|
|
116900
|
-
return section(el.children.map((k) => toChild(k, elements)));
|
|
116901
|
-
case "Card":
|
|
116902
|
-
return section([
|
|
116903
|
-
...p.title ? [text2(p.title, "bold")] : [],
|
|
116904
|
-
...p.subtitle ? [text2(p.subtitle, "muted")] : [],
|
|
116905
|
-
...el.children.map((k) => toChild(k, elements))
|
|
116906
|
-
]);
|
|
116907
|
-
case "Text":
|
|
116908
|
-
return text2(p.content, p.style ?? undefined);
|
|
116909
|
-
case "Divider":
|
|
116910
|
-
return divider();
|
|
116911
|
-
case "Image":
|
|
116912
|
-
return image(p.url, p.alt);
|
|
116913
|
-
case "Fields":
|
|
116914
|
-
return fields(children().map((f) => field2(f.props.label, f.props.value)));
|
|
116915
|
-
case "Table":
|
|
116916
|
-
return table({
|
|
116917
|
-
headers: p.headers,
|
|
116918
|
-
rows: p.rows,
|
|
116919
|
-
align: p.align ?? undefined,
|
|
116920
|
-
caption: p.caption ?? undefined
|
|
116921
|
-
});
|
|
116922
|
-
case "Chart": {
|
|
116923
|
-
const c = p.chart;
|
|
116924
|
-
return chart({
|
|
116925
|
-
title: p.title,
|
|
116926
|
-
chart: c.type === "pie" ? { type: "pie", segments: c.segments } : {
|
|
116927
|
-
type: c.type,
|
|
116928
|
-
categories: c.categories,
|
|
116929
|
-
xLabel: c.xLabel ?? undefined,
|
|
116930
|
-
yLabel: c.yLabel ?? undefined,
|
|
116931
|
-
series: c.series.map((s) => ({
|
|
116932
|
-
name: s.name,
|
|
116933
|
-
data: s.values.map((value, i) => ({
|
|
116934
|
-
label: c.categories[i],
|
|
116935
|
-
value
|
|
116936
|
-
}))
|
|
116937
|
-
}))
|
|
116938
|
-
}
|
|
116939
|
-
});
|
|
116940
|
-
}
|
|
116941
|
-
case "Actions":
|
|
116942
|
-
return actions(children().map((b) => b.type === "LinkButton" ? linkButton({ label: b.props.label, url: b.props.url }) : button({
|
|
116943
|
-
id: b.props.id,
|
|
116944
|
-
label: b.props.label,
|
|
116945
|
-
style: b.props.style ?? undefined,
|
|
116946
|
-
value: b.props.value ?? undefined
|
|
116947
|
-
})));
|
|
116948
|
-
default:
|
|
116949
|
-
throw new CardSpecError([`${key}: ${el.type} cannot be nested here`]);
|
|
116950
|
-
}
|
|
116951
|
-
}
|
|
116952
|
-
function materialize(spec, maxElements) {
|
|
116953
|
-
const source = spec.elements ?? {};
|
|
116954
|
-
const stateModel = spec.state ?? {};
|
|
116955
|
-
const out = {};
|
|
116956
|
-
const missing = [];
|
|
116957
|
-
const seen = /* @__PURE__ */ new Set;
|
|
116958
|
-
let budget = maxElements;
|
|
116959
|
-
let overflow = false;
|
|
116960
|
-
const spend = () => {
|
|
116961
|
-
if (budget <= 0) {
|
|
116962
|
-
overflow = true;
|
|
116963
|
-
return false;
|
|
116964
|
-
}
|
|
116965
|
-
budget -= 1;
|
|
116966
|
-
return true;
|
|
116967
|
-
};
|
|
116968
|
-
const itemsAt = (repeat, ctx) => {
|
|
116969
|
-
const path = resolveRepeatStatePath(repeat.statePath, ctx.repeatBasePath);
|
|
116970
|
-
const items = path ? getByPath(stateModel, path) : undefined;
|
|
116971
|
-
return { path: path ?? "", items: Array.isArray(items) ? items : [] };
|
|
116972
|
-
};
|
|
116973
|
-
const itemContext = (path, item, index) => ({
|
|
116974
|
-
stateModel,
|
|
116975
|
-
repeatItem: item,
|
|
116976
|
-
repeatIndex: index,
|
|
116977
|
-
repeatBasePath: resolveRepeatItemStatePath(path, index)
|
|
116978
|
-
});
|
|
116979
|
-
const visit = (key, outKey, ctx) => {
|
|
116980
|
-
const el = source[key];
|
|
116981
|
-
if (!el?.type) {
|
|
116982
|
-
missing.push(key);
|
|
116983
|
-
return false;
|
|
116984
|
-
}
|
|
116985
|
-
if (seen.has(outKey))
|
|
116986
|
-
return false;
|
|
116987
|
-
const { container, itemFilter } = el.repeat && ctx.repeatIndex === undefined ? splitRepeatVisibility(el.visible) : { container: el.visible, itemFilter: undefined };
|
|
116988
|
-
if (container !== undefined && !evaluateVisibility(container, ctx))
|
|
116989
|
-
return false;
|
|
116990
|
-
if (!spend())
|
|
116991
|
-
return false;
|
|
116992
|
-
seen.add(outKey);
|
|
116993
|
-
const props = el.props ?? {};
|
|
116994
|
-
const childKeys = el.children ?? [];
|
|
116995
|
-
const children = [];
|
|
116996
|
-
const repeat = el.repeat;
|
|
116997
|
-
const keep = (path, item, index) => itemFilter === undefined || evaluateVisibility(itemFilter, itemContext(path, item, index));
|
|
116998
|
-
if (repeat && el.type === "Table" && Array.isArray(props.rows)) {
|
|
116999
|
-
const { path, items } = itemsAt(repeat, ctx);
|
|
117000
|
-
const rows = [];
|
|
117001
|
-
for (let index = 0;index < items.length && !overflow; index++) {
|
|
117002
|
-
if (!keep(path, items[index], index))
|
|
117003
|
-
continue;
|
|
117004
|
-
const itemCtx = itemContext(path, items[index], index);
|
|
117005
|
-
for (const row of props.rows) {
|
|
117006
|
-
if (!spend())
|
|
117007
|
-
break;
|
|
117008
|
-
rows.push(resolveElementProps({ row }, itemCtx).row);
|
|
117009
|
-
}
|
|
117010
|
-
}
|
|
117011
|
-
out[outKey] = {
|
|
117012
|
-
type: el.type,
|
|
117013
|
-
props: { ...resolveElementProps(props, ctx), rows },
|
|
117014
|
-
children: []
|
|
117015
|
-
};
|
|
117016
|
-
return true;
|
|
117017
|
-
}
|
|
117018
|
-
if (repeat) {
|
|
117019
|
-
const { path, items } = itemsAt(repeat, ctx);
|
|
117020
|
-
const scope = outKey === key ? "" : `${outKey}.`;
|
|
117021
|
-
for (let index = 0;index < items.length && !overflow; index++) {
|
|
117022
|
-
if (!keep(path, items[index], index))
|
|
117023
|
-
continue;
|
|
117024
|
-
const itemCtx = itemContext(path, items[index], index);
|
|
117025
|
-
for (const child of childKeys) {
|
|
117026
|
-
const childOut = `${child}#${scope}${index}`;
|
|
117027
|
-
if (visit(child, childOut, itemCtx))
|
|
117028
|
-
children.push(childOut);
|
|
117029
|
-
}
|
|
117030
|
-
}
|
|
117031
|
-
} else {
|
|
117032
|
-
const suffix = outKey.slice(key.length);
|
|
117033
|
-
for (const child of childKeys)
|
|
117034
|
-
if (visit(child, child + suffix, ctx))
|
|
117035
|
-
children.push(child + suffix);
|
|
117036
|
-
}
|
|
117037
|
-
out[outKey] = {
|
|
117038
|
-
type: el.type,
|
|
117039
|
-
props: resolveElementProps(props, ctx),
|
|
117040
|
-
children
|
|
117041
|
-
};
|
|
117042
|
-
return true;
|
|
117043
|
-
};
|
|
117044
|
-
if (spec.root)
|
|
117045
|
-
visit(spec.root, spec.root, { stateModel });
|
|
117046
|
-
return { elements: out, missing, overflow };
|
|
117047
|
-
}
|
|
117048
|
-
function prune(elements, rootKey) {
|
|
117049
|
-
const kept = /* @__PURE__ */ new Map;
|
|
117050
|
-
const visit = (key) => {
|
|
117051
|
-
const cached = kept.get(key);
|
|
117052
|
-
if (cached !== undefined)
|
|
117053
|
-
return cached;
|
|
117054
|
-
kept.set(key, false);
|
|
117055
|
-
const el = elements[key];
|
|
117056
|
-
if (!el)
|
|
117057
|
-
return false;
|
|
117058
|
-
const accepts = ACCEPTS[el.type];
|
|
117059
|
-
el.children = el.children.filter((child) => elements[child] !== undefined && (!accepts || accepts.includes(elements[child].type)) && visit(child));
|
|
117060
|
-
const keep = key === rootKey || (GROUPS.has(el.type) ? el.children.length > 0 : el.type !== "Card" || hasContent(el));
|
|
117061
|
-
kept.set(key, keep);
|
|
117062
|
-
return keep;
|
|
117063
|
-
};
|
|
117064
|
-
visit(rootKey);
|
|
117065
|
-
}
|
|
117066
|
-
function buildCard(root, elements, keys) {
|
|
117067
|
-
return card({
|
|
117068
|
-
title: root.props.title ?? undefined,
|
|
117069
|
-
subtitle: root.props.subtitle ?? undefined,
|
|
117070
|
-
imageUrl: root.props.imageUrl ?? undefined,
|
|
117071
|
-
children: keys.map((k) => toChild(k, elements))
|
|
117072
|
-
});
|
|
117073
|
-
}
|
|
117074
|
-
function toCard(spec, options = {}) {
|
|
117075
|
-
const defs = options.components ?? standardComponentDefinitions;
|
|
117076
|
-
if (!spec || typeof spec.root !== "string" || !spec.elements)
|
|
117077
|
-
throw new CardSpecError(["spec needs a root and elements"]);
|
|
117078
|
-
const maxElements = options.maxElements ?? DEFAULT_MAX_ELEMENTS;
|
|
117079
|
-
const { elements, missing, overflow } = materialize(spec, maxElements);
|
|
117080
|
-
if (overflow)
|
|
117081
|
-
throw new CardSpecError([
|
|
117082
|
-
`the spec expands to more than ${maxElements} elements and table rows`
|
|
117083
|
-
]);
|
|
117084
|
-
let issues = validateProps(elements, defs);
|
|
117085
|
-
if (!issues.length)
|
|
117086
|
-
issues = [
|
|
117087
|
-
...missing.map((key) => `missing element "${key}"`),
|
|
117088
|
-
...validateStructure(spec, elements, defs)
|
|
117089
|
-
];
|
|
117090
|
-
if (!issues.length) {
|
|
117091
|
-
prune(elements, spec.root);
|
|
117092
|
-
if (!hasContent(elements[spec.root]))
|
|
117093
|
-
issues.push("the Card needs a title, an image or at least one child");
|
|
117094
|
-
}
|
|
117095
|
-
if (!issues.length && options.limits)
|
|
117096
|
-
issues = validateLimits(elements, options.limits);
|
|
117097
|
-
if (issues.length)
|
|
117098
|
-
throw new CardSpecError(issues);
|
|
117099
|
-
const root = elements[spec.root];
|
|
117100
|
-
return buildCard(root, elements, root.children);
|
|
117101
|
-
}
|
|
117102
|
-
var schema, displayText, pieChart, seriesChart, standardComponentDefinitions, card = (options) => ({ type: "card", ...options }), text2 = (content, style) => ({ type: "text", content, style }), image = (url, alt) => ({
|
|
117103
|
-
type: "image",
|
|
117104
|
-
url,
|
|
117105
|
-
alt
|
|
117106
|
-
}), divider = () => ({ type: "divider" }), section = (children) => ({
|
|
117107
|
-
type: "section",
|
|
117108
|
-
children
|
|
117109
|
-
}), field2 = (label, value) => ({
|
|
117110
|
-
type: "field",
|
|
117111
|
-
label,
|
|
117112
|
-
value
|
|
117113
|
-
}), fields = (children) => ({
|
|
117114
|
-
type: "fields",
|
|
117115
|
-
children
|
|
117116
|
-
}), table = (options) => ({
|
|
117117
|
-
type: "table",
|
|
117118
|
-
...options
|
|
117119
|
-
}), chart = (options) => ({
|
|
117120
|
-
type: "chart",
|
|
117121
|
-
...options
|
|
117122
|
-
}), button = (options) => ({ type: "button", ...options }), linkButton = (options) => ({ type: "link-button", ...options }), actions = (children) => ({ type: "actions", children }), DEFAULT_MAX_ELEMENTS = 1000, CardSpecError, normalizeKey = (value) => value.toLowerCase().replace(/[^a-z0-9]/g, ""), ID_KEYS, ACCEPTS, GROUPS, hasContent = (el) => Boolean(el.props.title || el.props.subtitle || el.props.imageUrl || el.children.length);
|
|
117123
|
-
var init_dist3 = __esm(() => {
|
|
117124
|
-
init_dist2();
|
|
117125
|
-
init_zod();
|
|
117126
|
-
init_dist2();
|
|
117127
|
-
init_dist2();
|
|
117128
|
-
schema = defineSchema((s) => ({
|
|
117129
|
-
spec: s.object({
|
|
117130
|
-
root: s.string(),
|
|
117131
|
-
elements: s.record(s.object({
|
|
117132
|
-
type: s.ref("catalog.components"),
|
|
117133
|
-
props: s.propsOf("catalog.components"),
|
|
117134
|
-
children: s.array(s.string()),
|
|
117135
|
-
visible: { ...s.any(), ...s.optional() },
|
|
117136
|
-
repeat: { ...s.any(), ...s.optional() }
|
|
117137
|
-
}))
|
|
117138
|
-
}),
|
|
117139
|
-
catalog: s.object({
|
|
117140
|
-
components: s.map({
|
|
117141
|
-
props: s.zod(),
|
|
117142
|
-
slots: s.array(s.string()),
|
|
117143
|
-
description: s.string(),
|
|
117144
|
-
example: s.any()
|
|
117145
|
-
})
|
|
117146
|
-
})
|
|
117147
|
-
}), {
|
|
117148
|
-
defaultRules: [
|
|
117149
|
-
"The root element MUST be a Card. Every other element is a descendant of it. To group items inside the message, use Section, not another Card.",
|
|
117150
|
-
"Messages are static once posted. $state, $item, $index, $template, repeat and visible are resolved when the card is built, but there are no inputs, so do not use $bindState or $bindItem.",
|
|
117151
|
-
"Pick components by the shape of the data: Fields for a few key numbers, Table for row data, Chart for a trend or a share of a whole, Actions for next steps.",
|
|
117152
|
-
'For a Table backed by state, set rows to { "$state": "/path" } where the path holds an array of rows (arrays or objects with one value per header).',
|
|
117153
|
-
"Text content uses markdown: **bold**, _italic_, `code` and [label](https://url). Do not use headings inside Text.",
|
|
117154
|
-
"Field elements MUST be children of a Fields element. Button and LinkButton elements MUST be children of an Actions element.",
|
|
117155
|
-
"Every series in a bar, line or area Chart has exactly one value per category, in category order.",
|
|
117156
|
-
'Every element MUST include a "children" array. Leaf elements use "children": [].'
|
|
117157
|
-
]
|
|
117158
|
-
});
|
|
117159
|
-
displayText = union3([string2(), number2()]).transform(String);
|
|
117160
|
-
pieChart = object2({
|
|
117161
|
-
type: literal2("pie"),
|
|
117162
|
-
segments: array2(object2({ label: string2().min(1), value: number2().positive() })).min(1)
|
|
117163
|
-
});
|
|
117164
|
-
seriesChart = object2({
|
|
117165
|
-
type: _enum2(["bar", "line", "area"]),
|
|
117166
|
-
categories: array2(string2().min(1)).min(1),
|
|
117167
|
-
series: array2(object2({ name: string2().min(1), values: array2(number2()) })).min(1),
|
|
117168
|
-
xLabel: string2().nullish(),
|
|
117169
|
-
yLabel: string2().nullish()
|
|
117170
|
-
});
|
|
117171
|
-
standardComponentDefinitions = {
|
|
117172
|
-
Card: {
|
|
117173
|
-
props: object2({
|
|
117174
|
-
title: string2().nullish(),
|
|
117175
|
-
subtitle: string2().nullish(),
|
|
117176
|
-
imageUrl: string2().url().nullish()
|
|
117177
|
-
}),
|
|
117178
|
-
slots: ["default"],
|
|
117179
|
-
description: "Root of a message. Title renders as the card header, subtitle as secondary text.",
|
|
117180
|
-
example: { title: "Weekly deploys", subtitle: "Oct 27 to Nov 2" }
|
|
117181
|
-
},
|
|
117182
|
-
Section: {
|
|
117183
|
-
props: object2({}),
|
|
117184
|
-
slots: ["default"],
|
|
117185
|
-
description: "Groups related elements.",
|
|
117186
|
-
example: {}
|
|
117187
|
-
},
|
|
117188
|
-
Text: {
|
|
117189
|
-
props: object2({
|
|
117190
|
-
content: string2().min(1),
|
|
117191
|
-
style: _enum2(["plain", "bold", "muted"]).nullish()
|
|
117192
|
-
}),
|
|
117193
|
-
slots: [],
|
|
117194
|
-
description: "A paragraph of markdown text. Use muted for footnotes.",
|
|
117195
|
-
example: { content: "Deploys are **up 12%** week over week." }
|
|
117196
|
-
},
|
|
117197
|
-
Fields: {
|
|
117198
|
-
props: object2({}),
|
|
117199
|
-
slots: ["default"],
|
|
117200
|
-
description: "Grid of label and value pairs. Children are Field elements.",
|
|
117201
|
-
example: {}
|
|
117202
|
-
},
|
|
117203
|
-
Field: {
|
|
117204
|
-
props: object2({ label: string2().min(1), value: displayText }),
|
|
117205
|
-
slots: [],
|
|
117206
|
-
description: "One label and value pair inside Fields. Good for KPIs.",
|
|
117207
|
-
example: { label: "Deploys", value: "1,284" }
|
|
117208
|
-
},
|
|
117209
|
-
Table: {
|
|
117210
|
-
props: object2({
|
|
117211
|
-
headers: array2(string2()).min(1),
|
|
117212
|
-
rows: array2(array2(displayText)),
|
|
117213
|
-
align: array2(_enum2(["left", "center", "right"])).nullish(),
|
|
117214
|
-
caption: string2().nullish()
|
|
117215
|
-
}),
|
|
117216
|
-
slots: [],
|
|
117217
|
-
description: "Table for row data. Every row has one cell per header. Right-align numeric columns.",
|
|
117218
|
-
example: {
|
|
117219
|
-
headers: ["Project", "Deploys"],
|
|
117220
|
-
rows: [
|
|
117221
|
-
["web", "412"],
|
|
117222
|
-
["api", "203"]
|
|
117223
|
-
],
|
|
117224
|
-
align: ["left", "right"]
|
|
117225
|
-
}
|
|
117226
|
-
},
|
|
117227
|
-
Chart: {
|
|
117228
|
-
props: object2({
|
|
117229
|
-
title: string2().min(1),
|
|
117230
|
-
chart: union3([pieChart, seriesChart])
|
|
117231
|
-
}),
|
|
117232
|
-
slots: [],
|
|
117233
|
-
description: "Chart. pie for shares of a whole, bar, line or area for series over categories.",
|
|
117234
|
-
example: {
|
|
117235
|
-
title: "Deploys per day",
|
|
117236
|
-
chart: {
|
|
117237
|
-
type: "bar",
|
|
117238
|
-
categories: ["Mon", "Tue", "Wed"],
|
|
117239
|
-
series: [{ name: "Deploys", values: [180, 210, 195] }]
|
|
117240
|
-
}
|
|
117241
|
-
}
|
|
117242
|
-
},
|
|
117243
|
-
Divider: {
|
|
117244
|
-
props: object2({}),
|
|
117245
|
-
slots: [],
|
|
117246
|
-
description: "Separator between groups.",
|
|
117247
|
-
example: {}
|
|
117248
|
-
},
|
|
117249
|
-
Image: {
|
|
117250
|
-
props: object2({ url: string2().url(), alt: string2().min(1) }),
|
|
117251
|
-
slots: [],
|
|
117252
|
-
description: "Image from a public https URL.",
|
|
117253
|
-
example: { url: "https://picsum.photos/600/300", alt: "Preview" }
|
|
117254
|
-
},
|
|
117255
|
-
Actions: {
|
|
117256
|
-
props: object2({}),
|
|
117257
|
-
slots: ["default"],
|
|
117258
|
-
description: "Row of Button and LinkButton elements.",
|
|
117259
|
-
example: {}
|
|
117260
|
-
},
|
|
117261
|
-
Button: {
|
|
117262
|
-
props: object2({
|
|
117263
|
-
id: string2().min(1),
|
|
117264
|
-
label: string2().min(1),
|
|
117265
|
-
style: _enum2(["primary", "danger", "default"]).nullish(),
|
|
117266
|
-
value: string2().nullish()
|
|
117267
|
-
}),
|
|
117268
|
-
slots: [],
|
|
117269
|
-
description: "Interactive button. id is the action id the bot handles with onAction.",
|
|
117270
|
-
example: { id: "approve", label: "Approve", style: "primary" }
|
|
117271
|
-
},
|
|
117272
|
-
LinkButton: {
|
|
117273
|
-
props: object2({ label: string2().min(1), url: string2().url() }),
|
|
117274
|
-
slots: [],
|
|
117275
|
-
description: "Button that opens a URL.",
|
|
117276
|
-
example: { label: "Open dashboard", url: "https://vercel.com" }
|
|
117277
|
-
}
|
|
117278
|
-
};
|
|
117279
|
-
CardSpecError = class extends Error {
|
|
117280
|
-
constructor(issues) {
|
|
117281
|
-
super(issues.join(`
|
|
117282
|
-
`));
|
|
117283
|
-
this.issues = issues;
|
|
117284
|
-
this.name = "CardSpecError";
|
|
117285
|
-
}
|
|
117286
|
-
};
|
|
117287
|
-
ID_KEYS = /* @__PURE__ */ new Set(["id", "key", "uuid"]);
|
|
117288
|
-
ACCEPTS = {
|
|
117289
|
-
Fields: ["Field"],
|
|
117290
|
-
Actions: ["Button", "LinkButton"]
|
|
117291
|
-
};
|
|
117292
|
-
GROUPS = /* @__PURE__ */ new Set(["Fields", "Actions", "Section"]);
|
|
117293
|
-
});
|
|
117294
|
-
|
|
117295
115544
|
// src/integrations/cards/index.ts
|
|
117296
115545
|
function renderCard(spec) {
|
|
117297
115546
|
let card;
|
|
@@ -117317,7 +115566,7 @@ ${issues.map((issue) => `- ${issue}`).join(`
|
|
|
117317
115566
|
`)}`;
|
|
117318
115567
|
}
|
|
117319
115568
|
async function cardToSlack(card) {
|
|
117320
|
-
const { cardToBlockKit, cardToFallbackText } = await import("./index-
|
|
115569
|
+
const { cardToBlockKit, cardToFallbackText } = await import("./index-620y7jzq.js");
|
|
117321
115570
|
const issues = cardChildren(card).flatMap((child) => {
|
|
117322
115571
|
const native = NATIVE_SLACK_BLOCKS[child.type];
|
|
117323
115572
|
if (!native)
|
|
@@ -117346,7 +115595,7 @@ function slackFallbackText(message, cardText) {
|
|
|
117346
115595
|
}
|
|
117347
115596
|
var _button, standard, chatCardComponents, CARD_LIMITS, TABLE_MAX_CELL_CHARS = 1e4, catalogLines, CARD_RULES = 'Every element has "children" (leaves use []). Field goes inside Fields, LinkButton inside Actions. A bar, line or area Chart has one value per category per series; a pie Chart uses {"type":"pie","segments":[{"label","value"}]}.', cardSpecInputSchema, NATIVE_SLACK_BLOCKS;
|
|
117348
115597
|
var init_cards = __esm(() => {
|
|
117349
|
-
|
|
115598
|
+
init_dist5();
|
|
117350
115599
|
init_zod();
|
|
117351
115600
|
({ Button: _button, ...standard } = standardComponentDefinitions);
|
|
117352
115601
|
chatCardComponents = {
|
|
@@ -122618,7 +120867,7 @@ var DeferAbortedError, registerDeferTaskTool = (server) => {
|
|
|
122618
120867
|
message: "Provide exactly one of wakeOn.taskId or wakeOn.taskIds."
|
|
122619
120868
|
}).refine((wake) => !wake.taskIds || new Set(wake.taskIds).size === wake.taskIds.length, {
|
|
122620
120869
|
message: "wakeOn.taskIds must not contain duplicates."
|
|
122621
|
-
}).optional().describe("Wake early on a task event. Provide taskId or nonempty, unique taskIds. mode defaults to all (every member must match); any wakes on the first match. settled covers completed, failed, cancelled, or skipped. Deferred and superseded members follow their continuations; a superseded member without a resume child holds to the ceiling. Any already-terminal member rejects the request; one delayMs/runAt ceiling is still required for the whole set. The member whose settlement wakes you creates no separate lead follow-up for your agent unless its followUpConfig sets onCompleted/onFailed; an all-mode member that settles while others are pending still does."),
|
|
120870
|
+
}).optional().describe("Wake early on a task event. Provide taskId or nonempty, unique taskIds. mode defaults to all (every member must match); any wakes on the first match. settled covers completed, failed, cancelled, or skipped. Deferred and superseded members follow their continuations; a superseded member without a resume child holds to the ceiling, except a workflow step superseded by its queued retry, which counts as failed. Any already-terminal member rejects the request; one delayMs/runAt ceiling is still required for the whole set. The member whose settlement wakes you creates no separate lead follow-up for your agent unless its followUpConfig sets onCompleted/onFailed; an all-mode member that settles while others are pending still does."),
|
|
122622
120871
|
summary: string2().min(1).max(4000).describe("What you did so far and where things stand. Stored in the task log for tasks with an outputSchema; otherwise becomes the task's output."),
|
|
122623
120872
|
output: string2().optional().describe("Required when the task has an outputSchema: a JSON string matching that schema, stored verbatim as terminal output. Ignored for tasks without an outputSchema."),
|
|
122624
120873
|
note: string2().min(1).max(2000).describe("What is pending, and what to check on wake-up."),
|
|
@@ -125761,6 +124010,32 @@ var init_memory_rate = __esm(() => {
|
|
|
125761
124010
|
REFERENCES_SOURCE_DESCRIPTION = "Optional external source ID this memory references. Free-form string, " + 'convention "<source>:<identifier>" (e.g. "github:owner/repo#N", ' + '"linear:KEY-N", "customer:<slug>", "slack:<channel>:<ts>", ' + '"agentmail:<thread-id>"). Pick any prefix that fits — no closed enum. ' + "When present, an edge from this memory to the external source is " + "created/updated.";
|
|
125762
124011
|
});
|
|
125763
124012
|
|
|
124013
|
+
// src/be/memory/demotion-evidence.ts
|
|
124014
|
+
async function attachDemotionEvidence(candidates) {
|
|
124015
|
+
const ids = [...new Set(candidates.filter((c) => c.beta > c.alpha).map((c) => c.id))];
|
|
124016
|
+
if (ids.length === 0)
|
|
124017
|
+
return candidates;
|
|
124018
|
+
const rows = await getDbClient2().query(`SELECT memoryId,
|
|
124019
|
+
SUM(CASE WHEN source = 'explicit-self' AND signal > 0 THEN signal * weight ELSE 0 END) AS selfAlpha,
|
|
124020
|
+
SUM(CASE WHEN source = 'explicit-self' AND signal < 0 THEN -signal * weight ELSE 0 END) AS selfBeta,
|
|
124021
|
+
SUM(CASE WHEN source = 'llm' AND signal > 0 THEN signal * weight ELSE 0 END) AS llmAlpha,
|
|
124022
|
+
SUM(CASE WHEN source = 'llm' AND signal < 0 THEN -signal * weight ELSE 0 END) AS llmBeta,
|
|
124023
|
+
SUM(CASE WHEN source = 'llm' THEN 1 ELSE 0 END) AS llmCount
|
|
124024
|
+
FROM memory_rating
|
|
124025
|
+
WHERE source IN ('explicit-self', 'llm') AND memoryId IN (${ids.map(() => "?").join(", ")})
|
|
124026
|
+
GROUP BY memoryId`, ids);
|
|
124027
|
+
if (rows.length === 0)
|
|
124028
|
+
return candidates;
|
|
124029
|
+
const byId = new Map(rows.map(({ memoryId, ...evidence }) => [memoryId, evidence]));
|
|
124030
|
+
return candidates.map((c) => {
|
|
124031
|
+
const demotionEvidence = byId.get(c.id);
|
|
124032
|
+
return demotionEvidence ? { ...c, demotionEvidence } : c;
|
|
124033
|
+
});
|
|
124034
|
+
}
|
|
124035
|
+
var init_demotion_evidence = __esm(() => {
|
|
124036
|
+
init_db4();
|
|
124037
|
+
});
|
|
124038
|
+
|
|
125764
124039
|
// src/be/memory/graph-expansion.ts
|
|
125765
124040
|
function addNeighborScopeConditions(conditions, params, agentId, scope, isLead) {
|
|
125766
124041
|
if (!isLead) {
|
|
@@ -125903,22 +124178,25 @@ var NUDGE_ELIGIBLE_SOURCES2, memorySearchOutputSchema, registerMemorySearchTool
|
|
|
125903
124178
|
const store = getMemoryStore2();
|
|
125904
124179
|
const queryEmbedding = await provider.embed(query, { kind: "query" });
|
|
125905
124180
|
const candidateLimit = limit * CANDIDATE_SET_MULTIPLIER;
|
|
124181
|
+
const excludeReviewTaskCompletions = await isReviewTaskId(requestInfo.sourceTaskId);
|
|
125906
124182
|
const candidates = await searchMemoryCandidates(store, queryEmbedding ?? new Float32Array(0), requestInfo.agentId, {
|
|
125907
124183
|
scope,
|
|
125908
124184
|
limit: candidateLimit,
|
|
125909
124185
|
source,
|
|
125910
124186
|
isLead,
|
|
125911
124187
|
queryText: query,
|
|
125912
|
-
keyPrefix
|
|
124188
|
+
keyPrefix,
|
|
124189
|
+
excludeReviewTaskCompletions
|
|
125913
124190
|
});
|
|
125914
|
-
const
|
|
124191
|
+
const graphExpanded = await expandCandidatesWithGraph(candidates, requestInfo.agentId, {
|
|
125915
124192
|
scope,
|
|
125916
124193
|
source,
|
|
125917
124194
|
keyPrefix,
|
|
125918
124195
|
isLead
|
|
125919
124196
|
});
|
|
124197
|
+
const expanded = excludeReviewTaskCompletions ? await dropReviewTaskCompletions(graphExpanded) : graphExpanded;
|
|
125920
124198
|
if (expanded.length > 0) {
|
|
125921
|
-
const ranked = rerank(expanded, { limit });
|
|
124199
|
+
const ranked = rerank(await attachDemotionEvidence(expanded), { limit });
|
|
125922
124200
|
if (requestInfo.sourceTaskId) {
|
|
125923
124201
|
try {
|
|
125924
124202
|
await recordRetrievals(requestInfo.sourceTaskId, requestInfo.agentId, ranked.map((r) => ({
|
|
@@ -125957,13 +124235,14 @@ var NUDGE_ELIGIBLE_SOURCES2, memorySearchOutputSchema, registerMemorySearchTool
|
|
|
125957
124235
|
data: { yourAgentId: requestInfo.agentId, results: mapped }
|
|
125958
124236
|
});
|
|
125959
124237
|
}
|
|
125960
|
-
const
|
|
124238
|
+
const listed = await store.list(requestInfo.agentId, {
|
|
125961
124239
|
scope,
|
|
125962
124240
|
limit,
|
|
125963
124241
|
isLead,
|
|
125964
124242
|
source,
|
|
125965
124243
|
keyPrefix
|
|
125966
124244
|
});
|
|
124245
|
+
const recent = excludeReviewTaskCompletions ? await dropReviewTaskCompletions(listed) : listed;
|
|
125967
124246
|
const consumedIds = dedupeMemoryDocumentIds(recent);
|
|
125968
124247
|
try {
|
|
125969
124248
|
await recordMemoryAccesses(consumedIds);
|
|
@@ -125992,10 +124271,12 @@ var init_memory_search = __esm(() => {
|
|
|
125992
124271
|
init_db4();
|
|
125993
124272
|
init_memory();
|
|
125994
124273
|
init_constants2();
|
|
124274
|
+
init_demotion_evidence();
|
|
125995
124275
|
init_graph_expansion();
|
|
125996
124276
|
init_key_paths();
|
|
125997
124277
|
init_retrieval();
|
|
125998
124278
|
init_reranker();
|
|
124279
|
+
init_review_recall_filter();
|
|
125999
124280
|
init_search_candidates();
|
|
126000
124281
|
init_utils();
|
|
126001
124282
|
init_types5();
|
|
@@ -128800,7 +127081,7 @@ class StringDecoder {
|
|
|
128800
127081
|
return res;
|
|
128801
127082
|
}
|
|
128802
127083
|
}
|
|
128803
|
-
var errorUnexpectedEndOfArray, errorIntegerOutOfRange, createDecoder = (uint8Array) => new Decoder(uint8Array),
|
|
127084
|
+
var errorUnexpectedEndOfArray, errorIntegerOutOfRange, createDecoder = (uint8Array) => new Decoder(uint8Array), hasContent = (decoder) => decoder.pos !== decoder.arr.length, readUint8Array = (decoder, len) => {
|
|
128804
127085
|
const view = new Uint8Array(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len);
|
|
128805
127086
|
decoder.pos += len;
|
|
128806
127087
|
return view;
|
|
@@ -128917,7 +127198,7 @@ var init_decoding = __esm(() => {
|
|
|
128917
127198
|
read() {
|
|
128918
127199
|
if (this.count === 0) {
|
|
128919
127200
|
this.s = this.reader(this);
|
|
128920
|
-
if (
|
|
127201
|
+
if (hasContent(this)) {
|
|
128921
127202
|
this.count = readVarUint(this) + 1;
|
|
128922
127203
|
} else {
|
|
128923
127204
|
this.count = -1;
|
|
@@ -133606,7 +131887,7 @@ function yToJson(value, depth = 0) {
|
|
|
133606
131887
|
throw new Error("room document contains a non-JSON value");
|
|
133607
131888
|
return value;
|
|
133608
131889
|
}
|
|
133609
|
-
function
|
|
131890
|
+
function materialize(doc) {
|
|
133610
131891
|
return yToJson(doc.getMap("root"));
|
|
133611
131892
|
}
|
|
133612
131893
|
function pathLabel(path) {
|
|
@@ -133761,7 +132042,7 @@ function applyOperations(doc, operations) {
|
|
|
133761
132042
|
try {
|
|
133762
132043
|
applyUpdate(candidate, encodeStateAsUpdate(doc));
|
|
133763
132044
|
applyUnchecked(candidate, parsed);
|
|
133764
|
-
|
|
132045
|
+
materialize(candidate);
|
|
133765
132046
|
} finally {
|
|
133766
132047
|
candidate.destroy();
|
|
133767
132048
|
}
|
|
@@ -133986,7 +132267,7 @@ function validateDocument(doc) {
|
|
|
133986
132267
|
if (key !== "root")
|
|
133987
132268
|
throw new Error(`room update contains unsupported shared type "${key}"`);
|
|
133988
132269
|
}
|
|
133989
|
-
|
|
132270
|
+
materialize(doc);
|
|
133990
132271
|
}
|
|
133991
132272
|
function decodeRoomSnapshot(value) {
|
|
133992
132273
|
const envelope = parseEnvelope(value);
|
|
@@ -133997,7 +132278,7 @@ function decodeRoomSnapshot(value) {
|
|
|
133997
132278
|
return {
|
|
133998
132279
|
schemaVersion: envelope.schemaVersion,
|
|
133999
132280
|
generation: envelope.generation,
|
|
134000
|
-
state:
|
|
132281
|
+
state: materialize(doc)
|
|
134001
132282
|
};
|
|
134002
132283
|
} finally {
|
|
134003
132284
|
doc.destroy();
|
|
@@ -134011,7 +132292,7 @@ function roomView(room, requestedVersion = room.schemaVersion) {
|
|
|
134011
132292
|
schemaVersion: room.schemaVersion,
|
|
134012
132293
|
generation: room.generation,
|
|
134013
132294
|
stale: requestedVersion !== room.schemaVersion,
|
|
134014
|
-
state:
|
|
132295
|
+
state: materialize(room.doc),
|
|
134015
132296
|
snapshot: envelope.snapshot,
|
|
134016
132297
|
bytes: envelopeBytes(envelope)
|
|
134017
132298
|
};
|
|
@@ -139288,6 +137569,7 @@ async function downloadSlackFile(file, token, path) {
|
|
|
139288
137569
|
}
|
|
139289
137570
|
}
|
|
139290
137571
|
async function createSlackTaskWithFiles(description, options, inbound, slack, carriedMessageTs = []) {
|
|
137572
|
+
options = { ...options, routingAffinity: options.routingAffinity ?? { capabilities: [] } };
|
|
139291
137573
|
noteSlackInboundSideEffect("task_created");
|
|
139292
137574
|
const context = { origin: "slack", slack };
|
|
139293
137575
|
const create = async (createOptions) => carriedMessageTs.length === 0 || !createOptions.slackChannelId ? await createTaskWithSiblingAwareness(description, createOptions, context) : await createSlackTaskCarryingMessages(await prepareTaskWithSiblingAwareness(description, createOptions, context), { slackChannelId: createOptions.slackChannelId, messageTs: carriedMessageTs });
|
|
@@ -141002,6 +139284,259 @@ var init_task_skip = __esm(() => {
|
|
|
141002
139284
|
init_secret_scrubber();
|
|
141003
139285
|
});
|
|
141004
139286
|
|
|
139287
|
+
// src/ui-spec/schema.ts
|
|
139288
|
+
var TaskUiSpecActionInputSchema, TaskUiSpecInputSchema;
|
|
139289
|
+
var init_schema2 = __esm(() => {
|
|
139290
|
+
init_zod();
|
|
139291
|
+
init_task_ui_spec2();
|
|
139292
|
+
TaskUiSpecActionInputSchema = discriminatedUnion("kind", [
|
|
139293
|
+
object2({ kind: literal2("follow_up"), prompt: string2().min(1).max(4000) }),
|
|
139294
|
+
object2({
|
|
139295
|
+
kind: literal2("script"),
|
|
139296
|
+
script: string2().min(1).max(200).describe("A global script named in UI_SPEC_SCRIPT_ACTIONS."),
|
|
139297
|
+
args: record2(string2(), unknown()).optional().describe("Frozen script input, at most 4 KB of JSON. A click sends no input.")
|
|
139298
|
+
})
|
|
139299
|
+
]);
|
|
139300
|
+
TaskUiSpecInputSchema = object2({
|
|
139301
|
+
spec: object2({
|
|
139302
|
+
root: string2().min(1),
|
|
139303
|
+
elements: record2(string2(), unknown()),
|
|
139304
|
+
state: record2(string2(), unknown()).optional()
|
|
139305
|
+
}).describe("A json-render spec for the chat catalog. Root must be a Card."),
|
|
139306
|
+
actions: record2(string2().regex(UI_SPEC_ACTION_ID), TaskUiSpecActionInputSchema).refine((actions) => Object.keys(actions).length <= UI_SPEC_MAX_ACTIONS, {
|
|
139307
|
+
message: `At most ${UI_SPEC_MAX_ACTIONS} actions.`
|
|
139308
|
+
}).optional().describe(`Actions that Button ids name, at most ${UI_SPEC_MAX_ACTIONS}. Needs UI_SPEC_ACTIONS_ENABLED=true. A \`script\` action also needs its script pinned in UI_SPEC_SCRIPT_ACTIONS.`)
|
|
139309
|
+
});
|
|
139310
|
+
});
|
|
139311
|
+
|
|
139312
|
+
// src/ui-spec/script-actions.ts
|
|
139313
|
+
async function readScriptActionAllowlist() {
|
|
139314
|
+
const [row] = await getSwarmConfigs2({ scope: "global", key: UI_SPEC_SCRIPT_ACTIONS_KEY });
|
|
139315
|
+
if (row)
|
|
139316
|
+
return row.value;
|
|
139317
|
+
const { getDeploymentEnvValue } = await import("./core-sxy4epp2.js");
|
|
139318
|
+
return getDeploymentEnvValue(UI_SPEC_SCRIPT_ACTIONS_KEY);
|
|
139319
|
+
}
|
|
139320
|
+
async function loadScriptActionLookups() {
|
|
139321
|
+
return {
|
|
139322
|
+
allPins: parseScriptActionAllowlist(await readScriptActionAllowlist()).pins,
|
|
139323
|
+
scripts: new Map
|
|
139324
|
+
};
|
|
139325
|
+
}
|
|
139326
|
+
async function resolveScriptAction(actionId, action, lookups) {
|
|
139327
|
+
const { allPins, scripts } = lookups ?? await loadScriptActionLookups();
|
|
139328
|
+
const pins = allPins.filter((pin) => pin.name === action.script);
|
|
139329
|
+
if (pins.length === 0) {
|
|
139330
|
+
return {
|
|
139331
|
+
ok: false,
|
|
139332
|
+
reason: "not_allowlisted",
|
|
139333
|
+
issue: `Action "${actionId}" runs script "${action.script}", which is not allowlisted in UI_SPEC_SCRIPT_ACTIONS.`
|
|
139334
|
+
};
|
|
139335
|
+
}
|
|
139336
|
+
let lookup = scripts.get(action.script);
|
|
139337
|
+
if (!lookup) {
|
|
139338
|
+
lookup = getScript({ name: action.script, scope: "global" });
|
|
139339
|
+
scripts.set(action.script, lookup);
|
|
139340
|
+
}
|
|
139341
|
+
const script = await lookup;
|
|
139342
|
+
if (!script) {
|
|
139343
|
+
return {
|
|
139344
|
+
ok: false,
|
|
139345
|
+
reason: "missing",
|
|
139346
|
+
issue: `Action "${actionId}" runs script "${action.script}", which is not a global script.`
|
|
139347
|
+
};
|
|
139348
|
+
}
|
|
139349
|
+
if (!pins.some((pin) => script.contentHash.toLowerCase().startsWith(pin.hashPrefix))) {
|
|
139350
|
+
return {
|
|
139351
|
+
ok: false,
|
|
139352
|
+
reason: "script_changed",
|
|
139353
|
+
issue: `Action "${actionId}": script "${action.script}" changed since it was allowlisted (contentHash ${script.contentHash.slice(0, 12)}). A human must re-pin it in UI_SPEC_SCRIPT_ACTIONS.`
|
|
139354
|
+
};
|
|
139355
|
+
}
|
|
139356
|
+
return { ok: true, script };
|
|
139357
|
+
}
|
|
139358
|
+
function argsIssue(actionId, action, script) {
|
|
139359
|
+
const args = action.args ?? {};
|
|
139360
|
+
const bytes = new TextEncoder().encode(JSON.stringify(args)).length;
|
|
139361
|
+
if (bytes > UI_SPEC_SCRIPT_ARGS_MAX_BYTES) {
|
|
139362
|
+
return `Action "${actionId}" args are ${bytes} bytes; the limit is ${UI_SPEC_SCRIPT_ARGS_MAX_BYTES}.`;
|
|
139363
|
+
}
|
|
139364
|
+
if (!script.argsJsonSchema)
|
|
139365
|
+
return null;
|
|
139366
|
+
let schema;
|
|
139367
|
+
try {
|
|
139368
|
+
schema = JSON.parse(script.argsJsonSchema);
|
|
139369
|
+
} catch {
|
|
139370
|
+
return `Action "${actionId}": script "${script.name}" has an unreadable argsJsonSchema.`;
|
|
139371
|
+
}
|
|
139372
|
+
const errors = validateJsonSchema(schema, args);
|
|
139373
|
+
return errors.length > 0 ? `Action "${actionId}" args do not match the script's argsJsonSchema: ${errors[0]}` : null;
|
|
139374
|
+
}
|
|
139375
|
+
async function scriptActionIssues(actions) {
|
|
139376
|
+
const issues = [];
|
|
139377
|
+
let lookups;
|
|
139378
|
+
for (const [actionId, action] of Object.entries(actions ?? {})) {
|
|
139379
|
+
if (action.kind !== "script")
|
|
139380
|
+
continue;
|
|
139381
|
+
if (!isEnvFlagEnabled("UI_SPEC_ACTIONS_ENABLED", false)) {
|
|
139382
|
+
issues.push(`Action "${actionId}" needs UI_SPEC_ACTIONS_ENABLED=true.`);
|
|
139383
|
+
continue;
|
|
139384
|
+
}
|
|
139385
|
+
lookups ??= await loadScriptActionLookups();
|
|
139386
|
+
const resolved = await resolveScriptAction(actionId, action, lookups);
|
|
139387
|
+
const issue = resolved.ok ? argsIssue(actionId, action, resolved.script) : resolved.issue;
|
|
139388
|
+
if (issue)
|
|
139389
|
+
issues.push(issue);
|
|
139390
|
+
}
|
|
139391
|
+
return issues;
|
|
139392
|
+
}
|
|
139393
|
+
async function scriptActionPinIssues(actions) {
|
|
139394
|
+
const scriptActions = Object.entries(actions ?? {}).filter((entry) => entry[1].kind === "script");
|
|
139395
|
+
if (scriptActions.length === 0)
|
|
139396
|
+
return [];
|
|
139397
|
+
const allPins = parseScriptActionAllowlist(await readScriptActionAllowlist()).pins;
|
|
139398
|
+
const hashes = await getGlobalScriptContentHashes([
|
|
139399
|
+
...new Set(scriptActions.map(([, action]) => action.script))
|
|
139400
|
+
]);
|
|
139401
|
+
const issues = [];
|
|
139402
|
+
for (const [actionId, action] of scriptActions) {
|
|
139403
|
+
const hash = hashes.get(action.script)?.toLowerCase();
|
|
139404
|
+
const pins = allPins.filter((pin) => pin.name === action.script);
|
|
139405
|
+
if (!hash || !pins.some((pin) => hash.startsWith(pin.hashPrefix))) {
|
|
139406
|
+
issues.push(`Action "${actionId}": script "${action.script}" is no longer allowlisted at its current contentHash in UI_SPEC_SCRIPT_ACTIONS.`);
|
|
139407
|
+
}
|
|
139408
|
+
}
|
|
139409
|
+
return issues;
|
|
139410
|
+
}
|
|
139411
|
+
function shortError(text) {
|
|
139412
|
+
const line = scrubSecrets(text).replace(/\s+/g, " ").trim();
|
|
139413
|
+
return line.length > 300 ? `${line.slice(0, 297)}...` : line;
|
|
139414
|
+
}
|
|
139415
|
+
async function runAndValidate(task, action, script, stored) {
|
|
139416
|
+
if (!task.agentId)
|
|
139417
|
+
return {
|
|
139418
|
+
ok: false,
|
|
139419
|
+
kind: "script_failed",
|
|
139420
|
+
error: "the task has no agent to run the script as"
|
|
139421
|
+
};
|
|
139422
|
+
const output = await runSavedScriptAsAgent({
|
|
139423
|
+
script,
|
|
139424
|
+
input: action.args ?? {},
|
|
139425
|
+
agentId: task.agentId,
|
|
139426
|
+
timeoutMs: UI_SPEC_SCRIPT_ACTION_TIMEOUT_MS
|
|
139427
|
+
});
|
|
139428
|
+
if (output.exitCode !== 0 || output.error || output.runtimeError) {
|
|
139429
|
+
const reason = output.runtimeError ? `${output.runtimeError.name}: ${output.runtimeError.message}` : output.error ? `script ${output.error}` : `script exited ${output.exitCode}`;
|
|
139430
|
+
return { ok: false, kind: "script_failed", error: reason };
|
|
139431
|
+
}
|
|
139432
|
+
const parsed = TaskUiSpecInputSchema.safeParse(output.result);
|
|
139433
|
+
if (!parsed.success) {
|
|
139434
|
+
const issue = parsed.error.issues[0];
|
|
139435
|
+
const path = issue?.path.join(".") || "result";
|
|
139436
|
+
return {
|
|
139437
|
+
ok: false,
|
|
139438
|
+
kind: "invalid_output",
|
|
139439
|
+
error: `script output is not { spec, actions? }: ${path}: ${issue?.message ?? "invalid"}`
|
|
139440
|
+
};
|
|
139441
|
+
}
|
|
139442
|
+
const newActions = parsed.data.actions;
|
|
139443
|
+
const scriptIssues = await scriptActionIssues(newActions);
|
|
139444
|
+
if (scriptIssues.length > 0)
|
|
139445
|
+
return { ok: false, kind: "invalid_output", error: scriptIssues[0] ?? "invalid action" };
|
|
139446
|
+
const actions = newActions ?? stored.actions;
|
|
139447
|
+
const validation = validateTaskUiSpec({ spec: parsed.data.spec, ...actions ? { actions } : {} }, { taskId: task.id, actionsEnabled: true });
|
|
139448
|
+
if (!validation.ok)
|
|
139449
|
+
return { ok: false, kind: "invalid_output", error: validation.issues[0] ?? "invalid uiSpec" };
|
|
139450
|
+
return {
|
|
139451
|
+
ok: true,
|
|
139452
|
+
uiSpec: {
|
|
139453
|
+
spec: validation.spec,
|
|
139454
|
+
...validation.actions ? { actions: validation.actions } : {},
|
|
139455
|
+
fallbackText: validation.fallbackText
|
|
139456
|
+
}
|
|
139457
|
+
};
|
|
139458
|
+
}
|
|
139459
|
+
async function runTaskUiScriptAction({
|
|
139460
|
+
task,
|
|
139461
|
+
actionId,
|
|
139462
|
+
action,
|
|
139463
|
+
stored,
|
|
139464
|
+
surface,
|
|
139465
|
+
actorUserId,
|
|
139466
|
+
slackUserId
|
|
139467
|
+
}) {
|
|
139468
|
+
const resolved = await resolveScriptAction(actionId, action);
|
|
139469
|
+
if (!resolved.ok) {
|
|
139470
|
+
if (resolved.reason === "missing") {
|
|
139471
|
+
return { status: "script_failed", error: `script "${action.script}" no longer exists` };
|
|
139472
|
+
}
|
|
139473
|
+
return { status: resolved.reason };
|
|
139474
|
+
}
|
|
139475
|
+
const lock = await acquireTaskUiScriptActionRun({
|
|
139476
|
+
taskId: task.id,
|
|
139477
|
+
actionId,
|
|
139478
|
+
surface,
|
|
139479
|
+
slackUserId,
|
|
139480
|
+
userId: actorUserId,
|
|
139481
|
+
leaseMs: UI_SPEC_SCRIPT_ACTION_LEASE_MS,
|
|
139482
|
+
cooldownMs: UI_SPEC_SCRIPT_ACTION_COOLDOWN_MS
|
|
139483
|
+
});
|
|
139484
|
+
if (lock.status !== "acquired")
|
|
139485
|
+
return lock;
|
|
139486
|
+
let outcome;
|
|
139487
|
+
try {
|
|
139488
|
+
outcome = await runAndValidate(task, action, resolved.script, stored);
|
|
139489
|
+
} catch (error) {
|
|
139490
|
+
outcome = {
|
|
139491
|
+
ok: false,
|
|
139492
|
+
kind: "script_failed",
|
|
139493
|
+
error: error instanceof Error ? error.message : String(error)
|
|
139494
|
+
};
|
|
139495
|
+
}
|
|
139496
|
+
if (outcome.ok) {
|
|
139497
|
+
const okOutcome = outcome;
|
|
139498
|
+
const pinIssue = await getDbClient2().transaction(async () => {
|
|
139499
|
+
const [issue] = await scriptActionPinIssues(okOutcome.uiSpec.actions);
|
|
139500
|
+
if (!issue)
|
|
139501
|
+
await upsertTaskUiSpec(task.id, okOutcome.uiSpec, actorUserId);
|
|
139502
|
+
return issue;
|
|
139503
|
+
});
|
|
139504
|
+
if (pinIssue)
|
|
139505
|
+
outcome = { ok: false, kind: "invalid_output", error: pinIssue };
|
|
139506
|
+
}
|
|
139507
|
+
if (!outcome.ok) {
|
|
139508
|
+
const error = shortError(outcome.error);
|
|
139509
|
+
await finishTaskUiScriptActionRun(task.id, actionId, error);
|
|
139510
|
+
await createLogEntry2({
|
|
139511
|
+
eventType: "task_ui_script_action_failed",
|
|
139512
|
+
...task.agentId ? { agentId: task.agentId } : {},
|
|
139513
|
+
taskId: task.id,
|
|
139514
|
+
newValue: error,
|
|
139515
|
+
metadata: { actionId, script: action.script, kind: outcome.kind }
|
|
139516
|
+
});
|
|
139517
|
+
return { status: outcome.kind, error };
|
|
139518
|
+
}
|
|
139519
|
+
await finishTaskUiScriptActionRun(task.id, actionId, null);
|
|
139520
|
+
getDbClient2().afterCommit(() => workflowEventBus2.emit(TASK_UI_SPEC_UPDATED_EVENT, { taskId: task.id }));
|
|
139521
|
+
return { status: "refreshed", uiSpec: await getTaskUiSpec(task.id) ?? outcome.uiSpec };
|
|
139522
|
+
}
|
|
139523
|
+
var UI_SPEC_SCRIPT_ACTION_TIMEOUT_MS = 30000, UI_SPEC_SCRIPT_ACTION_LEASE_MS, UI_SPEC_SCRIPT_ACTION_COOLDOWN_MS = 30000;
|
|
139524
|
+
var init_script_actions = __esm(() => {
|
|
139525
|
+
init_db4();
|
|
139526
|
+
init_db3();
|
|
139527
|
+
init_run_saved();
|
|
139528
|
+
init_task_ui_spec();
|
|
139529
|
+
init_env_flag();
|
|
139530
|
+
init_secret_scrubber();
|
|
139531
|
+
init_task_ui_spec2();
|
|
139532
|
+
init_event_bus();
|
|
139533
|
+
init_json_schema_validator();
|
|
139534
|
+
init_schema2();
|
|
139535
|
+
init_script_allowlist();
|
|
139536
|
+
init_validate2();
|
|
139537
|
+
UI_SPEC_SCRIPT_ACTION_LEASE_MS = UI_SPEC_SCRIPT_ACTION_TIMEOUT_MS + 15000;
|
|
139538
|
+
});
|
|
139539
|
+
|
|
141005
139540
|
// src/tools/store-progress.ts
|
|
141006
139541
|
async function foreignTaskWriteError(caller, task, sourceTaskId) {
|
|
141007
139542
|
const decision = can({
|
|
@@ -141040,6 +139575,7 @@ var BLOCKED_WAITING_PATTERN, BLOCKED_WAITING_MIN_ELAPSED_MS, storeProgressOutput
|
|
|
141040
139575
|
failureReason: string2().optional().describe("The reason for failure (used when failing), or the one-line reason for a skip (required with status 'skipped')."),
|
|
141041
139576
|
attachments: array2(AttachmentInputSchema).max(20).optional().describe("Pointer-based artifacts produced by this step — agent-fs path, URL, shared-fs path, or swarm Page. No inline file data; upload to agent-fs first and attach by path. Agent-fs pointers are verified before task state changes, using the explicit org/drive pair or the registering agent's configured defaults. May be sent on any call (progress or completion) and accumulates across calls; duplicates are de-duped by sha256 (when present) or by (kind, pointer, name)."),
|
|
141042
139577
|
citations: array2(CitationInputSchema).max(MAX_TASK_CITATIONS).catch([]).optional().describe('Claim sources, upserted by index across calls. Use only for factual claims the reader cannot already see in the thread or task tree, 1-2 sources; none on delegation, routing, acks, or status replies. Reference each one in output with [citation:N], or set general: true for a source that backs the whole answer (it renders under "General sources"). ref per kind: task = task UUID; memory = memory UUID (optional quote must appear verbatim in it); github = owner/repo#N, owner/repo@<sha>, or a github.com pull, issues, or commit URL; slack = permalink or channel/ts; agent-fs = file path; page = page id; script-run = script run id; url = http(s) URL. The first completing call is refused, and the task stays in progress, if a marker has no entry, a citation fails validation, or a non-general citation is unreferenced; the response lists each problem. After one refusal, completion proceeds and those markers and sources are dropped from rendered output. At most 50 citations per call/task, refs up to 2048 characters, labels up to 200. Invalid or oversized batches are ignored; existing indices can still be updated at capacity.'),
|
|
139578
|
+
uiSpec: TaskUiSpecInputSchema.optional().describe("Optional rich card for this result, rendered in the Slack outcome card, the session view and Chat SDK channels. `output` stays the prose answer. A Slack card shows only the spec of its own task. See the ui-spec skill."),
|
|
141043
139579
|
learning: union3([
|
|
141044
139580
|
string2(),
|
|
141045
139581
|
object2({
|
|
@@ -141061,6 +139597,7 @@ var BLOCKED_WAITING_PATTERN, BLOCKED_WAITING_MIN_ELAPSED_MS, storeProgressOutput
|
|
|
141061
139597
|
failureReason,
|
|
141062
139598
|
attachments,
|
|
141063
139599
|
citations,
|
|
139600
|
+
uiSpec,
|
|
141064
139601
|
learning,
|
|
141065
139602
|
persistMemory,
|
|
141066
139603
|
chainedTaskId,
|
|
@@ -141163,6 +139700,8 @@ var BLOCKED_WAITING_PATTERN, BLOCKED_WAITING_MIN_ELAPSED_MS, storeProgressOutput
|
|
|
141163
139700
|
}
|
|
141164
139701
|
}
|
|
141165
139702
|
let learningWrite;
|
|
139703
|
+
const uiSpecScriptIssues = uiSpec && status === "completed" && isEnvFlagEnabled("UI_SPEC_ENABLED", false) ? await scriptActionIssues(uiSpec.actions) : [];
|
|
139704
|
+
let uiSpecNote;
|
|
141166
139705
|
const result = await getDbClient2().transaction(async () => {
|
|
141167
139706
|
const agent = await getAgentById2(requestInfo.agentId ?? "");
|
|
141168
139707
|
if (!agent) {
|
|
@@ -141293,8 +139832,47 @@ This check refuses once per task; the next completion is accepted and unfixed ci
|
|
|
141293
139832
|
};
|
|
141294
139833
|
}
|
|
141295
139834
|
}
|
|
139835
|
+
let uiSpecToStore;
|
|
139836
|
+
if (uiSpec && !isEnvFlagEnabled("UI_SPEC_ENABLED", false)) {
|
|
139837
|
+
uiSpecNote = "uiSpec ignored: UI_SPEC_ENABLED is off.";
|
|
139838
|
+
} else if (uiSpec && status !== "completed") {
|
|
139839
|
+
uiSpecNote = 'uiSpec is stored only with status "completed".';
|
|
139840
|
+
} else if (uiSpec) {
|
|
139841
|
+
const scriptIssues = uiSpecScriptIssues.length > 0 ? uiSpecScriptIssues : await scriptActionPinIssues(uiSpec.actions);
|
|
139842
|
+
const validation = scriptIssues.length > 0 ? { ok: false, issues: scriptIssues } : validateTaskUiSpec(uiSpec, {
|
|
139843
|
+
taskId,
|
|
139844
|
+
actionsEnabled: isEnvFlagEnabled("UI_SPEC_ACTIONS_ENABLED", false)
|
|
139845
|
+
});
|
|
139846
|
+
if (validation.ok) {
|
|
139847
|
+
uiSpecToStore = {
|
|
139848
|
+
spec: validation.spec,
|
|
139849
|
+
...validation.actions ? { actions: validation.actions } : {},
|
|
139850
|
+
fallbackText: validation.fallbackText
|
|
139851
|
+
};
|
|
139852
|
+
} else if (!await hasTaskUiSpecCheckRefusal(taskId)) {
|
|
139853
|
+
await createLogEntry2({
|
|
139854
|
+
eventType: "task_ui_spec_check_refused",
|
|
139855
|
+
agentId: agent.id,
|
|
139856
|
+
taskId,
|
|
139857
|
+
newValue: validation.issues.join(`
|
|
139858
|
+
`)
|
|
139859
|
+
});
|
|
139860
|
+
return {
|
|
139861
|
+
success: false,
|
|
139862
|
+
task: existingTask,
|
|
139863
|
+
message: `Completion refused: uiSpec is not valid. The task stays ${existingTask.status}. Fix these, then call store-progress again:
|
|
139864
|
+
- ${validation.issues.join(`
|
|
139865
|
+
- `)}
|
|
139866
|
+
This check refuses once per task; the next completion is accepted without the spec.`
|
|
139867
|
+
};
|
|
139868
|
+
} else {
|
|
139869
|
+
uiSpecNote = `uiSpec dropped: ${validation.issues[0]}`;
|
|
139870
|
+
}
|
|
139871
|
+
}
|
|
141296
139872
|
if (status === "completed") {
|
|
141297
139873
|
const result = await completeTask2(taskId, output);
|
|
139874
|
+
if (result && uiSpecToStore)
|
|
139875
|
+
await upsertTaskUiSpec(taskId, uiSpecToStore);
|
|
141298
139876
|
if (result) {
|
|
141299
139877
|
updatedTask = result;
|
|
141300
139878
|
getDbClient2().afterCommit(() => {
|
|
@@ -141380,7 +139958,11 @@ This check refuses once per task; the next completion is accepted and unfixed ci
|
|
|
141380
139958
|
finalizeSkippedTaskReaction(result.task, "store-progress");
|
|
141381
139959
|
const learningResult = await learningWrite;
|
|
141382
139960
|
const { success } = result;
|
|
141383
|
-
const message =
|
|
139961
|
+
const message = [
|
|
139962
|
+
result.message,
|
|
139963
|
+
...learningResult ? [learningSentence(learningResult)] : [],
|
|
139964
|
+
...success && uiSpecNote ? [uiSpecNote] : []
|
|
139965
|
+
].join(" ");
|
|
141384
139966
|
const task = result.task ? {
|
|
141385
139967
|
id: result.task.id,
|
|
141386
139968
|
status: result.task.status,
|
|
@@ -141405,6 +139987,7 @@ var init_store_progress = __esm(() => {
|
|
|
141405
139987
|
init_constants2();
|
|
141406
139988
|
init_task_learning();
|
|
141407
139989
|
init_task_citations2();
|
|
139990
|
+
init_task_ui_spec();
|
|
141408
139991
|
init_agent_fs_provider();
|
|
141409
139992
|
init_rbac();
|
|
141410
139993
|
init_task_skip();
|
|
@@ -141412,6 +139995,10 @@ var init_store_progress = __esm(() => {
|
|
|
141412
139995
|
init_terminal_result_guard();
|
|
141413
139996
|
init_utils();
|
|
141414
139997
|
init_types5();
|
|
139998
|
+
init_schema2();
|
|
139999
|
+
init_script_actions();
|
|
140000
|
+
init_validate2();
|
|
140001
|
+
init_env_flag();
|
|
141415
140002
|
init_secret_scrubber();
|
|
141416
140003
|
init_task_citations();
|
|
141417
140004
|
init_business_use();
|
|
@@ -141790,6 +140377,11 @@ var registerDeleteConfigTool = (server) => {
|
|
|
141790
140377
|
data: { yourAgentId: requestInfo.agentId }
|
|
141791
140378
|
});
|
|
141792
140379
|
}
|
|
140380
|
+
if (isHumanOnlyConfigKey(existing.key)) {
|
|
140381
|
+
return toolErr(humanOnlyConfigKeyError(existing.key), {
|
|
140382
|
+
data: { yourAgentId: requestInfo.agentId }
|
|
140383
|
+
});
|
|
140384
|
+
}
|
|
141793
140385
|
if (isInternalConfigKey(existing.key)) {
|
|
141794
140386
|
return toolErr(internalConfigKeyError(existing.key).message, {
|
|
141795
140387
|
data: { yourAgentId: requestInfo.agentId }
|
|
@@ -141805,7 +140397,7 @@ var registerDeleteConfigTool = (server) => {
|
|
|
141805
140397
|
});
|
|
141806
140398
|
}
|
|
141807
140399
|
if (existing.scope === "global") {
|
|
141808
|
-
|
|
140400
|
+
scheduleIntegrationsReload2();
|
|
141809
140401
|
}
|
|
141810
140402
|
return toolOk(`Config "${existing.key}" deleted successfully.`, {
|
|
141811
140403
|
details: `Config "${existing.key}" (scope: ${existing.scope}${existing.scopeId ? `, scopeId: ${existing.scopeId}` : ""}) deleted successfully.`,
|
|
@@ -142056,6 +140648,11 @@ var configEntryShape3, registerSetConfigTool = (server) => {
|
|
|
142056
140648
|
const message = reservedKeyError(key).message;
|
|
142057
140649
|
return toolErr(message, { data: { yourAgentId: requestInfo.agentId } });
|
|
142058
140650
|
}
|
|
140651
|
+
if (isHumanOnlyConfigKey(key)) {
|
|
140652
|
+
return toolErr(humanOnlyConfigKeyError(key), {
|
|
140653
|
+
data: { yourAgentId: requestInfo.agentId }
|
|
140654
|
+
});
|
|
140655
|
+
}
|
|
142059
140656
|
if (isInternalConfigKey(key)) {
|
|
142060
140657
|
return toolErr(internalConfigKeyError(key).message, {
|
|
142061
140658
|
data: { yourAgentId: requestInfo.agentId }
|
|
@@ -142092,7 +140689,7 @@ var configEntryShape3, registerSetConfigTool = (server) => {
|
|
|
142092
140689
|
exportToEnv
|
|
142093
140690
|
});
|
|
142094
140691
|
if (scope === "global") {
|
|
142095
|
-
|
|
140692
|
+
scheduleIntegrationsReload2();
|
|
142096
140693
|
}
|
|
142097
140694
|
const [masked] = maskSecrets2([config]);
|
|
142098
140695
|
return toolOk(`Config "${key}" set successfully.`, {
|
|
@@ -142217,7 +140814,189 @@ var init_swarm_x = __esm(() => {
|
|
|
142217
140814
|
primitiveQueryValueSchema = union3([string2(), number2(), boolean()]);
|
|
142218
140815
|
});
|
|
142219
140816
|
|
|
140817
|
+
// src/http/session-cost-recompute.ts
|
|
140818
|
+
function cacheWriteSplit(input) {
|
|
140819
|
+
if (input.cacheWrite5mTokens == null || input.cacheWrite1hTokens == null)
|
|
140820
|
+
return null;
|
|
140821
|
+
const total = input.cacheWrite5mTokens + input.cacheWrite1hTokens;
|
|
140822
|
+
if (total === 0)
|
|
140823
|
+
return null;
|
|
140824
|
+
return {
|
|
140825
|
+
fiveMinuteRatio: input.cacheWrite5mTokens / total,
|
|
140826
|
+
oneHourRatio: input.cacheWrite1hTokens / total
|
|
140827
|
+
};
|
|
140828
|
+
}
|
|
140829
|
+
async function priceModel(provider, usage, split, atEpochMs, lookupRate) {
|
|
140830
|
+
const lookupModel = normalizeModelKey(provider, usage.model);
|
|
140831
|
+
const inputRate = await lookupRate(provider, lookupModel, "input", atEpochMs);
|
|
140832
|
+
const outputRate = await lookupRate(provider, lookupModel, "output", atEpochMs);
|
|
140833
|
+
if (inputRate == null || outputRate == null)
|
|
140834
|
+
return null;
|
|
140835
|
+
const cacheReadRate = await lookupRate(provider, lookupModel, "cached_input", atEpochMs) ?? 0;
|
|
140836
|
+
const uncachedInputTokens = INCLUSIVE_INPUT_PROVIDERS.has(provider) ? Math.max(0, usage.inputTokens - usage.cacheReadTokens) : usage.inputTokens;
|
|
140837
|
+
let cacheWriteCostUnits = 0;
|
|
140838
|
+
if (split) {
|
|
140839
|
+
const fiveMinuteTokens = usage.cacheWriteTokens * split.fiveMinuteRatio;
|
|
140840
|
+
const oneHourTokens = usage.cacheWriteTokens * split.oneHourRatio;
|
|
140841
|
+
const fiveMinuteRate = await lookupRate(provider, lookupModel, "cache_write", atEpochMs) ?? 0;
|
|
140842
|
+
const oneHourRate = await lookupRate(provider, lookupModel, "cache_write_1h", atEpochMs);
|
|
140843
|
+
if (oneHourTokens > 0 && oneHourRate == null)
|
|
140844
|
+
return null;
|
|
140845
|
+
cacheWriteCostUnits = fiveMinuteTokens * fiveMinuteRate + oneHourTokens * (oneHourRate ?? 0);
|
|
140846
|
+
} else {
|
|
140847
|
+
const cacheWriteRate = await lookupRate(provider, lookupModel, "cache_write", atEpochMs) ?? 0;
|
|
140848
|
+
cacheWriteCostUnits = usage.cacheWriteTokens * cacheWriteRate;
|
|
140849
|
+
}
|
|
140850
|
+
return (uncachedInputTokens * inputRate + usage.cacheReadTokens * cacheReadRate + cacheWriteCostUnits + usage.outputTokens * outputRate) / PER_MILLION;
|
|
140851
|
+
}
|
|
140852
|
+
function unpricedResult(input, modelBreakdown) {
|
|
140853
|
+
return {
|
|
140854
|
+
totalCostUsd: input.harnessCostUsd,
|
|
140855
|
+
costSource: "unpriced",
|
|
140856
|
+
modelBreakdown
|
|
140857
|
+
};
|
|
140858
|
+
}
|
|
140859
|
+
async function estimateAmpCost(input, lookupRate) {
|
|
140860
|
+
let selection;
|
|
140861
|
+
try {
|
|
140862
|
+
selection = resolveAmpModel(input.model);
|
|
140863
|
+
} catch {
|
|
140864
|
+
selection = undefined;
|
|
140865
|
+
}
|
|
140866
|
+
const candidates = [
|
|
140867
|
+
...new Set([
|
|
140868
|
+
selection?.pin,
|
|
140869
|
+
selection ? AMP_ESTIMATE_MODELS[selection.baseMode] : undefined,
|
|
140870
|
+
AMP_ESTIMATE_MODELS.medium
|
|
140871
|
+
])
|
|
140872
|
+
].filter((model) => !!model);
|
|
140873
|
+
for (const model of candidates) {
|
|
140874
|
+
const writes = ampBillsCacheWrites(model);
|
|
140875
|
+
const costUsd = await priceModel("amp", {
|
|
140876
|
+
model,
|
|
140877
|
+
inputTokens: input.inputTokens + (writes ? 0 : input.cacheWriteTokens),
|
|
140878
|
+
outputTokens: input.outputTokens,
|
|
140879
|
+
cacheReadTokens: input.cacheReadTokens,
|
|
140880
|
+
cacheWriteTokens: writes ? input.cacheWriteTokens : 0
|
|
140881
|
+
}, null, input.atEpochMs, lookupRate);
|
|
140882
|
+
if (costUsd != null)
|
|
140883
|
+
return { totalCostUsd: costUsd, costSource: "estimated", modelBreakdown: undefined };
|
|
140884
|
+
}
|
|
140885
|
+
return unpricedResult(input, undefined);
|
|
140886
|
+
}
|
|
140887
|
+
async function recomputeSessionCost(input, lookupRate) {
|
|
140888
|
+
const modelUsageEntries = input.models?.length ? input.models : undefined;
|
|
140889
|
+
const modelBreakdown = modelUsageEntries?.map((model) => ({ ...model }));
|
|
140890
|
+
if (!input.provider) {
|
|
140891
|
+
return {
|
|
140892
|
+
totalCostUsd: input.harnessCostUsd,
|
|
140893
|
+
costSource: "harness",
|
|
140894
|
+
modelBreakdown
|
|
140895
|
+
};
|
|
140896
|
+
}
|
|
140897
|
+
if ((input.provider === "amp" || input.provider === "grok" || input.harnessCostBilled) && input.harnessCostUsd > 0) {
|
|
140898
|
+
const priced = await recomputeSessionCost({ ...input, harnessCostUsd: 0, harnessCostBilled: false }, lookupRate);
|
|
140899
|
+
return {
|
|
140900
|
+
totalCostUsd: input.harnessCostUsd,
|
|
140901
|
+
costSource: "harness",
|
|
140902
|
+
modelBreakdown: priced.modelBreakdown
|
|
140903
|
+
};
|
|
140904
|
+
}
|
|
140905
|
+
if (input.provider === "acp" && input.harnessCostUsd > 0) {
|
|
140906
|
+
return { totalCostUsd: input.harnessCostUsd, costSource: "harness", modelBreakdown };
|
|
140907
|
+
}
|
|
140908
|
+
if (input.provider === "amp" && !modelUsageEntries)
|
|
140909
|
+
return estimateAmpCost(input, lookupRate);
|
|
140910
|
+
const split = cacheWriteSplit(input);
|
|
140911
|
+
const usages = modelUsageEntries ? modelUsageEntries : input.model ? [
|
|
140912
|
+
{
|
|
140913
|
+
model: input.model,
|
|
140914
|
+
inputTokens: input.inputTokens,
|
|
140915
|
+
outputTokens: input.outputTokens,
|
|
140916
|
+
cacheReadTokens: input.cacheReadTokens,
|
|
140917
|
+
cacheWriteTokens: input.cacheWriteTokens
|
|
140918
|
+
}
|
|
140919
|
+
] : [];
|
|
140920
|
+
if (usages.length === 0) {
|
|
140921
|
+
return {
|
|
140922
|
+
totalCostUsd: input.harnessCostUsd,
|
|
140923
|
+
costSource: "harness",
|
|
140924
|
+
modelBreakdown
|
|
140925
|
+
};
|
|
140926
|
+
}
|
|
140927
|
+
const pricedModels = [];
|
|
140928
|
+
let pricedCostUsd = 0;
|
|
140929
|
+
const hasWebSearchRequests = usages.some((usage) => (usage.webSearchRequests ?? 0) > 0);
|
|
140930
|
+
const webSearchRate = hasWebSearchRequests ? await lookupRate(input.provider, "*", "web_search", input.atEpochMs) : null;
|
|
140931
|
+
for (const usage of usages) {
|
|
140932
|
+
const tokenCostUsd = await priceModel(input.provider, usage, split, input.atEpochMs, lookupRate);
|
|
140933
|
+
if (tokenCostUsd == null)
|
|
140934
|
+
return unpricedResult(input, modelBreakdown);
|
|
140935
|
+
const webSearchCostUsd = (usage.webSearchRequests ?? 0) * (webSearchRate ?? 0) / PER_MILLION;
|
|
140936
|
+
const costUsd = tokenCostUsd + webSearchCostUsd;
|
|
140937
|
+
pricedCostUsd += costUsd;
|
|
140938
|
+
if (modelUsageEntries)
|
|
140939
|
+
pricedModels.push({ ...usage, costUsd });
|
|
140940
|
+
}
|
|
140941
|
+
let sessionFeesUsd = 0;
|
|
140942
|
+
const durationMs = input.durationMs ?? 0;
|
|
140943
|
+
if (input.provider === "claude-managed" && durationMs > 0) {
|
|
140944
|
+
const runtimeRate = await lookupRate(input.provider, "*", "runtime_hour", input.atEpochMs);
|
|
140945
|
+
if (runtimeRate == null)
|
|
140946
|
+
return unpricedResult(input, modelBreakdown);
|
|
140947
|
+
sessionFeesUsd += durationMs / 3600000 * (runtimeRate / PER_MILLION);
|
|
140948
|
+
}
|
|
140949
|
+
return {
|
|
140950
|
+
totalCostUsd: pricedCostUsd + sessionFeesUsd,
|
|
140951
|
+
costSource: "pricing-table",
|
|
140952
|
+
modelBreakdown: modelUsageEntries ? pricedModels : undefined
|
|
140953
|
+
};
|
|
140954
|
+
}
|
|
140955
|
+
var PER_MILLION = 1e6, INCLUSIVE_INPUT_PROVIDERS;
|
|
140956
|
+
var init_session_cost_recompute = __esm(() => {
|
|
140957
|
+
init_pricing_normalize();
|
|
140958
|
+
init_amp_models();
|
|
140959
|
+
INCLUSIVE_INPUT_PROVIDERS = new Set(["codex"]);
|
|
140960
|
+
});
|
|
140961
|
+
|
|
142220
140962
|
// src/tools/system-one-decide.ts
|
|
140963
|
+
async function costTask(taskId, requestInfo) {
|
|
140964
|
+
const id = taskId ?? requestInfo.sourceTaskId;
|
|
140965
|
+
if (!id)
|
|
140966
|
+
return {};
|
|
140967
|
+
const task = await getTaskById2(id);
|
|
140968
|
+
const allowed = !!task && (requestInfo.callOrigin === "extension" || task.agentId === requestInfo.agentId);
|
|
140969
|
+
if (allowed)
|
|
140970
|
+
return { task };
|
|
140971
|
+
return taskId ? { error: `taskId ${taskId} is not a task this caller can charge` } : {};
|
|
140972
|
+
}
|
|
140973
|
+
async function recordDecisionCost(task, callerAgentId, provider, output, durationMs) {
|
|
140974
|
+
const model = `${provider}/${output.model}`;
|
|
140975
|
+
const priced = await recomputeSessionCost({
|
|
140976
|
+
provider: "system-one",
|
|
140977
|
+
model,
|
|
140978
|
+
harnessCostUsd: 0,
|
|
140979
|
+
inputTokens: output.usage.input_tokens,
|
|
140980
|
+
outputTokens: output.usage.output_tokens,
|
|
140981
|
+
cacheReadTokens: 0,
|
|
140982
|
+
cacheWriteTokens: 0,
|
|
140983
|
+
atEpochMs: Date.now()
|
|
140984
|
+
}, async (pricingProvider, lookupModel, tokenClass, atEpochMs) => (await getActivePricingRow2(pricingProvider, lookupModel, tokenClass, atEpochMs))?.pricePerMillionUsd ?? null);
|
|
140985
|
+
const { cost } = await insertSessionCost2({
|
|
140986
|
+
sessionId: `system-one:${crypto.randomUUID()}`,
|
|
140987
|
+
taskId: task.id,
|
|
140988
|
+
agentId: task.agentId ?? callerAgentId,
|
|
140989
|
+
totalCostUsd: priced.totalCostUsd,
|
|
140990
|
+
inputTokens: output.usage.input_tokens,
|
|
140991
|
+
outputTokens: output.usage.output_tokens,
|
|
140992
|
+
durationMs,
|
|
140993
|
+
numTurns: null,
|
|
140994
|
+
model,
|
|
140995
|
+
costSource: priced.costSource,
|
|
140996
|
+
kind: "system-one"
|
|
140997
|
+
});
|
|
140998
|
+
return { taskId: task.id, costUsd: cost.totalCostUsd, costSource: cost.costSource };
|
|
140999
|
+
}
|
|
142221
141000
|
var registerSystemOneDecideTool = (server) => {
|
|
142222
141001
|
createToolRegistrar(server)("system-one-decide", {
|
|
142223
141002
|
title: "Ask a SystemOne decision model",
|
|
@@ -142229,19 +141008,28 @@ var registerSystemOneDecideTool = (server) => {
|
|
|
142229
141008
|
state: union3([string2(), array2(string2()), record2(string2(), unknown())]).describe("The state to decide on"),
|
|
142230
141009
|
questions: record2(string2(), record2(string2(), unknown())).describe("Questions by id, each `{ type: 'noul' | 'choice' | 'score', instructions, criteria }`"),
|
|
142231
141010
|
timeoutMs: number2().int().optional().describe("Time budget for the call, retries included (default 30000)"),
|
|
142232
|
-
maxRetries: number2().int().optional().describe("Retries on transient failures inside the time budget (default 2)")
|
|
141011
|
+
maxRetries: number2().int().optional().describe("Retries on transient failures inside the time budget (default 2)"),
|
|
141012
|
+
taskId: uuid().optional().describe("Task this decision serves; its cost is recorded on that task's session costs (default: the caller's X-Source-Task-Id). Must be the caller's own task, or, from an extension, the task of the event it handles")
|
|
142233
141013
|
}),
|
|
142234
141014
|
outputSchema: swarmToolOutputSchema({
|
|
142235
141015
|
model: string2().optional(),
|
|
142236
141016
|
answers: record2(string2(), unknown()).optional(),
|
|
142237
141017
|
usage: record2(string2(), unknown()).optional(),
|
|
142238
141018
|
requestId: string2().optional(),
|
|
141019
|
+
cost: looseObject({
|
|
141020
|
+
taskId: string2().optional(),
|
|
141021
|
+
costUsd: number2().optional(),
|
|
141022
|
+
costSource: string2().optional()
|
|
141023
|
+
}).optional().describe("The session-cost row recorded on the task, when a task was in scope"),
|
|
142239
141024
|
providerUnavailable: boolean().optional().describe("On an error: true when this deployment refuses the provider (e.g. OpenRouter behind a gateway) and no request was sent, so a caller choosing automatically can try its next provider")
|
|
142240
141025
|
})
|
|
142241
|
-
}, async ({ provider, model, state, questions, timeoutMs, maxRetries }, requestInfo) => {
|
|
141026
|
+
}, async ({ provider, model, state, questions, timeoutMs, maxRetries, taskId }, requestInfo) => {
|
|
142242
141027
|
if (!requestInfo.agentId) {
|
|
142243
141028
|
return toolErr('Agent ID not found. The MCP client should define the "X-Agent-ID" header.');
|
|
142244
141029
|
}
|
|
141030
|
+
const scope = await costTask(taskId, requestInfo);
|
|
141031
|
+
if (scope.error)
|
|
141032
|
+
return toolErr(scope.error);
|
|
142245
141033
|
const returns = Object.fromEntries(Object.entries(questions).map(([id, question]) => [id, { type: question.type }]));
|
|
142246
141034
|
const parsed = SystemOneDecisionConfigSchema.safeParse({
|
|
142247
141035
|
provider,
|
|
@@ -142260,23 +141048,35 @@ var registerSystemOneDecideTool = (server) => {
|
|
|
142260
141048
|
if (!(executor instanceof SystemOneDecisionExecutor)) {
|
|
142261
141049
|
return toolErr("The system-one-decision executor is not available");
|
|
142262
141050
|
}
|
|
141051
|
+
const startedAt = Date.now();
|
|
142263
141052
|
const decided = await executor.decide(parsed.data);
|
|
142264
141053
|
if (!decided.ok) {
|
|
142265
141054
|
return toolErr(decided.error, decided.deploymentRefused ? { data: { providerUnavailable: true } } : {});
|
|
142266
141055
|
}
|
|
142267
141056
|
const { output } = decided;
|
|
141057
|
+
let cost;
|
|
141058
|
+
if (scope.task) {
|
|
141059
|
+
try {
|
|
141060
|
+
cost = await recordDecisionCost(scope.task, requestInfo.agentId, decided.provider, output, Date.now() - startedAt);
|
|
141061
|
+
} catch (err) {
|
|
141062
|
+
console.warn(`[system-one-decide] cost not recorded on task ${scope.task.id}: ${err instanceof Error ? err.message : String(err)}`);
|
|
141063
|
+
}
|
|
141064
|
+
}
|
|
142268
141065
|
return toolOk(`Decision from ${output.model}`, {
|
|
142269
141066
|
data: {
|
|
142270
141067
|
model: output.model,
|
|
142271
141068
|
answers: output.answers,
|
|
142272
141069
|
usage: output.usage,
|
|
142273
|
-
requestId: output.requestId
|
|
141070
|
+
requestId: output.requestId,
|
|
141071
|
+
...cost ? { cost } : {}
|
|
142274
141072
|
}
|
|
142275
141073
|
});
|
|
142276
141074
|
});
|
|
142277
141075
|
};
|
|
142278
141076
|
var init_system_one_decide = __esm(() => {
|
|
142279
141077
|
init_zod();
|
|
141078
|
+
init_db4();
|
|
141079
|
+
init_session_cost_recompute();
|
|
142280
141080
|
init_utils();
|
|
142281
141081
|
init_workflows();
|
|
142282
141082
|
init_system_one_decision();
|
|
@@ -143544,6 +142344,7 @@ var registerCreateWorkflowTool = (server) => {
|
|
|
143544
142344
|
` + "- FOREACH NODE: type 'foreach' runs its body once per item. Config: " + "{ over: <array or exact {{input}} token>, itemKey: <property name>, body: { type: <any executor except foreach>, config: {...} }, " + "concurrency?: <integer >= 1, items in flight; unbounded when absent>, failurePolicy?: 'fail-fast' | 'collect-outcomes' }. " + "The body config is interpolated once per item with {{item.*}} and {{index}}. Child steps use synthetic IDs " + "'<foreachNodeId>#<itemKey>'; the parent waits for every child and exposes one aggregate result to successors. " + "failurePolicy defaults from onNodeFailure ('continue' = collect-outcomes, else fail-fast); fail-fast cancels queued items. " + `retry-workflow-run on a failed fan-out reruns only failed and cancelled items.
|
|
143545
142345
|
` + "- TRIGGER SCHEMA: Optional 'triggerSchema' is a JSON-Schema object that validates incoming trigger payloads. " + "Supported keywords: type, required, properties, enum, const, items (recursive into arrays). " + `Other JSON-Schema keywords (oneOf/anyOf/$ref/pattern/format/additionalProperties) are silently ignored.
|
|
143546
142346
|
` + "- WEBHOOK VERIFICATION: Webhook triggers use hmacSecret for all verification formats. " + "Omit verification for legacy HMAC-SHA256 over the raw body with fallback header scanning; " + "or set verification to { format: 'hmac-sha256', header }, { format: 'timestamped-hmac-sha256', header, toleranceSeconds? }, " + "{ format: 'token-equality', header }, or { format: 'standard-webhooks', toleranceSeconds? } " + "(standardwebhooks.com: webhook-id/webhook-timestamp/webhook-signature headers, hmacSecret is the whsec_ signing secret). Example: { type: 'webhook', hmacSecret: 'secret.SUPERAGENT_WEBHOOK_SECRET', " + `verification: { format: 'timestamped-hmac-sha256', header: 'X-Superagent-Signature', toleranceSeconds: 300 } }.
|
|
142347
|
+
` + "- WEBHOOK EVENT FILTER: optional events: ['pull_request'] on a webhook trigger drops other deliveries after signature verification, " + `before any run is saved (2xx skipped reply). The event is read from eventHeader (default X-GitHub-Event).
|
|
143547
142348
|
` + "- WAIT NODE: type 'wait' pauses a workflow for a duration or until a named workflowEventBus event arrives. " + "See runbooks/workflows.md#wait-nodes for config shapes, ordering caveats, and built-in event names.",
|
|
143548
142349
|
inputSchema: object2({
|
|
143549
142350
|
name: string2().describe("Unique name for the workflow"),
|
|
@@ -144315,7 +143116,7 @@ var registerUpdateWorkflowTool = (server) => {
|
|
|
144315
143116
|
createToolRegistrar(server)("update-workflow", {
|
|
144316
143117
|
title: "Update Workflow",
|
|
144317
143118
|
annotations: { destructiveHint: false },
|
|
144318
|
-
description: "Update an existing workflow's name, description, definition, triggers, cooldown, input, triggerSchema, or enabled state. " + "Creates a version snapshot before applying changes. " + "TRIGGER SCHEMA: pass 'triggerSchema' as a JSON-Schema object to set/replace, or 'null' to clear. " + "Supported JSON-Schema keywords: type, required, properties, enum, const, items (recursive into arrays). " + "Other JSON-Schema keywords (oneOf/anyOf/$ref/pattern/format/additionalProperties) are silently ignored. " + "WEBHOOK VERIFICATION: webhook triggers use hmacSecret for all verification formats. " + "Omit verification for legacy HMAC-SHA256 over the raw body with fallback header scanning; " + "or set verification to { format: 'hmac-sha256', header }, { format: 'timestamped-hmac-sha256', header, toleranceSeconds? }, " + "{ format: 'token-equality', header }, or { format: 'standard-webhooks', toleranceSeconds? } " + "(standardwebhooks.com: webhook-id/webhook-timestamp/webhook-signature headers, hmacSecret is the whsec_ signing secret).",
|
|
143119
|
+
description: "Update an existing workflow's name, description, definition, triggers, cooldown, input, triggerSchema, or enabled state. " + "Creates a version snapshot before applying changes. " + "TRIGGER SCHEMA: pass 'triggerSchema' as a JSON-Schema object to set/replace, or 'null' to clear. " + "Supported JSON-Schema keywords: type, required, properties, enum, const, items (recursive into arrays). " + "Other JSON-Schema keywords (oneOf/anyOf/$ref/pattern/format/additionalProperties) are silently ignored. " + "WEBHOOK VERIFICATION: webhook triggers use hmacSecret for all verification formats. " + "Omit verification for legacy HMAC-SHA256 over the raw body with fallback header scanning; " + "or set verification to { format: 'hmac-sha256', header }, { format: 'timestamped-hmac-sha256', header, toleranceSeconds? }, " + "{ format: 'token-equality', header }, or { format: 'standard-webhooks', toleranceSeconds? } " + "(standardwebhooks.com: webhook-id/webhook-timestamp/webhook-signature headers, hmacSecret is the whsec_ signing secret). " + "WEBHOOK EVENT FILTER: optional events: ['pull_request'] on a webhook trigger drops other deliveries after signature verification, " + "before any run is saved (2xx skipped reply). The event is read from eventHeader (default X-GitHub-Event).",
|
|
144319
143120
|
inputSchema: object2({
|
|
144320
143121
|
id: string2().uuid().describe("Workflow ID to update"),
|
|
144321
143122
|
key: AssetKeySchema.optional().describe("Move to a logical namespace."),
|
|
@@ -144501,7 +143302,7 @@ function removeTools(server, names) {
|
|
|
144501
143302
|
tools[name]?.remove();
|
|
144502
143303
|
}
|
|
144503
143304
|
async function createServer(opts = {}) {
|
|
144504
|
-
await
|
|
143305
|
+
await loadGlobalConfigsIntoEnv2(true);
|
|
144505
143306
|
const toolAllowlist = opts.fullSurface === true ? undefined : resolveToolAllowlist(opts.enabledTools ?? process.env.SWARM_ENABLED_TOOLS);
|
|
144506
143307
|
const hasCapability = (cap) => opts.fullSurface === true || toolAllowlist !== undefined || (cap === "chat-sdk" ? isChatSdkEnabled() : getCapabilities().has(cap));
|
|
144507
143308
|
initDb2(process.env.DATABASE_PATH);
|
|
@@ -144941,4 +143742,4 @@ var init_server = __esm(() => {
|
|
|
144941
143742
|
loggedToolAllowlistWarnings = new Set;
|
|
144942
143743
|
});
|
|
144943
143744
|
|
|
144944
|
-
export { DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, isJSONRPCErrorResponse, JSONRPCMessageSchema, isInitializeRequest, init_types, McpServer, init_mcp, referencedBundlePaths, skillDirs, init_manifest_format, recoverIncompleteRuns, init_recovery, handleWebhookTrigger, verifyHmacSignature, WebhookError, init_triggers, snapshotAndUpdateWorkflow, init_version, applyPreTaskCreate, init_apply_task_create, TaskCreationBlockedError, init_errors, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, init_raw_llm, getExecutorRegistry2, initWorkflows2, init_workflows, stripSiblingBlock, init_sibling_block, createTaskWithSiblingAwareness, init_sibling_awareness, dispatchScheduleTarget, calculateNextRun2, startScheduler2, stopScheduler2, runScheduleNow2, init_scheduler, ExtensionAssetConflictError, hashOf, scriptHash, liveScriptSpec, liveWorkflowSpec, skillSpecOf, liveSkillSpec, skillHash, init_assets, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, init_db, SDK_ALLOWLIST, mcpToolNameForSdkMethod, init_sdk_allowlist, MCP_OVERFLOW_NAMESPACE, mcpOverflowAuthError, init_kv_overflow, hasKvViewArgs, resolveKvView, init_kv_view, COLOR_LITERAL_THRESHOLD, countColorLiterals, init_color_literals, toolErr, createToolRegistrar, init_utils, handleMcpBridge, init_mcp_bridge, Redacted, init_redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, init_response_limit, retry, init_retry, ExtensionConfigError, init_loader, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, init_lifecycle, ExtensionAbortedError2, isRegistered2, isExtensionAgentId2, getExtensionBridgeToken2, resolveBridgeCallOrigin2, extensionIdForAgent2, runContext2, registerLoaded2, unregister2, listRegistered2, dispatchPre2, dispatchPost2, init_dispatcher, resolveIdentity, renderIdentity, init_identity, recordUnmappedIdentity, init_unmapped_identities, getDeliveredSlackMessageTs, foldIntoPendingSlackTask, init_slack_fold, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, scopeFromAttachment, backingProviderId, init_task_attachment_store, transcribeAudioNotes, init_transcription, init_templates, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, attachSlackFilesToDraft, notifySlackFileFailures, init_inbound_files, pendingWorkForAgent, countPoolRuntimes, computeDesired, init_demand, isRuntimePoolWakeable, isAgentReachable, isAgentOnDemand, init_reachability, isAddressedToOtherUser, broadcastMatches, routeMessage, extractTaskFromMessage, init_router, extractSlackMessageText, slackInboundMessageText, collectSlackMessageFiles, init_message_text, createAdditiveBuffer, init_additive_buffer, repointTrackerSyncBySwarmId, init_tracker, REBOOT_RETRY_PIN_TAG2, getPinCandidateAgent2, resolveLeadOnlyRecoveryAssignment2, getResumeGeneration2, getNextResumeGeneration2, inheritedModelSelection2, nextFallback2, createWorkerTaskFollowUp2, createResumeFollowUp2, createRerouteDecisionTask2, createPoolStarvationDecisionTask2, init_worker_follow_up, isGitHubEnabled, initGitHub, verifyWebhookSignature, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, isInboxAllowed, isSenderAllowed, handleMessageReceived, init_agentmail, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, init_azure_devops, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, handleWorkItemCreated, handleWorkItemUpdated, handleWorkItemCommented, handleWorkItemDeleted, handleWorkItemRestored, initAzureDevOpsOutbound, init_azure_devops2, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, init_rbac_audit, getTelemetryIngestAnchor, init_telemetry_ingest_anchor, initApiTelemetry, syncTelemetryEnabled, init_telemetry_enable, isBitbucketEnabled, initBitbucket, verifyBitbucketWebhook, isDuplicateDelivery, markDeliveryProcessed, pullRequestEventOf, pullRequestCommentEventOf, handlePullRequestCreated2, handlePullRequestCommentCreated, handlePullRequestClosed, init_bitbucket, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, init_github, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2, handleNote, handlePipeline, init_gitlab, isChatSdkEnabled, getChatSdkConfig, init_config, errorMessage, init_logger, resolveAdapterApiUrl, init_adapters, trackBackground, init_background, TelegramBotApiError, callTelegramBotApi, init_telegram_api, isTrustedTeamsServiceUrl, init_teams_origin, getSessionLabels, rememberSessionLabel, getResourceSessionLabels, init_session_labels, isChatSdkStopping, startChatSdk, getChatInstance, isChatAdapterConfigured, getChatSdkHealth, stopChatSdk, init_runtime, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, init_metadata, registerJiraWebhook, deleteJiraWebhook, init_webhook_lifecycle, isJiraEnabled, initJira, init_app, handleJiraWebhook, init_webhook, init_jira, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, init_sync, isLinearEnabled, initLinear, init_app2, init_linear, init_slack, verifyPageSession, LEGACY_PAGE_SESSION_COOKIE, isCookieSafePageId, extractPageSession, extractLegacyPageSession, extractAndVerifyCookie, isLocalDevPageRequest, pageSessionSetCookies, init_page_session, resolveHttpRequestAuth, init_auth, getDeploymentEnvValue, loadGlobalConfigsIntoEnv, reloadGlobalConfigsAndIntegrations, scheduleIntegrationsReload, handleCore, init_core, MCP_MAX_TOOL_INPUT_ELEMENTS, MCP_MAX_REQUEST_BODY_BYTES, init_mcp_limits, userCtx, init_task_tool_ctx, resolveRequestPrincipal, requestPrincipal, agentFirstPrincipal, requireAuthKind, rejectGuest, init_request_principal, resolveTaskRequester, init_task_requester, handleApps, init_apps, cancelApprovalRequest, cancelApprovalRequestAndRun, init_approval_cancel, getUserCommsPrefs, init_requester_comms, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, init_get_task_details, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, init_cancel_task, DbQueryTimeoutError, DbQueryConcurrencyCapError, executeReadOnlyQuery, getDbQueryHttpBudgetMs, init_db_query_shared, assertSelectOnlyQuery, executeReadOnlyQueryGated, handleDbQuery, init_db_query, snapshotMetric, init_version2, AssetKeyAuthorizationError, authorizeAssetKeyWrite, init_asset_key_auth, getPageEditCounter, init_page_versions, snapshotPage, init_version3, DEFAULT_THEME_ID, THEME_PRESET_IDS, getThemePreset, init_presets, readThemeFields, init_page_fields, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, init_app_validation, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, init_presets2, scopedResourceScopeIdSchema, resolveScopedResourceId, init_scoped_resource, MemoryKeyError, init_key_guard, refreshLinks, init_link_resolver, indexMemoryContent, init_index_content, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, init_retrieval, ExplicitSelfDuplicateError, applyRating, init_store, shouldPersistAutomaticTaskMemory, init_automatic_task_gate, guardTerminalTaskResultWrite, init_terminal_result_guard, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, init_get_tasks, requiresLeadToWrite, reservedNamespaceError, privateNamespaceError, reservedRoomKeyError, init_kv_reserved_namespaces, updateMcpServerChecked, init_mcp_server_checked_update, updateTouchesStdioExecution, init_mcp_server_stdio_gate, canReadMemory, init_access, getLinksForMemory, init_links_store, expandCandidatesWithGraph, init_graph_expansion, isApiDraining, drainApi, init_api_drain, markKapsoMessageRead, sendKapsoReaction, init_client, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, init_config2, changesAllowMerge, init_repo_merge_policy, updateSwarmRepoChecked, init_repo_checked_update, getCombConfig, init_config3, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, sessionAccessTopic, sessionPresenceRoot, init_auth2, RoomOperationSchema, init_document, removeAwarenessStates, init_awareness, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, init_rooms, init_scheduler2, MEMORY_KEYS_DEFAULT_PREFIX, MEMORY_KEYS_MAX_LIMIT, estimateTokens, posteriorMean, listMemoryKeys, checkChunkIntegrity, getMemoryChunks, getPosteriorsByIds, init_key_browser, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, init_events, mergeScheduleTiming, validateRecurringTiming, init_validate, followUpThreadForSourceTask, evaluateFollowUpRedelegation, init_follow_up_redelegation_guard, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, init_send_task, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, init_steer_task, skipReasonFrom, finalizeSkippedTaskReaction, init_task_skip, IMPROVEMENT_TEXT_MAX, IMPROVEMENT_STATUSES, IMPROVEMENT_SOURCES, ImprovementError, isImprovementsEnabled, getImprovement, listImprovements, createImprovement, approveAndSend, discardImprovement, improvementLeakHints, init_improvements, canClaim, init_budget_admission, emitBudgetRefusalSideEffects, init_budget_refusal_notify, workflowModelErrors, init_model_validation, patchWorkflowDefinition, init_patch_definition, idempotencyKeyHeader, readIdempotencyKey, replayAcceptedOperation, init_idempotency_key, resolveScriptsOnlyMode, init_scripts_only_mode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer, init_server };
|
|
143745
|
+
export { DEFAULT_NEGOTIATED_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, isJSONRPCRequest, isJSONRPCResultResponse, isJSONRPCErrorResponse, JSONRPCMessageSchema, isInitializeRequest, init_types, McpServer, init_mcp, referencedBundlePaths, skillDirs, init_manifest_format, recoverIncompleteRuns, init_recovery, handleWebhookTrigger, verifyHmacSignature, WebhookError, init_triggers, snapshotAndUpdateWorkflow, init_version, applyPreTaskCreate, init_apply_task_create, RawLlmConfigSchema, RawLlmOutputSchema, executeRawLlm, init_raw_llm, getExecutorRegistry2, initWorkflows2, init_workflows, stripSiblingBlock, init_sibling_block, createTaskWithSiblingAwareness, init_sibling_awareness, dispatchScheduleTarget, calculateNextRun2, startScheduler2, stopScheduler2, runScheduleNow2, init_scheduler, ExtensionAssetConflictError, hashOf, scriptHash, liveScriptSpec, liveWorkflowSpec, skillSpecOf, liveSkillSpec, skillHash, init_assets, ExtensionOwnershipError, getExtensionFiles, getExtensionById, getExtensionByName, listExtensions, listExtensionVersions, updateExtensionMeta, listExtensionRuns, init_db, SDK_ALLOWLIST, mcpToolNameForSdkMethod, init_sdk_allowlist, MCP_OVERFLOW_NAMESPACE, mcpOverflowAuthError, init_kv_overflow, hasKvViewArgs, resolveKvView, init_kv_view, COLOR_LITERAL_THRESHOLD, countColorLiterals, init_color_literals, toolErr, createToolRegistrar, init_utils, handleMcpBridge, init_mcp_bridge, Redacted, init_redacted, SCRIPT_SDK_RESPONSE_LIMIT_BYTES, readScriptSdkJsonResponse, init_response_limit, retry, init_retry, ExtensionConfigError, init_loader, ExtensionLifecycleError, setExtensionLoopbackBaseUrl, enableExtension, disableExtension, activateVersion, ExtensionAssetsInvalidError, installExtensionWithAssets, uninstallExtension, reloadExtension, loadEnabledExtensions, stopExtensionRuntime, init_lifecycle, ExtensionAbortedError2, isRegistered2, isExtensionAgentId2, getExtensionBridgeToken2, resolveBridgeCallOrigin2, extensionIdForAgent2, runContext2, registerLoaded2, unregister2, listRegistered2, dispatchPre2, dispatchPost2, init_dispatcher, resolveIdentity, renderIdentity, init_identity, recordUnmappedIdentity, init_unmapped_identities, getDeliveredSlackMessageTs, foldIntoPendingSlackTask, init_slack_fold, MAX_TASK_ATTACHMENT_BYTES, recordTaskAttachmentUpload, scopeFromAttachment, backingProviderId, init_task_attachment_store, transcribeAudioNotes, init_transcription, init_templates, buildEffectiveText, bufferedFileFailures, fetchSlackFiles, createSlackTaskWithFiles, attachSlackFilesToDraft, notifySlackFileFailures, init_inbound_files, pendingWorkForAgent, countPoolRuntimes, computeDesired, init_demand, isRuntimePoolWakeable, isAgentReachable, isAgentOnDemand, init_reachability, isAddressedToOtherUser, broadcastMatches, routeMessage, extractTaskFromMessage, init_router, extractSlackMessageText, slackInboundMessageText, collectSlackMessageFiles, init_message_text, createAdditiveBuffer, init_additive_buffer, isAgentMailEnabled, initAgentMail, verifyAgentMailWebhook, isInboxAllowed, isSenderAllowed, handleMessageReceived, init_agentmail, isAzureDevOpsEnabled, initAzureDevOps, verifyAzureDevOpsWebhook, repointTrackerSyncBySwarmId, init_tracker, isAzureDevOpsUrl, canonicalAzureDevOpsRepoUrl, parseAzureDevOpsRepoUrl, init_azure_devops, createdPullRequestOf, commentedPayloadOf, handlePullRequestCreated, handlePullRequestCommented, handleWorkItemCreated, handleWorkItemUpdated, handleWorkItemCommented, handleWorkItemDeleted, handleWorkItemRestored, initAzureDevOpsOutbound, init_azure_devops2, enqueueAuditRow, enqueueAdmissionRow, flushAuditBuffer, startAuditWriter, stopAuditWriter, startAuditGc, stopAuditGc, init_rbac_audit, getTelemetryIngestAnchor, init_telemetry_ingest_anchor, initApiTelemetry, syncTelemetryEnabled, init_telemetry_enable, isBitbucketEnabled, initBitbucket, verifyBitbucketWebhook, isDuplicateDelivery, markDeliveryProcessed, pullRequestEventOf, pullRequestCommentEventOf, handlePullRequestCreated2, handlePullRequestCommentCreated, handlePullRequestClosed, init_bitbucket, isGitHubEnabled, initGitHub, verifyWebhookSignature, handlePullRequest, handleIssue, handleComment, handlePullRequestReview, handleCheckRun, handleCheckSuite, handleWorkflowRun, init_github, isGitLabEnabled, initGitLab, verifyGitLabWebhook, handleMergeRequest, handleIssue2, handleNote, handlePipeline, init_gitlab, isChatSdkEnabled, getChatSdkConfig, init_config, errorMessage, init_logger, resolveAdapterApiUrl, init_adapters, trackBackground, init_background, TelegramBotApiError, callTelegramBotApi, init_telegram_api, isTrustedTeamsServiceUrl, init_teams_origin, getSessionLabels, rememberSessionLabel, getResourceSessionLabels, init_session_labels, isChatSdkStopping, startChatSdk, getChatInstance, isChatAdapterConfigured, getChatSdkHealth, stopChatSdk, init_runtime, getJiraMetadata, updateJiraMetadata, clearJiraMetadata, init_metadata, registerJiraWebhook, deleteJiraWebhook, init_webhook_lifecycle, isJiraEnabled, initJira, init_app, handleJiraWebhook, init_webhook, init_jira, handleAgentSessionEvent, handleIssueUpdate, handleIssueDelete, handleAgentSessionPrompted, init_sync, isLinearEnabled, initLinear, init_app2, init_linear, init_slack, verifyPageSession, LEGACY_PAGE_SESSION_COOKIE, isCookieSafePageId, extractPageSession, extractLegacyPageSession, extractAndVerifyCookie, isLocalDevPageRequest, pageSessionSetCookies, init_page_session, resolveHttpRequestAuth, init_auth, getDeploymentEnvValue2, loadGlobalConfigsIntoEnv2, reloadGlobalConfigsAndIntegrations2, scheduleIntegrationsReload2, handleCore2, init_core, runTaskUiScriptAction, init_script_actions, REBOOT_RETRY_PIN_TAG2, getPinCandidateAgent2, resolveLeadOnlyRecoveryAssignment2, getResumeGeneration2, getNextResumeGeneration2, inheritedModelSelection2, nextFallback2, createWorkerTaskFollowUp2, createResumeFollowUp2, createRerouteDecisionTask2, createPoolStarvationDecisionTask2, init_worker_follow_up, MCP_MAX_TOOL_INPUT_ELEMENTS, MCP_MAX_REQUEST_BODY_BYTES, init_mcp_limits, userCtx, init_task_tool_ctx, resolveRequestPrincipal, requestPrincipal, agentFirstPrincipal, requireAuthKind, rejectGuest, init_request_principal, resolveTaskRequester, init_task_requester, handleApps, init_apps, cancelApprovalRequest, cancelApprovalRequestAndRun, init_approval_cancel, getUserCommsPrefs, init_requester_comms, getTaskDetailsInputSchema, getTaskDetailsOutputSchema, getTaskDetailsHandler, init_get_task_details, cancelTaskInputSchema, cancelTaskOutputSchema, cancelTaskHandler, init_cancel_task, DbQueryTimeoutError, DbQueryConcurrencyCapError, executeReadOnlyQuery, getDbQueryHttpBudgetMs, init_db_query_shared, assertSelectOnlyQuery, executeReadOnlyQueryGated, handleDbQuery, init_db_query, snapshotMetric, init_version2, AssetKeyAuthorizationError, authorizeAssetKeyWrite, init_asset_key_auth, getPageEditCounter, init_page_versions, snapshotPage, init_version3, DEFAULT_THEME_ID, THEME_PRESET_IDS, getThemePreset, init_presets, readThemeFields, init_page_fields, assertOAuthAppUrlsSafe, assertOAuthEgressUrlSafe, init_app_validation, listOAuthPresets, listOAuthPresetIds, getOAuthPreset, hydrateOAuthAppFromPreset, init_presets2, scopedResourceScopeIdSchema, resolveScopedResourceId, init_scoped_resource, MemoryKeyError, init_key_guard, refreshLinks, init_link_resolver, indexMemoryContent, init_index_content, dedupeMemoryDocumentIds, recordMemoryAccesses, recordRetrievals, init_retrieval, ExplicitSelfDuplicateError, applyRating, init_store, shouldPersistAutomaticTaskMemory, init_automatic_task_gate, guardTerminalTaskResultWrite, init_terminal_result_guard, getTasksInputSchema, getTasksOutputSchema, getTasksHandler, init_get_tasks, requiresLeadToWrite, reservedNamespaceError, privateNamespaceError, reservedRoomKeyError, init_kv_reserved_namespaces, updateMcpServerChecked, init_mcp_server_checked_update, updateTouchesStdioExecution, init_mcp_server_stdio_gate, canReadMemory, init_access, getLinksForMemory, init_links_store, attachDemotionEvidence, init_demotion_evidence, expandCandidatesWithGraph, init_graph_expansion, isApiDraining, drainApi, init_api_drain, markKapsoMessageRead, sendKapsoReaction, init_client, getKapsoConfig, getKapsoNumberMapping, markKapsoMessageSeen, init_config2, changesAllowMerge, init_repo_merge_policy, updateSwarmRepoChecked, init_repo_checked_update, getCombConfig, init_config3, resolveRoomNamespace, roomRequestInfo, authorizeRoomNamespace, sessionAccessTopic, sessionPresenceRoot, init_auth2, RoomOperationSchema, init_document, removeAwarenessStates, init_awareness, roomTopic, decodeRoomSnapshot, roomView, getRoom, changeRoom, applyRoomUpdate, resetRoom, sweepRooms, closeRooms, removeNamespaceRooms, init_rooms, init_scheduler2, MEMORY_KEYS_DEFAULT_PREFIX, MEMORY_KEYS_MAX_LIMIT, estimateTokens, posteriorMean, listMemoryKeys, checkChunkIntegrity, getMemoryChunks, getPosteriorsByIds, init_key_browser, createEvent, createEventsBatch, getEventCountsFiltered, getEventsFiltered, init_events, mergeScheduleTiming, validateRecurringTiming, init_validate, followUpThreadForSourceTask, evaluateFollowUpRedelegation, init_follow_up_redelegation_guard, checkOutputSchemaShape, sendTaskOutputSchema, sendTaskHandler, init_send_task, steerTaskUserInputSchema, steerTaskOutputSchema, steerTaskHandler, init_steer_task, skipReasonFrom, finalizeSkippedTaskReaction, init_task_skip, IMPROVEMENT_TEXT_MAX, IMPROVEMENT_STATUSES, IMPROVEMENT_SOURCES, ImprovementError, isImprovementsEnabled, getImprovement, listImprovements, createImprovement, approveAndSend, discardImprovement, improvementLeakHints, init_improvements, recomputeSessionCost, init_session_cost_recompute, canClaim, init_budget_admission, emitBudgetRefusalSideEffects, init_budget_refusal_notify, workflowModelErrors, init_model_validation, patchWorkflowDefinition, init_patch_definition, idempotencyKeyHeader, readIdempotencyKey, replayAcceptedOperation, init_idempotency_key, resolveScriptsOnlyMode, init_scripts_only_mode, ALL_CAPABILITIES, hasCapability, getEnabledCapabilities, createServer, init_server };
|