nodebench-mcp 2.69.0 → 3.0.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 +95 -39
- package/dist/agents/alertRouter.d.ts +38 -0
- package/dist/agents/alertRouter.js +151 -0
- package/dist/agents/alertRouter.js.map +1 -0
- package/dist/agents/entityMemory.d.ts +40 -0
- package/dist/agents/entityMemory.js +64 -0
- package/dist/agents/entityMemory.js.map +1 -0
- package/dist/agents/subAgents.d.ts +35 -0
- package/dist/agents/subAgents.js +62 -0
- package/dist/agents/subAgents.js.map +1 -0
- package/dist/benchmarks/benchmarkRunner.js +14 -0
- package/dist/benchmarks/benchmarkRunner.js.map +1 -1
- package/dist/benchmarks/chainEval.js +107 -0
- package/dist/benchmarks/chainEval.js.map +1 -1
- package/dist/benchmarks/llmJudgeEval.js +85 -0
- package/dist/benchmarks/llmJudgeEval.js.map +1 -1
- package/dist/benchmarks/searchQualityEval.js +118 -5
- package/dist/benchmarks/searchQualityEval.js.map +1 -1
- package/dist/cli/search.d.ts +13 -0
- package/dist/cli/search.js +130 -0
- package/dist/cli/search.js.map +1 -0
- package/dist/db.d.ts +6 -2
- package/dist/db.js +470 -3
- package/dist/db.js.map +1 -1
- package/dist/index.js +349 -64
- package/dist/index.js.map +1 -1
- package/dist/profiler/behaviorStore.d.ts +97 -0
- package/dist/profiler/behaviorStore.js +276 -0
- package/dist/profiler/behaviorStore.js.map +1 -0
- package/dist/profiler/eventCollector.d.ts +119 -0
- package/dist/profiler/eventCollector.js +267 -0
- package/dist/profiler/eventCollector.js.map +1 -0
- package/dist/profiler/index.d.ts +15 -0
- package/dist/profiler/index.js +16 -0
- package/dist/profiler/index.js.map +1 -0
- package/dist/profiler/mcpProxy.d.ts +49 -0
- package/dist/profiler/mcpProxy.js +123 -0
- package/dist/profiler/mcpProxy.js.map +1 -0
- package/dist/profiler/modelRouter.d.ts +30 -0
- package/dist/profiler/modelRouter.js +99 -0
- package/dist/profiler/modelRouter.js.map +1 -0
- package/dist/profiler/otelReceiver.d.ts +17 -0
- package/dist/profiler/otelReceiver.js +62 -0
- package/dist/profiler/otelReceiver.js.map +1 -0
- package/dist/profiler/proofEngine.d.ts +41 -0
- package/dist/profiler/proofEngine.js +93 -0
- package/dist/profiler/proofEngine.js.map +1 -0
- package/dist/profiler/workflowTemplates.d.ts +41 -0
- package/dist/profiler/workflowTemplates.js +95 -0
- package/dist/profiler/workflowTemplates.js.map +1 -0
- package/dist/providers/localMemoryProvider.js +3 -2
- package/dist/providers/localMemoryProvider.js.map +1 -1
- package/dist/runtimeConfig.d.ts +11 -0
- package/dist/runtimeConfig.js +27 -0
- package/dist/runtimeConfig.js.map +1 -0
- package/dist/security/auditLog.js +8 -3
- package/dist/security/auditLog.js.map +1 -1
- package/dist/subconscious/blocks.d.ts +43 -0
- package/dist/subconscious/blocks.js +158 -0
- package/dist/subconscious/blocks.js.map +1 -0
- package/dist/subconscious/classifier.d.ts +22 -0
- package/dist/subconscious/classifier.js +118 -0
- package/dist/subconscious/classifier.js.map +1 -0
- package/dist/subconscious/graphEngine.d.ts +65 -0
- package/dist/subconscious/graphEngine.js +234 -0
- package/dist/subconscious/graphEngine.js.map +1 -0
- package/dist/subconscious/index.d.ts +19 -0
- package/dist/subconscious/index.js +20 -0
- package/dist/subconscious/index.js.map +1 -0
- package/dist/subconscious/tools.d.ts +5 -0
- package/dist/subconscious/tools.js +255 -0
- package/dist/subconscious/tools.js.map +1 -0
- package/dist/subconscious/whisperPolicy.d.ts +20 -0
- package/dist/subconscious/whisperPolicy.js +171 -0
- package/dist/subconscious/whisperPolicy.js.map +1 -0
- package/dist/sweep/engine.d.ts +27 -0
- package/dist/sweep/engine.js +244 -0
- package/dist/sweep/engine.js.map +1 -0
- package/dist/sweep/index.d.ts +9 -0
- package/dist/sweep/index.js +8 -0
- package/dist/sweep/index.js.map +1 -0
- package/dist/sweep/sources/github_trending.d.ts +6 -0
- package/dist/sweep/sources/github_trending.js +37 -0
- package/dist/sweep/sources/github_trending.js.map +1 -0
- package/dist/sweep/sources/hackernews.d.ts +7 -0
- package/dist/sweep/sources/hackernews.js +57 -0
- package/dist/sweep/sources/hackernews.js.map +1 -0
- package/dist/sweep/sources/openbb_finance.d.ts +9 -0
- package/dist/sweep/sources/openbb_finance.js +46 -0
- package/dist/sweep/sources/openbb_finance.js.map +1 -0
- package/dist/sweep/sources/producthunt.d.ts +6 -0
- package/dist/sweep/sources/producthunt.js +41 -0
- package/dist/sweep/sources/producthunt.js.map +1 -0
- package/dist/sweep/sources/web_signals.d.ts +7 -0
- package/dist/sweep/sources/web_signals.js +63 -0
- package/dist/sweep/sources/web_signals.js.map +1 -0
- package/dist/sweep/sources/yahoo_finance.d.ts +6 -0
- package/dist/sweep/sources/yahoo_finance.js +47 -0
- package/dist/sweep/sources/yahoo_finance.js.map +1 -0
- package/dist/sweep/types.d.ts +50 -0
- package/dist/sweep/types.js +9 -0
- package/dist/sweep/types.js.map +1 -0
- package/dist/sync/founderEpisodeStore.d.ts +98 -0
- package/dist/sync/founderEpisodeStore.js +230 -0
- package/dist/sync/founderEpisodeStore.js.map +1 -0
- package/dist/sync/hyperloopArchive.d.ts +51 -0
- package/dist/sync/hyperloopArchive.js +153 -0
- package/dist/sync/hyperloopArchive.js.map +1 -0
- package/dist/sync/hyperloopEval.d.ts +123 -0
- package/dist/sync/hyperloopEval.js +389 -0
- package/dist/sync/hyperloopEval.js.map +1 -0
- package/dist/sync/hyperloopEval.test.d.ts +4 -0
- package/dist/sync/hyperloopEval.test.js +60 -0
- package/dist/sync/hyperloopEval.test.js.map +1 -0
- package/dist/sync/protocol.d.ts +172 -0
- package/dist/sync/protocol.js +9 -0
- package/dist/sync/protocol.js.map +1 -0
- package/dist/sync/sessionMemory.d.ts +47 -0
- package/dist/sync/sessionMemory.js +138 -0
- package/dist/sync/sessionMemory.js.map +1 -0
- package/dist/sync/store.d.ts +384 -0
- package/dist/sync/store.js +1435 -0
- package/dist/sync/store.js.map +1 -0
- package/dist/sync/store.test.d.ts +4 -0
- package/dist/sync/store.test.js +43 -0
- package/dist/sync/store.test.js.map +1 -0
- package/dist/sync/syncBridgeClient.d.ts +30 -0
- package/dist/sync/syncBridgeClient.js +172 -0
- package/dist/sync/syncBridgeClient.js.map +1 -0
- package/dist/tools/autonomousDeliveryTools.d.ts +2 -0
- package/dist/tools/autonomousDeliveryTools.js +1104 -0
- package/dist/tools/autonomousDeliveryTools.js.map +1 -0
- package/dist/tools/claudeCodeIngestTools.d.ts +10 -0
- package/dist/tools/claudeCodeIngestTools.js +347 -0
- package/dist/tools/claudeCodeIngestTools.js.map +1 -0
- package/dist/tools/coreWorkflowTools.d.ts +2 -0
- package/dist/tools/coreWorkflowTools.js +488 -0
- package/dist/tools/coreWorkflowTools.js.map +1 -0
- package/dist/tools/deltaTools.d.ts +15 -0
- package/dist/tools/deltaTools.js +1522 -0
- package/dist/tools/deltaTools.js.map +1 -0
- package/dist/tools/entityLookupTools.d.ts +14 -0
- package/dist/tools/entityLookupTools.js +159 -0
- package/dist/tools/entityLookupTools.js.map +1 -0
- package/dist/tools/entityTemporalTools.d.ts +12 -0
- package/dist/tools/entityTemporalTools.js +330 -0
- package/dist/tools/entityTemporalTools.js.map +1 -0
- package/dist/tools/founderLocalPipeline.d.ts +215 -0
- package/dist/tools/founderLocalPipeline.js +1516 -2
- package/dist/tools/founderLocalPipeline.js.map +1 -1
- package/dist/tools/founderOperatingModel.d.ts +120 -0
- package/dist/tools/founderOperatingModel.js +469 -0
- package/dist/tools/founderOperatingModel.js.map +1 -0
- package/dist/tools/founderOperatingModelTools.d.ts +2 -0
- package/dist/tools/founderOperatingModelTools.js +169 -0
- package/dist/tools/founderOperatingModelTools.js.map +1 -0
- package/dist/tools/founderStrategicOpsTools.d.ts +2 -0
- package/dist/tools/founderStrategicOpsTools.js +1310 -0
- package/dist/tools/founderStrategicOpsTools.js.map +1 -0
- package/dist/tools/graphifyTools.d.ts +19 -0
- package/dist/tools/graphifyTools.js +375 -0
- package/dist/tools/graphifyTools.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/monteCarloTools.d.ts +16 -0
- package/dist/tools/monteCarloTools.js +225 -0
- package/dist/tools/monteCarloTools.js.map +1 -0
- package/dist/tools/packetCompilerTools.d.ts +12 -0
- package/dist/tools/packetCompilerTools.js +322 -0
- package/dist/tools/packetCompilerTools.js.map +1 -0
- package/dist/tools/planSynthesisTools.d.ts +15 -0
- package/dist/tools/planSynthesisTools.js +455 -0
- package/dist/tools/planSynthesisTools.js.map +1 -0
- package/dist/tools/profilerTools.d.ts +20 -0
- package/dist/tools/profilerTools.js +364 -0
- package/dist/tools/profilerTools.js.map +1 -0
- package/dist/tools/savingsTools.d.ts +11 -0
- package/dist/tools/savingsTools.js +155 -0
- package/dist/tools/savingsTools.js.map +1 -0
- package/dist/tools/scenarioCompilerTools.d.ts +14 -0
- package/dist/tools/scenarioCompilerTools.js +290 -0
- package/dist/tools/scenarioCompilerTools.js.map +1 -0
- package/dist/tools/sharedContextTools.d.ts +2 -0
- package/dist/tools/sharedContextTools.js +423 -0
- package/dist/tools/sharedContextTools.js.map +1 -0
- package/dist/tools/sitemapTools.d.ts +15 -0
- package/dist/tools/sitemapTools.js +560 -0
- package/dist/tools/sitemapTools.js.map +1 -0
- package/dist/tools/sweepTools.d.ts +9 -0
- package/dist/tools/sweepTools.js +112 -0
- package/dist/tools/sweepTools.js.map +1 -0
- package/dist/tools/syncBridgeTools.d.ts +2 -0
- package/dist/tools/syncBridgeTools.js +258 -0
- package/dist/tools/syncBridgeTools.js.map +1 -0
- package/dist/tools/toolRegistry.js +1216 -49
- package/dist/tools/toolRegistry.js.map +1 -1
- package/dist/tools/workspaceTools.d.ts +19 -0
- package/dist/tools/workspaceTools.js +762 -0
- package/dist/tools/workspaceTools.js.map +1 -0
- package/dist/toolsetRegistry.js +88 -2
- package/dist/toolsetRegistry.js.map +1 -1
- package/package.json +36 -36
- package/rules/nodebench-agentic-reliability.md +32 -0
- package/rules/nodebench-analyst-diagnostic.md +25 -0
- package/rules/nodebench-auto-qa.md +31 -0
- package/rules/nodebench-completion-traceability.md +22 -0
- package/rules/nodebench-flywheel-continuous.md +25 -0
- package/rules/nodebench-pre-release-review.md +24 -0
- package/rules/nodebench-qa-dogfood.md +26 -0
- package/rules/nodebench-scenario-testing.md +30 -0
- package/rules/nodebench-self-direction.md +23 -0
- package/rules/nodebench-self-judge-loop.md +24 -0
- package/scripts/install.sh +215 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sessionMemory.ts — Session-scoped action/failure memory for agent learning.
|
|
3
|
+
*
|
|
4
|
+
* Ported from TA Studio's SessionMemory + LearningStore pattern.
|
|
5
|
+
* Records every action and failure in a session, generates reflection
|
|
6
|
+
* prompts for retry, and persists recovery strategies across sessions.
|
|
7
|
+
*
|
|
8
|
+
* Storage: SQLite (shared with founderEpisodeStore).
|
|
9
|
+
*/
|
|
10
|
+
export interface ActionRecord {
|
|
11
|
+
actionId: string;
|
|
12
|
+
episodeId: string;
|
|
13
|
+
stepIndex: number;
|
|
14
|
+
toolName: string;
|
|
15
|
+
input: string;
|
|
16
|
+
output: string;
|
|
17
|
+
success: boolean;
|
|
18
|
+
durationMs: number;
|
|
19
|
+
timestamp: string;
|
|
20
|
+
}
|
|
21
|
+
export interface FailureRecord {
|
|
22
|
+
failureId: string;
|
|
23
|
+
episodeId: string;
|
|
24
|
+
stepIndex: number;
|
|
25
|
+
toolName: string;
|
|
26
|
+
failureType: string;
|
|
27
|
+
rootCause: string;
|
|
28
|
+
recoveryStrategy: string;
|
|
29
|
+
recoverySuccessful: boolean | null;
|
|
30
|
+
timestamp: string;
|
|
31
|
+
}
|
|
32
|
+
export interface RecoveryStrategy {
|
|
33
|
+
strategyId: string;
|
|
34
|
+
failureType: string;
|
|
35
|
+
toolName: string;
|
|
36
|
+
strategy: string;
|
|
37
|
+
successCount: number;
|
|
38
|
+
failureCount: number;
|
|
39
|
+
lastUsed: string;
|
|
40
|
+
}
|
|
41
|
+
export declare function initSessionMemoryTables(): void;
|
|
42
|
+
export declare function recordAction(action: Omit<ActionRecord, "actionId">): ActionRecord;
|
|
43
|
+
export declare function recordFailure(failure: Omit<FailureRecord, "failureId">): FailureRecord;
|
|
44
|
+
export declare function recordRecoveryOutcome(failureType: string, toolName: string, strategy: string, succeeded: boolean): void;
|
|
45
|
+
export declare function getReflectionPrompt(failureType: string, toolName: string): string;
|
|
46
|
+
export declare function getSessionActions(episodeId: string): ActionRecord[];
|
|
47
|
+
export declare function getSessionFailures(episodeId: string): FailureRecord[];
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sessionMemory.ts — Session-scoped action/failure memory for agent learning.
|
|
3
|
+
*
|
|
4
|
+
* Ported from TA Studio's SessionMemory + LearningStore pattern.
|
|
5
|
+
* Records every action and failure in a session, generates reflection
|
|
6
|
+
* prompts for retry, and persists recovery strategies across sessions.
|
|
7
|
+
*
|
|
8
|
+
* Storage: SQLite (shared with founderEpisodeStore).
|
|
9
|
+
*/
|
|
10
|
+
import { getDb, genId } from "../db.js";
|
|
11
|
+
// ─── Schema init ─────────────────────────────────────────────────
|
|
12
|
+
const MAX_ACTIONS_PER_EPISODE = 200;
|
|
13
|
+
const MAX_RECOVERY_STRATEGIES = 100;
|
|
14
|
+
const TRUNCATE_LIMIT = 2048;
|
|
15
|
+
function truncate(s, limit = TRUNCATE_LIMIT) {
|
|
16
|
+
return s.length > limit ? s.slice(0, limit - 3) + "..." : s;
|
|
17
|
+
}
|
|
18
|
+
export function initSessionMemoryTables() {
|
|
19
|
+
const db = getDb();
|
|
20
|
+
db.exec(`
|
|
21
|
+
CREATE TABLE IF NOT EXISTS session_actions (
|
|
22
|
+
action_id TEXT PRIMARY KEY,
|
|
23
|
+
episode_id TEXT NOT NULL,
|
|
24
|
+
step_index INTEGER NOT NULL,
|
|
25
|
+
tool_name TEXT NOT NULL,
|
|
26
|
+
input TEXT NOT NULL,
|
|
27
|
+
output TEXT NOT NULL,
|
|
28
|
+
success INTEGER NOT NULL,
|
|
29
|
+
duration_ms INTEGER NOT NULL,
|
|
30
|
+
timestamp TEXT NOT NULL
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
CREATE TABLE IF NOT EXISTS session_failures (
|
|
34
|
+
failure_id TEXT PRIMARY KEY,
|
|
35
|
+
episode_id TEXT NOT NULL,
|
|
36
|
+
step_index INTEGER NOT NULL,
|
|
37
|
+
tool_name TEXT NOT NULL,
|
|
38
|
+
failure_type TEXT NOT NULL,
|
|
39
|
+
root_cause TEXT NOT NULL,
|
|
40
|
+
recovery_strategy TEXT NOT NULL,
|
|
41
|
+
recovery_successful INTEGER,
|
|
42
|
+
timestamp TEXT NOT NULL
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
CREATE TABLE IF NOT EXISTS recovery_strategies (
|
|
46
|
+
strategy_id TEXT PRIMARY KEY,
|
|
47
|
+
failure_type TEXT NOT NULL,
|
|
48
|
+
tool_name TEXT NOT NULL,
|
|
49
|
+
strategy TEXT NOT NULL,
|
|
50
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
51
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
52
|
+
last_used TEXT NOT NULL
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
CREATE INDEX IF NOT EXISTS idx_actions_episode ON session_actions(episode_id);
|
|
56
|
+
CREATE INDEX IF NOT EXISTS idx_failures_episode ON session_failures(episode_id);
|
|
57
|
+
CREATE INDEX IF NOT EXISTS idx_recovery_type ON recovery_strategies(failure_type, tool_name);
|
|
58
|
+
`);
|
|
59
|
+
}
|
|
60
|
+
// ─── Record actions ──────────────────────────────────────────────
|
|
61
|
+
export function recordAction(action) {
|
|
62
|
+
const db = getDb();
|
|
63
|
+
initSessionMemoryTables();
|
|
64
|
+
const actionId = genId("action");
|
|
65
|
+
// Enforce bounded memory: evict oldest actions if over limit
|
|
66
|
+
const countStmt = db.prepare("SELECT COUNT(*) as cnt FROM session_actions WHERE episode_id = ?");
|
|
67
|
+
const count = countStmt.get(action.episodeId)?.cnt ?? 0;
|
|
68
|
+
if (count >= MAX_ACTIONS_PER_EPISODE) {
|
|
69
|
+
db.prepare("DELETE FROM session_actions WHERE action_id IN (SELECT action_id FROM session_actions WHERE episode_id = ? ORDER BY timestamp ASC LIMIT 10)").run(action.episodeId);
|
|
70
|
+
}
|
|
71
|
+
db.prepare(`
|
|
72
|
+
INSERT INTO session_actions (action_id, episode_id, step_index, tool_name, input, output, success, duration_ms, timestamp)
|
|
73
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
74
|
+
`).run(actionId, action.episodeId, action.stepIndex, action.toolName, truncate(action.input), truncate(action.output), action.success ? 1 : 0, action.durationMs, action.timestamp);
|
|
75
|
+
return { ...action, actionId };
|
|
76
|
+
}
|
|
77
|
+
// ─── Record failures ─────────────────────────────────────────────
|
|
78
|
+
export function recordFailure(failure) {
|
|
79
|
+
const db = getDb();
|
|
80
|
+
initSessionMemoryTables();
|
|
81
|
+
const failureId = genId("failure");
|
|
82
|
+
db.prepare(`
|
|
83
|
+
INSERT INTO session_failures (failure_id, episode_id, step_index, tool_name, failure_type, root_cause, recovery_strategy, recovery_successful, timestamp)
|
|
84
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
85
|
+
`).run(failureId, failure.episodeId, failure.stepIndex, failure.toolName, failure.failureType, failure.rootCause, failure.recoveryStrategy, failure.recoverySuccessful == null ? null : failure.recoverySuccessful ? 1 : 0, failure.timestamp);
|
|
86
|
+
return { ...failure, failureId };
|
|
87
|
+
}
|
|
88
|
+
// ─── Recovery strategy persistence ───────────────────────────────
|
|
89
|
+
export function recordRecoveryOutcome(failureType, toolName, strategy, succeeded) {
|
|
90
|
+
const db = getDb();
|
|
91
|
+
initSessionMemoryTables();
|
|
92
|
+
const existing = db.prepare("SELECT strategy_id, success_count, failure_count FROM recovery_strategies WHERE failure_type = ? AND tool_name = ? AND strategy = ?").get(failureType, toolName, strategy);
|
|
93
|
+
if (existing) {
|
|
94
|
+
if (succeeded) {
|
|
95
|
+
db.prepare("UPDATE recovery_strategies SET success_count = success_count + 1, last_used = ? WHERE strategy_id = ?")
|
|
96
|
+
.run(new Date().toISOString(), existing.strategy_id);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
db.prepare("UPDATE recovery_strategies SET failure_count = failure_count + 1, last_used = ? WHERE strategy_id = ?")
|
|
100
|
+
.run(new Date().toISOString(), existing.strategy_id);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Enforce bounded: evict lowest success rate if over limit
|
|
105
|
+
const countRow = db.prepare("SELECT COUNT(*) as cnt FROM recovery_strategies").get();
|
|
106
|
+
if ((countRow?.cnt ?? 0) >= MAX_RECOVERY_STRATEGIES) {
|
|
107
|
+
db.prepare("DELETE FROM recovery_strategies WHERE strategy_id IN (SELECT strategy_id FROM recovery_strategies ORDER BY (CAST(success_count AS REAL) / MAX(success_count + failure_count, 1)) ASC LIMIT 5)").run();
|
|
108
|
+
}
|
|
109
|
+
db.prepare(`
|
|
110
|
+
INSERT INTO recovery_strategies (strategy_id, failure_type, tool_name, strategy, success_count, failure_count, last_used)
|
|
111
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
112
|
+
`).run(genId("recovery"), failureType, toolName, strategy, succeeded ? 1 : 0, succeeded ? 0 : 1, new Date().toISOString());
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// ─── Reflection prompt generation ────────────────────────────────
|
|
116
|
+
export function getReflectionPrompt(failureType, toolName) {
|
|
117
|
+
const db = getDb();
|
|
118
|
+
initSessionMemoryTables();
|
|
119
|
+
// Get proven recovery strategies for this failure type
|
|
120
|
+
const strategies = db.prepare("SELECT strategy, success_count, failure_count FROM recovery_strategies WHERE failure_type = ? AND tool_name = ? AND success_count > 0 ORDER BY success_count DESC LIMIT 3").all(failureType, toolName);
|
|
121
|
+
if (strategies.length === 0) {
|
|
122
|
+
return `No known recovery strategies for ${failureType} on ${toolName}. Try a different approach.`;
|
|
123
|
+
}
|
|
124
|
+
const lines = strategies.map((s, i) => `${i + 1}. "${s.strategy}" (succeeded ${s.success_count}x, failed ${s.failure_count}x)`);
|
|
125
|
+
return `Known recovery strategies for ${failureType} on ${toolName}:\n${lines.join("\n")}\nUse the most successful strategy, or try a new approach if all have been exhausted.`;
|
|
126
|
+
}
|
|
127
|
+
// ─── Query helpers ────────────────────────────────────────────────
|
|
128
|
+
export function getSessionActions(episodeId) {
|
|
129
|
+
const db = getDb();
|
|
130
|
+
initSessionMemoryTables();
|
|
131
|
+
return db.prepare("SELECT * FROM session_actions WHERE episode_id = ? ORDER BY step_index ASC").all(episodeId);
|
|
132
|
+
}
|
|
133
|
+
export function getSessionFailures(episodeId) {
|
|
134
|
+
const db = getDb();
|
|
135
|
+
initSessionMemoryTables();
|
|
136
|
+
return db.prepare("SELECT * FROM session_failures WHERE episode_id = ? ORDER BY step_index ASC").all(episodeId);
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=sessionMemory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionMemory.js","sourceRoot":"","sources":["../../src/sync/sessionMemory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AA4CxC,oEAAoE;AAEpE,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,SAAS,QAAQ,CAAC,CAAS,EAAE,KAAK,GAAG,cAAc;IACjD,OAAO,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GA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;IAEF,OAAO,iCAAiC,WAAW,OAAO,QAAQ,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,uFAAuF,CAAC;AAClL,CAAC;AAED,qEAAqE;AAErE,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,uBAAuB,EAAE,CAAC;IAC1B,OAAO,EAAE,CAAC,OAAO,CAAC,4EAA4E,CAAC,CAAC,GAAG,CAAC,SAAS,CAAU,CAAC;AAC1H,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,uBAAuB,EAAE,CAAC;IAC1B,OAAO,EAAE,CAAC,OAAO,CAAC,6EAA6E,CAAC,CAAC,GAAG,CAAC,SAAS,CAAU,CAAC;AAC3H,CAAC"}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import type { DurableObjectKind, SharedContextMessageClass, SharedContextPacket, SharedContextPacketType, SharedContextPeer, SharedContextPeerSummary, SharedContextProduct, SharedContextRole, SharedContextSurface, SharedContextTask, SharedContextTaskStatus, SyncOperationType, SyncQueueOperation, SyncScope } from "./protocol.js";
|
|
3
|
+
export interface DurableObjectInput {
|
|
4
|
+
id?: string;
|
|
5
|
+
kind: DurableObjectKind | string;
|
|
6
|
+
label: string;
|
|
7
|
+
source?: string;
|
|
8
|
+
status?: string;
|
|
9
|
+
metadata?: Record<string, unknown>;
|
|
10
|
+
queueForSync?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ObjectEdgeInput {
|
|
13
|
+
id?: string;
|
|
14
|
+
fromId: string;
|
|
15
|
+
toId: string;
|
|
16
|
+
edgeType: string;
|
|
17
|
+
confidence?: number;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
queueForSync?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ExecutionReceiptInput {
|
|
22
|
+
id?: string;
|
|
23
|
+
runId?: string | null;
|
|
24
|
+
traceId?: string | null;
|
|
25
|
+
stepId?: string | null;
|
|
26
|
+
objectId?: string | null;
|
|
27
|
+
toolName?: string | null;
|
|
28
|
+
actionType: string;
|
|
29
|
+
summary: string;
|
|
30
|
+
input?: unknown;
|
|
31
|
+
output?: unknown;
|
|
32
|
+
status?: string;
|
|
33
|
+
metadata?: Record<string, unknown>;
|
|
34
|
+
queueForSync?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface LocalArtifactInput {
|
|
37
|
+
id?: string;
|
|
38
|
+
runId?: string | null;
|
|
39
|
+
objectId?: string | null;
|
|
40
|
+
kind: string;
|
|
41
|
+
path?: string | null;
|
|
42
|
+
summary?: string | null;
|
|
43
|
+
verificationStatus?: string;
|
|
44
|
+
content?: string | null;
|
|
45
|
+
metadata?: Record<string, unknown>;
|
|
46
|
+
queueForSync?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface LocalOutcomeInput {
|
|
49
|
+
id?: string;
|
|
50
|
+
runId?: string | null;
|
|
51
|
+
objectId?: string | null;
|
|
52
|
+
outcomeType: string;
|
|
53
|
+
headline: string;
|
|
54
|
+
userValue?: string | null;
|
|
55
|
+
stakeholderValue?: string | null;
|
|
56
|
+
status?: string;
|
|
57
|
+
evidence?: unknown[];
|
|
58
|
+
metadata?: Record<string, unknown>;
|
|
59
|
+
queueForSync?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface DeviceBindingInput {
|
|
62
|
+
deviceId: string;
|
|
63
|
+
deviceName: string;
|
|
64
|
+
platform?: string | null;
|
|
65
|
+
appVersion?: string | null;
|
|
66
|
+
bridgeUrl?: string | null;
|
|
67
|
+
deviceToken?: string | null;
|
|
68
|
+
bindingStatus?: "unpaired" | "paired" | "revoked";
|
|
69
|
+
metadata?: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
export interface AccountBindingInput {
|
|
72
|
+
deviceId: string;
|
|
73
|
+
userId: string;
|
|
74
|
+
workspaceId?: string | null;
|
|
75
|
+
scopes: SyncScope[];
|
|
76
|
+
syncEnabled?: boolean;
|
|
77
|
+
syncMode?: "offline" | "connected" | "cloud";
|
|
78
|
+
metadata?: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
export interface SharedContextPeerInput {
|
|
81
|
+
peerId?: string;
|
|
82
|
+
product: SharedContextProduct;
|
|
83
|
+
tenantId?: string | null;
|
|
84
|
+
workspaceId?: string | null;
|
|
85
|
+
surface: SharedContextSurface;
|
|
86
|
+
role: SharedContextRole;
|
|
87
|
+
capabilities?: string[];
|
|
88
|
+
contextScopes?: string[];
|
|
89
|
+
status?: SharedContextPeer["status"];
|
|
90
|
+
summary?: SharedContextPeerSummary;
|
|
91
|
+
metadata?: Record<string, unknown>;
|
|
92
|
+
queueForSync?: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface SharedContextPeerFilters {
|
|
95
|
+
product?: SharedContextProduct;
|
|
96
|
+
workspaceId?: string | null;
|
|
97
|
+
tenantId?: string | null;
|
|
98
|
+
role?: SharedContextRole;
|
|
99
|
+
surface?: SharedContextSurface;
|
|
100
|
+
status?: SharedContextPeer["status"];
|
|
101
|
+
capability?: string;
|
|
102
|
+
scope?: string;
|
|
103
|
+
limit?: number;
|
|
104
|
+
}
|
|
105
|
+
export interface SharedContextPacketInput {
|
|
106
|
+
contextId?: string;
|
|
107
|
+
contextType: SharedContextPacketType;
|
|
108
|
+
producerPeerId: string;
|
|
109
|
+
tenantId?: string | null;
|
|
110
|
+
workspaceId?: string | null;
|
|
111
|
+
scope?: string[];
|
|
112
|
+
subject: string;
|
|
113
|
+
summary: string;
|
|
114
|
+
claims?: string[];
|
|
115
|
+
evidenceRefs?: string[];
|
|
116
|
+
stateSnapshot?: Record<string, unknown>;
|
|
117
|
+
timeWindow?: Record<string, unknown>;
|
|
118
|
+
freshness?: Record<string, unknown>;
|
|
119
|
+
permissions?: Record<string, unknown>;
|
|
120
|
+
confidence?: number;
|
|
121
|
+
lineage?: Record<string, unknown>;
|
|
122
|
+
invalidates?: string[];
|
|
123
|
+
nextActions?: string[];
|
|
124
|
+
version?: number;
|
|
125
|
+
status?: SharedContextPacket["status"];
|
|
126
|
+
metadata?: Record<string, unknown>;
|
|
127
|
+
queueForSync?: boolean;
|
|
128
|
+
}
|
|
129
|
+
export interface SharedContextPacketQuery {
|
|
130
|
+
contextType?: SharedContextPacketType;
|
|
131
|
+
producerPeerId?: string;
|
|
132
|
+
requestingPeerId?: string;
|
|
133
|
+
tenantId?: string | null;
|
|
134
|
+
workspaceId?: string | null;
|
|
135
|
+
status?: SharedContextPacket["status"];
|
|
136
|
+
scopeIncludes?: string;
|
|
137
|
+
subjectIncludes?: string;
|
|
138
|
+
limit?: number;
|
|
139
|
+
}
|
|
140
|
+
export interface SharedContextPacketResource {
|
|
141
|
+
packet: SharedContextPacket;
|
|
142
|
+
resourceUri: string;
|
|
143
|
+
pullQuery: {
|
|
144
|
+
contextType: SharedContextPacket["contextType"];
|
|
145
|
+
producerPeerId: string;
|
|
146
|
+
workspaceId?: string;
|
|
147
|
+
tenantId?: string;
|
|
148
|
+
scopeIncludes?: string;
|
|
149
|
+
subjectIncludes: string;
|
|
150
|
+
};
|
|
151
|
+
subscriptionQuery: {
|
|
152
|
+
peerId?: string;
|
|
153
|
+
workspaceId?: string;
|
|
154
|
+
contextType: SharedContextPacket["contextType"];
|
|
155
|
+
producerPeerId: string;
|
|
156
|
+
scopeIncludes?: string;
|
|
157
|
+
subjectIncludes: string;
|
|
158
|
+
eventTypes: string[];
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export interface SharedContextSubscriptionQuery extends SharedContextPacketQuery {
|
|
162
|
+
peerId?: string;
|
|
163
|
+
eventTypes?: string[];
|
|
164
|
+
taskType?: string;
|
|
165
|
+
messageClass?: SharedContextMessageClass;
|
|
166
|
+
}
|
|
167
|
+
export interface SharedContextSubscriptionManifest {
|
|
168
|
+
peerId?: string;
|
|
169
|
+
snapshotQuery: {
|
|
170
|
+
limit: number;
|
|
171
|
+
peerId?: string;
|
|
172
|
+
workspaceId?: string;
|
|
173
|
+
contextType?: SharedContextPacket["contextType"];
|
|
174
|
+
producerPeerId?: string;
|
|
175
|
+
scopeIncludes?: string;
|
|
176
|
+
subjectIncludes?: string;
|
|
177
|
+
taskType?: string;
|
|
178
|
+
messageClass?: SharedContextMessageClass;
|
|
179
|
+
};
|
|
180
|
+
pullQuery: SharedContextPacketQuery;
|
|
181
|
+
subscriptionQuery: {
|
|
182
|
+
peerId?: string;
|
|
183
|
+
workspaceId?: string;
|
|
184
|
+
contextType?: SharedContextPacket["contextType"];
|
|
185
|
+
producerPeerId?: string;
|
|
186
|
+
scopeIncludes?: string;
|
|
187
|
+
subjectIncludes?: string;
|
|
188
|
+
taskType?: string;
|
|
189
|
+
messageClass?: SharedContextMessageClass;
|
|
190
|
+
eventTypes: string[];
|
|
191
|
+
};
|
|
192
|
+
packetResources: Array<{
|
|
193
|
+
contextId: string;
|
|
194
|
+
contextType: SharedContextPacket["contextType"];
|
|
195
|
+
subject: string;
|
|
196
|
+
resourceUri: string;
|
|
197
|
+
}>;
|
|
198
|
+
}
|
|
199
|
+
export interface SharedContextTaskInput {
|
|
200
|
+
taskId?: string;
|
|
201
|
+
taskType: string;
|
|
202
|
+
proposerPeerId: string;
|
|
203
|
+
assigneePeerId: string;
|
|
204
|
+
status?: SharedContextTaskStatus;
|
|
205
|
+
taskSpec?: Record<string, unknown>;
|
|
206
|
+
inputContextIds?: string[];
|
|
207
|
+
outputContextId?: string | null;
|
|
208
|
+
reason?: string | null;
|
|
209
|
+
metadata?: Record<string, unknown>;
|
|
210
|
+
queueForSync?: boolean;
|
|
211
|
+
}
|
|
212
|
+
export interface SharedContextScopedSnapshotFilters extends SharedContextSubscriptionQuery {
|
|
213
|
+
limit?: number;
|
|
214
|
+
}
|
|
215
|
+
export declare function getSharedContextEventBus(): EventEmitter;
|
|
216
|
+
export declare function upsertDurableObject(input: DurableObjectInput): {
|
|
217
|
+
objectId: string;
|
|
218
|
+
queuedSyncId?: string;
|
|
219
|
+
};
|
|
220
|
+
export declare function linkDurableObjects(input: ObjectEdgeInput): {
|
|
221
|
+
edgeId: string;
|
|
222
|
+
queuedSyncId?: string;
|
|
223
|
+
};
|
|
224
|
+
export declare function recordExecutionReceipt(input: ExecutionReceiptInput): {
|
|
225
|
+
receiptId: string;
|
|
226
|
+
queuedSyncId?: string;
|
|
227
|
+
};
|
|
228
|
+
export declare function recordLocalArtifact(input: LocalArtifactInput): {
|
|
229
|
+
artifactId: string;
|
|
230
|
+
queuedSyncId?: string;
|
|
231
|
+
};
|
|
232
|
+
export declare function recordLocalOutcome(input: LocalOutcomeInput): {
|
|
233
|
+
outcomeId: string;
|
|
234
|
+
queuedSyncId?: string;
|
|
235
|
+
};
|
|
236
|
+
export declare function upsertDeviceBinding(input: DeviceBindingInput): void;
|
|
237
|
+
export declare function bindDeviceToAccount(input: AccountBindingInput): {
|
|
238
|
+
bindingId: string;
|
|
239
|
+
};
|
|
240
|
+
export declare function getActiveAccountBinding(deviceId?: string): null | {
|
|
241
|
+
bindingId: string;
|
|
242
|
+
deviceId: string;
|
|
243
|
+
userId: string;
|
|
244
|
+
workspaceId: string | null;
|
|
245
|
+
scopes: SyncScope[];
|
|
246
|
+
syncEnabled: boolean;
|
|
247
|
+
syncMode: string;
|
|
248
|
+
lastSyncedAt: string | null;
|
|
249
|
+
revokedAt: string | null;
|
|
250
|
+
};
|
|
251
|
+
export declare function getDeviceBinding(deviceId: string): null | {
|
|
252
|
+
deviceId: string;
|
|
253
|
+
deviceName: string;
|
|
254
|
+
platform: string | null;
|
|
255
|
+
appVersion: string | null;
|
|
256
|
+
bridgeUrl: string | null;
|
|
257
|
+
deviceToken: string | null;
|
|
258
|
+
bindingStatus: string;
|
|
259
|
+
lastSeenAt: string | null;
|
|
260
|
+
};
|
|
261
|
+
export declare function enqueueSyncOperation(input: {
|
|
262
|
+
objectId: string | null;
|
|
263
|
+
objectKind: DurableObjectKind | string;
|
|
264
|
+
opType: SyncOperationType | string;
|
|
265
|
+
payload: Record<string, unknown>;
|
|
266
|
+
}): {
|
|
267
|
+
queueId: string;
|
|
268
|
+
payloadHash: string;
|
|
269
|
+
};
|
|
270
|
+
export declare function listPendingSyncOperations(limit?: number): SyncQueueOperation[];
|
|
271
|
+
export declare function markSyncAttempt(queueIds: string[], error?: string): void;
|
|
272
|
+
export declare function acknowledgeSyncOperations(args: {
|
|
273
|
+
queueIds: string[];
|
|
274
|
+
serverReceiptId?: string;
|
|
275
|
+
deviceId?: string;
|
|
276
|
+
userId?: string;
|
|
277
|
+
workspaceId?: string;
|
|
278
|
+
detail?: Record<string, unknown>;
|
|
279
|
+
}): void;
|
|
280
|
+
export declare function failSyncOperations(args: {
|
|
281
|
+
rejected: Array<{
|
|
282
|
+
id: string;
|
|
283
|
+
reason: string;
|
|
284
|
+
}>;
|
|
285
|
+
deviceId?: string;
|
|
286
|
+
userId?: string;
|
|
287
|
+
workspaceId?: string;
|
|
288
|
+
}): void;
|
|
289
|
+
export declare function getSyncBridgeStatus(deviceId?: string): {
|
|
290
|
+
mode: "offline" | "connected";
|
|
291
|
+
activeBinding: ReturnType<typeof getActiveAccountBinding>;
|
|
292
|
+
pendingCount: number;
|
|
293
|
+
retryCount: number;
|
|
294
|
+
acknowledgedCount: number;
|
|
295
|
+
lastAcknowledgedAt: string | null;
|
|
296
|
+
};
|
|
297
|
+
export declare function registerSharedContextPeer(input: SharedContextPeerInput): {
|
|
298
|
+
peerId: string;
|
|
299
|
+
queuedSyncId?: string;
|
|
300
|
+
};
|
|
301
|
+
export declare function heartbeatSharedContextPeer(peerId: string, summary?: SharedContextPeerSummary): {
|
|
302
|
+
peerId: string;
|
|
303
|
+
lastHeartbeatAt: string;
|
|
304
|
+
};
|
|
305
|
+
export declare function listSharedContextPeers(filters?: SharedContextPeerFilters): SharedContextPeer[];
|
|
306
|
+
export declare function getSharedContextPeer(peerId: string): SharedContextPeer | null;
|
|
307
|
+
export declare function getSharedContextPacket(contextId: string, requestingPeerId?: string): SharedContextPacket | null;
|
|
308
|
+
export declare function buildSharedContextPacketResource(packet: SharedContextPacket, requestingPeerId?: string): SharedContextPacketResource;
|
|
309
|
+
export declare function getSharedContextPacketResource(contextId: string, requestingPeerId?: string): SharedContextPacketResource | null;
|
|
310
|
+
export declare function buildSharedContextSubscriptionManifest(query?: SharedContextSubscriptionQuery): SharedContextSubscriptionManifest;
|
|
311
|
+
export declare function publishSharedContextPacket(input: SharedContextPacketInput): {
|
|
312
|
+
contextId: string;
|
|
313
|
+
queuedSyncId?: string;
|
|
314
|
+
};
|
|
315
|
+
export declare function pullSharedContextPackets(query?: SharedContextPacketQuery): SharedContextPacket[];
|
|
316
|
+
export declare function acknowledgeSharedContextPacket(contextId: string, peerId: string, detail?: Record<string, unknown>): {
|
|
317
|
+
ackId: string;
|
|
318
|
+
queuedSyncId?: string;
|
|
319
|
+
};
|
|
320
|
+
export declare function invalidateSharedContextPacket(contextId: string, producerPeerId: string, reason: string, invalidates?: string[]): {
|
|
321
|
+
contextId: string;
|
|
322
|
+
queuedSyncId: string;
|
|
323
|
+
};
|
|
324
|
+
export declare function sendSharedContextMessage(input: {
|
|
325
|
+
fromPeerId: string;
|
|
326
|
+
toPeerId: string;
|
|
327
|
+
messageClass: SharedContextMessageClass;
|
|
328
|
+
payload: Record<string, unknown>;
|
|
329
|
+
queueForSync?: boolean;
|
|
330
|
+
}): {
|
|
331
|
+
messageId: string;
|
|
332
|
+
queuedSyncId?: string;
|
|
333
|
+
};
|
|
334
|
+
export declare function listSharedContextMessages(peerId: string, unreadOnly?: boolean): Array<{
|
|
335
|
+
messageId: string;
|
|
336
|
+
fromPeerId: string;
|
|
337
|
+
toPeerId: string;
|
|
338
|
+
messageClass: SharedContextMessageClass;
|
|
339
|
+
payload: Record<string, unknown>;
|
|
340
|
+
status: string;
|
|
341
|
+
createdAt: string;
|
|
342
|
+
}>;
|
|
343
|
+
export declare function proposeSharedContextTask(input: SharedContextTaskInput): {
|
|
344
|
+
taskId: string;
|
|
345
|
+
queuedSyncId?: string;
|
|
346
|
+
};
|
|
347
|
+
export declare function acceptSharedContextTask(taskId: string, peerId: string): {
|
|
348
|
+
task: SharedContextTask;
|
|
349
|
+
queuedSyncId: string;
|
|
350
|
+
};
|
|
351
|
+
export declare function rejectSharedContextTask(taskId: string, peerId: string, reason: string): {
|
|
352
|
+
task: SharedContextTask;
|
|
353
|
+
queuedSyncId: string;
|
|
354
|
+
};
|
|
355
|
+
export declare function completeSharedContextTask(taskId: string, peerId: string, outputContextId?: string | null): {
|
|
356
|
+
task: SharedContextTask;
|
|
357
|
+
queuedSyncId: string;
|
|
358
|
+
};
|
|
359
|
+
export declare function escalateSharedContextTask(taskId: string, peerId: string, reason: string, outputContextId?: string | null): {
|
|
360
|
+
task: SharedContextTask;
|
|
361
|
+
queuedSyncId: string;
|
|
362
|
+
};
|
|
363
|
+
export declare function getSharedContextSnapshot(limit?: number, requestingPeerId?: string): {
|
|
364
|
+
peers: SharedContextPeer[];
|
|
365
|
+
recentPackets: SharedContextPacket[];
|
|
366
|
+
recentTasks: SharedContextTask[];
|
|
367
|
+
recentMessages: Array<{
|
|
368
|
+
messageId: string;
|
|
369
|
+
fromPeerId: string;
|
|
370
|
+
toPeerId: string;
|
|
371
|
+
messageClass: SharedContextMessageClass;
|
|
372
|
+
payload: Record<string, unknown>;
|
|
373
|
+
status: string;
|
|
374
|
+
createdAt: string;
|
|
375
|
+
}>;
|
|
376
|
+
counts: {
|
|
377
|
+
activePeers: number;
|
|
378
|
+
activePackets: number;
|
|
379
|
+
invalidatedPackets: number;
|
|
380
|
+
openTasks: number;
|
|
381
|
+
unreadMessages: number;
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
export declare function getSharedContextScopedSnapshot(filters?: SharedContextScopedSnapshotFilters): ReturnType<typeof getSharedContextSnapshot>;
|