@deepseek-harness-tui/dsh-tui 0.11.0 → 0.11.2
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 +55 -20
- package/assets/whale-girl/whale-girl-dark.png +0 -0
- package/assets/whale-girl/whale-girl-happy.png +0 -0
- package/assets/whale-girl/whale-girl.png +0 -0
- package/bin/dsh-tui.js +63 -3
- package/cordis.patch.yml +43 -20
- package/cordis.yml +6 -4
- package/lib/settings.json +1272 -0
- package/lib/types/activityPrefs.d.ts +24 -0
- package/lib/types/activityPrefs.d.ts.map +1 -1
- package/lib/types/activityPrefs.js +50 -1
- package/lib/types/adapter/channel/state.d.ts.map +1 -1
- package/lib/types/adapter/channel/state.js +3 -1
- package/lib/types/adapter/channel/ui-policy.d.ts +9 -2
- package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
- package/lib/types/adapter/channel/ui-policy.js +14 -1
- package/lib/types/adapter/kernel/replay.d.ts.map +1 -1
- package/lib/types/adapter/kernel/replay.js +2 -0
- package/lib/types/adapter/ports/channel-display.d.ts +12 -0
- package/lib/types/adapter/ports/channel-display.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel-session.d.ts +38 -0
- package/lib/types/adapter/ports/channel-session.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel-settings.d.ts +12 -0
- package/lib/types/adapter/ports/channel-settings.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel-ui.d.ts +53 -7
- package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel-view.d.ts +43 -12
- package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel.d.ts +4 -1
- package/lib/types/adapter/ports/channel.d.ts.map +1 -1
- package/lib/types/commands.d.ts.map +1 -1
- package/lib/types/commands.js +2 -0
- package/lib/types/components/ActivityLine.d.ts +7 -2
- package/lib/types/components/ActivityLine.d.ts.map +1 -1
- package/lib/types/components/ActivityLine.js +0 -8
- package/lib/types/components/BalanceReportRow.d.ts +10 -2
- package/lib/types/components/BalanceReportRow.d.ts.map +1 -1
- package/lib/types/components/BalanceReportRow.js +18 -4
- package/lib/types/components/CompactionStatusRow.d.ts +24 -0
- package/lib/types/components/CompactionStatusRow.d.ts.map +1 -0
- package/lib/types/components/CompactionStatusRow.js +72 -0
- package/lib/types/components/GoalTodoPanel.js +2 -2
- package/lib/types/components/HelpMenu.d.ts +2 -2
- package/lib/types/components/HelpMenu.d.ts.map +1 -1
- package/lib/types/components/HelpMenu.js +5 -4
- package/lib/types/components/InlineMathParagraph.d.ts +22 -0
- package/lib/types/components/InlineMathParagraph.d.ts.map +1 -0
- package/lib/types/components/InlineMathParagraph.js +178 -0
- package/lib/types/components/LogoV2.d.ts +41 -3
- package/lib/types/components/LogoV2.d.ts.map +1 -1
- package/lib/types/components/LogoV2.js +148 -24
- package/lib/types/components/Markdown.d.ts +10 -3
- package/lib/types/components/Markdown.d.ts.map +1 -1
- package/lib/types/components/Markdown.js +47 -14
- package/lib/types/components/MathBlock.d.ts +13 -0
- package/lib/types/components/MathBlock.d.ts.map +1 -0
- package/lib/types/components/MathBlock.js +136 -0
- package/lib/types/components/MessageList.d.ts +10 -1
- package/lib/types/components/MessageList.d.ts.map +1 -1
- package/lib/types/components/MessageList.js +15 -5
- package/lib/types/components/MigratePicker.d.ts +30 -0
- package/lib/types/components/MigratePicker.d.ts.map +1 -0
- package/lib/types/components/MigratePicker.js +38 -0
- package/lib/types/components/PromptInput.d.ts +17 -0
- package/lib/types/components/PromptInput.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +96 -9
- package/lib/types/components/SplitDiffView.d.ts.map +1 -1
- package/lib/types/components/SplitDiffView.js +3 -1
- package/lib/types/components/StarPrompt.d.ts +53 -0
- package/lib/types/components/StarPrompt.d.ts.map +1 -0
- package/lib/types/components/StarPrompt.js +281 -0
- package/lib/types/components/StreamingMarkdown.d.ts.map +1 -1
- package/lib/types/components/StreamingMarkdown.js +20 -3
- package/lib/types/components/SubagentCard.d.ts.map +1 -1
- package/lib/types/components/SubagentCard.js +12 -6
- package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
- package/lib/types/components/SubagentDetailScene.js +8 -3
- package/lib/types/components/TimelineRail.d.ts.map +1 -1
- package/lib/types/components/TimelineRail.js +9 -1
- package/lib/types/components/Whale.d.ts +17 -8
- package/lib/types/components/Whale.d.ts.map +1 -1
- package/lib/types/components/Whale.js +25 -15
- package/lib/types/components/WhaleGirl.d.ts +29 -0
- package/lib/types/components/WhaleGirl.d.ts.map +1 -0
- package/lib/types/components/WhaleGirl.js +32 -0
- package/lib/types/components/WorkingSpinner.d.ts +4 -1
- package/lib/types/components/WorkingSpinner.d.ts.map +1 -1
- package/lib/types/components/WorkingSpinner.js +2 -2
- package/lib/types/components/bigfont.d.ts +47 -18
- package/lib/types/components/bigfont.d.ts.map +1 -1
- package/lib/types/components/bigfont.js +55 -40
- package/lib/types/components/design-system/HintLine.d.ts +1 -2
- package/lib/types/components/design-system/HintLine.d.ts.map +1 -1
- package/lib/types/components/design-system/HintLine.js +1 -2
- package/lib/types/components/design-system/ThemeProvider.d.ts +6 -0
- package/lib/types/components/design-system/ThemeProvider.d.ts.map +1 -1
- package/lib/types/components/design-system/ThemeProvider.js +40 -1
- package/lib/types/components/maidPortrait.d.ts +44 -0
- package/lib/types/components/maidPortrait.d.ts.map +1 -0
- package/lib/types/components/maidPortrait.js +178 -0
- package/lib/types/components/mathPreview.d.ts +25 -0
- package/lib/types/components/mathPreview.d.ts.map +1 -0
- package/lib/types/components/mathPreview.js +48 -0
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts +2 -1
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantThinkingMessage.js +4 -2
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts +2 -2
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +31 -26
- package/lib/types/components/messages/TranscriptImages.d.ts.map +1 -1
- package/lib/types/components/messages/TranscriptImages.js +11 -1
- package/lib/types/components/questions/AskUserQuestionPanel.d.ts +14 -2
- package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
- package/lib/types/components/questions/AskUserQuestionPanel.js +80 -38
- package/lib/types/components/questions/PlanReviewPanel.d.ts.map +1 -1
- package/lib/types/components/questions/PlanReviewPanel.js +3 -3
- package/lib/types/components/sessions/ForeignSessionRow.d.ts +34 -0
- package/lib/types/components/sessions/ForeignSessionRow.d.ts.map +1 -0
- package/lib/types/components/sessions/ForeignSessionRow.js +43 -0
- package/lib/types/components/sessions/SourceTabs.d.ts +52 -0
- package/lib/types/components/sessions/SourceTabs.d.ts.map +1 -0
- package/lib/types/components/sessions/SourceTabs.js +70 -0
- package/lib/types/components/splashEggs.d.ts +56 -0
- package/lib/types/components/splashEggs.d.ts.map +1 -0
- package/lib/types/components/splashEggs.js +67 -0
- package/lib/types/components/splashFonts.d.ts +119 -0
- package/lib/types/components/splashFonts.d.ts.map +1 -0
- package/lib/types/components/splashFonts.js +267 -0
- package/lib/types/components/splashLayout.d.ts +41 -0
- package/lib/types/components/splashLayout.d.ts.map +1 -0
- package/lib/types/components/splashLayout.js +40 -0
- package/lib/types/components/whaleGirlSprite.d.ts +17 -0
- package/lib/types/components/whaleGirlSprite.d.ts.map +1 -0
- package/lib/types/components/whaleGirlSprite.js +47 -0
- package/lib/types/deepseekPricing.d.ts +74 -0
- package/lib/types/deepseekPricing.d.ts.map +1 -1
- package/lib/types/deepseekPricing.js +110 -11
- package/lib/types/dsh-adapter/activity-store.d.ts +221 -0
- package/lib/types/dsh-adapter/activity-store.d.ts.map +1 -0
- package/lib/types/dsh-adapter/activity-store.js +359 -0
- package/lib/types/dsh-adapter/channel/action-readiness.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/action-readiness.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/action-readiness.js +6 -1
- package/lib/types/dsh-adapter/channel/background-action.d.ts +2 -1
- package/lib/types/dsh-adapter/channel/background-action.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/background-action.js +2 -0
- package/lib/types/dsh-adapter/channel/binding-events.d.ts +15 -14
- package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/binding-events.js +70 -21
- package/lib/types/dsh-adapter/channel/compaction.d.ts +2 -2
- package/lib/types/dsh-adapter/channel/compaction.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/compaction.js +35 -4
- package/lib/types/dsh-adapter/channel/local-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/local-actions.js +6 -1
- package/lib/types/dsh-adapter/channel/model-switch.d.ts +1 -2
- package/lib/types/dsh-adapter/channel/model-switch.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/model-switch.js +6 -2
- package/lib/types/dsh-adapter/channel/paths.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/paths.js +7 -1
- package/lib/types/dsh-adapter/channel/preferences.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/preferences.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/preferences.js +16 -0
- package/lib/types/dsh-adapter/channel/projection.d.ts +1 -2
- package/lib/types/dsh-adapter/channel/projection.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/projection.js +127 -17
- package/lib/types/dsh-adapter/channel/question-record.d.ts +76 -0
- package/lib/types/dsh-adapter/channel/question-record.d.ts.map +1 -0
- package/lib/types/dsh-adapter/channel/question-record.js +107 -0
- package/lib/types/dsh-adapter/channel/session-adoption.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/session-adoption.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-adoption.js +1 -0
- package/lib/types/dsh-adapter/channel/session-lineage.d.ts +42 -0
- package/lib/types/dsh-adapter/channel/session-lineage.d.ts.map +1 -0
- package/lib/types/dsh-adapter/channel/session-lineage.js +51 -0
- package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts +3 -1
- package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-live-adoption.js +10 -3
- package/lib/types/dsh-adapter/channel/session-metadata.d.ts +2 -1
- package/lib/types/dsh-adapter/channel/session-metadata.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-metadata.js +43 -9
- package/lib/types/dsh-adapter/channel/session-reset.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-reset.js +7 -1
- package/lib/types/dsh-adapter/channel/session-resume.d.ts +2 -1
- package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-resume.js +5 -2
- package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/settings-host.js +8 -0
- package/lib/types/dsh-adapter/channel/state.d.ts +19 -1
- package/lib/types/dsh-adapter/channel/state.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/state.js +8 -3
- package/lib/types/dsh-adapter/channel/subagent-projection.d.ts +32 -17
- package/lib/types/dsh-adapter/channel/subagent-projection.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/subagent-projection.js +309 -8
- package/lib/types/dsh-adapter/channel/types.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel.d.ts +1 -1
- package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel.js +34 -18
- package/lib/types/dsh-adapter/compat/index.d.ts +1 -1
- package/lib/types/dsh-adapter/compat/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/compat/index.js +1 -1
- package/lib/types/dsh-adapter/compat/messages.d.ts +6 -0
- package/lib/types/dsh-adapter/compat/messages.d.ts.map +1 -1
- package/lib/types/dsh-adapter/compat/messages.js +9 -0
- package/lib/types/dsh-adapter/compat/sessionLog.d.ts +18 -0
- package/lib/types/dsh-adapter/compat/sessionLog.d.ts.map +1 -1
- package/lib/types/dsh-adapter/compat/sessionLog.js +18 -3
- package/lib/types/dsh-adapter/compat/settings.d.ts +2 -0
- package/lib/types/dsh-adapter/compat/settings.d.ts.map +1 -1
- package/lib/types/dsh-adapter/compat/settings.js +14 -0
- package/lib/types/dsh-adapter/contract.d.ts +5 -4
- package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
- package/lib/types/dsh-adapter/contract.js +9 -5
- package/lib/types/dsh-adapter/index.d.ts +36 -1
- package/lib/types/dsh-adapter/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/index.js +22 -6
- package/lib/types/dsh-adapter/migrate/adapters/claude-code.d.ts +3 -0
- package/lib/types/dsh-adapter/migrate/adapters/claude-code.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/claude-code.js +131 -0
- package/lib/types/dsh-adapter/migrate/adapters/claude-code.parse.d.ts +17 -0
- package/lib/types/dsh-adapter/migrate/adapters/claude-code.parse.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/claude-code.parse.js +329 -0
- package/lib/types/dsh-adapter/migrate/adapters/codex.d.ts +3 -0
- package/lib/types/dsh-adapter/migrate/adapters/codex.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/codex.js +102 -0
- package/lib/types/dsh-adapter/migrate/adapters/codex.parse.d.ts +16 -0
- package/lib/types/dsh-adapter/migrate/adapters/codex.parse.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/codex.parse.js +289 -0
- package/lib/types/dsh-adapter/migrate/adapters/grok-build.d.ts +3 -0
- package/lib/types/dsh-adapter/migrate/adapters/grok-build.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/grok-build.js +117 -0
- package/lib/types/dsh-adapter/migrate/adapters/grok-build.parse.d.ts +13 -0
- package/lib/types/dsh-adapter/migrate/adapters/grok-build.parse.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/grok-build.parse.js +178 -0
- package/lib/types/dsh-adapter/migrate/adapters/omp.d.ts +3 -0
- package/lib/types/dsh-adapter/migrate/adapters/omp.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/omp.js +133 -0
- package/lib/types/dsh-adapter/migrate/adapters/scan-fs.d.ts +60 -0
- package/lib/types/dsh-adapter/migrate/adapters/scan-fs.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/scan-fs.js +178 -0
- package/lib/types/dsh-adapter/migrate/adapters/scan.d.ts +8 -0
- package/lib/types/dsh-adapter/migrate/adapters/scan.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/scan.js +40 -0
- package/lib/types/dsh-adapter/migrate/adapters/zcode.d.ts +3 -0
- package/lib/types/dsh-adapter/migrate/adapters/zcode.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/zcode.js +93 -0
- package/lib/types/dsh-adapter/migrate/adapters/zcode.parse.d.ts +9 -0
- package/lib/types/dsh-adapter/migrate/adapters/zcode.parse.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/adapters/zcode.parse.js +89 -0
- package/lib/types/dsh-adapter/migrate/bin-path.d.ts +6 -0
- package/lib/types/dsh-adapter/migrate/bin-path.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/bin-path.js +30 -0
- package/lib/types/dsh-adapter/migrate/browse.d.ts +42 -0
- package/lib/types/dsh-adapter/migrate/browse.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/browse.js +90 -0
- package/lib/types/dsh-adapter/migrate/cli.d.ts +9 -0
- package/lib/types/dsh-adapter/migrate/cli.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/cli.js +106 -0
- package/lib/types/dsh-adapter/migrate/import-one.d.ts +89 -0
- package/lib/types/dsh-adapter/migrate/import-one.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/import-one.js +133 -0
- package/lib/types/dsh-adapter/migrate/index.d.ts +35 -0
- package/lib/types/dsh-adapter/migrate/index.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/index.js +107 -0
- package/lib/types/dsh-adapter/migrate/parse/injection.d.ts +40 -0
- package/lib/types/dsh-adapter/migrate/parse/injection.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/parse/injection.js +127 -0
- package/lib/types/dsh-adapter/migrate/parse/jsonl.d.ts +28 -0
- package/lib/types/dsh-adapter/migrate/parse/jsonl.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/parse/jsonl.js +40 -0
- package/lib/types/dsh-adapter/migrate/parse/role-turns.d.ts +28 -0
- package/lib/types/dsh-adapter/migrate/parse/role-turns.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/parse/role-turns.js +50 -0
- package/lib/types/dsh-adapter/migrate/parse/title.d.ts +18 -0
- package/lib/types/dsh-adapter/migrate/parse/title.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/parse/title.js +29 -0
- package/lib/types/dsh-adapter/migrate/parse/tools.d.ts +62 -0
- package/lib/types/dsh-adapter/migrate/parse/tools.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/parse/tools.js +110 -0
- package/lib/types/dsh-adapter/migrate/picker.d.ts +64 -0
- package/lib/types/dsh-adapter/migrate/picker.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/picker.js +86 -0
- package/lib/types/dsh-adapter/migrate/recent-agents.d.ts +40 -0
- package/lib/types/dsh-adapter/migrate/recent-agents.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/recent-agents.js +100 -0
- package/lib/types/dsh-adapter/migrate/sessionize.d.ts +39 -0
- package/lib/types/dsh-adapter/migrate/sessionize.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/sessionize.js +271 -0
- package/lib/types/dsh-adapter/migrate/types.d.ts +176 -0
- package/lib/types/dsh-adapter/migrate/types.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/types.js +11 -0
- package/lib/types/dsh-adapter/migrate/uuid.d.ts +7 -0
- package/lib/types/dsh-adapter/migrate/uuid.d.ts.map +1 -0
- package/lib/types/dsh-adapter/migrate/uuid.js +25 -0
- package/lib/types/dsh-adapter/plugin.d.ts +5 -3
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +168 -372
- package/lib/types/dsh-adapter/providerWizard.d.ts +17 -0
- package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -1
- package/lib/types/dsh-adapter/providerWizard.js +254 -66
- package/lib/types/dsh-adapter/questions.d.ts +22 -15
- package/lib/types/dsh-adapter/questions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/questions.js +47 -45
- package/lib/types/dsh-adapter/sessions/digest.d.ts +11 -6
- package/lib/types/dsh-adapter/sessions/digest.d.ts.map +1 -1
- package/lib/types/dsh-adapter/sessions/digest.js +20 -13
- package/lib/types/dsh-adapter/sessions/frames.d.ts +3 -1
- package/lib/types/dsh-adapter/sessions/frames.d.ts.map +1 -1
- package/lib/types/dsh-adapter/sessions/frames.js +5 -4
- package/lib/types/dsh-adapter/sessions/list.d.ts +6 -1
- package/lib/types/dsh-adapter/sessions/list.d.ts.map +1 -1
- package/lib/types/dsh-adapter/sessions/list.js +188 -164
- package/lib/types/dsh-adapter/sessions/recovery.d.ts +16 -0
- package/lib/types/dsh-adapter/sessions/recovery.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sessions/recovery.js +108 -0
- package/lib/types/dsh-adapter/sessions/snapshot.d.ts +7 -0
- package/lib/types/dsh-adapter/sessions/snapshot.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sessions/snapshot.js +90 -0
- package/lib/types/dsh-adapter/sessions/store.d.ts +10 -4
- package/lib/types/dsh-adapter/sessions/store.d.ts.map +1 -1
- package/lib/types/dsh-adapter/sessions/store.js +62 -25
- package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
- package/lib/types/dsh-adapter/settings-sections.js +7 -4
- package/lib/types/dsh-adapter/sideQuestion.d.ts +41 -2
- package/lib/types/dsh-adapter/sideQuestion.d.ts.map +1 -1
- package/lib/types/dsh-adapter/sideQuestion.js +98 -2
- package/lib/types/dsh-adapter/subagents.d.ts +44 -6
- package/lib/types/dsh-adapter/subagents.d.ts.map +1 -1
- package/lib/types/dsh-adapter/subagents.js +163 -26
- package/lib/types/herdr.d.ts +2 -0
- package/lib/types/herdr.d.ts.map +1 -1
- package/lib/types/herdr.js +9 -3
- package/lib/types/history.d.ts +13 -1
- package/lib/types/history.d.ts.map +1 -1
- package/lib/types/history.js +15 -2
- package/lib/types/i18n.d.ts +512 -41
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +199 -20
- package/lib/types/ink/components/App.d.ts +2 -2
- package/lib/types/ink/components/App.d.ts.map +1 -1
- package/lib/types/ink/components/App.js +5 -1
- package/lib/types/ink/components/Image.d.ts +14 -1
- package/lib/types/ink/components/Image.d.ts.map +1 -1
- package/lib/types/ink/components/Image.js +2 -2
- package/lib/types/ink/events/input-event.js +3 -3
- package/lib/types/ink/hooks/use-terminal-images.d.ts +12 -0
- package/lib/types/ink/hooks/use-terminal-images.d.ts.map +1 -1
- package/lib/types/ink/hooks/use-terminal-images.js +13 -0
- package/lib/types/ink/ink.d.ts +6 -0
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +16 -1
- package/lib/types/ink/kitty-graphics.d.ts +44 -3
- package/lib/types/ink/kitty-graphics.d.ts.map +1 -1
- package/lib/types/ink/kitty-graphics.js +184 -23
- package/lib/types/ink/log-update.d.ts.map +1 -1
- package/lib/types/ink/log-update.js +19 -1
- package/lib/types/ink/output.d.ts +24 -2
- package/lib/types/ink/output.d.ts.map +1 -1
- package/lib/types/ink/output.js +83 -5
- package/lib/types/ink/parse-keypress.d.ts +26 -1
- package/lib/types/ink/parse-keypress.d.ts.map +1 -1
- package/lib/types/ink/parse-keypress.js +156 -13
- package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
- package/lib/types/ink/render-node-to-output.js +8 -1
- package/lib/types/ink/screen.d.ts +24 -0
- package/lib/types/ink/screen.d.ts.map +1 -1
- package/lib/types/ink/screen.js +89 -0
- package/lib/types/ink/selection.d.ts +68 -18
- package/lib/types/ink/selection.d.ts.map +1 -1
- package/lib/types/ink/selection.js +178 -31
- package/lib/types/ink/sixel-codec.d.ts +12 -1
- package/lib/types/ink/sixel-codec.d.ts.map +1 -1
- package/lib/types/ink/sixel-codec.js +29 -5
- package/lib/types/ink/sixel-graphics.d.ts.map +1 -1
- package/lib/types/ink/sixel-graphics.js +5 -3
- package/lib/types/ink/styles.d.ts +9 -0
- package/lib/types/ink/styles.d.ts.map +1 -1
- package/lib/types/ink/terminal-image.d.ts +8 -0
- package/lib/types/ink/terminal-image.d.ts.map +1 -1
- package/lib/types/ink/terminal-querier.d.ts +7 -1
- package/lib/types/ink/terminal-querier.d.ts.map +1 -1
- package/lib/types/ink/terminal-querier.js +12 -2
- package/lib/types/ink/timeline-rail.d.ts +5 -0
- package/lib/types/ink/timeline-rail.d.ts.map +1 -1
- package/lib/types/math/inline-layout.d.ts +29 -0
- package/lib/types/math/inline-layout.d.ts.map +1 -0
- package/lib/types/math/inline-layout.js +106 -0
- package/lib/types/math/layout.d.ts +58 -0
- package/lib/types/math/layout.d.ts.map +1 -0
- package/lib/types/math/layout.js +59 -0
- package/lib/types/math/renderer.d.ts +64 -0
- package/lib/types/math/renderer.d.ts.map +1 -0
- package/lib/types/math/renderer.js +256 -0
- package/lib/types/screens/Chat.d.ts +17 -1
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +618 -57
- package/lib/types/screens/SessionSupervisor.d.ts +2 -1
- package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
- package/lib/types/screens/SessionSupervisor.js +156 -19
- package/lib/types/screens/Settings.d.ts.map +1 -1
- package/lib/types/screens/Settings.js +49 -11
- package/lib/types/screens/StatusLine.d.ts +5 -1
- package/lib/types/screens/StatusLine.d.ts.map +1 -1
- package/lib/types/screens/StatusLine.js +47 -17
- package/lib/types/screens/chatOverlay.d.ts +5 -0
- package/lib/types/screens/chatOverlay.d.ts.map +1 -1
- package/lib/types/screens/chatOverlay.js +1 -0
- package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts +47 -0
- package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -0
- package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +65 -0
- package/lib/types/screens/sessionSupervisor/model.d.ts +12 -0
- package/lib/types/screens/sessionSupervisor/model.d.ts.map +1 -1
- package/lib/types/screens/sessionSupervisor/model.js +26 -0
- package/lib/types/screens/sessionSupervisor/useForeignSessions.d.ts +107 -0
- package/lib/types/screens/sessionSupervisor/useForeignSessions.d.ts.map +1 -0
- package/lib/types/screens/sessionSupervisor/useForeignSessions.js +312 -0
- package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts +4 -1
- package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts.map +1 -1
- package/lib/types/screens/sessionSupervisor/useSessionSupervisor.js +97 -14
- package/lib/types/sessionHistory.d.ts +2 -2
- package/lib/types/sessionHistory.d.ts.map +1 -1
- package/lib/types/sessionHistory.js +31 -5
- package/lib/types/settings/definitions.d.ts +681 -0
- package/lib/types/settings/definitions.d.ts.map +1 -0
- package/lib/types/settings/definitions.js +511 -0
- package/lib/types/starAction.d.ts +44 -0
- package/lib/types/starAction.d.ts.map +1 -0
- package/lib/types/starAction.js +52 -0
- package/lib/types/terminal-utils/latex.d.ts +10 -0
- package/lib/types/terminal-utils/latex.d.ts.map +1 -0
- package/lib/types/terminal-utils/latex.js +1417 -0
- package/lib/types/terminal-utils/markdown.d.ts +3 -1
- package/lib/types/terminal-utils/markdown.d.ts.map +1 -1
- package/lib/types/terminal-utils/markdown.js +26 -1
- package/lib/types/terminal-utils/math.d.ts +66 -0
- package/lib/types/terminal-utils/math.d.ts.map +1 -0
- package/lib/types/terminal-utils/math.js +337 -0
- package/lib/types/tips.d.ts.map +1 -1
- package/lib/types/tips.js +6 -0
- package/lib/types/tuiDisplayPrefs.d.ts +67 -0
- package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
- package/lib/types/tuiDisplayPrefs.js +59 -0
- package/lib/types/ui.d.ts +1 -1
- package/lib/types/ui.d.ts.map +1 -1
- package/lib/types/ui.js +1 -1
- package/lib/types/usageStats.d.ts +98 -0
- package/lib/types/usageStats.d.ts.map +1 -0
- package/lib/types/usageStats.js +169 -0
- package/lib/types/utils/bmp.d.ts +17 -0
- package/lib/types/utils/bmp.d.ts.map +1 -0
- package/lib/types/utils/bmp.js +154 -0
- package/lib/types/utils/clipboard.d.ts +14 -2
- package/lib/types/utils/clipboard.d.ts.map +1 -1
- package/lib/types/utils/clipboard.js +143 -8
- package/lib/types/utils/fold-long-lines.d.ts +1 -1
- package/lib/types/utils/fold-long-lines.d.ts.map +1 -1
- package/lib/types/utils/fold-long-lines.js +3 -2
- package/lib/types/utils/keymap.d.ts +4 -1
- package/lib/types/utils/keymap.d.ts.map +1 -1
- package/lib/types/utils/keymap.js +8 -0
- package/lib/types/utils/modifiers.d.ts +4 -3
- package/lib/types/utils/modifiers.d.ts.map +1 -1
- package/lib/types/utils/modifiers.js +4 -3
- package/lib/types/working-activity.d.ts +10 -9
- package/lib/types/working-activity.d.ts.map +1 -1
- package/lib/types/working-activity.js +17 -10
- package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/LICENSE +202 -0
- package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/NOTICE +20 -0
- package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/index.d.ts +16 -0
- package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/lib/bundled-packages.json +4 -0
- package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/lib/index.mjs +20 -0
- package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/lib/index.mjs.LEGAL.txt +35 -0
- package/node_modules/@dsh-tui-vendor/mathjax-tex-svg/package.json +29 -0
- package/package.json +117 -99
- package/lib/types/components/design-system/KeyboardShortcutHint.d.ts +0 -19
- package/lib/types/components/design-system/KeyboardShortcutHint.d.ts.map +0 -1
- package/lib/types/components/design-system/KeyboardShortcutHint.js +0 -14
- package/lib/types/dsh-adapter/channel/activity.d.ts +0 -20
- package/lib/types/dsh-adapter/channel/activity.d.ts.map +0 -1
- package/lib/types/dsh-adapter/channel/activity.js +0 -113
- package/lib/types/terminal-utils/terminal.d.ts +0 -18
- package/lib/types/terminal-utils/terminal.d.ts.map +0 -1
- package/lib/types/terminal-utils/terminal.js +0 -96
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type AdapterScanSpec } from './recent-agents.js';
|
|
2
|
+
/** One selectable picker row (rendered by components/MigratePicker.tsx). */
|
|
3
|
+
export interface MigratePickerRow {
|
|
4
|
+
readonly agentId: string;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly count: number;
|
|
7
|
+
/** Minutes since the newest source activity, when inside the window. */
|
|
8
|
+
readonly minutesAgo?: number;
|
|
9
|
+
}
|
|
10
|
+
/** Each adapter's name-only scan shape, shared by count() callers and the activity hint. */
|
|
11
|
+
export declare const MIGRATE_SCAN_SPECS: Readonly<Record<string, AdapterScanSpec>>;
|
|
12
|
+
/**
|
|
13
|
+
* Collect picker rows for every registered adapter: scan count plus a
|
|
14
|
+
* recent-activity badge when the source was used inside the window. Recent
|
|
15
|
+
* sources sort first (newest activity at top), cold sources keep registry
|
|
16
|
+
* order. Sub-second at real-world scale, but still meant for a background
|
|
17
|
+
* pass — never the render path.
|
|
18
|
+
*/
|
|
19
|
+
export declare function collectMigratePickerRows(nowMs: number): MigratePickerRow[];
|
|
20
|
+
/** One source's import outcome, parsed from the CLI child's stdout. */
|
|
21
|
+
export interface ImportSummary {
|
|
22
|
+
readonly agentId: string;
|
|
23
|
+
readonly imported: number;
|
|
24
|
+
readonly existing: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse per-source import counters out of the CLI's report lines
|
|
28
|
+
* (`[<agentId>] imported 12 · already present 3`). Pure string work so the
|
|
29
|
+
* TUI's completion notification can carry real numbers (PRD #3) without
|
|
30
|
+
* re-running any scan.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseImportSummary(stdout: string): ImportSummary[];
|
|
33
|
+
/**
|
|
34
|
+
* Classify one `/migrate` command line (the text AFTER the command word) into
|
|
35
|
+
* the action Chat must take. Pure and registry-driven on purpose: whether a
|
|
36
|
+
* command is valid must never depend on the picker having been opened first
|
|
37
|
+
* (`migrateRows` is empty on a fresh mount, which used to make every
|
|
38
|
+
* `/migrate <agent>` report an unknown source), and the CLI keeps the same
|
|
39
|
+
* one-source rule (`dsh-tui migrate a b` is a usage error there too).
|
|
40
|
+
*
|
|
41
|
+
* @param rawInput - arguments after `/migrate`, e.g. `" claude-code --dry-run"`.
|
|
42
|
+
* @param knownAgentIds - the adapter registry's ids (see MIGRATION_ADAPTERS).
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveMigrateCommand(rawInput: string, knownAgentIds: readonly string[]): MigrateCommand;
|
|
45
|
+
/** What one `/migrate` line asks for. */
|
|
46
|
+
export type MigrateCommand = {
|
|
47
|
+
readonly kind: 'picker';
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: 'import';
|
|
50
|
+
readonly agentId: string;
|
|
51
|
+
readonly dryRun: boolean;
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: 'unknown';
|
|
54
|
+
readonly agentId: string;
|
|
55
|
+
}
|
|
56
|
+
/** More than one source named: rejected, like the CLI's usage error. */
|
|
57
|
+
| {
|
|
58
|
+
readonly kind: 'usage';
|
|
59
|
+
}
|
|
60
|
+
/** `--dry-run` with no source: previewing needs to know what to preview. */
|
|
61
|
+
| {
|
|
62
|
+
readonly kind: 'dry-run-needs-source';
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picker.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/migrate/picker.ts"],"names":[],"mappings":"AAWA,OAAO,EAA4C,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEnG,4EAA4E;AAC5E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,wEAAwE;IACxE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,4FAA4F;AAC5F,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAMxE,CAAA;AAID;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAc1E;AAED,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE,CAUlE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CAWxG;AAED,yCAAyC;AACzC,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC/E;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AACxD,wEAAwE;GACtE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE;AAC5B,4EAA4E;GAC1E;IAAE,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data collection for the `/migrate` source picker, plus the command
|
|
3
|
+
* classifier and the child-report parser.
|
|
4
|
+
*
|
|
5
|
+
* Combines the name-only scan count (list mode's fast path) with the
|
|
6
|
+
* recent-activity detector into the row shape the picker renders. Pure data:
|
|
7
|
+
* no React, no Cordis — Chat imports these helpers and owns all UI.
|
|
8
|
+
*
|
|
9
|
+
* @module @deepseek-harness-tui/dsh-tui/migrate/picker
|
|
10
|
+
*/
|
|
11
|
+
import { MIGRATION_ADAPTERS } from './index.js';
|
|
12
|
+
import { collectActivitySamples, recentAgentsFrom } from './recent-agents.js';
|
|
13
|
+
/** Each adapter's name-only scan shape, shared by count() callers and the activity hint. */
|
|
14
|
+
export const MIGRATE_SCAN_SPECS = {
|
|
15
|
+
'claude-code': { maxDepth: 3, fileMatch: name => name.endsWith('.jsonl') },
|
|
16
|
+
codex: { maxDepth: 5, fileMatch: name => name.startsWith('rollout-') && name.endsWith('.jsonl') },
|
|
17
|
+
omp: { maxDepth: 3, fileMatch: name => name.endsWith('.jsonl') },
|
|
18
|
+
zcode: { maxDepth: 3, fileMatch: name => name.endsWith('.json') },
|
|
19
|
+
'grok-build': { maxDepth: 2, fileMatch: name => name === 'chat_history.jsonl' },
|
|
20
|
+
};
|
|
21
|
+
const scanOf = (agentId) => MIGRATE_SCAN_SPECS[agentId];
|
|
22
|
+
/**
|
|
23
|
+
* Collect picker rows for every registered adapter: scan count plus a
|
|
24
|
+
* recent-activity badge when the source was used inside the window. Recent
|
|
25
|
+
* sources sort first (newest activity at top), cold sources keep registry
|
|
26
|
+
* order. Sub-second at real-world scale, but still meant for a background
|
|
27
|
+
* pass — never the render path.
|
|
28
|
+
*/
|
|
29
|
+
export function collectMigratePickerRows(nowMs) {
|
|
30
|
+
const samples = collectActivitySamples(MIGRATION_ADAPTERS, adapter => scanOf(adapter.id));
|
|
31
|
+
const recent = new Map(recentAgentsFrom(samples, nowMs).map(agent => [agent.agentId, agent.minutesAgo]));
|
|
32
|
+
const rows = MIGRATION_ADAPTERS.map(adapter => ({
|
|
33
|
+
agentId: adapter.id,
|
|
34
|
+
label: adapter.label,
|
|
35
|
+
count: adapter.count !== undefined ? adapter.count() : adapter.discover().sessions.length,
|
|
36
|
+
minutesAgo: recent.get(adapter.id),
|
|
37
|
+
}));
|
|
38
|
+
return rows.sort((a, b) => {
|
|
39
|
+
const aRecent = a.minutesAgo ?? Number.MAX_SAFE_INTEGER;
|
|
40
|
+
const bRecent = b.minutesAgo ?? Number.MAX_SAFE_INTEGER;
|
|
41
|
+
return aRecent - bRecent;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parse per-source import counters out of the CLI's report lines
|
|
46
|
+
* (`[<agentId>] imported 12 · already present 3`). Pure string work so the
|
|
47
|
+
* TUI's completion notification can carry real numbers (PRD #3) without
|
|
48
|
+
* re-running any scan.
|
|
49
|
+
*/
|
|
50
|
+
export function parseImportSummary(stdout) {
|
|
51
|
+
const summaries = [];
|
|
52
|
+
for (const match of stdout.matchAll(/\[([a-z0-9-]+)\] imported (\d+)(?: · already present (\d+))?/gu)) {
|
|
53
|
+
summaries.push({
|
|
54
|
+
agentId: match[1],
|
|
55
|
+
imported: Number(match[2]),
|
|
56
|
+
existing: match[3] === undefined ? 0 : Number(match[3]),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return summaries;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Classify one `/migrate` command line (the text AFTER the command word) into
|
|
63
|
+
* the action Chat must take. Pure and registry-driven on purpose: whether a
|
|
64
|
+
* command is valid must never depend on the picker having been opened first
|
|
65
|
+
* (`migrateRows` is empty on a fresh mount, which used to make every
|
|
66
|
+
* `/migrate <agent>` report an unknown source), and the CLI keeps the same
|
|
67
|
+
* one-source rule (`dsh-tui migrate a b` is a usage error there too).
|
|
68
|
+
*
|
|
69
|
+
* @param rawInput - arguments after `/migrate`, e.g. `" claude-code --dry-run"`.
|
|
70
|
+
* @param knownAgentIds - the adapter registry's ids (see MIGRATION_ADAPTERS).
|
|
71
|
+
*/
|
|
72
|
+
export function resolveMigrateCommand(rawInput, knownAgentIds) {
|
|
73
|
+
const words = rawInput.trim().split(/\s+/u).filter(Boolean);
|
|
74
|
+
const dryRun = words.includes('--dry-run');
|
|
75
|
+
const agents = words.filter(word => word !== '--dry-run');
|
|
76
|
+
// One source per invocation: the CLI rejects a second word, and silently
|
|
77
|
+
// importing only the first would hide which selection the user asked for.
|
|
78
|
+
if (agents.length > 1)
|
|
79
|
+
return { kind: 'usage' };
|
|
80
|
+
const wanted = agents[0];
|
|
81
|
+
if (wanted === undefined)
|
|
82
|
+
return dryRun ? { kind: 'dry-run-needs-source' } : { kind: 'picker' };
|
|
83
|
+
if (!knownAgentIds.includes(wanted))
|
|
84
|
+
return { kind: 'unknown', agentId: wanted };
|
|
85
|
+
return { kind: 'import', agentId: wanted, dryRun };
|
|
86
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MigrationAdapter } from './types.js';
|
|
2
|
+
/** How recent the newest source activity must be to earn a hint. */
|
|
3
|
+
export declare const RECENT_ACTIVITY_WINDOW_MS: number;
|
|
4
|
+
/** One source's last-activity sample. `newestMtimeMs: null` = no data. */
|
|
5
|
+
export interface ActivitySample {
|
|
6
|
+
readonly agentId: string;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly newestMtimeMs: number | null;
|
|
9
|
+
}
|
|
10
|
+
/** A source that was active inside the window. */
|
|
11
|
+
export interface RecentAgent {
|
|
12
|
+
readonly agentId: string;
|
|
13
|
+
readonly label: string;
|
|
14
|
+
/** Minutes since the newest activity, rounded down (≥ 0). */
|
|
15
|
+
readonly minutesAgo: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Pure judgment: which samples count as recent, newest first.
|
|
19
|
+
* @param samples - one per source, `null` mtime = no data (never recent).
|
|
20
|
+
* @param nowMs - the current epoch milliseconds (injected for testability).
|
|
21
|
+
* @param windowMs - activity window, default 20 minutes.
|
|
22
|
+
*/
|
|
23
|
+
export declare function recentAgentsFrom(samples: readonly ActivitySample[], nowMs: number, windowMs?: number): RecentAgent[];
|
|
24
|
+
/**
|
|
25
|
+
* Newest file mtime under one set of roots, name-matched only (the counter's
|
|
26
|
+
* walk shape — no parsing). Returns null when nothing matches or IO fails;
|
|
27
|
+
* failures must read as "no data", never as "long ago".
|
|
28
|
+
*/
|
|
29
|
+
export declare function collectNewestMtime(roots: readonly string[], fileMatch: (name: string) => boolean, maxDepth: number): number | null;
|
|
30
|
+
/** The file-name matcher and walk depth an adapter's count() uses. */
|
|
31
|
+
export interface AdapterScanSpec {
|
|
32
|
+
readonly maxDepth: number;
|
|
33
|
+
readonly fileMatch: (name: string) => boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Collect one sample per adapter that can describe its scan; adapters
|
|
37
|
+
* without count() (no name-only scan shape) are skipped, not guessed.
|
|
38
|
+
*/
|
|
39
|
+
export declare function collectActivitySamples(adapters: readonly MigrationAdapter[], scanOf: (adapter: MigrationAdapter) => AdapterScanSpec | undefined): ActivitySample[];
|
|
40
|
+
//# sourceMappingURL=recent-agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recent-agents.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/migrate/recent-agents.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,oEAAoE;AACpE,eAAO,MAAM,yBAAyB,QAAiB,CAAA;AAEvD,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CACtC;AAED,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,MAAkC,GAC3C,WAAW,EAAE,CAUf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,EACpC,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,IAAI,CA4Bf;AAED,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CAC9C;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EACrC,MAAM,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,eAAe,GAAG,SAAS,GACjE,cAAc,EAAE,CAYlB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recent foreign-agent activity detection for the migration hint.
|
|
3
|
+
*
|
|
4
|
+
* "Did the user just come from another coding agent?" is answered from file
|
|
5
|
+
* mtimes inside each source store: an active conversation appends to its
|
|
6
|
+
* log in real time (claude-code updates within the same minute), so the
|
|
7
|
+
* NEWEST file mtime per source is a faithful last-activity signal with good
|
|
8
|
+
* separation (measured on a real machine: 0min vs 117min vs 5867min across
|
|
9
|
+
* sources). Parent-directory mtimes would miss appends to existing
|
|
10
|
+
* conversations, so the scan is file-level — bounded by the same
|
|
11
|
+
* name-matching walk as the list-mode counter (sub-second at ~3000 files)
|
|
12
|
+
* and meant for a BACKGROUND pass, never the render path.
|
|
13
|
+
*
|
|
14
|
+
* Split: `recentAgentsFrom` is a pure judgment over collected samples
|
|
15
|
+
* (directly testable with fixture mtimes); `collectNewestMtime` is the IO
|
|
16
|
+
* collector; `detectRecentAgents` binds them for the TUI.
|
|
17
|
+
*
|
|
18
|
+
* @module @deepseek-harness-tui/dsh-tui/migrate/recent-agents
|
|
19
|
+
*/
|
|
20
|
+
import { readdirSync, statSync } from 'node:fs';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
/** How recent the newest source activity must be to earn a hint. */
|
|
23
|
+
export const RECENT_ACTIVITY_WINDOW_MS = 20 * 60 * 1000;
|
|
24
|
+
/**
|
|
25
|
+
* Pure judgment: which samples count as recent, newest first.
|
|
26
|
+
* @param samples - one per source, `null` mtime = no data (never recent).
|
|
27
|
+
* @param nowMs - the current epoch milliseconds (injected for testability).
|
|
28
|
+
* @param windowMs - activity window, default 20 minutes.
|
|
29
|
+
*/
|
|
30
|
+
export function recentAgentsFrom(samples, nowMs, windowMs = RECENT_ACTIVITY_WINDOW_MS) {
|
|
31
|
+
const recent = [];
|
|
32
|
+
for (const sample of samples) {
|
|
33
|
+
if (sample.newestMtimeMs === null)
|
|
34
|
+
continue;
|
|
35
|
+
const age = nowMs - sample.newestMtimeMs;
|
|
36
|
+
if (age < 0 || age > windowMs)
|
|
37
|
+
continue;
|
|
38
|
+
recent.push({ agentId: sample.agentId, label: sample.label, minutesAgo: Math.floor(age / 60_000) });
|
|
39
|
+
}
|
|
40
|
+
recent.sort((a, b) => a.minutesAgo - b.minutesAgo);
|
|
41
|
+
return recent;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Newest file mtime under one set of roots, name-matched only (the counter's
|
|
45
|
+
* walk shape — no parsing). Returns null when nothing matches or IO fails;
|
|
46
|
+
* failures must read as "no data", never as "long ago".
|
|
47
|
+
*/
|
|
48
|
+
export function collectNewestMtime(roots, fileMatch, maxDepth) {
|
|
49
|
+
const match = fileMatch;
|
|
50
|
+
let newest = null;
|
|
51
|
+
const walk = (dir, depth) => {
|
|
52
|
+
if (depth > maxDepth)
|
|
53
|
+
return;
|
|
54
|
+
let entries;
|
|
55
|
+
try {
|
|
56
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
for (const entry of entries) {
|
|
62
|
+
const path = join(dir, entry.name);
|
|
63
|
+
if (entry.isDirectory()) {
|
|
64
|
+
walk(path, depth + 1);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (!entry.isFile() || !match(entry.name))
|
|
68
|
+
continue;
|
|
69
|
+
try {
|
|
70
|
+
const mtimeMs = statSync(path).mtimeMs;
|
|
71
|
+
if (newest === null || mtimeMs > newest)
|
|
72
|
+
newest = mtimeMs;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// A stat race on one file costs that file, not the scan.
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
for (const root of roots)
|
|
80
|
+
walk(root, 0);
|
|
81
|
+
return newest;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Collect one sample per adapter that can describe its scan; adapters
|
|
85
|
+
* without count() (no name-only scan shape) are skipped, not guessed.
|
|
86
|
+
*/
|
|
87
|
+
export function collectActivitySamples(adapters, scanOf) {
|
|
88
|
+
const samples = [];
|
|
89
|
+
for (const adapter of adapters) {
|
|
90
|
+
const spec = scanOf(adapter);
|
|
91
|
+
if (spec === undefined)
|
|
92
|
+
continue;
|
|
93
|
+
samples.push({
|
|
94
|
+
agentId: adapter.id,
|
|
95
|
+
label: adapter.label,
|
|
96
|
+
newestMtimeMs: collectNewestMtime(adapter.roots(), spec.fileMatch, spec.maxDepth),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return samples;
|
|
100
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session';
|
|
2
|
+
import type { MigrationSession } from './types.js';
|
|
3
|
+
/** One migration turn's model-visible outcome, ready for persistence. */
|
|
4
|
+
export interface SessionizedLog {
|
|
5
|
+
readonly header: SessionHeader;
|
|
6
|
+
readonly events: readonly SessionEvent[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The empty system head an imported log opens with, in whichever shape the
|
|
10
|
+
* installed harness writes. `createSystemMessage` changed arity between the
|
|
11
|
+
* validated lines: 0.1.5-alpha.2 takes the owning plugin and stamps a plugin
|
|
12
|
+
* source, later lines take the text alone and stamp `system-prompt`. Calling
|
|
13
|
+
* it with both arguments lets each line build its own native head (the later
|
|
14
|
+
* one ignores the extra argument) instead of this module hard-coding either.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The checkpoint framing the native compaction engine writes around a summary
|
|
18
|
+
* (dsh-compaction-basic `frameSummary`): a preamble, then the summary inside
|
|
19
|
+
* `<compacted-summary>` tags. The tags are how a LATER compaction recognises
|
|
20
|
+
* this node as a prior checkpoint and merges it instead of summarising the
|
|
21
|
+
* summary, so an imported checkpoint has to carry them exactly. The package
|
|
22
|
+
* does not export the constants; verify-migrate pins these against the
|
|
23
|
+
* installed engine's own source so a drift fails the regression.
|
|
24
|
+
*/
|
|
25
|
+
export declare const CHECKPOINT_PREAMBLE = "This is an automatically generated checkpoint condensing an earlier span of the conversation to free up context. Treat the captured context as established background and build on it without restating it. Continue the task directly from the messages that follow, without acknowledging this checkpoint.";
|
|
26
|
+
export declare const SUMMARY_OPEN_TAG = "<compacted-summary>";
|
|
27
|
+
export declare const SUMMARY_CLOSE_TAG = "</compacted-summary>";
|
|
28
|
+
/**
|
|
29
|
+
* Build one official DSH session log from a normalized foreign conversation.
|
|
30
|
+
*
|
|
31
|
+
* @param id - deterministic session id (see uuid.ts); the id IS the dedupe.
|
|
32
|
+
* @param agentId - source adapter id, stamped into assistant provenance as
|
|
33
|
+
* `migrated:<agentId>` so the transcript can name where text came from.
|
|
34
|
+
* @param session - the normalized foreign conversation.
|
|
35
|
+
* @returns the official header plus the full event log, exactly as the
|
|
36
|
+
* persistence backend expects them.
|
|
37
|
+
*/
|
|
38
|
+
export declare function sessionize(id: SessionId, agentId: string, session: MigrationSession): SessionizedLog;
|
|
39
|
+
//# sourceMappingURL=sessionize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionize.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/migrate/sessionize.ts"],"names":[],"mappings":"AA0DA,OAAO,EAGL,SAAS,EAET,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAc,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAc9D,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAA;CACzC;AAgBD;;;;;;;GAOG;AACH;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,iTAAiT,CAAA;AACjV,eAAO,MAAM,gBAAgB,wBAAwB,CAAA;AACrD,eAAO,MAAM,iBAAiB,yBAAyB,CAAA;AAevD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAmJpG"}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-agent conversation migration: MigrationSession → official DSH events.
|
|
3
|
+
*
|
|
4
|
+
* The sessionize step owns NO storage decisions. It drives the official
|
|
5
|
+
* `Session` logical-event API (`Session.create` + `append`), so envelope
|
|
6
|
+
* fields (seq/time/id), surface contract and format version come from the
|
|
7
|
+
* upstream implementation — the part the first iteration of this feature got
|
|
8
|
+
* wrong by hand-crafting physical log rows. Physical encoding, project
|
|
9
|
+
* layout, zstd and atomic writes belong to JsonlSessionPersistence (see
|
|
10
|
+
* index.ts), exactly as scripts/migrate-sessions-to-jsonl.mts does for the
|
|
11
|
+
* retired sqlite store.
|
|
12
|
+
*
|
|
13
|
+
* Turn shape follows the live loop: `turn/start`, then one step per
|
|
14
|
+
* {@link ImportStep} with the turn's prompt as the first step's user message,
|
|
15
|
+
* then `turn/end`. A turn with no prompt (source lost its head) carries no
|
|
16
|
+
* user message; a turn with no step is a legal step-less turn whose prompt
|
|
17
|
+
* sits directly inside the turn.
|
|
18
|
+
*
|
|
19
|
+
* Inside a step, events follow the live loop too: the step's user inputs
|
|
20
|
+
* (mid-turn context), the assistant message whose content carries the
|
|
21
|
+
* tool-call blocks, one `tool/call` per call, then one `tool/result` per
|
|
22
|
+
* call citing its call event. Parsing already closed every call
|
|
23
|
+
* (closeToolPairs), so no step leaves a call unanswered — the invariant the
|
|
24
|
+
* wire needs on resume: every tool call is followed by its tool message
|
|
25
|
+
* before any later assistant message.
|
|
26
|
+
*
|
|
27
|
+
* System head: the live loop reserves surface node 0 for the system prompt
|
|
28
|
+
* (an empty `system/message` in the first step, before any user message).
|
|
29
|
+
* An imported log gets the same empty head: it projects to no message, so
|
|
30
|
+
* re-reading is unchanged, and when the session is resumed the loop REPLACES
|
|
31
|
+
* it with the rendered prompt. Without it the loop appends its prompt after
|
|
32
|
+
* the imported history, where adapters that only lift a LEADING system
|
|
33
|
+
* message (pi-ai) send it as one more user message.
|
|
34
|
+
*
|
|
35
|
+
* Compaction: a turn carrying {@link ImportTurn.compaction} is preceded by
|
|
36
|
+
* one native compaction transaction — `compaction/start` (standalone,
|
|
37
|
+
* `turn: null`), `compaction/summary`, the checkpoint `user/message` that
|
|
38
|
+
* REPLACES every surface node after the head, `compaction/end` — the same
|
|
39
|
+
* shape `/compact` writes. The raw log keeps the shadowed events (replay
|
|
40
|
+
* stays exact) while the model sees the checkpoint plus what follows, which
|
|
41
|
+
* is the context the source agent itself continued with. The upstream
|
|
42
|
+
* compaction package is not a dependency here, so its event and source
|
|
43
|
+
* shapes are written structurally (see compactionEvents below).
|
|
44
|
+
*
|
|
45
|
+
* Title: only a title the SOURCE owns (`titleExplicit`) is written, as one
|
|
46
|
+
* trailing `session/title` — a first-prompt fallback is left out so DSH
|
|
47
|
+
* derives it from the first user message exactly as for a native session.
|
|
48
|
+
*
|
|
49
|
+
* @module @deepseek-harness-tui/dsh-tui/migrate/sessionize
|
|
50
|
+
*/
|
|
51
|
+
import { ToolCallId, createAssistantMessage, createSystemMessage, createToolResultMessage, createUserMessage, } from '@deepseek-ai/dsh-llm';
|
|
52
|
+
import { SESSION_FORMAT_VERSION, Session, } from '@deepseek-ai/dsh-session';
|
|
53
|
+
import { userTitleData } from '../compat/sessionLog.js';
|
|
54
|
+
import { normalizeTitle } from './parse/title.js';
|
|
55
|
+
/** Rough token estimate for shadowed text (the compaction metering field). */
|
|
56
|
+
function estimateTokens(chars) {
|
|
57
|
+
return Math.ceil(chars / 4);
|
|
58
|
+
}
|
|
59
|
+
/** Blocks for one migrated step, in source order (reasoning before the text
|
|
60
|
+
* it explains, tool calls where the model made them). A step with no
|
|
61
|
+
* content keeps one empty text block so the assistant message stays
|
|
62
|
+
* well-formed. */
|
|
63
|
+
function assistantBlocks(step) {
|
|
64
|
+
const blocks = step.blocks.map(block => block.type === 'tool-call'
|
|
65
|
+
? { type: 'tool-call', id: ToolCallId(block.id), name: block.name, arguments: block.arguments }
|
|
66
|
+
: { type: block.type, text: block.text });
|
|
67
|
+
if (blocks.length === 0)
|
|
68
|
+
blocks.push({ type: 'text', text: '' });
|
|
69
|
+
return blocks;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The empty system head an imported log opens with, in whichever shape the
|
|
73
|
+
* installed harness writes. `createSystemMessage` changed arity between the
|
|
74
|
+
* validated lines: 0.1.5-alpha.2 takes the owning plugin and stamps a plugin
|
|
75
|
+
* source, later lines take the text alone and stamp `system-prompt`. Calling
|
|
76
|
+
* it with both arguments lets each line build its own native head (the later
|
|
77
|
+
* one ignores the extra argument) instead of this module hard-coding either.
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* The checkpoint framing the native compaction engine writes around a summary
|
|
81
|
+
* (dsh-compaction-basic `frameSummary`): a preamble, then the summary inside
|
|
82
|
+
* `<compacted-summary>` tags. The tags are how a LATER compaction recognises
|
|
83
|
+
* this node as a prior checkpoint and merges it instead of summarising the
|
|
84
|
+
* summary, so an imported checkpoint has to carry them exactly. The package
|
|
85
|
+
* does not export the constants; verify-migrate pins these against the
|
|
86
|
+
* installed engine's own source so a drift fails the regression.
|
|
87
|
+
*/
|
|
88
|
+
export const CHECKPOINT_PREAMBLE = 'This is an automatically generated checkpoint condensing an earlier span of the conversation to free up context. Treat the captured context as established background and build on it without restating it. Continue the task directly from the messages that follow, without acknowledging this checkpoint.';
|
|
89
|
+
export const SUMMARY_OPEN_TAG = '<compacted-summary>';
|
|
90
|
+
export const SUMMARY_CLOSE_TAG = '</compacted-summary>';
|
|
91
|
+
function frameCheckpoint(summary) {
|
|
92
|
+
return [
|
|
93
|
+
{ type: 'text', text: `${CHECKPOINT_PREAMBLE}\n\n${SUMMARY_OPEN_TAG}` },
|
|
94
|
+
{ type: 'text', text: summary },
|
|
95
|
+
{ type: 'text', text: SUMMARY_CLOSE_TAG },
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
function emptySystemHead() {
|
|
99
|
+
const create = createSystemMessage;
|
|
100
|
+
return create('', 'dsh-tui-migrate');
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Build one official DSH session log from a normalized foreign conversation.
|
|
104
|
+
*
|
|
105
|
+
* @param id - deterministic session id (see uuid.ts); the id IS the dedupe.
|
|
106
|
+
* @param agentId - source adapter id, stamped into assistant provenance as
|
|
107
|
+
* `migrated:<agentId>` so the transcript can name where text came from.
|
|
108
|
+
* @param session - the normalized foreign conversation.
|
|
109
|
+
* @returns the official header plus the full event log, exactly as the
|
|
110
|
+
* persistence backend expects them.
|
|
111
|
+
*/
|
|
112
|
+
export function sessionize(id, agentId, session) {
|
|
113
|
+
const header = {
|
|
114
|
+
version: SESSION_FORMAT_VERSION,
|
|
115
|
+
id,
|
|
116
|
+
createdAt: session.startedAt,
|
|
117
|
+
cwd: session.cwd,
|
|
118
|
+
isSeeded: false,
|
|
119
|
+
};
|
|
120
|
+
const model = Session.create(id, undefined, header);
|
|
121
|
+
// Collect each append()'s RETURN (a fully enveloped event) instead of the
|
|
122
|
+
// deprecated snapshotEvents() bulk read — upstream forbids NEW callers of
|
|
123
|
+
// the latter, and append already returns seq/time-stamped events.
|
|
124
|
+
const events = [];
|
|
125
|
+
let headWritten = false;
|
|
126
|
+
const writeHead = (turn, step) => {
|
|
127
|
+
events.push(model.append('system/message', { turn, step, message: emptySystemHead() }, { surfaceOp: 'append' }));
|
|
128
|
+
headWritten = true;
|
|
129
|
+
};
|
|
130
|
+
const writePrompt = (prompt) => {
|
|
131
|
+
if (prompt === '')
|
|
132
|
+
return;
|
|
133
|
+
surfaceChars += prompt.length;
|
|
134
|
+
events.push(model.append('user/message', createUserMessage({
|
|
135
|
+
content: [{ type: 'text', text: prompt }],
|
|
136
|
+
source: { kind: 'user' },
|
|
137
|
+
}), { surfaceOp: 'append' }));
|
|
138
|
+
};
|
|
139
|
+
const writeTools = (turn, step, imported) => {
|
|
140
|
+
const callSeqs = new Map();
|
|
141
|
+
for (const block of imported.blocks) {
|
|
142
|
+
if (block.type !== 'tool-call')
|
|
143
|
+
continue;
|
|
144
|
+
const call = model.append('tool/call', { turn, step, callId: ToolCallId(block.id), name: block.name, arguments: block.arguments });
|
|
145
|
+
events.push(call);
|
|
146
|
+
callSeqs.set(block.id, call.seq);
|
|
147
|
+
}
|
|
148
|
+
for (const result of imported.results) {
|
|
149
|
+
const callSeq = callSeqs.get(result.callId);
|
|
150
|
+
if (callSeq === undefined)
|
|
151
|
+
continue;
|
|
152
|
+
events.push(model.append('tool/result', {
|
|
153
|
+
turn,
|
|
154
|
+
step,
|
|
155
|
+
message: createToolResultMessage({
|
|
156
|
+
callId: ToolCallId(result.callId),
|
|
157
|
+
content: result.text === '' ? [] : [{ type: 'text', text: result.text }],
|
|
158
|
+
isError: result.isError,
|
|
159
|
+
}),
|
|
160
|
+
}, { surfaceOp: 'append', sourceEventSeqs: [callSeq] }));
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
let compactions = 0;
|
|
164
|
+
// Text volume on the surface since the last checkpoint, for the summary's
|
|
165
|
+
// shadowedTokenCount (an estimate, like the live engine's).
|
|
166
|
+
let surfaceChars = 0;
|
|
167
|
+
/** Fold every surface node after the head into one checkpoint; false when
|
|
168
|
+
* there is nothing to fold (the upstream contract needs a non-empty span). */
|
|
169
|
+
const writeCompaction = (summary, summaryModel) => {
|
|
170
|
+
const shadowed = model.surface.nodes.filter(seq => model.eventAt(seq)?.type !== 'system/message');
|
|
171
|
+
if (shadowed.length === 0)
|
|
172
|
+
return false;
|
|
173
|
+
compactions += 1;
|
|
174
|
+
const compactionId = `import:${id}:c${compactions}`;
|
|
175
|
+
const untyped = model;
|
|
176
|
+
const range = { start: shadowed[0], end: shadowed[shadowed.length - 1] };
|
|
177
|
+
events.push(untyped.append('compaction/start', { compactionId, turn: null }));
|
|
178
|
+
events.push(untyped.append('compaction/summary', {
|
|
179
|
+
compactionId,
|
|
180
|
+
summary: [{ type: 'text', text: summary }],
|
|
181
|
+
shadowedRange: range,
|
|
182
|
+
shadowedSeqs: shadowed,
|
|
183
|
+
shadowedTokenCount: estimateTokens(surfaceChars),
|
|
184
|
+
provider: `migrated:${agentId}`,
|
|
185
|
+
model: summaryModel ?? agentId,
|
|
186
|
+
}));
|
|
187
|
+
events.push(untyped.append('user/message', createUserMessage({
|
|
188
|
+
content: frameCheckpoint(summary),
|
|
189
|
+
// The compaction package's checkpoint marker (COMPACT_CHECKPOINT_MARKER).
|
|
190
|
+
source: { kind: 'compact-checkpoint', compactionId },
|
|
191
|
+
}), { surfaceOp: { op: 'replace', startSeq: range.start, endSeq: range.end }, sourceEventSeqs: shadowed }));
|
|
192
|
+
events.push(untyped.append('compaction/end', { compactionId, turn: null }));
|
|
193
|
+
surfaceChars = summary.length;
|
|
194
|
+
return true;
|
|
195
|
+
};
|
|
196
|
+
let turnIndex = 0;
|
|
197
|
+
for (const turn of session.turns) {
|
|
198
|
+
// A summary with nothing before it to fold still reaches the model: it
|
|
199
|
+
// opens the turn as a plain user message instead.
|
|
200
|
+
let preface = '';
|
|
201
|
+
if (turn.compaction !== undefined && turn.compaction.summary !== '') {
|
|
202
|
+
if (!writeCompaction(turn.compaction.summary, turn.compaction.model))
|
|
203
|
+
preface = turn.compaction.summary;
|
|
204
|
+
// A boundary with no prompt and no step (the source stopped right at
|
|
205
|
+
// the compaction) needs no turn of its own.
|
|
206
|
+
if (turn.prompt === '' && turn.steps.length === 0 && preface === '')
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
turnIndex += 1;
|
|
210
|
+
events.push(model.append('turn/start', { turn: turnIndex }));
|
|
211
|
+
if (turn.steps.length === 0) {
|
|
212
|
+
if (headWritten) {
|
|
213
|
+
writePrompt(preface);
|
|
214
|
+
writePrompt(turn.prompt);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// The head needs an open step; a step-less first turn gets one that
|
|
218
|
+
// carries only the head and the prompt (no model call).
|
|
219
|
+
events.push(model.append('step/start', { turn: turnIndex, step: 1 }));
|
|
220
|
+
writeHead(turnIndex, 1);
|
|
221
|
+
writePrompt(preface);
|
|
222
|
+
writePrompt(turn.prompt);
|
|
223
|
+
events.push(model.append('step/end', { turn: turnIndex, step: 1 }));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
let step = 0;
|
|
227
|
+
for (const imported of turn.steps) {
|
|
228
|
+
step += 1;
|
|
229
|
+
events.push(model.append('step/start', { turn: turnIndex, step }));
|
|
230
|
+
if (!headWritten)
|
|
231
|
+
writeHead(turnIndex, step);
|
|
232
|
+
if (step === 1) {
|
|
233
|
+
writePrompt(preface);
|
|
234
|
+
writePrompt(turn.prompt);
|
|
235
|
+
}
|
|
236
|
+
for (const input of imported.inputs)
|
|
237
|
+
writePrompt(input);
|
|
238
|
+
for (const block of imported.blocks)
|
|
239
|
+
surfaceChars += block.type === 'tool-call' ? block.arguments.length : block.text.length;
|
|
240
|
+
for (const result of imported.results)
|
|
241
|
+
surfaceChars += result.text.length;
|
|
242
|
+
events.push(model.append('assistant/message', {
|
|
243
|
+
turn: turnIndex,
|
|
244
|
+
step,
|
|
245
|
+
message: createAssistantMessage({
|
|
246
|
+
content: assistantBlocks(imported),
|
|
247
|
+
// createAssistantMessage stamps `kind: 'model'` itself; the
|
|
248
|
+
// caller-visible provenance is provider + model only.
|
|
249
|
+
source: {
|
|
250
|
+
provider: `migrated:${agentId}`,
|
|
251
|
+
model: imported.model ?? agentId,
|
|
252
|
+
},
|
|
253
|
+
}),
|
|
254
|
+
stream: [],
|
|
255
|
+
}, { surfaceOp: 'append' }));
|
|
256
|
+
writeTools(turnIndex, step, imported);
|
|
257
|
+
events.push(model.append('step/end', { turn: turnIndex, step }));
|
|
258
|
+
}
|
|
259
|
+
// A source-recorded interruption keeps its meaning. Sources record it
|
|
260
|
+
// coarsely (no user/hook/dispose distinction), which is exactly what the
|
|
261
|
+
// `legacy` cancel cause exists for.
|
|
262
|
+
events.push(model.append('turn/end', {
|
|
263
|
+
turn: turnIndex,
|
|
264
|
+
reason: turn.aborted === true ? { kind: 'aborted', reason: { kind: 'legacy' } } : { kind: 'completed' },
|
|
265
|
+
}));
|
|
266
|
+
}
|
|
267
|
+
const title = session.titleExplicit ? normalizeTitle(session.title) : '';
|
|
268
|
+
if (title !== '')
|
|
269
|
+
events.push(model.append('session/title', userTitleData(title)));
|
|
270
|
+
return { header: model.header, events };
|
|
271
|
+
}
|