@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,289 @@
|
|
|
1
|
+
import {
|
|
2
|
+
harnessPolicyDecisionEventSchema
|
|
3
|
+
} from "./index-kbrf5bx7.js";
|
|
4
|
+
import {
|
|
5
|
+
openCliSessionStore
|
|
6
|
+
} from "./index-6ehtssyz.js";
|
|
7
|
+
import {
|
|
8
|
+
SqliteDatabase
|
|
9
|
+
} from "./index-f970qtb4.js";
|
|
10
|
+
import {
|
|
11
|
+
streamEventDocument
|
|
12
|
+
} from "./index-5jxm2wy5.js";
|
|
13
|
+
|
|
14
|
+
// packages/core/src/client/service-events.ts
|
|
15
|
+
import { createHash } from "node:crypto";
|
|
16
|
+
import { createRedactionPolicy } from "@zhivex-ai/agents";
|
|
17
|
+
var MAX_SNAPSHOT_BYTES = 2 * 1024 * 1024;
|
|
18
|
+
var TEXT_CHUNK_CHARACTERS = 8192;
|
|
19
|
+
var serializeBoundedSnapshot = (snapshot, currentRun) => {
|
|
20
|
+
let encoded = JSON.stringify(snapshot);
|
|
21
|
+
if (Buffer.byteLength(encoded) <= MAX_SNAPSHOT_BYTES)
|
|
22
|
+
return encoded;
|
|
23
|
+
const historical = Object.keys(snapshot.runs).filter((id) => id !== currentRun);
|
|
24
|
+
const compact = (ids) => {
|
|
25
|
+
for (const field of ["text", "prompt", "tools"])
|
|
26
|
+
for (const id of ids) {
|
|
27
|
+
const run = snapshot.runs[id];
|
|
28
|
+
if (field === "text") {
|
|
29
|
+
if (!run.text)
|
|
30
|
+
continue;
|
|
31
|
+
run.text = "";
|
|
32
|
+
} else {
|
|
33
|
+
if (run[field] === undefined)
|
|
34
|
+
continue;
|
|
35
|
+
delete run[field];
|
|
36
|
+
}
|
|
37
|
+
run.truncated = true;
|
|
38
|
+
encoded = JSON.stringify(snapshot);
|
|
39
|
+
if (Buffer.byteLength(encoded) <= MAX_SNAPSHOT_BYTES)
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
};
|
|
44
|
+
if (compact(historical) || compact([currentRun]))
|
|
45
|
+
return encoded;
|
|
46
|
+
throw new Error("ACTIVITY_SNAPSHOT_LIMIT");
|
|
47
|
+
};
|
|
48
|
+
var openHarnessActivityStore = async (config, options = {}) => {
|
|
49
|
+
const index = await openCliSessionStore({ workspace: config.workspace, stateDirectory: config.stateDirectory, scope: config.scope });
|
|
50
|
+
const scope = `${index.workspaceKey}:${index.scopeKey}`;
|
|
51
|
+
const db = new SqliteDatabase(index.databasePath);
|
|
52
|
+
index.close();
|
|
53
|
+
const maxEvents = options.maxEvents ?? 1e4, retentionMs = options.retentionMs ?? 7 * 24 * 3600 * 1000, now = options.now ?? Date.now;
|
|
54
|
+
if (!Number.isSafeInteger(maxEvents) || maxEvents < 1 || maxEvents > 1e5 || !Number.isSafeInteger(retentionMs) || retentionMs < 1) {
|
|
55
|
+
db.close();
|
|
56
|
+
throw new Error("ACTIVITY_LIMIT_INVALID");
|
|
57
|
+
}
|
|
58
|
+
db.exec(`CREATE TABLE IF NOT EXISTS client_activity_events(sequence INTEGER PRIMARY KEY AUTOINCREMENT, scope TEXT NOT NULL, session TEXT NOT NULL, run TEXT NOT NULL, at INTEGER NOT NULL, activity TEXT NOT NULL);
|
|
59
|
+
CREATE INDEX IF NOT EXISTS client_activity_scope ON client_activity_events(scope, session, sequence);
|
|
60
|
+
CREATE INDEX IF NOT EXISTS client_activity_sequence ON client_activity_events(scope, sequence);
|
|
61
|
+
CREATE INDEX IF NOT EXISTS client_activity_age ON client_activity_events(scope, at);
|
|
62
|
+
CREATE TABLE IF NOT EXISTS client_activity_snapshots(scope TEXT NOT NULL, session TEXT NOT NULL, sequence INTEGER NOT NULL, expired_through INTEGER NOT NULL DEFAULT 0, snapshot TEXT NOT NULL, PRIMARY KEY(scope,session));`);
|
|
63
|
+
const readSnapshot = db.query("SELECT snapshot,expired_through FROM client_activity_snapshots WHERE scope=? AND session=?");
|
|
64
|
+
const retentionCutoff = db.query("SELECT sequence FROM client_activity_events WHERE scope=? ORDER BY sequence DESC LIMIT 1 OFFSET ?");
|
|
65
|
+
const expiredEvents = db.query(`SELECT session,MAX(sequence) AS seq FROM (
|
|
66
|
+
SELECT session,sequence FROM client_activity_events WHERE scope=? AND at < ?
|
|
67
|
+
UNION ALL SELECT session,sequence FROM client_activity_events WHERE scope=? AND sequence<=?
|
|
68
|
+
) GROUP BY session`);
|
|
69
|
+
const markExpired = db.query("UPDATE client_activity_snapshots SET expired_through=MAX(expired_through,?) WHERE scope=? AND session=?");
|
|
70
|
+
const deleteExpired = db.query("DELETE FROM client_activity_events WHERE scope=? AND session=? AND sequence<=?");
|
|
71
|
+
const insertEvent = db.query("INSERT INTO client_activity_events(scope,session,run,at,activity) VALUES(?,?,?,?,?)");
|
|
72
|
+
const lastSequence = db.query("SELECT last_insert_rowid() AS seq");
|
|
73
|
+
const saveSnapshot = db.query("INSERT INTO client_activity_snapshots(scope,session,sequence,snapshot) VALUES(?,?,?,?) ON CONFLICT(scope,session) DO UPDATE SET sequence=excluded.sequence,snapshot=excluded.snapshot");
|
|
74
|
+
const dataVersion = db.query("PRAGMA data_version");
|
|
75
|
+
let cached;
|
|
76
|
+
const readEvents = db.query("SELECT sequence,session,run,at,activity FROM client_activity_events WHERE scope=? AND session=? AND sequence>? ORDER BY sequence LIMIT 201");
|
|
77
|
+
const redaction = createRedactionPolicy({ includeEmails: true });
|
|
78
|
+
const redact = (text) => {
|
|
79
|
+
let result = text;
|
|
80
|
+
for (const secret of options.sensitiveValues ?? [])
|
|
81
|
+
if (secret)
|
|
82
|
+
result = result.split(secret).join("[REDACTED]");
|
|
83
|
+
return redaction.redactText(result).replace(/\b(?:sk|ghp|github_pat|xox[baprs])[-_][A-Za-z0-9_-]+/gi, "[REDACTED]");
|
|
84
|
+
};
|
|
85
|
+
const redactValue = (value) => typeof value === "string" ? redact(value) : Array.isArray(value) ? value.map(redactValue) : value && typeof value === "object" ? Object.fromEntries(Object.entries(value).map(([k, v]) => [k, redactValue(v)])) : value;
|
|
86
|
+
const tails = new Map;
|
|
87
|
+
const discard = new Set;
|
|
88
|
+
const flush = (key, chunk, final = false) => {
|
|
89
|
+
let text = (tails.get(key) ?? "") + chunk;
|
|
90
|
+
for (const secret of options.sensitiveValues ?? [])
|
|
91
|
+
if (secret)
|
|
92
|
+
text = text.split(secret).join("[REDACTED]");
|
|
93
|
+
if (discard.has(key)) {
|
|
94
|
+
const end = text.search(/\s/);
|
|
95
|
+
if (end < 0 && !final)
|
|
96
|
+
return "";
|
|
97
|
+
text = end < 0 ? "" : text.slice(end);
|
|
98
|
+
discard.delete(key);
|
|
99
|
+
}
|
|
100
|
+
let boundary = final ? text.length : text.match(/^[\s\S]*\s/)?.[0].length ?? 0;
|
|
101
|
+
if (!final)
|
|
102
|
+
for (const secret of options.sensitiveValues ?? []) {
|
|
103
|
+
if (!secret)
|
|
104
|
+
continue;
|
|
105
|
+
let start = text.indexOf(secret[0], Math.max(0, text.length - secret.length + 1));
|
|
106
|
+
while (start >= 0 && start < boundary) {
|
|
107
|
+
if (secret.startsWith(text.slice(start))) {
|
|
108
|
+
boundary = start;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
start = text.indexOf(secret[0], start + 1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
let result = redact(text.slice(0, boundary));
|
|
115
|
+
text = text.slice(boundary);
|
|
116
|
+
if (text.length > 16384) {
|
|
117
|
+
result += "[TRUNCATED]";
|
|
118
|
+
text = "";
|
|
119
|
+
discard.add(key);
|
|
120
|
+
}
|
|
121
|
+
tails.set(key, text);
|
|
122
|
+
return result;
|
|
123
|
+
};
|
|
124
|
+
const snapshot = (sessionId) => {
|
|
125
|
+
const row = readSnapshot.get(scope, sessionId);
|
|
126
|
+
return { state: row ? JSON.parse(row.snapshot) : { schemaVersion: 1, sessionId, sequence: 0, runs: {} }, expiredThrough: row?.expired_through ?? 0 };
|
|
127
|
+
};
|
|
128
|
+
const prune = () => {
|
|
129
|
+
const cutoff = retentionCutoff.get(scope, maxEvents)?.sequence ?? 0;
|
|
130
|
+
const expired = expiredEvents.all(scope, now() - retentionMs, scope, cutoff);
|
|
131
|
+
for (const row of expired) {
|
|
132
|
+
markExpired.run(row.seq, scope, row.session);
|
|
133
|
+
deleteExpired.run(scope, row.session, row.seq);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const write = (sessionId, runId, activity) => {
|
|
137
|
+
if (!/^[A-Za-z0-9._:-]{1,128}$/.test(sessionId) || !/^[A-Za-z0-9._:-]{1,128}$/.test(runId))
|
|
138
|
+
throw new Error("ACTIVITY_ID_INVALID");
|
|
139
|
+
const at = now();
|
|
140
|
+
const encoded = JSON.stringify(activity);
|
|
141
|
+
if (Buffer.byteLength(encoded) > 64 * 1024)
|
|
142
|
+
throw new Error("ACTIVITY_TOO_LARGE");
|
|
143
|
+
db.exec("BEGIN IMMEDIATE");
|
|
144
|
+
try {
|
|
145
|
+
const version = dataVersion.get().data_version;
|
|
146
|
+
const runs = cached?.sessionId === sessionId && cached.version === version ? { ...cached.runs } : Object.fromEntries(Object.entries(snapshot(sessionId).state.runs).map(([id, run]) => [id, JSON.stringify(run)]));
|
|
147
|
+
const previous = Object.hasOwn(runs, runId) ? runs[runId] : undefined;
|
|
148
|
+
if (!previous && Object.keys(runs).length >= 1000)
|
|
149
|
+
throw new Error("ACTIVITY_RUN_LIMIT");
|
|
150
|
+
const state = previous ? JSON.parse(previous) : { text: "", status: "running", truncated: false };
|
|
151
|
+
if (typeof activity.textDelta === "string") {
|
|
152
|
+
state.text += activity.textDelta;
|
|
153
|
+
if (state.text.length > 256 * 1024) {
|
|
154
|
+
state.text = state.text.slice(-256 * 1024);
|
|
155
|
+
state.truncated = true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (activity.type === "user-message" && typeof activity.prompt === "string")
|
|
159
|
+
state.prompt = activity.prompt;
|
|
160
|
+
if (typeof activity.toolCallId === "string" && typeof activity.toolName === "string") {
|
|
161
|
+
state.tools ??= {};
|
|
162
|
+
const key = `tool:${activity.toolCallId}`;
|
|
163
|
+
if (state.tools[key] || Object.keys(state.tools).length < 256) {
|
|
164
|
+
const status = activity.type === "tool-result" ? activity.isError === true || activity.timedOut === true || typeof activity.exitCode === "number" && activity.exitCode !== 0 ? "failed" : "completed" : "running";
|
|
165
|
+
state.tools[key] = { name: activity.toolName, status, ...typeof activity.exitCode === "number" ? { exitCode: activity.exitCode } : {}, ...typeof activity.timedOut === "boolean" ? { timedOut: activity.timedOut } : {} };
|
|
166
|
+
} else
|
|
167
|
+
state.truncated = true;
|
|
168
|
+
}
|
|
169
|
+
if (typeof activity.status === "string" && (activity.type === "checkpoint" || activity.type === "agent-run-finish"))
|
|
170
|
+
state.status = activity.status;
|
|
171
|
+
if (activity.type === "agent-run-start")
|
|
172
|
+
state.status = "running";
|
|
173
|
+
if (activity.type === "tool-approval-request" || activity.type === "agent-approval-request")
|
|
174
|
+
state.status = "waiting_approval";
|
|
175
|
+
insertEvent.run(scope, sessionId, runId, at, encoded);
|
|
176
|
+
const sequence = lastSequence.get().seq;
|
|
177
|
+
Object.defineProperty(runs, runId, { value: JSON.stringify(state), enumerable: true, configurable: true, writable: true });
|
|
178
|
+
const header = JSON.stringify({ schemaVersion: 1, sessionId, sequence });
|
|
179
|
+
let bounded = header.slice(0, -1) + ',"runs":{' + Object.entries(runs).map(([id, run]) => JSON.stringify(id) + ":" + run).join(",") + "}}";
|
|
180
|
+
if (Buffer.byteLength(bounded) > MAX_SNAPSHOT_BYTES) {
|
|
181
|
+
bounded = serializeBoundedSnapshot(JSON.parse(bounded), runId);
|
|
182
|
+
const compacted = JSON.parse(bounded);
|
|
183
|
+
for (const [id, run] of Object.entries(compacted.runs))
|
|
184
|
+
runs[id] = JSON.stringify(run);
|
|
185
|
+
}
|
|
186
|
+
saveSnapshot.run(scope, sessionId, sequence, bounded);
|
|
187
|
+
prune();
|
|
188
|
+
db.exec("COMMIT");
|
|
189
|
+
cached = { sessionId, version, runs };
|
|
190
|
+
} catch (e) {
|
|
191
|
+
cached = undefined;
|
|
192
|
+
db.exec("ROLLBACK");
|
|
193
|
+
throw e;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const writeText = (sessionId, runId, text) => {
|
|
197
|
+
for (let start = 0;start < text.length; ) {
|
|
198
|
+
let end = Math.min(text.length, start + TEXT_CHUNK_CHARACTERS);
|
|
199
|
+
if (end < text.length && /[\uD800-\uDBFF]/.test(text[end - 1]) && /[\uDC00-\uDFFF]/.test(text[end]))
|
|
200
|
+
end--;
|
|
201
|
+
write(sessionId, runId, { type: "text-delta", textDelta: text.slice(start, end) });
|
|
202
|
+
start = end;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
return {
|
|
206
|
+
policyDecision(sessionId, runId, event) {
|
|
207
|
+
write(sessionId, runId, redactValue(harnessPolicyDecisionEventSchema.parse(event)));
|
|
208
|
+
},
|
|
209
|
+
prompt(sessionId, runId, prompt) {
|
|
210
|
+
const safe = redact(prompt);
|
|
211
|
+
const activity = (value) => ({ type: "user-message", prompt: value });
|
|
212
|
+
let bounded = safe;
|
|
213
|
+
if (Buffer.byteLength(JSON.stringify(activity(safe))) > 60 * 1024) {
|
|
214
|
+
const characters = Array.from(safe);
|
|
215
|
+
let lower = 0, upper = characters.length;
|
|
216
|
+
while (lower < upper) {
|
|
217
|
+
const middle = Math.ceil((lower + upper) / 2);
|
|
218
|
+
const candidate = characters.slice(0, middle).join("") + "[TRUNCATED]";
|
|
219
|
+
if (Buffer.byteLength(JSON.stringify(activity(candidate))) <= 60 * 1024)
|
|
220
|
+
lower = middle;
|
|
221
|
+
else
|
|
222
|
+
upper = middle - 1;
|
|
223
|
+
}
|
|
224
|
+
bounded = characters.slice(0, lower).join("") + "[TRUNCATED]";
|
|
225
|
+
}
|
|
226
|
+
write(sessionId, runId, activity(bounded));
|
|
227
|
+
},
|
|
228
|
+
append(sessionId, runId, event) {
|
|
229
|
+
const key = `${sessionId}:${runId}`;
|
|
230
|
+
if (event.type === "text-delta") {
|
|
231
|
+
const textDelta = flush(key, event.textDelta);
|
|
232
|
+
writeText(sessionId, runId, textDelta);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (event.type === "agent-run-finish" || event.type === "error") {
|
|
236
|
+
const textDelta = flush(key, "", true);
|
|
237
|
+
writeText(sessionId, runId, textDelta);
|
|
238
|
+
tails.delete(key);
|
|
239
|
+
}
|
|
240
|
+
const projected = streamEventDocument(event);
|
|
241
|
+
if (projected) {
|
|
242
|
+
let receipt = {};
|
|
243
|
+
if (event.type === "tool-result" && event.toolResult.toolName === "run_check") {
|
|
244
|
+
const output = event.toolResult.output;
|
|
245
|
+
if (output && typeof output === "object" && !Array.isArray(output) && "exitCode" in output && Number.isSafeInteger(output.exitCode))
|
|
246
|
+
receipt = { exitCode: output.exitCode, timedOut: "timedOut" in output && output.timedOut === true };
|
|
247
|
+
}
|
|
248
|
+
write(sessionId, runId, redactValue({ ...projected, ...receipt }));
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
checkpoint(sessionId, runId, status) {
|
|
252
|
+
const key = `${sessionId}:${runId}`;
|
|
253
|
+
const textDelta = flush(key, "", true);
|
|
254
|
+
writeText(sessionId, runId, textDelta);
|
|
255
|
+
tails.delete(key);
|
|
256
|
+
write(sessionId, runId, { type: "checkpoint", status });
|
|
257
|
+
},
|
|
258
|
+
replay(sessionId, after = 0) {
|
|
259
|
+
if (!Number.isSafeInteger(after) || after < 0)
|
|
260
|
+
throw new Error("ACTIVITY_CURSOR_INVALID");
|
|
261
|
+
db.exec("BEGIN IMMEDIATE");
|
|
262
|
+
try {
|
|
263
|
+
prune();
|
|
264
|
+
db.exec("COMMIT");
|
|
265
|
+
} catch (e) {
|
|
266
|
+
cached = undefined;
|
|
267
|
+
db.exec("ROLLBACK");
|
|
268
|
+
throw e;
|
|
269
|
+
}
|
|
270
|
+
const current = snapshot(sessionId);
|
|
271
|
+
const expired = after < current.expiredThrough;
|
|
272
|
+
if (after > current.state.sequence)
|
|
273
|
+
throw new Error("ACTIVITY_CURSOR_AHEAD");
|
|
274
|
+
if (expired)
|
|
275
|
+
return { schemaVersion: 1, cursorExpired: true, hasMore: false, policyEvidenceIncomplete: true, nextCursor: current.state.sequence, events: [], snapshot: current.state };
|
|
276
|
+
const rows = readEvents.all(scope, sessionId, after);
|
|
277
|
+
const events = rows.slice(0, 200).map((row) => ({ schemaVersion: 1, eventId: createHash("sha256").update(`${scope}:${row.sequence}`).digest("hex"), sequence: row.sequence, sessionId: row.session, runId: row.run, at: row.at, activity: JSON.parse(row.activity) }));
|
|
278
|
+
return { schemaVersion: 1, cursorExpired: false, hasMore: rows.length > 200, policyEvidenceIncomplete: current.expiredThrough > 0, nextCursor: events.at(-1)?.sequence ?? after, events };
|
|
279
|
+
},
|
|
280
|
+
close() {
|
|
281
|
+
db.close();
|
|
282
|
+
cached = undefined;
|
|
283
|
+
tails.clear();
|
|
284
|
+
discard.clear();
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export { openHarnessActivityStore };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/workspace/edit-contracts.ts
|
|
1
|
+
// packages/core/src/workspace/edit-contracts.ts
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -144,7 +144,7 @@ var editContractDocument = (kind, result) => ({
|
|
|
144
144
|
result
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
-
// src/persistence/persistence-secrets.ts
|
|
147
|
+
// packages/core/src/persistence/persistence-secrets.ts
|
|
148
148
|
var protectedValues = new Set;
|
|
149
149
|
function protectPersistenceSecret(secret) {
|
|
150
150
|
if (!secret)
|
|
@@ -177,7 +177,7 @@ function assertNoPersistenceSecret(value) {
|
|
|
177
177
|
visit(value);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
// src/persistence/sqlite-access.ts
|
|
180
|
+
// packages/core/src/persistence/sqlite-access.ts
|
|
181
181
|
import { closeSync, constants, fchmodSync, fstatSync, lstatSync, openSync, realpathSync } from "node:fs";
|
|
182
182
|
import path2 from "node:path";
|
|
183
183
|
var O_SHLOCK = 16;
|
|
@@ -273,7 +273,7 @@ function validateSqliteAccess(lease, databasePath) {
|
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
// src/persistence/sqlite-database.ts
|
|
276
|
+
// packages/core/src/persistence/sqlite-database.ts
|
|
277
277
|
import { createRequire } from "node:module";
|
|
278
278
|
var require2 = createRequire(process.execPath);
|
|
279
279
|
var DatabaseSyncConstructor;
|
|
@@ -389,143 +389,7 @@ class SqliteDatabase {
|
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
-
// src/
|
|
393
|
-
import { constants as fsConstants } from "node:fs";
|
|
394
|
-
import { open } from "node:fs/promises";
|
|
395
|
-
import path3 from "node:path";
|
|
396
|
-
var sameOpenFile = (before, after) => before.dev === after.dev && before.ino === after.ino && before.size === after.size && before.mtimeMs === after.mtimeMs && before.ctimeMs === after.ctimeMs && before.mode === after.mode && before.nlink === after.nlink;
|
|
397
|
-
|
|
398
|
-
class UnsafeFileTypeError extends Error {
|
|
399
|
-
constructor(label) {
|
|
400
|
-
super(`${label} must be a regular file and must not be a symbolic link.`);
|
|
401
|
-
this.name = "UnsafeFileTypeError";
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
class FileSizeLimitError extends Error {
|
|
406
|
-
label;
|
|
407
|
-
maxBytes;
|
|
408
|
-
constructor(label, maxBytes) {
|
|
409
|
-
super(`${label} exceeds the ${maxBytes}-byte limit.`);
|
|
410
|
-
this.label = label;
|
|
411
|
-
this.maxBytes = maxBytes;
|
|
412
|
-
this.name = "FileSizeLimitError";
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
class FileChangedWhileReadingError extends Error {
|
|
417
|
-
constructor(label) {
|
|
418
|
-
super(`${label} changed while it was being read.`);
|
|
419
|
-
this.name = "FileChangedWhileReadingError";
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
var invalidFileError = (label) => new UnsafeFileTypeError(label);
|
|
423
|
-
var openRegularFileNoFollow = async (target, label) => {
|
|
424
|
-
try {
|
|
425
|
-
const flags = fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW | fsConstants.O_NONBLOCK;
|
|
426
|
-
let absolute = path3.resolve(target);
|
|
427
|
-
if (process.platform === "darwin") {
|
|
428
|
-
absolute = absolute.replace(/^\/(tmp|var|etc)(\/|$)/, "/private/$1$2");
|
|
429
|
-
return await open(absolute, fsConstants.O_RDONLY | fsConstants.O_NONBLOCK | 536870912, 384);
|
|
430
|
-
}
|
|
431
|
-
if (process.platform !== "linux")
|
|
432
|
-
throw new Error("Safe descriptor-relative reads require Linux or macOS.");
|
|
433
|
-
const segments = absolute.split("/").filter(Boolean);
|
|
434
|
-
const leaf = segments.pop();
|
|
435
|
-
if (!leaf)
|
|
436
|
-
throw invalidFileError(label);
|
|
437
|
-
let directory = await open("/", fsConstants.O_RDONLY | fsConstants.O_DIRECTORY);
|
|
438
|
-
try {
|
|
439
|
-
for (const segment of segments) {
|
|
440
|
-
const next = await open(`/proc/self/fd/${directory.fd}/${segment}`, fsConstants.O_RDONLY | fsConstants.O_DIRECTORY | fsConstants.O_NOFOLLOW);
|
|
441
|
-
await directory.close();
|
|
442
|
-
directory = next;
|
|
443
|
-
}
|
|
444
|
-
return await open(`/proc/self/fd/${directory.fd}/${leaf}`, flags);
|
|
445
|
-
} finally {
|
|
446
|
-
await directory.close();
|
|
447
|
-
}
|
|
448
|
-
} catch (error) {
|
|
449
|
-
const code = error.code;
|
|
450
|
-
if (code === "ELOOP" || code === "EMLINK" || code === "ENOTDIR")
|
|
451
|
-
throw invalidFileError(label);
|
|
452
|
-
throw error;
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
var statRegularFileNoFollow = async (target, options) => {
|
|
456
|
-
const handle = await openRegularFileNoFollow(target, options.label);
|
|
457
|
-
try {
|
|
458
|
-
const stat = await handle.stat();
|
|
459
|
-
if (!stat.isFile() || options.requireSingleLink && stat.nlink !== 1) {
|
|
460
|
-
throw invalidFileError(options.label);
|
|
461
|
-
}
|
|
462
|
-
return stat;
|
|
463
|
-
} finally {
|
|
464
|
-
await handle.close();
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
var readRegularFileNoFollow = async (target, options) => {
|
|
468
|
-
const handle = await openRegularFileNoFollow(target, options.label);
|
|
469
|
-
try {
|
|
470
|
-
const before = await handle.stat();
|
|
471
|
-
if (!before.isFile() || options.requireSingleLink && before.nlink !== 1) {
|
|
472
|
-
throw invalidFileError(options.label);
|
|
473
|
-
}
|
|
474
|
-
if (!Number.isSafeInteger(before.size) || before.size < 0) {
|
|
475
|
-
throw new Error(`${options.label} has an unsupported size.`);
|
|
476
|
-
}
|
|
477
|
-
if (!Number.isSafeInteger(options.maxBytes) || options.maxBytes < 0) {
|
|
478
|
-
throw new Error(`${options.label} has an invalid byte limit.`);
|
|
479
|
-
}
|
|
480
|
-
if (before.size > options.maxBytes) {
|
|
481
|
-
throw new FileSizeLimitError(options.label, options.maxBytes);
|
|
482
|
-
}
|
|
483
|
-
const contents = Buffer.alloc(before.size);
|
|
484
|
-
let offset = 0;
|
|
485
|
-
while (offset < contents.byteLength) {
|
|
486
|
-
const { bytesRead } = await handle.read(contents, offset, contents.byteLength - offset, offset);
|
|
487
|
-
if (bytesRead === 0)
|
|
488
|
-
break;
|
|
489
|
-
offset += bytesRead;
|
|
490
|
-
}
|
|
491
|
-
const probe = Buffer.allocUnsafe(1);
|
|
492
|
-
const { bytesRead: extraBytes } = await handle.read(probe, 0, 1, before.size);
|
|
493
|
-
const after = await handle.stat();
|
|
494
|
-
if (offset !== before.size || extraBytes !== 0 || !sameOpenFile(before, after) || options.requireSingleLink && after.nlink !== 1) {
|
|
495
|
-
throw new FileChangedWhileReadingError(options.label);
|
|
496
|
-
}
|
|
497
|
-
return { contents, stat: after };
|
|
498
|
-
} finally {
|
|
499
|
-
await handle.close();
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
async function* readRegularFileChunksNoFollow(target, options) {
|
|
503
|
-
const handle = await openRegularFileNoFollow(target, options.label);
|
|
504
|
-
try {
|
|
505
|
-
const before = await handle.stat();
|
|
506
|
-
if (!before.isFile() || options.requireSingleLink && before.nlink !== 1)
|
|
507
|
-
throw invalidFileError(options.label);
|
|
508
|
-
if (options.requirePrivate && (before.mode & 63) !== 0)
|
|
509
|
-
throw new Error(`${options.label} permissions must not grant group or other access.`);
|
|
510
|
-
let offset = 0;
|
|
511
|
-
while (offset < before.size) {
|
|
512
|
-
const buffer = Buffer.allocUnsafe(Math.min(64 * 1024, before.size - offset));
|
|
513
|
-
const { bytesRead: bytesRead2 } = await handle.read(buffer, 0, buffer.length, offset);
|
|
514
|
-
if (!bytesRead2)
|
|
515
|
-
throw new FileChangedWhileReadingError(options.label);
|
|
516
|
-
offset += bytesRead2;
|
|
517
|
-
yield buffer.subarray(0, bytesRead2);
|
|
518
|
-
}
|
|
519
|
-
const probe = Buffer.allocUnsafe(1);
|
|
520
|
-
const { bytesRead } = await handle.read(probe, 0, 1, offset);
|
|
521
|
-
if (bytesRead || !sameOpenFile(before, await handle.stat()))
|
|
522
|
-
throw new FileChangedWhileReadingError(options.label);
|
|
523
|
-
} finally {
|
|
524
|
-
await handle.close();
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
// src/runtime/task-acceptance-checks.ts
|
|
392
|
+
// packages/core/src/runtime/task-acceptance-checks.ts
|
|
529
393
|
import { createHash as createHash2 } from "node:crypto";
|
|
530
394
|
import { z as z2 } from "zod";
|
|
531
395
|
var sha = z2.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
@@ -628,7 +492,7 @@ function reconciledReceipt(receipt, journal) {
|
|
|
628
492
|
return true;
|
|
629
493
|
}
|
|
630
494
|
|
|
631
|
-
// src/runtime/task-acceptance-delivery.ts
|
|
495
|
+
// packages/core/src/runtime/task-acceptance-delivery.ts
|
|
632
496
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
633
497
|
import { z as z3 } from "zod";
|
|
634
498
|
var scopes = new AsyncLocalStorage;
|
|
@@ -716,4 +580,4 @@ async function taskAcceptanceOutcome(state, ledger) {
|
|
|
716
580
|
return { ...outcome, ...delivery && delivery.runId === state.runId ? { delivery: structuredClone(delivery) } : {} };
|
|
717
581
|
}
|
|
718
582
|
|
|
719
|
-
export { EDIT_CONTRACT_SCHEMA_VERSION, EDIT_DIGEST_ALGORITHM, MAX_EDIT_CHANGES, MAX_EDIT_FILE_BYTES, MAX_EDIT_PROPOSAL_BYTES, fileDigestSchema, workspaceFilePathSchema, editChangeSchema, editChangesSchema, editProposalInputSchema, editProposalChangeSchema, editProposalSchema, applyEditProposalInputSchema, moveFileInputSchema, quarantineFileInputSchema, restoreFileInputSchema, mutationOperationSchema, mutationAuditEntrySchema, createEditProposal, validateEditProposal, editContractDocument,
|
|
583
|
+
export { EDIT_CONTRACT_SCHEMA_VERSION, EDIT_DIGEST_ALGORITHM, MAX_EDIT_CHANGES, MAX_EDIT_FILE_BYTES, MAX_EDIT_PROPOSAL_BYTES, fileDigestSchema, workspaceFilePathSchema, editChangeSchema, editChangesSchema, editProposalInputSchema, editProposalChangeSchema, editProposalSchema, applyEditProposalInputSchema, moveFileInputSchema, quarantineFileInputSchema, restoreFileInputSchema, mutationOperationSchema, mutationAuditEntrySchema, createEditProposal, validateEditProposal, editContractDocument, taskCheckReceiptSchema, createTaskAcceptanceChecks, withTaskAcceptanceDelivery, assertTaskAcceptanceImport, taskAcceptanceChecks, taskAcceptanceDeliveryDiagnostic, confirmTaskAcceptanceImport, taskAcceptanceOutcome, protectPersistenceSecret, acquireSqliteAccess, exclusiveSqliteAccessDescriptor, adoptExclusiveSqliteAccess, SqliteDatabase };
|