@zhivex-ai/harness 1.6.3 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -3
- package/README.md +17 -5
- package/SECURITY.md +1 -1
- package/SUPPORT.md +2 -2
- package/benchmarks/README.md +98 -0
- package/contracts/engine-api.json +1587 -0
- package/contracts/public-api.json +114 -0
- package/contracts/stable-api-signatures.json +17 -17
- package/dist/acp-cli.js +37 -1090
- package/dist/application/agenda.d.ts +10 -0
- package/dist/application/approval-review.d.ts +61 -0
- package/dist/application/assistant/automation/scheduler.d.ts +21 -0
- package/dist/application/assistant/automation/summary.d.ts +29 -0
- package/dist/application/assistant/automation/time.d.ts +10 -0
- package/dist/application/assistant/calendar/calendar.d.ts +238 -0
- package/dist/application/assistant/calendar/connection.d.ts +50 -0
- package/dist/application/assistant/calendar/create-event.d.ts +75 -0
- package/dist/application/assistant/calendar/environment.d.ts +2 -0
- package/dist/application/assistant/calendar/http.d.ts +6 -0
- package/dist/application/assistant/calendar/oauth.d.ts +68 -0
- package/dist/application/assistant/calendar/store.d.ts +11 -0
- package/dist/application/assistant/calendar/tools.d.ts +78 -0
- package/dist/application/assistant/client.d.ts +10 -0
- package/dist/application/assistant/config.d.ts +9 -0
- package/dist/application/assistant/contracts.d.ts +77 -0
- package/dist/application/assistant/daily/service.d.ts +181 -0
- package/dist/application/assistant/doctor.d.ts +22 -0
- package/dist/application/assistant/evaluation.d.ts +81 -0
- package/dist/application/assistant/host.d.ts +399 -0
- package/dist/application/assistant/integrations/google.d.ts +117 -0
- package/dist/application/assistant/integrations/public-web.d.ts +16 -0
- package/dist/application/assistant/managed/secrets.d.ts +10 -0
- package/dist/application/assistant/managed/setup-state.d.ts +346 -0
- package/dist/application/assistant/managed/setup.d.ts +492 -0
- package/dist/application/assistant/microsoft/connection.d.ts +73 -0
- package/dist/application/assistant/microsoft/tools.d.ts +78 -0
- package/dist/application/assistant/modules/calendar.d.ts +3 -0
- package/dist/application/assistant/modules/catalog.d.ts +38 -0
- package/dist/application/assistant/modules/daily.d.ts +5 -0
- package/dist/application/assistant/modules/github.d.ts +5 -0
- package/dist/application/assistant/modules/google.d.ts +3 -0
- package/dist/application/assistant/modules/mcp.d.ts +11 -0
- package/dist/application/assistant/modules/microsoft.d.ts +3 -0
- package/dist/application/assistant/modules/module.d.ts +224 -0
- package/dist/application/assistant/modules/tools.d.ts +11 -0
- package/dist/application/assistant/modules/web.d.ts +7 -0
- package/dist/application/assistant/private-directory.d.ts +3 -0
- package/dist/application/assistant/proactive/service.d.ts +142 -0
- package/dist/application/assistant/providers/openai-compatible.d.ts +66 -0
- package/dist/application/assistant/providers/provider.d.ts +141 -0
- package/dist/application/assistant/providers/web-citations.d.ts +2 -0
- package/dist/application/assistant/runtime.d.ts +16 -0
- package/dist/application/assistant/task-metrics.d.ts +304 -0
- package/dist/application/assistant/telegram/api.d.ts +47 -0
- package/dist/application/assistant/telegram/bridge.d.ts +69 -0
- package/dist/application/assistant/telegram/store.d.ts +10 -0
- package/dist/application/automation.d.ts +5 -0
- package/dist/application/calendar-review.d.ts +5 -0
- package/dist/application/checkpoint-review.d.ts +30 -0
- package/dist/application/client.d.ts +18 -0
- package/dist/application/code/context.d.ts +5 -0
- package/dist/application/code/delivery.d.ts +6 -0
- package/dist/application/code/git-delivery.d.ts +54 -0
- package/dist/application/code/github-git-transport.d.ts +15 -0
- package/dist/application/code/github-pr-transport.d.ts +6 -0
- package/dist/application/code/host.d.ts +25 -0
- package/dist/application/code/pr-delivery.d.ts +79 -0
- package/dist/application/code/projects.d.ts +90 -0
- package/dist/application/code/remote-delivery.d.ts +80 -0
- package/dist/application/code/repository.d.ts +9 -0
- package/dist/application/code/worktrees.d.ts +123 -0
- package/dist/application/contracts.d.ts +288 -0
- package/dist/application/coordinator-client.d.ts +33 -0
- package/dist/application/coordinator-discovery.d.ts +17 -0
- package/dist/application/coordinator-launcher.d.ts +2 -0
- package/dist/application/coordinator.d.ts +27 -0
- package/dist/application/credential-process.d.ts +13 -0
- package/dist/application/host.d.ts +7 -0
- package/dist/application/management.d.ts +68 -0
- package/dist/application/notes.d.ts +5 -0
- package/dist/application/offline-migration.d.ts +16 -0
- package/dist/application/personal-state.d.ts +5 -0
- package/dist/application/review-channel.d.ts +23 -0
- package/dist/application/review-tickets.d.ts +29 -0
- package/dist/application/runtime-binding.d.ts +4 -0
- package/dist/application-cli-wfh08g41.js +184 -0
- package/dist/application-cli-z3f9pvcf.js +209 -0
- package/dist/arguments-75r85mvc.js +27 -0
- package/dist/arguments-x24bbqvd.js +22 -0
- package/dist/audit/index.js +16 -472
- package/dist/audit-pack-1gnych0m.js +93 -0
- package/dist/{audit-pack-s9n693by.js → audit-pack-h44kjkbj.js} +17 -11
- package/dist/calendar-2xw0rr7b.js +49 -0
- package/dist/cli/application-cli.d.ts +2 -0
- package/dist/cli/arguments.d.ts +14 -1
- package/dist/cli/auto-approve-setup.d.ts +13 -0
- package/dist/cli/configured-harness.d.ts +1 -2
- package/dist/cli/console/console-budget.d.ts +16 -2
- package/dist/cli/console/console-checkpoints.d.ts +12 -0
- package/dist/cli/console/console-commands.d.ts +3 -3
- package/dist/cli/console/console-compaction.d.ts +1 -1
- package/dist/cli/console/console-diff.d.ts +2 -0
- package/dist/cli/console/console-input.d.ts +29 -1
- package/dist/cli/console/console-navigation.d.ts +2 -2
- package/dist/cli/console/console-outcome.d.ts +10 -0
- package/dist/cli/console/console-presentation.d.ts +17 -2
- package/dist/cli/console/console-pricing.d.ts +14 -0
- package/dist/cli/console/console-reasoning.d.ts +1 -1
- package/dist/cli/console/console-recovery.d.ts +2 -0
- package/dist/cli/console/console-review.d.ts +34 -0
- package/dist/cli/console/console-run-policy.d.ts +5 -0
- package/dist/cli/console/console-run-view.d.ts +28 -0
- package/dist/cli/console/console-task.d.ts +30 -0
- package/dist/cli/console/console-welcome.d.ts +13 -3
- package/dist/cli/console/review-diff.d.ts +20 -0
- package/dist/cli/presentation.d.ts +8 -6
- package/dist/cli/service-checkpoints.d.ts +234 -0
- package/dist/cli/terminal/activity-history.d.ts +4 -2
- package/dist/cli/terminal/activity-stream.d.ts +33 -0
- package/dist/cli/terminal/file-diff.d.ts +11 -0
- package/dist/cli/terminal/terminal-theme.d.ts +9 -0
- package/dist/cli/terminal/terminal-ui.d.ts +44 -2
- package/dist/cli/terminal/tool-activity.d.ts +6 -2
- package/dist/{cli-entry-hdtfef27.js → cli-entry-68kqraj7.js} +95 -43
- package/dist/{cli-entry-1epvek01.js → cli-entry-86rcbmwh.js} +294 -14
- package/dist/cli-entry-btkpb4h1.js +3627 -0
- package/dist/cli-entry-bxjbs6qq.js +200 -0
- package/dist/cli-entry-cpm89r9q.js +624 -0
- package/dist/{cli-entry-mbcq96nx.js → cli-entry-dksm56sj.js} +39 -293
- package/dist/{cli-entry-rsx0wpvs.js → cli-entry-eka68ttb.js} +4087 -4625
- package/dist/cli-entry-h7dcah4p.js +137 -0
- package/dist/cli-entry-kwk23ktq.js +33 -0
- package/dist/{cli-entry-nyzyvf24.js → cli-entry-vmce694z.js} +1286 -3142
- package/dist/cli-entry-wanv05db.js +1113 -0
- package/dist/{cli-yxvq8qf1.js → cli-z7vhm1rk.js} +1767 -380
- package/dist/cli.js +8 -6
- package/dist/client/json-contracts.d.ts +153 -0
- package/dist/client/local-service.d.ts +7 -12
- package/dist/client/local-transport.d.ts +14 -0
- package/dist/client/protocol.d.ts +43 -1
- package/dist/compat/cli-options.d.ts +7 -1
- package/dist/compat/cli.d.ts +2 -0
- package/dist/compat/cli.js +4043 -0
- package/dist/compat/code-support.d.ts +4 -0
- package/dist/compat/code-support.js +50 -28
- package/dist/{config-r9fdhce6.js → config-hw78440t.js} +5 -5
- package/dist/{config-vyajmksy.js → config-v7s8hp37.js} +1 -1
- package/dist/context/adaptive-compaction.d.ts +1 -0
- package/dist/context/lossless-lines.d.ts +13 -0
- package/dist/context/numbered-read-lines.d.ts +15 -0
- package/dist/context/read-attempts.d.ts +21 -0
- package/dist/context/request-projection.d.ts +32 -4
- package/dist/context/scoped-context.d.ts +31 -5
- package/dist/context/working-read-replay.d.ts +12 -0
- package/dist/coordinator-client-nzysqxf0.js +10 -0
- package/dist/engine/acp.js +27 -21
- package/dist/engine/application-client.d.ts +11 -0
- package/dist/engine/application-client.js +18 -0
- package/dist/engine/application-protocol.d.ts +5 -0
- package/dist/engine/application-protocol.js +7 -0
- package/dist/engine/application.d.ts +43 -0
- package/dist/engine/application.js +206 -0
- package/dist/engine/assistant/automation/scheduler.d.ts +2 -0
- package/dist/engine/assistant/automation/scheduler.js +11 -0
- package/dist/engine/assistant/automation/summary.d.ts +3 -0
- package/dist/engine/assistant/automation/summary.js +8 -0
- package/dist/engine/assistant/automation/time.d.ts +5 -0
- package/dist/engine/assistant/automation/time.js +15 -0
- package/dist/engine/assistant/calendar/calendar.d.ts +5 -0
- package/dist/engine/assistant/calendar/calendar.js +12 -0
- package/dist/engine/assistant/calendar/connection.d.ts +2 -0
- package/dist/engine/assistant/calendar/connection.js +11 -0
- package/dist/engine/assistant/calendar/environment.d.ts +1 -0
- package/dist/engine/assistant/calendar/environment.js +7 -0
- package/dist/engine/assistant/calendar/http.d.ts +3 -0
- package/dist/engine/assistant/calendar/http.js +9 -0
- package/dist/engine/assistant/calendar/oauth.d.ts +5 -0
- package/dist/engine/assistant/calendar/oauth.js +12 -0
- package/dist/engine/assistant/calendar/store.d.ts +2 -0
- package/dist/engine/assistant/calendar/store.js +8 -0
- package/dist/engine/assistant/calendar/tools.d.ts +2 -0
- package/dist/engine/assistant/calendar/tools.js +46 -0
- package/dist/engine/assistant/client.d.ts +2 -0
- package/dist/engine/assistant/client.js +33 -0
- package/dist/engine/assistant/config.d.ts +1 -0
- package/dist/engine/assistant/config.js +102 -0
- package/dist/engine/assistant/contracts.d.ts +10 -0
- package/dist/engine/assistant/contracts.js +78 -0
- package/dist/engine/assistant/daily/service.d.ts +12 -0
- package/dist/engine/assistant/daily/service.js +27 -0
- package/dist/engine/assistant/doctor.d.ts +1 -0
- package/dist/engine/assistant/doctor.js +116 -0
- package/dist/engine/assistant/evaluation.d.ts +2 -0
- package/dist/engine/assistant/evaluation.js +76 -0
- package/dist/engine/assistant/host.d.ts +2 -0
- package/dist/engine/assistant/host.js +63 -0
- package/dist/engine/assistant/integrations/google.d.ts +9 -0
- package/dist/engine/assistant/integrations/google.js +30 -0
- package/dist/engine/assistant/integrations/public-web.d.ts +3 -0
- package/dist/engine/assistant/integrations/public-web.js +11 -0
- package/dist/engine/assistant/managed/secrets.d.ts +1 -0
- package/dist/engine/assistant/managed/secrets.js +0 -0
- package/dist/engine/assistant/managed/setup-state.d.ts +11 -0
- package/dist/engine/assistant/managed/setup-state.js +84 -0
- package/dist/engine/assistant/managed/setup.d.ts +3 -0
- package/dist/engine/assistant/managed/setup.js +85 -0
- package/dist/engine/assistant/microsoft/connection.d.ts +7 -0
- package/dist/engine/assistant/microsoft/connection.js +21 -0
- package/dist/engine/assistant/microsoft/tools.d.ts +8 -0
- package/dist/engine/assistant/microsoft/tools.js +30 -0
- package/dist/engine/assistant/modules/calendar.d.ts +1 -0
- package/dist/engine/assistant/modules/calendar.js +49 -0
- package/dist/engine/assistant/modules/catalog.d.ts +3 -0
- package/dist/engine/assistant/modules/catalog.js +67 -0
- package/dist/engine/assistant/modules/daily.d.ts +1 -0
- package/dist/engine/assistant/modules/daily.js +48 -0
- package/dist/engine/assistant/modules/github.d.ts +1 -0
- package/dist/engine/assistant/modules/github.js +43 -0
- package/dist/engine/assistant/modules/google.d.ts +1 -0
- package/dist/engine/assistant/modules/google.js +53 -0
- package/dist/engine/assistant/modules/mcp.d.ts +1 -0
- package/dist/engine/assistant/modules/mcp.js +42 -0
- package/dist/engine/assistant/modules/microsoft.d.ts +1 -0
- package/dist/engine/assistant/modules/microsoft.js +53 -0
- package/dist/engine/assistant/modules/module.d.ts +5 -0
- package/dist/engine/assistant/modules/module.js +42 -0
- package/dist/engine/assistant/modules/tools.d.ts +2 -0
- package/dist/engine/assistant/modules/tools.js +42 -0
- package/dist/engine/assistant/modules/web.d.ts +1 -0
- package/dist/engine/assistant/modules/web.js +45 -0
- package/dist/engine/assistant/private-directory.d.ts +1 -0
- package/dist/engine/assistant/private-directory.js +7 -0
- package/dist/engine/assistant/proactive/service.d.ts +6 -0
- package/dist/engine/assistant/proactive/service.js +16 -0
- package/dist/engine/assistant/providers/openai-compatible.d.ts +4 -0
- package/dist/engine/assistant/providers/openai-compatible.js +12 -0
- package/dist/engine/assistant/providers/provider.d.ts +7 -0
- package/dist/engine/assistant/providers/provider.js +54 -0
- package/dist/engine/assistant/providers/web-citations.d.ts +1 -0
- package/dist/engine/assistant/providers/web-citations.js +7 -0
- package/dist/engine/assistant/runtime.d.ts +2 -0
- package/dist/engine/assistant/runtime.js +73 -0
- package/dist/engine/assistant/task-metrics.d.ts +8 -0
- package/dist/engine/assistant/task-metrics.js +17 -0
- package/dist/engine/assistant/telegram/api.d.ts +5 -0
- package/dist/engine/assistant/telegram/api.js +11 -0
- package/dist/engine/assistant/telegram/bridge.d.ts +2 -0
- package/dist/engine/assistant/telegram/bridge.js +40 -0
- package/dist/engine/assistant/telegram/store.d.ts +2 -0
- package/dist/engine/assistant/telegram/store.js +8 -0
- package/dist/engine/client.js +26 -18
- package/dist/engine/desktop-providers-v1.js +4 -4
- package/dist/engine/desktop-state-v1.js +16 -13
- package/dist/engine/index.d.ts +4 -0
- package/dist/engine/index.js +117 -159
- package/dist/engine/mcp-stdio-v1.js +13 -12
- package/dist/engine/models.js +65 -23
- package/dist/engine/protocol.js +10 -6
- package/dist/engine/service.js +32 -21
- package/dist/hostile-repository-demo.js +2329 -1096
- package/dist/index-09rsdr2d.js +1744 -0
- package/dist/index-0csc5sc7.js +139 -0
- package/dist/{index-4mn6m3bq.js → index-0dkty795.js} +8 -6
- package/dist/index-0kkgqvg7.js +0 -0
- package/dist/index-0mzz9axm.js +58 -0
- package/dist/index-1e69ar8r.js +38 -0
- package/dist/index-1z0xhkh9.js +18 -0
- package/dist/index-2cef1k92.js +356 -0
- package/dist/{index-rgqzdgv6.js → index-2j0v1xwr.js} +17 -13
- package/dist/index-2jw9jd7h.js +116 -0
- package/dist/index-2n9qx4km.js +0 -0
- package/dist/index-3rvk23e8.js +877 -0
- package/dist/index-3wa4j0yk.js +71 -0
- package/dist/index-41q1k17x.js +210 -0
- package/dist/index-4vz4bqqw.js +33 -0
- package/dist/index-5jxm2wy5.js +123 -0
- package/dist/index-5rk6ss42.js +216 -0
- package/dist/index-5v1skxf7.js +1852 -0
- package/dist/{index-fqqz1yt8.js → index-6ehtssyz.js} +369 -335
- package/dist/index-76kpdbpw.js +80 -0
- package/dist/{index-5nmm0642.js → index-7nbmhmw5.js} +10 -10
- package/dist/index-8mx0yrkz.js +31 -0
- package/dist/index-8tjev5ds.js +11 -0
- package/dist/index-91n5wr6s.js +163 -0
- package/dist/index-91trs3ew.js +151 -0
- package/dist/index-9y8p5vy5.js +222 -0
- package/dist/index-abxahprd.js +55 -0
- package/dist/index-aptyr511.js +84 -0
- package/dist/{index-8sm2a1wa.js → index-ay26xfxt.js} +28 -20
- package/dist/index-b4yed1s3.js +657 -0
- package/dist/index-bb7phvtg.js +23 -0
- package/dist/index-bk5tn9b8.js +236 -0
- package/dist/index-bw34861c.js +292 -0
- package/dist/index-c6fnjhgv.js +55 -0
- package/dist/{index-qfsrrnz6.js → index-cjevq9s8.js} +2 -2
- package/dist/{index-c39197wq.js → index-ctcwrkrc.js} +4 -4
- package/dist/{index-yx52bt4a.js → index-cztmcesv.js} +2 -2
- package/dist/index-dpbmxnrf.js +564 -0
- package/dist/index-ekxdcy36.js +134 -0
- package/dist/index-f8zpcsx3.js +289 -0
- package/dist/{index-6dxrbnxm.js → index-f970qtb4.js} +7 -143
- package/dist/index-fatcn6fp.js +2791 -0
- package/dist/index-fbzykqxy.js +105 -0
- package/dist/{index-1265j7t2.js → index-fwf274vc.js} +24 -14
- package/dist/index-fy4w0a7v.js +0 -0
- package/dist/index-gvva3e5x.js +76 -0
- package/dist/index-h7dcah4p.js +137 -0
- package/dist/index-hm9r120s.js +42 -0
- package/dist/index-j3d2tw97.js +328 -0
- package/dist/index-jfqj20x8.js +41 -0
- package/dist/{index-hhrnrqfc.js → index-k529a278.js} +6 -6
- package/dist/{index-bt2p8x7r.js → index-kbrf5bx7.js} +110 -106
- package/dist/index-kwk23ktq.js +33 -0
- package/dist/index-kz857p1j.js +557 -0
- package/dist/{index-j466sekf.js → index-mkt5yrax.js} +31 -105
- package/dist/{index-nxmk6re7.js → index-ndgnvjez.js} +18 -18
- package/dist/index-nemn4epv.js +43 -0
- package/dist/index-nkwy5bjr.js +1225 -0
- package/dist/index-nvvzr4ny.js +136 -0
- package/dist/index-pkspzsfs.js +78 -0
- package/dist/{index-fm84men1.js → index-px1tnqgt.js} +2 -2
- package/dist/index-q7qdw883.js +79 -0
- package/dist/{index-mzydbzp8.js → index-qvbg6tx1.js} +65 -23
- package/dist/index-r3mwr5fb.js +0 -0
- package/dist/index-rdr78m0k.js +91 -0
- package/dist/index-rtamqsfs.js +59 -0
- package/dist/index-s125ss45.js +38 -0
- package/dist/{index-vn91b9z1.js → index-sx1t6dnd.js} +3721 -2382
- package/dist/index-tar0ngkm.js +359 -0
- package/dist/index-tn58cr6w.js +471 -0
- package/dist/{index-w0m1nckc.js → index-v79s9bf9.js} +118 -45
- package/dist/index-vk3rq21m.js +17 -0
- package/dist/index-vmvnr28y.js +72 -0
- package/dist/index-vz629cg8.js +49 -0
- package/dist/{index-eps3c3g6.js → index-w292hdpz.js} +197 -960
- package/dist/{index-amjttjaj.js → index-w9eqg6p9.js} +24 -302
- package/dist/index-wj96kdw2.js +57 -0
- package/dist/index-wyck5yhd.js +141 -0
- package/dist/index-xvtk8pxs.js +674 -0
- package/dist/{index-bpc596v3.js → index-xwb691v9.js} +2 -2
- package/dist/index-ym69x168.js +518 -0
- package/dist/index-yprdjk9v.js +65 -0
- package/dist/index-z2a81ccr.js +35 -0
- package/dist/{index-3ah1f369.js → index-z69cqk74.js} +3 -3
- package/dist/index-zaakvmzq.js +62 -0
- package/dist/index-zk3m4mzg.js +232 -0
- package/dist/index-zx3wgvx4.js +218 -0
- package/dist/index.js +102 -83
- package/dist/persistence/migration-guard.d.ts +3 -0
- package/dist/runtime/agent-profile.d.ts +12 -0
- package/dist/runtime/harness.d.ts +13 -0
- package/dist/runtime/known-file-preload.d.ts +35 -0
- package/dist/service-cli.js +130 -40
- package/dist/service-client-cli-2rzxy5mj.js +1166 -0
- package/dist/service-client-cli-5ne8q5ej.js +543 -0
- package/dist/tools/ooxml-zip.d.ts +21 -0
- package/dist/tools/presentations.d.ts +47 -0
- package/dist/tools/tabular-data.d.ts +114 -0
- package/dist/tools/workspace.d.ts +76 -0
- package/dist/verify-historical-migrations.js +2249 -1016
- package/dist/workspace/workspace.d.ts +13 -1
- package/dist/zhx.js +8 -6
- package/docs/APPLICATION_MIGRATION.md +32 -0
- package/docs/CLI.md +166 -2
- package/docs/CODE_RELEASE.md +11 -5
- package/docs/CODE_WEB_TASKS.md +3 -114
- package/docs/CONTEXT_ENGINEERING.md +93 -0
- package/docs/ENGINE_API.md +9 -2
- package/docs/EXTENSIBILITY.md +1 -1
- package/docs/FIRST_USE.md +6 -6
- package/docs/INTERNAL_ARCHIVE.md +43 -0
- package/docs/LOCAL_SERVICE.md +1 -1
- package/docs/MODEL_CATALOG.md +14 -0
- package/docs/PROJECT_MEMORY.md +1 -1
- package/docs/README.md +23 -4
- package/evaluations/representative-assembly-matrix.json +19 -1
- package/examples/README.md +4 -4
- package/examples/assistant/compatible-calendar.json +17 -0
- package/examples/assistant/composed-modules.json +23 -0
- package/examples/assistant/connected-tools.json +9 -0
- package/examples/assistant/daily-tools.json +6 -0
- package/examples/assistant/offline.mjs +24 -0
- package/fixtures/cli-compatibility/README.md +10 -0
- package/fixtures/cli-compatibility/inventory.json +7858 -0
- package/package.json +232 -26
- package/dist/cli/console/console-model-catalog.d.ts +0 -8
- package/dist/index-2yyfg69h.js +0 -619
- package/dist/index-3wwfn5n6.js +0 -270
- package/dist/index-4gt045j0.js +0 -288
- package/dist/index-4jw3tvy8.js +0 -301
- package/dist/service-client-cli-xbj7j5kj.js +0 -1251
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// packages/core/src/client/protocol.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var HARNESS_CLIENT_PROTOCOL_VERSION = 1;
|
|
4
|
+
var id = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/);
|
|
5
|
+
var revision = z.number().int().nonnegative().safe();
|
|
6
|
+
var scoped = { projectId: id };
|
|
7
|
+
var session = { ...scoped, sessionId: id };
|
|
8
|
+
var run = { ...session, runId: id };
|
|
9
|
+
var mutation = { idempotencyKey: id };
|
|
10
|
+
var checkpoint = { ...session, checkpointId: z.string().uuid() };
|
|
11
|
+
var restore = { ...session, operationId: z.string().uuid() };
|
|
12
|
+
var retention = { checkpointIds: z.array(z.string().uuid()).max(100), completedRestoreIds: z.array(z.string().uuid()).max(100) };
|
|
13
|
+
var fileDigest = z.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
14
|
+
var harnessClientCommandSchema = z.discriminatedUnion("method", [
|
|
15
|
+
z.object({ method: z.literal("project.get"), ...scoped }).strict(),
|
|
16
|
+
z.object({ method: z.literal("policy.get"), ...scoped }).strict(),
|
|
17
|
+
z.object({ method: z.literal("session.list"), ...scoped, search: z.string().max(256).optional() }).strict(),
|
|
18
|
+
z.object({ method: z.literal("session.create"), ...scoped, ...mutation, title: z.string().max(256).optional() }).strict(),
|
|
19
|
+
z.object({ method: z.literal("session.get"), ...session }).strict(),
|
|
20
|
+
z.object({ method: z.literal("session.rename"), ...session, ...mutation, expectedRevision: revision, title: z.string().max(256) }).strict(),
|
|
21
|
+
z.object({ method: z.literal("checkpoint.storage"), ...scoped }).strict(),
|
|
22
|
+
z.object({ method: z.literal("checkpoint.pruneReview"), ...scoped, selection: z.object(retention).strict() }).strict(),
|
|
23
|
+
z.object({ method: z.literal("checkpoint.pruneApply"), ...scoped, ...mutation, selection: z.object(retention).strict(), reviewedPlanId: fileDigest }).strict(),
|
|
24
|
+
z.object({ method: z.literal("checkpoint.list"), ...session }).strict(),
|
|
25
|
+
z.object({ method: z.literal("checkpoint.inspect"), ...checkpoint }).strict(),
|
|
26
|
+
z.object({
|
|
27
|
+
method: z.literal("checkpoint.capture"),
|
|
28
|
+
...session,
|
|
29
|
+
...mutation,
|
|
30
|
+
expectedRevision: revision,
|
|
31
|
+
turnId: id,
|
|
32
|
+
paths: z.array(z.string().min(1).max(1024)).min(1).max(20)
|
|
33
|
+
}).strict(),
|
|
34
|
+
z.object({
|
|
35
|
+
method: z.literal("restore.prepare"),
|
|
36
|
+
...checkpoint,
|
|
37
|
+
...mutation,
|
|
38
|
+
expectedRevision: revision,
|
|
39
|
+
expected: z.record(z.string().min(1).max(1024), fileDigest).refine((value) => Object.keys(value).length >= 1 && Object.keys(value).length <= 20)
|
|
40
|
+
}).strict(),
|
|
41
|
+
z.object({ method: z.literal("restore.get"), ...restore }).strict(),
|
|
42
|
+
z.object({ method: z.literal("restore.apply"), ...restore, ...mutation, expectedRevision: revision, reviewedProposalId: fileDigest }).strict(),
|
|
43
|
+
z.object({ method: z.literal("restore.recoverFork"), ...restore, ...mutation, expectedRevision: revision, forkSessionId: id }).strict(),
|
|
44
|
+
z.object({ method: z.literal("run.start"), ...session, ...mutation, expectedRevision: revision, prompt: z.string().min(1).max(64 * 1024) }).strict(),
|
|
45
|
+
z.object({
|
|
46
|
+
method: z.literal("task.start"),
|
|
47
|
+
...session,
|
|
48
|
+
...mutation,
|
|
49
|
+
expectedRevision: revision,
|
|
50
|
+
brief: z.strictObject({
|
|
51
|
+
goal: z.string().trim().min(1).max(2000),
|
|
52
|
+
paths: z.array(z.string().min(1).max(1024)).min(1).max(20),
|
|
53
|
+
checks: z.array(id).min(1).max(8),
|
|
54
|
+
constraints: z.array(z.string().trim().min(1).max(500)).max(8),
|
|
55
|
+
budget: z.strictObject({ inputTokens: z.number().int().positive().safe(), outputTokens: z.number().int().positive().safe(), totalTokens: z.number().int().positive().safe() })
|
|
56
|
+
})
|
|
57
|
+
}).strict(),
|
|
58
|
+
z.object({ method: z.literal("task.review"), ...run }).strict(),
|
|
59
|
+
z.object({ method: z.literal("task.keep"), ...run, ...mutation, reviewId: z.string().uuid() }).strict(),
|
|
60
|
+
z.object({ method: z.literal("task.revise"), ...run, ...mutation, reviewId: z.string().uuid(), correction: z.string().trim().min(1).max(500) }).strict(),
|
|
61
|
+
z.object({ method: z.literal("task.continue"), ...run, ...mutation, reviewId: z.string().uuid(), prompt: z.string().trim().min(1).max(2000) }).strict(),
|
|
62
|
+
z.object({ method: z.literal("task.get"), ...run, projectionVersion: z.number().int().nonnegative().safe() }).strict(),
|
|
63
|
+
z.object({ method: z.literal("run.get"), ...run, includeReview: z.boolean().optional(), includeDiff: z.boolean().optional(), decisionOffset: z.number().int().min(0).max(512).optional() }).strict(),
|
|
64
|
+
z.object({
|
|
65
|
+
method: z.literal("approval.resolve"),
|
|
66
|
+
...run,
|
|
67
|
+
...mutation,
|
|
68
|
+
expectedRevision: revision,
|
|
69
|
+
decisions: z.array(z.object({ approvalId: z.string().min(1).max(256), digest: z.string().regex(/^[a-f0-9]{64}$/), approve: z.boolean() }).strict()).min(1).max(64)
|
|
70
|
+
}).strict(),
|
|
71
|
+
z.object({ method: z.literal("run.cancel"), ...run, ...mutation, expectedRevision: revision }).strict()
|
|
72
|
+
]);
|
|
73
|
+
var harnessClientRequestSchema = z.object({
|
|
74
|
+
protocolVersion: z.literal(HARNESS_CLIENT_PROTOCOL_VERSION),
|
|
75
|
+
requestId: id,
|
|
76
|
+
connectionId: id,
|
|
77
|
+
command: harnessClientCommandSchema
|
|
78
|
+
}).strict();
|
|
79
|
+
|
|
80
|
+
export { HARNESS_CLIENT_PROTOCOL_VERSION, harnessClientCommandSchema, harnessClientRequestSchema };
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
changeEnvelopeSchema,
|
|
3
3
|
verifyChangeEnvelope
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-cztmcesv.js";
|
|
5
5
|
import {
|
|
6
6
|
APPROVAL_HISTORY_KEY,
|
|
7
7
|
approvalDecisionViews,
|
|
8
8
|
harnessPolicyDecisionEventSchema
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-kbrf5bx7.js";
|
|
10
|
+
import {
|
|
11
|
+
HARNESS_VERSION
|
|
12
|
+
} from "./index-kwk23ktq.js";
|
|
10
13
|
import {
|
|
11
14
|
TASK_ACCEPTANCE_EVIDENCE_KEY,
|
|
12
15
|
USAGE_LEDGER_KEY,
|
|
13
16
|
inspectRuntimeManifest,
|
|
14
17
|
inspectUsageLedger,
|
|
15
18
|
readTaskAcceptanceLedger
|
|
16
|
-
} from "./index-
|
|
17
|
-
import {
|
|
18
|
-
HARNESS_VERSION
|
|
19
|
-
} from "./index-3wwfn5n6.js";
|
|
19
|
+
} from "./index-6ehtssyz.js";
|
|
20
20
|
import {
|
|
21
21
|
taskCheckReceiptSchema
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-f970qtb4.js";
|
|
23
23
|
|
|
24
|
-
// src/persistence/governance-report.ts
|
|
24
|
+
// packages/core/src/persistence/governance-report.ts
|
|
25
25
|
import { createHash as createHash2 } from "node:crypto";
|
|
26
26
|
import { z as z2 } from "zod";
|
|
27
27
|
|
|
28
|
-
// src/persistence/governance-context.ts
|
|
28
|
+
// packages/core/src/persistence/governance-context.ts
|
|
29
29
|
import { createHash } from "node:crypto";
|
|
30
30
|
import { z } from "zod";
|
|
31
31
|
var digest = z.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
@@ -161,7 +161,7 @@ function projectGovernanceEnvelopes(envelopes, patches, now) {
|
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
// src/persistence/governance-report.ts
|
|
164
|
+
// packages/core/src/persistence/governance-report.ts
|
|
165
165
|
var digest2 = z2.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
166
166
|
var version = z2.string().regex(/^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/);
|
|
167
167
|
var bindingSchema = z2.object({ schemaVersion: z2.literal(1), id: z2.literal("zhivex-harness"), version, fingerprint: digest2, algorithm: z2.literal("sha256") });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openCalendarStore
|
|
3
|
+
} from "./index-0csc5sc7.js";
|
|
4
|
+
import {
|
|
5
|
+
createCalendarOAuth
|
|
6
|
+
} from "./index-41q1k17x.js";
|
|
7
|
+
|
|
8
|
+
// packages/core/src/application/assistant/calendar/connection.ts
|
|
9
|
+
import { mkdir, lstat } from "node:fs/promises";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
async function openCalendarConnection(directory, ownerId, options, recover = false) {
|
|
12
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/.test(ownerId))
|
|
13
|
+
throw new Error("CALENDAR_OWNER_INVALID");
|
|
14
|
+
await mkdir(directory, { recursive: true, mode: 448 });
|
|
15
|
+
const stat = await lstat(directory);
|
|
16
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || stat.uid !== process.getuid?.() || stat.mode & 63)
|
|
17
|
+
throw new Error("CALENDAR_STATE_UNSAFE");
|
|
18
|
+
const store = await openCalendarStore(path.join(directory, "state"), options.encryptionKey, recover);
|
|
19
|
+
try {
|
|
20
|
+
if (store.meta("owner") && store.meta("owner") !== ownerId)
|
|
21
|
+
throw new Error("CALENDAR_OWNER_MISMATCH");
|
|
22
|
+
store.set("owner", ownerId);
|
|
23
|
+
const oauth = createCalendarOAuth(store, options);
|
|
24
|
+
return { store, oauth, close: () => store.close() };
|
|
25
|
+
} catch (error) {
|
|
26
|
+
await store.close();
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { openCalendarConnection };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// packages/core/src/application/assistant/calendar/environment.ts
|
|
2
|
+
function calendarEnvironment(calendarId = "primary") {
|
|
3
|
+
return {
|
|
4
|
+
clientId: process.env.ASSISTANT_GOOGLE_CLIENT_ID ?? "",
|
|
5
|
+
encryptionKey: process.env.ASSISTANT_CREDENTIAL_KEY ?? "",
|
|
6
|
+
...process.env.ASSISTANT_GOOGLE_CLIENT_SECRET ? { clientSecret: process.env.ASSISTANT_GOOGLE_CLIENT_SECRET } : {},
|
|
7
|
+
calendarId
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { calendarEnvironment };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openCalendarStore
|
|
3
|
+
} from "./index-0csc5sc7.js";
|
|
4
|
+
import {
|
|
5
|
+
startCalendarAuthorization
|
|
6
|
+
} from "./index-41q1k17x.js";
|
|
7
|
+
|
|
8
|
+
// packages/core/src/application/assistant/microsoft/connection.ts
|
|
9
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
10
|
+
import { mkdir, lstat } from "node:fs/promises";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
var microsoftConfigSchema = z.strictObject({ clientId: z.uuid(), tenantId: z.uuid(), mail: z.boolean(), calendar: z.boolean() }).refine((v) => v.mail || v.calendar);
|
|
14
|
+
var microsoftScopes = (options) => ["User.Read", ...options.mail ? ["Mail.ReadWrite"] : [], ...options.calendar ? ["Calendars.ReadWrite"] : []];
|
|
15
|
+
|
|
16
|
+
class MicrosoftHttpError extends Error {
|
|
17
|
+
status;
|
|
18
|
+
constructor(status) {
|
|
19
|
+
super(`MICROSOFT_HTTP_${status}`);
|
|
20
|
+
this.status = status;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function microsoftJson(fetcher, url, init = {}, signal) {
|
|
24
|
+
try {
|
|
25
|
+
const response = await fetcher(url, { ...init, redirect: "error", signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(20000)]) : AbortSignal.timeout(20000) });
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
await response.body?.cancel();
|
|
28
|
+
throw new MicrosoftHttpError(response.status);
|
|
29
|
+
}
|
|
30
|
+
if (!response.body)
|
|
31
|
+
throw new Error;
|
|
32
|
+
const reader = response.body.getReader(), parts = [];
|
|
33
|
+
let size = 0;
|
|
34
|
+
try {
|
|
35
|
+
while (true) {
|
|
36
|
+
const part = await reader.read();
|
|
37
|
+
if (part.done)
|
|
38
|
+
break;
|
|
39
|
+
size += part.value.byteLength;
|
|
40
|
+
if (size > 1024 * 1024) {
|
|
41
|
+
await reader.cancel();
|
|
42
|
+
throw new Error;
|
|
43
|
+
}
|
|
44
|
+
parts.push(part.value);
|
|
45
|
+
}
|
|
46
|
+
} finally {
|
|
47
|
+
reader.releaseLock();
|
|
48
|
+
}
|
|
49
|
+
return JSON.parse(Buffer.concat(parts).toString("utf8"));
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (error instanceof MicrosoftHttpError)
|
|
52
|
+
throw error;
|
|
53
|
+
throw new Error("MICROSOFT_TRANSPORT_UNCERTAIN");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
var credentialSchema = z.object({ connectionId: z.string(), accountId: z.string(), email: z.string(), clientId: z.string(), tenantId: z.string(), accessToken: z.string(), refreshToken: z.string(), expiresAt: z.number(), scope: z.string() });
|
|
57
|
+
async function openMicrosoftConnection(directory, ownerId, options, recover = false) {
|
|
58
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/.test(ownerId))
|
|
59
|
+
throw new Error("MICROSOFT_OWNER_INVALID");
|
|
60
|
+
microsoftConfigSchema.parse({ clientId: options.clientId, tenantId: options.tenantId, mail: options.mail, calendar: options.calendar });
|
|
61
|
+
const root = path.join(directory, "microsoft");
|
|
62
|
+
await mkdir(root, { recursive: true, mode: 448 });
|
|
63
|
+
const stat = await lstat(root);
|
|
64
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || stat.uid !== process.getuid?.() || stat.mode & 63)
|
|
65
|
+
throw new Error("MICROSOFT_STATE_UNSAFE");
|
|
66
|
+
const store = await openCalendarStore(path.join(root, "state"), options.encryptionKey, recover);
|
|
67
|
+
try {
|
|
68
|
+
if (store.meta("owner") && store.meta("owner") !== ownerId)
|
|
69
|
+
throw new Error("MICROSOFT_OWNER_MISMATCH");
|
|
70
|
+
store.set("owner", ownerId);
|
|
71
|
+
const fetcher = options.fetcher ?? fetch, now = options.now ?? Date.now;
|
|
72
|
+
const authority = `https://login.microsoftonline.com/${options.tenantId}/oauth2/v2.0`;
|
|
73
|
+
const scopes = microsoftScopes(options), scope = `offline_access ${scopes.map((s) => `https://graph.microsoft.com/${s}`).join(" ")}`;
|
|
74
|
+
const hasScopes = (value) => scopes.every((s) => value.split(" ").some((v) => v.toLowerCase().replace("https://graph.microsoft.com/", "") === s.toLowerCase()));
|
|
75
|
+
const tokenRequest = (fields) => microsoftJson(fetcher, `${authority}/token`, { method: "POST", headers: { "content-type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ client_id: options.clientId, scope, ...fields }).toString() });
|
|
76
|
+
const credentials = () => {
|
|
77
|
+
const raw = store.decrypt("credentials");
|
|
78
|
+
if (!raw)
|
|
79
|
+
throw new Error("MICROSOFT_NOT_CONNECTED");
|
|
80
|
+
const value = credentialSchema.parse(raw);
|
|
81
|
+
if (value.clientId !== options.clientId || value.tenantId !== options.tenantId)
|
|
82
|
+
throw new Error("MICROSOFT_CLIENT_MISMATCH");
|
|
83
|
+
if (!hasScopes(value.scope) || store.meta("reauthorize") === "yes")
|
|
84
|
+
throw new Error("MICROSOFT_REAUTHORIZE");
|
|
85
|
+
return value;
|
|
86
|
+
};
|
|
87
|
+
const checkToken = (token) => {
|
|
88
|
+
if (typeof token.access_token !== "string" || !token.access_token || String(token.token_type).toLowerCase() !== "bearer" || !Number.isFinite(token.expires_in) || token.expires_in <= 0 || typeof token.scope !== "string" || !hasScopes(token.scope))
|
|
89
|
+
throw new Error("MICROSOFT_CONSENT_INCOMPLETE");
|
|
90
|
+
};
|
|
91
|
+
let refreshing;
|
|
92
|
+
const oauth = {
|
|
93
|
+
credentials,
|
|
94
|
+
async freshCredentials() {
|
|
95
|
+
const old = credentials();
|
|
96
|
+
if (old.expiresAt > now() + 60000)
|
|
97
|
+
return old;
|
|
98
|
+
refreshing ??= (async () => {
|
|
99
|
+
try {
|
|
100
|
+
const token = await tokenRequest({ grant_type: "refresh_token", refresh_token: old.refreshToken });
|
|
101
|
+
checkToken(token);
|
|
102
|
+
if (store.decrypt("credentials")?.connectionId !== old.connectionId)
|
|
103
|
+
throw new Error("MICROSOFT_CONNECTION_CHANGED");
|
|
104
|
+
const updated = { ...old, accessToken: token.access_token, refreshToken: typeof token.refresh_token === "string" && token.refresh_token ? token.refresh_token : old.refreshToken, expiresAt: now() + token.expires_in * 1000, scope: token.scope };
|
|
105
|
+
store.encrypt("credentials", updated);
|
|
106
|
+
return updated;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
if (error instanceof MicrosoftHttpError && [400, 401].includes(error.status)) {
|
|
109
|
+
store.set("reauthorize", "yes");
|
|
110
|
+
throw new Error("MICROSOFT_REAUTHORIZE");
|
|
111
|
+
}
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
})();
|
|
115
|
+
try {
|
|
116
|
+
return await refreshing;
|
|
117
|
+
} finally {
|
|
118
|
+
refreshing = undefined;
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
begin(redirectUri) {
|
|
122
|
+
const uri = new URL(redirectUri);
|
|
123
|
+
if (uri.protocol !== "http:" || uri.hostname !== "localhost" || !uri.port || uri.pathname !== "/oauth/callback" || uri.search || uri.hash || uri.username || uri.password)
|
|
124
|
+
throw new Error("MICROSOFT_REDIRECT_INVALID");
|
|
125
|
+
const state = randomBytes(32).toString("base64url"), verifier = randomBytes(32).toString("base64url");
|
|
126
|
+
store.encrypt("oauth", { state, verifier, redirectUri, expiresAt: now() + 600000 });
|
|
127
|
+
return `${authority}/authorize?${new URLSearchParams({ client_id: options.clientId, response_type: "code", response_mode: "query", redirect_uri: redirectUri, scope, state, prompt: "select_account", code_challenge: createHash("sha256").update(verifier).digest("base64url"), code_challenge_method: "S256" })}`;
|
|
128
|
+
},
|
|
129
|
+
async complete(code, state) {
|
|
130
|
+
const pending = store.decrypt("oauth");
|
|
131
|
+
if (!pending || pending.state !== state || pending.expiresAt < now() || !code || code.length > 8192)
|
|
132
|
+
throw new Error("MICROSOFT_OAUTH_STATE_INVALID");
|
|
133
|
+
store.run("DELETE FROM meta WHERE key='oauth'");
|
|
134
|
+
const token = await tokenRequest({ grant_type: "authorization_code", code, redirect_uri: pending.redirectUri, code_verifier: pending.verifier });
|
|
135
|
+
checkToken(token);
|
|
136
|
+
if (typeof token.refresh_token !== "string" || !token.refresh_token)
|
|
137
|
+
throw new Error("MICROSOFT_CONSENT_INCOMPLETE");
|
|
138
|
+
const me = await microsoftJson(fetcher, "https://graph.microsoft.com/v1.0/me?$select=id,mail,userPrincipalName", { headers: { authorization: `Bearer ${token.access_token}` } });
|
|
139
|
+
if (typeof me.id !== "string" || !me.id || typeof (me.mail || me.userPrincipalName) !== "string")
|
|
140
|
+
throw new Error("MICROSOFT_ACCOUNT_INVALID");
|
|
141
|
+
const previous = store.decrypt("credentials");
|
|
142
|
+
if (previous && (previous.accountId !== me.id || previous.tenantId !== options.tenantId || previous.clientId !== options.clientId))
|
|
143
|
+
throw new Error("MICROSOFT_ACCOUNT_MISMATCH_DISCONNECT_FIRST");
|
|
144
|
+
const value = { connectionId: previous?.connectionId ?? randomBytes(16).toString("hex"), accountId: me.id, email: me.mail || me.userPrincipalName, clientId: options.clientId, tenantId: options.tenantId, accessToken: token.access_token, refreshToken: token.refresh_token, expiresAt: now() + token.expires_in * 1000, scope: token.scope };
|
|
145
|
+
store.encrypt("credentials", value);
|
|
146
|
+
store.set("reauthorize", "no");
|
|
147
|
+
return { email: value.email, accountId: value.accountId };
|
|
148
|
+
},
|
|
149
|
+
async disconnect() {
|
|
150
|
+
store.run("DELETE FROM meta WHERE key IN ('credentials','oauth')");
|
|
151
|
+
store.set("reauthorize", "yes");
|
|
152
|
+
return { disconnected: true, revoked: false };
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
return { store, oauth, close: () => store.close() };
|
|
156
|
+
} catch (error) {
|
|
157
|
+
await store.close();
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
var startMicrosoftAuthorization = (oauth) => startCalendarAuthorization(oauth, { hostname: "localhost", provider: "Microsoft", errorPrefix: "MICROSOFT" });
|
|
162
|
+
|
|
163
|
+
export { microsoftConfigSchema, microsoftScopes, MicrosoftHttpError, microsoftJson, openMicrosoftConnection, startMicrosoftAuthorization };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dailyIntegrationSchema
|
|
3
|
+
} from "./index-gvva3e5x.js";
|
|
4
|
+
import {
|
|
5
|
+
microsoftConfigSchema
|
|
6
|
+
} from "./index-91n5wr6s.js";
|
|
7
|
+
import {
|
|
8
|
+
qwenRegions,
|
|
9
|
+
qwenServices
|
|
10
|
+
} from "./index-wj96kdw2.js";
|
|
11
|
+
|
|
12
|
+
// packages/core/src/application/assistant/managed/setup-state.ts
|
|
13
|
+
import { createHash } from "node:crypto";
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
var secret = z.string().trim().min(1).max(8192).regex(/^[\x21-\x7e]+$/);
|
|
16
|
+
var compatibleSetupSchema = z.strictObject({
|
|
17
|
+
baseURL: z.string().url().max(2048),
|
|
18
|
+
model: z.string().min(1).max(200),
|
|
19
|
+
apiKey: secret,
|
|
20
|
+
apiMode: z.enum(["chat", "responses"]).default("chat"),
|
|
21
|
+
webSearch: z.literal(true).optional(),
|
|
22
|
+
allowInsecureLocalhost: z.boolean().default(false)
|
|
23
|
+
});
|
|
24
|
+
var providerSchema = z.union([
|
|
25
|
+
compatibleSetupSchema,
|
|
26
|
+
z.strictObject({ kind: z.literal("meta"), model: z.string().min(1).max(200), apiKey: secret }),
|
|
27
|
+
z.strictObject({
|
|
28
|
+
kind: z.literal("qwen"),
|
|
29
|
+
service: z.enum(qwenServices).optional(),
|
|
30
|
+
model: z.string().min(1).max(200),
|
|
31
|
+
apiKey: secret,
|
|
32
|
+
region: z.enum(qwenRegions).default("singapore"),
|
|
33
|
+
workspaceId: z.string().trim().min(1).max(128).regex(/^[a-zA-Z0-9][a-zA-Z0-9-]*$/).optional()
|
|
34
|
+
})
|
|
35
|
+
]);
|
|
36
|
+
var calendarSchema = z.strictObject({
|
|
37
|
+
clientId: z.string().max(320).endsWith(".apps.googleusercontent.com"),
|
|
38
|
+
clientSecret: z.string().max(1024).optional()
|
|
39
|
+
});
|
|
40
|
+
var googleSchema = calendarSchema.extend({
|
|
41
|
+
encryptionKey: z.string(),
|
|
42
|
+
email: z.string().optional(),
|
|
43
|
+
mail: z.boolean(),
|
|
44
|
+
drive: z.boolean()
|
|
45
|
+
});
|
|
46
|
+
var agentName = z.string().trim().min(1).max(80);
|
|
47
|
+
var profileSchema = z.strictObject({
|
|
48
|
+
id: z.string().regex(/^[a-f0-9]{12}$/),
|
|
49
|
+
name: agentName,
|
|
50
|
+
microsoft: microsoftConfigSchema.safeExtend({ encryptionKey: z.string(), email: z.string().optional() }).optional(),
|
|
51
|
+
tools: dailyIntegrationSchema.optional(),
|
|
52
|
+
google: googleSchema.optional(),
|
|
53
|
+
connectionId: z.string().regex(/^[a-f0-9]{24}$/).optional(),
|
|
54
|
+
profileWebSearch: z.boolean().optional(),
|
|
55
|
+
profileBinding: z.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
56
|
+
provider: providerSchema.optional(),
|
|
57
|
+
calendar: calendarSchema.extend({ allowCreate: z.boolean().optional(), encryptionKey: z.string(), email: z.string().optional() }).optional(),
|
|
58
|
+
telegram: z.strictObject({
|
|
59
|
+
token: secret,
|
|
60
|
+
userId: z.string(),
|
|
61
|
+
offset: z.number().int().nonnegative().safe(),
|
|
62
|
+
username: z.string()
|
|
63
|
+
}).optional()
|
|
64
|
+
});
|
|
65
|
+
var savedSchema = z.strictObject({
|
|
66
|
+
version: z.literal(1),
|
|
67
|
+
active: z.string().optional(),
|
|
68
|
+
draft: profileSchema.optional(),
|
|
69
|
+
profiles: z.array(profileSchema).max(50),
|
|
70
|
+
connections: z.array(z.strictObject({ id: z.string(), provider: providerSchema })).max(200).optional()
|
|
71
|
+
});
|
|
72
|
+
var connectionId = (provider) => {
|
|
73
|
+
const { model: _, ...scope } = provider;
|
|
74
|
+
const {
|
|
75
|
+
apiMode: _mode,
|
|
76
|
+
webSearch: _search,
|
|
77
|
+
...identity
|
|
78
|
+
} = scope;
|
|
79
|
+
return createHash("sha256").update(JSON.stringify(identity)).digest("hex").slice(0, 24);
|
|
80
|
+
};
|
|
81
|
+
var profileConnectionId = (p) => p.connectionId ?? (p.provider ? connectionId(p.provider) : undefined);
|
|
82
|
+
var connectionsFor = (saved) => {
|
|
83
|
+
const entries = new Map((saved.connections ?? []).map((c) => [c.id, c.provider]));
|
|
84
|
+
for (const p of [...saved.profiles, ...saved.draft ? [saved.draft] : []])
|
|
85
|
+
if (p.provider)
|
|
86
|
+
entries.set(profileConnectionId(p), p.provider);
|
|
87
|
+
return entries;
|
|
88
|
+
};
|
|
89
|
+
var encodeSaved = (saved) => {
|
|
90
|
+
const profile = (p) => {
|
|
91
|
+
if (!p.provider)
|
|
92
|
+
return p;
|
|
93
|
+
const { apiKey: _, ...config } = p.provider;
|
|
94
|
+
return { ...p, provider: { ...config, connectionId: profileConnectionId(p) } };
|
|
95
|
+
};
|
|
96
|
+
return JSON.stringify({
|
|
97
|
+
...saved,
|
|
98
|
+
version: 2,
|
|
99
|
+
profiles: saved.profiles.map(profile),
|
|
100
|
+
...saved.draft ? { draft: profile(saved.draft) } : {},
|
|
101
|
+
connections: [...connectionsFor(saved)].map(([id, provider]) => {
|
|
102
|
+
const { apiKey, ...config } = provider;
|
|
103
|
+
return { id, apiKey, provider: config };
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
var decodeSaved = (text) => {
|
|
108
|
+
const raw = JSON.parse(text);
|
|
109
|
+
if (raw.version === 1)
|
|
110
|
+
return savedSchema.parse(raw);
|
|
111
|
+
const refProfile = profileSchema.extend({
|
|
112
|
+
provider: z.record(z.string(), z.unknown()).optional()
|
|
113
|
+
});
|
|
114
|
+
const stored = z.strictObject({
|
|
115
|
+
version: z.literal(2),
|
|
116
|
+
active: z.string().optional(),
|
|
117
|
+
draft: refProfile.optional(),
|
|
118
|
+
profiles: z.array(refProfile).max(50),
|
|
119
|
+
connections: z.array(z.strictObject({
|
|
120
|
+
id: z.string(),
|
|
121
|
+
apiKey: secret,
|
|
122
|
+
provider: z.record(z.string(), z.unknown()).optional()
|
|
123
|
+
})).max(200)
|
|
124
|
+
}).parse(raw);
|
|
125
|
+
const profile = (p) => {
|
|
126
|
+
if (!p.provider)
|
|
127
|
+
return p;
|
|
128
|
+
const { connectionId: id, ...config } = p.provider;
|
|
129
|
+
const connection = stored.connections.find((c) => c.id === id);
|
|
130
|
+
if (!connection)
|
|
131
|
+
throw new Error("SETUP_CONNECTION_NOT_FOUND");
|
|
132
|
+
return {
|
|
133
|
+
...p,
|
|
134
|
+
connectionId: connection.id,
|
|
135
|
+
provider: { ...config, apiKey: connection.apiKey }
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
const hydrated = savedSchema.parse({
|
|
139
|
+
version: 1,
|
|
140
|
+
active: stored.active,
|
|
141
|
+
profiles: stored.profiles.map(profile),
|
|
142
|
+
...stored.draft ? { draft: profile(stored.draft) } : {},
|
|
143
|
+
connections: stored.connections.filter((c) => c.provider).map((c) => ({ id: c.id, provider: { ...c.provider, apiKey: c.apiKey } }))
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
...hydrated,
|
|
147
|
+
connections: [...connectionsFor(hydrated)].map(([id, provider]) => ({ id, provider }))
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export { secret, providerSchema, calendarSchema, agentName, connectionId, profileConnectionId, connectionsFor, encodeSaved, decodeSaved };
|