@kabmo-labs/kabmo 0.24.0 → 0.26.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/dist/client/index.html +1 -1
- package/dist/client/index.js +585 -512
- package/dist/client/static/js/{index-jcr5twtp.js → index-95b3n20k.js} +1105 -1207
- package/dist/client/static/js/index-p2yw9ywf.css +1 -0
- package/package.json +2 -4
- package/src/cli/lib/args.js +24 -1
- package/src/cli/lib/args.test.js +16 -0
- package/src/cli/lib/commands/session.js +233 -0
- package/src/cli/lib/commands/session.test.js +103 -0
- package/src/cli/main.js +1 -1
- package/src/client/components/common/ComposerPicker.tsx +3 -0
- package/src/client/components/common/code-surface/shiki.test.ts +82 -0
- package/src/client/components/common/code-surface/shiki.ts +28 -7
- package/src/client/components/common/session-actions-menu/index.tsx +59 -2
- package/src/client/components/common/session-branch/BranchGuides.tsx +93 -0
- package/src/client/components/common/session-branch/SubagentRow.tsx +77 -0
- package/src/client/components/common/session-branch/index.tsx +169 -0
- package/src/client/components/common/session-branch/session-branch.test.tsx +240 -0
- package/src/client/components/common/session-branch/style.ts +29 -0
- package/src/client/components/common/session-row/StatusSlot.tsx +17 -5
- package/src/client/components/common/session-row/index.tsx +28 -3
- package/src/client/components/common/session-row/session-row.test.tsx +11 -0
- package/src/client/components/common/session-state-provider/index.tsx +1 -1
- package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +70 -61
- package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -3
- package/src/client/components/layout/session-sidebar/SessionItem.test.ts +25 -2
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +35 -7
- package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +39 -198
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +114 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +128 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +56 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +44 -36
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +62 -47
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +63 -50
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +37 -12
- package/src/client/components/settings/Sidebar.tsx +1 -1
- package/src/client/components/settings/categories/NotificationSettings.test.tsx +92 -0
- package/src/client/components/settings/categories/NotificationSettings.tsx +112 -2
- package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +94 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +31 -5
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
- package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +128 -122
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +11 -5
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +10 -0
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +15 -1
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +85 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +84 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
- package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +11 -20
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +115 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
- package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
- package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
- package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
- package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
- package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
- package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
- package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
- package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
- package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
- package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
- package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
- package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
- package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
- package/src/client/data/settings/omp-schema.json +1 -1
- package/src/client/data/theme/terminal.test.ts +25 -0
- package/src/client/data/theme/terminal.ts +96 -79
- package/src/client/hooks/chat/composer/items.test.ts +31 -26
- package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
- package/src/client/hooks/chat/omp/folder-auto-expand.ts +1 -1
- package/src/client/hooks/chat/omp/pending-adoption.ts +51 -0
- package/src/client/hooks/chat/omp/pending-child.test.ts +73 -0
- package/src/client/hooks/chat/omp/pending-entry.ts +59 -0
- package/src/client/hooks/chat/omp/pending-rows.ts +6 -2
- package/src/client/hooks/chat/omp/pending-sessions.test.ts +1 -2
- package/src/client/hooks/chat/omp/pending-sessions.ts +45 -69
- package/src/client/hooks/chat/omp/pending-waiting.ts +1 -1
- package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
- package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
- package/src/client/hooks/chat/omp/run-switch.ts +1 -1
- package/src/client/hooks/chat/omp/session-list.tsx +4 -0
- package/src/client/hooks/chat/subagents/roster.ts +122 -0
- package/src/client/hooks/chat/timeline/child-spawn.test.ts +55 -0
- package/src/client/hooks/chat/timeline/child-spawn.ts +45 -0
- package/src/client/hooks/chat/timeline/fork-request.test.ts +54 -0
- package/src/client/hooks/chat/timeline/fork-request.ts +43 -0
- package/src/client/hooks/chat/timeline/mode-availability.test.ts +1 -1
- package/src/client/hooks/chat/timeline/mode-availability.ts +33 -0
- package/src/client/hooks/chat/timeline/mode-markers.ts +7 -1
- package/src/client/hooks/chat/timeline/mode-post.ts +15 -3
- package/src/client/hooks/chat/timeline/modes-contract.ts +9 -4
- package/src/client/hooks/chat/timeline/modes.test.ts +56 -18
- package/src/client/hooks/chat/timeline/modes.ts +42 -29
- package/src/client/hooks/chat/timeline/pending-branch.ts +205 -0
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +253 -0
- package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
- package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
- package/src/client/hooks/chat/timeline/send-execute.test.ts +39 -0
- package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
- package/src/client/hooks/chat/timeline/send-steer.test.ts +3 -1
- package/src/client/hooks/chat/timeline/send.test-util.ts +7 -1
- package/src/client/hooks/chat/timeline/send.test.ts +3 -1
- package/src/client/hooks/chat/timeline/send.ts +48 -133
- package/src/client/hooks/chat/timeline/session-harness.ts +6 -0
- package/src/client/hooks/chat/timeline/stop-with-queue.ts +42 -0
- package/src/client/hooks/chat/timeline/use-fork-session.ts +58 -0
- package/src/client/hooks/models/use-harness-update.test.ts +286 -0
- package/src/client/hooks/models/use-harness-update.ts +250 -0
- package/src/client/hooks/ui/input-required-alert.ts +12 -5
- package/src/client/hooks/ui/notifications.ts +45 -0
- package/src/client/hooks/ui/run-outcome-alert.ts +48 -0
- package/src/client/hooks/workspace/expanded-sessions.ts +36 -7
- package/src/client/hooks/workspace/terminal/index.ts +17 -3
- package/src/client/hooks/workspace/terminal/socket.ts +9 -4
- package/src/client/lib/native/open-session.ts +33 -0
- package/src/client/lib/notifications/os.test.ts +125 -0
- package/src/client/lib/notifications/os.ts +130 -0
- package/src/client/lib/plugins/sidebar-bridge.ts +2 -20
- package/src/client/lib/router/open-session.test.ts +75 -0
- package/src/client/lib/router/open-session.ts +34 -0
- package/src/client/lib/session-tree.test.ts +50 -0
- package/src/client/lib/session-tree.ts +59 -0
- package/src/client/lib/signals.ts +5 -1
- package/src/client/main.tsx +6 -0
- package/src/client/tailwind.css +17 -11
- package/src/server/index.ts +2 -0
- package/src/server/lib/auth/guard.ts +10 -0
- package/src/server/lib/btw/session-copy.server.ts +6 -44
- package/src/server/lib/btw/session-copy.test.ts +2 -1
- package/src/server/lib/db/schema.ts +5 -0
- package/src/server/lib/db/seed-terminal.test.ts +1 -1
- package/src/server/lib/db/seed.test.ts +1 -1
- package/src/server/lib/harness/acp/background-work.test.ts +262 -0
- package/src/server/lib/harness/acp/background-work.ts +320 -0
- package/src/server/lib/harness/acp/calls.ts +15 -1
- package/src/server/lib/harness/acp/client-capabilities.test.ts +55 -0
- package/src/server/lib/harness/acp/client-capabilities.ts +61 -0
- package/src/server/lib/harness/acp/client-fs.test.ts +135 -0
- package/src/server/lib/harness/acp/client-fs.ts +131 -0
- package/src/server/lib/harness/acp/client-initialize.test.ts +70 -0
- package/src/server/lib/harness/acp/client-initialize.ts +84 -0
- package/src/server/lib/harness/acp/client.ts +33 -23
- package/src/server/lib/harness/acp/commands.test.ts +5 -5
- package/src/server/lib/harness/acp/commands.ts +14 -2
- package/src/server/lib/harness/acp/frames-timing.test.ts +68 -0
- package/src/server/lib/harness/acp/frames-v2.test.ts +85 -0
- package/src/server/lib/harness/acp/frames.ts +71 -158
- package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
- package/src/server/lib/harness/acp/gateway-env.ts +70 -0
- package/src/server/lib/harness/acp/mapper.test.ts +40 -0
- package/src/server/lib/harness/acp/mapper.ts +12 -0
- package/src/server/lib/harness/acp/permissions.ts +6 -0
- package/src/server/lib/harness/acp/prompt.test.ts +20 -0
- package/src/server/lib/harness/acp/prompt.ts +19 -3
- package/src/server/lib/harness/acp/protocol.ts +41 -2
- package/src/server/lib/harness/acp/session-background.test.ts +129 -0
- package/src/server/lib/harness/acp/session-exit.ts +31 -0
- package/src/server/lib/harness/acp/session-facts.ts +1 -1
- package/src/server/lib/harness/acp/session-handshake.test.ts +197 -0
- package/src/server/lib/harness/acp/session-handshake.ts +110 -7
- package/src/server/lib/harness/acp/session-idle.ts +7 -6
- package/src/server/lib/harness/acp/session-listeners.ts +31 -0
- package/src/server/lib/harness/acp/session-notifications.ts +41 -2
- package/src/server/lib/harness/acp/session-observers.test.ts +63 -0
- package/src/server/lib/harness/acp/session-permissions.test.ts +29 -0
- package/src/server/lib/harness/acp/session-permissions.ts +36 -0
- package/src/server/lib/harness/acp/session-requests.test.ts +92 -0
- package/src/server/lib/harness/acp/session-requests.ts +89 -0
- package/src/server/lib/harness/acp/session-turns.ts +28 -8
- package/src/server/lib/harness/acp/session-usage.ts +4 -0
- package/src/server/lib/harness/acp/session-web-state.ts +30 -2
- package/src/server/lib/harness/acp/session.test-util.ts +42 -2
- package/src/server/lib/harness/acp/session.ts +115 -115
- package/src/server/lib/harness/acp/tool-calls.ts +223 -0
- package/src/server/lib/harness/acp/turn.test.ts +183 -0
- package/src/server/lib/harness/acp/turn.ts +102 -10
- package/src/server/lib/harness/acp/v2.test.ts +144 -0
- package/src/server/lib/harness/acp/v2.ts +220 -0
- package/src/server/lib/harness/acp/verbs.ts +58 -8
- package/src/server/lib/harness/launch.test.ts +25 -0
- package/src/server/lib/harness/launch.ts +24 -10
- package/src/server/lib/harness/session.ts +3 -0
- package/src/server/lib/harness/spawn.server.ts +15 -2
- package/src/server/lib/harness/update-job-store.test.ts +151 -0
- package/src/server/lib/harness/update-job-store.ts +115 -0
- package/src/server/lib/harness/update-job.server.ts +94 -0
- package/src/server/lib/harness/update-queue.server.ts +292 -0
- package/src/server/lib/harness/update-queue.test.ts +265 -0
- package/src/server/lib/harness/update-spawn.server.ts +96 -0
- package/src/server/lib/harness/update-worker.test.ts +153 -0
- package/src/server/lib/harness/update-worker.ts +202 -0
- package/src/server/lib/lifecycle/after-listen.ts +9 -0
- package/src/server/lib/lifecycle/paths.ts +28 -0
- package/src/server/lib/omp/rpc/manager.ts +5 -5
- package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
- package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
- package/src/server/lib/omp/rpc/session-registry.ts +14 -2
- package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
- package/src/server/lib/omp/rpc/terminal-settle.ts +58 -6
- package/src/server/lib/omp/session/delete-flow.server.ts +48 -0
- package/src/server/lib/omp/session/delete.server.ts +5 -0
- package/src/server/lib/omp/session/rewind-file.ts +39 -21
- package/src/server/lib/omp/session/sidebar-data.server.ts +16 -18
- package/src/server/lib/omp/session/transcript-copy.ts +123 -0
- package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
- package/src/server/lib/sessions/agent-token.server.ts +134 -0
- package/src/server/lib/sessions/answers.server.test.ts +33 -0
- package/src/server/lib/sessions/answers.server.ts +37 -0
- package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
- package/src/server/lib/sessions/dispatch.server.ts +128 -0
- package/src/server/lib/sessions/fork.server.test.ts +277 -0
- package/src/server/lib/sessions/fork.server.ts +329 -0
- package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
- package/src/server/lib/sessions/lifecycle.server.ts +71 -0
- package/src/server/lib/sessions/notify.server.test.ts +112 -0
- package/src/server/lib/sessions/notify.server.ts +212 -0
- package/src/server/lib/sessions/relation-types.ts +76 -0
- package/src/server/lib/sessions/relations.server.test.ts +207 -0
- package/src/server/lib/sessions/relations.server.ts +337 -0
- package/src/server/lib/sessions/resolve.server.ts +106 -0
- package/src/server/lib/sessions/schema.server.ts +82 -0
- package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
- package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
- package/src/server/lib/sessions/spawn.server.test.ts +237 -0
- package/src/server/lib/sessions/spawn.server.ts +335 -0
- package/src/server/lib/terminal/attach-replay.test.ts +2 -2
- package/src/server/lib/terminal/output.test.ts +2 -2
- package/src/server/lib/terminal/output.ts +1 -1
- package/src/server/lib/terminal/resize.test.ts +99 -0
- package/src/server/lib/terminal/runtime.server.ts +26 -6
- package/src/server/lib/terminal/send-result.test.ts +18 -1
- package/src/server/lib/terminal/send-result.ts +26 -2
- package/src/server/lib/terminal/session.server.ts +6 -6
- package/src/server/lib/usage/new-api.test.ts +92 -0
- package/src/server/lib/usage/new-api.ts +131 -0
- package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
- package/src/server/lib/usage/provider-key.ts +33 -0
- package/src/server/lib/usage/providers.server.ts +10 -3
- package/src/server/lib/usage/vendor-balance.server.ts +4 -53
- package/src/server/lib/usage/vendor-http.ts +41 -0
- package/src/server/lib/usage/window.ts +55 -0
- package/src/server/routes/agent/command.ts +14 -1
- package/src/server/routes/agent/harness-command.ts +12 -5
- package/src/server/routes/agent/new.ts +15 -0
- package/src/server/routes/chat/stream.ts +7 -2
- package/src/server/routes/harness/add-provider.test.ts +9 -1
- package/src/server/routes/harness/import-action.ts +4 -0
- package/src/server/routes/harness/import.test.ts +1 -1
- package/src/server/routes/harness/index.ts +5 -1
- package/src/server/routes/harness/update-status.ts +32 -0
- package/src/server/routes/harness/update.test.ts +156 -0
- package/src/server/routes/harness/update.ts +64 -147
- package/src/server/routes/sessions/answer.ts +24 -0
- package/src/server/routes/sessions/batch-delete.ts +11 -5
- package/src/server/routes/sessions/body-readers.ts +43 -0
- package/src/server/routes/sessions/delete.ts +4 -2
- package/src/server/routes/sessions/fork.ts +89 -0
- package/src/server/routes/sessions/index.ts +14 -0
- package/src/server/routes/sessions/relations.ts +85 -0
- package/src/server/routes/sessions/routes.test.ts +1 -2
- package/src/server/routes/sessions/session.ts +23 -0
- package/src/server/routes/sessions/spawn.ts +137 -0
- package/src/server/routes/terminal/ws.ts +3 -3
- package/src/shared/lib/chat/composer/client.ts +31 -2
- package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
- package/src/shared/lib/chat/composer/delegation.ts +206 -0
- package/src/shared/lib/chat/notice-text.ts +1 -1
- package/src/shared/lib/chat/omp/agent-events.ts +11 -0
- package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
- package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
- package/src/shared/lib/code/ansi.ts +1 -1
- package/src/shared/lib/fonts/nerd-symbols.css +4 -3
- package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
- package/src/shared/lib/harness/mode-signal.ts +20 -0
- package/src/shared/lib/harness/provider-facts.test.ts +27 -0
- package/src/shared/lib/harness/providers.ts +35 -1
- package/src/shared/lib/harness/session-modes.ts +24 -0
- package/src/shared/lib/harness/update-job.ts +80 -0
- package/src/shared/lib/harness/update-plan.test.ts +21 -6
- package/src/shared/lib/harness/update-plan.ts +12 -4
- package/src/shared/lib/icons/tint-hues.generated.ts +34 -34
- package/src/shared/lib/notifications/outcomes.test.ts +96 -0
- package/src/shared/lib/notifications/outcomes.ts +64 -0
- package/src/shared/lib/notifications/settings.test.ts +49 -0
- package/src/shared/lib/notifications/settings.ts +34 -0
- package/src/shared/lib/omp/session/default-title.ts +5 -4
- package/src/shared/lib/omp/session/prewarm-misc.test.ts +3 -2
- package/src/shared/lib/omp/session/schema-migrations.ts +4 -0
- package/src/shared/lib/omp/session/stream-state.server.test.ts +19 -0
- package/src/shared/lib/omp/session/stream-state.server.ts +24 -4
- package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
- package/src/shared/lib/omp/session/wait-idle.ts +12 -2
- package/src/shared/lib/settings/defaults.ts +3 -0
- package/src/shared/lib/theme/catalog.test.ts +13 -9
- package/src/shared/lib/theme/color.test.ts +2 -2
- package/src/shared/lib/theme/color.ts +4 -4
- package/src/shared/lib/theme/theme.test.ts +1 -1
- package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
- package/src/shared/lib/workspace/terminal/input.ts +33 -0
- package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
- package/src/shared/lib/workspace/terminal/keys.ts +7 -7
- package/src/shared/types/chat.ts +1 -1
- package/src/shared/types/harness-update.ts +89 -0
- package/src/shared/types/omp/agent.ts +19 -2
- package/src/shared/types/realtime.ts +2 -0
- package/src/shared/types/settings/state.ts +10 -0
- package/src/shared/types/workspace.ts +8 -0
- package/src/test-support/fake-omp-fork.ts +16 -2
- package/src/test-support/harness-table.test-util.ts +31 -1
- package/dist/client/static/js/index-z3w7n85q.css +0 -1
- package/src/client/components/common/subagent-list/index.tsx +0 -165
- package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
- package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'preact/hooks';
|
|
2
|
-
import { Square } from 'lucide-preact';
|
|
3
|
-
import { useSearchParams } from '@/client/lib/router/search-params';
|
|
4
|
-
import { SubagentStatusIcon } from '@/client/components/common/SubagentStatusIcon';
|
|
5
|
-
import { isRecord } from '@/shared/lib/util/guards';
|
|
6
|
-
import { fetchSubagentHistory, historyEntryToSubagentInfo } from '@/shared/lib/omp/subagent/history/client';
|
|
7
|
-
import { subagentRowLabel } from '@/shared/lib/omp/subagent/label';
|
|
8
|
-
import { mergeSubagentRoster, parseSubagentLifecycle, parseSubagentRosterResponse, readSubagentProgressFrame } from '@/shared/lib/omp/subagent/parse';
|
|
9
|
-
import { subscribeSubagentFrame, type SubagentFrame } from '@/shared/lib/chat/omp/subagent-frames';
|
|
10
|
-
import { cancelSubagent } from '@/shared/lib/omp/subagent/control';
|
|
11
|
-
import type { SubagentInfo, SubagentProgress } from '@/shared/types';
|
|
12
|
-
|
|
13
|
-
type SubagentListProps = {
|
|
14
|
-
sessionId: string | number;
|
|
15
|
-
isActiveSession: boolean;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const PROGRESS_STATUS: Record<NonNullable<SubagentProgress['status']>, SubagentInfo['status']> = {
|
|
19
|
-
pending: 'started', running: 'started', completed: 'completed', failed: 'failed', aborted: 'aborted',
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/** Fold one progress frame into the roster entry it names (id, else index). */
|
|
23
|
-
function applyProgress(roster: SubagentInfo[], progress: SubagentProgress): SubagentInfo[] {
|
|
24
|
-
return roster.map((entry) => {
|
|
25
|
-
if (progress.id !== undefined) {
|
|
26
|
-
if (entry.id !== progress.id) return entry;
|
|
27
|
-
} else if (progress.index === undefined || progress.index < 0 || entry.index !== progress.index) {
|
|
28
|
-
return entry;
|
|
29
|
-
}
|
|
30
|
-
const status = progress.status && entry.status === 'started'
|
|
31
|
-
? PROGRESS_STATUS[progress.status] ?? entry.status
|
|
32
|
-
: entry.status;
|
|
33
|
-
return { ...entry, status, progress: { ...entry.progress, ...progress }, lastUpdate: Date.now() };
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Subagent roster nested under a session row: renders clean, readable subagent
|
|
39
|
-
* items matching the minimalist sidebar layout while preserving interactive inspection.
|
|
40
|
-
* Shared by the desktop sidebar's `CategoryItem` and the mobile drawer's
|
|
41
|
-
* `MobileSessionCategory`, so both list the same roster.
|
|
42
|
-
*/
|
|
43
|
-
export function SubagentList({ sessionId, isActiveSession }: SubagentListProps) {
|
|
44
|
-
const [searchParams] = useSearchParams();
|
|
45
|
-
const viewedSubagentId = searchParams.get('subagent');
|
|
46
|
-
const [subagents, setSubagents] = useState<SubagentInfo[]>([]);
|
|
47
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
48
|
-
|
|
49
|
-
// History pass: the roster floor for every session.
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
let cancelled = false;
|
|
52
|
-
const sid = String(sessionId);
|
|
53
|
-
setSubagents([]);
|
|
54
|
-
setIsLoading(true);
|
|
55
|
-
void fetchSubagentHistory(sid)
|
|
56
|
-
.then((entries) => {
|
|
57
|
-
if (cancelled || !entries) return;
|
|
58
|
-
const roster = entries.map(historyEntryToSubagentInfo);
|
|
59
|
-
setSubagents((prev) => mergeSubagentRoster(prev, roster));
|
|
60
|
-
})
|
|
61
|
-
.finally(() => { if (!cancelled) setIsLoading(false); });
|
|
62
|
-
return () => { cancelled = true; };
|
|
63
|
-
}, [sessionId]);
|
|
64
|
-
|
|
65
|
-
// Live pass: active session only.
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (!isActiveSession) return;
|
|
68
|
-
let cancelled = false;
|
|
69
|
-
const sid = String(sessionId);
|
|
70
|
-
const requestedAt = Date.now();
|
|
71
|
-
const forThisSession = (frame: SubagentFrame) =>
|
|
72
|
-
frame.sessionId === sid ? frame.payload : null;
|
|
73
|
-
|
|
74
|
-
const unsubLifecycle = subscribeSubagentFrame('subagent_lifecycle', (frame) => {
|
|
75
|
-
const entry = parseSubagentLifecycle(forThisSession(frame));
|
|
76
|
-
if (entry) {
|
|
77
|
-
setSubagents((prev) => mergeSubagentRoster(prev, [entry]));
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const unsubProgress = subscribeSubagentFrame('subagent_progress', (frame) => {
|
|
81
|
-
const progress = readSubagentProgressFrame(forThisSession(frame));
|
|
82
|
-
if (progress) setSubagents((prev) => applyProgress(prev, progress));
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Snapshot the LIVE registry. This POST is the spawn path, so the server
|
|
86
|
-
// refuses it (409) for a session it does not manage — an observer read must
|
|
87
|
-
// never boot an omp child. The history pass above already covers a finished
|
|
88
|
-
// session from disk, so nothing is missing when this comes back empty.
|
|
89
|
-
fetch(`/api/agent/${encodeURIComponent(sid)}`, {
|
|
90
|
-
method: 'POST',
|
|
91
|
-
headers: { 'Content-Type': 'application/json' },
|
|
92
|
-
body: JSON.stringify({ type: 'get_subagents' }),
|
|
93
|
-
})
|
|
94
|
-
.then((res) => (res.ok ? res.json() : null))
|
|
95
|
-
.then((body: unknown) => {
|
|
96
|
-
if (cancelled || !isRecord(body)) return;
|
|
97
|
-
const payload = 'data' in body ? body.data : body;
|
|
98
|
-
setSubagents((prev) => mergeSubagentRoster(prev, parseSubagentRosterResponse(payload), requestedAt));
|
|
99
|
-
})
|
|
100
|
-
.catch(() => {});
|
|
101
|
-
|
|
102
|
-
return () => {
|
|
103
|
-
cancelled = true;
|
|
104
|
-
unsubLifecycle();
|
|
105
|
-
unsubProgress();
|
|
106
|
-
};
|
|
107
|
-
}, [isActiveSession, sessionId]);
|
|
108
|
-
|
|
109
|
-
const hint = isLoading ? 'Loading subagents…' : subagents.length === 0 ? 'No subagent activity' : null;
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<div className="pl-6 pr-0 space-y-0.5 py-0.5">
|
|
113
|
-
{hint ? (
|
|
114
|
-
<div className="px-2 py-1 text-xs italic text-ink/40 flex items-center">
|
|
115
|
-
<span className="w-4 h-4 shrink-0" />
|
|
116
|
-
<span className="w-2 shrink-0" />
|
|
117
|
-
<span className="flex-1 min-w-0 truncate">{hint}</span>
|
|
118
|
-
</div>
|
|
119
|
-
) : (
|
|
120
|
-
subagents.map((subagent) => {
|
|
121
|
-
const label = subagentRowLabel(subagent);
|
|
122
|
-
const brief = subagent.task ?? subagent.assignment ?? subagent.description ?? label;
|
|
123
|
-
const isViewed = subagent.id === viewedSubagentId;
|
|
124
|
-
// A running subagent can be stopped from the roster. The row itself is
|
|
125
|
-
// a button (it opens the transcript), so the control is a SIBLING —
|
|
126
|
-
// nesting one button in another is invalid and swallows the inner
|
|
127
|
-
// click.
|
|
128
|
-
const running = isActiveSession && subagent.status === 'started';
|
|
129
|
-
return (
|
|
130
|
-
<div key={subagent.id} className="flex items-center group/subagent-row">
|
|
131
|
-
<button
|
|
132
|
-
type="button"
|
|
133
|
-
title={brief}
|
|
134
|
-
onClick={() => window.dispatchEvent(new CustomEvent('omp:view-subagent', { detail: { sessionId: String(sessionId), subagent } }))}
|
|
135
|
-
className={`flex-1 min-w-0 flex items-center text-left text-xs rounded-md px-2 py-1 cursor-pointer transition-colors select-none group/subagent ${isViewed ? 'bg-ink/10 font-medium text-ink' : 'text-ink/70 hover:text-ink hover:bg-ink/5'}`}
|
|
136
|
-
>
|
|
137
|
-
{/* Subagent status icon slot - aligned straight with session item text */}
|
|
138
|
-
<span className="w-4 h-4 flex items-center justify-center shrink-0">
|
|
139
|
-
<SubagentStatusIcon status={subagent.status} live={running} size={11} />
|
|
140
|
-
</span>
|
|
141
|
-
|
|
142
|
-
{/* Gap between subagent icon and task text */}
|
|
143
|
-
<span className="w-2 shrink-0" />
|
|
144
|
-
|
|
145
|
-
{/* Subagent label: `id (agent): target` */}
|
|
146
|
-
<span className="flex-1 min-w-0 truncate leading-snug">{label}</span>
|
|
147
|
-
</button>
|
|
148
|
-
{running && (
|
|
149
|
-
<button
|
|
150
|
-
type="button"
|
|
151
|
-
title="Stop this subagent"
|
|
152
|
-
aria-label="Stop this subagent"
|
|
153
|
-
onClick={() => void cancelSubagent(String(sessionId), subagent.id)}
|
|
154
|
-
className="touch-visible shrink-0 mr-1 w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-error hover:bg-error/5 opacity-0 group-hover/subagent-row:opacity-100 transition-opacity cursor-pointer"
|
|
155
|
-
>
|
|
156
|
-
<Square size={10} />
|
|
157
|
-
</button>
|
|
158
|
-
)}
|
|
159
|
-
</div>
|
|
160
|
-
);
|
|
161
|
-
})
|
|
162
|
-
)}
|
|
163
|
-
</div>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The terminal's WebGL context: held while the panel is on screen, released when
|
|
8
|
-
* it is not.
|
|
9
|
-
*
|
|
10
|
-
* The measured reason is in `webgl.ts` — 541.8 MB of `owned unmapped (graphics)`
|
|
11
|
-
* in an 817.7 MB footprint, with a 12.6 MB JS heap. What this file pins is the
|
|
12
|
-
* lifecycle, because every failure here is silent: a context that is never
|
|
13
|
-
* released is invisible until the machine is short of memory, and one released
|
|
14
|
-
* while the panel is still visible drops powerline glyphs back to the DOM
|
|
15
|
-
* renderer's notched version with no error.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { describe, expect, test } from 'bun:test';
|
|
19
|
-
import type { Terminal } from '@xterm/xterm';
|
|
20
|
-
import { createWebglControl } from '@/client/components/workspace/terminal-panel/webgl';
|
|
21
|
-
|
|
22
|
-
/** A terminal double: records addons, and can refuse the context like a driver. */
|
|
23
|
-
function fakeTerminal(options: { failLoad?: boolean } = {}) {
|
|
24
|
-
const loaded: string[] = [];
|
|
25
|
-
const term = {
|
|
26
|
-
loadAddon: (addon: { marker?: string }) => {
|
|
27
|
-
if (options.failLoad) throw new Error('no GPU context');
|
|
28
|
-
loaded.push(addon.marker ?? 'addon');
|
|
29
|
-
},
|
|
30
|
-
} as unknown as Terminal;
|
|
31
|
-
return { term, loaded };
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
describe('createWebglControl', () => {
|
|
35
|
-
test('attaching loads the addon exactly once', async () => {
|
|
36
|
-
const { term, loaded } = fakeTerminal();
|
|
37
|
-
const control = await createWebglControl(term);
|
|
38
|
-
control.attach();
|
|
39
|
-
control.attach();
|
|
40
|
-
expect(loaded.length).toBe(1);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('detaching releases it, and attaching again creates a NEW context', async () => {
|
|
44
|
-
const { term, loaded } = fakeTerminal();
|
|
45
|
-
const control = await createWebglControl(term);
|
|
46
|
-
control.attach();
|
|
47
|
-
control.detach();
|
|
48
|
-
control.detach();
|
|
49
|
-
control.attach();
|
|
50
|
-
// Two loads, because the second attach must not reuse a disposed addon: a
|
|
51
|
-
// disposed WebGL renderer draws nothing.
|
|
52
|
-
expect(loaded.length).toBe(2);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('`set` is the same lifecycle, so a panel mounted hidden stays released', async () => {
|
|
56
|
-
const { term, loaded } = fakeTerminal();
|
|
57
|
-
const control = await createWebglControl(term);
|
|
58
|
-
control.set(false);
|
|
59
|
-
expect(loaded.length).toBe(0);
|
|
60
|
-
control.set(true);
|
|
61
|
-
expect(loaded.length).toBe(1);
|
|
62
|
-
control.set(false);
|
|
63
|
-
control.set(true);
|
|
64
|
-
expect(loaded.length).toBe(2);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test('a driver that refuses the context leaves the DOM renderer in place', async () => {
|
|
68
|
-
const { term } = fakeTerminal({ failLoad: true });
|
|
69
|
-
const control = await createWebglControl(term);
|
|
70
|
-
// Must not throw: a machine with no GPU context still renders the terminal.
|
|
71
|
-
expect(() => control.attach()).not.toThrow();
|
|
72
|
-
// And a later detach is a no-op rather than a second throw.
|
|
73
|
-
expect(() => control.detach()).not.toThrow();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The terminal's WebGL context, and when it is allowed to exist.
|
|
8
|
-
*
|
|
9
|
-
* xterm's WebGL renderer draws powerline glyphs (U+E0B0 etc.) as full-cell vector
|
|
10
|
-
* paths, so segmented prompts stay seamless the way a local terminal does; the DOM
|
|
11
|
-
* renderer draws them as ordinary glyphs inside the font box, which leaves notches
|
|
12
|
-
* at every segment joint. That is why it is on at all.
|
|
13
|
-
*
|
|
14
|
-
* **It is not on permanently, and that is the point of this module.** A WebGL
|
|
15
|
-
* context costs GPU memory for as long as it lives — a glyph atlas plus the
|
|
16
|
-
* layer's textures — and the right-panel stack keeps every built-in view MOUNTED
|
|
17
|
-
* while another one is on screen, the terminal included, because it owns a live
|
|
18
|
-
* PTY. Eight terminals therefore held eight contexts. Measured with `vmmap` on the
|
|
19
|
-
* desktop shell: `owned unmapped (graphics)` was 541.8 MB of an 817.7 MB physical
|
|
20
|
-
* footprint, while the JS heap was 12.6 MB — so no garbage collection could ever
|
|
21
|
-
* have returned it.
|
|
22
|
-
*
|
|
23
|
-
* `attach()` on show and `detach()` on hide is the whole API: xterm falls back to
|
|
24
|
-
* its DOM renderer in between, so the buffer stays readable and scrolling still
|
|
25
|
-
* works while the panel is not the one on screen.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
import type { Terminal } from '@xterm/xterm';
|
|
29
|
-
import type { WebglAddon } from '@xterm/addon-webgl';
|
|
30
|
-
|
|
31
|
-
/** The addon class, or undefined when the module cannot be imported. */
|
|
32
|
-
type WebglAddonClass = new () => WebglAddon;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Load the WebGL addon lazily.
|
|
36
|
-
*
|
|
37
|
-
* Dynamic on purpose: `@xterm/addon-webgl` is only needed once a terminal exists,
|
|
38
|
-
* so it stays out of the initial client bundle. The module shape varies by build,
|
|
39
|
-
* hence the probes.
|
|
40
|
-
*/
|
|
41
|
-
async function loadAddonClass(): Promise<WebglAddonClass | undefined> {
|
|
42
|
-
try {
|
|
43
|
-
const module = (await import('@xterm/addon-webgl')) as unknown as {
|
|
44
|
-
WebglAddon?: WebglAddonClass;
|
|
45
|
-
default?: { WebglAddon?: WebglAddonClass } & WebglAddonClass;
|
|
46
|
-
};
|
|
47
|
-
return module.WebglAddon || module.default?.WebglAddon || module.default;
|
|
48
|
-
} catch {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface WebglControl {
|
|
54
|
-
/** Hold the context: loads the addon if it is not loaded. */
|
|
55
|
-
attach: () => void;
|
|
56
|
-
/** Release the context, leaving xterm on its DOM renderer. */
|
|
57
|
-
detach: () => void;
|
|
58
|
-
/** The current state, for a caller that mounts while hidden. */
|
|
59
|
-
set: (enabled: boolean) => void;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Bind a WebGL context to `term`, held only while `attach` has been called.
|
|
64
|
-
*
|
|
65
|
-
* Failure is not an error the caller can act on: a machine with no GPU context, a
|
|
66
|
-
* context lost to the driver, and a build without the addon all end in the same
|
|
67
|
-
* place — the DOM renderer, which is what xterm does when no renderer addon is
|
|
68
|
-
* loaded.
|
|
69
|
-
*/
|
|
70
|
-
export async function createWebglControl(term: Terminal): Promise<WebglControl> {
|
|
71
|
-
const AddonClass = await loadAddonClass();
|
|
72
|
-
let addon: WebglAddon | null = null;
|
|
73
|
-
|
|
74
|
-
const attach = (): void => {
|
|
75
|
-
if (!AddonClass || addon) return;
|
|
76
|
-
try {
|
|
77
|
-
const created = new AddonClass();
|
|
78
|
-
created.onContextLoss(() => {
|
|
79
|
-
// The driver took the context away. Disposing is what lets xterm fall
|
|
80
|
-
// back to the DOM renderer instead of drawing nothing.
|
|
81
|
-
created.dispose();
|
|
82
|
-
if (addon === created) addon = null;
|
|
83
|
-
});
|
|
84
|
-
term.loadAddon(created);
|
|
85
|
-
addon = created;
|
|
86
|
-
} catch {
|
|
87
|
-
addon = null;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const detach = (): void => {
|
|
92
|
-
if (!addon) return;
|
|
93
|
-
const previous = addon;
|
|
94
|
-
addon = null;
|
|
95
|
-
try {
|
|
96
|
-
previous.dispose();
|
|
97
|
-
} catch {
|
|
98
|
-
// A context the driver already destroyed throws on dispose; the reference
|
|
99
|
-
// is dropped either way.
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
attach,
|
|
105
|
-
detach,
|
|
106
|
-
set: (enabled: boolean) => (enabled ? attach() : detach()),
|
|
107
|
-
};
|
|
108
|
-
}
|