@gaodefa/daocore 2026.5.29 → 2026.5.30
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/dist/abort-DI3P6TIb.js +277 -0
- package/dist/abort.runtime-B6Z7lDEa.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/account-inspect-BFz7X0TX.js +173 -0
- package/dist/accounts-BoYYrY7x.js +107 -0
- package/dist/accounts-Busq29zW.js +107 -0
- package/dist/accounts-CuvH2tuN.js +119 -0
- package/dist/accounts-DkIcqvf7.js +2 -0
- package/dist/acp-runtime-BA8lzXzf.js +26 -0
- package/dist/acp-spawn-DPz2aX3A.js +2 -0
- package/dist/acp-spawn-DvVCsWYV.js +1275 -0
- package/dist/acp-stateful-target-driver-DcC76aZW.js +89 -0
- package/dist/action-kill-D-dVisIX.js +33 -0
- package/dist/action-runtime-BEiqwxDD.js +469 -0
- package/dist/action-runtime-api-1LzcGjcX.js +2 -0
- package/dist/action-send-c3CnDuPg.js +39 -0
- package/dist/action-spawn-Dj4kwpWs.js +47 -0
- package/dist/actions-qLccmQBc.js +161 -0
- package/dist/actions.runtime-B5vYAgNi.js +5 -0
- package/dist/agent-command-D6Ds198G.js +1367 -0
- package/dist/agent-components.runtime-xquK0B3L.js +10 -0
- package/dist/agent-components.runtime.js +1 -1
- package/dist/agent-harness-runtime-Dq1fCBOM.js +180 -0
- package/dist/agent-harness-task-runtime-DvSEqFkD.js +140 -0
- package/dist/agent-lm5ZYOFy.js +3 -0
- package/dist/agent-runner-execution-Dbh2pDhQ.js +1713 -0
- package/dist/agent-runner-utils-Di3r2T1T.js +266 -0
- package/dist/agent-runner.runtime-BW90EcGW.js +3455 -0
- package/dist/agent-runner.runtime.js +1 -1
- package/dist/agent-runtime-BgIT5Ytc.js +229 -0
- package/dist/agent-via-gateway-DMMS8-hK.js +463 -0
- package/dist/agent-ylolD8-V.js +2 -0
- package/dist/api-BB4vXLtW.js +2 -0
- package/dist/api-CUhM3KNB.js +134 -0
- package/dist/api-CewRHSbT.js +6 -0
- package/dist/api-CfKjNJlW.js +2 -0
- package/dist/api-Rsnqui1u.js +3 -0
- package/dist/api-k7AvxwHr.js +639 -0
- package/dist/apply-DQ4TQNMA.js +54 -0
- package/dist/apply-S_75Py4Y.js +41 -0
- package/dist/approval-handler.runtime-Cthxrstu.js +130 -0
- package/dist/assistant-Cp9pGaBw.js +291 -0
- package/dist/attachment-normalize-5R0bLLOj.js +225 -0
- package/dist/attempt-execution-DuyyZYsU.js +558 -0
- package/dist/attempt-execution.runtime-DF2GPgNh.js +3 -0
- package/dist/attempt-execution.runtime.js +1 -1
- package/dist/attempt-execution.shared-CwdukA3t.js +38 -0
- package/dist/attempt.prompt-helpers-CUqKtIa5.js +475 -0
- package/dist/attempt.tool-run-context-BbN4_BYO.js +2094 -0
- package/dist/binding-routing-C6Ex2Blu.js +113 -0
- package/dist/binding-targets-BqREncSL.js +121 -0
- package/dist/bot-DGMEkaIJ.js +7894 -0
- package/dist/bot-deps-BltYjeMX.js +2 -0
- package/dist/bot-deps-XvGCor9f.js +747 -0
- package/dist/bot-message-context.runtime-kK-xvLV7.js +7 -0
- package/dist/bot-message-context.runtime.js +1 -1
- package/dist/bot-message-context.session.runtime-DpOIJUae.js +12 -0
- package/dist/bot-message-context.session.runtime.js +1 -1
- package/dist/bot-native-commands.delivery.runtime-D49p5Lc1.js +4 -0
- package/dist/bot-native-commands.delivery.runtime.js +1 -1
- package/dist/bot-native-commands.runtime-8XBdSpkQ.js +13 -0
- package/dist/bot-native-commands.runtime.js +1 -1
- package/dist/bridge-server-y_XGduPx.js +113 -0
- package/dist/browser-cli-B2jmmTT3.js +230 -0
- package/dist/browser-cli-actions-input-JQt5ZQcn.js +473 -0
- package/dist/browser-cli-actions-observe-CrfKh6AX.js +81 -0
- package/dist/browser-cli-debug-DQACWlvC.js +137 -0
- package/dist/browser-cli-inspect-DDnxx0Xw.js +104 -0
- package/dist/browser-cli-lEuOnZzs.js +2 -0
- package/dist/browser-cli-manage-DogmwtYt.js +443 -0
- package/dist/browser-cli-resize-BHuV71VZ.js +26 -0
- package/dist/browser-cli-shared-CidShgoF.js +50 -0
- package/dist/browser-cli-state-i8cCGbiQ.js +337 -0
- package/dist/browser-control-auth-CKfXdXWj.js +2 -0
- package/dist/browser-profiles-ATBTvUGh.js +2 -0
- package/dist/browser-runtime-KmCT6FuL.js +384 -0
- package/dist/build-DOOT6f62.js +257 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +1 -1
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/capability-cli-DwvrwB-g.js +1782 -0
- package/dist/channel-B-wgK1bK.js +481 -0
- package/dist/channel-B1e_k1P0.js +867 -0
- package/dist/channel-BRDfa5tc.js +1777 -0
- package/dist/channel-BVEO1O4p.js +376 -0
- package/dist/channel-BYlO5l1d.js +508 -0
- package/dist/channel-Bl0sPoNx.js +653 -0
- package/dist/channel-C84xtDBy.js +1134 -0
- package/dist/channel-CLgKq4Ds.js +1556 -0
- package/dist/channel-CZT0qxLh.js +1249 -0
- package/dist/channel-CffBHWkb.js +955 -0
- package/dist/channel-D34ZJvVB.js +2126 -0
- package/dist/channel-DcdXLo_W.js +238 -0
- package/dist/channel-DnK5TrXV.js +362 -0
- package/dist/channel-Dzj4RHY2.js +740 -0
- package/dist/channel-OhZzLZCj.js +562 -0
- package/dist/channel-actions.runtime-Cdvhqc9s.js +265 -0
- package/dist/channel-actions.runtime.js +1 -1
- package/dist/channel-core-Dz9I_R4j.js +5 -0
- package/dist/channel-inbound-COGoV_aS.js +80 -0
- package/dist/channel-mP6HCIMr.js +1496 -0
- package/dist/channel-plugin-runtime-C0R46KeG.js +998 -0
- package/dist/channel-quGdgWel.js +808 -0
- package/dist/channel-runtime-FvPQoIF9.js +408 -0
- package/dist/channel.runtime-2vUz3gij.js +109 -0
- package/dist/channel.runtime-BZLDSNuQ.js +254 -0
- package/dist/channel.runtime-Bo5jO0Hj.js +4 -0
- package/dist/channel.runtime-CDgvrjM2.js +652 -0
- package/dist/channel.runtime-COf8SDFn.js +88 -0
- package/dist/channel.runtime-C_C1f8lu.js +733 -0
- package/dist/channel.runtime-CqPbsg8t.js +2528 -0
- package/dist/channel.runtime-DtV85Khx.js +1008 -0
- package/dist/channel.runtime-Spt1ukGW.js +21009 -0
- package/dist/channel.setup-Bc0LUQS1.js +1098 -0
- package/dist/channel.setup-ChTkj2hq.js +343 -0
- package/dist/channel.setup-CpMD9F8i.js +10 -0
- package/dist/chat-mUsjD5YN.js +2666 -0
- package/dist/chrome-u314zcbM.js +1503 -0
- package/dist/cli/run-main.js +5 -5
- package/dist/cli-CJMoqXrc.js +1341 -0
- package/dist/cli-compaction-qGYB7suI.js +347 -0
- package/dist/cli-metadata-BBJFpNU9.js +22 -0
- package/dist/cli-runner-C0kcts0I.js +540 -0
- package/dist/cli-runner-CTm8K6s8.js +2 -0
- package/dist/cli-runner.runtime-C8deL5FL.js +3 -0
- package/dist/cli-runner.runtime-DDAg1D0L.js +4 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-startup-metadata.json +8 -8
- package/dist/client-CPxpgs4m.js +650 -0
- package/dist/client-adapter-CLlqOqfu.js +897 -0
- package/dist/client-factory-R7Rr2jwn.js +9 -0
- package/dist/command-auth-CkQP1buP.js +135 -0
- package/dist/command-handlers-CJEjFyMk.js +1609 -0
- package/dist/command-registry-BDgyOqDw.js +4 -0
- package/dist/command-registry-BVi5Jn1S.js +9 -0
- package/dist/command-registry-core-JCfsVRtz.js +110 -0
- package/dist/command-status.runtime-CM1JLzi6.js +90 -0
- package/dist/command-status.runtime.js +1 -1
- package/dist/commands-acp-C1-I78U6.js +74 -0
- package/dist/commands-compact.runtime-DOsNavwp.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-handlers.runtime-BD1n2WGw.js +6154 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-status-DU_UTQz1.js +16 -0
- package/dist/commands-status-DejfTakp.js +3 -0
- package/dist/commands-status.runtime-DejfTakp.js +3 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-D7vo_2Y_.js +3 -0
- package/dist/commands-subagents-control.runtime-DGybTjJ6.js +2 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands-system-prompt-BEBXAMea.js +2 -0
- package/dist/commands-system-prompt-gj3oQpQO.js +162 -0
- package/dist/commands.runtime-CgXX70IN.js +176 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/commitments/runtime.js +1 -1
- package/dist/compact-C41XxMDt.js +480 -0
- package/dist/compact-DUVAF9EC.js +1141 -0
- package/dist/compact.runtime-COMRg6s3.js +12 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/completion-cli-CmEYoB9a.js +315 -0
- package/dist/computer-use-BwJHu1QF.js +367 -0
- package/dist/config-ATBTvUGh.js +2 -0
- package/dist/config-DlNgjF8W.js +373 -0
- package/dist/config-mutations-tl_OqI6d.js +159 -0
- package/dist/context-engine-host-compat-BNPAIK9F.js +288 -0
- package/dist/context-engine-host-compat-C69CK7zS.js +2 -0
- package/dist/context-engine-lifecycle-iQ8f5a_-.js +1274 -0
- package/dist/control-auth-vVxyGKxY.js +114 -0
- package/dist/control-service-73nj79EW.js +145 -0
- package/dist/control-ui/assets/agents-DdWIz8Vk.js +1008 -0
- package/dist/control-ui/assets/channel-config-extras-C7ELhuDi.js +2 -0
- package/dist/control-ui/assets/channels-Bsoj-9BS.js +367 -0
- package/dist/control-ui/assets/cron-BRTEw1tT.js +1013 -0
- package/dist/control-ui/assets/debug-EKl_F8_L.js +97 -0
- package/dist/control-ui/assets/index-DSbSO7ys.js +7370 -0
- package/dist/control-ui/assets/instances-B1AoYwI5.js +57 -0
- package/dist/control-ui/assets/logs-BChOznzh.js +74 -0
- package/dist/control-ui/assets/nodes-5yebKh9k.js +436 -0
- package/dist/control-ui/assets/sessions-BlDYNThc.js +399 -0
- package/dist/control-ui/assets/skills-shared-CNFnf7KU.js +11 -0
- package/dist/control-ui/assets/skills-uxTDRmLx.js +314 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/control-ui/sw.js +1 -1
- package/dist/conversation-binding-runtime-CmoTKcY1.js +4 -0
- package/dist/conversation-runtime-BxOHxuin.js +31 -0
- package/dist/core-D0Y2H55f.js +282 -0
- package/dist/core-api-BKlJUtDt.js +5 -0
- package/dist/core-api-_fiftUHn.js +2 -0
- package/dist/crestodian/crestodian.js +1 -1
- package/dist/crestodian/rescue-message.js +1 -1
- package/dist/crestodian-BJifoQiR.js +55 -0
- package/dist/daocore-tools-BMdF8RwK.js +11727 -0
- package/dist/delivery-e2ci_bcX.js +1002 -0
- package/dist/dialogue-BXayGhnz.js +37 -0
- package/dist/dir-fetch-tool-Cara5mZh.js +565 -0
- package/dist/dir-list-tool-CQ8Bo5Ez.js +100 -0
- package/dist/direct-dm-CPk6Qm9D.js +64 -0
- package/dist/directive-handling.fast-lane-BQ9aXqk8.js +68 -0
- package/dist/directive-handling.impl--a5AGurq.js +818 -0
- package/dist/directive-handling.impl-C4JqMwle.js +2 -0
- package/dist/directive-handling.model-selection-pyTYMIXn.js +122 -0
- package/dist/directive-handling.persist.runtime-B7vWT1r9.js +263 -0
- package/dist/directive-handling.persist.runtime.js +1 -1
- package/dist/dispatch-3Ru_eGq1.js +1640 -0
- package/dist/dispatch-acp-transcript.runtime-CYMP-5oE.js +40 -0
- package/dist/dispatch-acp-transcript.runtime.js +1 -1
- package/dist/dispatch-acp.runtime-BVCiklXk.js +18 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/doctor-B8mR3Sgr.js +2 -0
- package/dist/doctor-BJ6DuerV.js +6 -0
- package/dist/doctor-config-flow-BdOGs_zn.js +1741 -0
- package/dist/doctor-core-checks-CDf0stz-.js +2 -0
- package/dist/doctor-core-checks-Cpdnu2XI.js +573 -0
- package/dist/doctor-health-0qv_acBu.js +65 -0
- package/dist/doctor-health-contributions-Db1FQgFw.js +696 -0
- package/dist/doctor-lint-C1g4Llgl.js +94 -0
- package/dist/doctor-state-integrity-C8iXFLJ7.js +1231 -0
- package/dist/doctor-update-CsPu6p3d.js +58 -0
- package/dist/dynamic-tools-YQ0z0YKH.js +486 -0
- package/dist/embedded-backend-S0cahIZw.js +579 -0
- package/dist/embedded-gateway-stub.runtime-Cjw12ALm.js +12 -0
- package/dist/embedded-gateway-stub.runtime.js +1 -1
- package/dist/exec-approvals-ArHHjoE-.js +149 -0
- package/dist/extensionAPI.js +1 -1
- package/dist/extensions/active-memory/index.js +1 -1
- package/dist/extensions/admin-http-rpc/index.js +1 -1
- package/dist/extensions/browser/browser-bridge.js +1 -1
- package/dist/extensions/browser/browser-config.js +4 -4
- package/dist/extensions/browser/browser-control-auth.js +2 -2
- package/dist/extensions/browser/browser-doctor.js +2 -2
- package/dist/extensions/browser/browser-maintenance.js +1 -1
- package/dist/extensions/browser/browser-profiles.js +2 -2
- package/dist/extensions/browser/browser-runtime-api.js +11 -11
- package/dist/extensions/browser/cli-metadata.js +1 -1
- package/dist/extensions/browser/index.js +1 -1
- package/dist/extensions/browser/plugin-registration.js +1 -1
- package/dist/extensions/browser/register.runtime.js +4 -4
- package/dist/extensions/browser/runtime-api.js +13 -13
- package/dist/extensions/canvas/index.js +1 -1
- package/dist/extensions/clickclack/api.js +2 -2
- package/dist/extensions/clickclack/channel-plugin-api.js +1 -1
- package/dist/extensions/clickclack/runtime-api.js +2 -2
- package/dist/extensions/device-pair/api.js +1 -1
- package/dist/extensions/device-pair/pair-command-approve.js +1 -1
- package/dist/extensions/file-transfer/index.js +4 -4
- package/dist/extensions/imessage/api.js +2 -2
- package/dist/extensions/imessage/channel-plugin-api.js +1 -1
- package/dist/extensions/imessage/message-tool-api.d.ts +1 -1
- package/dist/extensions/imessage/runtime-api.js +3 -3
- package/dist/extensions/irc/api.js +2 -2
- package/dist/extensions/irc/channel-plugin-api.js +1 -1
- package/dist/extensions/llm-task/index.js +1 -1
- package/dist/extensions/mattermost/api.js +1 -1
- package/dist/extensions/mattermost/channel-plugin-api.js +1 -1
- package/dist/extensions/mattermost/channel-plugin-runtime.js +1 -1
- package/dist/extensions/mattermost/policy-api.js +1 -1
- package/dist/extensions/mattermost/runtime-api.js +2 -2
- package/dist/extensions/mattermost/slash-route-api.js +1 -1
- package/dist/extensions/memory-core/cli-metadata.js +1 -1
- package/dist/extensions/migrate-claude/apply.js +1 -1
- package/dist/extensions/migrate-claude/index.js +1 -1
- package/dist/extensions/migrate-claude/plan.js +1 -1
- package/dist/extensions/migrate-claude/provider.js +1 -1
- package/dist/extensions/migrate-claude/targets.js +1 -1
- package/dist/extensions/migrate-hermes/apply.js +1 -1
- package/dist/extensions/migrate-hermes/index.js +1 -1
- package/dist/extensions/migrate-hermes/model.js +1 -1
- package/dist/extensions/migrate-hermes/plan.js +1 -1
- package/dist/extensions/migrate-hermes/provider.js +1 -1
- package/dist/extensions/migrate-hermes/secrets.js +1 -1
- package/dist/extensions/migrate-hermes/targets.js +1 -1
- package/dist/extensions/policy/api.js +1 -1
- package/dist/extensions/policy/index.js +2 -2
- package/dist/extensions/signal/api.js +6 -6
- package/dist/extensions/signal/channel-plugin-api.js +1 -1
- package/dist/extensions/signal/reaction-runtime-api.js +1 -1
- package/dist/extensions/signal/runtime-api.js +7 -7
- package/dist/extensions/skill-workshop/api.js +1 -1
- package/dist/extensions/skill-workshop/index.js +2 -2
- package/dist/extensions/telegram/account-inspect-api.js +1 -1
- package/dist/extensions/telegram/api.js +11 -11
- package/dist/extensions/telegram/channel-plugin-api.js +2 -2
- package/dist/extensions/telegram/contract-api.js +3 -3
- package/dist/extensions/telegram/runtime-api.js +7 -7
- package/dist/extensions/telegram/security-audit-contract-api.js +1 -1
- package/dist/extensions/telegram/setup-plugin-api.js +1 -1
- package/dist/extensions/telegram/test-api.js +2 -2
- package/dist/extensions/webhooks/api.js +1 -1
- package/dist/extensions/webhooks/index.js +1 -1
- package/dist/extensions/xai/index.js +4 -4
- package/dist/extensions/xai/realtime-transcription-provider.js +1 -1
- package/dist/extensions/xai/speech-provider.js +1 -1
- package/dist/extensions/xai/test-api.js +1 -1
- package/dist/extensions/xai/tts.js +1 -1
- package/dist/extensions/xai/web-search.js +1 -1
- package/dist/extensions/xai/xai-oauth.js +1 -1
- package/dist/file-fetch-tool-DQpAtjX4.js +124 -0
- package/dist/file-write-tool-CkB0oYwe.js +127 -0
- package/dist/format-DUJUpMFQ.js +1145 -0
- package/dist/gateway-cli-CQo_E4Ka.js +435 -0
- package/dist/gateway-method-runtime-1QPgVJH7.js +21 -0
- package/dist/get-reply-DfUcsC-O.js +4689 -0
- package/dist/get-reply-from-config.runtime-C95MG73O.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/graph-users-DPJe0fPs.js +1419 -0
- package/dist/group-access-DefaNJ6L.js +112 -0
- package/dist/handle-action.guild-admin-C1sy1kGJ.js +288 -0
- package/dist/harness-BgPRdmNK.js +61 -0
- package/dist/health-DFR9A1YV.js +4 -0
- package/dist/heartbeat-runner-BiYVPs25.js +5 -0
- package/dist/heartbeat-runner.runtime-Bmaq8WUA.js +4 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/hooks-CNJDuJUm.js +534 -0
- package/dist/inbound-direct-dm-runtime-DFt58p71.js +2 -0
- package/dist/inbound-reply-dispatch-kgSDM8ax.js +148 -0
- package/dist/index.js +1 -1
- package/dist/init-B0zO_U4r.js +59 -0
- package/dist/inline-buttons-B6zgQW3J.js +40 -0
- package/dist/internal-events-C3Q5t6hg.js +90 -0
- package/dist/isolated-agent-CaSU5GCJ.js +2 -0
- package/dist/isolated-agent-CnsD2TmP.js +1118 -0
- package/dist/lifecycle-i3WZDaIn.js +571 -0
- package/dist/list.probe-g0rUiVXW.js +449 -0
- package/dist/list.status-command-DG3PrmeO.js +789 -0
- package/dist/llm-slug-generator-CHlf69FU.js +78 -0
- package/dist/llm-slug-generator.js +1 -1
- package/dist/local-dispatch.runtime-CDeHUp_A.js +9 -0
- package/dist/local-dispatch.runtime.js +1 -1
- package/dist/manager.runtime-BlLMPUTq.js +2714 -0
- package/dist/manager.runtime.js +1 -1
- package/dist/markdown-to-line-r_mBHMdy.js +811 -0
- package/dist/mcp-http-C5UPIJGR.js +555 -0
- package/dist/mcp-http-CTy9gpfA.js +2 -0
- package/dist/media-understanding-provider-BT6TOuVa.js +339 -0
- package/dist/message-actions-BdcjjwFt.js +145 -0
- package/dist/message-handler-B29Tj2p2.js +1715 -0
- package/dist/message-handler-BhHb1FHI.js +384 -0
- package/dist/message-handler.preflight-ouZ_-3o8.js +1125 -0
- package/dist/message-handler.process-CrYiBx_F.js +1484 -0
- package/dist/model-CLbtocQX.js +74 -0
- package/dist/model-selection-BG_vU9Kl.js +272 -0
- package/dist/models-4KERn3ya.js +104 -0
- package/dist/models-BCa-ipxi.js +2 -0
- package/dist/models-cli-DtpGXEsf.js +256 -0
- package/dist/monitor-B-egsvmI.js +1657 -0
- package/dist/monitor-BJX9Yv7k.js +2 -0
- package/dist/monitor-BPrIy3pV.js +715 -0
- package/dist/monitor-BWknZZ7N.js +4377 -0
- package/dist/monitor-C3y_PtI1.js +60 -0
- package/dist/monitor-DCzfdqE4.js +1370 -0
- package/dist/monitor-P24epSwE.js +2788 -0
- package/dist/monitor-auth-CEG_xldE.js +179 -0
- package/dist/monitor-jEePJbbS.js +834 -0
- package/dist/monitor-polling.runtime-BzlHK11u.js +883 -0
- package/dist/monitor-polling.runtime.js +1 -1
- package/dist/monitor-webhook.runtime-vFEhk_Zj.js +387 -0
- package/dist/monitor-webhook.runtime.js +1 -1
- package/dist/monitor.account-BUIfgWXg.js +5233 -0
- package/dist/monitor.runtime-Cp7W4fhb.js +2 -0
- package/dist/monitor.runtime.js +1 -1
- package/dist/monitor.webhook-DzrbeR4T.js +180 -0
- package/dist/node-cli-sessions-CLbI14UA.js +1228 -0
- package/dist/openai-http-BM9BIA_g.js +824 -0
- package/dist/openresponses-http-CNoW9kk8.js +1173 -0
- package/dist/operations-DT4bsxV6.js +805 -0
- package/dist/outbound-adapter-CZRUOgY0.js +543 -0
- package/dist/outbound-session-route-DneMsGNx.js +45 -0
- package/dist/outbound.runtime-CHuoKJJI.js +2 -0
- package/dist/outbound.runtime.js +1 -1
- package/dist/pi-embedded-1-rsueO_.js +3796 -0
- package/dist/pi-embedded-BRfDncVO.js +4 -0
- package/dist/pi-embedded.runtime-DEYoa6bW.js +4 -0
- package/dist/pi-embedded.runtime.js +1 -1
- package/dist/pi-tools-C0P3NgP5.js +2413 -0
- package/dist/plan-BQUkjBMY.js +81 -0
- package/dist/plan-CRO9_2_k.js +112 -0
- package/dist/plugin-BJCmWhnh.js +12396 -0
- package/dist/plugin-app-cache-key-CXAg0F7A.js +46 -0
- package/dist/plugin-enabled-D93Z9LSo.js +233 -0
- package/dist/plugin-registration-BBrTcZnf.js +88 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- package/dist/plugin-sdk/acp-runtime-backend.js +1 -1
- package/dist/plugin-sdk/acp-runtime.js +2 -2
- package/dist/plugin-sdk/agent-harness-runtime.js +6 -6
- package/dist/plugin-sdk/agent-harness-task-runtime.js +1 -1
- package/dist/plugin-sdk/agent-harness.js +7 -7
- package/dist/plugin-sdk/agent-runtime.js +2 -2
- package/dist/plugin-sdk/channel-core.js +2 -2
- package/dist/plugin-sdk/channel-inbound.js +2 -2
- package/dist/plugin-sdk/channel-test-helpers.js +1 -1
- package/dist/plugin-sdk/command-auth.js +1 -1
- package/dist/plugin-sdk/command-status-runtime.js +1 -1
- package/dist/plugin-sdk/compat.js +1 -1
- package/dist/plugin-sdk/conversation-binding-runtime.js +2 -2
- package/dist/plugin-sdk/conversation-runtime.js +3 -3
- package/dist/plugin-sdk/core.js +2 -2
- package/dist/plugin-sdk/direct-dm.js +1 -1
- package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
- package/dist/plugin-sdk/health.js +2 -2
- package/dist/plugin-sdk/inbound-reply-dispatch.js +1 -1
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/mattermost.js +1 -1
- package/dist/plugin-sdk/plugin-test-contracts.js +2 -2
- package/dist/plugin-sdk/provider-test-contracts.js +4 -4
- package/dist/plugin-sdk/reply-runtime.js +4 -4
- package/dist/plugin-sdk/testing.js +2 -2
- package/dist/plugin-sdk/zalouser.js +1 -1
- package/dist/plugin-service-DnZEPBEA.js +1229 -0
- package/dist/plugins/runtime/index.js +4 -4
- package/dist/policy-CMv5QMPG.js +138 -0
- package/dist/policy-CeoP4t9J.js +680 -0
- package/dist/prepare.runtime-DZ55JiTt.js +732 -0
- package/dist/prepare.runtime.js +1 -1
- package/dist/preview-warnings-O08PZRxu.js +392 -0
- package/dist/probe-C6w3bP8X.js +682 -0
- package/dist/probe-Cs1_X1NA.js +47 -0
- package/dist/probe-Cuee_jyM.js +2204 -0
- package/dist/probe-DZxCnDzn.js +2 -0
- package/dist/program-C2dT8VHB.js +131 -0
- package/dist/provider-C2_vSzYh.js +32 -0
- package/dist/provider-DSfTDQbj.js +152 -0
- package/dist/provider-U8hrm9h-.js +32 -0
- package/dist/provider-_v910H8y.js +8735 -0
- package/dist/provider-dispatcher-C3kmmIEC.js +22 -0
- package/dist/provider-dispatcher.runtime.js +1 -1
- package/dist/provider-session.runtime-Mg0fx5hH.js +9 -0
- package/dist/provider-session.runtime.js +1 -1
- package/dist/provider.runtime-pSTXuHrq.js +2 -0
- package/dist/provider.runtime.js +1 -1
- package/dist/public-surface-loader-09t4TTue.js +114 -0
- package/dist/pw-ai-DjNqHV3_.js +3029 -0
- package/dist/pw-role-snapshot-DoGefdv7.js +333 -0
- package/dist/reaction-level-C8Mqxizo.js +19 -0
- package/dist/reaction-runtime-api-DOP6xOsm.js +116 -0
- package/dist/realtime-transcription-provider-BTGEXXna.js +205 -0
- package/dist/register-CbZPpqI3.js +2178 -0
- package/dist/register.agent-DrBFuPKh.js +156 -0
- package/dist/register.crestodian-DwTbmaK8.js +24 -0
- package/dist/register.maintenance-BIeoYBub.js +83 -0
- package/dist/register.runtime-B5V9_Dwz.js +54 -0
- package/dist/register.subclis-CJE9ISZY.js +31 -0
- package/dist/register.subclis-YQsKas8N.js +3 -0
- package/dist/register.subclis-core-CjwdGeGU.js +273 -0
- package/dist/repair-sequencing-C0jrL5pw.js +640 -0
- package/dist/reply-delivery-B28mTIpb.js +196 -0
- package/dist/reply-runtime-BqQX7HHw.js +11 -0
- package/dist/reply.runtime-C95MG73O.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/request-BqoMvXxH.js +54 -0
- package/dist/resolve-allowlist-hbKKd_kq.js +220 -0
- package/dist/result-fallback-classifier-BrORPoxj.js +79 -0
- package/dist/route-HHRgSzVy.js +469 -0
- package/dist/route-resolution-C7bafjVc.js +274 -0
- package/dist/routes-86XGeo7a.js +2 -0
- package/dist/routes-BhVGr9ie.js +3602 -0
- package/dist/run-Bb5QP5JV.js +1162 -0
- package/dist/run-attempt-CLi0wV7j.js +7704 -0
- package/dist/run-command-Be6GAxiW.js +2 -0
- package/dist/run-command-Ds4hr3iU.js +23 -0
- package/dist/run-embedded.runtime-wX9ORojX.js +4 -0
- package/dist/run-embedded.runtime.js +1 -1
- package/dist/run-execution-cli.runtime-BmNZVB2N.js +4 -0
- package/dist/run-execution-cli.runtime.js +1 -1
- package/dist/run-executor.runtime.js +1 -1
- package/dist/run-subagent-registry.runtime-Uq5sjftu.js +2 -0
- package/dist/run-subagent-registry.runtime.js +1 -1
- package/dist/runtime-BktLQ75j.js +1287 -0
- package/dist/runtime-C9XdR62_.js +438 -0
- package/dist/runtime-CTvWDPx9.js +6179 -0
- package/dist/runtime-api-BojB3MUw.js +21 -0
- package/dist/runtime-api-C92MlAwp.js +13 -0
- package/dist/runtime-api-CFNZE9Xt.js +13 -0
- package/dist/runtime-api-Cimpgm5_.js +3 -0
- package/dist/runtime-api-D8qG_lUm.js +17 -0
- package/dist/runtime-api-DMDMnQEG.js +4 -0
- package/dist/runtime-api-DupQdIlE.js +24 -0
- package/dist/runtime-api.actions-B8i3elqu.js +3 -0
- package/dist/runtime-api.monitor-BntFzf_M.js +6 -0
- package/dist/runtime-api.send-CPlmi1jc.js +4 -0
- package/dist/runtime-api.threads-D-H_r_Nl.js +2 -0
- package/dist/runtime-channel-BGhTxnXZ.js +150 -0
- package/dist/runtime-channel-CPFxNapZ.js +2 -0
- package/dist/runtime-embedded-pi.runtime-BjnMTurB.js +2 -0
- package/dist/runtime-embedded-pi.runtime.js +1 -1
- package/dist/sanitize-outbound-BMUv1NeS.js +127 -0
- package/dist/sdk-setup-tools-Do3DkQi_.js +8 -0
- package/dist/secrets-B8YVPHhk.js +113 -0
- package/dist/security-audit-7Gg_nL4o.js +122 -0
- package/dist/security-audit-Bk3CREj-.js +118 -0
- package/dist/security-audit.runtime-BmSJrdeq.js +2 -0
- package/dist/security-audit.runtime.js +1 -1
- package/dist/selection-BFGde9-_.js +3 -0
- package/dist/selection-DrLFlbgG.js +16157 -0
- package/dist/send-4dLa-BQo.js +1631 -0
- package/dist/send-CV6gCwYP.js +192 -0
- package/dist/send-aGiK3Efu.js +143 -0
- package/dist/send-dB3CehAN.js +2 -0
- package/dist/send.components-BcG9BlkC.js +2 -0
- package/dist/send.components-rLjDlfYU.js +500 -0
- package/dist/send.runtime-D20k2MSr.js +2 -0
- package/dist/send.runtime.js +1 -1
- package/dist/server-BTRx_U1s.js +73 -0
- package/dist/server-CY0ymhBg.js +24 -0
- package/dist/server-close.runtime.js +1 -1
- package/dist/server-context-BxGT8wbK.js +955 -0
- package/dist/server-context-DYlbhAaT.js +2 -0
- package/dist/server-cron-BB_15lcP.js +2 -0
- package/dist/server-cron-CfyJX_a4.js +2989 -0
- package/dist/server-methods-Ck2ab6TC.js +16494 -0
- package/dist/server-node-events-BdRizF-5.js +596 -0
- package/dist/server-plugin-bootstrap-CPUr8NFE.js +70 -0
- package/dist/server-plugins-__5AxjzH.js +432 -0
- package/dist/server-reload-handlers-BMl9Fx9b.js +714 -0
- package/dist/server-restart-sentinel-D11M_ZsH.js +747 -0
- package/dist/server-restart-sentinel-DGptQ27c.js +2 -0
- package/dist/server-runtime-services-BwtLs-8I.js +2 -0
- package/dist/server-runtime-services-aJydixRu.js +267 -0
- package/dist/server-startup-plugins-m_P3gY4m.js +113 -0
- package/dist/server-startup-post-attach-DuXQ1AXL.js +716 -0
- package/dist/server-ws-runtime-mXmxB1W8.js +349 -0
- package/dist/server.impl-fuV8aKSP.js +2586 -0
- package/dist/service-a8cTFka4.js +1446 -0
- package/dist/session-binding-BIycxo9u.js +2 -0
- package/dist/session-binding-xHwQr9vM.js +219 -0
- package/dist/session-kill-http-DiUZhcoN.js +121 -0
- package/dist/session-reset-service-DkepDoob.js +625 -0
- package/dist/session-route-Ba5u7ecb.js +93 -0
- package/dist/session-status.runtime-Cb1X69Rl.js +2 -0
- package/dist/session-status.runtime.js +1 -1
- package/dist/session-subagent-reactivation.runtime-rbqmto4G.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-tab-registry-DSKOoJta.js +521 -0
- package/dist/sessions-history-http-CWP88I_C.js +430 -0
- package/dist/sessions.runtime-1q1OwLn3.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/setup-api-DtrOOYeP.js +29 -0
- package/dist/setup-core-DMrJS6LP.js +174 -0
- package/dist/setup-surface-BFPNu1qA.js +405 -0
- package/dist/setup-surface-CedShqhO.js +288 -0
- package/dist/setup-surface-DLOBH1Vf.js +320 -0
- package/dist/setup-surface-MhCeEWSj.js +221 -0
- package/dist/shared-DamL-e8D.js +121 -0
- package/dist/shared-client-B48JoAsz.js +2 -0
- package/dist/shared-client-BoSiDnUo.js +629 -0
- package/dist/side-question-DQoQ_ETb.js +683 -0
- package/dist/skill-tool-dispatch.runtime-CWLloYA8.js +143 -0
- package/dist/skill-tool-dispatch.runtime.js +1 -1
- package/dist/slash-state-DrrWJQfv.js +2166 -0
- package/dist/speech-provider-8Hx1uw41.js +184 -0
- package/dist/src-BbUYOPwU.js +4256 -0
- package/dist/startup-context-opAJAamX.js +313 -0
- package/dist/status-subagents.runtime-DSo7ZK_Z.js +18 -0
- package/dist/status-subagents.runtime.js +1 -1
- package/dist/status-text-AyPuDzrO.js +296 -0
- package/dist/sticker-cache-91Tp8mLP.js +206 -0
- package/dist/sticker-vision.runtime-DjleFXi5.js +17 -0
- package/dist/sticker-vision.runtime.js +1 -1
- package/dist/subagent-announce-delivery-DS_2W9oZ.js +958 -0
- package/dist/subagent-announce-hatA_PZ2.js +354 -0
- package/dist/subagent-control-IyFIvc7T.js +508 -0
- package/dist/subagent-hooks-BCj5eB0Z.js +2 -0
- package/dist/subagent-hooks-BWjTBkox.js +146 -0
- package/dist/subagent-hooks-CdGLK9_3.js +230 -0
- package/dist/subagent-hooks-EH0tBkw9.js +2 -0
- package/dist/subagent-hooks-api-BhYaXQJV.js +23 -0
- package/dist/subagent-hooks-api-uGsV8Xn5.js +22 -0
- package/dist/subagent-hooks-api-wfJFKIPx.js +23 -0
- package/dist/subagent-hooks-l8Xd94dt.js +2 -0
- package/dist/subagent-hooks-m2eHUO_d.js +116 -0
- package/dist/subagent-orphan-recovery-Bq9zvX3L.js +352 -0
- package/dist/subagent-registry-Bcb3zy6b.js +3 -0
- package/dist/subagent-registry-CoZNTFx-.js +2351 -0
- package/dist/subagent-registry.runtime.js +1 -1
- package/dist/subagent-session-cleanup--00EjDLe.js +525 -0
- package/dist/subagent-spawn-ClJJkz3D.js +1164 -0
- package/dist/target-id-BsZLiF3x.js +107 -0
- package/dist/targets-CQMe4AZP.js +44 -0
- package/dist/targets-SmL1AU-H.js +19 -0
- package/dist/targets-Y-roiA47.js +19 -0
- package/dist/task-registry-control.runtime.js +1 -1
- package/dist/telegram/token.js +1 -1
- package/dist/testing-B5hNJDuF.js +267 -0
- package/dist/thread-bindings-BD3eE0kK.js +232 -0
- package/dist/thread-bindings-C9NNiv8K.js +571 -0
- package/dist/thread-bindings-Dl4PN1vZ.js +228 -0
- package/dist/thread-bindings-uK1LLAwy.js +8 -0
- package/dist/thread-bindings.discord-api-BHNEUbnk.js +187 -0
- package/dist/thread-bindings.manager-B0LXiH3F.js +2 -0
- package/dist/thread-bindings.manager-BTlH4XMG.js +536 -0
- package/dist/thread-lifecycle-DG8uyPHd.js +1614 -0
- package/dist/token-BbGCANnE.js +134 -0
- package/dist/tool-actions.runtime-oUUrD8HB.js +534 -0
- package/dist/tool-actions.runtime.js +1 -1
- package/dist/tool-bqg-_vYv.js +139 -0
- package/dist/tool-resolution-CSZsa3kP.js +149 -0
- package/dist/tools-effective-inventory-0CqFp-vq.js +204 -0
- package/dist/tools-invoke-http-DhYHY0Yh.js +67 -0
- package/dist/tools-invoke-shared-CbVJJUj7.js +200 -0
- package/dist/tts-C2qD-ad6.js +66 -0
- package/dist/tui-CzGY254f.js +4709 -0
- package/dist/tui-backend-fzoeoSN0.js +256 -0
- package/dist/tui-cli-B2RWb2gM.js +37 -0
- package/dist/tui-dgS8hdXU.js +2 -0
- package/dist/update-cli-BmiBDf3c.js +3664 -0
- package/dist/update-runner-CM7QVX6u.js +2379 -0
- package/dist/vision-tools-BzoBZnIc.js +1409 -0
- package/dist/web-search-DmfOd66S.js +62 -0
- package/dist/web-search-provider.runtime-3C5-pODD.js +328 -0
- package/dist/web-search-provider.runtime-Doh-Z9We.js +2 -0
- package/dist/web-search-provider.runtime.js +1 -1
- package/dist/xai-oauth-BLvQ43hx.js +479 -0
- package/dist/xai-user-agent-BdMQ_0_O.js +32 -0
- package/package.json +1 -1
- package/dist/abort-DeEb_wKd.js +0 -277
- package/dist/abort.runtime-CoYXQGPK.js +0 -2
- package/dist/account-inspect-D_06-CYS.js +0 -173
- package/dist/accounts-BCTqtj4Y.js +0 -107
- package/dist/accounts-BudLl8P2.js +0 -107
- package/dist/accounts-CUReBDA0.js +0 -2
- package/dist/accounts-PCioSzzr.js +0 -119
- package/dist/acp-runtime-B2t9_BHD.js +0 -26
- package/dist/acp-spawn-0x4Iiu1o.js +0 -2
- package/dist/acp-spawn-B2Ghe0jJ.js +0 -1275
- package/dist/acp-stateful-target-driver-C4VgcSyz.js +0 -89
- package/dist/action-kill-ClYsXEz7.js +0 -33
- package/dist/action-runtime-DrLPkNvU.js +0 -469
- package/dist/action-runtime-api-BqSflr9q.js +0 -2
- package/dist/action-send-CIy9cziD.js +0 -39
- package/dist/action-spawn-BjV6lFnX.js +0 -47
- package/dist/actions-D-QH7wq5.js +0 -161
- package/dist/actions.runtime-hzDtXQGU.js +0 -5
- package/dist/agent-Bb1DTBgv.js +0 -3
- package/dist/agent-Cnqj258q.js +0 -2
- package/dist/agent-command-BRx6ZNgJ.js +0 -1367
- package/dist/agent-components.runtime-D-g6xXJ0.js +0 -10
- package/dist/agent-harness-runtime-dKUQFuOc.js +0 -180
- package/dist/agent-harness-task-runtime-v2crUm3i.js +0 -140
- package/dist/agent-runner-execution-AOzdxvWR.js +0 -1713
- package/dist/agent-runner-utils-Byv50B4Z.js +0 -266
- package/dist/agent-runner.runtime-hhgRE0Z-.js +0 -3455
- package/dist/agent-runtime-BHmh3i0o.js +0 -229
- package/dist/agent-via-gateway-DnCqaK4a.js +0 -463
- package/dist/api-Bzyb8sFU.js +0 -3
- package/dist/api-CIEDFXZs.js +0 -2
- package/dist/api-D_dTQAu8.js +0 -2
- package/dist/api-DilBjZ9Q.js +0 -6
- package/dist/api-E5zoQMmh.js +0 -134
- package/dist/api-OJZug8gQ.js +0 -639
- package/dist/apply-C0eV5T0O.js +0 -41
- package/dist/apply-alsYvxLE.js +0 -54
- package/dist/approval-handler.runtime-C6jqZXSN.js +0 -130
- package/dist/assistant-DDXnAAB5.js +0 -291
- package/dist/attachment-normalize-Cv-_4DWU.js +0 -225
- package/dist/attempt-execution-DECEU59r.js +0 -558
- package/dist/attempt-execution.runtime-kasMxuER.js +0 -3
- package/dist/attempt-execution.shared-ClUxk52p.js +0 -38
- package/dist/attempt.prompt-helpers-Bxlv9VSu.js +0 -475
- package/dist/attempt.tool-run-context-CplQWX6g.js +0 -2094
- package/dist/binding-routing-0Obpp-Ij.js +0 -113
- package/dist/binding-targets-CZHQaZL4.js +0 -121
- package/dist/bot-BPbQ0840.js +0 -7894
- package/dist/bot-deps-Cs1M9USs.js +0 -2
- package/dist/bot-deps-xAcaOtTZ.js +0 -747
- package/dist/bot-message-context.runtime-Bji78Cbn.js +0 -7
- package/dist/bot-message-context.session.runtime-C3dyOIYH.js +0 -12
- package/dist/bot-native-commands.delivery.runtime-WshH99fy.js +0 -4
- package/dist/bot-native-commands.runtime-C1L364gU.js +0 -13
- package/dist/bridge-server-DPlM8_Lk.js +0 -113
- package/dist/browser-cli-DFNQE98N.js +0 -230
- package/dist/browser-cli-Drb5E5--.js +0 -2
- package/dist/browser-cli-actions-input-Dx-1OXmE.js +0 -473
- package/dist/browser-cli-actions-observe-BMDfE7xU.js +0 -81
- package/dist/browser-cli-debug-nu7Ih09g.js +0 -137
- package/dist/browser-cli-inspect-D5X2wohg.js +0 -104
- package/dist/browser-cli-manage-DkzYwph4.js +0 -443
- package/dist/browser-cli-resize-B30Avedl.js +0 -26
- package/dist/browser-cli-shared-cMgQoQzF.js +0 -50
- package/dist/browser-cli-state-CQLDvDy7.js +0 -337
- package/dist/browser-control-auth-D7ArmHUt.js +0 -2
- package/dist/browser-profiles-B39SIZNb.js +0 -2
- package/dist/browser-runtime-DUbSAOOS.js +0 -384
- package/dist/build-D25KqC92.js +0 -257
- package/dist/capability-cli-CuyXrlAB.js +0 -1782
- package/dist/channel-0N3YGMGg.js +0 -1496
- package/dist/channel-1UyKoLyp.js +0 -481
- package/dist/channel-BG87pSEW.js +0 -740
- package/dist/channel-BPGSaZW7.js +0 -1249
- package/dist/channel-BQMPh1J_.js +0 -376
- package/dist/channel-Bd_8V6zn.js +0 -1134
- package/dist/channel-BtBjh_ij.js +0 -362
- package/dist/channel-CpFBlVH6.js +0 -562
- package/dist/channel-CwuTrIrF.js +0 -508
- package/dist/channel-Cxl4sJA-.js +0 -1777
- package/dist/channel-D-VfU4Z2.js +0 -2126
- package/dist/channel-D9q8aYrN.js +0 -867
- package/dist/channel-DKSvVvZh.js +0 -238
- package/dist/channel-DvoFfWLx.js +0 -808
- package/dist/channel-GktTcGHm.js +0 -955
- package/dist/channel-actions.runtime-CKcRA0GW.js +0 -265
- package/dist/channel-core-nm8s1qFZ.js +0 -5
- package/dist/channel-d3t2ESlE.js +0 -653
- package/dist/channel-inbound-DKz40dq-.js +0 -80
- package/dist/channel-plugin-runtime-DKIGZWfW.js +0 -998
- package/dist/channel-runtime-Bh8_GY12.js +0 -408
- package/dist/channel-yQ8jCOb9.js +0 -1556
- package/dist/channel.runtime-BG4mM5cQ.js +0 -652
- package/dist/channel.runtime-BS6PyFFa.js +0 -1008
- package/dist/channel.runtime-CE_xECqN.js +0 -88
- package/dist/channel.runtime-Cd1Sw8U4.js +0 -254
- package/dist/channel.runtime-DIq3XOEe.js +0 -733
- package/dist/channel.runtime-Dy1cx35I.js +0 -21009
- package/dist/channel.runtime-NyIMjLnP.js +0 -109
- package/dist/channel.runtime-Zx5mfE2V.js +0 -4
- package/dist/channel.runtime-rJRibGfN.js +0 -2528
- package/dist/channel.setup--4ACadmF.js +0 -10
- package/dist/channel.setup-DzwqIlo3.js +0 -1098
- package/dist/channel.setup-FKYSJwXR.js +0 -343
- package/dist/chat-CKxSm7r1.js +0 -2666
- package/dist/chrome-rMubJwRG.js +0 -1503
- package/dist/cli-CbTod55I.js +0 -1341
- package/dist/cli-compaction-BbHgjJyW.js +0 -347
- package/dist/cli-metadata-DkOWLC_p.js +0 -22
- package/dist/cli-runner-Cwzv_RKf.js +0 -540
- package/dist/cli-runner-DdnUsgPl.js +0 -2
- package/dist/cli-runner.runtime-BlrSgbEW.js +0 -3
- package/dist/cli-runner.runtime-D8kVfvFH.js +0 -4
- package/dist/client-ClvxsWgL.js +0 -650
- package/dist/client-adapter-CsrIIjK1.js +0 -897
- package/dist/client-factory-DAYClhwm.js +0 -9
- package/dist/command-auth-CCha2ofd.js +0 -135
- package/dist/command-handlers-DCWJzHyB.js +0 -1609
- package/dist/command-registry-BIf61QNz.js +0 -9
- package/dist/command-registry-DJROBy4h.js +0 -4
- package/dist/command-registry-core-BQOWqi6S.js +0 -110
- package/dist/command-status.runtime-D88CUglL.js +0 -90
- package/dist/commands-acp-B-8dHX4Z.js +0 -74
- package/dist/commands-compact.runtime-ComX5mUk.js +0 -10
- package/dist/commands-handlers.runtime-DR3wjXHX.js +0 -6154
- package/dist/commands-status-CDyGrwsI.js +0 -3
- package/dist/commands-status-DV-i_ZIK.js +0 -16
- package/dist/commands-status.runtime-CDyGrwsI.js +0 -3
- package/dist/commands-subagents-control.runtime-B029cXAS.js +0 -3
- package/dist/commands-subagents-control.runtime-DR8Qspe0.js +0 -2
- package/dist/commands-system-prompt-C10ctsG3.js +0 -162
- package/dist/commands-system-prompt-DQlRWwnk.js +0 -2
- package/dist/commands.runtime-BYmIAuN0.js +0 -176
- package/dist/compact-14Ljaaeu.js +0 -480
- package/dist/compact-B--ovdkx.js +0 -1141
- package/dist/compact.runtime-E0Idf2Dq.js +0 -12
- package/dist/completion-cli-DMvvQGSk.js +0 -315
- package/dist/computer-use-CcLwX5SR.js +0 -367
- package/dist/config-B39SIZNb.js +0 -2
- package/dist/config-D4rsGOyV.js +0 -373
- package/dist/config-mutations-CsI3YJu7.js +0 -159
- package/dist/context-engine-host-compat-BZpDFiMJ.js +0 -2
- package/dist/context-engine-host-compat-runUdES5.js +0 -288
- package/dist/context-engine-lifecycle-D6odtNrn.js +0 -1274
- package/dist/control-auth-BPGpPtfz.js +0 -114
- package/dist/control-service-C-OmdPCe.js +0 -145
- package/dist/control-ui/assets/agents-GeyOHPuW.js +0 -1008
- package/dist/control-ui/assets/channel-config-extras-D7en6iUg.js +0 -2
- package/dist/control-ui/assets/channels-DkEyr1w5.js +0 -367
- package/dist/control-ui/assets/cron-C-wThQ1Q.js +0 -1013
- package/dist/control-ui/assets/debug-83AFRtIX.js +0 -97
- package/dist/control-ui/assets/index-CiGEhMOA.js +0 -7370
- package/dist/control-ui/assets/instances-CVl0t-1h.js +0 -57
- package/dist/control-ui/assets/logs-eybVEXxg.js +0 -74
- package/dist/control-ui/assets/nodes-C_A7eoU2.js +0 -436
- package/dist/control-ui/assets/sessions-Cq4Nc69u.js +0 -399
- package/dist/control-ui/assets/skills-ZN6hroIh.js +0 -314
- package/dist/control-ui/assets/skills-shared-DIWGwmdC.js +0 -11
- package/dist/conversation-binding-runtime-C2U1JElL.js +0 -4
- package/dist/conversation-runtime-NmIUd3Zu.js +0 -31
- package/dist/core-DGKJP1dm.js +0 -282
- package/dist/core-api-1fA4sNeC.js +0 -5
- package/dist/core-api-BY822Quq.js +0 -2
- package/dist/crestodian-Bp-NXiBC.js +0 -55
- package/dist/daocore-tools-Defpam0j.js +0 -11727
- package/dist/delivery-CEdVAUGB.js +0 -1002
- package/dist/dialogue-CZ69INPq.js +0 -37
- package/dist/dir-fetch-tool-BCicHhQE.js +0 -565
- package/dist/dir-list-tool-Cv_WktsJ.js +0 -100
- package/dist/direct-dm-Bz89rM8x.js +0 -64
- package/dist/directive-handling.fast-lane-DDnbcc5S.js +0 -68
- package/dist/directive-handling.impl-B0H52Ymr.js +0 -818
- package/dist/directive-handling.impl-CgKpwEW-.js +0 -2
- package/dist/directive-handling.model-selection-_cXAr0vt.js +0 -122
- package/dist/directive-handling.persist.runtime-Dw0mfzXT.js +0 -263
- package/dist/dispatch-C3AeYvyP.js +0 -1640
- package/dist/dispatch-acp-transcript.runtime-CP8pqBwS.js +0 -40
- package/dist/dispatch-acp.runtime-Cdap-AZI.js +0 -18
- package/dist/doctor-BZwVH97p.js +0 -2
- package/dist/doctor-BfkGBii1.js +0 -6
- package/dist/doctor-config-flow-D3JASGDt.js +0 -1741
- package/dist/doctor-core-checks-DH5AIT0Q.js +0 -573
- package/dist/doctor-core-checks-DiNu7VSh.js +0 -2
- package/dist/doctor-health-BDIJ-Nro.js +0 -65
- package/dist/doctor-health-contributions-BgmF7w8X.js +0 -696
- package/dist/doctor-lint-uIxkMUSO.js +0 -94
- package/dist/doctor-state-integrity-ws1b_BGk.js +0 -1231
- package/dist/doctor-update-Cx4CqxaX.js +0 -58
- package/dist/dynamic-tools-DiqOxhJh.js +0 -486
- package/dist/embedded-backend-C634irMl.js +0 -579
- package/dist/embedded-gateway-stub.runtime-CCfrTOeN.js +0 -12
- package/dist/exec-approvals-D85KThSg.js +0 -149
- package/dist/file-fetch-tool-BERaGYCT.js +0 -124
- package/dist/file-write-tool-BjHrMyfe.js +0 -127
- package/dist/format-DE9PuPg1.js +0 -1145
- package/dist/gateway-cli-B5hjhbUy.js +0 -435
- package/dist/gateway-method-runtime-Bu0E9Eki.js +0 -21
- package/dist/get-reply-6PtPz9hv.js +0 -4689
- package/dist/get-reply-from-config.runtime-CwprvhoR.js +0 -2
- package/dist/graph-users-DUp1kgnS.js +0 -1419
- package/dist/group-access-D5GBQ3w6.js +0 -112
- package/dist/handle-action.guild-admin-CA0Y-buD.js +0 -288
- package/dist/harness-B5nOFVfm.js +0 -61
- package/dist/health-D5heIDj3.js +0 -4
- package/dist/heartbeat-runner-BzFkIFHh.js +0 -5
- package/dist/heartbeat-runner.runtime-p6H1_xMV.js +0 -4
- package/dist/hooks-BvTyQ14X.js +0 -534
- package/dist/inbound-direct-dm-runtime-DwiDXi8L.js +0 -2
- package/dist/inbound-reply-dispatch-YoDUOC6C.js +0 -148
- package/dist/init-CPtcV5Xu.js +0 -59
- package/dist/inline-buttons-DeD5d42c.js +0 -40
- package/dist/internal-events-DEb50Sw3.js +0 -90
- package/dist/isolated-agent-CcxFFZ-Z.js +0 -1118
- package/dist/isolated-agent-CpHzq5qr.js +0 -2
- package/dist/lifecycle-DNel-oMe.js +0 -571
- package/dist/list.probe-DCa3N25d.js +0 -449
- package/dist/list.status-command-CyeAJmZW.js +0 -789
- package/dist/llm-slug-generator-CyqTY37Z.js +0 -78
- package/dist/local-dispatch.runtime-nE39kFIP.js +0 -9
- package/dist/manager.runtime-CpAPB8D5.js +0 -2714
- package/dist/markdown-to-line-Ci6TRmoZ.js +0 -811
- package/dist/mcp-http-BR0vmxFL.js +0 -2
- package/dist/mcp-http-C0oniA8h.js +0 -555
- package/dist/media-understanding-provider-BwA0XqC3.js +0 -339
- package/dist/message-actions-C9C_Ngkd.js +0 -145
- package/dist/message-handler-CUUKPC5n.js +0 -384
- package/dist/message-handler-xRTfIXWV.js +0 -1715
- package/dist/message-handler.preflight-Ch2Q7V3M.js +0 -1125
- package/dist/message-handler.process-HM3mK93q.js +0 -1484
- package/dist/model-CB8Ex5xS.js +0 -74
- package/dist/model-selection-2s0Dinux.js +0 -272
- package/dist/models-Cn-6DJ41.js +0 -2
- package/dist/models-CzszJD__.js +0 -104
- package/dist/models-cli-CbhElnA5.js +0 -256
- package/dist/monitor-7aprTsMV.js +0 -715
- package/dist/monitor-BuVhqwDS.js +0 -1370
- package/dist/monitor-C4H_YkgY.js +0 -2
- package/dist/monitor-CPQsMxgv.js +0 -1657
- package/dist/monitor-Ce0V1PiR.js +0 -4377
- package/dist/monitor-D0bcGJWI.js +0 -60
- package/dist/monitor-DEjlJqzh.js +0 -834
- package/dist/monitor-auth-DjJZsjgV.js +0 -179
- package/dist/monitor-ikSYagv3.js +0 -2788
- package/dist/monitor-polling.runtime-D7yEflMM.js +0 -883
- package/dist/monitor-webhook.runtime-CIZt-biI.js +0 -387
- package/dist/monitor.account-C2sMOBCS.js +0 -5233
- package/dist/monitor.runtime-BAi6zmcn.js +0 -2
- package/dist/monitor.webhook-BcjpfRCX.js +0 -180
- package/dist/node-cli-sessions-CIhkJRU4.js +0 -1228
- package/dist/openai-http-Dj21RwSj.js +0 -824
- package/dist/openresponses-http-COnnr1ox.js +0 -1173
- package/dist/operations-H3vUh0lM.js +0 -805
- package/dist/outbound-adapter-WLtWE7wv.js +0 -543
- package/dist/outbound-session-route-CZtd64EH.js +0 -45
- package/dist/outbound.runtime-D98P0sN1.js +0 -2
- package/dist/pi-embedded-BWJzd4mK.js +0 -4
- package/dist/pi-embedded-DeNsSqQQ.js +0 -3796
- package/dist/pi-embedded.runtime-CZnNwFpc.js +0 -4
- package/dist/pi-tools-CNHSpjBa.js +0 -2413
- package/dist/plan-B0reFFlM.js +0 -81
- package/dist/plan-CrfF-TH8.js +0 -112
- package/dist/plugin-DI_8eYOe.js +0 -12396
- package/dist/plugin-app-cache-key-WaTUD3e-.js +0 -46
- package/dist/plugin-enabled-aWLXgGGi.js +0 -233
- package/dist/plugin-registration-ByjRIVJm.js +0 -88
- package/dist/plugin-service-VQm_241d.js +0 -1229
- package/dist/policy-BmJH-swe.js +0 -680
- package/dist/policy-DE-bO1zn.js +0 -138
- package/dist/prepare.runtime-bSj3-res.js +0 -732
- package/dist/preview-warnings-CbuGYsF9.js +0 -392
- package/dist/probe-C_rWg7_m.js +0 -682
- package/dist/probe-CagOFfx6.js +0 -2
- package/dist/probe-thX1HqOh.js +0 -2204
- package/dist/probe-zU6B6gFt.js +0 -47
- package/dist/program-BtVdH743.js +0 -131
- package/dist/provider-CDoD7tO0.js +0 -8735
- package/dist/provider-CK1gMdJ2.js +0 -32
- package/dist/provider-DJqr9djy.js +0 -32
- package/dist/provider-DsOJp5bK.js +0 -152
- package/dist/provider-dispatcher-UNQ-LSx9.js +0 -22
- package/dist/provider-session.runtime-DMrkMb4x.js +0 -9
- package/dist/provider.runtime-C2-t3zm8.js +0 -2
- package/dist/public-surface-loader-hTeyyHcd.js +0 -114
- package/dist/pw-ai-BaL3eVYx.js +0 -3029
- package/dist/pw-role-snapshot-DKeBqhN1.js +0 -333
- package/dist/reaction-level-BV2potsD.js +0 -19
- package/dist/reaction-runtime-api-CCBxgM10.js +0 -116
- package/dist/realtime-transcription-provider-CHYtIXZm.js +0 -205
- package/dist/register-BJf28G9B.js +0 -2178
- package/dist/register.agent-oXAHwNQv.js +0 -156
- package/dist/register.crestodian-CQ0sqdV2.js +0 -24
- package/dist/register.maintenance-CylVRs5M.js +0 -83
- package/dist/register.runtime-CcDgwy0X.js +0 -54
- package/dist/register.subclis-CpBYNw2X.js +0 -3
- package/dist/register.subclis-N2CvieOL.js +0 -31
- package/dist/register.subclis-core-BHaGvbzg.js +0 -273
- package/dist/repair-sequencing-EBBnBdIB.js +0 -640
- package/dist/reply-delivery-BLoPALlI.js +0 -196
- package/dist/reply-runtime-D4asNTSa.js +0 -11
- package/dist/reply.runtime-CwprvhoR.js +0 -2
- package/dist/request-DlWPRUDt.js +0 -54
- package/dist/resolve-allowlist-BukQf58x.js +0 -220
- package/dist/result-fallback-classifier-DyHFnqfV.js +0 -79
- package/dist/route-BMf4keN5.js +0 -469
- package/dist/route-resolution-DWNi1QAu.js +0 -274
- package/dist/routes-C20LC8c4.js +0 -3602
- package/dist/routes-CkK7Vv_m.js +0 -2
- package/dist/run-KDF_AEza.js +0 -1162
- package/dist/run-attempt-JHYCfonU.js +0 -7704
- package/dist/run-command-3PVihYIy.js +0 -2
- package/dist/run-command-QHAXnyKY.js +0 -23
- package/dist/run-embedded.runtime-BJw-2vss.js +0 -4
- package/dist/run-execution-cli.runtime-GHClMn2g.js +0 -4
- package/dist/run-subagent-registry.runtime-BLLMrhtE.js +0 -2
- package/dist/runtime-C2u-dC1r.js +0 -1287
- package/dist/runtime-ClyfkDWT.js +0 -6179
- package/dist/runtime-WXCarlPc.js +0 -438
- package/dist/runtime-api-3QhGLpZf.js +0 -13
- package/dist/runtime-api-DRAu3mjv.js +0 -4
- package/dist/runtime-api-JE07pOem.js +0 -13
- package/dist/runtime-api-JuKylHvw.js +0 -24
- package/dist/runtime-api-bcbk4yax.js +0 -21
- package/dist/runtime-api-dDe9U2_V.js +0 -17
- package/dist/runtime-api-uMexLqGS.js +0 -3
- package/dist/runtime-api.actions-Bo7TLDFl.js +0 -3
- package/dist/runtime-api.monitor-7q78L1Em.js +0 -6
- package/dist/runtime-api.send-Bf9RR4nV.js +0 -4
- package/dist/runtime-api.threads-Dj2QuhHj.js +0 -2
- package/dist/runtime-channel-k1C0Satl.js +0 -2
- package/dist/runtime-channel-qt9t0J-J.js +0 -150
- package/dist/runtime-embedded-pi.runtime-BPB9NlTS.js +0 -2
- package/dist/sanitize-outbound-BLH_SQvg.js +0 -127
- package/dist/sdk-setup-tools-BshlBPau.js +0 -8
- package/dist/secrets-CsHXv7d3.js +0 -113
- package/dist/security-audit-CUXBQXNX.js +0 -122
- package/dist/security-audit-CzdXbRma.js +0 -118
- package/dist/security-audit.runtime-Ca0FMFJG.js +0 -2
- package/dist/selection-BmvQJlSD.js +0 -3
- package/dist/selection-BplDXc9w.js +0 -16157
- package/dist/send--qFg8a9v.js +0 -1631
- package/dist/send-BPdryPPA.js +0 -192
- package/dist/send-Bl4YaRkS.js +0 -143
- package/dist/send-Ccm7RMXC.js +0 -2
- package/dist/send.components-c3OUPSmR.js +0 -2
- package/dist/send.components-rhQJYoXs.js +0 -500
- package/dist/send.runtime-dfUkAp5d.js +0 -2
- package/dist/server-DRhyTMLe.js +0 -73
- package/dist/server-Dv4BzjGn.js +0 -24
- package/dist/server-context-4HRJy2vp.js +0 -955
- package/dist/server-context-DlxYb1G5.js +0 -2
- package/dist/server-cron-Bt8Pkc3i.js +0 -2989
- package/dist/server-cron-CtNWsa4Z.js +0 -2
- package/dist/server-methods-rye_okUW.js +0 -16494
- package/dist/server-node-events-C1yZ5a1u.js +0 -596
- package/dist/server-plugin-bootstrap-DUMyVtlP.js +0 -70
- package/dist/server-plugins-B5ZWWkRE.js +0 -432
- package/dist/server-reload-handlers-CTnMXNjT.js +0 -714
- package/dist/server-restart-sentinel-CAYxtwmY.js +0 -747
- package/dist/server-restart-sentinel-DqrtSIvy.js +0 -2
- package/dist/server-runtime-services-CuptQTe5.js +0 -2
- package/dist/server-runtime-services-aaS2IiW3.js +0 -267
- package/dist/server-startup-plugins-D0ymJgQT.js +0 -113
- package/dist/server-startup-post-attach-DlrN2uyt.js +0 -716
- package/dist/server-ws-runtime-CdpLbv4o.js +0 -349
- package/dist/server.impl-Cb4qcMTg.js +0 -2586
- package/dist/service-qxvDlMQE.js +0 -1446
- package/dist/session-binding-6bLobLHL.js +0 -219
- package/dist/session-binding-Bm6fCpoY.js +0 -2
- package/dist/session-kill-http-B6WjVo8V.js +0 -121
- package/dist/session-reset-service-GUVIhxp4.js +0 -625
- package/dist/session-route-BcRDnvzG.js +0 -93
- package/dist/session-status.runtime-BcjOunV4.js +0 -2
- package/dist/session-subagent-reactivation.runtime-BSmk_KYn.js +0 -2
- package/dist/session-tab-registry-BBYzbSOu.js +0 -521
- package/dist/sessions-history-http-bLJJfgLm.js +0 -430
- package/dist/sessions.runtime-DNRtQzCk.js +0 -2
- package/dist/setup-api-CcolVVJs.js +0 -29
- package/dist/setup-core-eJD18F3B.js +0 -174
- package/dist/setup-surface-B75C2Qtz.js +0 -221
- package/dist/setup-surface-CFuPfVHp.js +0 -405
- package/dist/setup-surface-Dyy-Mzyz.js +0 -288
- package/dist/setup-surface-ZsVF_g8W.js +0 -320
- package/dist/shared-BkCNrcLX.js +0 -121
- package/dist/shared-client-B7zqC9p2.js +0 -2
- package/dist/shared-client-yXjKgZBz.js +0 -629
- package/dist/side-question-DU3gESCb.js +0 -683
- package/dist/skill-tool-dispatch.runtime-CPBuqyvk.js +0 -143
- package/dist/slash-state-Do3bAahA.js +0 -2166
- package/dist/speech-provider-Bg9los3C.js +0 -184
- package/dist/src-D7LzUctH.js +0 -4256
- package/dist/startup-context-CCF2gIOl.js +0 -313
- package/dist/status-subagents.runtime-DX5FTymp.js +0 -18
- package/dist/status-text-B-1u5dSV.js +0 -296
- package/dist/sticker-cache-DwpU_9RJ.js +0 -206
- package/dist/sticker-vision.runtime-Bbldi_YL.js +0 -17
- package/dist/subagent-announce-BCo0VHVL.js +0 -354
- package/dist/subagent-announce-delivery-JcnuDN_N.js +0 -958
- package/dist/subagent-control-BzbA3Suz.js +0 -508
- package/dist/subagent-hooks-BIGZQWrG.js +0 -2
- package/dist/subagent-hooks-Bj4qYZfv.js +0 -230
- package/dist/subagent-hooks-C-rvhVBv.js +0 -2
- package/dist/subagent-hooks-P01_AFl5.js +0 -116
- package/dist/subagent-hooks-VEfak8nl.js +0 -2
- package/dist/subagent-hooks-api-BPnSxxN4.js +0 -23
- package/dist/subagent-hooks-api-DwIAvMoS.js +0 -22
- package/dist/subagent-hooks-api-kgyR9FOb.js +0 -23
- package/dist/subagent-hooks-oED56wqq.js +0 -146
- package/dist/subagent-orphan-recovery-D79ZzwKN.js +0 -352
- package/dist/subagent-registry-D0soBT5j.js +0 -2351
- package/dist/subagent-registry-DRJDkmty.js +0 -3
- package/dist/subagent-session-cleanup-9eAO1aJe.js +0 -525
- package/dist/subagent-spawn-D80vbogm.js +0 -1164
- package/dist/target-id-COLv5LsJ.js +0 -107
- package/dist/targets-CDW5IQ6a.js +0 -44
- package/dist/targets-Ci6O1ZdP.js +0 -19
- package/dist/targets-CsaWFBg1.js +0 -19
- package/dist/testing-BoJit-h1.js +0 -267
- package/dist/thread-bindings-CGCvw0KT.js +0 -571
- package/dist/thread-bindings-ClCTNacX.js +0 -228
- package/dist/thread-bindings-DRb7BMZ6.js +0 -8
- package/dist/thread-bindings-Xc6smav0.js +0 -232
- package/dist/thread-bindings.discord-api-DC467oeF.js +0 -187
- package/dist/thread-bindings.manager-C_mpTDIZ.js +0 -536
- package/dist/thread-bindings.manager-DkCRs612.js +0 -2
- package/dist/thread-lifecycle-DpqCXlx9.js +0 -1614
- package/dist/token-CI6HjbTA.js +0 -134
- package/dist/tool-BMe7hjBK.js +0 -139
- package/dist/tool-actions.runtime-D-h5PI_m.js +0 -534
- package/dist/tool-resolution-CnLx0CHe.js +0 -149
- package/dist/tools-effective-inventory-BR6MUMtE.js +0 -204
- package/dist/tools-invoke-http-CTTs2yMT.js +0 -67
- package/dist/tools-invoke-shared-9B1EjXWf.js +0 -200
- package/dist/tts-eGOviZ5c.js +0 -66
- package/dist/tui-Bw0HqKd7.js +0 -4709
- package/dist/tui-CIZJnPzj.js +0 -2
- package/dist/tui-backend-BJ_r7tcF.js +0 -256
- package/dist/tui-cli-BaSMBpuA.js +0 -37
- package/dist/update-cli-zuCybGNR.js +0 -3664
- package/dist/update-runner-Dek2BHmQ.js +0 -2379
- package/dist/vision-tools-1ps0BEE5.js +0 -1409
- package/dist/web-search-B7EziZXE.js +0 -62
- package/dist/web-search-provider.runtime-DGTCvGch.js +0 -328
- package/dist/web-search-provider.runtime-DWL5t39M.js +0 -2
- package/dist/xai-oauth-CRtsj2Gs.js +0 -479
- package/dist/xai-user-agent-Dndwzw2S.js +0 -32
- /package/dist/{acp-runtime-backend-DSDBcyh9.js → acp-runtime-backend-Cxo7eBHf.js} +0 -0
- /package/dist/{channel-actions-FV66JqtI.js → channel-actions-UDeVjgGz.js} +0 -0
- /package/dist/{command-status-runtime-BRWKSoG7.js → command-status-runtime-CoHd4Fws.js} +0 -0
- /package/dist/{delegate-DGqKhwB4.js → delegate-B-2xZ77o.js} +0 -0
- /package/dist/{dispatch-acp-Ceoxja_Z.js → dispatch-acp-DLPkmK7K.js} +0 -0
- /package/dist/{heartbeat-runner-CJHvr5pG.js → heartbeat-runner-D2j6JwOI.js} +0 -0
- /package/dist/{library-Bq3aDek_.js → library-DBT0cIPP.js} +0 -0
- /package/dist/{run-executor.runtime-DNJhGPbA.js → run-executor.runtime-DE4J7f4M.js} +0 -0
- /package/dist/{shared-CYxmRpq1.js → shared-xeo8Yh5n.js} +0 -0
|
@@ -1,3664 +0,0 @@
|
|
|
1
|
-
import { a as normalizeLowercaseStringOrEmpty, c as normalizeOptionalString } from "./string-coerce-DyL154ka.js";
|
|
2
|
-
import { t as resolveDaoCorePackageRoot } from "./daocore-root-CYblIxyF.js";
|
|
3
|
-
import { d as resolveIncludeRoots, n as DEFAULT_GATEWAY_PORT, t as CONFIG_PATH, u as resolveGatewayPort } from "./paths-ZwPDM6zn.js";
|
|
4
|
-
import { n as resolveCliName, t as replaceCliName } from "./cli-name-jOXS5CgS.js";
|
|
5
|
-
import { t as formatCliCommand } from "./command-format-tWmMYcvZ.js";
|
|
6
|
-
import { t as formatDocsLink } from "./links-CM5vg8_V.js";
|
|
7
|
-
import { r as theme } from "./theme-D58JpUfy.js";
|
|
8
|
-
import { n as inheritOptionFromParent } from "./command-options-Dhjl7AMa.js";
|
|
9
|
-
import "./daemon-cli-DnahtAqj.js";
|
|
10
|
-
import { E as pathExists } from "./fs-safe-BFN3ftAo.js";
|
|
11
|
-
import { p as resolveUserPath, u as pathExists$1 } from "./utils-CNnMhEDp.js";
|
|
12
|
-
import { r as resolveConfigEnvVars } from "./env-substitution-D-Bqv65n.js";
|
|
13
|
-
import { i as GATEWAY_SERVICE_RUNTIME_PID_ENV, m as resolveGatewayWindowsTaskName, p as resolveGatewaySystemdServiceName, u as resolveGatewayLaunchAgentLabel } from "./constants-DZBCdcay.js";
|
|
14
|
-
import { i as resolveGatewayInstallEntrypoint } from "./gateway-entrypoint-Fvj9eT8J.js";
|
|
15
|
-
import { n as VERSION } from "./version-QmPt05QD.js";
|
|
16
|
-
import { a as resolveDefaultPluginNpmDir } from "./install-paths-wshgrJTh.js";
|
|
17
|
-
import { n as readPersistedInstalledPluginIndex } from "./installed-plugin-index-store-B5fUfQwG.js";
|
|
18
|
-
import { a as readJsonIfExists, m as writeJson } from "./json-files-D7wa8Ux4.js";
|
|
19
|
-
import { c as resolveEffectiveEnableState, s as normalizePluginsConfig } from "./config-state-FS_seYnZ.js";
|
|
20
|
-
import { t as loadInstalledPluginIndexInstallRecords } from "./installed-plugin-index-record-reader-DFAIDyGb.js";
|
|
21
|
-
import { o as resolvePackageExtensionEntries } from "./manifest-DbwIPpku.js";
|
|
22
|
-
import { r as validatePackageExtensionEntriesForInstall } from "./package-entry-resolution-ZpftJNrs.js";
|
|
23
|
-
import { n as defaultRuntime } from "./runtime-E_A14BX_.js";
|
|
24
|
-
import { a as parseSemver, i as nodeVersionSatisfiesEngine } from "./runtime-guard-CeaQ7tel.js";
|
|
25
|
-
import { c as resolveOfficialExternalPluginInstall, r as getOfficialExternalPluginCatalogManifest, t as getOfficialExternalPluginCatalogEntry } from "./official-external-plugin-catalog-D1DpizID.js";
|
|
26
|
-
import { t as loadPluginManifestRegistryForInstalledIndex } from "./manifest-registry-installed-ae6bsljP.js";
|
|
27
|
-
import { r as runCommandWithTimeout } from "./exec-PI-gh7wQ.js";
|
|
28
|
-
import { F as asResolvedSourceConfig, I as asRuntimeConfig, K as createPreUpdateConfigSnapshot, o as parseConfigJson5, p as readSourceConfigBestEffort, u as readConfigFileSnapshot } from "./io-Ct2JqgbR.js";
|
|
29
|
-
import { a as withPluginInstallRecords, o as withoutPluginInstallRecords } from "./installed-plugin-index-records-Dj6YXW_O.js";
|
|
30
|
-
import { a as resolveConfigIncludes } from "./includes-Dyyq3cbf.js";
|
|
31
|
-
import { n as formatConfigIssueLines } from "./issue-format-c8ezaSew.js";
|
|
32
|
-
import { n as assertConfigWriteAllowedInCurrentMode } from "./nix-mode-write-guard-BdS6kePT.js";
|
|
33
|
-
import { r as mutateConfigFileWithRetry } from "./mutate-DSZiMIjv.js";
|
|
34
|
-
import { n as quoteCmdScriptArg } from "./cmd-argv-fj4pRVR6.js";
|
|
35
|
-
import { r as getSelfAndAncestorPidsSync } from "./restart-stale-pids-Cq9Pey7h.js";
|
|
36
|
-
import { t as disableCurrentDaoCoreUpdateLaunchdJob } from "./launchd-Cubc47LE.js";
|
|
37
|
-
import { i as resolveGatewayRestartLogPath, n as renderPosixRestartLogSetup, o as shellEscapeRestartLogValue } from "./restart-logs-DHIuTlO-.js";
|
|
38
|
-
import "./config-CLrwLpl0.js";
|
|
39
|
-
import { i as resolveGatewayService, r as readGatewayServiceState } from "./service-BJz1apuv.js";
|
|
40
|
-
import { n as runDaemonInstall } from "./install-C5rX2pD-.js";
|
|
41
|
-
import { a as recoverInstalledLaunchAgent, t as runDaemonRestart } from "./lifecycle-CUksc9qU.js";
|
|
42
|
-
import { l as waitForGatewayHealthyRestart, o as renderRestartDiagnostics, s as terminateStaleGatewayPids } from "./restart-health-CBVKf_bz.js";
|
|
43
|
-
import { u as trimLogTail } from "./restart-sentinel-Du4en0Hw.js";
|
|
44
|
-
import { r as formatDurationPrecise } from "./format-duration-BrZ-AaEJ.js";
|
|
45
|
-
import { i as relinkDaoCorePeerDependenciesInManagedNpmRoot, n as auditDaoCorePeerDependencyLink } from "./plugin-peer-link-Bbj9bZaK.js";
|
|
46
|
-
import { n as stylePromptMessage } from "./prompt-style-DH7LpiPN.js";
|
|
47
|
-
import { t as formatHelpExamples } from "./help-format-DXVAk021.js";
|
|
48
|
-
import { r as commitPluginInstallRecordsWithConfig } from "./plugins-install-record-commit-CvOVXj8a.js";
|
|
49
|
-
import { t as refreshPluginRegistryAfterConfigMutation } from "./plugins-registry-refresh-Cpz52Ojd.js";
|
|
50
|
-
import { c as resolveEffectiveUpdateChannel, i as formatUpdateChannelLabel, l as resolveRegistryUpdateChannel, r as channelToNpmTag, s as normalizeUpdateChannel, u as resolveUpdateChannelDisplay } from "./update-channels-f-ieRme5.js";
|
|
51
|
-
import { a as installCompletion, n as COMPLETION_SKIP_PLUGIN_COMMANDS_ENV } from "./completion-runtime-BfGS2hGl.js";
|
|
52
|
-
import { n as renderTable, t as getTerminalTableWidth } from "./table-CgadVAEi.js";
|
|
53
|
-
import { i as updateNpmInstalledPlugins, n as resolveTrustedSourceLinkedOfficialNpmSpec, r as syncPluginsForUpdateChannel, t as resolveTrustedSourceLinkedOfficialClawHubSpec } from "./update-0l69uuvk.js";
|
|
54
|
-
import { n as readPackageName, r as readPackageVersion } from "./package-json-CIZcDaQ6.js";
|
|
55
|
-
import { i as fetchNpmTagVersion, n as compareSemverStrings, o as resolveNpmChannelTag, r as fetchNpmPackageTargetStatus, t as checkUpdateStatus } from "./update-check-Cv1EQVBi.js";
|
|
56
|
-
import { i as resolveUpdateAvailability, n as formatUpdateOneLiner, t as formatUpdateAvailableHint } from "./status.update-BQyHDWCY.js";
|
|
57
|
-
import { a as cleanupGlobalRenameDirs, c as detectGlobalInstallManagerForRoot, d as resolveGlobalInstallTarget, f as resolvePnpmGlobalDirFromGlobalRoot, i as canResolveRegistryVersionForPackageTarget, l as globalInstallArgs, n as runGatewayUpdate, o as createGlobalInstallEnv, p as normalizePackageTagInput, r as runGlobalPackageUpdateSteps, s as detectGlobalInstallManagerByPresence, u as resolveGlobalInstallSpec } from "./update-runner-Dek2BHmQ.js";
|
|
58
|
-
import { r as ensureCompletionCacheExists, t as checkShellCompletionStatus } from "./doctor-completion-pyXXj4oL.js";
|
|
59
|
-
import { t as doctorCommand } from "./doctor-BfkGBii1.js";
|
|
60
|
-
import { n as UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE_ENV, r as UPDATE_POST_CORE_CONVERGENCE_ENV, t as UPDATE_DEFER_CONFIGURED_PLUGIN_INSTALL_REPAIR_ENV } from "./update-phase-ueCdL5Fr.js";
|
|
61
|
-
import { t as summarizeGatewayServiceLayout } from "./service-layout-EdjNiu4j.js";
|
|
62
|
-
import { c as writeControlPlaneUpdateRestartSentinel, i as buildControlPlaneUpdateRestartHealthPendingResult, o as markControlPlaneUpdateRestartSentinelFailure, s as readControlPlaneUpdateSentinelMeta } from "./update-control-plane-sentinel-CHlpYBPO.js";
|
|
63
|
-
import { n as cleanupStaleManagedServiceUpdateHandoffs } from "./update-managed-service-handoff-cleanup-PGMcTNLe.js";
|
|
64
|
-
import { t as repairMissingConfiguredPluginInstalls } from "./missing-configured-plugin-install-CmkDxaVY.js";
|
|
65
|
-
import { n as pruneStaleLocalBundledPluginInstallRecords } from "./stale-local-bundled-plugin-install-records-Dr_9Wj4z.js";
|
|
66
|
-
import { t as selectStyled } from "./prompt-select-styled-Cp6-dKuR.js";
|
|
67
|
-
import fs, { existsSync } from "node:fs";
|
|
68
|
-
import path from "node:path";
|
|
69
|
-
import fs$1 from "node:fs/promises";
|
|
70
|
-
import os from "node:os";
|
|
71
|
-
import { execFile, spawn, spawnSync } from "node:child_process";
|
|
72
|
-
import { Writable } from "node:stream";
|
|
73
|
-
import { confirm, isCancel, spinner } from "@clack/prompts";
|
|
74
|
-
//#region src/cli/update-cli/shared.ts
|
|
75
|
-
const INVALID_TIMEOUT_ERROR = "--timeout must be a positive integer (seconds)";
|
|
76
|
-
function parseTimeoutMsOrExit(timeout) {
|
|
77
|
-
if (timeout === void 0) return;
|
|
78
|
-
const trimmed = timeout.trim();
|
|
79
|
-
const seconds = Number(trimmed);
|
|
80
|
-
if (!/^\d+$/u.test(trimmed) || !Number.isSafeInteger(seconds) || seconds <= 0) {
|
|
81
|
-
defaultRuntime.error(INVALID_TIMEOUT_ERROR);
|
|
82
|
-
defaultRuntime.exit(1);
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
return seconds * 1e3;
|
|
86
|
-
}
|
|
87
|
-
const DAOCORE_REPO_URL = "https://github.com/openclaw/openclaw.git";
|
|
88
|
-
const MAX_LOG_CHARS = 8e3;
|
|
89
|
-
const DEFAULT_PACKAGE_NAME = "@gaodefa/daocore";
|
|
90
|
-
const CORE_PACKAGE_NAMES = new Set([DEFAULT_PACKAGE_NAME]);
|
|
91
|
-
function normalizeTag(value) {
|
|
92
|
-
return normalizePackageTagInput(value, ["daocore", DEFAULT_PACKAGE_NAME]);
|
|
93
|
-
}
|
|
94
|
-
function normalizeVersionTag(tag) {
|
|
95
|
-
const trimmed = tag.trim();
|
|
96
|
-
if (!trimmed) return null;
|
|
97
|
-
const cleaned = trimmed.startsWith("v") ? trimmed.slice(1) : trimmed;
|
|
98
|
-
return parseSemver(cleaned) ? cleaned : null;
|
|
99
|
-
}
|
|
100
|
-
async function resolveTargetVersion(tag, timeoutMs) {
|
|
101
|
-
if (!canResolveRegistryVersionForPackageTarget(tag)) return null;
|
|
102
|
-
const direct = normalizeVersionTag(tag);
|
|
103
|
-
if (direct) return direct;
|
|
104
|
-
return (await fetchNpmTagVersion({
|
|
105
|
-
tag,
|
|
106
|
-
timeoutMs
|
|
107
|
-
})).version ?? null;
|
|
108
|
-
}
|
|
109
|
-
async function isGitCheckout(root) {
|
|
110
|
-
try {
|
|
111
|
-
await fs$1.stat(path.join(root, ".git"));
|
|
112
|
-
return true;
|
|
113
|
-
} catch {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
async function isCorePackage(root) {
|
|
118
|
-
const name = await readPackageName(root);
|
|
119
|
-
return Boolean(name && CORE_PACKAGE_NAMES.has(name));
|
|
120
|
-
}
|
|
121
|
-
async function isEmptyDir(targetPath) {
|
|
122
|
-
try {
|
|
123
|
-
return (await fs$1.readdir(targetPath)).length === 0;
|
|
124
|
-
} catch {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function resolveGitInstallDir() {
|
|
129
|
-
const override = process.env.DAOCORE_GIT_DIR?.trim();
|
|
130
|
-
if (override) return path.resolve(override);
|
|
131
|
-
return resolveDefaultGitDir();
|
|
132
|
-
}
|
|
133
|
-
function resolveDefaultGitDir() {
|
|
134
|
-
const home = os.homedir();
|
|
135
|
-
if (home.startsWith("/")) return path.posix.join(home, "daocore");
|
|
136
|
-
return path.join(home, "daocore");
|
|
137
|
-
}
|
|
138
|
-
function resolveNodeRunner() {
|
|
139
|
-
const base = normalizeLowercaseStringOrEmpty(path.basename(process.execPath));
|
|
140
|
-
if (base === "node" || base === "node.exe") return process.execPath;
|
|
141
|
-
return "node";
|
|
142
|
-
}
|
|
143
|
-
async function resolveUpdateRoot() {
|
|
144
|
-
return await resolveDaoCorePackageRoot({
|
|
145
|
-
moduleUrl: import.meta.url,
|
|
146
|
-
argv1: process.argv[1],
|
|
147
|
-
cwd: process.cwd()
|
|
148
|
-
}) ?? process.cwd();
|
|
149
|
-
}
|
|
150
|
-
async function runUpdateStep(params) {
|
|
151
|
-
const command = params.argv.join(" ");
|
|
152
|
-
params.progress?.onStepStart?.({
|
|
153
|
-
name: params.name,
|
|
154
|
-
command,
|
|
155
|
-
index: 0,
|
|
156
|
-
total: 0
|
|
157
|
-
});
|
|
158
|
-
const started = Date.now();
|
|
159
|
-
const res = await runCommandWithTimeout(params.argv, {
|
|
160
|
-
cwd: params.cwd,
|
|
161
|
-
env: params.env,
|
|
162
|
-
timeoutMs: params.timeoutMs
|
|
163
|
-
});
|
|
164
|
-
const durationMs = Date.now() - started;
|
|
165
|
-
const stderrTail = trimLogTail(res.stderr, MAX_LOG_CHARS);
|
|
166
|
-
params.progress?.onStepComplete?.({
|
|
167
|
-
name: params.name,
|
|
168
|
-
command,
|
|
169
|
-
index: 0,
|
|
170
|
-
total: 0,
|
|
171
|
-
durationMs,
|
|
172
|
-
exitCode: res.code,
|
|
173
|
-
stderrTail
|
|
174
|
-
});
|
|
175
|
-
return {
|
|
176
|
-
name: params.name,
|
|
177
|
-
command,
|
|
178
|
-
cwd: params.cwd ?? process.cwd(),
|
|
179
|
-
durationMs,
|
|
180
|
-
exitCode: res.code,
|
|
181
|
-
stdoutTail: trimLogTail(res.stdout, MAX_LOG_CHARS),
|
|
182
|
-
stderrTail
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
async function ensureGitCheckout(params) {
|
|
186
|
-
const gitEnv = params.env ?? await createGlobalInstallEnv();
|
|
187
|
-
if (!await pathExists$1(params.dir)) return await runUpdateStep({
|
|
188
|
-
name: "git clone",
|
|
189
|
-
argv: [
|
|
190
|
-
"git",
|
|
191
|
-
"clone",
|
|
192
|
-
DAOCORE_REPO_URL,
|
|
193
|
-
params.dir
|
|
194
|
-
],
|
|
195
|
-
env: gitEnv,
|
|
196
|
-
timeoutMs: params.timeoutMs,
|
|
197
|
-
progress: params.progress
|
|
198
|
-
});
|
|
199
|
-
if (!await isGitCheckout(params.dir)) {
|
|
200
|
-
if (!await isEmptyDir(params.dir)) throw new Error(`DAOCORE_GIT_DIR points at a non-git directory: ${params.dir}. Set DAOCORE_GIT_DIR to an empty folder or an daocore checkout.`);
|
|
201
|
-
return await runUpdateStep({
|
|
202
|
-
name: "git clone",
|
|
203
|
-
argv: [
|
|
204
|
-
"git",
|
|
205
|
-
"clone",
|
|
206
|
-
DAOCORE_REPO_URL,
|
|
207
|
-
params.dir
|
|
208
|
-
],
|
|
209
|
-
cwd: params.dir,
|
|
210
|
-
env: gitEnv,
|
|
211
|
-
timeoutMs: params.timeoutMs,
|
|
212
|
-
progress: params.progress
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
if (!await isCorePackage(params.dir)) throw new Error(`DAOCORE_GIT_DIR does not look like a core checkout: ${params.dir}.`);
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
async function resolveGlobalManager(params) {
|
|
219
|
-
const runCommand = createGlobalCommandRunner();
|
|
220
|
-
if (params.installKind === "package") {
|
|
221
|
-
const detected = await detectGlobalInstallManagerForRoot(runCommand, params.root, params.timeoutMs);
|
|
222
|
-
if (detected) return detected;
|
|
223
|
-
}
|
|
224
|
-
return await detectGlobalInstallManagerByPresence(runCommand, params.timeoutMs) ?? "npm";
|
|
225
|
-
}
|
|
226
|
-
const COMPLETION_CACHE_WRITE_TIMEOUT_MS = 3e4;
|
|
227
|
-
const COMPLETION_CACHE_MANUAL_REFRESH_HINT = "Shell tab-completion may be stale; refresh manually with: daocore completion --write-state";
|
|
228
|
-
async function tryWriteCompletionCache(root, jsonMode) {
|
|
229
|
-
const binPath = path.join(root, "daocore.mjs");
|
|
230
|
-
if (!await pathExists$1(binPath)) return;
|
|
231
|
-
const result = spawnSync(resolveNodeRunner(), [
|
|
232
|
-
binPath,
|
|
233
|
-
"completion",
|
|
234
|
-
"--write-state"
|
|
235
|
-
], {
|
|
236
|
-
cwd: root,
|
|
237
|
-
env: {
|
|
238
|
-
...process.env,
|
|
239
|
-
[COMPLETION_SKIP_PLUGIN_COMMANDS_ENV]: "1"
|
|
240
|
-
},
|
|
241
|
-
encoding: "utf-8",
|
|
242
|
-
timeout: COMPLETION_CACHE_WRITE_TIMEOUT_MS
|
|
243
|
-
});
|
|
244
|
-
if (result.error) {
|
|
245
|
-
if (!jsonMode) {
|
|
246
|
-
const reason = result.error.code === "ETIMEDOUT" ? `timed out after ${COMPLETION_CACHE_WRITE_TIMEOUT_MS / 1e3}s` : String(result.error);
|
|
247
|
-
defaultRuntime.log(theme.warn(`Completion cache update failed: ${reason}. ${COMPLETION_CACHE_MANUAL_REFRESH_HINT}`));
|
|
248
|
-
}
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
if (result.status !== 0 && !jsonMode) {
|
|
252
|
-
const stderr = (result.stderr ?? "").trim();
|
|
253
|
-
const detail = stderr ? ` (${stderr})` : "";
|
|
254
|
-
defaultRuntime.log(theme.warn(`Completion cache update failed${detail}. ${COMPLETION_CACHE_MANUAL_REFRESH_HINT}`));
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
function createGlobalCommandRunner() {
|
|
258
|
-
return async (argv, options) => {
|
|
259
|
-
const res = await runCommandWithTimeout(argv, options);
|
|
260
|
-
return {
|
|
261
|
-
stdout: res.stdout,
|
|
262
|
-
stderr: res.stderr,
|
|
263
|
-
code: res.code
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region src/cli/update-cli/status.ts
|
|
269
|
-
function formatGitStatusLine(params) {
|
|
270
|
-
const shortSha = params.sha ? params.sha.slice(0, 8) : null;
|
|
271
|
-
const branch = params.branch && params.branch !== "HEAD" ? params.branch : null;
|
|
272
|
-
const tag = params.tag;
|
|
273
|
-
return [
|
|
274
|
-
branch ?? (tag ? "detached" : "git"),
|
|
275
|
-
tag ? `tag ${tag}` : null,
|
|
276
|
-
shortSha ? `@ ${shortSha}` : null
|
|
277
|
-
].filter(Boolean).join(" · ");
|
|
278
|
-
}
|
|
279
|
-
async function updateStatusCommand(opts) {
|
|
280
|
-
const timeoutMs = parseTimeoutMsOrExit(opts.timeout);
|
|
281
|
-
if (timeoutMs === null) return;
|
|
282
|
-
const root = await resolveUpdateRoot();
|
|
283
|
-
const configChannel = normalizeUpdateChannel((await readSourceConfigBestEffort()).update?.channel);
|
|
284
|
-
const update = await checkUpdateStatus({
|
|
285
|
-
root,
|
|
286
|
-
timeoutMs: timeoutMs ?? 3500,
|
|
287
|
-
fetchGit: true,
|
|
288
|
-
includeRegistry: true,
|
|
289
|
-
registryChannel: resolveRegistryUpdateChannel({
|
|
290
|
-
configChannel,
|
|
291
|
-
currentVersion: VERSION
|
|
292
|
-
})
|
|
293
|
-
});
|
|
294
|
-
const channelInfo = resolveUpdateChannelDisplay({
|
|
295
|
-
configChannel,
|
|
296
|
-
currentVersion: VERSION,
|
|
297
|
-
installKind: update.installKind,
|
|
298
|
-
gitTag: update.git?.tag ?? null,
|
|
299
|
-
gitBranch: update.git?.branch ?? null
|
|
300
|
-
});
|
|
301
|
-
const channelLabel = channelInfo.label;
|
|
302
|
-
const gitLabel = update.installKind === "git" ? formatGitStatusLine({
|
|
303
|
-
branch: update.git?.branch ?? null,
|
|
304
|
-
tag: update.git?.tag ?? null,
|
|
305
|
-
sha: update.git?.sha ?? null
|
|
306
|
-
}) : null;
|
|
307
|
-
const updateAvailability = resolveUpdateAvailability(update);
|
|
308
|
-
const updateLine = formatUpdateOneLiner(update).replace(/^Update:\s*/i, "");
|
|
309
|
-
if (opts.json) {
|
|
310
|
-
defaultRuntime.writeJson({
|
|
311
|
-
update,
|
|
312
|
-
channel: {
|
|
313
|
-
value: channelInfo.channel,
|
|
314
|
-
source: channelInfo.source,
|
|
315
|
-
label: channelLabel,
|
|
316
|
-
config: configChannel
|
|
317
|
-
},
|
|
318
|
-
availability: updateAvailability
|
|
319
|
-
});
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
const tableWidth = getTerminalTableWidth();
|
|
323
|
-
const rows = [
|
|
324
|
-
{
|
|
325
|
-
Item: "Install",
|
|
326
|
-
Value: update.installKind === "git" ? `git (${update.root ?? "unknown"})` : update.installKind === "package" ? update.packageManager : "unknown"
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
Item: "Channel",
|
|
330
|
-
Value: channelLabel
|
|
331
|
-
},
|
|
332
|
-
...gitLabel ? [{
|
|
333
|
-
Item: "Git",
|
|
334
|
-
Value: gitLabel
|
|
335
|
-
}] : [],
|
|
336
|
-
{
|
|
337
|
-
Item: "Update",
|
|
338
|
-
Value: updateAvailability.available ? theme.warn(`available · ${updateLine}`) : updateLine
|
|
339
|
-
}
|
|
340
|
-
];
|
|
341
|
-
defaultRuntime.log(theme.heading("DaoCore update status"));
|
|
342
|
-
defaultRuntime.log("");
|
|
343
|
-
defaultRuntime.log(renderTable({
|
|
344
|
-
width: tableWidth,
|
|
345
|
-
columns: [{
|
|
346
|
-
key: "Item",
|
|
347
|
-
header: "Item",
|
|
348
|
-
minWidth: 10
|
|
349
|
-
}, {
|
|
350
|
-
key: "Value",
|
|
351
|
-
header: "Value",
|
|
352
|
-
flex: true,
|
|
353
|
-
minWidth: 24
|
|
354
|
-
}],
|
|
355
|
-
rows
|
|
356
|
-
}).trimEnd());
|
|
357
|
-
defaultRuntime.log("");
|
|
358
|
-
const updateHint = formatUpdateAvailableHint(update);
|
|
359
|
-
if (updateHint) defaultRuntime.log(theme.warn(updateHint));
|
|
360
|
-
}
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region src/infra/disk-space.ts
|
|
363
|
-
const LOW_DISK_SPACE_WARNING_THRESHOLD_BYTES = 1024 * 1024 * 1024;
|
|
364
|
-
function finiteNonNegativeNumber(value) {
|
|
365
|
-
const numberValue = Number(value);
|
|
366
|
-
return Number.isFinite(numberValue) && numberValue >= 0 ? numberValue : null;
|
|
367
|
-
}
|
|
368
|
-
function findExistingDiskSpacePath(targetPath) {
|
|
369
|
-
let current = path.resolve(targetPath);
|
|
370
|
-
while (true) try {
|
|
371
|
-
return fs.statSync(current).isDirectory() ? current : path.dirname(current);
|
|
372
|
-
} catch {
|
|
373
|
-
const parent = path.dirname(current);
|
|
374
|
-
if (parent === current) return null;
|
|
375
|
-
current = parent;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
function tryReadDiskSpace(targetPath) {
|
|
379
|
-
if (typeof fs.statfsSync !== "function") return null;
|
|
380
|
-
const checkedPath = findExistingDiskSpacePath(targetPath);
|
|
381
|
-
if (!checkedPath) return null;
|
|
382
|
-
try {
|
|
383
|
-
const stats = fs.statfsSync(checkedPath);
|
|
384
|
-
const blockSize = finiteNonNegativeNumber(stats.bsize);
|
|
385
|
-
const availableBlocks = finiteNonNegativeNumber(stats.bavail);
|
|
386
|
-
if (blockSize === null || availableBlocks === null) return null;
|
|
387
|
-
const totalBlocks = finiteNonNegativeNumber(stats.blocks);
|
|
388
|
-
return {
|
|
389
|
-
targetPath,
|
|
390
|
-
checkedPath,
|
|
391
|
-
availableBytes: blockSize * availableBlocks,
|
|
392
|
-
totalBytes: totalBlocks === null ? null : blockSize * totalBlocks
|
|
393
|
-
};
|
|
394
|
-
} catch {
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
function formatDiskSpaceBytes(bytes) {
|
|
399
|
-
const mib = bytes / (1024 * 1024);
|
|
400
|
-
if (mib < 1024) return `${Math.max(0, Math.round(mib))} MiB`;
|
|
401
|
-
const gib = mib / 1024;
|
|
402
|
-
return `${gib.toFixed(gib < 10 ? 1 : 0)} GiB`;
|
|
403
|
-
}
|
|
404
|
-
function createLowDiskSpaceWarning(params) {
|
|
405
|
-
const thresholdBytes = params.thresholdBytes ?? LOW_DISK_SPACE_WARNING_THRESHOLD_BYTES;
|
|
406
|
-
const snapshot = tryReadDiskSpace(params.targetPath);
|
|
407
|
-
if (!snapshot || snapshot.availableBytes >= thresholdBytes) return null;
|
|
408
|
-
return `Low disk space near ${path.resolve(snapshot.targetPath) === path.resolve(snapshot.checkedPath) ? snapshot.checkedPath : `${snapshot.targetPath} (volume checked at ${snapshot.checkedPath})`}: ${formatDiskSpaceBytes(snapshot.availableBytes)} available; ${params.purpose} may fail.`;
|
|
409
|
-
}
|
|
410
|
-
//#endregion
|
|
411
|
-
//#region src/cli/plugins-location-bridges.ts
|
|
412
|
-
function buildBridgeFromPersistedBundledRecord(record, manifest) {
|
|
413
|
-
if (record.origin !== "bundled" || !record.enabled) return null;
|
|
414
|
-
const officialEntry = getOfficialExternalPluginCatalogEntry(record.pluginId);
|
|
415
|
-
const officialInstall = officialEntry ? resolveOfficialExternalPluginInstall(officialEntry) : null;
|
|
416
|
-
const npmSpec = officialInstall?.npmSpec?.trim() ?? record.packageInstall?.npm?.spec;
|
|
417
|
-
const clawhubSpec = officialInstall?.clawhubSpec?.trim();
|
|
418
|
-
if (!npmSpec && !clawhubSpec) return null;
|
|
419
|
-
const officialChannelId = officialEntry ? getOfficialExternalPluginCatalogManifest(officialEntry)?.channel?.id?.trim() : void 0;
|
|
420
|
-
const channelIds = manifest?.channels.length ? manifest.channels : officialChannelId ? [officialChannelId] : [];
|
|
421
|
-
return {
|
|
422
|
-
bundledPluginId: record.pluginId,
|
|
423
|
-
pluginId: record.pluginId,
|
|
424
|
-
preferredSource: officialInstall?.defaultChoice === "clawhub" && clawhubSpec ? "clawhub" : "npm",
|
|
425
|
-
...npmSpec ? { npmSpec } : {},
|
|
426
|
-
...clawhubSpec ? { clawhubSpec } : {},
|
|
427
|
-
...record.enabledByDefault ? { enabledByDefault: true } : {},
|
|
428
|
-
...channelIds.length ? { channelIds } : {}
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
async function listPersistedBundledPluginLocationBridges(options) {
|
|
432
|
-
const index = await readPersistedInstalledPluginIndex(options);
|
|
433
|
-
if (!index) return [];
|
|
434
|
-
const manifestRegistry = loadPluginManifestRegistryForInstalledIndex({
|
|
435
|
-
index,
|
|
436
|
-
workspaceDir: options.workspaceDir,
|
|
437
|
-
env: options.env,
|
|
438
|
-
includeDisabled: true
|
|
439
|
-
});
|
|
440
|
-
const manifestByPluginId = new Map(manifestRegistry.plugins.map((plugin) => [plugin.id, plugin]));
|
|
441
|
-
return index.plugins.flatMap((record) => {
|
|
442
|
-
const bridge = buildBridgeFromPersistedBundledRecord(record, manifestByPluginId.get(record.pluginId));
|
|
443
|
-
return bridge ? [bridge] : [];
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
//#endregion
|
|
447
|
-
//#region src/cli/update-cli/plugin-payload-validation.ts
|
|
448
|
-
const TRACKED_SOURCES = new Set([
|
|
449
|
-
"npm",
|
|
450
|
-
"clawhub",
|
|
451
|
-
"git",
|
|
452
|
-
"marketplace"
|
|
453
|
-
]);
|
|
454
|
-
/**
|
|
455
|
-
* Verify that each tracked plugin install record on disk is structurally
|
|
456
|
-
* loadable: the install dir exists, contains a parseable `package.json`,
|
|
457
|
-
* and any declared package entry files exist.
|
|
458
|
-
*
|
|
459
|
-
* IMPORTANT: this is intentionally a *static* check. We do NOT execute the
|
|
460
|
-
* plugin's code, so post-update side effects (network calls, filesystem
|
|
461
|
-
* writes, registry registration) cannot fire while the gateway is still
|
|
462
|
-
* stopped. The goal is to catch obvious payload corruption — missing files,
|
|
463
|
-
* unparseable manifests — before we hand control back to the restart path.
|
|
464
|
-
*/
|
|
465
|
-
async function runPluginPayloadSmokeCheck(params) {
|
|
466
|
-
const checked = [];
|
|
467
|
-
const failures = [];
|
|
468
|
-
for (const [pluginId, record] of Object.entries(params.records).toSorted(([a], [b]) => a.localeCompare(b))) {
|
|
469
|
-
if (!record || typeof record !== "object" || !TRACKED_SOURCES.has(record.source)) continue;
|
|
470
|
-
const rawInstallPath = typeof record.installPath === "string" ? record.installPath.trim() : "";
|
|
471
|
-
if (!rawInstallPath) {
|
|
472
|
-
checked.push(pluginId);
|
|
473
|
-
failures.push({
|
|
474
|
-
pluginId,
|
|
475
|
-
reason: "missing-install-path",
|
|
476
|
-
detail: "Install path is missing from the plugin install record."
|
|
477
|
-
});
|
|
478
|
-
continue;
|
|
479
|
-
}
|
|
480
|
-
const installPath = resolveUserPath(rawInstallPath, params.env);
|
|
481
|
-
checked.push(pluginId);
|
|
482
|
-
if (!(await safeStat(installPath))?.isDirectory()) {
|
|
483
|
-
failures.push({
|
|
484
|
-
pluginId,
|
|
485
|
-
installPath,
|
|
486
|
-
reason: "missing-package-dir",
|
|
487
|
-
detail: `Install dir is missing: ${installPath}`
|
|
488
|
-
});
|
|
489
|
-
continue;
|
|
490
|
-
}
|
|
491
|
-
const packageJsonPath = path.join(installPath, "package.json");
|
|
492
|
-
if (!(await safeStat(packageJsonPath))?.isFile()) {
|
|
493
|
-
failures.push({
|
|
494
|
-
pluginId,
|
|
495
|
-
installPath,
|
|
496
|
-
reason: "missing-package-json",
|
|
497
|
-
detail: `package.json is missing under ${installPath}`
|
|
498
|
-
});
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
let manifest;
|
|
502
|
-
try {
|
|
503
|
-
manifest = JSON.parse(await fs$1.readFile(packageJsonPath, "utf8"));
|
|
504
|
-
} catch (err) {
|
|
505
|
-
failures.push({
|
|
506
|
-
pluginId,
|
|
507
|
-
installPath,
|
|
508
|
-
reason: "invalid-package-json",
|
|
509
|
-
detail: `Could not parse package.json: ${err instanceof Error ? err.message : String(err)}`
|
|
510
|
-
});
|
|
511
|
-
continue;
|
|
512
|
-
}
|
|
513
|
-
if (manifestDeclaresDaoCorePeer(manifest)) {
|
|
514
|
-
const peerIssue = await auditDaoCorePeerDependencyLink({
|
|
515
|
-
packageDir: installPath,
|
|
516
|
-
packageName: manifest.name ?? pluginId
|
|
517
|
-
});
|
|
518
|
-
if (peerIssue) failures.push({
|
|
519
|
-
pluginId,
|
|
520
|
-
installPath,
|
|
521
|
-
reason: "missing-daocore-peer-link",
|
|
522
|
-
detail: `Plugin declares peerDependency "daocore" but peer link audit failed: ${peerIssue.reason}.`
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
const extensionResolution = resolvePackageExtensionEntries(manifest);
|
|
526
|
-
if (extensionResolution.status === "invalid" || extensionResolution.status === "empty") failures.push({
|
|
527
|
-
pluginId,
|
|
528
|
-
installPath,
|
|
529
|
-
reason: "missing-extension-entry",
|
|
530
|
-
detail: `Plugin extension entry validation failed: ${extensionResolution.status === "invalid" ? extensionResolution.error : "package.json daocore.extensions is empty"}`
|
|
531
|
-
});
|
|
532
|
-
else if (extensionResolution.status === "ok") {
|
|
533
|
-
const extensionValidation = await validatePackageExtensionEntriesForInstall({
|
|
534
|
-
packageDir: installPath,
|
|
535
|
-
extensions: extensionResolution.entries,
|
|
536
|
-
manifest
|
|
537
|
-
});
|
|
538
|
-
if (!extensionValidation.ok) failures.push({
|
|
539
|
-
pluginId,
|
|
540
|
-
installPath,
|
|
541
|
-
reason: "missing-extension-entry",
|
|
542
|
-
detail: `Plugin extension entry validation failed: ${extensionValidation.error}`
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
if (typeof manifest.main !== "string" || !manifest.main.trim()) continue;
|
|
546
|
-
const mainRel = manifest.main.trim();
|
|
547
|
-
const mainPath = path.join(installPath, mainRel);
|
|
548
|
-
if (!(await safeStat(mainPath))?.isFile()) failures.push({
|
|
549
|
-
pluginId,
|
|
550
|
-
installPath,
|
|
551
|
-
reason: "missing-main-entry",
|
|
552
|
-
detail: `Plugin main entry "${mainRel}" not found at ${mainPath}`
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
return {
|
|
556
|
-
checked,
|
|
557
|
-
failures
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
function manifestDeclaresDaoCorePeer(manifest) {
|
|
561
|
-
const peerDependencies = manifest.peerDependencies;
|
|
562
|
-
return typeof peerDependencies === "object" && peerDependencies !== null && !Array.isArray(peerDependencies) && typeof peerDependencies.daocore === "string";
|
|
563
|
-
}
|
|
564
|
-
async function safeStat(target) {
|
|
565
|
-
try {
|
|
566
|
-
return await fs$1.stat(target);
|
|
567
|
-
} catch {
|
|
568
|
-
return null;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
//#endregion
|
|
572
|
-
//#region src/cli/update-cli/post-core-plugin-convergence.ts
|
|
573
|
-
const REPAIR_GUIDANCE = "Run `daocore doctor --fix` to retry plugin repair.";
|
|
574
|
-
const inspectGuidance = (pluginId) => `Run \`daocore plugins inspect ${pluginId} --runtime --json\` for details.`;
|
|
575
|
-
async function repairManagedNpmDaoCorePeerLinks(params) {
|
|
576
|
-
try {
|
|
577
|
-
const result = await relinkDaoCorePeerDependenciesInManagedNpmRoot({
|
|
578
|
-
npmRoot: resolveDefaultPluginNpmDir(params.env),
|
|
579
|
-
logger: {}
|
|
580
|
-
});
|
|
581
|
-
return {
|
|
582
|
-
changes: result.repaired > 0 ? [`Repaired DaoCore host peer link(s) for ${result.repaired} managed npm plugin package(s).`] : [],
|
|
583
|
-
warnings: []
|
|
584
|
-
};
|
|
585
|
-
} catch (err) {
|
|
586
|
-
const message = `Failed to repair managed npm DaoCore host peer links: ${err instanceof Error ? err.message : String(err)}`;
|
|
587
|
-
return {
|
|
588
|
-
changes: [],
|
|
589
|
-
warnings: [{
|
|
590
|
-
reason: message,
|
|
591
|
-
message,
|
|
592
|
-
guidance: [REPAIR_GUIDANCE]
|
|
593
|
-
}]
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Mandatory post-core convergence pass. Runs AFTER the core package files
|
|
599
|
-
* are swapped and the in-update doctor pass has already returned, but BEFORE
|
|
600
|
-
* the gateway is restarted. Failures here must block the restart so we
|
|
601
|
-
* never restart with a configured plugin whose payload is unloadable.
|
|
602
|
-
*/
|
|
603
|
-
async function runPostCorePluginConvergence(params) {
|
|
604
|
-
const env = {
|
|
605
|
-
...params.env,
|
|
606
|
-
DAOCORE_COMPATIBILITY_HOST_VERSION: VERSION,
|
|
607
|
-
[UPDATE_POST_CORE_CONVERGENCE_ENV]: "1"
|
|
608
|
-
};
|
|
609
|
-
const prunedBaseline = params.baselineInstallRecords ? pruneStaleLocalBundledPluginInstallRecords({
|
|
610
|
-
installRecords: params.baselineInstallRecords,
|
|
611
|
-
env
|
|
612
|
-
}) : null;
|
|
613
|
-
const repair = await repairMissingConfiguredPluginInstalls({
|
|
614
|
-
cfg: params.cfg,
|
|
615
|
-
env,
|
|
616
|
-
...prunedBaseline ? { baselineRecords: prunedBaseline.records } : {}
|
|
617
|
-
});
|
|
618
|
-
const warnings = repair.warnings.map((message) => ({
|
|
619
|
-
reason: message,
|
|
620
|
-
message,
|
|
621
|
-
guidance: [REPAIR_GUIDANCE]
|
|
622
|
-
}));
|
|
623
|
-
const peerLinkRepair = await repairManagedNpmDaoCorePeerLinks({ env });
|
|
624
|
-
warnings.push(...peerLinkRepair.warnings);
|
|
625
|
-
const records = repair.records;
|
|
626
|
-
const smoke = await runPluginPayloadSmokeCheck({
|
|
627
|
-
records: filterRecordsToActive({
|
|
628
|
-
cfg: params.cfg,
|
|
629
|
-
records
|
|
630
|
-
}),
|
|
631
|
-
env
|
|
632
|
-
});
|
|
633
|
-
for (const failure of smoke.failures) warnings.push({
|
|
634
|
-
pluginId: failure.pluginId,
|
|
635
|
-
reason: `${failure.reason}: ${failure.detail}`,
|
|
636
|
-
message: `Plugin "${failure.pluginId}" failed post-core payload smoke check (${failure.reason}): ${failure.detail}`,
|
|
637
|
-
guidance: [REPAIR_GUIDANCE, inspectGuidance(failure.pluginId)]
|
|
638
|
-
});
|
|
639
|
-
return {
|
|
640
|
-
changes: [
|
|
641
|
-
...prunedBaseline?.stale.map((record) => `Removed stale local bundled plugin install record "${record.pluginId}".`) ?? [],
|
|
642
|
-
...repair.changes,
|
|
643
|
-
...peerLinkRepair.changes
|
|
644
|
-
],
|
|
645
|
-
warnings,
|
|
646
|
-
errored: warnings.length > 0,
|
|
647
|
-
smokeFailures: smoke.failures,
|
|
648
|
-
installRecords: records
|
|
649
|
-
};
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* Drop install records that the gateway would never activate: disabled
|
|
653
|
-
* plugin entries, plugins listed in `plugins.deny`, etc. Records that
|
|
654
|
-
* resolve as a trusted-source-linked official install (npm or ClawHub)
|
|
655
|
-
* are retained even when the entry is disabled, mirroring the existing
|
|
656
|
-
* `collectMissingPluginInstallPayloads({ skipDisabledPlugins: true,
|
|
657
|
-
* syncOfficialPluginInstalls: true })` policy at
|
|
658
|
-
* `update-command.ts:~218`. We do NOT collapse to the configured plugin
|
|
659
|
-
* id set here — that would over-filter and miss e.g. providers/runtimes
|
|
660
|
-
* that are enabled implicitly via auth profiles or model refs. Effective
|
|
661
|
-
* enable state is the right precision boundary.
|
|
662
|
-
*/
|
|
663
|
-
function filterRecordsToActive(params) {
|
|
664
|
-
const normalizedPluginConfig = normalizePluginsConfig(params.cfg.plugins);
|
|
665
|
-
const filtered = {};
|
|
666
|
-
for (const [pluginId, record] of Object.entries(params.records)) {
|
|
667
|
-
if (!record || typeof record !== "object") continue;
|
|
668
|
-
if (resolveEffectiveEnableState({
|
|
669
|
-
id: pluginId,
|
|
670
|
-
origin: "global",
|
|
671
|
-
config: normalizedPluginConfig,
|
|
672
|
-
rootConfig: params.cfg
|
|
673
|
-
}).enabled) {
|
|
674
|
-
filtered[pluginId] = record;
|
|
675
|
-
continue;
|
|
676
|
-
}
|
|
677
|
-
const officialNpm = resolveTrustedSourceLinkedOfficialNpmSpec({
|
|
678
|
-
pluginId,
|
|
679
|
-
record
|
|
680
|
-
});
|
|
681
|
-
const officialClawHub = resolveTrustedSourceLinkedOfficialClawHubSpec({
|
|
682
|
-
pluginId,
|
|
683
|
-
record
|
|
684
|
-
});
|
|
685
|
-
if (officialNpm || officialClawHub) filtered[pluginId] = record;
|
|
686
|
-
}
|
|
687
|
-
return filtered;
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Pure helper used by `updatePluginsAfterCoreUpdate` to fold a convergence
|
|
691
|
-
* result into the existing `PluginUpdateOutcome[]` / warning shape that the
|
|
692
|
-
* post-core update result carries.
|
|
693
|
-
*
|
|
694
|
-
* Returns:
|
|
695
|
-
* - `outcomes` to append to `pluginUpdateOutcomes`. Only convergence
|
|
696
|
-
* warnings that name a `pluginId` produce per-plugin error outcomes; the
|
|
697
|
-
* rest are surfaced via `warnings`.
|
|
698
|
-
* - `errored` boolean that callers translate into `status: "error"`.
|
|
699
|
-
*/
|
|
700
|
-
function convergenceWarningsToOutcomes(convergence) {
|
|
701
|
-
const outcomes = convergence.warnings.filter((w) => Boolean(w.pluginId)).map((w) => ({
|
|
702
|
-
pluginId: w.pluginId,
|
|
703
|
-
status: "error",
|
|
704
|
-
message: w.message
|
|
705
|
-
}));
|
|
706
|
-
return {
|
|
707
|
-
warnings: convergence.warnings,
|
|
708
|
-
outcomes,
|
|
709
|
-
errored: convergence.errored
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
//#endregion
|
|
713
|
-
//#region src/cli/update-cli/progress.ts
|
|
714
|
-
const STEP_LABELS = {
|
|
715
|
-
"clean check": "Working directory is clean",
|
|
716
|
-
"upstream check": "Upstream branch exists",
|
|
717
|
-
"git fetch": "Fetching latest changes",
|
|
718
|
-
"git rebase": "Rebasing onto target commit",
|
|
719
|
-
"git rev-parse @{upstream}": "Resolving upstream commit",
|
|
720
|
-
"git rev-list": "Enumerating candidate commits",
|
|
721
|
-
"git clone": "Cloning git checkout",
|
|
722
|
-
"preflight worktree": "Preparing preflight worktree",
|
|
723
|
-
"preflight cleanup": "Cleaning preflight worktree",
|
|
724
|
-
"deps install": "Installing dependencies",
|
|
725
|
-
build: "Building",
|
|
726
|
-
"ui:build": "Building UI assets",
|
|
727
|
-
"ui:build (post-doctor repair)": "Restoring missing UI assets",
|
|
728
|
-
"ui assets verify": "Validating UI assets",
|
|
729
|
-
"daocore doctor entry": "Checking doctor entrypoint",
|
|
730
|
-
"daocore doctor": "Running doctor checks",
|
|
731
|
-
"git rev-parse HEAD (after)": "Verifying update",
|
|
732
|
-
"global update": "Updating via package manager",
|
|
733
|
-
"global update (omit optional)": "Retrying update without optional deps",
|
|
734
|
-
"global install stage": "Preparing staged package install",
|
|
735
|
-
"global install verify": "Verifying global package",
|
|
736
|
-
"global install swap": "Activating global package",
|
|
737
|
-
"global install": "Installing global package"
|
|
738
|
-
};
|
|
739
|
-
function getStepLabel(step) {
|
|
740
|
-
return STEP_LABELS[step.name] ?? step.name;
|
|
741
|
-
}
|
|
742
|
-
function inferUpdateFailureHints(result) {
|
|
743
|
-
if (result.status !== "error") return [];
|
|
744
|
-
if (result.reason === "pnpm-corepack-missing") return ["This pnpm checkout could not auto-enable pnpm because corepack is missing.", "Install pnpm manually or install Node with corepack available, then rerun the update command."];
|
|
745
|
-
if (result.reason === "pnpm-corepack-enable-failed") return ["This pnpm checkout could not auto-enable pnpm via corepack.", "Run `corepack enable` manually or install pnpm manually, then rerun the update command."];
|
|
746
|
-
if (result.reason === "pnpm-npm-bootstrap-failed") return ["This pnpm checkout could not bootstrap pnpm from npm automatically.", "Install pnpm manually, then rerun the update command."];
|
|
747
|
-
if (result.reason === "preferred-manager-unavailable") return ["This checkout requires its declared package manager and the updater could not find it.", "Install the missing package manager manually, then rerun the update command."];
|
|
748
|
-
if (result.mode !== "npm") return [];
|
|
749
|
-
const failedStep = [...result.steps].toReversed().find((step) => step.exitCode !== 0);
|
|
750
|
-
if (!failedStep) return [];
|
|
751
|
-
const stderr = normalizeLowercaseStringOrEmpty(failedStep.stderrTail);
|
|
752
|
-
const hints = [];
|
|
753
|
-
if ((failedStep.name.startsWith("global update") || failedStep.name.startsWith("global install")) && stderr.includes("eacces")) {
|
|
754
|
-
hints.push("Detected permission failure (EACCES). Re-run with a writable global prefix or sudo (for system-managed Node installs).");
|
|
755
|
-
hints.push("If you recover with sudo/manual package install on a managed Gateway, stop the Gateway first so it does not load files while the package tree is being replaced.");
|
|
756
|
-
hints.push("Example: npm config set prefix ~/.local && npm i -g daocore@latest");
|
|
757
|
-
hints.push("System install outline: daocore gateway stop -> sudo <system-npm> i -g daocore@latest -> daocore gateway install --force -> daocore gateway restart.");
|
|
758
|
-
}
|
|
759
|
-
if (failedStep.name.startsWith("global update") && (stderr.includes("node-gyp") || stderr.includes("prebuild"))) {
|
|
760
|
-
hints.push("Detected native optional dependency build failure. The updater retries with --omit=optional automatically.");
|
|
761
|
-
hints.push("If it still fails: npm i -g daocore@latest --omit=optional");
|
|
762
|
-
}
|
|
763
|
-
return hints;
|
|
764
|
-
}
|
|
765
|
-
function createUpdateProgress(enabled) {
|
|
766
|
-
if (!enabled) return {
|
|
767
|
-
progress: {},
|
|
768
|
-
stop: () => {}
|
|
769
|
-
};
|
|
770
|
-
let currentSpinner = null;
|
|
771
|
-
return {
|
|
772
|
-
progress: {
|
|
773
|
-
onStepStart: (step) => {
|
|
774
|
-
currentSpinner = spinner();
|
|
775
|
-
currentSpinner.start(theme.accent(getStepLabel(step)));
|
|
776
|
-
},
|
|
777
|
-
onStepComplete: (step) => {
|
|
778
|
-
if (!currentSpinner) return;
|
|
779
|
-
const label = getStepLabel(step);
|
|
780
|
-
const duration = theme.muted(`(${formatDurationPrecise(step.durationMs)})`);
|
|
781
|
-
const icon = step.exitCode === 0 ? theme.success("✓") : theme.error("✗");
|
|
782
|
-
currentSpinner.stop(`${icon} ${label} ${duration}`);
|
|
783
|
-
currentSpinner = null;
|
|
784
|
-
if (step.exitCode !== 0 && step.stderrTail) {
|
|
785
|
-
const lines = step.stderrTail.split("\n").slice(-10);
|
|
786
|
-
for (const line of lines) if (line.trim()) defaultRuntime.log(` ${theme.error(line)}`);
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
},
|
|
790
|
-
stop: () => {
|
|
791
|
-
if (currentSpinner) {
|
|
792
|
-
currentSpinner.stop();
|
|
793
|
-
currentSpinner = null;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
function formatStepStatus(exitCode) {
|
|
799
|
-
if (exitCode === 0) return theme.success("✓");
|
|
800
|
-
if (exitCode === null) return theme.warn("?");
|
|
801
|
-
return theme.error("✗");
|
|
802
|
-
}
|
|
803
|
-
function printResult(result, opts) {
|
|
804
|
-
if (opts.json) {
|
|
805
|
-
defaultRuntime.writeJson(result);
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
const statusColor = result.status === "ok" ? theme.success : result.status === "skipped" ? theme.warn : theme.error;
|
|
809
|
-
defaultRuntime.log("");
|
|
810
|
-
defaultRuntime.log(`${theme.heading("Update Result:")} ${statusColor(result.status.toUpperCase())}`);
|
|
811
|
-
if (result.root) defaultRuntime.log(` Root: ${theme.muted(result.root)}`);
|
|
812
|
-
if (result.reason) defaultRuntime.log(` Reason: ${theme.muted(result.reason)}`);
|
|
813
|
-
if (result.before?.version || result.before?.sha) {
|
|
814
|
-
const before = result.before.version ?? result.before.sha?.slice(0, 8) ?? "";
|
|
815
|
-
defaultRuntime.log(` Before: ${theme.muted(before)}`);
|
|
816
|
-
}
|
|
817
|
-
if (result.after?.version || result.after?.sha) {
|
|
818
|
-
const after = result.after.version ?? result.after.sha?.slice(0, 8) ?? "";
|
|
819
|
-
defaultRuntime.log(` After: ${theme.muted(after)}`);
|
|
820
|
-
}
|
|
821
|
-
if (!opts.hideSteps && result.steps.length > 0) {
|
|
822
|
-
defaultRuntime.log("");
|
|
823
|
-
defaultRuntime.log(theme.heading("Steps:"));
|
|
824
|
-
for (const step of result.steps) {
|
|
825
|
-
const status = formatStepStatus(step.exitCode);
|
|
826
|
-
const duration = theme.muted(`(${formatDurationPrecise(step.durationMs)})`);
|
|
827
|
-
defaultRuntime.log(` ${status} ${step.name} ${duration}`);
|
|
828
|
-
if (step.exitCode !== 0 && step.stderrTail) {
|
|
829
|
-
const lines = step.stderrTail.split("\n").slice(0, 5);
|
|
830
|
-
for (const line of lines) if (line.trim()) defaultRuntime.log(` ${theme.error(line)}`);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
const hints = inferUpdateFailureHints(result);
|
|
835
|
-
if (hints.length > 0) {
|
|
836
|
-
defaultRuntime.log("");
|
|
837
|
-
defaultRuntime.log(theme.heading("Recovery hints:"));
|
|
838
|
-
for (const hint of hints) defaultRuntime.log(` - ${theme.warn(hint)}`);
|
|
839
|
-
}
|
|
840
|
-
defaultRuntime.log("");
|
|
841
|
-
defaultRuntime.log(`Total time: ${theme.muted(formatDurationPrecise(result.durationMs))}`);
|
|
842
|
-
}
|
|
843
|
-
//#endregion
|
|
844
|
-
//#region src/cli/update-cli/restart-helper.ts
|
|
845
|
-
/**
|
|
846
|
-
* Shell-escape a string for embedding in single-quoted shell arguments.
|
|
847
|
-
* Replaces every `'` with `'\''` (end quote, escaped quote, resume quote).
|
|
848
|
-
* For batch scripts, validates against special characters instead.
|
|
849
|
-
*/
|
|
850
|
-
function shellEscape(value) {
|
|
851
|
-
return value.replace(/'/g, "'\\''");
|
|
852
|
-
}
|
|
853
|
-
/** Validates a task name is safe for embedding in Windows restart scripts. */
|
|
854
|
-
function isWindowsTaskNameSafe(value) {
|
|
855
|
-
return /^[A-Za-z0-9 _\-().]+$/.test(value);
|
|
856
|
-
}
|
|
857
|
-
function powerShellSingleQuote(value) {
|
|
858
|
-
return `'${value.replace(/'/g, "''")}'`;
|
|
859
|
-
}
|
|
860
|
-
function resolveSystemdUnit(env) {
|
|
861
|
-
const override = normalizeOptionalString(env.DAOCORE_SYSTEMD_UNIT);
|
|
862
|
-
if (override) return override.endsWith(".service") ? override : `${override}.service`;
|
|
863
|
-
return `${resolveGatewaySystemdServiceName(env.DAOCORE_PROFILE)}.service`;
|
|
864
|
-
}
|
|
865
|
-
function resolveLaunchdLabel(env) {
|
|
866
|
-
const override = normalizeOptionalString(env.DAOCORE_LAUNCHD_LABEL);
|
|
867
|
-
if (override) return override;
|
|
868
|
-
return resolveGatewayLaunchAgentLabel(env.DAOCORE_PROFILE);
|
|
869
|
-
}
|
|
870
|
-
function resolveWindowsTaskName(env) {
|
|
871
|
-
const override = env.DAOCORE_WINDOWS_TASK_NAME?.trim();
|
|
872
|
-
if (override) return override;
|
|
873
|
-
return resolveGatewayWindowsTaskName(env.DAOCORE_PROFILE);
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Prepares a standalone script to restart the gateway service.
|
|
877
|
-
* This script is written to a temporary directory and does not depend on
|
|
878
|
-
* the installed package files, ensuring restart capability even if the
|
|
879
|
-
* update process temporarily removes or corrupts installation files.
|
|
880
|
-
*/
|
|
881
|
-
async function prepareRestartScript(env = process.env, gatewayPort = DEFAULT_GATEWAY_PORT) {
|
|
882
|
-
const timestamp = Date.now();
|
|
883
|
-
const platform = process.platform;
|
|
884
|
-
let scriptContent = "";
|
|
885
|
-
let filename = "";
|
|
886
|
-
try {
|
|
887
|
-
if (platform === "linux") {
|
|
888
|
-
const escaped = shellEscape(resolveSystemdUnit(env));
|
|
889
|
-
const logSetup = renderPosixRestartLogSetup({
|
|
890
|
-
...process.env,
|
|
891
|
-
...env
|
|
892
|
-
});
|
|
893
|
-
filename = `daocore-restart-${timestamp}.sh`;
|
|
894
|
-
scriptContent = `#!/bin/sh
|
|
895
|
-
# Standalone restart script — survives parent process termination.
|
|
896
|
-
# Wait briefly to ensure file locks are released after update.
|
|
897
|
-
sleep 1
|
|
898
|
-
exec 3>&2
|
|
899
|
-
${logSetup}
|
|
900
|
-
printf '[%s] daocore restart attempt source=update target=%s\\n' "$(date -u +%FT%TZ)" '${escaped}' >&2
|
|
901
|
-
if systemctl --user is-active --quiet '${escaped}' || systemctl --user is-enabled --quiet '${escaped}'; then
|
|
902
|
-
if systemctl --user restart '${escaped}'; then
|
|
903
|
-
status=0
|
|
904
|
-
printf '[%s] daocore restart done source=update\\n' "$(date -u +%FT%TZ)" >&2
|
|
905
|
-
else
|
|
906
|
-
status=$?
|
|
907
|
-
printf '[%s] daocore restart failed source=update status=%s\\n' "$(date -u +%FT%TZ)" "$status" >&2
|
|
908
|
-
fi
|
|
909
|
-
elif systemctl is-active --quiet '${escaped}' || systemctl is-enabled --quiet '${escaped}'; then
|
|
910
|
-
status=78
|
|
911
|
-
printf '[%s] system-scoped daocore gateway unit detected; update cannot restart it without sudo. Run: sudo systemctl restart %s\\n' "$(date -u +%FT%TZ)" '${escaped}' >&2
|
|
912
|
-
printf '[%s] system-scoped daocore gateway unit detected; update cannot restart it without sudo. Run: sudo systemctl restart %s\\n' "$(date -u +%FT%TZ)" '${escaped}' >&3 2>/dev/null || true
|
|
913
|
-
else
|
|
914
|
-
if systemctl --user restart '${escaped}'; then
|
|
915
|
-
status=0
|
|
916
|
-
printf '[%s] daocore restart done source=update\\n' "$(date -u +%FT%TZ)" >&2
|
|
917
|
-
else
|
|
918
|
-
status=$?
|
|
919
|
-
printf '[%s] daocore restart failed source=update status=%s\\n' "$(date -u +%FT%TZ)" "$status" >&2
|
|
920
|
-
fi
|
|
921
|
-
fi
|
|
922
|
-
# Self-cleanup
|
|
923
|
-
script_dir=$(dirname "$0")
|
|
924
|
-
exec 3>&-
|
|
925
|
-
rm -f "$0"
|
|
926
|
-
rmdir "$script_dir" 2>/dev/null || true
|
|
927
|
-
exit "$status"
|
|
928
|
-
`;
|
|
929
|
-
} else if (platform === "darwin") {
|
|
930
|
-
const label = resolveLaunchdLabel(env);
|
|
931
|
-
const escaped = shellEscape(label);
|
|
932
|
-
const uid = process.getuid ? process.getuid() : 501;
|
|
933
|
-
const home = normalizeOptionalString(env.HOME) || process.env.HOME || os.homedir();
|
|
934
|
-
const escapedPlistPath = shellEscape(path.join(home, "Library", "LaunchAgents", `${label}.plist`));
|
|
935
|
-
const logSetup = renderPosixRestartLogSetup({
|
|
936
|
-
...process.env,
|
|
937
|
-
...env
|
|
938
|
-
});
|
|
939
|
-
filename = `daocore-restart-${timestamp}.sh`;
|
|
940
|
-
scriptContent = `#!/bin/sh
|
|
941
|
-
# Standalone restart script — survives parent process termination.
|
|
942
|
-
# Wait briefly to ensure file locks are released after update.
|
|
943
|
-
sleep 1
|
|
944
|
-
# Capture launchctl output so bootstrap/kickstart failures leave a durable
|
|
945
|
-
# audit trail. Log setup is best-effort: restart must still run if the log path
|
|
946
|
-
# is temporarily unavailable.
|
|
947
|
-
${logSetup}
|
|
948
|
-
printf '[%s] daocore restart attempt source=update target=%s\\n' "$(date -u +%FT%TZ)" '${shellEscapeRestartLogValue(label)}' >&2
|
|
949
|
-
# Try kickstart first (works when the service is still registered).
|
|
950
|
-
# If it fails (e.g. after bootout), clear any persisted disabled state,
|
|
951
|
-
# then re-register via bootstrap. Bootstrap loads RunAtLoad agents, so the
|
|
952
|
-
# fallback must not immediately kickstart -k the freshly spawned gateway.
|
|
953
|
-
# The final status is captured
|
|
954
|
-
# before self-cleanup so a genuine failure remains observable.
|
|
955
|
-
status=0
|
|
956
|
-
if ! launchctl kickstart -k 'gui/${uid}/${escaped}'; then
|
|
957
|
-
launchctl enable 'gui/${uid}/${escaped}'
|
|
958
|
-
if launchctl bootstrap 'gui/${uid}' '${escapedPlistPath}'; then
|
|
959
|
-
status=0
|
|
960
|
-
else
|
|
961
|
-
launchctl kickstart -k 'gui/${uid}/${escaped}'
|
|
962
|
-
status=$?
|
|
963
|
-
fi
|
|
964
|
-
fi
|
|
965
|
-
if [ "$status" -eq 0 ]; then
|
|
966
|
-
printf '[%s] daocore restart done source=update\\n' "$(date -u +%FT%TZ)" >&2
|
|
967
|
-
else
|
|
968
|
-
printf '[%s] daocore restart failed source=update status=%s\\n' "$(date -u +%FT%TZ)" "$status" >&2
|
|
969
|
-
fi
|
|
970
|
-
# Self-cleanup (log is retained under the DaoCore state logs directory).
|
|
971
|
-
script_dir=$(dirname "$0")
|
|
972
|
-
rm -f "$0"
|
|
973
|
-
rmdir "$script_dir" 2>/dev/null || true
|
|
974
|
-
exit "$status"
|
|
975
|
-
`;
|
|
976
|
-
} else if (platform === "win32") {
|
|
977
|
-
const taskName = resolveWindowsTaskName(env);
|
|
978
|
-
if (!isWindowsTaskNameSafe(taskName)) return null;
|
|
979
|
-
const port = Number.isFinite(gatewayPort) && gatewayPort > 0 ? gatewayPort : DEFAULT_GATEWAY_PORT;
|
|
980
|
-
const quotedLogPath = powerShellSingleQuote(resolveGatewayRestartLogPath({
|
|
981
|
-
...process.env,
|
|
982
|
-
...env
|
|
983
|
-
}));
|
|
984
|
-
const quotedTaskName = powerShellSingleQuote(taskName);
|
|
985
|
-
filename = `daocore-restart-${timestamp}.cmd`;
|
|
986
|
-
scriptContent = `@echo off
|
|
987
|
-
REM Standalone restart script - survives parent process termination.
|
|
988
|
-
REM Keep this as a cmd wrapper so Group Policy script execution policies
|
|
989
|
-
REM cannot block the update restart handoff before schtasks.exe runs.
|
|
990
|
-
setlocal
|
|
991
|
-
set "DAOCORE_RESTART_SCRIPT=%~f0"
|
|
992
|
-
set "DAOCORE_RESTART_SCRIPT_DIR=%~dp0."
|
|
993
|
-
powershell -NoProfile -ExecutionPolicy Bypass -Command "$p=$env:DAOCORE_RESTART_SCRIPT; $s=Get-Content -Raw -LiteralPath $p; $m='# POWERSHELL'; $i=$s.IndexOf($m); if ($i -lt 0) { exit 1 }; Invoke-Expression $s.Substring($i)"
|
|
994
|
-
set "status=%ERRORLEVEL%"
|
|
995
|
-
del "%~f0" >nul 2>&1
|
|
996
|
-
rmdir "%DAOCORE_RESTART_SCRIPT_DIR%" >nul 2>&1
|
|
997
|
-
exit /b %status%
|
|
998
|
-
# POWERSHELL
|
|
999
|
-
# Wait briefly to ensure file locks are released after update.
|
|
1000
|
-
$ErrorActionPreference = "Continue"
|
|
1001
|
-
Start-Sleep -Seconds 2
|
|
1002
|
-
|
|
1003
|
-
$logPath = ${quotedLogPath}
|
|
1004
|
-
try {
|
|
1005
|
-
$logDir = Split-Path -Parent $logPath
|
|
1006
|
-
New-Item -ItemType Directory -Path $logDir -Force | Out-Null
|
|
1007
|
-
Add-Content -LiteralPath $logPath -Value "[$(Get-Date -Format o)] daocore restart log initialized"
|
|
1008
|
-
} catch {
|
|
1009
|
-
# Restart should still run if log setup is unavailable.
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
function Write-RestartLog {
|
|
1013
|
-
param([string]$Message)
|
|
1014
|
-
try {
|
|
1015
|
-
Add-Content -LiteralPath $logPath -Value "[$(Get-Date -Format o)] $Message"
|
|
1016
|
-
} catch {
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
function Join-DaoCoreProcessArguments {
|
|
1021
|
-
param([string[]]$Arguments)
|
|
1022
|
-
($Arguments | ForEach-Object {
|
|
1023
|
-
if ($_ -match "\\s") {
|
|
1024
|
-
'"' + $_ + '"'
|
|
1025
|
-
} else {
|
|
1026
|
-
$_
|
|
1027
|
-
}
|
|
1028
|
-
}) -join " "
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
function Invoke-DaoCoreSchtasksWithTimeout {
|
|
1032
|
-
param(
|
|
1033
|
-
[string[]]$Arguments,
|
|
1034
|
-
[int]$TimeoutSeconds
|
|
1035
|
-
)
|
|
1036
|
-
$process = $null
|
|
1037
|
-
try {
|
|
1038
|
-
$startInfo = [System.Diagnostics.ProcessStartInfo]::new()
|
|
1039
|
-
$startInfo.FileName = "schtasks.exe"
|
|
1040
|
-
$startInfo.Arguments = Join-DaoCoreProcessArguments -Arguments $Arguments
|
|
1041
|
-
$startInfo.UseShellExecute = $false
|
|
1042
|
-
$startInfo.RedirectStandardOutput = $true
|
|
1043
|
-
$startInfo.RedirectStandardError = $true
|
|
1044
|
-
$process = [System.Diagnostics.Process]::Start($startInfo)
|
|
1045
|
-
if (-not $process.WaitForExit($TimeoutSeconds * 1000)) {
|
|
1046
|
-
try {
|
|
1047
|
-
$process.Kill()
|
|
1048
|
-
} catch {
|
|
1049
|
-
}
|
|
1050
|
-
Write-RestartLog "daocore restart schtasks timeout source=update args=$($Arguments -join ' ')"
|
|
1051
|
-
return 124
|
|
1052
|
-
}
|
|
1053
|
-
$stdout = $process.StandardOutput.ReadToEnd()
|
|
1054
|
-
$stderr = $process.StandardError.ReadToEnd()
|
|
1055
|
-
if ($stdout) {
|
|
1056
|
-
Write-RestartLog $stdout.Trim()
|
|
1057
|
-
}
|
|
1058
|
-
if ($stderr) {
|
|
1059
|
-
Write-RestartLog $stderr.Trim()
|
|
1060
|
-
}
|
|
1061
|
-
return $process.ExitCode
|
|
1062
|
-
} catch {
|
|
1063
|
-
Write-RestartLog "daocore restart schtasks failed source=update args=$($Arguments -join ' ') error=$($_.Exception.Message)"
|
|
1064
|
-
return 1
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
function Get-DaoCoreScheduledTaskState {
|
|
1069
|
-
param([string]$TaskName)
|
|
1070
|
-
try {
|
|
1071
|
-
$task = Get-ScheduledTask -TaskName $TaskName -ErrorAction Stop
|
|
1072
|
-
if ($task -and $task.State) {
|
|
1073
|
-
return [string]$task.State
|
|
1074
|
-
}
|
|
1075
|
-
} catch {
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
try {
|
|
1079
|
-
$queryOutput = & schtasks.exe /Query /TN $TaskName /FO LIST 2>$null
|
|
1080
|
-
foreach ($line in $queryOutput) {
|
|
1081
|
-
if ($line -match "^\\s*Status:\\s*(.+?)\\s*$") {
|
|
1082
|
-
return $Matches[1]
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
} catch {
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
return "Unknown"
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
function Get-DaoCoreListenerPids {
|
|
1092
|
-
param([int]$Port)
|
|
1093
|
-
$listenerPids = @()
|
|
1094
|
-
|
|
1095
|
-
try {
|
|
1096
|
-
if (Get-Command Get-NetTCPConnection -ErrorAction SilentlyContinue) {
|
|
1097
|
-
$listenerPids += Get-NetTCPConnection -LocalPort $Port -State Listen -ErrorAction SilentlyContinue |
|
|
1098
|
-
ForEach-Object { [int]$_.OwningProcess }
|
|
1099
|
-
}
|
|
1100
|
-
} catch {
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
if ($listenerPids.Count -eq 0) {
|
|
1104
|
-
try {
|
|
1105
|
-
$portPattern = [regex]::Escape(":$Port")
|
|
1106
|
-
$linePattern = "^\\s*TCP\\s+\\S+$portPattern\\s+\\S+\\s+LISTENING\\s+(\\d+)\\s*$"
|
|
1107
|
-
& netstat.exe -ano -p tcp 2>$null | ForEach-Object {
|
|
1108
|
-
if ($_ -match $linePattern) {
|
|
1109
|
-
$listenerPids += [int]$Matches[1]
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
} catch {
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
$listenerPids | Sort-Object -Unique
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
function Invoke-DaoCoreStartupLauncher {
|
|
1120
|
-
$launcherPath = Join-Path $env:USERPROFILE ".daocore\\gateway.cmd"
|
|
1121
|
-
if (-not (Test-Path -LiteralPath $launcherPath)) {
|
|
1122
|
-
Write-RestartLog "daocore restart startup launcher missing source=update path=$launcherPath"
|
|
1123
|
-
return 1
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
try {
|
|
1127
|
-
Start-Process -FilePath $launcherPath -WindowStyle Hidden | Out-Null
|
|
1128
|
-
Write-RestartLog "daocore restart launched startup fallback source=update path=$launcherPath"
|
|
1129
|
-
return 0
|
|
1130
|
-
} catch {
|
|
1131
|
-
Write-RestartLog "daocore restart startup fallback failed source=update error=$($_.Exception.Message)"
|
|
1132
|
-
return 1
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
$taskName = ${quotedTaskName}
|
|
1137
|
-
$port = ${port}
|
|
1138
|
-
Write-RestartLog "daocore restart attempt source=update target=$taskName"
|
|
1139
|
-
|
|
1140
|
-
$taskState = Get-DaoCoreScheduledTaskState -TaskName $taskName
|
|
1141
|
-
if ($taskState -eq "Running") {
|
|
1142
|
-
$endStatus = Invoke-DaoCoreSchtasksWithTimeout -Arguments @("/End", "/TN", $taskName) -TimeoutSeconds 10
|
|
1143
|
-
if ($endStatus -ne 0) {
|
|
1144
|
-
Write-RestartLog "daocore restart schtasks end did not complete cleanly source=update status=$endStatus"
|
|
1145
|
-
}
|
|
1146
|
-
} else {
|
|
1147
|
-
Write-RestartLog "daocore restart skipped schtasks end source=update state=$taskState"
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
for ($attempt = 1; $attempt -le 10; $attempt++) {
|
|
1151
|
-
$listeners = @(Get-DaoCoreListenerPids -Port $port)
|
|
1152
|
-
if ($listeners.Count -eq 0) {
|
|
1153
|
-
break
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
if ($attempt -eq 10) {
|
|
1157
|
-
foreach ($listenerPid in $listeners) {
|
|
1158
|
-
try {
|
|
1159
|
-
Stop-Process -Id $listenerPid -Force -ErrorAction Stop
|
|
1160
|
-
Write-RestartLog "daocore restart killed stale listener source=update pid=$listenerPid"
|
|
1161
|
-
} catch {
|
|
1162
|
-
Write-RestartLog "daocore restart failed to kill stale listener source=update pid=$listenerPid error=$($_.Exception.Message)"
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
break
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
Start-Sleep -Seconds 1
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
$status = Invoke-DaoCoreSchtasksWithTimeout -Arguments @("/Run", "/TN", $taskName) -TimeoutSeconds 30
|
|
1172
|
-
if ($status -ne 0) {
|
|
1173
|
-
$status = Invoke-DaoCoreStartupLauncher
|
|
1174
|
-
}
|
|
1175
|
-
if ($status -eq 0) {
|
|
1176
|
-
Write-RestartLog "daocore restart done source=update"
|
|
1177
|
-
} else {
|
|
1178
|
-
Write-RestartLog "daocore restart failed source=update status=$status"
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
exit $status
|
|
1182
|
-
`;
|
|
1183
|
-
} else return null;
|
|
1184
|
-
const scriptDir = await fs$1.mkdtemp(path.join(os.tmpdir(), "daocore-restart-"));
|
|
1185
|
-
const scriptPath = path.join(scriptDir, filename);
|
|
1186
|
-
try {
|
|
1187
|
-
await fs$1.writeFile(scriptPath, scriptContent, {
|
|
1188
|
-
mode: 493,
|
|
1189
|
-
flag: "wx"
|
|
1190
|
-
});
|
|
1191
|
-
} catch (error) {
|
|
1192
|
-
await fs$1.rm(scriptDir, {
|
|
1193
|
-
recursive: true,
|
|
1194
|
-
force: true
|
|
1195
|
-
}).catch(() => {});
|
|
1196
|
-
throw error;
|
|
1197
|
-
}
|
|
1198
|
-
return scriptPath;
|
|
1199
|
-
} catch {
|
|
1200
|
-
return null;
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
/**
|
|
1204
|
-
* Executes the prepared restart script as a **detached** process.
|
|
1205
|
-
*
|
|
1206
|
-
* The script must outlive the CLI process because the CLI itself is part
|
|
1207
|
-
* of the service being restarted — `systemctl restart` / `launchctl
|
|
1208
|
-
* kickstart -k` will terminate the current process tree. Using
|
|
1209
|
-
* `spawn({ detached: true })` + `unref()` ensures the script survives
|
|
1210
|
-
* the parent's exit.
|
|
1211
|
-
*
|
|
1212
|
-
* Resolves immediately after spawning; the script runs independently.
|
|
1213
|
-
*/
|
|
1214
|
-
async function runRestartScript(scriptPath) {
|
|
1215
|
-
const isWindows = process.platform === "win32";
|
|
1216
|
-
spawn(isWindows ? "cmd.exe" : "/bin/sh", isWindows ? [
|
|
1217
|
-
"/d",
|
|
1218
|
-
"/s",
|
|
1219
|
-
"/c",
|
|
1220
|
-
quoteCmdScriptArg(scriptPath)
|
|
1221
|
-
] : [scriptPath], {
|
|
1222
|
-
detached: true,
|
|
1223
|
-
stdio: "ignore",
|
|
1224
|
-
windowsHide: true
|
|
1225
|
-
}).unref();
|
|
1226
|
-
}
|
|
1227
|
-
//#endregion
|
|
1228
|
-
//#region src/cli/update-cli/suppress-deprecations.ts
|
|
1229
|
-
/**
|
|
1230
|
-
* Suppress Node.js deprecation warnings.
|
|
1231
|
-
*
|
|
1232
|
-
* On Node.js v23+ `process.noDeprecation` may be a read-only property
|
|
1233
|
-
* (defined via a getter on the prototype with no setter), so the
|
|
1234
|
-
* assignment can throw. We fall back to the environment variable which
|
|
1235
|
-
* achieves the same effect.
|
|
1236
|
-
*/
|
|
1237
|
-
function suppressDeprecations() {
|
|
1238
|
-
try {
|
|
1239
|
-
process.noDeprecation = true;
|
|
1240
|
-
} catch {}
|
|
1241
|
-
process.env.NODE_NO_WARNINGS = "1";
|
|
1242
|
-
}
|
|
1243
|
-
//#endregion
|
|
1244
|
-
//#region src/cli/update-cli/update-command.ts
|
|
1245
|
-
const CLI_NAME = resolveCliName();
|
|
1246
|
-
const SERVICE_REFRESH_TIMEOUT_MS = 6e4;
|
|
1247
|
-
const POST_REFRESH_ALREADY_HEALTHY_ATTEMPTS = 10;
|
|
1248
|
-
const POST_REFRESH_ALREADY_HEALTHY_DELAY_MS = 500;
|
|
1249
|
-
const DEFAULT_UPDATE_STEP_TIMEOUT_MS = 30 * 6e4;
|
|
1250
|
-
const POST_CORE_UPDATE_ENV = "DAOCORE_UPDATE_POST_CORE";
|
|
1251
|
-
const POST_CORE_UPDATE_CHANNEL_ENV = "DAOCORE_UPDATE_POST_CORE_CHANNEL";
|
|
1252
|
-
const POST_CORE_UPDATE_REQUESTED_CHANNEL_ENV = "DAOCORE_UPDATE_POST_CORE_REQUESTED_CHANNEL";
|
|
1253
|
-
const POST_CORE_UPDATE_RESULT_PATH_ENV = "DAOCORE_UPDATE_POST_CORE_RESULT_PATH";
|
|
1254
|
-
const POST_CORE_UPDATE_INSTALL_RECORDS_PATH_ENV = "DAOCORE_UPDATE_POST_CORE_INSTALL_RECORDS_PATH";
|
|
1255
|
-
const POST_CORE_UPDATE_SOURCE_CONFIG_PATH_ENV = "DAOCORE_UPDATE_POST_CORE_SOURCE_CONFIG_PATH";
|
|
1256
|
-
const POST_CORE_UPDATE_STARTED_AT_ENV = "DAOCORE_UPDATE_POST_CORE_STARTED_AT_MS";
|
|
1257
|
-
const POST_CORE_UPDATE_RESULT_POLL_MS = 100;
|
|
1258
|
-
const PRE_UPDATE_CONFIG_SNAPSHOT_MAX_AGE_MS = 360 * 60 * 1e3;
|
|
1259
|
-
const SERVICE_REFRESH_PATH_ENV_KEYS = [
|
|
1260
|
-
"DAOCORE_HOME",
|
|
1261
|
-
"DAOCORE_STATE_DIR",
|
|
1262
|
-
"DAOCORE_CONFIG_PATH"
|
|
1263
|
-
];
|
|
1264
|
-
const POST_INSTALL_DOCTOR_SERVICE_ENV_KEYS = [...SERVICE_REFRESH_PATH_ENV_KEYS, "DAOCORE_PROFILE"];
|
|
1265
|
-
const POST_UPDATE_PLUGIN_REPAIR_GUIDANCE = "Run daocore doctor --fix to attempt automatic repair.";
|
|
1266
|
-
const JSON_MODE_SERVICE_STDOUT = new Writable({ write(_chunk, _encoding, callback) {
|
|
1267
|
-
callback();
|
|
1268
|
-
} });
|
|
1269
|
-
async function createUpdateConfigSnapshot() {
|
|
1270
|
-
await createPreUpdateConfigSnapshot({
|
|
1271
|
-
configPath: CONFIG_PATH,
|
|
1272
|
-
fs: {
|
|
1273
|
-
writeFile: fs$1.writeFile,
|
|
1274
|
-
readFile: fs$1.readFile,
|
|
1275
|
-
existsSync
|
|
1276
|
-
}
|
|
1277
|
-
});
|
|
1278
|
-
}
|
|
1279
|
-
const UPDATE_QUIPS = [
|
|
1280
|
-
"Leveled up! New skills unlocked. You're welcome.",
|
|
1281
|
-
"Fresh code, same lobster. Miss me?",
|
|
1282
|
-
"Back and better. Did you even notice I was gone?",
|
|
1283
|
-
"Update complete. I learned some new tricks while I was out.",
|
|
1284
|
-
"Upgraded! Now with 23% more sass.",
|
|
1285
|
-
"I've evolved. Try to keep up.",
|
|
1286
|
-
"New version, who dis? Oh right, still me but shinier.",
|
|
1287
|
-
"Patched, polished, and ready to pinch. Let's go.",
|
|
1288
|
-
"The lobster has molted. Harder shell, sharper claws.",
|
|
1289
|
-
"Update done! Check the changelog or just trust me, it's good.",
|
|
1290
|
-
"Reborn from the boiling waters of npm. Stronger now.",
|
|
1291
|
-
"I went away and came back smarter. You should try it sometime.",
|
|
1292
|
-
"Update complete. The bugs feared me, so they left.",
|
|
1293
|
-
"New version installed. Old version sends its regards.",
|
|
1294
|
-
"Firmware fresh. Brain wrinkles: increased.",
|
|
1295
|
-
"I've seen things you wouldn't believe. Anyway, I'm updated.",
|
|
1296
|
-
"Back online. The changelog is long but our friendship is longer.",
|
|
1297
|
-
"Upgraded! Peter fixed stuff. Blame him if it breaks.",
|
|
1298
|
-
"Molting complete. Please don't look at my soft shell phase.",
|
|
1299
|
-
"Version bump! Same chaos energy, fewer crashes (probably)."
|
|
1300
|
-
];
|
|
1301
|
-
function pickUpdateQuip() {
|
|
1302
|
-
return UPDATE_QUIPS[Math.floor(Math.random() * UPDATE_QUIPS.length)] ?? "Update complete.";
|
|
1303
|
-
}
|
|
1304
|
-
function isPackageManagerUpdateMode(mode) {
|
|
1305
|
-
return mode === "npm" || mode === "pnpm" || mode === "bun";
|
|
1306
|
-
}
|
|
1307
|
-
function isTrackedPackageInstallRecord(record) {
|
|
1308
|
-
return record.source === "npm" || record.source === "clawhub" || record.source === "git" || record.source === "marketplace";
|
|
1309
|
-
}
|
|
1310
|
-
function isRecord(value) {
|
|
1311
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1312
|
-
}
|
|
1313
|
-
function normalizePluginInstallRecordMap(value) {
|
|
1314
|
-
if (!isRecord(value)) return {};
|
|
1315
|
-
const records = {};
|
|
1316
|
-
for (const [pluginId, record] of Object.entries(value).toSorted(([left], [right]) => left.localeCompare(right))) if (isRecord(record) && typeof record.source === "string") records[pluginId] = structuredClone(record);
|
|
1317
|
-
return records;
|
|
1318
|
-
}
|
|
1319
|
-
function normalizeChannelConfigMap(value) {
|
|
1320
|
-
if (!isRecord(value)) return null;
|
|
1321
|
-
return value;
|
|
1322
|
-
}
|
|
1323
|
-
function normalizeDirectAuthoredChannelConfigMap(value) {
|
|
1324
|
-
const channels = normalizeChannelConfigMap(value);
|
|
1325
|
-
if (!channels || Object.prototype.hasOwnProperty.call(channels, "$include")) return null;
|
|
1326
|
-
return channels;
|
|
1327
|
-
}
|
|
1328
|
-
function restorePreUpdateChannelModelOverrides(params) {
|
|
1329
|
-
if (params.restoredChannelIds.length === 0) return {
|
|
1330
|
-
channels: params.channels,
|
|
1331
|
-
changed: false
|
|
1332
|
-
};
|
|
1333
|
-
const preUpdateModelByChannel = normalizeChannelConfigMap(params.preUpdateChannels.modelByChannel);
|
|
1334
|
-
if (!preUpdateModelByChannel) return {
|
|
1335
|
-
channels: params.channels,
|
|
1336
|
-
changed: false
|
|
1337
|
-
};
|
|
1338
|
-
const currentModelByChannel = normalizeChannelConfigMap(params.channels.modelByChannel) ?? {};
|
|
1339
|
-
const restoredModelByChannel = structuredClone(currentModelByChannel);
|
|
1340
|
-
let changed = false;
|
|
1341
|
-
for (const [providerId, providerOverrides] of Object.entries(preUpdateModelByChannel)) {
|
|
1342
|
-
const preUpdateProviderOverrides = normalizeChannelConfigMap(providerOverrides);
|
|
1343
|
-
if (!preUpdateProviderOverrides) continue;
|
|
1344
|
-
const currentProviderOverrides = normalizeChannelConfigMap(restoredModelByChannel[providerId]) ?? {};
|
|
1345
|
-
let providerChanged = false;
|
|
1346
|
-
for (const channelId of params.restoredChannelIds) {
|
|
1347
|
-
if (currentProviderOverrides[channelId] !== void 0 || preUpdateProviderOverrides[channelId] === void 0) continue;
|
|
1348
|
-
currentProviderOverrides[channelId] = structuredClone(preUpdateProviderOverrides[channelId]);
|
|
1349
|
-
providerChanged = true;
|
|
1350
|
-
}
|
|
1351
|
-
if (providerChanged) {
|
|
1352
|
-
restoredModelByChannel[providerId] = currentProviderOverrides;
|
|
1353
|
-
changed = true;
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
return changed ? {
|
|
1357
|
-
channels: {
|
|
1358
|
-
...params.channels,
|
|
1359
|
-
modelByChannel: restoredModelByChannel
|
|
1360
|
-
},
|
|
1361
|
-
changed: true
|
|
1362
|
-
} : {
|
|
1363
|
-
channels: params.channels,
|
|
1364
|
-
changed: false
|
|
1365
|
-
};
|
|
1366
|
-
}
|
|
1367
|
-
function restoreDroppedPreUpdateChannels(snapshot, preUpdateConfig) {
|
|
1368
|
-
if (!snapshot.valid || !preUpdateConfig) return {
|
|
1369
|
-
snapshot,
|
|
1370
|
-
changed: false
|
|
1371
|
-
};
|
|
1372
|
-
const preUpdateChannels = normalizeChannelConfigMap(preUpdateConfig.sourceConfig.channels);
|
|
1373
|
-
if (!preUpdateChannels) return {
|
|
1374
|
-
snapshot,
|
|
1375
|
-
changed: false
|
|
1376
|
-
};
|
|
1377
|
-
let restoredChannels = { ...normalizeChannelConfigMap(snapshot.sourceConfig.channels) ?? {} };
|
|
1378
|
-
const restoredChannelIds = [];
|
|
1379
|
-
let restored = false;
|
|
1380
|
-
for (const [channelId, channelConfig] of Object.entries(preUpdateChannels)) {
|
|
1381
|
-
if (restoredChannels[channelId] !== void 0) continue;
|
|
1382
|
-
restoredChannels[channelId] = structuredClone(channelConfig);
|
|
1383
|
-
if (channelId !== "modelByChannel") restoredChannelIds.push(channelId);
|
|
1384
|
-
restored = true;
|
|
1385
|
-
}
|
|
1386
|
-
if (!restored) return {
|
|
1387
|
-
snapshot,
|
|
1388
|
-
changed: false
|
|
1389
|
-
};
|
|
1390
|
-
restoredChannels = restorePreUpdateChannelModelOverrides({
|
|
1391
|
-
channels: restoredChannels,
|
|
1392
|
-
preUpdateChannels,
|
|
1393
|
-
restoredChannelIds
|
|
1394
|
-
}).channels;
|
|
1395
|
-
const authoredChannels = resolveRestoredAuthoredChannels({
|
|
1396
|
-
currentChannels: snapshot.sourceConfig.channels,
|
|
1397
|
-
currentAuthoredChannels: isRecord(snapshot.parsed) ? snapshot.parsed.channels : snapshot.sourceConfig.channels,
|
|
1398
|
-
preUpdateAuthoredChannels: preUpdateConfig.authoredConfig.channels,
|
|
1399
|
-
restoredChannelIds
|
|
1400
|
-
});
|
|
1401
|
-
return {
|
|
1402
|
-
snapshot: {
|
|
1403
|
-
...createUpdatedConfigSnapshot(snapshot, {
|
|
1404
|
-
...snapshot.sourceConfig,
|
|
1405
|
-
channels: restoredChannels
|
|
1406
|
-
}),
|
|
1407
|
-
hash: snapshot.hash
|
|
1408
|
-
},
|
|
1409
|
-
changed: true,
|
|
1410
|
-
...authoredChannels !== void 0 ? { authoredChannels } : {}
|
|
1411
|
-
};
|
|
1412
|
-
}
|
|
1413
|
-
function hasRestorablePreUpdateChannels(snapshot, preUpdateConfig) {
|
|
1414
|
-
if (!snapshot.valid) return false;
|
|
1415
|
-
const preUpdateChannels = normalizeChannelConfigMap(preUpdateConfig.sourceConfig.channels);
|
|
1416
|
-
if (!preUpdateChannels) return false;
|
|
1417
|
-
const postUpdateChannels = normalizeChannelConfigMap(snapshot.sourceConfig.channels) ?? {};
|
|
1418
|
-
return Object.keys(preUpdateChannels).some((channelId) => postUpdateChannels[channelId] === void 0);
|
|
1419
|
-
}
|
|
1420
|
-
function resolveRestoredAuthoredChannels(params) {
|
|
1421
|
-
if (params.preUpdateAuthoredChannels === void 0) return;
|
|
1422
|
-
const directAuthoredChannels = normalizeDirectAuthoredChannelConfigMap(params.preUpdateAuthoredChannels);
|
|
1423
|
-
if (!directAuthoredChannels) {
|
|
1424
|
-
const preUpdateAuthoredChannels = normalizeChannelConfigMap(params.preUpdateAuthoredChannels);
|
|
1425
|
-
if (!preUpdateAuthoredChannels) return;
|
|
1426
|
-
const currentDirectAuthoredChannels = normalizeDirectAuthoredChannelConfigMap(params.currentAuthoredChannels);
|
|
1427
|
-
if (currentDirectAuthoredChannels) return {
|
|
1428
|
-
...structuredClone(preUpdateAuthoredChannels),
|
|
1429
|
-
...structuredClone(currentDirectAuthoredChannels)
|
|
1430
|
-
};
|
|
1431
|
-
const currentAuthoredChannels = normalizeChannelConfigMap(params.currentAuthoredChannels);
|
|
1432
|
-
return !currentAuthoredChannels || Object.keys(currentAuthoredChannels).length === 0 ? structuredClone(preUpdateAuthoredChannels) : void 0;
|
|
1433
|
-
}
|
|
1434
|
-
const restoredChannels = { ...normalizeDirectAuthoredChannelConfigMap(params.currentAuthoredChannels) ?? normalizeDirectAuthoredChannelConfigMap(params.currentChannels) ?? {} };
|
|
1435
|
-
let changed = false;
|
|
1436
|
-
for (const channelId of params.restoredChannelIds) {
|
|
1437
|
-
if (restoredChannels[channelId] !== void 0 || directAuthoredChannels[channelId] === void 0) continue;
|
|
1438
|
-
restoredChannels[channelId] = structuredClone(directAuthoredChannels[channelId]);
|
|
1439
|
-
changed = true;
|
|
1440
|
-
}
|
|
1441
|
-
const restoredModelOverrides = restorePreUpdateChannelModelOverrides({
|
|
1442
|
-
channels: restoredChannels,
|
|
1443
|
-
preUpdateChannels: directAuthoredChannels,
|
|
1444
|
-
restoredChannelIds: params.restoredChannelIds
|
|
1445
|
-
});
|
|
1446
|
-
if (restoredModelOverrides.changed) return restoredModelOverrides.channels;
|
|
1447
|
-
return changed ? restoredChannels : void 0;
|
|
1448
|
-
}
|
|
1449
|
-
async function collectMissingPluginInstallPayloads(params) {
|
|
1450
|
-
const env = params.env ?? process.env;
|
|
1451
|
-
const normalizedPluginConfig = params.skipDisabledPlugins && params.config ? normalizePluginsConfig(params.config.plugins) : void 0;
|
|
1452
|
-
const missing = [];
|
|
1453
|
-
for (const [pluginId, record] of Object.entries(params.records).toSorted(([left], [right]) => left.localeCompare(right))) {
|
|
1454
|
-
if (!isTrackedPackageInstallRecord(record)) continue;
|
|
1455
|
-
const officialNpmSpec = params.syncOfficialPluginInstalls ? resolveTrustedSourceLinkedOfficialNpmSpec({
|
|
1456
|
-
pluginId,
|
|
1457
|
-
record
|
|
1458
|
-
}) : void 0;
|
|
1459
|
-
const officialClawHubSpec = params.syncOfficialPluginInstalls ? resolveTrustedSourceLinkedOfficialClawHubSpec({
|
|
1460
|
-
pluginId,
|
|
1461
|
-
record
|
|
1462
|
-
}) : void 0;
|
|
1463
|
-
if (normalizedPluginConfig && params.config) {
|
|
1464
|
-
if (!resolveEffectiveEnableState({
|
|
1465
|
-
id: pluginId,
|
|
1466
|
-
origin: "global",
|
|
1467
|
-
config: normalizedPluginConfig,
|
|
1468
|
-
rootConfig: params.config
|
|
1469
|
-
}).enabled && !officialNpmSpec && !officialClawHubSpec) continue;
|
|
1470
|
-
}
|
|
1471
|
-
const rawInstallPath = normalizeOptionalString(record.installPath);
|
|
1472
|
-
if (!rawInstallPath) {
|
|
1473
|
-
missing.push({
|
|
1474
|
-
pluginId,
|
|
1475
|
-
reason: "missing-install-path"
|
|
1476
|
-
});
|
|
1477
|
-
continue;
|
|
1478
|
-
}
|
|
1479
|
-
const installPath = resolveUserPath(rawInstallPath, env);
|
|
1480
|
-
if (!await pathExists(installPath)) {
|
|
1481
|
-
missing.push({
|
|
1482
|
-
pluginId,
|
|
1483
|
-
installPath,
|
|
1484
|
-
reason: "missing-package-dir"
|
|
1485
|
-
});
|
|
1486
|
-
continue;
|
|
1487
|
-
}
|
|
1488
|
-
if (!await pathExists(path.join(installPath, "package.json"))) missing.push({
|
|
1489
|
-
pluginId,
|
|
1490
|
-
installPath,
|
|
1491
|
-
reason: "missing-package-json"
|
|
1492
|
-
});
|
|
1493
|
-
}
|
|
1494
|
-
return missing;
|
|
1495
|
-
}
|
|
1496
|
-
function formatMissingPluginPayloadReason(entry) {
|
|
1497
|
-
if (entry.reason === "missing-install-path") return "installPath is missing";
|
|
1498
|
-
if (entry.reason === "missing-package-json") return `package.json is missing under ${entry.installPath}`;
|
|
1499
|
-
return `package directory is missing: ${entry.installPath}`;
|
|
1500
|
-
}
|
|
1501
|
-
function formatPostUpdatePluginInspectGuidance(pluginId) {
|
|
1502
|
-
return `Run daocore plugins inspect ${pluginId} --runtime --json for details.`;
|
|
1503
|
-
}
|
|
1504
|
-
function createPostUpdatePluginWarning(params) {
|
|
1505
|
-
const reason = params.reason.trim() || "unknown plugin post-update failure";
|
|
1506
|
-
const guidance = [POST_UPDATE_PLUGIN_REPAIR_GUIDANCE, ...params.pluginId ? [formatPostUpdatePluginInspectGuidance(params.pluginId)] : []];
|
|
1507
|
-
return {
|
|
1508
|
-
...params.pluginId ? { pluginId: params.pluginId } : {},
|
|
1509
|
-
reason,
|
|
1510
|
-
message: params.pluginId ? `Plugin "${params.pluginId}" could not be processed after the core update: ${reason} ${guidance.join(" ")}` : `Plugin post-update processing could not complete after the core update: ${reason} ${guidance.join(" ")}`,
|
|
1511
|
-
guidance
|
|
1512
|
-
};
|
|
1513
|
-
}
|
|
1514
|
-
function createGuidedPostUpdatePluginOutcome(outcome) {
|
|
1515
|
-
if (outcome.status !== "error" && !isDisabledAfterFailureOutcome(outcome)) return { outcome };
|
|
1516
|
-
const warning = createPostUpdatePluginWarning({
|
|
1517
|
-
...outcome.pluginId && outcome.pluginId !== "unknown" ? { pluginId: outcome.pluginId } : {},
|
|
1518
|
-
reason: outcome.message
|
|
1519
|
-
});
|
|
1520
|
-
return {
|
|
1521
|
-
outcome: {
|
|
1522
|
-
...outcome,
|
|
1523
|
-
message: warning.message
|
|
1524
|
-
},
|
|
1525
|
-
warning
|
|
1526
|
-
};
|
|
1527
|
-
}
|
|
1528
|
-
function isDisabledAfterFailureOutcome(outcome) {
|
|
1529
|
-
return outcome.status === "skipped" && outcome.message.includes("after plugin update failure");
|
|
1530
|
-
}
|
|
1531
|
-
/**
|
|
1532
|
-
* Build the post-core-update result we return when the active config cannot
|
|
1533
|
-
* even be parsed. Mandatory post-core convergence requires a parseable
|
|
1534
|
-
* config to know which plugins are configured; if one isn't available, we
|
|
1535
|
-
* refuse to restart the gateway and surface this as a hard error so the
|
|
1536
|
-
* existing `status === "error"` ⇒ `exit 1` pre-restart gate fires.
|
|
1537
|
-
*
|
|
1538
|
-
* Exported for unit testing without having to drive the entire
|
|
1539
|
-
* `updatePluginsAfterCoreUpdate` orchestrator.
|
|
1540
|
-
*/
|
|
1541
|
-
function buildInvalidConfigPostCoreUpdateResult() {
|
|
1542
|
-
const guidance = ["Run `daocore doctor` to inspect the config validation errors.", "Once the config parses, rerun `daocore update`."];
|
|
1543
|
-
const message = "Plugin post-update convergence skipped because the config is invalid; refusing to restart the gateway with an unverified plugin set.";
|
|
1544
|
-
return {
|
|
1545
|
-
message,
|
|
1546
|
-
guidance,
|
|
1547
|
-
result: {
|
|
1548
|
-
status: "error",
|
|
1549
|
-
reason: "invalid-config",
|
|
1550
|
-
changed: false,
|
|
1551
|
-
sync: {
|
|
1552
|
-
changed: false,
|
|
1553
|
-
switchedToBundled: [],
|
|
1554
|
-
switchedToNpm: [],
|
|
1555
|
-
warnings: [],
|
|
1556
|
-
errors: []
|
|
1557
|
-
},
|
|
1558
|
-
npm: {
|
|
1559
|
-
changed: false,
|
|
1560
|
-
outcomes: []
|
|
1561
|
-
},
|
|
1562
|
-
integrityDrifts: [],
|
|
1563
|
-
warnings: [{
|
|
1564
|
-
reason: "invalid-config",
|
|
1565
|
-
message,
|
|
1566
|
-
guidance
|
|
1567
|
-
}]
|
|
1568
|
-
}
|
|
1569
|
-
};
|
|
1570
|
-
}
|
|
1571
|
-
function shouldPrepareUpdatedInstallRestart(params) {
|
|
1572
|
-
if (isPackageManagerUpdateMode(params.updateMode)) return params.serviceInstalled;
|
|
1573
|
-
return params.serviceLoaded;
|
|
1574
|
-
}
|
|
1575
|
-
function shouldUseLegacyProcessRestartAfterUpdate(params) {
|
|
1576
|
-
return !isPackageManagerUpdateMode(params.updateMode);
|
|
1577
|
-
}
|
|
1578
|
-
async function recoverInstalledLaunchAgentAfterUpdate(params) {
|
|
1579
|
-
if ((params.deps?.platform ?? process.platform) !== "darwin") return {
|
|
1580
|
-
attempted: false,
|
|
1581
|
-
recovered: false
|
|
1582
|
-
};
|
|
1583
|
-
const service = params.service ?? resolveGatewayService();
|
|
1584
|
-
const readState = params.deps?.readState ?? readGatewayServiceState;
|
|
1585
|
-
const recover = params.deps?.recover ?? recoverInstalledLaunchAgent;
|
|
1586
|
-
const state = await readState(service, { env: params.env }).catch(() => null);
|
|
1587
|
-
if (state?.loaded) return {
|
|
1588
|
-
attempted: false,
|
|
1589
|
-
recovered: false
|
|
1590
|
-
};
|
|
1591
|
-
if (state && !state.installed && !state.runtime?.missingSupervision) return {
|
|
1592
|
-
attempted: false,
|
|
1593
|
-
recovered: false
|
|
1594
|
-
};
|
|
1595
|
-
const recovered = await recover({
|
|
1596
|
-
result: "restarted",
|
|
1597
|
-
env: state?.env ?? params.env
|
|
1598
|
-
}).catch(() => null);
|
|
1599
|
-
if (!recovered) return {
|
|
1600
|
-
attempted: true,
|
|
1601
|
-
recovered: false,
|
|
1602
|
-
detail: "LaunchAgent was installed but not loaded; automatic bootstrap/kickstart recovery failed."
|
|
1603
|
-
};
|
|
1604
|
-
return {
|
|
1605
|
-
attempted: true,
|
|
1606
|
-
recovered: true,
|
|
1607
|
-
message: recovered.message
|
|
1608
|
-
};
|
|
1609
|
-
}
|
|
1610
|
-
async function recoverLaunchAgentAndRecheckGatewayHealth(params) {
|
|
1611
|
-
if (params.health.healthy) return {
|
|
1612
|
-
health: params.health,
|
|
1613
|
-
launchAgentRecovery: null
|
|
1614
|
-
};
|
|
1615
|
-
const launchAgentRecovery = await (params.deps?.recoverLaunchAgent ?? recoverInstalledLaunchAgentAfterUpdate)({
|
|
1616
|
-
service: params.service,
|
|
1617
|
-
env: params.env
|
|
1618
|
-
});
|
|
1619
|
-
if (!launchAgentRecovery.recovered) return {
|
|
1620
|
-
health: params.health,
|
|
1621
|
-
launchAgentRecovery
|
|
1622
|
-
};
|
|
1623
|
-
return {
|
|
1624
|
-
health: await (params.deps?.waitForHealthy ?? waitForGatewayHealthyRestart)({
|
|
1625
|
-
service: params.service,
|
|
1626
|
-
port: params.port,
|
|
1627
|
-
expectedVersion: params.expectedVersion,
|
|
1628
|
-
env: params.env
|
|
1629
|
-
}),
|
|
1630
|
-
launchAgentRecovery
|
|
1631
|
-
};
|
|
1632
|
-
}
|
|
1633
|
-
function formatPostUpdateGatewayRecoveryLine(platform) {
|
|
1634
|
-
const restartCommand = replaceCliName(formatCliCommand("daocore gateway restart"), CLI_NAME);
|
|
1635
|
-
const installCommand = replaceCliName(formatCliCommand("daocore gateway install --force"), CLI_NAME);
|
|
1636
|
-
const statusCommand = replaceCliName(formatCliCommand("daocore gateway status --deep"), CLI_NAME);
|
|
1637
|
-
if (platform === "darwin") return `Recovery: run \`${restartCommand}\`; if the LaunchAgent is installed but not loaded, run \`${installCommand}\` from the logged-in macOS user session, then rerun \`${statusCommand}\`.`;
|
|
1638
|
-
if (platform === "linux") return `Recovery: run \`${restartCommand}\`; if the systemd user service is missing, stale, or not active, run \`${installCommand}\` from the same user account, then rerun \`${statusCommand}\`.`;
|
|
1639
|
-
if (platform === "win32") return `Recovery: run \`${restartCommand}\`; if the gateway Scheduled Task or Windows login item is missing, stale, or not running, run \`${installCommand}\` from the same user account, then rerun \`${statusCommand}\`.`;
|
|
1640
|
-
return `Recovery: run \`${restartCommand}\`; if the local service manager reports the gateway service is missing, stale, or not running, run \`${installCommand}\` from the same user account, then rerun \`${statusCommand}\`.`;
|
|
1641
|
-
}
|
|
1642
|
-
function formatPostUpdateGatewayRecoveryInstructions(result, platform = process.platform) {
|
|
1643
|
-
const lines = [formatPostUpdateGatewayRecoveryLine(platform)];
|
|
1644
|
-
const beforeVersion = normalizeOptionalString(result.before?.version);
|
|
1645
|
-
if (isPackageManagerUpdateMode(result.mode) && beforeVersion) lines.push(`Rollback: reinstall DaoCore ${beforeVersion} with the same package manager, then rerun \`${replaceCliName(formatCliCommand("daocore gateway install --force"), CLI_NAME)}\`.`);
|
|
1646
|
-
return lines;
|
|
1647
|
-
}
|
|
1648
|
-
function formatGatewayAncestryBlockMessage(pid) {
|
|
1649
|
-
return `daocore update detected it is running inside the gateway process tree.
|
|
1650
|
-
Gateway PID ${pid} is an ancestor of this process, so this updater cannot safely stop or restart the gateway that owns it.
|
|
1651
|
-
Run \`${replaceCliName(formatCliCommand("daocore update"), CLI_NAME)}\` from a shell outside the gateway service, or stop the gateway service first and then update.`;
|
|
1652
|
-
}
|
|
1653
|
-
function parsePositivePid(value) {
|
|
1654
|
-
if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value);
|
|
1655
|
-
if (typeof value !== "string") return null;
|
|
1656
|
-
const trimmed = value.trim();
|
|
1657
|
-
if (!/^\d+$/u.test(trimmed)) return null;
|
|
1658
|
-
const parsed = Number.parseInt(trimmed, 10);
|
|
1659
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
1660
|
-
}
|
|
1661
|
-
function isInheritedGatewayRuntimePid(pid, env = process.env) {
|
|
1662
|
-
if (!isRunningInsideGatewayService(env)) return false;
|
|
1663
|
-
return parsePositivePid(env[GATEWAY_SERVICE_RUNTIME_PID_ENV]) === pid;
|
|
1664
|
-
}
|
|
1665
|
-
function isGatewayAncestorPid(pid, env = process.env) {
|
|
1666
|
-
const parsed = parsePositivePid(pid);
|
|
1667
|
-
if (parsed === null) return false;
|
|
1668
|
-
return isInheritedGatewayRuntimePid(parsed, env) || getSelfAndAncestorPidsSync().has(parsed);
|
|
1669
|
-
}
|
|
1670
|
-
function gatewayAncestryBlockMessage(pid) {
|
|
1671
|
-
return isGatewayAncestorPid(pid) ? formatGatewayAncestryBlockMessage(pid) : void 0;
|
|
1672
|
-
}
|
|
1673
|
-
function gatewayRuntimeAncestryBlockMessage(runtime) {
|
|
1674
|
-
return gatewayAncestryBlockMessage(runtime?.pid);
|
|
1675
|
-
}
|
|
1676
|
-
function serviceControlStdoutForMode(jsonMode) {
|
|
1677
|
-
return jsonMode ? JSON_MODE_SERVICE_STDOUT : process.stdout;
|
|
1678
|
-
}
|
|
1679
|
-
async function maybeStopManagedServiceBeforePackageUpdate(params) {
|
|
1680
|
-
let service;
|
|
1681
|
-
let serviceState;
|
|
1682
|
-
try {
|
|
1683
|
-
service = resolveGatewayService();
|
|
1684
|
-
serviceState = await readGatewayServiceState(service, { env: process.env });
|
|
1685
|
-
} catch {
|
|
1686
|
-
return {
|
|
1687
|
-
stopped: false,
|
|
1688
|
-
inspected: false,
|
|
1689
|
-
runtimeInspected: false,
|
|
1690
|
-
running: false
|
|
1691
|
-
};
|
|
1692
|
-
}
|
|
1693
|
-
const runtimeStatus = serviceState.runtime?.status;
|
|
1694
|
-
const runtimeInspected = runtimeStatus === "running" || runtimeStatus === "stopped";
|
|
1695
|
-
if (!serviceState.installed) return {
|
|
1696
|
-
stopped: false,
|
|
1697
|
-
inspected: true,
|
|
1698
|
-
runtimeInspected,
|
|
1699
|
-
running: serviceState.running,
|
|
1700
|
-
serviceEnv: serviceState.env
|
|
1701
|
-
};
|
|
1702
|
-
if (!params.shouldRestart) {
|
|
1703
|
-
if (!params.jsonMode && serviceState.running) defaultRuntime.log(theme.warn("--no-restart is set while the managed gateway service is running; the package update will not stop or restart that process."));
|
|
1704
|
-
return {
|
|
1705
|
-
stopped: false,
|
|
1706
|
-
inspected: true,
|
|
1707
|
-
runtimeInspected,
|
|
1708
|
-
running: serviceState.running,
|
|
1709
|
-
serviceEnv: serviceState.env
|
|
1710
|
-
};
|
|
1711
|
-
}
|
|
1712
|
-
if (!runtimeInspected) return {
|
|
1713
|
-
stopped: false,
|
|
1714
|
-
inspected: true,
|
|
1715
|
-
runtimeInspected: false,
|
|
1716
|
-
running: false,
|
|
1717
|
-
serviceEnv: serviceState.env
|
|
1718
|
-
};
|
|
1719
|
-
if (!serviceState.running) return {
|
|
1720
|
-
stopped: false,
|
|
1721
|
-
inspected: true,
|
|
1722
|
-
runtimeInspected: true,
|
|
1723
|
-
running: false,
|
|
1724
|
-
serviceEnv: serviceState.env
|
|
1725
|
-
};
|
|
1726
|
-
const blockMessage = gatewayRuntimeAncestryBlockMessage(serviceState.runtime);
|
|
1727
|
-
if (blockMessage) return {
|
|
1728
|
-
stopped: false,
|
|
1729
|
-
inspected: true,
|
|
1730
|
-
runtimeInspected: true,
|
|
1731
|
-
running: true,
|
|
1732
|
-
blockMessage,
|
|
1733
|
-
serviceEnv: serviceState.env
|
|
1734
|
-
};
|
|
1735
|
-
if (!params.jsonMode) defaultRuntime.log(theme.muted("Stopping managed gateway service before package update..."));
|
|
1736
|
-
await service.stop({
|
|
1737
|
-
env: serviceState.env,
|
|
1738
|
-
stdout: serviceControlStdoutForMode(params.jsonMode)
|
|
1739
|
-
});
|
|
1740
|
-
return {
|
|
1741
|
-
stopped: true,
|
|
1742
|
-
inspected: true,
|
|
1743
|
-
runtimeInspected: true,
|
|
1744
|
-
running: true,
|
|
1745
|
-
serviceEnv: serviceState.env
|
|
1746
|
-
};
|
|
1747
|
-
}
|
|
1748
|
-
async function maybeRestartServiceAfterFailedPackageUpdate(params) {
|
|
1749
|
-
if (!params.prePackageServiceStop?.stopped || !params.prePackageServiceStop.serviceEnv) return;
|
|
1750
|
-
try {
|
|
1751
|
-
await resolveGatewayService().restart({
|
|
1752
|
-
env: params.prePackageServiceStop.serviceEnv,
|
|
1753
|
-
stdout: serviceControlStdoutForMode(params.jsonMode)
|
|
1754
|
-
});
|
|
1755
|
-
if (!params.jsonMode) defaultRuntime.log(theme.muted("Restarted managed gateway service after failed update."));
|
|
1756
|
-
} catch (err) {
|
|
1757
|
-
const message = `Failed to restart managed gateway service after failed update: ${String(err)}`;
|
|
1758
|
-
if (params.jsonMode) defaultRuntime.error(message);
|
|
1759
|
-
else defaultRuntime.log(theme.warn(message));
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
function isRunningInsideGatewayService(env = process.env) {
|
|
1763
|
-
if (env.DAOCORE_SERVICE_MARKER?.trim() !== "daocore") return false;
|
|
1764
|
-
const serviceKind = env.DAOCORE_SERVICE_KIND?.trim();
|
|
1765
|
-
return !serviceKind || serviceKind === "gateway";
|
|
1766
|
-
}
|
|
1767
|
-
function shouldBlockPackageUpdateFromGatewayServiceEnv(params) {
|
|
1768
|
-
if (!isRunningInsideGatewayService()) return false;
|
|
1769
|
-
const stopState = params.prePackageServiceStop;
|
|
1770
|
-
if (!stopState?.inspected) return true;
|
|
1771
|
-
if (stopState.stopped) return false;
|
|
1772
|
-
if (!stopState.runtimeInspected) return true;
|
|
1773
|
-
return stopState.running;
|
|
1774
|
-
}
|
|
1775
|
-
function formatCommandFailure(stdout, stderr) {
|
|
1776
|
-
const detail = (stderr || stdout).trim();
|
|
1777
|
-
if (!detail) return "command returned a non-zero exit code";
|
|
1778
|
-
return detail.split("\n").slice(-3).join("\n");
|
|
1779
|
-
}
|
|
1780
|
-
function tryResolveInvocationCwd() {
|
|
1781
|
-
try {
|
|
1782
|
-
return process.cwd();
|
|
1783
|
-
} catch {
|
|
1784
|
-
return;
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
async function resolvePackageRuntimePreflightError(params) {
|
|
1788
|
-
if (!canResolveRegistryVersionForPackageTarget(params.tag)) return null;
|
|
1789
|
-
const target = params.tag.trim();
|
|
1790
|
-
if (!target) return null;
|
|
1791
|
-
const status = await fetchNpmPackageTargetStatus({
|
|
1792
|
-
target,
|
|
1793
|
-
timeoutMs: params.timeoutMs
|
|
1794
|
-
});
|
|
1795
|
-
if (status.error) return null;
|
|
1796
|
-
const runtime = await resolvePackageRuntimeForPreflight({
|
|
1797
|
-
nodeRunner: params.nodeRunner,
|
|
1798
|
-
timeoutMs: params.timeoutMs
|
|
1799
|
-
});
|
|
1800
|
-
if (nodeVersionSatisfiesEngine(runtime.version, status.nodeEngine) !== false) return null;
|
|
1801
|
-
const targetLabel = status.version ?? target;
|
|
1802
|
-
return [
|
|
1803
|
-
`${runtime.nodeRunner ? `Node ${runtime.version ?? "unknown"} at ${runtime.nodeRunner}` : `Node ${runtime.version ?? "unknown"}`} is too old for daocore@${targetLabel}.`,
|
|
1804
|
-
`The requested package requires ${status.nodeEngine}.`,
|
|
1805
|
-
runtime.nodeRunner ? "Upgrade the Node runtime that owns the managed Gateway service, then rerun `daocore update`." : "Upgrade Node to 22.19+ or Node 24, then rerun `daocore update`.",
|
|
1806
|
-
"Bare `npm i -g daocore` can silently install an older compatible release.",
|
|
1807
|
-
"After upgrading Node, use `npm i -g daocore@latest`."
|
|
1808
|
-
].join("\n");
|
|
1809
|
-
}
|
|
1810
|
-
async function resolvePackageRuntimeForPreflight(params) {
|
|
1811
|
-
const nodeRunner = normalizeOptionalString(params.nodeRunner);
|
|
1812
|
-
if (!nodeRunner) return { version: process.versions.node ?? null };
|
|
1813
|
-
const res = await runCommandWithTimeout([nodeRunner, "--version"], { timeoutMs: Math.min(params.timeoutMs ?? 1e4, 1e4) }).catch(() => null);
|
|
1814
|
-
return {
|
|
1815
|
-
version: (res?.code === 0 ? res.stdout.trim() : "").replace(/^v/u, "") || null,
|
|
1816
|
-
nodeRunner
|
|
1817
|
-
};
|
|
1818
|
-
}
|
|
1819
|
-
function resolveServiceRefreshEnv(env, invocationCwd) {
|
|
1820
|
-
const resolvedEnv = { ...env };
|
|
1821
|
-
for (const key of SERVICE_REFRESH_PATH_ENV_KEYS) {
|
|
1822
|
-
const rawValue = resolvedEnv[key]?.trim();
|
|
1823
|
-
if (!rawValue) continue;
|
|
1824
|
-
if (rawValue.startsWith("~") || path.isAbsolute(rawValue) || path.win32.isAbsolute(rawValue)) {
|
|
1825
|
-
resolvedEnv[key] = rawValue;
|
|
1826
|
-
continue;
|
|
1827
|
-
}
|
|
1828
|
-
if (!invocationCwd) {
|
|
1829
|
-
resolvedEnv[key] = rawValue;
|
|
1830
|
-
continue;
|
|
1831
|
-
}
|
|
1832
|
-
resolvedEnv[key] = path.resolve(invocationCwd, rawValue);
|
|
1833
|
-
}
|
|
1834
|
-
return resolvedEnv;
|
|
1835
|
-
}
|
|
1836
|
-
function disableUpdatedPackageCompileCacheEnv(env) {
|
|
1837
|
-
return {
|
|
1838
|
-
...env,
|
|
1839
|
-
NODE_DISABLE_COMPILE_CACHE: "1"
|
|
1840
|
-
};
|
|
1841
|
-
}
|
|
1842
|
-
function stripGatewayServiceMarkerEnv(env) {
|
|
1843
|
-
const resolvedEnv = { ...env };
|
|
1844
|
-
delete resolvedEnv.DAOCORE_SERVICE_MARKER;
|
|
1845
|
-
delete resolvedEnv.DAOCORE_SERVICE_KIND;
|
|
1846
|
-
delete resolvedEnv[GATEWAY_SERVICE_RUNTIME_PID_ENV];
|
|
1847
|
-
return resolvedEnv;
|
|
1848
|
-
}
|
|
1849
|
-
function resolveUpdatedInstallCommandEnv(env, invocationCwd) {
|
|
1850
|
-
return disableUpdatedPackageCompileCacheEnv(resolveServiceRefreshEnv(env, invocationCwd));
|
|
1851
|
-
}
|
|
1852
|
-
function resolvePostInstallDoctorEnv(params) {
|
|
1853
|
-
const resolvedEnv = disableUpdatedPackageCompileCacheEnv(params?.baseEnv ?? process.env);
|
|
1854
|
-
if (!params?.serviceEnv) return resolvedEnv;
|
|
1855
|
-
const serviceEnv = resolveServiceRefreshEnv(params.serviceEnv, params.invocationCwd);
|
|
1856
|
-
for (const key of POST_INSTALL_DOCTOR_SERVICE_ENV_KEYS) if (serviceEnv[key]?.trim()) resolvedEnv[key] = serviceEnv[key];
|
|
1857
|
-
return resolvedEnv;
|
|
1858
|
-
}
|
|
1859
|
-
function resolveUpdatedGatewayRestartPort(params) {
|
|
1860
|
-
return resolveGatewayPort(params.config, params.serviceEnv ?? params.processEnv ?? process.env);
|
|
1861
|
-
}
|
|
1862
|
-
function resolvePostUpdateServiceStateReadEnv(params) {
|
|
1863
|
-
if (isPackageManagerUpdateMode(params.updateMode) && params.prePackageServiceEnv) return params.prePackageServiceEnv;
|
|
1864
|
-
return params.processEnv ?? process.env;
|
|
1865
|
-
}
|
|
1866
|
-
function printDryRunPreview(preview, jsonMode) {
|
|
1867
|
-
if (jsonMode) {
|
|
1868
|
-
defaultRuntime.writeJson(preview);
|
|
1869
|
-
return;
|
|
1870
|
-
}
|
|
1871
|
-
defaultRuntime.log(theme.heading("Update dry-run"));
|
|
1872
|
-
defaultRuntime.log(theme.muted("No changes were applied."));
|
|
1873
|
-
defaultRuntime.log("");
|
|
1874
|
-
defaultRuntime.log(` Root: ${theme.muted(preview.root)}`);
|
|
1875
|
-
defaultRuntime.log(` Install kind: ${theme.muted(preview.installKind)}`);
|
|
1876
|
-
defaultRuntime.log(` Mode: ${theme.muted(preview.mode)}`);
|
|
1877
|
-
defaultRuntime.log(` Channel: ${theme.muted(preview.effectiveChannel)}`);
|
|
1878
|
-
defaultRuntime.log(` Tag/spec: ${theme.muted(preview.tag)}`);
|
|
1879
|
-
if (preview.currentVersion) defaultRuntime.log(` Current version: ${theme.muted(preview.currentVersion)}`);
|
|
1880
|
-
if (preview.targetVersion) defaultRuntime.log(` Target version: ${theme.muted(preview.targetVersion)}`);
|
|
1881
|
-
if (preview.downgradeRisk) defaultRuntime.log(theme.warn(" Downgrade confirmation would be required in a real run."));
|
|
1882
|
-
defaultRuntime.log("");
|
|
1883
|
-
defaultRuntime.log(theme.heading("Planned actions:"));
|
|
1884
|
-
for (const action of preview.actions) defaultRuntime.log(` - ${action}`);
|
|
1885
|
-
if (preview.notes.length > 0) {
|
|
1886
|
-
defaultRuntime.log("");
|
|
1887
|
-
defaultRuntime.log(theme.heading("Notes:"));
|
|
1888
|
-
for (const note of preview.notes) defaultRuntime.log(` - ${theme.muted(note)}`);
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
async function refreshGatewayServiceEnv(params) {
|
|
1892
|
-
const args = [
|
|
1893
|
-
"gateway",
|
|
1894
|
-
"install",
|
|
1895
|
-
"--force"
|
|
1896
|
-
];
|
|
1897
|
-
if (params.jsonMode) args.push("--json");
|
|
1898
|
-
const entrypoint = await resolveGatewayInstallEntrypoint(params.result.root);
|
|
1899
|
-
if (entrypoint) {
|
|
1900
|
-
const res = await runCommandWithTimeout([
|
|
1901
|
-
params.nodeRunner ?? resolveNodeRunner(),
|
|
1902
|
-
entrypoint,
|
|
1903
|
-
...args
|
|
1904
|
-
], {
|
|
1905
|
-
cwd: params.result.root,
|
|
1906
|
-
env: resolveUpdatedInstallCommandEnv(params.env ?? process.env, params.invocationCwd),
|
|
1907
|
-
timeoutMs: SERVICE_REFRESH_TIMEOUT_MS
|
|
1908
|
-
});
|
|
1909
|
-
if (res.code === 0) return;
|
|
1910
|
-
throw new Error(`updated install refresh failed (${entrypoint}): ${formatCommandFailure(res.stdout, res.stderr)}`);
|
|
1911
|
-
}
|
|
1912
|
-
if (isPackageManagerUpdateMode(params.result.mode)) throw new Error(`updated install entrypoint not found under ${params.result.root ?? "unknown"}`);
|
|
1913
|
-
await runDaemonInstall({
|
|
1914
|
-
force: true,
|
|
1915
|
-
json: params.jsonMode || void 0
|
|
1916
|
-
});
|
|
1917
|
-
}
|
|
1918
|
-
async function runUpdatedInstallGatewayRestart(params) {
|
|
1919
|
-
const entrypoint = await resolveGatewayInstallEntrypoint(params.result.root);
|
|
1920
|
-
if (!entrypoint) throw new Error(`updated install entrypoint not found under ${params.result.root ?? "unknown"}`);
|
|
1921
|
-
const args = ["gateway", "restart"];
|
|
1922
|
-
if (params.jsonMode) args.push("--json");
|
|
1923
|
-
const res = await runCommandWithTimeout([
|
|
1924
|
-
params.nodeRunner ?? resolveNodeRunner(),
|
|
1925
|
-
entrypoint,
|
|
1926
|
-
...args
|
|
1927
|
-
], {
|
|
1928
|
-
cwd: params.result.root,
|
|
1929
|
-
env: resolveUpdatedInstallCommandEnv(params.env ?? process.env, params.invocationCwd),
|
|
1930
|
-
timeoutMs: SERVICE_REFRESH_TIMEOUT_MS
|
|
1931
|
-
});
|
|
1932
|
-
if (res.code === 0) return true;
|
|
1933
|
-
throw new Error(`updated install restart failed (${entrypoint}): ${formatCommandFailure(res.stdout, res.stderr)}`);
|
|
1934
|
-
}
|
|
1935
|
-
async function tryInstallShellCompletion(opts) {
|
|
1936
|
-
if (opts.jsonMode || !process.stdin.isTTY) return;
|
|
1937
|
-
const status = await checkShellCompletionStatus(CLI_NAME);
|
|
1938
|
-
if (status.usesSlowPattern) {
|
|
1939
|
-
defaultRuntime.log(theme.muted("Upgrading shell completion to cached version..."));
|
|
1940
|
-
if (await ensureCompletionCacheExists(CLI_NAME)) await installCompletion(status.shell, true, CLI_NAME);
|
|
1941
|
-
return;
|
|
1942
|
-
}
|
|
1943
|
-
if (status.profileInstalled && !status.cacheExists) {
|
|
1944
|
-
defaultRuntime.log(theme.muted("Regenerating shell completion cache..."));
|
|
1945
|
-
await ensureCompletionCacheExists(CLI_NAME);
|
|
1946
|
-
return;
|
|
1947
|
-
}
|
|
1948
|
-
if (!status.profileInstalled) {
|
|
1949
|
-
defaultRuntime.log("");
|
|
1950
|
-
defaultRuntime.log(theme.heading("Shell completion"));
|
|
1951
|
-
const shouldInstall = await confirm({
|
|
1952
|
-
message: stylePromptMessage(`Enable ${status.shell} shell completion for ${CLI_NAME}?`),
|
|
1953
|
-
initialValue: true
|
|
1954
|
-
});
|
|
1955
|
-
if (isCancel(shouldInstall) || !shouldInstall) {
|
|
1956
|
-
if (!opts.skipPrompt) defaultRuntime.log(theme.muted(`Skipped. Run \`${replaceCliName(formatCliCommand("daocore completion --install"), CLI_NAME)}\` later to enable.`));
|
|
1957
|
-
return;
|
|
1958
|
-
}
|
|
1959
|
-
if (!await ensureCompletionCacheExists(CLI_NAME)) {
|
|
1960
|
-
defaultRuntime.log(theme.warn("Failed to generate completion cache."));
|
|
1961
|
-
return;
|
|
1962
|
-
}
|
|
1963
|
-
await installCompletion(status.shell, opts.skipPrompt, CLI_NAME);
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
async function tryRealpathOrResolve(value) {
|
|
1967
|
-
try {
|
|
1968
|
-
return await fs$1.realpath(path.resolve(value));
|
|
1969
|
-
} catch {
|
|
1970
|
-
return path.resolve(value);
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
function isNodeExecutable(value) {
|
|
1974
|
-
const base = normalizeOptionalString(value ? path.basename(value) : void 0)?.toLowerCase();
|
|
1975
|
-
return base === "node" || base === "node.exe";
|
|
1976
|
-
}
|
|
1977
|
-
function resolveManagedServiceNodeRunner(command) {
|
|
1978
|
-
const args = command?.programArguments;
|
|
1979
|
-
if (!args?.length) return;
|
|
1980
|
-
const gatewayIndex = args.indexOf("gateway");
|
|
1981
|
-
if (gatewayIndex <= 1) return;
|
|
1982
|
-
const runner = args[gatewayIndex - 2];
|
|
1983
|
-
return isNodeExecutable(runner) ? runner : void 0;
|
|
1984
|
-
}
|
|
1985
|
-
/**
|
|
1986
|
-
* Resolve the node binary baked into the managed gateway service unit,
|
|
1987
|
-
* independent of any package root redirect. This detects when the user's
|
|
1988
|
-
* current PATH-resolved node differs from the service's baked node even
|
|
1989
|
-
* when the package root is the same.
|
|
1990
|
-
*/
|
|
1991
|
-
async function resolveManagedServiceNodeRunnerOverride() {
|
|
1992
|
-
const serviceNode = resolveManagedServiceNodeRunner(await resolveGatewayService().readCommand(process.env).catch(() => null));
|
|
1993
|
-
if (!serviceNode) return;
|
|
1994
|
-
const currentNode = resolveNodeRunner();
|
|
1995
|
-
const [serviceNodeReal, currentNodeReal] = await Promise.all([tryRealpathOrResolve(serviceNode), tryRealpathOrResolve(currentNode)]);
|
|
1996
|
-
if (serviceNodeReal === currentNodeReal) return;
|
|
1997
|
-
return serviceNode;
|
|
1998
|
-
}
|
|
1999
|
-
async function resolveManagedServicePackageUpdateRoot(params) {
|
|
2000
|
-
const command = await resolveGatewayService().readCommand(process.env).catch(() => null);
|
|
2001
|
-
const layout = await summarizeGatewayServiceLayout(command);
|
|
2002
|
-
const serviceRoot = layout?.packageRoot;
|
|
2003
|
-
if (!serviceRoot || layout.entrypointSourceCheckout === true) return null;
|
|
2004
|
-
const [currentRootReal, serviceRootReal] = await Promise.all([tryRealpathOrResolve(params.root), tryRealpathOrResolve(serviceRoot)]);
|
|
2005
|
-
if (currentRootReal === serviceRootReal) return null;
|
|
2006
|
-
const nodeRunner = resolveManagedServiceNodeRunner(command);
|
|
2007
|
-
return {
|
|
2008
|
-
root: serviceRoot,
|
|
2009
|
-
previousRoot: params.root,
|
|
2010
|
-
...nodeRunner ? { nodeRunner } : {}
|
|
2011
|
-
};
|
|
2012
|
-
}
|
|
2013
|
-
async function runPackageInstallUpdate(params) {
|
|
2014
|
-
const manager = await resolveGlobalManager({
|
|
2015
|
-
root: params.root,
|
|
2016
|
-
installKind: params.installKind,
|
|
2017
|
-
timeoutMs: params.timeoutMs
|
|
2018
|
-
});
|
|
2019
|
-
const installEnv = await createGlobalInstallEnv();
|
|
2020
|
-
const runCommand = createGlobalCommandRunner();
|
|
2021
|
-
const installTarget = await resolveGlobalInstallTarget({
|
|
2022
|
-
manager,
|
|
2023
|
-
runCommand,
|
|
2024
|
-
timeoutMs: params.timeoutMs,
|
|
2025
|
-
pkgRoot: params.root,
|
|
2026
|
-
honorPackageRoot: params.honorPackageRoot === true
|
|
2027
|
-
});
|
|
2028
|
-
const pkgRoot = installTarget.packageRoot;
|
|
2029
|
-
const packageName = (pkgRoot ? await readPackageName(pkgRoot) : await readPackageName(params.root)) ?? "@gaodefa/daocore";
|
|
2030
|
-
const installSpec = resolveGlobalInstallSpec({
|
|
2031
|
-
packageName,
|
|
2032
|
-
tag: params.tag,
|
|
2033
|
-
env: installEnv
|
|
2034
|
-
});
|
|
2035
|
-
const beforeVersion = pkgRoot ? await readPackageVersion(pkgRoot) : null;
|
|
2036
|
-
if (pkgRoot) await cleanupGlobalRenameDirs({
|
|
2037
|
-
globalRoot: path.dirname(pkgRoot),
|
|
2038
|
-
packageName
|
|
2039
|
-
});
|
|
2040
|
-
const diskWarning = createLowDiskSpaceWarning({
|
|
2041
|
-
targetPath: pkgRoot ? path.dirname(pkgRoot) : params.root,
|
|
2042
|
-
purpose: "global package update"
|
|
2043
|
-
});
|
|
2044
|
-
if (diskWarning) if (params.jsonMode) defaultRuntime.error(`Warning: ${diskWarning}`);
|
|
2045
|
-
else defaultRuntime.log(theme.warn(diskWarning));
|
|
2046
|
-
const packageUpdate = await runGlobalPackageUpdateSteps({
|
|
2047
|
-
installTarget,
|
|
2048
|
-
installSpec,
|
|
2049
|
-
packageName,
|
|
2050
|
-
packageRoot: pkgRoot,
|
|
2051
|
-
runCommand,
|
|
2052
|
-
timeoutMs: params.timeoutMs,
|
|
2053
|
-
...installEnv === void 0 ? {} : { env: installEnv },
|
|
2054
|
-
runStep: (stepParams) => runUpdateStep({
|
|
2055
|
-
...stepParams,
|
|
2056
|
-
progress: params.progress
|
|
2057
|
-
}),
|
|
2058
|
-
postVerifyStep: async (verifiedPackageRoot) => {
|
|
2059
|
-
const entryPath = await resolveGatewayInstallEntrypoint(verifiedPackageRoot);
|
|
2060
|
-
if (entryPath) {
|
|
2061
|
-
await createUpdateConfigSnapshot();
|
|
2062
|
-
const candidateHostVersion = await readPackageVersion(verifiedPackageRoot);
|
|
2063
|
-
return await runUpdateStep({
|
|
2064
|
-
name: `${CLI_NAME} doctor`,
|
|
2065
|
-
argv: [
|
|
2066
|
-
params.nodeRunner ?? resolveNodeRunner(),
|
|
2067
|
-
entryPath,
|
|
2068
|
-
"doctor",
|
|
2069
|
-
"--non-interactive",
|
|
2070
|
-
"--fix"
|
|
2071
|
-
],
|
|
2072
|
-
cwd: verifiedPackageRoot,
|
|
2073
|
-
env: {
|
|
2074
|
-
...resolvePostInstallDoctorEnv({
|
|
2075
|
-
serviceEnv: params.managedServiceEnv,
|
|
2076
|
-
invocationCwd: params.invocationCwd
|
|
2077
|
-
}),
|
|
2078
|
-
DAOCORE_UPDATE_IN_PROGRESS: "1",
|
|
2079
|
-
[UPDATE_DEFER_CONFIGURED_PLUGIN_INSTALL_REPAIR_ENV]: "1",
|
|
2080
|
-
[UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE_ENV]: "1",
|
|
2081
|
-
...candidateHostVersion === null ? {} : { DAOCORE_COMPATIBILITY_HOST_VERSION: candidateHostVersion }
|
|
2082
|
-
},
|
|
2083
|
-
timeoutMs: params.timeoutMs,
|
|
2084
|
-
progress: params.progress
|
|
2085
|
-
});
|
|
2086
|
-
}
|
|
2087
|
-
return null;
|
|
2088
|
-
}
|
|
2089
|
-
});
|
|
2090
|
-
return {
|
|
2091
|
-
status: packageUpdate.failedStep ? "error" : "ok",
|
|
2092
|
-
mode: manager,
|
|
2093
|
-
root: packageUpdate.verifiedPackageRoot ?? params.root,
|
|
2094
|
-
reason: packageUpdate.failedStep ? packageUpdate.failedStep.name : void 0,
|
|
2095
|
-
before: { version: beforeVersion },
|
|
2096
|
-
after: { version: packageUpdate.afterVersion ?? beforeVersion },
|
|
2097
|
-
steps: packageUpdate.steps,
|
|
2098
|
-
durationMs: Date.now() - params.startedAt
|
|
2099
|
-
};
|
|
2100
|
-
}
|
|
2101
|
-
async function runGitUpdate(params) {
|
|
2102
|
-
const updateRoot = params.switchToGit ? resolveGitInstallDir() : params.root;
|
|
2103
|
-
const effectiveTimeout = params.timeoutMs ?? DEFAULT_UPDATE_STEP_TIMEOUT_MS;
|
|
2104
|
-
const installEnv = await createGlobalInstallEnv();
|
|
2105
|
-
const cloneStep = params.switchToGit ? await ensureGitCheckout({
|
|
2106
|
-
dir: updateRoot,
|
|
2107
|
-
env: installEnv,
|
|
2108
|
-
timeoutMs: effectiveTimeout,
|
|
2109
|
-
progress: params.progress
|
|
2110
|
-
}) : null;
|
|
2111
|
-
if (cloneStep && cloneStep.exitCode !== 0) {
|
|
2112
|
-
const result = {
|
|
2113
|
-
status: "error",
|
|
2114
|
-
mode: "git",
|
|
2115
|
-
root: updateRoot,
|
|
2116
|
-
reason: cloneStep.name,
|
|
2117
|
-
steps: [cloneStep],
|
|
2118
|
-
durationMs: Date.now() - params.startedAt
|
|
2119
|
-
};
|
|
2120
|
-
params.stop();
|
|
2121
|
-
printResult(result, {
|
|
2122
|
-
...params.opts,
|
|
2123
|
-
hideSteps: params.showProgress
|
|
2124
|
-
});
|
|
2125
|
-
defaultRuntime.exit(1);
|
|
2126
|
-
return result;
|
|
2127
|
-
}
|
|
2128
|
-
const updateResult = await runGatewayUpdate({
|
|
2129
|
-
cwd: updateRoot,
|
|
2130
|
-
argv1: params.switchToGit ? void 0 : process.argv[1],
|
|
2131
|
-
timeoutMs: params.timeoutMs,
|
|
2132
|
-
progress: params.progress,
|
|
2133
|
-
channel: params.channel,
|
|
2134
|
-
tag: params.tag,
|
|
2135
|
-
devTargetRef: params.devTargetRef,
|
|
2136
|
-
deferConfiguredPluginInstallRepair: true
|
|
2137
|
-
});
|
|
2138
|
-
const steps = [...cloneStep ? [cloneStep] : [], ...updateResult.steps];
|
|
2139
|
-
if (params.switchToGit && updateResult.status === "ok") {
|
|
2140
|
-
const installTarget = await resolveGlobalInstallTarget({
|
|
2141
|
-
manager: await resolveGlobalManager({
|
|
2142
|
-
root: params.root,
|
|
2143
|
-
installKind: params.installKind,
|
|
2144
|
-
timeoutMs: effectiveTimeout
|
|
2145
|
-
}),
|
|
2146
|
-
runCommand: createGlobalCommandRunner(),
|
|
2147
|
-
timeoutMs: effectiveTimeout,
|
|
2148
|
-
pkgRoot: params.root
|
|
2149
|
-
});
|
|
2150
|
-
const installStep = await runUpdateStep({
|
|
2151
|
-
name: "global install",
|
|
2152
|
-
argv: globalInstallArgs(installTarget, updateRoot, void 0, installTarget.manager === "pnpm" ? resolvePnpmGlobalDirFromGlobalRoot(installTarget.globalRoot) : null),
|
|
2153
|
-
cwd: updateRoot,
|
|
2154
|
-
env: installEnv,
|
|
2155
|
-
timeoutMs: effectiveTimeout,
|
|
2156
|
-
progress: params.progress
|
|
2157
|
-
});
|
|
2158
|
-
steps.push(installStep);
|
|
2159
|
-
const failedStep = installStep.exitCode !== 0 ? installStep : null;
|
|
2160
|
-
return {
|
|
2161
|
-
...updateResult,
|
|
2162
|
-
status: updateResult.status === "ok" && !failedStep ? "ok" : "error",
|
|
2163
|
-
steps,
|
|
2164
|
-
durationMs: Date.now() - params.startedAt
|
|
2165
|
-
};
|
|
2166
|
-
}
|
|
2167
|
-
return {
|
|
2168
|
-
...updateResult,
|
|
2169
|
-
steps,
|
|
2170
|
-
durationMs: Date.now() - params.startedAt
|
|
2171
|
-
};
|
|
2172
|
-
}
|
|
2173
|
-
async function updatePluginsAfterCoreUpdate(params) {
|
|
2174
|
-
if (!params.configSnapshot.valid) {
|
|
2175
|
-
const invalid = buildInvalidConfigPostCoreUpdateResult();
|
|
2176
|
-
if (!params.opts.json) {
|
|
2177
|
-
defaultRuntime.log(theme.error(invalid.message));
|
|
2178
|
-
for (const line of invalid.guidance) defaultRuntime.log(theme.muted(` ${line}`));
|
|
2179
|
-
}
|
|
2180
|
-
return invalid.result;
|
|
2181
|
-
}
|
|
2182
|
-
const pluginLogger = params.opts.json ? {} : {
|
|
2183
|
-
info: (msg) => defaultRuntime.log(msg),
|
|
2184
|
-
warn: (msg) => defaultRuntime.log(theme.warn(msg)),
|
|
2185
|
-
error: (msg) => defaultRuntime.log(theme.error(msg))
|
|
2186
|
-
};
|
|
2187
|
-
if (!params.opts.json) {
|
|
2188
|
-
defaultRuntime.log("");
|
|
2189
|
-
defaultRuntime.log(theme.heading("Updating plugins..."));
|
|
2190
|
-
}
|
|
2191
|
-
const warnings = [];
|
|
2192
|
-
const pluginInstallRecords = params.pluginInstallRecords ?? await loadInstalledPluginIndexInstallRecords();
|
|
2193
|
-
const syncResult = await syncPluginsForUpdateChannel({
|
|
2194
|
-
config: withPluginInstallRecords(params.configSnapshot.sourceConfig, pluginInstallRecords),
|
|
2195
|
-
channel: params.channel,
|
|
2196
|
-
workspaceDir: params.root,
|
|
2197
|
-
externalizedBundledPluginBridges: await listPersistedBundledPluginLocationBridges({ workspaceDir: params.root }),
|
|
2198
|
-
logger: pluginLogger
|
|
2199
|
-
});
|
|
2200
|
-
for (const error of syncResult.summary.errors) warnings.push(createPostUpdatePluginWarning({ reason: error }));
|
|
2201
|
-
let pluginConfig = syncResult.config;
|
|
2202
|
-
const integrityDrifts = [];
|
|
2203
|
-
const pluginUpdateOutcomes = [];
|
|
2204
|
-
let pluginsChanged = syncResult.changed || params.configChanged === true;
|
|
2205
|
-
let npmPluginsChanged = false;
|
|
2206
|
-
const onPluginIntegrityDrift = async (drift) => {
|
|
2207
|
-
integrityDrifts.push({
|
|
2208
|
-
pluginId: drift.pluginId,
|
|
2209
|
-
spec: drift.spec,
|
|
2210
|
-
expectedIntegrity: drift.expectedIntegrity,
|
|
2211
|
-
actualIntegrity: drift.actualIntegrity,
|
|
2212
|
-
...drift.resolvedSpec ? { resolvedSpec: drift.resolvedSpec } : {},
|
|
2213
|
-
...drift.resolvedVersion ? { resolvedVersion: drift.resolvedVersion } : {},
|
|
2214
|
-
action: "aborted"
|
|
2215
|
-
});
|
|
2216
|
-
if (!params.opts.json) {
|
|
2217
|
-
const specLabel = drift.resolvedSpec ?? drift.spec;
|
|
2218
|
-
defaultRuntime.log(theme.warn(`Integrity drift detected for "${drift.pluginId}" (${specLabel})\nExpected: ${drift.expectedIntegrity}\nActual: ${drift.actualIntegrity}
|
|
2219
|
-
Plugin update aborted. Reinstall the plugin only if you trust the new artifact.`));
|
|
2220
|
-
}
|
|
2221
|
-
return false;
|
|
2222
|
-
};
|
|
2223
|
-
const collectMissingPayloadWarnings = async (records) => {
|
|
2224
|
-
const missing = await collectMissingPluginInstallPayloads({
|
|
2225
|
-
records,
|
|
2226
|
-
config: pluginConfig,
|
|
2227
|
-
skipDisabledPlugins: true,
|
|
2228
|
-
syncOfficialPluginInstalls: true
|
|
2229
|
-
});
|
|
2230
|
-
if (missing.length === 0) return [];
|
|
2231
|
-
const missingIds = missing.map((entry) => entry.pluginId);
|
|
2232
|
-
for (const entry of missing) {
|
|
2233
|
-
const warning = createPostUpdatePluginWarning({
|
|
2234
|
-
pluginId: entry.pluginId,
|
|
2235
|
-
reason: `Plugin install payload missing after update: ${formatMissingPluginPayloadReason(entry)}.`
|
|
2236
|
-
});
|
|
2237
|
-
warnings.push(warning);
|
|
2238
|
-
pluginUpdateOutcomes.push({
|
|
2239
|
-
pluginId: entry.pluginId,
|
|
2240
|
-
status: "error",
|
|
2241
|
-
message: warning.message
|
|
2242
|
-
});
|
|
2243
|
-
if (!params.opts.json) defaultRuntime.log(theme.warn(warning.message));
|
|
2244
|
-
}
|
|
2245
|
-
const repairResult = await updateNpmInstalledPlugins({
|
|
2246
|
-
config: pluginConfig,
|
|
2247
|
-
pluginIds: missingIds,
|
|
2248
|
-
timeoutMs: params.timeoutMs,
|
|
2249
|
-
updateChannel: params.channel,
|
|
2250
|
-
skipDisabledPlugins: true,
|
|
2251
|
-
syncOfficialPluginInstalls: true,
|
|
2252
|
-
disableOnFailure: true,
|
|
2253
|
-
logger: pluginLogger,
|
|
2254
|
-
onIntegrityDrift: onPluginIntegrityDrift
|
|
2255
|
-
});
|
|
2256
|
-
pluginConfig = repairResult.config;
|
|
2257
|
-
pluginsChanged ||= repairResult.changed;
|
|
2258
|
-
npmPluginsChanged ||= repairResult.changed;
|
|
2259
|
-
pluginUpdateOutcomes.push(...repairResult.outcomes);
|
|
2260
|
-
return missingIds;
|
|
2261
|
-
};
|
|
2262
|
-
const missingPayloadIds = await collectMissingPayloadWarnings(pluginInstallRecords);
|
|
2263
|
-
const npmResult = await updateNpmInstalledPlugins({
|
|
2264
|
-
config: pluginConfig,
|
|
2265
|
-
timeoutMs: params.timeoutMs,
|
|
2266
|
-
updateChannel: params.channel,
|
|
2267
|
-
skipIds: new Set([...syncResult.summary.switchedToNpm, ...missingPayloadIds]),
|
|
2268
|
-
skipDisabledPlugins: true,
|
|
2269
|
-
syncOfficialPluginInstalls: true,
|
|
2270
|
-
disableOnFailure: true,
|
|
2271
|
-
logger: pluginLogger,
|
|
2272
|
-
onIntegrityDrift: onPluginIntegrityDrift
|
|
2273
|
-
});
|
|
2274
|
-
pluginConfig = npmResult.config;
|
|
2275
|
-
pluginsChanged ||= npmResult.changed;
|
|
2276
|
-
npmPluginsChanged ||= npmResult.changed;
|
|
2277
|
-
for (const rawOutcome of npmResult.outcomes) {
|
|
2278
|
-
const guided = createGuidedPostUpdatePluginOutcome(rawOutcome);
|
|
2279
|
-
pluginUpdateOutcomes.push(guided.outcome);
|
|
2280
|
-
if (guided.warning) warnings.push(guided.warning);
|
|
2281
|
-
}
|
|
2282
|
-
const remainingMissingPayloads = await collectMissingPluginInstallPayloads({
|
|
2283
|
-
records: pluginConfig.plugins?.installs ?? {},
|
|
2284
|
-
config: pluginConfig,
|
|
2285
|
-
skipDisabledPlugins: true,
|
|
2286
|
-
syncOfficialPluginInstalls: true
|
|
2287
|
-
});
|
|
2288
|
-
pluginUpdateOutcomes.push(...remainingMissingPayloads.filter((entry) => !missingPayloadIds.includes(entry.pluginId)).map((entry) => {
|
|
2289
|
-
const warning = createPostUpdatePluginWarning({
|
|
2290
|
-
pluginId: entry.pluginId,
|
|
2291
|
-
reason: `Plugin install payload missing after update: ${formatMissingPluginPayloadReason(entry)}.`
|
|
2292
|
-
});
|
|
2293
|
-
warnings.push(warning);
|
|
2294
|
-
return {
|
|
2295
|
-
pluginId: entry.pluginId,
|
|
2296
|
-
status: "error",
|
|
2297
|
-
message: warning.message
|
|
2298
|
-
};
|
|
2299
|
-
}));
|
|
2300
|
-
const convergenceBaselineRecords = pluginConfig.plugins?.installs ?? {};
|
|
2301
|
-
const convergence = await runPostCorePluginConvergence({
|
|
2302
|
-
cfg: pluginConfig,
|
|
2303
|
-
env: process.env,
|
|
2304
|
-
baselineInstallRecords: convergenceBaselineRecords
|
|
2305
|
-
});
|
|
2306
|
-
for (const change of convergence.changes) if (!params.opts.json) defaultRuntime.log(theme.muted(change));
|
|
2307
|
-
const convergenceFolded = convergenceWarningsToOutcomes(convergence);
|
|
2308
|
-
for (const warning of convergenceFolded.warnings) {
|
|
2309
|
-
warnings.push(warning);
|
|
2310
|
-
if (!params.opts.json) {
|
|
2311
|
-
defaultRuntime.log(theme.warn(warning.message));
|
|
2312
|
-
for (const guidance of warning.guidance) defaultRuntime.log(theme.muted(` ${guidance}`));
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
pluginUpdateOutcomes.push(...convergenceFolded.outcomes);
|
|
2316
|
-
const convergenceErrored = convergenceFolded.errored;
|
|
2317
|
-
pluginConfig = withPluginInstallRecords(pluginConfig, convergence.installRecords);
|
|
2318
|
-
if (convergence.changes.length > 0) pluginsChanged = true;
|
|
2319
|
-
if (pluginsChanged) {
|
|
2320
|
-
const nextInstallRecords = pluginConfig.plugins?.installs ?? {};
|
|
2321
|
-
let nextConfig = withoutPluginInstallRecords(pluginConfig);
|
|
2322
|
-
if (params.restoredAuthoredChannels !== void 0) nextConfig = {
|
|
2323
|
-
...nextConfig,
|
|
2324
|
-
channels: structuredClone(params.restoredAuthoredChannels)
|
|
2325
|
-
};
|
|
2326
|
-
await commitPluginInstallRecordsWithConfig({
|
|
2327
|
-
previousInstallRecords: pluginInstallRecords,
|
|
2328
|
-
nextInstallRecords,
|
|
2329
|
-
nextConfig,
|
|
2330
|
-
baseHash: params.configSnapshot.hash
|
|
2331
|
-
});
|
|
2332
|
-
await refreshPluginRegistryAfterConfigMutation({
|
|
2333
|
-
config: nextConfig,
|
|
2334
|
-
reason: "source-changed",
|
|
2335
|
-
workspaceDir: params.root,
|
|
2336
|
-
installRecords: nextInstallRecords,
|
|
2337
|
-
logger: pluginLogger
|
|
2338
|
-
});
|
|
2339
|
-
}
|
|
2340
|
-
if (params.opts.json) return {
|
|
2341
|
-
status: convergenceErrored ? "error" : warnings.length > 0 ? "warning" : "ok",
|
|
2342
|
-
changed: pluginsChanged,
|
|
2343
|
-
warnings,
|
|
2344
|
-
sync: {
|
|
2345
|
-
changed: syncResult.changed,
|
|
2346
|
-
switchedToBundled: syncResult.summary.switchedToBundled,
|
|
2347
|
-
switchedToNpm: syncResult.summary.switchedToNpm,
|
|
2348
|
-
warnings: syncResult.summary.warnings,
|
|
2349
|
-
errors: syncResult.summary.errors
|
|
2350
|
-
},
|
|
2351
|
-
npm: {
|
|
2352
|
-
changed: npmPluginsChanged,
|
|
2353
|
-
outcomes: pluginUpdateOutcomes
|
|
2354
|
-
},
|
|
2355
|
-
integrityDrifts
|
|
2356
|
-
};
|
|
2357
|
-
const summarizeList = (list) => {
|
|
2358
|
-
if (list.length <= 6) return list.join(", ");
|
|
2359
|
-
return `${list.slice(0, 6).join(", ")} +${list.length - 6} more`;
|
|
2360
|
-
};
|
|
2361
|
-
if (syncResult.summary.switchedToBundled.length > 0) defaultRuntime.log(theme.muted(`Switched to bundled plugins: ${summarizeList(syncResult.summary.switchedToBundled)}.`));
|
|
2362
|
-
if (syncResult.summary.switchedToNpm.length > 0) defaultRuntime.log(theme.muted(`Restored npm plugins: ${summarizeList(syncResult.summary.switchedToNpm)}.`));
|
|
2363
|
-
for (const warning of syncResult.summary.warnings) defaultRuntime.log(theme.warn(warning));
|
|
2364
|
-
for (const error of syncResult.summary.errors) defaultRuntime.log(theme.warn(createPostUpdatePluginWarning({ reason: error }).message));
|
|
2365
|
-
const updated = pluginUpdateOutcomes.filter((entry) => entry.status === "updated").length;
|
|
2366
|
-
const unchanged = pluginUpdateOutcomes.filter((entry) => entry.status === "unchanged").length;
|
|
2367
|
-
const failed = pluginUpdateOutcomes.filter((entry) => entry.status === "error").length;
|
|
2368
|
-
const skipped = pluginUpdateOutcomes.filter((entry) => entry.status === "skipped").length;
|
|
2369
|
-
if (pluginUpdateOutcomes.length === 0) defaultRuntime.log(theme.muted("No plugin updates needed."));
|
|
2370
|
-
else {
|
|
2371
|
-
const parts = [`${updated} updated`, `${unchanged} unchanged`];
|
|
2372
|
-
if (failed > 0) parts.push(`${failed} failed`);
|
|
2373
|
-
if (skipped > 0) parts.push(`${skipped} skipped`);
|
|
2374
|
-
defaultRuntime.log(theme.muted(`npm plugins: ${parts.join(", ")}.`));
|
|
2375
|
-
}
|
|
2376
|
-
for (const outcome of pluginUpdateOutcomes) {
|
|
2377
|
-
if (outcome.status !== "error") continue;
|
|
2378
|
-
defaultRuntime.log(theme.warn(outcome.message));
|
|
2379
|
-
}
|
|
2380
|
-
return {
|
|
2381
|
-
status: convergenceErrored ? "error" : warnings.length > 0 ? "warning" : "ok",
|
|
2382
|
-
changed: pluginsChanged,
|
|
2383
|
-
warnings,
|
|
2384
|
-
sync: {
|
|
2385
|
-
changed: syncResult.changed,
|
|
2386
|
-
switchedToBundled: syncResult.summary.switchedToBundled,
|
|
2387
|
-
switchedToNpm: syncResult.summary.switchedToNpm,
|
|
2388
|
-
warnings: syncResult.summary.warnings,
|
|
2389
|
-
errors: syncResult.summary.errors
|
|
2390
|
-
},
|
|
2391
|
-
npm: {
|
|
2392
|
-
changed: npmPluginsChanged,
|
|
2393
|
-
outcomes: pluginUpdateOutcomes
|
|
2394
|
-
},
|
|
2395
|
-
integrityDrifts
|
|
2396
|
-
};
|
|
2397
|
-
}
|
|
2398
|
-
async function maybeRestartService(params) {
|
|
2399
|
-
const verifyRestartedGateway = async (expectedGatewayVersion) => {
|
|
2400
|
-
const restartAfterStaleCleanup = async () => {
|
|
2401
|
-
if (params.refreshServiceEnv && isPackageManagerUpdateMode(params.result.mode)) {
|
|
2402
|
-
await runUpdatedInstallGatewayRestart({
|
|
2403
|
-
result: params.result,
|
|
2404
|
-
jsonMode: Boolean(params.opts.json),
|
|
2405
|
-
invocationCwd: params.invocationCwd,
|
|
2406
|
-
env: params.serviceEnv,
|
|
2407
|
-
nodeRunner: params.nodeRunner
|
|
2408
|
-
});
|
|
2409
|
-
return;
|
|
2410
|
-
}
|
|
2411
|
-
if (shouldUseLegacyProcessRestartAfterUpdate({ updateMode: params.result.mode })) await runDaemonRestart();
|
|
2412
|
-
};
|
|
2413
|
-
const service = resolveGatewayService();
|
|
2414
|
-
let health = await waitForGatewayHealthyRestart({
|
|
2415
|
-
service,
|
|
2416
|
-
port: params.gatewayPort,
|
|
2417
|
-
expectedVersion: expectedGatewayVersion,
|
|
2418
|
-
env: params.serviceEnv
|
|
2419
|
-
});
|
|
2420
|
-
if (!health.healthy && health.staleGatewayPids.length > 0) {
|
|
2421
|
-
if (!params.opts.json) defaultRuntime.log(theme.warn(`Found stale gateway process(es) after restart: ${health.staleGatewayPids.join(", ")}. Cleaning up...`));
|
|
2422
|
-
await terminateStaleGatewayPids(health.staleGatewayPids);
|
|
2423
|
-
await restartAfterStaleCleanup();
|
|
2424
|
-
health = await waitForGatewayHealthyRestart({
|
|
2425
|
-
service,
|
|
2426
|
-
port: params.gatewayPort,
|
|
2427
|
-
expectedVersion: expectedGatewayVersion,
|
|
2428
|
-
env: params.serviceEnv
|
|
2429
|
-
});
|
|
2430
|
-
}
|
|
2431
|
-
const recoveryVerification = await recoverLaunchAgentAndRecheckGatewayHealth({
|
|
2432
|
-
health,
|
|
2433
|
-
service,
|
|
2434
|
-
port: params.gatewayPort,
|
|
2435
|
-
expectedVersion: expectedGatewayVersion,
|
|
2436
|
-
env: params.serviceEnv
|
|
2437
|
-
});
|
|
2438
|
-
health = recoveryVerification.health;
|
|
2439
|
-
const launchAgentRecovery = recoveryVerification.launchAgentRecovery;
|
|
2440
|
-
if (launchAgentRecovery?.attempted) if (!params.opts.json) defaultRuntime.log(launchAgentRecovery.recovered ? theme.warn(launchAgentRecovery.message) : theme.warn(launchAgentRecovery.detail));
|
|
2441
|
-
else defaultRuntime.error(launchAgentRecovery.recovered ? launchAgentRecovery.message : launchAgentRecovery.detail);
|
|
2442
|
-
if (health.healthy) {
|
|
2443
|
-
if (!params.opts.json) defaultRuntime.log(theme.success("Gateway: restarted and verified."));
|
|
2444
|
-
return true;
|
|
2445
|
-
}
|
|
2446
|
-
const diagnosticLines = [
|
|
2447
|
-
"Gateway did not become healthy after restart.",
|
|
2448
|
-
...renderRestartDiagnostics(health),
|
|
2449
|
-
...launchAgentRecovery?.attempted ? [launchAgentRecovery.recovered ? `LaunchAgent recovery: ${launchAgentRecovery.message}` : `LaunchAgent recovery failed: ${launchAgentRecovery.detail}`] : [],
|
|
2450
|
-
`Restart log: ${resolveGatewayRestartLogPath(params.serviceEnv ?? process.env)}`,
|
|
2451
|
-
`Run \`${replaceCliName(formatCliCommand("daocore gateway status --deep"), CLI_NAME)}\` for details.`,
|
|
2452
|
-
...formatPostUpdateGatewayRecoveryInstructions(params.result)
|
|
2453
|
-
];
|
|
2454
|
-
if (params.opts.json) defaultRuntime.error(diagnosticLines.join("\n"));
|
|
2455
|
-
else {
|
|
2456
|
-
defaultRuntime.log(theme.warn(diagnosticLines[0] ?? "Gateway did not become healthy."));
|
|
2457
|
-
for (const line of diagnosticLines.slice(1)) defaultRuntime.log(theme.muted(line));
|
|
2458
|
-
}
|
|
2459
|
-
if (isPackageManagerUpdateMode(params.result.mode)) return false;
|
|
2460
|
-
return !(health.versionMismatch || health.activatedPluginErrors?.length);
|
|
2461
|
-
};
|
|
2462
|
-
if (params.shouldRestart) {
|
|
2463
|
-
if (!params.opts.json) {
|
|
2464
|
-
defaultRuntime.log("");
|
|
2465
|
-
defaultRuntime.log(theme.heading("Restarting service..."));
|
|
2466
|
-
}
|
|
2467
|
-
try {
|
|
2468
|
-
const expectedGatewayVersion = isPackageManagerUpdateMode(params.result.mode) ? normalizeOptionalString(params.result.after?.version) : void 0;
|
|
2469
|
-
const isPackageUpdate = isPackageManagerUpdateMode(params.result.mode);
|
|
2470
|
-
let restarted = false;
|
|
2471
|
-
let restartInitiated = false;
|
|
2472
|
-
let refreshedGatewayAlreadyHealthy = false;
|
|
2473
|
-
if (params.refreshServiceEnv) {
|
|
2474
|
-
try {
|
|
2475
|
-
await refreshGatewayServiceEnv({
|
|
2476
|
-
result: params.result,
|
|
2477
|
-
jsonMode: Boolean(params.opts.json),
|
|
2478
|
-
invocationCwd: params.invocationCwd,
|
|
2479
|
-
env: params.serviceEnv,
|
|
2480
|
-
nodeRunner: params.nodeRunner
|
|
2481
|
-
});
|
|
2482
|
-
} catch (err) {
|
|
2483
|
-
const message = `Failed to refresh gateway service environment from updated install: ${String(err)}`;
|
|
2484
|
-
if (params.opts.json) defaultRuntime.error(message);
|
|
2485
|
-
else defaultRuntime.log(theme.warn(message));
|
|
2486
|
-
if (isPackageUpdate) return false;
|
|
2487
|
-
}
|
|
2488
|
-
if (isPackageUpdate && expectedGatewayVersion) {
|
|
2489
|
-
refreshedGatewayAlreadyHealthy = (await waitForGatewayHealthyRestart({
|
|
2490
|
-
service: resolveGatewayService(),
|
|
2491
|
-
port: params.gatewayPort,
|
|
2492
|
-
expectedVersion: expectedGatewayVersion,
|
|
2493
|
-
env: params.serviceEnv,
|
|
2494
|
-
attempts: POST_REFRESH_ALREADY_HEALTHY_ATTEMPTS,
|
|
2495
|
-
delayMs: POST_REFRESH_ALREADY_HEALTHY_DELAY_MS
|
|
2496
|
-
})).healthy;
|
|
2497
|
-
if (refreshedGatewayAlreadyHealthy && !params.opts.json) defaultRuntime.log(theme.muted("Gateway already reports the updated version after service refresh; skipped redundant restart."));
|
|
2498
|
-
}
|
|
2499
|
-
}
|
|
2500
|
-
if (!refreshedGatewayAlreadyHealthy && params.restartScriptPath) {
|
|
2501
|
-
await createUpdateConfigSnapshot();
|
|
2502
|
-
await runRestartScript(params.restartScriptPath);
|
|
2503
|
-
restartInitiated = true;
|
|
2504
|
-
} else if (!refreshedGatewayAlreadyHealthy && params.refreshServiceEnv && isPackageUpdate) {
|
|
2505
|
-
await createUpdateConfigSnapshot();
|
|
2506
|
-
restarted = await runUpdatedInstallGatewayRestart({
|
|
2507
|
-
result: params.result,
|
|
2508
|
-
jsonMode: Boolean(params.opts.json),
|
|
2509
|
-
invocationCwd: params.invocationCwd,
|
|
2510
|
-
env: params.serviceEnv,
|
|
2511
|
-
nodeRunner: params.nodeRunner
|
|
2512
|
-
});
|
|
2513
|
-
} else if (!refreshedGatewayAlreadyHealthy && shouldUseLegacyProcessRestartAfterUpdate({ updateMode: params.result.mode })) {
|
|
2514
|
-
await createUpdateConfigSnapshot();
|
|
2515
|
-
restarted = await runDaemonRestart();
|
|
2516
|
-
} else if (!refreshedGatewayAlreadyHealthy && !params.opts.json) defaultRuntime.log(theme.muted("Gateway: restart skipped (no installed service found)."));
|
|
2517
|
-
if (refreshedGatewayAlreadyHealthy || restartInitiated || restarted && expectedGatewayVersion !== void 0) {
|
|
2518
|
-
if (!await verifyRestartedGateway(expectedGatewayVersion)) {
|
|
2519
|
-
if (!params.opts.json) defaultRuntime.log("");
|
|
2520
|
-
return false;
|
|
2521
|
-
}
|
|
2522
|
-
if (!params.opts.json && restartInitiated) {
|
|
2523
|
-
defaultRuntime.log(theme.success("Daemon restart completed."));
|
|
2524
|
-
defaultRuntime.log("");
|
|
2525
|
-
}
|
|
2526
|
-
}
|
|
2527
|
-
if (!params.opts.json && restarted) {
|
|
2528
|
-
defaultRuntime.log(theme.success("Daemon restarted successfully."));
|
|
2529
|
-
defaultRuntime.log("");
|
|
2530
|
-
await createUpdateConfigSnapshot();
|
|
2531
|
-
process.env.DAOCORE_UPDATE_IN_PROGRESS = "1";
|
|
2532
|
-
process.env[UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE_ENV] = "1";
|
|
2533
|
-
try {
|
|
2534
|
-
await doctorCommand(defaultRuntime, { nonInteractive: !(process.stdin.isTTY && !params.opts.json && params.opts.yes !== true) });
|
|
2535
|
-
} catch (err) {
|
|
2536
|
-
defaultRuntime.log(theme.warn(`Doctor failed: ${String(err)}`));
|
|
2537
|
-
} finally {
|
|
2538
|
-
delete process.env.DAOCORE_UPDATE_IN_PROGRESS;
|
|
2539
|
-
delete process.env[UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE_ENV];
|
|
2540
|
-
}
|
|
2541
|
-
}
|
|
2542
|
-
} catch (err) {
|
|
2543
|
-
if (!params.opts.json) {
|
|
2544
|
-
defaultRuntime.log(theme.warn(`Gateway: restart failed: ${String(err)}`));
|
|
2545
|
-
defaultRuntime.log(theme.muted(`You may need to restart the service manually: ${replaceCliName(formatCliCommand("daocore gateway restart"), CLI_NAME)}`));
|
|
2546
|
-
}
|
|
2547
|
-
if (isPackageManagerUpdateMode(params.result.mode)) return false;
|
|
2548
|
-
}
|
|
2549
|
-
return true;
|
|
2550
|
-
}
|
|
2551
|
-
if (!params.opts.json) {
|
|
2552
|
-
defaultRuntime.log("");
|
|
2553
|
-
defaultRuntime.log(theme.muted("Gateway: restart skipped (--no-restart)."));
|
|
2554
|
-
if (params.result.mode === "npm" || params.result.mode === "pnpm") defaultRuntime.log(theme.muted(`Tip: Run \`${replaceCliName(formatCliCommand("daocore doctor"), CLI_NAME)}\`, then \`${replaceCliName(formatCliCommand("daocore gateway restart"), CLI_NAME)}\` to apply updates to a running gateway.`));
|
|
2555
|
-
else defaultRuntime.log(theme.muted(`Tip: Run \`${replaceCliName(formatCliCommand("daocore gateway restart"), CLI_NAME)}\` to apply updates to a running gateway.`));
|
|
2556
|
-
}
|
|
2557
|
-
return true;
|
|
2558
|
-
}
|
|
2559
|
-
async function runPostCorePluginUpdate(params) {
|
|
2560
|
-
return await updatePluginsAfterCoreUpdate({
|
|
2561
|
-
root: params.root,
|
|
2562
|
-
channel: params.channel,
|
|
2563
|
-
configSnapshot: params.configSnapshot,
|
|
2564
|
-
configChanged: params.configChanged,
|
|
2565
|
-
restoredAuthoredChannels: params.restoredAuthoredChannels,
|
|
2566
|
-
opts: params.opts,
|
|
2567
|
-
timeoutMs: params.timeoutMs,
|
|
2568
|
-
pluginInstallRecords: params.pluginInstallRecords
|
|
2569
|
-
});
|
|
2570
|
-
}
|
|
2571
|
-
function withUpdateFinalizationEnv(run) {
|
|
2572
|
-
const previousUpdateInProgress = process.env.DAOCORE_UPDATE_IN_PROGRESS;
|
|
2573
|
-
const previousDeferConfiguredPluginInstallRepair = process.env[UPDATE_DEFER_CONFIGURED_PLUGIN_INSTALL_REPAIR_ENV];
|
|
2574
|
-
const previousParentSupportsDoctorConfigWrite = process.env[UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE_ENV];
|
|
2575
|
-
process.env.DAOCORE_UPDATE_IN_PROGRESS = "1";
|
|
2576
|
-
process.env[UPDATE_DEFER_CONFIGURED_PLUGIN_INSTALL_REPAIR_ENV] = "1";
|
|
2577
|
-
process.env[UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE_ENV] = "1";
|
|
2578
|
-
return run().finally(() => {
|
|
2579
|
-
if (previousUpdateInProgress === void 0) delete process.env.DAOCORE_UPDATE_IN_PROGRESS;
|
|
2580
|
-
else process.env.DAOCORE_UPDATE_IN_PROGRESS = previousUpdateInProgress;
|
|
2581
|
-
if (previousDeferConfiguredPluginInstallRepair === void 0) delete process.env[UPDATE_DEFER_CONFIGURED_PLUGIN_INSTALL_REPAIR_ENV];
|
|
2582
|
-
else process.env[UPDATE_DEFER_CONFIGURED_PLUGIN_INSTALL_REPAIR_ENV] = previousDeferConfiguredPluginInstallRepair;
|
|
2583
|
-
if (previousParentSupportsDoctorConfigWrite === void 0) delete process.env[UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE_ENV];
|
|
2584
|
-
else process.env[UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE_ENV] = previousParentSupportsDoctorConfigWrite;
|
|
2585
|
-
});
|
|
2586
|
-
}
|
|
2587
|
-
async function updateFinalizeCommand(opts) {
|
|
2588
|
-
suppressDeprecations();
|
|
2589
|
-
const timeoutMs = parseTimeoutMsOrExit(opts.timeout);
|
|
2590
|
-
if (timeoutMs === null) return;
|
|
2591
|
-
assertConfigWriteAllowedInCurrentMode();
|
|
2592
|
-
const root = await resolveUpdateRoot();
|
|
2593
|
-
let configSnapshot = await readConfigFileSnapshot({ skipPluginValidation: true });
|
|
2594
|
-
const preFinalizeConfig = configSnapshot.valid ? {
|
|
2595
|
-
sourceConfig: configSnapshot.sourceConfig,
|
|
2596
|
-
authoredConfig: isRecord(configSnapshot.parsed) ? configSnapshot.parsed : configSnapshot.sourceConfig
|
|
2597
|
-
} : void 0;
|
|
2598
|
-
const requestedChannel = normalizeUpdateChannel(opts.channel);
|
|
2599
|
-
if (opts.channel && !requestedChannel) {
|
|
2600
|
-
defaultRuntime.error(`--channel must be "stable", "beta", or "dev" (got "${opts.channel}")`);
|
|
2601
|
-
defaultRuntime.exit(1);
|
|
2602
|
-
return;
|
|
2603
|
-
}
|
|
2604
|
-
const storedChannel = configSnapshot.valid ? normalizeUpdateChannel(configSnapshot.config.update?.channel) : null;
|
|
2605
|
-
const channel = requestedChannel ?? storedChannel ?? "stable";
|
|
2606
|
-
if (requestedChannel) configSnapshot = await persistRequestedUpdateChannel({
|
|
2607
|
-
configSnapshot,
|
|
2608
|
-
requestedChannel
|
|
2609
|
-
});
|
|
2610
|
-
const pluginUpdate = await withUpdateFinalizationEnv(async () => {
|
|
2611
|
-
await createUpdateConfigSnapshot();
|
|
2612
|
-
await doctorCommand(defaultRuntime, {
|
|
2613
|
-
nonInteractive: true,
|
|
2614
|
-
repair: true,
|
|
2615
|
-
yes: opts.yes === true
|
|
2616
|
-
});
|
|
2617
|
-
configSnapshot = await readConfigFileSnapshot({ skipPluginValidation: true });
|
|
2618
|
-
if (requestedChannel) configSnapshot = await persistRequestedUpdateChannel({
|
|
2619
|
-
configSnapshot,
|
|
2620
|
-
requestedChannel
|
|
2621
|
-
});
|
|
2622
|
-
const restoredConfig = restoreDroppedPreUpdateChannels(configSnapshot, preFinalizeConfig);
|
|
2623
|
-
configSnapshot = restoredConfig.snapshot;
|
|
2624
|
-
const postDoctorStoredChannel = configSnapshot.valid ? normalizeUpdateChannel(configSnapshot.config.update?.channel) : null;
|
|
2625
|
-
const postDoctorChannel = requestedChannel ?? postDoctorStoredChannel ?? storedChannel ?? "stable";
|
|
2626
|
-
const pluginInstallRecords = await loadInstalledPluginIndexInstallRecords();
|
|
2627
|
-
return await runPostCorePluginUpdate({
|
|
2628
|
-
root,
|
|
2629
|
-
channel: postDoctorChannel,
|
|
2630
|
-
configSnapshot,
|
|
2631
|
-
configChanged: restoredConfig.changed,
|
|
2632
|
-
restoredAuthoredChannels: restoredConfig.authoredChannels,
|
|
2633
|
-
opts: {
|
|
2634
|
-
json: opts.json,
|
|
2635
|
-
timeout: opts.timeout,
|
|
2636
|
-
yes: opts.yes,
|
|
2637
|
-
restart: false
|
|
2638
|
-
},
|
|
2639
|
-
timeoutMs: timeoutMs ?? DEFAULT_UPDATE_STEP_TIMEOUT_MS,
|
|
2640
|
-
pluginInstallRecords
|
|
2641
|
-
});
|
|
2642
|
-
});
|
|
2643
|
-
const result = {
|
|
2644
|
-
status: pluginUpdate.status === "error" ? "error" : pluginUpdate.status === "warning" ? "warning" : "ok",
|
|
2645
|
-
mode: "finalize",
|
|
2646
|
-
root,
|
|
2647
|
-
channel: requestedChannel ?? (configSnapshot.valid ? normalizeUpdateChannel(configSnapshot.config.update?.channel) : null) ?? channel,
|
|
2648
|
-
restart: false,
|
|
2649
|
-
postUpdate: {
|
|
2650
|
-
doctor: { status: "ok" },
|
|
2651
|
-
plugins: pluginUpdate
|
|
2652
|
-
}
|
|
2653
|
-
};
|
|
2654
|
-
await tryWriteCompletionCache(root, Boolean(opts.json));
|
|
2655
|
-
if (opts.json) defaultRuntime.writeJson(result);
|
|
2656
|
-
else if (result.status === "ok") defaultRuntime.log(theme.muted("Update finalization completed."));
|
|
2657
|
-
if (result.status === "error") defaultRuntime.exit(1);
|
|
2658
|
-
}
|
|
2659
|
-
async function persistRequestedUpdateChannel(params) {
|
|
2660
|
-
if (!params.requestedChannel || !params.configSnapshot.valid) return params.configSnapshot;
|
|
2661
|
-
const storedChannel = normalizeUpdateChannel(params.configSnapshot.config.update?.channel);
|
|
2662
|
-
if (params.requestedChannel === storedChannel) return params.configSnapshot;
|
|
2663
|
-
const requestedChannel = params.requestedChannel;
|
|
2664
|
-
const mutation = await mutateConfigFileWithRetry({
|
|
2665
|
-
writeOptions: { skipPluginValidation: true },
|
|
2666
|
-
mutate: (draft) => {
|
|
2667
|
-
draft.update = {
|
|
2668
|
-
...draft.update,
|
|
2669
|
-
channel: requestedChannel
|
|
2670
|
-
};
|
|
2671
|
-
}
|
|
2672
|
-
});
|
|
2673
|
-
return createUpdatedConfigSnapshot(mutation.snapshot, mutation.nextConfig);
|
|
2674
|
-
}
|
|
2675
|
-
function createUpdatedConfigSnapshot(snapshot, next) {
|
|
2676
|
-
if (!snapshot.valid) return snapshot;
|
|
2677
|
-
return {
|
|
2678
|
-
...snapshot,
|
|
2679
|
-
hash: void 0,
|
|
2680
|
-
parsed: next,
|
|
2681
|
-
sourceConfig: asResolvedSourceConfig(next),
|
|
2682
|
-
resolved: asResolvedSourceConfig(next),
|
|
2683
|
-
runtimeConfig: asRuntimeConfig(next),
|
|
2684
|
-
config: asRuntimeConfig(next)
|
|
2685
|
-
};
|
|
2686
|
-
}
|
|
2687
|
-
async function maybeRepairLegacyConfigForUpdateChannel(params) {
|
|
2688
|
-
if (params.configSnapshot.valid || params.configSnapshot.legacyIssues.length === 0) return params.configSnapshot;
|
|
2689
|
-
const { repairLegacyConfigForUpdateChannel } = await import("./legacy-config-repair-C8CiuHTf.js");
|
|
2690
|
-
const { snapshot, repaired } = await repairLegacyConfigForUpdateChannel(params);
|
|
2691
|
-
if (!params.jsonMode && repaired) defaultRuntime.log(theme.muted("Migrated legacy config before changing update channel."));
|
|
2692
|
-
return snapshot;
|
|
2693
|
-
}
|
|
2694
|
-
async function writePostCorePluginUpdateResultFile(filePath, result) {
|
|
2695
|
-
if (!filePath) return;
|
|
2696
|
-
await writeJson(filePath, result, { trailingNewline: true });
|
|
2697
|
-
}
|
|
2698
|
-
async function writePostCorePluginInstallRecordsFile(filePath, records) {
|
|
2699
|
-
await fs$1.writeFile(filePath, `${JSON.stringify(records)}\n`, "utf-8");
|
|
2700
|
-
}
|
|
2701
|
-
async function writePostCoreSourceConfigFile(filePath, preUpdateConfig) {
|
|
2702
|
-
if (!preUpdateConfig) return;
|
|
2703
|
-
await fs$1.writeFile(filePath, `${JSON.stringify(preUpdateConfig)}\n`, "utf-8");
|
|
2704
|
-
}
|
|
2705
|
-
async function readPostCorePluginInstallRecordsFile(filePath) {
|
|
2706
|
-
if (!filePath) return;
|
|
2707
|
-
try {
|
|
2708
|
-
return normalizePluginInstallRecordMap(JSON.parse(await fs$1.readFile(filePath, "utf-8")));
|
|
2709
|
-
} catch {
|
|
2710
|
-
return;
|
|
2711
|
-
}
|
|
2712
|
-
}
|
|
2713
|
-
async function readPostCoreSourceConfigFile(filePath, options) {
|
|
2714
|
-
if (!filePath) return;
|
|
2715
|
-
try {
|
|
2716
|
-
const parsed = parseConfigJson5(await fs$1.readFile(filePath, "utf-8"));
|
|
2717
|
-
if (!parsed.ok || !isRecord(parsed.parsed)) return;
|
|
2718
|
-
return normalizePreUpdateConfigRestoreInput(parsed.parsed, options);
|
|
2719
|
-
} catch {
|
|
2720
|
-
return;
|
|
2721
|
-
}
|
|
2722
|
-
}
|
|
2723
|
-
function normalizePreUpdateConfigRestoreInput(parsed, options) {
|
|
2724
|
-
const sourceConfig = parsed.sourceConfig;
|
|
2725
|
-
const authoredConfig = parsed.authoredConfig;
|
|
2726
|
-
if (isRecord(sourceConfig) && isRecord(authoredConfig)) return {
|
|
2727
|
-
sourceConfig,
|
|
2728
|
-
authoredConfig
|
|
2729
|
-
};
|
|
2730
|
-
const authored = parsed;
|
|
2731
|
-
return {
|
|
2732
|
-
sourceConfig: options?.configPath ? resolvePreUpdateSourceConfigFromAuthored(authored, options.configPath) : authored,
|
|
2733
|
-
authoredConfig: authored
|
|
2734
|
-
};
|
|
2735
|
-
}
|
|
2736
|
-
function resolvePreUpdateSourceConfigFromAuthored(authoredConfig, configPath) {
|
|
2737
|
-
try {
|
|
2738
|
-
const resolved = resolveConfigEnvVars(resolveConfigIncludes(authoredConfig, configPath, void 0, { allowedRoots: resolveIncludeRoots(process.env) }), process.env, { onMissing: () => void 0 });
|
|
2739
|
-
return isRecord(resolved) ? resolved : authoredConfig;
|
|
2740
|
-
} catch {
|
|
2741
|
-
return authoredConfig;
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
async function isFreshPreUpdateConfigSnapshot(params) {
|
|
2745
|
-
const snapshotStat = await fs$1.stat(params.snapshotPath).catch(() => null);
|
|
2746
|
-
if (!snapshotStat) return false;
|
|
2747
|
-
if (params.updateStartedAtMs !== void 0 && snapshotStat.mtimeMs + 1e3 < params.updateStartedAtMs) return false;
|
|
2748
|
-
if (Date.now() - snapshotStat.mtimeMs > PRE_UPDATE_CONFIG_SNAPSHOT_MAX_AGE_MS) return false;
|
|
2749
|
-
const currentStat = await fs$1.stat(params.currentConfigPath).catch(() => null);
|
|
2750
|
-
return !currentStat || snapshotStat.mtimeMs <= currentStat.mtimeMs + 1e3;
|
|
2751
|
-
}
|
|
2752
|
-
async function execFileStdout(file, args) {
|
|
2753
|
-
return await new Promise((resolve) => {
|
|
2754
|
-
execFile(file, args, {
|
|
2755
|
-
timeout: 1e3,
|
|
2756
|
-
windowsHide: true
|
|
2757
|
-
}, (error, stdout) => {
|
|
2758
|
-
resolve(error ? void 0 : stdout);
|
|
2759
|
-
});
|
|
2760
|
-
});
|
|
2761
|
-
}
|
|
2762
|
-
async function readProcessStartTimeMs(pid) {
|
|
2763
|
-
if (!Number.isInteger(pid) || pid <= 0) return;
|
|
2764
|
-
const raw = process.platform === "win32" ? await execFileStdout("powershell.exe", [
|
|
2765
|
-
"-NoProfile",
|
|
2766
|
-
"-NonInteractive",
|
|
2767
|
-
"-Command",
|
|
2768
|
-
`[Console]::Out.Write((Get-Process -Id ${pid}).StartTime.ToUniversalTime().ToString("o"))`
|
|
2769
|
-
]) : await execFileStdout("ps", [
|
|
2770
|
-
"-o",
|
|
2771
|
-
"lstart=",
|
|
2772
|
-
"-p",
|
|
2773
|
-
String(pid)
|
|
2774
|
-
]);
|
|
2775
|
-
if (!raw) return;
|
|
2776
|
-
const parsed = Date.parse(raw.trim().replace(/\s+/g, " "));
|
|
2777
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
2778
|
-
}
|
|
2779
|
-
async function resolvePostCoreUpdateStartedAtMs(env) {
|
|
2780
|
-
const fromEnv = Number.parseInt(env[POST_CORE_UPDATE_STARTED_AT_ENV] ?? "", 10);
|
|
2781
|
-
if (Number.isFinite(fromEnv) && fromEnv > 0) return fromEnv;
|
|
2782
|
-
return await readProcessStartTimeMs(process.ppid);
|
|
2783
|
-
}
|
|
2784
|
-
async function readPostCorePreUpdateSourceConfig(params) {
|
|
2785
|
-
const fromChildEnv = await readPostCoreSourceConfigFile(params.sourceConfigPath);
|
|
2786
|
-
if (fromChildEnv) return fromChildEnv;
|
|
2787
|
-
if (params.updateStartedAtMs === void 0) return;
|
|
2788
|
-
const explicitPreUpdatePath = `${params.currentSnapshot.path}.pre-update`;
|
|
2789
|
-
if (await isFreshPreUpdateConfigSnapshot({
|
|
2790
|
-
currentConfigPath: params.currentSnapshot.path,
|
|
2791
|
-
snapshotPath: explicitPreUpdatePath,
|
|
2792
|
-
updateStartedAtMs: params.updateStartedAtMs
|
|
2793
|
-
})) {
|
|
2794
|
-
const preUpdateConfig = await readPostCoreSourceConfigFile(explicitPreUpdatePath, { configPath: params.currentSnapshot.path });
|
|
2795
|
-
if (preUpdateConfig && hasRestorablePreUpdateChannels(params.currentSnapshot, preUpdateConfig)) return preUpdateConfig;
|
|
2796
|
-
return;
|
|
2797
|
-
}
|
|
2798
|
-
const backupPath = `${params.currentSnapshot.path}.bak`;
|
|
2799
|
-
if (await isFreshPreUpdateConfigSnapshot({
|
|
2800
|
-
currentConfigPath: params.currentSnapshot.path,
|
|
2801
|
-
snapshotPath: backupPath,
|
|
2802
|
-
updateStartedAtMs: params.updateStartedAtMs
|
|
2803
|
-
})) {
|
|
2804
|
-
const preUpdateConfig = await readPostCoreSourceConfigFile(backupPath, { configPath: params.currentSnapshot.path });
|
|
2805
|
-
if (preUpdateConfig && hasRestorablePreUpdateChannels(params.currentSnapshot, preUpdateConfig)) return preUpdateConfig;
|
|
2806
|
-
}
|
|
2807
|
-
}
|
|
2808
|
-
async function readPostCorePluginUpdateResultFile(filePath) {
|
|
2809
|
-
try {
|
|
2810
|
-
const parsed = await readJsonIfExists(filePath);
|
|
2811
|
-
if (parsed && typeof parsed === "object" && (parsed.status === "ok" || parsed.status === "warning" || parsed.status === "skipped" || parsed.status === "error")) return parsed;
|
|
2812
|
-
} catch {
|
|
2813
|
-
return;
|
|
2814
|
-
}
|
|
2815
|
-
}
|
|
2816
|
-
function stopPostCoreUpdateChild(child) {
|
|
2817
|
-
if (process.platform === "win32" && child.pid) try {
|
|
2818
|
-
spawn("taskkill", [
|
|
2819
|
-
"/PID",
|
|
2820
|
-
String(child.pid),
|
|
2821
|
-
"/T",
|
|
2822
|
-
"/F"
|
|
2823
|
-
], {
|
|
2824
|
-
stdio: "ignore",
|
|
2825
|
-
windowsHide: true
|
|
2826
|
-
}).once("error", () => {
|
|
2827
|
-
child.kill();
|
|
2828
|
-
});
|
|
2829
|
-
return;
|
|
2830
|
-
} catch {
|
|
2831
|
-
child.kill();
|
|
2832
|
-
return;
|
|
2833
|
-
}
|
|
2834
|
-
child.kill();
|
|
2835
|
-
}
|
|
2836
|
-
/**
|
|
2837
|
-
* Returns the stdio mode for the post-core-update child process.
|
|
2838
|
-
*
|
|
2839
|
-
* Windows shells (PowerShell/CMD) wait for all processes that hold inherited console handles to
|
|
2840
|
-
* exit before returning the prompt, even after the immediate child has exited. Using "pipe" on
|
|
2841
|
-
* Windows prevents the child (and any grandchildren it spawns) from ever receiving a reference to
|
|
2842
|
-
* the parent's console handles, eliminating the terminal hang seen in #78445.
|
|
2843
|
-
*
|
|
2844
|
-
* @internal exported for testing
|
|
2845
|
-
*/
|
|
2846
|
-
function resolvePostCoreUpdateChildStdio(platform = process.platform) {
|
|
2847
|
-
return platform === "win32" ? "pipe" : "inherit";
|
|
2848
|
-
}
|
|
2849
|
-
async function continuePostCoreUpdateInFreshProcess(params) {
|
|
2850
|
-
const entryPath = await resolveGatewayInstallEntrypoint(params.root);
|
|
2851
|
-
if (!entryPath) return { resumed: false };
|
|
2852
|
-
const argv = [entryPath, "update"];
|
|
2853
|
-
if (params.opts.json) argv.push("--json");
|
|
2854
|
-
if (params.opts.restart === false) argv.push("--no-restart");
|
|
2855
|
-
if (params.opts.yes) argv.push("--yes");
|
|
2856
|
-
if (params.opts.timeout) argv.push("--timeout", params.opts.timeout);
|
|
2857
|
-
const resultDir = await fs$1.mkdtemp(path.join(os.tmpdir(), "daocore-update-post-core-"));
|
|
2858
|
-
const resultPath = path.join(resultDir, "plugins.json");
|
|
2859
|
-
const installRecordsPath = path.join(resultDir, "plugin-install-records.json");
|
|
2860
|
-
const sourceConfigPath = path.join(resultDir, "source-config.json");
|
|
2861
|
-
const postCoreHostVersion = await readPackageVersion(params.root);
|
|
2862
|
-
try {
|
|
2863
|
-
await writePostCorePluginInstallRecordsFile(installRecordsPath, params.pluginInstallRecords);
|
|
2864
|
-
await writePostCoreSourceConfigFile(sourceConfigPath, params.preUpdateConfig);
|
|
2865
|
-
const childStdio = resolvePostCoreUpdateChildStdio();
|
|
2866
|
-
const child = spawn(params.nodeRunner ?? resolveNodeRunner(), argv, {
|
|
2867
|
-
stdio: childStdio,
|
|
2868
|
-
env: {
|
|
2869
|
-
...stripGatewayServiceMarkerEnv(disableUpdatedPackageCompileCacheEnv(process.env)),
|
|
2870
|
-
[POST_CORE_UPDATE_ENV]: "1",
|
|
2871
|
-
[POST_CORE_UPDATE_CHANNEL_ENV]: params.channel,
|
|
2872
|
-
...params.requestedChannel ? { [POST_CORE_UPDATE_REQUESTED_CHANNEL_ENV]: params.requestedChannel } : {},
|
|
2873
|
-
[POST_CORE_UPDATE_RESULT_PATH_ENV]: resultPath,
|
|
2874
|
-
[POST_CORE_UPDATE_INSTALL_RECORDS_PATH_ENV]: installRecordsPath,
|
|
2875
|
-
[POST_CORE_UPDATE_STARTED_AT_ENV]: String(params.updateStartedAtMs),
|
|
2876
|
-
...postCoreHostVersion === null ? {} : { DAOCORE_COMPATIBILITY_HOST_VERSION: postCoreHostVersion },
|
|
2877
|
-
...params.preUpdateConfig ? { [POST_CORE_UPDATE_SOURCE_CONFIG_PATH_ENV]: sourceConfigPath } : {}
|
|
2878
|
-
}
|
|
2879
|
-
});
|
|
2880
|
-
if (childStdio === "pipe") {
|
|
2881
|
-
child.stdout?.pipe(process.stdout);
|
|
2882
|
-
child.stderr?.pipe(process.stderr);
|
|
2883
|
-
}
|
|
2884
|
-
const childResult = await new Promise((resolve, reject) => {
|
|
2885
|
-
let settled = false;
|
|
2886
|
-
const finish = (result) => {
|
|
2887
|
-
if (settled) return;
|
|
2888
|
-
settled = true;
|
|
2889
|
-
clearInterval(resultPoll);
|
|
2890
|
-
resolve(result);
|
|
2891
|
-
};
|
|
2892
|
-
const resultPoll = setInterval(() => {
|
|
2893
|
-
readPostCorePluginUpdateResultFile(resultPath).then((pluginUpdate) => {
|
|
2894
|
-
if (!pluginUpdate) return;
|
|
2895
|
-
stopPostCoreUpdateChild(child);
|
|
2896
|
-
finish({
|
|
2897
|
-
kind: "plugin-update",
|
|
2898
|
-
pluginUpdate
|
|
2899
|
-
});
|
|
2900
|
-
}).catch(() => void 0);
|
|
2901
|
-
}, POST_CORE_UPDATE_RESULT_POLL_MS);
|
|
2902
|
-
child.once("error", (error) => {
|
|
2903
|
-
if (settled) return;
|
|
2904
|
-
settled = true;
|
|
2905
|
-
clearInterval(resultPoll);
|
|
2906
|
-
reject(error);
|
|
2907
|
-
});
|
|
2908
|
-
child.once("exit", (code, signal) => {
|
|
2909
|
-
if (settled) return;
|
|
2910
|
-
if (signal) {
|
|
2911
|
-
settled = true;
|
|
2912
|
-
clearInterval(resultPoll);
|
|
2913
|
-
reject(/* @__PURE__ */ new Error(`post-update process terminated by signal ${signal}`));
|
|
2914
|
-
return;
|
|
2915
|
-
}
|
|
2916
|
-
finish({
|
|
2917
|
-
kind: "exit",
|
|
2918
|
-
exitCode: code ?? 1
|
|
2919
|
-
});
|
|
2920
|
-
});
|
|
2921
|
-
});
|
|
2922
|
-
const pluginUpdate = childResult.kind === "plugin-update" ? childResult.pluginUpdate : await readPostCorePluginUpdateResultFile(resultPath);
|
|
2923
|
-
const exitCode = childResult.kind === "exit" ? childResult.exitCode : 0;
|
|
2924
|
-
if (exitCode !== 0) {
|
|
2925
|
-
if (pluginUpdate) return {
|
|
2926
|
-
resumed: true,
|
|
2927
|
-
pluginUpdate
|
|
2928
|
-
};
|
|
2929
|
-
defaultRuntime.exit(exitCode);
|
|
2930
|
-
throw new Error(`post-update process exited with code ${exitCode}`);
|
|
2931
|
-
}
|
|
2932
|
-
return {
|
|
2933
|
-
resumed: true,
|
|
2934
|
-
...pluginUpdate ? { pluginUpdate } : {}
|
|
2935
|
-
};
|
|
2936
|
-
} finally {
|
|
2937
|
-
await fs$1.rm(resultDir, {
|
|
2938
|
-
recursive: true,
|
|
2939
|
-
force: true
|
|
2940
|
-
}).catch(() => void 0);
|
|
2941
|
-
}
|
|
2942
|
-
}
|
|
2943
|
-
function shouldResumePostCoreUpdateInFreshProcess(params) {
|
|
2944
|
-
if (params.downgradeRisk) return false;
|
|
2945
|
-
if (isPackageManagerUpdateMode(params.result.mode)) return true;
|
|
2946
|
-
if (params.result.mode !== "git") return false;
|
|
2947
|
-
const beforeSha = normalizeOptionalString(params.result.before?.sha);
|
|
2948
|
-
const afterSha = normalizeOptionalString(params.result.after?.sha);
|
|
2949
|
-
if (beforeSha && afterSha && beforeSha !== afterSha) return true;
|
|
2950
|
-
const beforeVersion = normalizeOptionalString(params.result.before?.version);
|
|
2951
|
-
const afterVersion = normalizeOptionalString(params.result.after?.version);
|
|
2952
|
-
return Boolean(beforeVersion && afterVersion && beforeVersion !== afterVersion);
|
|
2953
|
-
}
|
|
2954
|
-
async function writeControlPlaneUpdateRestartSentinelBestEffort(params) {
|
|
2955
|
-
if (!params.meta) return;
|
|
2956
|
-
try {
|
|
2957
|
-
await writeControlPlaneUpdateRestartSentinel({
|
|
2958
|
-
meta: params.meta,
|
|
2959
|
-
result: params.result
|
|
2960
|
-
});
|
|
2961
|
-
} catch (err) {
|
|
2962
|
-
const message = `Failed to write update.run restart sentinel: ${String(err)}`;
|
|
2963
|
-
if (params.jsonMode) defaultRuntime.error(message);
|
|
2964
|
-
else defaultRuntime.log(theme.warn(message));
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
|
-
async function markControlPlaneUpdateRestartSentinelFailureBestEffort(params) {
|
|
2968
|
-
if (!params.meta) return;
|
|
2969
|
-
try {
|
|
2970
|
-
await markControlPlaneUpdateRestartSentinelFailure(params.reason);
|
|
2971
|
-
} catch (err) {
|
|
2972
|
-
const message = `Failed to mark update.run restart sentinel failed: ${String(err)}`;
|
|
2973
|
-
if (params.jsonMode) defaultRuntime.error(message);
|
|
2974
|
-
else defaultRuntime.log(theme.warn(message));
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2977
|
-
async function updateCommand(opts) {
|
|
2978
|
-
suppressDeprecations();
|
|
2979
|
-
await cleanupStaleManagedServiceUpdateHandoffs().catch(() => void 0);
|
|
2980
|
-
const invocationCwd = tryResolveInvocationCwd();
|
|
2981
|
-
const postCoreUpdateResume = process.env[POST_CORE_UPDATE_ENV] === "1";
|
|
2982
|
-
const postCoreUpdateChannel = process.env[POST_CORE_UPDATE_CHANNEL_ENV]?.trim();
|
|
2983
|
-
const postCoreRequestedChannelInput = process.env[POST_CORE_UPDATE_REQUESTED_CHANNEL_ENV]?.trim() ?? "";
|
|
2984
|
-
const postCoreInstallRecordsPath = process.env[POST_CORE_UPDATE_INSTALL_RECORDS_PATH_ENV];
|
|
2985
|
-
const timeoutMs = parseTimeoutMsOrExit(opts.timeout);
|
|
2986
|
-
const shouldRestart = opts.restart !== false;
|
|
2987
|
-
if (timeoutMs === null) return;
|
|
2988
|
-
if (opts.dryRun !== true) {
|
|
2989
|
-
await disableCurrentDaoCoreUpdateLaunchdJob().catch(() => void 0);
|
|
2990
|
-
assertConfigWriteAllowedInCurrentMode();
|
|
2991
|
-
}
|
|
2992
|
-
const updateStepTimeoutMs = timeoutMs ?? DEFAULT_UPDATE_STEP_TIMEOUT_MS;
|
|
2993
|
-
let root = await resolveUpdateRoot();
|
|
2994
|
-
if (postCoreUpdateResume) {
|
|
2995
|
-
if (postCoreUpdateChannel !== "stable" && postCoreUpdateChannel !== "beta" && postCoreUpdateChannel !== "dev") {
|
|
2996
|
-
defaultRuntime.error("Missing post-core update channel context.");
|
|
2997
|
-
defaultRuntime.exit(1);
|
|
2998
|
-
return;
|
|
2999
|
-
}
|
|
3000
|
-
const postCoreRequestedChannel = postCoreRequestedChannelInput ? normalizeUpdateChannel(postCoreRequestedChannelInput) : null;
|
|
3001
|
-
if (postCoreRequestedChannelInput && !postCoreRequestedChannel) {
|
|
3002
|
-
defaultRuntime.error("Invalid post-core requested update channel context.");
|
|
3003
|
-
defaultRuntime.exit(1);
|
|
3004
|
-
return;
|
|
3005
|
-
}
|
|
3006
|
-
process.env.DAOCORE_COMPATIBILITY_HOST_VERSION = await readPackageVersion(root) ?? VERSION;
|
|
3007
|
-
let postCoreConfigSnapshot = await readConfigFileSnapshot({ skipPluginValidation: true });
|
|
3008
|
-
const preUpdateSourceConfig = await readPostCorePreUpdateSourceConfig({
|
|
3009
|
-
sourceConfigPath: process.env[POST_CORE_UPDATE_SOURCE_CONFIG_PATH_ENV],
|
|
3010
|
-
currentSnapshot: postCoreConfigSnapshot,
|
|
3011
|
-
updateStartedAtMs: await resolvePostCoreUpdateStartedAtMs(process.env)
|
|
3012
|
-
});
|
|
3013
|
-
postCoreConfigSnapshot = await persistRequestedUpdateChannel({
|
|
3014
|
-
configSnapshot: postCoreConfigSnapshot,
|
|
3015
|
-
requestedChannel: postCoreRequestedChannel
|
|
3016
|
-
});
|
|
3017
|
-
const restoredPostCoreConfig = restoreDroppedPreUpdateChannels(postCoreConfigSnapshot, preUpdateSourceConfig);
|
|
3018
|
-
const parentPluginInstallRecords = await readPostCorePluginInstallRecordsFile(postCoreInstallRecordsPath);
|
|
3019
|
-
const currentPluginInstallRecords = await loadInstalledPluginIndexInstallRecords();
|
|
3020
|
-
const pluginInstallRecords = Object.keys(currentPluginInstallRecords).length > 0 ? currentPluginInstallRecords : parentPluginInstallRecords;
|
|
3021
|
-
const pluginUpdate = await runPostCorePluginUpdate({
|
|
3022
|
-
root,
|
|
3023
|
-
channel: postCoreUpdateChannel,
|
|
3024
|
-
configSnapshot: restoredPostCoreConfig.snapshot,
|
|
3025
|
-
configChanged: restoredPostCoreConfig.changed,
|
|
3026
|
-
restoredAuthoredChannels: restoredPostCoreConfig.authoredChannels,
|
|
3027
|
-
opts,
|
|
3028
|
-
timeoutMs: updateStepTimeoutMs,
|
|
3029
|
-
pluginInstallRecords
|
|
3030
|
-
});
|
|
3031
|
-
if (process.env[POST_CORE_UPDATE_RESULT_PATH_ENV]) await writePostCorePluginUpdateResultFile(process.env[POST_CORE_UPDATE_RESULT_PATH_ENV], pluginUpdate);
|
|
3032
|
-
if (opts.json) {
|
|
3033
|
-
if (!process.env[POST_CORE_UPDATE_RESULT_PATH_ENV]) {
|
|
3034
|
-
const result = {
|
|
3035
|
-
status: pluginUpdate.status === "error" ? "error" : "ok",
|
|
3036
|
-
mode: "unknown",
|
|
3037
|
-
root,
|
|
3038
|
-
steps: [],
|
|
3039
|
-
durationMs: 0,
|
|
3040
|
-
postUpdate: { plugins: pluginUpdate }
|
|
3041
|
-
};
|
|
3042
|
-
defaultRuntime.writeJson(result);
|
|
3043
|
-
}
|
|
3044
|
-
}
|
|
3045
|
-
defaultRuntime.exit(0);
|
|
3046
|
-
return;
|
|
3047
|
-
}
|
|
3048
|
-
const controlPlaneUpdateSentinelMeta = await readControlPlaneUpdateSentinelMeta();
|
|
3049
|
-
const updateStatus = await checkUpdateStatus({
|
|
3050
|
-
root,
|
|
3051
|
-
timeoutMs: timeoutMs ?? 3500,
|
|
3052
|
-
fetchGit: false,
|
|
3053
|
-
includeRegistry: false
|
|
3054
|
-
});
|
|
3055
|
-
const requestedChannel = normalizeUpdateChannel(opts.channel);
|
|
3056
|
-
if (opts.channel && !requestedChannel) {
|
|
3057
|
-
defaultRuntime.error(`--channel must be "stable", "beta", or "dev" (got "${opts.channel}")`);
|
|
3058
|
-
defaultRuntime.exit(1);
|
|
3059
|
-
return;
|
|
3060
|
-
}
|
|
3061
|
-
let configSnapshot = await readConfigFileSnapshot({ skipPluginValidation: true });
|
|
3062
|
-
if (opts.channel && !opts.dryRun && !configSnapshot.valid) configSnapshot = await maybeRepairLegacyConfigForUpdateChannel({
|
|
3063
|
-
configSnapshot,
|
|
3064
|
-
jsonMode: Boolean(opts.json)
|
|
3065
|
-
});
|
|
3066
|
-
const storedChannel = configSnapshot.valid ? normalizeUpdateChannel(configSnapshot.config.update?.channel) : null;
|
|
3067
|
-
if (opts.channel && !configSnapshot.valid) {
|
|
3068
|
-
const issues = formatConfigIssueLines(configSnapshot.issues, "-");
|
|
3069
|
-
defaultRuntime.error(["Config is invalid; cannot set update channel.", ...issues].join("\n"));
|
|
3070
|
-
defaultRuntime.exit(1);
|
|
3071
|
-
return;
|
|
3072
|
-
}
|
|
3073
|
-
const installKind = updateStatus.installKind;
|
|
3074
|
-
const switchToGit = requestedChannel === "dev" && installKind !== "git";
|
|
3075
|
-
const switchToPackage = requestedChannel !== null && requestedChannel !== "dev" && installKind === "git";
|
|
3076
|
-
const updateInstallKind = switchToGit ? "git" : switchToPackage ? "package" : installKind;
|
|
3077
|
-
const channel = requestedChannel ?? storedChannel ?? (updateInstallKind === "git" ? "dev" : "stable");
|
|
3078
|
-
const devTargetRef = channel === "dev" ? process.env.DAOCORE_UPDATE_DEV_TARGET_REF?.trim() || void 0 : void 0;
|
|
3079
|
-
const explicitTag = normalizeTag(opts.tag);
|
|
3080
|
-
let tag = explicitTag ?? channelToNpmTag(channel);
|
|
3081
|
-
let currentVersion = null;
|
|
3082
|
-
let targetVersion = null;
|
|
3083
|
-
let downgradeRisk = false;
|
|
3084
|
-
let fallbackToLatest = false;
|
|
3085
|
-
let packageInstallSpec = null;
|
|
3086
|
-
let packageAlreadyCurrent = false;
|
|
3087
|
-
let managedServiceRootRedirect = null;
|
|
3088
|
-
let managedServiceNodeRunner;
|
|
3089
|
-
if (updateInstallKind === "package") {
|
|
3090
|
-
managedServiceRootRedirect = await resolveManagedServicePackageUpdateRoot({ root });
|
|
3091
|
-
if (managedServiceRootRedirect) {
|
|
3092
|
-
root = managedServiceRootRedirect.root;
|
|
3093
|
-
managedServiceNodeRunner = managedServiceRootRedirect.nodeRunner;
|
|
3094
|
-
if (!opts.json) {
|
|
3095
|
-
defaultRuntime.log(theme.muted(`Targeting managed gateway service package root: ${managedServiceRootRedirect.root}`));
|
|
3096
|
-
defaultRuntime.log(theme.warn(`Shell DaoCore root differs from the managed gateway service root: ${managedServiceRootRedirect.previousRoot}`));
|
|
3097
|
-
defaultRuntime.log(theme.muted(`After the update, make sure \`${CLI_NAME}\` on PATH resolves to the managed service root or reinstall the gateway service from the shell install you want to use.`));
|
|
3098
|
-
if (managedServiceNodeRunner) defaultRuntime.log(theme.muted(`Managed gateway service Node: ${managedServiceNodeRunner}`));
|
|
3099
|
-
}
|
|
3100
|
-
} else {
|
|
3101
|
-
managedServiceNodeRunner = await resolveManagedServiceNodeRunnerOverride();
|
|
3102
|
-
if (managedServiceNodeRunner && !opts.json) {
|
|
3103
|
-
defaultRuntime.log(theme.warn(`Current Node (${resolveNodeRunner()}) differs from the managed gateway service Node (${managedServiceNodeRunner}).`));
|
|
3104
|
-
defaultRuntime.log(theme.muted(`Using the managed service Node for this update so the gateway can start after the upgrade.`));
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
if (updateInstallKind !== "git") {
|
|
3109
|
-
currentVersion = switchToPackage ? null : await readPackageVersion(root);
|
|
3110
|
-
if (explicitTag) targetVersion = await resolveTargetVersion(tag, timeoutMs);
|
|
3111
|
-
else targetVersion = await resolveNpmChannelTag({
|
|
3112
|
-
channel,
|
|
3113
|
-
timeoutMs
|
|
3114
|
-
}).then((resolved) => {
|
|
3115
|
-
tag = resolved.tag;
|
|
3116
|
-
fallbackToLatest = channel === "beta" && resolved.tag === "latest";
|
|
3117
|
-
return resolved.version;
|
|
3118
|
-
});
|
|
3119
|
-
const cmp = currentVersion && targetVersion ? compareSemverStrings(currentVersion, targetVersion) : null;
|
|
3120
|
-
packageAlreadyCurrent = updateInstallKind === "package" && !switchToPackage && currentVersion != null && targetVersion != null && currentVersion === targetVersion && (requestedChannel === null || requestedChannel === storedChannel);
|
|
3121
|
-
downgradeRisk = canResolveRegistryVersionForPackageTarget(tag) && !fallbackToLatest && currentVersion != null && (targetVersion == null || cmp != null && cmp > 0);
|
|
3122
|
-
packageInstallSpec = resolveGlobalInstallSpec({
|
|
3123
|
-
packageName: DEFAULT_PACKAGE_NAME,
|
|
3124
|
-
tag,
|
|
3125
|
-
env: process.env
|
|
3126
|
-
});
|
|
3127
|
-
}
|
|
3128
|
-
if (opts.dryRun) {
|
|
3129
|
-
let mode = "unknown";
|
|
3130
|
-
if (updateInstallKind === "git") mode = "git";
|
|
3131
|
-
else if (updateInstallKind === "package") mode = await resolveGlobalManager({
|
|
3132
|
-
root,
|
|
3133
|
-
installKind,
|
|
3134
|
-
timeoutMs: updateStepTimeoutMs
|
|
3135
|
-
});
|
|
3136
|
-
const actions = [];
|
|
3137
|
-
if (requestedChannel && requestedChannel !== storedChannel) actions.push(`Persist update.channel=${requestedChannel} in config`);
|
|
3138
|
-
if (switchToGit) actions.push("Switch install mode from package to git checkout (dev channel)");
|
|
3139
|
-
else if (switchToPackage) actions.push(`Switch install mode from git to package manager (${mode})`);
|
|
3140
|
-
else if (updateInstallKind === "git") actions.push(`Run git update flow on channel ${channel} (fetch/rebase/build/doctor)`);
|
|
3141
|
-
else if (packageAlreadyCurrent) actions.push(`Refresh package install with spec ${packageInstallSpec ?? tag}; current version already matches ${targetVersion}`);
|
|
3142
|
-
else actions.push(`Run global package manager update with spec ${packageInstallSpec ?? tag}`);
|
|
3143
|
-
actions.push("Run plugin update sync after core update");
|
|
3144
|
-
actions.push("Refresh shell completion cache (if needed)");
|
|
3145
|
-
actions.push(shouldRestart ? "Restart gateway service and run doctor checks" : "Skip restart (because --no-restart is set)");
|
|
3146
|
-
const notes = [];
|
|
3147
|
-
if (opts.tag && updateInstallKind === "git") notes.push("--tag applies to npm installs only; git updates ignore it.");
|
|
3148
|
-
if (fallbackToLatest) notes.push("Beta channel resolves to latest for this run (fallback).");
|
|
3149
|
-
if (managedServiceRootRedirect) notes.push(`Package update targets managed service root ${managedServiceRootRedirect.root} instead of invoking root ${managedServiceRootRedirect.previousRoot}.`);
|
|
3150
|
-
if (explicitTag && !canResolveRegistryVersionForPackageTarget(tag)) notes.push("Non-registry package specs skip npm version lookup and downgrade previews.");
|
|
3151
|
-
printDryRunPreview({
|
|
3152
|
-
dryRun: true,
|
|
3153
|
-
root,
|
|
3154
|
-
installKind,
|
|
3155
|
-
mode,
|
|
3156
|
-
updateInstallKind,
|
|
3157
|
-
switchToGit,
|
|
3158
|
-
switchToPackage,
|
|
3159
|
-
restart: shouldRestart,
|
|
3160
|
-
requestedChannel,
|
|
3161
|
-
storedChannel,
|
|
3162
|
-
effectiveChannel: channel,
|
|
3163
|
-
tag: packageInstallSpec ?? tag,
|
|
3164
|
-
currentVersion,
|
|
3165
|
-
targetVersion,
|
|
3166
|
-
downgradeRisk,
|
|
3167
|
-
actions,
|
|
3168
|
-
notes
|
|
3169
|
-
}, Boolean(opts.json));
|
|
3170
|
-
return;
|
|
3171
|
-
}
|
|
3172
|
-
if (downgradeRisk && !opts.yes) {
|
|
3173
|
-
if (!process.stdin.isTTY || opts.json) {
|
|
3174
|
-
defaultRuntime.error(["Downgrade confirmation required.", "Downgrading can break configuration. Re-run in a TTY to confirm."].join("\n"));
|
|
3175
|
-
defaultRuntime.exit(1);
|
|
3176
|
-
return;
|
|
3177
|
-
}
|
|
3178
|
-
const targetLabel = targetVersion ?? `${tag} (unknown)`;
|
|
3179
|
-
const ok = await confirm({
|
|
3180
|
-
message: stylePromptMessage(`Downgrading from ${currentVersion} to ${targetLabel} can break configuration. Continue?`),
|
|
3181
|
-
initialValue: false
|
|
3182
|
-
});
|
|
3183
|
-
if (isCancel(ok) || !ok) {
|
|
3184
|
-
if (!opts.json) defaultRuntime.log(theme.muted("Update cancelled."));
|
|
3185
|
-
defaultRuntime.exit(0);
|
|
3186
|
-
return;
|
|
3187
|
-
}
|
|
3188
|
-
}
|
|
3189
|
-
if (updateInstallKind === "git" && opts.tag && !opts.json) defaultRuntime.log(theme.muted("Note: --tag applies to npm installs only; git updates ignore it."));
|
|
3190
|
-
if (updateInstallKind === "package") {
|
|
3191
|
-
const runtimePreflightError = await resolvePackageRuntimePreflightError({
|
|
3192
|
-
tag,
|
|
3193
|
-
timeoutMs,
|
|
3194
|
-
nodeRunner: managedServiceNodeRunner
|
|
3195
|
-
});
|
|
3196
|
-
if (runtimePreflightError) {
|
|
3197
|
-
defaultRuntime.error(runtimePreflightError);
|
|
3198
|
-
defaultRuntime.exit(1);
|
|
3199
|
-
return;
|
|
3200
|
-
}
|
|
3201
|
-
}
|
|
3202
|
-
const showProgress = !opts.json && process.stdout.isTTY;
|
|
3203
|
-
if (!opts.json) {
|
|
3204
|
-
defaultRuntime.log(theme.heading("Updating DaoCore..."));
|
|
3205
|
-
defaultRuntime.log("");
|
|
3206
|
-
}
|
|
3207
|
-
const { progress, stop } = createUpdateProgress(showProgress);
|
|
3208
|
-
const startedAt = Date.now();
|
|
3209
|
-
const preUpdatePluginInstallRecords = await loadInstalledPluginIndexInstallRecords();
|
|
3210
|
-
let prePackageServiceStop;
|
|
3211
|
-
if (updateInstallKind === "package") {
|
|
3212
|
-
try {
|
|
3213
|
-
prePackageServiceStop = await maybeStopManagedServiceBeforePackageUpdate({
|
|
3214
|
-
shouldRestart,
|
|
3215
|
-
jsonMode: Boolean(opts.json)
|
|
3216
|
-
});
|
|
3217
|
-
} catch (err) {
|
|
3218
|
-
stop();
|
|
3219
|
-
defaultRuntime.error(`Failed to stop managed gateway service before update: ${String(err)}`);
|
|
3220
|
-
defaultRuntime.exit(1);
|
|
3221
|
-
return;
|
|
3222
|
-
}
|
|
3223
|
-
if (prePackageServiceStop?.blockMessage) {
|
|
3224
|
-
stop();
|
|
3225
|
-
defaultRuntime.error(prePackageServiceStop.blockMessage);
|
|
3226
|
-
defaultRuntime.exit(1);
|
|
3227
|
-
return;
|
|
3228
|
-
}
|
|
3229
|
-
if (shouldBlockPackageUpdateFromGatewayServiceEnv({ prePackageServiceStop })) {
|
|
3230
|
-
stop();
|
|
3231
|
-
defaultRuntime.error([
|
|
3232
|
-
"Package updates cannot run from inside the gateway service process.",
|
|
3233
|
-
"That path replaces the active DaoCore dist tree while the live gateway may still lazy-load old chunks.",
|
|
3234
|
-
`Run \`${replaceCliName(formatCliCommand("daocore update"), CLI_NAME)}\` from a shell outside the gateway service, or stop the gateway service first and then update.`
|
|
3235
|
-
].join("\n"));
|
|
3236
|
-
defaultRuntime.exit(1);
|
|
3237
|
-
return;
|
|
3238
|
-
}
|
|
3239
|
-
}
|
|
3240
|
-
let result;
|
|
3241
|
-
try {
|
|
3242
|
-
result = updateInstallKind === "package" ? await runPackageInstallUpdate({
|
|
3243
|
-
root,
|
|
3244
|
-
installKind,
|
|
3245
|
-
tag,
|
|
3246
|
-
timeoutMs: updateStepTimeoutMs,
|
|
3247
|
-
startedAt,
|
|
3248
|
-
progress,
|
|
3249
|
-
jsonMode: Boolean(opts.json),
|
|
3250
|
-
managedServiceEnv: prePackageServiceStop?.serviceEnv,
|
|
3251
|
-
invocationCwd,
|
|
3252
|
-
honorPackageRoot: managedServiceRootRedirect !== null || managedServiceNodeRunner !== void 0,
|
|
3253
|
-
nodeRunner: managedServiceNodeRunner
|
|
3254
|
-
}) : await runGitUpdate({
|
|
3255
|
-
root,
|
|
3256
|
-
switchToGit,
|
|
3257
|
-
installKind,
|
|
3258
|
-
timeoutMs,
|
|
3259
|
-
startedAt,
|
|
3260
|
-
progress,
|
|
3261
|
-
channel,
|
|
3262
|
-
tag,
|
|
3263
|
-
showProgress,
|
|
3264
|
-
opts,
|
|
3265
|
-
stop,
|
|
3266
|
-
devTargetRef
|
|
3267
|
-
});
|
|
3268
|
-
} catch (err) {
|
|
3269
|
-
stop();
|
|
3270
|
-
await maybeRestartServiceAfterFailedPackageUpdate({
|
|
3271
|
-
prePackageServiceStop,
|
|
3272
|
-
jsonMode: Boolean(opts.json)
|
|
3273
|
-
});
|
|
3274
|
-
throw err;
|
|
3275
|
-
}
|
|
3276
|
-
stop();
|
|
3277
|
-
if (!opts.json || result.status !== "ok") printResult(result, {
|
|
3278
|
-
...opts,
|
|
3279
|
-
hideSteps: showProgress
|
|
3280
|
-
});
|
|
3281
|
-
if (result.status === "error") {
|
|
3282
|
-
await writeControlPlaneUpdateRestartSentinelBestEffort({
|
|
3283
|
-
meta: controlPlaneUpdateSentinelMeta,
|
|
3284
|
-
result,
|
|
3285
|
-
jsonMode: Boolean(opts.json)
|
|
3286
|
-
});
|
|
3287
|
-
await maybeRestartServiceAfterFailedPackageUpdate({
|
|
3288
|
-
prePackageServiceStop,
|
|
3289
|
-
jsonMode: Boolean(opts.json)
|
|
3290
|
-
});
|
|
3291
|
-
defaultRuntime.exit(1);
|
|
3292
|
-
return;
|
|
3293
|
-
}
|
|
3294
|
-
if (result.status === "skipped") {
|
|
3295
|
-
await writeControlPlaneUpdateRestartSentinelBestEffort({
|
|
3296
|
-
meta: controlPlaneUpdateSentinelMeta,
|
|
3297
|
-
result,
|
|
3298
|
-
jsonMode: Boolean(opts.json)
|
|
3299
|
-
});
|
|
3300
|
-
await maybeRestartServiceAfterFailedPackageUpdate({
|
|
3301
|
-
prePackageServiceStop,
|
|
3302
|
-
jsonMode: Boolean(opts.json)
|
|
3303
|
-
});
|
|
3304
|
-
if (result.reason === "dirty") {
|
|
3305
|
-
defaultRuntime.error(theme.error("Update blocked: local files are edited in this checkout."));
|
|
3306
|
-
defaultRuntime.log(theme.warn("Git-based updates need a clean working tree before they can switch commits, fetch, or rebase."));
|
|
3307
|
-
defaultRuntime.log(theme.muted("Commit, stash, or discard the local changes, then rerun `daocore update`."));
|
|
3308
|
-
}
|
|
3309
|
-
if (result.reason === "not-git-install") {
|
|
3310
|
-
defaultRuntime.log(theme.warn(`Skipped: this DaoCore install isn't a git checkout, and the package manager couldn't be detected. Update via your package manager, then run \`${replaceCliName(formatCliCommand("daocore doctor"), CLI_NAME)}\` and \`${replaceCliName(formatCliCommand("daocore gateway restart"), CLI_NAME)}\`.`));
|
|
3311
|
-
defaultRuntime.log(theme.muted(`Examples: \`${replaceCliName("npm i -g daocore@latest", CLI_NAME)}\` or \`${replaceCliName("pnpm add -g daocore@latest", CLI_NAME)}\``));
|
|
3312
|
-
}
|
|
3313
|
-
defaultRuntime.exit(0);
|
|
3314
|
-
return;
|
|
3315
|
-
}
|
|
3316
|
-
const shouldResumePostCoreInFreshProcess = shouldResumePostCoreUpdateInFreshProcess({
|
|
3317
|
-
result,
|
|
3318
|
-
downgradeRisk
|
|
3319
|
-
});
|
|
3320
|
-
let postUpdateConfigSnapshot = result.status === "ok" && !opts.dryRun ? await readConfigFileSnapshot({ skipPluginValidation: true }) : configSnapshot;
|
|
3321
|
-
if (!shouldResumePostCoreInFreshProcess) postUpdateConfigSnapshot = await persistRequestedUpdateChannel({
|
|
3322
|
-
configSnapshot: postUpdateConfigSnapshot,
|
|
3323
|
-
requestedChannel
|
|
3324
|
-
});
|
|
3325
|
-
if (requestedChannel && configSnapshot.valid && requestedChannel !== storedChannel && !shouldResumePostCoreInFreshProcess && !opts.json) defaultRuntime.log(theme.muted(`Update channel set to ${requestedChannel}.`));
|
|
3326
|
-
else if (requestedChannel && configSnapshot.valid && requestedChannel !== storedChannel && shouldResumePostCoreInFreshProcess && !opts.json) defaultRuntime.log(theme.muted(`Update channel will be set to ${requestedChannel}.`));
|
|
3327
|
-
const postUpdateRoot = result.root ?? root;
|
|
3328
|
-
let postCorePluginUpdate;
|
|
3329
|
-
let pluginsUpdatedInFreshProcess = false;
|
|
3330
|
-
if (shouldResumePostCoreInFreshProcess) {
|
|
3331
|
-
const freshProcessResult = await continuePostCoreUpdateInFreshProcess({
|
|
3332
|
-
root: postUpdateRoot,
|
|
3333
|
-
channel,
|
|
3334
|
-
requestedChannel,
|
|
3335
|
-
opts,
|
|
3336
|
-
pluginInstallRecords: preUpdatePluginInstallRecords,
|
|
3337
|
-
updateStartedAtMs: startedAt,
|
|
3338
|
-
nodeRunner: managedServiceNodeRunner,
|
|
3339
|
-
preUpdateConfig: configSnapshot.valid ? {
|
|
3340
|
-
sourceConfig: configSnapshot.sourceConfig,
|
|
3341
|
-
authoredConfig: isRecord(configSnapshot.parsed) ? configSnapshot.parsed : configSnapshot.sourceConfig
|
|
3342
|
-
} : void 0
|
|
3343
|
-
});
|
|
3344
|
-
pluginsUpdatedInFreshProcess = freshProcessResult.resumed;
|
|
3345
|
-
postCorePluginUpdate = freshProcessResult.pluginUpdate;
|
|
3346
|
-
}
|
|
3347
|
-
if (!pluginsUpdatedInFreshProcess) {
|
|
3348
|
-
if (shouldResumePostCoreInFreshProcess) postUpdateConfigSnapshot = await persistRequestedUpdateChannel({
|
|
3349
|
-
configSnapshot: postUpdateConfigSnapshot,
|
|
3350
|
-
requestedChannel
|
|
3351
|
-
});
|
|
3352
|
-
const restoredConfig = restoreDroppedPreUpdateChannels(postUpdateConfigSnapshot, configSnapshot.valid ? {
|
|
3353
|
-
sourceConfig: configSnapshot.sourceConfig,
|
|
3354
|
-
authoredConfig: isRecord(configSnapshot.parsed) ? configSnapshot.parsed : configSnapshot.sourceConfig
|
|
3355
|
-
} : void 0);
|
|
3356
|
-
postUpdateConfigSnapshot = restoredConfig.snapshot;
|
|
3357
|
-
postCorePluginUpdate = await runPostCorePluginUpdate({
|
|
3358
|
-
root: postUpdateRoot,
|
|
3359
|
-
channel,
|
|
3360
|
-
configSnapshot: postUpdateConfigSnapshot,
|
|
3361
|
-
configChanged: restoredConfig.changed,
|
|
3362
|
-
restoredAuthoredChannels: restoredConfig.authoredChannels,
|
|
3363
|
-
opts,
|
|
3364
|
-
timeoutMs: updateStepTimeoutMs,
|
|
3365
|
-
pluginInstallRecords: preUpdatePluginInstallRecords
|
|
3366
|
-
});
|
|
3367
|
-
}
|
|
3368
|
-
const resultWithPostUpdate = postCorePluginUpdate ? {
|
|
3369
|
-
...result,
|
|
3370
|
-
status: postCorePluginUpdate.status === "error" ? "error" : result.status,
|
|
3371
|
-
...postCorePluginUpdate.status === "error" ? { reason: "post-update-plugins" } : {},
|
|
3372
|
-
postUpdate: {
|
|
3373
|
-
...result.postUpdate,
|
|
3374
|
-
plugins: postCorePluginUpdate
|
|
3375
|
-
}
|
|
3376
|
-
} : result;
|
|
3377
|
-
if (postCorePluginUpdate?.status === "error") {
|
|
3378
|
-
await writeControlPlaneUpdateRestartSentinelBestEffort({
|
|
3379
|
-
meta: controlPlaneUpdateSentinelMeta,
|
|
3380
|
-
result: resultWithPostUpdate,
|
|
3381
|
-
jsonMode: Boolean(opts.json)
|
|
3382
|
-
});
|
|
3383
|
-
if (opts.json) defaultRuntime.writeJson(resultWithPostUpdate);
|
|
3384
|
-
else defaultRuntime.error(theme.error("Update failed during plugin post-update sync."));
|
|
3385
|
-
defaultRuntime.exit(1);
|
|
3386
|
-
return;
|
|
3387
|
-
}
|
|
3388
|
-
let restartScriptPath = null;
|
|
3389
|
-
let refreshGatewayServiceEnv = false;
|
|
3390
|
-
let gatewayServiceEnv;
|
|
3391
|
-
let gatewayPort = resolveUpdatedGatewayRestartPort({
|
|
3392
|
-
config: postUpdateConfigSnapshot.valid ? postUpdateConfigSnapshot.config : void 0,
|
|
3393
|
-
processEnv: process.env
|
|
3394
|
-
});
|
|
3395
|
-
if (shouldRestart) try {
|
|
3396
|
-
const serviceState = await readGatewayServiceState(resolveGatewayService(), { env: resolvePostUpdateServiceStateReadEnv({
|
|
3397
|
-
updateMode: resultWithPostUpdate.mode,
|
|
3398
|
-
processEnv: process.env,
|
|
3399
|
-
prePackageServiceEnv: prePackageServiceStop?.serviceEnv
|
|
3400
|
-
}) });
|
|
3401
|
-
if (shouldPrepareUpdatedInstallRestart({
|
|
3402
|
-
updateMode: resultWithPostUpdate.mode,
|
|
3403
|
-
serviceInstalled: serviceState.installed,
|
|
3404
|
-
serviceLoaded: serviceState.loaded
|
|
3405
|
-
})) {
|
|
3406
|
-
gatewayServiceEnv = serviceState.env;
|
|
3407
|
-
gatewayPort = resolveUpdatedGatewayRestartPort({
|
|
3408
|
-
config: postUpdateConfigSnapshot.valid ? postUpdateConfigSnapshot.config : void 0,
|
|
3409
|
-
processEnv: process.env,
|
|
3410
|
-
serviceEnv: gatewayServiceEnv
|
|
3411
|
-
});
|
|
3412
|
-
restartScriptPath = await prepareRestartScript(serviceState.env, gatewayPort);
|
|
3413
|
-
refreshGatewayServiceEnv = true;
|
|
3414
|
-
}
|
|
3415
|
-
} catch {}
|
|
3416
|
-
await tryWriteCompletionCache(postUpdateRoot, Boolean(opts.json));
|
|
3417
|
-
await tryInstallShellCompletion({
|
|
3418
|
-
jsonMode: Boolean(opts.json),
|
|
3419
|
-
skipPrompt: Boolean(opts.yes)
|
|
3420
|
-
});
|
|
3421
|
-
await writeControlPlaneUpdateRestartSentinelBestEffort({
|
|
3422
|
-
meta: controlPlaneUpdateSentinelMeta,
|
|
3423
|
-
result: buildControlPlaneUpdateRestartHealthPendingResult(resultWithPostUpdate),
|
|
3424
|
-
jsonMode: Boolean(opts.json)
|
|
3425
|
-
});
|
|
3426
|
-
if (!await maybeRestartService({
|
|
3427
|
-
shouldRestart,
|
|
3428
|
-
result: resultWithPostUpdate,
|
|
3429
|
-
opts,
|
|
3430
|
-
refreshServiceEnv: refreshGatewayServiceEnv,
|
|
3431
|
-
serviceEnv: gatewayServiceEnv,
|
|
3432
|
-
gatewayPort,
|
|
3433
|
-
restartScriptPath,
|
|
3434
|
-
invocationCwd,
|
|
3435
|
-
nodeRunner: managedServiceNodeRunner
|
|
3436
|
-
})) {
|
|
3437
|
-
await markControlPlaneUpdateRestartSentinelFailureBestEffort({
|
|
3438
|
-
meta: controlPlaneUpdateSentinelMeta,
|
|
3439
|
-
reason: "restart-unhealthy",
|
|
3440
|
-
jsonMode: Boolean(opts.json)
|
|
3441
|
-
});
|
|
3442
|
-
defaultRuntime.exit(1);
|
|
3443
|
-
return;
|
|
3444
|
-
}
|
|
3445
|
-
await writeControlPlaneUpdateRestartSentinelBestEffort({
|
|
3446
|
-
meta: controlPlaneUpdateSentinelMeta,
|
|
3447
|
-
result: resultWithPostUpdate,
|
|
3448
|
-
jsonMode: Boolean(opts.json)
|
|
3449
|
-
});
|
|
3450
|
-
if (!opts.json) defaultRuntime.log(theme.muted(pickUpdateQuip()));
|
|
3451
|
-
else defaultRuntime.writeJson(resultWithPostUpdate);
|
|
3452
|
-
}
|
|
3453
|
-
//#endregion
|
|
3454
|
-
//#region src/cli/update-cli/wizard.ts
|
|
3455
|
-
async function updateWizardCommand(opts = {}) {
|
|
3456
|
-
if (!process.stdin.isTTY) {
|
|
3457
|
-
defaultRuntime.error("Update wizard requires a TTY. Use `daocore update --channel <stable|beta|dev>` instead.");
|
|
3458
|
-
defaultRuntime.exit(1);
|
|
3459
|
-
return;
|
|
3460
|
-
}
|
|
3461
|
-
const timeoutMs = parseTimeoutMsOrExit(opts.timeout);
|
|
3462
|
-
if (timeoutMs === null) return;
|
|
3463
|
-
const root = await resolveUpdateRoot();
|
|
3464
|
-
const [updateStatus, configSnapshot] = await Promise.all([checkUpdateStatus({
|
|
3465
|
-
root,
|
|
3466
|
-
timeoutMs: timeoutMs ?? 3500,
|
|
3467
|
-
fetchGit: false,
|
|
3468
|
-
includeRegistry: false
|
|
3469
|
-
}), readConfigFileSnapshot()]);
|
|
3470
|
-
const channelInfo = resolveEffectiveUpdateChannel({
|
|
3471
|
-
configChannel: configSnapshot.valid ? normalizeUpdateChannel(configSnapshot.config.update?.channel) : null,
|
|
3472
|
-
installKind: updateStatus.installKind,
|
|
3473
|
-
git: updateStatus.git ? {
|
|
3474
|
-
tag: updateStatus.git.tag,
|
|
3475
|
-
branch: updateStatus.git.branch
|
|
3476
|
-
} : void 0
|
|
3477
|
-
});
|
|
3478
|
-
const channelLabel = formatUpdateChannelLabel({
|
|
3479
|
-
channel: channelInfo.channel,
|
|
3480
|
-
source: channelInfo.source,
|
|
3481
|
-
gitTag: updateStatus.git?.tag ?? null,
|
|
3482
|
-
gitBranch: updateStatus.git?.branch ?? null
|
|
3483
|
-
});
|
|
3484
|
-
const pickedChannel = await selectStyled({
|
|
3485
|
-
message: "Update channel",
|
|
3486
|
-
options: [
|
|
3487
|
-
{
|
|
3488
|
-
value: "keep",
|
|
3489
|
-
label: `Keep current (${channelInfo.channel})`,
|
|
3490
|
-
hint: channelLabel
|
|
3491
|
-
},
|
|
3492
|
-
{
|
|
3493
|
-
value: "stable",
|
|
3494
|
-
label: "Stable",
|
|
3495
|
-
hint: "Tagged releases (npm latest)"
|
|
3496
|
-
},
|
|
3497
|
-
{
|
|
3498
|
-
value: "beta",
|
|
3499
|
-
label: "Beta",
|
|
3500
|
-
hint: "Prereleases (npm beta)"
|
|
3501
|
-
},
|
|
3502
|
-
{
|
|
3503
|
-
value: "dev",
|
|
3504
|
-
label: "Dev",
|
|
3505
|
-
hint: "Git main"
|
|
3506
|
-
}
|
|
3507
|
-
],
|
|
3508
|
-
initialValue: "keep"
|
|
3509
|
-
});
|
|
3510
|
-
if (isCancel(pickedChannel)) {
|
|
3511
|
-
defaultRuntime.log(theme.muted("Update cancelled."));
|
|
3512
|
-
defaultRuntime.exit(0);
|
|
3513
|
-
return;
|
|
3514
|
-
}
|
|
3515
|
-
const requestedChannel = pickedChannel === "keep" ? null : pickedChannel;
|
|
3516
|
-
if (requestedChannel === "dev" && updateStatus.installKind !== "git") {
|
|
3517
|
-
const gitDir = resolveGitInstallDir();
|
|
3518
|
-
if (!await isGitCheckout(gitDir)) {
|
|
3519
|
-
if (await pathExists$1(gitDir)) {
|
|
3520
|
-
if (!await isEmptyDir(gitDir)) {
|
|
3521
|
-
defaultRuntime.error(`DAOCORE_GIT_DIR points at a non-git directory: ${gitDir}. Set DAOCORE_GIT_DIR to an empty folder or an daocore checkout.`);
|
|
3522
|
-
defaultRuntime.exit(1);
|
|
3523
|
-
return;
|
|
3524
|
-
}
|
|
3525
|
-
}
|
|
3526
|
-
const ok = await confirm({
|
|
3527
|
-
message: stylePromptMessage(`Create a git checkout at ${gitDir}? (override via DAOCORE_GIT_DIR)`),
|
|
3528
|
-
initialValue: true
|
|
3529
|
-
});
|
|
3530
|
-
if (isCancel(ok) || !ok) {
|
|
3531
|
-
defaultRuntime.log(theme.muted("Update cancelled."));
|
|
3532
|
-
defaultRuntime.exit(0);
|
|
3533
|
-
return;
|
|
3534
|
-
}
|
|
3535
|
-
}
|
|
3536
|
-
}
|
|
3537
|
-
const restart = await confirm({
|
|
3538
|
-
message: stylePromptMessage("Restart the gateway service after update?"),
|
|
3539
|
-
initialValue: true
|
|
3540
|
-
});
|
|
3541
|
-
if (isCancel(restart)) {
|
|
3542
|
-
defaultRuntime.log(theme.muted("Update cancelled."));
|
|
3543
|
-
defaultRuntime.exit(0);
|
|
3544
|
-
return;
|
|
3545
|
-
}
|
|
3546
|
-
try {
|
|
3547
|
-
await updateCommand({
|
|
3548
|
-
channel: requestedChannel ?? void 0,
|
|
3549
|
-
restart,
|
|
3550
|
-
timeout: opts.timeout
|
|
3551
|
-
});
|
|
3552
|
-
} catch (err) {
|
|
3553
|
-
defaultRuntime.error(String(err));
|
|
3554
|
-
defaultRuntime.exit(1);
|
|
3555
|
-
}
|
|
3556
|
-
}
|
|
3557
|
-
//#endregion
|
|
3558
|
-
//#region src/cli/update-cli.ts
|
|
3559
|
-
function inheritedUpdateJson(command) {
|
|
3560
|
-
return Boolean(inheritOptionFromParent(command, "json"));
|
|
3561
|
-
}
|
|
3562
|
-
function inheritedUpdateTimeout(opts, command) {
|
|
3563
|
-
const timeout = opts.timeout;
|
|
3564
|
-
if (timeout) return timeout;
|
|
3565
|
-
return inheritOptionFromParent(command, "timeout");
|
|
3566
|
-
}
|
|
3567
|
-
function registerUpdateCli(program) {
|
|
3568
|
-
program.enablePositionalOptions();
|
|
3569
|
-
const update = program.command("update").description("Update DaoCore and inspect update channel status").option("--json", "Output result as JSON", false).option("--no-restart", "Skip restarting the gateway service after a successful update").option("--dry-run", "Preview update actions without making changes", false).option("--channel <stable|beta|dev>", "Persist update channel (git + npm)").option("--tag <dist-tag|version|spec>", "Override the package target for this update (dist-tag, version, or package spec)").option("--timeout <seconds>", "Timeout for each update step in seconds (default: 1800)").option("--yes", "Skip confirmation prompts (non-interactive)", false).addHelpText("after", () => {
|
|
3570
|
-
const fmtExamples = [
|
|
3571
|
-
["daocore update", "Update a source checkout (git)"],
|
|
3572
|
-
["daocore update --channel beta", "Switch to beta channel (git + npm)"],
|
|
3573
|
-
["daocore update --channel dev", "Switch to dev channel (git + npm)"],
|
|
3574
|
-
["daocore update --tag beta", "One-off update to a dist-tag or version"],
|
|
3575
|
-
["daocore update --tag main", "One-off package update from GitHub main"],
|
|
3576
|
-
["daocore update --dry-run", "Preview actions without changing anything"],
|
|
3577
|
-
["daocore update --no-restart", "Update without restarting the service"],
|
|
3578
|
-
["daocore update --json", "Output result as JSON"],
|
|
3579
|
-
["daocore update --yes", "Non-interactive (accept downgrade prompts)"],
|
|
3580
|
-
["daocore update wizard", "Interactive update wizard"],
|
|
3581
|
-
["daocore --update", "Shorthand for daocore update"]
|
|
3582
|
-
].map(([cmd, desc]) => ` ${theme.command(cmd)} ${theme.muted(`# ${desc}`)}`).join("\n");
|
|
3583
|
-
return `
|
|
3584
|
-
${theme.heading("What this does:")}
|
|
3585
|
-
- Git checkouts: fetches, rebases, installs deps, builds, and runs doctor
|
|
3586
|
-
- npm installs: updates via detected package manager
|
|
3587
|
-
|
|
3588
|
-
${theme.heading("Switch channels:")}
|
|
3589
|
-
- Use --channel stable|beta|dev to persist the update channel in config
|
|
3590
|
-
- Run daocore update status to see the active channel and source
|
|
3591
|
-
- Use --tag <dist-tag|version|spec> for a one-off package update without persisting
|
|
3592
|
-
- Use --tag main for a one-off package update from GitHub main
|
|
3593
|
-
|
|
3594
|
-
${theme.heading("Non-interactive:")}
|
|
3595
|
-
- Use --yes to accept downgrade prompts
|
|
3596
|
-
- Combine with --channel/--tag/--no-restart/--json/--timeout as needed
|
|
3597
|
-
- Use --dry-run to preview actions without writing config/installing/restarting
|
|
3598
|
-
|
|
3599
|
-
${theme.heading("Examples:")}
|
|
3600
|
-
${fmtExamples}
|
|
3601
|
-
|
|
3602
|
-
${theme.heading("Notes:")}
|
|
3603
|
-
- Switch channels with --channel stable|beta|dev
|
|
3604
|
-
- For global installs: auto-updates via detected package manager when possible (see docs/install/updating.md)
|
|
3605
|
-
- Downgrades require confirmation (can break configuration)
|
|
3606
|
-
- Skips update if the working directory has uncommitted changes
|
|
3607
|
-
|
|
3608
|
-
${theme.muted("Docs:")} ${formatDocsLink("/cli/update", "docs.openclaw.ai/cli/update")}`;
|
|
3609
|
-
}).action(async (opts) => {
|
|
3610
|
-
try {
|
|
3611
|
-
await updateCommand({
|
|
3612
|
-
json: Boolean(opts.json),
|
|
3613
|
-
restart: Boolean(opts.restart),
|
|
3614
|
-
dryRun: Boolean(opts.dryRun),
|
|
3615
|
-
channel: opts.channel,
|
|
3616
|
-
tag: opts.tag,
|
|
3617
|
-
timeout: opts.timeout,
|
|
3618
|
-
yes: Boolean(opts.yes)
|
|
3619
|
-
});
|
|
3620
|
-
} catch (err) {
|
|
3621
|
-
defaultRuntime.error(String(err));
|
|
3622
|
-
defaultRuntime.exit(1);
|
|
3623
|
-
}
|
|
3624
|
-
});
|
|
3625
|
-
update.command("finalize", { hidden: true }).description("Run DaoCore update finalization after an external core runtime change").option("--json", "Output result as JSON", false).option("--channel <stable|beta|dev>", "Persist update channel for finalization").option("--timeout <seconds>", "Timeout for update finalization steps in seconds (default: 1800)").option("--yes", "Skip confirmation prompts (non-interactive)", false).option("--no-restart", "Accepted for update command parity; finalization never restarts").action(async (opts, command) => {
|
|
3626
|
-
try {
|
|
3627
|
-
await updateFinalizeCommand({
|
|
3628
|
-
json: Boolean(opts.json) || inheritedUpdateJson(command),
|
|
3629
|
-
channel: opts.channel,
|
|
3630
|
-
timeout: inheritedUpdateTimeout(opts, command),
|
|
3631
|
-
yes: Boolean(opts.yes),
|
|
3632
|
-
restart: Boolean(opts.restart)
|
|
3633
|
-
});
|
|
3634
|
-
} catch (err) {
|
|
3635
|
-
defaultRuntime.error(String(err));
|
|
3636
|
-
defaultRuntime.exit(1);
|
|
3637
|
-
}
|
|
3638
|
-
});
|
|
3639
|
-
update.command("wizard").description("Interactive update wizard").option("--timeout <seconds>", "Timeout for each update step in seconds (default: 1800)").addHelpText("after", `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/update", "docs.openclaw.ai/cli/update")}\n`).action(async (opts, command) => {
|
|
3640
|
-
try {
|
|
3641
|
-
await updateWizardCommand({ timeout: inheritedUpdateTimeout(opts, command) });
|
|
3642
|
-
} catch (err) {
|
|
3643
|
-
defaultRuntime.error(String(err));
|
|
3644
|
-
defaultRuntime.exit(1);
|
|
3645
|
-
}
|
|
3646
|
-
});
|
|
3647
|
-
update.command("status").description("Show update channel and version status").option("--json", "Output result as JSON", false).option("--timeout <seconds>", "Timeout for update checks in seconds (default: 3)").addHelpText("after", () => `\n${theme.heading("Examples:")}\n${formatHelpExamples([
|
|
3648
|
-
["daocore update status", "Show channel + version status."],
|
|
3649
|
-
["daocore update status --json", "JSON output."],
|
|
3650
|
-
["daocore update status --timeout 10", "Custom timeout."]
|
|
3651
|
-
])}\n\n${theme.heading("Notes:")}\n${theme.muted("- Shows current update channel (stable/beta/dev) and source")}\n${theme.muted("- Includes git tag/branch/SHA for source checkouts")}\n\n${theme.muted("Docs:")} ${formatDocsLink("/cli/update", "docs.openclaw.ai/cli/update")}`).action(async (opts, command) => {
|
|
3652
|
-
try {
|
|
3653
|
-
await updateStatusCommand({
|
|
3654
|
-
json: Boolean(opts.json) || inheritedUpdateJson(command),
|
|
3655
|
-
timeout: inheritedUpdateTimeout(opts, command)
|
|
3656
|
-
});
|
|
3657
|
-
} catch (err) {
|
|
3658
|
-
defaultRuntime.error(String(err));
|
|
3659
|
-
defaultRuntime.exit(1);
|
|
3660
|
-
}
|
|
3661
|
-
});
|
|
3662
|
-
}
|
|
3663
|
-
//#endregion
|
|
3664
|
-
export { registerUpdateCli, updateCommand, updateFinalizeCommand, updateStatusCommand, updateWizardCommand };
|