@zhivex-ai/harness 1.7.0 → 1.8.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/CHANGELOG.md +8 -2
- package/README.md +17 -5
- package/SECURITY.md +1 -1
- package/SUPPORT.md +2 -2
- package/benchmarks/README.md +26 -0
- package/contracts/engine-api.json +1557 -0
- package/contracts/public-api.json +114 -0
- package/contracts/stable-api-signatures.json +17 -17
- package/dist/acp-cli.js +37 -1090
- package/dist/application/agenda.d.ts +10 -0
- package/dist/application/approval-review.d.ts +61 -0
- package/dist/application/assistant/automation/scheduler.d.ts +21 -0
- package/dist/application/assistant/automation/summary.d.ts +29 -0
- package/dist/application/assistant/automation/time.d.ts +10 -0
- package/dist/application/assistant/calendar/calendar.d.ts +238 -0
- package/dist/application/assistant/calendar/connection.d.ts +50 -0
- package/dist/application/assistant/calendar/create-event.d.ts +75 -0
- package/dist/application/assistant/calendar/environment.d.ts +2 -0
- package/dist/application/assistant/calendar/http.d.ts +6 -0
- package/dist/application/assistant/calendar/oauth.d.ts +68 -0
- package/dist/application/assistant/calendar/store.d.ts +11 -0
- package/dist/application/assistant/calendar/tools.d.ts +78 -0
- package/dist/application/assistant/client.d.ts +10 -0
- package/dist/application/assistant/config.d.ts +9 -0
- package/dist/application/assistant/contracts.d.ts +77 -0
- package/dist/application/assistant/daily/service.d.ts +181 -0
- package/dist/application/assistant/doctor.d.ts +22 -0
- package/dist/application/assistant/evaluation.d.ts +81 -0
- package/dist/application/assistant/host.d.ts +399 -0
- package/dist/application/assistant/integrations/google.d.ts +117 -0
- package/dist/application/assistant/integrations/public-web.d.ts +16 -0
- package/dist/application/assistant/managed/secrets.d.ts +10 -0
- package/dist/application/assistant/managed/setup-state.d.ts +346 -0
- package/dist/application/assistant/managed/setup.d.ts +492 -0
- package/dist/application/assistant/microsoft/connection.d.ts +73 -0
- package/dist/application/assistant/microsoft/tools.d.ts +78 -0
- package/dist/application/assistant/modules/calendar.d.ts +3 -0
- package/dist/application/assistant/modules/catalog.d.ts +38 -0
- package/dist/application/assistant/modules/daily.d.ts +5 -0
- package/dist/application/assistant/modules/github.d.ts +5 -0
- package/dist/application/assistant/modules/google.d.ts +3 -0
- package/dist/application/assistant/modules/mcp.d.ts +11 -0
- package/dist/application/assistant/modules/microsoft.d.ts +3 -0
- package/dist/application/assistant/modules/module.d.ts +224 -0
- package/dist/application/assistant/modules/tools.d.ts +11 -0
- package/dist/application/assistant/modules/web.d.ts +7 -0
- package/dist/application/assistant/private-directory.d.ts +3 -0
- package/dist/application/assistant/proactive/service.d.ts +142 -0
- package/dist/application/assistant/providers/openai-compatible.d.ts +66 -0
- package/dist/application/assistant/providers/provider.d.ts +141 -0
- package/dist/application/assistant/providers/web-citations.d.ts +2 -0
- package/dist/application/assistant/runtime.d.ts +16 -0
- package/dist/application/assistant/task-metrics.d.ts +304 -0
- package/dist/application/assistant/telegram/api.d.ts +47 -0
- package/dist/application/assistant/telegram/bridge.d.ts +69 -0
- package/dist/application/assistant/telegram/store.d.ts +10 -0
- package/dist/application/automation.d.ts +5 -0
- package/dist/application/calendar-review.d.ts +5 -0
- package/dist/application/checkpoint-review.d.ts +30 -0
- package/dist/application/client.d.ts +18 -0
- package/dist/application/code/context.d.ts +5 -0
- package/dist/application/code/delivery.d.ts +6 -0
- package/dist/application/code/git-delivery.d.ts +54 -0
- package/dist/application/code/github-git-transport.d.ts +15 -0
- package/dist/application/code/github-pr-transport.d.ts +6 -0
- package/dist/application/code/host.d.ts +25 -0
- package/dist/application/code/pr-delivery.d.ts +79 -0
- package/dist/application/code/projects.d.ts +90 -0
- package/dist/application/code/remote-delivery.d.ts +80 -0
- package/dist/application/code/repository.d.ts +9 -0
- package/dist/application/code/worktrees.d.ts +123 -0
- package/dist/application/contracts.d.ts +288 -0
- package/dist/application/coordinator-client.d.ts +33 -0
- package/dist/application/coordinator-discovery.d.ts +17 -0
- package/dist/application/coordinator-launcher.d.ts +2 -0
- package/dist/application/coordinator.d.ts +27 -0
- package/dist/application/credential-process.d.ts +13 -0
- package/dist/application/host.d.ts +7 -0
- package/dist/application/management.d.ts +68 -0
- package/dist/application/notes.d.ts +5 -0
- package/dist/application/offline-migration.d.ts +16 -0
- package/dist/application/personal-state.d.ts +5 -0
- package/dist/application/review-channel.d.ts +23 -0
- package/dist/application/review-tickets.d.ts +29 -0
- package/dist/application/runtime-binding.d.ts +4 -0
- package/dist/application-cli-wfh08g41.js +184 -0
- package/dist/application-cli-z3f9pvcf.js +209 -0
- package/dist/approvals/auto-approve.d.ts +1 -1
- package/dist/arguments-75r85mvc.js +27 -0
- package/dist/arguments-x24bbqvd.js +22 -0
- package/dist/audit/index.js +16 -472
- package/dist/audit-pack-1gnych0m.js +93 -0
- package/dist/{audit-pack-y02n8zd0.js → audit-pack-h44kjkbj.js} +17 -11
- package/dist/calendar-2xw0rr7b.js +49 -0
- package/dist/cli/application-cli.d.ts +2 -0
- package/dist/cli/arguments.d.ts +14 -1
- package/dist/cli/auto-approve-setup.d.ts +13 -0
- package/dist/cli/configured-harness.d.ts +1 -2
- package/dist/cli/console/console-budget.d.ts +16 -2
- package/dist/cli/console/console-checkpoints.d.ts +12 -0
- package/dist/cli/console/console-commands.d.ts +3 -3
- package/dist/cli/console/console-compaction.d.ts +1 -1
- package/dist/cli/console/console-diff.d.ts +2 -0
- package/dist/cli/console/console-input.d.ts +29 -1
- package/dist/cli/console/console-navigation.d.ts +2 -2
- package/dist/cli/console/console-outcome.d.ts +10 -0
- package/dist/cli/console/console-presentation.d.ts +17 -2
- package/dist/cli/console/console-pricing.d.ts +14 -0
- package/dist/cli/console/console-reasoning.d.ts +1 -1
- package/dist/cli/console/console-recovery.d.ts +2 -0
- package/dist/cli/console/console-review.d.ts +34 -0
- package/dist/cli/console/console-run-policy.d.ts +5 -0
- package/dist/cli/console/console-run-view.d.ts +28 -0
- package/dist/cli/console/console-task.d.ts +30 -0
- package/dist/cli/console/console-welcome.d.ts +13 -3
- package/dist/cli/console/review-diff.d.ts +20 -0
- package/dist/cli/presentation.d.ts +8 -6
- package/dist/cli/service-checkpoints.d.ts +234 -0
- package/dist/cli/terminal/activity-history.d.ts +4 -2
- package/dist/cli/terminal/activity-stream.d.ts +33 -0
- package/dist/cli/terminal/file-diff.d.ts +11 -0
- package/dist/cli/terminal/terminal-theme.d.ts +9 -0
- package/dist/cli/terminal/terminal-ui.d.ts +44 -2
- package/dist/cli/terminal/tool-activity.d.ts +6 -2
- package/dist/{cli-entry-hdtfef27.js → cli-entry-68kqraj7.js} +95 -43
- package/dist/{cli-entry-j6jcb2jb.js → cli-entry-86rcbmwh.js} +294 -14
- package/dist/cli-entry-btkpb4h1.js +3627 -0
- package/dist/cli-entry-bxjbs6qq.js +200 -0
- package/dist/cli-entry-cpm89r9q.js +624 -0
- package/dist/{cli-entry-v5db3eb2.js → cli-entry-dksm56sj.js} +39 -297
- package/dist/{cli-entry-td04s0fa.js → cli-entry-eka68ttb.js} +3919 -4549
- package/dist/cli-entry-h7dcah4p.js +137 -0
- package/dist/cli-entry-kwk23ktq.js +33 -0
- package/dist/{cli-entry-ynahz9qc.js → cli-entry-vmce694z.js} +1251 -3139
- package/dist/cli-entry-wanv05db.js +1113 -0
- package/dist/{cli-zw18kdqx.js → cli-z7vhm1rk.js} +1767 -380
- package/dist/cli.js +8 -6
- package/dist/client/json-contracts.d.ts +153 -0
- package/dist/client/local-service.d.ts +7 -12
- package/dist/client/local-transport.d.ts +14 -0
- package/dist/client/protocol.d.ts +43 -1
- package/dist/compat/cli-options.d.ts +7 -1
- package/dist/compat/cli.d.ts +2 -0
- package/dist/compat/cli.js +4043 -0
- package/dist/compat/code-support.d.ts +3 -0
- package/dist/compat/code-support.js +50 -28
- package/dist/{config-r9fdhce6.js → config-hw78440t.js} +5 -5
- package/dist/{config-vyajmksy.js → config-v7s8hp37.js} +1 -1
- package/dist/context/adaptive-compaction.d.ts +1 -0
- package/dist/context/lossless-lines.d.ts +13 -0
- package/dist/context/numbered-read-lines.d.ts +15 -0
- package/dist/context/read-attempts.d.ts +21 -0
- package/dist/context/request-projection.d.ts +32 -4
- package/dist/context/scoped-context.d.ts +14 -0
- package/dist/context/working-read-replay.d.ts +12 -0
- package/dist/coordinator-client-nzysqxf0.js +10 -0
- package/dist/engine/acp.js +27 -21
- package/dist/engine/application-client.d.ts +11 -0
- package/dist/engine/application-client.js +18 -0
- package/dist/engine/application-protocol.d.ts +5 -0
- package/dist/engine/application-protocol.js +7 -0
- package/dist/engine/application.d.ts +43 -0
- package/dist/engine/application.js +206 -0
- package/dist/engine/assistant/automation/scheduler.d.ts +2 -0
- package/dist/engine/assistant/automation/scheduler.js +11 -0
- package/dist/engine/assistant/automation/summary.d.ts +3 -0
- package/dist/engine/assistant/automation/summary.js +8 -0
- package/dist/engine/assistant/automation/time.d.ts +5 -0
- package/dist/engine/assistant/automation/time.js +15 -0
- package/dist/engine/assistant/calendar/calendar.d.ts +5 -0
- package/dist/engine/assistant/calendar/calendar.js +12 -0
- package/dist/engine/assistant/calendar/connection.d.ts +2 -0
- package/dist/engine/assistant/calendar/connection.js +11 -0
- package/dist/engine/assistant/calendar/environment.d.ts +1 -0
- package/dist/engine/assistant/calendar/environment.js +7 -0
- package/dist/engine/assistant/calendar/http.d.ts +3 -0
- package/dist/engine/assistant/calendar/http.js +9 -0
- package/dist/engine/assistant/calendar/oauth.d.ts +5 -0
- package/dist/engine/assistant/calendar/oauth.js +12 -0
- package/dist/engine/assistant/calendar/store.d.ts +2 -0
- package/dist/engine/assistant/calendar/store.js +8 -0
- package/dist/engine/assistant/calendar/tools.d.ts +2 -0
- package/dist/engine/assistant/calendar/tools.js +46 -0
- package/dist/engine/assistant/client.d.ts +2 -0
- package/dist/engine/assistant/client.js +33 -0
- package/dist/engine/assistant/config.d.ts +1 -0
- package/dist/engine/assistant/config.js +102 -0
- package/dist/engine/assistant/contracts.d.ts +10 -0
- package/dist/engine/assistant/contracts.js +78 -0
- package/dist/engine/assistant/daily/service.d.ts +12 -0
- package/dist/engine/assistant/daily/service.js +27 -0
- package/dist/engine/assistant/doctor.d.ts +1 -0
- package/dist/engine/assistant/doctor.js +116 -0
- package/dist/engine/assistant/evaluation.d.ts +2 -0
- package/dist/engine/assistant/evaluation.js +76 -0
- package/dist/engine/assistant/host.d.ts +2 -0
- package/dist/engine/assistant/host.js +63 -0
- package/dist/engine/assistant/integrations/google.d.ts +9 -0
- package/dist/engine/assistant/integrations/google.js +30 -0
- package/dist/engine/assistant/integrations/public-web.d.ts +3 -0
- package/dist/engine/assistant/integrations/public-web.js +11 -0
- package/dist/engine/assistant/managed/secrets.d.ts +1 -0
- package/dist/engine/assistant/managed/secrets.js +0 -0
- package/dist/engine/assistant/managed/setup-state.d.ts +11 -0
- package/dist/engine/assistant/managed/setup-state.js +84 -0
- package/dist/engine/assistant/managed/setup.d.ts +3 -0
- package/dist/engine/assistant/managed/setup.js +85 -0
- package/dist/engine/assistant/microsoft/connection.d.ts +7 -0
- package/dist/engine/assistant/microsoft/connection.js +21 -0
- package/dist/engine/assistant/microsoft/tools.d.ts +8 -0
- package/dist/engine/assistant/microsoft/tools.js +30 -0
- package/dist/engine/assistant/modules/calendar.d.ts +1 -0
- package/dist/engine/assistant/modules/calendar.js +49 -0
- package/dist/engine/assistant/modules/catalog.d.ts +3 -0
- package/dist/engine/assistant/modules/catalog.js +67 -0
- package/dist/engine/assistant/modules/daily.d.ts +1 -0
- package/dist/engine/assistant/modules/daily.js +48 -0
- package/dist/engine/assistant/modules/github.d.ts +1 -0
- package/dist/engine/assistant/modules/github.js +43 -0
- package/dist/engine/assistant/modules/google.d.ts +1 -0
- package/dist/engine/assistant/modules/google.js +53 -0
- package/dist/engine/assistant/modules/mcp.d.ts +1 -0
- package/dist/engine/assistant/modules/mcp.js +42 -0
- package/dist/engine/assistant/modules/microsoft.d.ts +1 -0
- package/dist/engine/assistant/modules/microsoft.js +53 -0
- package/dist/engine/assistant/modules/module.d.ts +5 -0
- package/dist/engine/assistant/modules/module.js +42 -0
- package/dist/engine/assistant/modules/tools.d.ts +2 -0
- package/dist/engine/assistant/modules/tools.js +42 -0
- package/dist/engine/assistant/modules/web.d.ts +1 -0
- package/dist/engine/assistant/modules/web.js +45 -0
- package/dist/engine/assistant/private-directory.d.ts +1 -0
- package/dist/engine/assistant/private-directory.js +7 -0
- package/dist/engine/assistant/proactive/service.d.ts +6 -0
- package/dist/engine/assistant/proactive/service.js +16 -0
- package/dist/engine/assistant/providers/openai-compatible.d.ts +4 -0
- package/dist/engine/assistant/providers/openai-compatible.js +12 -0
- package/dist/engine/assistant/providers/provider.d.ts +7 -0
- package/dist/engine/assistant/providers/provider.js +54 -0
- package/dist/engine/assistant/providers/web-citations.d.ts +1 -0
- package/dist/engine/assistant/providers/web-citations.js +7 -0
- package/dist/engine/assistant/runtime.d.ts +2 -0
- package/dist/engine/assistant/runtime.js +73 -0
- package/dist/engine/assistant/task-metrics.d.ts +8 -0
- package/dist/engine/assistant/task-metrics.js +17 -0
- package/dist/engine/assistant/telegram/api.d.ts +5 -0
- package/dist/engine/assistant/telegram/api.js +11 -0
- package/dist/engine/assistant/telegram/bridge.d.ts +2 -0
- package/dist/engine/assistant/telegram/bridge.js +40 -0
- package/dist/engine/assistant/telegram/store.d.ts +2 -0
- package/dist/engine/assistant/telegram/store.js +8 -0
- package/dist/engine/client.js +26 -18
- package/dist/engine/desktop-providers-v1.js +4 -4
- package/dist/engine/desktop-state-v1.js +16 -13
- package/dist/engine/index.js +111 -159
- package/dist/engine/mcp-stdio-v1.js +13 -12
- package/dist/engine/models.js +65 -23
- package/dist/engine/protocol.js +10 -6
- package/dist/engine/service.js +32 -21
- package/dist/hostile-repository-demo.js +1822 -696
- package/dist/index-09rsdr2d.js +1744 -0
- package/dist/index-0csc5sc7.js +139 -0
- package/dist/{index-v86bh0eg.js → index-0dkty795.js} +8 -6
- package/dist/index-0kkgqvg7.js +0 -0
- package/dist/index-0mzz9axm.js +58 -0
- package/dist/index-1e69ar8r.js +38 -0
- package/dist/index-1z0xhkh9.js +18 -0
- package/dist/index-2cef1k92.js +356 -0
- package/dist/{index-k1a1xesg.js → index-2j0v1xwr.js} +17 -13
- package/dist/index-2jw9jd7h.js +116 -0
- package/dist/index-2n9qx4km.js +0 -0
- package/dist/index-3rvk23e8.js +877 -0
- package/dist/index-3wa4j0yk.js +71 -0
- package/dist/index-41q1k17x.js +210 -0
- package/dist/index-4vz4bqqw.js +33 -0
- package/dist/index-5jxm2wy5.js +123 -0
- package/dist/index-5rk6ss42.js +216 -0
- package/dist/index-5v1skxf7.js +1852 -0
- package/dist/{index-qz4fs9f9.js → index-6ehtssyz.js} +355 -332
- package/dist/index-76kpdbpw.js +80 -0
- package/dist/{index-r0q0r88h.js → index-7nbmhmw5.js} +10 -10
- package/dist/index-8mx0yrkz.js +31 -0
- package/dist/index-8tjev5ds.js +11 -0
- package/dist/index-91n5wr6s.js +163 -0
- package/dist/index-91trs3ew.js +151 -0
- package/dist/index-9y8p5vy5.js +222 -0
- package/dist/index-abxahprd.js +55 -0
- package/dist/index-aptyr511.js +84 -0
- package/dist/{index-8sm2a1wa.js → index-ay26xfxt.js} +28 -20
- package/dist/index-b4yed1s3.js +657 -0
- package/dist/index-bb7phvtg.js +23 -0
- package/dist/index-bk5tn9b8.js +236 -0
- package/dist/index-bw34861c.js +292 -0
- package/dist/index-c6fnjhgv.js +55 -0
- package/dist/{index-qfsrrnz6.js → index-cjevq9s8.js} +2 -2
- package/dist/{index-c39197wq.js → index-ctcwrkrc.js} +4 -4
- package/dist/{index-yx52bt4a.js → index-cztmcesv.js} +2 -2
- package/dist/index-dpbmxnrf.js +564 -0
- package/dist/index-ekxdcy36.js +134 -0
- package/dist/index-f8zpcsx3.js +289 -0
- package/dist/{index-6dxrbnxm.js → index-f970qtb4.js} +7 -143
- package/dist/index-fatcn6fp.js +2791 -0
- package/dist/index-fbzykqxy.js +105 -0
- package/dist/{index-1265j7t2.js → index-fwf274vc.js} +24 -14
- package/dist/index-fy4w0a7v.js +0 -0
- package/dist/index-gvva3e5x.js +76 -0
- package/dist/index-h7dcah4p.js +137 -0
- package/dist/index-hm9r120s.js +42 -0
- package/dist/index-j3d2tw97.js +328 -0
- package/dist/index-jfqj20x8.js +41 -0
- package/dist/{index-yp0jtaxp.js → index-k529a278.js} +6 -6
- package/dist/{index-bt2p8x7r.js → index-kbrf5bx7.js} +110 -106
- package/dist/index-kwk23ktq.js +33 -0
- package/dist/index-kz857p1j.js +557 -0
- package/dist/{index-tc2r2n8b.js → index-mkt5yrax.js} +31 -105
- package/dist/{index-tgt8gtq7.js → index-ndgnvjez.js} +18 -18
- package/dist/index-nemn4epv.js +43 -0
- package/dist/index-nkwy5bjr.js +1225 -0
- package/dist/index-nvvzr4ny.js +136 -0
- package/dist/index-pkspzsfs.js +78 -0
- package/dist/{index-fm84men1.js → index-px1tnqgt.js} +2 -2
- package/dist/index-q7qdw883.js +79 -0
- package/dist/{index-mzydbzp8.js → index-qvbg6tx1.js} +65 -23
- package/dist/index-r3mwr5fb.js +0 -0
- package/dist/index-rdr78m0k.js +91 -0
- package/dist/index-rtamqsfs.js +59 -0
- package/dist/index-s125ss45.js +38 -0
- package/dist/{index-h8r80xhk.js → index-sx1t6dnd.js} +4005 -2781
- package/dist/index-tar0ngkm.js +359 -0
- package/dist/index-tn58cr6w.js +471 -0
- package/dist/{index-v17e1xs8.js → index-v79s9bf9.js} +96 -23
- package/dist/index-vk3rq21m.js +17 -0
- package/dist/index-vmvnr28y.js +72 -0
- package/dist/index-vz629cg8.js +49 -0
- package/dist/{index-eps3c3g6.js → index-w292hdpz.js} +197 -960
- package/dist/{index-t6sjhxh8.js → index-w9eqg6p9.js} +24 -302
- package/dist/index-wj96kdw2.js +57 -0
- package/dist/index-wyck5yhd.js +141 -0
- package/dist/index-xvtk8pxs.js +674 -0
- package/dist/{index-bpc596v3.js → index-xwb691v9.js} +2 -2
- package/dist/index-ym69x168.js +518 -0
- package/dist/index-yprdjk9v.js +65 -0
- package/dist/index-z2a81ccr.js +35 -0
- package/dist/{index-3ah1f369.js → index-z69cqk74.js} +3 -3
- package/dist/index-zaakvmzq.js +62 -0
- package/dist/index-zk3m4mzg.js +232 -0
- package/dist/index-zx3wgvx4.js +218 -0
- package/dist/index.js +102 -83
- package/dist/persistence/migration-guard.d.ts +3 -0
- package/dist/runtime/harness.d.ts +2 -0
- package/dist/service-cli.js +130 -40
- package/dist/service-client-cli-2rzxy5mj.js +1166 -0
- package/dist/service-client-cli-5ne8q5ej.js +543 -0
- package/dist/tools/ooxml-zip.d.ts +21 -0
- package/dist/tools/presentations.d.ts +47 -0
- package/dist/tools/tabular-data.d.ts +114 -0
- package/dist/tools/workspace.d.ts +76 -0
- package/dist/verify-historical-migrations.js +1923 -797
- package/dist/workspace/workspace.d.ts +13 -1
- package/dist/zhx.js +8 -6
- package/docs/APPLICATION_MIGRATION.md +32 -0
- package/docs/CLI.md +166 -2
- package/docs/CODE_RELEASE.md +5 -3
- package/docs/CODE_WEB_TASKS.md +3 -114
- package/docs/CONTEXT_ENGINEERING.md +27 -0
- package/docs/ENGINE_API.md +1 -1
- package/docs/EXTENSIBILITY.md +1 -1
- package/docs/FIRST_USE.md +6 -6
- package/docs/INTERNAL_ARCHIVE.md +43 -0
- package/docs/LOCAL_SERVICE.md +1 -1
- package/docs/MODEL_CATALOG.md +14 -0
- package/docs/README.md +13 -2
- package/evaluations/representative-assembly-matrix.json +10 -1
- package/examples/README.md +3 -3
- package/examples/assistant/compatible-calendar.json +17 -0
- package/examples/assistant/composed-modules.json +23 -0
- package/examples/assistant/connected-tools.json +9 -0
- package/examples/assistant/daily-tools.json +6 -0
- package/examples/assistant/offline.mjs +24 -0
- package/fixtures/cli-compatibility/README.md +10 -0
- package/fixtures/cli-compatibility/inventory.json +7858 -0
- package/package.json +230 -28
- package/dist/cli/console/console-model-catalog.d.ts +0 -8
- package/dist/index-4gt045j0.js +0 -288
- package/dist/index-4jw3tvy8.js +0 -301
- package/dist/index-ebb5d4s3.js +0 -640
- package/dist/index-x9hv1a34.js +0 -274
- package/dist/service-client-cli-gtk26axb.js +0 -1251
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fileDigestSchema
|
|
3
|
+
} from "./cli-entry-vmce694z.js";
|
|
4
|
+
import {
|
|
5
|
+
providerStreamDiagnostic
|
|
6
|
+
} from "./cli-entry-68kqraj7.js";
|
|
7
|
+
|
|
8
|
+
// packages/core/src/client/stream.ts
|
|
9
|
+
var CLI_JSON_SCHEMA_VERSION = 1;
|
|
10
|
+
var CLI_EVENT_SCHEMA_VERSION = 1;
|
|
11
|
+
var streamEventDocument = (event, sequence = 0) => {
|
|
12
|
+
if (!Number.isSafeInteger(sequence) || sequence < 0) {
|
|
13
|
+
throw new Error("JSONL event sequence must be a non-negative integer.");
|
|
14
|
+
}
|
|
15
|
+
const base = {
|
|
16
|
+
schemaVersion: CLI_EVENT_SCHEMA_VERSION,
|
|
17
|
+
kind: "run-event",
|
|
18
|
+
sequence,
|
|
19
|
+
type: event.type
|
|
20
|
+
};
|
|
21
|
+
switch (event.type) {
|
|
22
|
+
case "text-delta":
|
|
23
|
+
return { ...base, textDelta: event.textDelta };
|
|
24
|
+
case "tool-call":
|
|
25
|
+
return { ...base, toolCallId: event.toolCall.id, toolName: event.toolCall.name };
|
|
26
|
+
case "tool-result":
|
|
27
|
+
return {
|
|
28
|
+
...base,
|
|
29
|
+
toolCallId: event.toolResult.toolCallId,
|
|
30
|
+
toolName: event.toolResult.toolName,
|
|
31
|
+
isError: event.toolResult.isError
|
|
32
|
+
};
|
|
33
|
+
case "tool-approval-request":
|
|
34
|
+
case "agent-approval-request":
|
|
35
|
+
return {
|
|
36
|
+
...base,
|
|
37
|
+
approvalRequestId: event.approval.id,
|
|
38
|
+
approvalKind: event.approval.kind ?? "provider",
|
|
39
|
+
toolName: event.approval.name
|
|
40
|
+
};
|
|
41
|
+
case "agent-approval-resolved":
|
|
42
|
+
return {
|
|
43
|
+
...base,
|
|
44
|
+
approvalRequestId: event.approval.approvalRequestId,
|
|
45
|
+
approved: event.approval.approve
|
|
46
|
+
};
|
|
47
|
+
case "provider-data":
|
|
48
|
+
return { ...base, provider: event.provider };
|
|
49
|
+
case "image-generation":
|
|
50
|
+
return {
|
|
51
|
+
...base,
|
|
52
|
+
provider: event.provider,
|
|
53
|
+
partial: event.partial,
|
|
54
|
+
...event.id ? { id: event.id } : {},
|
|
55
|
+
...event.index !== undefined ? { index: event.index } : {}
|
|
56
|
+
};
|
|
57
|
+
case "finish":
|
|
58
|
+
return {
|
|
59
|
+
...base,
|
|
60
|
+
...event.finishReason ? { finishReason: event.finishReason } : {},
|
|
61
|
+
...event.usage ? { usage: event.usage } : {}
|
|
62
|
+
};
|
|
63
|
+
case "error": {
|
|
64
|
+
const diagnostic = providerStreamDiagnostic(event.error);
|
|
65
|
+
return { ...base, error: "Provider stream failed.", ...diagnostic ? { providerDiagnostic: diagnostic } : {} };
|
|
66
|
+
}
|
|
67
|
+
case "agent-run-start":
|
|
68
|
+
return { ...base, currentStep: event.currentStep, maxSteps: event.maxSteps };
|
|
69
|
+
case "agent-step-start":
|
|
70
|
+
return { ...base, stepIndex: event.stepIndex };
|
|
71
|
+
case "agent-step-finish":
|
|
72
|
+
return {
|
|
73
|
+
...base,
|
|
74
|
+
stepIndex: event.step.index,
|
|
75
|
+
status: event.step.status,
|
|
76
|
+
toolCalls: event.step.toolResults.length
|
|
77
|
+
};
|
|
78
|
+
case "agent-compaction":
|
|
79
|
+
return {
|
|
80
|
+
...base,
|
|
81
|
+
compactionId: event.compaction.id,
|
|
82
|
+
reasons: event.compaction.reasons,
|
|
83
|
+
messageCountBefore: event.compaction.messageCountBefore,
|
|
84
|
+
messageCountAfter: event.compaction.messageCountAfter
|
|
85
|
+
};
|
|
86
|
+
case "agent-run-finish":
|
|
87
|
+
return {
|
|
88
|
+
...base,
|
|
89
|
+
runId: event.state.runId,
|
|
90
|
+
status: event.status,
|
|
91
|
+
provider: event.state.provider,
|
|
92
|
+
model: event.state.modelId
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var serializeStreamEvent = (event, sequence = 0) => JSON.stringify(streamEventDocument(event, sequence));
|
|
97
|
+
var streamResultDocument = (result, sequence = 0) => {
|
|
98
|
+
if (!Number.isSafeInteger(sequence) || sequence < 0) {
|
|
99
|
+
throw new Error("JSONL result sequence must be a non-negative integer.");
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
schemaVersion: CLI_EVENT_SCHEMA_VERSION,
|
|
103
|
+
kind: "run-stream-result",
|
|
104
|
+
sequence,
|
|
105
|
+
runId: result.runId,
|
|
106
|
+
status: result.status,
|
|
107
|
+
provider: result.provider,
|
|
108
|
+
model: result.model,
|
|
109
|
+
steps: result.steps,
|
|
110
|
+
toolCalls: result.toolCalls,
|
|
111
|
+
pendingApprovals: (result.pendingApprovals ?? []).map((approval) => ({
|
|
112
|
+
id: approval.id,
|
|
113
|
+
kind: approval.kind,
|
|
114
|
+
name: approval.name,
|
|
115
|
+
...approval.childRunId ? { childRunId: approval.childRunId } : {},
|
|
116
|
+
...approval.childAgentId ? { childAgentId: approval.childAgentId } : {}
|
|
117
|
+
})),
|
|
118
|
+
children: (result.children ?? []).map((child) => ({
|
|
119
|
+
runId: child.runId,
|
|
120
|
+
status: child.status
|
|
121
|
+
}))
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
var serializeStreamResult = (result, sequence = 0) => JSON.stringify(streamResultDocument(result, sequence));
|
|
125
|
+
|
|
126
|
+
// packages/core/src/workspace/change-envelope.ts
|
|
127
|
+
import { createHash } from "node:crypto";
|
|
128
|
+
import { z } from "zod";
|
|
129
|
+
var CHANGE_ENVELOPE_SCHEMA_VERSION = 1;
|
|
130
|
+
var CHANGE_ENVELOPE_DIGEST_ALGORITHM = "sha256";
|
|
131
|
+
var MAX_CHANGE_ENVELOPE_CHECKS = 100;
|
|
132
|
+
var MAX_CHANGE_ENVELOPE_APPROVALS = 100;
|
|
133
|
+
var MAX_CHANGE_ENVELOPE_APPROVAL_SCOPES = 32;
|
|
134
|
+
var MAX_CHANGE_ENVELOPE_ATTESTATIONS = 32;
|
|
135
|
+
var timestampSchema = z.iso.datetime({ precision: 3 });
|
|
136
|
+
var boundedIdentifierSchema = z.string().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:@/-]*$/, "Identifier must contain only bounded non-secret token characters.");
|
|
137
|
+
var approvalScopeSchema = z.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._:/*-]*$/, "Approval scope must contain only bounded token characters.");
|
|
138
|
+
var attestationFormatSchema = z.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9.+_-]*$/);
|
|
139
|
+
var mediaTypeSchema = z.string().min(3).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*\/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*$/);
|
|
140
|
+
var addDuplicateIssues = (values, key, context, path) => {
|
|
141
|
+
const seen = new Set;
|
|
142
|
+
for (let index = 0;index < values.length; index += 1) {
|
|
143
|
+
const value = values[index];
|
|
144
|
+
if (value === undefined)
|
|
145
|
+
continue;
|
|
146
|
+
const identifier = key(value);
|
|
147
|
+
if (seen.has(identifier)) {
|
|
148
|
+
context.addIssue({
|
|
149
|
+
code: "custom",
|
|
150
|
+
path: [index, path],
|
|
151
|
+
message: `Duplicate ${path}: ${identifier}.`
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
seen.add(identifier);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
var addCanonicalOrderIssue = (values, key, context, path) => {
|
|
158
|
+
for (let index = 1;index < values.length; index += 1) {
|
|
159
|
+
const previous = values[index - 1];
|
|
160
|
+
const current = values[index];
|
|
161
|
+
if (previous !== undefined && current !== undefined && key(previous) >= key(current)) {
|
|
162
|
+
context.addIssue({
|
|
163
|
+
code: "custom",
|
|
164
|
+
path: [index, path],
|
|
165
|
+
message: `${path} entries must be unique and in canonical ascending order.`
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
var approvalScopesInputSchema = z.array(approvalScopeSchema).min(1).max(MAX_CHANGE_ENVELOPE_APPROVAL_SCOPES).superRefine((scopes, context) => addDuplicateIssues(scopes, (scope) => scope, context, "scope"));
|
|
171
|
+
var canonicalApprovalScopesSchema = z.array(approvalScopeSchema).min(1).max(MAX_CHANGE_ENVELOPE_APPROVAL_SCOPES).superRefine((scopes, context) => addCanonicalOrderIssue(scopes, (scope) => scope, context, "scope"));
|
|
172
|
+
var changeEnvelopeCheckSchema = z.strictObject({
|
|
173
|
+
checkId: boundedIdentifierSchema,
|
|
174
|
+
status: z.enum(["passed", "failed", "skipped"]),
|
|
175
|
+
redacted: z.literal(true),
|
|
176
|
+
startedAt: timestampSchema,
|
|
177
|
+
completedAt: timestampSchema,
|
|
178
|
+
durationMs: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
179
|
+
exitCode: z.number().int().min(0).max(255).optional(),
|
|
180
|
+
redactedOutputDigest: fileDigestSchema.optional(),
|
|
181
|
+
runnerFingerprint: fileDigestSchema.optional()
|
|
182
|
+
}).superRefine((check, context) => {
|
|
183
|
+
const startedAt = Date.parse(check.startedAt);
|
|
184
|
+
const completedAt = Date.parse(check.completedAt);
|
|
185
|
+
if (completedAt < startedAt) {
|
|
186
|
+
context.addIssue({
|
|
187
|
+
code: "custom",
|
|
188
|
+
path: ["completedAt"],
|
|
189
|
+
message: "Check completion cannot precede its start."
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
if (check.status === "passed" && check.exitCode !== undefined && check.exitCode !== 0) {
|
|
193
|
+
context.addIssue({
|
|
194
|
+
code: "custom",
|
|
195
|
+
path: ["exitCode"],
|
|
196
|
+
message: "A passed check cannot have a non-zero exit code."
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
if (check.status === "failed" && check.exitCode === 0) {
|
|
200
|
+
context.addIssue({
|
|
201
|
+
code: "custom",
|
|
202
|
+
path: ["exitCode"],
|
|
203
|
+
message: "A failed check cannot have a zero exit code."
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (check.status === "skipped" && check.exitCode !== undefined) {
|
|
207
|
+
context.addIssue({
|
|
208
|
+
code: "custom",
|
|
209
|
+
path: ["exitCode"],
|
|
210
|
+
message: "A skipped check cannot have an exit code."
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
var checkInputListSchema = z.array(changeEnvelopeCheckSchema).min(1).max(MAX_CHANGE_ENVELOPE_CHECKS).superRefine((checks, context) => addDuplicateIssues(checks, (check) => check.checkId, context, "checkId"));
|
|
215
|
+
var canonicalCheckListSchema = z.array(changeEnvelopeCheckSchema).min(1).max(MAX_CHANGE_ENVELOPE_CHECKS).superRefine((checks, context) => addCanonicalOrderIssue(checks, (check) => check.checkId, context, "checkId"));
|
|
216
|
+
var changeEnvelopeApprovalSchema = z.strictObject({
|
|
217
|
+
kind: z.literal("approval-reference"),
|
|
218
|
+
approvalId: boundedIdentifierSchema,
|
|
219
|
+
approvalDigest: fileDigestSchema,
|
|
220
|
+
approverDigest: fileDigestSchema,
|
|
221
|
+
scopes: canonicalApprovalScopesSchema,
|
|
222
|
+
approvedAt: timestampSchema,
|
|
223
|
+
expiresAt: timestampSchema.optional()
|
|
224
|
+
}).superRefine((approval, context) => {
|
|
225
|
+
if (approval.expiresAt && Date.parse(approval.expiresAt) <= Date.parse(approval.approvedAt)) {
|
|
226
|
+
context.addIssue({
|
|
227
|
+
code: "custom",
|
|
228
|
+
path: ["expiresAt"],
|
|
229
|
+
message: "Approval expiry must be later than approval time."
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
var changeEnvelopeApprovalInputSchema = z.strictObject({
|
|
234
|
+
kind: z.literal("approval-reference"),
|
|
235
|
+
approvalId: boundedIdentifierSchema,
|
|
236
|
+
approvalDigest: fileDigestSchema,
|
|
237
|
+
approverDigest: fileDigestSchema,
|
|
238
|
+
scopes: approvalScopesInputSchema,
|
|
239
|
+
approvedAt: timestampSchema,
|
|
240
|
+
expiresAt: timestampSchema.optional()
|
|
241
|
+
}).superRefine((approval, context) => {
|
|
242
|
+
if (approval.expiresAt && Date.parse(approval.expiresAt) <= Date.parse(approval.approvedAt)) {
|
|
243
|
+
context.addIssue({
|
|
244
|
+
code: "custom",
|
|
245
|
+
path: ["expiresAt"],
|
|
246
|
+
message: "Approval expiry must be later than approval time."
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
var approvalInputListSchema = z.array(changeEnvelopeApprovalInputSchema).min(1).max(MAX_CHANGE_ENVELOPE_APPROVALS).superRefine((approvals, context) => addDuplicateIssues(approvals, (approval) => approval.approvalId, context, "approvalId"));
|
|
251
|
+
var canonicalApprovalListSchema = z.array(changeEnvelopeApprovalSchema).min(1).max(MAX_CHANGE_ENVELOPE_APPROVALS).superRefine((approvals, context) => addCanonicalOrderIssue(approvals, (approval) => approval.approvalId, context, "approvalId"));
|
|
252
|
+
var externalAttestationReferenceSchema = z.strictObject({
|
|
253
|
+
kind: z.literal("external-attestation-reference"),
|
|
254
|
+
attestationId: boundedIdentifierSchema,
|
|
255
|
+
format: attestationFormatSchema,
|
|
256
|
+
mediaType: mediaTypeSchema,
|
|
257
|
+
bundleDigest: fileDigestSchema
|
|
258
|
+
});
|
|
259
|
+
var externalAttestationInputListSchema = z.array(externalAttestationReferenceSchema).min(1).max(MAX_CHANGE_ENVELOPE_ATTESTATIONS).superRefine((attestations, context) => addDuplicateIssues(attestations, (attestation) => attestation.attestationId, context, "attestationId"));
|
|
260
|
+
var canonicalExternalAttestationListSchema = z.array(externalAttestationReferenceSchema).min(1).max(MAX_CHANGE_ENVELOPE_ATTESTATIONS).superRefine((attestations, context) => addCanonicalOrderIssue(attestations, (attestation) => attestation.attestationId, context, "attestationId"));
|
|
261
|
+
var changeEnvelopeBaseSchema = z.strictObject({
|
|
262
|
+
workspaceDigest: fileDigestSchema,
|
|
263
|
+
treeDigest: fileDigestSchema
|
|
264
|
+
});
|
|
265
|
+
var changeEnvelopePatchSchema = z.strictObject({
|
|
266
|
+
patchId: boundedIdentifierSchema,
|
|
267
|
+
patchDigest: fileDigestSchema
|
|
268
|
+
});
|
|
269
|
+
var changeEnvelopeFingerprintsSchema = z.strictObject({
|
|
270
|
+
harness: fileDigestSchema,
|
|
271
|
+
policy: fileDigestSchema,
|
|
272
|
+
environment: fileDigestSchema
|
|
273
|
+
});
|
|
274
|
+
var changeEnvelopeEvidenceSchema = z.strictObject({
|
|
275
|
+
schemaVersion: z.literal(CHANGE_ENVELOPE_SCHEMA_VERSION),
|
|
276
|
+
kind: z.literal("check-evidence-summary"),
|
|
277
|
+
digestAlgorithm: z.literal(CHANGE_ENVELOPE_DIGEST_ALGORITHM),
|
|
278
|
+
evidenceDigest: fileDigestSchema,
|
|
279
|
+
checks: canonicalCheckListSchema
|
|
280
|
+
});
|
|
281
|
+
var changeEnvelopeInputSchema = z.strictObject({
|
|
282
|
+
createdAt: timestampSchema,
|
|
283
|
+
expiresAt: timestampSchema.optional(),
|
|
284
|
+
base: changeEnvelopeBaseSchema,
|
|
285
|
+
patch: changeEnvelopePatchSchema,
|
|
286
|
+
fingerprints: changeEnvelopeFingerprintsSchema,
|
|
287
|
+
checks: checkInputListSchema,
|
|
288
|
+
approvals: approvalInputListSchema.optional(),
|
|
289
|
+
externalAttestations: externalAttestationInputListSchema.optional()
|
|
290
|
+
});
|
|
291
|
+
var changeEnvelopeSchema = z.strictObject({
|
|
292
|
+
schemaVersion: z.literal(CHANGE_ENVELOPE_SCHEMA_VERSION),
|
|
293
|
+
kind: z.literal("change-envelope"),
|
|
294
|
+
digestAlgorithm: z.literal(CHANGE_ENVELOPE_DIGEST_ALGORITHM),
|
|
295
|
+
envelopeId: fileDigestSchema,
|
|
296
|
+
createdAt: timestampSchema,
|
|
297
|
+
expiresAt: timestampSchema.optional(),
|
|
298
|
+
base: changeEnvelopeBaseSchema,
|
|
299
|
+
patch: changeEnvelopePatchSchema,
|
|
300
|
+
fingerprints: changeEnvelopeFingerprintsSchema,
|
|
301
|
+
evidence: changeEnvelopeEvidenceSchema,
|
|
302
|
+
approvals: canonicalApprovalListSchema.optional(),
|
|
303
|
+
externalAttestations: canonicalExternalAttestationListSchema.optional()
|
|
304
|
+
}).superRefine((envelope, context) => {
|
|
305
|
+
if (envelope.expiresAt && Date.parse(envelope.expiresAt) <= Date.parse(envelope.createdAt)) {
|
|
306
|
+
context.addIssue({
|
|
307
|
+
code: "custom",
|
|
308
|
+
path: ["expiresAt"],
|
|
309
|
+
message: "Envelope expiry must be later than creation time."
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
for (let index = 0;index < envelope.evidence.checks.length; index += 1) {
|
|
313
|
+
const check = envelope.evidence.checks[index];
|
|
314
|
+
if (check && Date.parse(check.completedAt) > Date.parse(envelope.createdAt)) {
|
|
315
|
+
context.addIssue({
|
|
316
|
+
code: "custom",
|
|
317
|
+
path: ["evidence", "checks", index, "completedAt"],
|
|
318
|
+
message: "Check completion cannot be later than envelope creation time."
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
for (let index = 0;index < (envelope.approvals?.length ?? 0); index += 1) {
|
|
323
|
+
const approval = envelope.approvals?.[index];
|
|
324
|
+
if (approval && Date.parse(approval.approvedAt) > Date.parse(envelope.createdAt)) {
|
|
325
|
+
context.addIssue({
|
|
326
|
+
code: "custom",
|
|
327
|
+
path: ["approvals", index, "approvedAt"],
|
|
328
|
+
message: "Approval time cannot be later than envelope creation time."
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
var canonicalJson = (value) => {
|
|
334
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
335
|
+
return JSON.stringify(value);
|
|
336
|
+
}
|
|
337
|
+
if (typeof value === "number") {
|
|
338
|
+
if (!Number.isFinite(value))
|
|
339
|
+
throw new TypeError("Canonical JSON cannot encode a non-finite number.");
|
|
340
|
+
return JSON.stringify(Object.is(value, -0) ? 0 : value);
|
|
341
|
+
}
|
|
342
|
+
if (Array.isArray(value)) {
|
|
343
|
+
return `[${value.map((entry) => canonicalJson(entry)).join(",")}]`;
|
|
344
|
+
}
|
|
345
|
+
if (typeof value === "object") {
|
|
346
|
+
const record = value;
|
|
347
|
+
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`).join(",")}}`;
|
|
348
|
+
}
|
|
349
|
+
throw new TypeError(`Canonical JSON cannot encode ${typeof value}.`);
|
|
350
|
+
};
|
|
351
|
+
var digestCanonical = (value) => `sha256:${createHash("sha256").update(canonicalJson(value)).digest("hex")}`;
|
|
352
|
+
var digestChangeEnvelopeArtifact = (value) => `sha256:${createHash("sha256").update(value).digest("hex")}`;
|
|
353
|
+
var evidencePayload = (checks) => ({
|
|
354
|
+
schemaVersion: CHANGE_ENVELOPE_SCHEMA_VERSION,
|
|
355
|
+
kind: "check-evidence-summary",
|
|
356
|
+
digestAlgorithm: CHANGE_ENVELOPE_DIGEST_ALGORITHM,
|
|
357
|
+
checks: [...checks]
|
|
358
|
+
});
|
|
359
|
+
var envelopePayload = (envelope) => {
|
|
360
|
+
const { envelopeId: _envelopeId, ...payload } = envelope;
|
|
361
|
+
return payload;
|
|
362
|
+
};
|
|
363
|
+
var sortBy = (values, key) => [...values].sort((left, right) => {
|
|
364
|
+
const leftKey = key(left);
|
|
365
|
+
const rightKey = key(right);
|
|
366
|
+
return leftKey < rightKey ? -1 : leftKey > rightKey ? 1 : 0;
|
|
367
|
+
});
|
|
368
|
+
var createChangeEnvelope = (input) => {
|
|
369
|
+
const parsed = changeEnvelopeInputSchema.parse(input);
|
|
370
|
+
const checks = sortBy(parsed.checks, (check) => check.checkId);
|
|
371
|
+
const evidenceWithoutDigest = evidencePayload(checks);
|
|
372
|
+
const evidence = {
|
|
373
|
+
...evidenceWithoutDigest,
|
|
374
|
+
evidenceDigest: digestCanonical(evidenceWithoutDigest)
|
|
375
|
+
};
|
|
376
|
+
const approvals = parsed.approvals ? sortBy(parsed.approvals, (approval) => approval.approvalId).map((approval) => ({
|
|
377
|
+
...approval,
|
|
378
|
+
scopes: [...approval.scopes].sort()
|
|
379
|
+
})) : undefined;
|
|
380
|
+
const externalAttestations = parsed.externalAttestations ? sortBy(parsed.externalAttestations, (attestation) => attestation.attestationId) : undefined;
|
|
381
|
+
const payload = {
|
|
382
|
+
schemaVersion: CHANGE_ENVELOPE_SCHEMA_VERSION,
|
|
383
|
+
kind: "change-envelope",
|
|
384
|
+
digestAlgorithm: CHANGE_ENVELOPE_DIGEST_ALGORITHM,
|
|
385
|
+
createdAt: parsed.createdAt,
|
|
386
|
+
...parsed.expiresAt ? { expiresAt: parsed.expiresAt } : {},
|
|
387
|
+
base: parsed.base,
|
|
388
|
+
patch: parsed.patch,
|
|
389
|
+
fingerprints: parsed.fingerprints,
|
|
390
|
+
evidence,
|
|
391
|
+
...approvals ? { approvals } : {},
|
|
392
|
+
...externalAttestations ? { externalAttestations } : {}
|
|
393
|
+
};
|
|
394
|
+
return changeEnvelopeSchema.parse({
|
|
395
|
+
...payload,
|
|
396
|
+
envelopeId: digestCanonical(payload)
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
var canonicalizeChangeEnvelope = (input) => canonicalJson(changeEnvelopeSchema.parse(input));
|
|
400
|
+
var changeEnvelopePreconditionsSchema = z.strictObject({
|
|
401
|
+
envelopeId: fileDigestSchema.optional(),
|
|
402
|
+
baseWorkspaceDigest: fileDigestSchema.optional(),
|
|
403
|
+
baseTreeDigest: fileDigestSchema.optional(),
|
|
404
|
+
patchId: boundedIdentifierSchema.optional(),
|
|
405
|
+
patchDigest: fileDigestSchema.optional(),
|
|
406
|
+
harnessFingerprint: fileDigestSchema.optional(),
|
|
407
|
+
policyFingerprint: fileDigestSchema.optional(),
|
|
408
|
+
environmentFingerprint: fileDigestSchema.optional(),
|
|
409
|
+
evidenceDigest: fileDigestSchema.optional(),
|
|
410
|
+
requiredPassedChecks: z.array(boundedIdentifierSchema).max(MAX_CHANGE_ENVELOPE_CHECKS).optional(),
|
|
411
|
+
requiredApprovalDigests: z.array(fileDigestSchema).max(MAX_CHANGE_ENVELOPE_APPROVALS).optional(),
|
|
412
|
+
requiredApprovalScopes: z.array(approvalScopeSchema).max(MAX_CHANGE_ENVELOPE_APPROVAL_SCOPES).optional(),
|
|
413
|
+
requiredAttestationDigests: z.array(fileDigestSchema).max(MAX_CHANGE_ENVELOPE_ATTESTATIONS).optional()
|
|
414
|
+
}).superRefine((preconditions, context) => {
|
|
415
|
+
if (preconditions.requiredPassedChecks) {
|
|
416
|
+
addDuplicateIssues(preconditions.requiredPassedChecks, (checkId) => checkId, context, "requiredPassedCheck");
|
|
417
|
+
}
|
|
418
|
+
if (preconditions.requiredApprovalDigests) {
|
|
419
|
+
addDuplicateIssues(preconditions.requiredApprovalDigests, (digest) => digest, context, "requiredApprovalDigest");
|
|
420
|
+
}
|
|
421
|
+
if (preconditions.requiredApprovalScopes) {
|
|
422
|
+
addDuplicateIssues(preconditions.requiredApprovalScopes, (scope) => scope, context, "requiredApprovalScope");
|
|
423
|
+
}
|
|
424
|
+
if (preconditions.requiredAttestationDigests) {
|
|
425
|
+
addDuplicateIssues(preconditions.requiredAttestationDigests, (digest) => digest, context, "requiredAttestationDigest");
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
var verificationOptionsSchema = z.strictObject({
|
|
429
|
+
now: z.union([z.date(), z.number().int(), timestampSchema]).optional(),
|
|
430
|
+
preconditions: changeEnvelopePreconditionsSchema.optional()
|
|
431
|
+
});
|
|
432
|
+
var verificationTime = (value) => {
|
|
433
|
+
const date = value === undefined ? new Date : value instanceof Date ? value : new Date(value);
|
|
434
|
+
if (!Number.isFinite(date.getTime()))
|
|
435
|
+
throw new TypeError("Verification time must be a valid date.");
|
|
436
|
+
return date;
|
|
437
|
+
};
|
|
438
|
+
var verifyChangeEnvelope = (input, options = {}) => {
|
|
439
|
+
const parsedOptions = verificationOptionsSchema.parse(options);
|
|
440
|
+
const now = verificationTime(parsedOptions.now);
|
|
441
|
+
const checkedAt = now.toISOString();
|
|
442
|
+
const parsedEnvelope = changeEnvelopeSchema.safeParse(input);
|
|
443
|
+
if (!parsedEnvelope.success) {
|
|
444
|
+
return {
|
|
445
|
+
valid: false,
|
|
446
|
+
verificationScope: "integrity-expiration-and-preconditions-only",
|
|
447
|
+
issues: parsedEnvelope.error.issues.map((issue) => ({
|
|
448
|
+
code: "invalid-schema",
|
|
449
|
+
path: issue.path.map((segment) => typeof segment === "symbol" ? segment.description ?? "symbol" : segment),
|
|
450
|
+
message: issue.message
|
|
451
|
+
})),
|
|
452
|
+
integrity: { envelopeDigestValid: false, evidenceDigestValid: false },
|
|
453
|
+
expiration: { checkedAt, envelopeNotYetValid: false, envelopeExpired: false, expiredApprovalIds: [] },
|
|
454
|
+
checks: {
|
|
455
|
+
recorded: 0,
|
|
456
|
+
passed: [],
|
|
457
|
+
failed: [],
|
|
458
|
+
skipped: [],
|
|
459
|
+
requiredPassed: [...parsedOptions.preconditions?.requiredPassedChecks ?? []].sort(),
|
|
460
|
+
missingPassed: [...parsedOptions.preconditions?.requiredPassedChecks ?? []].sort()
|
|
461
|
+
},
|
|
462
|
+
approvals: {
|
|
463
|
+
recorded: 0,
|
|
464
|
+
requiredScopes: [...parsedOptions.preconditions?.requiredApprovalScopes ?? []].sort(),
|
|
465
|
+
missingScopes: [...parsedOptions.preconditions?.requiredApprovalScopes ?? []].sort(),
|
|
466
|
+
authenticity: "not-verified"
|
|
467
|
+
},
|
|
468
|
+
externalAttestations: {
|
|
469
|
+
referenced: 0,
|
|
470
|
+
requiredDigests: [...parsedOptions.preconditions?.requiredAttestationDigests ?? []].sort(),
|
|
471
|
+
missingDigests: [...parsedOptions.preconditions?.requiredAttestationDigests ?? []].sort(),
|
|
472
|
+
authenticity: "not-verified"
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
const envelope = parsedEnvelope.data;
|
|
477
|
+
const issues = [];
|
|
478
|
+
const computedEvidenceDigest = digestCanonical(evidencePayload(envelope.evidence.checks));
|
|
479
|
+
const evidenceDigestValid = computedEvidenceDigest === envelope.evidence.evidenceDigest;
|
|
480
|
+
if (!evidenceDigestValid) {
|
|
481
|
+
issues.push({
|
|
482
|
+
code: "evidence-digest-mismatch",
|
|
483
|
+
path: ["evidence", "evidenceDigest"],
|
|
484
|
+
message: "Evidence digest does not match the canonical redacted check summary.",
|
|
485
|
+
expected: computedEvidenceDigest,
|
|
486
|
+
actual: envelope.evidence.evidenceDigest
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
const computedEnvelopeDigest = digestCanonical(envelopePayload(envelope));
|
|
490
|
+
const envelopeDigestValid = computedEnvelopeDigest === envelope.envelopeId;
|
|
491
|
+
if (!envelopeDigestValid) {
|
|
492
|
+
issues.push({
|
|
493
|
+
code: "envelope-digest-mismatch",
|
|
494
|
+
path: ["envelopeId"],
|
|
495
|
+
message: "Envelope digest does not match its canonical payload.",
|
|
496
|
+
expected: computedEnvelopeDigest,
|
|
497
|
+
actual: envelope.envelopeId
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
const envelopeNotYetValid = now.getTime() < Date.parse(envelope.createdAt);
|
|
501
|
+
if (envelopeNotYetValid) {
|
|
502
|
+
issues.push({
|
|
503
|
+
code: "envelope-not-yet-valid",
|
|
504
|
+
path: ["createdAt"],
|
|
505
|
+
message: "Change envelope creation time is in the future."
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
const envelopeExpired = envelope.expiresAt !== undefined && now.getTime() >= Date.parse(envelope.expiresAt);
|
|
509
|
+
if (envelopeExpired) {
|
|
510
|
+
issues.push({
|
|
511
|
+
code: "envelope-expired",
|
|
512
|
+
path: ["expiresAt"],
|
|
513
|
+
message: "Change envelope has expired."
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
const expiredApprovalIds = (envelope.approvals ?? []).filter((approval) => approval.expiresAt !== undefined && now.getTime() >= Date.parse(approval.expiresAt)).map((approval) => approval.approvalId);
|
|
517
|
+
for (const approvalId of expiredApprovalIds) {
|
|
518
|
+
issues.push({
|
|
519
|
+
code: "approval-expired",
|
|
520
|
+
path: ["approvals", envelope.approvals?.findIndex((approval) => approval.approvalId === approvalId) ?? 0, "expiresAt"],
|
|
521
|
+
message: `Recorded approval has expired: ${approvalId}.`
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
const preconditions = parsedOptions.preconditions;
|
|
525
|
+
const comparePrecondition = (field, expected, actual, path) => {
|
|
526
|
+
if (expected !== undefined && expected !== actual) {
|
|
527
|
+
issues.push({
|
|
528
|
+
code: "precondition-mismatch",
|
|
529
|
+
path,
|
|
530
|
+
message: `Change envelope precondition does not match: ${field}.`,
|
|
531
|
+
expected,
|
|
532
|
+
actual
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
comparePrecondition("envelopeId", preconditions?.envelopeId, envelope.envelopeId, ["envelopeId"]);
|
|
537
|
+
comparePrecondition("baseWorkspaceDigest", preconditions?.baseWorkspaceDigest, envelope.base.workspaceDigest, ["base", "workspaceDigest"]);
|
|
538
|
+
comparePrecondition("baseTreeDigest", preconditions?.baseTreeDigest, envelope.base.treeDigest, ["base", "treeDigest"]);
|
|
539
|
+
comparePrecondition("patchId", preconditions?.patchId, envelope.patch.patchId, ["patch", "patchId"]);
|
|
540
|
+
comparePrecondition("patchDigest", preconditions?.patchDigest, envelope.patch.patchDigest, ["patch", "patchDigest"]);
|
|
541
|
+
comparePrecondition("harnessFingerprint", preconditions?.harnessFingerprint, envelope.fingerprints.harness, ["fingerprints", "harness"]);
|
|
542
|
+
comparePrecondition("policyFingerprint", preconditions?.policyFingerprint, envelope.fingerprints.policy, ["fingerprints", "policy"]);
|
|
543
|
+
comparePrecondition("environmentFingerprint", preconditions?.environmentFingerprint, envelope.fingerprints.environment, ["fingerprints", "environment"]);
|
|
544
|
+
comparePrecondition("evidenceDigest", preconditions?.evidenceDigest, envelope.evidence.evidenceDigest, ["evidence", "evidenceDigest"]);
|
|
545
|
+
const passedChecks = envelope.evidence.checks.filter((check) => check.status === "passed").map((check) => check.checkId);
|
|
546
|
+
const failedChecks = envelope.evidence.checks.filter((check) => check.status === "failed").map((check) => check.checkId);
|
|
547
|
+
const skippedChecks = envelope.evidence.checks.filter((check) => check.status === "skipped").map((check) => check.checkId);
|
|
548
|
+
const passedCheckSet = new Set(passedChecks);
|
|
549
|
+
const requiredPassed = [...preconditions?.requiredPassedChecks ?? []].sort();
|
|
550
|
+
const missingPassed = requiredPassed.filter((checkId) => !passedCheckSet.has(checkId));
|
|
551
|
+
for (const checkId of missingPassed) {
|
|
552
|
+
issues.push({
|
|
553
|
+
code: "missing-passed-check",
|
|
554
|
+
path: ["evidence", "checks"],
|
|
555
|
+
message: `Required passed check is not recorded: ${checkId}.`,
|
|
556
|
+
expected: checkId
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
const expiredApprovals = new Set(expiredApprovalIds);
|
|
560
|
+
const activeApprovals = (envelope.approvals ?? []).filter((approval) => !expiredApprovals.has(approval.approvalId));
|
|
561
|
+
const approvalDigests = new Set(activeApprovals.map((approval) => approval.approvalDigest));
|
|
562
|
+
for (const requiredDigest of preconditions?.requiredApprovalDigests ?? []) {
|
|
563
|
+
if (!approvalDigests.has(requiredDigest)) {
|
|
564
|
+
issues.push({
|
|
565
|
+
code: "missing-approval-digest",
|
|
566
|
+
path: ["approvals"],
|
|
567
|
+
message: `Required active approval digest is not recorded: ${requiredDigest}.`,
|
|
568
|
+
expected: requiredDigest
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
const approvedScopes = new Set(activeApprovals.flatMap((approval) => approval.scopes));
|
|
573
|
+
const requiredScopes = [...preconditions?.requiredApprovalScopes ?? []].sort();
|
|
574
|
+
const missingScopes = requiredScopes.filter((scope) => !approvedScopes.has(scope));
|
|
575
|
+
for (const scope of missingScopes) {
|
|
576
|
+
issues.push({
|
|
577
|
+
code: "missing-approval-scope",
|
|
578
|
+
path: ["approvals"],
|
|
579
|
+
message: `Required active approval scope is not recorded: ${scope}.`,
|
|
580
|
+
expected: scope
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
const attestationDigests = new Set((envelope.externalAttestations ?? []).map((attestation) => attestation.bundleDigest));
|
|
584
|
+
const requiredAttestationDigests = [...preconditions?.requiredAttestationDigests ?? []].sort();
|
|
585
|
+
const missingAttestationDigests = requiredAttestationDigests.filter((digest) => !attestationDigests.has(digest));
|
|
586
|
+
for (const requiredDigest of missingAttestationDigests) {
|
|
587
|
+
issues.push({
|
|
588
|
+
code: "missing-attestation-digest",
|
|
589
|
+
path: ["externalAttestations"],
|
|
590
|
+
message: `Required external attestation digest is not referenced: ${requiredDigest}.`,
|
|
591
|
+
expected: requiredDigest
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
valid: issues.length === 0,
|
|
596
|
+
verificationScope: "integrity-expiration-and-preconditions-only",
|
|
597
|
+
envelope,
|
|
598
|
+
issues,
|
|
599
|
+
integrity: { envelopeDigestValid, evidenceDigestValid },
|
|
600
|
+
expiration: { checkedAt, envelopeNotYetValid, envelopeExpired, expiredApprovalIds },
|
|
601
|
+
checks: {
|
|
602
|
+
recorded: envelope.evidence.checks.length,
|
|
603
|
+
passed: passedChecks,
|
|
604
|
+
failed: failedChecks,
|
|
605
|
+
skipped: skippedChecks,
|
|
606
|
+
requiredPassed,
|
|
607
|
+
missingPassed
|
|
608
|
+
},
|
|
609
|
+
approvals: {
|
|
610
|
+
recorded: envelope.approvals?.length ?? 0,
|
|
611
|
+
requiredScopes,
|
|
612
|
+
missingScopes,
|
|
613
|
+
authenticity: "not-verified"
|
|
614
|
+
},
|
|
615
|
+
externalAttestations: {
|
|
616
|
+
referenced: envelope.externalAttestations?.length ?? 0,
|
|
617
|
+
requiredDigests: requiredAttestationDigests,
|
|
618
|
+
missingDigests: missingAttestationDigests,
|
|
619
|
+
authenticity: "not-verified"
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
export { CLI_JSON_SCHEMA_VERSION, CLI_EVENT_SCHEMA_VERSION, streamEventDocument, serializeStreamEvent, serializeStreamResult, changeEnvelopeSchema, digestChangeEnvelopeArtifact, createChangeEnvelope, canonicalizeChangeEnvelope, changeEnvelopePreconditionsSchema, verifyChangeEnvelope };
|