@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
|
@@ -35,7 +35,12 @@ import fs from 'fs';
|
|
|
35
35
|
import * as path from 'path';
|
|
36
36
|
import { getDatabasePath } from '@/server/db.server';
|
|
37
37
|
import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
|
|
38
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
buildTitleLine,
|
|
40
|
+
completeLines,
|
|
41
|
+
lastEntryId,
|
|
42
|
+
parseJsonObject,
|
|
43
|
+
} from '@/server/lib/omp/session/transcript-copy';
|
|
39
44
|
import { isRecord } from '@/shared/lib/util/guards';
|
|
40
45
|
|
|
41
46
|
/** Root holding every topic workspace, beside Kabmo database. */
|
|
@@ -45,37 +50,6 @@ export async function getBtwRoot(): Promise<string> {
|
|
|
45
50
|
return root;
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
function parseJsonObject(line: string): Record<string, unknown> | null {
|
|
49
|
-
try {
|
|
50
|
-
const value: unknown = JSON.parse(line);
|
|
51
|
-
return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : null;
|
|
52
|
-
} catch {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The file's lines, minus a torn tail. A snapshot taken while the parent is
|
|
59
|
-
* mid-append can end in a partial line; keeping it would make the side child
|
|
60
|
-
* fail to load the transcript.
|
|
61
|
-
*/
|
|
62
|
-
function completeLines(text: string): string[] {
|
|
63
|
-
const lines = text.split('\n');
|
|
64
|
-
if (lines[lines.length - 1] === '') lines.pop();
|
|
65
|
-
const last = lines[lines.length - 1];
|
|
66
|
-
if (last !== undefined && parseJsonObject(last) === null) lines.pop();
|
|
67
|
-
return lines;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** The transcript's leaf: the id of its last entry. */
|
|
71
|
-
export function lastEntryId(lines: string[]): string | null {
|
|
72
|
-
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
73
|
-
const record = parseJsonObject(lines[index]);
|
|
74
|
-
if (record && typeof record.id === 'string') return record.id;
|
|
75
|
-
}
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
53
|
/** Read a transcript's leaf id straight from disk. */
|
|
80
54
|
export async function readTranscriptLeaf(sessionFile: string): Promise<string | null> {
|
|
81
55
|
try {
|
|
@@ -85,18 +59,6 @@ export async function readTranscriptLeaf(sessionFile: string): Promise<string |
|
|
|
85
59
|
}
|
|
86
60
|
}
|
|
87
61
|
|
|
88
|
-
/** The title slot line, padded to the fixed slot omp rewrites in place, with
|
|
89
|
-
* the trailing newline removed (the writer here joins lines itself).
|
|
90
|
-
*
|
|
91
|
-
* Delegates to the repo's slot serializer rather than re-deriving the width:
|
|
92
|
-
* that one truncates the title by code point, so a question written in CJK
|
|
93
|
-
* (up to 3 UTF-8 bytes each) still fits — clipping by character count alone
|
|
94
|
-
* would overflow the slot and fail promotion outright. */
|
|
95
|
-
export function buildTitleLine(title: string, source: string, updatedAt: string): string {
|
|
96
|
-
const line = serializeTitleSlot({ title, source: source === 'auto' ? 'auto' : 'user', updatedAt });
|
|
97
|
-
return line.endsWith('\n') ? line.slice(0, -1) : line;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
62
|
export interface BtwWorkspace {
|
|
101
63
|
dir: string;
|
|
102
64
|
sessionFile: string;
|
|
@@ -13,7 +13,8 @@ import { afterEach, describe, expect, test } from 'bun:test';
|
|
|
13
13
|
import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
|
|
14
14
|
import { tmpdir } from 'os';
|
|
15
15
|
import { join } from 'path';
|
|
16
|
-
import { buildTitleLine
|
|
16
|
+
import { buildTitleLine } from '@/server/lib/omp/session/transcript-copy';
|
|
17
|
+
import { createBtwWorkspace, getBtwRoot, promoteBtwTopic, readTranscriptLeaf } from '@/server/lib/btw/session-copy.server';
|
|
17
18
|
|
|
18
19
|
const timestamp = '2026-09-23T08:41:10.683Z';
|
|
19
20
|
const createdDirs: string[] = [];
|
|
@@ -23,6 +23,7 @@ import { ensureUsageIndexSchema } from '@/server/lib/usage/index-schema.server';
|
|
|
23
23
|
import { ensureWorktreeSchema } from '@/server/lib/db/worktree-registry.server';
|
|
24
24
|
import { ensureReviewSchema } from '@/server/lib/review/schema.server';
|
|
25
25
|
import { ensureHarnessSchema } from '@/server/lib/harness/schema.server';
|
|
26
|
+
import { ensureSessionRelationsSchema } from '@/server/lib/sessions/schema.server';
|
|
26
27
|
import { migrateWorkspaceFolderColumns } from '@/shared/lib/workspace/schema-migrations';
|
|
27
28
|
import { migrateSessionStreamStateColumns } from '@/shared/lib/omp/session/schema-migrations';
|
|
28
29
|
|
|
@@ -108,6 +109,7 @@ export async function initSchema(db: DbClient): Promise<void> {
|
|
|
108
109
|
owner_pid INTEGER,
|
|
109
110
|
model_provider TEXT,
|
|
110
111
|
model_id TEXT,
|
|
112
|
+
failure TEXT,
|
|
111
113
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
112
114
|
);
|
|
113
115
|
`);
|
|
@@ -141,6 +143,9 @@ export async function initSchema(db: DbClient): Promise<void> {
|
|
|
141
143
|
// Harness ownership per session: the sidebar's mark needs it, and it has to
|
|
142
144
|
// outlive the process that spawned the child (a restart, a second instance).
|
|
143
145
|
await ensureHarnessSchema(db);
|
|
146
|
+
// Session trees: parent, cleanup ownership and fork origin. Keyed by the id
|
|
147
|
+
// the sidebar and the URL use, so it works for omp files and ACP sessions.
|
|
148
|
+
await ensureSessionRelationsSchema(db);
|
|
144
149
|
await db.exec(`
|
|
145
150
|
CREATE TABLE IF NOT EXISTS files (
|
|
146
151
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* The `terminal/session.server.ts` helpers are pinned alongside because they
|
|
24
24
|
* need no PTY: the viewer fan-out drop rule (a viewer that cannot keep up is
|
|
25
|
-
* dropped, never skipped, or
|
|
25
|
+
* dropped, never skipped, or the renderer's parser is left mid-sequence), the snapshot
|
|
26
26
|
* shape, and the process-group signalling fallback for a session with no child.
|
|
27
27
|
* Anything requiring a real PTY spawn is deliberately not tested here.
|
|
28
28
|
*/
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* The `terminal/session.server.ts` helpers are pinned alongside because they
|
|
18
18
|
* need no PTY: the viewer fan-out drop rule (a viewer that cannot keep up is
|
|
19
|
-
* dropped, never skipped, or
|
|
19
|
+
* dropped, never skipped, or the renderer's parser is left mid-sequence), the snapshot
|
|
20
20
|
* shape, and the process-group signalling fallback for a session with no child.
|
|
21
21
|
* Anything requiring a real PTY spawn is deliberately not tested here.
|
|
22
22
|
*/
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The delayed-answer probe: antigravity ends a turn when it SPAWNS a subagent
|
|
8
|
+
* and holds the completion until the next request (upstream #1461), so Kabmo
|
|
9
|
+
* replays the transcript with `session/load` and emits only the text the
|
|
10
|
+
* operator has not seen.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { describe, expect, test } from 'bun:test';
|
|
14
|
+
import {
|
|
15
|
+
AcpBackgroundProbe,
|
|
16
|
+
backgroundNotice,
|
|
17
|
+
backgroundNoticeFrames,
|
|
18
|
+
spawnsBackgroundWork,
|
|
19
|
+
} from '@/server/lib/harness/acp/background-work';
|
|
20
|
+
|
|
21
|
+
const toolCall = (name: string) => ({
|
|
22
|
+
role: 'assistant',
|
|
23
|
+
content: [{ type: 'toolCall', id: 't1', name }],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const chunk = (update: Record<string, unknown>) => ({ update });
|
|
27
|
+
const textChunk = (kind: 'user_message_chunk' | 'agent_message_chunk', text: string) =>
|
|
28
|
+
chunk({ sessionUpdate: kind, content: { type: 'text', text } });
|
|
29
|
+
|
|
30
|
+
interface FakeTimer {
|
|
31
|
+
fn: () => void;
|
|
32
|
+
ms: number;
|
|
33
|
+
cancelled: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function isFakeTimer(value: unknown): value is FakeTimer {
|
|
37
|
+
return (
|
|
38
|
+
typeof value === 'object' &&
|
|
39
|
+
value !== null &&
|
|
40
|
+
'fn' in value &&
|
|
41
|
+
'ms' in value &&
|
|
42
|
+
'cancelled' in value &&
|
|
43
|
+
typeof value.fn === 'function' &&
|
|
44
|
+
typeof value.ms === 'number' &&
|
|
45
|
+
typeof value.cancelled === 'boolean'
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The probe arms a timer; cases drive it themselves so nothing sleeps. */
|
|
50
|
+
function timers() {
|
|
51
|
+
const scheduled: FakeTimer[] = [];
|
|
52
|
+
return {
|
|
53
|
+
schedule: (fn: () => void, ms: number): unknown => {
|
|
54
|
+
const handle: FakeTimer = { fn, ms, cancelled: false };
|
|
55
|
+
scheduled.push(handle);
|
|
56
|
+
return handle;
|
|
57
|
+
},
|
|
58
|
+
cancel: (handle: unknown): void => {
|
|
59
|
+
if (isFakeTimer(handle)) handle.cancelled = true;
|
|
60
|
+
},
|
|
61
|
+
next: (): FakeTimer | undefined => scheduled.shift(),
|
|
62
|
+
pending: () => scheduled.filter((handle) => !handle.cancelled),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function settle(): Promise<void> {
|
|
67
|
+
for (let i = 0; i < 6; i += 1) await Promise.resolve();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
describe('background work detection', () => {
|
|
71
|
+
test('a spawned subagent tool call is background work', () => {
|
|
72
|
+
expect(spawnsBackgroundWork(toolCall('invoke_subagent'))).toBe(true);
|
|
73
|
+
expect(spawnsBackgroundWork(toolCall('spawn_subagent'))).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('an awaited tool call is not', () => {
|
|
77
|
+
expect(spawnsBackgroundWork(toolCall('run_command'))).toBe(false);
|
|
78
|
+
expect(spawnsBackgroundWork({ role: 'assistant', content: [{ type: 'text', text: 'hi' }] })).toBe(false);
|
|
79
|
+
expect(spawnsBackgroundWork(undefined)).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('delayed notice extraction', () => {
|
|
84
|
+
test('returns only the text past the answer already shown', () => {
|
|
85
|
+
expect(backgroundNotice('Sedang membuat…', 'Sedang membuat…\nBerikut gambarnya')).toBe('Berikut gambarnya');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('a replay of the same answer is not a notice', () => {
|
|
89
|
+
expect(backgroundNotice('Sedang membuat…', 'Sedang membuat…')).toBeNull();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('a diverged replay is not guessed at', () => {
|
|
93
|
+
expect(backgroundNotice('Sedang membuat…', 'Jawaban lain')).toBeNull();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('an empty baseline accepts the whole segment', () => {
|
|
97
|
+
expect(backgroundNotice('', 'Berikut gambarnya')).toBe('Berikut gambarnya');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('background notice frames', () => {
|
|
102
|
+
test('form a complete run so the client releases its generating flag', () => {
|
|
103
|
+
const frames = backgroundNoticeFrames('Berikut gambarnya');
|
|
104
|
+
expect(frames.map((frame) => frame.type)).toEqual([
|
|
105
|
+
'agent_start',
|
|
106
|
+
'turn_start',
|
|
107
|
+
'message_update',
|
|
108
|
+
'message_end',
|
|
109
|
+
'agent_end',
|
|
110
|
+
]);
|
|
111
|
+
expect(frames[3]).toMatchObject({
|
|
112
|
+
type: 'message_end',
|
|
113
|
+
message: { role: 'assistant', content: [{ type: 'text', text: 'Berikut gambarnya' }] },
|
|
114
|
+
});
|
|
115
|
+
expect(frames[4]).toMatchObject({ type: 'agent_end', isTerminal: true });
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('AcpBackgroundProbe', () => {
|
|
120
|
+
test('backs off and emits once a replay carries new text', async () => {
|
|
121
|
+
const clock = timers();
|
|
122
|
+
const emitted: string[] = [];
|
|
123
|
+
let probe!: AcpBackgroundProbe;
|
|
124
|
+
const replays = ['Sedang membuat…', 'Sedang membuat…\nBerikut gambarnya', 'Sedang membuat…\nBerikut gambarnya'];
|
|
125
|
+
let attempts = 0;
|
|
126
|
+
probe = new AcpBackgroundProbe({
|
|
127
|
+
load: async () => {
|
|
128
|
+
const text = replays[Math.min(attempts, replays.length - 1)];
|
|
129
|
+
attempts += 1;
|
|
130
|
+
probe.consume('session/update', textChunk('user_message_chunk', 'buat gambar'));
|
|
131
|
+
for (const piece of text.split('\n')) {
|
|
132
|
+
probe.consume('session/update', textChunk('agent_message_chunk', piece));
|
|
133
|
+
}
|
|
134
|
+
return {};
|
|
135
|
+
},
|
|
136
|
+
resetIdle: () => {},
|
|
137
|
+
emit: (text) => emitted.push(text),
|
|
138
|
+
firstDelayMs: 10,
|
|
139
|
+
maxDelayMs: 40,
|
|
140
|
+
now: () => 0,
|
|
141
|
+
schedule: clock.schedule,
|
|
142
|
+
cancel: clock.cancel,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
probe.start('Sedang membuat…');
|
|
146
|
+
const first = clock.next();
|
|
147
|
+
expect(first?.ms).toBe(10);
|
|
148
|
+
first?.fn();
|
|
149
|
+
await settle();
|
|
150
|
+
expect(attempts).toBe(1);
|
|
151
|
+
expect(emitted).toEqual([]);
|
|
152
|
+
// No notice yet: the next attempt is scheduled with a doubled delay.
|
|
153
|
+
const second = clock.next();
|
|
154
|
+
expect(second?.ms).toBe(20);
|
|
155
|
+
second?.fn();
|
|
156
|
+
await settle();
|
|
157
|
+
expect(attempts).toBe(2);
|
|
158
|
+
// A first sighting is a prefix while the agent is still writing.
|
|
159
|
+
expect(emitted).toEqual([]);
|
|
160
|
+
const third = clock.next();
|
|
161
|
+
expect(third?.ms).toBe(10);
|
|
162
|
+
third?.fn();
|
|
163
|
+
await settle();
|
|
164
|
+
expect(attempts).toBe(3);
|
|
165
|
+
expect(emitted).toEqual(['Berikut gambarnya']);
|
|
166
|
+
expect(clock.pending()).toHaveLength(0);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('swallows the replay, and stops swallowing once its load resolves', async () => {
|
|
170
|
+
const clock = timers();
|
|
171
|
+
const deferred = Promise.withResolvers<unknown>();
|
|
172
|
+
let probe!: AcpBackgroundProbe;
|
|
173
|
+
probe = new AcpBackgroundProbe({
|
|
174
|
+
load: () => deferred.promise,
|
|
175
|
+
resetIdle: () => {},
|
|
176
|
+
emit: () => {},
|
|
177
|
+
schedule: clock.schedule,
|
|
178
|
+
cancel: clock.cancel,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
expect(probe.consume('session/update', textChunk('agent_message_chunk', 'x'))).toBe(false);
|
|
182
|
+
probe.start('wait');
|
|
183
|
+
clock.next()?.fn();
|
|
184
|
+
await settle();
|
|
185
|
+
expect(probe.consume('session/update', textChunk('agent_message_chunk', 'replay'))).toBe(true);
|
|
186
|
+
|
|
187
|
+
deferred.resolve({});
|
|
188
|
+
await settle();
|
|
189
|
+
expect(probe.consume('session/update', textChunk('agent_message_chunk', 'live'))).toBe(false);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('a stopped probe still swallows the replay its load is waiting on', async () => {
|
|
193
|
+
const clock = timers();
|
|
194
|
+
const deferred = Promise.withResolvers<unknown>();
|
|
195
|
+
let probe!: AcpBackgroundProbe;
|
|
196
|
+
probe = new AcpBackgroundProbe({
|
|
197
|
+
load: () => deferred.promise,
|
|
198
|
+
resetIdle: () => {},
|
|
199
|
+
emit: () => {},
|
|
200
|
+
schedule: clock.schedule,
|
|
201
|
+
cancel: clock.cancel,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
probe.start('wait');
|
|
205
|
+
clock.next()?.fn();
|
|
206
|
+
await settle();
|
|
207
|
+
probe.stop();
|
|
208
|
+
expect(probe.consume('session/update', textChunk('agent_message_chunk', 'replay'))).toBe(true);
|
|
209
|
+
deferred.resolve({});
|
|
210
|
+
await settle();
|
|
211
|
+
expect(probe.consume('session/update', textChunk('agent_message_chunk', 'live'))).toBe(false);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test('retries a failed load, then gives up instead of spinning', async () => {
|
|
215
|
+
const clock = timers();
|
|
216
|
+
let loads = 0;
|
|
217
|
+
const probe = new AcpBackgroundProbe({
|
|
218
|
+
load: async () => {
|
|
219
|
+
loads += 1;
|
|
220
|
+
throw new Error('session/load is busy');
|
|
221
|
+
},
|
|
222
|
+
resetIdle: () => {},
|
|
223
|
+
emit: () => {},
|
|
224
|
+
timeoutMs: 60_000,
|
|
225
|
+
firstDelayMs: 10,
|
|
226
|
+
now: () => 0,
|
|
227
|
+
schedule: clock.schedule,
|
|
228
|
+
cancel: clock.cancel,
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
probe.start('wait');
|
|
232
|
+
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
|
233
|
+
clock.next()?.fn();
|
|
234
|
+
await settle();
|
|
235
|
+
expect(loads).toBe(attempt);
|
|
236
|
+
}
|
|
237
|
+
expect(clock.pending()).toHaveLength(0);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test('gives up at its deadline instead of polling forever', async () => {
|
|
241
|
+
const clock = timers();
|
|
242
|
+
let loads = 0;
|
|
243
|
+
const probe = new AcpBackgroundProbe({
|
|
244
|
+
load: async () => {
|
|
245
|
+
loads += 1;
|
|
246
|
+
return {};
|
|
247
|
+
},
|
|
248
|
+
resetIdle: () => {},
|
|
249
|
+
emit: () => {},
|
|
250
|
+
timeoutMs: 0,
|
|
251
|
+
firstDelayMs: 10,
|
|
252
|
+
schedule: clock.schedule,
|
|
253
|
+
cancel: clock.cancel,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
probe.start('wait');
|
|
257
|
+
clock.next()?.fn();
|
|
258
|
+
await settle();
|
|
259
|
+
expect(loads).toBe(1);
|
|
260
|
+
expect(clock.pending()).toHaveLength(0);
|
|
261
|
+
});
|
|
262
|
+
});
|