@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,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLI_CHANGES_COMMANDS,
|
|
3
|
+
CLI_COMMANDS,
|
|
4
|
+
CLI_RUNS_COMMANDS,
|
|
5
|
+
CLI_SESSIONS_COMMANDS,
|
|
6
|
+
CLI_STATE_COMMANDS,
|
|
7
|
+
CliUsageError,
|
|
8
|
+
parseCliArgs
|
|
9
|
+
} from "./index-nkwy5bjr.js";
|
|
10
|
+
import"./index-0kkgqvg7.js";
|
|
11
|
+
import"./index-ay26xfxt.js";
|
|
12
|
+
import"./index-fwf274vc.js";
|
|
13
|
+
import"./index-ctcwrkrc.js";
|
|
14
|
+
import"./index-qvbg6tx1.js";
|
|
15
|
+
import"./index-h7dcah4p.js";
|
|
16
|
+
import"./index-xwb691v9.js";
|
|
17
|
+
import"./index-px1tnqgt.js";
|
|
18
|
+
import"./index-1bx83sw4.js";
|
|
19
|
+
export {
|
|
20
|
+
CLI_CHANGES_COMMANDS,
|
|
21
|
+
CLI_COMMANDS,
|
|
22
|
+
CLI_RUNS_COMMANDS,
|
|
23
|
+
CLI_SESSIONS_COMMANDS,
|
|
24
|
+
CLI_STATE_COMMANDS,
|
|
25
|
+
CliUsageError,
|
|
26
|
+
parseCliArgs
|
|
27
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLI_CHANGES_COMMANDS,
|
|
3
|
+
CLI_COMMANDS,
|
|
4
|
+
CLI_RUNS_COMMANDS,
|
|
5
|
+
CLI_SESSIONS_COMMANDS,
|
|
6
|
+
CLI_STATE_COMMANDS,
|
|
7
|
+
CliUsageError,
|
|
8
|
+
parseCliArgs
|
|
9
|
+
} from "./cli-entry-wanv05db.js";
|
|
10
|
+
import"./cli-entry-dksm56sj.js";
|
|
11
|
+
import"./cli-entry-h7dcah4p.js";
|
|
12
|
+
import"./cli-entry-68kqraj7.js";
|
|
13
|
+
import"./cli-entry-1bx83sw4.js";
|
|
14
|
+
export {
|
|
15
|
+
CLI_CHANGES_COMMANDS,
|
|
16
|
+
CLI_COMMANDS,
|
|
17
|
+
CLI_RUNS_COMMANDS,
|
|
18
|
+
CLI_SESSIONS_COMMANDS,
|
|
19
|
+
CLI_STATE_COMMANDS,
|
|
20
|
+
CliUsageError,
|
|
21
|
+
parseCliArgs
|
|
22
|
+
};
|
package/dist/audit/index.js
CHANGED
|
@@ -1,477 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
HARNESS_VERSION
|
|
20
|
-
} from "../index-x9hv1a34.js";
|
|
21
|
-
import {
|
|
22
|
-
readRegularFileNoFollow
|
|
23
|
-
} from "../index-6dxrbnxm.js";
|
|
24
|
-
import"../index-bpc596v3.js";
|
|
25
|
-
import"../index-fm84men1.js";
|
|
2
|
+
AUDIT_PACK_SCHEMA_VERSION,
|
|
3
|
+
auditPackManifestSchema,
|
|
4
|
+
canonicalizeAuditPackManifest,
|
|
5
|
+
exportHarnessAuditPack,
|
|
6
|
+
loadAuditSigningKey,
|
|
7
|
+
verifyHarnessAuditPack
|
|
8
|
+
} from "../index-tn58cr6w.js";
|
|
9
|
+
import"../index-7nbmhmw5.js";
|
|
10
|
+
import"../index-cztmcesv.js";
|
|
11
|
+
import"../index-kbrf5bx7.js";
|
|
12
|
+
import"../index-kwk23ktq.js";
|
|
13
|
+
import"../index-6ehtssyz.js";
|
|
14
|
+
import"../index-f970qtb4.js";
|
|
15
|
+
import"../index-h7dcah4p.js";
|
|
16
|
+
import"../index-xwb691v9.js";
|
|
17
|
+
import"../index-px1tnqgt.js";
|
|
26
18
|
import"../index-1bx83sw4.js";
|
|
27
|
-
|
|
28
|
-
// src/audit/pack.ts
|
|
29
|
-
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
30
|
-
import { lstat, mkdir, readdir, rm, writeFile } from "node:fs/promises";
|
|
31
|
-
import path from "node:path";
|
|
32
|
-
import { z } from "zod";
|
|
33
|
-
import { createRedactionPolicy } from "@zhivex-ai/agents";
|
|
34
|
-
var AUDIT_PACK_SCHEMA_VERSION = 1;
|
|
35
|
-
var MAX_FILE_BYTES = 8 * 1024 * 1024;
|
|
36
|
-
var MAX_PACK_BYTES = 32 * 1024 * 1024;
|
|
37
|
-
var MAX_ACTIVITY_EVENTS = 2000;
|
|
38
|
-
var COMPONENT_NAMES = ["governance-report.json", "approvals.json", "policy-decisions.json", "redaction.jsonl", "usage-ledger.json"];
|
|
39
|
-
var digest = z.string().regex(/^[a-f0-9]{64}$/);
|
|
40
|
-
var relativePath = z.string().regex(/^[A-Za-z0-9._-]{1,80}(?:\/[A-Za-z0-9._-]{1,80}){0,3}$/);
|
|
41
|
-
var fileEntry = z.strictObject({ path: relativePath, sha256: digest, bytes: z.number().int().nonnegative().safe() });
|
|
42
|
-
var subjectSchema = z.strictObject({
|
|
43
|
-
kind: z.enum(["run", "task"]),
|
|
44
|
-
id: z.string().min(1).max(256),
|
|
45
|
-
runIds: z.array(z.string().min(1).max(256)).min(1).max(64)
|
|
46
|
-
});
|
|
47
|
-
var unsignedManifestSchema = z.strictObject({
|
|
48
|
-
schemaVersion: z.literal(1),
|
|
49
|
-
kind: z.literal("zhivex-harness-audit-pack"),
|
|
50
|
-
integrity: z.literal("hmac-sha256"),
|
|
51
|
-
exporterVersion: z.string().regex(/^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/),
|
|
52
|
-
createdAt: z.iso.datetime(),
|
|
53
|
-
subject: subjectSchema,
|
|
54
|
-
files: z.array(fileEntry).min(5).max(320)
|
|
55
|
-
}).superRefine((value, ctx) => {
|
|
56
|
-
const seen = new Set;
|
|
57
|
-
for (const file of value.files) {
|
|
58
|
-
if (seen.has(file.path) || file.path === "manifest.json")
|
|
59
|
-
ctx.addIssue({ code: "custom", message: "Duplicate or reserved audit pack path." });
|
|
60
|
-
seen.add(file.path);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
var signatureSchema = z.strictObject({
|
|
64
|
-
algorithm: z.literal("hmac-sha256"),
|
|
65
|
-
keyId: z.string().regex(/^[a-f0-9]{16}$/),
|
|
66
|
-
value: z.string().regex(/^[A-Za-z0-9+/]{43}=$/)
|
|
67
|
-
});
|
|
68
|
-
var auditPackManifestSchema = unsignedManifestSchema.extend({ signature: signatureSchema });
|
|
69
|
-
var accountView = z.object({
|
|
70
|
-
taskId: z.string().min(1).max(256),
|
|
71
|
-
runs: z.array(z.string().min(1).max(256)).max(64)
|
|
72
|
-
}).passthrough();
|
|
73
|
-
function fail(code) {
|
|
74
|
-
throw new Error(code);
|
|
75
|
-
}
|
|
76
|
-
var canonical = (value) => Array.isArray(value) ? `[${value.map(canonical).join(",")}]` : value && typeof value === "object" ? `{${Object.entries(value).filter(([, item]) => item !== undefined).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(",")}}` : JSON.stringify(value) ?? "null";
|
|
77
|
-
var canonicalizeAuditPackManifest = (value) => canonical(unsignedManifestSchema.parse(value));
|
|
78
|
-
var keyIdFor = (key) => createHash("sha256").update(key).digest("hex").slice(0, 16);
|
|
79
|
-
var signManifest = (unsigned, key) => createHmac("sha256", key).update(canonicalizeAuditPackManifest(unsigned)).digest("base64");
|
|
80
|
-
var assertKey = (key) => {
|
|
81
|
-
if (key.byteLength < 32 || key.byteLength > 4096)
|
|
82
|
-
fail("AUDIT_PACK_KEY_INVALID");
|
|
83
|
-
};
|
|
84
|
-
var redaction = createRedactionPolicy({ includeEmails: true });
|
|
85
|
-
var redactText = (value) => redaction.redactText(value).replace(/\b(?:sk|ghp|github_pat|xox[baprs])[-_][A-Za-z0-9_-]+/gi, "[REDACTED]");
|
|
86
|
-
var redactValue = (value) => typeof value === "string" ? redactText(value) : Array.isArray(value) ? value.map(redactValue) : value && typeof value === "object" ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactValue(item)])) : value;
|
|
87
|
-
var sameScope = (state, scope) => !state.scope || state.scope.tenantId === scope?.tenantId && state.scope.userId === scope?.userId && state.scope.namespace === scope?.namespace;
|
|
88
|
-
var contained = (root, relativePath2) => {
|
|
89
|
-
if (relativePath2.includes("\\") || path.isAbsolute(relativePath2) || relativePath2.split("/").some((part) => part === "" || part === "." || part === ".."))
|
|
90
|
-
fail("AUDIT_PACK_PATH_INVALID");
|
|
91
|
-
const target = path.resolve(root, relativePath2);
|
|
92
|
-
const relative = path.relative(root, target);
|
|
93
|
-
if (relative.startsWith("..") || path.isAbsolute(relative))
|
|
94
|
-
fail("AUDIT_PACK_PATH_INVALID");
|
|
95
|
-
return target;
|
|
96
|
-
};
|
|
97
|
-
var runSegment = (runId, used) => {
|
|
98
|
-
const base = /^[A-Za-z0-9._-]{1,64}$/.test(runId) ? runId : `run-${createHash("sha256").update(runId).digest("hex").slice(0, 16)}`;
|
|
99
|
-
let name = base;
|
|
100
|
-
for (let suffix = 2;used.has(name); suffix += 1)
|
|
101
|
-
name = `${base}-${suffix}`;
|
|
102
|
-
used.add(name);
|
|
103
|
-
return name;
|
|
104
|
-
};
|
|
105
|
-
async function loadRun(store, scope, runId) {
|
|
106
|
-
const state = await store.load(runId, scope);
|
|
107
|
-
if (!state || state.runId !== runId || !sameScope(state, scope))
|
|
108
|
-
fail("AUDIT_PACK_SUBJECT_UNAVAILABLE");
|
|
109
|
-
return structuredClone(state);
|
|
110
|
-
}
|
|
111
|
-
async function readJournal(store, scope, runId) {
|
|
112
|
-
if (!store.listToolCalls)
|
|
113
|
-
return;
|
|
114
|
-
const listed = await store.listToolCalls(runId, scope);
|
|
115
|
-
return listed ? structuredClone(listed) : undefined;
|
|
116
|
-
}
|
|
117
|
-
async function captureRun(store, scope, runId) {
|
|
118
|
-
return { state: await loadRun(store, scope, runId), journal: await readJournal(store, scope, runId) };
|
|
119
|
-
}
|
|
120
|
-
var sameJson = (left, right) => JSON.stringify(left) === JSON.stringify(right);
|
|
121
|
-
async function assertCaptured(store, scope, captured) {
|
|
122
|
-
const current = await store.load(captured.state.runId, scope);
|
|
123
|
-
const currentJournal = store.listToolCalls ? await store.listToolCalls(captured.state.runId, scope) : undefined;
|
|
124
|
-
if (!current || !sameJson(current, captured.state) || !sameJson(currentJournal, captured.journal))
|
|
125
|
-
fail("AUDIT_PACK_STATE_CHANGED");
|
|
126
|
-
}
|
|
127
|
-
function snapshotStore(real, captured) {
|
|
128
|
-
return {
|
|
129
|
-
async load(id, scope) {
|
|
130
|
-
const snap = captured.get(id);
|
|
131
|
-
if (snap)
|
|
132
|
-
return structuredClone(snap.state);
|
|
133
|
-
return real.load(id, scope);
|
|
134
|
-
},
|
|
135
|
-
...real.listToolCalls ? { async listToolCalls(id, scope) {
|
|
136
|
-
const snap = captured.get(id);
|
|
137
|
-
if (snap)
|
|
138
|
-
return snap.journal ? structuredClone(snap.journal) : undefined;
|
|
139
|
-
return real.listToolCalls(id, scope);
|
|
140
|
-
} } : {}
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
async function resolveSubject(store, scope, subjectId) {
|
|
144
|
-
const direct = await store.load(subjectId, scope);
|
|
145
|
-
const accountOf = (state) => {
|
|
146
|
-
const parsed = accountView.safeParse(state?.metadata?.[TASK_BUDGET_ACCOUNT_KEY]);
|
|
147
|
-
return parsed.success && state?.runId.startsWith("task_budget_") ? parsed.data : undefined;
|
|
148
|
-
};
|
|
149
|
-
const directAccount = direct && direct.runId === subjectId && sameScope(direct, scope) ? accountOf(direct) : undefined;
|
|
150
|
-
if (direct && direct.runId === subjectId && sameScope(direct, scope) && !directAccount) {
|
|
151
|
-
return { kind: "run", id: subjectId, runs: [{ state: structuredClone(direct), journal: await readJournal(store, scope, subjectId) }], accountState: undefined };
|
|
152
|
-
}
|
|
153
|
-
let account = directAccount;
|
|
154
|
-
let taskId = account?.taskId;
|
|
155
|
-
let accountState = direct && directAccount ? structuredClone(direct) : undefined;
|
|
156
|
-
if (!account && scope) {
|
|
157
|
-
const loaded = await store.load(TaskBudget.accountId(scope, subjectId), scope);
|
|
158
|
-
const parsed = loaded && sameScope(loaded, scope) ? accountOf(loaded) : undefined;
|
|
159
|
-
if (parsed && parsed.taskId === subjectId) {
|
|
160
|
-
account = parsed;
|
|
161
|
-
taskId = parsed.taskId;
|
|
162
|
-
accountState = structuredClone(loaded);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (!account || !taskId || !accountState || account.runs.length === 0)
|
|
166
|
-
fail("AUDIT_PACK_SUBJECT_UNAVAILABLE");
|
|
167
|
-
const runs = [];
|
|
168
|
-
for (const runId of account.runs)
|
|
169
|
-
runs.push(await captureRun(store, scope, runId));
|
|
170
|
-
return { kind: "task", id: taskId, runs, accountState };
|
|
171
|
-
}
|
|
172
|
-
function collectActivity(session, runIds) {
|
|
173
|
-
if (!session?.history)
|
|
174
|
-
return { availability: "unavailable", truncated: false, retention: "unknown", events: [] };
|
|
175
|
-
const events = [];
|
|
176
|
-
let cursor = 0;
|
|
177
|
-
let truncated = false;
|
|
178
|
-
let retention = "retained";
|
|
179
|
-
for (let pageIndex = 0;pageIndex < 50; pageIndex += 1) {
|
|
180
|
-
const page = session.history.replay(session.id, cursor);
|
|
181
|
-
if (page.schemaVersion !== 1 || !Number.isSafeInteger(page.nextCursor) || page.nextCursor < cursor)
|
|
182
|
-
fail("AUDIT_PACK_HISTORY_INVALID");
|
|
183
|
-
if (page.cursorExpired || page.policyEvidenceIncomplete)
|
|
184
|
-
retention = "expired";
|
|
185
|
-
let last = cursor;
|
|
186
|
-
for (const event of page.events) {
|
|
187
|
-
if (event.sessionId !== session.id || !Number.isSafeInteger(event.sequence) || event.sequence <= last || event.sequence > page.nextCursor)
|
|
188
|
-
fail("AUDIT_PACK_HISTORY_INVALID");
|
|
189
|
-
last = event.sequence;
|
|
190
|
-
if (!runIds.has(event.runId))
|
|
191
|
-
continue;
|
|
192
|
-
if (events.length >= MAX_ACTIVITY_EVENTS) {
|
|
193
|
-
truncated = true;
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
events.push({ sequence: event.sequence, runId: event.runId, ...typeof event.at === "number" ? { at: event.at } : {}, activity: event.activity });
|
|
197
|
-
}
|
|
198
|
-
if (page.cursorExpired || !page.hasMore)
|
|
199
|
-
break;
|
|
200
|
-
if (page.nextCursor === cursor)
|
|
201
|
-
fail("AUDIT_PACK_HISTORY_INVALID");
|
|
202
|
-
cursor = page.nextCursor;
|
|
203
|
-
if (pageIndex === 49)
|
|
204
|
-
truncated = true;
|
|
205
|
-
}
|
|
206
|
-
return { availability: truncated || retention === "expired" ? "incomplete" : "recorded", truncated, retention, events };
|
|
207
|
-
}
|
|
208
|
-
function approvalPages(state, journal) {
|
|
209
|
-
const decisions = [];
|
|
210
|
-
for (let offset = 0;offset < 512; offset += 25) {
|
|
211
|
-
const rows = approvalDecisionViews(state, journal, offset);
|
|
212
|
-
decisions.push(...rows);
|
|
213
|
-
if (rows.length < 25)
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
return decisions;
|
|
217
|
-
}
|
|
218
|
-
async function componentFiles(captured, store, scope, session, activity, ledger) {
|
|
219
|
-
const state = captured.state;
|
|
220
|
-
const rows = captured.journal ?? [];
|
|
221
|
-
let approvals;
|
|
222
|
-
try {
|
|
223
|
-
const decisions = approvalPages(state, rows);
|
|
224
|
-
approvals = { schemaVersion: 1, kind: "zhivex-audit-approvals", runId: state.runId, availability: state.metadata?.[APPROVAL_HISTORY_KEY] === undefined && decisions.length === 0 ? "unavailable" : "recorded", decisions: redactValue(decisions) };
|
|
225
|
-
} catch {
|
|
226
|
-
approvals = { schemaVersion: 1, kind: "zhivex-audit-approvals", runId: state.runId, availability: "invalid", decisions: [] };
|
|
227
|
-
}
|
|
228
|
-
const policyEvents = [];
|
|
229
|
-
let invalid = 0;
|
|
230
|
-
for (const event of activity.events) {
|
|
231
|
-
if (event.runId !== state.runId || event.activity.type !== "policy-decision")
|
|
232
|
-
continue;
|
|
233
|
-
const parsed = harnessPolicyDecisionEventSchema.safeParse(event.activity);
|
|
234
|
-
if (!parsed.success) {
|
|
235
|
-
invalid += 1;
|
|
236
|
-
continue;
|
|
237
|
-
}
|
|
238
|
-
policyEvents.push({ sequence: event.sequence, event: parsed.data });
|
|
239
|
-
}
|
|
240
|
-
const policy = {
|
|
241
|
-
schemaVersion: 1,
|
|
242
|
-
kind: "zhivex-audit-policy-decisions",
|
|
243
|
-
runId: state.runId,
|
|
244
|
-
availability: activity.availability === "unavailable" ? "unavailable" : invalid > 0 || activity.availability === "incomplete" ? "incomplete" : "recorded",
|
|
245
|
-
invalid,
|
|
246
|
-
decisions: policyEvents
|
|
247
|
-
};
|
|
248
|
-
const own = activity.events.filter((event) => event.runId === state.runId);
|
|
249
|
-
const header = { schemaVersion: 1, kind: "zhivex-redaction-log", availability: activity.availability, count: own.length, truncated: activity.truncated, retention: activity.retention };
|
|
250
|
-
const lines = [header, ...own.map((event) => ({ schemaVersion: 1, kind: "zhivex-redacted-activity", sequence: event.sequence, runId: event.runId, ...event.at === undefined ? {} : { at: event.at }, activity: event.activity }))];
|
|
251
|
-
const redactionLog = `${lines.map((line) => JSON.stringify(line)).join(`
|
|
252
|
-
`)}
|
|
253
|
-
`;
|
|
254
|
-
let transport = null;
|
|
255
|
-
let transportAvailability = "unavailable";
|
|
256
|
-
if (ledger) {
|
|
257
|
-
try {
|
|
258
|
-
transport = ledger.summary(state.runId);
|
|
259
|
-
transportAvailability = "recorded";
|
|
260
|
-
} catch {
|
|
261
|
-
transport = null;
|
|
262
|
-
transportAvailability = "unavailable";
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
const usage = {
|
|
266
|
-
schemaVersion: 1,
|
|
267
|
-
kind: "zhivex-audit-usage-ledger",
|
|
268
|
-
runId: state.runId,
|
|
269
|
-
projection: inspectUsageLedger(state.metadata?.[USAGE_LEDGER_KEY]),
|
|
270
|
-
transport,
|
|
271
|
-
transportAvailability
|
|
272
|
-
};
|
|
273
|
-
const report = await exportHarnessGovernanceReport(store, scope, state.runId, session ? { session } : {});
|
|
274
|
-
return new Map([
|
|
275
|
-
["governance-report.json", Buffer.from(`${JSON.stringify(report, null, 2)}
|
|
276
|
-
`)],
|
|
277
|
-
["approvals.json", Buffer.from(`${JSON.stringify(approvals, null, 2)}
|
|
278
|
-
`)],
|
|
279
|
-
["policy-decisions.json", Buffer.from(`${JSON.stringify(policy, null, 2)}
|
|
280
|
-
`)],
|
|
281
|
-
["redaction.jsonl", Buffer.from(redactionLog)],
|
|
282
|
-
["usage-ledger.json", Buffer.from(`${JSON.stringify(usage, null, 2)}
|
|
283
|
-
`)]
|
|
284
|
-
]);
|
|
285
|
-
}
|
|
286
|
-
async function loadAuditSigningKey(input) {
|
|
287
|
-
let bytes;
|
|
288
|
-
if (input.file) {
|
|
289
|
-
const data = await readRegularFileNoFollow(path.resolve(input.file), { label: "Audit signing key", maxBytes: 4096 });
|
|
290
|
-
bytes = data.contents;
|
|
291
|
-
if (bytes.at(-1) === 10)
|
|
292
|
-
bytes = bytes.subarray(0, -1);
|
|
293
|
-
if (bytes.at(-1) === 13)
|
|
294
|
-
bytes = bytes.subarray(0, -1);
|
|
295
|
-
} else if (input.value !== undefined)
|
|
296
|
-
bytes = Buffer.from(input.value, "utf8");
|
|
297
|
-
else
|
|
298
|
-
fail("AUDIT_PACK_KEY_INVALID");
|
|
299
|
-
assertKey(bytes);
|
|
300
|
-
return Buffer.from(bytes);
|
|
301
|
-
}
|
|
302
|
-
async function exportHarnessAuditPack(options) {
|
|
303
|
-
assertKey(options.signingKey);
|
|
304
|
-
const subject = await resolveSubject(options.store, options.scope, options.subjectId);
|
|
305
|
-
const runIds = new Set(subject.runs.map((run) => run.state.runId));
|
|
306
|
-
const activity = collectActivity(options.session, runIds);
|
|
307
|
-
let ledger;
|
|
308
|
-
if (options.config) {
|
|
309
|
-
try {
|
|
310
|
-
ledger = await UsageLedger.open(options.config);
|
|
311
|
-
} catch {
|
|
312
|
-
ledger = undefined;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
try {
|
|
316
|
-
const files = new Map;
|
|
317
|
-
const segments = new Set;
|
|
318
|
-
const frozen = snapshotStore(options.store, new Map(subject.runs.map((run) => [run.state.runId, run])));
|
|
319
|
-
const prefixFor = subject.runs.length === 1 ? (_runId) => "" : (runId) => `runs/${runSegment(runId, segments)}/`;
|
|
320
|
-
for (const captured of subject.runs) {
|
|
321
|
-
const prefix = prefixFor(captured.state.runId);
|
|
322
|
-
const parts = await componentFiles(captured, frozen, options.scope, options.session, activity, ledger);
|
|
323
|
-
for (const name of COMPONENT_NAMES) {
|
|
324
|
-
const bytes = parts.get(name);
|
|
325
|
-
if (!bytes)
|
|
326
|
-
fail("AUDIT_PACK_CONTENT_INVALID");
|
|
327
|
-
if (bytes.byteLength > MAX_FILE_BYTES)
|
|
328
|
-
fail("AUDIT_PACK_LIMIT");
|
|
329
|
-
files.set(`${prefix}${name}`, bytes);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
const listed = [...files.keys()].sort();
|
|
333
|
-
let total = 0;
|
|
334
|
-
const entries = listed.map((file) => {
|
|
335
|
-
const bytes = files.get(file);
|
|
336
|
-
total += bytes.byteLength;
|
|
337
|
-
return { path: file, sha256: createHash("sha256").update(bytes).digest("hex"), bytes: bytes.byteLength };
|
|
338
|
-
});
|
|
339
|
-
for (const captured of subject.runs)
|
|
340
|
-
await assertCaptured(options.store, options.scope, captured);
|
|
341
|
-
if (subject.accountState) {
|
|
342
|
-
const currentAccount = await options.store.load(subject.accountState.runId, options.scope);
|
|
343
|
-
if (!currentAccount || !sameJson(currentAccount, subject.accountState))
|
|
344
|
-
fail("AUDIT_PACK_STATE_CHANGED");
|
|
345
|
-
}
|
|
346
|
-
const unsigned = {
|
|
347
|
-
schemaVersion: 1,
|
|
348
|
-
kind: "zhivex-harness-audit-pack",
|
|
349
|
-
integrity: "hmac-sha256",
|
|
350
|
-
exporterVersion: HARNESS_VERSION,
|
|
351
|
-
createdAt: new Date(options.now ?? Date.now()).toISOString(),
|
|
352
|
-
subject: { kind: subject.kind, id: subject.id, runIds: subject.runs.map((run) => run.state.runId) },
|
|
353
|
-
files: entries
|
|
354
|
-
};
|
|
355
|
-
const manifest = auditPackManifestSchema.parse({
|
|
356
|
-
...unsigned,
|
|
357
|
-
signature: { algorithm: "hmac-sha256", keyId: keyIdFor(options.signingKey), value: signManifest(unsigned, options.signingKey) }
|
|
358
|
-
});
|
|
359
|
-
const manifestBytes = Buffer.from(`${JSON.stringify(manifest, null, 2)}
|
|
360
|
-
`);
|
|
361
|
-
if (manifestBytes.byteLength > MAX_FILE_BYTES || total + manifestBytes.byteLength > MAX_PACK_BYTES)
|
|
362
|
-
fail("AUDIT_PACK_LIMIT");
|
|
363
|
-
const directory = path.resolve(options.directory);
|
|
364
|
-
const parent = await lstat(path.dirname(directory)).catch(() => fail("AUDIT_PACK_OUTPUT_UNAVAILABLE"));
|
|
365
|
-
if (!parent.isDirectory() || parent.isSymbolicLink())
|
|
366
|
-
fail("AUDIT_PACK_OUTPUT_UNAVAILABLE");
|
|
367
|
-
await mkdir(directory, { mode: 448 }).catch((error) => fail(error.code === "EEXIST" ? "AUDIT_PACK_OUTPUT_EXISTS" : "AUDIT_PACK_OUTPUT_UNAVAILABLE"));
|
|
368
|
-
try {
|
|
369
|
-
for (const file of listed) {
|
|
370
|
-
const target = contained(directory, file);
|
|
371
|
-
await mkdir(path.dirname(target), { recursive: true, mode: 448 });
|
|
372
|
-
await writeFile(target, files.get(file), { flag: "wx", mode: 384 });
|
|
373
|
-
}
|
|
374
|
-
await writeFile(path.join(directory, "manifest.json"), `${JSON.stringify(manifest, null, 2)}
|
|
375
|
-
`, { flag: "wx", mode: 384 });
|
|
376
|
-
} catch (error) {
|
|
377
|
-
await rm(directory, { recursive: true, force: true });
|
|
378
|
-
if (error instanceof Error && error.message.startsWith("AUDIT_PACK_"))
|
|
379
|
-
throw error;
|
|
380
|
-
fail("AUDIT_PACK_WRITE_FAILED");
|
|
381
|
-
}
|
|
382
|
-
return manifest;
|
|
383
|
-
} finally {
|
|
384
|
-
ledger?.close();
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
var kindSchema = (kind) => z.object({ schemaVersion: z.literal(1), kind: z.literal(kind) }).passthrough();
|
|
388
|
-
async function verifyHarnessAuditPack(options) {
|
|
389
|
-
assertKey(options.signingKey);
|
|
390
|
-
const directory = path.resolve(options.directory);
|
|
391
|
-
const root = await lstat(directory).catch(() => fail("AUDIT_PACK_UNAVAILABLE"));
|
|
392
|
-
if (!root.isDirectory() || root.isSymbolicLink())
|
|
393
|
-
fail("AUDIT_PACK_UNAVAILABLE");
|
|
394
|
-
const manifestBytes = await readRegularFileNoFollow(path.join(directory, "manifest.json"), { label: "Audit manifest", maxBytes: MAX_FILE_BYTES });
|
|
395
|
-
let manifest;
|
|
396
|
-
try {
|
|
397
|
-
manifest = auditPackManifestSchema.parse(JSON.parse(manifestBytes.contents.toString("utf8")));
|
|
398
|
-
} catch {
|
|
399
|
-
fail("AUDIT_PACK_MANIFEST_INVALID");
|
|
400
|
-
}
|
|
401
|
-
const present = [];
|
|
402
|
-
const walk = async (current, prefix) => {
|
|
403
|
-
const entries = await readdir(current, { withFileTypes: true });
|
|
404
|
-
for (const entry of entries.sort((a, b) => a.name < b.name ? -1 : 1)) {
|
|
405
|
-
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
406
|
-
if (entry.isSymbolicLink())
|
|
407
|
-
fail("AUDIT_PACK_PATH_INVALID");
|
|
408
|
-
const full = path.join(current, entry.name);
|
|
409
|
-
if (entry.isDirectory())
|
|
410
|
-
await walk(full, relative);
|
|
411
|
-
else if (entry.isFile())
|
|
412
|
-
present.push(relative);
|
|
413
|
-
else
|
|
414
|
-
fail("AUDIT_PACK_PATH_INVALID");
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
await walk(directory, "");
|
|
418
|
-
present.sort();
|
|
419
|
-
const expected = ["manifest.json", ...manifest.files.map((file) => file.path)].sort();
|
|
420
|
-
if (present.length !== expected.length || present.some((file, index) => file !== expected[index]))
|
|
421
|
-
fail("AUDIT_PACK_FILES_MISMATCH");
|
|
422
|
-
let total = manifestBytes.contents.byteLength;
|
|
423
|
-
for (const file of manifest.files) {
|
|
424
|
-
const target = contained(directory, file.path);
|
|
425
|
-
const contents = await readRegularFileNoFollow(target, { label: "Audit pack file", maxBytes: MAX_FILE_BYTES }).catch((error) => {
|
|
426
|
-
if (error instanceof Error && error.message.startsWith("AUDIT_PACK_"))
|
|
427
|
-
throw error;
|
|
428
|
-
fail("AUDIT_PACK_HASH_MISMATCH");
|
|
429
|
-
});
|
|
430
|
-
total += contents.contents.byteLength;
|
|
431
|
-
if (contents.contents.byteLength !== file.bytes || createHash("sha256").update(contents.contents).digest("hex") !== file.sha256)
|
|
432
|
-
fail("AUDIT_PACK_HASH_MISMATCH");
|
|
433
|
-
try {
|
|
434
|
-
if (file.path.endsWith("governance-report.json")) {
|
|
435
|
-
if (!harnessGovernanceReportSchema.safeParse(JSON.parse(contents.contents.toString("utf8"))).success)
|
|
436
|
-
fail("AUDIT_PACK_CONTENT_INVALID");
|
|
437
|
-
} else if (file.path.endsWith("approvals.json")) {
|
|
438
|
-
if (!kindSchema("zhivex-audit-approvals").safeParse(JSON.parse(contents.contents.toString("utf8"))).success)
|
|
439
|
-
fail("AUDIT_PACK_CONTENT_INVALID");
|
|
440
|
-
} else if (file.path.endsWith("policy-decisions.json")) {
|
|
441
|
-
if (!kindSchema("zhivex-audit-policy-decisions").safeParse(JSON.parse(contents.contents.toString("utf8"))).success)
|
|
442
|
-
fail("AUDIT_PACK_CONTENT_INVALID");
|
|
443
|
-
} else if (file.path.endsWith("usage-ledger.json")) {
|
|
444
|
-
if (!kindSchema("zhivex-audit-usage-ledger").safeParse(JSON.parse(contents.contents.toString("utf8"))).success)
|
|
445
|
-
fail("AUDIT_PACK_CONTENT_INVALID");
|
|
446
|
-
} else if (file.path.endsWith("redaction.jsonl")) {
|
|
447
|
-
const lines = contents.contents.toString("utf8").split(`
|
|
448
|
-
`);
|
|
449
|
-
if (lines.at(-1) !== "")
|
|
450
|
-
fail("AUDIT_PACK_CONTENT_INVALID");
|
|
451
|
-
for (const line of lines.slice(0, -1)) {
|
|
452
|
-
if (!kindSchema("zhivex-redaction-log").or(kindSchema("zhivex-redacted-activity")).safeParse(JSON.parse(line)).success)
|
|
453
|
-
fail("AUDIT_PACK_CONTENT_INVALID");
|
|
454
|
-
}
|
|
455
|
-
} else
|
|
456
|
-
fail("AUDIT_PACK_PATH_INVALID");
|
|
457
|
-
} catch (error) {
|
|
458
|
-
if (error instanceof Error && error.message.startsWith("AUDIT_PACK_"))
|
|
459
|
-
throw error;
|
|
460
|
-
fail("AUDIT_PACK_CONTENT_INVALID");
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
if (total > MAX_PACK_BYTES)
|
|
464
|
-
fail("AUDIT_PACK_LIMIT");
|
|
465
|
-
if (manifest.signature.keyId !== keyIdFor(options.signingKey))
|
|
466
|
-
fail("AUDIT_PACK_KEY_MISMATCH");
|
|
467
|
-
const { signature, ...unsigned } = manifest;
|
|
468
|
-
const expectedSignature = Buffer.from(signManifest(unsigned, options.signingKey), "base64");
|
|
469
|
-
const actualSignature = Buffer.from(signature.value, "base64");
|
|
470
|
-
if (actualSignature.length !== expectedSignature.length || actualSignature.toString("base64") !== signature.value || !timingSafeEqual(actualSignature, expectedSignature)) {
|
|
471
|
-
fail("AUDIT_PACK_SIGNATURE_INVALID");
|
|
472
|
-
}
|
|
473
|
-
return { schemaVersion: 1, kind: "zhivex-audit-pack-verification", subject: manifest.subject, fileCount: manifest.files.length, keyId: signature.keyId };
|
|
474
|
-
}
|
|
475
19
|
export {
|
|
476
20
|
AUDIT_PACK_SCHEMA_VERSION,
|
|
477
21
|
auditPackManifestSchema,
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CliUsageError
|
|
3
|
+
} from "./index-nkwy5bjr.js";
|
|
4
|
+
import"./index-0kkgqvg7.js";
|
|
5
|
+
import {
|
|
6
|
+
exportHarnessAuditPack,
|
|
7
|
+
loadAuditSigningKey,
|
|
8
|
+
verifyHarnessAuditPack
|
|
9
|
+
} from "./index-tn58cr6w.js";
|
|
10
|
+
import {
|
|
11
|
+
openHarnessActivityStore
|
|
12
|
+
} from "./index-f8zpcsx3.js";
|
|
13
|
+
import"./index-ay26xfxt.js";
|
|
14
|
+
import {
|
|
15
|
+
openHarnessPersistence
|
|
16
|
+
} from "./index-w9eqg6p9.js";
|
|
17
|
+
import"./index-v79s9bf9.js";
|
|
18
|
+
import {
|
|
19
|
+
resolveHarnessConfig
|
|
20
|
+
} from "./index-fwf274vc.js";
|
|
21
|
+
import"./index-ctcwrkrc.js";
|
|
22
|
+
import"./index-qvbg6tx1.js";
|
|
23
|
+
import"./index-7nbmhmw5.js";
|
|
24
|
+
import"./index-cztmcesv.js";
|
|
25
|
+
import"./index-kbrf5bx7.js";
|
|
26
|
+
import"./index-kwk23ktq.js";
|
|
27
|
+
import {
|
|
28
|
+
openCliSessionStore,
|
|
29
|
+
validateStateDirectory
|
|
30
|
+
} from "./index-6ehtssyz.js";
|
|
31
|
+
import"./index-f970qtb4.js";
|
|
32
|
+
import"./index-h7dcah4p.js";
|
|
33
|
+
import"./index-5jxm2wy5.js";
|
|
34
|
+
import"./index-xwb691v9.js";
|
|
35
|
+
import"./index-px1tnqgt.js";
|
|
36
|
+
import"./index-1bx83sw4.js";
|
|
37
|
+
|
|
38
|
+
// packages/core/src/cli/audit-pack.ts
|
|
39
|
+
import path from "node:path";
|
|
40
|
+
var signingKey = async (file) => {
|
|
41
|
+
if (!file && process.env.ZHIVEX_AUDIT_SIGNING_KEY === undefined) {
|
|
42
|
+
throw new CliUsageError("Set ZHIVEX_AUDIT_SIGNING_KEY or pass --signing-key-file. The key is not stored in the pack.");
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
return await loadAuditSigningKey({ ...file ? { file } : {}, ...file ? {} : { value: process.env.ZHIVEX_AUDIT_SIGNING_KEY ?? "" } });
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (error instanceof Error && (error.message === "AUDIT_PACK_KEY_INVALID" || error.name === "UnsafeFileTypeError" || error.name === "FileSizeLimitError")) {
|
|
48
|
+
throw new CliUsageError("Audit signing key must be a regular file or environment value of 32 to 4096 bytes.");
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
async function auditPackCli(options) {
|
|
54
|
+
const key = await signingKey(options.signingKeyFile);
|
|
55
|
+
if (options.command === "verify-audit") {
|
|
56
|
+
const result = await verifyHarnessAuditPack({ directory: path.resolve(options.auditOut), signingKey: key });
|
|
57
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}
|
|
58
|
+
` : `Audit pack verified: ${result.subject.kind} ${result.subject.id} (${result.fileCount} files, key ${result.keyId}).
|
|
59
|
+
`);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
const config = resolveHarnessConfig(options);
|
|
63
|
+
await validateStateDirectory(config.workspace, config.stateDirectory);
|
|
64
|
+
const persistence = await openHarnessPersistence(config);
|
|
65
|
+
let index;
|
|
66
|
+
let history;
|
|
67
|
+
try {
|
|
68
|
+
if (options.sessionId) {
|
|
69
|
+
index = await openCliSessionStore({ workspace: config.workspace, stateDirectory: config.stateDirectory, scope: config.scope });
|
|
70
|
+
history = await openHarnessActivityStore(config);
|
|
71
|
+
}
|
|
72
|
+
const manifest = await exportHarnessAuditPack({
|
|
73
|
+
store: persistence.store,
|
|
74
|
+
scope: config.scope,
|
|
75
|
+
subjectId: options.runId,
|
|
76
|
+
directory: path.resolve(options.auditOut),
|
|
77
|
+
signingKey: key,
|
|
78
|
+
config,
|
|
79
|
+
...index && history && options.sessionId ? { session: { id: options.sessionId, index, history } } : {}
|
|
80
|
+
});
|
|
81
|
+
process.stdout.write(options.json ? `${JSON.stringify(manifest, null, 2)}
|
|
82
|
+
` : `Audit pack written to ${path.resolve(options.auditOut)} (${manifest.subject.kind} ${manifest.subject.id}, ${manifest.files.length} files).
|
|
83
|
+
`);
|
|
84
|
+
return manifest;
|
|
85
|
+
} finally {
|
|
86
|
+
history?.close();
|
|
87
|
+
index?.close();
|
|
88
|
+
persistence.close();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
auditPackCli
|
|
93
|
+
};
|