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