@steerable/agent-shell 0.12.8 → 0.14.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/attachments/image-normalizer.d.ts +39 -0
- package/dist/attachments/image-normalizer.js +131 -0
- package/dist/auth/credentials.d.ts +83 -0
- package/dist/auth/credentials.js +426 -0
- package/dist/auth/index.d.ts +33 -9
- package/dist/auth/index.js +85 -0
- package/dist/host/external-pack-loader.d.ts +40 -0
- package/dist/host/external-pack-loader.js +247 -0
- package/dist/host/http-routes.d.ts +6 -2
- package/dist/host/http-routes.js +5 -2
- package/dist/host/pack-assembly.d.ts +9 -1
- package/dist/host/runtime.js +54 -1
- package/dist/image-attachment.js +10 -5
- package/dist/local-backend/coreloop-stream.d.ts +4 -0
- package/dist/local-backend/coreloop-stream.js +4 -0
- package/dist/local-backend/fact-chain.d.ts +38 -0
- package/dist/local-backend/fact-chain.js +145 -0
- package/dist/local-backend/router.d.ts +3 -1
- package/dist/local-backend/router.js +602 -45
- package/dist/local-backend/state-reconcile.d.ts +42 -0
- package/dist/local-backend/state-reconcile.js +81 -0
- package/dist/local-backend/title-refresh.d.ts +39 -0
- package/dist/local-backend/title-refresh.js +80 -0
- package/dist/local-backend/turn-security-context.d.ts +42 -0
- package/dist/local-backend/turn-security-context.js +62 -0
- package/dist/local-backend/ui-surface.d.ts +75 -0
- package/dist/local-backend/ui-surface.js +368 -0
- package/dist/local-executor.d.ts +3 -0
- package/dist/local-executor.js +40 -1
- package/dist/memory/authoring-candidates.d.ts +26 -0
- package/dist/memory/authoring-candidates.js +73 -0
- package/dist/memory/injector.d.ts +38 -0
- package/dist/memory/injector.js +122 -0
- package/dist/memory/routes.d.ts +16 -0
- package/dist/memory/routes.js +146 -0
- package/dist/memory/store.d.ts +176 -0
- package/dist/memory/store.js +623 -0
- package/dist/memory/tools.d.ts +83 -0
- package/dist/memory/tools.js +143 -0
- package/dist/present-files.d.ts +25 -1
- package/dist/present-files.js +170 -2
- package/dist/raster-image.d.ts +7 -1
- package/dist/raster-image.js +34 -0
- package/dist/scenario/applications.d.ts +52 -0
- package/dist/scenario/applications.js +143 -0
- package/dist/scenario/pack.d.ts +1 -1
- package/dist/security/policy-digest.d.ts +28 -0
- package/dist/security/policy-digest.js +104 -0
- package/dist/server/http-server.js +23 -6
- package/dist/sidecar/boot.d.ts +1 -0
- package/dist/sidecar/boot.js +2 -0
- package/dist/sidecar/index.d.ts +1 -1
- package/dist/sidecar/rejected-before-effect.d.ts +22 -0
- package/dist/sidecar/rejected-before-effect.js +63 -0
- package/dist/sidecar/reverse-approval.d.ts +2 -0
- package/dist/sidecar/reverse-approval.js +28 -5
- package/dist/sidecar/reverse-tools.d.ts +3 -0
- package/dist/sidecar/reverse-tools.js +146 -18
- package/dist/sidecar/supervisor.d.ts +31 -1
- package/dist/sidecar/supervisor.js +47 -0
- package/dist/sidecar/types.d.ts +72 -0
- package/dist/storage/fde-fallback.d.ts +4 -0
- package/dist/storage/fde-fallback.js +354 -0
- package/dist/storage/fde-types.d.ts +215 -0
- package/dist/storage/fde-types.js +1 -0
- package/dist/storage/index.d.ts +113 -1
- package/dist/storage/index.js +797 -0
- package/dist/storage/insights-redact.d.ts +4 -1
- package/dist/storage/insights-redact.js +6 -1
- package/dist/storage/process-locks.d.ts +1 -1
- package/dist/storage/process-locks.js +1 -1
- package/dist/storage/reliability-summary.d.ts +1 -1
- package/dist/storage/scoped-store.d.ts +3 -1
- package/dist/tool-presentation.js +20 -0
- package/dist/tool-router.d.ts +20 -1
- package/dist/tool-router.js +76 -12
- package/package.json +5 -5
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot-anchored memory injector (Phase 9 R8-2).
|
|
3
|
+
*
|
|
4
|
+
* Prefix KV-cache invariants:
|
|
5
|
+
* 1. `system` prompt bytes remain 100% static — memory NEVER enters `system`.
|
|
6
|
+
* 2. A `<untrusted_memory_note trust="untrusted">` snapshot is captured ONLY at
|
|
7
|
+
* session Turn 1 and immediately after a `CompactionBoundary` rewrite (`compactionEpoch` bump).
|
|
8
|
+
* 3. Mid-session writes, renewals, or withdrawals NEVER mutate the anchored turn-1
|
|
9
|
+
* snapshot message; instead, they append a single `[memory delta] ...` line
|
|
10
|
+
* immediately before the latest user message on the next turn.
|
|
11
|
+
* 4. Tracks `memoryContributed` per chat so `insights` telemetry automatically
|
|
12
|
+
* strips free-text transcripts whenever private memory entered a session.
|
|
13
|
+
*/
|
|
14
|
+
import { LOCAL_DEFAULT_PRINCIPAL } from '../auth/index.js';
|
|
15
|
+
import { TENANT_INJECT_BUDGET_BYTES, USER_INJECT_BUDGET_BYTES, WORKSPACE_INJECT_BUDGET_BYTES, } from './store.js';
|
|
16
|
+
const sessionMemoryMap = new Map();
|
|
17
|
+
const sessionCompactionEpochMap = new Map();
|
|
18
|
+
/** Read the current compaction epoch for a chat session (default 0). */
|
|
19
|
+
export function getSessionCompactionEpoch(chatId) {
|
|
20
|
+
return sessionCompactionEpochMap.get(chatId) ?? 0;
|
|
21
|
+
}
|
|
22
|
+
/** Increment and return the compaction epoch after a CompactionBoundary rewrite. */
|
|
23
|
+
export function bumpSessionCompactionEpoch(chatId) {
|
|
24
|
+
const next = (sessionCompactionEpochMap.get(chatId) ?? 0) + 1;
|
|
25
|
+
sessionCompactionEpochMap.set(chatId, next);
|
|
26
|
+
return next;
|
|
27
|
+
}
|
|
28
|
+
export async function buildMemoryTurnInjection(options) {
|
|
29
|
+
const mode = await options.memoryStore.getPermissionMode();
|
|
30
|
+
const epoch = options.compactionEpoch ?? getSessionCompactionEpoch(options.chatId);
|
|
31
|
+
const existing = sessionMemoryMap.get(options.chatId);
|
|
32
|
+
if (mode === 'off') {
|
|
33
|
+
return {
|
|
34
|
+
anchoredPrefixNote: '',
|
|
35
|
+
tailDeltaNotice: '',
|
|
36
|
+
memoryContributed: existing?.memoryContributed ?? false,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Reuse frozen snapshot mid-session unless CompactionBoundary bumped `compactionEpoch`
|
|
40
|
+
if (existing && existing.compactionEpoch === epoch) {
|
|
41
|
+
const deltas = existing.pendingDeltas.splice(0, existing.pendingDeltas.length);
|
|
42
|
+
const tailDeltaNotice = deltas.length > 0 ? deltas.join('\n') : '';
|
|
43
|
+
return {
|
|
44
|
+
anchoredPrefixNote: existing.snapshotBlock,
|
|
45
|
+
tailDeltaNotice,
|
|
46
|
+
memoryContributed: existing.memoryContributed,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const principal = options.principal ?? LOCAL_DEFAULT_PRINCIPAL;
|
|
50
|
+
const workspaceId = options.workspaceId || 'default';
|
|
51
|
+
const [tenantMd, workspaceMd, userMd] = await Promise.all([
|
|
52
|
+
options.memoryStore.renderVisibleMarkdownForScope({
|
|
53
|
+
scope: 'tenant',
|
|
54
|
+
scopeId: principal.tenantId,
|
|
55
|
+
principal,
|
|
56
|
+
budgetBytes: TENANT_INJECT_BUDGET_BYTES,
|
|
57
|
+
nowMs: options.nowMs,
|
|
58
|
+
}),
|
|
59
|
+
options.memoryStore.renderVisibleMarkdownForScope({
|
|
60
|
+
scope: 'workspace',
|
|
61
|
+
scopeId: workspaceId,
|
|
62
|
+
principal,
|
|
63
|
+
budgetBytes: WORKSPACE_INJECT_BUDGET_BYTES,
|
|
64
|
+
nowMs: options.nowMs,
|
|
65
|
+
}),
|
|
66
|
+
options.memoryStore.renderVisibleMarkdownForScope({
|
|
67
|
+
scope: 'user',
|
|
68
|
+
scopeId: principal.id,
|
|
69
|
+
principal,
|
|
70
|
+
budgetBytes: USER_INJECT_BUDGET_BYTES,
|
|
71
|
+
nowMs: options.nowMs,
|
|
72
|
+
}),
|
|
73
|
+
]);
|
|
74
|
+
const sections = [];
|
|
75
|
+
if (tenantMd)
|
|
76
|
+
sections.push(`## Tenant shared rules\n${tenantMd}`);
|
|
77
|
+
if (workspaceMd)
|
|
78
|
+
sections.push(`## Workspace memory\n${workspaceMd}`);
|
|
79
|
+
if (userMd)
|
|
80
|
+
sections.push(`## Personal preferences\n${userMd}`);
|
|
81
|
+
const snapshotBlock = sections.length > 0
|
|
82
|
+
? `<untrusted_memory_note trust="untrusted">\n${sections.join('\n\n')}\n</untrusted_memory_note>`
|
|
83
|
+
: '';
|
|
84
|
+
const contributed = Boolean(snapshotBlock) || (existing?.memoryContributed ?? false);
|
|
85
|
+
sessionMemoryMap.set(options.chatId, {
|
|
86
|
+
snapshotBlock,
|
|
87
|
+
compactionEpoch: epoch,
|
|
88
|
+
pendingDeltas: [],
|
|
89
|
+
memoryContributed: contributed,
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
anchoredPrefixNote: snapshotBlock,
|
|
93
|
+
tailDeltaNotice: '',
|
|
94
|
+
memoryContributed: contributed,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function recordMidSessionMemoryDelta(chatId, deltaSummary) {
|
|
98
|
+
if (!chatId)
|
|
99
|
+
return;
|
|
100
|
+
const entry = sessionMemoryMap.get(chatId);
|
|
101
|
+
const formatted = deltaSummary.startsWith('[memory delta]')
|
|
102
|
+
? deltaSummary
|
|
103
|
+
: `[memory delta] ${deltaSummary}`;
|
|
104
|
+
if (entry) {
|
|
105
|
+
entry.pendingDeltas.push(formatted);
|
|
106
|
+
entry.memoryContributed = true;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
sessionMemoryMap.set(chatId, {
|
|
110
|
+
snapshotBlock: '',
|
|
111
|
+
compactionEpoch: 0,
|
|
112
|
+
pendingDeltas: [formatted],
|
|
113
|
+
memoryContributed: true,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export function didChatContributeMemory(chatId) {
|
|
118
|
+
return sessionMemoryMap.get(chatId)?.memoryContributed === true;
|
|
119
|
+
}
|
|
120
|
+
export function resetMemorySnapshotsForTests() {
|
|
121
|
+
sessionMemoryMap.clear();
|
|
122
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP route handlers for `/api/v2/memory*` (Phase 9 R8-4).
|
|
3
|
+
*/
|
|
4
|
+
import { type Principal } from '../auth/index.js';
|
|
5
|
+
import type { ScopedStore } from '../storage/scoped-store.js';
|
|
6
|
+
export declare function handleMemoryHttpRoute(options: {
|
|
7
|
+
readonly method: string;
|
|
8
|
+
readonly pathname: string;
|
|
9
|
+
readonly searchParams: URLSearchParams;
|
|
10
|
+
readonly body: Record<string, unknown>;
|
|
11
|
+
readonly store: ScopedStore;
|
|
12
|
+
readonly principal?: Principal;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
status: number;
|
|
15
|
+
data: unknown;
|
|
16
|
+
} | null>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP route handlers for `/api/v2/memory*` (Phase 9 R8-4).
|
|
3
|
+
*/
|
|
4
|
+
import { LOCAL_DEFAULT_PRINCIPAL } from '../auth/index.js';
|
|
5
|
+
import { recordMidSessionMemoryDelta } from './injector.js';
|
|
6
|
+
import { MemoryAccessDeniedError, MemoryBaseHashConflictError, MemoryStore, } from './store.js';
|
|
7
|
+
function parseScope(raw) {
|
|
8
|
+
if (raw === 'workspace' || raw === 'tenant')
|
|
9
|
+
return raw;
|
|
10
|
+
return 'user';
|
|
11
|
+
}
|
|
12
|
+
export async function handleMemoryHttpRoute(options) {
|
|
13
|
+
const { method, pathname, searchParams, body } = options;
|
|
14
|
+
if (!pathname.startsWith('/api/v2/memory'))
|
|
15
|
+
return null;
|
|
16
|
+
const principal = options.principal ?? LOCAL_DEFAULT_PRINCIPAL;
|
|
17
|
+
const memoryStore = new MemoryStore(options.store);
|
|
18
|
+
try {
|
|
19
|
+
if (pathname === '/api/v2/memory' && method === 'GET') {
|
|
20
|
+
const scope = parseScope(searchParams.get('scope'));
|
|
21
|
+
const scopeId = searchParams.get('scopeId') ?? undefined;
|
|
22
|
+
const permissionMode = await memoryStore.getPermissionMode();
|
|
23
|
+
const doc = await memoryStore.readDocument({ scope, scopeId, principal });
|
|
24
|
+
return {
|
|
25
|
+
status: 200,
|
|
26
|
+
data: {
|
|
27
|
+
permissionMode,
|
|
28
|
+
...doc,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (pathname === '/api/v2/memory' && method === 'PUT') {
|
|
33
|
+
if (body.permissionMode === 'off' ||
|
|
34
|
+
body.permissionMode === 'ask' ||
|
|
35
|
+
body.permissionMode === 'auto') {
|
|
36
|
+
await memoryStore.setPermissionMode(body.permissionMode);
|
|
37
|
+
if (body.contentMarkdown === undefined) {
|
|
38
|
+
return {
|
|
39
|
+
status: 200,
|
|
40
|
+
data: { permissionMode: body.permissionMode },
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const scope = parseScope(body.scope ?? searchParams.get('scope'));
|
|
45
|
+
const scopeId = typeof body.scopeId === 'string'
|
|
46
|
+
? body.scopeId
|
|
47
|
+
: searchParams.get('scopeId') ?? undefined;
|
|
48
|
+
const contentMarkdown = String(body.contentMarkdown ?? '');
|
|
49
|
+
const baseHash = typeof body.baseHash === 'string' ? body.baseHash : undefined;
|
|
50
|
+
const chatId = typeof body.chatId === 'string' ? body.chatId : undefined;
|
|
51
|
+
const saved = await memoryStore.writeDocument({
|
|
52
|
+
scope,
|
|
53
|
+
scopeId,
|
|
54
|
+
principal,
|
|
55
|
+
contentMarkdown,
|
|
56
|
+
baseHash,
|
|
57
|
+
sourceChatId: chatId ?? null,
|
|
58
|
+
isHumanEdit: true,
|
|
59
|
+
});
|
|
60
|
+
if (chatId) {
|
|
61
|
+
recordMidSessionMemoryDelta(chatId, `updated ${scope} MEMORY.md`);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
status: 200,
|
|
65
|
+
data: saved,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (pathname === '/api/v2/memory/propose' && method === 'POST') {
|
|
69
|
+
const scope = parseScope(body.scope);
|
|
70
|
+
const scopeId = typeof body.scopeId === 'string' ? body.scopeId : undefined;
|
|
71
|
+
const chatId = typeof body.chatId === 'string' ? body.chatId : 'local';
|
|
72
|
+
const turnId = typeof body.turnId === 'string' ? body.turnId : 'manual_turn';
|
|
73
|
+
const content = String(body.content ?? '').trim();
|
|
74
|
+
const res = await memoryStore.proposeRefinement({
|
|
75
|
+
scope,
|
|
76
|
+
scopeId,
|
|
77
|
+
principal,
|
|
78
|
+
content,
|
|
79
|
+
evidence: {
|
|
80
|
+
chatId,
|
|
81
|
+
turnId,
|
|
82
|
+
...(typeof body.toolCallId === 'string' ? { toolCallId: body.toolCallId } : {}),
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
if (res.accepted) {
|
|
86
|
+
recordMidSessionMemoryDelta(chatId, `saved ${scope} paragraph ${res.meta.id}`);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
status: 200,
|
|
90
|
+
data: res,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const refActionMatch = pathname.match(/^\/api\/v2\/memory\/refinements\/([^/]+)\/(renew|convert|withdraw)$/);
|
|
94
|
+
if (refActionMatch && method === 'POST') {
|
|
95
|
+
const refinementId = decodeURIComponent(refActionMatch[1]);
|
|
96
|
+
const action = refActionMatch[2];
|
|
97
|
+
const workspaceId = typeof body.workspaceId === 'string' ? body.workspaceId : undefined;
|
|
98
|
+
const chatId = typeof body.chatId === 'string' ? body.chatId : undefined;
|
|
99
|
+
let updated = null;
|
|
100
|
+
if (action === 'renew') {
|
|
101
|
+
updated = await memoryStore.renewRefinement({ refinementId, principal, workspaceId });
|
|
102
|
+
}
|
|
103
|
+
else if (action === 'convert') {
|
|
104
|
+
updated = await memoryStore.convertRefinementToOrdinary({
|
|
105
|
+
refinementId,
|
|
106
|
+
principal,
|
|
107
|
+
workspaceId,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
updated = await memoryStore.withdrawRefinement({
|
|
112
|
+
refinementId,
|
|
113
|
+
principal,
|
|
114
|
+
workspaceId,
|
|
115
|
+
});
|
|
116
|
+
if (updated && chatId) {
|
|
117
|
+
recordMidSessionMemoryDelta(chatId, `withdrawn paragraph ${refinementId}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (!updated)
|
|
121
|
+
return { status: 404, data: { detail: 'refinement not found' } };
|
|
122
|
+
return { status: 200, data: { refinement: updated } };
|
|
123
|
+
}
|
|
124
|
+
const revokedMatch = pathname.match(/^\/api\/v2\/memory\/revoked\/([^/]+)$/);
|
|
125
|
+
if (revokedMatch && method === 'DELETE') {
|
|
126
|
+
const hash = decodeURIComponent(revokedMatch[1]);
|
|
127
|
+
const scope = parseScope(searchParams.get('scope'));
|
|
128
|
+
const scopeId = searchParams.get('scopeId') ?? undefined;
|
|
129
|
+
const removed = await memoryStore.unrevokeHash({ scope, scopeId, hash, principal });
|
|
130
|
+
return { status: 200, data: { removed } };
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
if (err instanceof MemoryAccessDeniedError) {
|
|
136
|
+
return { status: 403, data: { code: err.code, detail: err.message } };
|
|
137
|
+
}
|
|
138
|
+
if (err instanceof MemoryBaseHashConflictError) {
|
|
139
|
+
return {
|
|
140
|
+
status: 409,
|
|
141
|
+
data: { code: err.code, currentHash: err.currentHash, detail: err.message },
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
throw err;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { type Principal } from '../auth/index.js';
|
|
2
|
+
import type { MemoryScopeKind } from '../storage/fde-types.js';
|
|
3
|
+
import type { ScopedStore } from '../storage/scoped-store.js';
|
|
4
|
+
export declare const MAX_MEMORY_INDEX_BYTES: number;
|
|
5
|
+
export declare const MAX_MEMORY_INDEX_LINES = 200;
|
|
6
|
+
export declare const MAX_MEMORY_TOPIC_BYTES: number;
|
|
7
|
+
export declare const MAX_MEMORY_TOTAL_BYTES: number;
|
|
8
|
+
export declare const TENANT_INJECT_BUDGET_BYTES: number;
|
|
9
|
+
export declare const WORKSPACE_INJECT_BUDGET_BYTES: number;
|
|
10
|
+
export declare const USER_INJECT_BUDGET_BYTES: number;
|
|
11
|
+
export declare const RSI_TTL_MS: number;
|
|
12
|
+
export declare const MEMORY_PERMISSION_SETTING_KEY = "memory_permission_mode";
|
|
13
|
+
export type MemoryPermissionMode = 'off' | 'ask' | 'auto';
|
|
14
|
+
export interface RefinementEvidence {
|
|
15
|
+
readonly chatId: string;
|
|
16
|
+
readonly turnId: string;
|
|
17
|
+
readonly toolCallId?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface RefinementParagraphMeta {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly normalizedHash: string;
|
|
22
|
+
readonly scope: MemoryScopeKind;
|
|
23
|
+
readonly scopeId: string;
|
|
24
|
+
readonly content: string;
|
|
25
|
+
readonly evidence: RefinementEvidence;
|
|
26
|
+
readonly humanEdited: boolean;
|
|
27
|
+
readonly status: 'active' | 'ordinary' | 'withdrawn';
|
|
28
|
+
readonly createdAt: string;
|
|
29
|
+
readonly expiresAt: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface MemoryConflictDraft {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly targetRefinementId: string;
|
|
34
|
+
readonly proposedContent: string;
|
|
35
|
+
readonly createdAt: string;
|
|
36
|
+
}
|
|
37
|
+
export declare class MemoryAccessDeniedError extends Error {
|
|
38
|
+
readonly status = 403;
|
|
39
|
+
readonly code = "memory_access_denied";
|
|
40
|
+
constructor(message: string);
|
|
41
|
+
}
|
|
42
|
+
export declare class MemoryBaseHashConflictError extends Error {
|
|
43
|
+
readonly status = 409;
|
|
44
|
+
readonly code = "MEMORY_BASE_HASH_CONFLICT";
|
|
45
|
+
readonly currentHash: string;
|
|
46
|
+
constructor(currentHash: string);
|
|
47
|
+
}
|
|
48
|
+
export declare function getHostMemoryRootDir(): string;
|
|
49
|
+
export declare function hashWorkspaceScopeId(workspacePathOrId: string): string;
|
|
50
|
+
export declare function sha256Text(text: string): string;
|
|
51
|
+
export declare function normalizeMemoryParagraphHash(raw: string): string;
|
|
52
|
+
export declare function extractRefinementBlocks(markdown: string): Map<string, string>;
|
|
53
|
+
export declare class MemoryStore {
|
|
54
|
+
private readonly store;
|
|
55
|
+
constructor(store: ScopedStore);
|
|
56
|
+
private get p9();
|
|
57
|
+
getPermissionMode(): Promise<MemoryPermissionMode>;
|
|
58
|
+
setPermissionMode(mode: MemoryPermissionMode): Promise<void>;
|
|
59
|
+
private metaKey;
|
|
60
|
+
private revokedKey;
|
|
61
|
+
private topicsKey;
|
|
62
|
+
private conflictsKey;
|
|
63
|
+
private loadMetaList;
|
|
64
|
+
private saveMetaList;
|
|
65
|
+
private loadRevokedSet;
|
|
66
|
+
private saveRevokedSet;
|
|
67
|
+
private loadTopicsMap;
|
|
68
|
+
private saveTopicsMap;
|
|
69
|
+
listConflicts(scope: MemoryScopeKind, requestedScopeId: string | undefined, principal?: Principal): Promise<MemoryConflictDraft[]>;
|
|
70
|
+
private appendConflict;
|
|
71
|
+
private mirrorToHostPrivateDisk;
|
|
72
|
+
readDocument(options: {
|
|
73
|
+
readonly scope: MemoryScopeKind;
|
|
74
|
+
readonly scopeId?: string;
|
|
75
|
+
readonly principal?: Principal;
|
|
76
|
+
}): Promise<{
|
|
77
|
+
readonly scope: MemoryScopeKind;
|
|
78
|
+
readonly scopeId: string;
|
|
79
|
+
readonly contentMarkdown: string;
|
|
80
|
+
readonly contentSha256: string;
|
|
81
|
+
readonly bytesUsed: number;
|
|
82
|
+
readonly maxBytes: number;
|
|
83
|
+
readonly linesUsed: number;
|
|
84
|
+
readonly maxLines: number;
|
|
85
|
+
readonly refinements: RefinementParagraphMeta[];
|
|
86
|
+
readonly revokedHashes: string[];
|
|
87
|
+
readonly topics: string[];
|
|
88
|
+
readonly conflicts: MemoryConflictDraft[];
|
|
89
|
+
}>;
|
|
90
|
+
writeDocument(options: {
|
|
91
|
+
readonly scope: MemoryScopeKind;
|
|
92
|
+
readonly scopeId?: string;
|
|
93
|
+
readonly principal?: Principal;
|
|
94
|
+
readonly contentMarkdown: string;
|
|
95
|
+
readonly baseHash?: string;
|
|
96
|
+
readonly sourceChatId?: string | null;
|
|
97
|
+
readonly isHumanEdit?: boolean;
|
|
98
|
+
}): Promise<{
|
|
99
|
+
readonly contentMarkdown: string;
|
|
100
|
+
readonly contentSha256: string;
|
|
101
|
+
readonly bytesUsed: number;
|
|
102
|
+
readonly linesUsed: number;
|
|
103
|
+
}>;
|
|
104
|
+
writeTopic(options: {
|
|
105
|
+
readonly scope: MemoryScopeKind;
|
|
106
|
+
readonly scopeId?: string;
|
|
107
|
+
readonly principal?: Principal;
|
|
108
|
+
readonly topicName: string;
|
|
109
|
+
readonly contentMarkdown: string;
|
|
110
|
+
}): Promise<void>;
|
|
111
|
+
readTopic(options: {
|
|
112
|
+
readonly scope: MemoryScopeKind;
|
|
113
|
+
readonly scopeId?: string;
|
|
114
|
+
readonly principal?: Principal;
|
|
115
|
+
readonly topicName: string;
|
|
116
|
+
}): Promise<string | null>;
|
|
117
|
+
search(options: {
|
|
118
|
+
readonly query: string;
|
|
119
|
+
readonly workspaceId?: string;
|
|
120
|
+
readonly principal?: Principal;
|
|
121
|
+
}): Promise<Array<{
|
|
122
|
+
scope: MemoryScopeKind;
|
|
123
|
+
source: string;
|
|
124
|
+
snippet: string;
|
|
125
|
+
}>>;
|
|
126
|
+
proposeRefinement(options: {
|
|
127
|
+
readonly id?: string;
|
|
128
|
+
readonly scope: MemoryScopeKind;
|
|
129
|
+
readonly scopeId?: string;
|
|
130
|
+
readonly principal?: Principal;
|
|
131
|
+
readonly content: string;
|
|
132
|
+
readonly evidence: RefinementEvidence;
|
|
133
|
+
readonly nowMs?: number;
|
|
134
|
+
}): Promise<{
|
|
135
|
+
readonly accepted: true;
|
|
136
|
+
readonly meta: RefinementParagraphMeta;
|
|
137
|
+
} | {
|
|
138
|
+
readonly accepted: false;
|
|
139
|
+
readonly reason: 'user_revoked' | 'human_edited_conflict';
|
|
140
|
+
readonly conflictDraft?: MemoryConflictDraft;
|
|
141
|
+
}>;
|
|
142
|
+
private findRefinementAcrossScopes;
|
|
143
|
+
renewRefinement(options: {
|
|
144
|
+
readonly refinementId: string;
|
|
145
|
+
readonly principal?: Principal;
|
|
146
|
+
readonly workspaceId?: string;
|
|
147
|
+
readonly nowMs?: number;
|
|
148
|
+
}): Promise<RefinementParagraphMeta | null>;
|
|
149
|
+
convertRefinementToOrdinary(options: {
|
|
150
|
+
readonly refinementId: string;
|
|
151
|
+
readonly principal?: Principal;
|
|
152
|
+
readonly workspaceId?: string;
|
|
153
|
+
}): Promise<RefinementParagraphMeta | null>;
|
|
154
|
+
withdrawRefinement(options: {
|
|
155
|
+
readonly refinementId: string;
|
|
156
|
+
readonly principal?: Principal;
|
|
157
|
+
readonly workspaceId?: string;
|
|
158
|
+
}): Promise<RefinementParagraphMeta | null>;
|
|
159
|
+
unrevokeHash(options: {
|
|
160
|
+
readonly scope: MemoryScopeKind;
|
|
161
|
+
readonly scopeId?: string;
|
|
162
|
+
readonly hash: string;
|
|
163
|
+
readonly principal?: Principal;
|
|
164
|
+
}): Promise<boolean>;
|
|
165
|
+
/**
|
|
166
|
+
* Renders active, non-expired, non-revoked markdown for a single scope within
|
|
167
|
+
* `budgetBytes`, preserving original source text on disk even when expired.
|
|
168
|
+
*/
|
|
169
|
+
renderVisibleMarkdownForScope(options: {
|
|
170
|
+
readonly scope: MemoryScopeKind;
|
|
171
|
+
readonly scopeId: string;
|
|
172
|
+
readonly principal: Principal;
|
|
173
|
+
readonly budgetBytes: number;
|
|
174
|
+
readonly nowMs?: number;
|
|
175
|
+
}): Promise<string>;
|
|
176
|
+
}
|