oh-my-claude-sisyphus 3.6.1 → 3.6.3
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/commands/doctor.md +1 -1
- package/commands/psm.md +180 -0
- package/dist/__tests__/analytics/analytics-summary.test.d.ts +2 -0
- package/dist/__tests__/analytics/analytics-summary.test.d.ts.map +1 -0
- package/dist/__tests__/analytics/analytics-summary.test.js +267 -0
- package/dist/__tests__/analytics/analytics-summary.test.js.map +1 -0
- package/dist/__tests__/analytics/cost-estimator.test.d.ts +2 -0
- package/dist/__tests__/analytics/cost-estimator.test.d.ts.map +1 -0
- package/dist/__tests__/analytics/cost-estimator.test.js +212 -0
- package/dist/__tests__/analytics/cost-estimator.test.js.map +1 -0
- package/dist/__tests__/hooks/auto-slash-command/executor.test.d.ts +7 -0
- package/dist/__tests__/hooks/auto-slash-command/executor.test.d.ts.map +1 -0
- package/dist/__tests__/hooks/auto-slash-command/executor.test.js +374 -0
- package/dist/__tests__/hooks/auto-slash-command/executor.test.js.map +1 -0
- package/dist/__tests__/hud/auto-tracking.integration.test.d.ts +2 -0
- package/dist/__tests__/hud/auto-tracking.integration.test.d.ts.map +1 -0
- package/dist/__tests__/hud/auto-tracking.integration.test.js +12 -0
- package/dist/__tests__/hud/auto-tracking.integration.test.js.map +1 -0
- package/dist/__tests__/installer.test.js +1 -1
- package/dist/__tests__/learned-skills/config.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/config.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/config.test.js +37 -0
- package/dist/__tests__/learned-skills/config.test.js.map +1 -0
- package/dist/__tests__/learned-skills/detector.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/detector.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/detector.test.js +99 -0
- package/dist/__tests__/learned-skills/detector.test.js.map +1 -0
- package/dist/__tests__/learned-skills/finder.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/finder.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/finder.test.js +59 -0
- package/dist/__tests__/learned-skills/finder.test.js.map +1 -0
- package/dist/__tests__/learned-skills/loader.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/loader.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/loader.test.js +69 -0
- package/dist/__tests__/learned-skills/loader.test.js.map +1 -0
- package/dist/__tests__/learned-skills/parser.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/parser.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/parser.test.js +81 -0
- package/dist/__tests__/learned-skills/parser.test.js.map +1 -0
- package/dist/__tests__/learned-skills/validator.test.d.ts +2 -0
- package/dist/__tests__/learned-skills/validator.test.d.ts.map +1 -0
- package/dist/__tests__/learned-skills/validator.test.js +85 -0
- package/dist/__tests__/learned-skills/validator.test.js.map +1 -0
- package/dist/__tests__/skills.test.js +6 -5
- package/dist/__tests__/skills.test.js.map +1 -1
- package/dist/agents/codex-agents.d.ts +20 -0
- package/dist/agents/codex-agents.d.ts.map +1 -0
- package/dist/agents/codex-agents.js +36 -0
- package/dist/agents/codex-agents.js.map +1 -0
- package/dist/agents/document-writer.d.ts +11 -0
- package/dist/agents/document-writer.d.ts.map +1 -0
- package/dist/agents/document-writer.js +209 -0
- package/dist/agents/document-writer.js.map +1 -0
- package/dist/agents/frontend-engineer.d.ts +11 -0
- package/dist/agents/frontend-engineer.d.ts.map +1 -0
- package/dist/agents/frontend-engineer.js +115 -0
- package/dist/agents/frontend-engineer.js.map +1 -0
- package/dist/agents/librarian.d.ts +12 -0
- package/dist/agents/librarian.d.ts.map +1 -0
- package/dist/agents/librarian.js +103 -0
- package/dist/agents/librarian.js.map +1 -0
- package/dist/agents/metis.d.ts +12 -0
- package/dist/agents/metis.d.ts.map +1 -0
- package/dist/agents/metis.js +117 -0
- package/dist/agents/metis.js.map +1 -0
- package/dist/agents/momus.d.ts +12 -0
- package/dist/agents/momus.d.ts.map +1 -0
- package/dist/agents/momus.js +128 -0
- package/dist/agents/momus.js.map +1 -0
- package/dist/agents/multimodal-looker.d.ts +11 -0
- package/dist/agents/multimodal-looker.d.ts.map +1 -0
- package/dist/agents/multimodal-looker.js +70 -0
- package/dist/agents/multimodal-looker.js.map +1 -0
- package/dist/agents/oracle.d.ts +13 -0
- package/dist/agents/oracle.d.ts.map +1 -0
- package/dist/agents/oracle.js +191 -0
- package/dist/agents/oracle.js.map +1 -0
- package/dist/agents/orchestrator-sisyphus.d.ts +11 -0
- package/dist/agents/orchestrator-sisyphus.d.ts.map +1 -0
- package/dist/agents/orchestrator-sisyphus.js +115 -0
- package/dist/agents/orchestrator-sisyphus.js.map +1 -0
- package/dist/agents/prometheus.d.ts +12 -0
- package/dist/agents/prometheus.d.ts.map +1 -0
- package/dist/agents/prometheus.js +195 -0
- package/dist/agents/prometheus.js.map +1 -0
- package/dist/agents/sisyphus-junior.d.ts +12 -0
- package/dist/agents/sisyphus-junior.d.ts.map +1 -0
- package/dist/agents/sisyphus-junior.js +93 -0
- package/dist/agents/sisyphus-junior.js.map +1 -0
- package/dist/cli/analytics.js +0 -0
- package/dist/cli/components/CostDashboard.d.ts +15 -0
- package/dist/cli/components/CostDashboard.d.ts.map +1 -0
- package/dist/cli/components/CostDashboard.js +15 -0
- package/dist/cli/components/CostDashboard.js.map +1 -0
- package/dist/cli/components/LiveStats.d.ts +16 -0
- package/dist/cli/components/LiveStats.d.ts.map +1 -0
- package/dist/cli/components/LiveStats.js +16 -0
- package/dist/cli/components/LiveStats.js.map +1 -0
- package/dist/cli/components/SessionBrowser.d.ts +14 -0
- package/dist/cli/components/SessionBrowser.d.ts.map +1 -0
- package/dist/cli/components/SessionBrowser.js +14 -0
- package/dist/cli/components/SessionBrowser.js.map +1 -0
- package/dist/cli/index.js +0 -0
- package/dist/cli/tui.d.ts +21 -0
- package/dist/cli/tui.d.ts.map +1 -0
- package/dist/cli/tui.js +21 -0
- package/dist/cli/tui.js.map +1 -0
- package/dist/hooks/autopilot/signals.d.ts +20 -0
- package/dist/hooks/autopilot/signals.d.ts.map +1 -0
- package/dist/hooks/autopilot/signals.js +75 -0
- package/dist/hooks/autopilot/signals.js.map +1 -0
- package/dist/hooks/autopilot/summary.d.ts +27 -0
- package/dist/hooks/autopilot/summary.d.ts.map +1 -0
- package/dist/hooks/autopilot/summary.js +160 -0
- package/dist/hooks/autopilot/summary.js.map +1 -0
- package/dist/hooks/autopilot/transition.d.ts +39 -0
- package/dist/hooks/autopilot/transition.d.ts.map +1 -0
- package/dist/hooks/autopilot/transition.js +216 -0
- package/dist/hooks/autopilot/transition.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/constants.d.ts +28 -0
- package/dist/hooks/context-window-limit-recovery/constants.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/constants.js +85 -0
- package/dist/hooks/context-window-limit-recovery/constants.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/index.d.ts +62 -0
- package/dist/hooks/context-window-limit-recovery/index.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/index.js +201 -0
- package/dist/hooks/context-window-limit-recovery/index.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/parser.d.ts +31 -0
- package/dist/hooks/context-window-limit-recovery/parser.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/parser.js +241 -0
- package/dist/hooks/context-window-limit-recovery/parser.js.map +1 -0
- package/dist/hooks/context-window-limit-recovery/types.d.ts +84 -0
- package/dist/hooks/context-window-limit-recovery/types.d.ts.map +1 -0
- package/dist/hooks/context-window-limit-recovery/types.js +34 -0
- package/dist/hooks/context-window-limit-recovery/types.js.map +1 -0
- package/dist/hooks/edit-error-recovery/index.d.ts +62 -0
- package/dist/hooks/edit-error-recovery/index.d.ts.map +1 -0
- package/dist/hooks/edit-error-recovery/index.js +89 -0
- package/dist/hooks/edit-error-recovery/index.js.map +1 -0
- package/dist/hooks/learned-skills/config.d.ts +53 -0
- package/dist/hooks/learned-skills/config.d.ts.map +1 -0
- package/dist/hooks/learned-skills/config.js +103 -0
- package/dist/hooks/learned-skills/config.js.map +1 -0
- package/dist/hooks/learned-skills/constants.d.ts +24 -0
- package/dist/hooks/learned-skills/constants.d.ts.map +1 -0
- package/dist/hooks/learned-skills/constants.js +26 -0
- package/dist/hooks/learned-skills/constants.js.map +1 -0
- package/dist/hooks/learned-skills/detection-hook.d.ts +39 -0
- package/dist/hooks/learned-skills/detection-hook.d.ts.map +1 -0
- package/dist/hooks/learned-skills/detection-hook.js +83 -0
- package/dist/hooks/learned-skills/detection-hook.js.map +1 -0
- package/dist/hooks/learned-skills/detector.d.ts +30 -0
- package/dist/hooks/learned-skills/detector.d.ts.map +1 -0
- package/dist/hooks/learned-skills/detector.js +150 -0
- package/dist/hooks/learned-skills/detector.js.map +1 -0
- package/dist/hooks/learned-skills/finder.d.ts +21 -0
- package/dist/hooks/learned-skills/finder.d.ts.map +1 -0
- package/dist/hooks/learned-skills/finder.js +117 -0
- package/dist/hooks/learned-skills/finder.js.map +1 -0
- package/dist/hooks/learned-skills/index.d.ts +62 -0
- package/dist/hooks/learned-skills/index.d.ts.map +1 -0
- package/dist/hooks/learned-skills/index.js +137 -0
- package/dist/hooks/learned-skills/index.js.map +1 -0
- package/dist/hooks/learned-skills/loader.d.ts +20 -0
- package/dist/hooks/learned-skills/loader.d.ts.map +1 -0
- package/dist/hooks/learned-skills/loader.js +107 -0
- package/dist/hooks/learned-skills/loader.js.map +1 -0
- package/dist/hooks/learned-skills/parser.d.ts +21 -0
- package/dist/hooks/learned-skills/parser.d.ts.map +1 -0
- package/dist/hooks/learned-skills/parser.js +190 -0
- package/dist/hooks/learned-skills/parser.js.map +1 -0
- package/dist/hooks/learned-skills/promotion.d.ts +29 -0
- package/dist/hooks/learned-skills/promotion.d.ts.map +1 -0
- package/dist/hooks/learned-skills/promotion.js +87 -0
- package/dist/hooks/learned-skills/promotion.js.map +1 -0
- package/dist/hooks/learned-skills/types.d.ts +109 -0
- package/dist/hooks/learned-skills/types.d.ts.map +1 -0
- package/dist/hooks/learned-skills/types.js +8 -0
- package/dist/hooks/learned-skills/types.js.map +1 -0
- package/dist/hooks/learned-skills/validator.d.ts +15 -0
- package/dist/hooks/learned-skills/validator.d.ts.map +1 -0
- package/dist/hooks/learned-skills/validator.js +87 -0
- package/dist/hooks/learned-skills/validator.js.map +1 -0
- package/dist/hooks/learned-skills/writer.d.ts +27 -0
- package/dist/hooks/learned-skills/writer.d.ts.map +1 -0
- package/dist/hooks/learned-skills/writer.js +126 -0
- package/dist/hooks/learned-skills/writer.js.map +1 -0
- package/dist/hooks/mnemosyne/config.d.ts +53 -0
- package/dist/hooks/mnemosyne/config.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/config.js +103 -0
- package/dist/hooks/mnemosyne/config.js.map +1 -0
- package/dist/hooks/mnemosyne/constants.d.ts +24 -0
- package/dist/hooks/mnemosyne/constants.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/constants.js +26 -0
- package/dist/hooks/mnemosyne/constants.js.map +1 -0
- package/dist/hooks/mnemosyne/detection-hook.d.ts +39 -0
- package/dist/hooks/mnemosyne/detection-hook.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/detection-hook.js +83 -0
- package/dist/hooks/mnemosyne/detection-hook.js.map +1 -0
- package/dist/hooks/mnemosyne/detector.d.ts +30 -0
- package/dist/hooks/mnemosyne/detector.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/detector.js +150 -0
- package/dist/hooks/mnemosyne/detector.js.map +1 -0
- package/dist/hooks/mnemosyne/finder.d.ts +21 -0
- package/dist/hooks/mnemosyne/finder.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/finder.js +117 -0
- package/dist/hooks/mnemosyne/finder.js.map +1 -0
- package/dist/hooks/mnemosyne/index.d.ts +62 -0
- package/dist/hooks/mnemosyne/index.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/index.js +137 -0
- package/dist/hooks/mnemosyne/index.js.map +1 -0
- package/dist/hooks/mnemosyne/loader.d.ts +20 -0
- package/dist/hooks/mnemosyne/loader.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/loader.js +113 -0
- package/dist/hooks/mnemosyne/loader.js.map +1 -0
- package/dist/hooks/mnemosyne/parser.d.ts +21 -0
- package/dist/hooks/mnemosyne/parser.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/parser.js +190 -0
- package/dist/hooks/mnemosyne/parser.js.map +1 -0
- package/dist/hooks/mnemosyne/promotion.d.ts +29 -0
- package/dist/hooks/mnemosyne/promotion.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/promotion.js +87 -0
- package/dist/hooks/mnemosyne/promotion.js.map +1 -0
- package/dist/hooks/mnemosyne/types.d.ts +109 -0
- package/dist/hooks/mnemosyne/types.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/types.js +8 -0
- package/dist/hooks/mnemosyne/types.js.map +1 -0
- package/dist/hooks/mnemosyne/validator.d.ts +15 -0
- package/dist/hooks/mnemosyne/validator.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/validator.js +87 -0
- package/dist/hooks/mnemosyne/validator.js.map +1 -0
- package/dist/hooks/mnemosyne/writer.d.ts +27 -0
- package/dist/hooks/mnemosyne/writer.d.ts.map +1 -0
- package/dist/hooks/mnemosyne/writer.js +126 -0
- package/dist/hooks/mnemosyne/writer.js.map +1 -0
- package/dist/hooks/ralph-loop/index.d.ts +116 -0
- package/dist/hooks/ralph-loop/index.d.ts.map +1 -0
- package/dist/hooks/ralph-loop/index.js +322 -0
- package/dist/hooks/ralph-loop/index.js.map +1 -0
- package/dist/hooks/ralph-prd/index.d.ts +130 -0
- package/dist/hooks/ralph-prd/index.d.ts.map +1 -0
- package/dist/hooks/ralph-prd/index.js +310 -0
- package/dist/hooks/ralph-prd/index.js.map +1 -0
- package/dist/hooks/ralph-progress/index.d.ts +102 -0
- package/dist/hooks/ralph-progress/index.d.ts.map +1 -0
- package/dist/hooks/ralph-progress/index.js +408 -0
- package/dist/hooks/ralph-progress/index.js.map +1 -0
- package/dist/hooks/ralph-verifier/index.d.ts +72 -0
- package/dist/hooks/ralph-verifier/index.d.ts.map +1 -0
- package/dist/hooks/ralph-verifier/index.js +223 -0
- package/dist/hooks/ralph-verifier/index.js.map +1 -0
- package/dist/hooks/session-recovery/constants.d.ts +56 -0
- package/dist/hooks/session-recovery/constants.d.ts.map +1 -0
- package/dist/hooks/session-recovery/constants.js +78 -0
- package/dist/hooks/session-recovery/constants.js.map +1 -0
- package/dist/hooks/session-recovery/index.d.ts +53 -0
- package/dist/hooks/session-recovery/index.d.ts.map +1 -0
- package/dist/hooks/session-recovery/index.js +321 -0
- package/dist/hooks/session-recovery/index.js.map +1 -0
- package/dist/hooks/session-recovery/storage.d.ts +76 -0
- package/dist/hooks/session-recovery/storage.d.ts.map +1 -0
- package/dist/hooks/session-recovery/storage.js +383 -0
- package/dist/hooks/session-recovery/storage.js.map +1 -0
- package/dist/hooks/session-recovery/types.d.ts +145 -0
- package/dist/hooks/session-recovery/types.d.ts.map +1 -0
- package/dist/hooks/session-recovery/types.js +8 -0
- package/dist/hooks/session-recovery/types.js.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/constants.d.ts +23 -0
- package/dist/hooks/sisyphus-orchestrator/constants.d.ts.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/constants.js +142 -0
- package/dist/hooks/sisyphus-orchestrator/constants.js.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/index.d.ts +113 -0
- package/dist/hooks/sisyphus-orchestrator/index.d.ts.map +1 -0
- package/dist/hooks/sisyphus-orchestrator/index.js +309 -0
- package/dist/hooks/sisyphus-orchestrator/index.js.map +1 -0
- package/dist/hooks/subagent-tracker/index.d.ts +83 -0
- package/dist/hooks/subagent-tracker/index.d.ts.map +1 -0
- package/dist/hooks/subagent-tracker/index.js +207 -0
- package/dist/hooks/subagent-tracker/index.js.map +1 -0
- package/dist/hooks/ultraqa-loop/index.d.ts +94 -0
- package/dist/hooks/ultraqa-loop/index.d.ts.map +1 -0
- package/dist/hooks/ultraqa-loop/index.js +216 -0
- package/dist/hooks/ultraqa-loop/index.js.map +1 -0
- package/dist/hooks/ultrawork-state/index.d.ts +62 -0
- package/dist/hooks/ultrawork-state/index.d.ts.map +1 -0
- package/dist/hooks/ultrawork-state/index.js +208 -0
- package/dist/hooks/ultrawork-state/index.js.map +1 -0
- package/dist/hud/sisyphus-state.d.ts +31 -0
- package/dist/hud/sisyphus-state.d.ts.map +1 -0
- package/dist/hud/sisyphus-state.js +163 -0
- package/dist/hud/sisyphus-state.js.map +1 -0
- package/dist/installer/index.d.ts +1 -1
- package/dist/installer/index.js +1 -1
- package/docs/MIGRATION.md +2 -2
- package/docs/design/project-session-manager.md +1033 -0
- package/package.json +1 -1
- package/skills/doctor/SKILL.md +1 -1
- package/skills/project-session-manager/SKILL.md +410 -0
- package/skills/project-session-manager/lib/config.sh +86 -0
- package/skills/project-session-manager/lib/parse.sh +121 -0
- package/skills/project-session-manager/lib/session.sh +132 -0
- package/skills/project-session-manager/lib/tmux.sh +103 -0
- package/skills/project-session-manager/lib/worktree.sh +171 -0
- package/skills/project-session-manager/psm.sh +629 -0
- package/skills/project-session-manager/templates/feature.md +56 -0
- package/skills/project-session-manager/templates/issue-fix.md +57 -0
- package/skills/project-session-manager/templates/pr-review.md +65 -0
- package/skills/project-session-manager/templates/projects.json +19 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ralph Verifier
|
|
3
|
+
*
|
|
4
|
+
* Adds architect verification to ralph completion claims.
|
|
5
|
+
* When ralph outputs a completion promise, instead of immediately
|
|
6
|
+
* accepting it, we trigger an architect verification phase.
|
|
7
|
+
*
|
|
8
|
+
* Flow:
|
|
9
|
+
* 1. Ralph outputs <promise>TASK_COMPLETE</promise>
|
|
10
|
+
* 2. System detects this and enters verification mode
|
|
11
|
+
* 3. Architect agent is invoked to verify the work
|
|
12
|
+
* 4. If architect approves -> truly complete
|
|
13
|
+
* 5. If architect finds flaws -> continue ralph with architect feedback
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync, readFileSync, writeFileSync, unlinkSync, mkdirSync } from 'fs';
|
|
16
|
+
import { join } from 'path';
|
|
17
|
+
const DEFAULT_MAX_VERIFICATION_ATTEMPTS = 3;
|
|
18
|
+
/**
|
|
19
|
+
* Get verification state file path
|
|
20
|
+
*/
|
|
21
|
+
function getVerificationStatePath(directory) {
|
|
22
|
+
return join(directory, '.omc', 'ralph-verification.json');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Read verification state
|
|
26
|
+
*/
|
|
27
|
+
export function readVerificationState(directory) {
|
|
28
|
+
const statePath = getVerificationStatePath(directory);
|
|
29
|
+
if (!existsSync(statePath)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(readFileSync(statePath, 'utf-8'));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Write verification state
|
|
41
|
+
*/
|
|
42
|
+
export function writeVerificationState(directory, state) {
|
|
43
|
+
const statePath = getVerificationStatePath(directory);
|
|
44
|
+
const stateDir = join(directory, '.omc');
|
|
45
|
+
if (!existsSync(stateDir)) {
|
|
46
|
+
try {
|
|
47
|
+
mkdirSync(stateDir, { recursive: true });
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
writeFileSync(statePath, JSON.stringify(state, null, 2));
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Clear verification state
|
|
63
|
+
*/
|
|
64
|
+
export function clearVerificationState(directory) {
|
|
65
|
+
const statePath = getVerificationStatePath(directory);
|
|
66
|
+
if (existsSync(statePath)) {
|
|
67
|
+
try {
|
|
68
|
+
unlinkSync(statePath);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Start verification process
|
|
79
|
+
*/
|
|
80
|
+
export function startVerification(directory, completionClaim, originalTask) {
|
|
81
|
+
const state = {
|
|
82
|
+
pending: true,
|
|
83
|
+
completion_claim: completionClaim,
|
|
84
|
+
verification_attempts: 0,
|
|
85
|
+
max_verification_attempts: DEFAULT_MAX_VERIFICATION_ATTEMPTS,
|
|
86
|
+
requested_at: new Date().toISOString(),
|
|
87
|
+
original_task: originalTask
|
|
88
|
+
};
|
|
89
|
+
writeVerificationState(directory, state);
|
|
90
|
+
return state;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Record architect feedback
|
|
94
|
+
*/
|
|
95
|
+
export function recordArchitectFeedback(directory, approved, feedback) {
|
|
96
|
+
const state = readVerificationState(directory);
|
|
97
|
+
if (!state) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
state.verification_attempts += 1;
|
|
101
|
+
state.architect_approved = approved;
|
|
102
|
+
state.architect_feedback = feedback;
|
|
103
|
+
if (approved) {
|
|
104
|
+
// Clear state on approval
|
|
105
|
+
clearVerificationState(directory);
|
|
106
|
+
return { ...state, pending: false };
|
|
107
|
+
}
|
|
108
|
+
// Check if max attempts reached
|
|
109
|
+
if (state.verification_attempts >= state.max_verification_attempts) {
|
|
110
|
+
clearVerificationState(directory);
|
|
111
|
+
return { ...state, pending: false };
|
|
112
|
+
}
|
|
113
|
+
// Continue verification loop
|
|
114
|
+
writeVerificationState(directory, state);
|
|
115
|
+
return state;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Generate architect verification prompt
|
|
119
|
+
*/
|
|
120
|
+
export function getArchitectVerificationPrompt(state) {
|
|
121
|
+
return `<ralph-verification>
|
|
122
|
+
|
|
123
|
+
[ARCHITECT VERIFICATION REQUIRED - Attempt ${state.verification_attempts + 1}/${state.max_verification_attempts}]
|
|
124
|
+
|
|
125
|
+
The agent claims the task is complete. Before accepting, YOU MUST verify with Architect.
|
|
126
|
+
|
|
127
|
+
**Original Task:**
|
|
128
|
+
${state.original_task}
|
|
129
|
+
|
|
130
|
+
**Completion Claim:**
|
|
131
|
+
${state.completion_claim}
|
|
132
|
+
|
|
133
|
+
${state.architect_feedback ? `**Previous Architect Feedback (rejected):**\n${state.architect_feedback}\n` : ''}
|
|
134
|
+
|
|
135
|
+
## MANDATORY VERIFICATION STEPS
|
|
136
|
+
|
|
137
|
+
1. **Spawn Architect Agent** for verification:
|
|
138
|
+
\`\`\`
|
|
139
|
+
Task(subagent_type="architect", prompt="Verify this task completion claim...")
|
|
140
|
+
\`\`\`
|
|
141
|
+
|
|
142
|
+
2. **Architect must check:**
|
|
143
|
+
- Are ALL requirements from the original task met?
|
|
144
|
+
- Is the implementation complete, not partial?
|
|
145
|
+
- Are there any obvious bugs or issues?
|
|
146
|
+
- Does the code compile/run without errors?
|
|
147
|
+
- Are tests passing (if applicable)?
|
|
148
|
+
|
|
149
|
+
3. **Based on Architect's response:**
|
|
150
|
+
- If APPROVED: Output \`<architect-approved>VERIFIED_COMPLETE</architect-approved>\`
|
|
151
|
+
- If REJECTED: Continue working on the identified issues
|
|
152
|
+
|
|
153
|
+
DO NOT output the completion promise again until Architect approves.
|
|
154
|
+
|
|
155
|
+
</ralph-verification>
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Generate continuation prompt after architect rejection
|
|
163
|
+
*/
|
|
164
|
+
export function getArchitectRejectionContinuationPrompt(state) {
|
|
165
|
+
return `<ralph-continuation-after-rejection>
|
|
166
|
+
|
|
167
|
+
[ARCHITECT REJECTED - Continue Working]
|
|
168
|
+
|
|
169
|
+
Architect found issues with your completion claim. You must address them.
|
|
170
|
+
|
|
171
|
+
**Architect Feedback:**
|
|
172
|
+
${state.architect_feedback}
|
|
173
|
+
|
|
174
|
+
**Original Task:**
|
|
175
|
+
${state.original_task}
|
|
176
|
+
|
|
177
|
+
## INSTRUCTIONS
|
|
178
|
+
|
|
179
|
+
1. Address ALL issues identified by Architect
|
|
180
|
+
2. Do NOT claim completion again until issues are fixed
|
|
181
|
+
3. When truly done, output the completion promise again
|
|
182
|
+
4. Another Architect verification will be triggered
|
|
183
|
+
|
|
184
|
+
Continue working now.
|
|
185
|
+
|
|
186
|
+
</ralph-continuation-after-rejection>
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
`;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Check if text contains architect approval
|
|
194
|
+
*/
|
|
195
|
+
export function detectArchitectApproval(text) {
|
|
196
|
+
return /<architect-approved>.*?VERIFIED_COMPLETE.*?<\/architect-approved>/is.test(text);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Check if text contains architect rejection indicators
|
|
200
|
+
*/
|
|
201
|
+
export function detectArchitectRejection(text) {
|
|
202
|
+
// Look for explicit rejection patterns
|
|
203
|
+
const rejectionPatterns = [
|
|
204
|
+
/architect.*?(rejected|found issues|not complete|incomplete)/i,
|
|
205
|
+
/issues? (found|identified|detected)/i,
|
|
206
|
+
/not yet complete/i,
|
|
207
|
+
/missing.*?(implementation|feature|test)/i,
|
|
208
|
+
/bug.*?(found|detected|identified)/i,
|
|
209
|
+
/error.*?(found|detected|identified)/i
|
|
210
|
+
];
|
|
211
|
+
for (const pattern of rejectionPatterns) {
|
|
212
|
+
if (pattern.test(text)) {
|
|
213
|
+
// Extract feedback (rough heuristic)
|
|
214
|
+
const feedbackMatch = text.match(/(?:architect|feedback|issue|problem|error|bug)[:\s]+([^.]+\.)/i);
|
|
215
|
+
return {
|
|
216
|
+
rejected: true,
|
|
217
|
+
feedback: feedbackMatch ? feedbackMatch[1] : 'Architect found issues with the implementation.'
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return { rejected: false, feedback: '' };
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/ralph-verifier/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAqB5B,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAE5C;;GAEG;AACH,SAAS,wBAAwB,CAAC,SAAiB;IACjD,OAAO,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,yBAAyB,CAAC,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAiB;IACrD,MAAM,SAAS,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;IACtD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,SAAiB,EAAE,KAAwB;IAChF,MAAM,SAAS,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAEzC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,IAAI,CAAC;YACH,SAA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AO,qEAAqE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAY;IACnD,uCAAuC;IACvC,MAAM,iBAAiB,GAAG;QACxB,8DAA8D;QAC9D,sCAAsC;QACtC,mBAAmB;QACnB,0CAA0C;QAC1C,oCAAoC;QACpC,sCAAsC;KACvC,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACxC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,qCAAqC;YACrC,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;YACnG,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,iDAAiD;aAC/F,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Recovery Constants
|
|
3
|
+
*
|
|
4
|
+
* Constants for session recovery including storage paths and recovery messages.
|
|
5
|
+
* Adapted from oh-my-opencode's session-recovery hook.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CLAUDE_CODE_STORAGE: string;
|
|
8
|
+
export declare const MESSAGE_STORAGE: string;
|
|
9
|
+
export declare const PART_STORAGE: string;
|
|
10
|
+
/**
|
|
11
|
+
* Part type sets for categorization
|
|
12
|
+
*/
|
|
13
|
+
export declare const THINKING_TYPES: Set<string>;
|
|
14
|
+
export declare const META_TYPES: Set<string>;
|
|
15
|
+
export declare const CONTENT_TYPES: Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Recovery messages
|
|
18
|
+
*/
|
|
19
|
+
export declare const RECOVERY_RESUME_TEXT = "[session recovered - continuing previous task]";
|
|
20
|
+
export declare const PLACEHOLDER_TEXT = "[user interrupted]";
|
|
21
|
+
/**
|
|
22
|
+
* Toast/notification messages for recovery
|
|
23
|
+
*/
|
|
24
|
+
export declare const RECOVERY_MESSAGES: {
|
|
25
|
+
readonly tool_result_missing: {
|
|
26
|
+
readonly title: "Tool Crash Recovery";
|
|
27
|
+
readonly message: "Injecting cancelled tool results...";
|
|
28
|
+
};
|
|
29
|
+
readonly thinking_block_order: {
|
|
30
|
+
readonly title: "Thinking Block Recovery";
|
|
31
|
+
readonly message: "Fixing message structure...";
|
|
32
|
+
};
|
|
33
|
+
readonly thinking_disabled_violation: {
|
|
34
|
+
readonly title: "Thinking Strip Recovery";
|
|
35
|
+
readonly message: "Stripping thinking blocks...";
|
|
36
|
+
};
|
|
37
|
+
readonly empty_content: {
|
|
38
|
+
readonly title: "Empty Content Recovery";
|
|
39
|
+
readonly message: "Adding placeholder content...";
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Recovery error patterns
|
|
44
|
+
*/
|
|
45
|
+
export declare const ERROR_PATTERNS: {
|
|
46
|
+
readonly tool_result_missing: readonly ["tool_use", "tool_result"];
|
|
47
|
+
readonly thinking_block_order: readonly ["thinking", "first block", "must start with", "preceeding", "final block", "cannot be thinking"];
|
|
48
|
+
readonly thinking_disabled_violation: readonly ["thinking is disabled", "cannot contain"];
|
|
49
|
+
readonly empty_content: readonly ["empty", "content", "message"];
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Debug logging configuration
|
|
53
|
+
*/
|
|
54
|
+
export declare const DEBUG: boolean;
|
|
55
|
+
export declare const DEBUG_LOG_PATH: string;
|
|
56
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/hooks/session-recovery/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,eAAO,MAAM,mBAAmB,QAA4B,CAAC;AAC7D,eAAO,MAAM,eAAe,QAAuC,CAAC;AACpE,eAAO,MAAM,YAAY,QAAoC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,cAAc,aAA0D,CAAC;AACtF,eAAO,MAAM,UAAU,aAAyC,CAAC;AACjE,eAAO,MAAM,aAAa,aAAuD,CAAC;AAElF;;GAEG;AACH,eAAO,MAAM,oBAAoB,mDAAmD,CAAC;AACrF,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAiBpB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;CAYjB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,KAAK,SAA6C,CAAC;AAChE,eAAO,MAAM,cAAc,QAA+C,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Recovery Constants
|
|
3
|
+
*
|
|
4
|
+
* Constants for session recovery including storage paths and recovery messages.
|
|
5
|
+
* Adapted from oh-my-opencode's session-recovery hook.
|
|
6
|
+
*/
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { homedir, tmpdir } from "node:os";
|
|
9
|
+
/**
|
|
10
|
+
* Get the data directory for Claude Code storage
|
|
11
|
+
* Follows XDG Base Directory specification
|
|
12
|
+
*/
|
|
13
|
+
function getDataDir() {
|
|
14
|
+
return process.env.XDG_DATA_HOME ?? join(homedir(), ".local", "share");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the Claude Code storage directory
|
|
18
|
+
*/
|
|
19
|
+
function getClaudeCodeStorageDir() {
|
|
20
|
+
return join(getDataDir(), "claude-code", "storage");
|
|
21
|
+
}
|
|
22
|
+
export const CLAUDE_CODE_STORAGE = getClaudeCodeStorageDir();
|
|
23
|
+
export const MESSAGE_STORAGE = join(CLAUDE_CODE_STORAGE, "message");
|
|
24
|
+
export const PART_STORAGE = join(CLAUDE_CODE_STORAGE, "part");
|
|
25
|
+
/**
|
|
26
|
+
* Part type sets for categorization
|
|
27
|
+
*/
|
|
28
|
+
export const THINKING_TYPES = new Set(["thinking", "redacted_thinking", "reasoning"]);
|
|
29
|
+
export const META_TYPES = new Set(["step-start", "step-finish"]);
|
|
30
|
+
export const CONTENT_TYPES = new Set(["text", "tool", "tool_use", "tool_result"]);
|
|
31
|
+
/**
|
|
32
|
+
* Recovery messages
|
|
33
|
+
*/
|
|
34
|
+
export const RECOVERY_RESUME_TEXT = "[session recovered - continuing previous task]";
|
|
35
|
+
export const PLACEHOLDER_TEXT = "[user interrupted]";
|
|
36
|
+
/**
|
|
37
|
+
* Toast/notification messages for recovery
|
|
38
|
+
*/
|
|
39
|
+
export const RECOVERY_MESSAGES = {
|
|
40
|
+
tool_result_missing: {
|
|
41
|
+
title: "Tool Crash Recovery",
|
|
42
|
+
message: "Injecting cancelled tool results...",
|
|
43
|
+
},
|
|
44
|
+
thinking_block_order: {
|
|
45
|
+
title: "Thinking Block Recovery",
|
|
46
|
+
message: "Fixing message structure...",
|
|
47
|
+
},
|
|
48
|
+
thinking_disabled_violation: {
|
|
49
|
+
title: "Thinking Strip Recovery",
|
|
50
|
+
message: "Stripping thinking blocks...",
|
|
51
|
+
},
|
|
52
|
+
empty_content: {
|
|
53
|
+
title: "Empty Content Recovery",
|
|
54
|
+
message: "Adding placeholder content...",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Recovery error patterns
|
|
59
|
+
*/
|
|
60
|
+
export const ERROR_PATTERNS = {
|
|
61
|
+
tool_result_missing: ["tool_use", "tool_result"],
|
|
62
|
+
thinking_block_order: [
|
|
63
|
+
"thinking",
|
|
64
|
+
"first block",
|
|
65
|
+
"must start with",
|
|
66
|
+
"preceeding",
|
|
67
|
+
"final block",
|
|
68
|
+
"cannot be thinking",
|
|
69
|
+
],
|
|
70
|
+
thinking_disabled_violation: ["thinking is disabled", "cannot contain"],
|
|
71
|
+
empty_content: ["empty", "content", "message"],
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Debug logging configuration
|
|
75
|
+
*/
|
|
76
|
+
export const DEBUG = process.env.SESSION_RECOVERY_DEBUG === "1";
|
|
77
|
+
export const DEBUG_LOG_PATH = join(tmpdir(), "session-recovery-debug.log");
|
|
78
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/hooks/session-recovery/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE1C;;;GAGG;AACH,SAAS,UAAU;IACjB,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB;IAC9B,OAAO,IAAI,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,EAAE,CAAC;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,mBAAmB,EAAE,WAAW,CAAC,CAAC,CAAC;AACtF,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;AACjE,MAAM,CA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ashes.
|
|
5
|
+
* Detects and fixes various error conditions that can cause session failures.
|
|
6
|
+
*
|
|
7
|
+
* Adapted from oh-my-opencode's session-recovery hook for Claude Code's
|
|
8
|
+
* shell hook system.
|
|
9
|
+
*
|
|
10
|
+
* Recovery Strategies:
|
|
11
|
+
* 1. Tool Result Missing: Inject cancelled tool results for orphaned tool_use
|
|
12
|
+
* 2. Thinking Block Order: Fix messages where thinking isn't first
|
|
13
|
+
* 3. Thinking Disabled: Strip thinking blocks when model doesn't support them
|
|
14
|
+
* 4. Empty Content: Add placeholder text to empty messages
|
|
15
|
+
*/
|
|
16
|
+
import type { MessageData, RecoveryErrorType, RecoveryResult, SessionRecoveryConfig } from "./types.js";
|
|
17
|
+
/**
|
|
18
|
+
* Detect the type of recoverable error
|
|
19
|
+
*/
|
|
20
|
+
export declare function detectErrorType(error: unknown): RecoveryErrorType;
|
|
21
|
+
/**
|
|
22
|
+
* Check if an error is recoverable
|
|
23
|
+
*/
|
|
24
|
+
export declare function isRecoverableError(error: unknown): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Main recovery handler
|
|
27
|
+
*/
|
|
28
|
+
export declare function handleSessionRecovery(sessionID: string, error: unknown, failedMessage?: MessageData, config?: SessionRecoveryConfig): Promise<RecoveryResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Create session recovery hook for Claude Code
|
|
31
|
+
*/
|
|
32
|
+
export declare function createSessionRecoveryHook(config?: SessionRecoveryConfig): {
|
|
33
|
+
/**
|
|
34
|
+
* Check for errors during tool execution or message processing
|
|
35
|
+
*/
|
|
36
|
+
onError: (input: {
|
|
37
|
+
session_id: string;
|
|
38
|
+
error: unknown;
|
|
39
|
+
message?: MessageData;
|
|
40
|
+
}) => Promise<RecoveryResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Check if an error is recoverable
|
|
43
|
+
*/
|
|
44
|
+
isRecoverable: (error: unknown) => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Get recovery message for an error type
|
|
47
|
+
*/
|
|
48
|
+
getRecoveryMessage: (errorType: RecoveryErrorType) => string | undefined;
|
|
49
|
+
};
|
|
50
|
+
export type { MessageData, RecoveryErrorType, RecoveryResult, SessionRecoveryConfig, StoredMessageMeta, StoredPart, StoredTextPart, StoredToolPart, } from "./types.js";
|
|
51
|
+
export { RECOVERY_MESSAGES, PLACEHOLDER_TEXT, } from "./constants.js";
|
|
52
|
+
export { findEmptyMessages, findMessagesWithThinkingBlocks, findMessagesWithOrphanThinking, readMessages, readParts, } from "./storage.js";
|
|
53
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/session-recovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiBH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACtB,MAAM,YAAY,CAAC;AA4DpB;;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,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,CAqDzB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,CAAC,EAAE,qBAAqB;IAIpE;;OAEG;qBACoB;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,WAAW,CAAC;KACvB,KAAG,OAAO,CAAC,cAAc,CAAC;IAS3B;;OAEG;2BACoB,OAAO,KAAG,OAAO;IAIxC;;OAEG;oCAC6B,iBAAiB,KAAG,MAAM,GAAG,SAAS;EAMzE;AAGD,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iBAAiB,EACjB,8BAA8B,EAC9B,8BAA8B,EAC9B,YAAY,EACZ,SAAS,GACV,MAAM,cAAc,CAAC"}
|