kaizen-agent 1.86.0 → 1.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/cli/annotate-proxy.ts +6 -3
- package/cli/build-web.ts +46 -16
- package/cli/dev.ts +67 -0
- package/cli/docs.ts +1 -1
- package/cli/notes.ts +9 -3
- package/cli/ports.ts +121 -0
- package/cli/settings.ts +16 -17
- package/cli/state.ts +15 -29
- package/cli/task-service.ts +44 -14
- package/cli/tasks.ts +1 -1
- package/cli/term-image.ts +18 -0
- package/cli/ui-audit.allow.json +0 -1
- package/cli/ui-audit.ts +12 -12
- package/cli/web.ts +182 -58
- package/package.json +21 -4
- package/skills/kaizen/spec.md +10 -3
- package/tsconfig.json +16 -0
- package/web/README.md +105 -0
- package/web/{annotate.js → annotate/annotate.ts} +51 -50
- package/web/boot/boot.ts +7 -0
- package/web/components/annotate/annotate-bar.tsx +78 -0
- package/web/components/annotate/annotate-panel.tsx +20 -0
- package/web/components/annotate/annotate-settings.tsx +60 -0
- package/web/components/annotate/index.ts +1 -0
- package/web/components/annotate/notes-list.tsx +75 -0
- package/web/components/board/board-card.tsx +177 -0
- package/web/components/board/board-column.tsx +212 -0
- package/web/components/board/board-mode-switch.tsx +21 -0
- package/web/components/board/board-popups.tsx +45 -0
- package/web/components/board/card-footer.tsx +58 -0
- package/web/components/board/card-form.tsx +168 -0
- package/web/components/board/card-kids.tsx +53 -0
- package/web/components/board/clear-menu.tsx +36 -0
- package/web/components/board/filter-box.tsx +42 -0
- package/web/components/board/index.ts +6 -0
- package/web/components/board/run-form.tsx +129 -0
- package/web/components/board/severity-menu.tsx +44 -0
- package/web/components/board/status-strip.tsx +75 -0
- package/web/components/board/task-form.tsx +140 -0
- package/web/components/board/ws-card.tsx +38 -0
- package/web/components/context/context-panel.tsx +244 -0
- package/web/components/context/index.ts +1 -0
- package/web/components/decision/decision-bar.tsx +422 -0
- package/web/components/decision/index.ts +1 -0
- package/web/components/decision/inline-form.tsx +47 -0
- package/web/components/decision/plan-answers-form.tsx +78 -0
- package/web/components/decision/revise-form.tsx +65 -0
- package/web/components/decision/task-reply-form.tsx +48 -0
- package/web/components/footer/foot-bar.tsx +67 -0
- package/web/components/footer/index.ts +1 -0
- package/web/components/git/git-ask.tsx +88 -0
- package/web/components/git/git-commits.tsx +53 -0
- package/web/components/git/git-confirm.tsx +78 -0
- package/web/components/git/git-counts.tsx +10 -0
- package/web/components/git/git-files.tsx +113 -0
- package/web/components/git/git-head.tsx +70 -0
- package/web/components/git/git-icon.tsx +25 -0
- package/web/components/git/git-message.tsx +44 -0
- package/web/components/git/git-split.tsx +64 -0
- package/web/components/git/git-tab.tsx +55 -0
- package/web/components/git/index.ts +1 -0
- package/web/components/home/chat-list.tsx +57 -0
- package/web/components/home/home-composer.tsx +169 -0
- package/web/components/home/home-message.tsx +120 -0
- package/web/components/home/home-window.tsx +253 -0
- package/web/components/home/home-ws-add.tsx +47 -0
- package/web/components/home/index.ts +6 -0
- package/web/components/home/onboarding-dialog.tsx +371 -0
- package/web/components/icebox/board-chip.tsx +27 -0
- package/web/components/icebox/board-menu.tsx +41 -0
- package/web/components/icebox/bulk-bar.tsx +41 -0
- package/web/components/icebox/capture-box.tsx +155 -0
- package/web/components/icebox/choice-menu.tsx +39 -0
- package/web/components/icebox/collection-dialog.tsx +60 -0
- package/web/components/icebox/favicon.tsx +39 -0
- package/web/components/icebox/index.ts +10 -0
- package/web/components/icebox/kind-label.tsx +22 -0
- package/web/components/icebox/kind-menu.tsx +20 -0
- package/web/components/icebox/promote-form.tsx +93 -0
- package/web/components/icebox/reply-box.tsx +88 -0
- package/web/components/icebox/request-actions.tsx +141 -0
- package/web/components/icebox/request-badges.tsx +13 -0
- package/web/components/icebox/request-card.tsx +99 -0
- package/web/components/icebox/request-detail.tsx +43 -0
- package/web/components/icebox/request-images.tsx +33 -0
- package/web/components/icebox/request-phone-row.tsx +181 -0
- package/web/components/icebox/request-row.tsx +120 -0
- package/web/components/icebox/service-chip.tsx +58 -0
- package/web/components/icebox/snooze-menu.tsx +83 -0
- package/web/components/icebox/source-card.tsx +225 -0
- package/web/components/icebox/source-drawer.tsx +112 -0
- package/web/components/icebox/source-form.tsx +147 -0
- package/web/components/icebox/swipe-deck.tsx +242 -0
- package/web/components/layout/index.ts +1 -0
- package/web/components/layout/page-frame.tsx +44 -0
- package/web/components/markdown/index.ts +1 -0
- package/web/components/markdown/markdown.tsx +156 -0
- package/web/components/notebook/editor-pane.tsx +23 -0
- package/web/components/notebook/index.ts +5 -0
- package/web/components/notebook/note-body.tsx +172 -0
- package/web/components/notebook/note-tree.tsx +99 -0
- package/web/components/notebook/notes-head.tsx +37 -0
- package/web/components/notebook/notes-side.tsx +46 -0
- package/web/components/notes/index.ts +1 -0
- package/web/components/notes/note-composer.tsx +90 -0
- package/web/components/notes/notes-chat.tsx +58 -0
- package/web/components/panes/browser-pane.tsx +281 -0
- package/web/components/panes/index.ts +3 -0
- package/web/components/panes/preview-pane.tsx +91 -0
- package/web/components/panes/terminal-pane.tsx +52 -0
- package/web/components/phone/haptic.tsx +29 -0
- package/web/components/phone/index.ts +6 -0
- package/web/components/phone/phone-card.tsx +118 -0
- package/web/components/phone/phone-home.tsx +304 -0
- package/web/components/phone/phone-sheets.tsx +103 -0
- package/web/components/phone/qr-code.tsx +6 -0
- package/web/components/phone/usage-chips.tsx +85 -0
- package/web/components/phone/whatsapp-card.tsx +85 -0
- package/web/components/project/add-project-dialog.tsx +435 -0
- package/web/components/project/index.ts +3 -0
- package/web/components/project/project-bar.tsx +101 -0
- package/web/components/project/ws-menu.tsx +21 -0
- package/web/components/rail/agent-chips.tsx +110 -0
- package/web/components/rail/index.ts +4 -0
- package/web/components/rail/rail-filter.tsx +118 -0
- package/web/components/rail/rail-list.tsx +259 -0
- package/web/components/rail/source-marks.tsx +21 -0
- package/web/components/resources/index.ts +1 -0
- package/web/components/resources/resources-popup.tsx +490 -0
- package/web/components/run/doc-body.tsx +123 -0
- package/web/components/run/file-viewer.tsx +53 -0
- package/web/components/run/fix-form.tsx +88 -0
- package/web/components/run/index.ts +16 -0
- package/web/components/run/inline-md.tsx +30 -0
- package/web/components/run/key-hint.tsx +29 -0
- package/web/components/run/pane-gutter.tsx +52 -0
- package/web/components/run/pane-header.tsx +35 -0
- package/web/components/run/pane.tsx +140 -0
- package/web/components/run/panel-grip.tsx +49 -0
- package/web/components/run/panel-head.tsx +56 -0
- package/web/components/run/panel-tabs.tsx +35 -0
- package/web/components/run/phase-steps.tsx +37 -0
- package/web/components/run/project-notes.tsx +49 -0
- package/web/components/run/run-add-menu.tsx +80 -0
- package/web/components/run/run-bar.tsx +40 -0
- package/web/components/run/run-empty.tsx +10 -0
- package/web/components/run/run-footer.tsx +53 -0
- package/web/components/run/run-history.tsx +24 -0
- package/web/components/run/run-panes.tsx +78 -0
- package/web/components/run/run-picker.tsx +51 -0
- package/web/components/run/run-progress.tsx +30 -0
- package/web/components/run/run-tabs.tsx +147 -0
- package/web/components/run/run-wait.tsx +18 -0
- package/web/components/search/index.ts +1 -0
- package/web/components/search/search-palette.tsx +159 -0
- package/web/components/settings/account-rows.tsx +128 -0
- package/web/components/settings/agent-rows.tsx +249 -0
- package/web/components/settings/automation-rows.tsx +211 -0
- package/web/components/settings/browser-row.tsx +111 -0
- package/web/components/settings/cleanup-row.tsx +32 -0
- package/web/components/settings/commit-input.tsx +39 -0
- package/web/components/settings/index.ts +4 -0
- package/web/components/settings/integration-row.tsx +158 -0
- package/web/components/settings/mic-row.tsx +48 -0
- package/web/components/settings/orchestration-flow.tsx +87 -0
- package/web/components/settings/setting-row.tsx +131 -0
- package/web/components/settings/settings-item.tsx +78 -0
- package/web/components/settings/settings-loading.tsx +41 -0
- package/web/components/settings/settings-nav.tsx +119 -0
- package/web/components/settings/settings-scope.tsx +66 -0
- package/web/components/settings/settings-section.tsx +33 -0
- package/web/components/settings/skill-card.tsx +131 -0
- package/web/components/settings/stepper.tsx +74 -0
- package/web/components/settings/update-bar.tsx +167 -0
- package/web/components/shared/action-menu.tsx +76 -0
- package/web/components/shared/ask-host.tsx +18 -0
- package/web/components/shared/attach-button.tsx +23 -0
- package/web/components/shared/chip.tsx +19 -0
- package/web/components/shared/client-mark.tsx +15 -0
- package/web/components/shared/confirm-dialog.tsx +35 -0
- package/web/components/shared/empty-state.tsx +29 -0
- package/web/components/shared/field.tsx +77 -0
- package/web/components/shared/filter-popover.tsx +29 -0
- package/web/components/shared/form-frame.tsx +19 -0
- package/web/components/shared/icon-button.tsx +50 -0
- package/web/components/shared/index.ts +18 -0
- package/web/components/shared/mic-button.tsx +75 -0
- package/web/components/shared/pager.tsx +49 -0
- package/web/components/shared/picker.tsx +108 -0
- package/web/components/shared/project-mark.tsx +38 -0
- package/web/components/shared/segmented.tsx +43 -0
- package/web/components/shared/state-dot.tsx +4 -0
- package/web/components/shared/status-mark.tsx +26 -0
- package/web/components/shell/index.ts +3 -0
- package/web/components/shell/rail.tsx +259 -0
- package/web/components/shell/sprite.tsx +124 -0
- package/web/components/shell/wordmark.tsx +13 -0
- package/web/components/task/artifact-view.tsx +148 -0
- package/web/components/task/chat-bubble.tsx +43 -0
- package/web/components/task/filter-menu.tsx +38 -0
- package/web/components/task/index.ts +7 -0
- package/web/components/task/result-checks.tsx +34 -0
- package/web/components/task/result-view.tsx +103 -0
- package/web/components/task/status-badge.tsx +24 -0
- package/web/components/task/task-row.tsx +34 -0
- package/web/components/task/typing-dots.tsx +16 -0
- package/web/components/terminal/index.ts +3 -0
- package/web/components/terminal/terminal-bar.tsx +91 -0
- package/web/components/terminal/terminal-grid.tsx +149 -0
- package/web/components/terminal/terminal-modes.tsx +23 -0
- package/web/components/terminal/terminal-tile.tsx +139 -0
- package/web/dist/annotate.js +24 -0
- package/web/dist/board.css +718 -0
- package/web/dist/board.js +115 -0
- package/web/dist/boot.js +2 -0
- package/web/dist/notebook.css +319 -0
- package/web/dist/notebook.js +89 -0
- package/web/dist/popup.css +41 -0
- package/web/dist/popup.js +13 -0
- package/web/{term.js → dist/term.js} +48 -48
- package/web/dist/ui.css +3 -0
- package/web/dist/video.js +108 -0
- package/web/html/board.html +17 -0
- package/web/html/notes.html +14 -0
- package/web/html/popup.html +13 -0
- package/web/{video.html → html/video.html} +14 -15
- package/web/lib/annotate/index.ts +2 -0
- package/web/lib/annotate/notes.ts +105 -0
- package/web/lib/annotate/page.ts +121 -0
- package/web/lib/annotate/rules.ts +37 -0
- package/web/lib/annotate/session.ts +336 -0
- package/web/lib/board/board-actions.ts +119 -0
- package/web/lib/board/board-open.ts +12 -0
- package/web/lib/board/board-store.ts +159 -0
- package/web/lib/board/filter-box.ts +7 -0
- package/web/lib/board/index.ts +10 -0
- package/web/lib/board/nav.ts +29 -0
- package/web/lib/board/on-state.ts +90 -0
- package/web/lib/board/popups.ts +22 -0
- package/web/lib/board/snapshot.ts +105 -0
- package/web/lib/board/strip.ts +43 -0
- package/web/{board → lib/board}/ws-board.ts +1 -1
- package/web/lib/context/context-rules.ts +27 -0
- package/web/lib/context/context-store.ts +95 -0
- package/web/lib/context/feed.ts +28 -0
- package/web/lib/context/index.ts +3 -0
- package/web/lib/core/api.ts +86 -0
- package/web/lib/core/ask.ts +24 -0
- package/web/lib/core/board.ts +290 -0
- package/web/lib/core/brief.ts +31 -0
- package/web/lib/core/format.ts +8 -0
- package/web/lib/core/host.ts +107 -0
- package/web/lib/core/index.ts +16 -0
- package/web/{board → lib/core}/labels.ts +6 -5
- package/web/lib/core/layers.ts +7 -0
- package/web/lib/core/leave.ts +7 -0
- package/web/lib/core/motion.ts +10 -0
- package/web/{board/toast.ts → lib/core/notices.ts} +2 -20
- package/web/lib/core/notifier.ts +15 -0
- package/web/lib/core/store.ts +39 -0
- package/web/lib/core/term-handle.ts +8 -0
- package/web/lib/core/toast.ts +29 -0
- package/web/lib/core/utils.ts +15 -0
- package/web/lib/decision/index.ts +1 -0
- package/web/lib/decision/plan-questions.ts +39 -0
- package/web/lib/dictation/chunks.ts +93 -0
- package/web/lib/dictation/dictation-store.ts +22 -0
- package/web/lib/dictation/engine.ts +265 -0
- package/web/lib/dictation/index.ts +5 -0
- package/web/lib/dictation/mic.ts +42 -0
- package/web/lib/dictation/terminal-dictation.ts +50 -0
- package/web/lib/footer/footer-rules.ts +13 -0
- package/web/lib/footer/footer-store.ts +42 -0
- package/web/lib/footer/index.ts +2 -0
- package/web/lib/git/git-actions.ts +110 -0
- package/web/lib/git/git-panel.ts +43 -0
- package/web/lib/git/git-store.ts +47 -0
- package/web/lib/git/git.ts +170 -0
- package/web/lib/git/index.ts +4 -0
- package/web/lib/home/home-engine.ts +16 -0
- package/web/lib/home/home-events.ts +9 -0
- package/web/lib/home/home-store.ts +247 -0
- package/web/lib/home/home-window.ts +193 -0
- package/web/lib/home/home.ts +85 -0
- package/web/lib/home/index.ts +7 -0
- package/web/lib/home/onboarding.ts +199 -0
- package/web/lib/home/use-float-drag.ts +62 -0
- package/web/lib/icebox/icebox-actions.ts +518 -0
- package/web/lib/icebox/icebox-store.ts +112 -0
- package/web/lib/icebox/icebox-view.ts +48 -0
- package/web/lib/icebox/icebox.ts +273 -0
- package/web/lib/icebox/index.ts +8 -0
- package/web/lib/icebox/use-card-drag.ts +82 -0
- package/web/lib/icebox/use-ice-keys.ts +75 -0
- package/web/lib/icebox/use-icebox.ts +41 -0
- package/web/lib/icebox/use-row-swipe.ts +107 -0
- package/web/lib/markdown/index.ts +1 -0
- package/web/lib/markdown/markdown.ts +136 -0
- package/web/lib/notebook/autosave.ts +131 -0
- package/web/lib/notebook/deal.ts +58 -0
- package/web/lib/notebook/engine-complete.ts +128 -0
- package/web/lib/notebook/engine-preview.ts +287 -0
- package/web/lib/notebook/engine-types.ts +26 -0
- package/web/lib/notebook/engine-widgets.ts +218 -0
- package/web/lib/notebook/engine.ts +74 -0
- package/web/lib/notebook/index.ts +9 -0
- package/web/lib/notebook/kit-loader.ts +16 -0
- package/web/lib/notebook/kit.ts +12 -0
- package/web/{notes-lib.ts → lib/notebook/text.ts} +11 -10
- package/web/lib/notebook/vault-actions.ts +239 -0
- package/web/lib/notebook/vault-rules.ts +74 -0
- package/web/lib/notebook/vault-session.ts +73 -0
- package/web/lib/notebook/vault-store.ts +63 -0
- package/web/lib/notes/index.ts +4 -0
- package/web/lib/notes/md-html.ts +115 -0
- package/web/lib/notes/notes-actions.ts +32 -0
- package/web/lib/notes/notes-store.ts +22 -0
- package/web/lib/notes/notes.ts +58 -0
- package/web/{board → lib/notes}/rich.ts +1 -2
- package/web/lib/phone/index.ts +7 -0
- package/web/lib/phone/phone-actions.ts +77 -0
- package/web/lib/phone/phone-home.ts +102 -0
- package/web/lib/phone/phone-setup.ts +59 -0
- package/web/lib/phone/phone-sheet.ts +25 -0
- package/web/lib/phone/phone-store.ts +32 -0
- package/web/lib/phone/sheet-swipe.ts +55 -0
- package/web/lib/phone/use-phone-setup.ts +89 -0
- package/web/lib/project/add-project.ts +37 -0
- package/web/lib/project/branch.ts +14 -0
- package/web/lib/project/index.ts +5 -0
- package/web/lib/project/project-bar.ts +76 -0
- package/web/lib/project/project-pick.ts +36 -0
- package/web/lib/project/ws-menu.ts +8 -0
- package/web/lib/rail/agents.ts +63 -0
- package/web/lib/rail/card-links.ts +20 -0
- package/web/lib/rail/index.ts +7 -0
- package/web/lib/rail/rail-actions.ts +74 -0
- package/web/lib/rail/rail-boot.ts +99 -0
- package/web/lib/rail/rail-store.ts +85 -0
- package/web/lib/rail/rules.ts +241 -0
- package/web/lib/rail/source-marks.ts +17 -0
- package/web/lib/rail/use-rank-drag.ts +108 -0
- package/web/lib/resources/index.ts +3 -0
- package/web/lib/resources/resources-actions.ts +59 -0
- package/web/lib/resources/resources-store.ts +48 -0
- package/web/lib/resources/rules.ts +56 -0
- package/web/lib/router/index.ts +3 -0
- package/web/lib/router/route-rules.ts +96 -0
- package/web/lib/router/route-store.ts +115 -0
- package/web/lib/router/use-route-classes.ts +15 -0
- package/web/lib/run/browser.ts +53 -0
- package/web/lib/run/card-terminal.ts +32 -0
- package/web/lib/run/doc.ts +42 -0
- package/web/lib/run/grip.ts +8 -0
- package/web/lib/run/index.ts +19 -0
- package/web/lib/run/kept.ts +58 -0
- package/web/lib/run/layout-store.ts +156 -0
- package/web/lib/run/layout.ts +195 -0
- package/web/lib/run/panel-actions.ts +104 -0
- package/web/lib/run/panel-derive.ts +148 -0
- package/web/lib/run/panel-store.ts +125 -0
- package/web/lib/run/preview.ts +105 -0
- package/web/lib/run/run-actions.ts +118 -0
- package/web/lib/run/run-view-store.ts +134 -0
- package/web/lib/run/term-loader.ts +19 -0
- package/web/lib/run/use-panel-run.ts +125 -0
- package/web/lib/run/use-run-lifecycle.ts +70 -0
- package/web/lib/run/viewer.ts +12 -0
- package/web/lib/run/workspace.ts +281 -0
- package/web/lib/run/ws-actions.ts +293 -0
- package/web/lib/run/ws-derive.ts +50 -0
- package/web/lib/run/ws-draw.ts +102 -0
- package/web/lib/run/ws-store.ts +21 -0
- package/web/lib/run/ws-tabs.ts +125 -0
- package/web/lib/search/index.ts +3 -0
- package/web/lib/search/search-match.ts +48 -0
- package/web/lib/search/search-rows.ts +228 -0
- package/web/lib/search/search.ts +30 -0
- package/web/lib/search/use-search-rows.ts +22 -0
- package/web/lib/server/attention.ts +29 -0
- package/web/lib/server/index.ts +6 -0
- package/web/lib/server/poll-rules.ts +57 -0
- package/web/lib/server/poller.ts +210 -0
- package/web/lib/server/server-store.ts +39 -0
- package/web/lib/server/types.ts +31 -0
- package/web/lib/server/use-server.ts +19 -0
- package/web/lib/settings/agent-favicons.ts +14 -0
- package/web/lib/settings/index.ts +7 -0
- package/web/lib/settings/panel-settings.ts +29 -0
- package/web/lib/settings/settings-actions.ts +357 -0
- package/web/lib/settings/settings-store.ts +114 -0
- package/web/lib/settings/settings.ts +413 -0
- package/web/lib/settings/skill-icons.ts +24 -0
- package/web/lib/settings/update.ts +70 -0
- package/web/lib/shared/data-urls.ts +32 -0
- package/web/lib/shared/index.ts +4 -0
- package/web/lib/shared/use-draft.ts +38 -0
- package/web/lib/shared/use-narrow.ts +11 -0
- package/web/lib/shared/use-pager.ts +24 -0
- package/web/lib/shell/appearance.ts +97 -0
- package/web/lib/shell/help-store.ts +4 -0
- package/web/lib/shell/index.ts +4 -0
- package/web/lib/shell/shell-store.ts +23 -0
- package/web/lib/shell/stored-look.ts +47 -0
- package/web/lib/task/index.ts +7 -0
- package/web/lib/task/task-results.ts +92 -0
- package/web/lib/task/tasks.ts +132 -0
- package/web/lib/task/use-live-frame.ts +85 -0
- package/web/lib/task/use-saved-text.ts +25 -0
- package/web/lib/task/use-task.ts +161 -0
- package/web/lib/task/use-tasks.ts +50 -0
- package/web/{board → lib/task}/zoom.ts +25 -12
- package/web/lib/terminal/hidden-badge.ts +15 -0
- package/web/lib/terminal/index.ts +8 -0
- package/web/lib/terminal/layout.ts +138 -0
- package/web/{term-font.ts → lib/terminal/term-font.ts} +3 -2
- package/web/lib/terminal/terminal-store.ts +65 -0
- package/web/lib/terminal/terms-feed.ts +37 -0
- package/web/lib/terminal/use-arranged.ts +15 -0
- package/web/lib/terminal/use-terminal-keys.ts +37 -0
- package/web/lib/url/index.ts +1 -0
- package/web/lib/url/safe-url.ts +9 -0
- package/web/notebook/notebook.ts +27 -0
- package/web/notebook/notes-lib.ts +3 -0
- package/web/pages/board/App.tsx +76 -0
- package/web/pages/board/header.tsx +83 -0
- package/web/pages/board/help.tsx +59 -0
- package/web/pages/board/host-bridge.ts +94 -0
- package/web/pages/board/host.tsx +19 -0
- package/web/pages/board/keys.ts +112 -0
- package/web/pages/board/live.ts +39 -0
- package/web/pages/board/main.ts +32 -0
- package/web/pages/board/pages.tsx +86 -0
- package/web/pages/board/panel.tsx +157 -0
- package/web/pages/board/portal.tsx +39 -0
- package/web/pages/board/use-boot.ts +13 -0
- package/web/pages/board/views.ts +63 -0
- package/web/pages/board-page.tsx +62 -0
- package/web/pages/home-page.tsx +127 -0
- package/web/pages/icebox-page.tsx +440 -0
- package/web/pages/notebook/App.tsx +35 -0
- package/web/pages/notebook-page.tsx +50 -0
- package/web/pages/popup/App.tsx +207 -0
- package/web/pages/settings-page.tsx +111 -0
- package/web/pages/task-page.tsx +383 -0
- package/web/pages/tasks-page.tsx +151 -0
- package/web/pages/terminal-page.tsx +15 -0
- package/web/popup/popup.ts +7 -0
- package/web/{term.ts → term/term.ts} +48 -20
- package/web/ui/alert-dialog.tsx +39 -0
- package/web/ui/badge.tsx +20 -0
- package/web/ui/button.tsx +37 -0
- package/web/ui/checkbox.tsx +20 -0
- package/web/ui/command.tsx +41 -0
- package/web/ui/dialog.tsx +28 -0
- package/web/ui/dropdown-menu.tsx +54 -0
- package/web/ui/icon.tsx +17 -0
- package/web/ui/index.ts +21 -0
- package/web/ui/input.tsx +9 -0
- package/web/ui/label.tsx +7 -0
- package/web/ui/legacy/board.css +715 -0
- package/web/{notes.html → ui/legacy/notes.css} +23 -157
- package/web/ui/legacy/popup.css +40 -0
- package/web/ui/popover.tsx +28 -0
- package/web/ui/select.tsx +61 -0
- package/web/ui/sheet.tsx +43 -0
- package/web/ui/skeleton.tsx +6 -0
- package/web/ui/sonner.tsx +25 -0
- package/web/ui/spinner.tsx +12 -0
- package/web/ui/switch.tsx +18 -0
- package/web/ui/tabs.tsx +18 -0
- package/web/ui/textarea.tsx +14 -0
- package/web/ui/theme.css +125 -0
- package/web/ui/toggle.tsx +8 -0
- package/web/ui/tooltip.tsx +26 -0
- package/web/{video.ts → video/video.ts} +5 -5
- package/web/board/add-project.ts +0 -147
- package/web/board/agent-favicons.ts +0 -9
- package/web/board/agent-term.ts +0 -51
- package/web/board/annotate-lib.ts +0 -19
- package/web/board/annotate.ts +0 -221
- package/web/board/api.ts +0 -180
- package/web/board/approvals.ts +0 -109
- package/web/board/badge.ts +0 -115
- package/web/board/cards.ts +0 -1080
- package/web/board/chat.ts +0 -128
- package/web/board/context.ts +0 -248
- package/web/board/dictation.ts +0 -343
- package/web/board/dom.ts +0 -132
- package/web/board/drafts.ts +0 -21
- package/web/board/fixes.ts +0 -89
- package/web/board/git.ts +0 -416
- package/web/board/home-ws.ts +0 -266
- package/web/board/home.ts +0 -421
- package/web/board/icebox.ts +0 -1788
- package/web/board/keys.ts +0 -121
- package/web/board/live.ts +0 -87
- package/web/board/main.ts +0 -94
- package/web/board/markdown.ts +0 -210
- package/web/board/onboarding.ts +0 -227
- package/web/board/panel.ts +0 -437
- package/web/board/phone-setup.ts +0 -79
- package/web/board/phone.ts +0 -219
- package/web/board/projects.ts +0 -277
- package/web/board/resources.ts +0 -170
- package/web/board/run-pick.ts +0 -41
- package/web/board/run-view.ts +0 -1316
- package/web/board/search-match.ts +0 -20
- package/web/board/search.ts +0 -330
- package/web/board/settings-accounts.ts +0 -76
- package/web/board/settings-agents.ts +0 -102
- package/web/board/settings-automations.ts +0 -71
- package/web/board/settings-cleanup.ts +0 -42
- package/web/board/settings-orchestration.ts +0 -32
- package/web/board/settings-pages.ts +0 -62
- package/web/board/settings-skills.ts +0 -103
- package/web/board/settings-voice.ts +0 -28
- package/web/board/settings.ts +0 -490
- package/web/board/store.ts +0 -47
- package/web/board/task-page.ts +0 -628
- package/web/board/task-results.ts +0 -234
- package/web/board/tasks.ts +0 -242
- package/web/board/terms.ts +0 -390
- package/web/board/update.ts +0 -171
- package/web/board/viewer.ts +0 -47
- package/web/board/views.ts +0 -164
- package/web/board/whatsapp-setup.ts +0 -149
- package/web/board/workspace.ts +0 -650
- package/web/board/ws-board-ui.ts +0 -95
- package/web/board/ws-tabs.ts +0 -227
- package/web/board.html +0 -1563
- package/web/board.js +0 -505
- package/web/notebook.js +0 -519
- package/web/notebook.ts +0 -1254
- package/web/popup.html +0 -141
- package/web/video.js +0 -575
- /package/web/{term.css → dist/term.css} +0 -0
- /package/web/{board/term-sessions.ts → lib/terminal/sessions.ts} +0 -0
- /package/web/{board/terminal-viewport.ts → lib/terminal/viewport.ts} +0 -0
- /package/web/{term-paste.ts → term/term-paste.ts} +0 -0
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// The search palette's matcher, apart from the page so a test can load it.
|
|
2
|
-
export type Item = { group: string; title: string; sub?: string; when?: string; hay: string; at?: number; dot?: string; ico: string; act: () => void };
|
|
3
|
-
|
|
4
|
-
// Every word of the query in the item; a title that starts with it ranks first, then a title
|
|
5
|
-
// holding it, then the rest by recency.
|
|
6
|
-
export function match(list: Item[], q: string): Item[] {
|
|
7
|
-
const words = q.toLowerCase().split(/\s+/).filter(Boolean);
|
|
8
|
-
if (!words.length) return list;
|
|
9
|
-
const lq = q.trim().toLowerCase();
|
|
10
|
-
const score = (i: Item) => {
|
|
11
|
-
const t = i.title.toLowerCase();
|
|
12
|
-
return t.startsWith(lq) ? 0 : t.includes(lq) ? 1 : 2;
|
|
13
|
-
};
|
|
14
|
-
return list
|
|
15
|
-
.filter((i) => {
|
|
16
|
-
const h = (i.title + " " + (i.sub ?? "") + " " + i.hay).toLowerCase();
|
|
17
|
-
return words.every((w) => h.includes(w));
|
|
18
|
-
})
|
|
19
|
-
.sort((a, b) => score(a) - score(b) || (b.at ?? 0) - (a.at ?? 0));
|
|
20
|
-
}
|
package/web/board/search.ts
DELETED
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
// Global search: the "Search" entry on top of the side menu, and Ctrl/Cmd+K anywhere, open
|
|
2
|
-
// one palette over workspaces, runs and tasks, chats, agent terminals, projects, pages and
|
|
3
|
-
// actions (modelled on Orca's "Jump to..." palette). Nothing is fetched but /chats; the rest
|
|
4
|
-
// is what the side menu already holds. Stands alone like workspace.ts, so the notebook and
|
|
5
|
-
// video pages carry it too: a pick the page cannot do in place navigates instead.
|
|
6
|
-
import { $, html, raw } from "./dom.ts";
|
|
7
|
-
import { age } from "./labels.ts";
|
|
8
|
-
import { openAdd } from "./add-project.ts";
|
|
9
|
-
import { cardHref, projName, railData, stateOf, titleOf, wsHref, wsLabel, wsOfCard } from "./workspace.ts";
|
|
10
|
-
import { match, type Item } from "./search-match.ts";
|
|
11
|
-
import { leaves, wsKey } from "./ws-tabs.ts";
|
|
12
|
-
|
|
13
|
-
// The pages that can open a thing in place answer this event and cancel it.
|
|
14
|
-
const ask = (name: string, detail: any) => !dispatchEvent(new CustomEvent(name, { cancelable: true, detail }));
|
|
15
|
-
// A menu entry's own click: in place on the board, a page load elsewhere.
|
|
16
|
-
const page = (v: string, href: string) => () => {
|
|
17
|
-
const a = document.querySelector<HTMLElement>(`.rail a[data-view="${v}"]`);
|
|
18
|
-
a ? a.click() : (location.href = href);
|
|
19
|
-
};
|
|
20
|
-
const openWs = (dir: string, ws: string) => {
|
|
21
|
-
if (!ask("kz-open-ws", { dir, ws })) location.href = wsHref(dir, ws);
|
|
22
|
-
};
|
|
23
|
-
// The run view's saved layouts (run-view.ts keeps them here per workspace).
|
|
24
|
-
const layouts = (): Record<string, any> => {
|
|
25
|
-
try {
|
|
26
|
-
return JSON.parse(localStorage.getItem("kz-runtabs") || "{}");
|
|
27
|
-
} catch {
|
|
28
|
-
return {};
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
// A tab: the board opens it in place; elsewhere its screen is chosen in storage, then the workspace loads.
|
|
32
|
-
const openTab = (dir: string, ws: string, id: string) => {
|
|
33
|
-
if (ask("kz-open-tab", { dir, ws, id })) return;
|
|
34
|
-
const all = layouts(),
|
|
35
|
-
s = all[wsKey(dir, ws)],
|
|
36
|
-
sc = s?.screens?.find((x) => leaves(x.tree).includes(id));
|
|
37
|
-
if (sc)
|
|
38
|
-
try {
|
|
39
|
-
s.on = sc.id;
|
|
40
|
-
localStorage.setItem("kz-runtabs", JSON.stringify(all));
|
|
41
|
-
} catch {}
|
|
42
|
-
location.href = wsHref(dir, ws);
|
|
43
|
-
};
|
|
44
|
-
// The run view's own tabs worth jumping to; agent tabs are listed with the terminals.
|
|
45
|
-
const TAB_KINDS = ["local", "preview", "note", "history", "shell"];
|
|
46
|
-
const browsed = (k: string) => {
|
|
47
|
-
try {
|
|
48
|
-
return localStorage.getItem("kz-browse:" + k)?.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
49
|
-
} catch {}
|
|
50
|
-
};
|
|
51
|
-
const ICO = {
|
|
52
|
-
ws: '<circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="8" r="2"/><path d="M6 8v8M18 10c0 4-6 3-12 6"/>',
|
|
53
|
-
run: '<path d="M5 4l14 8-14 8z"/>',
|
|
54
|
-
idea: '<path d="M9 18h6M10 21h4M12 3a6 6 0 0 0-4 10.5c.7.7 1 1.5 1 2.5h6c0-1 .3-1.8 1-2.5A6 6 0 0 0 12 3z"/>',
|
|
55
|
-
chat: '<path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/>',
|
|
56
|
-
term: '<path d="M4 17l6-5-6-5M12 19h8"/>',
|
|
57
|
-
proj: '<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',
|
|
58
|
-
page: '<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 9h16"/>',
|
|
59
|
-
act: '<path d="M13 3L5 14h6l-1 7 8-11h-6z"/>',
|
|
60
|
-
tab: '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 9h8V5"/>',
|
|
61
|
-
plus: '<path d="M12 5v14M5 12h14"/>',
|
|
62
|
-
search: '<circle cx="11" cy="11" r="7"/><path d="M20 20l-4-4"/>',
|
|
63
|
-
};
|
|
64
|
-
const svg = (k: string) => raw(`<svg viewBox="0 0 24 24" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${ICO[k]}</g></svg>`);
|
|
65
|
-
|
|
66
|
-
let chats: any[] = [];
|
|
67
|
-
function items(): Item[] {
|
|
68
|
-
const { cards, projects = [], agents = [] } = railData();
|
|
69
|
-
const now = Date.now();
|
|
70
|
-
const cur = new URLSearchParams(location.search);
|
|
71
|
-
// The workspace open now: named by the address, or the one holding the run it names.
|
|
72
|
-
const curRun = cur.get("id") && cards.find((c) => c.kind === "run" && c.state === cur.get("dir") && c.id === cur.get("id"));
|
|
73
|
-
const curWs = cur.get("ws") ?? (curRun ? wsOfCard(curRun, projects) : null);
|
|
74
|
-
const out: Item[] = [];
|
|
75
|
-
const saved = layouts();
|
|
76
|
-
// Workspaces, the one open now first; then by their latest run.
|
|
77
|
-
const latest = new Map<string, number>();
|
|
78
|
-
for (const c of cards) {
|
|
79
|
-
const k = c.state + "\0" + wsOfCard(c, projects);
|
|
80
|
-
latest.set(k, Math.max(latest.get(k) ?? 0, c.moved ?? 0));
|
|
81
|
-
}
|
|
82
|
-
for (const p of projects) {
|
|
83
|
-
const name = projName(p.dir, projects);
|
|
84
|
-
for (const w of p.workspaces ?? []) {
|
|
85
|
-
const here = cur.get("dir") === p.dir && curWs === w.path;
|
|
86
|
-
const at = latest.get(p.dir + "\0" + w.path);
|
|
87
|
-
out.push({
|
|
88
|
-
group: here ? "Current" : "Workspaces",
|
|
89
|
-
title: wsLabel(w),
|
|
90
|
-
sub: name,
|
|
91
|
-
when: at ? age(at, now) : undefined,
|
|
92
|
-
hay: `${wsLabel(w)} ${name} ${w.path} workspace`,
|
|
93
|
-
at: here ? Infinity : at ?? 0,
|
|
94
|
-
ico: "ws",
|
|
95
|
-
act: () => openWs(p.dir, w.path),
|
|
96
|
-
});
|
|
97
|
-
const k = wsKey(p.dir, w.path),
|
|
98
|
-
lay = saved[k];
|
|
99
|
-
for (const t of lay?.tabs ?? []) {
|
|
100
|
-
if (!TAB_KINDS.includes(t.kind) || lay.hidden?.includes(t.id)) continue;
|
|
101
|
-
const title = (t.kind === "local" && browsed(k)) || t.title;
|
|
102
|
-
out.push({ group: "Tabs", title, sub: `${wsLabel(w)} · ${name}`, hay: `${title} ${t.title} ${t.kind} ${t.note ?? ""} ${wsLabel(w)} ${name} tab`, ico: "tab", act: () => openTab(p.dir, w.path, t.id) });
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
out.push({ group: "Projects", title: name, hay: `${name} ${p.dir} project`, ico: "proj", act: () => {
|
|
106
|
-
const main = p.workspaces?.find((w) => w.main) ?? p.workspaces?.[0];
|
|
107
|
-
main ? openWs(p.dir, main.path) : page("board", "/?view=board")();
|
|
108
|
-
} });
|
|
109
|
-
}
|
|
110
|
-
// Runs and tasks, not archived.
|
|
111
|
-
for (const c of cards.filter((c) => !c.archived)) {
|
|
112
|
-
const st = stateOf(c);
|
|
113
|
-
out.push({
|
|
114
|
-
group: c.kind === "run" ? "Runs" : "Tasks",
|
|
115
|
-
title: titleOf(c) || c.id,
|
|
116
|
-
sub: projName(c.state, projects),
|
|
117
|
-
when: c.moved ? age(c.moved, now) : undefined,
|
|
118
|
-
hay: `${titleOf(c)} ${c.id ?? ""} ${c.text ?? ""} ${projName(c.state, projects)} ${st}`,
|
|
119
|
-
at: c.moved ?? 0,
|
|
120
|
-
dot: st,
|
|
121
|
-
ico: c.kind === "run" ? "run" : "idea",
|
|
122
|
-
act: () => {
|
|
123
|
-
if (!ask("kz-open-card", { dir: c.state, id: c.kind === "run" ? c.id : undefined, text: c.text })) location.href = cardHref(c);
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
for (const c of chats) {
|
|
128
|
-
// updated is an ISO date string.
|
|
129
|
-
const at = Date.parse(c.updated) || 0;
|
|
130
|
-
out.push({
|
|
131
|
-
group: "Chats & terminals",
|
|
132
|
-
title: c.title || "Chat",
|
|
133
|
-
sub: c.project ? projName(c.project, projects) : undefined,
|
|
134
|
-
when: at ? age(at, now) : undefined,
|
|
135
|
-
hay: `${c.title} chat ${c.project ?? ""}`,
|
|
136
|
-
at,
|
|
137
|
-
dot: c.busy ? "build" : undefined,
|
|
138
|
-
ico: "chat",
|
|
139
|
-
act: () => {
|
|
140
|
-
try {
|
|
141
|
-
sessionStorage.setItem("kz-chat", c.id);
|
|
142
|
-
} catch {}
|
|
143
|
-
page("home", "/")();
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
for (const a of agents)
|
|
148
|
-
out.push({
|
|
149
|
-
group: "Chats & terminals",
|
|
150
|
-
title: a.name || a.agent || "Terminal",
|
|
151
|
-
sub: projName(a.dir, projects),
|
|
152
|
-
hay: `${a.name} ${a.agent ?? ""} ${a.run ?? ""} ${a.last ?? ""} ${projName(a.dir, projects)} terminal agent`,
|
|
153
|
-
at: a.at ?? a.born ?? 0,
|
|
154
|
-
dot: a.asking ? "wait" : a.busy ? "build" : "done",
|
|
155
|
-
ico: "term",
|
|
156
|
-
act: () => {
|
|
157
|
-
if (!ask("kz-open-term", { dir: a.dir, ws: a.ws, key: a.key })) location.href = wsHref(a.dir, a.ws ?? "");
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
// Pages and actions. Each clicks the side menu's own control, so it behaves the same.
|
|
161
|
-
const click = (id: string) => () => $(id)?.click();
|
|
162
|
-
const acts: [string, string, () => void, string?][] = [
|
|
163
|
-
["Chat", "page", page("home", "/"), "home"],
|
|
164
|
-
["Icebox", "page", page("sources", "/?view=icebox"), "requests sources gathered capture inbox later add note"],
|
|
165
|
-
["Tasks", "page", page("tasks", "/?view=tasks"), "backlog"],
|
|
166
|
-
["Board", "page", page("board", "/?view=board"), "kanban runs"],
|
|
167
|
-
["Notes", "page", () => (location.href = "/notebook"), "notebook docs"],
|
|
168
|
-
["Settings", "page", page("settings", "/?view=settings"), "preferences config"],
|
|
169
|
-
["New task", "act", () => ($("newtop") ? $("newtop").click() : (location.href = "/?view=board")), "create add run"],
|
|
170
|
-
["Add a project", "act", () => openAdd({ dir: null }), "clone folder create workspace"],
|
|
171
|
-
["Toggle theme", "act", click("themet"), "dark light"],
|
|
172
|
-
["Collapse or expand menu", "act", click("fold"), "sidebar rail"],
|
|
173
|
-
["Keyboard shortcuts", "act", click("kbd"), "keys help"],
|
|
174
|
-
["Report an issue", "act", () => open("/issue", "_blank", "noopener"), "bug feedback"],
|
|
175
|
-
];
|
|
176
|
-
for (const [title, ico, act, kw] of acts) out.push({ group: "Actions", title, hay: `${title} ${kw ?? ""}`, ico, act });
|
|
177
|
-
return out;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const ORDER = ["Current", "Workspaces", "Tabs", "Chats & terminals", "Runs", "Tasks", "Projects", "Actions"];
|
|
181
|
-
// With nothing typed each group shows its most recent few, as Orca's does.
|
|
182
|
-
const CAP = { Workspaces: 5, Tabs: 4, "Chats & terminals": 5, Runs: 5, Tasks: 3, Projects: 5 };
|
|
183
|
-
|
|
184
|
-
let dl: HTMLDialogElement | null = null;
|
|
185
|
-
let shown: Item[] = [];
|
|
186
|
-
let sel = 0;
|
|
187
|
-
function draw() {
|
|
188
|
-
const q = (dl!.querySelector("input") as HTMLInputElement).value;
|
|
189
|
-
const all = items();
|
|
190
|
-
const hit = q.trim() ? match(all, q) : all.slice().sort((a, b) => (b.at ?? 0) - (a.at ?? 0));
|
|
191
|
-
shown = [];
|
|
192
|
-
// Typed: the group holding the best match comes first, so Enter takes it.
|
|
193
|
-
const order = q.trim() ? [...new Set(hit.map((i) => i.group))] : ORDER;
|
|
194
|
-
for (const g of order) {
|
|
195
|
-
const rows = hit.filter((i) => i.group === g);
|
|
196
|
-
shown.push(...rows.slice(0, q.trim() ? 8 : CAP[g] ?? rows.length));
|
|
197
|
-
}
|
|
198
|
-
// Orca offers to create what was typed; here that is a new task.
|
|
199
|
-
if (q.trim())
|
|
200
|
-
shown.push({ group: "Create", title: `New task "${q.trim()}"`, hay: "", ico: "plus", act: () => newTaskWith(q.trim()) });
|
|
201
|
-
sel = Math.min(sel, shown.length - 1);
|
|
202
|
-
const list = dl!.querySelector(".gs-list")!;
|
|
203
|
-
let g = "";
|
|
204
|
-
list.innerHTML = String(
|
|
205
|
-
html`${shown.map((i, n) => {
|
|
206
|
-
const head = i.group !== g ? ((g = i.group), html`<div class="gs-h" role="presentation">${i.group}</div>`) : "";
|
|
207
|
-
return html`${head}<div class="gs-i" role="option" id="gs-${n}" data-n="${n}" aria-selected="${String(n === sel)}">${svg(i.ico)}${i.dot ? html`<span class="si ${i.dot}"></span>` : ""}<span class="gs-t">${i.title}</span>${i.sub ? html`<span class="gs-s">${i.sub}</span>` : ""}${i.when ? html`<span class="gs-w">${i.when}</span>` : ""}</div>`;
|
|
208
|
-
})}${shown.length === 1 && q.trim() ? html`<div class="gs-none">No results</div>` : ""}`,
|
|
209
|
-
);
|
|
210
|
-
mark(sel);
|
|
211
|
-
dl!.querySelector(".gs-live")!.textContent = `${shown.length} result${shown.length === 1 ? "" : "s"} found`;
|
|
212
|
-
}
|
|
213
|
-
// Moves the selection without rebuilding the list.
|
|
214
|
-
function mark(n: number) {
|
|
215
|
-
dl!.querySelector(`#gs-${sel}`)?.setAttribute("aria-selected", "false");
|
|
216
|
-
sel = n;
|
|
217
|
-
const r = dl!.querySelector(`#gs-${n}`);
|
|
218
|
-
r?.setAttribute("aria-selected", "true");
|
|
219
|
-
dl!.querySelector("input")!.setAttribute("aria-activedescendant", "gs-" + n);
|
|
220
|
-
r?.scrollIntoView({ block: "nearest" });
|
|
221
|
-
}
|
|
222
|
-
function newTaskWith(text: string) {
|
|
223
|
-
if (!$("newtop")) return void (location.href = "/?view=board");
|
|
224
|
-
$("newtop").click();
|
|
225
|
-
const t = document.querySelector<HTMLTextAreaElement>("dialog[open] textarea");
|
|
226
|
-
if (t) (t.value = text), t.dispatchEvent(new Event("input", { bubbles: true }));
|
|
227
|
-
}
|
|
228
|
-
function pick(n: number) {
|
|
229
|
-
const i = shown[n];
|
|
230
|
-
if (!i) return;
|
|
231
|
-
dl!.close();
|
|
232
|
-
i.act();
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export function openSearch() {
|
|
236
|
-
if (dl) return dl.querySelector("input")!.focus();
|
|
237
|
-
dl = document.createElement("dialog");
|
|
238
|
-
dl.className = "gs";
|
|
239
|
-
dl.setAttribute("aria-label", "Search");
|
|
240
|
-
dl.innerHTML = String(
|
|
241
|
-
html`<div class="gs-box"><div class="gs-q">${svg("search")}<input type="text" placeholder="Search" aria-label="Search" role="combobox" aria-expanded="true" aria-controls="gs-list" autocomplete="off" spellcheck="false"></div><div class="gs-list" id="gs-list" role="listbox"></div><span class="gs-live" role="status" aria-live="polite"></span></div>`,
|
|
242
|
-
);
|
|
243
|
-
document.body.append(dl);
|
|
244
|
-
const q = dl.querySelector("input")!;
|
|
245
|
-
sel = 0;
|
|
246
|
-
q.oninput = () => ((sel = 0), draw());
|
|
247
|
-
q.onkeydown = (e) => {
|
|
248
|
-
const d = { ArrowDown: 1, ArrowUp: -1 }[e.key] ?? (e.ctrlKey && e.key === "n" ? 1 : e.ctrlKey && e.key === "p" ? -1 : 0);
|
|
249
|
-
if (d) {
|
|
250
|
-
e.preventDefault();
|
|
251
|
-
mark((sel + d + shown.length) % shown.length);
|
|
252
|
-
} else if (e.key === "Enter") {
|
|
253
|
-
e.preventDefault();
|
|
254
|
-
pick(sel);
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
const list = dl.querySelector<HTMLElement>(".gs-list")!;
|
|
258
|
-
list.onclick = (e) => {
|
|
259
|
-
const r = (e.target as Element).closest<HTMLElement>(".gs-i");
|
|
260
|
-
if (r) pick(+r.dataset.n!);
|
|
261
|
-
};
|
|
262
|
-
list.onpointermove = (e) => {
|
|
263
|
-
const r = (e.target as Element).closest<HTMLElement>(".gs-i");
|
|
264
|
-
if (r && +r.dataset.n! !== sel) mark(+r.dataset.n!);
|
|
265
|
-
};
|
|
266
|
-
dl.onclick = (e) => e.target === dl && dl!.close();
|
|
267
|
-
dl.onclose = () => (dl!.remove(), (dl = null));
|
|
268
|
-
dl.showModal();
|
|
269
|
-
draw();
|
|
270
|
-
// Chats live behind one fetch; the list redraws when they land.
|
|
271
|
-
fetch("/chats")
|
|
272
|
-
.then((r) => r.json())
|
|
273
|
-
.then((d) => {
|
|
274
|
-
chats = d.chats ?? [];
|
|
275
|
-
if (dl) draw();
|
|
276
|
-
})
|
|
277
|
-
.catch(() => {});
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const CSS = `dialog.gs{border:0;padding:0;margin:14vh auto auto;background:none;width:min(560px,calc(100vw - 32px));color:var(--ink);overflow:visible}
|
|
281
|
-
dialog.gs::backdrop{background:rgb(0 0 0/.35)}
|
|
282
|
-
.gs-box{display:flex;flex-direction:column;max-height:min(480px,72vh);background:var(--bg);border:1px solid var(--line);border-radius:10px;box-shadow:0 16px 40px rgb(0 0 0/.25);overflow:hidden}
|
|
283
|
-
.gs-q{display:flex;align-items:center;gap:8px;padding:0 12px;border-bottom:1px solid var(--line)}
|
|
284
|
-
.gs-q svg{width:15px;height:15px;color:var(--dim);flex:none}
|
|
285
|
-
.gs-q input{flex:1;min-width:0;height:40px;border:0;outline:0;background:none;color:var(--ink);font:inherit;font-size:var(--fs-l,14px)}
|
|
286
|
-
.gs-list{flex:1;overflow:auto;padding:4px}
|
|
287
|
-
.gs-h{padding:10px 8px 4px;font-size:var(--fs-xs,11px);color:var(--dim)}
|
|
288
|
-
.gs-i{display:flex;align-items:center;gap:8px;height:var(--btn-s,32px);padding:0 var(--padx,8px);border-radius:var(--r-s,4px);cursor:pointer;font-size:var(--fs,13px)}
|
|
289
|
-
.gs-i[aria-selected=true]{background:var(--hover)}
|
|
290
|
-
.gs-i svg{width:var(--ico,14px);height:var(--ico,14px);color:var(--dim);flex:none}
|
|
291
|
-
.gs-i .si{flex:none}
|
|
292
|
-
.gs-t{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
293
|
-
.gs-s{color:var(--dim);font-size:var(--fs-s,12px);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex:0 1 auto}
|
|
294
|
-
.gs-w{margin-left:auto;padding-left:8px;color:var(--dim);font-size:var(--fs-xs,11px);flex:none}
|
|
295
|
-
.gs-none{padding:14px 8px;text-align:center;color:var(--dim);font-size:var(--fs-s,12px)}
|
|
296
|
-
.gs-live{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
|
|
297
|
-
@media(max-width:640px){.rail a.it.gs-it{order:4}}`;
|
|
298
|
-
|
|
299
|
-
export function initSearch() {
|
|
300
|
-
const st = document.createElement("style");
|
|
301
|
-
st.textContent = CSS;
|
|
302
|
-
document.head.append(st);
|
|
303
|
-
const mac = /Mac|iP(hone|ad)/.test(navigator.platform);
|
|
304
|
-
const it = $("gsearch");
|
|
305
|
-
if (it) it.onclick = (e) => (e.preventDefault(), openSearch());
|
|
306
|
-
// Opened before the menu's data came in: fill in as it lands.
|
|
307
|
-
addEventListener("kz-rail", () => dl && draw());
|
|
308
|
-
// Ctrl/Cmd+K anywhere, and Orca's own Cmd+J (Ctrl+Shift+J is the browser's console).
|
|
309
|
-
addEventListener(
|
|
310
|
-
"keydown",
|
|
311
|
-
(e) => {
|
|
312
|
-
// Ctrl+Shift+Space works in a terminal too: no shell or agent needs it.
|
|
313
|
-
if (e.ctrlKey && e.shiftKey && e.code === "Space") {
|
|
314
|
-
e.preventDefault();
|
|
315
|
-
e.stopPropagation();
|
|
316
|
-
return void (dl ? dl.close() : openSearch());
|
|
317
|
-
}
|
|
318
|
-
// A terminal keeps its keys: Ctrl+K there is the shell's kill-line.
|
|
319
|
-
if ((e.target as Element)?.closest?.(".xterm")) return;
|
|
320
|
-
const mod = mac ? e.metaKey : e.ctrlKey;
|
|
321
|
-
const k = e.key.toLowerCase();
|
|
322
|
-
if (mod && !e.altKey && ((k === "k" && !e.shiftKey) || (mac && k === "j" && !e.shiftKey))) {
|
|
323
|
-
e.preventDefault();
|
|
324
|
-
e.stopPropagation();
|
|
325
|
-
dl ? dl.close() : openSearch();
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
true,
|
|
329
|
-
);
|
|
330
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { AGENT_FAVICONS } from "./agent-favicons.ts";
|
|
2
|
-
import { post } from "./api.ts";
|
|
3
|
-
import { $, html } from "./dom.ts";
|
|
4
|
-
import { store } from "./store.ts";
|
|
5
|
-
import { toast } from "./toast.ts";
|
|
6
|
-
|
|
7
|
-
// Settings → AI Accounts. /accounts never carries a token.
|
|
8
|
-
type Row = { id: string; tool: string; name: string; isDefault: boolean; signedIn: boolean; signIn: string; usage: any; usageKnown?: boolean; who?: string; plan?: string; via?: string };
|
|
9
|
-
type Normal = { tool: string; isDefault: boolean; signedIn: boolean; signIn: string; usage: any; usageKnown?: boolean; noAccounts?: boolean; who?: string; plan?: string; via?: string };
|
|
10
|
-
// Who the tool says is signed in: an email (Claude), else how (Codex: "ChatGPT"), and the plan.
|
|
11
|
-
const whoLine = (a: { signedIn: boolean; who?: string; plan?: string; via?: string }) =>
|
|
12
|
-
a.signedIn && (a.who || a.via || a.plan) ? html`<span class="ac-who">${[a.who ?? (a.via ? `via ${a.via}` : ""), a.plan].filter(Boolean).join(" · ")}</span>` : "";
|
|
13
|
-
const TOOL: Record<string, string> = { claude: "Claude", codex: "Codex", gemini: "Gemini CLI", agy: "Antigravity" };
|
|
14
|
-
const TOOLS = ["claude", "codex", "gemini", "agy"];
|
|
15
|
-
|
|
16
|
-
// `known`: the tool keeps plan usage kaizen can read (Gemini CLI does not).
|
|
17
|
-
function usageLine(u: any, signed: boolean, known = true) {
|
|
18
|
-
if (!u) return html`<span class="ac-u${signed ? "" : " bad"}">${signed ? (known ? "Signed in · no usage yet" : "Signed in") : "Not signed in"}</span>`;
|
|
19
|
-
if (u.expired) return html`<span class="ac-u bad">Sign-in expired. Sign in again</span>`;
|
|
20
|
-
if (u.error) return html`<span class="ac-u bad">Usage unavailable</span>`;
|
|
21
|
-
return html`<span class="ac-u">${u.five ? `${u.five.pct}% of 5 hours` : ""}${u.five && u.week ? " · " : ""}${u.week ? `${u.week.pct}% of the week` : ""}</span>`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const row = (a: Row) =>
|
|
25
|
-
html`<div class="sk" data-q="account ${a.name.toLowerCase()} ${a.tool}">
|
|
26
|
-
<div class="sk-h"><img class="ag-i" src="${AGENT_FAVICONS[a.tool] ?? ""}" alt="" width="28" height="28"><span class="sk-n"><input class="sel ac-name" data-ac-name="${a.id}" value="${a.name}" aria-label="Account name, click to rename" title="Click to rename" maxlength="60" autocomplete="off" spellcheck="false">${whoLine(a)}${usageLine(a.usage, a.signedIn, a.usageKnown !== false)}</span>
|
|
27
|
-
${a.signedIn && !a.usage?.expired ? "" : html`<button type="button" class="btn" data-ac-sign="${a.id}" data-tool="${a.tool}">Sign in</button>`}
|
|
28
|
-
<button type="button" class="btn" data-ac-def="${a.isDefault ? "" : a.id}" data-tool="${a.tool}" aria-pressed="${String(a.isDefault)}">${a.isDefault ? "✓ Default" : "Default"}</button>
|
|
29
|
-
<button type="button" class="btn" data-ac-rm="${a.id}" data-name="${a.name}">Remove</button></div>
|
|
30
|
-
${a.signedIn && !a.usage?.expired ? "" : html`<div class="sk-a"><code>${a.signIn}</code></div>`}
|
|
31
|
-
</div>`;
|
|
32
|
-
|
|
33
|
-
// The login the tool uses on its own (~/.claude, ~/.codex): first in its section, Default unless an
|
|
34
|
-
// account below is.
|
|
35
|
-
const normalRow = (n: Normal) =>
|
|
36
|
-
html`<div class="sk ac-normal" data-q="account login normal default ${n.tool} ${(n.who ?? "").toLowerCase()}">
|
|
37
|
-
<div class="sk-h"><img class="ag-i" src="${AGENT_FAVICONS[n.tool] ?? ""}" alt="" width="28" height="28"><span class="sk-n"><span class="ac-nm">Your login <i>~/.${n.tool}</i></span>${whoLine(n)}${usageLine(n.usage, n.signedIn, n.usageKnown !== false)}</span>
|
|
38
|
-
${n.signedIn && !n.usage?.expired ? "" : html`<button type="button" class="btn" data-ac-sign="" data-tool="${n.tool}">Sign in</button>`}
|
|
39
|
-
${n.noAccounts ? "" : html`<button type="button" class="btn" data-ac-def="" data-tool="${n.tool}" aria-pressed="${String(n.isDefault)}"${n.isDefault ? " disabled" : ""} title="${n.isDefault ? "Runs use this login" : "Use this login for runs again"}">${n.isDefault ? "✓ Default" : "Default"}</button>`}</div>
|
|
40
|
-
${n.signedIn && !n.usage?.expired ? "" : html`<div class="sk-a"><code>${n.signIn}</code></div>`}
|
|
41
|
-
</div>`;
|
|
42
|
-
|
|
43
|
-
export const accountRows = (d: { accounts: Row[]; normal?: Normal[]; windows: boolean }) =>
|
|
44
|
-
html`${TOOLS.filter((t) => d.accounts.some((a) => a.tool === t) || (d.normal ?? []).some((n) => n.tool === t)).map((t) => html`<h3 class="sg">${TOOL[t]}</h3><div class="sgrp">${(d.normal ?? []).filter((n) => n.tool === t).map(normalRow)}${d.accounts.filter((a) => a.tool === t).map(row)}</div>`)}
|
|
45
|
-
<h3 class="sg">Add an account</h3><div class="sgrp"><div class="ac-add" data-q="add account sign in claude codex gemini provider">
|
|
46
|
-
<div class="achips">${TOOLS.filter((t) => t !== "agy").filter((t) => t !== "gemini" || (d.normal ?? []).some((n) => n.tool === t) || d.accounts.some((a) => a.tool === t)).map((t) => html`<button type="button" data-ac-new="${t}"${d.windows ? " disabled" : ""}><img src="${AGENT_FAVICONS[t]}" alt="" width="16" height="16">Add ${TOOL[t]} account</button>`)}</div></div></div>`;
|
|
47
|
-
|
|
48
|
-
export function wireAccounts(redraw: () => Promise<unknown>) {
|
|
49
|
-
const send = async (body: object) => {
|
|
50
|
-
const j = await post("/accounts", body);
|
|
51
|
-
toast(j.error ? j.error : "Saved");
|
|
52
|
-
await redraw();
|
|
53
|
-
};
|
|
54
|
-
const root = $("pbody");
|
|
55
|
-
root.querySelectorAll<HTMLInputElement>("[data-ac-name]").forEach((i) => (i.onchange = () => send({ op: "rename", id: i.dataset.acName, name: i.value })));
|
|
56
|
-
root.querySelectorAll<HTMLElement>("[data-ac-new]").forEach((b) => (b.onclick = async () => {
|
|
57
|
-
const j = await post("/accounts", { op: "add", tool: b.dataset.acNew });
|
|
58
|
-
if (j.error || !j.added) return toast(j.error || "Could not add the account");
|
|
59
|
-
await signIn(j.added, b.dataset.acNew!);
|
|
60
|
-
redraw();
|
|
61
|
-
}));
|
|
62
|
-
root.querySelectorAll<HTMLElement>("[data-ac-def]").forEach((b) => (b.onclick = () => send({ op: "default", tool: b.dataset.tool, id: b.dataset.acDef })));
|
|
63
|
-
root.querySelectorAll<HTMLElement>("[data-ac-rm]").forEach((b) => (b.onclick = () => {
|
|
64
|
-
if (!confirm(`Remove ${b.dataset.name}? Runs started on it won't start until you pick another.`)) return;
|
|
65
|
-
send({ op: "remove", id: b.dataset.acRm, deleteFolder: confirm("Also delete its folder, with its login and conversations? Cancel keeps them.") });
|
|
66
|
-
}));
|
|
67
|
-
const signIn = async (id: string, tool: string) => {
|
|
68
|
-
const dir = store.dir || store.S?.dir;
|
|
69
|
-
if (!dir) return toast("Open a project first, or run the line shown here in a terminal");
|
|
70
|
-
const j = await post("/shell", { dir, agent: tool, account: id, login: true });
|
|
71
|
-
if (j.error || !j.key) return toast(j.error || "Could not open a terminal. Run the line shown here");
|
|
72
|
-
const opened = !dispatchEvent(new CustomEvent("kz-open-term", { cancelable: true, detail: { dir, ws: j.ws, key: j.key } }));
|
|
73
|
-
toast(opened ? "Sign in, then close the terminal" : "Terminal started. Open it from the side menu");
|
|
74
|
-
};
|
|
75
|
-
root.querySelectorAll<HTMLElement>("[data-ac-sign]").forEach((b) => (b.onclick = () => signIn(b.dataset.acSign!, b.dataset.tool!)));
|
|
76
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { AGENT_FAVICONS } from "./agent-favicons.ts";
|
|
2
|
-
import { post } from "./api.ts";
|
|
3
|
-
import { $, html, ico } from "./dom.ts";
|
|
4
|
-
import { toast } from "./toast.ts";
|
|
5
|
-
|
|
6
|
-
// Settings → Agents, above the page's ordinary rows: the default, permissions and one row
|
|
7
|
-
// per agent. These saves are per user (/agent-prefs); only the default is scoped.
|
|
8
|
-
type Row = { cmd: string; name: string; installed: boolean; bypass: boolean; enabled: boolean; permissions: string; command: string; args: string; env: string[]; preview: string };
|
|
9
|
-
type View = { permissions: string; envWorks: boolean; agents: Row[] };
|
|
10
|
-
|
|
11
|
-
// Open rows survive the redraw each save does.
|
|
12
|
-
const open = new Set<string>();
|
|
13
|
-
const MODES = [["own", "Each agent's own settings"], ["bypass", "Bypass every permission prompt"]];
|
|
14
|
-
|
|
15
|
-
const bar = (id: string, vals: [string, string][], on: string, off = false) =>
|
|
16
|
-
html`<span class="bar" id="${id}" role="group">${vals.map(([v, l]) => html`<button type="button" data-v="${v}" class="${v === on ? "on" : ""}" aria-pressed="${String(v === on)}"${off ? " disabled" : ""}>${l}</button>`)}</span>`;
|
|
17
|
-
|
|
18
|
-
function agentRow(a: Row, view: View, def: string) {
|
|
19
|
-
const id = "ag-" + a.cmd;
|
|
20
|
-
const allMode = MODES.find(([v]) => v === view.permissions)![1];
|
|
21
|
-
return html`<div class="ag${a.installed ? "" : " gone"}" data-q="${[a.name, a.cmd, "agent installed command arguments environment permissions"].join(" ").toLowerCase()}">
|
|
22
|
-
<div class="ag-h">
|
|
23
|
-
<img class="ag-i" src="${AGENT_FAVICONS[a.cmd] ?? ""}" alt="" width="28" height="28">
|
|
24
|
-
<span class="ag-n"><b>${a.name}</b><code>${a.command || a.cmd}</code></span>
|
|
25
|
-
${a.installed ? "" : html`<span class="hint">Not installed</span>`}
|
|
26
|
-
${bar(id + "-on", [["true", "Enabled"], ["false", "Disabled"]], String(a.enabled))}
|
|
27
|
-
<button type="button" class="btn" id="${id}-def" aria-pressed="${String(def === a.cmd)}"${!a.enabled || !a.installed ? " disabled" : ""}>${def === a.cmd ? "✓ Default" : "Default"}</button>
|
|
28
|
-
<button type="button" class="ib ag-more" id="${id}-more" aria-expanded="${String(open.has(a.cmd))}" aria-controls="${id}-b" aria-label="Details for ${a.name}">${ico("chev")}</button>
|
|
29
|
-
</div>
|
|
30
|
-
<div class="ag-b" id="${id}-b"${open.has(a.cmd) ? "" : " hidden"}>
|
|
31
|
-
<label id="${id}-pl">Permissions</label>
|
|
32
|
-
${a.bypass ? html`<select class="sel" id="${id}-perm" aria-labelledby="${id}-pl">${[["all", `Same as all agents · ${allMode}`], ["own", `Use ${a.name}'s own settings`], ["bypass", "Bypass every permission prompt"]].map(([v, l]) => html`<option value="${v}"${v === a.permissions ? " selected" : ""}>${l}</option>`)}</select>` : html`<p class="hint">${a.name} has no bypass mode, so it uses its own settings.</p>`}
|
|
33
|
-
<label for="${id}-cmd">Command</label>
|
|
34
|
-
<input class="sel" id="${id}-cmd" value="${a.command}" placeholder="${a.cmd}" spellcheck="false" autocomplete="off">
|
|
35
|
-
<label for="${id}-args">Arguments</label>
|
|
36
|
-
<input class="sel" id="${id}-args" value="${a.args}" placeholder="No default arguments" spellcheck="false" autocomplete="off">
|
|
37
|
-
<label>Environment</label>
|
|
38
|
-
${a.env.map((k) => html`<div class="ag-env"><code>${k}=•••</code><button type="button" class="btn" data-rm="${k}" data-agent="${a.cmd}">Remove</button></div>`)}
|
|
39
|
-
<div class="ag-add"><input class="sel" id="${id}-ek" placeholder="NAME" aria-label="Variable name" spellcheck="false" autocomplete="off"><input class="sel" id="${id}-ev" type="password" placeholder="value" aria-label="Variable value" autocomplete="new-password"><button type="button" class="btn" id="${id}-ea">Add</button></div>
|
|
40
|
-
<p class="hint">Don't store secrets here: values are saved as plain text in ~/.kaizen/agents.json and are visible in the process list while the agent runs.${view.envWorks ? "" : " Not applied on Windows yet."}</p>
|
|
41
|
-
<label>Launch line</label>
|
|
42
|
-
<pre>${a.preview}</pre>
|
|
43
|
-
</div>
|
|
44
|
-
</div>`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function agentRows(view: View, def: string, scopeName: string) {
|
|
48
|
-
const usable = view.agents.filter((a) => a.enabled && a.installed);
|
|
49
|
-
const seen = view.agents.filter((a) => a.installed).length;
|
|
50
|
-
return html`<h3 class="sg">Default agent</h3><div class="sgrp"><div class="srow" data-q="default agent auto tool launches ${usable.map((a) => a.name).join(" ").toLowerCase()}"><label id="ag-def-l">Default for new agents${scopeName ? ` in ${scopeName}` : ""}</label>
|
|
51
|
-
<div class="achips" role="group" aria-labelledby="ag-def-l">${[{ cmd: "auto", name: "Auto" }, ...usable].map((a) => html`<button type="button" data-def="${a.cmd}" class="${a.cmd === def ? "on" : ""}" aria-pressed="${String(a.cmd === def)}">${AGENT_FAVICONS[a.cmd] ? html`<img src="${AGENT_FAVICONS[a.cmd]}" alt="" width="16" height="16">` : ""}${a.name}${a.cmd === def ? " ✓" : ""}</button>`)}</div></div></div>
|
|
52
|
-
<h3 class="sg">Permissions</h3><div class="sgrp"><div class="srow" data-q="permissions bypass yolo all agents without asking"><label for="ag-perm">All agents</label>
|
|
53
|
-
<select class="sel" id="ag-perm">${MODES.map(([v, l]) => html`<option value="${v}"${v === view.permissions ? " selected" : ""}>${l}</option>`)}</select>
|
|
54
|
-
<p class="hint">What every agent may do without asking, for all your projects. You can set one agent differently below. Cards show when a run uses bypass.</p></div></div>
|
|
55
|
-
<h3 class="sg">Installed · ${seen} detected <button type="button" id="ag-refresh">Refresh</button></h3><div class="sgrp">${view.agents.map((a) => agentRow(a, view, def))}</div>`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function wireAgents(redraw: () => Promise<unknown>, scope: string | null) {
|
|
59
|
-
const root = $("pbody");
|
|
60
|
-
const save = async (patch: object) => {
|
|
61
|
-
const j = await post("/agent-prefs", patch);
|
|
62
|
-
toast(j.error ? j.error : "Saved");
|
|
63
|
-
await redraw();
|
|
64
|
-
};
|
|
65
|
-
const setDefault = async (cmd: string) => {
|
|
66
|
-
const j = await post("/settings", { key: "agent.default", value: cmd, scope });
|
|
67
|
-
toast(j.ok ? "Saved" : j.error || "Could not save");
|
|
68
|
-
await redraw();
|
|
69
|
-
};
|
|
70
|
-
root.querySelectorAll<HTMLElement>("[data-def]").forEach((b) => (b.onclick = () => setDefault(b.dataset.def!)));
|
|
71
|
-
$("ag-refresh").onclick = () => redraw();
|
|
72
|
-
$("ag-perm").onchange = (e) => {
|
|
73
|
-
const v = e.target.value;
|
|
74
|
-
if (v === "bypass" && !confirm("Agents will run commands without asking, in every project. Turn on bypass?")) return redraw();
|
|
75
|
-
save({ permissions: v });
|
|
76
|
-
};
|
|
77
|
-
root.querySelectorAll<HTMLElement>("[data-rm]").forEach((b) => (b.onclick = () => save({ agent: b.dataset.agent, envRemove: b.dataset.rm })));
|
|
78
|
-
root.querySelectorAll<HTMLElement>(".ag-more").forEach((b) => (b.onclick = () => {
|
|
79
|
-
const cmd = b.id.slice(3, -5), body = $(`ag-${cmd}-b`);
|
|
80
|
-
body.hidden = !body.hidden;
|
|
81
|
-
b.setAttribute("aria-expanded", String(!body.hidden));
|
|
82
|
-
body.hidden ? open.delete(cmd) : open.add(cmd);
|
|
83
|
-
}));
|
|
84
|
-
root.querySelectorAll<HTMLElement>(".ag-h [id$='-on'] [data-v]").forEach((b) => (b.onclick = () => {
|
|
85
|
-
const cmd = b.parentElement!.id.slice(3, -3);
|
|
86
|
-
save({ agent: cmd, enabled: b.dataset.v === "true" });
|
|
87
|
-
}));
|
|
88
|
-
root.querySelectorAll<HTMLElement>("[id$='-def'].btn").forEach((b) => (b.onclick = () => setDefault(b.id.slice(3, -4))));
|
|
89
|
-
root.querySelectorAll<HTMLInputElement>("input[id$='-cmd']").forEach((i) => (i.onchange = () => save({ agent: i.id.slice(3, -4), command: i.value })));
|
|
90
|
-
root.querySelectorAll<HTMLInputElement>("input[id$='-args']").forEach((i) => (i.onchange = () => save({ agent: i.id.slice(3, -5), args: i.value })));
|
|
91
|
-
root.querySelectorAll<HTMLSelectElement>("select[id$='-perm']").forEach((s) => {
|
|
92
|
-
if (s.id === "ag-perm") return;
|
|
93
|
-
s.onchange = () => {
|
|
94
|
-
if (s.value === "bypass" && !confirm("This agent will run commands without asking. Turn on bypass?")) return redraw();
|
|
95
|
-
save({ agent: s.id.slice(3, -5), agentPermissions: s.value });
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
root.querySelectorAll<HTMLElement>("[id$='-ea']").forEach((b) => (b.onclick = () => {
|
|
99
|
-
const cmd = b.id.slice(3, -3), k = $(`ag-${cmd}-ek`) as HTMLInputElement, v = $(`ag-${cmd}-ev`) as HTMLInputElement;
|
|
100
|
-
if (k.value.trim()) save({ agent: cmd, envName: k.value.trim(), envValue: v.value });
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { post } from "./api.ts";
|
|
2
|
-
import { $, html, raw, toggleSwitch } from "./dom.ts";
|
|
3
|
-
import { toast } from "./toast.ts";
|
|
4
|
-
|
|
5
|
-
// Settings → Automations: schedules that start a run in this project. /automations
|
|
6
|
-
// answers for the page's project; the server makes every decision, this only draws and posts.
|
|
7
|
-
type Hist = { fire: string; at: number; kind: string; status: string; reason?: string; run?: string };
|
|
8
|
-
type Rule = { id: string; name: string; text: string; cron: string; kind: string; enabled: boolean; agent?: string; precheck?: string; precheck_timeout: number; grace_minutes: number; next: number | null; history: Hist[] };
|
|
9
|
-
export type Auto = { zone: string; cap: number; project: string; agents: { cmd: string; name: string }[]; rules: Rule[] };
|
|
10
|
-
|
|
11
|
-
// The form survives the redraw every change event causes.
|
|
12
|
-
const draft: Record<string, string> = { kind: "daily", time: "09:00", day: "mon", grace_minutes: "720", precheck_timeout: "60" };
|
|
13
|
-
let editing = "";
|
|
14
|
-
const when = (t: number) => new Date(t).toLocaleString([], { weekday: "short", hour: "2-digit", minute: "2-digit", day: "numeric", month: "short" });
|
|
15
|
-
const SCHEDULE: Record<string, string> = { hourly: "Every hour", daily: "Every day", weekdays: "Weekdays", weekly: "Every week", cron: "Cron" };
|
|
16
|
-
const f = (k: string) => draft[k] ?? "";
|
|
17
|
-
|
|
18
|
-
const hist = (h: Hist) => html`<li><time>${when(h.at)}</time> · ${h.kind} · <b>${h.status.replace(/_/g, " ")}</b>${h.reason ? html` · ${h.reason}` : ""}${h.run ? html` · <code>${h.run}</code>` : ""}</li>`;
|
|
19
|
-
|
|
20
|
-
const row = (r: Rule) => html`<div class="sk" data-q="${["automation", r.name, r.text, r.cron].join(" ").toLowerCase()}">
|
|
21
|
-
<div class="sk-h"><span class="sk-n"><b>${r.name}</b><span>${SCHEDULE[r.kind]} · <code>${r.cron}</code> · ${r.enabled ? (r.next ? "next " + when(r.next) : "never") : "paused"}</span></span>
|
|
22
|
-
<button type="button" class="btn" data-auto="run" data-id="${r.id}">Run now</button>
|
|
23
|
-
<button type="button" class="btn" data-auto="edit" data-id="${r.id}">Edit</button>
|
|
24
|
-
<button type="button" class="btn" data-auto="delete" data-id="${r.id}">Delete</button>
|
|
25
|
-
${toggleSwitch(r.enabled, { sm: true, attrs: { "data-auto": r.enabled ? "pause" : "resume", "data-id": r.id, "aria-label": r.name, title: r.enabled ? "On" : "Paused" } })}</div>
|
|
26
|
-
<div class="sk-a"><span>${r.text.length > 140 ? r.text.slice(0, 140) + "…" : r.text}</span></div>
|
|
27
|
-
${r.history.length ? html`<details class="sk-a"><summary>History (${r.history.length})</summary><ul>${r.history.map(hist)}</ul></details>` : ""}
|
|
28
|
-
</div>`;
|
|
29
|
-
|
|
30
|
-
const field = (label: string, id: string, ctl: unknown) => html`<label class="sk-n" style="display:block;margin-top:8px"><span style="display:block">${label}</span>${ctl}</label>`;
|
|
31
|
-
const input = (k: string, attrs = "") => html`<input class="sel" data-f="${k}" value="${f(k)}" ${raw(attrs)} spellcheck="false" autocomplete="off" style="width:100%">`;
|
|
32
|
-
|
|
33
|
-
const form = (d: Auto) => html`<div class="sk" data-q="automation new create add schedule">
|
|
34
|
-
<div class="sk-n"><b>${editing ? "Edit automation" : "New automation"}</b><span>Project: ${d.project}. Times are ${d.zone}, this computer's. One board per project: runs start only while a board is open.</span></div>
|
|
35
|
-
<p class="hint" role="alert" style="color:var(--warn)">Warning: an automation runs unattended in auto mode. It plans, builds and reviews with nobody watching, so it changes code in this project and spends tokens. It stops at the final approval only if your approval settings say so. At most ${d.cap} runs a day, and one open run at a time.</p>
|
|
36
|
-
${field("Name", "name", input("name", 'maxlength="60"'))}
|
|
37
|
-
${field("Request (what each run should do)", "text", html`<textarea class="sel" data-f="text" rows="3" style="width:100%">${f("text")}</textarea>`)}
|
|
38
|
-
${field("Schedule", "kind", html`<select class="sel" data-f="kind" style="width:100%">${Object.entries(SCHEDULE).map(([k, v]) => html`<option value="${k}"${f("kind") === k ? " selected" : ""}>${v}</option>`)}</select>`)}
|
|
39
|
-
${f("kind") === "cron" ? field("Cron (minute hour day month weekday)", "cron", input("cron", 'placeholder="0 9 * * 1-5"')) : html`${field(f("kind") === "hourly" ? "At minute (uses the minutes of HH:MM)" : "Time (HH:MM)", "time", input("time", 'placeholder="09:00"'))}${f("kind") === "weekly" ? field("Day", "day", html`<select class="sel" data-f="day" style="width:100%">${["mon", "tue", "wed", "thu", "fri", "sat", "sun"].map((x) => html`<option${f("day") === x ? " selected" : ""}>${x}</option>`)}</select>`) : ""}`}
|
|
40
|
-
${field("Agent", "agent", html`<select class="sel" data-f="agent" style="width:100%"><option value="">Project default</option>${d.agents.map((a) => html`<option value="${a.cmd}"${f("agent") === a.cmd ? " selected" : ""}>${a.name}</option>`)}</select>`)}
|
|
41
|
-
${field("Check before each scheduled run (optional shell command; exit 0 continues)", "precheck", input("precheck", 'placeholder="git fetch -q && test -n "$(git log --since=7.days -1)""'))}
|
|
42
|
-
<p class="hint">Runs on this computer, in the project folder, every time this fires. Not run by Run now.</p>
|
|
43
|
-
${field("Check time limit (seconds)", "precheck_timeout", input("precheck_timeout", 'inputmode="numeric"'))}
|
|
44
|
-
${field("Late start allowed (minutes after the due time)", "grace_minutes", input("grace_minutes", 'inputmode="numeric"'))}
|
|
45
|
-
<div class="sk-a"><button type="button" class="btn pri" data-auto="save">${editing ? "Save" : "Create"}</button>${editing ? html`<button type="button" class="btn" data-auto="cancel">Cancel</button>` : ""}</div>
|
|
46
|
-
</div>`;
|
|
47
|
-
|
|
48
|
-
export const automationRows = (d: Auto) => html`<h3 class="sg">Automations</h3><div class="sgrp">${d.rules.map(row)}${form(d)}</div>`;
|
|
49
|
-
|
|
50
|
-
export function wireAutomations(d: Auto, redraw: () => Promise<unknown>) {
|
|
51
|
-
$("pbody").querySelectorAll<HTMLInputElement>("[data-f]").forEach((el) => {
|
|
52
|
-
el.oninput = () => { draft[el.dataset.f!] = el.value; };
|
|
53
|
-
el.onchange = () => { draft[el.dataset.f!] = el.value; if (el.dataset.f === "kind") redraw(); };
|
|
54
|
-
});
|
|
55
|
-
$("pbody").querySelectorAll<HTMLElement>("[data-auto]").forEach((b) => (b.onclick = async () => {
|
|
56
|
-
const op = b.dataset.auto!, id = b.dataset.id ?? "";
|
|
57
|
-
if (op === "edit") {
|
|
58
|
-
const r = d.rules.find((x) => x.id === id)!;
|
|
59
|
-
editing = id;
|
|
60
|
-
Object.assign(draft, { name: r.name, text: r.text, kind: r.kind, cron: r.cron, agent: r.agent ?? "", precheck: r.precheck ?? "", precheck_timeout: String(r.precheck_timeout), grace_minutes: String(r.grace_minutes), time: "09:00", day: "mon" });
|
|
61
|
-
return void redraw();
|
|
62
|
-
}
|
|
63
|
-
if (op === "cancel") { editing = ""; return void redraw(); }
|
|
64
|
-
if (op === "delete" && !confirm("Delete this automation and its history?")) return;
|
|
65
|
-
const j = await post("/automations", op === "save" ? { op: editing ? "update" : "create", id: editing, ...draft } : { op, id });
|
|
66
|
-
if (j.error) return toast(j.error);
|
|
67
|
-
if (op === "save") { editing = ""; for (const k of ["name", "text", "cron", "agent", "precheck"]) delete draft[k]; toast("Saved"); }
|
|
68
|
-
else if (op === "run") toast(j.ok ? "Started" : (j.status ?? "not started").replace(/_/g, " ") + (j.why ? ": " + j.why : ""));
|
|
69
|
-
await redraw();
|
|
70
|
-
}));
|
|
71
|
-
}
|