@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,674 @@
|
|
|
1
|
+
import {
|
|
2
|
+
startManagedAssistant
|
|
3
|
+
} from "./index-fatcn6fp.js";
|
|
4
|
+
import {
|
|
5
|
+
dayWindow,
|
|
6
|
+
validZone
|
|
7
|
+
} from "./index-rtamqsfs.js";
|
|
8
|
+
import {
|
|
9
|
+
createEventInputSchema
|
|
10
|
+
} from "./index-2cef1k92.js";
|
|
11
|
+
import {
|
|
12
|
+
connectApplication
|
|
13
|
+
} from "./index-0mzz9axm.js";
|
|
14
|
+
import {
|
|
15
|
+
__require
|
|
16
|
+
} from "./index-1bx83sw4.js";
|
|
17
|
+
|
|
18
|
+
// packages/core/src/application/credential-process.ts
|
|
19
|
+
import { spawn } from "node:child_process";
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
21
|
+
import { realpath } from "node:fs/promises";
|
|
22
|
+
import { z } from "zod";
|
|
23
|
+
var requestSchema = z.discriminatedUnion("operation", [
|
|
24
|
+
z.object({ operation: z.literal("read"), account: z.string().regex(/^[a-f0-9]{64}$/) }).strict(),
|
|
25
|
+
z.object({ operation: z.literal("write"), account: z.string().regex(/^[a-f0-9]{64}$/), value: z.string().max(2 * 1024 * 1024) }).strict()
|
|
26
|
+
]);
|
|
27
|
+
var responseSchema = z.object({ ok: z.literal(true), value: z.string().nullable().optional() }).strict();
|
|
28
|
+
async function createProcessSecretStore(directory, options) {
|
|
29
|
+
const account = createHash("sha256").update(await realpath(directory)).digest("hex");
|
|
30
|
+
const timeoutMs = options.timeoutMs ?? 8000;
|
|
31
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1)
|
|
32
|
+
throw new Error("SETUP_KEYCHAIN_TIMEOUT_INVALID");
|
|
33
|
+
let busy = false, uncertain = false;
|
|
34
|
+
const invoke = async (input) => {
|
|
35
|
+
if (busy)
|
|
36
|
+
throw new Error("SETUP_KEYCHAIN_BUSY");
|
|
37
|
+
if (input.operation === "write" && uncertain)
|
|
38
|
+
throw new Error("SETUP_KEYCHAIN_RECONCILE_REQUIRED");
|
|
39
|
+
busy = true;
|
|
40
|
+
try {
|
|
41
|
+
const response = await new Promise((resolve, reject) => {
|
|
42
|
+
const child = spawn(options.executable, [options.entry, ...options.args ?? []], { stdio: ["pipe", "pipe", "ignore"], env: options.env ?? process.env });
|
|
43
|
+
const output = [];
|
|
44
|
+
let bytes = 0, failed = false;
|
|
45
|
+
const timer = setTimeout(() => {
|
|
46
|
+
failed = true;
|
|
47
|
+
child.kill("SIGKILL");
|
|
48
|
+
}, timeoutMs);
|
|
49
|
+
child.once("error", () => {
|
|
50
|
+
failed = true;
|
|
51
|
+
});
|
|
52
|
+
child.stdin.on("error", () => {
|
|
53
|
+
failed = true;
|
|
54
|
+
});
|
|
55
|
+
child.stdout.on("error", () => {
|
|
56
|
+
failed = true;
|
|
57
|
+
child.kill("SIGKILL");
|
|
58
|
+
});
|
|
59
|
+
child.stdout.on("data", (chunk) => {
|
|
60
|
+
bytes += chunk.length;
|
|
61
|
+
if (bytes > 3 * 1024 * 1024) {
|
|
62
|
+
failed = true;
|
|
63
|
+
child.kill("SIGKILL");
|
|
64
|
+
} else
|
|
65
|
+
output.push(Buffer.from(chunk));
|
|
66
|
+
});
|
|
67
|
+
child.once("close", (code) => {
|
|
68
|
+
clearTimeout(timer);
|
|
69
|
+
if (failed || code !== 0) {
|
|
70
|
+
reject(new Error("SETUP_KEYCHAIN_UNAVAILABLE"));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
resolve(responseSchema.parse(JSON.parse(Buffer.concat(output).toString("utf8"))));
|
|
75
|
+
} catch {
|
|
76
|
+
reject(new Error("SETUP_KEYCHAIN_UNAVAILABLE"));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
child.stdin.end(JSON.stringify(input));
|
|
80
|
+
});
|
|
81
|
+
return response;
|
|
82
|
+
} catch {
|
|
83
|
+
if (input.operation === "write")
|
|
84
|
+
uncertain = true;
|
|
85
|
+
throw new Error(input.operation === "write" ? "SETUP_KEYCHAIN_WRITE_UNCONFIRMED" : "SETUP_KEYCHAIN_UNAVAILABLE");
|
|
86
|
+
} finally {
|
|
87
|
+
busy = false;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
async read() {
|
|
92
|
+
const response = await invoke({ operation: "read", account });
|
|
93
|
+
if (!("value" in response))
|
|
94
|
+
throw new Error("SETUP_KEYCHAIN_UNAVAILABLE");
|
|
95
|
+
uncertain = false;
|
|
96
|
+
return response.value;
|
|
97
|
+
},
|
|
98
|
+
async write(value) {
|
|
99
|
+
await invoke(requestSchema.parse({ operation: "write", account, value }));
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async function runCredentialWorker(createStore) {
|
|
104
|
+
const watchdog = setTimeout(() => process.kill(process.pid, "SIGKILL"), 12000);
|
|
105
|
+
watchdog.unref();
|
|
106
|
+
try {
|
|
107
|
+
const chunks = [];
|
|
108
|
+
let size = 0;
|
|
109
|
+
for await (const chunk of process.stdin) {
|
|
110
|
+
size += chunk.length;
|
|
111
|
+
if (size > 3 * 1024 * 1024)
|
|
112
|
+
throw new Error("LIMIT");
|
|
113
|
+
chunks.push(Buffer.from(chunk));
|
|
114
|
+
}
|
|
115
|
+
const request = requestSchema.parse(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
116
|
+
const entry = await createStore(request.account);
|
|
117
|
+
if (request.operation === "read")
|
|
118
|
+
process.stdout.write(JSON.stringify({ ok: true, value: await entry.read() ?? null }));
|
|
119
|
+
else {
|
|
120
|
+
await entry.write(request.value);
|
|
121
|
+
process.stdout.write('{"ok":true}');
|
|
122
|
+
}
|
|
123
|
+
} catch {
|
|
124
|
+
process.exitCode = 1;
|
|
125
|
+
} finally {
|
|
126
|
+
clearTimeout(watchdog);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// packages/core/src/application/agenda.ts
|
|
131
|
+
import { z as z2 } from "zod";
|
|
132
|
+
var dateSchema = z2.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((value) => Number.isFinite(Date.parse(value + "T00:00:00Z")) && new Date(value + "T00:00:00Z").toISOString().slice(0, 10) === value);
|
|
133
|
+
var timeSchema = z2.object({ date: dateSchema.optional(), dateTime: z2.string().refine((value) => /(?:Z|[+-]\d{2}:\d{2})$/.test(value) && Number.isFinite(Date.parse(value))).optional() }).refine((value) => Boolean(value.date) !== Boolean(value.dateTime));
|
|
134
|
+
var eventSchema = z2.object({ id: z2.string().min(1), summary: z2.string().max(16000), status: z2.string().optional(), busy: z2.boolean().optional(), start: timeSchema, end: timeSchema }).refine((value) => Boolean(value.start.date) === Boolean(value.end.date) && Date.parse(value.end.dateTime ?? value.end.date) > Date.parse(value.start.dateTime ?? value.start.date));
|
|
135
|
+
async function readApplicationAgenda(manager, raw, cancellation) {
|
|
136
|
+
const input = z2.object({ projectId: z2.string().min(1), date: dateSchema, timeZone: z2.string().refine(validZone) }).strict().parse(raw);
|
|
137
|
+
const host = manager.currentHost();
|
|
138
|
+
if (!host)
|
|
139
|
+
throw new Error("ASSISTANT_UNAVAILABLE");
|
|
140
|
+
if ((await connectApplication(host.credentialsPath)).projectId !== input.projectId)
|
|
141
|
+
throw new Error("APPLICATION_SCOPE_CHANGED");
|
|
142
|
+
const base = { date: input.date, timeZone: input.timeZone };
|
|
143
|
+
if (!host.agendaSource)
|
|
144
|
+
return { ...base, connected: false, complete: true, events: [] };
|
|
145
|
+
const window = dayWindow(input.date, input.timeZone);
|
|
146
|
+
if (!window)
|
|
147
|
+
throw new Error("AGENDA_DAY_MISSING");
|
|
148
|
+
const signal = AbortSignal.any([AbortSignal.timeout(20000), ...cancellation ? [cancellation] : []]);
|
|
149
|
+
const events = new Map, seen = new Set;
|
|
150
|
+
let pageToken, complete = false;
|
|
151
|
+
for (let page = 0;page < 10; page++) {
|
|
152
|
+
signal.throwIfAborted();
|
|
153
|
+
let abort;
|
|
154
|
+
const cancelled = new Promise((_, reject) => {
|
|
155
|
+
abort = () => reject(new Error("AGENDA_READ_CANCELLED"));
|
|
156
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
157
|
+
});
|
|
158
|
+
let result;
|
|
159
|
+
try {
|
|
160
|
+
result = await Promise.race([host.agendaSource.list({ timeMin: new Date(window.start).toISOString(), timeMax: new Date(window.end).toISOString(), ...pageToken ? { pageToken } : {} }, signal), cancelled]);
|
|
161
|
+
} finally {
|
|
162
|
+
signal.removeEventListener("abort", abort);
|
|
163
|
+
}
|
|
164
|
+
if (manager.currentHost() !== host)
|
|
165
|
+
throw new Error("APPLICATION_SCOPE_CHANGED");
|
|
166
|
+
if (!Array.isArray(result.events) || result.events.length > 100)
|
|
167
|
+
throw new Error("AGENDA_PAGE_INVALID");
|
|
168
|
+
for (const event of z2.array(eventSchema).parse(result.events))
|
|
169
|
+
events.set(event.id, event);
|
|
170
|
+
if (result.complete && !result.nextPageToken) {
|
|
171
|
+
complete = true;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
if (!result.nextPageToken || seen.has(result.nextPageToken))
|
|
175
|
+
break;
|
|
176
|
+
if (typeof result.nextPageToken !== "string" || result.nextPageToken.length > 2048)
|
|
177
|
+
throw new Error("AGENDA_PAGE_INVALID");
|
|
178
|
+
seen.add(result.nextPageToken);
|
|
179
|
+
pageToken = result.nextPageToken;
|
|
180
|
+
}
|
|
181
|
+
return { ...base, connected: true, ...host.agendaSource.canCreate ? { canCreate: true } : {}, complete, calendarId: host.agendaSource.calendarId, events: [...events.values()].sort((a, b) => Number(Boolean(b.start.date)) - Number(Boolean(a.start.date)) || Date.parse(a.start.dateTime ?? a.start.date) - Date.parse(b.start.dateTime ?? b.start.date) || a.id.localeCompare(b.id)) };
|
|
182
|
+
}
|
|
183
|
+
async function prepareApplicationCalendarCreation(manager, raw) {
|
|
184
|
+
const input = z2.strictObject({ projectId: z2.string().min(1), event: createEventInputSchema }).parse(raw);
|
|
185
|
+
const host = manager.currentHost();
|
|
186
|
+
if (!host)
|
|
187
|
+
throw new Error("ASSISTANT_UNAVAILABLE");
|
|
188
|
+
if ((await connectApplication(host.credentialsPath)).projectId !== input.projectId || manager.currentHost() !== host)
|
|
189
|
+
throw new Error("APPLICATION_SCOPE_CHANGED");
|
|
190
|
+
if (!host.prepareCalendarCreation)
|
|
191
|
+
throw new Error("CALENDAR_CREATION_DISABLED");
|
|
192
|
+
return host.prepareCalendarCreation(input.event);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// packages/core/src/application/automation.ts
|
|
196
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
197
|
+
import { z as z3 } from "zod";
|
|
198
|
+
var stateSchema = z3.object({
|
|
199
|
+
schedule: z3.object({ enabled: z3.number().int().min(0).max(1), revision: z3.number().int(), next_at: z3.number() }).nullable(),
|
|
200
|
+
preferences: z3.array(z3.object({ key: z3.string(), value: z3.string() })),
|
|
201
|
+
occurrences: z3.array(z3.object({ id: z3.string(), day: z3.string(), status: z3.string(), attempts: z3.number().int() }))
|
|
202
|
+
});
|
|
203
|
+
var changeSchema = z3.object({ action: z3.enum(["configure", "pause", "resume", "delete", "forget"]), expectedDigest: z3.string().regex(/^sha256:[a-f0-9]{64}$/), confirmed: z3.literal(true), localTime: z3.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d$/).optional(), timeZone: z3.string().refine(validZone).optional() }).strict();
|
|
204
|
+
async function applicationAutomation(manager, raw) {
|
|
205
|
+
const input = z3.object({ projectId: z3.string().min(1), change: changeSchema.optional() }).strict().parse(raw);
|
|
206
|
+
const host = manager.currentHost();
|
|
207
|
+
if (!host)
|
|
208
|
+
throw new Error("ASSISTANT_UNAVAILABLE");
|
|
209
|
+
if ((await connectApplication(host.credentialsPath)).projectId !== input.projectId)
|
|
210
|
+
throw new Error("APPLICATION_SCOPE_CHANGED");
|
|
211
|
+
const snapshot = () => {
|
|
212
|
+
const state = host.automation ? stateSchema.parse(host.automation.status()) : null;
|
|
213
|
+
const linked = Boolean(host.diagnostics().telegram?.linked);
|
|
214
|
+
const digest = "sha256:" + createHash2("sha256").update(JSON.stringify({ projectId: input.projectId, linked, schedule: state?.schedule, preferences: state?.preferences })).digest("hex");
|
|
215
|
+
return { available: Boolean(state), linked, delivery: "telegram", digest, state };
|
|
216
|
+
};
|
|
217
|
+
const before = snapshot(), change = input.change;
|
|
218
|
+
if (!change)
|
|
219
|
+
return before;
|
|
220
|
+
if (!host.automation)
|
|
221
|
+
throw new Error("AUTOMATION_UNAVAILABLE");
|
|
222
|
+
if (change.expectedDigest !== before.digest)
|
|
223
|
+
throw new Error("AUTOMATION_REVIEW_STALE");
|
|
224
|
+
if (["configure", "resume"].includes(change.action) && !before.linked)
|
|
225
|
+
throw new Error("AUTOMATION_TELEGRAM_REQUIRED");
|
|
226
|
+
if (change.action !== "configure" && (change.localTime || change.timeZone))
|
|
227
|
+
throw new Error("AUTOMATION_ARGUMENTS_INVALID");
|
|
228
|
+
let command;
|
|
229
|
+
if (change.action === "configure") {
|
|
230
|
+
if (!change.localTime || !change.timeZone)
|
|
231
|
+
throw new Error("AUTOMATION_PREFERENCES_REQUIRED");
|
|
232
|
+
command = `/daily ${change.localTime} ${change.timeZone}`;
|
|
233
|
+
} else
|
|
234
|
+
command = change.action === "forget" ? "/memory forget all" : `/daily ${change.action}`;
|
|
235
|
+
host.automation.command(command);
|
|
236
|
+
const after = snapshot();
|
|
237
|
+
if (["configure", "resume"].includes(change.action) && !after.state?.schedule?.enabled)
|
|
238
|
+
throw new Error("AUTOMATION_PREFERENCES_REQUIRED");
|
|
239
|
+
return after;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// packages/core/src/application/notes.ts
|
|
243
|
+
import { z as z4 } from "zod";
|
|
244
|
+
var summary = z4.object({ id: z4.string().uuid(), title: z4.string(), created_at: z4.number() });
|
|
245
|
+
var note = summary.extend({ body: z4.string() });
|
|
246
|
+
async function readNotes(manager, raw) {
|
|
247
|
+
const input = z4.object({ projectId: z4.string().min(1), query: z4.string().trim().max(200).default(""), offset: z4.number().int().min(0).max(1e4).default(0), noteId: z4.string().uuid().optional() }).strict().parse(raw);
|
|
248
|
+
const host = manager.currentHost();
|
|
249
|
+
if (!host)
|
|
250
|
+
throw new Error("ASSISTANT_UNAVAILABLE");
|
|
251
|
+
const client = await connectApplication(host.credentialsPath);
|
|
252
|
+
if (client.projectId !== input.projectId || manager.currentHost() !== host)
|
|
253
|
+
throw new Error("APPLICATION_SCOPE_CHANGED");
|
|
254
|
+
if (!host.daily)
|
|
255
|
+
return { enabled: false, notes: [], total: 0, nextOffset: null };
|
|
256
|
+
const page = input.query ? host.daily.searchNotes({ query: input.query, offset: input.offset, limit: 20 }) : host.daily.listNotes({ offset: input.offset, limit: 20 });
|
|
257
|
+
return { enabled: true, notes: z4.array(summary).parse(page.notes), total: page.total, nextOffset: page.nextOffset, ...input.noteId ? { note: note.parse(host.daily.readNote({ noteId: input.noteId })) } : {} };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// packages/core/src/application/personal-state.ts
|
|
261
|
+
import { z as z5 } from "zod";
|
|
262
|
+
var taskSchema = z5.object({ id: z5.string(), title: z5.string(), due_date: z5.string().nullable(), status: z5.string(), created_at: z5.number() });
|
|
263
|
+
var reminderSchema = z5.object({ id: z5.string(), text: z5.string(), due_at: z5.number(), time_zone: z5.string(), channel: z5.string(), status: z5.string() });
|
|
264
|
+
async function readPersonalState(manager, raw) {
|
|
265
|
+
const input = z5.object({ projectId: z5.string().min(1), offset: z5.number().int().min(0).max(1e4).default(0) }).strict().parse(raw);
|
|
266
|
+
const host = manager.currentHost();
|
|
267
|
+
if (!host)
|
|
268
|
+
throw new Error("ASSISTANT_UNAVAILABLE");
|
|
269
|
+
const client = await connectApplication(host.credentialsPath);
|
|
270
|
+
if (client.projectId !== input.projectId)
|
|
271
|
+
throw new Error("APPLICATION_SCOPE_CHANGED");
|
|
272
|
+
if (!host.daily)
|
|
273
|
+
return { enabled: false, tasks: [], total: 0, nextOffset: null, reminders: [] };
|
|
274
|
+
const page = host.daily.listTasks({ offset: input.offset, limit: 20 });
|
|
275
|
+
const proactive = host.daily.proactive.status();
|
|
276
|
+
return { proactive: {
|
|
277
|
+
enabled: host.binding().tools.includes("daily_write_configure_proactive"),
|
|
278
|
+
policy: proactive.policy,
|
|
279
|
+
sources: proactive.sources,
|
|
280
|
+
health: proactive.health,
|
|
281
|
+
alerts: proactive.alerts.map(({ id, kind, text, status, channel, created_at }) => ({ id, kind, text, status, channel, created_at })),
|
|
282
|
+
watches: proactive.watches.map(({ id, title, status, due_at }) => ({ id, title, status, due_at }))
|
|
283
|
+
}, enabled: true, tasks: z5.array(taskSchema).parse(page.tasks), total: page.total, nextOffset: page.nextOffset, reminders: z5.array(reminderSchema).parse(host.daily.listReminders()) };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// packages/core/src/application/management.ts
|
|
287
|
+
import { z as z6 } from "zod";
|
|
288
|
+
var requestSchema2 = z6.object({ resource: z6.enum(["agents", "connections", "projects"]), action: z6.string(), args: z6.array(z6.string()).max(3), input: z6.unknown().optional(), confirmed: z6.boolean().optional() }).strict();
|
|
289
|
+
async function manageApplication(manager, raw) {
|
|
290
|
+
const { resource, action, args, input, confirmed } = requestSchema2.parse(raw);
|
|
291
|
+
if (resource !== "projects" && manager.state().locked)
|
|
292
|
+
throw new Error("SETUP_KEYCHAIN_UNAVAILABLE");
|
|
293
|
+
const arity = (count) => {
|
|
294
|
+
if (args.length !== count)
|
|
295
|
+
throw new Error("APPLICATION_ARGUMENTS_INVALID");
|
|
296
|
+
};
|
|
297
|
+
if (resource === "agents") {
|
|
298
|
+
switch (action) {
|
|
299
|
+
case "list":
|
|
300
|
+
arity(0);
|
|
301
|
+
break;
|
|
302
|
+
case "create":
|
|
303
|
+
arity(1);
|
|
304
|
+
if (manager.state().editing)
|
|
305
|
+
throw new Error("SETUP_DRAFT_PENDING");
|
|
306
|
+
await manager.action("begin", { name: args[0] });
|
|
307
|
+
break;
|
|
308
|
+
case "tools":
|
|
309
|
+
arity(0);
|
|
310
|
+
await manager.action("tools", input);
|
|
311
|
+
break;
|
|
312
|
+
case "start":
|
|
313
|
+
arity(0);
|
|
314
|
+
await manager.action("start", {});
|
|
315
|
+
break;
|
|
316
|
+
case "select":
|
|
317
|
+
arity(1);
|
|
318
|
+
await manager.action("select", { id: args[0] });
|
|
319
|
+
break;
|
|
320
|
+
case "rename":
|
|
321
|
+
arity(2);
|
|
322
|
+
await manager.action("rename", { id: args[0], name: args[1] });
|
|
323
|
+
break;
|
|
324
|
+
case "model":
|
|
325
|
+
arity(2);
|
|
326
|
+
await manager.action("model", { id: args[0], model: args[1] });
|
|
327
|
+
break;
|
|
328
|
+
case "discard":
|
|
329
|
+
arity(0);
|
|
330
|
+
if (!confirmed)
|
|
331
|
+
throw new Error("APPLICATION_CONFIRMATION_REQUIRED");
|
|
332
|
+
await manager.action("discard", {});
|
|
333
|
+
break;
|
|
334
|
+
case "delete":
|
|
335
|
+
arity(1);
|
|
336
|
+
if (!confirmed)
|
|
337
|
+
throw new Error("APPLICATION_CONFIRMATION_REQUIRED");
|
|
338
|
+
await manager.action("delete-agent", { id: args[0] });
|
|
339
|
+
break;
|
|
340
|
+
default:
|
|
341
|
+
throw new Error("APPLICATION_ACTION_INVALID");
|
|
342
|
+
}
|
|
343
|
+
const state = manager.state();
|
|
344
|
+
return { schemaVersion: 1, kind: "application-agents", agents: state.profiles, draft: state.editing ? { name: state.draftName, tools: state.tools } : null, ready: state.ready };
|
|
345
|
+
}
|
|
346
|
+
if (resource === "connections") {
|
|
347
|
+
switch (action) {
|
|
348
|
+
case "list":
|
|
349
|
+
arity(0);
|
|
350
|
+
break;
|
|
351
|
+
case "configure":
|
|
352
|
+
arity(0);
|
|
353
|
+
await manager.action("provider", input);
|
|
354
|
+
break;
|
|
355
|
+
case "use":
|
|
356
|
+
arity(1);
|
|
357
|
+
await manager.action("reuse-provider", { id: args[0] });
|
|
358
|
+
break;
|
|
359
|
+
default:
|
|
360
|
+
throw new Error("APPLICATION_ACTION_INVALID");
|
|
361
|
+
}
|
|
362
|
+
return { schemaVersion: 1, kind: "application-connections", connections: manager.state().connections };
|
|
363
|
+
}
|
|
364
|
+
switch (action) {
|
|
365
|
+
case "list":
|
|
366
|
+
arity(0);
|
|
367
|
+
break;
|
|
368
|
+
case "open":
|
|
369
|
+
arity(2);
|
|
370
|
+
await manager.codeProjects.open(args[0], args[1]);
|
|
371
|
+
break;
|
|
372
|
+
case "connection":
|
|
373
|
+
arity(2);
|
|
374
|
+
await manager.codeProjects.configure(args[0], args[1]);
|
|
375
|
+
break;
|
|
376
|
+
case "select":
|
|
377
|
+
arity(1);
|
|
378
|
+
await manager.codeProjects.select(args[0]);
|
|
379
|
+
break;
|
|
380
|
+
default:
|
|
381
|
+
throw new Error("APPLICATION_ACTION_INVALID");
|
|
382
|
+
}
|
|
383
|
+
return { schemaVersion: 1, kind: "application-projects", ...manager.codeProjects.state() };
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// packages/core/src/application/coordinator.ts
|
|
387
|
+
import { createServer } from "node:http";
|
|
388
|
+
import { createHash as createHash3, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
389
|
+
import { chmod, lstat, realpath as realpath2, rename, unlink, writeFile } from "node:fs/promises";
|
|
390
|
+
import path from "node:path";
|
|
391
|
+
import { z as z7 } from "zod";
|
|
392
|
+
var requestSchema3 = z7.object({ version: z7.number().int(), method: z7.enum(["reply-watch-proposal", "mail-draft-proposal", "catalog", "calendar-create-proposal", "notes", "agenda", "authorization", "automation", "hello", "personal-state", "management", "state", "shutdown", "shutdown-summary", "action", "code-configure", "code-open", "code-select", "code-retry", "code-tools", "code-delivery"]), input: z7.unknown().optional() }).strict();
|
|
393
|
+
var actionSchema = z7.object({ name: z7.string(), value: z7.unknown().optional() }).strict();
|
|
394
|
+
var toolSchema = z7.object({ action: z7.string(), value: z7.unknown().optional() }).strict();
|
|
395
|
+
async function startApplicationCoordinator(directory, options) {
|
|
396
|
+
const manager = await startManagedAssistant(directory, options);
|
|
397
|
+
let queue = Promise.resolve(), closing = false, closePromise;
|
|
398
|
+
let socketOwned = false, credentialsOwned = false;
|
|
399
|
+
directory = await realpath2(directory);
|
|
400
|
+
const socketPath = path.join(directory, "coordinator.sock"), credentialsPath = path.join(directory, "coordinator.json");
|
|
401
|
+
const token = randomBytes(32).toString("hex"), generation = randomUUID();
|
|
402
|
+
const state = () => ({ state: manager.state(), credentialsPath: manager.currentHost()?.credentialsPath, code: manager.codeProjects.state(), codeCredentialsPath: manager.codeProjects.currentHost()?.credentialsPath });
|
|
403
|
+
const readController = new AbortController;
|
|
404
|
+
const dispatch = async (raw) => {
|
|
405
|
+
const request = requestSchema3.parse(raw);
|
|
406
|
+
if (request.version !== 1)
|
|
407
|
+
throw new Error("COORDINATOR_VERSION_UNSUPPORTED");
|
|
408
|
+
const projects = manager.codeProjects;
|
|
409
|
+
switch (request.method) {
|
|
410
|
+
case "hello": {
|
|
411
|
+
const input = z7.object({ versions: z7.array(z7.number().int()).min(1).max(16) }).strict().parse(request.input ?? { versions: [1] });
|
|
412
|
+
if (!input.versions.includes(1))
|
|
413
|
+
throw new Error("COORDINATOR_VERSION_UNSUPPORTED");
|
|
414
|
+
return { version: 1, projectionVersion: 1, activityVersion: 1, generation, capabilities: ["application.state", "application.setup", "application.code", "application.shutdown-preview", "application.shutdown", "application.management", "application.personal-state", "application.automation", "application.authorization", "application.agenda", "application.notes", "application.calendar-create-proposal", "application.code-context", "application.catalog", "application.mail-draft-proposal", "application.reply-watch-proposal"] };
|
|
415
|
+
}
|
|
416
|
+
case "catalog": {
|
|
417
|
+
const snapshot = manager.state(), code = projects.state();
|
|
418
|
+
const runtimes = [];
|
|
419
|
+
for (const [area, host, id] of [["assistant", manager.currentHost(), snapshot.profiles.find((profile) => profile.active)?.id], ["code", projects.currentHost(), code.active]]) {
|
|
420
|
+
if (host && id)
|
|
421
|
+
runtimes.push({ area, id, projectId: (await connectApplication(host.credentialsPath)).projectId, binding: host.binding() });
|
|
422
|
+
}
|
|
423
|
+
const body = { locked: snapshot.locked, agents: snapshot.profiles, connections: snapshot.connections, projects: code, runtimes };
|
|
424
|
+
return { schemaVersion: 1, generation, revision: createHash3("sha256").update(JSON.stringify(body)).digest("hex"), ...body };
|
|
425
|
+
}
|
|
426
|
+
case "state":
|
|
427
|
+
return state();
|
|
428
|
+
case "reply-watch-proposal": {
|
|
429
|
+
const input = z7.object({ projectId: z7.string(), watch: z7.unknown() }).strict().parse(request.input);
|
|
430
|
+
const host = manager.currentHost();
|
|
431
|
+
if (!host)
|
|
432
|
+
throw new Error("ASSISTANT_UNAVAILABLE");
|
|
433
|
+
if ((await connectApplication(host.credentialsPath)).projectId !== input.projectId)
|
|
434
|
+
throw new Error("APPLICATION_SCOPE_CHANGED");
|
|
435
|
+
if (!host.daily || !host.binding().tools.includes("daily_write_apply_reply_watch"))
|
|
436
|
+
throw new Error("PROACTIVE_UNAVAILABLE");
|
|
437
|
+
return host.daily.proactive.proposeWatch(input.watch);
|
|
438
|
+
}
|
|
439
|
+
case "mail-draft-proposal": {
|
|
440
|
+
const input = z7.object({ projectId: z7.string(), provider: z7.enum(["google", "microsoft"]), draft: z7.unknown() }).strict().parse(request.input);
|
|
441
|
+
const host = manager.currentHost();
|
|
442
|
+
if (!host)
|
|
443
|
+
throw new Error("ASSISTANT_UNAVAILABLE");
|
|
444
|
+
if ((await connectApplication(host.credentialsPath)).projectId !== input.projectId)
|
|
445
|
+
throw new Error("APPLICATION_SCOPE_CHANGED");
|
|
446
|
+
const prepare = host.mailDrafts?.[input.provider];
|
|
447
|
+
if (!prepare)
|
|
448
|
+
throw new Error("MAIL_DRAFT_UNAVAILABLE");
|
|
449
|
+
return prepare(input.draft);
|
|
450
|
+
}
|
|
451
|
+
case "calendar-create-proposal":
|
|
452
|
+
return prepareApplicationCalendarCreation(manager, request.input);
|
|
453
|
+
case "agenda":
|
|
454
|
+
return readApplicationAgenda(manager, request.input, readController.signal);
|
|
455
|
+
case "authorization":
|
|
456
|
+
return { url: manager.authorizationUrl() ?? null };
|
|
457
|
+
case "automation":
|
|
458
|
+
return applicationAutomation(manager, request.input);
|
|
459
|
+
case "notes":
|
|
460
|
+
return readNotes(manager, request.input);
|
|
461
|
+
case "personal-state":
|
|
462
|
+
return readPersonalState(manager, request.input);
|
|
463
|
+
case "management":
|
|
464
|
+
return manageApplication(manager, request.input);
|
|
465
|
+
case "shutdown":
|
|
466
|
+
z7.object({ confirmed: z7.literal(true) }).strict().parse(request.input);
|
|
467
|
+
return { status: "stop-requested" };
|
|
468
|
+
case "shutdown-summary":
|
|
469
|
+
return manager.shutdownSummary();
|
|
470
|
+
case "action": {
|
|
471
|
+
const input = actionSchema.parse(request.input);
|
|
472
|
+
await manager.action(input.name, input.value);
|
|
473
|
+
return state();
|
|
474
|
+
}
|
|
475
|
+
case "code-configure": {
|
|
476
|
+
const input = z7.object({ id: z7.string(), connectionId: z7.string() }).strict().parse(request.input);
|
|
477
|
+
await projects.configure(input.id, input.connectionId);
|
|
478
|
+
return state();
|
|
479
|
+
}
|
|
480
|
+
case "code-open": {
|
|
481
|
+
const input = z7.object({ workspace: z7.string(), connectionId: z7.string() }).strict().parse(request.input);
|
|
482
|
+
await projects.open(input.workspace, input.connectionId);
|
|
483
|
+
return state();
|
|
484
|
+
}
|
|
485
|
+
case "code-select": {
|
|
486
|
+
const input = z7.object({ id: z7.string() }).strict().parse(request.input);
|
|
487
|
+
await projects.select(input.id);
|
|
488
|
+
return state();
|
|
489
|
+
}
|
|
490
|
+
case "code-retry":
|
|
491
|
+
await projects.restore();
|
|
492
|
+
return state();
|
|
493
|
+
case "code-delivery": {
|
|
494
|
+
const input = toolSchema.parse(request.input), host = projects.currentHost();
|
|
495
|
+
if (!host)
|
|
496
|
+
throw new Error("CODE_UNAVAILABLE");
|
|
497
|
+
return host.delivery(input.action, input.value);
|
|
498
|
+
}
|
|
499
|
+
case "code-tools": {
|
|
500
|
+
const input = toolSchema.parse(request.input);
|
|
501
|
+
switch (input.action) {
|
|
502
|
+
case "list":
|
|
503
|
+
return projects.worktrees();
|
|
504
|
+
case "create":
|
|
505
|
+
return projects.createWorktree(input.value);
|
|
506
|
+
case "open":
|
|
507
|
+
await projects.openWorktree(z7.string().uuid().parse(input.value));
|
|
508
|
+
return state();
|
|
509
|
+
case "review-removal":
|
|
510
|
+
return projects.reviewWorktreeRemoval(z7.string().uuid().parse(input.value));
|
|
511
|
+
case "remove":
|
|
512
|
+
return projects.removeWorktree(z7.string().uuid().parse(input.value));
|
|
513
|
+
case "context": {
|
|
514
|
+
const inputScope = z7.object({ projectId: z7.string().min(1) }).strict().parse(input.value);
|
|
515
|
+
const host = projects.currentHost();
|
|
516
|
+
if (!host)
|
|
517
|
+
throw new Error("CODE_UNAVAILABLE");
|
|
518
|
+
if ((await connectApplication(host.credentialsPath)).projectId !== inputScope.projectId || projects.currentHost() !== host)
|
|
519
|
+
throw new Error("APPLICATION_SCOPE_CHANGED");
|
|
520
|
+
return host.context();
|
|
521
|
+
}
|
|
522
|
+
case "checks": {
|
|
523
|
+
const host = projects.currentHost();
|
|
524
|
+
if (!host)
|
|
525
|
+
throw new Error("CODE_UNAVAILABLE");
|
|
526
|
+
return host.checks();
|
|
527
|
+
}
|
|
528
|
+
default:
|
|
529
|
+
throw new Error("CODE_ACTION_INVALID");
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
let close;
|
|
535
|
+
const server = createServer(async (request, response) => {
|
|
536
|
+
const send = (status, value) => {
|
|
537
|
+
response.writeHead(status, { "content-type": "application/json", "cache-control": "no-store" });
|
|
538
|
+
response.end(JSON.stringify(value));
|
|
539
|
+
};
|
|
540
|
+
const authorization = Buffer.from(request.headers.authorization ?? "");
|
|
541
|
+
const expected = Buffer.from(`Bearer ${token}`);
|
|
542
|
+
if (request.method !== "POST" || request.url !== "/application" || request.headers.origin || authorization.length !== expected.length || !timingSafeEqual(authorization, expected)) {
|
|
543
|
+
send(403, { ok: false, error: "COORDINATOR_UNAUTHORIZED" });
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
try {
|
|
547
|
+
if (closing)
|
|
548
|
+
throw new Error("COORDINATOR_CLOSING");
|
|
549
|
+
const chunks = [];
|
|
550
|
+
let size = 0;
|
|
551
|
+
for await (const chunk of request) {
|
|
552
|
+
size += chunk.length;
|
|
553
|
+
if (size > 128 * 1024)
|
|
554
|
+
throw new Error("COORDINATOR_REQUEST_TOO_LARGE");
|
|
555
|
+
chunks.push(chunk);
|
|
556
|
+
}
|
|
557
|
+
const input = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
558
|
+
const readOnly = input?.method === "agenda";
|
|
559
|
+
const operation = readOnly ? dispatch(input) : queue.then(() => {
|
|
560
|
+
if (closing)
|
|
561
|
+
throw new Error("COORDINATOR_CLOSING");
|
|
562
|
+
return dispatch(input);
|
|
563
|
+
});
|
|
564
|
+
if (!readOnly)
|
|
565
|
+
queue = operation.then(() => {}, () => {});
|
|
566
|
+
send(200, { ok: true, result: await operation });
|
|
567
|
+
if (input.method === "shutdown")
|
|
568
|
+
close().catch(() => {});
|
|
569
|
+
} catch (error) {
|
|
570
|
+
const code = error instanceof Error && /^[A-Z][A-Z0-9_]{1,90}$/.test(error.message) ? error.message : "COORDINATOR_REQUEST_FAILED";
|
|
571
|
+
const detail = { schemaVersion: 1, code, recovery: code === "COORDINATOR_VERSION_UNSUPPORTED" ? "upgrade" : code === "APPLICATION_SCOPE_CHANGED" ? "refresh" : /BUSY|UNCONFIRMED|UNAVAILABLE|CLOSING/.test(code) ? "reconcile" : "review-request" };
|
|
572
|
+
send(200, { ok: false, error: code, detail });
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
server.requestTimeout = 15000;
|
|
576
|
+
const removeOwned = async () => {
|
|
577
|
+
if (credentialsOwned)
|
|
578
|
+
await unlink(credentialsPath);
|
|
579
|
+
if (socketOwned)
|
|
580
|
+
await unlink(socketPath).catch((error) => {
|
|
581
|
+
if (error.code !== "ENOENT")
|
|
582
|
+
throw error;
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
try {
|
|
586
|
+
if (Buffer.byteLength(socketPath) > 100)
|
|
587
|
+
throw new Error("LOCAL_SERVICE_SOCKET_PATH_TOO_LONG");
|
|
588
|
+
try {
|
|
589
|
+
const info = await lstat(socketPath);
|
|
590
|
+
if (!info.isSocket() || info.uid !== process.getuid?.())
|
|
591
|
+
throw new Error("COORDINATOR_SOCKET_UNSAFE");
|
|
592
|
+
await unlink(socketPath);
|
|
593
|
+
} catch (error) {
|
|
594
|
+
if (error.code !== "ENOENT")
|
|
595
|
+
throw error;
|
|
596
|
+
}
|
|
597
|
+
await new Promise((resolve, reject) => {
|
|
598
|
+
server.once("error", reject);
|
|
599
|
+
server.listen(socketPath, () => {
|
|
600
|
+
server.off("error", reject);
|
|
601
|
+
resolve();
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
socketOwned = true;
|
|
605
|
+
await chmod(socketPath, 384);
|
|
606
|
+
const temporary = credentialsPath + "." + randomBytes(8).toString("hex");
|
|
607
|
+
try {
|
|
608
|
+
await writeFile(temporary, JSON.stringify({ schemaVersion: 1, socketPath, token }), { mode: 384, flag: "wx" });
|
|
609
|
+
await rename(temporary, credentialsPath);
|
|
610
|
+
credentialsOwned = true;
|
|
611
|
+
} finally {
|
|
612
|
+
await unlink(temporary).catch(() => {});
|
|
613
|
+
}
|
|
614
|
+
} catch (error) {
|
|
615
|
+
if (server.listening)
|
|
616
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
617
|
+
await removeOwned();
|
|
618
|
+
await manager.close();
|
|
619
|
+
throw error;
|
|
620
|
+
}
|
|
621
|
+
close = () => closePromise ??= (async () => {
|
|
622
|
+
closing = true;
|
|
623
|
+
readController.abort();
|
|
624
|
+
await queue;
|
|
625
|
+
await new Promise((resolve, reject) => server.close((error) => error ? reject(error) : resolve()));
|
|
626
|
+
try {
|
|
627
|
+
await manager.close();
|
|
628
|
+
} finally {
|
|
629
|
+
await removeOwned();
|
|
630
|
+
}
|
|
631
|
+
})();
|
|
632
|
+
return { credentialsPath, state, close };
|
|
633
|
+
}
|
|
634
|
+
async function acquireApplicationCoordinator(directory, options) {
|
|
635
|
+
const { connectCoordinator } = await import("./coordinator-client-nzysqxf0.js");
|
|
636
|
+
let owner;
|
|
637
|
+
let client;
|
|
638
|
+
try {
|
|
639
|
+
client = await connectCoordinator(directory);
|
|
640
|
+
} catch (error) {
|
|
641
|
+
if (error.code !== "ENOENT" && (!(error instanceof Error) || error.message !== "LOCAL_SERVICE_UNAVAILABLE"))
|
|
642
|
+
throw error;
|
|
643
|
+
try {
|
|
644
|
+
owner = await startApplicationCoordinator(directory, options);
|
|
645
|
+
} catch (failure) {
|
|
646
|
+
if (!(failure instanceof Error) || failure.message !== "SETUP_ALREADY_RUNNING")
|
|
647
|
+
throw failure;
|
|
648
|
+
const deadline = Date.now() + 30000;
|
|
649
|
+
while (Date.now() < deadline) {
|
|
650
|
+
try {
|
|
651
|
+
client = await connectCoordinator(directory);
|
|
652
|
+
break;
|
|
653
|
+
} catch (error2) {
|
|
654
|
+
if (error2.code !== "ENOENT" && (!(error2 instanceof Error) || error2.message !== "LOCAL_SERVICE_UNAVAILABLE"))
|
|
655
|
+
throw error2;
|
|
656
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if (!client)
|
|
660
|
+
throw failure;
|
|
661
|
+
}
|
|
662
|
+
try {
|
|
663
|
+
client ??= await connectCoordinator(directory);
|
|
664
|
+
} catch (failure) {
|
|
665
|
+
await owner?.close();
|
|
666
|
+
throw failure;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
return { client, ownsService: Boolean(owner), close: async () => {
|
|
670
|
+
await owner?.close();
|
|
671
|
+
} };
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
export { createProcessSecretStore, runCredentialWorker, startApplicationCoordinator, acquireApplicationCoordinator };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
classifyProviderFailure,
|
|
3
3
|
providerDiagnostic
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-px1tnqgt.js";
|
|
5
5
|
|
|
6
|
-
// src/runtime/errors.ts
|
|
6
|
+
// packages/core/src/runtime/errors.ts
|
|
7
7
|
var HARNESS_ERROR_CODES = [
|
|
8
8
|
"CONFIG_INVALID",
|
|
9
9
|
"CLI_USAGE_INVALID",
|