@legionworks/facet 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +23 -0
- package/README.md +158 -0
- package/dist/gallery/chunk-4g8rem85.css +656 -0
- package/dist/gallery/chunk-c6s9k9ty.js +5970 -0
- package/dist/gallery/frame/artifact.css +8424 -0
- package/dist/gallery/frame/chunks/abnfDiagram-N423BO3Z-jj74szbm.js +155 -0
- package/dist/gallery/frame/chunks/architecture-TIHT7OUA-cvdjn7dt.js +10 -0
- package/dist/gallery/frame/chunks/architectureDiagram-T3A2C74G-n4z77eg6.js +8675 -0
- package/dist/gallery/frame/chunks/blockDiagram-VBNYF7ZC-7xsqzrd1.js +3529 -0
- package/dist/gallery/frame/chunks/c4Diagram-5PPSVZJV-z2zjs7wx.js +2413 -0
- package/dist/gallery/frame/chunks/classDiagram-JCYQIIEL-ve8rngqp.js +47 -0
- package/dist/gallery/frame/chunks/classDiagram-v2-OCEON4UE-8cfaxb8z.js +47 -0
- package/dist/gallery/frame/chunks/cose-bilkent-JH36ORCC-sn92qexx.js +4822 -0
- package/dist/gallery/frame/chunks/cynefin-VYW2F7L2-tqjv913d.js +10 -0
- package/dist/gallery/frame/chunks/cynefinDiagram-MW4NZA55-c1c0dj12.js +500 -0
- package/dist/gallery/frame/chunks/dagre-VZM6K2ZE-7tyg4yt2.js +476 -0
- package/dist/gallery/frame/chunks/diagram-7IWD3JNH-y4eng9sc.js +526 -0
- package/dist/gallery/frame/chunks/diagram-B4RE2ZJO-rn3p7j5h.js +673 -0
- package/dist/gallery/frame/chunks/diagram-LBJQPF4R-w4a2cm9q.js +255 -0
- package/dist/gallery/frame/chunks/diagram-Q27KOJAE-aqc2v7wy.js +575 -0
- package/dist/gallery/frame/chunks/diagram-UB23O5K3-xncy8nyd.js +355 -0
- package/dist/gallery/frame/chunks/ebnfDiagram-BXEA7PRR-acwgxz16.js +175 -0
- package/dist/gallery/frame/chunks/erDiagram-JOGREHBK-mzp5nswt.js +1332 -0
- package/dist/gallery/frame/chunks/eventmodeling-45OFAUF4-sg07qr0c.js +10 -0
- package/dist/gallery/frame/chunks/flowDiagram-UKHOOZJN-2e5ygs44.js +29 -0
- package/dist/gallery/frame/chunks/ganttDiagram-PKOTCBZU-p2hhh7hr.js +2620 -0
- package/dist/gallery/frame/chunks/gitGraph-TEB2WS4Q-j6kw0naa.js +10 -0
- package/dist/gallery/frame/chunks/gitGraphDiagram-DS77QQ5N-4z9z8wjm.js +1347 -0
- package/dist/gallery/frame/chunks/info-DKCQHKI2-mpt80jd3.js +10 -0
- package/dist/gallery/frame/chunks/infoDiagram-6WML65LV-5rqm3mgg.js +65 -0
- package/dist/gallery/frame/chunks/ishikawaDiagram-WSZJBQD7-b51z96jy.js +975 -0
- package/dist/gallery/frame/chunks/journeyDiagram-NVQOT4AX-9jbfp0pk.js +1272 -0
- package/dist/gallery/frame/chunks/kanban-definition-27J2QSJJ-4x0vx4se.js +1116 -0
- package/dist/gallery/frame/chunks/katex-xfgk95tv.js +14034 -0
- package/dist/gallery/frame/chunks/markdown-1s5vwkf2.js +9 -0
- package/dist/gallery/frame/chunks/markdown-2h6bwsms.js +3239 -0
- package/dist/gallery/frame/chunks/markdown-2x113yh8.js +107 -0
- package/dist/gallery/frame/chunks/markdown-30b7rwmp.js +1943 -0
- package/dist/gallery/frame/chunks/markdown-356bfj4g.js +2031 -0
- package/dist/gallery/frame/chunks/markdown-44n9ea69.js +2406 -0
- package/dist/gallery/frame/chunks/markdown-56enrf2r.js +39 -0
- package/dist/gallery/frame/chunks/markdown-5avymm8t.js +725 -0
- package/dist/gallery/frame/chunks/markdown-6r4svars.js +33 -0
- package/dist/gallery/frame/chunks/markdown-6zz8efx2.js +24 -0
- package/dist/gallery/frame/chunks/markdown-7jp6prnb.js +19 -0
- package/dist/gallery/frame/chunks/markdown-809k7q41.js +55 -0
- package/dist/gallery/frame/chunks/markdown-82xmzhzd.js +1076 -0
- package/dist/gallery/frame/chunks/markdown-92n37gd4.js +7627 -0
- package/dist/gallery/frame/chunks/markdown-ag2sssf8.js +36 -0
- package/dist/gallery/frame/chunks/markdown-b4s7ntq2.js +19 -0
- package/dist/gallery/frame/chunks/markdown-c9k0fvp1.js +100 -0
- package/dist/gallery/frame/chunks/markdown-ceefymn8.js +125 -0
- package/dist/gallery/frame/chunks/markdown-d1wfbs70.js +243 -0
- package/dist/gallery/frame/chunks/markdown-dy5sgjhc.js +11022 -0
- package/dist/gallery/frame/chunks/markdown-dz3z5w30.js +30868 -0
- package/dist/gallery/frame/chunks/markdown-eg6ngz7y.js +30340 -0
- package/dist/gallery/frame/chunks/markdown-ff5wvb43.js +1149 -0
- package/dist/gallery/frame/chunks/markdown-ffg06nfz.js +86 -0
- package/dist/gallery/frame/chunks/markdown-fvfncadf.js +472 -0
- package/dist/gallery/frame/chunks/markdown-gvyszqpv.js +19 -0
- package/dist/gallery/frame/chunks/markdown-gx1p0ew0.js +88 -0
- package/dist/gallery/frame/chunks/markdown-gxye5frz.js +65 -0
- package/dist/gallery/frame/chunks/markdown-h7pzv34e.js +105 -0
- package/dist/gallery/frame/chunks/markdown-hab789t9.js +47 -0
- package/dist/gallery/frame/chunks/markdown-hjp6sj8t.js +125 -0
- package/dist/gallery/frame/chunks/markdown-jka64qgp.js +1993 -0
- package/dist/gallery/frame/chunks/markdown-k8xkn8mw.js +56 -0
- package/dist/gallery/frame/chunks/markdown-m7frq8x8.js +112 -0
- package/dist/gallery/frame/chunks/markdown-p740v4qm.js +36 -0
- package/dist/gallery/frame/chunks/markdown-pxfeh231.js +57 -0
- package/dist/gallery/frame/chunks/markdown-pzgd8z3s.js +87 -0
- package/dist/gallery/frame/chunks/markdown-qx3cngz2.js +1673 -0
- package/dist/gallery/frame/chunks/markdown-rawhfvvc.js +85 -0
- package/dist/gallery/frame/chunks/markdown-rd8w0ng9.js +49 -0
- package/dist/gallery/frame/chunks/markdown-rm2yxfjj.js +2773 -0
- package/dist/gallery/frame/chunks/markdown-s1jatrnk.js +993 -0
- package/dist/gallery/frame/chunks/markdown-sgfg5vvq.js +59 -0
- package/dist/gallery/frame/chunks/markdown-t4ethv9d.js +409 -0
- package/dist/gallery/frame/chunks/markdown-tnmabqvz.js +36 -0
- package/dist/gallery/frame/chunks/markdown-tvdpppw8.js +5292 -0
- package/dist/gallery/frame/chunks/markdown-v0x27twr.js +22 -0
- package/dist/gallery/frame/chunks/markdown-v14td68x.js +36 -0
- package/dist/gallery/frame/chunks/markdown-w6sgd54z.js +36 -0
- package/dist/gallery/frame/chunks/markdown-xw8dsk8b.js +2125 -0
- package/dist/gallery/frame/chunks/markdown-y18mve73.js +85 -0
- package/dist/gallery/frame/chunks/markdown-yengsms5.js +427 -0
- package/dist/gallery/frame/chunks/markdown-z1wc0v0d.js +1826 -0
- package/dist/gallery/frame/chunks/markdown-zazx9h4n.js +329 -0
- package/dist/gallery/frame/chunks/mermaid-de7p4v0x.js +30 -0
- package/dist/gallery/frame/chunks/mindmap-definition-FAOFIHXS-ra44cbem.js +1216 -0
- package/dist/gallery/frame/chunks/packet-7NZHBO7P-xppm5913.js +10 -0
- package/dist/gallery/frame/chunks/pegDiagram-VL7TDLO6-a2a4wg03.js +163 -0
- package/dist/gallery/frame/chunks/pie-RZYD4A2V-hnbxk152.js +10 -0
- package/dist/gallery/frame/chunks/pieDiagram-7S7Q4E2Y-f1vxjtmx.js +311 -0
- package/dist/gallery/frame/chunks/quadrantDiagram-CIZ2JOQS-ywafa6kh.js +1390 -0
- package/dist/gallery/frame/chunks/radar-I7S5WNFK-ewqd27se.js +10 -0
- package/dist/gallery/frame/chunks/railroad-3IZDKUUU-5hy4bdx3.js +10 -0
- package/dist/gallery/frame/chunks/railroad-abnf-AHOZXSZD-bh5sxz0d.js +10 -0
- package/dist/gallery/frame/chunks/railroad-ebnf-EBAXGLYW-6b9c3zeh.js +10 -0
- package/dist/gallery/frame/chunks/railroad-peg-LSFZ7HO6-avc8v39s.js +10 -0
- package/dist/gallery/frame/chunks/railroadDiagram-AXF67PYL-qc61wax4.js +131 -0
- package/dist/gallery/frame/chunks/requirementDiagram-LRYGKXZP-9bs4786c.js +1295 -0
- package/dist/gallery/frame/chunks/sankeyDiagram-W5VNT64P-awt1em8b.js +1339 -0
- package/dist/gallery/frame/chunks/sequenceDiagram-SI44F4Z6-qaf9mz3t.js +4324 -0
- package/dist/gallery/frame/chunks/sizeCapture-X5ZJPWSS-9fq685xd.js +64 -0
- package/dist/gallery/frame/chunks/stateDiagram-OKZ733FA-vx7a7hh0.js +456 -0
- package/dist/gallery/frame/chunks/stateDiagram-v2-UEYNNEHI-x4m6ws5t.js +46 -0
- package/dist/gallery/frame/chunks/swimlanes-SLNWSIFB-e4mxm1gh.js +8287 -0
- package/dist/gallery/frame/chunks/swimlanesDiagram-ULZ7WXOC-0h93e2qq.js +42 -0
- package/dist/gallery/frame/chunks/timeline-definition-Z64GVDOM-wp0bhbzg.js +1549 -0
- package/dist/gallery/frame/chunks/treeView-QDETBFTQ-hcx7n0vt.js +10 -0
- package/dist/gallery/frame/chunks/treemap-6X3UGDF4-av02skdw.js +10 -0
- package/dist/gallery/frame/chunks/vennDiagram-T6HMQDX7-pmvk1p7n.js +2566 -0
- package/dist/gallery/frame/chunks/wardley-OPB4EBWU-njsp6e40.js +10 -0
- package/dist/gallery/frame/chunks/wardleyDiagram-T6FBY63Y-eggmnv4z.js +979 -0
- package/dist/gallery/frame/chunks/xychartDiagram-ELKLHX3M-q40tnpe5.js +1954 -0
- package/dist/gallery/frame/frame.css +183 -0
- package/dist/gallery/frame/runtime/chart.js +42744 -0
- package/dist/gallery/frame/runtime/html.js +14 -0
- package/dist/gallery/frame/runtime/markdown.js +1403 -0
- package/dist/gallery/frame/runtime/mermaid.js +32 -0
- package/dist/gallery/frame/runtime/svg.js +14 -0
- package/dist/gallery/frame/runtime/tsx.js +52 -0
- package/dist/gallery/index.html +104 -0
- package/docs/reference/cli.md +163 -0
- package/docs/reference/export.md +106 -0
- package/docs/reference/html.md +215 -0
- package/docs/reference/http.md +85 -0
- package/docs/reference/mcp.md +78 -0
- package/docs/reference/security.md +119 -0
- package/docs/reference/storage.md +93 -0
- package/docs/reference/tsx.md +101 -0
- package/docs/reference/validation.md +212 -0
- package/package.json +89 -0
- package/scripts/build-gallery.ts +127 -0
- package/scripts/launch-netns.sh +67 -0
- package/skills/facet/SKILL.md +100 -0
- package/src/cli/client.ts +311 -0
- package/src/cli/commands/create.ts +49 -0
- package/src/cli/commands/doctor.ts +249 -0
- package/src/cli/commands/export.ts +179 -0
- package/src/cli/commands/instantiate.ts +35 -0
- package/src/cli/commands/list.ts +49 -0
- package/src/cli/commands/open.ts +75 -0
- package/src/cli/commands/pin.ts +39 -0
- package/src/cli/commands/promote.ts +49 -0
- package/src/cli/commands/publish.ts +122 -0
- package/src/cli/commands/read-back.ts +56 -0
- package/src/cli/commands/status.ts +114 -0
- package/src/cli/commands/watch.ts +146 -0
- package/src/cli/main.ts +522 -0
- package/src/cli/output.ts +106 -0
- package/src/cli/parser.ts +376 -0
- package/src/cli/presenter.ts +212 -0
- package/src/cli/service-metadata.ts +134 -0
- package/src/cli/spawn-service.ts +326 -0
- package/src/css.d.ts +4 -0
- package/src/gallery-web/app.ts +1581 -0
- package/src/gallery-web/export-menu.ts +121 -0
- package/src/gallery-web/export.ts +112 -0
- package/src/gallery-web/favicon.ts +54 -0
- package/src/gallery-web/frame/entries/chart.ts +6 -0
- package/src/gallery-web/frame/entries/html.ts +6 -0
- package/src/gallery-web/frame/entries/markdown.ts +6 -0
- package/src/gallery-web/frame/entries/mermaid.ts +6 -0
- package/src/gallery-web/frame/entries/svg.ts +6 -0
- package/src/gallery-web/frame/entries/tsx.ts +6 -0
- package/src/gallery-web/frame/frame-payload.ts +91 -0
- package/src/gallery-web/frame/renderer-validation.ts +13 -0
- package/src/gallery-web/frame/renderers/chart.ts +182 -0
- package/src/gallery-web/frame/renderers/dompurify-shim.ts +112 -0
- package/src/gallery-web/frame/renderers/html.ts +48 -0
- package/src/gallery-web/frame/renderers/markdown.ts +81 -0
- package/src/gallery-web/frame/renderers/mermaid.ts +120 -0
- package/src/gallery-web/frame/renderers/registry.ts +260 -0
- package/src/gallery-web/frame/renderers/svg.ts +393 -0
- package/src/gallery-web/frame/renderers/tsx.ts +61 -0
- package/src/gallery-web/frame/runtime.ts +501 -0
- package/src/gallery-web/frame/styles/artifact.css +8424 -0
- package/src/gallery-web/frame/styles/frame.css +183 -0
- package/src/gallery-web/frame/styles/html-source.css +23 -0
- package/src/gallery-web/frame/view-box.ts +33 -0
- package/src/gallery-web/frame-html.ts +72 -0
- package/src/gallery-web/index.html +104 -0
- package/src/gallery-web/session.ts +107 -0
- package/src/gallery-web/sse-client.ts +212 -0
- package/src/gallery-web/styles/app.css +420 -0
- package/src/gallery-web/styles/tokens.css +112 -0
- package/src/gallery-web/styles/verdict.css +186 -0
- package/src/gallery-web/swap.ts +64 -0
- package/src/gallery-web/theme.ts +40 -0
- package/src/gallery-web/view-state.ts +93 -0
- package/src/harness-adapters/claude-code/README.md +10 -0
- package/src/harness-adapters/claude-code/facet.sh +4 -0
- package/src/harness-adapters/codex/README.md +10 -0
- package/src/harness-adapters/codex/facet.sh +4 -0
- package/src/harness-adapters/mcp/README.md +13 -0
- package/src/harness-adapters/mcp/cli-bridge.ts +216 -0
- package/src/harness-adapters/mcp/main.ts +15 -0
- package/src/harness-adapters/mcp/server.ts +164 -0
- package/src/harness-adapters/mcp/tool-schemas.ts +53 -0
- package/src/harness-adapters/opencode/README.md +10 -0
- package/src/harness-adapters/opencode/facet.sh +4 -0
- package/src/runtime/compiled-entrypoints.ts +69 -0
- package/src/service/dispatcher.ts +717 -0
- package/src/service/export.ts +218 -0
- package/src/service/http-utils.ts +55 -0
- package/src/service/lexical/expectations.ts +210 -0
- package/src/service/lifecycle/idle-controller.ts +125 -0
- package/src/service/lifecycle/orphan-cleanup.ts +128 -0
- package/src/service/lifecycle/process-lock.ts +235 -0
- package/src/service/main.ts +136 -0
- package/src/service/process.ts +240 -0
- package/src/service/router-guards.ts +239 -0
- package/src/service/router.ts +627 -0
- package/src/service/security/auth.ts +168 -0
- package/src/service/security/host-origin.ts +138 -0
- package/src/service/security/http-guards.ts +13 -0
- package/src/service/security/leases.ts +182 -0
- package/src/service/security/token-store.ts +138 -0
- package/src/service/server.ts +356 -0
- package/src/service/store/database.ts +61 -0
- package/src/service/store/evidence-retention.ts +234 -0
- package/src/service/store/migrations.ts +167 -0
- package/src/service/store/repository-lifecycle.ts +121 -0
- package/src/service/store/repository.ts +732 -0
- package/src/service/store/schema.ts +218 -0
- package/src/service/stored-verdict.ts +97 -0
- package/src/service/stream.ts +301 -0
- package/src/service/verdict-enrichment.ts +45 -0
- package/src/shared/build/frame-bundle-plugins.ts +61 -0
- package/src/shared/build-mode.ts +28 -0
- package/src/shared/config/evidence-read.ts +98 -0
- package/src/shared/config/limits.ts +56 -0
- package/src/shared/config/paths.ts +96 -0
- package/src/shared/contracts/artifact-types.ts +2 -0
- package/src/shared/contracts/artifact.ts +98 -0
- package/src/shared/contracts/commands/_shared.ts +59 -0
- package/src/shared/contracts/commands/guards.ts +86 -0
- package/src/shared/contracts/commands/index.ts +204 -0
- package/src/shared/contracts/commands/names.ts +35 -0
- package/src/shared/contracts/commands/requests.ts +149 -0
- package/src/shared/contracts/commands/results.ts +200 -0
- package/src/shared/contracts/envelope.ts +140 -0
- package/src/shared/contracts/events.ts +41 -0
- package/src/shared/contracts/observed-counts.ts +19 -0
- package/src/shared/contracts/renderers.ts +6 -0
- package/src/shared/contracts/validation.ts +296 -0
- package/src/shared/errors/facet-error.ts +127 -0
- package/src/shared/errors/store-error.ts +68 -0
- package/src/shared/evidence-image.ts +37 -0
- package/src/shared/export.ts +31 -0
- package/src/shared/html/policy.ts +108 -0
- package/src/shared/html/style-vocabulary.ts +352 -0
- package/src/shared/logging/logger.ts +108 -0
- package/src/shared/logging/redact.ts +49 -0
- package/src/shared/security/frozen-csp.ts +13 -0
- package/src/shared/storage-version.ts +2 -0
- package/src/shared/tsx/execution.ts +29 -0
- package/src/shared/tsx/import-policy.ts +94 -0
- package/src/shared/util/dir-permissions.ts +94 -0
- package/src/shared/util/mermaid-nodes.ts +230 -0
- package/src/shared/util/process.ts +67 -0
- package/src/shared/util/time.ts +21 -0
- package/src/shared/version.ts +3 -0
- package/src/validation/sandbox/limits.ts +41 -0
- package/src/validation/sandbox/netns.ts +177 -0
- package/src/validation/tier0/chart.ts +177 -0
- package/src/validation/tier0/dom-shim.ts +54 -0
- package/src/validation/tier0/html.ts +408 -0
- package/src/validation/tier0/markdown.ts +285 -0
- package/src/validation/tier0/mermaid.ts +98 -0
- package/src/validation/tier0/runner.ts +504 -0
- package/src/validation/tier0/svg.ts +321 -0
- package/src/validation/tier0/tsx/allowlist-resolver.ts +77 -0
- package/src/validation/tier0/tsx/ast-policy-capabilities.ts +238 -0
- package/src/validation/tier0/tsx/ast-policy-shared.ts +71 -0
- package/src/validation/tier0/tsx/ast-policy.ts +181 -0
- package/src/validation/tier0/tsx/compiler.ts +156 -0
- package/src/validation/tier0/worker-dispatch.ts +211 -0
- package/src/validation/tier0/worker-entry.ts +96 -0
- package/src/validation/tier0/worker-input.ts +75 -0
- package/src/validation/tier1/browser-process.ts +147 -0
- package/src/validation/tier1/cdp-pipe.ts +281 -0
- package/src/validation/tier1/entries/chart.ts +5 -0
- package/src/validation/tier1/entries/html.ts +6 -0
- package/src/validation/tier1/entries/markdown.ts +5 -0
- package/src/validation/tier1/entries/mermaid.ts +5 -0
- package/src/validation/tier1/entries/svg.ts +5 -0
- package/src/validation/tier1/entries/tsx.ts +5 -0
- package/src/validation/tier1/frame-target.ts +162 -0
- package/src/validation/tier1/harness-entry.ts +261 -0
- package/src/validation/tier1/harness.ts +215 -0
- package/src/validation/tier1/isolated-probe.ts +94 -0
- package/src/validation/tier1/launcher.ts +177 -0
- package/src/validation/tier1/limits.ts +80 -0
- package/src/validation/tier1/nonce.ts +17 -0
- package/src/validation/tier1/protocol-probe.ts +519 -0
- package/src/validation/tier1/runner.ts +1122 -0
- package/src/validation/tier1/verdict.ts +246 -0
- package/src/validation/tier1/webp.ts +69 -0
- package/templates/README.md +88 -0
- package/templates/bar-compare.vl.json +63 -0
- package/templates/capacity-report.tsx +102 -0
- package/templates/decision-record.md +24 -0
- package/templates/deployment-state.mmd +40 -0
- package/templates/exemplar.md +91 -0
- package/templates/facet-story.tsx +799 -0
- package/templates/fleet-dashboard.html +141 -0
- package/templates/html-release-ledger.html +91 -0
- package/templates/html-status-report.html +114 -0
- package/templates/incident-console.tsx +147 -0
- package/templates/legion-boundaries.mmd +23 -0
- package/templates/legion-flow.mmd +15 -0
- package/templates/legion-sequence.mmd +14 -0
- package/templates/legion-state.mmd +7 -0
- package/templates/metric-card.svg +29 -0
- package/templates/observability-map.svg +101 -0
- package/templates/pipeline-audit.md +108 -0
- package/templates/release-metrics.vl.json +98 -0
- package/templates/service-topology.mmd +47 -0
- package/templates/status-report.md +32 -0
- package/templates/system-map.svg +53 -0
- package/templates/timeseries.vl.json +71 -0
- package/templates/tsx-interactive-counter.tsx +19 -0
- package/templates/tsx-status-report.tsx +31 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public command-verb surface. Per-verb request/result schemas live in
|
|
3
|
+
* `requests.ts` and `results.ts`; the discriminator unions that bind
|
|
4
|
+
* them into a single `CommandRequest` / `CommandResult` live here so a
|
|
5
|
+
* caller can `import { CommandRequestSchema, CommandResultSchema } from
|
|
6
|
+
* "../contracts/commands"` without knowing the internal split.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
|
|
11
|
+
import type { Artifact, Revision, Template } from "../artifact";
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
ArtifactEnvelopeSchema,
|
|
15
|
+
BaseRequestSchema,
|
|
16
|
+
BaseResultSchema,
|
|
17
|
+
ReadBackTierSchema,
|
|
18
|
+
RevisionEnvelopeSchema,
|
|
19
|
+
TemplateEnvelopeSchema,
|
|
20
|
+
normalizeReadBackTier,
|
|
21
|
+
type ArtifactEnvelope,
|
|
22
|
+
type ReadBackTier,
|
|
23
|
+
type RevisionEnvelope,
|
|
24
|
+
type TemplateEnvelope,
|
|
25
|
+
} from "./_shared";
|
|
26
|
+
import {
|
|
27
|
+
CommandNameSchema,
|
|
28
|
+
IMPLEMENTED_COMMANDS,
|
|
29
|
+
RESERVED_COMMANDS,
|
|
30
|
+
type CommandName,
|
|
31
|
+
} from "./names";
|
|
32
|
+
import {
|
|
33
|
+
CreateRequestSchema,
|
|
34
|
+
InstantiateRequestSchema,
|
|
35
|
+
ListRequestSchema,
|
|
36
|
+
OpenRequestSchema,
|
|
37
|
+
PinRequestSchema,
|
|
38
|
+
PromoteRequestSchema,
|
|
39
|
+
PublishArtifactTypeSchema,
|
|
40
|
+
PublishRequestSchema,
|
|
41
|
+
ReadBackRequestSchema,
|
|
42
|
+
ExportFormatSchema,
|
|
43
|
+
ExportRequestSchema,
|
|
44
|
+
StatusRequestSchema,
|
|
45
|
+
type CreateRequest,
|
|
46
|
+
type InstantiateRequest,
|
|
47
|
+
type ListRequest,
|
|
48
|
+
type OpenRequest,
|
|
49
|
+
type PinRequest,
|
|
50
|
+
type PromoteRequest,
|
|
51
|
+
type PublishRequest,
|
|
52
|
+
type ReadBackRequest,
|
|
53
|
+
type ExportFormat,
|
|
54
|
+
type ExportRequest,
|
|
55
|
+
type StatusRequest,
|
|
56
|
+
} from "./requests";
|
|
57
|
+
import {
|
|
58
|
+
CreateResultSchema,
|
|
59
|
+
InstantiateResultSchema,
|
|
60
|
+
ListResultSchema,
|
|
61
|
+
OpenResultSchema,
|
|
62
|
+
PinResultSchema,
|
|
63
|
+
PromoteResultSchema,
|
|
64
|
+
PublishResultSchema,
|
|
65
|
+
ReadBackResultSchema,
|
|
66
|
+
ExportSidecarSchema,
|
|
67
|
+
ExportResultSchema,
|
|
68
|
+
StatusResultSchema,
|
|
69
|
+
DoctorProbeNameSchema,
|
|
70
|
+
DoctorProbeResultSchema,
|
|
71
|
+
DoctorResultSchema,
|
|
72
|
+
type CreateResult,
|
|
73
|
+
type InstantiateResult,
|
|
74
|
+
type ListResult,
|
|
75
|
+
type OpenResult,
|
|
76
|
+
type PinResult,
|
|
77
|
+
type PromoteResult,
|
|
78
|
+
type PublishResult,
|
|
79
|
+
type ReadBackResult,
|
|
80
|
+
type ExportSidecar,
|
|
81
|
+
type ExportResult,
|
|
82
|
+
type StatusResult,
|
|
83
|
+
type DoctorResult,
|
|
84
|
+
} from "./results";
|
|
85
|
+
import {
|
|
86
|
+
checkArtifactTypeSupported,
|
|
87
|
+
checkCommandImplemented,
|
|
88
|
+
checkExecutionSupported,
|
|
89
|
+
checkRendererSupported,
|
|
90
|
+
} from "./guards";
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Discriminated union of every command request the protocol parses.
|
|
94
|
+
* `export` is included as an implemented command contract; its dispatcher
|
|
95
|
+
* arm is intentionally landed separately from this contract flip.
|
|
96
|
+
*/
|
|
97
|
+
export const CommandRequestSchema = z.discriminatedUnion("command", [
|
|
98
|
+
CreateRequestSchema,
|
|
99
|
+
PublishRequestSchema,
|
|
100
|
+
ListRequestSchema,
|
|
101
|
+
ReadBackRequestSchema,
|
|
102
|
+
StatusRequestSchema,
|
|
103
|
+
OpenRequestSchema,
|
|
104
|
+
PromoteRequestSchema,
|
|
105
|
+
InstantiateRequestSchema,
|
|
106
|
+
PinRequestSchema,
|
|
107
|
+
ExportRequestSchema,
|
|
108
|
+
]);
|
|
109
|
+
export type CommandRequest = z.infer<typeof CommandRequestSchema>;
|
|
110
|
+
|
|
111
|
+
export const CommandResultSchema = z.discriminatedUnion("command", [
|
|
112
|
+
CreateResultSchema,
|
|
113
|
+
PublishResultSchema,
|
|
114
|
+
ListResultSchema,
|
|
115
|
+
ReadBackResultSchema,
|
|
116
|
+
StatusResultSchema,
|
|
117
|
+
OpenResultSchema,
|
|
118
|
+
PromoteResultSchema,
|
|
119
|
+
InstantiateResultSchema,
|
|
120
|
+
PinResultSchema,
|
|
121
|
+
ExportResultSchema,
|
|
122
|
+
]);
|
|
123
|
+
export type CommandResult = z.infer<typeof CommandResultSchema>;
|
|
124
|
+
|
|
125
|
+
// Re-export Artifact/Revision/Template so callers can `import { Artifact, Revision, Template } from "..."/commands`.
|
|
126
|
+
export type { Artifact, Revision, Template };
|
|
127
|
+
export type { ArtifactEnvelope, RevisionEnvelope, TemplateEnvelope };
|
|
128
|
+
|
|
129
|
+
// Surface the full public API. Anything not re-exported here is internal.
|
|
130
|
+
export {
|
|
131
|
+
// shared primitives
|
|
132
|
+
ArtifactEnvelopeSchema,
|
|
133
|
+
BaseRequestSchema,
|
|
134
|
+
BaseResultSchema,
|
|
135
|
+
ReadBackTierSchema,
|
|
136
|
+
RevisionEnvelopeSchema,
|
|
137
|
+
TemplateEnvelopeSchema,
|
|
138
|
+
normalizeReadBackTier,
|
|
139
|
+
// names
|
|
140
|
+
CommandNameSchema,
|
|
141
|
+
IMPLEMENTED_COMMANDS,
|
|
142
|
+
RESERVED_COMMANDS,
|
|
143
|
+
// requests
|
|
144
|
+
CreateRequestSchema,
|
|
145
|
+
PublishRequestSchema,
|
|
146
|
+
PublishArtifactTypeSchema,
|
|
147
|
+
ListRequestSchema,
|
|
148
|
+
ReadBackRequestSchema,
|
|
149
|
+
StatusRequestSchema,
|
|
150
|
+
OpenRequestSchema,
|
|
151
|
+
PromoteRequestSchema,
|
|
152
|
+
InstantiateRequestSchema,
|
|
153
|
+
PinRequestSchema,
|
|
154
|
+
ExportFormatSchema,
|
|
155
|
+
ExportRequestSchema,
|
|
156
|
+
// results
|
|
157
|
+
CreateResultSchema,
|
|
158
|
+
PublishResultSchema,
|
|
159
|
+
ListResultSchema,
|
|
160
|
+
ReadBackResultSchema,
|
|
161
|
+
StatusResultSchema,
|
|
162
|
+
OpenResultSchema,
|
|
163
|
+
PromoteResultSchema,
|
|
164
|
+
InstantiateResultSchema,
|
|
165
|
+
PinResultSchema,
|
|
166
|
+
ExportResultSchema,
|
|
167
|
+
ExportSidecarSchema,
|
|
168
|
+
DoctorProbeNameSchema,
|
|
169
|
+
DoctorProbeResultSchema,
|
|
170
|
+
DoctorResultSchema,
|
|
171
|
+
// guards
|
|
172
|
+
checkCommandImplemented,
|
|
173
|
+
checkArtifactTypeSupported,
|
|
174
|
+
checkExecutionSupported,
|
|
175
|
+
checkRendererSupported,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export type { CommandName };
|
|
179
|
+
export type {
|
|
180
|
+
CreateRequest,
|
|
181
|
+
PublishRequest,
|
|
182
|
+
ListRequest,
|
|
183
|
+
ReadBackRequest,
|
|
184
|
+
StatusRequest,
|
|
185
|
+
OpenRequest,
|
|
186
|
+
PromoteRequest,
|
|
187
|
+
InstantiateRequest,
|
|
188
|
+
PinRequest,
|
|
189
|
+
ExportFormat,
|
|
190
|
+
ExportRequest,
|
|
191
|
+
CreateResult,
|
|
192
|
+
PublishResult,
|
|
193
|
+
ListResult,
|
|
194
|
+
ReadBackResult,
|
|
195
|
+
StatusResult,
|
|
196
|
+
DoctorResult,
|
|
197
|
+
OpenResult,
|
|
198
|
+
PromoteResult,
|
|
199
|
+
InstantiateResult,
|
|
200
|
+
PinResult,
|
|
201
|
+
ExportResult,
|
|
202
|
+
ExportSidecar,
|
|
203
|
+
ReadBackTier,
|
|
204
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Every command verb the protocol recognizes. `RESERVED_COMMANDS` is empty
|
|
5
|
+
* today; the reserved mechanism remains so a future verb can be described
|
|
6
|
+
* by the wire schema before its handler is shipped.
|
|
7
|
+
*/
|
|
8
|
+
export const CommandNameSchema = z.enum([
|
|
9
|
+
"create",
|
|
10
|
+
"publish",
|
|
11
|
+
"list",
|
|
12
|
+
"readBack",
|
|
13
|
+
"status",
|
|
14
|
+
"open",
|
|
15
|
+
"promote",
|
|
16
|
+
"instantiate",
|
|
17
|
+
"pin",
|
|
18
|
+
"export",
|
|
19
|
+
]);
|
|
20
|
+
export type CommandName = z.infer<typeof CommandNameSchema>;
|
|
21
|
+
|
|
22
|
+
export const IMPLEMENTED_COMMANDS: readonly CommandName[] = [
|
|
23
|
+
"create",
|
|
24
|
+
"publish",
|
|
25
|
+
"list",
|
|
26
|
+
"readBack",
|
|
27
|
+
"status",
|
|
28
|
+
"open",
|
|
29
|
+
"promote",
|
|
30
|
+
"instantiate",
|
|
31
|
+
"pin",
|
|
32
|
+
"export",
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
export const RESERVED_COMMANDS: readonly CommandName[] = [];
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
import { ArtifactTypeSchema, RendererSchema } from "../artifact";
|
|
4
|
+
import { TSX_EXECUTION_MODES } from "../../tsx/execution";
|
|
5
|
+
import { MAX_LIST_LIMIT } from "../../config/limits";
|
|
6
|
+
|
|
7
|
+
import { BaseRequestSchema, ReadBackTierSchema } from "./_shared";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Wire-encoded byte payload for publish. JSON cannot carry a Uint8Array
|
|
11
|
+
* directly; the v1 contract uses base64 (per D1 review) so a 5 MiB
|
|
12
|
+
* source fits in ~7 MiB of JSON. The schema validates base64 syntax;
|
|
13
|
+
* the dispatcher enforces SOURCE_CAP_BYTES on the decoded length and
|
|
14
|
+
* throws `payload_too_large` so the wire response is a typed 413
|
|
15
|
+
* rather than a schema-level 400.
|
|
16
|
+
*/
|
|
17
|
+
const BASE64_RE = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
18
|
+
|
|
19
|
+
export const PublishBytesSchema = z.string().superRefine((value, ctx) => {
|
|
20
|
+
if (value.length === 0) {
|
|
21
|
+
ctx.addIssue({
|
|
22
|
+
code: z.ZodIssueCode.custom,
|
|
23
|
+
message: "publish.bytes is empty",
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!BASE64_RE.test(value)) {
|
|
28
|
+
ctx.addIssue({
|
|
29
|
+
code: z.ZodIssueCode.custom,
|
|
30
|
+
message: "publish.bytes is not valid base64",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/** Publish accepts every implemented artifact type from the canonical contract. */
|
|
36
|
+
export const PublishArtifactTypeSchema = ArtifactTypeSchema;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* TSX execution mode. Derived from the canonical `TSX_EXECUTION_MODES`
|
|
40
|
+
* array so a typo or a new mode lands in one place. The publish
|
|
41
|
+
* request schema refines this with `artifactType` so a non-TSX request
|
|
42
|
+
* carrying `execution` is rejected with a typed `invalid_request`
|
|
43
|
+
* rather than silently coerced.
|
|
44
|
+
*/
|
|
45
|
+
export const TsxExecutionSchema = z.enum(TSX_EXECUTION_MODES);
|
|
46
|
+
|
|
47
|
+
export const CreateRequestSchema = BaseRequestSchema.extend({
|
|
48
|
+
command: z.literal("create"),
|
|
49
|
+
projectId: z.string().min(1),
|
|
50
|
+
slug: z.string().min(1),
|
|
51
|
+
title: z.string().min(1),
|
|
52
|
+
});
|
|
53
|
+
export type CreateRequest = z.infer<typeof CreateRequestSchema>;
|
|
54
|
+
|
|
55
|
+
export const PublishRequestSchema = BaseRequestSchema.extend({
|
|
56
|
+
command: z.literal("publish"),
|
|
57
|
+
artifactId: z.string().min(1),
|
|
58
|
+
artifactType: PublishArtifactTypeSchema,
|
|
59
|
+
renderer: RendererSchema.default("svg"),
|
|
60
|
+
bytes: PublishBytesSchema,
|
|
61
|
+
note: z.string().nullable().optional(),
|
|
62
|
+
parentRevisionId: z.string().min(1).nullable().optional(),
|
|
63
|
+
/**
|
|
64
|
+
* TSX execution mode (D2). Optional on the wire; defaults to
|
|
65
|
+
* `static` at the service layer when `artifactType === "tsx"`. A
|
|
66
|
+
* non-TSX artifact type carrying `execution` is rejected by the
|
|
67
|
+
* `checkExecutionSupported` guard called before storage — the same
|
|
68
|
+
* pattern `checkRendererSupported` uses for `renderer: "canvas"`
|
|
69
|
+
* on non-chart types. SuperRefine is intentionally NOT used here:
|
|
70
|
+
* Zod's discriminated `command` union requires direct ZodObject
|
|
71
|
+
* options, so cross-field validation belongs in a guard.
|
|
72
|
+
*/
|
|
73
|
+
execution: TsxExecutionSchema.optional(),
|
|
74
|
+
});
|
|
75
|
+
export type PublishRequest = z.infer<typeof PublishRequestSchema>;
|
|
76
|
+
|
|
77
|
+
export const ListRequestSchema = BaseRequestSchema.extend({
|
|
78
|
+
command: z.literal("list"),
|
|
79
|
+
projectId: z.string().min(1),
|
|
80
|
+
slugPrefix: z.string().optional(),
|
|
81
|
+
limit: z.number().int().positive().max(MAX_LIST_LIMIT).optional(),
|
|
82
|
+
});
|
|
83
|
+
export type ListRequest = z.infer<typeof ListRequestSchema>;
|
|
84
|
+
|
|
85
|
+
export const ReadBackRequestSchema = BaseRequestSchema.extend({
|
|
86
|
+
command: z.literal("readBack"),
|
|
87
|
+
artifactId: z.string().min(1),
|
|
88
|
+
revisionSha: z
|
|
89
|
+
.string()
|
|
90
|
+
.regex(/^[a-f0-9]{64}$/)
|
|
91
|
+
.optional(),
|
|
92
|
+
tier: ReadBackTierSchema,
|
|
93
|
+
});
|
|
94
|
+
export type ReadBackRequest = z.infer<typeof ReadBackRequestSchema>;
|
|
95
|
+
|
|
96
|
+
export const StatusRequestSchema = BaseRequestSchema.extend({
|
|
97
|
+
command: z.literal("status"),
|
|
98
|
+
artifactId: z.string().min(1).optional(),
|
|
99
|
+
});
|
|
100
|
+
export type StatusRequest = z.infer<typeof StatusRequestSchema>;
|
|
101
|
+
|
|
102
|
+
export const OpenRequestSchema = BaseRequestSchema.extend({
|
|
103
|
+
command: z.literal("open"),
|
|
104
|
+
artifactId: z.string().min(1),
|
|
105
|
+
revisionSha: z
|
|
106
|
+
.string()
|
|
107
|
+
.regex(/^[a-f0-9]{64}$/)
|
|
108
|
+
.optional(),
|
|
109
|
+
});
|
|
110
|
+
export type OpenRequest = z.infer<typeof OpenRequestSchema>;
|
|
111
|
+
|
|
112
|
+
export const PromoteRequestSchema = BaseRequestSchema.extend({
|
|
113
|
+
command: z.literal("promote"),
|
|
114
|
+
artifactId: z.string().min(1).optional(),
|
|
115
|
+
revisionId: z.string().min(1),
|
|
116
|
+
name: z.string().min(1),
|
|
117
|
+
description: z.string().nullable().optional(),
|
|
118
|
+
promotedBy: z.string().min(1),
|
|
119
|
+
});
|
|
120
|
+
export type PromoteRequest = z.infer<typeof PromoteRequestSchema>;
|
|
121
|
+
|
|
122
|
+
export const InstantiateRequestSchema = BaseRequestSchema.extend({
|
|
123
|
+
command: z.literal("instantiate"),
|
|
124
|
+
name: z.string().min(1),
|
|
125
|
+
newSlug: z.string().min(1),
|
|
126
|
+
projectId: z.string().min(1).optional(),
|
|
127
|
+
});
|
|
128
|
+
export type InstantiateRequest = z.infer<typeof InstantiateRequestSchema>;
|
|
129
|
+
|
|
130
|
+
export const PinRequestSchema = BaseRequestSchema.extend({
|
|
131
|
+
command: z.literal("pin"),
|
|
132
|
+
revisionId: z.string().min(1),
|
|
133
|
+
pinned: z.boolean(),
|
|
134
|
+
});
|
|
135
|
+
export type PinRequest = z.infer<typeof PinRequestSchema>;
|
|
136
|
+
|
|
137
|
+
export const ExportFormatSchema = z.enum(["source", "render"]);
|
|
138
|
+
export type ExportFormat = z.infer<typeof ExportFormatSchema>;
|
|
139
|
+
|
|
140
|
+
export const ExportRequestSchema = BaseRequestSchema.extend({
|
|
141
|
+
command: z.literal("export"),
|
|
142
|
+
artifactId: z.string().min(1),
|
|
143
|
+
revisionSha: z
|
|
144
|
+
.string()
|
|
145
|
+
.regex(/^[a-f0-9]{64}$/)
|
|
146
|
+
.optional(),
|
|
147
|
+
format: ExportFormatSchema.default("source"),
|
|
148
|
+
});
|
|
149
|
+
export type ExportRequest = z.infer<typeof ExportRequestSchema>;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
import { Tier1ResultSchema, VerdictSchema } from "../validation";
|
|
4
|
+
import { ArtifactTypeSchema, RendererSchema } from "../artifact";
|
|
5
|
+
import { EvidenceImageFormatSchema } from "../../evidence-image";
|
|
6
|
+
import { ExportFormatSchema } from "./requests";
|
|
7
|
+
|
|
8
|
+
export const DoctorProbeNameSchema = z.enum([
|
|
9
|
+
"bun",
|
|
10
|
+
"chrome-headless-shell",
|
|
11
|
+
"netns-userns",
|
|
12
|
+
"database",
|
|
13
|
+
"token-permissions",
|
|
14
|
+
"evidence-permissions",
|
|
15
|
+
"service-lock",
|
|
16
|
+
]);
|
|
17
|
+
export const DoctorProbeResultSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
name: DoctorProbeNameSchema,
|
|
20
|
+
status: z.enum(["pass", "fail"]),
|
|
21
|
+
summary: z.string(),
|
|
22
|
+
fixCommand: z.string().nullable(),
|
|
23
|
+
details: z.record(z.union([z.string(), z.number(), z.boolean(), z.null()])),
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
export const DoctorResultSchema = z
|
|
27
|
+
.object({
|
|
28
|
+
command: z.literal("doctor"),
|
|
29
|
+
allPassed: z.boolean(),
|
|
30
|
+
probes: z.array(DoctorProbeResultSchema),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
export type DoctorResult = z.infer<typeof DoctorResultSchema>;
|
|
34
|
+
|
|
35
|
+
import {
|
|
36
|
+
ArtifactEnvelopeSchema,
|
|
37
|
+
BaseResultSchema,
|
|
38
|
+
RevisionEnvelopeSchema,
|
|
39
|
+
TemplateEnvelopeSchema,
|
|
40
|
+
} from "./_shared";
|
|
41
|
+
|
|
42
|
+
export const CreateResultSchema = BaseResultSchema.extend({
|
|
43
|
+
command: z.literal("create"),
|
|
44
|
+
artifact: ArtifactEnvelopeSchema,
|
|
45
|
+
});
|
|
46
|
+
export type CreateResult = z.infer<typeof CreateResultSchema>;
|
|
47
|
+
|
|
48
|
+
export const PublishResultSchema = BaseResultSchema.extend({
|
|
49
|
+
command: z.literal("publish"),
|
|
50
|
+
revision: RevisionEnvelopeSchema,
|
|
51
|
+
verdict: VerdictSchema,
|
|
52
|
+
/**
|
|
53
|
+
* Deprecated compatibility field. Publish is browser-free; visual
|
|
54
|
+
* read-back owns Tier 1 verification.
|
|
55
|
+
*/
|
|
56
|
+
tier1Verdict: Tier1ResultSchema.nullable().optional(),
|
|
57
|
+
});
|
|
58
|
+
export type PublishResult = z.infer<typeof PublishResultSchema>;
|
|
59
|
+
|
|
60
|
+
export const ListResultSchema = BaseResultSchema.extend({
|
|
61
|
+
command: z.literal("list"),
|
|
62
|
+
artifacts: z.array(ArtifactEnvelopeSchema),
|
|
63
|
+
nextCursor: z.string().nullable().optional(),
|
|
64
|
+
});
|
|
65
|
+
export type ListResult = z.infer<typeof ListResultSchema>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Read-back result embeds the canonical `VerdictSchema` from
|
|
69
|
+
* `validation.ts`. The two definitions are the SAME object so a
|
|
70
|
+
* `toMatchObject({ verdict })` against a read-back response and a
|
|
71
|
+
* `toMatchObject(...)` against a Tier 1 run produce the same shape.
|
|
72
|
+
*/
|
|
73
|
+
export const ReadBackResultSchema = BaseResultSchema.extend({
|
|
74
|
+
command: z.literal("readBack"),
|
|
75
|
+
renderer: RendererSchema,
|
|
76
|
+
verdict: VerdictSchema,
|
|
77
|
+
});
|
|
78
|
+
export type ReadBackResult = z.infer<typeof ReadBackResultSchema>;
|
|
79
|
+
|
|
80
|
+
export const StatusResultSchema = BaseResultSchema.extend({
|
|
81
|
+
command: z.literal("status"),
|
|
82
|
+
artifactId: z.string().min(1).optional(),
|
|
83
|
+
latestRevisionSha: z
|
|
84
|
+
.string()
|
|
85
|
+
.regex(/^[a-f0-9]{64}$/)
|
|
86
|
+
.optional(),
|
|
87
|
+
revisionCount: z.number().int().nonnegative().optional(),
|
|
88
|
+
pinnedCount: z.number().int().nonnegative().optional(),
|
|
89
|
+
templateCount: z.number().int().nonnegative().optional(),
|
|
90
|
+
state: z.enum(["dormant", "active"]).optional(),
|
|
91
|
+
process: z
|
|
92
|
+
.object({
|
|
93
|
+
pid: z.number().int().positive(),
|
|
94
|
+
uptimeMs: z.number().nonnegative(),
|
|
95
|
+
rssBytes: z.number().nonnegative().nullable(),
|
|
96
|
+
pssBytes: z.number().nonnegative().nullable(),
|
|
97
|
+
})
|
|
98
|
+
.nullable()
|
|
99
|
+
.optional(),
|
|
100
|
+
dbBytes: z.number().int().nonnegative().optional(),
|
|
101
|
+
evidenceBytes: z.number().int().nonnegative().optional(),
|
|
102
|
+
activeLeases: z.number().int().nonnegative().optional(),
|
|
103
|
+
activeJobs: z.number().int().nonnegative().optional(),
|
|
104
|
+
browserJobs: z.number().int().nonnegative().optional(),
|
|
105
|
+
idleDeadline: z.number().int().positive().nullable().optional(),
|
|
106
|
+
version: z.string().min(1).optional(),
|
|
107
|
+
contractVersion: z.string().min(1).optional(),
|
|
108
|
+
});
|
|
109
|
+
export type StatusResult = z.infer<typeof StatusResultSchema>;
|
|
110
|
+
|
|
111
|
+
export const OpenResultSchema = BaseResultSchema.extend({
|
|
112
|
+
command: z.literal("open"),
|
|
113
|
+
artifactId: z.string().min(1),
|
|
114
|
+
revisionSha: z.string().regex(/^[a-f0-9]{64}$/),
|
|
115
|
+
frameUrl: z.string().min(1),
|
|
116
|
+
launched: z.boolean(),
|
|
117
|
+
/**
|
|
118
|
+
* Out-of-band lease capability for the SSE route. The lease id is
|
|
119
|
+
* never embedded in `frameUrl`; the client carries it via the
|
|
120
|
+
* `X-Gallery-Lease` header on the stream connect request.
|
|
121
|
+
*/
|
|
122
|
+
lease: z.object({
|
|
123
|
+
leaseId: z.string().min(1),
|
|
124
|
+
expiresAt: z.number().int().positive(),
|
|
125
|
+
}),
|
|
126
|
+
});
|
|
127
|
+
export type OpenResult = z.infer<typeof OpenResultSchema>;
|
|
128
|
+
|
|
129
|
+
export const PromoteResultSchema = BaseResultSchema.extend({
|
|
130
|
+
command: z.literal("promote"),
|
|
131
|
+
template: TemplateEnvelopeSchema,
|
|
132
|
+
});
|
|
133
|
+
export type PromoteResult = z.infer<typeof PromoteResultSchema>;
|
|
134
|
+
|
|
135
|
+
export const InstantiateResultSchema = BaseResultSchema.extend({
|
|
136
|
+
command: z.literal("instantiate"),
|
|
137
|
+
artifact: ArtifactEnvelopeSchema,
|
|
138
|
+
template: TemplateEnvelopeSchema,
|
|
139
|
+
});
|
|
140
|
+
export type InstantiateResult = z.infer<typeof InstantiateResultSchema>;
|
|
141
|
+
|
|
142
|
+
export const PinResultSchema = BaseResultSchema.extend({
|
|
143
|
+
command: z.literal("pin"),
|
|
144
|
+
revisionId: z.string().min(1),
|
|
145
|
+
pinned: z.boolean(),
|
|
146
|
+
});
|
|
147
|
+
export type PinResult = z.infer<typeof PinResultSchema>;
|
|
148
|
+
|
|
149
|
+
export const ExportSidecarSchema = z
|
|
150
|
+
.object({
|
|
151
|
+
artifactId: z.string().min(1),
|
|
152
|
+
slug: z.string().min(1),
|
|
153
|
+
revisionSha: z.string().regex(/^[a-f0-9]{64}$/),
|
|
154
|
+
artifactType: ArtifactTypeSchema,
|
|
155
|
+
renderer: RendererSchema,
|
|
156
|
+
verdict: VerdictSchema,
|
|
157
|
+
format: ExportFormatSchema,
|
|
158
|
+
renderFormat: EvidenceImageFormatSchema.optional(),
|
|
159
|
+
exportedAt: z.string().datetime({ offset: true }),
|
|
160
|
+
})
|
|
161
|
+
.superRefine((value, context) => {
|
|
162
|
+
if (value.format === "render" && value.renderFormat === undefined) {
|
|
163
|
+
context.addIssue({ code: "custom", message: "render exports require renderFormat" });
|
|
164
|
+
}
|
|
165
|
+
if (value.format === "source" && value.renderFormat !== undefined) {
|
|
166
|
+
context.addIssue({ code: "custom", message: "source exports must omit renderFormat" });
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
export type ExportSidecar = z.infer<typeof ExportSidecarSchema>;
|
|
170
|
+
|
|
171
|
+
function isBase64(value: string): boolean {
|
|
172
|
+
if (value.length % 4 !== 0) return false;
|
|
173
|
+
let paddingStart = value.length;
|
|
174
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
175
|
+
const code = value.charCodeAt(index);
|
|
176
|
+
const isUpper = code >= 65 && code <= 90;
|
|
177
|
+
const isLower = code >= 97 && code <= 122;
|
|
178
|
+
const isDigit = code >= 48 && code <= 57;
|
|
179
|
+
if (isUpper || isLower || isDigit || code === 43 || code === 47) continue;
|
|
180
|
+
if (code === 61) {
|
|
181
|
+
paddingStart = index;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
const padding = value.length - paddingStart;
|
|
187
|
+
if (padding > 2) return false;
|
|
188
|
+
for (let index = paddingStart; index < value.length; index += 1) {
|
|
189
|
+
if (value.charCodeAt(index) !== 61) return false;
|
|
190
|
+
}
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export const ExportResultSchema = BaseResultSchema.extend({
|
|
195
|
+
command: z.literal("export"),
|
|
196
|
+
format: ExportFormatSchema,
|
|
197
|
+
bytes: z.string().refine(isBase64, "Invalid base64"),
|
|
198
|
+
sidecar: ExportSidecarSchema,
|
|
199
|
+
});
|
|
200
|
+
export type ExportResult = z.infer<typeof ExportResultSchema>;
|