kaizen-agent 1.85.2 → 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/rea.ts +99 -11
- package/cli/settings.ts +16 -17
- package/cli/state.ts +15 -29
- package/cli/task-service.ts +114 -34
- package/cli/tasks.ts +8 -2
- 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 +197 -61
- package/package.json +21 -4
- package/skills/kaizen/spec.md +12 -4
- package/skills/optional/disk-cleanup/SKILL.md +60 -0
- package/skills/optional/disk-cleanup/skill.json +1 -0
- package/skills/optional/disk-cleanup/tui.py +90 -0
- 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/term-paste.ts +10 -0
- package/web/{term.ts → term/term.ts} +101 -27
- 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 -86
- 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 -615
- 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 -500
- package/web/notebook.js +0 -514
- package/web/notebook.ts +0 -1254
- package/web/popup.html +0 -141
- package/web/video.js +0 -570
- /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/board/annotate.ts
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
// The Browser tab's annotator, board side: the toolbar, the notes list, the settings and the
|
|
2
|
-
// conversation with the page. The page is served by the board's proxy on another origin
|
|
3
|
-
// (cli/annotate-proxy.ts) and runs web/annotate.js; the two talk only by postMessage, and this
|
|
4
|
-
// side accepts a message only from the frame window, from the proxy's origin, with the token the
|
|
5
|
-
// proxy handed out when it was opened. Notes live here (and in localStorage, without crops).
|
|
6
|
-
import { html, raw } from "./dom.ts";
|
|
7
|
-
import { post } from "./api.ts";
|
|
8
|
-
import { toast } from "./toast.ts";
|
|
9
|
-
import { ico } from "./dom.ts";
|
|
10
|
-
import { accept, acceptHost, mapUrl, safeCrop, MAX_BOARD_NOTES } from "./annotate-lib.ts";
|
|
11
|
-
|
|
12
|
-
type Note = Record<string, any> & { id: string; n: number };
|
|
13
|
-
type Settings = { mode: string; level: string; components: boolean; color: string; clear: boolean; block: boolean };
|
|
14
|
-
const DEFAULTS: Settings = { mode: "element", level: "standard", components: true, color: "#3c82f7", clear: false, block: true };
|
|
15
|
-
const MODES: [string, string, string][] = [["element", "Element", "Click an element"], ["text", "Text", "Select text on the page"], ["multi", "Multi", "Shift not needed: click several, then Enter"], ["area", "Area", "Drag a rectangle"]];
|
|
16
|
-
|
|
17
|
-
const read = <T>(k: string, d: T): T => { try { return { ...d, ...JSON.parse(localStorage.getItem(k) || "{}") }; } catch { return d; } };
|
|
18
|
-
const write = (k: string, v: unknown) => { try { localStorage.setItem(k, JSON.stringify(v)); } catch { /* private window */ } };
|
|
19
|
-
|
|
20
|
-
export type Annotator = {
|
|
21
|
-
proxied(): boolean;
|
|
22
|
-
active(): boolean;
|
|
23
|
-
// Open this address through the proxy; returns the address for the frame, or null to load it directly.
|
|
24
|
-
open(u: string): Promise<string | null>;
|
|
25
|
-
closeProxy(): void;
|
|
26
|
-
toggle(): void;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export function annotator(o: {
|
|
30
|
-
host: HTMLElement; frame: HTMLIFrameElement | HTMLElement; wsKey: string; run: () => { dir: string; id: string } | null; onLocation: (u: string) => void; reload: () => void; button: HTMLElement;
|
|
31
|
-
}): Annotator {
|
|
32
|
-
const sk = "kz-annotate", nk = "kz-ann:" + o.wsKey;
|
|
33
|
-
const S: Settings = read(sk, DEFAULTS);
|
|
34
|
-
let on = false, hide = false, pause = false, want = false, listOpen = false;
|
|
35
|
-
let px: { origin: string; token: string; target: string } | null = null;
|
|
36
|
-
let notes: Note[] = [];
|
|
37
|
-
try { notes = JSON.parse(localStorage.getItem(nk) || "[]"); } catch { /* none */ }
|
|
38
|
-
let counter = notes.reduce((m, n) => Math.max(m, n.n), 0);
|
|
39
|
-
|
|
40
|
-
const bar = document.createElement("div");
|
|
41
|
-
bar.className = "annbar";
|
|
42
|
-
bar.hidden = true;
|
|
43
|
-
const side = document.createElement("div");
|
|
44
|
-
side.className = "annlist";
|
|
45
|
-
side.hidden = true;
|
|
46
|
-
// Both float over the page (board.html .annrow): a dark pill bottom-right, a notes panel on the right.
|
|
47
|
-
const rowEl = o.frame.parentElement!;
|
|
48
|
-
rowEl.append(side, bar);
|
|
49
|
-
|
|
50
|
-
// The Browser tab is an iframe, or in the desktop app a <webview> (talks over IPC, not postMessage).
|
|
51
|
-
const web = o.frame.tagName === "WEBVIEW" ? (o.frame as any) : null;
|
|
52
|
-
const frameWin = () => (o.frame as HTMLIFrameElement).contentWindow;
|
|
53
|
-
const say = (m: Record<string, unknown>) => {
|
|
54
|
-
if (!px) return;
|
|
55
|
-
const msg = { kz: 1, t: px.token, ...m };
|
|
56
|
-
if (web) { try { web.send("kz-ann", msg); } catch { /* not loaded yet: the page says ready when it is */ } } else frameWin()?.postMessage(msg, px.origin);
|
|
57
|
-
};
|
|
58
|
-
const cfg = () => ({ on, mode: S.mode, hide, block: S.block, color: S.color, components: S.components });
|
|
59
|
-
const markers = () => notes.map((n) => ({ n: n.n, kind: n.kind, selector: n.selector, items: n.items, pb: n.pb, page: n.page, comment: n.comment, intent: n.intent, severity: n.severity }));
|
|
60
|
-
const push = () => { say({ type: "config", cfg: { ...cfg(), pause } }); say({ type: "markers", list: markers() }); };
|
|
61
|
-
const save = () => write(nk, notes.map(({ crop, ...n }) => n));
|
|
62
|
-
const forServer = () => notes.map((n) => ({ ...n }));
|
|
63
|
-
|
|
64
|
-
function draw() {
|
|
65
|
-
const show = !!px;
|
|
66
|
-
bar.hidden = !show;
|
|
67
|
-
side.hidden = !show || !listOpen;
|
|
68
|
-
rowEl.classList.toggle("lst", show && listOpen);
|
|
69
|
-
o.button.classList.toggle("on", want);
|
|
70
|
-
if (!px) return;
|
|
71
|
-
// Icon buttons in one dark pill, as in Agentation: modes, then pause, markers, copy, send, clear, notes, settings, close.
|
|
72
|
-
const b = (id: string, icon: string, title: string, active = false, disabled = false, badge = 0) =>
|
|
73
|
-
html`<button type="button" data-a="${id}" title="${title}" aria-label="${title}" class="${active ? "on" : ""}"${raw(disabled ? " disabled" : "")}>${ico(icon)}${badge ? html`<i class="cnt">${badge}</i>` : ""}</button>`;
|
|
74
|
-
const mode = (id: string, icon: string, t: string) => b("mode:" + id, icon, t, on && S.mode === id);
|
|
75
|
-
bar.textContent = "";
|
|
76
|
-
bar.insertAdjacentHTML("beforeend", String(html`${mode("element", "a-pick", "Pick an element")}${mode("text", "a-text", "Select text")}${mode("multi", "a-multi", "Pick several elements")}${mode("area", "a-area", "Drag an area")}<span class="sep"></span>${b("pause", "a-pause", "Freeze animations (P)", pause)}${b("hide", "eye", "Show or hide markers (H)", !hide)}${b("copy", "a-copy", "Copy notes as markdown (C)", false, !notes.length)}${b("send", "send", "Type the notes into this run's agent (S)", false, !notes.length)}${b("clear", "trash", "Remove all notes (X)", false, !notes.length)}<span class="sep"></span>${b("list", "note", "Notes list", listOpen, false, notes.length)}${b("set", "gear", "Output detail, colour, behaviour", !!settings)}${b("off", "x", "Close the annotator (the Annotate button brings it back)")}`));
|
|
77
|
-
side.textContent = "";
|
|
78
|
-
if (!notes.length) side.insertAdjacentHTML("beforeend", String(html`<p class="annempty">No notes yet. Pick something on the page and write what should change.</p>`));
|
|
79
|
-
for (const n of notes) {
|
|
80
|
-
side.insertAdjacentHTML("beforeend", String(html`<div class="ann" data-n="${n.n}"><b class="annn${n.kind === "multi" || n.kind === "area" ? " g" : ""}">${n.n}</b><div class="annb"><div class="annc" contenteditable="plaintext-only" spellcheck="false" data-a="edit">${n.comment}</div><code>${n.selector}</code><small>${n.intent} · ${n.severity}${n.crop ? "" : " · no crop"}</small>${raw(n.crop ? `<img alt="crop" src="${n.crop}">` : "")}</div><button type="button" data-a="del" title="Delete" aria-label="Delete">×</button></div>`));
|
|
81
|
-
}
|
|
82
|
-
if (settings) side.prepend(settings);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
let settings: HTMLElement | null = null;
|
|
86
|
-
function drawSettings() {
|
|
87
|
-
if (!settings) return;
|
|
88
|
-
settings.textContent = "";
|
|
89
|
-
settings.insertAdjacentHTML("beforeend", String(html`<label>Output detail <select data-s="level">${raw(["compact", "standard", "detailed", "forensic"].map((l) => `<option${l === S.level ? " selected" : ""}>${l}</option>`).join(""))}</select></label><label><input type="checkbox" data-s="components"${raw(S.components ? " checked" : "")}> Component names</label><label>Marker colour <input type="color" data-s="color" value="${S.color}"></label><label><input type="checkbox" data-s="clear"${raw(S.clear ? " checked" : "")}> Clear after copy or send</label><label><input type="checkbox" data-s="block"${raw(S.block ? " checked" : "")}> Block page clicks while picking</label>`));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async function copy() {
|
|
93
|
-
if (!notes.length) return;
|
|
94
|
-
const r = await post("/annotate/format", { notes: notes.map(({ crop, ...n }) => n), level: S.level, components: S.components });
|
|
95
|
-
if (!r?.ok) return;
|
|
96
|
-
try { await navigator.clipboard.writeText(r.text); } catch { say({ type: "copy", text: r.text }); }
|
|
97
|
-
toast(`Copied ${notes.length} note${notes.length === 1 ? "" : "s"}`);
|
|
98
|
-
if (S.clear) clear();
|
|
99
|
-
}
|
|
100
|
-
async function sendNotes() {
|
|
101
|
-
const run = o.run();
|
|
102
|
-
if (!run) return void toast("Open this run's agent first: there is nothing to send to.");
|
|
103
|
-
if (!notes.length) return;
|
|
104
|
-
const r = await post("/annotate/send", { dir: run.dir, id: run.id, notes: forServer(), level: S.level, components: S.components });
|
|
105
|
-
if (!r?.ok) return;
|
|
106
|
-
toast(`Sent ${r.sent} note${r.sent === 1 ? "" : "s"} to the agent${r.crops ? `, ${r.crops} crop${r.crops === 1 ? "" : "s"} saved` : ""}`);
|
|
107
|
-
if (S.clear) clear();
|
|
108
|
-
}
|
|
109
|
-
function clear() { notes = []; save(); say({ type: "markers", list: [] }); draw(); }
|
|
110
|
-
function setMode(m: string) { S.mode = m; on = true; write(sk, S); push(); draw(); }
|
|
111
|
-
|
|
112
|
-
const act = (a: string) => {
|
|
113
|
-
if (a.startsWith("mode:")) return on && S.mode === a.slice(5) ? (on = false, push(), draw()) : setMode(a.slice(5));
|
|
114
|
-
if (a === "pick") { on = !on; push(); draw(); }
|
|
115
|
-
else if (a === "pause") { pause = !pause; push(); draw(); }
|
|
116
|
-
else if (a === "hide") { hide = !hide; push(); draw(); }
|
|
117
|
-
else if (a === "copy") void copy();
|
|
118
|
-
else if (a === "send") void sendNotes();
|
|
119
|
-
else if (a === "clear") clear();
|
|
120
|
-
else if (a === "list") { listOpen = !listOpen; draw(); }
|
|
121
|
-
else if (a === "set") { settings = settings ? null : document.createElement("div"); if (settings) { settings.className = "annset"; listOpen = true; } drawSettings(); draw(); }
|
|
122
|
-
else if (a === "off") { want = false; on = false; pause = false; listOpen = false; px = null; draw(); o.reload(); }
|
|
123
|
-
};
|
|
124
|
-
bar.onclick = (e) => { const a = (e.target as Element).closest<HTMLElement>("[data-a]")?.dataset.a; if (a) act(a); };
|
|
125
|
-
side.onclick = (e) => {
|
|
126
|
-
const t = e.target as Element;
|
|
127
|
-
const row = t.closest<HTMLElement>(".ann");
|
|
128
|
-
if (t.closest("[data-a=del]") && row) { notes = notes.filter((n) => String(n.n) !== row.dataset.n); save(); say({ type: "markers", list: markers() }); draw(); }
|
|
129
|
-
};
|
|
130
|
-
side.addEventListener("focusout", (e) => {
|
|
131
|
-
const c = (e.target as HTMLElement).closest?.<HTMLElement>("[data-a=edit]");
|
|
132
|
-
const row = c?.closest<HTMLElement>(".ann");
|
|
133
|
-
const n = row && notes.find((x) => String(x.n) === row.dataset.n);
|
|
134
|
-
if (c && n && c.textContent!.trim() && c.textContent!.trim() !== n.comment) { n.comment = c.textContent!.trim(); save(); }
|
|
135
|
-
});
|
|
136
|
-
side.addEventListener("change", (e) => {
|
|
137
|
-
const el = e.target as HTMLInputElement, k = el.dataset.s as keyof Settings | undefined;
|
|
138
|
-
if (!k) return;
|
|
139
|
-
(S as any)[k] = el.type === "checkbox" ? el.checked : el.value;
|
|
140
|
-
write(sk, S);
|
|
141
|
-
if (k === "color") push();
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// Keys on the board's own side (the page forwards the same ones from inside the frame).
|
|
145
|
-
const keyAct = (k: string) => {
|
|
146
|
-
if (k === "toggle") return act("pick");
|
|
147
|
-
if (!on) return;
|
|
148
|
-
if (k === "p") act("pause"); else if (k === "h") act("hide"); else if (k === "c") act("copy"); else if (k === "s") act("send"); else if (k === "x") act("clear");
|
|
149
|
-
else if (k === "esc") act("pick");
|
|
150
|
-
};
|
|
151
|
-
const onKey = (e: KeyboardEvent) => {
|
|
152
|
-
if (!px || !o.host.isConnected) return;
|
|
153
|
-
const t = e.target as HTMLElement;
|
|
154
|
-
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key.toLowerCase() === "f") { e.preventDefault(); return keyAct("toggle"); }
|
|
155
|
-
if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)) || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
156
|
-
const k = e.key.toLowerCase();
|
|
157
|
-
if (k === "escape") keyAct("esc"); else if ("phcsx".includes(k) && k.length === 1) keyAct(k);
|
|
158
|
-
};
|
|
159
|
-
addEventListener("keydown", onKey);
|
|
160
|
-
|
|
161
|
-
const onMsg = (e: MessageEvent) => {
|
|
162
|
-
if (!px || !o.host.isConnected) return;
|
|
163
|
-
if (!accept(e, frameWin(), px.origin, px.token)) return;
|
|
164
|
-
handle(e.data);
|
|
165
|
-
};
|
|
166
|
-
const handle = (d: any) => {
|
|
167
|
-
if (!px) return;
|
|
168
|
-
if (d.type === "ready") { on = true; push(); draw(); }
|
|
169
|
-
else if (d.type === "loc") { const u = mapUrl(String(d.href), px.origin, px.target); if (u) o.onLocation(u); }
|
|
170
|
-
else if (d.type === "key") keyAct(String(d.key));
|
|
171
|
-
else if (d.type === "marker") { side.querySelector(`[data-n="${d.n}"]`)?.scrollIntoView({ block: "nearest" }); side.querySelector(`[data-n="${d.n}"]`)?.classList.add("flash"); setTimeout(() => side.querySelector(`[data-n="${d.n}"]`)?.classList.remove("flash"), 900); }
|
|
172
|
-
else if (d.type === "note" && d.note) {
|
|
173
|
-
const n = d.note;
|
|
174
|
-
if (notes.length >= MAX_BOARD_NOTES) return;
|
|
175
|
-
const note: Note = { ...n, id: Math.random().toString(36).slice(2), n: ++counter, crop: safeCrop(n.crop), url: mapUrl(String(n.url || ""), px.origin, px.target) ?? "", page: String(n.page || "") };
|
|
176
|
-
notes.push(note);
|
|
177
|
-
save();
|
|
178
|
-
say({ type: "markers", list: markers() });
|
|
179
|
-
draw();
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
addEventListener("message", onMsg);
|
|
183
|
-
// A public site in the desktop app's webview: no proxy can add the script, so the board puts it in
|
|
184
|
-
// after each load, with this open's token (annotate.js reads __kzAnnToken). The webview's preload
|
|
185
|
-
// relays its messages; only ones carrying the token are taken (acceptHost).
|
|
186
|
-
let inject = false, src: string | null = null;
|
|
187
|
-
const injectNow = async () => {
|
|
188
|
-
if (!web || !inject || !px) return;
|
|
189
|
-
try { px.origin = px.target = new URL(web.getURL()).origin; } catch { /* about:blank */ }
|
|
190
|
-
src ??= await fetch("/annotate.js").then((r) => (r.ok ? r.text() : null), () => null);
|
|
191
|
-
if (!src || !inject || !px) return;
|
|
192
|
-
web.executeJavaScript(`window.__kzAnnToken=${JSON.stringify(px.token)};\n${src}`).catch(() => {});
|
|
193
|
-
};
|
|
194
|
-
web?.addEventListener("dom-ready", () => void injectNow());
|
|
195
|
-
web?.addEventListener("ipc-message", (e: any) => { if (px && o.host.isConnected && e.channel === "kz-ann" && acceptHost(e.args?.[0], px.token)) handle(e.args[0]); });
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
proxied: () => !!px,
|
|
199
|
-
active: () => on,
|
|
200
|
-
async open(u) {
|
|
201
|
-
inject = false;
|
|
202
|
-
if (want && web && /^https?:\/\//.test(u) && !/^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])(:|\/|$)/.test(u)) {
|
|
203
|
-
const token = [...crypto.getRandomValues(new Uint8Array(16))].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
204
|
-
const origin = new URL(u).origin;
|
|
205
|
-
px = { origin, token, target: origin };
|
|
206
|
-
inject = true;
|
|
207
|
-
on = false;
|
|
208
|
-
draw();
|
|
209
|
-
return null; // loaded directly; dom-ready puts the annotator in
|
|
210
|
-
}
|
|
211
|
-
if (!want || !/^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])(:|\/|$)/.test(u)) { px = null; on = false; pause = false; draw(); return null; }
|
|
212
|
-
const r = await post("/annotate/open", { url: u });
|
|
213
|
-
if (!r?.ok) { want = false; px = null; draw(); return null; }
|
|
214
|
-
px = { origin: r.origin, token: r.token, target: new URL(u).origin };
|
|
215
|
-
draw();
|
|
216
|
-
return r.url;
|
|
217
|
-
},
|
|
218
|
-
closeProxy() { px = null; inject = false; on = false; pause = false; draw(); },
|
|
219
|
-
toggle() { want = !want; o.reload(); },
|
|
220
|
-
};
|
|
221
|
-
}
|
package/web/board/api.ts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { store } from "./store.ts";
|
|
2
|
-
import { key, render } from "./cards.ts";
|
|
3
|
-
import { $, vt } from "./dom.ts";
|
|
4
|
-
import { close, taskBody, open, openRun } from "./panel.ts";
|
|
5
|
-
import { notifyUser, toast } from "./toast.ts";
|
|
6
|
-
import { openTerms, termsShowing } from "./terms.ts";
|
|
7
|
-
import { refreshBoardBadge } from "./badge.ts";
|
|
8
|
-
|
|
9
|
-
// The server writes notifier() from state.ts over a marker in board.html: one rule for both UIs.
|
|
10
|
-
declare const due: (key: string, say: string | null, done: boolean, now: number) => boolean;
|
|
11
|
-
|
|
12
|
-
// In-card agents waiting on input, by session key. null until the first /state: what is
|
|
13
|
-
// already asking when the page loads is not news, only what starts asking after.
|
|
14
|
-
let asked: Set<string> | null = null;
|
|
15
|
-
|
|
16
|
-
// Each card's column and whether it needed you, as of the last /state: a card that changed
|
|
17
|
-
// column slides to the new one, one that starts needing you flashes. null: the first load is not news.
|
|
18
|
-
let before: Map<string, [number, boolean]> | null = null;
|
|
19
|
-
|
|
20
|
-
// This page's project, sent with each request: the server keeps none, so another
|
|
21
|
-
// tab or a phone picking a project never moves this one.
|
|
22
|
-
export const dirHeader = () => (store.dir ? { "x-kz-dir": store.dir } : {});
|
|
23
|
-
let latestLoad = 0;
|
|
24
|
-
// A change event can come several times a second while agents work, and a full read and
|
|
25
|
-
// redraw blocks this thread (and any terminal in it). One quiet load per QUIET_GAP, the
|
|
26
|
-
// last change always covered; a hidden tab only watches for agents asking.
|
|
27
|
-
const QUIET_GAP = 500, HIDDEN_GAP = 5000;
|
|
28
|
-
// The last reply without its clock, and when it was last drawn: an identical reply skips
|
|
29
|
-
// the redraw, but ages and repeat notices still need one now and then.
|
|
30
|
-
const REDRAW_MS = 30_000;
|
|
31
|
-
let lastBody = "", drawnAt = 0;
|
|
32
|
-
let lastQuiet = 0;
|
|
33
|
-
let quietTimer: ReturnType<typeof setTimeout> | 0 = 0;
|
|
34
|
-
const runQuiet = () => {
|
|
35
|
-
quietTimer = 0;
|
|
36
|
-
lastQuiet = Date.now();
|
|
37
|
-
return read(true);
|
|
38
|
-
};
|
|
39
|
-
// quiet: the server said something changed, nobody asked for a redraw.
|
|
40
|
-
export function load(quiet?: boolean) {
|
|
41
|
-
if (!quiet) return read(false);
|
|
42
|
-
if (!quietTimer) quietTimer = setTimeout(runQuiet, Math.max(0, lastQuiet + (document.hidden ? HIDDEN_GAP : QUIET_GAP) - Date.now()));
|
|
43
|
-
}
|
|
44
|
-
// Back on a hidden tab: what it put off is shown now.
|
|
45
|
-
export function flushLoad() {
|
|
46
|
-
if (!document.hidden && quietTimer) { clearTimeout(quietTimer); void runQuiet(); }
|
|
47
|
-
}
|
|
48
|
-
async function read(quiet: boolean) {
|
|
49
|
-
const current = ++latestLoad;
|
|
50
|
-
let r;
|
|
51
|
-
try {
|
|
52
|
-
r = await fetch("/state" + (store.all ? "?all=1" : ""), { headers: dirHeader() });
|
|
53
|
-
} catch {
|
|
54
|
-
toast(GONE);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const text = await r.text();
|
|
58
|
-
if (current !== latestLoad) return;
|
|
59
|
-
const body = text.replace(/"now":\d+\}$/, "");
|
|
60
|
-
const same = quiet && body === lastBody && Date.now() - drawnAt < REDRAW_MS;
|
|
61
|
-
lastBody = body;
|
|
62
|
-
if (same) {
|
|
63
|
-
if (!store.all) void refreshBoardBadge();
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
drawnAt = Date.now();
|
|
67
|
-
const next = JSON.parse(text);
|
|
68
|
-
const was = store.openKey && store.S.cards.find((x) => key(x) === store.openKey);
|
|
69
|
-
store.S = next;
|
|
70
|
-
if (!store.all) void refreshBoardBadge();
|
|
71
|
-
// Home follows a project switch without the board importing it.
|
|
72
|
-
dispatchEvent(new Event("kz-state"));
|
|
73
|
-
{
|
|
74
|
-
const seen = new Map();
|
|
75
|
-
for (const c of store.S.cards) {
|
|
76
|
-
const b = key(c),
|
|
77
|
-
n = seen.get(b) || 0;
|
|
78
|
-
seen.set(b, n + 1);
|
|
79
|
-
c._k = n ? b + "#" + n : b;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
for (const c of store.S.cards) {
|
|
83
|
-
if (c.kind !== "run" || c.archived) continue;
|
|
84
|
-
if (due(key(c), c.notice, c.status === "done", store.S.now)) notifyUser(c.notice);
|
|
85
|
-
}
|
|
86
|
-
{
|
|
87
|
-
const now = new Map(store.S.cards.filter((c) => !c.archived && c.pty?.alive && c.pty.asking).map((c) => [c.pty.key, c]));
|
|
88
|
-
if (asked && document.hidden)
|
|
89
|
-
for (const [k, c] of now) if (!asked.has(k)) notifyUser(`${c.kind === "run" ? c.id : String(c.text).split("\n")[0].slice(0, 80)} needs you`, "ask:" + k);
|
|
90
|
-
asked = new Set(now.keys());
|
|
91
|
-
}
|
|
92
|
-
const need = (c) => c.status === "waiting" || !!(c.pty?.alive && c.pty.asking),
|
|
93
|
-
moved = [];
|
|
94
|
-
for (const c of before ? store.S.cards : []) {
|
|
95
|
-
const b = before.get(key(c));
|
|
96
|
-
if (b && b[0] !== c.column) moved.push(key(c));
|
|
97
|
-
if (b && !b[1] && need(c)) store.flash.add(key(c));
|
|
98
|
-
}
|
|
99
|
-
before = new Map(store.S.cards.map((c) => [key(c), [c.column, need(c)]]));
|
|
100
|
-
// The old and new element of a moved card share a view-transition-name, so the browser slides one into the other.
|
|
101
|
-
const name = () =>
|
|
102
|
-
moved.forEach((k, i) => {
|
|
103
|
-
const el = $("board").querySelector(`[data-k="${CSS.escape(k)}"]`);
|
|
104
|
-
if (el) el.style.viewTransitionName = "kzm" + i;
|
|
105
|
-
});
|
|
106
|
-
// A redraw under a form being typed in would reset its fields and its focus.
|
|
107
|
-
if (!(quiet && store.mode && $("board").querySelector(".inl input"))) {
|
|
108
|
-
name();
|
|
109
|
-
await (moved.length ? vt(() => (render(), name())) : (render(), undefined));
|
|
110
|
-
store.flash.clear();
|
|
111
|
-
} else store.flash.clear(); // no redraw now: a flash at some later one would be stale
|
|
112
|
-
if (termsShowing()) openTerms();
|
|
113
|
-
// Run on a task closed the panel: open the card on its agent once the board knows the session.
|
|
114
|
-
if (store.wantTerm && !store.openKey && !store.mode) {
|
|
115
|
-
const n = store.S.cards.find((x) => key(x) === store.wantTerm && x.pty);
|
|
116
|
-
if (n) {
|
|
117
|
-
store.wantTerm = null;
|
|
118
|
-
open(n);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (store.openKey) {
|
|
123
|
-
const c = store.S.cards.find((x) => key(x) === store.openKey),
|
|
124
|
-
nb = $("pbody").querySelector(".notes");
|
|
125
|
-
// The textarea is hidden under the rich editor: focus anywhere in the notes counts.
|
|
126
|
-
if (nb?.contains(document.activeElement)) return;
|
|
127
|
-
if (!c) {
|
|
128
|
-
if (was && was.kind === "idea") follow(was);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (store.runDoc && c.kind === "run") openRun(c, true, true);
|
|
132
|
-
else if (c.kind === "idea") taskBody(c);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
// A task's card goes when its run starts. Follow it to that run rather than keep
|
|
136
|
-
// offering "Run again": the newest run in its project whose request holds the task's
|
|
137
|
-
// text, the rule boardCards() retires it by. No such run: close the panel.
|
|
138
|
-
// ponytail: checks the five newest runs, one /run fetch each; a run that took the task
|
|
139
|
-
// further back than that closes the panel instead.
|
|
140
|
-
async function follow(task) {
|
|
141
|
-
const k = key(task),
|
|
142
|
-
norm = (s) => s.toLowerCase().replace(/\s+/g, " ").trim(),
|
|
143
|
-
t = norm(task.text);
|
|
144
|
-
for (const r of store.S.cards
|
|
145
|
-
.filter((x) => x.kind === "run" && x.state === task.state)
|
|
146
|
-
.sort((a, b) => (b.moved ?? 0) - (a.moved ?? 0))
|
|
147
|
-
.slice(0, 5)) {
|
|
148
|
-
const d = await fetch(`/run/${encodeURIComponent(r.id)}?dir=${encodeURIComponent(r.state)}`)
|
|
149
|
-
.then((x) => x.json())
|
|
150
|
-
.catch(() => null);
|
|
151
|
-
if (store.openKey !== k) return;
|
|
152
|
-
if (norm(d?.request || "").includes(t)) {
|
|
153
|
-
open(r);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (store.openKey === k) close();
|
|
158
|
-
}
|
|
159
|
-
// A tab outliving its server would otherwise swallow every click: say so.
|
|
160
|
-
const GONE = "The kaizen server is not running — start it with kaizen web (or the shortcut), then reload.";
|
|
161
|
-
export async function post(path, body) {
|
|
162
|
-
let r;
|
|
163
|
-
try {
|
|
164
|
-
r = await fetch(path, {
|
|
165
|
-
method: "POST",
|
|
166
|
-
headers: { "content-type": "application/json", ...dirHeader() },
|
|
167
|
-
body: JSON.stringify(body),
|
|
168
|
-
});
|
|
169
|
-
} catch {
|
|
170
|
-
toast(GONE);
|
|
171
|
-
return { ok: false };
|
|
172
|
-
}
|
|
173
|
-
const j = await r.json().catch(() => ({}));
|
|
174
|
-
if (!r.ok) {
|
|
175
|
-
const m = j.error || j.why || "That did not work";
|
|
176
|
-
toast(m, { title: m.slice(0, 80), what: `POST ${path} failed (HTTP ${r.status}): ${m}` });
|
|
177
|
-
if (j.manual) console.log("run manually:", j.manual);
|
|
178
|
-
}
|
|
179
|
-
return j;
|
|
180
|
-
}
|
package/web/board/approvals.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { store } from "./store.ts";
|
|
2
|
-
import { where } from "./agent-term.ts";
|
|
3
|
-
import { post } from "./api.ts";
|
|
4
|
-
import { key, via } from "./cards.ts";
|
|
5
|
-
import { $, html } from "./dom.ts";
|
|
6
|
-
import { openRun } from "./panel.ts";
|
|
7
|
-
import { askNotify, toast } from "./toast.ts";
|
|
8
|
-
|
|
9
|
-
// Resume: a run whose in-card agent ended, or one stalled with no progress, gets its agent
|
|
10
|
-
// back on the run (its conversation, where the tool can resume one), in its card.
|
|
11
|
-
export const resumable = (c) => c.status === "stalled" || !!(c.pty && !c.pty.alive);
|
|
12
|
-
export async function resume(c, b) {
|
|
13
|
-
b.disabled = true;
|
|
14
|
-
askNotify();
|
|
15
|
-
const r = await post("/resume", { dir: c.state, id: c.id });
|
|
16
|
-
if (!r.ok) {
|
|
17
|
-
b.disabled = false;
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
toast("Resumed, " + where(r) + ": " + via(r.agent));
|
|
21
|
-
if (r.pty) (store.wantTerm = key(c)), (store.wantPty = { key: r.pty, at: Date.now() });
|
|
22
|
-
if (store.openKey === key(c)) {
|
|
23
|
-
$("pfoot").innerHTML = "";
|
|
24
|
-
openRun(c, true);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export const APPROVAL = {
|
|
28
|
-
explore: "Explore brief ready.",
|
|
29
|
-
"approvals.plan": "Plan ready.",
|
|
30
|
-
"approvals.review": "Ready to check.",
|
|
31
|
-
findings: "Open findings.",
|
|
32
|
-
},
|
|
33
|
-
decided = new Set(),
|
|
34
|
-
answer = (c) => key(c) + ":" + c.awaiting + ":" + c.moved;
|
|
35
|
-
export async function decide(c, b, why, answers) {
|
|
36
|
-
b.disabled = true;
|
|
37
|
-
askNotify();
|
|
38
|
-
const r = await post("/decide", {
|
|
39
|
-
dir: c.state,
|
|
40
|
-
id: c.id,
|
|
41
|
-
awaiting: c.awaiting,
|
|
42
|
-
...(why === undefined ? {} : { why }),
|
|
43
|
-
...(answers ? { answers } : {}),
|
|
44
|
-
});
|
|
45
|
-
// A failed send keeps the footer, and with it a typed comment.
|
|
46
|
-
if (!r.ok) {
|
|
47
|
-
b.disabled = false;
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
decided.add(answer(c));
|
|
51
|
-
toast((why === undefined ? "Approved" : "Sent back") + ", " + (r.reused ? "sent to the agent already open in its workspace" : where(r) + ": " + via(r.agent)));
|
|
52
|
-
if (r.pty) (store.wantTerm = key(c)), (store.wantPty = { key: r.pty, at: Date.now() });
|
|
53
|
-
if (store.openKey === key(c)) {
|
|
54
|
-
$("pfoot").innerHTML = "";
|
|
55
|
-
openRun(c, true);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
export function confirmRevise(c) {
|
|
59
|
-
const foot = $("pfoot"),
|
|
60
|
-
plan = c.awaiting === "approvals.plan";
|
|
61
|
-
if (c.awaiting === "explore") {
|
|
62
|
-
foot.innerHTML = html`<div class="inl" style="flex:1"><label>What should we explore further?<textarea aria-label="Explore feedback"></textarea></label><button class="btn pri">Continue Explore</button></div>`;
|
|
63
|
-
foot.querySelector("button").onclick = (e) => {
|
|
64
|
-
const why = foot.querySelector("textarea").value.trim();
|
|
65
|
-
if (why) decide(c, e.target, why);
|
|
66
|
-
};
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
foot.innerHTML = html`<div class="inl" style="flex:1"><div class="q">${plan ? "What should the plan do differently?" : "What should change in the work?"}</div><div class="q dim">Opens your agent on this run with your comment.${plan ? " It revises the plan and comes back here for approval." : " It changes the work, rechecks it and comes back here."}</div><textarea aria-label="Revise comment"></textarea><div class="row"><button class="btn ghost" data-a="c">Cancel</button><button class="btn pri" data-a="s">Send back</button></div></div>`;
|
|
70
|
-
const inp = foot.querySelector("textarea");
|
|
71
|
-
inp.focus();
|
|
72
|
-
foot.querySelector("[data-a=c]").onclick = () => {
|
|
73
|
-
foot.innerHTML = "";
|
|
74
|
-
openRun(c, true);
|
|
75
|
-
};
|
|
76
|
-
foot.querySelector("[data-a=s]").onclick = (e) => {
|
|
77
|
-
const why = inp.value.trim();
|
|
78
|
-
if (!why) {
|
|
79
|
-
toast("Say what should change");
|
|
80
|
-
inp.focus();
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
decide(c, e.target, why);
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
// The plan's questions, answered with the approval: the recommended option preselected,
|
|
87
|
-
// a note for what the options miss. Each answer reaches the agent as one line.
|
|
88
|
-
export function confirmAnswers(c, qs) {
|
|
89
|
-
const foot = $("pfoot");
|
|
90
|
-
foot.innerHTML = html`<div class="inl qa" style="flex:1"><div class="q">The plan asks ${qs.length === 1 ? "one question" : qs.length + " questions"}.</div><div class="q dim">Your answers go to your agent with the approval. It records them and builds the plan.</div>${qs.map((x, i) => html`<fieldset><legend>${x.q}</legend>${x.options.map((o, j) => html`<label><input type="${x.multi ? "checkbox" : "radio"}" name="q${i}" value="${j}"${o.rec || (!x.multi && !j && !x.options.some((p) => p.rec)) ? " checked" : ""}> ${o.text}</label>`)}<input type="text" data-n="${i}" placeholder="Note (optional)" aria-label="Note: ${x.q}"></fieldset>`)}<div class="row"><button class="btn ghost" data-a="c">Cancel</button><button class="btn pri" data-a="s">Approve with these answers</button></div></div>`;
|
|
91
|
-
foot.querySelector("[data-a=c]").onclick = () => {
|
|
92
|
-
foot.innerHTML = "";
|
|
93
|
-
openRun(c, true);
|
|
94
|
-
};
|
|
95
|
-
foot.querySelector("[data-a=s]").onclick = (e) =>
|
|
96
|
-
decide(
|
|
97
|
-
c,
|
|
98
|
-
e.target,
|
|
99
|
-
undefined,
|
|
100
|
-
qs.map((x, i) => {
|
|
101
|
-
const picked =
|
|
102
|
-
[...foot.querySelectorAll(`[name=q${i}]:checked`)]
|
|
103
|
-
.map((n) => `"${x.options[+n.value].label}"`)
|
|
104
|
-
.join(", ") || "none of the options",
|
|
105
|
-
note = foot.querySelector(`[data-n="${i}"]`).value.trim();
|
|
106
|
-
return `${x.q} — ${picked}${note ? "; " + note : ""}`;
|
|
107
|
-
}),
|
|
108
|
-
);
|
|
109
|
-
}
|
package/web/board/badge.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
export type AttentionTask = {
|
|
2
|
-
id: string;
|
|
3
|
-
dir: string;
|
|
4
|
-
title: string;
|
|
5
|
-
status?: string;
|
|
6
|
-
activeRun?: string | null;
|
|
7
|
-
runs?: (string | { id: string })[];
|
|
8
|
-
runIds?: string[];
|
|
9
|
-
legacy?: { kind: string; id?: string; index?: number };
|
|
10
|
-
attention: { category: string; reason: string; action: string };
|
|
11
|
-
};
|
|
12
|
-
export let attentionTasks: AttentionTask[] | null = null;
|
|
13
|
-
export const taskForCard = (c: any, tasks = attentionTasks) =>
|
|
14
|
-
tasks?.find(
|
|
15
|
-
(t) =>
|
|
16
|
-
t.dir === c.state &&
|
|
17
|
-
(t.id === c.taskId ||
|
|
18
|
-
(c.kind === "run" &&
|
|
19
|
-
[
|
|
20
|
-
t.activeRun,
|
|
21
|
-
...(t.runs ?? t.runIds ?? []).map((r) => (typeof r === "string" ? r : r.id)),
|
|
22
|
-
...(t.legacy?.kind === "run" ? [t.legacy.id] : []),
|
|
23
|
-
].includes(c.id))),
|
|
24
|
-
);
|
|
25
|
-
export function setTaskAttention(tasks: AttentionTask[]) {
|
|
26
|
-
attentionTasks = tasks;
|
|
27
|
-
if (typeof document !== "undefined") {
|
|
28
|
-
const count = tasks.filter((t) => t.attention.category === "needs-you").length;
|
|
29
|
-
document.querySelectorAll<HTMLElement>('.rail a[data-view="tasks"]').forEach((a) => {
|
|
30
|
-
if (count) a.dataset.n = String(count);
|
|
31
|
-
else delete a.dataset.n;
|
|
32
|
-
a.title = count ? `Tasks · ${count} need you` : "Tasks";
|
|
33
|
-
a.setAttribute("aria-label", a.title);
|
|
34
|
-
});
|
|
35
|
-
dispatchEvent(new Event("kz-task-attention"));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
type BadgeCard = {
|
|
39
|
-
state?: string;
|
|
40
|
-
archived?: boolean;
|
|
41
|
-
kind: string;
|
|
42
|
-
status: string;
|
|
43
|
-
pty?: { alive: boolean; asking: boolean };
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export function waitingCount(cards: BadgeCard[], tasks = attentionTasks) {
|
|
47
|
-
if (tasks) {
|
|
48
|
-
const dirs = new Set(cards.map((c) => c.state).filter(Boolean));
|
|
49
|
-
return tasks.filter((t) => (!dirs.size || dirs.has(t.dir)) && t.attention.category === "needs-you").length;
|
|
50
|
-
}
|
|
51
|
-
return cards.filter(
|
|
52
|
-
(c) => !c.archived && ((c.kind === "run" && c.status === "waiting") || (c.pty?.alive && c.pty.asking)),
|
|
53
|
-
).length;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// The rail's Projects list draws from the same cards: one fetch feeds both.
|
|
57
|
-
export let allBoardCards: any[] | null = null;
|
|
58
|
-
|
|
59
|
-
let onCards: ((cards: any[], projects?: any[], agents?: any[]) => void) | null = null;
|
|
60
|
-
export const onBoardCards = (f: typeof onCards) => {
|
|
61
|
-
onCards = f;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export function boardBadge(cards: BadgeCard[], projects?: unknown[], agents?: unknown[]) {
|
|
65
|
-
generation++;
|
|
66
|
-
allBoardCards = cards;
|
|
67
|
-
if (typeof window !== "undefined") dispatchEvent(new Event("kz-all-cards"));
|
|
68
|
-
onCards?.(cards, projects, agents);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
let generation = 0;
|
|
72
|
-
let lastAll = "";
|
|
73
|
-
let loading = false;
|
|
74
|
-
let again = false;
|
|
75
|
-
// The badge reads every project's state (hundreds of KB), and a busy agent triggers a
|
|
76
|
-
// board refresh a couple of times a second: at most one badge read per BADGE_GAP, the
|
|
77
|
-
// last request still served when the gap ends.
|
|
78
|
-
const BADGE_GAP = 2000;
|
|
79
|
-
let lastRun = 0;
|
|
80
|
-
let waiting: ReturnType<typeof setTimeout> | undefined;
|
|
81
|
-
export async function refreshBoardBadge() {
|
|
82
|
-
if (loading) {
|
|
83
|
-
again = true;
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const gap = lastRun + BADGE_GAP - Date.now();
|
|
87
|
-
if (gap > 0) {
|
|
88
|
-
waiting ??= setTimeout(() => {
|
|
89
|
-
waiting = undefined;
|
|
90
|
-
void refreshBoardBadge();
|
|
91
|
-
}, gap);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
lastRun = Date.now();
|
|
95
|
-
loading = true;
|
|
96
|
-
do {
|
|
97
|
-
again = false;
|
|
98
|
-
const current = generation;
|
|
99
|
-
try {
|
|
100
|
-
const r = await fetch("/state?all=1");
|
|
101
|
-
if (!r.ok) continue;
|
|
102
|
-
const text = await r.text();
|
|
103
|
-
const body = text.replace(/"now":\d+\}$/, "");
|
|
104
|
-
if (body === lastAll) continue;
|
|
105
|
-
const { cards, projects, rail, agents } = JSON.parse(text);
|
|
106
|
-
if (!again && current === generation) {
|
|
107
|
-
lastAll = body;
|
|
108
|
-
boardBadge(cards, [...projects, ...(rail ?? [])], agents);
|
|
109
|
-
}
|
|
110
|
-
} catch {
|
|
111
|
-
/* keep the last count while the board is offline */
|
|
112
|
-
}
|
|
113
|
-
} while (again);
|
|
114
|
-
loading = false;
|
|
115
|
-
}
|