wezard 2.8.8 → 3.0.1
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/.claude-plugin/plugin.json +0 -6
- package/CLAUDE.md +36 -16
- package/README.md +41 -54
- package/cli/wezard.sh +3 -0
- package/config.example.jsonc +6 -8
- package/dist/cli/codex-hook.js +20 -4
- package/dist/cli/codex-hook.js.map +1 -1
- package/dist/cli/init.js +45 -8
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/skills.js +113 -0
- package/dist/cli/skills.js.map +1 -0
- package/dist/cli/sync.js +32 -112
- package/dist/cli/sync.js.map +1 -1
- package/dist/daemon/apprentice.js +75 -0
- package/dist/daemon/apprentice.js.map +1 -0
- package/dist/daemon/approval.js +78 -20
- package/dist/daemon/approval.js.map +1 -1
- package/dist/daemon/channel-context.js +69 -0
- package/dist/daemon/channel-context.js.map +1 -0
- package/dist/daemon/channel-posts.js +53 -0
- package/dist/daemon/channel-posts.js.map +1 -0
- package/dist/daemon/channel-store.js +96 -0
- package/dist/daemon/channel-store.js.map +1 -0
- package/dist/daemon/channel.js +805 -0
- package/dist/daemon/channel.js.map +1 -0
- package/dist/daemon/chat-name.js +24 -161
- package/dist/daemon/chat-name.js.map +1 -1
- package/dist/daemon/classes.js +418 -0
- package/dist/daemon/classes.js.map +1 -0
- package/dist/daemon/config-api.js +11 -3
- package/dist/daemon/config-api.js.map +1 -1
- package/dist/daemon/danger.js +24 -205
- package/dist/daemon/danger.js.map +1 -1
- package/dist/daemon/detail.js +14 -8
- package/dist/daemon/detail.js.map +1 -1
- package/dist/daemon/handoff.js +266 -50
- package/dist/daemon/handoff.js.map +1 -1
- package/dist/daemon/http.js +25 -18
- package/dist/daemon/http.js.map +1 -1
- package/dist/daemon/idle-reap.js +30 -0
- package/dist/daemon/idle-reap.js.map +1 -0
- package/dist/daemon/inbound.js +366 -143
- package/dist/daemon/inbound.js.map +1 -1
- package/dist/daemon/index.js +2232 -2616
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/last-response.js +44 -9
- package/dist/daemon/last-response.js.map +1 -1
- package/dist/daemon/memory-steward.js +1 -1
- package/dist/daemon/memory-steward.js.map +1 -1
- package/dist/daemon/message-format.js +10 -2
- package/dist/daemon/message-format.js.map +1 -1
- package/dist/daemon/mirror-bridge.js +714 -485
- package/dist/daemon/mirror-bridge.js.map +1 -1
- package/dist/daemon/mirror-store.js +24 -0
- package/dist/daemon/mirror-store.js.map +1 -1
- package/dist/daemon/notices.js +2 -2
- package/dist/daemon/notices.js.map +1 -1
- package/dist/daemon/onboarding.js +384 -0
- package/dist/daemon/onboarding.js.map +1 -0
- package/dist/daemon/outbound.js +21 -11
- package/dist/daemon/outbound.js.map +1 -1
- package/dist/daemon/peers.js +38 -230
- package/dist/daemon/peers.js.map +1 -1
- package/dist/daemon/pending.js +7 -5
- package/dist/daemon/pending.js.map +1 -1
- package/dist/daemon/picker-policy.js +27 -12
- package/dist/daemon/picker-policy.js.map +1 -1
- package/dist/daemon/plans.js.map +1 -1
- package/dist/daemon/room-auto-adhoc.js +18 -0
- package/dist/daemon/room-auto-adhoc.js.map +1 -0
- package/dist/daemon/room-facts.js +35 -0
- package/dist/daemon/room-facts.js.map +1 -0
- package/dist/daemon/room-hub.js +430 -0
- package/dist/daemon/room-hub.js.map +1 -0
- package/dist/daemon/room-overdue.js +98 -0
- package/dist/daemon/room-overdue.js.map +1 -0
- package/dist/daemon/room-prune.js +74 -0
- package/dist/daemon/room-prune.js.map +1 -0
- package/dist/daemon/room-spawn.js +20 -0
- package/dist/daemon/room-spawn.js.map +1 -0
- package/dist/daemon/room-watchdog.js +153 -0
- package/dist/daemon/room-watchdog.js.map +1 -0
- package/dist/daemon/rooms.js +107 -0
- package/dist/daemon/rooms.js.map +1 -0
- package/dist/daemon/route.js +7 -18
- package/dist/daemon/route.js.map +1 -1
- package/dist/daemon/spawn-tmux.js +171 -55
- package/dist/daemon/spawn-tmux.js.map +1 -1
- package/dist/daemon/steward-guard.js +2 -2
- package/dist/daemon/steward.js +132 -0
- package/dist/daemon/steward.js.map +1 -0
- package/dist/daemon/tasks.js +4 -14
- package/dist/daemon/tasks.js.map +1 -1
- package/dist/daemon/turn-opening.js +25 -0
- package/dist/daemon/turn-opening.js.map +1 -0
- package/dist/daemon/wake-tail.js +55 -0
- package/dist/daemon/wake-tail.js.map +1 -0
- package/dist/daemon/weixin-cmd.js +10 -14
- package/dist/daemon/weixin-cmd.js.map +1 -1
- package/dist/daemon/wezard-session.js +7 -2
- package/dist/daemon/wezard-session.js.map +1 -1
- package/dist/daemon/wizard-names.js +0 -22
- package/dist/daemon/wizard-names.js.map +1 -1
- package/dist/daemon/wizard.js +589 -145
- package/dist/daemon/wizard.js.map +1 -1
- package/dist/mcp/output.js +6 -5
- package/dist/mcp/output.js.map +1 -1
- package/dist/mcp/tools.js +258 -236
- package/dist/mcp/tools.js.map +1 -1
- package/dist/shared/allow-rules.js +32 -8
- package/dist/shared/allow-rules.js.map +1 -1
- package/dist/shared/charter-rearm.js +179 -0
- package/dist/shared/charter-rearm.js.map +1 -0
- package/dist/shared/chat-http.js +374 -459
- package/dist/shared/chat-http.js.map +1 -1
- package/dist/shared/chat-record.js +55 -0
- package/dist/shared/chat-record.js.map +1 -0
- package/dist/shared/chat-render.js +7 -4
- package/dist/shared/chat-render.js.map +1 -1
- package/dist/shared/chat-view.js +2 -41
- package/dist/shared/chat-view.js.map +1 -1
- package/dist/shared/cli-backends.js +27 -5
- package/dist/shared/cli-backends.js.map +1 -1
- package/dist/shared/config.js +122 -38
- package/dist/shared/config.js.map +1 -1
- package/dist/shared/detail-render.js +104 -21
- package/dist/shared/detail-render.js.map +1 -1
- package/dist/shared/detail-store.js.map +1 -1
- package/dist/shared/group-members.js +35 -0
- package/dist/shared/group-members.js.map +1 -0
- package/dist/shared/inject-view.js +105 -0
- package/dist/shared/inject-view.js.map +1 -0
- package/dist/shared/json-map-store.js +23 -6
- package/dist/shared/json-map-store.js.map +1 -1
- package/dist/shared/legacy-routes.js +199 -0
- package/dist/shared/legacy-routes.js.map +1 -0
- package/dist/shared/mem-guard.js +32 -0
- package/dist/shared/mem-guard.js.map +1 -0
- package/dist/shared/message-footer.js +4 -3
- package/dist/shared/message-footer.js.map +1 -1
- package/dist/shared/pricing.js +5 -0
- package/dist/shared/pricing.js.map +1 -1
- package/dist/shared/reminder.js +30 -38
- package/dist/shared/reminder.js.map +1 -1
- package/dist/shared/repl-script.js +114 -26
- package/dist/shared/repl-script.js.map +1 -1
- package/dist/shared/role-render.js +209 -210
- package/dist/shared/role-render.js.map +1 -1
- package/dist/shared/role-view.js +61 -299
- package/dist/shared/role-view.js.map +1 -1
- package/dist/shared/room-label.js +13 -0
- package/dist/shared/room-label.js.map +1 -0
- package/dist/shared/room-migrate.js +404 -0
- package/dist/shared/room-migrate.js.map +1 -0
- package/dist/shared/room-overdue.js +81 -0
- package/dist/shared/room-overdue.js.map +1 -0
- package/dist/shared/room-search.js +102 -0
- package/dist/shared/room-search.js.map +1 -0
- package/dist/shared/room-view.js +261 -0
- package/dist/shared/room-view.js.map +1 -0
- package/dist/shared/room.js +610 -0
- package/dist/shared/room.js.map +1 -0
- package/dist/shared/session-hooks.js +58 -0
- package/dist/shared/session-hooks.js.map +1 -0
- package/dist/shared/session-label.js +80 -60
- package/dist/shared/session-label.js.map +1 -1
- package/dist/shared/session-mcp.js +77 -0
- package/dist/shared/session-mcp.js.map +1 -0
- package/dist/shared/session-skills.js +63 -0
- package/dist/shared/session-skills.js.map +1 -0
- package/dist/shared/skill-sync.js +229 -0
- package/dist/shared/skill-sync.js.map +1 -0
- package/dist/shared/smarts.js +39 -0
- package/dist/shared/smarts.js.map +1 -0
- package/dist/shared/stream-page.js +22 -0
- package/dist/shared/stream-page.js.map +1 -0
- package/dist/shared/task-file.js +0 -5
- package/dist/shared/task-file.js.map +1 -1
- package/dist/shared/task-template.js +1 -1
- package/dist/shared/task-template.js.map +1 -1
- package/dist/shared/tool-hints.js +76 -17
- package/dist/shared/tool-hints.js.map +1 -1
- package/dist/shared/workspace-trust.js +8 -0
- package/dist/shared/workspace-trust.js.map +1 -1
- package/dist/shared/world.js +101 -166
- package/dist/shared/world.js.map +1 -1
- package/dist/svr/facts-store.js +26 -0
- package/dist/svr/facts-store.js.map +1 -0
- package/dist/svr/index.js +62 -6
- package/dist/svr/index.js.map +1 -1
- package/hooks/pre-tool-use.sh +18 -0
- package/hooks/stop.sh +26 -0
- package/package.json +7 -3
- package/scripts/install.sh +11 -0
- package/skills/LICENSE.wecom-unified.txt +21 -0
- package/skills/wecom-unified/SKILL.md +151 -0
- package/skills/wecom-unified/assets/templates/broadside/DESIGN.preset.md +172 -0
- package/skills/wecom-unified/assets/templates/broadside/shell/content.jsx +31 -0
- package/skills/wecom-unified/assets/templates/broadside/slides/01_cover.slide +48 -0
- package/skills/wecom-unified/assets/templates/broadside/slides/02_section.slide +58 -0
- package/skills/wecom-unified/assets/templates/broadside/slides/03_cards.slide +53 -0
- package/skills/wecom-unified/assets/templates/broadside/slides/04_image.slide +64 -0
- package/skills/wecom-unified/assets/templates/cartesian/DESIGN.preset.md +139 -0
- package/skills/wecom-unified/assets/templates/cartesian/shell/content.jsx +28 -0
- package/skills/wecom-unified/assets/templates/cartesian/slides/01_cover.slide +44 -0
- package/skills/wecom-unified/assets/templates/cartesian/slides/02_compare.slide +79 -0
- package/skills/wecom-unified/assets/templates/cartesian/slides/03_table.slide +79 -0
- package/skills/wecom-unified/assets/templates/cobalt-grid/DESIGN.preset.md +118 -0
- package/skills/wecom-unified/assets/templates/cobalt-grid/shell/content.jsx +24 -0
- package/skills/wecom-unified/assets/templates/cobalt-grid/slides/01_cover.slide +61 -0
- package/skills/wecom-unified/assets/templates/cobalt-grid/slides/02_structure.slide +85 -0
- package/skills/wecom-unified/assets/templates/cobalt-grid/slides/03_data.slide +60 -0
- package/skills/wecom-unified/assets/templates/editorial-forest/DESIGN.preset.md +135 -0
- package/skills/wecom-unified/assets/templates/editorial-forest/shell/content.jsx +19 -0
- package/skills/wecom-unified/assets/templates/editorial-forest/slides/01_cover.slide +29 -0
- package/skills/wecom-unified/assets/templates/editorial-forest/slides/02_cards.slide +60 -0
- package/skills/wecom-unified/assets/templates/editorial-forest/slides/03_data.slide +49 -0
- package/skills/wecom-unified/assets/templates/editorial-forest/slides/04_image.slide +46 -0
- package/skills/wecom-unified/assets/templates/emerald-editorial/DESIGN.preset.md +119 -0
- package/skills/wecom-unified/assets/templates/emerald-editorial/shell/content.jsx +18 -0
- package/skills/wecom-unified/assets/templates/emerald-editorial/slides/01_cover.slide +36 -0
- package/skills/wecom-unified/assets/templates/emerald-editorial/slides/02_section.slide +39 -0
- package/skills/wecom-unified/assets/templates/emerald-editorial/slides/03_data.slide +79 -0
- package/skills/wecom-unified/assets/templates/emerald-editorial/slides/04_steps.slide +53 -0
- package/skills/wecom-unified/assets/templates/grove/DESIGN.preset.md +159 -0
- package/skills/wecom-unified/assets/templates/grove/shell/content.jsx +18 -0
- package/skills/wecom-unified/assets/templates/grove/shell/content_light.jsx +18 -0
- package/skills/wecom-unified/assets/templates/grove/slides/01_cover.slide +26 -0
- package/skills/wecom-unified/assets/templates/grove/slides/02_compare.slide +92 -0
- package/skills/wecom-unified/assets/templates/grove/slides/03_table.slide +68 -0
- package/skills/wecom-unified/assets/templates/index.json +280 -0
- package/skills/wecom-unified/assets/templates/long-table/DESIGN.preset.md +135 -0
- package/skills/wecom-unified/assets/templates/long-table/shell/content.jsx +36 -0
- package/skills/wecom-unified/assets/templates/long-table/slides/01_cover.slide +71 -0
- package/skills/wecom-unified/assets/templates/long-table/slides/02_cards.slide +72 -0
- package/skills/wecom-unified/assets/templates/long-table/slides/03_timeline.slide +81 -0
- package/skills/wecom-unified/assets/templates/long-table/slides/04_image.slide +60 -0
- package/skills/wecom-unified/assets/templates/sakura-chroma/DESIGN.preset.md +121 -0
- package/skills/wecom-unified/assets/templates/sakura-chroma/shell/content.jsx +13 -0
- package/skills/wecom-unified/assets/templates/sakura-chroma/slides/01_cover.slide +54 -0
- package/skills/wecom-unified/assets/templates/sakura-chroma/slides/02_products.slide +134 -0
- package/skills/wecom-unified/assets/templates/sakura-chroma/slides/03_section.slide +30 -0
- package/skills/wecom-unified/assets/templates/sakura-chroma/slides/04_schedule.slide +65 -0
- package/skills/wecom-unified/assets/templates/signal/DESIGN.preset.md +121 -0
- package/skills/wecom-unified/assets/templates/signal/shell/content.jsx +18 -0
- package/skills/wecom-unified/assets/templates/signal/shell/content_dark.jsx +23 -0
- package/skills/wecom-unified/assets/templates/signal/slides/01_cover.slide +48 -0
- package/skills/wecom-unified/assets/templates/signal/slides/02_cards.slide +67 -0
- package/skills/wecom-unified/assets/templates/signal/slides/03_data.slide +68 -0
- package/skills/wecom-unified/references/wecomcli-calendar-agenda.md +227 -0
- package/skills/wecom-unified/references/wecomcli-calendar-cancel.md +108 -0
- package/skills/wecom-unified/references/wecomcli-calendar-create.md +238 -0
- package/skills/wecom-unified/references/wecomcli-calendar-freebusy.md +207 -0
- package/skills/wecom-unified/references/wecomcli-calendar-meeting-room.md +170 -0
- package/skills/wecom-unified/references/wecomcli-calendar-search.md +209 -0
- package/skills/wecom-unified/references/wecomcli-calendar-update.md +272 -0
- package/skills/wecom-unified/references/wecomcli-calendar.md +296 -0
- package/skills/wecom-unified/references/wecomcli-contact.md +48 -0
- package/skills/wecom-unified/references/wecomcli-disk.md +380 -0
- package/skills/wecom-unified/references/wecomcli-doc-contents-append.md +20 -0
- package/skills/wecom-unified/references/wecomcli-doc-contents-overwrite.md +27 -0
- package/skills/wecom-unified/references/wecomcli-doc-create.md +162 -0
- package/skills/wecom-unified/references/wecomcli-doc-manage-doc-members-update.md +24 -0
- package/skills/wecom-unified/references/wecomcli-doc-manage-doc-names-update.md +20 -0
- package/skills/wecom-unified/references/wecomcli-doc-manage-doc-rules-update.md +22 -0
- package/skills/wecom-unified/references/wecomcli-doc-manage.md +127 -0
- package/skills/wecom-unified/references/wecomcli-doc.md +135 -0
- package/skills/wecom-unified/references/wecomcli-email-forward-mail.md +131 -0
- package/skills/wecom-unified/references/wecomcli-email-get-mail.md +187 -0
- package/skills/wecom-unified/references/wecomcli-email-reply-mail.md +138 -0
- package/skills/wecom-unified/references/wecomcli-email-search-mail.md +114 -0
- package/skills/wecom-unified/references/wecomcli-email-security.md +52 -0
- package/skills/wecom-unified/references/wecomcli-email-send-mail.md +186 -0
- package/skills/wecom-unified/references/wecomcli-email-send-schedule.md +83 -0
- package/skills/wecom-unified/references/wecomcli-email.md +206 -0
- package/skills/wecom-unified/references/wecomcli-media.md +89 -0
- package/skills/wecom-unified/references/wecomcli-meeting-cancel.md +113 -0
- package/skills/wecom-unified/references/wecomcli-meeting-create.md +167 -0
- package/skills/wecom-unified/references/wecomcli-meeting-list.md +228 -0
- package/skills/wecom-unified/references/wecomcli-meeting-original-get.md +101 -0
- package/skills/wecom-unified/references/wecomcli-meeting-search.md +176 -0
- package/skills/wecom-unified/references/wecomcli-meeting-update.md +217 -0
- package/skills/wecom-unified/references/wecomcli-meeting.md +366 -0
- package/skills/wecom-unified/references/wecomcli-message.md +190 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-animation.md +62 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-box.md +102 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-chart.md +261 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-codeblock.md +70 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-diagram.md +54 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-faicon.md +71 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-hyperlink.md +55 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-image.md +107 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-math.md +65 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-qrcode.md +22 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-slide.md +74 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-svg.md +95 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-table.md +72 -0
- package/skills/wecom-unified/references/wecomcli-pptx-component-text.md +96 -0
- package/skills/wecom-unified/references/wecomcli-pptx-content-contract.md +73 -0
- package/skills/wecom-unified/references/wecomcli-pptx-create-from-material.md +67 -0
- package/skills/wecom-unified/references/wecomcli-pptx-create-from-scratch.md +178 -0
- package/skills/wecom-unified/references/wecomcli-pptx-create-from-template.md +123 -0
- package/skills/wecom-unified/references/wecomcli-pptx-design-principle.md +65 -0
- package/skills/wecom-unified/references/wecomcli-pptx-government-contract.md +40 -0
- package/skills/wecom-unified/references/wecomcli-pptx-human-alignment.md +140 -0
- package/skills/wecom-unified/references/wecomcli-pptx-pptx-api.md +161 -0
- package/skills/wecom-unified/references/wecomcli-pptx-pptx-edit.md +37 -0
- package/skills/wecom-unified/references/wecomcli-pptx-story-principle.md +184 -0
- package/skills/wecom-unified/references/wecomcli-pptx-templates-README.md +165 -0
- package/skills/wecom-unified/references/wecomcli-pptx-templates-anti-ai-slop.md +52 -0
- package/skills/wecom-unified/references/wecomcli-pptx.md +158 -0
- package/skills/wecom-unified/references/wecomcli-sheet-conditional-formatting.md +203 -0
- package/skills/wecom-unified/references/wecomcli-sheet-filter.md +179 -0
- package/skills/wecom-unified/references/wecomcli-sheet-float-image.md +235 -0
- package/skills/wecom-unified/references/wecomcli-sheet-formulas.md +71 -0
- package/skills/wecom-unified/references/wecomcli-sheet-history.md +118 -0
- package/skills/wecom-unified/references/wecomcli-sheet-protection.md +170 -0
- package/skills/wecom-unified/references/wecomcli-sheet-range-operations.md +306 -0
- package/skills/wecom-unified/references/wecomcli-sheet-read-data.md +151 -0
- package/skills/wecom-unified/references/wecomcli-sheet-search-replace.md +121 -0
- package/skills/wecom-unified/references/wecomcli-sheet-structure-operations.md +394 -0
- package/skills/wecom-unified/references/wecomcli-sheet-style.md +246 -0
- package/skills/wecom-unified/references/wecomcli-sheet-table-style.md +199 -0
- package/skills/wecom-unified/references/wecomcli-sheet-validation.md +217 -0
- package/skills/wecom-unified/references/wecomcli-sheet-visual-standards.md +166 -0
- package/skills/wecom-unified/references/wecomcli-sheet-workbook.md +264 -0
- package/skills/wecom-unified/references/wecomcli-sheet-write-cells.md +320 -0
- package/skills/wecom-unified/references/wecomcli-sheet-xlsx-process.md +324 -0
- package/skills/wecom-unified/references/wecomcli-sheet.md +96 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-data-driven-pages.md +50 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-edit.md +526 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-formula-arraylist.md +369 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-formula-datetime.md +283 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-formula-logic.md +247 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-formula-math.md +362 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-formula-operators.md +246 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-formula-pageblock.md +76 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-formula-reference.md +192 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-formula-templates.md +410 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-formula-text.md +377 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-formula-user.md +22 -0
- package/skills/wecom-unified/references/wecomcli-smartpage-mdx-syntax.md +739 -0
- package/skills/wecom-unified/references/wecomcli-smartpage.md +179 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-chart-types.md +95 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-common.md +160 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-edit.md +609 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-field-types.md +438 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-formula.md +845 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-read.md +411 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-record-values.md +218 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-ai_efficiency.md +709 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-connect_to_app.md +380 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-financial_accounting.md +369 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-hr_and_administration.md +475 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-ledger_records.md +156 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-manufacturing.md +395 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-marketing.md +186 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-office_essentials.md +299 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-personal_efficiency.md +70 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-procurement_logistics.md +325 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-project_management.md +564 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-rd_process_customer.md +222 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-rd_process_ops.md +105 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-rd_process_project.md +109 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-rd_process_research.md +92 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-sales_and_operations.md +446 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-store_management.md +431 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-team_tasks.md +274 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-wechat_customer.md +384 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-template-work_report.md +100 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-templates.md +53 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-view-types.md +373 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-webhook-examples.md +176 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet-webhook.md +186 -0
- package/skills/wecom-unified/references/wecomcli-smartsheet.md +147 -0
- package/skills/wecom-unified/references/wecomcli-todo-create.md +137 -0
- package/skills/wecom-unified/references/wecomcli-todo-delete.md +63 -0
- package/skills/wecom-unified/references/wecomcli-todo-finish.md +72 -0
- package/skills/wecom-unified/references/wecomcli-todo-get.md +69 -0
- package/skills/wecom-unified/references/wecomcli-todo-list.md +136 -0
- package/skills/wecom-unified/references/wecomcli-todo-update.md +112 -0
- package/skills/wecom-unified/references/wecomcli-todo.md +68 -0
- package/skills/wecom-unified/scripts/build_docx.py +1274 -0
- package/skills/wecom-unified/scripts/build_page.py +2449 -0
- package/skills/wecom-unified/scripts/collect.py +868 -0
- package/skills/wecom-unified/scripts/doc_image_extractor.py +498 -0
- package/skills/wecom-unified/scripts/pptx2image.py +268 -0
- package/skills/wecom-unified/scripts/recalc.py +403 -0
- package/systemd/wezard.service.template +6 -0
- package/web/chat.css +70 -273
- package/web/chat.js +2228 -2190
- package/dist/daemon/chat-log.js +0 -130
- package/dist/daemon/chat-log.js.map +0 -1
- package/dist/daemon/dispatch.js +0 -6
- package/dist/daemon/dispatch.js.map +0 -1
- package/dist/daemon/idle-nudge.js +0 -69
- package/dist/daemon/idle-nudge.js.map +0 -1
- package/dist/daemon/message-events.js +0 -1083
- package/dist/daemon/message-events.js.map +0 -1
- package/dist/daemon/pending-items.js +0 -160
- package/dist/daemon/pending-items.js.map +0 -1
- package/dist/daemon/router.js +0 -742
- package/dist/daemon/router.js.map +0 -1
- package/dist/daemon/tips.js +0 -25
- package/dist/daemon/tips.js.map +0 -1
- package/dist/daemon/wedoc.js +0 -210
- package/dist/daemon/wedoc.js.map +0 -1
- package/dist/shared/role-search.js +0 -100
- package/dist/shared/role-search.js.map +0 -1
- package/dist/shared/startup-notice.js +0 -21
- package/dist/shared/startup-notice.js.map +0 -1
- package/dist/shared/turn-state.js +0 -27
- package/dist/shared/turn-state.js.map +0 -1
- package/hooks/hooks.json +0 -16
|
@@ -39,9 +39,12 @@ import { isSessionKey, windowLabel } from "../shared/session-label.js";
|
|
|
39
39
|
import { activateBackend, resolveCliBackend } from "../shared/cli-backends.js";
|
|
40
40
|
import { selectModel } from "./model-select.js";
|
|
41
41
|
import { hasRegistry, sessionOnPane } from "./wezard-session.js";
|
|
42
|
-
import {
|
|
42
|
+
import { memAvailableMb, memShortfall } from "../shared/mem-guard.js";
|
|
43
|
+
import { codebuddyTrustPrompt, startupConfirmation, startupDialog, workspaceTrustPrompt, workspaceTrustConfig } from "../shared/workspace-trust.js";
|
|
43
44
|
import { isModalPane } from "../shared/modal-pane.js";
|
|
44
|
-
import {
|
|
45
|
+
import { prepareSessionHooks, sessionHookArgs } from "../shared/session-hooks.js";
|
|
46
|
+
import { prepareSessionMcp, sessionMcpArgs } from "../shared/session-mcp.js";
|
|
47
|
+
import { prepareSessionSkills, sessionSkillArgs } from "../shared/session-skills.js";
|
|
45
48
|
// New sessions follow configuration; resumed transcripts retain their backend.
|
|
46
49
|
export const backendFor = (cfg) => {
|
|
47
50
|
const backend = resolveCliBackend(cfg.wrc);
|
|
@@ -58,6 +61,11 @@ const DETACHED_COLS = 200;
|
|
|
58
61
|
const DETACHED_ROWS = 60;
|
|
59
62
|
// stderr signatures of a transient server-side fork failure (ENOMEM/EAGAIN).
|
|
60
63
|
const TRANSIENT_FORK_RE = /Cannot allocate memory|Resource temporarily unavailable/;
|
|
64
|
+
// The two sides of the has-session → new-session/new-window race (see openPane).
|
|
65
|
+
const DUPLICATE_SESSION_RE = /duplicate session/;
|
|
66
|
+
const SESSION_GONE_RE = /can't find session|no server running|session not found/;
|
|
67
|
+
// `--resume <sid>` on a sid whose transcript is gone: no model / flag change can fix it.
|
|
68
|
+
const NO_CONVERSATION_RE = /No conversation found/;
|
|
61
69
|
export const TMUX_TIMEOUT_MS = (() => {
|
|
62
70
|
const raw = Number(process.env.WEZARD_TMUX_TIMEOUT_MS);
|
|
63
71
|
return Number.isFinite(raw) && raw >= 0 ? raw : 10_000;
|
|
@@ -70,8 +78,6 @@ let timeoutReporter;
|
|
|
70
78
|
export const setTmuxTimeoutReporter = (fn) => {
|
|
71
79
|
timeoutReporter = fn;
|
|
72
80
|
};
|
|
73
|
-
let _startupNotice;
|
|
74
|
-
export const bindStartupNotice = (fn) => { _startupNotice = fn; };
|
|
75
81
|
export const runTmux = (args, opts = {}) => new Promise((resolve) => {
|
|
76
82
|
// `-u`: launchd/systemd 起的 daemon 没有 LANG/LC_*, tmux 把这样的 client 当非
|
|
77
83
|
// UTF-8, 输出里的控制字符一律洗成 `_` —— `-F "#{pane_id}\t…"` 的 tab 也在其中,
|
|
@@ -156,6 +162,68 @@ const SHELL_CMD_RE = /^-?(zsh|bash|sh|fish|dash|ksh)$/;
|
|
|
156
162
|
// 与 spawn 里的 paneEnv 同源 (rc 的 oh-my-zsh 更新询问会吃掉启动行); 暖 pane 建在
|
|
157
163
|
// tmux ≥3.0 上, 所以直接走 `-e`。
|
|
158
164
|
const ANTI_UPDATE_ENV = ["-e", "DISABLE_AUTO_UPDATE=true", "-e", "DISABLE_UPDATE_PROMPT=true"];
|
|
165
|
+
// ── 归属标记 ─────────────────────────────────────────────────────────────
|
|
166
|
+
// PreToolUse hook 是全机注册的 (CodeBuddy settings.json / Claude 插件 / Codex
|
|
167
|
+
// hooks.json), 每个人自己开的 CLI 会话也会触发它。只有 wezard spawn 出来的 CLI
|
|
168
|
+
// 进程带这个变量, hook 据此把别的会话原样交回 CLI 的权限流程 —— 子进程 (子代理 /
|
|
169
|
+
// 工具 exec 出来的命令) 自然继承, 所以它只加在启动行上, 不加在 pane 的 shell env。
|
|
170
|
+
const MANAGED_ENV = "WEZARD_MANAGED=1";
|
|
171
|
+
/** 启动行的环境前缀: 归属标记 + hook / wezard MCP 需要的 daemon 地址。这几项原来由
|
|
172
|
+
* `wezard sync` 写进全机 settings.json 的 env —— 那会让每个人自己开的 CLI 也带着
|
|
173
|
+
* wezard 的变量; 现在只出现在 wezard 自己 spawn 的进程里。 */
|
|
174
|
+
const launchEnv = (cfg) => [
|
|
175
|
+
MANAGED_ENV,
|
|
176
|
+
// wizard 不用 claude.ai 远程连接器 (Gmail / Drive / Docs ...): 关掉省每进程约 10~12MB、
|
|
177
|
+
// 启动时的连接请求和提示里的工具名。不认该变量的后端 (codebuddy / codex) 直接忽略。
|
|
178
|
+
"ENABLE_CLAUDEAI_MCP_SERVERS=false",
|
|
179
|
+
`WEZARD_DAEMON_BASE=${shQuote(`http://${cfg.daemon.host}:${cfg.daemon.port}`)}`,
|
|
180
|
+
`WEZARD_DAEMON_URL=${shQuote(`http://${cfg.daemon.host}:${cfg.daemon.port}/approve`)}`,
|
|
181
|
+
`WEZARD_STATE_DIR=${shQuote(expandHome(cfg.daemon.stateDir))}`,
|
|
182
|
+
`WEZARD_HOOK_TIMEOUT=${cfg.approval.hookTimeoutSec}`,
|
|
183
|
+
];
|
|
184
|
+
/** 按会话注入审批 hook。写不出来只记日志、照常 spawn: 没有 hook 的 pane 会退回
|
|
185
|
+
* CLI 自己的权限流程 (看得见、要人点), 不是静默放权, 比整个 spawn 失败轻。 */
|
|
186
|
+
const sessionHooksFor = (cfg, log) => {
|
|
187
|
+
try {
|
|
188
|
+
return prepareSessionHooks(expandHome(cfg.daemon.stateDir), cfg.approval.hookTimeoutSec);
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
log.warn({ err: e.message }, "spawn-tmux: session hook injection failed — pane falls back to the CLI's own permission flow");
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
/** 按会话注入 wezard MCP (`--mcp-config`): 全机 mcp.json / settings 里已经不再有它,
|
|
196
|
+
* 人自己开的会话因此既看不见也不多起一个 node 进程。写不出来只记日志 —— pane 少了
|
|
197
|
+
* 工具面但还能用 CLI 本来的东西。 */
|
|
198
|
+
const sessionMcpFor = (cfg, log) => {
|
|
199
|
+
try {
|
|
200
|
+
return prepareSessionMcp(expandHome(cfg.daemon.stateDir), {
|
|
201
|
+
port: cfg.daemon.port, transport: cfg.daemon.mcpTransport,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
log.warn({ err: e.message }, "spawn-tmux: session MCP injection failed — pane starts without wezard tools");
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
/** 按会话注入 skill (`--plugin-dir`): 企微文档那套只该出现在 wezard 的 pane 里,
|
|
210
|
+
* 所以内容放在 <stateDir>/skills, 插件壳软链过去; 全机 skills 目录一个字节都不写。
|
|
211
|
+
* 写不出来只记日志 —— pane 少一批工具知识, 别的照常。 */
|
|
212
|
+
const sessionSkillsFor = (cfg, log) => {
|
|
213
|
+
try {
|
|
214
|
+
return prepareSessionSkills(expandHome(cfg.daemon.stateDir));
|
|
215
|
+
}
|
|
216
|
+
catch (e) {
|
|
217
|
+
log.warn({ err: e.message }, "spawn-tmux: session skill injection failed — pane starts without wezard skills");
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
/** 升级兼容: 升级前已在跑的 pane 改不了 env, 给它的 pane 打一个标记, 让 hook 的
|
|
222
|
+
* 兜底仍认它是我们的 (tmux < 2.6 没有 pane option: 静默失败, 新 pane 靠 env)。 */
|
|
223
|
+
export const markManagedPane = async (pane) => {
|
|
224
|
+
if (pane)
|
|
225
|
+
await runTmux(["set-option", "-p", "-t", pane, "@wezard_managed", "1"]);
|
|
226
|
+
};
|
|
159
227
|
const warmPool = new Map();
|
|
160
228
|
// 同一 cwd 的补位去重: 补位是 fire-and-forget, 连着开两个会话会同时补。
|
|
161
229
|
const warmInflight = new Set();
|
|
@@ -424,12 +492,19 @@ const buildSpare = async (cfg, log, spec) => {
|
|
|
424
492
|
return;
|
|
425
493
|
}
|
|
426
494
|
// 与 commandFor 同形的启动行: 不带宪章、不带 resume, 只把这一档的环境定下来。
|
|
495
|
+
const hooks = sessionHooksFor(cfg, log);
|
|
496
|
+
const mcp = sessionMcpFor(cfg, log);
|
|
497
|
+
const skills = sessionSkillsFor(cfg, log);
|
|
427
498
|
const envPrefix = [
|
|
499
|
+
...launchEnv(cfg),
|
|
428
500
|
...(supportsE ? [] : ["DISABLE_AUTO_UPDATE=true", "DISABLE_UPDATE_PROMPT=true"]),
|
|
429
501
|
"DISABLE_AUTOUPDATER=1",
|
|
430
502
|
];
|
|
431
503
|
const argv = [
|
|
432
504
|
"--session-id", sessionId,
|
|
505
|
+
...(hooks ? sessionHookArgs(spec.backend.name, hooks) : []),
|
|
506
|
+
...(mcp ? sessionMcpArgs(spec.backend.name, mcp) : []),
|
|
507
|
+
...(skills ? sessionSkillArgs(spec.backend.name, skills) : []),
|
|
433
508
|
...(spec.model && spec.backend.modelFlag ? [spec.backend.modelFlag, spec.model] : []),
|
|
434
509
|
...(spec.effort && spec.backend.effortFlag ? [spec.backend.effortFlag, spec.effort] : []),
|
|
435
510
|
...cfg.wrc.extraArgs,
|
|
@@ -444,7 +519,7 @@ const buildSpare = async (cfg, log, spec) => {
|
|
|
444
519
|
}
|
|
445
520
|
log.info({ tmuxName: warm, winName: "spare", tmuxPane: pane, cwd: dir, sessionId, cli: spec.backend.name, spare: true }, "spawn-tmux: pane created");
|
|
446
521
|
// 与正常启动同一套就绪判据 (注册表 idle / 输入框 / 退出标记)。
|
|
447
|
-
const tui = await waitForTuiReady(pane, line, spec.backend, dir,
|
|
522
|
+
const tui = await waitForTuiReady(pane, line, spec.backend, dir, log);
|
|
448
523
|
// 建不成就是建不成: 失败只 kill, 绝不重试 —— 认不出的 model id 会被重试一次次砸在
|
|
449
524
|
// 同一个判据上, 而备用本来只是提速。
|
|
450
525
|
if (!tui.ready || tui.exited) {
|
|
@@ -563,6 +638,12 @@ export const ensureSpare = async (cfg, log, cwd, model, effort) => {
|
|
|
563
638
|
return;
|
|
564
639
|
if (cfg.wrc.sparePool.maxTotal <= 0)
|
|
565
640
|
return;
|
|
641
|
+
// 备用是一条躺着的完整 CLI: 内存紧时宁可下次冷启动, 也不把主机推进无 swap 的抖动。
|
|
642
|
+
const short = memShortfall(cfg.wrc.memoryGuard.spareMinMb, memAvailableMb());
|
|
643
|
+
if (short) {
|
|
644
|
+
log.info({ cwd, ...short }, "spawn-tmux: spare skipped (low memory)");
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
566
647
|
// 全局满了先按 LRU 腾位置: 这条冷启动刚证明可用, 比一条躺着没人要的更值钱。
|
|
567
648
|
while (spares.length >= cfg.wrc.sparePool.maxTotal) {
|
|
568
649
|
const oldest = [...spares].sort((a, b) => a.builtAt - b.builtAt)[0];
|
|
@@ -726,34 +807,14 @@ export const answerCodebuddyTrust = async (pane, cwd, log, screen) => {
|
|
|
726
807
|
log.info({ pane, cwd, key }, "codebuddy trust: confirmed folder-only trust");
|
|
727
808
|
return true;
|
|
728
809
|
};
|
|
729
|
-
const waitForTuiReady = async (pane, cmd, backend, cwd,
|
|
810
|
+
const waitForTuiReady = async (pane, cmd, backend, cwd, log) => {
|
|
730
811
|
const registry = hasRegistry(backend.homeDir);
|
|
731
812
|
const t0 = Date.now();
|
|
732
813
|
const deadline = t0 + MIN_SETTLE_MS + TUI_READY_TIMEOUT_MS;
|
|
733
814
|
let resent = false;
|
|
734
815
|
let sawSession = false;
|
|
735
816
|
let lastCap = 0;
|
|
736
|
-
// 认不出的启动确认框: ready 判定照旧不放行 (留给本地人工, 不按任何键)
|
|
737
|
-
// 远端看不见的框广播到该 spawn 的频道 —— 同一形状只发一次 (指纹), 一次 spawn 最多
|
|
738
|
-
// 3 条 (框里带动态内容时兜底)。fire-and-forget: 失败只记日志, 不阻塞轮询。
|
|
739
|
-
let noticedFp;
|
|
740
|
-
let noticeCount = 0;
|
|
741
|
-
const notifyUnknownFrame = (screen) => {
|
|
742
|
-
if (!notice?.chatKey || noticeCount >= 3)
|
|
743
|
-
return;
|
|
744
|
-
const n = unknownStartupNotice({ who: notice.who, pane, tmuxSession: notice.tmuxSession, cwd, screen });
|
|
745
|
-
if (!n.fp || n.fp === noticedFp)
|
|
746
|
-
return;
|
|
747
|
-
noticedFp = n.fp;
|
|
748
|
-
noticeCount += 1;
|
|
749
|
-
log.info({ pane, cwd, who: notice.who }, "spawn-tmux: unknown startup confirmation, notifying chat");
|
|
750
|
-
try {
|
|
751
|
-
_startupNotice?.(notice.chatKey, n.text);
|
|
752
|
-
}
|
|
753
|
-
catch (e) {
|
|
754
|
-
log.warn({ pane, err: e.message }, "spawn-tmux: startup notice dispatch failed");
|
|
755
|
-
}
|
|
756
|
-
};
|
|
817
|
+
// 认不出的启动确认框: ready 判定照旧不放行 (留给本地人工, 不按任何键)。
|
|
757
818
|
while (Date.now() < deadline) {
|
|
758
819
|
await sleep(registry ? REGISTRY_POLL_MS : SCREEN_POLL_MS);
|
|
759
820
|
let registryIdle = false;
|
|
@@ -781,10 +842,8 @@ const waitForTuiReady = async (pane, cmd, backend, cwd, notice, log) => {
|
|
|
781
842
|
continue;
|
|
782
843
|
if (await answerCodebuddyTrust(pane, cwd, log, cap))
|
|
783
844
|
continue;
|
|
784
|
-
if (
|
|
785
|
-
notifyUnknownFrame(cap);
|
|
845
|
+
if (startupDialog(cap))
|
|
786
846
|
continue;
|
|
787
|
-
}
|
|
788
847
|
if (registryIdle)
|
|
789
848
|
return { ready: true };
|
|
790
849
|
// 注册表认不到这个 pane (schema 不认识 / 后端不写) 时, pane 读屏就是唯一证人;
|
|
@@ -809,7 +868,7 @@ const waitForTuiReady = async (pane, cmd, backend, cwd, notice, log) => {
|
|
|
809
868
|
const exited = cliExit(last);
|
|
810
869
|
if (exited)
|
|
811
870
|
return { ready: false, exited };
|
|
812
|
-
if (!
|
|
871
|
+
if (!startupDialog(last) && sawSession && TUI_READY_RE.test(last))
|
|
813
872
|
return { ready: true };
|
|
814
873
|
log.warn({ pane, registry, sawSession }, "spawn-tmux: TUI ready timeout, proceeding anyway");
|
|
815
874
|
return { ready: false };
|
|
@@ -898,7 +957,7 @@ const charterArg = (cfg, backend, sessionId, charter, log) => {
|
|
|
898
957
|
return "";
|
|
899
958
|
}
|
|
900
959
|
};
|
|
901
|
-
const spawnTmuxInner = async ({ cfg, log, resumeSessionId, sessionId: freshSessionId, handoffId, windowName, cwdOverride,
|
|
960
|
+
const spawnTmuxInner = async ({ cfg, log, resumeSessionId, sessionId: freshSessionId, handoffId, windowName, cwdOverride, cli, model, effort, systemPrompt, forkSession }) => {
|
|
902
961
|
const backend = resumeSessionId && cli
|
|
903
962
|
? resolveCliBackend({ ...cfg.wrc, defaultCli: cli })
|
|
904
963
|
: backendFor(cfg);
|
|
@@ -997,12 +1056,29 @@ const spawnTmuxInner = async ({ cfg, log, resumeSessionId, sessionId: freshSessi
|
|
|
997
1056
|
// The trailing colon selects the next free window index.
|
|
998
1057
|
// Bare `-t wezard` is ambiguous: if a *window* is also named
|
|
999
1058
|
// `wezard`, tmux matches it and tries to reuse its index → "index N in use".
|
|
1000
|
-
|
|
1059
|
+
let exists = has.code === 0;
|
|
1060
|
+
const create = () => exists
|
|
1001
1061
|
? runTmux(["new-window", "-d", "-t", `=${tmuxName}:`, "-n", winName, ...cwdArg, ...paneEnv, "-P", "-F", "#{pane_id}"])
|
|
1002
1062
|
: runTmux(["new-session", "-d", "-s", tmuxName, "-n", winName, ...sizeArg, ...cwdArg, ...paneEnv, "-P", "-F", "#{pane_id}"]);
|
|
1003
1063
|
let pane = warmPane ?? "";
|
|
1004
1064
|
if (!pane) {
|
|
1005
1065
|
let created = await create();
|
|
1066
|
+
// has-session → create is not atomic: several respawns at once (boot, the
|
|
1067
|
+
// room pump's 30s kick over cold targets) all see "no session", one wins
|
|
1068
|
+
// new-session and the rest die on "duplicate session" — and a loser that
|
|
1069
|
+
// could have come up is skipped every round while the winner's lone window
|
|
1070
|
+
// takes the whole session down with it (2026-11-21). Flip to the other
|
|
1071
|
+
// verb and go again; the reverse race (session vanished under new-window)
|
|
1072
|
+
// is the same fix.
|
|
1073
|
+
for (let flip = 0; !created.ok && flip < 2; flip++) {
|
|
1074
|
+
const lost = exists ? SESSION_GONE_RE.test(created.stderr) : DUPLICATE_SESSION_RE.test(created.stderr);
|
|
1075
|
+
if (!lost)
|
|
1076
|
+
break;
|
|
1077
|
+
exists = !exists;
|
|
1078
|
+
if (exists)
|
|
1079
|
+
await runTmux(["set-option", "-t", `=${tmuxName}`, "default-size", `${DETACHED_COLS}x${DETACHED_ROWS}`]);
|
|
1080
|
+
created = await create();
|
|
1081
|
+
}
|
|
1006
1082
|
// Server-side fork failing ENOMEM/EAGAIN is transient on swap-less macOS
|
|
1007
1083
|
// (a momentary pressure spike, e.g. >20 CLI panes, fails fork outright) —
|
|
1008
1084
|
// retry briefly before giving up.
|
|
@@ -1014,7 +1090,7 @@ const spawnTmuxInner = async ({ cfg, log, resumeSessionId, sessionId: freshSessi
|
|
|
1014
1090
|
// leaves zero trace in daemon.log (the 2026-10-14 ENOMEM was unfindable).
|
|
1015
1091
|
if (!created.ok) {
|
|
1016
1092
|
log.warn({ tmuxName, winName, stderr: created.stderr.trim(), code: created.code }, "spawn-tmux: pane creation failed");
|
|
1017
|
-
return { reason: `tmux ${
|
|
1093
|
+
return { reason: `tmux ${exists ? "new-window" : "new-session"} failed: ${created.stderr.trim() || created.code}` };
|
|
1018
1094
|
}
|
|
1019
1095
|
pane = created.stdout.split("\n").map((s) => s.trim()).filter(Boolean)[0] ?? "";
|
|
1020
1096
|
if (!pane)
|
|
@@ -1027,14 +1103,18 @@ const spawnTmuxInner = async ({ cfg, log, resumeSessionId, sessionId: freshSessi
|
|
|
1027
1103
|
return { reason: `could not persist workspace handoff pane identity: ${tagged.stderr.trim() || tagged.code}` };
|
|
1028
1104
|
}
|
|
1029
1105
|
}
|
|
1030
|
-
log.info({ tmuxName, winName, tmuxPane: pane, cwd, sessionId, cli: backend.name, reused:
|
|
1106
|
+
log.info({ tmuxName, winName, tmuxPane: pane, cwd, sessionId, cli: backend.name, reused: exists, warm: !!warmPane, spare: false }, "spawn-tmux: pane created");
|
|
1031
1107
|
return { pane, warm: !!warmPane };
|
|
1032
1108
|
};
|
|
1033
1109
|
// DISABLE_AUTOUPDATER=1 防止新 pane 启动时弹出 "An update is available" 询问 ——
|
|
1034
1110
|
// 该交互会吞掉首条 paste-buffer 注入,导致仅落字符不进入 claude 输入框。
|
|
1035
1111
|
// On old tmux the pane never got the two anti-update-prompt vars via `-e`, so
|
|
1036
1112
|
// fold them into the command line as inline exports (`KEY=VAL cmd`).
|
|
1113
|
+
const sessionHooks = sessionHooksFor(cfg, log);
|
|
1114
|
+
const sessionMcp = sessionMcpFor(cfg, log);
|
|
1115
|
+
const sessionSkills = sessionSkillsFor(cfg, log);
|
|
1037
1116
|
const envPrefix = [
|
|
1117
|
+
...launchEnv(cfg),
|
|
1038
1118
|
...(supportsE ? [] : ["DISABLE_AUTO_UPDATE=true", "DISABLE_UPDATE_PROMPT=true"]),
|
|
1039
1119
|
"DISABLE_AUTOUPDATER=1",
|
|
1040
1120
|
];
|
|
@@ -1059,6 +1139,9 @@ const spawnTmuxInner = async ({ cfg, log, resumeSessionId, sessionId: freshSessi
|
|
|
1059
1139
|
"-c", `mcp_servers.wezard.env.CODEX_THREAD_ID=${JSON.stringify(sessionId)}`,
|
|
1060
1140
|
] : []),
|
|
1061
1141
|
...codexApprovalArgs,
|
|
1142
|
+
...(sessionHooks && backend.name !== "codex" ? sessionHookArgs(backend.name, sessionHooks) : []),
|
|
1143
|
+
...(sessionMcp && backend.name !== "codex" ? sessionMcpArgs(backend.name, sessionMcp) : []),
|
|
1144
|
+
...(sessionSkills && backend.name !== "codex" ? sessionSkillArgs(backend.name, sessionSkills) : []),
|
|
1062
1145
|
...(backend.name === "codex" && effort ? ["-c", `model_reasoning_effort=${JSON.stringify(effort)}`] : []),
|
|
1063
1146
|
...(backend.name === "codex" && systemPrompt ? ["-c", `developer_instructions=${JSON.stringify(systemPrompt)}`] : []),
|
|
1064
1147
|
...(flagModel ? [backend.modelFlag, flagModel] : []),
|
|
@@ -1073,19 +1156,33 @@ const spawnTmuxInner = async ({ cfg, log, resumeSessionId, sessionId: freshSessi
|
|
|
1073
1156
|
// One pane, one CLI process, verified up. `failure` = the CLI couldn't take
|
|
1074
1157
|
// `flagModel`: it quit, or came up not knowing it.
|
|
1075
1158
|
const launch = async (flagModel, retry = false) => {
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1159
|
+
let pane = "";
|
|
1160
|
+
let line = "";
|
|
1161
|
+
let script;
|
|
1162
|
+
for (let attempt = 0;; attempt++) {
|
|
1163
|
+
const opened = await openPane();
|
|
1164
|
+
if ("reason" in opened)
|
|
1165
|
+
return { ok: false, reason: opened.reason };
|
|
1166
|
+
pane = opened.pane;
|
|
1167
|
+
const fullCommand = commandFor(flagModel, retry, pane);
|
|
1168
|
+
// PTY canonical input truncates long hook/TOML arguments at ~4 KiB.
|
|
1169
|
+
// Send only a short script invocation through the interactive shell.
|
|
1170
|
+
script = backend.name === "codex" ? join(tmpdir(), `wezard-codex-${randomUUID()}.sh`) : undefined;
|
|
1171
|
+
if (script) {
|
|
1172
|
+
try {
|
|
1173
|
+
writeFileSync(script, `${fullCommand}\n`, { mode: 0o600, flag: "wx" });
|
|
1174
|
+
}
|
|
1175
|
+
catch (e) {
|
|
1176
|
+
await runTmux(["kill-pane", "-t", pane]).catch(() => undefined);
|
|
1177
|
+
return { ok: false, reason: `could not prepare Codex launch script: ${e.message}` };
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
// 赋给外层 line, 不在循环内 const 重声明: 遮蔽会让 break 后的
|
|
1181
|
+
// waitForTuiReady 拿到 "" (重发启动行那一手就废了)。
|
|
1182
|
+
line = script ? `/bin/sh ${shQuote(script)}` : fullCommand;
|
|
1183
|
+
const sent = await runTmux(["send-keys", "-t", pane, line, "Enter"]);
|
|
1184
|
+
if (sent.ok)
|
|
1185
|
+
break;
|
|
1089
1186
|
if (script)
|
|
1090
1187
|
try {
|
|
1091
1188
|
unlinkSync(script);
|
|
@@ -1093,15 +1190,27 @@ const spawnTmuxInner = async ({ cfg, log, resumeSessionId, sessionId: freshSessi
|
|
|
1093
1190
|
catch { /* already removed */ }
|
|
1094
1191
|
// Kill only this window/pane, never the shared session.
|
|
1095
1192
|
await runTmux(["kill-pane", "-t", pane]);
|
|
1096
|
-
|
|
1193
|
+
// A timed-out send-keys means the tmux server wedged (2026-11-12: /new died
|
|
1194
|
+
// outright on `tmux timeout after 10000ms`). The line may still land on this
|
|
1195
|
+
// pane late, so never resend to it — the abandoned pane is left for the orphan
|
|
1196
|
+
// sweep and the retry gets a whole fresh one.
|
|
1197
|
+
if (!sent.timedOut || attempt >= 2)
|
|
1198
|
+
return { ok: false, reason: `tmux send-keys failed: ${sent.stderr.trim() || sent.code}` };
|
|
1199
|
+
log.warn({ pane, attempt: attempt + 1, stderr: sent.stderr.trim() }, "spawn-tmux: launch line send timed out (server wedged), retrying on a fresh pane");
|
|
1200
|
+
await sleep(500 * (attempt + 1));
|
|
1097
1201
|
}
|
|
1098
1202
|
// Actively verify the TUI reached interactive state before returning.
|
|
1099
1203
|
// claude does NOT create the transcript jsonl until it processes the first
|
|
1100
1204
|
// user input, so we don't wait for the file — mirror tail tolerates a
|
|
1101
1205
|
// missing jsonl and starts emitting once claude writes the first line.
|
|
1102
|
-
let
|
|
1206
|
+
let keepPane = false;
|
|
1103
1207
|
try {
|
|
1104
|
-
tui = await waitForTuiReady(pane, line, backend, cwd,
|
|
1208
|
+
const tui = await waitForTuiReady(pane, line, backend, cwd, log);
|
|
1209
|
+
if (tui.exited)
|
|
1210
|
+
return { ok: true, pane, ready: false, failure: tui.exited };
|
|
1211
|
+
const unknown = !!flagModel && tui.ready && modelNotRecognized(await capturePaneBottom(pane, "-"), flagModel);
|
|
1212
|
+
keepPane = true;
|
|
1213
|
+
return { ok: true, pane, ready: tui.ready, ...(unknown ? { failure: `CLI 不认识 --model ${flagModel} (欢迎框原样回显, 首轮会 400)` } : {}) };
|
|
1105
1214
|
}
|
|
1106
1215
|
finally {
|
|
1107
1216
|
if (script)
|
|
@@ -1109,11 +1218,11 @@ const spawnTmuxInner = async ({ cfg, log, resumeSessionId, sessionId: freshSessi
|
|
|
1109
1218
|
unlinkSync(script);
|
|
1110
1219
|
}
|
|
1111
1220
|
catch { /* already removed */ }
|
|
1221
|
+
// A CLI that exited leaves the shell (and sometimes its window/session)
|
|
1222
|
+
// behind. Any exception before a verified launch has the same ownership.
|
|
1223
|
+
if (!keepPane)
|
|
1224
|
+
await runTmux(["kill-pane", "-t", pane]).catch(() => undefined);
|
|
1112
1225
|
}
|
|
1113
|
-
if (tui.exited)
|
|
1114
|
-
return { ok: true, pane, ready: false, failure: tui.exited };
|
|
1115
|
-
const unknown = !!flagModel && tui.ready && modelNotRecognized(await capturePaneBottom(pane, "-"), flagModel);
|
|
1116
|
-
return { ok: true, pane, ready: tui.ready, ...(unknown ? { failure: `CLI 不认识 --model ${flagModel} (欢迎框原样回显, 首轮会 400)` } : {}) };
|
|
1117
1226
|
};
|
|
1118
1227
|
// Whatever was asked goes straight in with `--model`. Only when the CLI
|
|
1119
1228
|
// proves it can't take it is the pane thrown away and relaunched bare —
|
|
@@ -1136,6 +1245,13 @@ const spawnTmuxInner = async ({ cfg, log, resumeSessionId, sessionId: freshSessi
|
|
|
1136
1245
|
const first = spare ? { ok: true, pane: spare.pane, ready: true } : await launch(flagModel);
|
|
1137
1246
|
if (!first.ok)
|
|
1138
1247
|
return { ok: false, reason: first.reason };
|
|
1248
|
+
// A transcript that no longer exists will fail the bare relaunch exactly the
|
|
1249
|
+
// same way — and every retry by a caller would open (and tear down) one more
|
|
1250
|
+
// pane. Say so once, non-retryable; only a human /new replaces the session.
|
|
1251
|
+
if (first.failure && NO_CONVERSATION_RE.test(first.failure))
|
|
1252
|
+
return { ok: false, retryable: false, reason: `会话转录已不存在, 无法 --resume ${sessionId}; 发 /new 开新会话 (${first.failure})` };
|
|
1253
|
+
if (first.failure && !flagModel)
|
|
1254
|
+
return { ok: false, reason: first.failure };
|
|
1139
1255
|
let landed = first;
|
|
1140
1256
|
const launchFailure = flagModel ? first.failure : undefined;
|
|
1141
1257
|
if (launchFailure) {
|