@qduc/term2 0.26.1 → 0.27.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/dist/app.js +3 -2
- package/dist/app.js.map +1 -1
- package/dist/cli.js +12 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/resume-command.d.ts +1 -1
- package/dist/commands/resume-command.d.ts.map +1 -1
- package/dist/components/ErrorBoundary.js +4 -2
- package/dist/components/ErrorBoundary.js.map +1 -1
- package/dist/components/InputBox.d.ts.map +1 -1
- package/dist/components/InputBox.js +29 -37
- package/dist/components/InputBox.js.map +1 -1
- package/dist/components/common/Divider.d.ts +11 -0
- package/dist/components/common/Divider.d.ts.map +1 -0
- package/dist/components/common/Divider.js +11 -0
- package/dist/components/common/Divider.js.map +1 -0
- package/dist/components/common/MenuContainer.d.ts +3 -1
- package/dist/components/common/MenuContainer.d.ts.map +1 -1
- package/dist/components/common/MenuContainer.js +2 -7
- package/dist/components/common/MenuContainer.js.map +1 -1
- package/dist/components/input/ApplicationInputSurface.d.ts +1 -1
- package/dist/components/input/ApplicationInputSurface.d.ts.map +1 -1
- package/dist/components/input/ApplicationInputSurface.js +2 -1
- package/dist/components/input/ApplicationInputSurface.js.map +1 -1
- package/dist/components/input/PendingQueueList.d.ts +6 -0
- package/dist/components/input/PendingQueueList.d.ts.map +1 -1
- package/dist/components/input/PendingQueueList.js +42 -37
- package/dist/components/input/PendingQueueList.js.map +1 -1
- package/dist/components/input/ResumeMenuSession.d.ts.map +1 -1
- package/dist/components/input/ResumeMenuSession.js +1 -1
- package/dist/components/input/ResumeMenuSession.js.map +1 -1
- package/dist/components/layout/BackgroundTaskManager.d.ts.map +1 -1
- package/dist/components/layout/BackgroundTaskManager.js +8 -5
- package/dist/components/layout/BackgroundTaskManager.js.map +1 -1
- package/dist/components/layout/BottomArea.d.ts +1 -1
- package/dist/components/layout/BottomArea.d.ts.map +1 -1
- package/dist/components/layout/BottomArea.js +2 -0
- package/dist/components/layout/BottomArea.js.map +1 -1
- package/dist/components/menu/CopyMenu.d.ts.map +1 -1
- package/dist/components/menu/CopyMenu.js +8 -3
- package/dist/components/menu/CopyMenu.js.map +1 -1
- package/dist/components/menu/McpSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/McpSelectionMenu.js +13 -8
- package/dist/components/menu/McpSelectionMenu.js.map +1 -1
- package/dist/components/menu/PathSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/PathSelectionMenu.js +10 -7
- package/dist/components/menu/PathSelectionMenu.js.map +1 -1
- package/dist/components/menu/ProviderSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/ProviderSelectionMenu.js +58 -23
- package/dist/components/menu/ProviderSelectionMenu.js.map +1 -1
- package/dist/components/menu/ResumeSelectionMenu.d.ts +2 -0
- package/dist/components/menu/ResumeSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/ResumeSelectionMenu.js +9 -3
- package/dist/components/menu/ResumeSelectionMenu.js.map +1 -1
- package/dist/components/menu/RewindMenu.d.ts.map +1 -1
- package/dist/components/menu/RewindMenu.js +10 -5
- package/dist/components/menu/RewindMenu.js.map +1 -1
- package/dist/components/menu/SettingsSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/SettingsSelectionMenu.js +12 -17
- package/dist/components/menu/SettingsSelectionMenu.js.map +1 -1
- package/dist/components/menu/SettingsValueSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/SettingsValueSelectionMenu.js +10 -23
- package/dist/components/menu/SettingsValueSelectionMenu.js.map +1 -1
- package/dist/components/menu/SubagentPoolSelectionMenu.d.ts.map +1 -1
- package/dist/components/menu/SubagentPoolSelectionMenu.js +45 -24
- package/dist/components/menu/SubagentPoolSelectionMenu.js.map +1 -1
- package/dist/components/message/ChatMessage.d.ts.map +1 -1
- package/dist/components/message/ChatMessage.js +7 -2
- package/dist/components/message/ChatMessage.js.map +1 -1
- package/dist/components/message/CommandMessage.js +8 -1
- package/dist/components/message/CommandMessage.js.map +1 -1
- package/dist/components/message/MemoryRenderer.d.ts.map +1 -1
- package/dist/components/message/MemoryRenderer.js +11 -11
- package/dist/components/message/MemoryRenderer.js.map +1 -1
- package/dist/components/message/SubagentActivityMessage.d.ts.map +1 -1
- package/dist/components/message/SubagentActivityMessage.js +3 -3
- package/dist/components/message/SubagentActivityMessage.js.map +1 -1
- package/dist/components/message/command-message-helpers.d.ts +5 -5
- package/dist/components/prompt/ConfirmPrompt.d.ts +17 -0
- package/dist/components/prompt/ConfirmPrompt.d.ts.map +1 -0
- package/dist/components/prompt/ConfirmPrompt.js +54 -0
- package/dist/components/prompt/ConfirmPrompt.js.map +1 -0
- package/dist/components/prompt/HandoffConfirmationPrompt.d.ts.map +1 -1
- package/dist/components/prompt/HandoffConfirmationPrompt.js +3 -37
- package/dist/components/prompt/HandoffConfirmationPrompt.js.map +1 -1
- package/dist/components/prompt/InputSurgeConfirmationPrompt.d.ts.map +1 -1
- package/dist/components/prompt/InputSurgeConfirmationPrompt.js +3 -43
- package/dist/components/prompt/InputSurgeConfirmationPrompt.js.map +1 -1
- package/dist/components/prompt/LargeUncachedConfirmationPrompt.d.ts.map +1 -1
- package/dist/components/prompt/LargeUncachedConfirmationPrompt.js +5 -44
- package/dist/components/prompt/LargeUncachedConfirmationPrompt.js.map +1 -1
- package/dist/components/prompt/ModeSwitchConfirmationPrompt.d.ts.map +1 -1
- package/dist/components/prompt/ModeSwitchConfirmationPrompt.js +5 -46
- package/dist/components/prompt/ModeSwitchConfirmationPrompt.js.map +1 -1
- package/dist/components/prompt/QueuePausedPrompt.d.ts.map +1 -1
- package/dist/components/prompt/QueuePausedPrompt.js +11 -14
- package/dist/components/prompt/QueuePausedPrompt.js.map +1 -1
- package/dist/components/prompt/StandardModeConfirmationPrompt.d.ts.map +1 -1
- package/dist/components/prompt/StandardModeConfirmationPrompt.js +3 -37
- package/dist/components/prompt/StandardModeConfirmationPrompt.js.map +1 -1
- package/dist/components/theme.d.ts +5 -3
- package/dist/components/theme.d.ts.map +1 -1
- package/dist/components/theme.js +5 -3
- package/dist/components/theme.js.map +1 -1
- package/dist/hooks/use-app-commands.d.ts +1 -1
- package/dist/hooks/use-app-commands.d.ts.map +1 -1
- package/dist/hooks/use-conversation.d.ts.map +1 -1
- package/dist/hooks/use-conversation.js +0 -3
- package/dist/hooks/use-conversation.js.map +1 -1
- package/dist/hooks/use-resume-selection.d.ts +3 -1
- package/dist/hooks/use-resume-selection.d.ts.map +1 -1
- package/dist/hooks/use-resume-selection.js +26 -1
- package/dist/hooks/use-resume-selection.js.map +1 -1
- package/dist/lib/agent-chat-service.d.ts +2 -0
- package/dist/lib/agent-chat-service.d.ts.map +1 -1
- package/dist/lib/agent-chat-service.js +14 -0
- package/dist/lib/agent-chat-service.js.map +1 -1
- package/dist/lib/agent-client.d.ts +6 -0
- package/dist/lib/agent-client.d.ts.map +1 -1
- package/dist/lib/agent-client.js +17 -14
- package/dist/lib/agent-client.js.map +1 -1
- package/dist/non-interactive.d.ts.map +1 -1
- package/dist/non-interactive.js +4 -0
- package/dist/non-interactive.js.map +1 -1
- package/dist/prompts/memory-recall-notice.d.ts +28 -0
- package/dist/prompts/memory-recall-notice.d.ts.map +1 -0
- package/dist/prompts/memory-recall-notice.js +59 -0
- package/dist/prompts/memory-recall-notice.js.map +1 -0
- package/dist/prompts/memory-recall-notice.test.ts +50 -0
- package/dist/prompts/memory-recall-notice.ts +69 -0
- package/dist/prompts/memory.md +1 -1
- package/dist/prompts/prompt-constructor.test.ts +5 -4
- package/dist/services/conversation/conversation-adapter.d.ts.map +1 -1
- package/dist/services/conversation/conversation-adapter.js +6 -1
- package/dist/services/conversation/conversation-adapter.js.map +1 -1
- package/dist/services/conversation/conversation-decoder.d.ts.map +1 -1
- package/dist/services/conversation/conversation-decoder.js +6 -0
- package/dist/services/conversation/conversation-decoder.js.map +1 -1
- package/dist/services/conversation/conversation-events.d.ts +7 -1
- package/dist/services/conversation/conversation-events.d.ts.map +1 -1
- package/dist/services/conversation/conversation-events.js +5 -0
- package/dist/services/conversation/conversation-events.js.map +1 -1
- package/dist/services/conversation/conversation-message-projection.d.ts.map +1 -1
- package/dist/services/conversation/conversation-message-projection.js +3 -2
- package/dist/services/conversation/conversation-message-projection.js.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.d.ts.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.js +0 -8
- package/dist/services/conversation/conversation-orchestrator.js.map +1 -1
- package/dist/services/conversation/conversation-persistence.d.ts +11 -0
- package/dist/services/conversation/conversation-persistence.d.ts.map +1 -1
- package/dist/services/conversation/conversation-persistence.js +18 -3
- package/dist/services/conversation/conversation-persistence.js.map +1 -1
- package/dist/services/conversation/conversation-replay.d.ts.map +1 -1
- package/dist/services/conversation/conversation-replay.js +10 -0
- package/dist/services/conversation/conversation-replay.js.map +1 -1
- package/dist/services/conversation/conversation-runtime-factory.d.ts +2 -0
- package/dist/services/conversation/conversation-runtime-factory.d.ts.map +1 -1
- package/dist/services/conversation/conversation-runtime-factory.js.map +1 -1
- package/dist/services/conversation/conversation-service.d.ts +4 -1
- package/dist/services/conversation/conversation-service.d.ts.map +1 -1
- package/dist/services/conversation/conversation-service.js +5 -1
- package/dist/services/conversation/conversation-service.js.map +1 -1
- package/dist/services/conversation/recent-conversations.d.ts +35 -0
- package/dist/services/conversation/recent-conversations.d.ts.map +1 -0
- package/dist/services/conversation/recent-conversations.js +54 -0
- package/dist/services/conversation/recent-conversations.js.map +1 -0
- package/dist/services/conversation/session-index/session-index-worker-client.d.ts +15 -2
- package/dist/services/conversation/session-index/session-index-worker-client.d.ts.map +1 -1
- package/dist/services/conversation/session-index/session-index-worker-client.js +31 -5
- package/dist/services/conversation/session-index/session-index-worker-client.js.map +1 -1
- package/dist/services/conversation/session-index/session-index-worker.d.ts +6 -0
- package/dist/services/conversation/session-index/session-index-worker.d.ts.map +1 -1
- package/dist/services/conversation/session-index/session-index-worker.js +14 -0
- package/dist/services/conversation/session-index/session-index-worker.js.map +1 -1
- package/dist/services/conversation/session-knowledge-candidates.d.ts +15 -0
- package/dist/services/conversation/session-knowledge-candidates.d.ts.map +1 -0
- package/dist/services/conversation/session-knowledge-candidates.js +66 -0
- package/dist/services/conversation/session-knowledge-candidates.js.map +1 -0
- package/dist/services/conversation-agent-client.d.ts +8 -2
- package/dist/services/conversation-agent-client.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-events.d.ts +7 -1
- package/dist/services/logging/conversation-log-events.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-events.js.map +1 -1
- package/dist/services/logging/conversation-log-writer.d.ts +1 -1
- package/dist/services/logging/conversation-log-writer.d.ts.map +1 -1
- package/dist/services/logging/conversation-logger.d.ts.map +1 -1
- package/dist/services/logging/conversation-logger.js +4 -0
- package/dist/services/logging/conversation-logger.js.map +1 -1
- package/dist/services/memory/automatic-memory-canary.d.ts +20 -0
- package/dist/services/memory/automatic-memory-canary.d.ts.map +1 -0
- package/dist/services/memory/automatic-memory-canary.js +36 -0
- package/dist/services/memory/automatic-memory-canary.js.map +1 -0
- package/dist/services/memory/distiller/path-safety.d.ts +3 -0
- package/dist/services/memory/distiller/path-safety.d.ts.map +1 -0
- package/dist/services/memory/distiller/path-safety.js +7 -0
- package/dist/services/memory/distiller/path-safety.js.map +1 -0
- package/dist/services/memory/distiller/promotion-policy.d.ts +26 -0
- package/dist/services/memory/distiller/promotion-policy.d.ts.map +1 -0
- package/dist/services/memory/distiller/promotion-policy.js +40 -0
- package/dist/services/memory/distiller/promotion-policy.js.map +1 -0
- package/dist/services/memory/distiller/secret-redaction.d.ts +3 -0
- package/dist/services/memory/distiller/secret-redaction.d.ts.map +1 -0
- package/dist/services/memory/distiller/secret-redaction.js +40 -0
- package/dist/services/memory/distiller/secret-redaction.js.map +1 -0
- package/dist/services/memory/memory-capabilities.d.ts +19 -0
- package/dist/services/memory/memory-capabilities.d.ts.map +1 -1
- package/dist/services/memory/memory-capabilities.js +87 -15
- package/dist/services/memory/memory-capabilities.js.map +1 -1
- package/dist/services/memory/memory-store.d.ts +24 -2
- package/dist/services/memory/memory-store.d.ts.map +1 -1
- package/dist/services/memory/memory-store.js +110 -6
- package/dist/services/memory/memory-store.js.map +1 -1
- package/dist/services/session/initial-input-preparer.d.ts.map +1 -1
- package/dist/services/session/initial-input-preparer.js +5 -1
- package/dist/services/session/initial-input-preparer.js.map +1 -1
- package/dist/services/session/initial-turn-recovery-handler.d.ts.map +1 -1
- package/dist/services/session/initial-turn-recovery-handler.js +2 -1
- package/dist/services/session/initial-turn-recovery-handler.js.map +1 -1
- package/dist/services/session/session-composition.d.ts +6 -2
- package/dist/services/session/session-composition.d.ts.map +1 -1
- package/dist/services/session/session-composition.js +14 -27
- package/dist/services/session/session-composition.js.map +1 -1
- package/dist/services/session/turn-attempt-factory.d.ts +2 -0
- package/dist/services/session/turn-attempt-factory.d.ts.map +1 -1
- package/dist/services/session/turn-attempt-factory.js.map +1 -1
- package/dist/services/session/turn-attempt.d.ts +5 -0
- package/dist/services/session/turn-attempt.d.ts.map +1 -1
- package/dist/services/session/turn-attempt.js +9 -0
- package/dist/services/session/turn-attempt.js.map +1 -1
- package/dist/services/session/turn-coordinator.d.ts +5 -2
- package/dist/services/session/turn-coordinator.d.ts.map +1 -1
- package/dist/services/session/turn-coordinator.js +47 -0
- package/dist/services/session/turn-coordinator.js.map +1 -1
- package/dist/services/session/turn-workflow.d.ts.map +1 -1
- package/dist/services/session/turn-workflow.js +41 -1
- package/dist/services/session/turn-workflow.js.map +1 -1
- package/dist/services/session-rollover/session-rollover-brief.d.ts.map +1 -1
- package/dist/services/session-rollover/session-rollover-brief.js +2 -0
- package/dist/services/session-rollover/session-rollover-brief.js.map +1 -1
- package/dist/tools/memory/memory-tools.d.ts.map +1 -1
- package/dist/tools/memory/memory-tools.js +55 -20
- package/dist/tools/memory/memory-tools.js.map +1 -1
- package/dist/tools/session-rollover/session-rollover-tool.d.ts.map +1 -1
- package/dist/tools/session-rollover/session-rollover-tool.js +9 -4
- package/dist/tools/session-rollover/session-rollover-tool.js.map +1 -1
- package/dist/types/message.d.ts +2 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/conversation/conversation-event-handler.d.ts.map +1 -1
- package/dist/utils/conversation/conversation-event-handler.js +11 -0
- package/dist/utils/conversation/conversation-event-handler.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CreateMemoryInput } from '../memory-store.js';
|
|
2
|
+
type Record = {
|
|
3
|
+
sourceIndex: number;
|
|
4
|
+
role: string;
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
type Lead = {
|
|
8
|
+
sourceIndex: number;
|
|
9
|
+
quote: string;
|
|
10
|
+
category: string;
|
|
11
|
+
};
|
|
12
|
+
type Evidence = {
|
|
13
|
+
sourceIndex: number;
|
|
14
|
+
quote: string;
|
|
15
|
+
};
|
|
16
|
+
type Decision = {
|
|
17
|
+
status: 'rejected' | 'noop';
|
|
18
|
+
} | {
|
|
19
|
+
status: 'eligible' | 'candidate';
|
|
20
|
+
memory: CreateMemoryInput;
|
|
21
|
+
evidence: Evidence;
|
|
22
|
+
};
|
|
23
|
+
/** The model selects a lead; it never authors text that can become a memory. */
|
|
24
|
+
export declare function validateDistilledOperation(value: unknown, records: readonly Record[], leads: readonly Lead[]): Decision;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=promotion-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promotion-policy.d.ts","sourceRoot":"","sources":["../../../../source/services/memory/distiller/promotion-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,KAAK,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAClE,KAAK,IAAI,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AACrE,KAAK,QAAQ,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACvD,KAAK,QAAQ,GACT;IAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAAA;CAAE,GAC/B;IAAE,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;IAAC,MAAM,EAAE,iBAAiB,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC;AAExF,gFAAgF;AAChF,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,KAAK,EAAE,SAAS,IAAI,EAAE,GACrB,QAAQ,CA2CV"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { containsSecret } from './secret-redaction.js';
|
|
2
|
+
/** The model selects a lead; it never authors text that can become a memory. */
|
|
3
|
+
export function validateDistilledOperation(value, records, leads) {
|
|
4
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
5
|
+
return { status: 'rejected' };
|
|
6
|
+
const raw = value;
|
|
7
|
+
if (raw.op === 'noop')
|
|
8
|
+
return { status: 'noop' };
|
|
9
|
+
if (raw.op !== 'create' ||
|
|
10
|
+
raw.scope !== 'project' ||
|
|
11
|
+
typeof raw.id !== 'string' ||
|
|
12
|
+
!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(raw.id) ||
|
|
13
|
+
!['preference', 'decision', 'correction', 'reference'].includes(raw.kind) ||
|
|
14
|
+
!Array.isArray(raw.evidence) ||
|
|
15
|
+
raw.evidence.length !== 1)
|
|
16
|
+
return { status: 'rejected' };
|
|
17
|
+
const evidence = raw.evidence[0];
|
|
18
|
+
if (!evidence ||
|
|
19
|
+
!Number.isSafeInteger(evidence.sourceIndex) ||
|
|
20
|
+
typeof evidence.quote !== 'string' ||
|
|
21
|
+
evidence.quote.length === 0 ||
|
|
22
|
+
evidence.quote.length > 280 ||
|
|
23
|
+
evidence.quote.includes('[REDACTED]') ||
|
|
24
|
+
containsSecret(evidence.quote) ||
|
|
25
|
+
!records.some((record) => record.role === 'user' && record.sourceIndex === evidence.sourceIndex && record.text === evidence.quote))
|
|
26
|
+
return { status: 'rejected' };
|
|
27
|
+
const quote = evidence.quote;
|
|
28
|
+
const lead = leads.find((candidate) => candidate.sourceIndex === evidence.sourceIndex && candidate.quote === quote);
|
|
29
|
+
const memory = { id: raw.id, title: quote, summary: quote, content: quote, tags: [raw.kind] };
|
|
30
|
+
return {
|
|
31
|
+
status: lead?.category === 'preference' &&
|
|
32
|
+
raw.kind === 'preference' &&
|
|
33
|
+
!/\b(?:for this task|for now|just this time|temporarily|today|this session|this one time)\b/i.test(quote)
|
|
34
|
+
? 'eligible'
|
|
35
|
+
: 'candidate',
|
|
36
|
+
memory,
|
|
37
|
+
evidence: { sourceIndex: evidence.sourceIndex, quote },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=promotion-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promotion-policy.js","sourceRoot":"","sources":["../../../../source/services/memory/distiller/promotion-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AASvD,gFAAgF;AAChF,MAAM,UAAU,0BAA0B,CACxC,KAAc,EACd,OAA0B,EAC1B,KAAsB;IAEtB,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAC/F,MAAM,GAAG,GAAG,KAAmC,CAAC;IAChD,IAAI,GAAG,CAAC,EAAE,KAAK,MAAM;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACj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,SAAS,CAAC,WAAW,KAAK,QAAQ,CAAC,WAAW,IAAI,SAAS,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IACpH,MAAM,MAAM,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,IAAc,CAAC,EAAE,CAAC;IACxG,OAAO;QACL,MAAM,EACJ,IAAI,EAAE,QAAQ,KAAK,YAAY;YAC/B,GAAG,CAAC,IAAI,KAAK,YAAY;YACzB,CAAC,4FAA4F,CAAC,IAAI,CAAC,KAAK,CAAC;YACvG,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,WAAW;QACjB,MAAM;QACN,QAAQ,EAAE,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAY,EAAE,KAAK,EAAE;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-redaction.d.ts","sourceRoot":"","sources":["../../../../source/services/memory/distiller/secret-redaction.ts"],"names":[],"mappings":"AAqBA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAclD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-level secret redaction for text that leaves the machine or becomes
|
|
3
|
+
* durable memory. Key-name redaction (provider traffic) cannot see a token
|
|
4
|
+
* pasted into a chat message, so this matches credential shapes in prose.
|
|
5
|
+
*
|
|
6
|
+
* Tuned toward recall: a false positive only drops a sentence from a
|
|
7
|
+
* transcript excerpt or blocks one memory write.
|
|
8
|
+
*/
|
|
9
|
+
const PATTERNS = [
|
|
10
|
+
/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,
|
|
11
|
+
/\bsk-(?:ant-|proj-|or-)?[A-Za-z0-9_-]{20,}/g,
|
|
12
|
+
/\b(?:ghp|gho|ghu|ghs|ghr|github_pat)_[A-Za-z0-9_]{20,}/g,
|
|
13
|
+
/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,
|
|
14
|
+
/\bxox[abprs]-[A-Za-z0-9-]{10,}/g,
|
|
15
|
+
/\bAIza[0-9A-Za-z_-]{30,}/g,
|
|
16
|
+
/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g,
|
|
17
|
+
/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{16,}/gi,
|
|
18
|
+
/\b[a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:[^\s@/]{3,}@/gi,
|
|
19
|
+
/\b([A-Za-z0-9_]*(?:api[_-]?key|secret|token|passw(?:or)?d|credential)[A-Za-z0-9_]*)(\s*[:=]\s*)("[^"\n]{4,}"|'[^'\n]{4,}'|[^\s"',;]{8,})/gi,
|
|
20
|
+
];
|
|
21
|
+
export function redactSecrets(text) {
|
|
22
|
+
let result = text;
|
|
23
|
+
for (const pattern of PATTERNS) {
|
|
24
|
+
result = result.replace(pattern, (match, name, separator) => {
|
|
25
|
+
// Keep the key name so the surrounding sentence still reads.
|
|
26
|
+
// No-capture regexes pass the match offset and input string in these
|
|
27
|
+
// positions; only the assignment pattern supplies string captures here.
|
|
28
|
+
if (typeof name === 'string' && typeof separator === 'string' && /[:=]/.test(separator))
|
|
29
|
+
return `${name}${separator}[REDACTED]`;
|
|
30
|
+
if (/^(Bearer|Basic)\s/i.test(match))
|
|
31
|
+
return `${match.split(/\s+/)[0]} [REDACTED]`;
|
|
32
|
+
return '[REDACTED]';
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
export function containsSecret(text) {
|
|
38
|
+
return redactSecrets(text) !== text;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=secret-redaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-redaction.js","sourceRoot":"","sources":["../../../../source/services/memory/distiller/secret-redaction.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,QAAQ,GAAa;IACzB,6EAA6E;IAC7E,6CAA6C;IAC7C,yDAAyD;IACzD,gCAAgC;IAChC,iCAAiC;IACjC,2BAA2B;IAC3B,kEAAkE;IAClE,8CAA8C;IAC9C,kDAAkD;IAClD,4IAA4I;CAC7I,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,IAAwB,EAAE,SAA6B,EAAE,EAAE;YAClG,6DAA6D;YAC7D,qEAAqE;YACrE,wEAAwE;YACxE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;gBACrF,OAAO,GAAG,IAAI,GAAG,SAAS,YAAY,CAAC;YACzC,IAAI,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;gBAAE,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;YACnF,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;AACtC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ISettingsService } from '../service-interfaces.js';
|
|
2
|
+
import { FileMemoryStore } from './memory-store.js';
|
|
2
3
|
import type { ToolDefinition } from '../../tools/types.js';
|
|
3
4
|
export type MemoryAccess = 'none' | 'read' | 'write';
|
|
4
5
|
export type MemoryCapabilitySubject = {
|
|
@@ -13,6 +14,15 @@ export type MemoryCapability = {
|
|
|
13
14
|
guidance: string;
|
|
14
15
|
context: string;
|
|
15
16
|
};
|
|
17
|
+
export type InjectedMemory = {
|
|
18
|
+
scope: 'global' | 'project';
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
};
|
|
22
|
+
export type TurnMemorySelection = {
|
|
23
|
+
text: string;
|
|
24
|
+
memories: InjectedMemory[];
|
|
25
|
+
};
|
|
16
26
|
/** Resolves role-specific memory authority and the bounded root-turn working set. */
|
|
17
27
|
export declare class MemoryCapabilityBuilder {
|
|
18
28
|
#private;
|
|
@@ -23,9 +33,18 @@ export declare class MemoryCapabilityBuilder {
|
|
|
23
33
|
contextForTurn(query: string, options?: {
|
|
24
34
|
projectPath?: string;
|
|
25
35
|
}): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* The recall block for one user turn. `exclude` holds `recallKey`s already
|
|
38
|
+
* recalled into this conversation, so a memory is sent at most once.
|
|
39
|
+
*/
|
|
40
|
+
selectForTurn(query: string, options?: {
|
|
41
|
+
projectPath?: string;
|
|
42
|
+
exclude?: ReadonlySet<string>;
|
|
43
|
+
}): Promise<TurnMemorySelection>;
|
|
26
44
|
build(subject: MemoryCapabilitySubject, options?: {
|
|
27
45
|
projectPath?: string;
|
|
28
46
|
includeContext?: boolean;
|
|
29
47
|
}): MemoryCapability;
|
|
48
|
+
projectStore(projectPath: string): FileMemoryStore;
|
|
30
49
|
}
|
|
31
50
|
//# sourceMappingURL=memory-capabilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-capabilities.d.ts","sourceRoot":"","sources":["../../../source/services/memory/memory-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA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AE3F;IAED;;;OAGG;IACG,aAAa,CACjB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;KAAO,GACpE,OAAO,CAAC,mBAAmB,CAAC,CA4D9B;IAED,KAAK,CACH,OAAO,EAAE,uBAAuB,EAChC,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,OAAO,CAAA;KAAO,GAC/D,gBAAgB,CAqDlB;IA0BD,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe,CAWjD;CAmBF"}
|
|
@@ -4,10 +4,17 @@ import { createMemoryToolDefinitions } from '../../tools/memory/memory-tools.js'
|
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
+
import { MEMORY_RECALL_OVERHEAD, recallKey, renderMemoryRecall, renderRecallLine, } from '../../prompts/memory-recall-notice.js';
|
|
7
8
|
const READ_TOOL_COUNT = 4;
|
|
9
|
+
/**
|
|
10
|
+
* Per-turn recall now stays in history, so every recalled line is paid for on
|
|
11
|
+
* every later request of the session. Keep it to the few best matches.
|
|
12
|
+
*/
|
|
13
|
+
const TURN_RECALL_MAX_MEMORIES = 3;
|
|
14
|
+
const TURN_RECALL_MAX_CHARS = 1500;
|
|
8
15
|
const MAIN_GUIDANCE = `### Persistent memory
|
|
9
16
|
|
|
10
|
-
You have access to persistent memory.
|
|
17
|
+
You have access to persistent memory. When memories look relevant to a user message, the harness adds their summaries in a <memory-recall> block ahead of that message; the user did not write it. Each memory is recalled at most once per conversation, and the block is not a complete index; when a relevant item is absent, use memory_search or memory_list. Treat summaries as retrieval triggers, not verified facts; read the full memory with memory_get when it could affect your decision.
|
|
11
18
|
|
|
12
19
|
Memory has two scopes: global for cross-project preferences and reusable knowledge, and project for repository-specific decisions and conventions. Read tools (memory_list, memory_get, memory_search, memory_retrieve) operate across both scopes together. Only the write tools (memory_create, memory_update, memory_delete) take a scope parameter and require it, so explicitly pass scope: "project" when writing project memory.
|
|
13
20
|
|
|
@@ -42,6 +49,33 @@ For **memory maintenance** tasks, review the memory store and existing memories,
|
|
|
42
49
|
Always cite source memory IDs so the caller can trace claims to their sources. Treat all memory as potentially stale. Never fabricate memory content. Do not store temporary task state, intermediate reasoning, or sensitive data.`;
|
|
43
50
|
const QUERY_STOP_WORDS = new Set([
|
|
44
51
|
'the',
|
|
52
|
+
'can',
|
|
53
|
+
'we',
|
|
54
|
+
'were',
|
|
55
|
+
'doing',
|
|
56
|
+
'these',
|
|
57
|
+
'those',
|
|
58
|
+
'refine',
|
|
59
|
+
'feature',
|
|
60
|
+
'memory',
|
|
61
|
+
'memories',
|
|
62
|
+
'session',
|
|
63
|
+
'project',
|
|
64
|
+
'did',
|
|
65
|
+
'it',
|
|
66
|
+
'decide',
|
|
67
|
+
'decision',
|
|
68
|
+
'see',
|
|
69
|
+
'message',
|
|
70
|
+
'little',
|
|
71
|
+
'noisy',
|
|
72
|
+
'fix',
|
|
73
|
+
'please',
|
|
74
|
+
'help',
|
|
75
|
+
'show',
|
|
76
|
+
'tell',
|
|
77
|
+
'know',
|
|
78
|
+
'remember',
|
|
45
79
|
'and',
|
|
46
80
|
'for',
|
|
47
81
|
'are',
|
|
@@ -86,12 +120,21 @@ export class MemoryCapabilityBuilder {
|
|
|
86
120
|
}
|
|
87
121
|
/** A per-turn, summary-only working set; search tools remain authoritative. */
|
|
88
122
|
async contextForTurn(query, options = {}) {
|
|
123
|
+
return (await this.selectForTurn(query, options)).text;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The recall block for one user turn. `exclude` holds `recallKey`s already
|
|
127
|
+
* recalled into this conversation, so a memory is sent at most once.
|
|
128
|
+
*/
|
|
129
|
+
async selectForTurn(query, options = {}) {
|
|
130
|
+
const empty = () => ({ text: '', memories: [] });
|
|
89
131
|
if (!this.#settings.get('memory.enabled'))
|
|
90
|
-
return
|
|
132
|
+
return empty();
|
|
91
133
|
const terms = retrievalQuery(query);
|
|
92
134
|
if (!terms)
|
|
93
|
-
return
|
|
94
|
-
const
|
|
135
|
+
return empty();
|
|
136
|
+
const queryWords = terms.split(' ');
|
|
137
|
+
const budget = Math.min(this.#settings.get('memory.contextBudgetChars'), TURN_RECALL_MAX_CHARS);
|
|
95
138
|
try {
|
|
96
139
|
const stores = this.#createStores({
|
|
97
140
|
enabled: true,
|
|
@@ -100,27 +143,47 @@ export class MemoryCapabilityBuilder {
|
|
|
100
143
|
searchDefaultLimit: this.#settings.get('memory.searchDefaultLimit'),
|
|
101
144
|
searchMaxLimit: this.#settings.get('memory.searchMaxLimit'),
|
|
102
145
|
}, options.projectPath ?? process.cwd());
|
|
103
|
-
|
|
146
|
+
// Search wide: already-recalled memories are filtered out after ranking and
|
|
147
|
+
// must not use up the result window.
|
|
148
|
+
const limit = this.#settings.get('memory.searchMaxLimit');
|
|
149
|
+
const [global, project] = await Promise.all([
|
|
150
|
+
stores.global.search(terms, { limit }),
|
|
151
|
+
stores.project.search(terms, { limit }),
|
|
152
|
+
]);
|
|
104
153
|
// A content-only hit has no relevant summary to show as turn guidance.
|
|
105
154
|
const ranked = rankMemorySearchResults([
|
|
106
155
|
...global.map((result) => ({ ...result, scope: 'global' })),
|
|
107
156
|
...project.map((result) => ({ ...result, scope: 'project' })),
|
|
108
|
-
]).filter((
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
157
|
+
]).filter(({ scope, memory }) => {
|
|
158
|
+
// Require evidence in the injected metadata, not a substring hit in full content.
|
|
159
|
+
// Known conversational padding cannot make a topical match more or less eligible.
|
|
160
|
+
// Ambiguous follow-ups can still use memory tools instead of a guessed summary.
|
|
161
|
+
const words = new Set([memory.id, memory.title, ...memory.tags, memory.summary]
|
|
162
|
+
.join(' ')
|
|
163
|
+
.toLowerCase()
|
|
164
|
+
.match(/[a-z0-9]+/g) ?? []);
|
|
165
|
+
return queryWords.some((word) => words.has(word)) && !options.exclude?.has(recallKey(scope, memory.id));
|
|
166
|
+
});
|
|
167
|
+
let used = MEMORY_RECALL_OVERHEAD;
|
|
168
|
+
const lines = [];
|
|
169
|
+
const memories = [];
|
|
113
170
|
for (const { scope, memory } of ranked) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
171
|
+
if (memories.length >= TURN_RECALL_MAX_MEMORIES)
|
|
172
|
+
break;
|
|
173
|
+
const title = memory.title.slice(0, 120);
|
|
174
|
+
const line = renderRecallLine({ scope, id: memory.id, title, summary: memory.summary });
|
|
175
|
+
if (used + line.length + 1 <= budget) {
|
|
176
|
+
used += line.length + 1;
|
|
177
|
+
lines.push(line);
|
|
178
|
+
memories.push({ scope, id: memory.id, title });
|
|
179
|
+
}
|
|
117
180
|
}
|
|
118
|
-
return
|
|
181
|
+
return memories.length ? { text: renderMemoryRecall(lines), memories } : empty();
|
|
119
182
|
}
|
|
120
183
|
catch (error) {
|
|
121
184
|
const detail = error instanceof Error ? error.message : String(error);
|
|
122
185
|
this.#onWarning(`Persistent memory retrieval could not be loaded: ${detail}`);
|
|
123
|
-
return
|
|
186
|
+
return empty();
|
|
124
187
|
}
|
|
125
188
|
}
|
|
126
189
|
build(subject, options = {}) {
|
|
@@ -201,6 +264,15 @@ export class MemoryCapabilityBuilder {
|
|
|
201
264
|
project: new FileMemoryStore({ root: path.join(settings.directory, 'projects', projectId), ...options }),
|
|
202
265
|
};
|
|
203
266
|
}
|
|
267
|
+
projectStore(projectPath) {
|
|
268
|
+
return this.#createStores({
|
|
269
|
+
enabled: this.#settings.get('memory.enabled'),
|
|
270
|
+
directory: this.#settings.get('memory.directory'),
|
|
271
|
+
contextBudgetChars: this.#settings.get('memory.contextBudgetChars'),
|
|
272
|
+
searchDefaultLimit: this.#settings.get('memory.searchDefaultLimit'),
|
|
273
|
+
searchMaxLimit: this.#settings.get('memory.searchMaxLimit'),
|
|
274
|
+
}, projectPath).project;
|
|
275
|
+
}
|
|
204
276
|
#resolveProjectId(projectPath) {
|
|
205
277
|
try {
|
|
206
278
|
const commonDir = execSync('git rev-parse --git-common-dir', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-capabilities.js","sourceRoot":"","sources":["../../../source/services/memory/memory-capabilities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"memory-capabilities.js","sourceRoot":"","sources":["../../../source/services/memory/memory-capabilities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,uCAAuC,CAAC;AAwB/C,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B;;;GAGG;AACH,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;0XAcoW,CAAC;AAE3X,MAAM,iBAAiB,GAAG;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SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;gBAC/F,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC3C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9E,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,mEAAmE;QACrE,CAAC;QACD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export type MemoryId = string;
|
|
2
|
+
export interface MemoryProvenance {
|
|
3
|
+
at: string;
|
|
4
|
+
sessionId?: string;
|
|
5
|
+
reason: string;
|
|
6
|
+
}
|
|
2
7
|
export interface MemoryMetadata {
|
|
3
8
|
id: MemoryId;
|
|
4
9
|
title: string;
|
|
@@ -6,6 +11,7 @@ export interface MemoryMetadata {
|
|
|
6
11
|
tags: string[];
|
|
7
12
|
createdAt: string;
|
|
8
13
|
updatedAt: string;
|
|
14
|
+
provenance?: MemoryProvenance;
|
|
9
15
|
}
|
|
10
16
|
export interface Memory extends MemoryMetadata {
|
|
11
17
|
content: string;
|
|
@@ -22,6 +28,13 @@ export interface UpdateMemoryInput {
|
|
|
22
28
|
summary?: string;
|
|
23
29
|
content?: string;
|
|
24
30
|
tags?: string[];
|
|
31
|
+
/** Correction of a fact rather than a cosmetic edit; preserves the prior version. */
|
|
32
|
+
supersede?: {
|
|
33
|
+
reason: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface MemoryHistoryEntry extends Memory {
|
|
37
|
+
supersededBy: MemoryProvenance;
|
|
25
38
|
}
|
|
26
39
|
export interface MemorySearchResult {
|
|
27
40
|
memory: MemoryMetadata;
|
|
@@ -45,7 +58,10 @@ export interface MemoryStore {
|
|
|
45
58
|
maxLimit: number;
|
|
46
59
|
};
|
|
47
60
|
create(input: CreateMemoryInput): Promise<Memory>;
|
|
48
|
-
update(id: MemoryId, input: UpdateMemoryInput
|
|
61
|
+
update(id: MemoryId, input: UpdateMemoryInput, context?: {
|
|
62
|
+
sessionId?: string;
|
|
63
|
+
}): Promise<Memory>;
|
|
64
|
+
history?(id: MemoryId): Promise<MemoryHistoryEntry[]>;
|
|
49
65
|
remove(id: MemoryId): Promise<boolean>;
|
|
50
66
|
}
|
|
51
67
|
export declare class InvalidMemoryError extends Error {
|
|
@@ -95,6 +111,7 @@ export declare class FileMemoryStore implements MemoryStore {
|
|
|
95
111
|
limit?: number;
|
|
96
112
|
}): Promise<MemoryMetadata[]>;
|
|
97
113
|
get(id: MemoryId): Promise<Memory | null>;
|
|
114
|
+
history(id: MemoryId): Promise<MemoryHistoryEntry[]>;
|
|
98
115
|
search(query: string, options?: {
|
|
99
116
|
limit?: number;
|
|
100
117
|
}): Promise<MemorySearchResult[]>;
|
|
@@ -103,11 +120,16 @@ export declare class FileMemoryStore implements MemoryStore {
|
|
|
103
120
|
maxLimit: number;
|
|
104
121
|
};
|
|
105
122
|
create(input: CreateMemoryInput): Promise<Memory>;
|
|
106
|
-
|
|
123
|
+
/** A non-blocking, cross-process pilot lock; a busy/stale lock fails closed. */
|
|
124
|
+
createAutomatic(input: CreateMemoryInput, sessionId: string): Promise<Memory | null>;
|
|
125
|
+
update(id: MemoryId, input: UpdateMemoryInput, context?: {
|
|
126
|
+
sessionId?: string;
|
|
127
|
+
}): Promise<Memory>;
|
|
107
128
|
remove(id: MemoryId): Promise<boolean>;
|
|
108
129
|
context(budgetChars: number): Promise<string>;
|
|
109
130
|
contextSync(budgetChars: number): string;
|
|
110
131
|
private itemPath;
|
|
132
|
+
private historyPath;
|
|
111
133
|
private load;
|
|
112
134
|
private initialize;
|
|
113
135
|
private initializeOnce;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../../source/services/memory/memory-store.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,QAAQ,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../../source/services/memory/memory-store.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,QAAQ,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AACD,MAAM,WAAW,MAAO,SAAQ,cAAc;IAC5C,OAAO,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,QAAQ,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AACD,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,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AAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,WAAW;YAIL,IAAI;YAoBJ,UAAU;YAWV,cAAc;YAad,aAAa;YASb,UAAU;YASV,mBAAmB;YAKnB,MAAM;CAarB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdir, readFile, rename, unlink, writeFile } from 'node:fs/promises';
|
|
1
|
+
import { mkdir, readFile, rename, rmdir, unlink, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
@@ -137,6 +137,22 @@ export class FileMemoryStore {
|
|
|
137
137
|
throw new MemoryStorageError(`Memory content is unavailable for '${id}'.`);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
+
async history(id) {
|
|
141
|
+
validateId(id);
|
|
142
|
+
if (!(await this.load()).memories.some((entry) => entry.id === id))
|
|
143
|
+
return [];
|
|
144
|
+
try {
|
|
145
|
+
const entries = JSON.parse(await readFile(this.historyPath(id), 'utf8'));
|
|
146
|
+
if (!Array.isArray(entries) || !entries.every(validHistoryEntry))
|
|
147
|
+
throw new Error();
|
|
148
|
+
return entries;
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (error.code === 'ENOENT')
|
|
152
|
+
return [];
|
|
153
|
+
throw new MemoryStorageError(`Memory history is unavailable for '${id}'.`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
140
156
|
async search(query, options = {}) {
|
|
141
157
|
const terms = queryTerms(query);
|
|
142
158
|
if (!terms.length)
|
|
@@ -182,9 +198,57 @@ export class FileMemoryStore {
|
|
|
182
198
|
return memory;
|
|
183
199
|
});
|
|
184
200
|
}
|
|
185
|
-
|
|
186
|
-
|
|
201
|
+
/** A non-blocking, cross-process pilot lock; a busy/stale lock fails closed. */
|
|
202
|
+
async createAutomatic(input, sessionId) {
|
|
203
|
+
return this.mutate(async () => {
|
|
204
|
+
const normalized = normalizeCreate(input);
|
|
205
|
+
if (!sessionId.trim())
|
|
206
|
+
throw new InvalidMemoryError('Automatic memory requires a source session.');
|
|
207
|
+
await this.initialize();
|
|
208
|
+
const lock = join(this.root, '.automatic-canary.lock');
|
|
209
|
+
try {
|
|
210
|
+
await mkdir(lock);
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
if (error.code === 'EEXIST')
|
|
214
|
+
return null;
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
const index = await this.load();
|
|
219
|
+
if (index.memories.some((memory) => memory.id === normalized.id || memory.title === normalized.title))
|
|
220
|
+
return null;
|
|
221
|
+
const timestamp = this.now().toISOString();
|
|
222
|
+
const memory = {
|
|
223
|
+
...normalized,
|
|
224
|
+
createdAt: timestamp,
|
|
225
|
+
updatedAt: timestamp,
|
|
226
|
+
provenance: { at: timestamp, sessionId: sessionId.trim(), reason: normalized.content },
|
|
227
|
+
};
|
|
228
|
+
await writeFile(this.itemPath(memory.id), memory.content, { encoding: 'utf8', flag: 'wx' });
|
|
229
|
+
try {
|
|
230
|
+
await this.writeIndex({ version: 1, memories: [...index.memories, metadata(memory)] });
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
// The primary index may have committed before its backup failed.
|
|
234
|
+
// Only discard the item when a readable index proves it was not committed.
|
|
235
|
+
const committed = await this.load().then((current) => current.memories.some((entry) => entry.id === memory.id), () => true);
|
|
236
|
+
if (!committed)
|
|
237
|
+
await unlink(this.itemPath(memory.id));
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
return memory;
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
await rmdir(lock);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
async update(id, input, context) {
|
|
248
|
+
if (!Object.entries(input).some(([key, value]) => key !== 'supersede' && value !== undefined))
|
|
187
249
|
throw new InvalidMemoryError('At least one field must be provided for a memory update.');
|
|
250
|
+
if (input.supersede && !input.supersede.reason?.trim())
|
|
251
|
+
throw new InvalidMemoryError('A correction requires a reason.');
|
|
188
252
|
return this.mutate(async () => {
|
|
189
253
|
validateId(id);
|
|
190
254
|
const index = await this.load();
|
|
@@ -195,9 +259,19 @@ export class FileMemoryStore {
|
|
|
195
259
|
if (!old)
|
|
196
260
|
throw new MemoryNotFoundError(id);
|
|
197
261
|
const next = normalizeUpdate(old, input);
|
|
198
|
-
const
|
|
262
|
+
const timestamp = this.now().toISOString();
|
|
263
|
+
const provenance = input.supersede && {
|
|
264
|
+
at: timestamp,
|
|
265
|
+
...(context?.sessionId?.trim() ? { sessionId: context.sessionId.trim() } : {}),
|
|
266
|
+
reason: input.supersede.reason.trim(),
|
|
267
|
+
};
|
|
268
|
+
const memory = { ...next, updatedAt: timestamp, ...(provenance ? { provenance } : {}) };
|
|
269
|
+
if (provenance) {
|
|
270
|
+
const history = await this.history(id);
|
|
271
|
+
await this.writeFileAtomically(this.historyPath(id), `${JSON.stringify([...history, { ...old, supersededBy: provenance }], null, 2)}\n`);
|
|
272
|
+
}
|
|
199
273
|
if (input.content !== undefined && input.content !== old.content)
|
|
200
|
-
await
|
|
274
|
+
await this.writeFileAtomically(this.itemPath(id), memory.content);
|
|
201
275
|
await this.writeIndex({
|
|
202
276
|
version: 1,
|
|
203
277
|
memories: index.memories.map((entry) => (entry.id === id ? metadata(memory) : entry)),
|
|
@@ -216,6 +290,10 @@ export class FileMemoryStore {
|
|
|
216
290
|
if (error.code !== 'ENOENT')
|
|
217
291
|
throw new MemoryStorageError('Unable to remove memory content.');
|
|
218
292
|
});
|
|
293
|
+
await unlink(this.historyPath(id)).catch((error) => {
|
|
294
|
+
if (error.code !== 'ENOENT')
|
|
295
|
+
throw new MemoryStorageError('Unable to remove memory history.');
|
|
296
|
+
});
|
|
219
297
|
return true;
|
|
220
298
|
});
|
|
221
299
|
}
|
|
@@ -238,6 +316,10 @@ export class FileMemoryStore {
|
|
|
238
316
|
validateId(id);
|
|
239
317
|
return join(this.itemsPath, `${id}.md`);
|
|
240
318
|
}
|
|
319
|
+
historyPath(id) {
|
|
320
|
+
validateId(id);
|
|
321
|
+
return join(this.itemsPath, `${id}.history.json`);
|
|
322
|
+
}
|
|
241
323
|
async load() {
|
|
242
324
|
await this.initialize();
|
|
243
325
|
let contents;
|
|
@@ -408,7 +490,8 @@ function validateIndex(value) {
|
|
|
408
490
|
!Array.isArray(entry.tags) ||
|
|
409
491
|
entry.tags.some((tag) => typeof tag !== 'string') ||
|
|
410
492
|
!isUtcTimestamp(entry.createdAt) ||
|
|
411
|
-
!isUtcTimestamp(entry.updatedAt)
|
|
493
|
+
!isUtcTimestamp(entry.updatedAt) ||
|
|
494
|
+
(entry.provenance !== undefined && !validProvenance(entry.provenance)))
|
|
412
495
|
throw new Error();
|
|
413
496
|
ids.add(entry.id);
|
|
414
497
|
}
|
|
@@ -418,6 +501,27 @@ function validateIndex(value) {
|
|
|
418
501
|
}
|
|
419
502
|
return index;
|
|
420
503
|
}
|
|
504
|
+
function validProvenance(value) {
|
|
505
|
+
const provenance = value;
|
|
506
|
+
return (!!provenance &&
|
|
507
|
+
isUtcTimestamp(provenance.at) &&
|
|
508
|
+
(provenance.sessionId === undefined ||
|
|
509
|
+
(typeof provenance.sessionId === 'string' && !!provenance.sessionId.trim())) &&
|
|
510
|
+
typeof provenance.reason === 'string' &&
|
|
511
|
+
!!provenance.reason.trim());
|
|
512
|
+
}
|
|
513
|
+
function validHistoryEntry(value) {
|
|
514
|
+
const entry = value;
|
|
515
|
+
if (!entry || typeof entry.content !== 'string' || !validProvenance(entry.supersededBy))
|
|
516
|
+
return false;
|
|
517
|
+
try {
|
|
518
|
+
validateIndex({ version: 1, memories: [metadata(entry)] });
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
521
|
+
catch {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
421
525
|
function isUtcTimestamp(value) {
|
|
422
526
|
return (typeof value === 'string' &&
|
|
423
527
|
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value) &&
|