@desplega.ai/agent-swarm 2.9.0 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-adapter-g909b5hw.js +16 -0
- package/dist/{acp-targets-swxq55dr.js → acp-targets-ny75x1qy.js} +7 -7
- package/dist/{actions-pb678g3e.js → actions-b9qgrmeq.js} +81 -21
- package/dist/{agent-fs-provision-dmhnc38q.js → agent-fs-provision-b5dhdsbd.js} +4 -4
- package/dist/{amp-adapter-3pa66q27.js → amp-adapter-vtax2c9s.js} +2 -2
- package/dist/{anthropic-messages-x2cp5fvf.js → anthropic-messages-r5xf5hqw.js} +10 -10
- package/dist/{app-17d12ev4.js → app-g2z15hax.js} +6 -3
- package/dist/{approval-notifications-h7vd9pmg.js → approval-notifications-yt13wp8r.js} +8 -5
- package/dist/{assistant-t7k39ree.js → assistant-2cgfxsgk.js} +23 -21
- package/dist/{boot-args-schema-0gqmkfbe.js → boot-args-schema-3gwy0f60.js} +1 -1
- package/dist/{boot-reembed-n6anc01d.js → boot-reembed-92g7s5zp.js} +1 -1
- package/dist/{boot-reembed-f064w382.js → boot-reembed-mywmyp4s.js} +1 -1
- package/dist/{boot-scrub-sweep-ejd5dnrz.js → boot-scrub-sweep-7dkdzqxx.js} +3 -3
- package/dist/{boot-seeds-f99fjs5q.js → boot-seeds-ce7rvgq1.js} +4 -4
- package/dist/{claude-adapter-gvznwxgc.js → claude-adapter-3m4q7735.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-c217draw.js} +3 -3
- package/dist/{claude-sdk-session-0t2teq6n.js → claude-sdk-session-7fbqm51z.js} +7 -7
- package/dist/{cli-9a2rtd77.js → cli-1jykg0py.js} +6 -4
- package/dist/{cli-5ntc4we6.js → cli-2czxfnvj.js} +235 -2003
- package/dist/{cli-dd37e0cm.js → cli-2dq9yv8p.js} +1 -1
- package/dist/{cli-c07v0qfa.js → cli-2xs8tsf7.js} +69 -66
- package/dist/{cli-7fx9jyfs.js → cli-2yjj3e31.js} +64 -10
- package/dist/{cli-4ghh072d.js → cli-32djehja.js} +36 -36
- package/dist/{cli-cw7mc1je.js → cli-3j873zxq.js} +3 -3
- 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-5gygrr67.js → cli-67mwzr35.js} +1 -1
- package/dist/{cli-5kcmxwxv.js → cli-6945ywhr.js} +1 -1
- 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-eg437b5p.js → cli-7sf9sb0w.js} +2 -1
- package/dist/{cli-nr46j5pw.js → cli-8zh9nrew.js} +1 -1
- package/dist/{cli-wr1h0k28.js → cli-9w8712tq.js} +617 -278
- package/dist/{cli-ssvdrk4y.js → cli-b6px1k1q.js} +1 -1
- package/dist/{cli-7831nhaw.js → cli-b91nz213.js} +3 -3
- package/dist/{cli-7cgf614g.js → cli-bg63qmsx.js} +2 -2
- package/dist/{cli-me4maa4j.js → cli-bkjdknnp.js} +9 -5
- package/dist/{cli-rts1qvb4.js → cli-bnqncekd.js} +2 -2
- package/dist/{cli-25nstr34.js → cli-br0924pw.js} +1 -1
- package/dist/{cli-ymct0ycy.js → cli-ctx0b85j.js} +5222 -4978
- package/dist/{cli-kqh27v2y.js → cli-dgs10ttj.js} +1 -1
- package/dist/{cli-kmvcm34h.js → cli-f3jyzq4g.js} +2 -2
- package/dist/cli-f8x9drqr.js +84 -0
- package/dist/{cli-8axx8vnw.js → cli-f9gz2vyj.js} +5 -5
- package/dist/{cli-vvgaz8t6.js → cli-fh97xn30.js} +2 -2
- package/dist/{cli-8x8y70av.js → cli-fkef327x.js} +2 -2
- package/dist/{cli-js8zrfyg.js → cli-gfy38pvt.js} +2 -2
- package/dist/{cli-kaa4bd7x.js → cli-h9yqfzx9.js} +7 -6
- package/dist/{cli-svc803vq.js → cli-j7svy295.js} +11 -11
- package/dist/{cli-nhq5js1b.js → cli-jaw5v1sy.js} +3 -3
- package/dist/{cli-w7dxb2fj.js → cli-jkw6ptfw.js} +6 -6
- package/dist/{cli-1tvdx9t5.js → cli-jm0hvmz2.js} +1 -1
- package/dist/{cli-e9973bf0.js → cli-jwampxxq.js} +2 -2
- package/dist/{cli-dx439zpg.js → cli-kpgcm7xy.js} +13 -1
- package/dist/{cli-pz1c00aa.js → cli-kxx4k2jw.js} +2 -2
- package/dist/{cli-aa8s22gn.js → cli-m7c2380k.js} +191 -182
- package/dist/{cli-2kg31ted.js → cli-m7zvgt57.js} +11 -11
- package/dist/{cli-57pvhnyt.js → cli-mhapr559.js} +1 -1
- package/dist/{cli-gddgcnav.js → cli-mjw0yf82.js} +1 -1
- package/dist/{cli-h474mvp5.js → cli-mkwkwq81.js} +7 -4
- package/dist/{cli-jd3kxppb.js → cli-mw620q3n.js} +1 -1
- package/dist/{cli-spzkdgtg.js → cli-n3qe7tyr.js} +172 -168
- package/dist/{cli-3zxdz9r7.js → cli-nafvvsp8.js} +3 -3
- package/dist/{cli-fnh4b12r.js → cli-nbt14he0.js} +6 -6
- package/dist/{cli-7akn6ze9.js → cli-nh7x3133.js} +7 -28
- package/dist/{cli-faf46gdq.js → cli-p4kckx1z.js} +10 -10
- package/dist/{cli-k7pt28ad.js → cli-pb2ay3sh.js} +2 -2
- package/dist/{cli-pn1v1pb0.js → cli-psffsanb.js} +3 -2
- package/dist/{cli-2tnbc3gw.js → cli-pyjn0qhk.js} +2257 -61
- package/dist/{cli-fgphc007.js → cli-rq5rpv6k.js} +1 -1
- package/dist/{cli-vw5x18yj.js → cli-sn650d7x.js} +9 -9
- package/dist/{cli-mc1fx4xd.js → cli-td9tb872.js} +10 -10
- package/dist/{cli-6dp0jkfj.js → cli-tvc4jag9.js} +3 -3
- package/dist/{cli-a9hfzg2r.js → cli-ty3gha1p.js} +6 -6
- package/dist/{cli-pwsax0vp.js → cli-v57d7fmm.js} +1 -1
- package/dist/{cli-nmcpzbty.js → cli-vt89089n.js} +4 -4
- package/dist/{cli-sn4pc4qx.js → cli-vyff45ve.js} +2 -2
- package/dist/{cli-m1fbz2wj.js → cli-w4n323t3.js} +175 -16
- package/dist/{cli-g3zzby8t.js → cli-wn13hhdt.js} +5 -5
- package/dist/{cli-q8cfh1t9.js → cli-xag7btpe.js} +1 -1
- package/dist/{cli-c5cspahx.js → cli-y2ewxhth.js} +38 -13
- package/dist/{cli-k09cxm6m.js → cli-ysvspf5e.js} +2 -2
- package/dist/{cli-eepnpee7.js → cli-zh0e5x7p.js} +4 -4
- package/dist/{cli-bk9v1xrv.js → cli-zr6qy15y.js} +11 -11
- package/dist/cli.js +21 -20
- package/dist/{codex-adapter-44yq2fkn.js → codex-adapter-n656pvb8.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-p0fbv5y9.js} +6 -6
- package/dist/{commands-54f02v5b.js → commands-gwea8z5p.js} +3 -3
- package/dist/{controller-9gpwcdek.js → controller-t67c3grh.js} +6 -3
- package/dist/{controllers-connect-61re6k1n.js → controllers-connect-ks155r0h.js} +22 -20
- package/dist/{cursor-adapter-7e4g81vd.js → cursor-adapter-ygwrtmkv.js} +1 -1
- package/dist/{db-dg2gc7fd.js → db-kpmx06s9.js} +8 -2
- package/dist/{db-wnh0qjy1.js → db-rb2xqdb1.js} +3 -3
- package/dist/{dispatcher-jrm24r43.js → dispatcher-31sm0ej2.js} +20 -18
- package/dist/{docker-9aq30pp2.js → docker-09tkkg0n.js} +42 -3
- package/dist/{dsh-adapter-1yqk267c.js → dsh-adapter-qyxh0w31.js} +1 -1
- package/dist/{easter-egg-3d-r4h9cs9m.js → easter-egg-3d-00wjscn6.js} +1 -1
- package/dist/{embedding-space-bafjr5f7.js → embedding-space-qhw4g68n.js} +6 -6
- package/dist/{embeddings-7xmgqe0e.js → embeddings-zdv9ke6x.js} +1 -1
- package/dist/{execute-d6jg5ns0.js → execute-zna8wwr7.js} +1 -1
- package/dist/{external-channel-frq1xvq2.js → external-channel-1ac6t56s.js} +2 -2
- package/dist/fx-adapter-sk7n0fzc.js +19 -0
- package/dist/{google-generative-ai-hh7strj3.js → google-generative-ai-maq6c9bf.js} +1 -1
- package/dist/{google-vertex-fy5bw2pm.js → google-vertex-2jgsw2nb.js} +1 -1
- package/dist/grok-adapter-sjbcm5ew.js +19 -0
- package/dist/handlers-yzy0c87x.js +35 -0
- package/dist/{heartbeat-6bpa611t.js → heartbeat-2f6z4kdx.js} +23 -21
- package/dist/{hook-w12k146y.js → hook-8y0gvtp1.js} +6 -6
- package/dist/{hook-hvm5nf46.js → hook-w1skzaqc.js} +5 -5
- package/dist/{http-43tthdvs.js → http-wghxvpef.js} +714 -145
- package/dist/{index-1f0vypbg.js → index-0h6qd4p1.js} +34 -24
- package/dist/index-25pvya7q.js +40 -0
- package/dist/index-2t4859r5.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-mhq4sh5w.js → index-8zn8nxn5.js} +1 -1
- package/dist/{index-m5gx1xd6.js → index-9myfj74s.js} +40 -40
- package/dist/{index-ftywhyr0.js → index-9zkchs9t.js} +221 -65
- package/dist/{index-bs7gw5fd.js → index-b5wgnm78.js} +44 -44
- package/dist/index-cxca2t8y.js +36 -0
- package/dist/{index-585gyczt.js → index-pe3d8jfy.js} +3 -3
- package/dist/{index-tx9mc2ap.js → index-rv89fvzf.js} +24 -22
- package/dist/{index-fn054vsf.js → index-s71ez27v.js} +1 -1
- package/dist/{keepalive-rk0j0jvh.js → keepalive-sh02349h.js} +3 -3
- package/dist/lead-gk4h5eg7.js +74 -0
- package/dist/{maintenance-g6z6kaxw.js → maintenance-yj0dcjja.js} +1 -1
- package/dist/{node-jftbyawr.js → node-dqm4xgxw.js} +1 -1
- package/dist/{oauth-refresh-sweep-2k3g2q4w.js → oauth-refresh-sweep-d9xedk66.js} +2 -2
- package/dist/{onboard-6fdbvh3v.js → onboard-dpgjn03r.js} +2 -2
- package/dist/{opencode-adapter-fdbsvts7.js → opencode-adapter-2d31cpjc.js} +6 -6
- package/dist/{otel-impl-rvwtc09q.js → otel-impl-1skarpfq.js} +1 -1
- package/dist/{pending-sqkrb836.js → pending-bfmxtx0g.js} +21 -19
- package/dist/{pi-mono-adapter-asqayqcg.js → pi-mono-adapter-gvppnasy.js} +40 -13
- package/dist/{pricing-refresh-f5tkgmw2.js → pricing-refresh-c6b325mk.js} +2 -2
- package/dist/{rbac-roles-06s555fa.js → rbac-roles-h80qbdbs.js} +3 -3
- package/dist/{rbac-roles-szxsg8t1.js → rbac-roles-zfcx68tx.js} +2 -2
- package/dist/{render-v2-103p266q.js → render-v2-nx20t3rb.js} +6 -3
- package/dist/{resume-v7kjewt9.js → resume-5ep8agan.js} +10 -7
- package/dist/{runtime-f1gmk0b7.js → runtime-r3pj4mce.js} +1 -1
- package/dist/{session-access-6shev8ts.js → session-access-n7p3m15b.js} +4 -4
- package/dist/{session-source-backfill-bd7spzjd.js → session-source-backfill-v8mt0zwn.js} +3 -3
- package/dist/{setup-kmxmztdb.js → setup-z1psaqhe.js} +1 -1
- package/dist/thread-buffer-a1re2r9r.js +38 -0
- package/dist/{virtual-modules-57eje5wy.js → virtual-modules-rrbjdpxn.js} +3 -3
- package/dist/{work-objects-zr47ygmf.js → work-objects-4aghh73z.js} +29 -23
- package/dist/worker-3dyyb8ev.js +74 -0
- package/dist/{worker-follow-up-grrr3fda.js → worker-follow-up-166zmex1.js} +20 -18
- package/openapi.json +1387 -13
- package/package.json +7 -6
- package/src/apps/catalog.generated.json +43 -3
- package/src/apps/page-validator.ts +27 -0
- package/src/be/db/model-profiles.ts +4 -1
- package/src/be/db/session-costs.ts +219 -0
- package/src/be/db/session-log-reasoning.ts +36 -0
- package/src/be/db/tasks/read.ts +7 -3
- package/src/be/db/tasks/write.ts +33 -1
- package/src/be/db.ts +200 -304
- package/src/be/key-window-usage.ts +385 -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/runtime-pools/db.ts +3 -0
- 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/wait-for-task.ts +5 -1
- package/src/be/seed-skills/index.ts +3 -0
- package/src/be/swarm-config-guard.ts +24 -1
- package/src/be/task-ui-spec.ts +158 -0
- package/src/commands/controller.ts +3 -0
- package/src/commands/credential-outcome-report.ts +13 -3
- 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/http/api-keys.ts +258 -30
- package/src/http/session-data.ts +74 -23
- package/src/http/sessions.ts +6 -2
- package/src/http/tasks.ts +105 -5
- 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 +1 -1
- 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 +32 -0
- package/src/providers/types.ts +11 -0
- package/src/runtime-providers/docker.ts +65 -1
- package/src/scheduler/deferred-task-waits.ts +18 -5
- package/src/scripts-runtime/types/swarm-extension.d.ts +8 -8
- package/src/slack/actions.ts +56 -0
- package/src/slack/app.ts +22 -15
- package/src/slack/inbound-files.ts +2 -0
- package/src/slack/render-v2.ts +107 -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 +4 -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 +149 -1
- 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-outcome-report.test.ts +20 -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/docker-isolation-config-guard.test.ts +29 -0
- package/src/tests/docs-index-footprint.test.js +11 -3
- package/src/tests/e2e-visuals-comment.test.ts +82 -0
- package/src/tests/e2e-visuals-verify-pr.test.ts +138 -0
- package/src/tests/extensions-example-sql-admin-only.test.ts +7 -4
- 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/gitleaks-download-retry.test.ts +85 -0
- package/src/tests/human-thread-routing.test.ts +187 -0
- package/src/tests/jira-outbound-sync.test.ts +33 -1
- package/src/tests/key-window-usage.test.ts +831 -0
- package/src/tests/linear-outbound-sync.test.ts +30 -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/reasoning-events.test.ts +164 -0
- package/src/tests/routing-affinity-inventory.test.ts +22 -0
- package/src/tests/runtime-providers-docker.test.ts +91 -0
- package/src/tests/script-connections.test.ts +5 -0
- 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/slack-render-v2.test.ts +357 -0
- package/src/tests/slack-start-reload-race.test.ts +67 -0
- package/src/tests/subscription-plans.test.ts +20 -1
- package/src/tests/task-ui-action-route.test.ts +191 -0
- package/src/tests/task-ui-actions.test.ts +195 -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/workflow-agent-task-retry.test.ts +34 -1
- package/src/tools/defer-task.ts +1 -1
- package/src/tools/store-progress.ts +69 -3
- package/src/types.ts +7 -2
- package/src/ui-spec/actions.ts +86 -0
- package/src/ui-spec/fallback.ts +19 -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/subscription-plans.ts +11 -59
- package/src/utils/task-ui-spec.ts +67 -0
- package/src/workflows/task-step-routing.ts +8 -3
- 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/ui-spec/config.json +14 -0
- package/templates/skills/ui-spec/content.md +127 -0
- package/dist/acp-adapter-jqn86aam.js +0 -16
- 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/{cli-j49yqpvh.js → cli-7evph51z.js} +3 -3
|
@@ -1,4 +1,21 @@
|
|
|
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,
|
|
2
19
|
chatSdkContextKey,
|
|
3
20
|
chatThreadOfContextKey,
|
|
4
21
|
agentmailContextKey,
|
|
@@ -19,6 +36,8 @@ import {
|
|
|
19
36
|
sessionSourceKey,
|
|
20
37
|
sourceOfKey,
|
|
21
38
|
init_source_key,
|
|
39
|
+
TaskCreationBlockedError,
|
|
40
|
+
init_errors2,
|
|
22
41
|
checkSlackRoutingCoherence,
|
|
23
42
|
init_slack_routing,
|
|
24
43
|
beginRequestAuthScope,
|
|
@@ -34,23 +53,6 @@ import {
|
|
|
34
53
|
track,
|
|
35
54
|
telemetry,
|
|
36
55
|
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
56
|
isRbacEnabled,
|
|
55
57
|
decideAdmission,
|
|
56
58
|
grantLeadEquivalence,
|
|
@@ -385,23 +387,23 @@ import {
|
|
|
385
387
|
recordInlineScriptRun2,
|
|
386
388
|
exports_db,
|
|
387
389
|
init_db4
|
|
388
|
-
} from "./cli-
|
|
390
|
+
} from "./cli-ctx0b85j.js";
|
|
389
391
|
import {
|
|
390
392
|
assertMayActOnOperatorGrantedTarget2,
|
|
391
393
|
getUserGrant2,
|
|
392
394
|
init_rbac_roles
|
|
393
|
-
} from "./cli-
|
|
395
|
+
} from "./cli-pb2ay3sh.js";
|
|
394
396
|
import {
|
|
395
397
|
ensurePricingSeeded2,
|
|
396
398
|
ensureRbacSeeded2,
|
|
397
399
|
ensureModelProfilesSeeded2,
|
|
398
400
|
init_boot_seeds
|
|
399
|
-
} from "./cli-
|
|
401
|
+
} from "./cli-b91nz213.js";
|
|
400
402
|
import {
|
|
401
403
|
requestModelCatalogRefresh2,
|
|
402
404
|
startPricingRefreshLoop2,
|
|
403
405
|
init_pricing_refresh
|
|
404
|
-
} from "./cli-
|
|
406
|
+
} from "./cli-dgs10ttj.js";
|
|
405
407
|
import {
|
|
406
408
|
workflowEventBus2,
|
|
407
409
|
init_event_bus
|
|
@@ -414,7 +416,11 @@ import {
|
|
|
414
416
|
externalChannelToolError2,
|
|
415
417
|
getChannelBlockReason2,
|
|
416
418
|
init_external_channel
|
|
417
|
-
} from "./cli-
|
|
419
|
+
} from "./cli-xag7btpe.js";
|
|
420
|
+
import {
|
|
421
|
+
tableToAscii2,
|
|
422
|
+
init_dist8
|
|
423
|
+
} from "./cli-9w8712tq.js";
|
|
418
424
|
import {
|
|
419
425
|
noteSlackInboundSideEffect,
|
|
420
426
|
init_inbound_dispatch,
|
|
@@ -444,8 +450,23 @@ import {
|
|
|
444
450
|
getTaskCitations,
|
|
445
451
|
hasTaskCitationCheckRefusal,
|
|
446
452
|
init_task_citations2,
|
|
453
|
+
getTaskUiSpec,
|
|
454
|
+
upsertTaskUiSpec,
|
|
455
|
+
hasTaskUiSpecCheckRefusal,
|
|
456
|
+
init_task_ui_spec,
|
|
457
|
+
standardComponentDefinitions,
|
|
458
|
+
CardSpecError,
|
|
459
|
+
toCard,
|
|
460
|
+
init_dist5,
|
|
461
|
+
UI_SPEC_ACTION_ID,
|
|
462
|
+
UI_SPEC_CARD_LIMITS,
|
|
463
|
+
init_task_ui_spec2,
|
|
464
|
+
validateTaskUiSpec,
|
|
465
|
+
init_validate2,
|
|
447
466
|
ensure,
|
|
448
467
|
init_business_use,
|
|
468
|
+
withUiSpecFallback,
|
|
469
|
+
init_fallback,
|
|
449
470
|
getAgentDisplayName,
|
|
450
471
|
getAgentSlackIcon,
|
|
451
472
|
init_responses,
|
|
@@ -453,7 +474,7 @@ import {
|
|
|
453
474
|
startSlackApp2,
|
|
454
475
|
stopSlackAppUnderLifecycleLock2,
|
|
455
476
|
init_app3
|
|
456
|
-
} from "./cli-
|
|
477
|
+
} from "./cli-pyjn0qhk.js";
|
|
457
478
|
import {
|
|
458
479
|
AGENT_MAX_TASKS_CONFIG_KEY,
|
|
459
480
|
resetAgentMaxTasksMirror,
|
|
@@ -474,7 +495,7 @@ import {
|
|
|
474
495
|
postApprovalCancellationUpdates2,
|
|
475
496
|
createApprovalFollowUpTask2,
|
|
476
497
|
init_approval_notifications
|
|
477
|
-
} from "./cli-
|
|
498
|
+
} from "./cli-jkw6ptfw.js";
|
|
478
499
|
import {
|
|
479
500
|
shapeApprovalResolution,
|
|
480
501
|
init_approval_resolution,
|
|
@@ -498,7 +519,7 @@ import {
|
|
|
498
519
|
resumeFromChildRun2,
|
|
499
520
|
initWaitBusSubscriptions2,
|
|
500
521
|
init_resume
|
|
501
|
-
} from "./cli-
|
|
522
|
+
} from "./cli-1jykg0py.js";
|
|
502
523
|
import {
|
|
503
524
|
FilesError,
|
|
504
525
|
providerPath,
|
|
@@ -509,14 +530,10 @@ import {
|
|
|
509
530
|
getFileStorageProvider2,
|
|
510
531
|
init_registry2
|
|
511
532
|
} from "./cli-7cp6aa1q.js";
|
|
512
|
-
import {
|
|
513
|
-
tableToAscii2,
|
|
514
|
-
init_dist4
|
|
515
|
-
} from "./cli-wr1h0k28.js";
|
|
516
533
|
import {
|
|
517
534
|
getRuntimePool2,
|
|
518
535
|
init_db2
|
|
519
|
-
} from "./cli-
|
|
536
|
+
} from "./cli-mkwkwq81.js";
|
|
520
537
|
import {
|
|
521
538
|
duplicateGuardedQueryKey,
|
|
522
539
|
parseQueryParams,
|
|
@@ -552,7 +569,7 @@ import {
|
|
|
552
569
|
findRoute,
|
|
553
570
|
route,
|
|
554
571
|
init_route_def
|
|
555
|
-
} from "./cli-
|
|
572
|
+
} from "./cli-nbt14he0.js";
|
|
556
573
|
import {
|
|
557
574
|
COMPOSIO_HTTP_METHODS,
|
|
558
575
|
executeComposioRequest,
|
|
@@ -654,7 +671,7 @@ import {
|
|
|
654
671
|
init_typecheck,
|
|
655
672
|
parseSkillContent,
|
|
656
673
|
init_skill_parser
|
|
657
|
-
} from "./cli-
|
|
674
|
+
} from "./cli-2yjj3e31.js";
|
|
658
675
|
import {
|
|
659
676
|
detachedProcessGroup,
|
|
660
677
|
registerProcessGroup,
|
|
@@ -669,7 +686,7 @@ import {
|
|
|
669
686
|
ensureToken,
|
|
670
687
|
ensureTokenOrThrow,
|
|
671
688
|
init_ensure_token
|
|
672
|
-
} from "./cli-
|
|
689
|
+
} from "./cli-jm0hvmz2.js";
|
|
673
690
|
import {
|
|
674
691
|
require_fast_deep_equal
|
|
675
692
|
} from "./cli-bhp11egn.js";
|
|
@@ -686,7 +703,7 @@ import {
|
|
|
686
703
|
isSlackLeaveThreadDisabled,
|
|
687
704
|
leaveSlackThread,
|
|
688
705
|
init_left_threads
|
|
689
|
-
} from "./cli-
|
|
706
|
+
} from "./cli-br0924pw.js";
|
|
690
707
|
import {
|
|
691
708
|
notifyAutomationPreflightFailure,
|
|
692
709
|
init_automation_preflight_alert,
|
|
@@ -761,7 +778,7 @@ import {
|
|
|
761
778
|
validateDefinition,
|
|
762
779
|
applyDefinitionPatch,
|
|
763
780
|
init_definition2
|
|
764
|
-
} from "./cli-
|
|
781
|
+
} from "./cli-j7svy295.js";
|
|
765
782
|
import {
|
|
766
783
|
isMultiRuntimeEnabled,
|
|
767
784
|
init_multi_runtime2
|
|
@@ -776,11 +793,11 @@ import {
|
|
|
776
793
|
import {
|
|
777
794
|
canProvisionKind,
|
|
778
795
|
init_runtime_providers
|
|
779
|
-
} from "./cli-
|
|
796
|
+
} from "./cli-6945ywhr.js";
|
|
780
797
|
import {
|
|
781
798
|
publicEndpointSsrfOptions,
|
|
782
799
|
init_mcp_wrapper
|
|
783
|
-
} from "./cli-
|
|
800
|
+
} from "./cli-2dq9yv8p.js";
|
|
784
801
|
import {
|
|
785
802
|
findUserById,
|
|
786
803
|
findUserByExternalId,
|
|
@@ -795,7 +812,7 @@ import {
|
|
|
795
812
|
resolveSessionToken,
|
|
796
813
|
fingerprintApiKey,
|
|
797
814
|
init_users
|
|
798
|
-
} from "./cli-
|
|
815
|
+
} from "./cli-v57d7fmm.js";
|
|
799
816
|
import {
|
|
800
817
|
normalizeAssetKey,
|
|
801
818
|
defaultAssetKey,
|
|
@@ -815,7 +832,7 @@ import {
|
|
|
815
832
|
init_import,
|
|
816
833
|
$OpenAPIRegistry,
|
|
817
834
|
$OpenApiGeneratorV31,
|
|
818
|
-
|
|
835
|
+
init_dist9,
|
|
819
836
|
init_zod_openapi,
|
|
820
837
|
AssetKeySchema,
|
|
821
838
|
ModelTierSchema,
|
|
@@ -845,6 +862,7 @@ import {
|
|
|
845
862
|
AgentMemorySourceSchema,
|
|
846
863
|
RuntimePoolUpdateSchema,
|
|
847
864
|
RuntimePoolCreateAgentSchema,
|
|
865
|
+
SUPERSEDED_WORKFLOW_TASK_REASON,
|
|
848
866
|
WorkflowDefinitionSchema,
|
|
849
867
|
WorkflowNodePatchSchema,
|
|
850
868
|
TriggerConfigSchema,
|
|
@@ -866,7 +884,7 @@ import {
|
|
|
866
884
|
KvNamespaceSchema,
|
|
867
885
|
KvKeySchema,
|
|
868
886
|
init_types5
|
|
869
|
-
} from "./cli-
|
|
887
|
+
} from "./cli-bkjdknnp.js";
|
|
870
888
|
import {
|
|
871
889
|
resolveGitHubHost,
|
|
872
890
|
getGitHubLinkConfig,
|
|
@@ -884,7 +902,7 @@ import {
|
|
|
884
902
|
init_task_attachment_links,
|
|
885
903
|
contentSha256,
|
|
886
904
|
init_profile_sync
|
|
887
|
-
} from "./cli-
|
|
905
|
+
} from "./cli-m7c2380k.js";
|
|
888
906
|
import {
|
|
889
907
|
getSlackConfiguration,
|
|
890
908
|
isSlackConfigured,
|
|
@@ -897,7 +915,7 @@ import {
|
|
|
897
915
|
import {
|
|
898
916
|
selectCredential,
|
|
899
917
|
init_credentials2
|
|
900
|
-
} from "./cli-
|
|
918
|
+
} from "./cli-psffsanb.js";
|
|
901
919
|
import {
|
|
902
920
|
findInterpolationTokens,
|
|
903
921
|
interpolate,
|
|
@@ -907,7 +925,7 @@ import {
|
|
|
907
925
|
init_registry3,
|
|
908
926
|
resolveTemplate,
|
|
909
927
|
init_resolver
|
|
910
|
-
} from "./cli-
|
|
928
|
+
} from "./cli-6ehs4mta.js";
|
|
911
929
|
import {
|
|
912
930
|
init_zod
|
|
913
931
|
} from "./cli-zcfpsfzf.js";
|
|
@@ -924,7 +942,6 @@ import {
|
|
|
924
942
|
unknown,
|
|
925
943
|
array2,
|
|
926
944
|
object2,
|
|
927
|
-
strictObject2,
|
|
928
945
|
looseObject,
|
|
929
946
|
union3,
|
|
930
947
|
discriminatedUnion,
|
|
@@ -934,7 +951,6 @@ import {
|
|
|
934
951
|
literal2,
|
|
935
952
|
ZodOptional,
|
|
936
953
|
optional2,
|
|
937
|
-
lazy,
|
|
938
954
|
custom,
|
|
939
955
|
preprocess,
|
|
940
956
|
ZodIssueCode,
|
|
@@ -962,7 +978,7 @@ import {
|
|
|
962
978
|
import {
|
|
963
979
|
init_package,
|
|
964
980
|
package_default
|
|
965
|
-
} from "./cli-
|
|
981
|
+
} from "./cli-h9yqfzx9.js";
|
|
966
982
|
import {
|
|
967
983
|
getNodeEnv,
|
|
968
984
|
isDevOrTestNodeEnv,
|
|
@@ -20340,7 +20356,7 @@ function startRetryPoller(registry, intervalMs = 5000) {
|
|
|
20340
20356
|
if (!waiting)
|
|
20341
20357
|
continue;
|
|
20342
20358
|
if (result.waitFor === "workflow.child.finished") {
|
|
20343
|
-
const { resumeFromChildRun } = await import("./resume-
|
|
20359
|
+
const { resumeFromChildRun } = await import("./resume-5ep8agan.js");
|
|
20344
20360
|
await resumeFromChildRun(step.id, registry);
|
|
20345
20361
|
}
|
|
20346
20362
|
} else {
|
|
@@ -20810,21 +20826,6 @@ var init_wait_poller = __esm(() => {
|
|
|
20810
20826
|
init_resume();
|
|
20811
20827
|
});
|
|
20812
20828
|
|
|
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
20829
|
// src/workflows/executors/agent-task.ts
|
|
20829
20830
|
var AgentTaskConfigSchema, AgentTaskOutputSchema, AgentTaskExecutor;
|
|
20830
20831
|
var init_agent_task = __esm(() => {
|
|
@@ -20833,7 +20834,7 @@ var init_agent_task = __esm(() => {
|
|
|
20833
20834
|
init_model_validation2();
|
|
20834
20835
|
init_apply_task_create();
|
|
20835
20836
|
init_context_key();
|
|
20836
|
-
|
|
20837
|
+
init_errors2();
|
|
20837
20838
|
init_types5();
|
|
20838
20839
|
init_base();
|
|
20839
20840
|
AgentTaskConfigSchema = object2({
|
|
@@ -21086,7 +21087,7 @@ var init_notify = __esm(() => {
|
|
|
21086
21087
|
}
|
|
21087
21088
|
}
|
|
21088
21089
|
case "slack": {
|
|
21089
|
-
const { getSlackApp } = await import("./app-
|
|
21090
|
+
const { getSlackApp } = await import("./app-g2z15hax.js");
|
|
21090
21091
|
let app = getSlackApp();
|
|
21091
21092
|
if (!app) {
|
|
21092
21093
|
if (!isSlackConfigured()) {
|
|
@@ -21219,7 +21220,7 @@ var init_property_match = __esm(() => {
|
|
|
21219
21220
|
async function executeRawLlm(config) {
|
|
21220
21221
|
let modelName = config.model ?? "google/gemini-3-flash-preview";
|
|
21221
21222
|
try {
|
|
21222
|
-
const { createOpenAI } = await import("./index-
|
|
21223
|
+
const { createOpenAI } = await import("./index-9myfj74s.js");
|
|
21223
21224
|
const llmConfig = await resolveWorkflowLlmConfig(config.model);
|
|
21224
21225
|
modelName = llmConfig.model;
|
|
21225
21226
|
const provider = createOpenAI({
|
|
@@ -21229,7 +21230,7 @@ async function executeRawLlm(config) {
|
|
|
21229
21230
|
});
|
|
21230
21231
|
const model = provider(llmConfig.model);
|
|
21231
21232
|
if (config.schema) {
|
|
21232
|
-
const { generateObject, jsonSchema } = await import("./index-
|
|
21233
|
+
const { generateObject, jsonSchema } = await import("./index-b5wgnm78.js");
|
|
21233
21234
|
const { object } = await generateObject({
|
|
21234
21235
|
model,
|
|
21235
21236
|
schema: jsonSchema(config.schema),
|
|
@@ -21243,7 +21244,7 @@ async function executeRawLlm(config) {
|
|
|
21243
21244
|
output: { result: object, model: modelName }
|
|
21244
21245
|
};
|
|
21245
21246
|
}
|
|
21246
|
-
const { generateText } = await import("./index-
|
|
21247
|
+
const { generateText } = await import("./index-b5wgnm78.js");
|
|
21247
21248
|
const { text } = await generateText({
|
|
21248
21249
|
model,
|
|
21249
21250
|
prompt: config.prompt
|
|
@@ -21724,7 +21725,7 @@ function validateJsonSchemaBasic(value, schema) {
|
|
|
21724
21725
|
return errors;
|
|
21725
21726
|
}
|
|
21726
21727
|
var ValidateConfigSchema, ValidateOutputSchema, ValidateExecutor;
|
|
21727
|
-
var
|
|
21728
|
+
var init_validate3 = __esm(() => {
|
|
21728
21729
|
init_zod();
|
|
21729
21730
|
init_base();
|
|
21730
21731
|
init_workflow_llm();
|
|
@@ -21803,8 +21804,8 @@ var init_validate2 = __esm(() => {
|
|
|
21803
21804
|
const interpolatedPrompt = this.deps.interpolate(prompt, context);
|
|
21804
21805
|
const outputStr = typeof targetOutput === "string" ? targetOutput : JSON.stringify(targetOutput);
|
|
21805
21806
|
try {
|
|
21806
|
-
const { createOpenAI } = await import("./index-
|
|
21807
|
-
const { generateObject, jsonSchema } = await import("./index-
|
|
21807
|
+
const { createOpenAI } = await import("./index-9myfj74s.js");
|
|
21808
|
+
const { generateObject, jsonSchema } = await import("./index-b5wgnm78.js");
|
|
21808
21809
|
const llmConfig = await resolveWorkflowLlmConfig();
|
|
21809
21810
|
const provider = createOpenAI({
|
|
21810
21811
|
baseURL: llmConfig.baseURL,
|
|
@@ -21963,7 +21964,7 @@ var init_registry = __esm(() => {
|
|
|
21963
21964
|
init_swarm_script();
|
|
21964
21965
|
init_system_one_decision();
|
|
21965
21966
|
init_system_one_extraction();
|
|
21966
|
-
|
|
21967
|
+
init_validate3();
|
|
21967
21968
|
init_vcs();
|
|
21968
21969
|
init_wait();
|
|
21969
21970
|
});
|
|
@@ -22109,7 +22110,7 @@ async function resolveWaitCause(scheduleId, reason) {
|
|
|
22109
22110
|
return;
|
|
22110
22111
|
if (reason === "ceiling")
|
|
22111
22112
|
return { wait, cause: "ceiling expired", matchedTaskIds: [] };
|
|
22112
|
-
const members = await client.query(`SELECT m.taskId,
|
|
22113
|
+
const members = await client.query(`SELECT m.taskId, ${WAIT_MEMBER_STATUS_SQL} AS taskStatus, EXISTS (
|
|
22113
22114
|
SELECT 1 FROM scheduled_tasks d
|
|
22114
22115
|
WHERE d.parentTaskId = t.id AND d.taskType = 'deferred' AND d.enabled = 1
|
|
22115
22116
|
) AS deferred
|
|
@@ -22226,16 +22227,17 @@ async function reconcileDeferredTaskWaits(taskId) {
|
|
|
22226
22227
|
});
|
|
22227
22228
|
return reconcileDeferredTaskWaits();
|
|
22228
22229
|
}
|
|
22229
|
-
const rows = await client.query(`SELECT DISTINCT w.*,
|
|
22230
|
+
const rows = await client.query(`SELECT DISTINCT w.*, ${WAIT_MEMBER_STATUS_SQL} AS taskStatus FROM deferred_task_waits w
|
|
22230
22231
|
JOIN deferred_task_wait_members m ON m.scheduleId = w.scheduleId
|
|
22231
22232
|
JOIN agent_tasks t ON t.id = m.taskId
|
|
22232
22233
|
JOIN scheduled_tasks s ON s.id = w.scheduleId
|
|
22233
|
-
WHERE w.status = 'pending' AND s.enabled = 1
|
|
22234
|
+
WHERE w.status = 'pending' AND s.enabled = 1
|
|
22235
|
+
AND ${WAIT_MEMBER_STATUS_SQL} IN ('completed', 'failed', 'cancelled', 'skipped')
|
|
22234
22236
|
AND NOT EXISTS (
|
|
22235
22237
|
SELECT 1 FROM scheduled_tasks d
|
|
22236
22238
|
WHERE d.parentTaskId = t.id AND d.taskType = 'deferred' AND d.enabled = 1
|
|
22237
22239
|
)
|
|
22238
|
-
AND (w.eventName = 'settled' OR w.eventName = 'task.' ||
|
|
22240
|
+
AND (w.eventName = 'settled' OR w.eventName = 'task.' || ${WAIT_MEMBER_STATUS_SQL})
|
|
22239
22241
|
${taskId ? "AND m.taskId = ?" : ""}`, taskId ? [taskId] : []);
|
|
22240
22242
|
for (const row of rows) {
|
|
22241
22243
|
try {
|
|
@@ -22281,11 +22283,15 @@ function stopDeferredTaskWaits() {
|
|
|
22281
22283
|
workflowEventBus2.off("task.superseded", onTaskEvent);
|
|
22282
22284
|
workflowEventBus2.off("task.created", onTaskEvent);
|
|
22283
22285
|
}
|
|
22284
|
-
var DEFERRED_WAIT_WOKE_EVENT = "task_deferred_wait_woke", SPENT_DEFERRED_SCHEDULE_RETENTION_MS;
|
|
22286
|
+
var WAIT_MEMBER_STATUS_SQL, DEFERRED_WAIT_WOKE_EVENT = "task_deferred_wait_woke", SPENT_DEFERRED_SCHEDULE_RETENTION_MS;
|
|
22285
22287
|
var init_deferred_task_waits = __esm(() => {
|
|
22286
22288
|
init_db4();
|
|
22289
|
+
init_types5();
|
|
22287
22290
|
init_event_bus();
|
|
22288
22291
|
init_schedule_task();
|
|
22292
|
+
WAIT_MEMBER_STATUS_SQL = `CASE
|
|
22293
|
+
WHEN t.status = 'superseded' AND t.failureReason = '${SUPERSEDED_WORKFLOW_TASK_REASON}' THEN 'failed'
|
|
22294
|
+
ELSE t.status END`;
|
|
22289
22295
|
SPENT_DEFERRED_SCHEDULE_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
|
|
22290
22296
|
});
|
|
22291
22297
|
|
|
@@ -24510,7 +24516,7 @@ function setPreloadedTools(server, names) {
|
|
|
24510
24516
|
async function applyPreToolCall(name, args, requestInfo, inputSchema) {
|
|
24511
24517
|
if (requestInfo.callOrigin !== "mcp")
|
|
24512
24518
|
return { args };
|
|
24513
|
-
const dispatcher = await import("./dispatcher-
|
|
24519
|
+
const dispatcher = await import("./dispatcher-31sm0ej2.js");
|
|
24514
24520
|
const result = await dispatcher.dispatchPre("pre.tool.call", { tool: name, args, requestInfo }, inputSchema ? {
|
|
24515
24521
|
validateModify: async (data) => {
|
|
24516
24522
|
const schema = normalizeObjectSchema(inputSchema) ?? inputSchema;
|
|
@@ -27441,7 +27447,7 @@ async function createTaskWithSiblingAwareness(description, options, args = {}) {
|
|
|
27441
27447
|
var init_sibling_awareness = __esm(() => {
|
|
27442
27448
|
init_db4();
|
|
27443
27449
|
init_apply_task_create();
|
|
27444
|
-
|
|
27450
|
+
init_errors2();
|
|
27445
27451
|
init_sibling_block();
|
|
27446
27452
|
});
|
|
27447
27453
|
|
|
@@ -32258,7 +32264,7 @@ async function loadAdapter(name, config, logger) {
|
|
|
32258
32264
|
const base = { ...config, apiUrl, logger };
|
|
32259
32265
|
switch (name) {
|
|
32260
32266
|
case "telegram": {
|
|
32261
|
-
const { TelegramAdapter } = await import("./index-
|
|
32267
|
+
const { TelegramAdapter } = await import("./index-8p0j4h4j.js");
|
|
32262
32268
|
|
|
32263
32269
|
class SwarmTelegramAdapter extends TelegramAdapter {
|
|
32264
32270
|
isBotMentioned(message, text) {
|
|
@@ -32272,7 +32278,7 @@ async function loadAdapter(name, config, logger) {
|
|
|
32272
32278
|
});
|
|
32273
32279
|
}
|
|
32274
32280
|
case "slack": {
|
|
32275
|
-
const { createSlackAdapter } = await import("./index-
|
|
32281
|
+
const { createSlackAdapter } = await import("./index-620y7jzq.js");
|
|
32276
32282
|
return createSlackAdapter({
|
|
32277
32283
|
...base,
|
|
32278
32284
|
signingSecret: config.signingSecret ?? "",
|
|
@@ -32282,7 +32288,7 @@ async function loadAdapter(name, config, logger) {
|
|
|
32282
32288
|
});
|
|
32283
32289
|
}
|
|
32284
32290
|
case "discord": {
|
|
32285
|
-
const { createDiscordAdapter } = await import("./index-
|
|
32291
|
+
const { createDiscordAdapter } = await import("./index-0h6qd4p1.js");
|
|
32286
32292
|
return createDiscordAdapter({
|
|
32287
32293
|
...base,
|
|
32288
32294
|
logger: withInfoFilter(logger, keepDiscordInfoLine),
|
|
@@ -32291,7 +32297,7 @@ async function loadAdapter(name, config, logger) {
|
|
|
32291
32297
|
});
|
|
32292
32298
|
}
|
|
32293
32299
|
case "teams": {
|
|
32294
|
-
const { createTeamsAdapter } = await import("./index-
|
|
32300
|
+
const { createTeamsAdapter } = await import("./index-4k7m5dgj.js");
|
|
32295
32301
|
const { teamsWebhookVerifier, teamsToken } = getChatSdkTestHooks();
|
|
32296
32302
|
return createTeamsAdapter({
|
|
32297
32303
|
...base,
|
|
@@ -32500,7 +32506,7 @@ async function readPersistedThreadHistory(threadId) {
|
|
|
32500
32506
|
const rows = await new SqliteChatState().getList(`${SDK_THREAD_HISTORY_PREFIX}${threadId}`);
|
|
32501
32507
|
if (rows.length === 0)
|
|
32502
32508
|
return [];
|
|
32503
|
-
const { Message: MessageClass } = await import("./index-
|
|
32509
|
+
const { Message: MessageClass } = await import("./index-pe3d8jfy.js");
|
|
32504
32510
|
return rows.map((row) => MessageClass.fromJSON(row));
|
|
32505
32511
|
}
|
|
32506
32512
|
var SDK_THREAD_HISTORY_PREFIX = "msg-history:";
|
|
@@ -33580,7 +33586,7 @@ function render(node) {
|
|
|
33580
33586
|
}
|
|
33581
33587
|
}
|
|
33582
33588
|
var init_message_text2 = __esm(() => {
|
|
33583
|
-
|
|
33589
|
+
init_dist8();
|
|
33584
33590
|
});
|
|
33585
33591
|
|
|
33586
33592
|
// src/integrations/chat-sdk/limits.ts
|
|
@@ -34689,7 +34695,7 @@ var init_inbound = __esm(() => {
|
|
|
34689
34695
|
init_dispatcher();
|
|
34690
34696
|
init_resolver();
|
|
34691
34697
|
init_context_key();
|
|
34692
|
-
|
|
34698
|
+
init_errors2();
|
|
34693
34699
|
init_secret_scrubber();
|
|
34694
34700
|
init_workflows();
|
|
34695
34701
|
init_event_bus();
|
|
@@ -34918,6 +34924,65 @@ ${piece}
|
|
|
34918
34924
|
${block}` : block;
|
|
34919
34925
|
});
|
|
34920
34926
|
}
|
|
34927
|
+
function withoutCallbackButtons(children) {
|
|
34928
|
+
return children.flatMap((child) => {
|
|
34929
|
+
if (child.type === "section") {
|
|
34930
|
+
return [{ ...child, children: withoutCallbackButtons(child.children) }];
|
|
34931
|
+
}
|
|
34932
|
+
if (child.type !== "actions")
|
|
34933
|
+
return [child];
|
|
34934
|
+
const kept = child.children.filter((element) => element.type !== "button");
|
|
34935
|
+
return kept.length ? [{ ...child, children: kept }] : [];
|
|
34936
|
+
});
|
|
34937
|
+
}
|
|
34938
|
+
async function chatRelayUiSpec(taskId) {
|
|
34939
|
+
if (!isEnvFlagEnabled("UI_SPEC_ENABLED", false))
|
|
34940
|
+
return null;
|
|
34941
|
+
const stored = await getTaskUiSpec(taskId);
|
|
34942
|
+
if (!stored)
|
|
34943
|
+
return null;
|
|
34944
|
+
try {
|
|
34945
|
+
const card = toCard(stored.spec, {
|
|
34946
|
+
limits: UI_SPEC_CARD_LIMITS
|
|
34947
|
+
});
|
|
34948
|
+
return {
|
|
34949
|
+
card: { ...card, children: withoutCallbackButtons(card.children) },
|
|
34950
|
+
fallbackText: stored.fallbackText
|
|
34951
|
+
};
|
|
34952
|
+
} catch (error) {
|
|
34953
|
+
if (!(error instanceof CardSpecError))
|
|
34954
|
+
throw error;
|
|
34955
|
+
console.warn(`[chat-sdk] stored uiSpec for task ${taskId} no longer renders: ${error.issues.join(" | ")}`);
|
|
34956
|
+
return { card: null, fallbackText: stored.fallbackText };
|
|
34957
|
+
}
|
|
34958
|
+
}
|
|
34959
|
+
async function postChatRelayCard(adapter, threadId, task) {
|
|
34960
|
+
let uiSpec;
|
|
34961
|
+
try {
|
|
34962
|
+
uiSpec = await chatRelayUiSpec(task.id);
|
|
34963
|
+
} catch (error) {
|
|
34964
|
+
console.error(`[chat-sdk] uiSpec of task ${task.id} unreadable: ${errorMessage(error)}`);
|
|
34965
|
+
return;
|
|
34966
|
+
}
|
|
34967
|
+
if (!uiSpec)
|
|
34968
|
+
return;
|
|
34969
|
+
if (uiSpec.card) {
|
|
34970
|
+
try {
|
|
34971
|
+
await postChatMessage({ adapter, threadId, text: [], card: uiSpec.card, taskId: task.id });
|
|
34972
|
+
return;
|
|
34973
|
+
} catch (error) {
|
|
34974
|
+
console.warn(`[chat-sdk] Card post of task ${task.id} failed: ${errorMessage(error)}`);
|
|
34975
|
+
}
|
|
34976
|
+
}
|
|
34977
|
+
if (!uiSpec.fallbackText)
|
|
34978
|
+
return;
|
|
34979
|
+
try {
|
|
34980
|
+
const text = scrubSecrets(uiSpec.fallbackText);
|
|
34981
|
+
await postChatMessage({ adapter, threadId, text, taskId: task.id });
|
|
34982
|
+
} catch (error) {
|
|
34983
|
+
console.error(`[chat-sdk] Card fallback of task ${task.id} failed: ${errorMessage(error)}`);
|
|
34984
|
+
}
|
|
34985
|
+
}
|
|
34921
34986
|
async function processPendingChatRelays(now = Date.now(), signal) {
|
|
34922
34987
|
const retired = await giveUpStaleChatRelays2(now, RELAY_GIVE_UP_AFTER_MS);
|
|
34923
34988
|
if (retired > 0)
|
|
@@ -34956,6 +35021,7 @@ async function processPendingChatRelays(now = Date.now(), signal) {
|
|
|
34956
35021
|
files: await taskOutputChatFiles(task.id),
|
|
34957
35022
|
replyToMessageId: task.mentionMessageId
|
|
34958
35023
|
});
|
|
35024
|
+
await postChatRelayCard(target.adapter, target.threadId, task);
|
|
34959
35025
|
stopTypingKeepalive(target.threadId);
|
|
34960
35026
|
await markChatRelayDelivered2(task.id, now);
|
|
34961
35027
|
console.log(`[chat-sdk] Relayed ${task.status} task ${task.id} to ${target.adapter}`);
|
|
@@ -35022,10 +35088,14 @@ async function stopChatRelayWatcher() {
|
|
|
35022
35088
|
}
|
|
35023
35089
|
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
35090
|
var init_relay = __esm(() => {
|
|
35091
|
+
init_dist5();
|
|
35025
35092
|
init_db4();
|
|
35093
|
+
init_task_ui_spec();
|
|
35026
35094
|
init_reaction_events();
|
|
35027
35095
|
init_context_key();
|
|
35096
|
+
init_env_flag();
|
|
35028
35097
|
init_secret_scrubber();
|
|
35098
|
+
init_task_ui_spec2();
|
|
35029
35099
|
init_event_bus();
|
|
35030
35100
|
init_commands();
|
|
35031
35101
|
init_limits();
|
|
@@ -35124,7 +35194,7 @@ async function startChatSdk() {
|
|
|
35124
35194
|
for (const [name, reason] of Object.entries(config.incomplete ?? {})) {
|
|
35125
35195
|
console.warn(`[chat-sdk] ${name} not started, incomplete: ${scrubSecrets(reason)}`);
|
|
35126
35196
|
}
|
|
35127
|
-
const { Chat: ChatClass } = await import("./index-
|
|
35197
|
+
const { Chat: ChatClass } = await import("./index-pe3d8jfy.js");
|
|
35128
35198
|
const state = new SqliteChatState;
|
|
35129
35199
|
startChatRelayWatcher();
|
|
35130
35200
|
await Promise.all(CHAT_SDK_ADAPTER_NAMES.map(async (name) => {
|
|
@@ -35498,9 +35568,9 @@ async function handleTaskCompleted(data) {
|
|
|
35498
35568
|
return;
|
|
35499
35569
|
const trimmed = (output ?? "").slice(0, OUTPUT_TRUNCATE_CHARS);
|
|
35500
35570
|
const ellipsized = output && output.length > OUTPUT_TRUNCATE_CHARS ? `${trimmed}…` : trimmed;
|
|
35501
|
-
const body = ellipsized ? `✅ Swarm task completed.
|
|
35571
|
+
const body = await withUiSpecFallback(taskId, ellipsized ? `✅ Swarm task completed.
|
|
35502
35572
|
|
|
35503
|
-
${ellipsized}` : "✅ Swarm task completed.";
|
|
35573
|
+
${ellipsized}` : "✅ Swarm task completed.");
|
|
35504
35574
|
await postLifecycleComment(taskId, "task.completed", body);
|
|
35505
35575
|
}
|
|
35506
35576
|
async function handleTaskFailed(data) {
|
|
@@ -35558,6 +35628,7 @@ function shouldSkipForLoopPrevention(sync) {
|
|
|
35558
35628
|
var subscribed3 = false, LOOP_PREVENTION_WINDOW_MS = 5000, OUTPUT_TRUNCATE_CHARS = 4000, onTaskCreated2, onTaskCompleted3, onTaskFailed2, onTaskCancelled2;
|
|
35559
35629
|
var init_outbound3 = __esm(() => {
|
|
35560
35630
|
init_tracker();
|
|
35631
|
+
init_fallback();
|
|
35561
35632
|
init_secret_scrubber();
|
|
35562
35633
|
init_event_bus();
|
|
35563
35634
|
init_client2();
|
|
@@ -36032,7 +36103,7 @@ async function notifySlack(text) {
|
|
|
36032
36103
|
return;
|
|
36033
36104
|
}
|
|
36034
36105
|
try {
|
|
36035
|
-
const { getSlackApp } = await import("./app-
|
|
36106
|
+
const { getSlackApp } = await import("./app-g2z15hax.js");
|
|
36036
36107
|
const app = getSlackApp();
|
|
36037
36108
|
if (!app) {
|
|
36038
36109
|
console.warn("[Jira webhook keepalive] Slack not available, cannot send notification");
|
|
@@ -36103,7 +36174,7 @@ async function deleteJiraWebhook(webhookId) {
|
|
|
36103
36174
|
console.log(`[Jira webhook keepalive] Deleted webhook id=${webhookId}`);
|
|
36104
36175
|
}
|
|
36105
36176
|
async function overwriteWebhookIds(next) {
|
|
36106
|
-
const { getDbClient } = await import("./db-
|
|
36177
|
+
const { getDbClient } = await import("./db-kpmx06s9.js");
|
|
36107
36178
|
await getDbClient().transaction(async (tx) => {
|
|
36108
36179
|
const row = await tx.get("SELECT metadata FROM oauth_apps WHERE provider = 'jira'");
|
|
36109
36180
|
if (!row) {
|
|
@@ -108693,7 +108764,7 @@ async function handleTaskCompleted2(data) {
|
|
|
108693
108764
|
if (shouldSkipForLoopPrevention2(sync))
|
|
108694
108765
|
return;
|
|
108695
108766
|
const sessionId = taskSessionMap.get(taskId);
|
|
108696
|
-
const body = output?.trim() ? formatLinearOutcomeBody(output, taskId) : "Task completed.";
|
|
108767
|
+
const body = output?.trim() ? formatLinearOutcomeBody(await withUiSpecFallback(taskId, output), taskId) : await withUiSpecFallback(taskId, "Task completed.");
|
|
108697
108768
|
if (sessionId) {
|
|
108698
108769
|
endAgentSession(sessionId, body, "response").catch((err) => {
|
|
108699
108770
|
console.error(`[Linear Outbound] Failed to end AgentSession for task ${taskId}:`, err);
|
|
@@ -108808,6 +108879,7 @@ var subscribed4 = false, LOOP_PREVENTION_WINDOW_MS2 = 5000, onTaskCreated3, onTa
|
|
|
108808
108879
|
var init_outbound4 = __esm(() => {
|
|
108809
108880
|
init_tracker();
|
|
108810
108881
|
init_ensure_token();
|
|
108882
|
+
init_fallback();
|
|
108811
108883
|
init_secret_scrubber();
|
|
108812
108884
|
init_event_bus();
|
|
108813
108885
|
init_client3();
|
|
@@ -109544,7 +109616,7 @@ var ErrorResponseSchema, cachedSpec = null, SCALAR_HTML = `<!DOCTYPE html>
|
|
|
109544
109616
|
</body>
|
|
109545
109617
|
</html>`;
|
|
109546
109618
|
var init_openapi = __esm(() => {
|
|
109547
|
-
|
|
109619
|
+
init_dist9();
|
|
109548
109620
|
init_constants3();
|
|
109549
109621
|
init_zod_openapi();
|
|
109550
109622
|
init_route_def();
|
|
@@ -109598,7 +109670,7 @@ async function reloadGlobalConfigsAndIntegrations() {
|
|
|
109598
109670
|
return runWithoutRequestAuth(() => runSlackLifecycleExclusive(() => reloadGlobalConfigsAndIntegrationsInner()));
|
|
109599
109671
|
}
|
|
109600
109672
|
async function reloadGlobalConfigsAndIntegrationsInner() {
|
|
109601
|
-
const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-
|
|
109673
|
+
const { getEmbeddingProvider, resetEmbeddingProvider } = await import("./index-s71ez27v.js");
|
|
109602
109674
|
const wasEmbeddingsConfigured = getEmbeddingProvider().isConfigured();
|
|
109603
109675
|
const updated = await loadGlobalConfigsIntoEnv(true);
|
|
109604
109676
|
await syncTelemetryEnabled("settings").catch((err) => {
|
|
@@ -109614,7 +109686,7 @@ async function reloadGlobalConfigsAndIntegrationsInner() {
|
|
|
109614
109686
|
integrations.push("embeddings");
|
|
109615
109687
|
}
|
|
109616
109688
|
if (isEmbeddingsConfigured) {
|
|
109617
|
-
import("./embedding-space-
|
|
109689
|
+
import("./embedding-space-qhw4g68n.js").then(({ runEmbeddingMaintenance }) => runEmbeddingMaintenance({ backfill: !wasEmbeddingsConfigured })).catch((err) => {
|
|
109618
109690
|
console.error("[config-reload] embedding maintenance failed (non-fatal):", err);
|
|
109619
109691
|
});
|
|
109620
109692
|
}
|
|
@@ -115395,1903 +115467,6 @@ var init_chat_open_dm = __esm(() => {
|
|
|
115395
115467
|
init_utils();
|
|
115396
115468
|
});
|
|
115397
115469
|
|
|
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
115470
|
// src/integrations/cards/index.ts
|
|
117296
115471
|
function renderCard(spec) {
|
|
117297
115472
|
let card;
|
|
@@ -117317,7 +115492,7 @@ ${issues.map((issue) => `- ${issue}`).join(`
|
|
|
117317
115492
|
`)}`;
|
|
117318
115493
|
}
|
|
117319
115494
|
async function cardToSlack(card) {
|
|
117320
|
-
const { cardToBlockKit, cardToFallbackText } = await import("./index-
|
|
115495
|
+
const { cardToBlockKit, cardToFallbackText } = await import("./index-620y7jzq.js");
|
|
117321
115496
|
const issues = cardChildren(card).flatMap((child) => {
|
|
117322
115497
|
const native = NATIVE_SLACK_BLOCKS[child.type];
|
|
117323
115498
|
if (!native)
|
|
@@ -117346,7 +115521,7 @@ function slackFallbackText(message, cardText) {
|
|
|
117346
115521
|
}
|
|
117347
115522
|
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
115523
|
var init_cards = __esm(() => {
|
|
117349
|
-
|
|
115524
|
+
init_dist5();
|
|
117350
115525
|
init_zod();
|
|
117351
115526
|
({ Button: _button, ...standard } = standardComponentDefinitions);
|
|
117352
115527
|
chatCardComponents = {
|
|
@@ -122618,7 +120793,7 @@ var DeferAbortedError, registerDeferTaskTool = (server) => {
|
|
|
122618
120793
|
message: "Provide exactly one of wakeOn.taskId or wakeOn.taskIds."
|
|
122619
120794
|
}).refine((wake) => !wake.taskIds || new Set(wake.taskIds).size === wake.taskIds.length, {
|
|
122620
120795
|
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."),
|
|
120796
|
+
}).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
120797
|
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
120798
|
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
120799
|
note: string2().min(1).max(2000).describe("What is pending, and what to check on wake-up."),
|
|
@@ -128800,7 +126975,7 @@ class StringDecoder {
|
|
|
128800
126975
|
return res;
|
|
128801
126976
|
}
|
|
128802
126977
|
}
|
|
128803
|
-
var errorUnexpectedEndOfArray, errorIntegerOutOfRange, createDecoder = (uint8Array) => new Decoder(uint8Array),
|
|
126978
|
+
var errorUnexpectedEndOfArray, errorIntegerOutOfRange, createDecoder = (uint8Array) => new Decoder(uint8Array), hasContent = (decoder) => decoder.pos !== decoder.arr.length, readUint8Array = (decoder, len) => {
|
|
128804
126979
|
const view = new Uint8Array(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len);
|
|
128805
126980
|
decoder.pos += len;
|
|
128806
126981
|
return view;
|
|
@@ -128917,7 +127092,7 @@ var init_decoding = __esm(() => {
|
|
|
128917
127092
|
read() {
|
|
128918
127093
|
if (this.count === 0) {
|
|
128919
127094
|
this.s = this.reader(this);
|
|
128920
|
-
if (
|
|
127095
|
+
if (hasContent(this)) {
|
|
128921
127096
|
this.count = readVarUint(this) + 1;
|
|
128922
127097
|
} else {
|
|
128923
127098
|
this.count = -1;
|
|
@@ -133606,7 +131781,7 @@ function yToJson(value, depth = 0) {
|
|
|
133606
131781
|
throw new Error("room document contains a non-JSON value");
|
|
133607
131782
|
return value;
|
|
133608
131783
|
}
|
|
133609
|
-
function
|
|
131784
|
+
function materialize(doc) {
|
|
133610
131785
|
return yToJson(doc.getMap("root"));
|
|
133611
131786
|
}
|
|
133612
131787
|
function pathLabel(path) {
|
|
@@ -133761,7 +131936,7 @@ function applyOperations(doc, operations) {
|
|
|
133761
131936
|
try {
|
|
133762
131937
|
applyUpdate(candidate, encodeStateAsUpdate(doc));
|
|
133763
131938
|
applyUnchecked(candidate, parsed);
|
|
133764
|
-
|
|
131939
|
+
materialize(candidate);
|
|
133765
131940
|
} finally {
|
|
133766
131941
|
candidate.destroy();
|
|
133767
131942
|
}
|
|
@@ -133986,7 +132161,7 @@ function validateDocument(doc) {
|
|
|
133986
132161
|
if (key !== "root")
|
|
133987
132162
|
throw new Error(`room update contains unsupported shared type "${key}"`);
|
|
133988
132163
|
}
|
|
133989
|
-
|
|
132164
|
+
materialize(doc);
|
|
133990
132165
|
}
|
|
133991
132166
|
function decodeRoomSnapshot(value) {
|
|
133992
132167
|
const envelope = parseEnvelope(value);
|
|
@@ -133997,7 +132172,7 @@ function decodeRoomSnapshot(value) {
|
|
|
133997
132172
|
return {
|
|
133998
132173
|
schemaVersion: envelope.schemaVersion,
|
|
133999
132174
|
generation: envelope.generation,
|
|
134000
|
-
state:
|
|
132175
|
+
state: materialize(doc)
|
|
134001
132176
|
};
|
|
134002
132177
|
} finally {
|
|
134003
132178
|
doc.destroy();
|
|
@@ -134011,7 +132186,7 @@ function roomView(room, requestedVersion = room.schemaVersion) {
|
|
|
134011
132186
|
schemaVersion: room.schemaVersion,
|
|
134012
132187
|
generation: room.generation,
|
|
134013
132188
|
stale: requestedVersion !== room.schemaVersion,
|
|
134014
|
-
state:
|
|
132189
|
+
state: materialize(room.doc),
|
|
134015
132190
|
snapshot: envelope.snapshot,
|
|
134016
132191
|
bytes: envelopeBytes(envelope)
|
|
134017
132192
|
};
|
|
@@ -139288,6 +137463,7 @@ async function downloadSlackFile(file, token, path) {
|
|
|
139288
137463
|
}
|
|
139289
137464
|
}
|
|
139290
137465
|
async function createSlackTaskWithFiles(description, options, inbound, slack, carriedMessageTs = []) {
|
|
137466
|
+
options = { ...options, routingAffinity: options.routingAffinity ?? { capabilities: [] } };
|
|
139291
137467
|
noteSlackInboundSideEffect("task_created");
|
|
139292
137468
|
const context = { origin: "slack", slack };
|
|
139293
137469
|
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 });
|
|
@@ -141040,6 +139216,14 @@ var BLOCKED_WAITING_PATTERN, BLOCKED_WAITING_MIN_ELAPSED_MS, storeProgressOutput
|
|
|
141040
139216
|
failureReason: string2().optional().describe("The reason for failure (used when failing), or the one-line reason for a skip (required with status 'skipped')."),
|
|
141041
139217
|
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
139218
|
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.'),
|
|
139219
|
+
uiSpec: object2({
|
|
139220
|
+
spec: object2({
|
|
139221
|
+
root: string2().min(1),
|
|
139222
|
+
elements: record2(string2(), unknown()),
|
|
139223
|
+
state: record2(string2(), unknown()).optional()
|
|
139224
|
+
}).describe("A json-render spec for the chat catalog. Root must be a Card."),
|
|
139225
|
+
actions: record2(string2().regex(UI_SPEC_ACTION_ID), object2({ kind: literal2("follow_up"), prompt: string2().min(1).max(4000) })).optional().describe("Actions that Button ids name. Needs UI_SPEC_ACTIONS_ENABLED=true.")
|
|
139226
|
+
}).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
139227
|
learning: union3([
|
|
141044
139228
|
string2(),
|
|
141045
139229
|
object2({
|
|
@@ -141061,6 +139245,7 @@ var BLOCKED_WAITING_PATTERN, BLOCKED_WAITING_MIN_ELAPSED_MS, storeProgressOutput
|
|
|
141061
139245
|
failureReason,
|
|
141062
139246
|
attachments,
|
|
141063
139247
|
citations,
|
|
139248
|
+
uiSpec,
|
|
141064
139249
|
learning,
|
|
141065
139250
|
persistMemory,
|
|
141066
139251
|
chainedTaskId,
|
|
@@ -141163,6 +139348,7 @@ var BLOCKED_WAITING_PATTERN, BLOCKED_WAITING_MIN_ELAPSED_MS, storeProgressOutput
|
|
|
141163
139348
|
}
|
|
141164
139349
|
}
|
|
141165
139350
|
let learningWrite;
|
|
139351
|
+
let uiSpecNote;
|
|
141166
139352
|
const result = await getDbClient2().transaction(async () => {
|
|
141167
139353
|
const agent = await getAgentById2(requestInfo.agentId ?? "");
|
|
141168
139354
|
if (!agent) {
|
|
@@ -141293,8 +139479,46 @@ This check refuses once per task; the next completion is accepted and unfixed ci
|
|
|
141293
139479
|
};
|
|
141294
139480
|
}
|
|
141295
139481
|
}
|
|
139482
|
+
let uiSpecToStore;
|
|
139483
|
+
if (uiSpec && !isEnvFlagEnabled("UI_SPEC_ENABLED", false)) {
|
|
139484
|
+
uiSpecNote = "uiSpec ignored: UI_SPEC_ENABLED is off.";
|
|
139485
|
+
} else if (uiSpec && status !== "completed") {
|
|
139486
|
+
uiSpecNote = 'uiSpec is stored only with status "completed".';
|
|
139487
|
+
} else if (uiSpec) {
|
|
139488
|
+
const validation = validateTaskUiSpec(uiSpec, {
|
|
139489
|
+
taskId,
|
|
139490
|
+
actionsEnabled: isEnvFlagEnabled("UI_SPEC_ACTIONS_ENABLED", false)
|
|
139491
|
+
});
|
|
139492
|
+
if (validation.ok) {
|
|
139493
|
+
uiSpecToStore = {
|
|
139494
|
+
spec: validation.spec,
|
|
139495
|
+
...validation.actions ? { actions: validation.actions } : {},
|
|
139496
|
+
fallbackText: validation.fallbackText
|
|
139497
|
+
};
|
|
139498
|
+
} else if (!await hasTaskUiSpecCheckRefusal(taskId)) {
|
|
139499
|
+
await createLogEntry2({
|
|
139500
|
+
eventType: "task_ui_spec_check_refused",
|
|
139501
|
+
agentId: agent.id,
|
|
139502
|
+
taskId,
|
|
139503
|
+
newValue: validation.issues.join(`
|
|
139504
|
+
`)
|
|
139505
|
+
});
|
|
139506
|
+
return {
|
|
139507
|
+
success: false,
|
|
139508
|
+
task: existingTask,
|
|
139509
|
+
message: `Completion refused: uiSpec is not valid. The task stays ${existingTask.status}. Fix these, then call store-progress again:
|
|
139510
|
+
- ${validation.issues.join(`
|
|
139511
|
+
- `)}
|
|
139512
|
+
This check refuses once per task; the next completion is accepted without the spec.`
|
|
139513
|
+
};
|
|
139514
|
+
} else {
|
|
139515
|
+
uiSpecNote = `uiSpec dropped: ${validation.issues[0]}`;
|
|
139516
|
+
}
|
|
139517
|
+
}
|
|
141296
139518
|
if (status === "completed") {
|
|
141297
139519
|
const result = await completeTask2(taskId, output);
|
|
139520
|
+
if (result && uiSpecToStore)
|
|
139521
|
+
await upsertTaskUiSpec(taskId, uiSpecToStore);
|
|
141298
139522
|
if (result) {
|
|
141299
139523
|
updatedTask = result;
|
|
141300
139524
|
getDbClient2().afterCommit(() => {
|
|
@@ -141380,7 +139604,11 @@ This check refuses once per task; the next completion is accepted and unfixed ci
|
|
|
141380
139604
|
finalizeSkippedTaskReaction(result.task, "store-progress");
|
|
141381
139605
|
const learningResult = await learningWrite;
|
|
141382
139606
|
const { success } = result;
|
|
141383
|
-
const message =
|
|
139607
|
+
const message = [
|
|
139608
|
+
result.message,
|
|
139609
|
+
...learningResult ? [learningSentence(learningResult)] : [],
|
|
139610
|
+
...success && uiSpecNote ? [uiSpecNote] : []
|
|
139611
|
+
].join(" ");
|
|
141384
139612
|
const task = result.task ? {
|
|
141385
139613
|
id: result.task.id,
|
|
141386
139614
|
status: result.task.status,
|
|
@@ -141405,6 +139633,7 @@ var init_store_progress = __esm(() => {
|
|
|
141405
139633
|
init_constants2();
|
|
141406
139634
|
init_task_learning();
|
|
141407
139635
|
init_task_citations2();
|
|
139636
|
+
init_task_ui_spec();
|
|
141408
139637
|
init_agent_fs_provider();
|
|
141409
139638
|
init_rbac();
|
|
141410
139639
|
init_task_skip();
|
|
@@ -141412,8 +139641,11 @@ var init_store_progress = __esm(() => {
|
|
|
141412
139641
|
init_terminal_result_guard();
|
|
141413
139642
|
init_utils();
|
|
141414
139643
|
init_types5();
|
|
139644
|
+
init_validate2();
|
|
139645
|
+
init_env_flag();
|
|
141415
139646
|
init_secret_scrubber();
|
|
141416
139647
|
init_task_citations();
|
|
139648
|
+
init_task_ui_spec2();
|
|
141417
139649
|
init_business_use();
|
|
141418
139650
|
BLOCKED_WAITING_PATTERN = /\b(waiting (for|on)|blocked (on|until|by)|still waiting|awaiting)\b/i;
|
|
141419
139651
|
BLOCKED_WAITING_MIN_ELAPSED_MS = 3 * 60 * 1000;
|
|
@@ -144941,4 +143173,4 @@ var init_server = __esm(() => {
|
|
|
144941
143173
|
loggedToolAllowlistWarnings = new Set;
|
|
144942
143174
|
});
|
|
144943
143175
|
|
|
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,
|
|
143176
|
+
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, 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 };
|