praana 0.5.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/LICENSE +21 -0
- package/README.md +124 -0
- package/bin/praana.js +17 -0
- package/bin/pran.js +17 -0
- package/dist/app-banner.d.ts +11 -0
- package/dist/app-banner.js +161 -0
- package/dist/app-controller.d.ts +44 -0
- package/dist/app-controller.js +143 -0
- package/dist/app-identity.d.ts +18 -0
- package/dist/app-identity.js +52 -0
- package/dist/auto-compact.d.ts +16 -0
- package/dist/auto-compact.js +101 -0
- package/dist/cli-args.d.ts +14 -0
- package/dist/cli-args.js +69 -0
- package/dist/compile-classic.d.ts +21 -0
- package/dist/compile-classic.js +106 -0
- package/dist/compiler.d.ts +75 -0
- package/dist/compiler.js +406 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +433 -0
- package/dist/context-engine/activity-log.d.ts +9 -0
- package/dist/context-engine/activity-log.js +109 -0
- package/dist/context-engine/artifact-store.d.ts +32 -0
- package/dist/context-engine/artifact-store.js +272 -0
- package/dist/context-engine/bm25.d.ts +3 -0
- package/dist/context-engine/bm25.js +32 -0
- package/dist/context-engine/checkpoint.d.ts +34 -0
- package/dist/context-engine/checkpoint.js +430 -0
- package/dist/context-engine/classify.d.ts +3 -0
- package/dist/context-engine/classify.js +60 -0
- package/dist/context-engine/db.d.ts +73 -0
- package/dist/context-engine/db.js +505 -0
- package/dist/context-engine/distiller.d.ts +30 -0
- package/dist/context-engine/distiller.js +67 -0
- package/dist/context-engine/engine-compiler.d.ts +23 -0
- package/dist/context-engine/engine-compiler.js +297 -0
- package/dist/context-engine/error-tracker.d.ts +21 -0
- package/dist/context-engine/error-tracker.js +74 -0
- package/dist/context-engine/event-lineage.d.ts +26 -0
- package/dist/context-engine/event-lineage.js +120 -0
- package/dist/context-engine/extraction.d.ts +26 -0
- package/dist/context-engine/extraction.js +83 -0
- package/dist/context-engine/index.d.ts +82 -0
- package/dist/context-engine/index.js +238 -0
- package/dist/context-engine/scoring.d.ts +13 -0
- package/dist/context-engine/scoring.js +47 -0
- package/dist/context-engine/state-snapshot.d.ts +8 -0
- package/dist/context-engine/state-snapshot.js +50 -0
- package/dist/context-engine/summarize.d.ts +6 -0
- package/dist/context-engine/summarize.js +32 -0
- package/dist/context-engine/telemetry.d.ts +25 -0
- package/dist/context-engine/telemetry.js +64 -0
- package/dist/context-engine/turn-digest.d.ts +50 -0
- package/dist/context-engine/turn-digest.js +250 -0
- package/dist/context-engine/turn-ledger.d.ts +18 -0
- package/dist/context-engine/turn-ledger.js +184 -0
- package/dist/context-engine/turn-recorder.d.ts +24 -0
- package/dist/context-engine/turn-recorder.js +88 -0
- package/dist/context-engine/types.d.ts +201 -0
- package/dist/context-engine/types.js +4 -0
- package/dist/context-pressure.d.ts +19 -0
- package/dist/context-pressure.js +36 -0
- package/dist/distillers/generic.d.ts +14 -0
- package/dist/distillers/generic.js +93 -0
- package/dist/distillers/git-diff.d.ts +8 -0
- package/dist/distillers/git-diff.js +119 -0
- package/dist/distillers/index.d.ts +2 -0
- package/dist/distillers/index.js +16 -0
- package/dist/distillers/npm-test.d.ts +8 -0
- package/dist/distillers/npm-test.js +50 -0
- package/dist/distillers/rg-results.d.ts +8 -0
- package/dist/distillers/rg-results.js +28 -0
- package/dist/distillers/tsc-errors.d.ts +8 -0
- package/dist/distillers/tsc-errors.js +52 -0
- package/dist/event-log.d.ts +56 -0
- package/dist/event-log.js +214 -0
- package/dist/llm.d.ts +29 -0
- package/dist/llm.js +155 -0
- package/dist/logger.d.ts +94 -0
- package/dist/logger.js +287 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +54 -0
- package/dist/memory/confidence.d.ts +7 -0
- package/dist/memory/confidence.js +37 -0
- package/dist/memory/consolidation.d.ts +26 -0
- package/dist/memory/consolidation.js +166 -0
- package/dist/memory/db.d.ts +40 -0
- package/dist/memory/db.js +283 -0
- package/dist/memory/dedup.d.ts +6 -0
- package/dist/memory/dedup.js +50 -0
- package/dist/memory/embedder-factory.d.ts +3 -0
- package/dist/memory/embedder-factory.js +81 -0
- package/dist/memory/embeddings.d.ts +15 -0
- package/dist/memory/embeddings.js +67 -0
- package/dist/memory/index.d.ts +9 -0
- package/dist/memory/index.js +11 -0
- package/dist/memory/ollama-summarizer.d.ts +19 -0
- package/dist/memory/ollama-summarizer.js +72 -0
- package/dist/memory/openai-summarizer.d.ts +21 -0
- package/dist/memory/openai-summarizer.js +51 -0
- package/dist/memory/store.d.ts +61 -0
- package/dist/memory/store.js +502 -0
- package/dist/memory/summarizer-factory.d.ts +3 -0
- package/dist/memory/summarizer-factory.js +69 -0
- package/dist/memory/summarizer.d.ts +4 -0
- package/dist/memory/summarizer.js +112 -0
- package/dist/memory/types.d.ts +87 -0
- package/dist/memory/types.js +17 -0
- package/dist/model-context.d.ts +15 -0
- package/dist/model-context.js +212 -0
- package/dist/project-detector.d.ts +37 -0
- package/dist/project-detector.js +604 -0
- package/dist/render.d.ts +15 -0
- package/dist/render.js +46 -0
- package/dist/session.d.ts +118 -0
- package/dist/session.js +809 -0
- package/dist/skills/index.d.ts +69 -0
- package/dist/skills/index.js +885 -0
- package/dist/skills/types.d.ts +93 -0
- package/dist/skills/types.js +8 -0
- package/dist/slash-commands.d.ts +14 -0
- package/dist/slash-commands.js +301 -0
- package/dist/state-graph.d.ts +38 -0
- package/dist/state-graph.js +255 -0
- package/dist/status-bar.d.ts +54 -0
- package/dist/status-bar.js +184 -0
- package/dist/thinking-display.d.ts +21 -0
- package/dist/thinking-display.js +37 -0
- package/dist/tool-summary.d.ts +4 -0
- package/dist/tool-summary.js +67 -0
- package/dist/tools/index.d.ts +925 -0
- package/dist/tools/index.js +86 -0
- package/dist/tools/knowledge.d.ts +140 -0
- package/dist/tools/knowledge.js +260 -0
- package/dist/tools/memory.d.ts +39 -0
- package/dist/tools/memory.js +300 -0
- package/dist/tools/search-code.d.ts +134 -0
- package/dist/tools/search-code.js +390 -0
- package/dist/tools/system.d.ts +16 -0
- package/dist/tools/system.js +499 -0
- package/dist/tools/tool-def.d.ts +6 -0
- package/dist/tools/tool-def.js +3 -0
- package/dist/turn-control.d.ts +51 -0
- package/dist/turn-control.js +210 -0
- package/dist/turn.d.ts +20 -0
- package/dist/turn.js +624 -0
- package/dist/types.d.ts +233 -0
- package/dist/types.js +4 -0
- package/dist/ui/readline-ui.d.ts +2 -0
- package/dist/ui/readline-ui.js +176 -0
- package/dist/ui/tui/app.d.ts +13 -0
- package/dist/ui/tui/app.js +270 -0
- package/dist/ui/tui/busy-indicator.d.ts +2 -0
- package/dist/ui/tui/busy-indicator.js +13 -0
- package/dist/ui/tui/components/gutter-rule.d.ts +5 -0
- package/dist/ui/tui/components/gutter-rule.js +9 -0
- package/dist/ui/tui/components/inline-tool-row.d.ts +10 -0
- package/dist/ui/tui/components/inline-tool-row.js +8 -0
- package/dist/ui/tui/components/prompt-input.d.ts +20 -0
- package/dist/ui/tui/components/prompt-input.js +120 -0
- package/dist/ui/tui/components/system-line.d.ts +5 -0
- package/dist/ui/tui/components/system-line.js +6 -0
- package/dist/ui/tui/components/thinking-block.d.ts +11 -0
- package/dist/ui/tui/components/thinking-block.js +31 -0
- package/dist/ui/tui/components/toast-line.d.ts +4 -0
- package/dist/ui/tui/components/toast-line.js +8 -0
- package/dist/ui/tui/components/tool-result-line.d.ts +5 -0
- package/dist/ui/tui/components/tool-result-line.js +6 -0
- package/dist/ui/tui/components/turn-footer.d.ts +5 -0
- package/dist/ui/tui/components/turn-footer.js +7 -0
- package/dist/ui/tui/components/user-block.d.ts +6 -0
- package/dist/ui/tui/components/user-block.js +6 -0
- package/dist/ui/tui/logo-banner.d.ts +5 -0
- package/dist/ui/tui/logo-banner.js +8 -0
- package/dist/ui/tui/markdown-render.d.ts +16 -0
- package/dist/ui/tui/markdown-render.js +218 -0
- package/dist/ui/tui/palette.d.ts +12 -0
- package/dist/ui/tui/palette.js +13 -0
- package/dist/ui/tui/reasoning-summary.d.ts +12 -0
- package/dist/ui/tui/reasoning-summary.js +27 -0
- package/dist/ui/tui/reducer.d.ts +92 -0
- package/dist/ui/tui/reducer.js +260 -0
- package/dist/ui/tui/run.d.ts +3 -0
- package/dist/ui/tui/run.js +40 -0
- package/dist/ui/tui/sink.d.ts +4 -0
- package/dist/ui/tui/sink.js +89 -0
- package/dist/ui/tui/status-bar-view.d.ts +5 -0
- package/dist/ui/tui/status-bar-view.js +44 -0
- package/dist/ui/tui/terminal-height.d.ts +12 -0
- package/dist/ui/tui/terminal-height.js +20 -0
- package/dist/ui/tui/terminal-width.d.ts +2 -0
- package/dist/ui/tui/terminal-width.js +5 -0
- package/dist/ui/tui/tool-display.d.ts +23 -0
- package/dist/ui/tui/tool-display.js +217 -0
- package/dist/ui/tui/transcript-line.d.ts +12 -0
- package/dist/ui/tui/transcript-line.js +43 -0
- package/dist/ui/tui/transcript-replay.d.ts +12 -0
- package/dist/ui/tui/transcript-replay.js +117 -0
- package/dist/ui-events.d.ts +39 -0
- package/dist/ui-events.js +33 -0
- package/dist/ui.d.ts +77 -0
- package/dist/ui.js +179 -0
- package/package.json +73 -0
- package/praana.config.example.toml +231 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Event } from "../types.js";
|
|
2
|
+
import type { StateGraph } from "../state-graph.js";
|
|
3
|
+
import type { PraanaConfig } from "../types.js";
|
|
4
|
+
import { ArtifactStore } from "./artifact-store.js";
|
|
5
|
+
import { CheckpointStore } from "./checkpoint.js";
|
|
6
|
+
import { type EventLineage } from "./event-lineage.js";
|
|
7
|
+
import { TelemetryRecorder, type SessionTelemetrySummary } from "./telemetry.js";
|
|
8
|
+
import { TurnExtraction } from "./extraction.js";
|
|
9
|
+
import { TurnLedger } from "./turn-ledger.js";
|
|
10
|
+
import type { ContextEngineConfig } from "../types.js";
|
|
11
|
+
import type { ActivityEntry, CheckpointDraft, IngestToolResultInput, IngestToolResultOutput, RetrieveArtifactOptions, SessionCheckpoint, StateSnapshot, TurnDigest, TurnRecord, TurnSearchMatch } from "./types.js";
|
|
12
|
+
export type { ActivityEntry, ActivityEntryType, CheckpointDraft, ContentType, ContextArtifact, OpenError, ToolCallRecord, SessionCheckpoint, TurnDigest, TurnRecord, TurnSearchMatch, } from "./types.js";
|
|
13
|
+
export type { ContextEngineConfig } from "../types.js";
|
|
14
|
+
export { CheckpointStore, renderCheckpoint, renderContextSummary } from "./checkpoint.js";
|
|
15
|
+
export { classifyContentType } from "./classify.js";
|
|
16
|
+
export { estimateTokens } from "./summarize.js";
|
|
17
|
+
export { ArtifactStore } from "./artifact-store.js";
|
|
18
|
+
export { TurnLedger, groupEventsIntoTurns } from "./turn-ledger.js";
|
|
19
|
+
export { TurnRecorder, buildTurnSearchText } from "./turn-recorder.js";
|
|
20
|
+
export { extractTurnDigest, extractUserIntent } from "./turn-digest.js";
|
|
21
|
+
export { snapshotStateGraph } from "./state-snapshot.js";
|
|
22
|
+
export { compileEngineWithMetrics, explainUnitScore } from "./engine-compiler.js";
|
|
23
|
+
export { scoreContextUnit, recencyScore } from "./scoring.js";
|
|
24
|
+
export { buildEventLineage, formatEventLineage, type EventLineage } from "./event-lineage.js";
|
|
25
|
+
export { TelemetryRecorder, renderSessionTelemetrySummary, type SessionTelemetrySummary, } from "./telemetry.js";
|
|
26
|
+
export declare function normalizeContextEngineConfig(config?: Partial<ContextEngineConfig>): ContextEngineConfig;
|
|
27
|
+
export declare function resolveContextEngineConfig(config: PraanaConfig): ContextEngineConfig;
|
|
28
|
+
export declare function isContextEngineEnabled(config: PraanaConfig): boolean;
|
|
29
|
+
export declare function resolveContextDbPath(config: PraanaConfig, cwd: string): string;
|
|
30
|
+
export declare class ContextEngine {
|
|
31
|
+
readonly store: ArtifactStore;
|
|
32
|
+
readonly ledger: TurnLedger;
|
|
33
|
+
readonly extraction: TurnExtraction;
|
|
34
|
+
readonly checkpoint: CheckpointStore | null;
|
|
35
|
+
readonly telemetry: TelemetryRecorder;
|
|
36
|
+
private readonly config;
|
|
37
|
+
private constructor();
|
|
38
|
+
static open(dbPath: string, sessionId: string, config: Partial<ContextEngineConfig> & Pick<ContextEngineConfig, "enabled">): ContextEngine;
|
|
39
|
+
runStartupMaintenance(currentTurn: number): number;
|
|
40
|
+
runShutdownMaintenance(currentTurn: number): number;
|
|
41
|
+
migrateLedgerFromEvents(events: Event[]): number;
|
|
42
|
+
captureStateSnapshot(stateGraph: StateGraph): StateSnapshot;
|
|
43
|
+
ingestToolResult(input: IngestToolResultInput): IngestToolResultOutput;
|
|
44
|
+
flushDeferredDistillation(): Promise<number>;
|
|
45
|
+
appendTurn(record: TurnRecord): void;
|
|
46
|
+
processTurnExtraction(input: {
|
|
47
|
+
userMessage: string;
|
|
48
|
+
record: TurnRecord;
|
|
49
|
+
stateBefore: StateSnapshot;
|
|
50
|
+
stateGraph: StateGraph;
|
|
51
|
+
}): TurnDigest;
|
|
52
|
+
getRecentActivity(): ActivityEntry[];
|
|
53
|
+
getCheckpointDraft(): CheckpointDraft;
|
|
54
|
+
getLatestDigest(): TurnDigest | null;
|
|
55
|
+
renderCheckpointSection(): string | null;
|
|
56
|
+
renderContextSummary(): string;
|
|
57
|
+
getSessionCheckpoint(): SessionCheckpoint | null;
|
|
58
|
+
recordCompileTelemetry(input: {
|
|
59
|
+
turn: number;
|
|
60
|
+
pressureMode: import("./types.js").PressureMode;
|
|
61
|
+
excludedScoredUnits: number;
|
|
62
|
+
}): void;
|
|
63
|
+
finalizeTelemetry(totalTurns: number): SessionTelemetrySummary;
|
|
64
|
+
renderTelemetrySummary(totalTurns: number): string;
|
|
65
|
+
searchTurnEvents(query: string, limit?: number, currentTurn?: number): TurnSearchMatch[];
|
|
66
|
+
eventLineage(artifactId: string, currentTurn: number): {
|
|
67
|
+
ok: true;
|
|
68
|
+
lineage: EventLineage;
|
|
69
|
+
text: string;
|
|
70
|
+
} | {
|
|
71
|
+
ok: false;
|
|
72
|
+
error: string;
|
|
73
|
+
};
|
|
74
|
+
retrieveArtifact(id: string, currentTurn: number, options?: RetrieveArtifactOptions): {
|
|
75
|
+
ok: true;
|
|
76
|
+
content: string;
|
|
77
|
+
} | {
|
|
78
|
+
ok: false;
|
|
79
|
+
error: string;
|
|
80
|
+
};
|
|
81
|
+
close(): void;
|
|
82
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { resolveDefaultMemoryDbPath } from "../app-identity.js";
|
|
4
|
+
import { ArtifactStore } from "./artifact-store.js";
|
|
5
|
+
import { CheckpointStore, renderContextSummary as formatContextSummary } from "./checkpoint.js";
|
|
6
|
+
import { buildEventLineage, formatEventLineage, } from "./event-lineage.js";
|
|
7
|
+
import { getTurnDigest, listSessionArtifacts } from "./db.js";
|
|
8
|
+
import { renderSessionTelemetrySummary, TelemetryRecorder, } from "./telemetry.js";
|
|
9
|
+
import { TurnExtraction } from "./extraction.js";
|
|
10
|
+
import { TurnLedger } from "./turn-ledger.js";
|
|
11
|
+
export { CheckpointStore, renderCheckpoint, renderContextSummary } from "./checkpoint.js";
|
|
12
|
+
export { classifyContentType } from "./classify.js";
|
|
13
|
+
export { estimateTokens } from "./summarize.js";
|
|
14
|
+
export { ArtifactStore } from "./artifact-store.js";
|
|
15
|
+
export { TurnLedger, groupEventsIntoTurns } from "./turn-ledger.js";
|
|
16
|
+
export { TurnRecorder, buildTurnSearchText } from "./turn-recorder.js";
|
|
17
|
+
export { extractTurnDigest, extractUserIntent } from "./turn-digest.js";
|
|
18
|
+
export { snapshotStateGraph } from "./state-snapshot.js";
|
|
19
|
+
export { compileEngineWithMetrics, explainUnitScore } from "./engine-compiler.js";
|
|
20
|
+
export { scoreContextUnit, recencyScore } from "./scoring.js";
|
|
21
|
+
export { buildEventLineage, formatEventLineage } from "./event-lineage.js";
|
|
22
|
+
export { TelemetryRecorder, renderSessionTelemetrySummary, } from "./telemetry.js";
|
|
23
|
+
const CONTEXT_ENGINE_DEFAULTS = {
|
|
24
|
+
enabled: true,
|
|
25
|
+
measurement_mode: false,
|
|
26
|
+
artifact_inline_threshold: 400,
|
|
27
|
+
artifact_ttl_turns: 50,
|
|
28
|
+
distiller: { default_intensity: "full" },
|
|
29
|
+
llm_digest: false,
|
|
30
|
+
activity_log_max_entries: 15,
|
|
31
|
+
checkpoint_enabled: true,
|
|
32
|
+
scoring: {
|
|
33
|
+
w_pin: 1.0,
|
|
34
|
+
w_recency: 0.5,
|
|
35
|
+
w_relevance: 0.3,
|
|
36
|
+
},
|
|
37
|
+
pressure: {
|
|
38
|
+
compact_at: 0.7,
|
|
39
|
+
emergency_at: 0.85,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export function normalizeContextEngineConfig(config = {}) {
|
|
43
|
+
return {
|
|
44
|
+
...CONTEXT_ENGINE_DEFAULTS,
|
|
45
|
+
...config,
|
|
46
|
+
distiller: {
|
|
47
|
+
...CONTEXT_ENGINE_DEFAULTS.distiller,
|
|
48
|
+
...(config.distiller ?? {}),
|
|
49
|
+
},
|
|
50
|
+
scoring: {
|
|
51
|
+
...CONTEXT_ENGINE_DEFAULTS.scoring,
|
|
52
|
+
...(config.scoring ?? {}),
|
|
53
|
+
},
|
|
54
|
+
pressure: {
|
|
55
|
+
...CONTEXT_ENGINE_DEFAULTS.pressure,
|
|
56
|
+
...(config.pressure ?? {}),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function resolveContextEngineConfig(config) {
|
|
61
|
+
return normalizeContextEngineConfig(config.context_engine ?? {});
|
|
62
|
+
}
|
|
63
|
+
export function isContextEngineEnabled(config) {
|
|
64
|
+
return resolveContextEngineConfig(config).enabled;
|
|
65
|
+
}
|
|
66
|
+
export function resolveContextDbPath(config, cwd) {
|
|
67
|
+
const configuredPath = config.memory?.db_path;
|
|
68
|
+
if (configuredPath) {
|
|
69
|
+
const expanded = expandHome(configuredPath);
|
|
70
|
+
return expanded.startsWith("/") ? expanded : join(cwd, expanded);
|
|
71
|
+
}
|
|
72
|
+
return resolveDefaultMemoryDbPath();
|
|
73
|
+
}
|
|
74
|
+
function expandHome(p) {
|
|
75
|
+
return p.startsWith("~/") ? p.replace(/^~\//, `${homedir()}/`) : p;
|
|
76
|
+
}
|
|
77
|
+
export class ContextEngine {
|
|
78
|
+
store;
|
|
79
|
+
ledger;
|
|
80
|
+
extraction;
|
|
81
|
+
checkpoint;
|
|
82
|
+
telemetry;
|
|
83
|
+
config;
|
|
84
|
+
constructor(store, ledger, extraction, checkpoint, telemetry, config) {
|
|
85
|
+
this.store = store;
|
|
86
|
+
this.ledger = ledger;
|
|
87
|
+
this.extraction = extraction;
|
|
88
|
+
this.checkpoint = checkpoint;
|
|
89
|
+
this.telemetry = telemetry;
|
|
90
|
+
this.config = config;
|
|
91
|
+
}
|
|
92
|
+
static open(dbPath, sessionId, config) {
|
|
93
|
+
const resolved = normalizeContextEngineConfig(config);
|
|
94
|
+
const store = ArtifactStore.open(dbPath, sessionId, resolved);
|
|
95
|
+
const ledger = new TurnLedger(store.getDb(), sessionId);
|
|
96
|
+
const extraction = new TurnExtraction(store.getDb(), sessionId, resolved);
|
|
97
|
+
const checkpoint = resolved.checkpoint_enabled
|
|
98
|
+
? CheckpointStore.open(store.getDb(), sessionId)
|
|
99
|
+
: null;
|
|
100
|
+
const telemetry = new TelemetryRecorder(store.getDb(), sessionId, resolved.enabled);
|
|
101
|
+
return new ContextEngine(store, ledger, extraction, checkpoint, telemetry, resolved);
|
|
102
|
+
}
|
|
103
|
+
runStartupMaintenance(currentTurn) {
|
|
104
|
+
return this.store.runEviction(currentTurn);
|
|
105
|
+
}
|
|
106
|
+
runShutdownMaintenance(currentTurn) {
|
|
107
|
+
return this.store.runEviction(currentTurn);
|
|
108
|
+
}
|
|
109
|
+
migrateLedgerFromEvents(events) {
|
|
110
|
+
return this.ledger.migrateFromEvents(events);
|
|
111
|
+
}
|
|
112
|
+
captureStateSnapshot(stateGraph) {
|
|
113
|
+
return this.extraction.captureStateSnapshot(stateGraph);
|
|
114
|
+
}
|
|
115
|
+
ingestToolResult(input) {
|
|
116
|
+
return this.store.ingestToolResult(input);
|
|
117
|
+
}
|
|
118
|
+
async flushDeferredDistillation() {
|
|
119
|
+
return this.store.flushDeferredDistillation();
|
|
120
|
+
}
|
|
121
|
+
appendTurn(record) {
|
|
122
|
+
this.ledger.append(record);
|
|
123
|
+
}
|
|
124
|
+
processTurnExtraction(input) {
|
|
125
|
+
const digest = this.extraction.processTurn(input);
|
|
126
|
+
if (this.checkpoint) {
|
|
127
|
+
this.checkpoint.reconcile(digest, this.extraction.getCheckpointDraft(), digest.turnId);
|
|
128
|
+
this.checkpoint.persist();
|
|
129
|
+
}
|
|
130
|
+
return digest;
|
|
131
|
+
}
|
|
132
|
+
getRecentActivity() {
|
|
133
|
+
return this.extraction.getRecentActivity();
|
|
134
|
+
}
|
|
135
|
+
getCheckpointDraft() {
|
|
136
|
+
return this.extraction.getCheckpointDraft();
|
|
137
|
+
}
|
|
138
|
+
getLatestDigest() {
|
|
139
|
+
return this.extraction.getLatestDigest();
|
|
140
|
+
}
|
|
141
|
+
renderCheckpointSection() {
|
|
142
|
+
if (!this.checkpoint)
|
|
143
|
+
return null;
|
|
144
|
+
const rendered = this.checkpoint.render();
|
|
145
|
+
return rendered.length > 0 ? rendered : null;
|
|
146
|
+
}
|
|
147
|
+
renderContextSummary() {
|
|
148
|
+
const artifactCount = this.store.countArtifacts();
|
|
149
|
+
if (this.checkpoint) {
|
|
150
|
+
return this.checkpoint.renderContextSummary({ artifactCount });
|
|
151
|
+
}
|
|
152
|
+
const draft = this.extraction.getCheckpointDraft();
|
|
153
|
+
return draft.lastUserIntent
|
|
154
|
+
? formatContextSummary({
|
|
155
|
+
version: 1,
|
|
156
|
+
state: {
|
|
157
|
+
activeRequest: draft.lastUserIntent,
|
|
158
|
+
plans: [],
|
|
159
|
+
constraints: draft.recentConstraints,
|
|
160
|
+
decisions: draft.recentDecisions.map((d) => ({ ...d, compact: false })),
|
|
161
|
+
files: [],
|
|
162
|
+
findings: [],
|
|
163
|
+
errors: draft.openErrors.map((e) => ({
|
|
164
|
+
key: e.key,
|
|
165
|
+
message: e.message,
|
|
166
|
+
turn: e.turn,
|
|
167
|
+
fixed: false,
|
|
168
|
+
})),
|
|
169
|
+
questions: [],
|
|
170
|
+
activity: draft.recentActivity,
|
|
171
|
+
narrative: [],
|
|
172
|
+
lastReconciledTurn: -1,
|
|
173
|
+
},
|
|
174
|
+
}, { artifactCount })
|
|
175
|
+
: "## Context Summary\n\nNo checkpoint data yet.";
|
|
176
|
+
}
|
|
177
|
+
getSessionCheckpoint() {
|
|
178
|
+
return this.checkpoint?.getCheckpoint() ?? null;
|
|
179
|
+
}
|
|
180
|
+
recordCompileTelemetry(input) {
|
|
181
|
+
this.telemetry.recordCompileTelemetry(input);
|
|
182
|
+
}
|
|
183
|
+
finalizeTelemetry(totalTurns) {
|
|
184
|
+
return this.telemetry.finalize(totalTurns);
|
|
185
|
+
}
|
|
186
|
+
renderTelemetrySummary(totalTurns) {
|
|
187
|
+
return renderSessionTelemetrySummary(this.finalizeTelemetry(totalTurns));
|
|
188
|
+
}
|
|
189
|
+
searchTurnEvents(query, limit = 20, currentTurn) {
|
|
190
|
+
const matches = this.ledger.search(query, limit);
|
|
191
|
+
if (currentTurn !== undefined) {
|
|
192
|
+
for (const match of matches) {
|
|
193
|
+
for (const artifactId of match.artifactIds) {
|
|
194
|
+
this.store.touchAccess(artifactId, currentTurn);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return matches;
|
|
199
|
+
}
|
|
200
|
+
eventLineage(artifactId, currentTurn) {
|
|
201
|
+
const artifact = this.store.getArtifact(artifactId);
|
|
202
|
+
if (!artifact) {
|
|
203
|
+
return { ok: false, error: `Artifact ${artifactId} not found` };
|
|
204
|
+
}
|
|
205
|
+
const sessionId = this.store.getSessionId();
|
|
206
|
+
const db = this.store.getDb();
|
|
207
|
+
const turnRecord = this.ledger.get(artifact.createdTurn);
|
|
208
|
+
const turnDigest = getTurnDigest(db, sessionId, artifact.createdTurn);
|
|
209
|
+
const checkpoint = this.checkpoint?.getCheckpoint() ?? null;
|
|
210
|
+
const sessionArtifacts = listSessionArtifacts(db, sessionId);
|
|
211
|
+
const turnRecords = this.ledger.list();
|
|
212
|
+
const lineage = buildEventLineage({
|
|
213
|
+
artifact,
|
|
214
|
+
turnRecord,
|
|
215
|
+
turnDigest,
|
|
216
|
+
checkpoint,
|
|
217
|
+
sessionArtifacts,
|
|
218
|
+
turnRecords,
|
|
219
|
+
});
|
|
220
|
+
this.store.touchAccess(artifactId, currentTurn);
|
|
221
|
+
this.telemetry.recordArtifactAccess(artifactId, "retrieved", currentTurn);
|
|
222
|
+
for (const related of lineage.relatedArtifacts) {
|
|
223
|
+
this.store.touchAccess(related.id, currentTurn);
|
|
224
|
+
this.telemetry.recordArtifactAccess(related.id, "retrieved", currentTurn);
|
|
225
|
+
}
|
|
226
|
+
return { ok: true, lineage, text: formatEventLineage(lineage) };
|
|
227
|
+
}
|
|
228
|
+
retrieveArtifact(id, currentTurn, options) {
|
|
229
|
+
const result = this.store.retrieve(id, currentTurn, options);
|
|
230
|
+
if (result.ok) {
|
|
231
|
+
this.telemetry.recordArtifactAccess(id, "retrieved", currentTurn);
|
|
232
|
+
}
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
close() {
|
|
236
|
+
this.store.close();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ContextEngineScoringConfig } from "../types.js";
|
|
2
|
+
import type { ContextUnit, ScoreBreakdown, ScoredContextUnit } from "./types.js";
|
|
3
|
+
export declare function recencyScore(ageTurns: number): number;
|
|
4
|
+
export declare function scoreContextUnit(unit: ContextUnit, currentTurn: number, userInput: string, weights: ContextEngineScoringConfig): {
|
|
5
|
+
score: number;
|
|
6
|
+
breakdown: ScoreBreakdown;
|
|
7
|
+
};
|
|
8
|
+
export declare function rankContextUnits(units: ContextUnit[], currentTurn: number, userInput: string, weights: ContextEngineScoringConfig): ScoredContextUnit[];
|
|
9
|
+
export declare function selectUnitsWithinBudget(ranked: ScoredContextUnit[], tokenBudget: number): {
|
|
10
|
+
included: ScoredContextUnit[];
|
|
11
|
+
excluded: ScoredContextUnit[];
|
|
12
|
+
};
|
|
13
|
+
export declare function unitTokens(content: string): number;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { bm25Relevance } from "./bm25.js";
|
|
2
|
+
import { estimateTokens } from "./summarize.js";
|
|
3
|
+
const PIN_BOOST = 1000;
|
|
4
|
+
export function recencyScore(ageTurns) {
|
|
5
|
+
return 1 / (1 + Math.max(0, ageTurns));
|
|
6
|
+
}
|
|
7
|
+
export function scoreContextUnit(unit, currentTurn, userInput, weights) {
|
|
8
|
+
const pin = unit.pinned ? PIN_BOOST * weights.w_pin : 0;
|
|
9
|
+
const age = Math.max(0, currentTurn - unit.sourceTurn);
|
|
10
|
+
const recency = recencyScore(age) * weights.w_recency;
|
|
11
|
+
const relevance = bm25Relevance(userInput, unit.content) * weights.w_relevance;
|
|
12
|
+
return {
|
|
13
|
+
score: pin + recency + relevance,
|
|
14
|
+
breakdown: { pin, recency, relevance },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function rankContextUnits(units, currentTurn, userInput, weights) {
|
|
18
|
+
return units
|
|
19
|
+
.map((unit) => {
|
|
20
|
+
const scored = scoreContextUnit(unit, currentTurn, userInput, weights);
|
|
21
|
+
return { ...unit, ...scored };
|
|
22
|
+
})
|
|
23
|
+
.sort((a, b) => b.score - a.score || a.id.localeCompare(b.id));
|
|
24
|
+
}
|
|
25
|
+
export function selectUnitsWithinBudget(ranked, tokenBudget) {
|
|
26
|
+
const included = [];
|
|
27
|
+
const excluded = [];
|
|
28
|
+
let used = 0;
|
|
29
|
+
for (const unit of ranked) {
|
|
30
|
+
if (unit.pinned) {
|
|
31
|
+
included.push(unit);
|
|
32
|
+
used += unit.tokens;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (used + unit.tokens <= tokenBudget) {
|
|
36
|
+
included.push(unit);
|
|
37
|
+
used += unit.tokens;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
excluded.push(unit);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { included, excluded };
|
|
44
|
+
}
|
|
45
|
+
export function unitTokens(content) {
|
|
46
|
+
return estimateTokens(content);
|
|
47
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StateObject } from "../types.js";
|
|
2
|
+
import type { StateGraph } from "../state-graph.js";
|
|
3
|
+
import type { StateSnapshot, TurnDigestDecision } from "./types.js";
|
|
4
|
+
export declare function snapshotStateGraph(stateGraph: StateGraph): StateSnapshot;
|
|
5
|
+
export declare function diffStateGraph(before: StateSnapshot, afterObjects: StateObject[]): {
|
|
6
|
+
decisions: TurnDigestDecision[];
|
|
7
|
+
constraints: string[];
|
|
8
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export function snapshotStateGraph(stateGraph) {
|
|
2
|
+
const objects = new Map();
|
|
3
|
+
for (const obj of stateGraph.snapshot()) {
|
|
4
|
+
if (obj.retracted)
|
|
5
|
+
continue;
|
|
6
|
+
objects.set(obj.id, {
|
|
7
|
+
kind: obj.kind,
|
|
8
|
+
updated: obj.updated,
|
|
9
|
+
payloadJson: JSON.stringify(obj.payload),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return { objects };
|
|
13
|
+
}
|
|
14
|
+
export function diffStateGraph(before, afterObjects) {
|
|
15
|
+
const decisions = [];
|
|
16
|
+
const constraints = [];
|
|
17
|
+
for (const obj of afterObjects) {
|
|
18
|
+
if (obj.retracted)
|
|
19
|
+
continue;
|
|
20
|
+
const prev = before.objects.get(obj.id);
|
|
21
|
+
if (obj.kind === "decision") {
|
|
22
|
+
const payload = obj.payload;
|
|
23
|
+
const entry = {
|
|
24
|
+
summary: payload.summary,
|
|
25
|
+
rationale: payload.rationale || undefined,
|
|
26
|
+
};
|
|
27
|
+
// Omit rationale key entirely if not present — cleaner serialisation
|
|
28
|
+
if (!entry.rationale)
|
|
29
|
+
delete entry.rationale;
|
|
30
|
+
if (!prev) {
|
|
31
|
+
decisions.push(entry);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (obj.updated > prev.updated || prev.payloadJson !== JSON.stringify(obj.payload)) {
|
|
35
|
+
decisions.push(entry);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (obj.kind === "constraint") {
|
|
39
|
+
const text = obj.payload.text;
|
|
40
|
+
if (!prev) {
|
|
41
|
+
constraints.push(text);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (obj.updated > prev.updated || prev.payloadJson !== JSON.stringify(obj.payload)) {
|
|
45
|
+
constraints.push(text);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { decisions, constraints };
|
|
50
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ContentType } from "./types.js";
|
|
2
|
+
/** Rough token estimate: 1 token ≈ 4 chars. */
|
|
3
|
+
export declare function estimateTokens(text: string): number;
|
|
4
|
+
/** Generic head/tail summary for Phase 1 (specialized distillers land in Phase 2). */
|
|
5
|
+
export declare function summarizeGeneric(rawText: string, contentType: ContentType): string;
|
|
6
|
+
export declare function buildArtifactCard(artifactId: string, sourceTool: string, command: string | undefined, rawTokens: number, summary: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Rough token estimate: 1 token ≈ 4 chars. */
|
|
2
|
+
export function estimateTokens(text) {
|
|
3
|
+
return Math.ceil(text.length / 4);
|
|
4
|
+
}
|
|
5
|
+
/** Generic head/tail summary for Phase 1 (specialized distillers land in Phase 2). */
|
|
6
|
+
export function summarizeGeneric(rawText, contentType) {
|
|
7
|
+
if (contentType === "error") {
|
|
8
|
+
return rawText;
|
|
9
|
+
}
|
|
10
|
+
const lines = rawText.split("\n");
|
|
11
|
+
if (lines.length <= 8 && rawText.length <= 600) {
|
|
12
|
+
return rawText;
|
|
13
|
+
}
|
|
14
|
+
const headChars = 400;
|
|
15
|
+
const tailChars = 400;
|
|
16
|
+
if (rawText.length <= headChars + tailChars + 40) {
|
|
17
|
+
return rawText;
|
|
18
|
+
}
|
|
19
|
+
const head = rawText.slice(0, headChars).trimEnd();
|
|
20
|
+
const tail = rawText.slice(-tailChars).trimStart();
|
|
21
|
+
const omitted = rawText.length - head.length - tail.length;
|
|
22
|
+
return `${head}\n… [${omitted.toLocaleString()} chars omitted] …\n${tail}`;
|
|
23
|
+
}
|
|
24
|
+
export function buildArtifactCard(artifactId, sourceTool, command, rawTokens, summary) {
|
|
25
|
+
const label = command ? `${sourceTool}: ${command}` : sourceTool;
|
|
26
|
+
const lines = [
|
|
27
|
+
`[artifact: ${artifactId} | ${label} | ${rawTokens.toLocaleString()} tokens raw]`,
|
|
28
|
+
summary,
|
|
29
|
+
`Retrieve: retrieve_artifact("${artifactId}")`,
|
|
30
|
+
];
|
|
31
|
+
return lines.join("\n");
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type Database from "better-sqlite3";
|
|
2
|
+
import type { PressureMode } from "./types.js";
|
|
3
|
+
import { type ArtifactAccessType, type DistillerCostRow, type SessionStatsRow } from "./db.js";
|
|
4
|
+
export interface CompileTelemetryInput {
|
|
5
|
+
turn: number;
|
|
6
|
+
pressureMode: PressureMode;
|
|
7
|
+
excludedScoredUnits: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SessionTelemetrySummary {
|
|
10
|
+
stats: SessionStatsRow;
|
|
11
|
+
artifactsProduced: number;
|
|
12
|
+
retrievalRate: number;
|
|
13
|
+
distillerRanking: DistillerCostRow[];
|
|
14
|
+
}
|
|
15
|
+
export declare class TelemetryRecorder {
|
|
16
|
+
private readonly db;
|
|
17
|
+
private readonly sessionId;
|
|
18
|
+
private lastPressureMode;
|
|
19
|
+
private readonly contextEngineEnabled;
|
|
20
|
+
constructor(db: Database.Database, sessionId: string, contextEngineEnabled?: boolean);
|
|
21
|
+
recordArtifactAccess(artifactId: string, accessType: ArtifactAccessType, turn: number): void;
|
|
22
|
+
recordCompileTelemetry(input: CompileTelemetryInput): void;
|
|
23
|
+
finalize(totalTurns: number): SessionTelemetrySummary;
|
|
24
|
+
}
|
|
25
|
+
export declare function renderSessionTelemetrySummary(summary: SessionTelemetrySummary): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { countSessionArtifacts, finalizeSessionStats, incrementSessionStat, insertArtifactAccess, listDistillerCostRanking, } from "./db.js";
|
|
2
|
+
export class TelemetryRecorder {
|
|
3
|
+
db;
|
|
4
|
+
sessionId;
|
|
5
|
+
lastPressureMode = "normal";
|
|
6
|
+
contextEngineEnabled;
|
|
7
|
+
constructor(db, sessionId, contextEngineEnabled = true) {
|
|
8
|
+
this.db = db;
|
|
9
|
+
this.sessionId = sessionId;
|
|
10
|
+
this.contextEngineEnabled = contextEngineEnabled;
|
|
11
|
+
}
|
|
12
|
+
recordArtifactAccess(artifactId, accessType, turn) {
|
|
13
|
+
insertArtifactAccess(this.db, this.sessionId, artifactId, accessType, turn);
|
|
14
|
+
if (accessType === "retrieved") {
|
|
15
|
+
incrementSessionStat(this.db, this.sessionId, "artifact_retrievals", 1, this.contextEngineEnabled);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
recordCompileTelemetry(input) {
|
|
19
|
+
if (input.pressureMode !== "normal" && this.lastPressureMode === "normal") {
|
|
20
|
+
incrementSessionStat(this.db, this.sessionId, "pressure_events", 1, this.contextEngineEnabled);
|
|
21
|
+
}
|
|
22
|
+
if (input.pressureMode === "emergency" && this.lastPressureMode === "compact") {
|
|
23
|
+
incrementSessionStat(this.db, this.sessionId, "pressure_events", 1, this.contextEngineEnabled);
|
|
24
|
+
}
|
|
25
|
+
this.lastPressureMode = input.pressureMode;
|
|
26
|
+
if (input.excludedScoredUnits > 0) {
|
|
27
|
+
incrementSessionStat(this.db, this.sessionId, "compaction_triggers", 1, this.contextEngineEnabled);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
finalize(totalTurns) {
|
|
31
|
+
const stats = finalizeSessionStats(this.db, this.sessionId, totalTurns, this.contextEngineEnabled);
|
|
32
|
+
const artifactsProduced = countSessionArtifacts(this.db, this.sessionId);
|
|
33
|
+
const retrievalRate = artifactsProduced > 0 ? stats.artifactRetrievals / artifactsProduced : 0;
|
|
34
|
+
const distillerRanking = listDistillerCostRanking(this.db, this.sessionId);
|
|
35
|
+
return {
|
|
36
|
+
stats,
|
|
37
|
+
artifactsProduced,
|
|
38
|
+
retrievalRate,
|
|
39
|
+
distillerRanking,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function renderSessionTelemetrySummary(summary) {
|
|
44
|
+
const { stats, artifactsProduced, retrievalRate, distillerRanking } = summary;
|
|
45
|
+
const lines = [
|
|
46
|
+
"Context engine telemetry:",
|
|
47
|
+
` turns: ${stats.totalTurns}`,
|
|
48
|
+
` artifacts produced: ${artifactsProduced}`,
|
|
49
|
+
` artifact retrievals: ${stats.artifactRetrievals} (${(retrievalRate * 100).toFixed(1)}% retrieval rate)`,
|
|
50
|
+
` distiller token savings: ${Math.round(stats.totalDistillerSavings)}`,
|
|
51
|
+
` pressure events: ${stats.pressureEvents}`,
|
|
52
|
+
` compaction triggers: ${stats.compactionTriggers}`,
|
|
53
|
+
];
|
|
54
|
+
if (distillerRanking.length > 0) {
|
|
55
|
+
lines.push(" distiller cost ranking (top 3):");
|
|
56
|
+
for (const row of distillerRanking.slice(0, 3)) {
|
|
57
|
+
lines.push(` - ${row.distiller}/${row.tool}: ${row.runs} runs, ~${row.estimatedCost} residual tokens, ${row.avgSavingsPct}% avg savings`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (retrievalRate > 0.25) {
|
|
61
|
+
lines.push(" note: retrieval rate >25% — distillers may be too aggressive for some commands");
|
|
62
|
+
}
|
|
63
|
+
return lines.join("\n");
|
|
64
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { StateGraph } from "../state-graph.js";
|
|
2
|
+
import type { StateSnapshot, TurnDigest, TurnDigestDecision } from "./types.js";
|
|
3
|
+
export declare function extractUserIntent(userMessage: string): string;
|
|
4
|
+
export declare function buildToolSummary(record: {
|
|
5
|
+
toolCalls: Array<{
|
|
6
|
+
tool: string;
|
|
7
|
+
}>;
|
|
8
|
+
}): string;
|
|
9
|
+
export declare function decisionSummary(decision: TurnDigestDecision | string): string;
|
|
10
|
+
export declare function normalizeTurnDigest(raw: TurnDigest): TurnDigest;
|
|
11
|
+
/**
|
|
12
|
+
* Extract implicit constraints from user messages.
|
|
13
|
+
*
|
|
14
|
+
* **Architecture note:** Regex is a minimal safety net for the most syntactically
|
|
15
|
+
* unambiguous patterns only. It is NOT the primary mechanism for capturing
|
|
16
|
+
* implicit knowledge — the system prompt nudge (see `compiler.ts` "Implicit
|
|
17
|
+
* Knowledge Capture") is the primary mechanism, because the LLM is the
|
|
18
|
+
* language-understanding component, not regex.
|
|
19
|
+
*
|
|
20
|
+
* We only capture patterns where the syntax is unambiguous enough that missing
|
|
21
|
+
* them would be worse than occasionally over-capturing. Specifically:
|
|
22
|
+
* - "not X, Y" corrections (the user directly reversing a wrong choice)
|
|
23
|
+
*
|
|
24
|
+
* Patterns like "we use", "let's use", "I prefer", "make sure", "how about"
|
|
25
|
+
* are NOT captured here because they are too variable in natural language.
|
|
26
|
+
* Those are the LLM's responsibility via the system prompt nudge.
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractImplicitConstraints(userMessage: string): string[];
|
|
29
|
+
export declare function isNarrativeWorthy(digest: TurnDigest, previousIntent?: string): boolean;
|
|
30
|
+
export declare function buildNarrativeEntry(digest: TurnDigest, previousIntent?: string): string | null;
|
|
31
|
+
export declare function extractPlan(assistantMessage: string): string | null;
|
|
32
|
+
export declare function extractPlanItems(planText: string): string[];
|
|
33
|
+
export declare function detectCompletedPlanItems(planItems: string[], digest: TurnDigest): string[];
|
|
34
|
+
export declare function extractTurnDigest(input: {
|
|
35
|
+
turn: number;
|
|
36
|
+
userMessage: string;
|
|
37
|
+
record: {
|
|
38
|
+
filesRead: string[];
|
|
39
|
+
filesWritten: string[];
|
|
40
|
+
assistantMessage: string;
|
|
41
|
+
toolCalls: Array<{
|
|
42
|
+
tool: string;
|
|
43
|
+
}>;
|
|
44
|
+
artifactIds: string[];
|
|
45
|
+
};
|
|
46
|
+
stateBefore: StateSnapshot;
|
|
47
|
+
stateGraph: StateGraph;
|
|
48
|
+
errorsNew: string[];
|
|
49
|
+
errorsFixed: string[];
|
|
50
|
+
}): TurnDigest;
|