oh-my-claude-sisyphus 3.3.10 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/agents/explore-high.md +195 -0
- package/agents/qa-tester-high.md +141 -0
- package/agents/templates/README.md +110 -0
- package/agents/templates/base-agent.md +54 -0
- package/agents/templates/tier-instructions.md +94 -0
- package/commands/ecomode.md +60 -0
- package/commands/help.md +1 -1
- package/commands/mcp-setup.md +7 -6
- package/commands/ralplan.md +8 -1
- package/commands/ultrapilot.md +158 -0
- package/commands/ultrawork.md +1 -0
- package/dist/__tests__/delegation-enforcer-integration.test.d.ts +6 -0
- package/dist/__tests__/delegation-enforcer-integration.test.d.ts.map +1 -0
- package/dist/__tests__/delegation-enforcer-integration.test.js +136 -0
- package/dist/__tests__/delegation-enforcer-integration.test.js.map +1 -0
- package/dist/__tests__/delegation-enforcer.test.d.ts +5 -0
- package/dist/__tests__/delegation-enforcer.test.d.ts.map +1 -0
- package/dist/__tests__/delegation-enforcer.test.js +208 -0
- package/dist/__tests__/delegation-enforcer.test.js.map +1 -0
- package/dist/__tests__/hooks.test.js +2 -2
- package/dist/__tests__/hooks.test.js.map +1 -1
- package/dist/__tests__/installer.test.js +4 -6
- package/dist/__tests__/installer.test.js.map +1 -1
- package/dist/__tests__/ralph-prd.test.js +1 -1
- package/dist/__tests__/ralph-prd.test.js.map +1 -1
- package/dist/__tests__/ralph-progress.test.js +1 -1
- package/dist/__tests__/ralph-progress.test.js.map +1 -1
- package/dist/__tests__/skills.test.js +31 -24
- package/dist/__tests__/skills.test.js.map +1 -1
- package/dist/agents/analyst.d.ts.map +1 -1
- package/dist/agents/analyst.js +1 -0
- package/dist/agents/analyst.js.map +1 -1
- package/dist/agents/architect.d.ts.map +1 -1
- package/dist/agents/architect.js +1 -0
- package/dist/agents/architect.js.map +1 -1
- package/dist/agents/critic.d.ts.map +1 -1
- package/dist/agents/critic.js +1 -0
- package/dist/agents/critic.js.map +1 -1
- package/dist/agents/definitions.d.ts +5 -1
- package/dist/agents/definitions.d.ts.map +1 -1
- package/dist/agents/definitions.js +53 -155
- package/dist/agents/definitions.js.map +1 -1
- package/dist/agents/designer.d.ts.map +1 -1
- package/dist/agents/designer.js +1 -0
- package/dist/agents/designer.js.map +1 -1
- package/dist/agents/executor.d.ts.map +1 -1
- package/dist/agents/executor.js +1 -0
- package/dist/agents/executor.js.map +1 -1
- package/dist/agents/explore.d.ts.map +1 -1
- package/dist/agents/explore.js +1 -0
- package/dist/agents/explore.js.map +1 -1
- package/dist/agents/planner.d.ts.map +1 -1
- package/dist/agents/planner.js +1 -0
- package/dist/agents/planner.js.map +1 -1
- package/dist/agents/qa-tester.d.ts.map +1 -1
- package/dist/agents/qa-tester.js +1 -0
- package/dist/agents/qa-tester.js.map +1 -1
- package/dist/agents/researcher.d.ts.map +1 -1
- package/dist/agents/researcher.js +1 -0
- package/dist/agents/researcher.js.map +1 -1
- package/dist/agents/scientist.d.ts.map +1 -1
- package/dist/agents/scientist.js +1 -0
- package/dist/agents/scientist.js.map +1 -1
- package/dist/agents/types.d.ts +2 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/types.js.map +1 -1
- package/dist/agents/vision.d.ts.map +1 -1
- package/dist/agents/vision.js +1 -0
- package/dist/agents/vision.js.map +1 -1
- package/dist/agents/writer.d.ts.map +1 -1
- package/dist/agents/writer.js +1 -0
- package/dist/agents/writer.js.map +1 -1
- package/dist/cli/index.js +0 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +1 -6
- package/dist/config/loader.js.map +1 -1
- package/dist/features/delegation-enforcer.d.ts +71 -0
- package/dist/features/delegation-enforcer.d.ts.map +1 -0
- package/dist/features/delegation-enforcer.js +128 -0
- package/dist/features/delegation-enforcer.js.map +1 -0
- package/dist/features/index.d.ts +3 -0
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/index.js +18 -0
- package/dist/features/index.js.map +1 -1
- package/dist/features/state-manager/index.d.ts +100 -0
- package/dist/features/state-manager/index.d.ts.map +1 -0
- package/dist/features/state-manager/index.js +407 -0
- package/dist/features/state-manager/index.js.map +1 -0
- package/dist/features/state-manager/types.d.ts +147 -0
- package/dist/features/state-manager/types.d.ts.map +1 -0
- package/dist/features/state-manager/types.js +30 -0
- package/dist/features/state-manager/types.js.map +1 -0
- package/dist/features/task-decomposer/index.d.ts +33 -0
- package/dist/features/task-decomposer/index.d.ts.map +1 -0
- package/dist/features/task-decomposer/index.js +698 -0
- package/dist/features/task-decomposer/index.js.map +1 -0
- package/dist/features/task-decomposer/types.d.ts +133 -0
- package/dist/features/task-decomposer/types.d.ts.map +1 -0
- package/dist/features/task-decomposer/types.js +8 -0
- package/dist/features/task-decomposer/types.js.map +1 -0
- package/dist/features/verification/example.d.ts +49 -0
- package/dist/features/verification/example.d.ts.map +1 -0
- package/dist/features/verification/example.js +235 -0
- package/dist/features/verification/example.js.map +1 -0
- package/dist/features/verification/index.d.ts +97 -0
- package/dist/features/verification/index.d.ts.map +1 -0
- package/dist/features/verification/index.js +439 -0
- package/dist/features/verification/index.js.map +1 -0
- package/dist/features/verification/types.d.ts +142 -0
- package/dist/features/verification/types.d.ts.map +1 -0
- package/dist/features/verification/types.js +7 -0
- package/dist/features/verification/types.js.map +1 -0
- package/dist/hooks/agent-usage-reminder/constants.d.ts.map +1 -1
- package/dist/hooks/agent-usage-reminder/constants.js +0 -1
- package/dist/hooks/agent-usage-reminder/constants.js.map +1 -1
- package/dist/hooks/autopilot/__tests__/cancel.test.js +4 -4
- package/dist/hooks/autopilot/__tests__/cancel.test.js.map +1 -1
- package/dist/hooks/autopilot/__tests__/summary.test.js +1 -1
- package/dist/hooks/autopilot/__tests__/summary.test.js.map +1 -1
- package/dist/hooks/autopilot/__tests__/transition.test.js +1 -2
- package/dist/hooks/autopilot/__tests__/transition.test.js.map +1 -1
- package/dist/hooks/autopilot/cancel.js +2 -2
- package/dist/hooks/autopilot/cancel.js.map +1 -1
- package/dist/hooks/autopilot/enforcement.d.ts +16 -2
- package/dist/hooks/autopilot/enforcement.d.ts.map +1 -1
- package/dist/hooks/autopilot/enforcement.js +78 -4
- package/dist/hooks/autopilot/enforcement.js.map +1 -1
- package/dist/hooks/autopilot/index.d.ts +3 -6
- package/dist/hooks/autopilot/index.d.ts.map +1 -1
- package/dist/hooks/autopilot/index.js +6 -12
- package/dist/hooks/autopilot/index.js.map +1 -1
- package/dist/hooks/autopilot/state.d.ts +36 -2
- package/dist/hooks/autopilot/state.d.ts.map +1 -1
- package/dist/hooks/autopilot/state.js +216 -2
- package/dist/hooks/autopilot/state.js.map +1 -1
- package/dist/hooks/autopilot/validation.d.ts +23 -2
- package/dist/hooks/autopilot/validation.d.ts.map +1 -1
- package/dist/hooks/autopilot/validation.js +158 -1
- package/dist/hooks/autopilot/validation.js.map +1 -1
- package/dist/hooks/bridge.js +3 -3
- package/dist/hooks/bridge.js.map +1 -1
- package/dist/hooks/index.d.ts +5 -9
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +31 -21
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/learner/promotion.js +1 -1
- package/dist/hooks/learner/promotion.js.map +1 -1
- package/dist/hooks/persistent-mode/index.d.ts.map +1 -1
- package/dist/hooks/persistent-mode/index.js +2 -3
- package/dist/hooks/persistent-mode/index.js.map +1 -1
- package/dist/hooks/ralph/index.d.ts +11 -0
- package/dist/hooks/ralph/index.d.ts.map +1 -0
- package/dist/hooks/ralph/index.js +53 -0
- package/dist/hooks/ralph/index.js.map +1 -0
- package/dist/hooks/ralph/loop.d.ts +116 -0
- package/dist/hooks/ralph/loop.d.ts.map +1 -0
- package/dist/hooks/ralph/loop.js +322 -0
- package/dist/hooks/ralph/loop.js.map +1 -0
- package/dist/hooks/ralph/prd.d.ts +130 -0
- package/dist/hooks/ralph/prd.d.ts.map +1 -0
- package/dist/hooks/ralph/prd.js +310 -0
- package/dist/hooks/ralph/prd.js.map +1 -0
- package/dist/hooks/ralph/progress.d.ts +102 -0
- package/dist/hooks/ralph/progress.d.ts.map +1 -0
- package/dist/hooks/ralph/progress.js +408 -0
- package/dist/hooks/ralph/progress.js.map +1 -0
- package/dist/hooks/ralph/verifier.d.ts +72 -0
- package/dist/hooks/ralph/verifier.d.ts.map +1 -0
- package/dist/hooks/ralph/verifier.js +223 -0
- package/dist/hooks/ralph/verifier.js.map +1 -0
- package/dist/hooks/recovery/constants.d.ts +114 -0
- package/dist/hooks/recovery/constants.d.ts.map +1 -0
- package/dist/hooks/recovery/constants.js +227 -0
- package/dist/hooks/recovery/constants.js.map +1 -0
- package/dist/hooks/recovery/context-window.d.ts +24 -0
- package/dist/hooks/recovery/context-window.d.ts.map +1 -0
- package/dist/hooks/recovery/context-window.js +321 -0
- package/dist/hooks/recovery/context-window.js.map +1 -0
- package/dist/hooks/recovery/edit-error.d.ts +24 -0
- package/dist/hooks/recovery/edit-error.d.ts.map +1 -0
- package/dist/hooks/recovery/edit-error.js +56 -0
- package/dist/hooks/recovery/edit-error.js.map +1 -0
- package/dist/hooks/recovery/index.d.ts +102 -0
- package/dist/hooks/recovery/index.d.ts.map +1 -0
- package/dist/hooks/recovery/index.js +166 -0
- package/dist/hooks/recovery/index.js.map +1 -0
- package/dist/hooks/recovery/session-recovery.d.ts +24 -0
- package/dist/hooks/recovery/session-recovery.d.ts.map +1 -0
- package/dist/hooks/recovery/session-recovery.js +281 -0
- package/dist/hooks/recovery/session-recovery.js.map +1 -0
- package/dist/hooks/recovery/storage.d.ts +75 -0
- package/dist/hooks/recovery/storage.d.ts.map +1 -0
- package/dist/hooks/recovery/storage.js +382 -0
- package/dist/hooks/recovery/storage.js.map +1 -0
- package/dist/hooks/recovery/types.d.ts +196 -0
- package/dist/hooks/recovery/types.d.ts.map +1 -0
- package/dist/hooks/recovery/types.js +32 -0
- package/dist/hooks/recovery/types.js.map +1 -0
- package/dist/hooks/ultrapilot/index.d.ts +90 -0
- package/dist/hooks/ultrapilot/index.d.ts.map +1 -0
- package/dist/hooks/ultrapilot/index.js +310 -0
- package/dist/hooks/ultrapilot/index.js.map +1 -0
- package/dist/hooks/ultrapilot/state.d.ts +72 -0
- package/dist/hooks/ultrapilot/state.d.ts.map +1 -0
- package/dist/hooks/ultrapilot/state.js +258 -0
- package/dist/hooks/ultrapilot/state.js.map +1 -0
- package/dist/hooks/ultrapilot/types.d.ts +113 -0
- package/dist/hooks/ultrapilot/types.d.ts.map +1 -0
- package/dist/hooks/ultrapilot/types.js +36 -0
- package/dist/hooks/ultrapilot/types.js.map +1 -0
- package/dist/hooks/ultraqa/index.d.ts +94 -0
- package/dist/hooks/ultraqa/index.d.ts.map +1 -0
- package/dist/hooks/ultraqa/index.js +216 -0
- package/dist/hooks/ultraqa/index.js.map +1 -0
- package/dist/hooks/ultrawork/index.d.ts +62 -0
- package/dist/hooks/ultrawork/index.d.ts.map +1 -0
- package/dist/hooks/ultrawork/index.js +208 -0
- package/dist/hooks/ultrawork/index.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/installer/index.d.ts +1 -1
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +1 -1
- package/dist/installer/index.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/servers.d.ts +2 -18
- package/dist/mcp/servers.d.ts.map +1 -1
- package/dist/mcp/servers.js +4 -36
- package/dist/mcp/servers.js.map +1 -1
- package/dist/shared/types.d.ts +1 -3
- package/dist/shared/types.d.ts.map +1 -1
- package/docs/CLAUDE.md +170 -44
- package/docs/DELEGATION-ENFORCER.md +282 -0
- package/docs/FULL-README.md +1 -1
- package/docs/LOCAL_PLUGIN_INSTALL.md +1 -1
- package/docs/MIGRATION.md +298 -104
- package/package.json +2 -2
- package/scripts/test-mutual-exclusion.ts +1 -1
- package/skills/analyze/SKILL.md +0 -1
- package/skills/autopilot/SKILL.md +0 -1
- package/skills/cancel/SKILL.md +580 -0
- package/skills/cancel-autopilot/SKILL.md +0 -1
- package/skills/cancel-ecomode/SKILL.md +41 -0
- package/skills/cancel-ralph/SKILL.md +0 -1
- package/skills/cancel-ultraqa/SKILL.md +0 -1
- package/skills/cancel-ultrawork/SKILL.md +0 -1
- package/skills/deepinit/SKILL.md +0 -1
- package/skills/deepsearch/SKILL.md +0 -1
- package/skills/doctor/SKILL.md +0 -1
- package/skills/ecomode/SKILL.md +128 -0
- package/skills/frontend-ui-ux/SKILL.md +0 -1
- package/skills/git-master/SKILL.md +0 -1
- package/skills/help/SKILL.md +1 -2
- package/skills/hud/SKILL.md +0 -1
- package/skills/learner/SKILL.md +0 -1
- package/skills/mcp-setup/SKILL.md +8 -7
- package/skills/note/SKILL.md +0 -1
- package/skills/omc-default/SKILL.md +0 -1
- package/skills/omc-default-global/SKILL.md +0 -1
- package/skills/omc-setup/SKILL.md +176 -10
- package/skills/orchestrate/SKILL.md +0 -1
- package/skills/pipeline/SKILL.md +417 -0
- package/skills/plan/SKILL.md +138 -21
- package/skills/planner/SKILL.md +0 -1
- package/skills/ralph/SKILL.md +65 -1
- package/skills/ralph-init/SKILL.md +0 -1
- package/skills/ralplan/SKILL.md +0 -1
- package/skills/release/SKILL.md +0 -1
- package/skills/research/SKILL.md +0 -1
- package/skills/review/SKILL.md +0 -1
- package/skills/swarm/SKILL.md +349 -0
- package/skills/tdd/SKILL.md +0 -1
- package/skills/ultrapilot/SKILL.md +563 -0
- package/skills/ultraqa/SKILL.md +0 -1
- package/skills/ultrawork/SKILL.md +0 -1
- package/docs/MIGRATION-v3.md +0 -186
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Recovery Module
|
|
3
|
+
*
|
|
4
|
+
* Consolidates all recovery mechanisms into a single, coordinated system.
|
|
5
|
+
* Handles context window limits, edit errors, and session recovery.
|
|
6
|
+
*
|
|
7
|
+
* Recovery Priority (checked in order):
|
|
8
|
+
* 1. Context Window Limit - Most critical, blocks all progress
|
|
9
|
+
* 2. Edit Errors - Immediate user feedback needed
|
|
10
|
+
* 3. Session Recovery - Structural errors that need fixing
|
|
11
|
+
*/
|
|
12
|
+
import { handleContextWindowRecovery, detectContextLimitError, parseTokenLimitError, } from './context-window.js';
|
|
13
|
+
import { handleEditErrorRecovery, detectEditError, processEditOutput, } from './edit-error.js';
|
|
14
|
+
import { handleSessionRecovery, detectErrorType as detectSessionErrorType, isRecoverableError, } from './session-recovery.js';
|
|
15
|
+
export { RETRY_CONFIG, TRUNCATE_CONFIG } from './types.js';
|
|
16
|
+
// Re-export constants
|
|
17
|
+
export { CONTEXT_LIMIT_RECOVERY_MESSAGE, CONTEXT_LIMIT_SHORT_MESSAGE, NON_EMPTY_CONTENT_RECOVERY_MESSAGE, TRUNCATION_APPLIED_MESSAGE, RECOVERY_FAILED_MESSAGE, TOKEN_LIMIT_PATTERNS, TOKEN_LIMIT_KEYWORDS, EDIT_ERROR_PATTERNS, EDIT_ERROR_REMINDER, RECOVERY_MESSAGES, PLACEHOLDER_TEXT, } from './constants.js';
|
|
18
|
+
// Re-export storage utilities
|
|
19
|
+
export { readMessages, readParts, findEmptyMessages, findMessagesWithThinkingBlocks, findMessagesWithOrphanThinking, injectTextPart, prependThinkingPart, stripThinkingParts, replaceEmptyTextParts, } from './storage.js';
|
|
20
|
+
// Re-export individual recovery functions
|
|
21
|
+
export { handleContextWindowRecovery, detectContextLimitError, parseTokenLimitError, containsTokenLimitError, } from './context-window.js';
|
|
22
|
+
export { handleEditErrorRecovery, detectEditError, processEditOutput, } from './edit-error.js';
|
|
23
|
+
export { handleSessionRecovery, detectErrorType as detectSessionErrorType, isRecoverableError, } from './session-recovery.js';
|
|
24
|
+
/**
|
|
25
|
+
* Unified recovery handler
|
|
26
|
+
*
|
|
27
|
+
* Attempts recovery in priority order:
|
|
28
|
+
* 1. Context Window Limit (most critical)
|
|
29
|
+
* 2. Session Recovery (structural errors)
|
|
30
|
+
* 3. Edit Errors (handled during tool execution)
|
|
31
|
+
*
|
|
32
|
+
* @param input Recovery input
|
|
33
|
+
* @returns Recovery result
|
|
34
|
+
*/
|
|
35
|
+
export async function handleRecovery(input) {
|
|
36
|
+
const { sessionId, error, toolName, toolOutput, message, config } = input;
|
|
37
|
+
// Priority 1: Context Window Limit
|
|
38
|
+
if (error) {
|
|
39
|
+
const contextResult = handleContextWindowRecovery(sessionId, error, config);
|
|
40
|
+
if (contextResult.attempted && contextResult.success) {
|
|
41
|
+
return contextResult;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Priority 2: Session Recovery
|
|
45
|
+
if (error) {
|
|
46
|
+
const sessionResult = await handleSessionRecovery(sessionId, error, message, config);
|
|
47
|
+
if (sessionResult.attempted && sessionResult.success) {
|
|
48
|
+
return sessionResult;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Priority 3: Edit Error Recovery
|
|
52
|
+
if (toolName && toolOutput) {
|
|
53
|
+
const editResult = handleEditErrorRecovery(toolName, toolOutput);
|
|
54
|
+
if (editResult.attempted && editResult.success) {
|
|
55
|
+
return editResult;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
attempted: false,
|
|
60
|
+
success: false,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Detect if an error is recoverable
|
|
65
|
+
*
|
|
66
|
+
* Checks all recovery mechanisms to see if the error can be handled.
|
|
67
|
+
*/
|
|
68
|
+
export function detectRecoverableError(error) {
|
|
69
|
+
// Check context window limit
|
|
70
|
+
const parsed = parseTokenLimitError(error);
|
|
71
|
+
if (parsed) {
|
|
72
|
+
return {
|
|
73
|
+
recoverable: true,
|
|
74
|
+
type: 'context_window_limit',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Check session recovery
|
|
78
|
+
const sessionErrorType = detectSessionErrorType(error);
|
|
79
|
+
if (sessionErrorType) {
|
|
80
|
+
return {
|
|
81
|
+
recoverable: true,
|
|
82
|
+
type: sessionErrorType,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
recoverable: false,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Detect if output contains an edit error
|
|
91
|
+
*/
|
|
92
|
+
export function detectEditErrorInOutput(output) {
|
|
93
|
+
return detectEditError(output);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Create unified recovery hook for Claude Code
|
|
97
|
+
*
|
|
98
|
+
* This hook provides a single entry point for all recovery mechanisms.
|
|
99
|
+
*/
|
|
100
|
+
export function createRecoveryHook(config) {
|
|
101
|
+
return {
|
|
102
|
+
/**
|
|
103
|
+
* Check for errors during tool execution or message processing
|
|
104
|
+
*/
|
|
105
|
+
onError: async (input) => {
|
|
106
|
+
return handleRecovery({
|
|
107
|
+
sessionId: input.session_id,
|
|
108
|
+
error: input.error,
|
|
109
|
+
message: input.message,
|
|
110
|
+
config,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* Post-tool execution hook for edit error recovery
|
|
115
|
+
*/
|
|
116
|
+
afterToolExecute: (input) => {
|
|
117
|
+
const result = handleEditErrorRecovery(input.tool, input.output);
|
|
118
|
+
if (result.attempted && result.success) {
|
|
119
|
+
return {
|
|
120
|
+
output: processEditOutput(input.tool, input.output),
|
|
121
|
+
recovery: result,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
output: input.output,
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* Check if an error is recoverable
|
|
130
|
+
*/
|
|
131
|
+
isRecoverable: (error) => {
|
|
132
|
+
return detectRecoverableError(error).recoverable;
|
|
133
|
+
},
|
|
134
|
+
/**
|
|
135
|
+
* Get recovery type for an error
|
|
136
|
+
*/
|
|
137
|
+
getRecoveryType: (error) => {
|
|
138
|
+
return detectRecoverableError(error).type;
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Parse context limit error for detailed information
|
|
144
|
+
*/
|
|
145
|
+
export function parseContextLimitError(error) {
|
|
146
|
+
return parseTokenLimitError(error);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Detect if text contains a context limit error
|
|
150
|
+
*/
|
|
151
|
+
export function detectContextLimitErrorInText(text) {
|
|
152
|
+
return detectContextLimitError(text);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Detect if text contains an edit error
|
|
156
|
+
*/
|
|
157
|
+
export function detectEditErrorInText(text) {
|
|
158
|
+
return detectEditError(text);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Check if session error is recoverable
|
|
162
|
+
*/
|
|
163
|
+
export function isSessionRecoverable(error) {
|
|
164
|
+
return isRecoverableError(error);
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/recovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,eAAe,IAAI,sBAAsB,EACzC,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAkB/B,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3D,sBAAsB;AACtB,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,kCAAkC,EAClC,0BAA0B,EAC1B,uBAAuB,EACvB,oBAAoB,EACpB,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
|
+
* Detects and fixes various error conditions that can cause session failures.
|
|
6
|
+
*/
|
|
7
|
+
import type { MessageData, RecoveryResult, RecoveryConfig } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Recovery error types
|
|
10
|
+
*/
|
|
11
|
+
export type RecoveryErrorType = 'tool_result_missing' | 'thinking_block_order' | 'thinking_disabled_violation' | 'empty_content' | null;
|
|
12
|
+
/**
|
|
13
|
+
* Detect the type of recoverable error
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectErrorType(error: unknown): RecoveryErrorType;
|
|
16
|
+
/**
|
|
17
|
+
* Check if an error is recoverable
|
|
18
|
+
*/
|
|
19
|
+
export declare function isRecoverableError(error: unknown): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Main recovery handler
|
|
22
|
+
*/
|
|
23
|
+
export declare function handleSessionRecovery(sessionID: string, error: unknown, failedMessage?: MessageData, config?: RecoveryConfig): Promise<RecoveryResult>;
|
|
24
|
+
//# sourceMappingURL=session-recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-recovery.d.ts","sourceRoot":"","sources":["../../../src/hooks/recovery/session-recovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuBH,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,qBAAqB,GACrB,sBAAsB,GACtB,6BAA6B,GAC7B,eAAe,GACf,IAAI,CAAC;AAsDT;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CA+BjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE1D;AA2LD;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,WAAW,EAC3B,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,CAAC,CAsDzB"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Recovery
|
|
3
|
+
*
|
|
4
|
+
* Helps recover session state when Claude Code restarts or crashes.
|
|
5
|
+
* Detects and fixes various error conditions that can cause session failures.
|
|
6
|
+
*/
|
|
7
|
+
import { appendFileSync } from 'node:fs';
|
|
8
|
+
import { findEmptyMessages, findEmptyMessageByIndex, findMessageByIndexNeedingThinking, findMessagesWithEmptyTextParts, findMessagesWithOrphanThinking, findMessagesWithThinkingBlocks, findMessagesWithThinkingOnly, injectTextPart, prependThinkingPart, readParts, replaceEmptyTextParts, stripThinkingParts, } from './storage.js';
|
|
9
|
+
import { DEBUG, DEBUG_FILE, PLACEHOLDER_TEXT, RECOVERY_MESSAGES, } from './constants.js';
|
|
10
|
+
/**
|
|
11
|
+
* Debug logging utility
|
|
12
|
+
*/
|
|
13
|
+
function debugLog(...args) {
|
|
14
|
+
if (DEBUG) {
|
|
15
|
+
const msg = `[${new Date().toISOString()}] [session-recovery] ${args
|
|
16
|
+
.map((a) => (typeof a === 'object' ? JSON.stringify(a, null, 2) : String(a)))
|
|
17
|
+
.join(' ')}\n`;
|
|
18
|
+
appendFileSync(DEBUG_FILE, msg);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extract error message from various error formats
|
|
23
|
+
*/
|
|
24
|
+
function getErrorMessage(error) {
|
|
25
|
+
if (!error)
|
|
26
|
+
return '';
|
|
27
|
+
if (typeof error === 'string')
|
|
28
|
+
return error.toLowerCase();
|
|
29
|
+
const errorObj = error;
|
|
30
|
+
const paths = [
|
|
31
|
+
errorObj.data,
|
|
32
|
+
errorObj.error,
|
|
33
|
+
errorObj,
|
|
34
|
+
errorObj.data?.error,
|
|
35
|
+
];
|
|
36
|
+
for (const obj of paths) {
|
|
37
|
+
if (obj && typeof obj === 'object') {
|
|
38
|
+
const msg = obj.message;
|
|
39
|
+
if (typeof msg === 'string' && msg.length > 0) {
|
|
40
|
+
return msg.toLowerCase();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
return JSON.stringify(error).toLowerCase();
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Extract message index from error (e.g., "messages.5")
|
|
53
|
+
*/
|
|
54
|
+
function extractMessageIndex(error) {
|
|
55
|
+
const message = getErrorMessage(error);
|
|
56
|
+
const match = message.match(/messages\.(\d+)/);
|
|
57
|
+
return match ? parseInt(match[1], 10) : null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Detect the type of recoverable error
|
|
61
|
+
*/
|
|
62
|
+
export function detectErrorType(error) {
|
|
63
|
+
const message = getErrorMessage(error);
|
|
64
|
+
if (message.includes('tool_use') && message.includes('tool_result')) {
|
|
65
|
+
return 'tool_result_missing';
|
|
66
|
+
}
|
|
67
|
+
if (message.includes('thinking') &&
|
|
68
|
+
(message.includes('first block') ||
|
|
69
|
+
message.includes('must start with') ||
|
|
70
|
+
message.includes('preceeding') ||
|
|
71
|
+
message.includes('final block') ||
|
|
72
|
+
message.includes('cannot be thinking') ||
|
|
73
|
+
(message.includes('expected') && message.includes('found')))) {
|
|
74
|
+
return 'thinking_block_order';
|
|
75
|
+
}
|
|
76
|
+
if (message.includes('thinking is disabled') && message.includes('cannot contain')) {
|
|
77
|
+
return 'thinking_disabled_violation';
|
|
78
|
+
}
|
|
79
|
+
if (message.includes('empty') &&
|
|
80
|
+
(message.includes('content') || message.includes('message'))) {
|
|
81
|
+
return 'empty_content';
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Check if an error is recoverable
|
|
87
|
+
*/
|
|
88
|
+
export function isRecoverableError(error) {
|
|
89
|
+
return detectErrorType(error) !== null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Extract tool_use IDs from message parts
|
|
93
|
+
*/
|
|
94
|
+
function extractToolUseIds(parts) {
|
|
95
|
+
return parts
|
|
96
|
+
.filter((p) => p.type === 'tool_use' && !!p.id)
|
|
97
|
+
.map((p) => p.id);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Recover from missing tool results
|
|
101
|
+
*/
|
|
102
|
+
async function recoverToolResultMissing(sessionID, failedAssistantMsg) {
|
|
103
|
+
debugLog('recoverToolResultMissing', { sessionID, msgId: failedAssistantMsg.info?.id });
|
|
104
|
+
// Try API parts first, fallback to filesystem if empty
|
|
105
|
+
let parts = failedAssistantMsg.parts || [];
|
|
106
|
+
if (parts.length === 0 && failedAssistantMsg.info?.id) {
|
|
107
|
+
const storedParts = readParts(failedAssistantMsg.info.id);
|
|
108
|
+
parts = storedParts.map((p) => ({
|
|
109
|
+
type: p.type === 'tool' ? 'tool_use' : p.type,
|
|
110
|
+
id: 'callID' in p ? p.callID : p.id,
|
|
111
|
+
name: 'tool' in p ? p.tool : undefined,
|
|
112
|
+
input: 'state' in p
|
|
113
|
+
? p.state?.input
|
|
114
|
+
: undefined,
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
const toolUseIds = extractToolUseIds(parts);
|
|
118
|
+
if (toolUseIds.length === 0) {
|
|
119
|
+
debugLog('No tool_use IDs found');
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
debugLog('Found tool_use IDs to inject results for', toolUseIds);
|
|
123
|
+
// Note: In Claude Code's simplified architecture, we would need to
|
|
124
|
+
// integrate with the actual session/tool system to inject tool results.
|
|
125
|
+
// This is a placeholder showing the recovery intent.
|
|
126
|
+
// A full implementation would require access to the SDK client.
|
|
127
|
+
return true; // Indicate recovery was attempted
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Recover from thinking block order errors
|
|
131
|
+
*/
|
|
132
|
+
async function recoverThinkingBlockOrder(sessionID, _failedAssistantMsg, error) {
|
|
133
|
+
debugLog('recoverThinkingBlockOrder', { sessionID });
|
|
134
|
+
const targetIndex = extractMessageIndex(error);
|
|
135
|
+
if (targetIndex !== null) {
|
|
136
|
+
const targetMessageID = findMessageByIndexNeedingThinking(sessionID, targetIndex);
|
|
137
|
+
if (targetMessageID) {
|
|
138
|
+
debugLog('Found target message by index', { targetIndex, targetMessageID });
|
|
139
|
+
return prependThinkingPart(sessionID, targetMessageID);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const orphanMessages = findMessagesWithOrphanThinking(sessionID);
|
|
143
|
+
if (orphanMessages.length === 0) {
|
|
144
|
+
debugLog('No orphan thinking messages found');
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
debugLog('Found orphan thinking messages', orphanMessages);
|
|
148
|
+
let anySuccess = false;
|
|
149
|
+
for (const messageID of orphanMessages) {
|
|
150
|
+
if (prependThinkingPart(sessionID, messageID)) {
|
|
151
|
+
anySuccess = true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return anySuccess;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Recover from thinking disabled violations
|
|
158
|
+
*/
|
|
159
|
+
async function recoverThinkingDisabledViolation(sessionID, _failedAssistantMsg) {
|
|
160
|
+
debugLog('recoverThinkingDisabledViolation', { sessionID });
|
|
161
|
+
const messagesWithThinking = findMessagesWithThinkingBlocks(sessionID);
|
|
162
|
+
if (messagesWithThinking.length === 0) {
|
|
163
|
+
debugLog('No messages with thinking blocks found');
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
debugLog('Found messages with thinking blocks', messagesWithThinking);
|
|
167
|
+
let anySuccess = false;
|
|
168
|
+
for (const messageID of messagesWithThinking) {
|
|
169
|
+
if (stripThinkingParts(messageID)) {
|
|
170
|
+
anySuccess = true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return anySuccess;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Recover from empty content messages
|
|
177
|
+
*/
|
|
178
|
+
async function recoverEmptyContentMessage(sessionID, failedAssistantMsg, error) {
|
|
179
|
+
debugLog('recoverEmptyContentMessage', { sessionID });
|
|
180
|
+
const targetIndex = extractMessageIndex(error);
|
|
181
|
+
const failedID = failedAssistantMsg.info?.id;
|
|
182
|
+
let anySuccess = false;
|
|
183
|
+
// Fix messages with empty text parts
|
|
184
|
+
const messagesWithEmptyText = findMessagesWithEmptyTextParts(sessionID);
|
|
185
|
+
for (const messageID of messagesWithEmptyText) {
|
|
186
|
+
if (replaceEmptyTextParts(messageID, PLACEHOLDER_TEXT)) {
|
|
187
|
+
anySuccess = true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Fix messages with only thinking
|
|
191
|
+
const thinkingOnlyIDs = findMessagesWithThinkingOnly(sessionID);
|
|
192
|
+
for (const messageID of thinkingOnlyIDs) {
|
|
193
|
+
if (injectTextPart(sessionID, messageID, PLACEHOLDER_TEXT)) {
|
|
194
|
+
anySuccess = true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Try target index if provided
|
|
198
|
+
if (targetIndex !== null) {
|
|
199
|
+
const targetMessageID = findEmptyMessageByIndex(sessionID, targetIndex);
|
|
200
|
+
if (targetMessageID) {
|
|
201
|
+
if (replaceEmptyTextParts(targetMessageID, PLACEHOLDER_TEXT)) {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
if (injectTextPart(sessionID, targetMessageID, PLACEHOLDER_TEXT)) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Try failed message ID
|
|
210
|
+
if (failedID) {
|
|
211
|
+
if (replaceEmptyTextParts(failedID, PLACEHOLDER_TEXT)) {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
if (injectTextPart(sessionID, failedID, PLACEHOLDER_TEXT)) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Fix all empty messages as last resort
|
|
219
|
+
const emptyMessageIDs = findEmptyMessages(sessionID);
|
|
220
|
+
for (const messageID of emptyMessageIDs) {
|
|
221
|
+
if (replaceEmptyTextParts(messageID, PLACEHOLDER_TEXT)) {
|
|
222
|
+
anySuccess = true;
|
|
223
|
+
}
|
|
224
|
+
if (injectTextPart(sessionID, messageID, PLACEHOLDER_TEXT)) {
|
|
225
|
+
anySuccess = true;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return anySuccess;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Main recovery handler
|
|
232
|
+
*/
|
|
233
|
+
export async function handleSessionRecovery(sessionID, error, failedMessage, config) {
|
|
234
|
+
debugLog('handleSessionRecovery', { sessionID, error });
|
|
235
|
+
const errorType = detectErrorType(error);
|
|
236
|
+
if (!errorType) {
|
|
237
|
+
debugLog('Not a recoverable error');
|
|
238
|
+
return {
|
|
239
|
+
attempted: false,
|
|
240
|
+
success: false,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
debugLog('Detected recoverable error type', errorType);
|
|
244
|
+
try {
|
|
245
|
+
let success = false;
|
|
246
|
+
const failedMsg = failedMessage || { info: {}, parts: [] };
|
|
247
|
+
switch (errorType) {
|
|
248
|
+
case 'tool_result_missing':
|
|
249
|
+
success = await recoverToolResultMissing(sessionID, failedMsg);
|
|
250
|
+
break;
|
|
251
|
+
case 'thinking_block_order':
|
|
252
|
+
success = await recoverThinkingBlockOrder(sessionID, failedMsg, error);
|
|
253
|
+
break;
|
|
254
|
+
case 'thinking_disabled_violation':
|
|
255
|
+
success = await recoverThinkingDisabledViolation(sessionID, failedMsg);
|
|
256
|
+
break;
|
|
257
|
+
case 'empty_content':
|
|
258
|
+
success = await recoverEmptyContentMessage(sessionID, failedMsg, error);
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
debugLog('Recovery result', { errorType, success });
|
|
262
|
+
const recoveryMessage = config?.customMessages?.[errorType] ||
|
|
263
|
+
RECOVERY_MESSAGES[errorType]?.message ||
|
|
264
|
+
`Session recovery attempted for ${errorType}`;
|
|
265
|
+
return {
|
|
266
|
+
attempted: true,
|
|
267
|
+
success,
|
|
268
|
+
message: success ? recoveryMessage : undefined,
|
|
269
|
+
errorType,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
debugLog('Recovery failed with error', err);
|
|
274
|
+
return {
|
|
275
|
+
attempted: true,
|
|
276
|
+
success: false,
|
|
277
|
+
errorType,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
//# sourceMappingURL=session-recovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-recovery.js","sourceRoot":"","sources":["../../../src/hooks/recovery/session-recovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,iCAAiC,EACjC,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B,EAC9B,4BAA4B,EAC5B,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,EACL,UAAU,EACV,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAiBxB;;GAEG;AACH,SAAS,QAAQ,CAAC,GAAG,IAAe;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,GAAG,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,wBAAwB,IAAI;aACjE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,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AAC,CAAC;QAEpD,MAAM,eAAe,GACnB,MAAM,EAAE,cAAc,EAAE,CAAC,SAAS,CAAC;YACnC,iBAAiB,CAAC,SAAS,CAAC,EAAE,OAAO;YACrC,kCAAkC,SAAS,EAAE,CAAC;QAEhD,OAAO;YACL,SAAS,EAAE,IAAI;YACf,OAAO;YACP,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;YAC9C,SAAS;SACV,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,QAAQ,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;QAC5C,OAAO;YACL,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,KAAK;YACd,SAAS;SACV,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Recovery Storage Operations
|
|
3
|
+
*
|
|
4
|
+
* Functions for reading and manipulating stored session data.
|
|
5
|
+
*/
|
|
6
|
+
import type { StoredMessageMeta, StoredPart } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Generate a unique part ID
|
|
9
|
+
*/
|
|
10
|
+
export declare function generatePartId(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Get the directory containing messages for a session
|
|
13
|
+
*/
|
|
14
|
+
export declare function getMessageDir(sessionID: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Read all messages for a session
|
|
17
|
+
*/
|
|
18
|
+
export declare function readMessages(sessionID: string): StoredMessageMeta[];
|
|
19
|
+
/**
|
|
20
|
+
* Read all parts for a message
|
|
21
|
+
*/
|
|
22
|
+
export declare function readParts(messageID: string): StoredPart[];
|
|
23
|
+
/**
|
|
24
|
+
* Check if a part has content (not thinking/meta)
|
|
25
|
+
*/
|
|
26
|
+
export declare function hasContent(part: StoredPart): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a message has content
|
|
29
|
+
*/
|
|
30
|
+
export declare function messageHasContent(messageID: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Inject a text part into a message
|
|
33
|
+
*/
|
|
34
|
+
export declare function injectTextPart(sessionID: string, messageID: string, text: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Find all messages with empty content
|
|
37
|
+
*/
|
|
38
|
+
export declare function findEmptyMessages(sessionID: string): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Find empty message by index (with fuzzy matching)
|
|
41
|
+
*/
|
|
42
|
+
export declare function findEmptyMessageByIndex(sessionID: string, targetIndex: number): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Find messages that have thinking blocks
|
|
45
|
+
*/
|
|
46
|
+
export declare function findMessagesWithThinkingBlocks(sessionID: string): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Find messages that have thinking but no content
|
|
49
|
+
*/
|
|
50
|
+
export declare function findMessagesWithThinkingOnly(sessionID: string): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Find messages with orphan thinking (thinking not first)
|
|
53
|
+
*/
|
|
54
|
+
export declare function findMessagesWithOrphanThinking(sessionID: string): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Prepend a thinking part to a message
|
|
57
|
+
*/
|
|
58
|
+
export declare function prependThinkingPart(sessionID: string, messageID: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Strip all thinking parts from a message
|
|
61
|
+
*/
|
|
62
|
+
export declare function stripThinkingParts(messageID: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Replace empty text parts with placeholder text
|
|
65
|
+
*/
|
|
66
|
+
export declare function replaceEmptyTextParts(messageID: string, replacementText?: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Find messages with empty text parts
|
|
69
|
+
*/
|
|
70
|
+
export declare function findMessagesWithEmptyTextParts(sessionID: string): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Find message by index that needs thinking block
|
|
73
|
+
*/
|
|
74
|
+
export declare function findMessageByIndexNeedingThinking(sessionID: string, targetIndex: number): string | null;
|
|
75
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/hooks/recovery/storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EAEX,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAIvC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAgBvD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAqBnE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CAgBzD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAkBpD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAG5D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAuBT;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAW7D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,IAAI,CA0Bf;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAe1E;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBxE;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,M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