@zhivex-ai/harness 1.6.3 → 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 +16 -3
- package/README.md +17 -5
- package/SECURITY.md +1 -1
- package/SUPPORT.md +2 -2
- package/benchmarks/README.md +98 -0
- package/contracts/engine-api.json +1587 -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/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-s9n693by.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-1epvek01.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-mbcq96nx.js → cli-entry-dksm56sj.js} +39 -293
- package/dist/{cli-entry-rsx0wpvs.js → cli-entry-eka68ttb.js} +4087 -4625
- package/dist/cli-entry-h7dcah4p.js +137 -0
- package/dist/cli-entry-kwk23ktq.js +33 -0
- package/dist/{cli-entry-nyzyvf24.js → cli-entry-vmce694z.js} +1286 -3142
- package/dist/cli-entry-wanv05db.js +1113 -0
- package/dist/{cli-yxvq8qf1.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 +4 -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 +31 -5
- 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.d.ts +4 -0
- package/dist/engine/index.js +117 -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 +2329 -1096
- package/dist/index-09rsdr2d.js +1744 -0
- package/dist/index-0csc5sc7.js +139 -0
- package/dist/{index-4mn6m3bq.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-rgqzdgv6.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-fqqz1yt8.js → index-6ehtssyz.js} +369 -335
- package/dist/index-76kpdbpw.js +80 -0
- package/dist/{index-5nmm0642.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-hhrnrqfc.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-j466sekf.js → index-mkt5yrax.js} +31 -105
- package/dist/{index-nxmk6re7.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-vn91b9z1.js → index-sx1t6dnd.js} +3721 -2382
- package/dist/index-tar0ngkm.js +359 -0
- package/dist/index-tn58cr6w.js +471 -0
- package/dist/{index-w0m1nckc.js → index-v79s9bf9.js} +118 -45
- 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-amjttjaj.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/agent-profile.d.ts +12 -0
- package/dist/runtime/harness.d.ts +13 -0
- package/dist/runtime/known-file-preload.d.ts +35 -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 +2249 -1016
- 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 +11 -5
- package/docs/CODE_WEB_TASKS.md +3 -114
- package/docs/CONTEXT_ENGINEERING.md +93 -0
- package/docs/ENGINE_API.md +9 -2
- 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/PROJECT_MEMORY.md +1 -1
- package/docs/README.md +23 -4
- package/evaluations/representative-assembly-matrix.json +19 -1
- package/examples/README.md +4 -4
- 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 +232 -26
- package/dist/cli/console/console-model-catalog.d.ts +0 -8
- package/dist/index-2yyfg69h.js +0 -619
- package/dist/index-3wwfn5n6.js +0 -270
- package/dist/index-4gt045j0.js +0 -288
- package/dist/index-4jw3tvy8.js +0 -301
- package/dist/service-client-cli-xbj7j5kj.js +0 -1251
|
@@ -0,0 +1,1166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connectApplication
|
|
3
|
+
} from "./cli-entry-bxjbs6qq.js";
|
|
4
|
+
import {
|
|
5
|
+
ActivityHistory,
|
|
6
|
+
ConsoleInput,
|
|
7
|
+
ToolActivity,
|
|
8
|
+
formatAppliedFiles,
|
|
9
|
+
formatConsoleHelp,
|
|
10
|
+
formatConsoleWelcome,
|
|
11
|
+
formatPolicyDecision,
|
|
12
|
+
navigateConsole,
|
|
13
|
+
printPolicyInspection
|
|
14
|
+
} from "./cli-entry-btkpb4h1.js";
|
|
15
|
+
import {
|
|
16
|
+
sanitizeTerminalText
|
|
17
|
+
} from "./cli-entry-eka68ttb.js";
|
|
18
|
+
import {
|
|
19
|
+
CLI_EVENT_SCHEMA_VERSION,
|
|
20
|
+
CLI_JSON_SCHEMA_VERSION,
|
|
21
|
+
changeEnvelopeSchema,
|
|
22
|
+
serializeStreamResult
|
|
23
|
+
} from "./cli-entry-cpm89r9q.js";
|
|
24
|
+
import"./cli-entry-wanv05db.js";
|
|
25
|
+
import"./cli-entry-dksm56sj.js";
|
|
26
|
+
import {
|
|
27
|
+
harnessPolicyDecisionEventSchema
|
|
28
|
+
} from "./cli-entry-vmce694z.js";
|
|
29
|
+
import {
|
|
30
|
+
HARNESS_VERSION
|
|
31
|
+
} from "./cli-entry-kwk23ktq.js";
|
|
32
|
+
import"./cli-entry-h7dcah4p.js";
|
|
33
|
+
import {
|
|
34
|
+
HARNESS_ERROR_CODES,
|
|
35
|
+
HARNESS_ERROR_SCHEMA_VERSION,
|
|
36
|
+
HarnessConfigError,
|
|
37
|
+
HarnessStateConflictError,
|
|
38
|
+
PROVIDERS,
|
|
39
|
+
reasoningEffortSchema
|
|
40
|
+
} from "./cli-entry-68kqraj7.js";
|
|
41
|
+
import"./cli-entry-1bx83sw4.js";
|
|
42
|
+
|
|
43
|
+
// packages/core/src/cli/service-checkpoints.ts
|
|
44
|
+
import { randomUUID } from "node:crypto";
|
|
45
|
+
async function serviceCheckpointDocument(client, options) {
|
|
46
|
+
const [target = "", second, ...paths] = options.checkpointArguments ?? [];
|
|
47
|
+
const sessionId = ["list", "capture"].includes(options.checkpointsCommand) ? target : options.sessionId;
|
|
48
|
+
const call = async (command) => {
|
|
49
|
+
if (!client.capabilities.includes(String(command.method)))
|
|
50
|
+
throw new HarnessConfigError("The host does not support this checkpoint operation. Update the host before retrying.");
|
|
51
|
+
const response = await client.command(command);
|
|
52
|
+
if (!response.ok)
|
|
53
|
+
throw new HarnessStateConflictError(`Checkpoint command failed: ${response.error.code}. Inspect the saved operation before retrying.`);
|
|
54
|
+
return response.data;
|
|
55
|
+
};
|
|
56
|
+
if (options.checkpointsCommand === "storage")
|
|
57
|
+
return call({ method: "checkpoint.storage" });
|
|
58
|
+
if (options.checkpointsCommand === "prune-review" || options.checkpointsCommand === "prune-apply") {
|
|
59
|
+
const applying = options.checkpointsCommand === "prune-apply";
|
|
60
|
+
const selected = (options.checkpointArguments ?? []).slice(applying ? 1 : 0);
|
|
61
|
+
const selection = { checkpointIds: [], completedRestoreIds: [] };
|
|
62
|
+
for (const item of selected) {
|
|
63
|
+
const match = /^(checkpoint|restore):([0-9a-f-]+)$/i.exec(item);
|
|
64
|
+
if (!match)
|
|
65
|
+
throw new HarnessConfigError("Select exact IDs as checkpoint:<id> or restore:<id>.");
|
|
66
|
+
(match[1].toLowerCase() === "checkpoint" ? selection.checkpointIds : selection.completedRestoreIds).push(match[2]);
|
|
67
|
+
}
|
|
68
|
+
return call({
|
|
69
|
+
method: applying ? "checkpoint.pruneApply" : "checkpoint.pruneReview",
|
|
70
|
+
selection,
|
|
71
|
+
...applying ? { reviewedPlanId: target, idempotencyKey: `retention_cli_${randomUUID()}` } : {}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const source = await call({ method: "session.get", sessionId });
|
|
75
|
+
if (source.kind !== "session")
|
|
76
|
+
throw new HarnessStateConflictError("Unexpected checkpoint session response.");
|
|
77
|
+
const mutation = () => ({ sessionId, expectedRevision: source.session.revision, idempotencyKey: `checkpoint_cli_${randomUUID()}` });
|
|
78
|
+
const inspect = async (checkpointId) => {
|
|
79
|
+
const result = await call({ method: "checkpoint.inspect", sessionId, checkpointId });
|
|
80
|
+
if (result.kind !== "checkpoint")
|
|
81
|
+
throw new HarnessStateConflictError("Unexpected checkpoint inspection.");
|
|
82
|
+
return result.inspection;
|
|
83
|
+
};
|
|
84
|
+
switch (options.checkpointsCommand) {
|
|
85
|
+
case "list":
|
|
86
|
+
return call({ method: "checkpoint.list", sessionId });
|
|
87
|
+
case "capture":
|
|
88
|
+
return call({ method: "checkpoint.capture", ...mutation(), turnId: second, paths });
|
|
89
|
+
case "inspect":
|
|
90
|
+
return { kind: "checkpoint", inspection: await inspect(target) };
|
|
91
|
+
case "prepare": {
|
|
92
|
+
const inspection = await inspect(target);
|
|
93
|
+
const expected = {};
|
|
94
|
+
for (const file of inspection.files) {
|
|
95
|
+
if (file.status !== "available")
|
|
96
|
+
throw new HarnessStateConflictError("Checkpoint contains unavailable files or mode conflicts; inspect before proceeding.");
|
|
97
|
+
expected[file.path] = file.expectedDigest;
|
|
98
|
+
}
|
|
99
|
+
const result = await call({ method: "restore.prepare", ...mutation(), checkpointId: target, expected });
|
|
100
|
+
if (result.kind !== "restore")
|
|
101
|
+
throw new HarnessStateConflictError("Unexpected restore response.");
|
|
102
|
+
return {
|
|
103
|
+
kind: "restore-review",
|
|
104
|
+
operationId: result.operation.id,
|
|
105
|
+
stage: result.operation.stage,
|
|
106
|
+
reviewedProposalId: result.operation.proposalId,
|
|
107
|
+
previewStatus: result.preview.status,
|
|
108
|
+
...result.preview.status === "available" ? { diff: result.preview.diff } : {},
|
|
109
|
+
coverage: inspection.coverage
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
case "review": {
|
|
113
|
+
const result = await call({ method: "restore.get", sessionId, operationId: target });
|
|
114
|
+
if (result.kind !== "restore")
|
|
115
|
+
throw new HarnessStateConflictError("Unexpected restore response.");
|
|
116
|
+
return {
|
|
117
|
+
kind: "restore-review",
|
|
118
|
+
operationId: result.operation.id,
|
|
119
|
+
stage: result.operation.stage,
|
|
120
|
+
reviewedProposalId: result.operation.proposalId,
|
|
121
|
+
forkSessionId: result.operation.forkSessionId,
|
|
122
|
+
previewStatus: result.preview.status,
|
|
123
|
+
...result.preview.status === "available" ? { diff: result.preview.diff } : {},
|
|
124
|
+
coverage: (await inspect(result.operation.checkpointId)).coverage
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
case "apply": {
|
|
128
|
+
const result = await call({ method: "restore.apply", ...mutation(), operationId: target, reviewedProposalId: second });
|
|
129
|
+
if (result.kind !== "restore" || !result.session)
|
|
130
|
+
throw new HarnessStateConflictError("Restore result unavailable; inspect the operation before retrying.");
|
|
131
|
+
return { kind: "restore-completed", operationId: result.operation.id, stage: result.operation.stage, session: result.session };
|
|
132
|
+
}
|
|
133
|
+
case "recover": {
|
|
134
|
+
const result = await call({ method: "restore.recoverFork", ...mutation(), operationId: target, forkSessionId: second });
|
|
135
|
+
if (result.kind !== "restore")
|
|
136
|
+
throw new HarnessStateConflictError("Unexpected restore recovery response.");
|
|
137
|
+
return { kind: "restore-recovery", operationId: result.operation.id, stage: result.operation.stage, forkSessionId: result.operation.forkSessionId };
|
|
138
|
+
}
|
|
139
|
+
default:
|
|
140
|
+
throw new HarnessConfigError("This checkpoint operation does not yet support service mode.");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// packages/core/src/cli/service-client-cli.ts
|
|
145
|
+
import { randomUUID as randomUUID2, createHash } from "node:crypto";
|
|
146
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
147
|
+
|
|
148
|
+
// packages/core/src/client/json-contracts.ts
|
|
149
|
+
import { z } from "zod";
|
|
150
|
+
var observationalDocument = (shape) => z.object(shape).passthrough();
|
|
151
|
+
var jsonBase = { schemaVersion: z.literal(CLI_JSON_SCHEMA_VERSION) };
|
|
152
|
+
var eventBase = {
|
|
153
|
+
schemaVersion: z.literal(CLI_EVENT_SCHEMA_VERSION),
|
|
154
|
+
sequence: z.number().int().nonnegative()
|
|
155
|
+
};
|
|
156
|
+
var nonnegativeInteger = z.number().int().nonnegative();
|
|
157
|
+
var digestSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
158
|
+
var jsonObjectSchema = observationalDocument({});
|
|
159
|
+
var scopeSchema = observationalDocument({
|
|
160
|
+
tenantId: z.string().min(1),
|
|
161
|
+
userId: z.string().min(1).optional(),
|
|
162
|
+
namespace: z.string().min(1).optional()
|
|
163
|
+
});
|
|
164
|
+
var runIdentity = {
|
|
165
|
+
runId: z.string().min(1),
|
|
166
|
+
status: z.string().min(1),
|
|
167
|
+
provider: z.string().min(1),
|
|
168
|
+
model: z.string().min(1)
|
|
169
|
+
};
|
|
170
|
+
var runSummarySchema = observationalDocument({
|
|
171
|
+
...runIdentity,
|
|
172
|
+
revision: nonnegativeInteger,
|
|
173
|
+
scope: scopeSchema,
|
|
174
|
+
steps: nonnegativeInteger,
|
|
175
|
+
toolCalls: nonnegativeInteger,
|
|
176
|
+
toolErrors: nonnegativeInteger,
|
|
177
|
+
pendingApprovals: nonnegativeInteger,
|
|
178
|
+
compactions: nonnegativeInteger,
|
|
179
|
+
childRuns: nonnegativeInteger,
|
|
180
|
+
startedAt: nonnegativeInteger,
|
|
181
|
+
updatedAt: nonnegativeInteger
|
|
182
|
+
});
|
|
183
|
+
var sessionRunSchema = observationalDocument({
|
|
184
|
+
turnId: z.string().min(1),
|
|
185
|
+
sequence: nonnegativeInteger,
|
|
186
|
+
runId: z.string().min(1),
|
|
187
|
+
provider: z.string().min(1),
|
|
188
|
+
model: z.string().min(1),
|
|
189
|
+
status: z.string().min(1),
|
|
190
|
+
createdAt: nonnegativeInteger,
|
|
191
|
+
updatedAt: nonnegativeInteger
|
|
192
|
+
});
|
|
193
|
+
var sessionSchema = observationalDocument({
|
|
194
|
+
schemaVersion: z.literal(1),
|
|
195
|
+
sessionId: z.string().min(1),
|
|
196
|
+
workspaceKey: z.string().min(1),
|
|
197
|
+
scopeKey: z.string().min(1),
|
|
198
|
+
revision: nonnegativeInteger,
|
|
199
|
+
createdAt: nonnegativeInteger,
|
|
200
|
+
updatedAt: nonnegativeInteger,
|
|
201
|
+
runs: z.array(sessionRunSchema)
|
|
202
|
+
});
|
|
203
|
+
var tokenUsageSchema = observationalDocument({
|
|
204
|
+
inputTokens: nonnegativeInteger.optional(),
|
|
205
|
+
cachedInputTokens: nonnegativeInteger.optional(),
|
|
206
|
+
cacheWriteTokens: nonnegativeInteger.optional(),
|
|
207
|
+
outputTokens: nonnegativeInteger.optional(),
|
|
208
|
+
reasoningTokens: nonnegativeInteger.optional(),
|
|
209
|
+
totalTokens: nonnegativeInteger.optional(),
|
|
210
|
+
speed: z.enum(["standard", "fast"]).optional()
|
|
211
|
+
});
|
|
212
|
+
var budgetConfigSchema = observationalDocument({
|
|
213
|
+
unlimitedTokens: z.boolean().optional(),
|
|
214
|
+
unlimitedSteps: z.boolean().optional(),
|
|
215
|
+
unlimitedToolCalls: z.boolean().optional(),
|
|
216
|
+
maxSteps: nonnegativeInteger,
|
|
217
|
+
maxToolCalls: nonnegativeInteger,
|
|
218
|
+
maxToolErrors: nonnegativeInteger,
|
|
219
|
+
maxInputTokens: nonnegativeInteger,
|
|
220
|
+
maxOutputTokens: nonnegativeInteger,
|
|
221
|
+
maxTotalTokens: nonnegativeInteger,
|
|
222
|
+
includeChildRuns: z.boolean()
|
|
223
|
+
});
|
|
224
|
+
var budgetConsumptionSchema = observationalDocument({
|
|
225
|
+
steps: nonnegativeInteger,
|
|
226
|
+
toolCalls: nonnegativeInteger,
|
|
227
|
+
toolErrors: nonnegativeInteger,
|
|
228
|
+
inputTokens: nonnegativeInteger,
|
|
229
|
+
outputTokens: nonnegativeInteger,
|
|
230
|
+
totalTokens: nonnegativeInteger
|
|
231
|
+
});
|
|
232
|
+
var budgetRemainingSchema = observationalDocument({
|
|
233
|
+
steps: nonnegativeInteger.optional(),
|
|
234
|
+
toolCalls: nonnegativeInteger.optional(),
|
|
235
|
+
toolErrors: nonnegativeInteger.optional(),
|
|
236
|
+
inputTokens: nonnegativeInteger.optional(),
|
|
237
|
+
outputTokens: nonnegativeInteger.optional(),
|
|
238
|
+
totalTokens: nonnegativeInteger.optional()
|
|
239
|
+
});
|
|
240
|
+
var budgetStatusSchema = observationalDocument({
|
|
241
|
+
consumption: budgetConsumptionSchema,
|
|
242
|
+
remaining: budgetRemainingSchema,
|
|
243
|
+
includeChildRuns: z.boolean()
|
|
244
|
+
});
|
|
245
|
+
var costEstimateSchema = observationalDocument({
|
|
246
|
+
inputCost: z.number().nonnegative().optional(),
|
|
247
|
+
outputCost: z.number().nonnegative().optional(),
|
|
248
|
+
totalCost: z.number().nonnegative().optional(),
|
|
249
|
+
currency: z.string().min(1).optional(),
|
|
250
|
+
usage: tokenUsageSchema.optional()
|
|
251
|
+
});
|
|
252
|
+
var mutationAuditSchema = observationalDocument({
|
|
253
|
+
id: z.string().min(1),
|
|
254
|
+
operation: z.enum(["create", "update", "move", "quarantine", "restore"]),
|
|
255
|
+
path: z.string().min(1),
|
|
256
|
+
destination: z.string().min(1).optional(),
|
|
257
|
+
beforeDigest: digestSchema.optional(),
|
|
258
|
+
afterDigest: digestSchema.optional(),
|
|
259
|
+
timestamp: z.iso.datetime(),
|
|
260
|
+
quarantineId: z.string().min(1).optional()
|
|
261
|
+
});
|
|
262
|
+
var approvalSummarySchema = observationalDocument({
|
|
263
|
+
id: z.string().min(1),
|
|
264
|
+
kind: z.string().min(1),
|
|
265
|
+
name: z.string().min(1),
|
|
266
|
+
arguments: z.json(),
|
|
267
|
+
childRunId: z.string().min(1).optional(),
|
|
268
|
+
childAgentId: z.string().min(1).optional()
|
|
269
|
+
});
|
|
270
|
+
var childRunSummarySchema = observationalDocument({
|
|
271
|
+
runId: z.string().min(1),
|
|
272
|
+
agentId: z.string().min(1).optional(),
|
|
273
|
+
toolName: z.string().min(1).optional(),
|
|
274
|
+
status: z.string().min(1),
|
|
275
|
+
steps: nonnegativeInteger,
|
|
276
|
+
toolCalls: nonnegativeInteger,
|
|
277
|
+
toolErrors: nonnegativeInteger,
|
|
278
|
+
usage: tokenUsageSchema.optional()
|
|
279
|
+
});
|
|
280
|
+
var capabilityReportSchema = observationalDocument({
|
|
281
|
+
provider: z.string().min(1),
|
|
282
|
+
model: z.string().min(1),
|
|
283
|
+
supportTier: z.string().min(1).optional(),
|
|
284
|
+
capabilities: observationalDocument({
|
|
285
|
+
streaming: z.boolean(),
|
|
286
|
+
tools: z.boolean(),
|
|
287
|
+
"structured-output": z.boolean(),
|
|
288
|
+
"parallel-tools": z.boolean(),
|
|
289
|
+
reasoning: z.boolean(),
|
|
290
|
+
"web-search": z.boolean()
|
|
291
|
+
})
|
|
292
|
+
});
|
|
293
|
+
var providerConfigurationSchema = z.object({
|
|
294
|
+
customEndpoint: z.boolean(),
|
|
295
|
+
endpointValid: z.boolean(),
|
|
296
|
+
endpointSecure: z.boolean()
|
|
297
|
+
}).catchall(z.boolean());
|
|
298
|
+
var providerAvailabilitySchema = observationalDocument({
|
|
299
|
+
id: z.string().min(1),
|
|
300
|
+
name: z.string().min(1),
|
|
301
|
+
defaultModel: z.string().min(1),
|
|
302
|
+
credentialNames: z.array(z.string().min(1)),
|
|
303
|
+
capabilities: z.array(z.enum(["streaming", "tool-calling", "approval-resume"])),
|
|
304
|
+
support: z.enum(["certified", "provisional"]),
|
|
305
|
+
configured: z.boolean(),
|
|
306
|
+
credentials: z.array(observationalDocument({
|
|
307
|
+
name: z.string().min(1),
|
|
308
|
+
present: z.boolean()
|
|
309
|
+
})),
|
|
310
|
+
configuration: providerConfigurationSchema
|
|
311
|
+
});
|
|
312
|
+
var orchestrationConfigSchema = observationalDocument({
|
|
313
|
+
profiles: z.array(z.enum(["explorer", "implementer", "tester", "reviewer"])),
|
|
314
|
+
childBudget: budgetConfigSchema,
|
|
315
|
+
childTimeoutMs: nonnegativeInteger,
|
|
316
|
+
maxParallelReviews: nonnegativeInteger
|
|
317
|
+
});
|
|
318
|
+
var executionConfigSchema = z.discriminatedUnion("backend", [
|
|
319
|
+
observationalDocument({ backend: z.literal("none") }),
|
|
320
|
+
observationalDocument({
|
|
321
|
+
backend: z.literal("oci"),
|
|
322
|
+
policyVersion: z.string().min(1),
|
|
323
|
+
runtime: z.enum(["docker", "podman"]),
|
|
324
|
+
image: z.string().min(1),
|
|
325
|
+
allowedCommands: z.array(z.string().min(1)),
|
|
326
|
+
shellMode: z.enum(["deny", "ask"]),
|
|
327
|
+
maxProcessRuntimeMs: nonnegativeInteger,
|
|
328
|
+
maxProcessOutputBytes: nonnegativeInteger,
|
|
329
|
+
maxMemoryMb: nonnegativeInteger,
|
|
330
|
+
maxPids: nonnegativeInteger,
|
|
331
|
+
maxCpus: z.number().positive(),
|
|
332
|
+
maxWorkspaceBytes: nonnegativeInteger,
|
|
333
|
+
maxFileWriteBytes: nonnegativeInteger,
|
|
334
|
+
tmpfsMb: nonnegativeInteger
|
|
335
|
+
})
|
|
336
|
+
]);
|
|
337
|
+
var executionBindingSchema = observationalDocument({
|
|
338
|
+
environmentId: z.string().min(1),
|
|
339
|
+
environmentVersion: z.string().min(1).optional(),
|
|
340
|
+
fingerprint: z.string().min(1),
|
|
341
|
+
workspaceId: z.string().min(1).optional()
|
|
342
|
+
});
|
|
343
|
+
var ociImageSchema = observationalDocument({
|
|
344
|
+
runtime: z.enum(["docker", "podman"]),
|
|
345
|
+
runtimeVersion: z.string().min(1),
|
|
346
|
+
imageReference: z.string().min(1),
|
|
347
|
+
imageId: z.string().min(1),
|
|
348
|
+
imageDigest: z.string().min(1)
|
|
349
|
+
});
|
|
350
|
+
var runExecutionSchema = z.discriminatedUnion("backend", [
|
|
351
|
+
observationalDocument({ backend: z.literal("none") }),
|
|
352
|
+
observationalDocument({
|
|
353
|
+
backend: z.literal("oci"),
|
|
354
|
+
binding: executionBindingSchema,
|
|
355
|
+
image: ociImageSchema
|
|
356
|
+
})
|
|
357
|
+
]);
|
|
358
|
+
var migrationResultSchema = observationalDocument({
|
|
359
|
+
scannedRuns: nonnegativeInteger,
|
|
360
|
+
migratedRuns: nonnegativeInteger,
|
|
361
|
+
migratedToolCalls: nonnegativeInteger
|
|
362
|
+
});
|
|
363
|
+
var runStoreSchema = observationalDocument({
|
|
364
|
+
backend: z.enum(["sqlite", "file"]),
|
|
365
|
+
stateDirectory: z.string().min(1),
|
|
366
|
+
migration: migrationResultSchema.optional()
|
|
367
|
+
});
|
|
368
|
+
var doctorCheckSchema = observationalDocument({
|
|
369
|
+
id: z.string().min(1),
|
|
370
|
+
status: z.enum(["pass", "warn", "fail"]),
|
|
371
|
+
message: z.string(),
|
|
372
|
+
details: z.record(z.string(), z.union([
|
|
373
|
+
z.boolean(),
|
|
374
|
+
z.number(),
|
|
375
|
+
z.string(),
|
|
376
|
+
z.array(z.string())
|
|
377
|
+
]))
|
|
378
|
+
});
|
|
379
|
+
var doctorConfigurationSchema = observationalDocument({
|
|
380
|
+
requireVerifiedDelivery: z.boolean().optional(),
|
|
381
|
+
provider: z.string().min(1),
|
|
382
|
+
model: z.string().min(1),
|
|
383
|
+
workspace: z.string().min(1),
|
|
384
|
+
stateDirectory: z.string().min(1),
|
|
385
|
+
storeBackend: z.enum(["sqlite", "file"]),
|
|
386
|
+
scope: scopeSchema,
|
|
387
|
+
maxSteps: nonnegativeInteger,
|
|
388
|
+
timeoutMs: nonnegativeInteger,
|
|
389
|
+
unlimitedDuration: z.boolean().optional(),
|
|
390
|
+
budget: budgetConfigSchema,
|
|
391
|
+
costBudget: observationalDocument({
|
|
392
|
+
maxCostUsd: z.number().nonnegative(),
|
|
393
|
+
inputCostPer1kTokens: z.number().nonnegative(),
|
|
394
|
+
outputCostPer1kTokens: z.number().nonnegative()
|
|
395
|
+
}).optional(),
|
|
396
|
+
compaction: observationalDocument({
|
|
397
|
+
maxMessages: nonnegativeInteger,
|
|
398
|
+
maxEstimatedInputTokens: nonnegativeInteger,
|
|
399
|
+
keepRecentMessages: nonnegativeInteger
|
|
400
|
+
}),
|
|
401
|
+
allowedChecks: z.array(z.string().min(1)),
|
|
402
|
+
requiredCapabilities: z.array(z.enum([
|
|
403
|
+
"streaming",
|
|
404
|
+
"tools",
|
|
405
|
+
"structured-output",
|
|
406
|
+
"parallel-tools",
|
|
407
|
+
"reasoning",
|
|
408
|
+
"web-search"
|
|
409
|
+
])),
|
|
410
|
+
orchestration: orchestrationConfigSchema,
|
|
411
|
+
context: observationalDocument({ enabled: z.boolean(), configPath: z.string().min(1) }),
|
|
412
|
+
execution: executionConfigSchema,
|
|
413
|
+
mcpConfigPath: z.string().min(1).optional()
|
|
414
|
+
});
|
|
415
|
+
var cliRunResultDocumentSchema = observationalDocument({
|
|
416
|
+
...jsonBase,
|
|
417
|
+
kind: z.literal("run-result"),
|
|
418
|
+
...runIdentity,
|
|
419
|
+
output: z.string(),
|
|
420
|
+
steps: nonnegativeInteger,
|
|
421
|
+
toolCalls: nonnegativeInteger,
|
|
422
|
+
mutations: z.array(mutationAuditSchema),
|
|
423
|
+
pendingApprovals: z.array(approvalSummarySchema),
|
|
424
|
+
children: z.array(childRunSummarySchema),
|
|
425
|
+
usage: tokenUsageSchema.optional(),
|
|
426
|
+
budget: budgetStatusSchema,
|
|
427
|
+
costBudget: observationalDocument({
|
|
428
|
+
limitUsd: z.number().nonnegative(),
|
|
429
|
+
estimate: costEstimateSchema
|
|
430
|
+
}).optional(),
|
|
431
|
+
scope: scopeSchema,
|
|
432
|
+
capabilities: capabilityReportSchema,
|
|
433
|
+
orchestration: observationalDocument({
|
|
434
|
+
profiles: orchestrationConfigSchema.shape.profiles,
|
|
435
|
+
childBudget: budgetConfigSchema,
|
|
436
|
+
mcpServers: z.array(z.string().min(1))
|
|
437
|
+
}),
|
|
438
|
+
execution: runExecutionSchema,
|
|
439
|
+
store: runStoreSchema,
|
|
440
|
+
stateDirectory: z.string()
|
|
441
|
+
});
|
|
442
|
+
var cliProviderDocumentSchema = observationalDocument({
|
|
443
|
+
...jsonBase,
|
|
444
|
+
kind: z.literal("providers"),
|
|
445
|
+
providers: z.array(providerAvailabilitySchema)
|
|
446
|
+
});
|
|
447
|
+
var cliInitDocumentSchema = observationalDocument({
|
|
448
|
+
...jsonBase,
|
|
449
|
+
kind: z.literal("init"),
|
|
450
|
+
profile: observationalDocument({
|
|
451
|
+
name: z.string().min(1),
|
|
452
|
+
path: z.string().min(1),
|
|
453
|
+
schemaVersion: nonnegativeInteger,
|
|
454
|
+
provider: z.enum(PROVIDERS),
|
|
455
|
+
model: z.string().min(1),
|
|
456
|
+
reasoningEffort: reasoningEffortSchema.optional()
|
|
457
|
+
}),
|
|
458
|
+
credential: observationalDocument({
|
|
459
|
+
configured: z.boolean(),
|
|
460
|
+
names: z.array(z.string().min(1))
|
|
461
|
+
}),
|
|
462
|
+
next: observationalDocument({
|
|
463
|
+
doctor: z.string().min(1),
|
|
464
|
+
run: z.string().min(1)
|
|
465
|
+
})
|
|
466
|
+
});
|
|
467
|
+
var cliDoctorDocumentSchema = observationalDocument({
|
|
468
|
+
...jsonBase,
|
|
469
|
+
kind: z.literal("doctor"),
|
|
470
|
+
ok: z.boolean(),
|
|
471
|
+
harnessVersion: z.string().min(1),
|
|
472
|
+
configSchemaVersion: nonnegativeInteger,
|
|
473
|
+
configuration: doctorConfigurationSchema,
|
|
474
|
+
checks: z.array(doctorCheckSchema),
|
|
475
|
+
providers: z.array(providerAvailabilitySchema)
|
|
476
|
+
});
|
|
477
|
+
var cliReviewGroupDocumentSchema = observationalDocument({
|
|
478
|
+
...jsonBase,
|
|
479
|
+
kind: z.literal("review-group"),
|
|
480
|
+
groupId: z.string().min(1),
|
|
481
|
+
status: z.enum(["completed", "failed"]),
|
|
482
|
+
profiles: z.array(z.string().min(1)).min(1),
|
|
483
|
+
outputs: z.array(observationalDocument({
|
|
484
|
+
status: z.enum(["fulfilled", "rejected"]),
|
|
485
|
+
name: z.string().min(1).optional(),
|
|
486
|
+
agentId: z.string().min(1).optional(),
|
|
487
|
+
runId: z.string().min(1).optional(),
|
|
488
|
+
runStatus: z.string().min(1).optional(),
|
|
489
|
+
output: z.string().optional(),
|
|
490
|
+
steps: nonnegativeInteger.optional(),
|
|
491
|
+
usage: tokenUsageSchema.optional(),
|
|
492
|
+
error: observationalDocument({
|
|
493
|
+
code: z.enum(HARNESS_ERROR_CODES),
|
|
494
|
+
category: z.enum([
|
|
495
|
+
"configuration",
|
|
496
|
+
"usage",
|
|
497
|
+
"workspace",
|
|
498
|
+
"state",
|
|
499
|
+
"provider",
|
|
500
|
+
"approval",
|
|
501
|
+
"execution"
|
|
502
|
+
]),
|
|
503
|
+
retryable: z.boolean()
|
|
504
|
+
}).optional()
|
|
505
|
+
}))
|
|
506
|
+
});
|
|
507
|
+
var cliRunListDocumentSchema = observationalDocument({
|
|
508
|
+
...jsonBase,
|
|
509
|
+
kind: z.literal("run-list"),
|
|
510
|
+
scope: scopeSchema,
|
|
511
|
+
backend: z.string().min(1),
|
|
512
|
+
runs: z.array(runSummarySchema)
|
|
513
|
+
});
|
|
514
|
+
var runInspectionShape = {
|
|
515
|
+
run: runSummarySchema,
|
|
516
|
+
budget: jsonObjectSchema,
|
|
517
|
+
snapshot: jsonObjectSchema,
|
|
518
|
+
trace: jsonObjectSchema,
|
|
519
|
+
hierarchy: jsonObjectSchema,
|
|
520
|
+
ledger: jsonObjectSchema,
|
|
521
|
+
toolJournal: z.array(jsonObjectSchema)
|
|
522
|
+
};
|
|
523
|
+
var cliRunInspectionDocumentSchema = observationalDocument({
|
|
524
|
+
...jsonBase,
|
|
525
|
+
kind: z.literal("run-inspection"),
|
|
526
|
+
...runInspectionShape
|
|
527
|
+
});
|
|
528
|
+
var cliRunExportDocumentSchema = observationalDocument({
|
|
529
|
+
...jsonBase,
|
|
530
|
+
kind: z.literal("run-export"),
|
|
531
|
+
...runInspectionShape
|
|
532
|
+
});
|
|
533
|
+
var cliRunCancellationDocumentSchema = observationalDocument({
|
|
534
|
+
...jsonBase,
|
|
535
|
+
kind: z.literal("run-cancellation"),
|
|
536
|
+
cascade: z.boolean(),
|
|
537
|
+
run: runSummarySchema.optional(),
|
|
538
|
+
parent: runSummarySchema.optional(),
|
|
539
|
+
children: z.array(runSummarySchema).optional()
|
|
540
|
+
}).superRefine((document, context) => {
|
|
541
|
+
if (!document.cascade && !document.run || document.cascade && (!document.parent || !document.children)) {
|
|
542
|
+
context.addIssue({ code: "custom", message: "Cancellation payload does not match cascade mode." });
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
var cliRunCleanupDocumentSchema = observationalDocument({
|
|
546
|
+
...jsonBase,
|
|
547
|
+
kind: z.literal("run-cleanup"),
|
|
548
|
+
before: nonnegativeInteger,
|
|
549
|
+
statuses: z.array(z.string().min(1)),
|
|
550
|
+
deleted: nonnegativeInteger
|
|
551
|
+
});
|
|
552
|
+
var cliSessionListDocumentSchema = observationalDocument({
|
|
553
|
+
...jsonBase,
|
|
554
|
+
kind: z.literal("session-list"),
|
|
555
|
+
sessions: z.array(sessionSchema)
|
|
556
|
+
});
|
|
557
|
+
var cliSessionDocumentSchema = observationalDocument({
|
|
558
|
+
...jsonBase,
|
|
559
|
+
kind: z.literal("session"),
|
|
560
|
+
session: sessionSchema
|
|
561
|
+
});
|
|
562
|
+
var cliChangeEnvelopeVerificationDocumentSchema = observationalDocument({
|
|
563
|
+
...jsonBase,
|
|
564
|
+
kind: z.literal("change-envelope-verification"),
|
|
565
|
+
valid: z.boolean(),
|
|
566
|
+
verificationScope: z.literal("integrity-expiration-and-preconditions-only"),
|
|
567
|
+
issues: z.array(jsonObjectSchema),
|
|
568
|
+
integrity: jsonObjectSchema,
|
|
569
|
+
expiration: jsonObjectSchema,
|
|
570
|
+
checks: jsonObjectSchema,
|
|
571
|
+
approvals: jsonObjectSchema,
|
|
572
|
+
externalAttestations: jsonObjectSchema
|
|
573
|
+
});
|
|
574
|
+
var cliStateStatusDocumentSchema = observationalDocument({
|
|
575
|
+
...jsonBase,
|
|
576
|
+
kind: z.literal("state-status"),
|
|
577
|
+
compatible: z.boolean(),
|
|
578
|
+
schemas: jsonObjectSchema,
|
|
579
|
+
counts: z.record(z.string(), nonnegativeInteger)
|
|
580
|
+
});
|
|
581
|
+
var cliStateExportDocumentSchema = observationalDocument({
|
|
582
|
+
...jsonBase,
|
|
583
|
+
kind: z.literal("state-export"),
|
|
584
|
+
path: z.string().min(1),
|
|
585
|
+
checksum: digestSchema,
|
|
586
|
+
counts: z.record(z.string(), nonnegativeInteger)
|
|
587
|
+
});
|
|
588
|
+
var cliStateImportDocumentSchema = observationalDocument({
|
|
589
|
+
...jsonBase,
|
|
590
|
+
kind: z.literal("state-import"),
|
|
591
|
+
dryRun: z.boolean(),
|
|
592
|
+
checksum: digestSchema,
|
|
593
|
+
inserted: z.record(z.string(), nonnegativeInteger),
|
|
594
|
+
identical: nonnegativeInteger
|
|
595
|
+
});
|
|
596
|
+
var providerStreamDiagnosticSchema = z.strictObject({
|
|
597
|
+
provider: z.literal("qwen"),
|
|
598
|
+
transport: z.enum(["chat", "responses"]),
|
|
599
|
+
diagnosticCode: z.literal("QWEN_SSE_EVENT_INVALID"),
|
|
600
|
+
reason: z.enum(["invalid_json", "invalid_event"]),
|
|
601
|
+
retryable: z.literal(false)
|
|
602
|
+
});
|
|
603
|
+
var cliErrorDocumentSchema = observationalDocument({
|
|
604
|
+
schemaVersion: z.literal(HARNESS_ERROR_SCHEMA_VERSION),
|
|
605
|
+
kind: z.literal("error"),
|
|
606
|
+
error: observationalDocument({
|
|
607
|
+
code: z.enum(HARNESS_ERROR_CODES),
|
|
608
|
+
category: z.enum([
|
|
609
|
+
"configuration",
|
|
610
|
+
"usage",
|
|
611
|
+
"workspace",
|
|
612
|
+
"state",
|
|
613
|
+
"provider",
|
|
614
|
+
"approval",
|
|
615
|
+
"execution"
|
|
616
|
+
]),
|
|
617
|
+
retryable: z.boolean(),
|
|
618
|
+
providerDiagnostic: providerStreamDiagnosticSchema.optional()
|
|
619
|
+
})
|
|
620
|
+
});
|
|
621
|
+
var cliPolicyInspectionSchema = observationalDocument({
|
|
622
|
+
...jsonBase,
|
|
623
|
+
kind: z.literal("policy-inspection"),
|
|
624
|
+
digest: digestSchema.nullable(),
|
|
625
|
+
source: z.enum(["operator-file", "application", "baseline"]),
|
|
626
|
+
explicitReviewRequired: z.boolean(),
|
|
627
|
+
tools: z.array(observationalDocument({ name: z.string(), requiresApproval: z.boolean() })),
|
|
628
|
+
restrictions: z.array(observationalDocument({ ruleId: z.string(), tools: z.array(z.string()), decision: z.enum(["allow", "ask_user", "deny"]), reason: z.string(), pathCount: nonnegativeInteger })),
|
|
629
|
+
execution: observationalDocument({ configuredBackend: z.enum(["none", "oci"]), activeBackend: z.enum(["none", "oci"]), evidence: z.literal("configuration-only") }),
|
|
630
|
+
limits: observationalDocument({ maxSteps: nonnegativeInteger, timeoutMs: nonnegativeInteger, unlimitedDuration: z.boolean().optional(), budget: jsonObjectSchema })
|
|
631
|
+
});
|
|
632
|
+
var cliJsonDocumentSchema = z.union([
|
|
633
|
+
observationalDocument({ ...jsonBase, kind: z.literal("application-notes"), projectId: z.string(), enabled: z.boolean(), notes: z.array(observationalDocument({ id: z.string(), title: z.string(), created_at: z.number() })), total: nonnegativeInteger, nextOffset: nonnegativeInteger.nullable(), note: observationalDocument({ id: z.string(), title: z.string(), created_at: z.number(), body: z.string() }).optional() }),
|
|
634
|
+
observationalDocument({ ...jsonBase, kind: z.literal("application-automation"), projectId: z.string(), available: z.boolean(), linked: z.boolean(), delivery: z.literal("telegram"), digest: z.string(), state: observationalDocument({
|
|
635
|
+
schedule: observationalDocument({ enabled: z.number().int().min(0).max(1), revision: z.number().int(), next_at: z.number() }).nullable(),
|
|
636
|
+
preferences: z.array(observationalDocument({ key: z.string(), value: z.string() })),
|
|
637
|
+
occurrences: z.array(observationalDocument({ id: z.string(), day: z.string(), status: z.string(), attempts: z.number().int() }))
|
|
638
|
+
}).nullable() }),
|
|
639
|
+
observationalDocument({ ...jsonBase, kind: z.literal("application-tasks"), projectId: z.string(), enabled: z.boolean(), tasks: z.array(observationalDocument({ id: z.string(), title: z.string(), due_date: z.string().nullable(), status: z.string(), created_at: z.number() })), total: nonnegativeInteger, nextOffset: nonnegativeInteger.nullable() }),
|
|
640
|
+
observationalDocument({ ...jsonBase, kind: z.literal("application-reminders"), projectId: z.string(), enabled: z.boolean(), reminders: z.array(observationalDocument({ id: z.string(), text: z.string(), due_at: z.number(), time_zone: z.string(), channel: z.string(), status: z.string() })) }),
|
|
641
|
+
observationalDocument({ ...jsonBase, kind: z.literal("application-agents"), agents: z.array(observationalDocument({ id: z.string(), name: z.string(), active: z.boolean() })), draft: z.object({ name: z.string().optional(), tools: z.object({ daily: z.boolean(), proactive: z.boolean().optional(), github: z.object({ account: z.string(), authorizationEnv: z.string() }).optional(), web: z.object({ apiKeyEnv: z.string() }).optional() }).optional() }).nullable(), ready: z.boolean() }),
|
|
642
|
+
observationalDocument({ ...jsonBase, kind: z.literal("application-connections"), connections: z.array(observationalDocument({ id: z.string(), label: z.string() })) }),
|
|
643
|
+
observationalDocument({
|
|
644
|
+
...jsonBase,
|
|
645
|
+
kind: z.literal("application-code-context"),
|
|
646
|
+
projectId: z.string(),
|
|
647
|
+
enabled: z.boolean(),
|
|
648
|
+
provider: z.string(),
|
|
649
|
+
model: z.string(),
|
|
650
|
+
fingerprint: z.string(),
|
|
651
|
+
manifest: observationalDocument({ path: z.string(), digest: z.string(), bytes: nonnegativeInteger }).optional(),
|
|
652
|
+
sources: z.array(observationalDocument({ kind: z.enum(["context", "rule"]), path: z.string(), digest: z.string(), bytes: nonnegativeInteger })),
|
|
653
|
+
skills: z.array(observationalDocument({ id: z.string(), path: z.string(), digest: z.string(), bytes: nonnegativeInteger }))
|
|
654
|
+
}),
|
|
655
|
+
observationalDocument({ ...jsonBase, kind: z.literal("application-projects"), projects: z.array(observationalDocument({ id: z.string(), workspace: z.string(), connectionId: z.string(), label: z.string() })), active: z.string().optional(), ready: z.boolean(), error: z.string().nullable() }),
|
|
656
|
+
observationalDocument({ ...jsonBase, kind: z.literal("application-status"), status: z.enum(["running", "unavailable", "stop-requested"]), directory: z.string(), assistantReady: z.boolean().optional(), assistantLocked: z.boolean().optional(), assistantError: z.string().nullable().optional(), codeReady: z.boolean().optional() }),
|
|
657
|
+
cliPolicyInspectionSchema,
|
|
658
|
+
cliRunResultDocumentSchema,
|
|
659
|
+
cliInitDocumentSchema,
|
|
660
|
+
cliProviderDocumentSchema,
|
|
661
|
+
cliDoctorDocumentSchema,
|
|
662
|
+
cliReviewGroupDocumentSchema,
|
|
663
|
+
cliRunListDocumentSchema,
|
|
664
|
+
cliRunInspectionDocumentSchema,
|
|
665
|
+
cliRunExportDocumentSchema,
|
|
666
|
+
cliRunCancellationDocumentSchema,
|
|
667
|
+
cliRunCleanupDocumentSchema,
|
|
668
|
+
cliSessionListDocumentSchema,
|
|
669
|
+
cliSessionDocumentSchema,
|
|
670
|
+
cliChangeEnvelopeVerificationDocumentSchema,
|
|
671
|
+
cliStateStatusDocumentSchema,
|
|
672
|
+
cliStateExportDocumentSchema,
|
|
673
|
+
cliStateImportDocumentSchema,
|
|
674
|
+
cliErrorDocumentSchema,
|
|
675
|
+
changeEnvelopeSchema
|
|
676
|
+
]);
|
|
677
|
+
var runEvent = (type, shape) => observationalDocument({
|
|
678
|
+
...eventBase,
|
|
679
|
+
kind: z.literal("run-event"),
|
|
680
|
+
type: z.literal(type),
|
|
681
|
+
...shape
|
|
682
|
+
});
|
|
683
|
+
var cliRunEventDocumentSchema = z.discriminatedUnion("type", [
|
|
684
|
+
runEvent("policy-decision", {
|
|
685
|
+
phase: z.enum(["approval-request", "tool-entry"]),
|
|
686
|
+
toolName: z.string(),
|
|
687
|
+
decision: z.enum(["allow", "ask_user", "deny"]),
|
|
688
|
+
ruleIds: z.array(z.string()),
|
|
689
|
+
reason: z.string(),
|
|
690
|
+
reasonTruncated: z.boolean(),
|
|
691
|
+
policyDigest: digestSchema.nullable(),
|
|
692
|
+
source: z.enum(["operator-file", "application", "baseline"]),
|
|
693
|
+
approvalRequired: z.boolean(),
|
|
694
|
+
explicitReviewRequired: z.boolean(),
|
|
695
|
+
executionBackend: z.enum(["none", "oci"]),
|
|
696
|
+
evidence: z.literal("policy-evaluation")
|
|
697
|
+
}),
|
|
698
|
+
runEvent("text-delta", { textDelta: z.string() }),
|
|
699
|
+
runEvent("tool-call", {
|
|
700
|
+
toolCallId: z.string().min(1),
|
|
701
|
+
toolName: z.string().min(1)
|
|
702
|
+
}),
|
|
703
|
+
runEvent("tool-result", {
|
|
704
|
+
toolCallId: z.string().min(1),
|
|
705
|
+
toolName: z.string().min(1),
|
|
706
|
+
isError: z.boolean()
|
|
707
|
+
}),
|
|
708
|
+
runEvent("tool-approval-request", {
|
|
709
|
+
approvalRequestId: z.string().min(1),
|
|
710
|
+
approvalKind: z.string().min(1),
|
|
711
|
+
toolName: z.string().min(1)
|
|
712
|
+
}),
|
|
713
|
+
runEvent("agent-approval-request", {
|
|
714
|
+
approvalRequestId: z.string().min(1),
|
|
715
|
+
approvalKind: z.string().min(1),
|
|
716
|
+
toolName: z.string().min(1)
|
|
717
|
+
}),
|
|
718
|
+
runEvent("agent-approval-resolved", {
|
|
719
|
+
approvalRequestId: z.string().min(1),
|
|
720
|
+
approved: z.boolean()
|
|
721
|
+
}),
|
|
722
|
+
runEvent("provider-data", { provider: z.string().min(1) }),
|
|
723
|
+
runEvent("image-generation", {
|
|
724
|
+
provider: z.string().min(1),
|
|
725
|
+
partial: z.boolean(),
|
|
726
|
+
id: z.string().min(1).optional(),
|
|
727
|
+
index: nonnegativeInteger.optional()
|
|
728
|
+
}),
|
|
729
|
+
runEvent("finish", {
|
|
730
|
+
finishReason: z.string().min(1).optional(),
|
|
731
|
+
usage: jsonObjectSchema.optional()
|
|
732
|
+
}),
|
|
733
|
+
runEvent("error", { error: z.literal("Provider stream failed."), providerDiagnostic: providerStreamDiagnosticSchema.optional() }),
|
|
734
|
+
runEvent("agent-run-start", {
|
|
735
|
+
currentStep: nonnegativeInteger,
|
|
736
|
+
maxSteps: z.union([nonnegativeInteger, z.literal("unlimited")])
|
|
737
|
+
}),
|
|
738
|
+
runEvent("agent-step-start", { stepIndex: nonnegativeInteger }),
|
|
739
|
+
runEvent("agent-step-finish", {
|
|
740
|
+
stepIndex: nonnegativeInteger,
|
|
741
|
+
status: z.string().min(1),
|
|
742
|
+
toolCalls: nonnegativeInteger
|
|
743
|
+
}),
|
|
744
|
+
runEvent("agent-compaction", {
|
|
745
|
+
compactionId: z.string().min(1),
|
|
746
|
+
reasons: z.array(z.string().min(1)),
|
|
747
|
+
messageCountBefore: nonnegativeInteger,
|
|
748
|
+
messageCountAfter: nonnegativeInteger
|
|
749
|
+
}),
|
|
750
|
+
runEvent("agent-run-finish", {
|
|
751
|
+
runId: z.string().min(1),
|
|
752
|
+
status: z.string().min(1),
|
|
753
|
+
provider: z.string().min(1),
|
|
754
|
+
model: z.string().min(1)
|
|
755
|
+
})
|
|
756
|
+
]);
|
|
757
|
+
var cliStreamResultDocumentSchema = observationalDocument({
|
|
758
|
+
...eventBase,
|
|
759
|
+
kind: z.literal("run-stream-result"),
|
|
760
|
+
...runIdentity,
|
|
761
|
+
steps: nonnegativeInteger,
|
|
762
|
+
toolCalls: nonnegativeInteger,
|
|
763
|
+
pendingApprovals: z.array(observationalDocument({
|
|
764
|
+
id: z.string().min(1),
|
|
765
|
+
kind: z.string().min(1),
|
|
766
|
+
name: z.string().min(1),
|
|
767
|
+
childRunId: z.string().min(1).optional(),
|
|
768
|
+
childAgentId: z.string().min(1).optional()
|
|
769
|
+
})),
|
|
770
|
+
children: z.array(observationalDocument({
|
|
771
|
+
runId: z.string().min(1),
|
|
772
|
+
status: z.string().min(1)
|
|
773
|
+
}))
|
|
774
|
+
});
|
|
775
|
+
var cliStreamErrorDocumentSchema = observationalDocument({
|
|
776
|
+
...eventBase,
|
|
777
|
+
kind: z.literal("run-stream-error"),
|
|
778
|
+
error: cliErrorDocumentSchema.shape.error
|
|
779
|
+
});
|
|
780
|
+
var cliJsonLineDocumentSchema = z.union([
|
|
781
|
+
cliRunEventDocumentSchema,
|
|
782
|
+
cliStreamResultDocumentSchema,
|
|
783
|
+
cliStreamErrorDocumentSchema
|
|
784
|
+
]);
|
|
785
|
+
|
|
786
|
+
// packages/core/src/cli/service-client-cli.ts
|
|
787
|
+
var runServiceCli = async (options, annotate) => {
|
|
788
|
+
const client = await connectApplication(options.serviceFile);
|
|
789
|
+
const projectId = client.projectId;
|
|
790
|
+
let sequence = 0;
|
|
791
|
+
const key = (purpose, supplied) => createHash("sha256").update(`${purpose}:${supplied ?? randomUUID2()}`).digest("hex");
|
|
792
|
+
const call = async (command) => {
|
|
793
|
+
const r = await client.command(command);
|
|
794
|
+
if (!r.ok)
|
|
795
|
+
throw new HarnessStateConflictError(`Service command failed: ${r.error.code}. Inspect durable state before retrying.`);
|
|
796
|
+
return r.data;
|
|
797
|
+
};
|
|
798
|
+
const getSession = async (sessionId) => {
|
|
799
|
+
const r = await call({ method: "session.get", sessionId });
|
|
800
|
+
if (r.kind !== "session")
|
|
801
|
+
throw new HarnessStateConflictError("Unexpected service response.");
|
|
802
|
+
return r.session;
|
|
803
|
+
};
|
|
804
|
+
const list = async (search) => {
|
|
805
|
+
const r = await call({ method: "session.list", ...search ? { search } : {} });
|
|
806
|
+
if (r.kind !== "sessions")
|
|
807
|
+
throw new HarnessStateConflictError("Unexpected service response.");
|
|
808
|
+
return r.sessions;
|
|
809
|
+
};
|
|
810
|
+
const create = async (idempotencyKey) => {
|
|
811
|
+
const r = await call({ method: "session.create", idempotencyKey: key("session", idempotencyKey) });
|
|
812
|
+
if (r.kind !== "session")
|
|
813
|
+
throw new HarnessStateConflictError("Unexpected service response.");
|
|
814
|
+
return r.session;
|
|
815
|
+
};
|
|
816
|
+
const print = (document) => process.stdout.write((options.json ? JSON.stringify(document, null, 2) : sanitizeTerminalText(JSON.stringify(document, null, 2))) + `
|
|
817
|
+
`);
|
|
818
|
+
if (options.command === "checkpoints") {
|
|
819
|
+
print({ schemaVersion: 1, ...await serviceCheckpointDocument(client, options) });
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
if (options.command === "policy") {
|
|
823
|
+
const result = await call({ method: "policy.get" });
|
|
824
|
+
if (result.kind !== "policy")
|
|
825
|
+
throw new HarnessStateConflictError("Unexpected service policy response.");
|
|
826
|
+
printPolicyInspection(result.policy, options.json);
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
if (options.command === "sessions") {
|
|
830
|
+
if (options.sessionsCommand === "list") {
|
|
831
|
+
const sessions = await list(options.sessionSearch);
|
|
832
|
+
print({ schemaVersion: 1, kind: "session-list", sessions });
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
let session2 = await getSession(options.sessionId);
|
|
836
|
+
if (options.sessionsCommand === "rename") {
|
|
837
|
+
const renamed = await call({ method: "session.rename", sessionId: session2.sessionId, expectedRevision: session2.revision, idempotencyKey: key("rename"), title: options.sessionTitle });
|
|
838
|
+
if (renamed.kind !== "session")
|
|
839
|
+
throw new HarnessStateConflictError("Unexpected response.");
|
|
840
|
+
session2 = renamed.session;
|
|
841
|
+
} else if (options.sessionsCommand !== "inspect")
|
|
842
|
+
throw new HarnessConfigError("Unsupported service session command.");
|
|
843
|
+
print({ schemaVersion: 1, kind: "session", session: session2 });
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
if (!["run", "resume", "chat"].includes(options.command))
|
|
847
|
+
throw new HarnessConfigError("This command does not support service mode.");
|
|
848
|
+
let session;
|
|
849
|
+
if (options.sessionId)
|
|
850
|
+
session = await getSession(options.sessionId);
|
|
851
|
+
else if (options.command === "resume") {
|
|
852
|
+
const found = (await list()).find((s) => s.runs.some((r) => r.runId === options.runId));
|
|
853
|
+
if (!found)
|
|
854
|
+
throw new HarnessStateConflictError("Run session not found; supply --session.");
|
|
855
|
+
session = found;
|
|
856
|
+
} else if (options.continueSession) {
|
|
857
|
+
const latest = (await list())[0];
|
|
858
|
+
if (!latest)
|
|
859
|
+
throw new HarnessStateConflictError("No session to continue.");
|
|
860
|
+
session = latest;
|
|
861
|
+
} else
|
|
862
|
+
session = await create(options.idempotencyKey);
|
|
863
|
+
let activeRun;
|
|
864
|
+
let consoleInput;
|
|
865
|
+
const history = new ActivityHistory;
|
|
866
|
+
const seenMutations = new Set;
|
|
867
|
+
const currentRun = async (runId = activeRun ?? session.runs.at(-1)?.runId) => {
|
|
868
|
+
if (!runId)
|
|
869
|
+
return;
|
|
870
|
+
const r = await call({ method: "run.get", sessionId: session.sessionId, runId });
|
|
871
|
+
if (r.kind !== "run")
|
|
872
|
+
throw new HarnessStateConflictError("Unexpected run response.");
|
|
873
|
+
return r.run;
|
|
874
|
+
};
|
|
875
|
+
const cancel = async () => {
|
|
876
|
+
const run = await currentRun();
|
|
877
|
+
if (run)
|
|
878
|
+
await call({ method: "run.cancel", sessionId: session.sessionId, runId: run.runId, expectedRevision: run.revision, idempotencyKey: key("cancel") });
|
|
879
|
+
};
|
|
880
|
+
const cursorAtEnd = async () => {
|
|
881
|
+
let after = 0;
|
|
882
|
+
for (;; ) {
|
|
883
|
+
const page = await client.events(session.sessionId, after);
|
|
884
|
+
after = page.nextCursor;
|
|
885
|
+
if (page.cursorExpired || page.events.length < 200)
|
|
886
|
+
return after;
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
const invoke = async (command) => {
|
|
890
|
+
let cursor = await cursorAtEnd();
|
|
891
|
+
let finished = false, streamed = false;
|
|
892
|
+
consoleInput?.startBackground();
|
|
893
|
+
const activity = new ToolActivity((text) => {
|
|
894
|
+
process.stderr.write(text);
|
|
895
|
+
}, Boolean(consoleInput && process.stdout.isTTY), () => process.stdout.columns || 80, () => consoleInput?.backgroundStatus ?? "");
|
|
896
|
+
const observe = (a) => {
|
|
897
|
+
if (options.json || options.jsonl)
|
|
898
|
+
return;
|
|
899
|
+
if (a.type === "policy-decision") {
|
|
900
|
+
const decision2 = harnessPolicyDecisionEventSchema.safeParse(a);
|
|
901
|
+
if (decision2.success)
|
|
902
|
+
process.stderr.write(formatPolicyDecision(decision2.data) + `
|
|
903
|
+
`);
|
|
904
|
+
}
|
|
905
|
+
history.observeService(a);
|
|
906
|
+
if (a.type === "agent-step-start" || a.type === "agent-run-start")
|
|
907
|
+
activity.phase("Waiting for model response");
|
|
908
|
+
else if (a.type === "agent-compaction")
|
|
909
|
+
activity.phase("Updating context");
|
|
910
|
+
else if (a.type === "tool-call")
|
|
911
|
+
activity.start(typeof a.toolName === "string" ? a.toolName : undefined);
|
|
912
|
+
else if (a.type === "tool-result")
|
|
913
|
+
activity.finish(typeof a.toolName === "string" ? a.toolName : "tool", a.isError !== true);
|
|
914
|
+
else if (["agent-run-finish", "tool-approval-request", "agent-approval-request"].includes(String(a.type)))
|
|
915
|
+
activity.flush();
|
|
916
|
+
else if (a.type === "text-delta")
|
|
917
|
+
activity.pause();
|
|
918
|
+
};
|
|
919
|
+
const pending = call(command).finally(() => {
|
|
920
|
+
finished = true;
|
|
921
|
+
});
|
|
922
|
+
pending.catch(() => {
|
|
923
|
+
return;
|
|
924
|
+
});
|
|
925
|
+
try {
|
|
926
|
+
do {
|
|
927
|
+
const page = await client.events(session.sessionId, cursor);
|
|
928
|
+
if (page.cursorExpired && !options.json)
|
|
929
|
+
throw new HarnessStateConflictError("Service activity cursor expired; reopen the session snapshot.");
|
|
930
|
+
cursor = page.nextCursor;
|
|
931
|
+
for (const event of page.events) {
|
|
932
|
+
activeRun = event.runId;
|
|
933
|
+
const a = event.activity;
|
|
934
|
+
if (a.type === "checkpoint" || a.type === "user-message")
|
|
935
|
+
continue;
|
|
936
|
+
observe(a);
|
|
937
|
+
if (options.jsonl)
|
|
938
|
+
process.stdout.write(JSON.stringify({ ...a, schemaVersion: 1, kind: "run-event", sequence: ++sequence }) + `
|
|
939
|
+
`);
|
|
940
|
+
else if (!options.json && typeof a.textDelta === "string") {
|
|
941
|
+
process.stdout.write(sanitizeTerminalText(a.textDelta));
|
|
942
|
+
streamed = true;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
if (!finished)
|
|
946
|
+
await Promise.race([pending.then(() => {
|
|
947
|
+
return;
|
|
948
|
+
}, () => {
|
|
949
|
+
return;
|
|
950
|
+
}), delay(40)]);
|
|
951
|
+
} while (!finished);
|
|
952
|
+
for (;; ) {
|
|
953
|
+
const tail = await client.events(session.sessionId, cursor);
|
|
954
|
+
if (tail.cursorExpired && !options.json)
|
|
955
|
+
throw new HarnessStateConflictError("Service activity cursor expired; inspect session.");
|
|
956
|
+
for (const event of tail.events) {
|
|
957
|
+
const a = event.activity;
|
|
958
|
+
if (a.type === "checkpoint" || a.type === "user-message")
|
|
959
|
+
continue;
|
|
960
|
+
observe(a);
|
|
961
|
+
if (options.jsonl)
|
|
962
|
+
process.stdout.write(JSON.stringify({ ...a, schemaVersion: 1, kind: "run-event", sequence: ++sequence }) + `
|
|
963
|
+
`);
|
|
964
|
+
else if (!options.json && typeof a.textDelta === "string") {
|
|
965
|
+
process.stdout.write(sanitizeTerminalText(a.textDelta));
|
|
966
|
+
streamed = true;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
cursor = tail.nextCursor;
|
|
970
|
+
if (tail.events.length < 200)
|
|
971
|
+
break;
|
|
972
|
+
}
|
|
973
|
+
const result = await pending;
|
|
974
|
+
if (result.kind !== "run")
|
|
975
|
+
throw new HarnessStateConflictError("Unexpected run response.");
|
|
976
|
+
session = result.session;
|
|
977
|
+
return { run: result.run, streamed };
|
|
978
|
+
} catch (e) {
|
|
979
|
+
throw annotate(e, sequence);
|
|
980
|
+
} finally {
|
|
981
|
+
activity.flush();
|
|
982
|
+
consoleInput?.stopBackground();
|
|
983
|
+
activeRun = undefined;
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
const finish = (run, streamed) => {
|
|
987
|
+
const document = cliRunResultDocumentSchema.parse(run.cliResult);
|
|
988
|
+
if (options.jsonl)
|
|
989
|
+
process.stdout.write(serializeStreamResult({ runId: document.runId, status: document.status, provider: document.provider, model: document.model, steps: document.steps, toolCalls: document.toolCalls, pendingApprovals: document.pendingApprovals.map((a) => ({ id: a.id, kind: a.kind, name: a.name, ...a.childRunId ? { childRunId: a.childRunId } : {}, ...a.childAgentId ? { childAgentId: a.childAgentId } : {} })), children: document.children.map((c) => ({ runId: c.runId, status: c.status })) }, ++sequence) + `
|
|
990
|
+
`);
|
|
991
|
+
else if (options.json)
|
|
992
|
+
print({ ...document, sessionId: session.sessionId });
|
|
993
|
+
else {
|
|
994
|
+
if (!streamed)
|
|
995
|
+
process.stdout.write(sanitizeTerminalText(document.output));
|
|
996
|
+
process.stdout.write(`
|
|
997
|
+
Run ${run.runId} · ${run.status} · session ${session.sessionId}
|
|
998
|
+
`);
|
|
999
|
+
}
|
|
1000
|
+
if (!options.json && !options.jsonl) {
|
|
1001
|
+
const fresh = document.mutations.filter((entry) => !seenMutations.has(entry.id));
|
|
1002
|
+
for (const entry of fresh)
|
|
1003
|
+
seenMutations.add(entry.id);
|
|
1004
|
+
while (seenMutations.size > 2000)
|
|
1005
|
+
seenMutations.delete(seenMutations.values().next().value);
|
|
1006
|
+
const receipt = formatAppliedFiles(fresh, "Review changes in the host workspace");
|
|
1007
|
+
if (receipt) {
|
|
1008
|
+
process.stdout.write(receipt);
|
|
1009
|
+
history.add(receipt.trim());
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
if (["failed", "cancelled", "timed_out"].includes(run.status))
|
|
1013
|
+
process.exitCode = 1;
|
|
1014
|
+
};
|
|
1015
|
+
const decision = async (run, approve) => invoke({ method: "approval.resolve", sessionId: session.sessionId, runId: run.runId, expectedRevision: run.revision, idempotencyKey: key("decision"), decisions: run.approvals.map((a) => ({ approvalId: a.approvalId, digest: a.digest, approve })) });
|
|
1016
|
+
const start = async (prompt) => {
|
|
1017
|
+
session = await getSession(session.sessionId);
|
|
1018
|
+
let result = await invoke({ method: "run.start", sessionId: session.sessionId, expectedRevision: session.revision, idempotencyKey: key("run", options.idempotencyKey), prompt });
|
|
1019
|
+
while (options.yes && result.run.status === "waiting_approval")
|
|
1020
|
+
result = await decision(result.run, true);
|
|
1021
|
+
finish(result.run, result.streamed);
|
|
1022
|
+
};
|
|
1023
|
+
const interrupt = () => {
|
|
1024
|
+
if (!activeRun)
|
|
1025
|
+
return;
|
|
1026
|
+
cancel().catch(() => process.stderr.write(`Cancellation conflicted; inspect the run before retrying.
|
|
1027
|
+
`));
|
|
1028
|
+
};
|
|
1029
|
+
process.on("SIGINT", interrupt);
|
|
1030
|
+
try {
|
|
1031
|
+
if (options.command === "resume") {
|
|
1032
|
+
const run = await currentRun(options.runId);
|
|
1033
|
+
if (!run)
|
|
1034
|
+
throw new HarnessStateConflictError("Run not found.");
|
|
1035
|
+
const result = await decision(run, options.approve === true);
|
|
1036
|
+
finish(result.run, result.streamed);
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
if (options.command === "run") {
|
|
1040
|
+
let prompt = options.prompt ?? "";
|
|
1041
|
+
if (!prompt && !process.stdin.isTTY) {
|
|
1042
|
+
for await (const chunk of process.stdin) {
|
|
1043
|
+
prompt += chunk.toString();
|
|
1044
|
+
if (Buffer.byteLength(prompt) > 64 * 1024)
|
|
1045
|
+
throw new HarnessConfigError("Prompt exceeds 64 KiB.");
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
if (!prompt.trim())
|
|
1049
|
+
throw new HarnessConfigError("A prompt is required.");
|
|
1050
|
+
await start(prompt);
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
const input = new ConsoleInput(process.stdin, process.stdout, Boolean(process.stdin.isTTY), "service");
|
|
1054
|
+
input.onInterrupt = interrupt;
|
|
1055
|
+
consoleInput = input;
|
|
1056
|
+
try {
|
|
1057
|
+
process.stdout.write(formatConsoleWelcome({ version: HARNESS_VERSION, workspace: projectId, sessionId: session.sessionId, service: true }, { columns: process.stdout.columns ?? 80 }) + `
|
|
1058
|
+
`);
|
|
1059
|
+
const previous = await currentRun();
|
|
1060
|
+
if (previous)
|
|
1061
|
+
print(previous);
|
|
1062
|
+
for (;; ) {
|
|
1063
|
+
input.setQueueEnabled(!session.runs.some((run) => ["created", "running", "waiting_approval"].includes(run.status)));
|
|
1064
|
+
const raw = await input.compose({ model: "local service", status: session.runs.at(-1)?.status === "waiting_approval" ? "approval pending · /pending" : "ready", ...session.title ? { title: session.title } : {}, automaticApprovals: options.yes === true }).catch((e) => {
|
|
1065
|
+
if (input.isClosed)
|
|
1066
|
+
return "/exit";
|
|
1067
|
+
if (e instanceof Error && e.name === "AbortError")
|
|
1068
|
+
return "";
|
|
1069
|
+
throw e;
|
|
1070
|
+
});
|
|
1071
|
+
const literal = input.lastSubmissionWasPaste || raw.includes(`
|
|
1072
|
+
`);
|
|
1073
|
+
let text = literal ? raw : raw.trim();
|
|
1074
|
+
if (!text)
|
|
1075
|
+
continue;
|
|
1076
|
+
if (!literal && ["/exit", "/quit"].includes(text))
|
|
1077
|
+
break;
|
|
1078
|
+
try {
|
|
1079
|
+
if (!literal && text.startsWith("/")) {
|
|
1080
|
+
if (text === "/menu") {
|
|
1081
|
+
const selected = await navigateConsole(input, { entry: "menu", current: { provider: "service", model: "host" }, providers: [], service: true, sessions: async () => (await list()).map((s) => ({ value: s.sessionId, label: s.title ?? "Untitled conversation", detail: s.sessionId })) });
|
|
1082
|
+
if (!selected || !("command" in selected))
|
|
1083
|
+
continue;
|
|
1084
|
+
text = selected.command;
|
|
1085
|
+
}
|
|
1086
|
+
if (text === "/help" || text === "/help all")
|
|
1087
|
+
process.stdout.write(formatConsoleHelp("service", text === "/help all"));
|
|
1088
|
+
else if (text === "/activity" || text === "/activity clear") {
|
|
1089
|
+
if (text.endsWith(" clear"))
|
|
1090
|
+
history.clear();
|
|
1091
|
+
process.stdout.write(history.render());
|
|
1092
|
+
} else if (text === "/queue clear") {
|
|
1093
|
+
input.clearQueue();
|
|
1094
|
+
process.stdout.write(`Queued tasks cleared.
|
|
1095
|
+
`);
|
|
1096
|
+
} else if (text === "/queue")
|
|
1097
|
+
process.stdout.write(input.queueSummary());
|
|
1098
|
+
else if (text === "/sessions" || text.startsWith("/sessions "))
|
|
1099
|
+
print(await list(text.slice(9).trim() || undefined));
|
|
1100
|
+
else if (text === "/new") {
|
|
1101
|
+
session = await create();
|
|
1102
|
+
input.clearHistory();
|
|
1103
|
+
history.clear();
|
|
1104
|
+
seenMutations.clear();
|
|
1105
|
+
process.stdout.write(`Session ${session.sessionId}.
|
|
1106
|
+
`);
|
|
1107
|
+
} else if (text === "/resume" || text.startsWith("/resume ")) {
|
|
1108
|
+
let id = text.slice(7).trim();
|
|
1109
|
+
if (!id) {
|
|
1110
|
+
const selected = await input.select("Zhivex / Conversations", (await list()).map((s) => ({ value: s.sessionId, label: s.title ?? "Untitled conversation", detail: s.sessionId })));
|
|
1111
|
+
if (!selected)
|
|
1112
|
+
continue;
|
|
1113
|
+
id = selected;
|
|
1114
|
+
}
|
|
1115
|
+
session = await getSession(id);
|
|
1116
|
+
input.clearHistory();
|
|
1117
|
+
history.clear();
|
|
1118
|
+
seenMutations.clear();
|
|
1119
|
+
print(await currentRun());
|
|
1120
|
+
} else if (text.startsWith("/rename ")) {
|
|
1121
|
+
const r = await call({ method: "session.rename", sessionId: session.sessionId, expectedRevision: session.revision, idempotencyKey: key("rename"), title: text.slice(8) });
|
|
1122
|
+
if (r.kind === "session")
|
|
1123
|
+
session = r.session;
|
|
1124
|
+
} else if (["/status", "/pending"].includes(text))
|
|
1125
|
+
print(await currentRun() ?? { message: "No run yet." });
|
|
1126
|
+
else if (text === "/paste") {
|
|
1127
|
+
const draft = await input.multiline();
|
|
1128
|
+
process.stdout.write(`Draft preview:
|
|
1129
|
+
${sanitizeTerminalText(draft)}
|
|
1130
|
+
`);
|
|
1131
|
+
if ((await input.question("Send this draft? Type send: ")).trim() === "send" && draft.trim()) {
|
|
1132
|
+
input.rememberPrompt(draft, true);
|
|
1133
|
+
await start(draft);
|
|
1134
|
+
}
|
|
1135
|
+
} else if (text === "/cancel")
|
|
1136
|
+
await cancel();
|
|
1137
|
+
else if (["/approve", "/deny"].includes(text)) {
|
|
1138
|
+
const run = await currentRun();
|
|
1139
|
+
if (run) {
|
|
1140
|
+
const r = await decision(run, text === "/approve");
|
|
1141
|
+
finish(r.run, r.streamed);
|
|
1142
|
+
}
|
|
1143
|
+
} else
|
|
1144
|
+
process.stdout.write(`Unsupported service command. Use /help.
|
|
1145
|
+
`);
|
|
1146
|
+
} else {
|
|
1147
|
+
input.rememberPrompt(text, literal);
|
|
1148
|
+
await start(text);
|
|
1149
|
+
}
|
|
1150
|
+
} catch {
|
|
1151
|
+
if (input.isClosed)
|
|
1152
|
+
break;
|
|
1153
|
+
process.stderr.write(`Service operation failed. Inspect /status before retrying.
|
|
1154
|
+
`);
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
} finally {
|
|
1158
|
+
input.close();
|
|
1159
|
+
}
|
|
1160
|
+
} finally {
|
|
1161
|
+
process.off("SIGINT", interrupt);
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
export {
|
|
1165
|
+
runServiceCli
|
|
1166
|
+
};
|