@desplega.ai/agent-swarm 2.8.1 → 2.8.2
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-pdy3qsvg.js → acp-adapter-fqzkxyra.js} +3 -3
- package/dist/{actions-pwjpn0j6.js → actions-kxek041g.js} +17 -17
- package/dist/{amp-adapter-cq9jgj6x.js → amp-adapter-ce7jjke4.js} +1 -1
- package/dist/{app-cnfffgwg.js → app-v6zz8yh0.js} +3 -3
- package/dist/{assistant-kpn317y1.js → assistant-m0sw9xx2.js} +18 -18
- package/dist/{boot-args-schema-pbbnhmc3.js → boot-args-schema-66bk37wv.js} +1 -1
- package/dist/{boot-reembed-9m0ysxma.js → boot-reembed-edjpwsc1.js} +1 -1
- package/dist/{boot-reembed-majbn53m.js → boot-reembed-y27n09tz.js} +1 -1
- package/dist/{boot-scrub-sweep-app8g8ym.js → boot-scrub-sweep-1xc35965.js} +3 -3
- package/dist/{boot-seeds-pbtmvcjm.js → boot-seeds-7hjj91qj.js} +4 -4
- package/dist/{boxd-qbkxy6ap.js → boxd-ent8ch04.js} +1 -1
- package/dist/{claude-adapter-wn1g3qp5.js → claude-adapter-stw7jdcf.js} +3 -3
- package/dist/{claude-managed-setup-pd47nzch.js → claude-managed-setup-y6z2perp.js} +1 -1
- package/dist/{claude-sdk-session-3a2a6589.js → claude-sdk-session-vvya8wqk.js} +3 -3
- package/dist/{cli-wk18cm92.js → cli-0cq8y6m7.js} +1 -1
- package/dist/{cli-p1w18yhx.js → cli-1pz0330a.js} +1 -1
- package/dist/{cli-d3p5vwbk.js → cli-1qkz151v.js} +3 -3
- package/dist/{cli-89cqnasv.js → cli-26ctbcdp.js} +18 -6
- package/dist/{cli-syybb0p1.js → cli-2kvhc7x8.js} +7 -7
- package/dist/{cli-93k32c37.js → cli-3e875j5p.js} +128 -41
- package/dist/{cli-k0615eh8.js → cli-3sy2xags.js} +10 -10
- package/dist/{cli-dy32zecz.js → cli-3vmb0n58.js} +1 -1
- package/dist/{cli-4r05hnqa.js → cli-4vzgeta4.js} +13 -13
- package/dist/{cli-b5rs97a6.js → cli-5y340nzn.js} +4 -4
- package/dist/{cli-7p1kvkck.js → cli-6rc5frdm.js} +1 -1
- package/dist/{cli-jcpr5smb.js → cli-837vfs2x.js} +2 -2
- package/dist/{cli-b085njxz.js → cli-959kp5h2.js} +12 -11
- package/dist/{cli-k93bq1wq.js → cli-97ae65rz.js} +4 -4
- package/dist/{cli-m4dqmnbp.js → cli-9mb2q6pb.js} +1 -1
- package/dist/{cli-bb431xey.js → cli-a0z912j7.js} +121 -33
- package/dist/{cli-k26bkr9t.js → cli-b98a65ed.js} +3 -3
- package/dist/{cli-k0wwfqbg.js → cli-dns0y538.js} +4 -0
- package/dist/{cli-tk7cjj8h.js → cli-dzpc6en0.js} +1 -1
- package/dist/{cli-6mma83xa.js → cli-e1p3n5gq.js} +4 -4
- package/dist/{cli-re4raaj0.js → cli-f4e8r23x.js} +1 -1
- package/dist/{cli-qmqk2yc2.js → cli-f4r3g076.js} +1 -1
- package/dist/{cli-pcad4cb1.js → cli-f6bahpn5.js} +1 -1
- package/dist/{cli-b8e9nb04.js → cli-fpjmegdb.js} +1 -1
- package/dist/{cli-0ntbxyaa.js → cli-fwy8kfd6.js} +271 -37
- package/dist/{cli-tacge1w0.js → cli-g5mtmf6t.js} +6 -6
- package/dist/{cli-sn7rtnj4.js → cli-gyt3zydq.js} +3 -3
- package/dist/{cli-vbh10fqa.js → cli-j24zbska.js} +3 -3
- package/dist/{cli-vqptjbr7.js → cli-jdknh18m.js} +10 -10
- package/dist/{cli-7b8sbmag.js → cli-kjtwrhea.js} +1 -1
- package/dist/{cli-9vhebtjz.js → cli-mxn1qvbn.js} +3 -2
- package/dist/{cli-zcsw143p.js → cli-n6vtrcht.js} +1 -1
- package/dist/{cli-2zp0et3v.js → cli-pchypa1s.js} +55 -19
- package/dist/{cli-gax7fk3t.js → cli-pfs8adn4.js} +1 -1
- package/dist/{cli-1xh9a7hn.js → cli-q24n86d2.js} +2 -2
- package/dist/{cli-7w69ne2f.js → cli-rcecc3yq.js} +167 -43
- package/dist/{cli-xae4g51r.js → cli-rh15cakt.js} +1 -1
- package/dist/{cli-yn2bbre9.js → cli-rmzsadkf.js} +1 -1
- package/dist/{cli-a3b239vq.js → cli-t2tma8gb.js} +1 -1
- package/dist/{cli-9wngrawf.js → cli-tekytdq9.js} +2 -2
- package/dist/{cli-tqegb8eq.js → cli-vdektqgf.js} +1 -1
- package/dist/{cli-cyhbbd1z.js → cli-w401b9tq.js} +1 -1
- package/dist/{cli-jywyhqws.js → cli-xf3qw745.js} +3 -3
- package/dist/{cli-hxpyc9sn.js → cli-z1w943va.js} +2 -2
- package/dist/{cli-yncmerje.js → cli-zh9rsbqf.js} +2 -2
- package/dist/cli.js +16 -16
- package/dist/{codex-adapter-nha71q3n.js → codex-adapter-zerf5qsp.js} +1 -1
- package/dist/{codex-hook-h3vk6xzr.js → codex-hook-30gyhzxe.js} +1 -1
- package/dist/{codex-session-runner-ak9x1k1h.js → codex-session-runner-89s304py.js} +1 -1
- package/dist/{commands-f587qpq8.js → commands-jeh1b51j.js} +3 -3
- package/dist/{controller-hxx8wwy1.js → controller-mctfbrse.js} +3 -3
- package/dist/{controllers-connect-k5sg9m9h.js → controllers-connect-nxa1ddwn.js} +18 -18
- package/dist/{cursor-adapter-n5nc3mfe.js → cursor-adapter-qj8vehv6.js} +1 -1
- package/dist/{db-nzf8zb5z.js → db-2dvay0es.js} +3 -3
- package/dist/{db-amm8w15a.js → db-b36qn6k3.js} +2 -2
- package/dist/{dispatcher-89zrts8f.js → dispatcher-gndbta01.js} +16 -16
- package/dist/{dsh-adapter-nrhbrjz8.js → dsh-adapter-f75sz821.js} +1 -1
- package/dist/{e2b-jkwfhbcv.js → e2b-3gpc2n3w.js} +1 -1
- package/dist/{e2b-s16txnpx.js → e2b-jbm7mj93.js} +1 -1
- package/dist/{embedding-space-ezwenjmj.js → embedding-space-4p05vb2x.js} +6 -6
- package/dist/{embeddings-np74ht6g.js → embeddings-m6768mgh.js} +1 -1
- package/dist/{external-channel-z46yx9d7.js → external-channel-gjv3jne3.js} +2 -2
- package/dist/{fx-adapter-3q12snn6.js → fx-adapter-rpsgb1tw.js} +4 -4
- package/dist/{grok-adapter-ahb1w033.js → grok-adapter-n2m3zjg1.js} +4 -4
- package/dist/handlers-nv8edn19.js +32 -0
- package/dist/{heartbeat-dt9qw9c8.js → heartbeat-a1tv60gt.js} +19 -19
- package/dist/{hook-8k6fbz9b.js → hook-8h5dzcgq.js} +2 -2
- package/dist/{hook-jgcgygex.js → hook-cyaps9ba.js} +4 -4
- package/dist/{http-haw4r8ne.js → http-t15mhbd9.js} +1731 -77
- package/dist/{index-s4ewdma4.js → index-ksmyd6kc.js} +16 -16
- package/dist/{index-tez78qj3.js → index-qav6455f.js} +13 -11
- package/dist/index-rjnrje98.js +32 -0
- package/dist/index-tv3413wy.js +33 -0
- package/dist/{index-5gk12my8.js → index-w1zqf680.js} +1 -1
- package/dist/{keepalive-xn6s7rmg.js → keepalive-91s7hzrb.js} +3 -3
- package/dist/{lead-6ygbfhbh.js → lead-3hmddvrm.js} +30 -30
- package/dist/{maintenance-vdts800b.js → maintenance-7pjmy5xy.js} +1 -1
- package/dist/{oauth-refresh-sweep-094c8wfk.js → oauth-refresh-sweep-rzqfm94j.js} +2 -2
- package/dist/{onboard-v99eh56m.js → onboard-74st7pag.js} +3 -3
- package/dist/{opencode-adapter-dsagkhtw.js → opencode-adapter-arn7gm8q.js} +2 -2
- package/dist/{otel-impl-q7yr9yp0.js → otel-impl-rnzey8cb.js} +1 -1
- package/dist/{pi-mono-adapter-546cd1cc.js → pi-mono-adapter-6mkwq64n.js} +3 -2
- package/dist/{pricing-refresh-7dh2yase.js → pricing-refresh-ha21jhk7.js} +2 -2
- package/dist/{rbac-roles-npbmdh77.js → rbac-roles-59dxachk.js} +2 -2
- package/dist/{rbac-roles-mdmc96p4.js → rbac-roles-wqhma4dr.js} +3 -3
- package/dist/{render-v2-twhhwmms.js → render-v2-14kpzx12.js} +3 -3
- package/dist/{resume-5gsrjd5e.js → resume-gsa5fb5f.js} +6 -6
- package/dist/{session-access-m191x30x.js → session-access-skm7bnp6.js} +4 -4
- package/dist/{session-source-backfill-nt923ask.js → session-source-backfill-pbqzbncv.js} +2 -2
- package/dist/{setup-wv467afy.js → setup-5yermsem.js} +1 -1
- package/dist/{work-objects-8zkrpy13.js → work-objects-xj0ck0w4.js} +19 -19
- package/dist/{worker-follow-up-cecqszem.js → worker-follow-up-911xc0b8.js} +18 -16
- package/dist/{worker-mz5z7kj0.js → worker-qgg0m2gw.js} +30 -30
- package/openapi.json +1741 -290
- package/package.json +2 -2
- package/src/apps/catalog.generated.json +120 -1
- package/src/apps/definition.ts +38 -11
- package/src/apps/page-validator.ts +88 -0
- package/src/be/db/model-profiles.ts +110 -11
- package/src/be/db/tasks/read.ts +20 -0
- package/src/be/db/workflow-run-definitions.ts +19 -8
- package/src/be/db-client.ts +43 -5
- package/src/be/db.ts +9 -3
- package/src/be/migrations/284_model_profile_fallbacks.sql +9 -0
- package/src/be/model-profile-check.ts +43 -18
- package/src/be/runtime-pools/routing.ts +1 -0
- package/src/be/savings/calibrate.ts +468 -0
- package/src/be/savings/compute.ts +182 -0
- package/src/be/savings/model.ts +406 -0
- package/src/be/scripts/typecheck.ts +5 -0
- package/src/be/seed/agent-fs-provision.ts +48 -11
- package/src/be/seed/workflows-seeder.ts +67 -23
- package/src/be/skill-parser.ts +19 -7
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/provider-error-class.ts +97 -0
- package/src/commands/runner.ts +99 -17
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/http/all-routes.ts +2 -0
- package/src/http/fs.ts +8 -2
- package/src/http/index.ts +4 -0
- package/src/http/model-profiles.ts +43 -10
- package/src/http/poll.ts +1 -0
- package/src/http/savings-calibration.ts +277 -0
- package/src/http/savings.ts +363 -0
- package/src/http/tasks.ts +46 -4
- package/src/http/trackers/authorize-gate.ts +41 -0
- package/src/http/trackers/jira.ts +26 -4
- package/src/http/trackers/linear.ts +26 -4
- package/src/integrations/chat-sdk/limits.ts +6 -1
- package/src/jira/oauth.ts +7 -1
- package/src/linear/README.md +2 -1
- package/src/linear/oauth.ts +7 -1
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/codex-adapter.ts +3 -0
- package/src/providers/pi-mono-adapter.ts +6 -5
- package/src/providers/types.ts +7 -0
- package/src/scripts-runtime/sdk-allowlist.ts +11 -1
- package/src/scripts-runtime/swarm-sdk.ts +6 -0
- package/src/scripts-runtime/types/stdlib.d.ts +9 -0
- package/src/scripts-runtime/types/swarm-extension.d.ts +34 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +9 -0
- package/src/tasks/worker-follow-up.ts +142 -3
- package/src/tests/agent-fs-provision-seeder.test.ts +81 -0
- package/src/tests/apps-chart-shell.test.ts +170 -0
- package/src/tests/apps-icon.test.ts +156 -2
- package/src/tests/chat-sdk-relay.test.ts +12 -0
- package/src/tests/codex-adapter.test.ts +11 -0
- package/src/tests/comb-default.test.ts +6 -0
- package/src/tests/core-auth.test.ts +7 -6
- package/src/tests/db-client-busy-retry.test.ts +58 -6
- package/src/tests/deploy-guard.test.ts +154 -0
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/fixtures/app-shell-charts-definition.json.txt +180 -0
- package/src/tests/model-profile-fallbacks.test.ts +482 -0
- package/src/tests/model-profiles-api.test.ts +1 -0
- package/src/tests/pi-mono-session-cost-on-abort.test.ts +115 -0
- package/src/tests/provider-error-class.test.ts +174 -0
- package/src/tests/runner-provider-fallback.test.ts +197 -0
- package/src/tests/savings-calibration-api.test.ts +264 -0
- package/src/tests/savings-calibration.test.ts +201 -0
- package/src/tests/savings-compute.test.ts +406 -0
- package/src/tests/savings-model.test.ts +287 -0
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/sdk-allowlist.test.ts +40 -0
- package/src/tests/seed-workflows.test.ts +167 -11
- package/src/tests/skill-parser.test.ts +45 -0
- package/src/tests/tracker-oauth-authorize-auth.test.ts +262 -0
- package/src/tests/workflow-definition-pinning.test.ts +128 -3
- package/src/tests/workflow-script-principal.test.ts +94 -4
- package/src/tools/app-upsert.ts +1 -1
- package/src/tools/model-profiles/list-model-profiles.ts +4 -2
- package/src/tools/update-profile.ts +1 -1
- package/src/types.ts +115 -33
- package/src/utils/constants.ts +2 -0
- package/templates/skills/apps/SKILL.md +62 -3
- package/templates/skills/apps/content.md +62 -3
- package/templates/skills/swarm-docs/content.md +2 -0
- package/dist/handlers-vbww69re.js +0 -32
- package/dist/index-4xwaf5th.js +0 -32
- package/dist/index-f0hcrs8e.js +0 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@desplega.ai/agent-swarm",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2",
|
|
4
4
|
"description": "agent-swarm.dev — an open-source operating system for AI work: a lead agent breaks goals into tasks, routes them to specialized workers such as Claude Code or Codex, runs each worker in an isolated container, and preserves shared memory, tools, schedules, and review gates so delegated work compounds across sessions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-swarm.dev",
|
|
@@ -214,7 +214,7 @@
|
|
|
214
214
|
"@chat-adapter/teams": "4.41.1",
|
|
215
215
|
"@chat-adapter/telegram": "4.41.1",
|
|
216
216
|
"@cursor/sdk": "1.3.1",
|
|
217
|
-
"@desplega.ai/agent-fs-just-bash": "0.18.
|
|
217
|
+
"@desplega.ai/agent-fs-just-bash": "0.18.22",
|
|
218
218
|
"@desplega.ai/business-use": "^0.4.2",
|
|
219
219
|
"@earendil-works/pi-agent-core": "^1.5.0",
|
|
220
220
|
"@earendil-works/pi-ai": "^1.5.0",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"NumberInput",
|
|
17
17
|
"Button",
|
|
18
18
|
"Metric",
|
|
19
|
+
"Chart",
|
|
19
20
|
"Alert",
|
|
20
21
|
"Badge",
|
|
21
22
|
"Icon",
|
|
@@ -623,7 +624,7 @@
|
|
|
623
624
|
}
|
|
624
625
|
},
|
|
625
626
|
"Metric": {
|
|
626
|
-
"description": "Stat tile (the dashboard `StatPanel`): label, value, optional `detail` line and `trend: { direction: \"up\"|\"down\"|\"flat\", label }` (arrow plus success/error/muted text). `icon` adds a tile tinted by `tone` (neutral|success|active|error|info|pending|warning|paused); `info` is a one-sentence explanation in a tooltip next to the label. Bind `loading` to the backing query (`{ \"$state\": \"/queries/<name>/loading\" }`) to show a skeleton instead of a blank value while it loads; an empty value renders an em dash.",
|
|
627
|
+
"description": "Stat tile (the dashboard `StatPanel`): label, value, optional `detail` line and `trend: { direction: \"up\"|\"down\"|\"flat\", label }` (arrow plus success/error/muted text). `icon` adds a tile tinted by `tone` (neutral|success|active|error|info|pending|warning|paused); `info` is a one-sentence explanation in a tooltip next to the label. Bind `loading` to the backing query (`{ \"$state\": \"/queries/<name>/loading\" }`) to show a skeleton instead of a blank value while it loads; an empty value renders an em dash. `sparkline` draws a small trend line under the value, in the `tone` color: an array of numbers (`null` is a gap), or rows (bind `{ \"$state\": \"/queries/<name>/data\" }`) read through `sparklineKey`. Fewer than two points draws nothing.",
|
|
627
628
|
"props": {
|
|
628
629
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
629
630
|
"type": "object",
|
|
@@ -714,12 +715,130 @@
|
|
|
714
715
|
},
|
|
715
716
|
"required": ["direction", "label"],
|
|
716
717
|
"additionalProperties": false
|
|
718
|
+
},
|
|
719
|
+
"sparkline": {
|
|
720
|
+
"maxItems": 500,
|
|
721
|
+
"type": "array",
|
|
722
|
+
"items": {
|
|
723
|
+
"anyOf": [
|
|
724
|
+
{
|
|
725
|
+
"type": "number"
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"type": "null"
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
"type": "object",
|
|
732
|
+
"propertyNames": {
|
|
733
|
+
"type": "string"
|
|
734
|
+
},
|
|
735
|
+
"additionalProperties": {}
|
|
736
|
+
}
|
|
737
|
+
]
|
|
738
|
+
}
|
|
739
|
+
},
|
|
740
|
+
"sparklineKey": {
|
|
741
|
+
"type": "string"
|
|
717
742
|
}
|
|
718
743
|
},
|
|
719
744
|
"required": ["label", "value"],
|
|
720
745
|
"additionalProperties": false
|
|
721
746
|
}
|
|
722
747
|
},
|
|
748
|
+
"Chart": {
|
|
749
|
+
"description": "Line, area or bar chart over rows. Bind `data`/`loading`/`error` to a named query like Table. `x` is the row field on the x axis: `xType: \"category\"` (default) keeps row order, `\"time\"` parses ISO dates or epoch ms, sorts the rows and labels ticks as dates (rows whose `x` does not parse are dropped). `series: [{ key, label?, color? }]` (1-8) plots numeric row fields; `color` is chart-1..chart-5, primary, success, warning, error, info or muted (default palette, in order: primary, chart-2..chart-5). `stacked` stacks area and bar series (lines never stack). `format` number (default) | currency (`currency`, ISO code, default USD) | percent (values are ratios, 0.42 = 42%) shapes axis ticks and the tooltip. Hover shows a tooltip with every series; the legend shows with two or more series (`legend` forces it on or off). `height` px (120-640, default 240). No rows renders `emptyMessage` (default \"No data yet\"). Wrap it in a `Card` for a title.",
|
|
750
|
+
"props": {
|
|
751
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
752
|
+
"type": "object",
|
|
753
|
+
"properties": {
|
|
754
|
+
"kind": {
|
|
755
|
+
"type": "string",
|
|
756
|
+
"enum": ["line", "area", "bar"]
|
|
757
|
+
},
|
|
758
|
+
"data": {
|
|
759
|
+
"type": "array",
|
|
760
|
+
"items": {
|
|
761
|
+
"type": "object",
|
|
762
|
+
"propertyNames": {
|
|
763
|
+
"type": "string"
|
|
764
|
+
},
|
|
765
|
+
"additionalProperties": {}
|
|
766
|
+
}
|
|
767
|
+
},
|
|
768
|
+
"loading": {
|
|
769
|
+
"type": "boolean"
|
|
770
|
+
},
|
|
771
|
+
"error": {
|
|
772
|
+
"type": ["string", "null"]
|
|
773
|
+
},
|
|
774
|
+
"x": {
|
|
775
|
+
"type": "string"
|
|
776
|
+
},
|
|
777
|
+
"xType": {
|
|
778
|
+
"type": "string",
|
|
779
|
+
"enum": ["category", "time"]
|
|
780
|
+
},
|
|
781
|
+
"series": {
|
|
782
|
+
"minItems": 1,
|
|
783
|
+
"maxItems": 8,
|
|
784
|
+
"type": "array",
|
|
785
|
+
"items": {
|
|
786
|
+
"type": "object",
|
|
787
|
+
"properties": {
|
|
788
|
+
"key": {
|
|
789
|
+
"type": "string"
|
|
790
|
+
},
|
|
791
|
+
"label": {
|
|
792
|
+
"type": "string"
|
|
793
|
+
},
|
|
794
|
+
"color": {
|
|
795
|
+
"type": "string",
|
|
796
|
+
"enum": [
|
|
797
|
+
"chart-1",
|
|
798
|
+
"chart-2",
|
|
799
|
+
"chart-3",
|
|
800
|
+
"chart-4",
|
|
801
|
+
"chart-5",
|
|
802
|
+
"primary",
|
|
803
|
+
"success",
|
|
804
|
+
"warning",
|
|
805
|
+
"error",
|
|
806
|
+
"info",
|
|
807
|
+
"muted"
|
|
808
|
+
]
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
"required": ["key"],
|
|
812
|
+
"additionalProperties": false
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
"stacked": {
|
|
816
|
+
"type": "boolean"
|
|
817
|
+
},
|
|
818
|
+
"format": {
|
|
819
|
+
"type": "string",
|
|
820
|
+
"enum": ["number", "currency", "percent"]
|
|
821
|
+
},
|
|
822
|
+
"currency": {
|
|
823
|
+
"type": "string",
|
|
824
|
+
"pattern": "^[A-Z]{3}$"
|
|
825
|
+
},
|
|
826
|
+
"height": {
|
|
827
|
+
"type": "integer",
|
|
828
|
+
"minimum": 120,
|
|
829
|
+
"maximum": 640
|
|
830
|
+
},
|
|
831
|
+
"legend": {
|
|
832
|
+
"type": "boolean"
|
|
833
|
+
},
|
|
834
|
+
"emptyMessage": {
|
|
835
|
+
"type": "string"
|
|
836
|
+
}
|
|
837
|
+
},
|
|
838
|
+
"required": ["kind", "x", "series"],
|
|
839
|
+
"additionalProperties": false
|
|
840
|
+
}
|
|
841
|
+
},
|
|
723
842
|
"Alert": {
|
|
724
843
|
"description": "Status-toned inline alert. `icon` overrides the tone's default icon. `actionLabel` adds a button inside the callout that emits the element's `press` event (wire it with `on.press`).",
|
|
725
844
|
"props": {
|
package/src/apps/definition.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
crossPageDefinitionIssues,
|
|
11
11
|
type ElementReferenceContext,
|
|
12
12
|
elementDefinitionIssues,
|
|
13
|
+
shellDefinitionIssues,
|
|
13
14
|
validatePage,
|
|
14
15
|
} from "./page-validator";
|
|
15
16
|
import { resolveSyncRunAs } from "./sync-run-as";
|
|
@@ -380,6 +381,15 @@ const AppPageSchema = z
|
|
|
380
381
|
elements: z.record(z.string(), z.unknown()),
|
|
381
382
|
title: z.string().optional(),
|
|
382
383
|
params: z.record(AppNameSchema, AppPageParamSchema).optional(),
|
|
384
|
+
// Sidebar layout (`layout: "sidebar"`) metadata. `icon` is a catalog icon
|
|
385
|
+
// name (checked against the generated catalog in `shellDefinitionIssues`).
|
|
386
|
+
icon: z.string().optional(),
|
|
387
|
+
/** One line under the title in the sticky page header. */
|
|
388
|
+
description: z.string().max(280).optional(),
|
|
389
|
+
/** Element of this page rendered in the header's actions slot, outside `root`'s tree. */
|
|
390
|
+
headerActions: z.string().optional(),
|
|
391
|
+
/** `false` leaves the page out of the sidebar. Pages with a required param never list. */
|
|
392
|
+
nav: z.boolean().optional(),
|
|
383
393
|
})
|
|
384
394
|
.strict();
|
|
385
395
|
|
|
@@ -469,10 +479,22 @@ export const AppDefinitionSchema = z
|
|
|
469
479
|
defaultPage: AppNameSchema,
|
|
470
480
|
theme: AppThemeIdSchema.optional(),
|
|
471
481
|
/**
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
|
|
482
|
+
* `sidebar` wraps every page in the app shell: a left sidebar listing the
|
|
483
|
+
* pages and a sticky page header (title, description, `headerActions`).
|
|
484
|
+
* Omitted = the plain page canvas.
|
|
485
|
+
*/
|
|
486
|
+
layout: z.enum(["sidebar"]).optional(),
|
|
487
|
+
/**
|
|
488
|
+
* Icon shown for the app on the dashboard Apps page. One of:
|
|
489
|
+
* - `{type:"lucide", icon, color?}`: a lucide icon name + optional hex color.
|
|
490
|
+
* The dashboard owns the curated icon catalog and falls back to a generic
|
|
491
|
+
* icon when the name is unknown (`AVATAR_ICON_CATALOG` in
|
|
492
|
+
* `apps/ui/src/lib/agent-icon.ts`).
|
|
493
|
+
* - `{type:"url", url}`: an https image link (no credentials, max 2048).
|
|
494
|
+
* - `{type:"agent-fs", path, orgId?, driveId?}`: an image in agent-fs. Omit
|
|
495
|
+
* both IDs for the swarm drive, or pass both for another drive.
|
|
496
|
+
* The server validates shape only; the dashboard shows the glyph fallback
|
|
497
|
+
* when an image cannot load. A merge patch replaces `icon` whole.
|
|
476
498
|
*/
|
|
477
499
|
icon: AppIconSchema.optional(),
|
|
478
500
|
})
|
|
@@ -635,6 +657,7 @@ const APP_DEFINITION_TOP_LEVEL_KEYS = new Set([
|
|
|
635
657
|
"schemaVersion",
|
|
636
658
|
"theme",
|
|
637
659
|
"icon",
|
|
660
|
+
"layout",
|
|
638
661
|
]);
|
|
639
662
|
|
|
640
663
|
const TOP_LEVEL_KEY_SUGGESTIONS: Record<string, string> = {
|
|
@@ -1035,6 +1058,7 @@ export async function parseAppDefinition(
|
|
|
1035
1058
|
validatePage(parsed.data, catalog, pageName),
|
|
1036
1059
|
),
|
|
1037
1060
|
...crossPageDefinitionIssues(parsed.data, catalog),
|
|
1061
|
+
...shellDefinitionIssues(parsed.data, catalog),
|
|
1038
1062
|
...(await elementDefinitionIssues(parsed.data, catalog, elementContext)),
|
|
1039
1063
|
];
|
|
1040
1064
|
const grandfatheredScriptRefs = collectScriptReferencePathMap(elementContext.existingDefinition);
|
|
@@ -1177,19 +1201,22 @@ function applyMergePatch(target: unknown, patch: unknown, path: string[]): unkno
|
|
|
1177
1201
|
delete result[key];
|
|
1178
1202
|
continue;
|
|
1179
1203
|
}
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1204
|
+
// A top-level `icon` is replaced whole so switching its `type` never
|
|
1205
|
+
// leaves keys from the previous variant behind.
|
|
1206
|
+
const replaceWhole =
|
|
1207
|
+
(path.length === 0 && key === "icon") ||
|
|
1208
|
+
(entriesAreAtomic &&
|
|
1184
1209
|
!(
|
|
1185
1210
|
path.length === 1 &&
|
|
1186
1211
|
path[0] === "elements" &&
|
|
1187
1212
|
isMergePatchObject(value) &&
|
|
1188
1213
|
Object.keys(value).length === 1 &&
|
|
1189
1214
|
isMergePatchObject(value.elements)
|
|
1190
|
-
)
|
|
1191
|
-
|
|
1192
|
-
|
|
1215
|
+
));
|
|
1216
|
+
defineMergePatchValue(
|
|
1217
|
+
result,
|
|
1218
|
+
key,
|
|
1219
|
+
replaceWhole ? value : applyMergePatch(result[key], value, [...path, key]),
|
|
1193
1220
|
);
|
|
1194
1221
|
}
|
|
1195
1222
|
return result;
|
|
@@ -111,6 +111,7 @@ const DATA_FIELD_PROPS: Record<string, readonly string[]> = {
|
|
|
111
111
|
Kanban: ["columnField", "titleField", "idField"],
|
|
112
112
|
Calendar: ["startField", "endField", "titleField", "idField"],
|
|
113
113
|
ContributionGraph: ["dateField", "countField"],
|
|
114
|
+
Chart: ["x"],
|
|
114
115
|
};
|
|
115
116
|
const CONDITION_KEYS = new Set(["eq", "neq", "gt", "gte", "lt", "lte", "not"]);
|
|
116
117
|
|
|
@@ -1322,6 +1323,72 @@ interface ElementTreeValidationTarget {
|
|
|
1322
1323
|
elementProps?: Record<string, unknown>;
|
|
1323
1324
|
}
|
|
1324
1325
|
|
|
1326
|
+
const CHART_MAX_SERIES = 8;
|
|
1327
|
+
|
|
1328
|
+
/** Chart bounds the generic JSON-schema walker does not evaluate (minItems, pattern, minimum). */
|
|
1329
|
+
function chartPropIssues(
|
|
1330
|
+
props: Record<string, unknown>,
|
|
1331
|
+
elementPath: string,
|
|
1332
|
+
): AppValidationIssue[] {
|
|
1333
|
+
const issues: AppValidationIssue[] = [];
|
|
1334
|
+
const propsPath = `${elementPath}.props`;
|
|
1335
|
+
if (Array.isArray(props.series)) {
|
|
1336
|
+
if (props.series.length === 0 || props.series.length > CHART_MAX_SERIES) {
|
|
1337
|
+
issues.push(issue(`${propsPath}.series`, `must list 1-${CHART_MAX_SERIES} series`));
|
|
1338
|
+
}
|
|
1339
|
+
const seen = new Set<string>();
|
|
1340
|
+
for (const [index, entry] of props.series.entries()) {
|
|
1341
|
+
if (!isPlainObject(entry) || typeof entry.key !== "string") continue;
|
|
1342
|
+
if (seen.has(entry.key)) {
|
|
1343
|
+
issues.push(issue(`${propsPath}.series.${index}.key`, `duplicate series "${entry.key}"`));
|
|
1344
|
+
}
|
|
1345
|
+
seen.add(entry.key);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
if (typeof props.currency === "string" && !/^[A-Z]{3}$/.test(props.currency)) {
|
|
1349
|
+
issues.push(issue(`${propsPath}.currency`, "must be an ISO 4217 code like USD"));
|
|
1350
|
+
}
|
|
1351
|
+
if (
|
|
1352
|
+
typeof props.height === "number" &&
|
|
1353
|
+
(!Number.isInteger(props.height) || props.height < 120 || props.height > 640)
|
|
1354
|
+
) {
|
|
1355
|
+
issues.push(issue(`${propsPath}.height`, "must be an integer from 120 to 640"));
|
|
1356
|
+
}
|
|
1357
|
+
return issues;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* Sidebar-layout page metadata: `icon` from the catalog icon set, and
|
|
1362
|
+
* `headerActions` / `nav` only where the sidebar layout renders them.
|
|
1363
|
+
*/
|
|
1364
|
+
export function shellDefinitionIssues(
|
|
1365
|
+
definition: AppDefinition,
|
|
1366
|
+
catalog: AppCatalog,
|
|
1367
|
+
): AppValidationIssue[] {
|
|
1368
|
+
const issues: AppValidationIssue[] = [];
|
|
1369
|
+
const iconNames = catalog.components.Icon?.props.properties?.name?.enum ?? [];
|
|
1370
|
+
const sidebar = definition.layout === "sidebar";
|
|
1371
|
+
for (const [pageName, page] of Object.entries(definition.pages)) {
|
|
1372
|
+
const pagePath = appendPath("pages", pageName);
|
|
1373
|
+
if (page.icon !== undefined && !iconNames.includes(page.icon)) {
|
|
1374
|
+
issues.push(issue(appendPath(pagePath, "icon"), `unknown icon "${page.icon}"`));
|
|
1375
|
+
}
|
|
1376
|
+
if (!sidebar) {
|
|
1377
|
+
for (const key of ["headerActions", "nav"] as const) {
|
|
1378
|
+
if (page[key] !== undefined) {
|
|
1379
|
+
issues.push(
|
|
1380
|
+
issue(
|
|
1381
|
+
appendPath(pagePath, key),
|
|
1382
|
+
'only rendered with layout: "sidebar"; set it or drop this',
|
|
1383
|
+
),
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
return issues;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1325
1392
|
export function validatePage(
|
|
1326
1393
|
definition: AppDefinition,
|
|
1327
1394
|
catalog: AppCatalog,
|
|
@@ -1459,6 +1526,7 @@ export function validatePage(
|
|
|
1459
1526
|
);
|
|
1460
1527
|
}
|
|
1461
1528
|
collectLinkFieldIssues(definition, type, rawElement.props, elementPath, issues);
|
|
1529
|
+
if (type === "Chart") issues.push(...chartPropIssues(rawElement.props, elementPath));
|
|
1462
1530
|
if (type === "Table") {
|
|
1463
1531
|
// Row selection lives at `/ui/<id>/selected`, so it needs an id to root it.
|
|
1464
1532
|
const tableProps = rawElement.props;
|
|
@@ -1587,6 +1655,13 @@ export function validatePage(
|
|
|
1587
1655
|
}
|
|
1588
1656
|
}
|
|
1589
1657
|
}
|
|
1658
|
+
if (type === "Chart" && Array.isArray(props.series)) {
|
|
1659
|
+
for (const [index, entry] of props.series.entries()) {
|
|
1660
|
+
if (isPlainObject(entry)) {
|
|
1661
|
+
fieldNames.push([`${elementPath}.props.series.${index}.key`, entry.key]);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1590
1665
|
for (const [fieldPath, fieldName] of fieldNames) {
|
|
1591
1666
|
if (typeof fieldName !== "string") continue;
|
|
1592
1667
|
const found = fieldBindingIssue(
|
|
@@ -1810,6 +1885,19 @@ export function validatePage(
|
|
|
1810
1885
|
}
|
|
1811
1886
|
};
|
|
1812
1887
|
if (typeof root === "string") markReachable(root);
|
|
1888
|
+
// The sidebar layout renders `headerActions` as a second root in the sticky
|
|
1889
|
+
// page header, so its subtree is reachable too, but never also from `root`.
|
|
1890
|
+
const headerActions = pageName ? definition.pages[pageName]?.headerActions : undefined;
|
|
1891
|
+
if (headerActions !== undefined) {
|
|
1892
|
+
const headerPath = appendPath(pagePath, "headerActions");
|
|
1893
|
+
if (!Object.hasOwn(elements, headerActions)) {
|
|
1894
|
+
issues.push(issue(headerPath, `element "${headerActions}" not found`));
|
|
1895
|
+
} else if (reachable.has(headerActions)) {
|
|
1896
|
+
issues.push(issue(headerPath, `element "${headerActions}" is already rendered from root`));
|
|
1897
|
+
} else {
|
|
1898
|
+
markReachable(headerActions);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1813
1901
|
for (const elementId of Object.keys(elements)) {
|
|
1814
1902
|
if (!reachable.has(elementId)) {
|
|
1815
1903
|
issues.push(issue(`${elementsPath}.${elementId}`, "element is not reachable from root"));
|
|
@@ -34,6 +34,7 @@ type ModelProfileRow = {
|
|
|
34
34
|
description: string | null;
|
|
35
35
|
seededFrom: string | null;
|
|
36
36
|
credentialAllowlist: string | null;
|
|
37
|
+
fallbacks: string | null;
|
|
37
38
|
createdAt: string;
|
|
38
39
|
lastUpdatedAt: string;
|
|
39
40
|
};
|
|
@@ -74,6 +75,20 @@ function serializeCredentialAllowlist(
|
|
|
74
75
|
return value && Object.keys(value).length > 0 ? JSON.stringify(value) : null;
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
/** The stored fallback list; anything but a JSON array of names reads as none. */
|
|
79
|
+
function parseFallbacks(value: string | null): string[] {
|
|
80
|
+
if (!value) return [];
|
|
81
|
+
try {
|
|
82
|
+
const parsed: unknown = JSON.parse(value);
|
|
83
|
+
if (Array.isArray(parsed)) {
|
|
84
|
+
return parsed.filter((name): name is string => typeof name === "string" && name.length > 0);
|
|
85
|
+
}
|
|
86
|
+
} catch {
|
|
87
|
+
// Falls through to none.
|
|
88
|
+
}
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
|
|
77
92
|
function rowToModelProfile(row: ModelProfileRow): ModelProfile {
|
|
78
93
|
const allowlist = parseCredentialAllowlist(row.credentialAllowlist);
|
|
79
94
|
const profile: ModelProfile = {
|
|
@@ -88,6 +103,7 @@ function rowToModelProfile(row: ModelProfileRow): ModelProfile {
|
|
|
88
103
|
description: row.description,
|
|
89
104
|
seededFrom: row.seededFrom,
|
|
90
105
|
credentials: allowlist.credentials,
|
|
106
|
+
fallbacks: parseFallbacks(row.fallbacks),
|
|
91
107
|
createdAt: row.createdAt,
|
|
92
108
|
lastUpdatedAt: row.lastUpdatedAt,
|
|
93
109
|
};
|
|
@@ -127,6 +143,8 @@ export interface ModelProfileInput {
|
|
|
127
143
|
seededFrom?: string | null;
|
|
128
144
|
/** Pooled-key allowlist, stored as `credentialAllowlist`; null uses the whole pool. */
|
|
129
145
|
credentials?: ModelProfileCredentials | null;
|
|
146
|
+
/** Same-harness profiles to hop to on a provider error, in order. */
|
|
147
|
+
fallbacks?: string[];
|
|
130
148
|
}
|
|
131
149
|
|
|
132
150
|
/** Insert a profile. Returns null when the name is taken. */
|
|
@@ -137,8 +155,8 @@ export async function createModelProfile(
|
|
|
137
155
|
const now = new Date().toISOString();
|
|
138
156
|
const row = await getDbClient().get<ModelProfileRow>(
|
|
139
157
|
`INSERT INTO model_profiles
|
|
140
|
-
(id, name, harness, model, effort, allowCustomModel, description, seededFrom, credentialAllowlist, createdAt, lastUpdatedAt, created_by, updated_by)
|
|
141
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
158
|
+
(id, name, harness, model, effort, allowCustomModel, description, seededFrom, credentialAllowlist, fallbacks, createdAt, lastUpdatedAt, created_by, updated_by)
|
|
159
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
142
160
|
ON CONFLICT(name) DO NOTHING
|
|
143
161
|
RETURNING *`,
|
|
144
162
|
[
|
|
@@ -151,6 +169,7 @@ export async function createModelProfile(
|
|
|
151
169
|
input.description ?? null,
|
|
152
170
|
input.seededFrom ?? null,
|
|
153
171
|
serializeCredentialAllowlist(input.credentials),
|
|
172
|
+
JSON.stringify(input.fallbacks ?? []),
|
|
154
173
|
now,
|
|
155
174
|
now,
|
|
156
175
|
audit.userId ?? null,
|
|
@@ -161,12 +180,15 @@ export async function createModelProfile(
|
|
|
161
180
|
}
|
|
162
181
|
|
|
163
182
|
export type ModelProfilePatch = Partial<
|
|
164
|
-
Pick<
|
|
183
|
+
Pick<
|
|
184
|
+
ModelProfileInput,
|
|
185
|
+
"model" | "effort" | "allowCustomModel" | "description" | "credentials" | "fallbacks"
|
|
186
|
+
>
|
|
165
187
|
>;
|
|
166
188
|
|
|
167
189
|
/**
|
|
168
|
-
* Update a profile's model, effort, description
|
|
169
|
-
* (`credentials: null` clears it). The name and harness are fixed.
|
|
190
|
+
* Update a profile's model, effort, description, credential allowlist
|
|
191
|
+
* (`credentials: null` clears it) or fallbacks. The name and harness are fixed.
|
|
170
192
|
*/
|
|
171
193
|
export async function updateModelProfile(
|
|
172
194
|
name: string,
|
|
@@ -195,6 +217,10 @@ export async function updateModelProfile(
|
|
|
195
217
|
sets.push("credentialAllowlist = ?");
|
|
196
218
|
params.push(serializeCredentialAllowlist(patch.credentials));
|
|
197
219
|
}
|
|
220
|
+
if (patch.fallbacks !== undefined) {
|
|
221
|
+
sets.push("fallbacks = ?");
|
|
222
|
+
params.push(JSON.stringify(patch.fallbacks));
|
|
223
|
+
}
|
|
198
224
|
sets.push("lastUpdatedAt = ?", "updated_by = ?");
|
|
199
225
|
params.push(new Date().toISOString(), audit.userId ?? null);
|
|
200
226
|
const row = await getDbClient().get<ModelProfileRow>(
|
|
@@ -224,13 +250,22 @@ function repairWindowStart(): string {
|
|
|
224
250
|
return new Date(Date.now() - SUPERSEDED_RESUME_REPAIR_WINDOW_MS).toISOString();
|
|
225
251
|
}
|
|
226
252
|
|
|
253
|
+
/** Profiles (alias `o`) whose fallback list names `model_profiles.name`. */
|
|
254
|
+
const LISTED_AS_FALLBACK_SQL = `EXISTS (
|
|
255
|
+
SELECT 1 FROM model_profiles o, json_each(CASE WHEN json_valid(o.fallbacks) THEN o.fallbacks ELSE '[]' END) j
|
|
256
|
+
WHERE j.value = model_profiles.name AND o.name <> model_profiles.name)`;
|
|
257
|
+
|
|
227
258
|
/**
|
|
228
259
|
* Who still points at a profile: agents with it as default, tasks that still
|
|
229
|
-
* hold it,
|
|
260
|
+
* hold it, schedules that fire tasks with it, and profiles that list it as a
|
|
261
|
+
* fallback.
|
|
230
262
|
*/
|
|
231
|
-
export async function modelProfileReferences(
|
|
232
|
-
|
|
233
|
-
|
|
263
|
+
export async function modelProfileReferences(name: string): Promise<{
|
|
264
|
+
agentIds: string[];
|
|
265
|
+
openTaskCount: number;
|
|
266
|
+
scheduleIds: string[];
|
|
267
|
+
fallbackOf: string[];
|
|
268
|
+
}> {
|
|
234
269
|
const agents = await getDbClient().query<{ scopeId: string }>(
|
|
235
270
|
"SELECT scopeId FROM swarm_config WHERE scope = 'agent' AND key = ? AND value = ?",
|
|
236
271
|
[MODEL_PROFILE_CONFIG_KEY, name],
|
|
@@ -244,10 +279,17 @@ export async function modelProfileReferences(
|
|
|
244
279
|
"SELECT id FROM scheduled_tasks WHERE profile = ? ORDER BY id",
|
|
245
280
|
[name],
|
|
246
281
|
);
|
|
282
|
+
const fallbackOf = await getDbClient().query<{ name: string }>(
|
|
283
|
+
`SELECT o.name FROM model_profiles o,
|
|
284
|
+
json_each(CASE WHEN json_valid(o.fallbacks) THEN o.fallbacks ELSE '[]' END) j
|
|
285
|
+
WHERE j.value = ? AND o.name <> ? ORDER BY o.name`,
|
|
286
|
+
[name, name],
|
|
287
|
+
);
|
|
247
288
|
return {
|
|
248
289
|
agentIds: agents.map((a) => a.scopeId),
|
|
249
290
|
openTaskCount: tasks?.n ?? 0,
|
|
250
291
|
scheduleIds: schedules.map((s) => s.id),
|
|
292
|
+
fallbackOf: [...new Set(fallbackOf.map((p) => p.name))],
|
|
251
293
|
};
|
|
252
294
|
}
|
|
253
295
|
|
|
@@ -264,7 +306,8 @@ export function modelProfileRefError(error: unknown): "missing" | null {
|
|
|
264
306
|
* Delete a profile unless a task still holds it (`TASK_HOLDS_PROFILE_SQL`) as
|
|
265
307
|
* its ask or as the profile claim applied (`resolvedProfile`, which a paused
|
|
266
308
|
* task's resume re-reads for its credential allowlist), an
|
|
267
|
-
* agent default names it,
|
|
309
|
+
* agent default names it, a schedule names it, or another profile lists it
|
|
310
|
+
* as a fallback. The check is part of the
|
|
268
311
|
* DELETE statement, so a reference written after the caller's own count still
|
|
269
312
|
* makes it `in-use`; the triggers in migrations 220 and 240 refuse the
|
|
270
313
|
* opposite order (a reference written after this delete).
|
|
@@ -282,6 +325,7 @@ export async function deleteModelProfile(name: string): Promise<"deleted" | "mis
|
|
|
282
325
|
WHERE scope = 'agent' AND key = ? AND trim(value) = model_profiles.name)
|
|
283
326
|
AND NOT EXISTS (
|
|
284
327
|
SELECT 1 FROM scheduled_tasks s WHERE s.profile = model_profiles.name)
|
|
328
|
+
AND NOT ${LISTED_AS_FALLBACK_SQL}
|
|
285
329
|
RETURNING id`,
|
|
286
330
|
[name, repairWindowStart(), MODEL_PROFILE_CONFIG_KEY],
|
|
287
331
|
);
|
|
@@ -289,6 +333,58 @@ export async function deleteModelProfile(name: string): Promise<"deleted" | "mis
|
|
|
289
333
|
return (await getModelProfileByName(name)) ? "in-use" : "missing";
|
|
290
334
|
}
|
|
291
335
|
|
|
336
|
+
/** Longest fallback list a profile may store. */
|
|
337
|
+
export const MAX_MODEL_PROFILE_FALLBACKS = 10;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Why `fallbacks` cannot be saved on profile `name` (on `harness`), or null.
|
|
341
|
+
* Every fallback must exist, run on the same harness (a hop resumes on the
|
|
342
|
+
* same agent), appear once, and not be the profile itself; and the stored
|
|
343
|
+
* fallback graph with this change must stay acyclic, so a hop chain always
|
|
344
|
+
* ends. Run it in the same transaction as the write.
|
|
345
|
+
*/
|
|
346
|
+
export async function modelProfileFallbacksError(
|
|
347
|
+
name: string,
|
|
348
|
+
harness: ProviderName,
|
|
349
|
+
fallbacks: string[],
|
|
350
|
+
): Promise<string | null> {
|
|
351
|
+
if (fallbacks.length > MAX_MODEL_PROFILE_FALLBACKS) {
|
|
352
|
+
return `A profile lists at most ${MAX_MODEL_PROFILE_FALLBACKS} fallbacks.`;
|
|
353
|
+
}
|
|
354
|
+
const seen = new Set<string>();
|
|
355
|
+
for (const fallback of fallbacks) {
|
|
356
|
+
if (fallback === name) return `"${name}" cannot list itself as a fallback.`;
|
|
357
|
+
if (seen.has(fallback)) return `Fallback "${fallback}" is listed twice.`;
|
|
358
|
+
seen.add(fallback);
|
|
359
|
+
}
|
|
360
|
+
if (fallbacks.length === 0) return null;
|
|
361
|
+
const rows = await getDbClient().query<{ name: string; harness: string; fallbacks: string }>(
|
|
362
|
+
"SELECT name, harness, fallbacks FROM model_profiles",
|
|
363
|
+
);
|
|
364
|
+
const graph = new Map(rows.map((row) => [row.name, parseFallbacks(row.fallbacks)]));
|
|
365
|
+
const harnessOf = new Map(rows.map((row) => [row.name, row.harness]));
|
|
366
|
+
for (const fallback of fallbacks) {
|
|
367
|
+
const other = harnessOf.get(fallback);
|
|
368
|
+
if (other === undefined) return `Unknown fallback profile "${fallback}".`;
|
|
369
|
+
if (other !== harness) {
|
|
370
|
+
return `Fallback "${fallback}" runs on ${other}, not ${harness}; a fallback resumes on the same agent.`;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
graph.set(name, fallbacks);
|
|
374
|
+
// DFS from `name`: reaching `name` again is a cycle through this change.
|
|
375
|
+
const stack = fallbacks.map((fallback) => [name, fallback]);
|
|
376
|
+
const visited = new Set<string>();
|
|
377
|
+
while (stack.length > 0) {
|
|
378
|
+
const path = stack.pop() as string[];
|
|
379
|
+
const node = path[path.length - 1] as string;
|
|
380
|
+
if (node === name) return `Fallbacks would form a cycle: ${path.join(" → ")}.`;
|
|
381
|
+
if (visited.has(node)) continue;
|
|
382
|
+
visited.add(node);
|
|
383
|
+
for (const next of graph.get(node) ?? []) stack.push([...path, next]);
|
|
384
|
+
}
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
|
|
292
388
|
/** The agent's default profile name (agent-scoped MODEL_PROFILE), or null. */
|
|
293
389
|
export async function getAgentDefaultProfileName(agentId: string): Promise<string | null> {
|
|
294
390
|
const row = await getDbClient().get<{ value: string }>(
|
|
@@ -347,7 +443,10 @@ export async function taskProfileError(check: {
|
|
|
347
443
|
return `Unknown model profile "${name}". List profiles with list-model-profiles.`;
|
|
348
444
|
}
|
|
349
445
|
if (!check.agentId) return null;
|
|
350
|
-
const result = await checkProfileForAgent(check.agentId, name, {
|
|
446
|
+
const result = await checkProfileForAgent(check.agentId, name, {
|
|
447
|
+
vcsRepo: check.vcsRepo,
|
|
448
|
+
fallbacks: false,
|
|
449
|
+
});
|
|
351
450
|
if (!result || result.ok) return null;
|
|
352
451
|
return formatProfileCheckFailures(result);
|
|
353
452
|
}
|
package/src/be/db/tasks/read.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
AgentTaskStatus,
|
|
7
7
|
AgentTaskSummary,
|
|
8
8
|
AgentTaskTimelineItem,
|
|
9
|
+
FallbackHop,
|
|
9
10
|
FollowUpConfig,
|
|
10
11
|
ProviderName,
|
|
11
12
|
ReasoningEffort,
|
|
@@ -14,6 +15,7 @@ import type {
|
|
|
14
15
|
RoutingSource,
|
|
15
16
|
} from "../../../types";
|
|
16
17
|
import {
|
|
18
|
+
FallbackHopSchema,
|
|
17
19
|
FollowUpConfigSchema,
|
|
18
20
|
parseModelTier,
|
|
19
21
|
ReasoningEffortSchema,
|
|
@@ -98,6 +100,7 @@ export type AgentTaskRow = {
|
|
|
98
100
|
modelAlias?: string | null;
|
|
99
101
|
profile?: string | null;
|
|
100
102
|
resolvedProfile?: string | null;
|
|
103
|
+
fallbackHops?: string | null;
|
|
101
104
|
scheduleId: string | null;
|
|
102
105
|
workflowRunId: string | null;
|
|
103
106
|
workflowRunStepId: string | null;
|
|
@@ -256,6 +259,22 @@ const LIST_COLUMNS = {
|
|
|
256
259
|
|
|
257
260
|
type TaskListFields = keyof typeof LIST_COLUMNS;
|
|
258
261
|
|
|
262
|
+
/** The stored hop list; entries that do not parse are dropped, none reads as unset. */
|
|
263
|
+
function parseFallbackHops(value: string | null | undefined): FallbackHop[] | undefined {
|
|
264
|
+
if (!value) return undefined;
|
|
265
|
+
try {
|
|
266
|
+
const parsed: unknown = JSON.parse(value);
|
|
267
|
+
if (!Array.isArray(parsed)) return undefined;
|
|
268
|
+
const hops = parsed.flatMap((entry) => {
|
|
269
|
+
const hop = FallbackHopSchema.safeParse(entry);
|
|
270
|
+
return hop.success ? [hop.data] : [];
|
|
271
|
+
});
|
|
272
|
+
return hops.length > 0 ? hops : undefined;
|
|
273
|
+
} catch {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
259
278
|
export function rowToAgentTask(row: AgentTaskRow): AgentTask {
|
|
260
279
|
let followUpConfig: FollowUpConfig | undefined;
|
|
261
280
|
if (row.followUpConfig) {
|
|
@@ -361,6 +380,7 @@ export function rowToAgentTask(row: AgentTaskRow): AgentTask {
|
|
|
361
380
|
: undefined,
|
|
362
381
|
profile: row.profile ?? undefined,
|
|
363
382
|
resolvedProfile: row.resolvedProfile ?? undefined,
|
|
383
|
+
fallbackHops: parseFallbackHops(row.fallbackHops),
|
|
364
384
|
scheduleId: row.scheduleId ?? undefined,
|
|
365
385
|
workflowRunId: row.workflowRunId ?? undefined,
|
|
366
386
|
workflowRunStepId: row.workflowRunStepId ?? undefined,
|