@zhivex-ai/harness 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -2
- package/README.md +17 -5
- package/SECURITY.md +1 -1
- package/SUPPORT.md +2 -2
- package/benchmarks/README.md +26 -0
- package/contracts/engine-api.json +1557 -0
- package/contracts/public-api.json +114 -0
- package/contracts/stable-api-signatures.json +17 -17
- package/dist/acp-cli.js +37 -1090
- package/dist/application/agenda.d.ts +10 -0
- package/dist/application/approval-review.d.ts +61 -0
- package/dist/application/assistant/automation/scheduler.d.ts +21 -0
- package/dist/application/assistant/automation/summary.d.ts +29 -0
- package/dist/application/assistant/automation/time.d.ts +10 -0
- package/dist/application/assistant/calendar/calendar.d.ts +238 -0
- package/dist/application/assistant/calendar/connection.d.ts +50 -0
- package/dist/application/assistant/calendar/create-event.d.ts +75 -0
- package/dist/application/assistant/calendar/environment.d.ts +2 -0
- package/dist/application/assistant/calendar/http.d.ts +6 -0
- package/dist/application/assistant/calendar/oauth.d.ts +68 -0
- package/dist/application/assistant/calendar/store.d.ts +11 -0
- package/dist/application/assistant/calendar/tools.d.ts +78 -0
- package/dist/application/assistant/client.d.ts +10 -0
- package/dist/application/assistant/config.d.ts +9 -0
- package/dist/application/assistant/contracts.d.ts +77 -0
- package/dist/application/assistant/daily/service.d.ts +181 -0
- package/dist/application/assistant/doctor.d.ts +22 -0
- package/dist/application/assistant/evaluation.d.ts +81 -0
- package/dist/application/assistant/host.d.ts +399 -0
- package/dist/application/assistant/integrations/google.d.ts +117 -0
- package/dist/application/assistant/integrations/public-web.d.ts +16 -0
- package/dist/application/assistant/managed/secrets.d.ts +10 -0
- package/dist/application/assistant/managed/setup-state.d.ts +346 -0
- package/dist/application/assistant/managed/setup.d.ts +492 -0
- package/dist/application/assistant/microsoft/connection.d.ts +73 -0
- package/dist/application/assistant/microsoft/tools.d.ts +78 -0
- package/dist/application/assistant/modules/calendar.d.ts +3 -0
- package/dist/application/assistant/modules/catalog.d.ts +38 -0
- package/dist/application/assistant/modules/daily.d.ts +5 -0
- package/dist/application/assistant/modules/github.d.ts +5 -0
- package/dist/application/assistant/modules/google.d.ts +3 -0
- package/dist/application/assistant/modules/mcp.d.ts +11 -0
- package/dist/application/assistant/modules/microsoft.d.ts +3 -0
- package/dist/application/assistant/modules/module.d.ts +224 -0
- package/dist/application/assistant/modules/tools.d.ts +11 -0
- package/dist/application/assistant/modules/web.d.ts +7 -0
- package/dist/application/assistant/private-directory.d.ts +3 -0
- package/dist/application/assistant/proactive/service.d.ts +142 -0
- package/dist/application/assistant/providers/openai-compatible.d.ts +66 -0
- package/dist/application/assistant/providers/provider.d.ts +141 -0
- package/dist/application/assistant/providers/web-citations.d.ts +2 -0
- package/dist/application/assistant/runtime.d.ts +16 -0
- package/dist/application/assistant/task-metrics.d.ts +304 -0
- package/dist/application/assistant/telegram/api.d.ts +47 -0
- package/dist/application/assistant/telegram/bridge.d.ts +69 -0
- package/dist/application/assistant/telegram/store.d.ts +10 -0
- package/dist/application/automation.d.ts +5 -0
- package/dist/application/calendar-review.d.ts +5 -0
- package/dist/application/checkpoint-review.d.ts +30 -0
- package/dist/application/client.d.ts +18 -0
- package/dist/application/code/context.d.ts +5 -0
- package/dist/application/code/delivery.d.ts +6 -0
- package/dist/application/code/git-delivery.d.ts +54 -0
- package/dist/application/code/github-git-transport.d.ts +15 -0
- package/dist/application/code/github-pr-transport.d.ts +6 -0
- package/dist/application/code/host.d.ts +25 -0
- package/dist/application/code/pr-delivery.d.ts +79 -0
- package/dist/application/code/projects.d.ts +90 -0
- package/dist/application/code/remote-delivery.d.ts +80 -0
- package/dist/application/code/repository.d.ts +9 -0
- package/dist/application/code/worktrees.d.ts +123 -0
- package/dist/application/contracts.d.ts +288 -0
- package/dist/application/coordinator-client.d.ts +33 -0
- package/dist/application/coordinator-discovery.d.ts +17 -0
- package/dist/application/coordinator-launcher.d.ts +2 -0
- package/dist/application/coordinator.d.ts +27 -0
- package/dist/application/credential-process.d.ts +13 -0
- package/dist/application/host.d.ts +7 -0
- package/dist/application/management.d.ts +68 -0
- package/dist/application/notes.d.ts +5 -0
- package/dist/application/offline-migration.d.ts +16 -0
- package/dist/application/personal-state.d.ts +5 -0
- package/dist/application/review-channel.d.ts +23 -0
- package/dist/application/review-tickets.d.ts +29 -0
- package/dist/application/runtime-binding.d.ts +4 -0
- package/dist/application-cli-wfh08g41.js +184 -0
- package/dist/application-cli-z3f9pvcf.js +209 -0
- package/dist/approvals/auto-approve.d.ts +1 -1
- package/dist/arguments-75r85mvc.js +27 -0
- package/dist/arguments-x24bbqvd.js +22 -0
- package/dist/audit/index.js +16 -472
- package/dist/audit-pack-1gnych0m.js +93 -0
- package/dist/{audit-pack-y02n8zd0.js → audit-pack-h44kjkbj.js} +17 -11
- package/dist/calendar-2xw0rr7b.js +49 -0
- package/dist/cli/application-cli.d.ts +2 -0
- package/dist/cli/arguments.d.ts +14 -1
- package/dist/cli/auto-approve-setup.d.ts +13 -0
- package/dist/cli/configured-harness.d.ts +1 -2
- package/dist/cli/console/console-budget.d.ts +16 -2
- package/dist/cli/console/console-checkpoints.d.ts +12 -0
- package/dist/cli/console/console-commands.d.ts +3 -3
- package/dist/cli/console/console-compaction.d.ts +1 -1
- package/dist/cli/console/console-diff.d.ts +2 -0
- package/dist/cli/console/console-input.d.ts +29 -1
- package/dist/cli/console/console-navigation.d.ts +2 -2
- package/dist/cli/console/console-outcome.d.ts +10 -0
- package/dist/cli/console/console-presentation.d.ts +17 -2
- package/dist/cli/console/console-pricing.d.ts +14 -0
- package/dist/cli/console/console-reasoning.d.ts +1 -1
- package/dist/cli/console/console-recovery.d.ts +2 -0
- package/dist/cli/console/console-review.d.ts +34 -0
- package/dist/cli/console/console-run-policy.d.ts +5 -0
- package/dist/cli/console/console-run-view.d.ts +28 -0
- package/dist/cli/console/console-task.d.ts +30 -0
- package/dist/cli/console/console-welcome.d.ts +13 -3
- package/dist/cli/console/review-diff.d.ts +20 -0
- package/dist/cli/presentation.d.ts +8 -6
- package/dist/cli/service-checkpoints.d.ts +234 -0
- package/dist/cli/terminal/activity-history.d.ts +4 -2
- package/dist/cli/terminal/activity-stream.d.ts +33 -0
- package/dist/cli/terminal/file-diff.d.ts +11 -0
- package/dist/cli/terminal/terminal-theme.d.ts +9 -0
- package/dist/cli/terminal/terminal-ui.d.ts +44 -2
- package/dist/cli/terminal/tool-activity.d.ts +6 -2
- package/dist/{cli-entry-hdtfef27.js → cli-entry-68kqraj7.js} +95 -43
- package/dist/{cli-entry-j6jcb2jb.js → cli-entry-86rcbmwh.js} +294 -14
- package/dist/cli-entry-btkpb4h1.js +3627 -0
- package/dist/cli-entry-bxjbs6qq.js +200 -0
- package/dist/cli-entry-cpm89r9q.js +624 -0
- package/dist/{cli-entry-v5db3eb2.js → cli-entry-dksm56sj.js} +39 -297
- package/dist/{cli-entry-td04s0fa.js → cli-entry-eka68ttb.js} +3919 -4549
- package/dist/cli-entry-h7dcah4p.js +137 -0
- package/dist/cli-entry-kwk23ktq.js +33 -0
- package/dist/{cli-entry-ynahz9qc.js → cli-entry-vmce694z.js} +1251 -3139
- package/dist/cli-entry-wanv05db.js +1113 -0
- package/dist/{cli-zw18kdqx.js → cli-z7vhm1rk.js} +1767 -380
- package/dist/cli.js +8 -6
- package/dist/client/json-contracts.d.ts +153 -0
- package/dist/client/local-service.d.ts +7 -12
- package/dist/client/local-transport.d.ts +14 -0
- package/dist/client/protocol.d.ts +43 -1
- package/dist/compat/cli-options.d.ts +7 -1
- package/dist/compat/cli.d.ts +2 -0
- package/dist/compat/cli.js +4043 -0
- package/dist/compat/code-support.d.ts +3 -0
- package/dist/compat/code-support.js +50 -28
- package/dist/{config-r9fdhce6.js → config-hw78440t.js} +5 -5
- package/dist/{config-vyajmksy.js → config-v7s8hp37.js} +1 -1
- package/dist/context/adaptive-compaction.d.ts +1 -0
- package/dist/context/lossless-lines.d.ts +13 -0
- package/dist/context/numbered-read-lines.d.ts +15 -0
- package/dist/context/read-attempts.d.ts +21 -0
- package/dist/context/request-projection.d.ts +32 -4
- package/dist/context/scoped-context.d.ts +14 -0
- package/dist/context/working-read-replay.d.ts +12 -0
- package/dist/coordinator-client-nzysqxf0.js +10 -0
- package/dist/engine/acp.js +27 -21
- package/dist/engine/application-client.d.ts +11 -0
- package/dist/engine/application-client.js +18 -0
- package/dist/engine/application-protocol.d.ts +5 -0
- package/dist/engine/application-protocol.js +7 -0
- package/dist/engine/application.d.ts +43 -0
- package/dist/engine/application.js +206 -0
- package/dist/engine/assistant/automation/scheduler.d.ts +2 -0
- package/dist/engine/assistant/automation/scheduler.js +11 -0
- package/dist/engine/assistant/automation/summary.d.ts +3 -0
- package/dist/engine/assistant/automation/summary.js +8 -0
- package/dist/engine/assistant/automation/time.d.ts +5 -0
- package/dist/engine/assistant/automation/time.js +15 -0
- package/dist/engine/assistant/calendar/calendar.d.ts +5 -0
- package/dist/engine/assistant/calendar/calendar.js +12 -0
- package/dist/engine/assistant/calendar/connection.d.ts +2 -0
- package/dist/engine/assistant/calendar/connection.js +11 -0
- package/dist/engine/assistant/calendar/environment.d.ts +1 -0
- package/dist/engine/assistant/calendar/environment.js +7 -0
- package/dist/engine/assistant/calendar/http.d.ts +3 -0
- package/dist/engine/assistant/calendar/http.js +9 -0
- package/dist/engine/assistant/calendar/oauth.d.ts +5 -0
- package/dist/engine/assistant/calendar/oauth.js +12 -0
- package/dist/engine/assistant/calendar/store.d.ts +2 -0
- package/dist/engine/assistant/calendar/store.js +8 -0
- package/dist/engine/assistant/calendar/tools.d.ts +2 -0
- package/dist/engine/assistant/calendar/tools.js +46 -0
- package/dist/engine/assistant/client.d.ts +2 -0
- package/dist/engine/assistant/client.js +33 -0
- package/dist/engine/assistant/config.d.ts +1 -0
- package/dist/engine/assistant/config.js +102 -0
- package/dist/engine/assistant/contracts.d.ts +10 -0
- package/dist/engine/assistant/contracts.js +78 -0
- package/dist/engine/assistant/daily/service.d.ts +12 -0
- package/dist/engine/assistant/daily/service.js +27 -0
- package/dist/engine/assistant/doctor.d.ts +1 -0
- package/dist/engine/assistant/doctor.js +116 -0
- package/dist/engine/assistant/evaluation.d.ts +2 -0
- package/dist/engine/assistant/evaluation.js +76 -0
- package/dist/engine/assistant/host.d.ts +2 -0
- package/dist/engine/assistant/host.js +63 -0
- package/dist/engine/assistant/integrations/google.d.ts +9 -0
- package/dist/engine/assistant/integrations/google.js +30 -0
- package/dist/engine/assistant/integrations/public-web.d.ts +3 -0
- package/dist/engine/assistant/integrations/public-web.js +11 -0
- package/dist/engine/assistant/managed/secrets.d.ts +1 -0
- package/dist/engine/assistant/managed/secrets.js +0 -0
- package/dist/engine/assistant/managed/setup-state.d.ts +11 -0
- package/dist/engine/assistant/managed/setup-state.js +84 -0
- package/dist/engine/assistant/managed/setup.d.ts +3 -0
- package/dist/engine/assistant/managed/setup.js +85 -0
- package/dist/engine/assistant/microsoft/connection.d.ts +7 -0
- package/dist/engine/assistant/microsoft/connection.js +21 -0
- package/dist/engine/assistant/microsoft/tools.d.ts +8 -0
- package/dist/engine/assistant/microsoft/tools.js +30 -0
- package/dist/engine/assistant/modules/calendar.d.ts +1 -0
- package/dist/engine/assistant/modules/calendar.js +49 -0
- package/dist/engine/assistant/modules/catalog.d.ts +3 -0
- package/dist/engine/assistant/modules/catalog.js +67 -0
- package/dist/engine/assistant/modules/daily.d.ts +1 -0
- package/dist/engine/assistant/modules/daily.js +48 -0
- package/dist/engine/assistant/modules/github.d.ts +1 -0
- package/dist/engine/assistant/modules/github.js +43 -0
- package/dist/engine/assistant/modules/google.d.ts +1 -0
- package/dist/engine/assistant/modules/google.js +53 -0
- package/dist/engine/assistant/modules/mcp.d.ts +1 -0
- package/dist/engine/assistant/modules/mcp.js +42 -0
- package/dist/engine/assistant/modules/microsoft.d.ts +1 -0
- package/dist/engine/assistant/modules/microsoft.js +53 -0
- package/dist/engine/assistant/modules/module.d.ts +5 -0
- package/dist/engine/assistant/modules/module.js +42 -0
- package/dist/engine/assistant/modules/tools.d.ts +2 -0
- package/dist/engine/assistant/modules/tools.js +42 -0
- package/dist/engine/assistant/modules/web.d.ts +1 -0
- package/dist/engine/assistant/modules/web.js +45 -0
- package/dist/engine/assistant/private-directory.d.ts +1 -0
- package/dist/engine/assistant/private-directory.js +7 -0
- package/dist/engine/assistant/proactive/service.d.ts +6 -0
- package/dist/engine/assistant/proactive/service.js +16 -0
- package/dist/engine/assistant/providers/openai-compatible.d.ts +4 -0
- package/dist/engine/assistant/providers/openai-compatible.js +12 -0
- package/dist/engine/assistant/providers/provider.d.ts +7 -0
- package/dist/engine/assistant/providers/provider.js +54 -0
- package/dist/engine/assistant/providers/web-citations.d.ts +1 -0
- package/dist/engine/assistant/providers/web-citations.js +7 -0
- package/dist/engine/assistant/runtime.d.ts +2 -0
- package/dist/engine/assistant/runtime.js +73 -0
- package/dist/engine/assistant/task-metrics.d.ts +8 -0
- package/dist/engine/assistant/task-metrics.js +17 -0
- package/dist/engine/assistant/telegram/api.d.ts +5 -0
- package/dist/engine/assistant/telegram/api.js +11 -0
- package/dist/engine/assistant/telegram/bridge.d.ts +2 -0
- package/dist/engine/assistant/telegram/bridge.js +40 -0
- package/dist/engine/assistant/telegram/store.d.ts +2 -0
- package/dist/engine/assistant/telegram/store.js +8 -0
- package/dist/engine/client.js +26 -18
- package/dist/engine/desktop-providers-v1.js +4 -4
- package/dist/engine/desktop-state-v1.js +16 -13
- package/dist/engine/index.js +111 -159
- package/dist/engine/mcp-stdio-v1.js +13 -12
- package/dist/engine/models.js +65 -23
- package/dist/engine/protocol.js +10 -6
- package/dist/engine/service.js +32 -21
- package/dist/hostile-repository-demo.js +1822 -696
- package/dist/index-09rsdr2d.js +1744 -0
- package/dist/index-0csc5sc7.js +139 -0
- package/dist/{index-v86bh0eg.js → index-0dkty795.js} +8 -6
- package/dist/index-0kkgqvg7.js +0 -0
- package/dist/index-0mzz9axm.js +58 -0
- package/dist/index-1e69ar8r.js +38 -0
- package/dist/index-1z0xhkh9.js +18 -0
- package/dist/index-2cef1k92.js +356 -0
- package/dist/{index-k1a1xesg.js → index-2j0v1xwr.js} +17 -13
- package/dist/index-2jw9jd7h.js +116 -0
- package/dist/index-2n9qx4km.js +0 -0
- package/dist/index-3rvk23e8.js +877 -0
- package/dist/index-3wa4j0yk.js +71 -0
- package/dist/index-41q1k17x.js +210 -0
- package/dist/index-4vz4bqqw.js +33 -0
- package/dist/index-5jxm2wy5.js +123 -0
- package/dist/index-5rk6ss42.js +216 -0
- package/dist/index-5v1skxf7.js +1852 -0
- package/dist/{index-qz4fs9f9.js → index-6ehtssyz.js} +355 -332
- package/dist/index-76kpdbpw.js +80 -0
- package/dist/{index-r0q0r88h.js → index-7nbmhmw5.js} +10 -10
- package/dist/index-8mx0yrkz.js +31 -0
- package/dist/index-8tjev5ds.js +11 -0
- package/dist/index-91n5wr6s.js +163 -0
- package/dist/index-91trs3ew.js +151 -0
- package/dist/index-9y8p5vy5.js +222 -0
- package/dist/index-abxahprd.js +55 -0
- package/dist/index-aptyr511.js +84 -0
- package/dist/{index-8sm2a1wa.js → index-ay26xfxt.js} +28 -20
- package/dist/index-b4yed1s3.js +657 -0
- package/dist/index-bb7phvtg.js +23 -0
- package/dist/index-bk5tn9b8.js +236 -0
- package/dist/index-bw34861c.js +292 -0
- package/dist/index-c6fnjhgv.js +55 -0
- package/dist/{index-qfsrrnz6.js → index-cjevq9s8.js} +2 -2
- package/dist/{index-c39197wq.js → index-ctcwrkrc.js} +4 -4
- package/dist/{index-yx52bt4a.js → index-cztmcesv.js} +2 -2
- package/dist/index-dpbmxnrf.js +564 -0
- package/dist/index-ekxdcy36.js +134 -0
- package/dist/index-f8zpcsx3.js +289 -0
- package/dist/{index-6dxrbnxm.js → index-f970qtb4.js} +7 -143
- package/dist/index-fatcn6fp.js +2791 -0
- package/dist/index-fbzykqxy.js +105 -0
- package/dist/{index-1265j7t2.js → index-fwf274vc.js} +24 -14
- package/dist/index-fy4w0a7v.js +0 -0
- package/dist/index-gvva3e5x.js +76 -0
- package/dist/index-h7dcah4p.js +137 -0
- package/dist/index-hm9r120s.js +42 -0
- package/dist/index-j3d2tw97.js +328 -0
- package/dist/index-jfqj20x8.js +41 -0
- package/dist/{index-yp0jtaxp.js → index-k529a278.js} +6 -6
- package/dist/{index-bt2p8x7r.js → index-kbrf5bx7.js} +110 -106
- package/dist/index-kwk23ktq.js +33 -0
- package/dist/index-kz857p1j.js +557 -0
- package/dist/{index-tc2r2n8b.js → index-mkt5yrax.js} +31 -105
- package/dist/{index-tgt8gtq7.js → index-ndgnvjez.js} +18 -18
- package/dist/index-nemn4epv.js +43 -0
- package/dist/index-nkwy5bjr.js +1225 -0
- package/dist/index-nvvzr4ny.js +136 -0
- package/dist/index-pkspzsfs.js +78 -0
- package/dist/{index-fm84men1.js → index-px1tnqgt.js} +2 -2
- package/dist/index-q7qdw883.js +79 -0
- package/dist/{index-mzydbzp8.js → index-qvbg6tx1.js} +65 -23
- package/dist/index-r3mwr5fb.js +0 -0
- package/dist/index-rdr78m0k.js +91 -0
- package/dist/index-rtamqsfs.js +59 -0
- package/dist/index-s125ss45.js +38 -0
- package/dist/{index-h8r80xhk.js → index-sx1t6dnd.js} +4005 -2781
- package/dist/index-tar0ngkm.js +359 -0
- package/dist/index-tn58cr6w.js +471 -0
- package/dist/{index-v17e1xs8.js → index-v79s9bf9.js} +96 -23
- package/dist/index-vk3rq21m.js +17 -0
- package/dist/index-vmvnr28y.js +72 -0
- package/dist/index-vz629cg8.js +49 -0
- package/dist/{index-eps3c3g6.js → index-w292hdpz.js} +197 -960
- package/dist/{index-t6sjhxh8.js → index-w9eqg6p9.js} +24 -302
- package/dist/index-wj96kdw2.js +57 -0
- package/dist/index-wyck5yhd.js +141 -0
- package/dist/index-xvtk8pxs.js +674 -0
- package/dist/{index-bpc596v3.js → index-xwb691v9.js} +2 -2
- package/dist/index-ym69x168.js +518 -0
- package/dist/index-yprdjk9v.js +65 -0
- package/dist/index-z2a81ccr.js +35 -0
- package/dist/{index-3ah1f369.js → index-z69cqk74.js} +3 -3
- package/dist/index-zaakvmzq.js +62 -0
- package/dist/index-zk3m4mzg.js +232 -0
- package/dist/index-zx3wgvx4.js +218 -0
- package/dist/index.js +102 -83
- package/dist/persistence/migration-guard.d.ts +3 -0
- package/dist/runtime/harness.d.ts +2 -0
- package/dist/service-cli.js +130 -40
- package/dist/service-client-cli-2rzxy5mj.js +1166 -0
- package/dist/service-client-cli-5ne8q5ej.js +543 -0
- package/dist/tools/ooxml-zip.d.ts +21 -0
- package/dist/tools/presentations.d.ts +47 -0
- package/dist/tools/tabular-data.d.ts +114 -0
- package/dist/tools/workspace.d.ts +76 -0
- package/dist/verify-historical-migrations.js +1923 -797
- package/dist/workspace/workspace.d.ts +13 -1
- package/dist/zhx.js +8 -6
- package/docs/APPLICATION_MIGRATION.md +32 -0
- package/docs/CLI.md +166 -2
- package/docs/CODE_RELEASE.md +5 -3
- package/docs/CODE_WEB_TASKS.md +3 -114
- package/docs/CONTEXT_ENGINEERING.md +27 -0
- package/docs/ENGINE_API.md +1 -1
- package/docs/EXTENSIBILITY.md +1 -1
- package/docs/FIRST_USE.md +6 -6
- package/docs/INTERNAL_ARCHIVE.md +43 -0
- package/docs/LOCAL_SERVICE.md +1 -1
- package/docs/MODEL_CATALOG.md +14 -0
- package/docs/README.md +13 -2
- package/evaluations/representative-assembly-matrix.json +10 -1
- package/examples/README.md +3 -3
- package/examples/assistant/compatible-calendar.json +17 -0
- package/examples/assistant/composed-modules.json +23 -0
- package/examples/assistant/connected-tools.json +9 -0
- package/examples/assistant/daily-tools.json +6 -0
- package/examples/assistant/offline.mjs +24 -0
- package/fixtures/cli-compatibility/README.md +10 -0
- package/fixtures/cli-compatibility/inventory.json +7858 -0
- package/package.json +230 -28
- package/dist/cli/console/console-model-catalog.d.ts +0 -8
- package/dist/index-4gt045j0.js +0 -288
- package/dist/index-4jw3tvy8.js +0 -301
- package/dist/index-ebb5d4s3.js +0 -640
- package/dist/index-x9hv1a34.js +0 -274
- package/dist/service-client-cli-gtk26axb.js +0 -1251
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Launch a persistent service only when discovery finds no live endpoint; the manager lease resolves races. */
|
|
2
|
+
export declare function ensureApplicationCoordinator(directory: string, launcher: {
|
|
3
|
+
executable: string;
|
|
4
|
+
entry: string;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
call: <T = unknown>(method: import("./contracts.js").CoordinatorMethod | 'hello', input?: unknown) => Promise<T>;
|
|
7
|
+
protocol: {
|
|
8
|
+
version: 1;
|
|
9
|
+
projectionVersion?: 1 | undefined;
|
|
10
|
+
activityVersion?: 1 | undefined;
|
|
11
|
+
generation?: string | undefined;
|
|
12
|
+
capabilities: string[];
|
|
13
|
+
};
|
|
14
|
+
capabilities: string[];
|
|
15
|
+
catalog: () => Promise<import("./contracts.js").ApplicationCatalogSnapshot>;
|
|
16
|
+
state: () => Promise<import("./coordinator-client.js").CoordinatorSnapshot>;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ApplicationCatalogSnapshot } from './contracts.js';
|
|
2
|
+
import { startManagedAssistant } from './assistant/managed/setup.js';
|
|
3
|
+
import type { CoordinatorSnapshot } from './coordinator-client.js';
|
|
4
|
+
/** One manager lease and one authenticated control endpoint per private application directory. */
|
|
5
|
+
export declare function startApplicationCoordinator(directory: string, options: Parameters<typeof startManagedAssistant>[1]): Promise<{
|
|
6
|
+
credentialsPath: string;
|
|
7
|
+
state: () => CoordinatorSnapshot;
|
|
8
|
+
close: () => Promise<void>;
|
|
9
|
+
}>;
|
|
10
|
+
/** Both launchers use the same discovery and lease-race resolution. Attached clients never own shutdown. */
|
|
11
|
+
export declare function acquireApplicationCoordinator(directory: string, options: Parameters<typeof startManagedAssistant>[1]): Promise<{
|
|
12
|
+
client: {
|
|
13
|
+
call: <T = unknown>(method: import("./contracts.js").CoordinatorMethod | 'hello', input?: unknown) => Promise<T>;
|
|
14
|
+
protocol: {
|
|
15
|
+
version: 1;
|
|
16
|
+
projectionVersion?: 1 | undefined;
|
|
17
|
+
activityVersion?: 1 | undefined;
|
|
18
|
+
generation?: string | undefined;
|
|
19
|
+
capabilities: string[];
|
|
20
|
+
};
|
|
21
|
+
capabilities: string[];
|
|
22
|
+
catalog: () => Promise<ApplicationCatalogSnapshot>;
|
|
23
|
+
state: () => Promise<CoordinatorSnapshot>;
|
|
24
|
+
};
|
|
25
|
+
ownsService: boolean;
|
|
26
|
+
close: () => Promise<void>;
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SecretStore } from './assistant/managed/secrets.js';
|
|
2
|
+
/** One killable process per native request. Secrets travel only through private pipes.
|
|
3
|
+
* A write with no confirmed response locks writes until an explicit successful read.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createProcessSecretStore(directory: string, options: {
|
|
6
|
+
executable: string;
|
|
7
|
+
entry: string;
|
|
8
|
+
args?: string[];
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
}): Promise<SecretStore>;
|
|
12
|
+
/** Internal worker entrypoint. Never logs native errors or credential values. */
|
|
13
|
+
export declare function runCredentialWorker(createStore: (account: string) => Promise<SecretStore>): Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createApplicationReviewChannel } from "./review-channel.js";
|
|
2
|
+
import type { ZhivexHarness } from "../runtime/harness.js";
|
|
3
|
+
import { type HarnessLocalServiceOptions } from "../client/local-service.js";
|
|
4
|
+
/** The application owns lifecycle; the existing engine retains authoritative state,
|
|
5
|
+
* admission, revisions and leases. Callers must close the harness if startup fails.
|
|
6
|
+
*/
|
|
7
|
+
export declare function startApplicationHost(harness: ZhivexHarness, options: HarnessLocalServiceOptions, review?: Parameters<typeof createApplicationReviewChannel>[2]): Promise<import("../index.js").HarnessLocalService>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ManagedApplication } from './coordinator-client.js';
|
|
2
|
+
/** Shared management operations. The coordinator serializes these with setup and project changes. */
|
|
3
|
+
export declare function manageApplication(manager: ManagedApplication, raw: unknown): Promise<{
|
|
4
|
+
schemaVersion: 1;
|
|
5
|
+
kind: 'application-agents';
|
|
6
|
+
agents: {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
active: boolean;
|
|
10
|
+
connectionId?: string | undefined;
|
|
11
|
+
provider: import("./contracts.js").ProviderSummary | null;
|
|
12
|
+
integrations: {
|
|
13
|
+
microsoft: boolean;
|
|
14
|
+
microsoftEmail?: string | undefined;
|
|
15
|
+
outlookMail: boolean;
|
|
16
|
+
outlookCalendar: boolean;
|
|
17
|
+
daily: boolean;
|
|
18
|
+
github: boolean;
|
|
19
|
+
web: boolean;
|
|
20
|
+
mail: boolean;
|
|
21
|
+
drive: boolean;
|
|
22
|
+
calendar: boolean;
|
|
23
|
+
calendarEmail?: string | undefined;
|
|
24
|
+
telegram: boolean;
|
|
25
|
+
};
|
|
26
|
+
}[];
|
|
27
|
+
draft: {
|
|
28
|
+
name: string | undefined;
|
|
29
|
+
tools: {
|
|
30
|
+
daily: boolean;
|
|
31
|
+
proactive?: boolean | undefined;
|
|
32
|
+
github?: {
|
|
33
|
+
account: string;
|
|
34
|
+
authorizationEnv: string;
|
|
35
|
+
} | undefined;
|
|
36
|
+
web?: {
|
|
37
|
+
apiKeyEnv: string;
|
|
38
|
+
} | undefined;
|
|
39
|
+
};
|
|
40
|
+
} | null;
|
|
41
|
+
ready: boolean;
|
|
42
|
+
connections?: never;
|
|
43
|
+
} | {
|
|
44
|
+
agents?: never;
|
|
45
|
+
draft?: never;
|
|
46
|
+
ready?: never;
|
|
47
|
+
schemaVersion: 1;
|
|
48
|
+
kind: 'application-connections';
|
|
49
|
+
connections: ({
|
|
50
|
+
id: string;
|
|
51
|
+
agents: {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
}[];
|
|
55
|
+
draft: boolean;
|
|
56
|
+
label: string;
|
|
57
|
+
} & Partial<import("./contracts.js").ProviderSummary>)[];
|
|
58
|
+
} | {
|
|
59
|
+
projects: import("./contracts.js").CodeProject[];
|
|
60
|
+
active?: string | undefined;
|
|
61
|
+
ready: boolean;
|
|
62
|
+
error: string | null;
|
|
63
|
+
agents?: never;
|
|
64
|
+
draft?: never;
|
|
65
|
+
connections?: never;
|
|
66
|
+
schemaVersion: 1;
|
|
67
|
+
kind: 'application-projects';
|
|
68
|
+
}>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NotesSnapshot } from './contracts.js';
|
|
2
|
+
export type { NotesSnapshot } from './contracts.js';
|
|
3
|
+
import type { ManagedApplication } from './coordinator-client.js';
|
|
4
|
+
/** Reads only: writing and deleting notes require the runtime's reviewed tools. */
|
|
5
|
+
export declare function readNotes(manager: ManagedApplication, raw: unknown): Promise<NotesSnapshot>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Offline only: no schema inference, credential access, identity remapping or relocation.
|
|
2
|
+
* Every caller-provided application/state root is copied byte-for-byte. Unknown files
|
|
3
|
+
* are retained; sockets and cooperative lock inodes are operational, not user state.
|
|
4
|
+
*/
|
|
5
|
+
export declare function applicationMigration(options: {
|
|
6
|
+
roots: string[];
|
|
7
|
+
backup: string;
|
|
8
|
+
action: 'backup' | 'inspect' | 'abort' | 'inspect-rollback' | 'rollback';
|
|
9
|
+
expectedCurrentSha256?: string;
|
|
10
|
+
afterWrite?: () => Promise<void>;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
manifestSha256: string;
|
|
13
|
+
currentSha256: string;
|
|
14
|
+
phase: "aborted" | "copying" | "ready" | "restored" | "restoring";
|
|
15
|
+
files: number;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PersonalSnapshot } from './contracts.js';
|
|
2
|
+
export type { PersonalSnapshot } from './contracts.js';
|
|
3
|
+
import type { ManagedApplication } from './coordinator-client.js';
|
|
4
|
+
/** Read projection only. Mutations continue through the runtime's reviewed tools. */
|
|
5
|
+
export declare function readPersonalState(manager: ManagedApplication, raw: unknown): Promise<PersonalSnapshot>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type HarnessClientAdapter, type HarnessClientResponse, type HarnessClientRun } from "../client/protocol.js";
|
|
2
|
+
import { type ApprovalReview } from "./approval-review.js";
|
|
3
|
+
import { type TicketedApprovalReview } from "./review-tickets.js";
|
|
4
|
+
export type ApplicationReviewResponse = {
|
|
5
|
+
ok: true;
|
|
6
|
+
review: TicketedApprovalReview;
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
error: {
|
|
10
|
+
code: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/** Enabled only by the application host on its authenticated, owner-private socket.
|
|
14
|
+
* Raw engine commands never acquire reviewed authority. A client must first get
|
|
15
|
+
* the bounded host projection and resolve its connection-bound, single-use receipt.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createApplicationReviewChannel(adapter: HarnessClientAdapter, secrets: readonly string[], options?: {
|
|
18
|
+
tools?: readonly string[];
|
|
19
|
+
project?: (run: HarnessClientRun, redact: (text: string) => string, redactContactDetails: (text: string) => string) => Promise<ApprovalReview>;
|
|
20
|
+
}): {
|
|
21
|
+
review(value: unknown): Promise<ApplicationReviewResponse>;
|
|
22
|
+
decide(value: unknown): Promise<HarnessClientResponse>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ApprovalReview } from "./approval-review.js";
|
|
2
|
+
/** Host-owned receipts: renderer supplies only an opaque ticket and a boolean decision. */
|
|
3
|
+
export declare class ReviewTickets {
|
|
4
|
+
private readonly supported;
|
|
5
|
+
constructor(additionalTools?: readonly string[]);
|
|
6
|
+
private readonly entries;
|
|
7
|
+
issue(sessionId: string, review: ApprovalReview): {
|
|
8
|
+
schemaVersion: 1;
|
|
9
|
+
runId: string;
|
|
10
|
+
revision: number;
|
|
11
|
+
status: string;
|
|
12
|
+
items: import("./approval-review.js").ApprovalReviewItem[];
|
|
13
|
+
ticketId: `${string}-${string}-${string}-${string}-${string}`;
|
|
14
|
+
canApprove: boolean;
|
|
15
|
+
};
|
|
16
|
+
consume(ticketId: unknown, approve: unknown, now?: number): {
|
|
17
|
+
method: "approval.resolve";
|
|
18
|
+
sessionId: string;
|
|
19
|
+
runId: string;
|
|
20
|
+
expectedRevision: number;
|
|
21
|
+
idempotencyKey: string;
|
|
22
|
+
decisions: {
|
|
23
|
+
approvalId: string;
|
|
24
|
+
digest: string;
|
|
25
|
+
approve: boolean;
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export type TicketedApprovalReview = ReturnType<ReviewTickets["issue"]>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ZhivexHarness } from '../runtime/harness.js';
|
|
2
|
+
import type { ApplicationRuntimeBinding } from './contracts.js';
|
|
3
|
+
/** Only immutable identity and tool names cross the presentation boundary. */
|
|
4
|
+
export declare function applicationRuntimeBinding(harness: ZhivexHarness): ApplicationRuntimeBinding;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sanitizeTerminalText
|
|
3
|
+
} from "./index-3rvk23e8.js";
|
|
4
|
+
import"./index-dpbmxnrf.js";
|
|
5
|
+
import"./index-cjevq9s8.js";
|
|
6
|
+
import {
|
|
7
|
+
validZone
|
|
8
|
+
} from "./index-rtamqsfs.js";
|
|
9
|
+
import"./index-sx1t6dnd.js";
|
|
10
|
+
import"./index-k529a278.js";
|
|
11
|
+
import"./index-bw34861c.js";
|
|
12
|
+
import"./index-w9eqg6p9.js";
|
|
13
|
+
import"./index-v79s9bf9.js";
|
|
14
|
+
import"./index-fwf274vc.js";
|
|
15
|
+
import"./index-ctcwrkrc.js";
|
|
16
|
+
import"./index-qvbg6tx1.js";
|
|
17
|
+
import"./index-kbrf5bx7.js";
|
|
18
|
+
import"./index-kwk23ktq.js";
|
|
19
|
+
import"./index-6ehtssyz.js";
|
|
20
|
+
import"./index-f970qtb4.js";
|
|
21
|
+
import"./index-h7dcah4p.js";
|
|
22
|
+
import {
|
|
23
|
+
connectCoordinator
|
|
24
|
+
} from "./index-s125ss45.js";
|
|
25
|
+
import {
|
|
26
|
+
connectApplication
|
|
27
|
+
} from "./index-0mzz9axm.js";
|
|
28
|
+
import"./index-3wa4j0yk.js";
|
|
29
|
+
import {
|
|
30
|
+
HarnessConfigError
|
|
31
|
+
} from "./index-xwb691v9.js";
|
|
32
|
+
import"./index-px1tnqgt.js";
|
|
33
|
+
import"./index-76kpdbpw.js";
|
|
34
|
+
import"./index-1bx83sw4.js";
|
|
35
|
+
|
|
36
|
+
// packages/core/src/cli/application-cli.ts
|
|
37
|
+
import { z } from "zod";
|
|
38
|
+
import path from "node:path";
|
|
39
|
+
import os from "node:os";
|
|
40
|
+
import { realpath } from "node:fs/promises";
|
|
41
|
+
|
|
42
|
+
// packages/core/src/application/coordinator-discovery.ts
|
|
43
|
+
import { spawn } from "node:child_process";
|
|
44
|
+
var unavailable = (error) => error.code === "ENOENT" || error instanceof Error && error.message === "LOCAL_SERVICE_UNAVAILABLE";
|
|
45
|
+
async function ensureApplicationCoordinator(directory, launcher) {
|
|
46
|
+
try {
|
|
47
|
+
return await connectCoordinator(directory);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (!unavailable(error))
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
const child = spawn(launcher.executable, [launcher.entry, "--application-directory", directory], { detached: true, stdio: "ignore", env: process.env });
|
|
53
|
+
let failed = false;
|
|
54
|
+
child.once("error", () => {
|
|
55
|
+
failed = true;
|
|
56
|
+
});
|
|
57
|
+
child.unref();
|
|
58
|
+
for (let attempt = 0;attempt < 300; attempt++) {
|
|
59
|
+
try {
|
|
60
|
+
return await connectCoordinator(directory);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (!unavailable(error))
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
if (failed)
|
|
66
|
+
throw new Error("COORDINATOR_LAUNCH_FAILED");
|
|
67
|
+
if (child.exitCode !== null && child.exitCode !== 0)
|
|
68
|
+
throw new Error("COORDINATOR_LAUNCH_FAILED");
|
|
69
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
70
|
+
}
|
|
71
|
+
throw new Error("COORDINATOR_START_UNCONFIRMED");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// packages/core/src/cli/application-cli.ts
|
|
75
|
+
async function useApplicationCli(options) {
|
|
76
|
+
const automationInput = options.command === "automations" && options.automationCommand === "apply" ? parseAutomationInput(options.managementInput) : undefined;
|
|
77
|
+
const directory = path.resolve(options.applicationDirectory ?? path.join(os.homedir(), ".zhx-app"));
|
|
78
|
+
const lifecycle = options.command === "application" ? options.applicationCommand : undefined;
|
|
79
|
+
let client;
|
|
80
|
+
try {
|
|
81
|
+
if (lifecycle === "status" || lifecycle === "stop")
|
|
82
|
+
client = await connectCoordinator(directory);
|
|
83
|
+
else {
|
|
84
|
+
const entry = await realpath(process.argv[1]);
|
|
85
|
+
const launcher = path.join(path.dirname(entry), entry.endsWith(".ts") ? "service-cli.ts" : "service-cli.js");
|
|
86
|
+
client = await ensureApplicationCoordinator(directory, { executable: process.execPath, entry: launcher });
|
|
87
|
+
}
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (lifecycle === "status" && (error.code === "ENOENT" || error instanceof Error && error.message === "LOCAL_SERVICE_UNAVAILABLE")) {
|
|
90
|
+
print({ schemaVersion: 1, kind: "application-status", status: "unavailable", directory }, options.json);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
throw new HarnessConfigError(`Application service unavailable (${error instanceof Error ? error.message : "unknown"}). Inspect its state before retrying.`);
|
|
94
|
+
}
|
|
95
|
+
if (lifecycle === "stop") {
|
|
96
|
+
await client.call("shutdown", { confirmed: true });
|
|
97
|
+
print({ schemaVersion: 1, kind: "application-status", status: "stop-requested", directory }, options.json);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (options.command === "projects" && options.managementAction === "context") {
|
|
101
|
+
if (!client.capabilities.includes("application.code-context"))
|
|
102
|
+
throw new HarnessConfigError("The running host does not support Code context. Update and restart the host.");
|
|
103
|
+
const snapshot2 = await client.state();
|
|
104
|
+
if (!snapshot2.codeCredentialsPath)
|
|
105
|
+
throw new HarnessConfigError("No active Code project is ready. Open or select a project first.");
|
|
106
|
+
const code = await connectApplication(snapshot2.codeCredentialsPath);
|
|
107
|
+
const context = await client.call("code-tools", { action: "context", value: { projectId: code.projectId } });
|
|
108
|
+
print({ ...context, kind: "application-code-context", projectId: code.projectId }, options.json);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (["agents", "connections", "projects"].includes(options.command)) {
|
|
112
|
+
if (!client.capabilities.includes("application.management"))
|
|
113
|
+
throw new HarnessConfigError("The running application host does not support management commands. Stop it explicitly and restart with the updated version.");
|
|
114
|
+
try {
|
|
115
|
+
const result = await client.call("management", { resource: options.command, action: options.managementAction, args: options.managementArgs ?? [], ...options.managementInput === undefined ? {} : { input: options.managementInput }, confirmed: options.yes });
|
|
116
|
+
print(result, options.json);
|
|
117
|
+
return;
|
|
118
|
+
} catch (error) {
|
|
119
|
+
throw new HarnessConfigError(`Application configuration failed (${error instanceof Error ? error.message : "unknown"}). Inspect the shared draft and state before retrying.`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const snapshot = await client.state();
|
|
123
|
+
if (options.command === "automations") {
|
|
124
|
+
if (!client.capabilities.includes("application.automation"))
|
|
125
|
+
throw new HarnessConfigError("The running host does not support automations. Update and restart the host.");
|
|
126
|
+
if (!snapshot.credentialsPath)
|
|
127
|
+
throw new HarnessConfigError("No active Assistant is ready. Configure or select an agent first.");
|
|
128
|
+
const assistant = await connectApplication(snapshot.credentialsPath);
|
|
129
|
+
if (automationInput && automationInput.projectId !== assistant.projectId)
|
|
130
|
+
throw new HarnessConfigError("APPLICATION_SCOPE_CHANGED: review automation status for the active Assistant.");
|
|
131
|
+
try {
|
|
132
|
+
const automation = await client.call("automation", { projectId: assistant.projectId, ...automationInput ? { change: { ...automationInput.change, confirmed: true } } : {} });
|
|
133
|
+
print({ schemaVersion: 1, kind: "application-automation", projectId: assistant.projectId, ...automation }, options.json);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
throw new HarnessConfigError(`Automation configuration failed (${error instanceof Error ? error.message : "unknown"}). Read automations status before retrying; do not automatically repeat an uncertain change.`);
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (options.command === "personal") {
|
|
140
|
+
const notesCommand = ["notes", "search-notes", "note"].includes(options.personalCommand ?? "");
|
|
141
|
+
if (!client.capabilities.includes(notesCommand ? "application.notes" : "application.personal-state"))
|
|
142
|
+
throw new HarnessConfigError("The running host does not support personal state. Update and restart the host.");
|
|
143
|
+
if (!snapshot.credentialsPath)
|
|
144
|
+
throw new HarnessConfigError("No active Assistant is ready. Configure or select an agent first.");
|
|
145
|
+
const assistant = await connectApplication(snapshot.credentialsPath);
|
|
146
|
+
if (notesCommand) {
|
|
147
|
+
const notes = await client.call("notes", { projectId: assistant.projectId, offset: options.personalOffset ?? 0, query: options.personalQuery ?? "", ...options.personalNoteId ? { noteId: options.personalNoteId } : {} });
|
|
148
|
+
print({ schemaVersion: 1, kind: "application-notes", projectId: assistant.projectId, ...notes }, options.json);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const personal = await client.call("personal-state", { projectId: assistant.projectId, offset: options.personalOffset ?? 0 });
|
|
152
|
+
const base = { schemaVersion: 1, projectId: assistant.projectId, enabled: personal.enabled };
|
|
153
|
+
print(options.personalCommand === "tasks" ? { ...base, kind: "application-tasks", tasks: personal.tasks, total: personal.total, nextOffset: personal.nextOffset } : { ...base, kind: "application-reminders", reminders: personal.reminders }, options.json);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (lifecycle) {
|
|
157
|
+
print({ schemaVersion: 1, kind: "application-status", status: "running", directory, assistantReady: snapshot.state.ready, assistantLocked: snapshot.state.locked, assistantError: snapshot.state.error, codeReady: snapshot.code.ready }, options.json);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const area = options.applicationArea ?? "assistant";
|
|
161
|
+
const file = area === "assistant" ? snapshot.credentialsPath : snapshot.codeCredentialsPath;
|
|
162
|
+
if (!file)
|
|
163
|
+
throw new HarnessConfigError(area === "assistant" ? "The shared Assistant is not configured. Configure its agent and connection before running a task." : "No shared Code project is open. Select a Git project and model connection before running a task.");
|
|
164
|
+
return file;
|
|
165
|
+
}
|
|
166
|
+
function print(value, json) {
|
|
167
|
+
const text = JSON.stringify(value, null, 2);
|
|
168
|
+
process.stdout.write((json ? text : sanitizeTerminalText(text)) + `
|
|
169
|
+
`);
|
|
170
|
+
}
|
|
171
|
+
function parseAutomationInput(value) {
|
|
172
|
+
const common = { expectedDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/) };
|
|
173
|
+
const schema = z.object({ projectId: z.string().min(1), change: z.discriminatedUnion("action", [
|
|
174
|
+
z.object({ ...common, action: z.literal("configure"), localTime: z.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d$/), timeZone: z.string().refine(validZone) }).strict(),
|
|
175
|
+
z.object({ ...common, action: z.enum(["pause", "resume", "delete", "forget"]) }).strict()
|
|
176
|
+
]) }).strict();
|
|
177
|
+
const result = schema.safeParse(value);
|
|
178
|
+
if (!result.success)
|
|
179
|
+
throw new HarnessConfigError("Invalid automation configuration. Supply projectId and change with action and expectedDigest; configure also requires localTime (HH:mm) and a valid timeZone.");
|
|
180
|
+
return result.data;
|
|
181
|
+
}
|
|
182
|
+
export {
|
|
183
|
+
useApplicationCli
|
|
184
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connectApplication,
|
|
3
|
+
readHarnessLocalCredentials,
|
|
4
|
+
requestLocalServiceDocument
|
|
5
|
+
} from "./cli-entry-bxjbs6qq.js";
|
|
6
|
+
import {
|
|
7
|
+
sanitizeTerminalText
|
|
8
|
+
} from "./cli-entry-eka68ttb.js";
|
|
9
|
+
import"./cli-entry-vmce694z.js";
|
|
10
|
+
import"./cli-entry-kwk23ktq.js";
|
|
11
|
+
import"./cli-entry-h7dcah4p.js";
|
|
12
|
+
import {
|
|
13
|
+
HarnessConfigError
|
|
14
|
+
} from "./cli-entry-68kqraj7.js";
|
|
15
|
+
import"./cli-entry-1bx83sw4.js";
|
|
16
|
+
|
|
17
|
+
// packages/core/src/cli/application-cli.ts
|
|
18
|
+
import { z as z2 } from "zod";
|
|
19
|
+
|
|
20
|
+
// packages/core/src/application/assistant/automation/time.ts
|
|
21
|
+
var cache = new Map;
|
|
22
|
+
function validZone(zone) {
|
|
23
|
+
try {
|
|
24
|
+
return zone.length <= 100 && !!new Intl.DateTimeFormat("en", { timeZone: zone }).resolvedOptions().timeZone;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// packages/core/src/cli/application-cli.ts
|
|
31
|
+
import path2 from "node:path";
|
|
32
|
+
import os from "node:os";
|
|
33
|
+
import { realpath } from "node:fs/promises";
|
|
34
|
+
|
|
35
|
+
// packages/core/src/application/coordinator-client.ts
|
|
36
|
+
import path from "node:path";
|
|
37
|
+
import { z } from "zod";
|
|
38
|
+
async function connectCoordinator(directory, options = {}) {
|
|
39
|
+
const credentials = await readHarnessLocalCredentials(path.join(directory, "coordinator.json"));
|
|
40
|
+
const call = async (method, input) => {
|
|
41
|
+
const result = await requestLocalServiceDocument(credentials, "application", { version: 1, method, input }, method === "hello" || method === "state" ? 3000 : 120000);
|
|
42
|
+
if (!result.ok)
|
|
43
|
+
throw new ApplicationCoordinatorError(result.error ?? "COORDINATOR_RESPONSE_INVALID", result.detail);
|
|
44
|
+
return result.result;
|
|
45
|
+
};
|
|
46
|
+
const hello = z.object({ version: z.literal(1), projectionVersion: z.literal(1).optional(), activityVersion: z.literal(1).optional(), generation: z.string().uuid().optional(), capabilities: z.array(z.string()).max(100) }).parse(await call("hello", { versions: options.versions ?? [1] }));
|
|
47
|
+
if (options.requiredCapabilities?.some((capability) => !hello.capabilities.includes(capability)))
|
|
48
|
+
throw new ApplicationCoordinatorError("COORDINATOR_CAPABILITY_UNSUPPORTED", { schemaVersion: 1, code: "COORDINATOR_CAPABILITY_UNSUPPORTED", recovery: "upgrade" });
|
|
49
|
+
return { call, protocol: hello, capabilities: hello.capabilities, catalog: () => {
|
|
50
|
+
if (!hello.capabilities.includes("application.catalog"))
|
|
51
|
+
throw new ApplicationCoordinatorError("COORDINATOR_CAPABILITY_UNSUPPORTED");
|
|
52
|
+
return call("catalog");
|
|
53
|
+
}, state: () => call("state") };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class ApplicationCoordinatorError extends Error {
|
|
57
|
+
code;
|
|
58
|
+
detail;
|
|
59
|
+
constructor(code, detail) {
|
|
60
|
+
super(code);
|
|
61
|
+
this.name = "ApplicationCoordinatorError";
|
|
62
|
+
this.code = code;
|
|
63
|
+
this.detail = detail;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// packages/core/src/application/coordinator-discovery.ts
|
|
68
|
+
import { spawn } from "node:child_process";
|
|
69
|
+
var unavailable = (error) => error.code === "ENOENT" || error instanceof Error && error.message === "LOCAL_SERVICE_UNAVAILABLE";
|
|
70
|
+
async function ensureApplicationCoordinator(directory, launcher) {
|
|
71
|
+
try {
|
|
72
|
+
return await connectCoordinator(directory);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (!unavailable(error))
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
const child = spawn(launcher.executable, [launcher.entry, "--application-directory", directory], { detached: true, stdio: "ignore", env: process.env });
|
|
78
|
+
let failed = false;
|
|
79
|
+
child.once("error", () => {
|
|
80
|
+
failed = true;
|
|
81
|
+
});
|
|
82
|
+
child.unref();
|
|
83
|
+
for (let attempt = 0;attempt < 300; attempt++) {
|
|
84
|
+
try {
|
|
85
|
+
return await connectCoordinator(directory);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (!unavailable(error))
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
if (failed)
|
|
91
|
+
throw new Error("COORDINATOR_LAUNCH_FAILED");
|
|
92
|
+
if (child.exitCode !== null && child.exitCode !== 0)
|
|
93
|
+
throw new Error("COORDINATOR_LAUNCH_FAILED");
|
|
94
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
95
|
+
}
|
|
96
|
+
throw new Error("COORDINATOR_START_UNCONFIRMED");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// packages/core/src/cli/application-cli.ts
|
|
100
|
+
async function useApplicationCli(options) {
|
|
101
|
+
const automationInput = options.command === "automations" && options.automationCommand === "apply" ? parseAutomationInput(options.managementInput) : undefined;
|
|
102
|
+
const directory = path2.resolve(options.applicationDirectory ?? path2.join(os.homedir(), ".zhx-app"));
|
|
103
|
+
const lifecycle = options.command === "application" ? options.applicationCommand : undefined;
|
|
104
|
+
let client;
|
|
105
|
+
try {
|
|
106
|
+
if (lifecycle === "status" || lifecycle === "stop")
|
|
107
|
+
client = await connectCoordinator(directory);
|
|
108
|
+
else {
|
|
109
|
+
const entry = await realpath(process.argv[1]);
|
|
110
|
+
const launcher = path2.join(path2.dirname(entry), entry.endsWith(".ts") ? "service-cli.ts" : "service-cli.js");
|
|
111
|
+
client = await ensureApplicationCoordinator(directory, { executable: process.execPath, entry: launcher });
|
|
112
|
+
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (lifecycle === "status" && (error.code === "ENOENT" || error instanceof Error && error.message === "LOCAL_SERVICE_UNAVAILABLE")) {
|
|
115
|
+
print({ schemaVersion: 1, kind: "application-status", status: "unavailable", directory }, options.json);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
throw new HarnessConfigError(`Application service unavailable (${error instanceof Error ? error.message : "unknown"}). Inspect its state before retrying.`);
|
|
119
|
+
}
|
|
120
|
+
if (lifecycle === "stop") {
|
|
121
|
+
await client.call("shutdown", { confirmed: true });
|
|
122
|
+
print({ schemaVersion: 1, kind: "application-status", status: "stop-requested", directory }, options.json);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (options.command === "projects" && options.managementAction === "context") {
|
|
126
|
+
if (!client.capabilities.includes("application.code-context"))
|
|
127
|
+
throw new HarnessConfigError("The running host does not support Code context. Update and restart the host.");
|
|
128
|
+
const snapshot2 = await client.state();
|
|
129
|
+
if (!snapshot2.codeCredentialsPath)
|
|
130
|
+
throw new HarnessConfigError("No active Code project is ready. Open or select a project first.");
|
|
131
|
+
const code = await connectApplication(snapshot2.codeCredentialsPath);
|
|
132
|
+
const context = await client.call("code-tools", { action: "context", value: { projectId: code.projectId } });
|
|
133
|
+
print({ ...context, kind: "application-code-context", projectId: code.projectId }, options.json);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (["agents", "connections", "projects"].includes(options.command)) {
|
|
137
|
+
if (!client.capabilities.includes("application.management"))
|
|
138
|
+
throw new HarnessConfigError("The running application host does not support management commands. Stop it explicitly and restart with the updated version.");
|
|
139
|
+
try {
|
|
140
|
+
const result = await client.call("management", { resource: options.command, action: options.managementAction, args: options.managementArgs ?? [], ...options.managementInput === undefined ? {} : { input: options.managementInput }, confirmed: options.yes });
|
|
141
|
+
print(result, options.json);
|
|
142
|
+
return;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
throw new HarnessConfigError(`Application configuration failed (${error instanceof Error ? error.message : "unknown"}). Inspect the shared draft and state before retrying.`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const snapshot = await client.state();
|
|
148
|
+
if (options.command === "automations") {
|
|
149
|
+
if (!client.capabilities.includes("application.automation"))
|
|
150
|
+
throw new HarnessConfigError("The running host does not support automations. Update and restart the host.");
|
|
151
|
+
if (!snapshot.credentialsPath)
|
|
152
|
+
throw new HarnessConfigError("No active Assistant is ready. Configure or select an agent first.");
|
|
153
|
+
const assistant = await connectApplication(snapshot.credentialsPath);
|
|
154
|
+
if (automationInput && automationInput.projectId !== assistant.projectId)
|
|
155
|
+
throw new HarnessConfigError("APPLICATION_SCOPE_CHANGED: review automation status for the active Assistant.");
|
|
156
|
+
try {
|
|
157
|
+
const automation = await client.call("automation", { projectId: assistant.projectId, ...automationInput ? { change: { ...automationInput.change, confirmed: true } } : {} });
|
|
158
|
+
print({ schemaVersion: 1, kind: "application-automation", projectId: assistant.projectId, ...automation }, options.json);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
throw new HarnessConfigError(`Automation configuration failed (${error instanceof Error ? error.message : "unknown"}). Read automations status before retrying; do not automatically repeat an uncertain change.`);
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (options.command === "personal") {
|
|
165
|
+
const notesCommand = ["notes", "search-notes", "note"].includes(options.personalCommand ?? "");
|
|
166
|
+
if (!client.capabilities.includes(notesCommand ? "application.notes" : "application.personal-state"))
|
|
167
|
+
throw new HarnessConfigError("The running host does not support personal state. Update and restart the host.");
|
|
168
|
+
if (!snapshot.credentialsPath)
|
|
169
|
+
throw new HarnessConfigError("No active Assistant is ready. Configure or select an agent first.");
|
|
170
|
+
const assistant = await connectApplication(snapshot.credentialsPath);
|
|
171
|
+
if (notesCommand) {
|
|
172
|
+
const notes = await client.call("notes", { projectId: assistant.projectId, offset: options.personalOffset ?? 0, query: options.personalQuery ?? "", ...options.personalNoteId ? { noteId: options.personalNoteId } : {} });
|
|
173
|
+
print({ schemaVersion: 1, kind: "application-notes", projectId: assistant.projectId, ...notes }, options.json);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const personal = await client.call("personal-state", { projectId: assistant.projectId, offset: options.personalOffset ?? 0 });
|
|
177
|
+
const base = { schemaVersion: 1, projectId: assistant.projectId, enabled: personal.enabled };
|
|
178
|
+
print(options.personalCommand === "tasks" ? { ...base, kind: "application-tasks", tasks: personal.tasks, total: personal.total, nextOffset: personal.nextOffset } : { ...base, kind: "application-reminders", reminders: personal.reminders }, options.json);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (lifecycle) {
|
|
182
|
+
print({ schemaVersion: 1, kind: "application-status", status: "running", directory, assistantReady: snapshot.state.ready, assistantLocked: snapshot.state.locked, assistantError: snapshot.state.error, codeReady: snapshot.code.ready }, options.json);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const area = options.applicationArea ?? "assistant";
|
|
186
|
+
const file = area === "assistant" ? snapshot.credentialsPath : snapshot.codeCredentialsPath;
|
|
187
|
+
if (!file)
|
|
188
|
+
throw new HarnessConfigError(area === "assistant" ? "The shared Assistant is not configured. Configure its agent and connection before running a task." : "No shared Code project is open. Select a Git project and model connection before running a task.");
|
|
189
|
+
return file;
|
|
190
|
+
}
|
|
191
|
+
function print(value, json) {
|
|
192
|
+
const text = JSON.stringify(value, null, 2);
|
|
193
|
+
process.stdout.write((json ? text : sanitizeTerminalText(text)) + `
|
|
194
|
+
`);
|
|
195
|
+
}
|
|
196
|
+
function parseAutomationInput(value) {
|
|
197
|
+
const common = { expectedDigest: z2.string().regex(/^sha256:[a-f0-9]{64}$/) };
|
|
198
|
+
const schema = z2.object({ projectId: z2.string().min(1), change: z2.discriminatedUnion("action", [
|
|
199
|
+
z2.object({ ...common, action: z2.literal("configure"), localTime: z2.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d$/), timeZone: z2.string().refine(validZone) }).strict(),
|
|
200
|
+
z2.object({ ...common, action: z2.enum(["pause", "resume", "delete", "forget"]) }).strict()
|
|
201
|
+
]) }).strict();
|
|
202
|
+
const result = schema.safeParse(value);
|
|
203
|
+
if (!result.success)
|
|
204
|
+
throw new HarnessConfigError("Invalid automation configuration. Supply projectId and change with action and expectedDigest; configure also requires localTime (HH:mm) and a valid timeZone.");
|
|
205
|
+
return result.data;
|
|
206
|
+
}
|
|
207
|
+
export {
|
|
208
|
+
useApplicationCli
|
|
209
|
+
};
|
|
@@ -77,12 +77,12 @@ export declare const decideBatch: (items: readonly {
|
|
|
77
77
|
name?: string;
|
|
78
78
|
arguments?: string;
|
|
79
79
|
}[], policy: AutoApprovePolicy) => {
|
|
80
|
-
reason?: never;
|
|
81
80
|
auto: true;
|
|
82
81
|
results: {
|
|
83
82
|
decision: "auto";
|
|
84
83
|
reason: "edit-in-root" | "allowlisted-command";
|
|
85
84
|
}[];
|
|
85
|
+
reason?: never;
|
|
86
86
|
} | {
|
|
87
87
|
results?: never;
|
|
88
88
|
auto: false;
|