@peer-agent/protocol 0.1.0-rc.5 → 0.1.0-rc.51
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/acceptance-close-gate.d.ts +10 -1
- package/dist/acceptance-close-gate.js +12 -0
- package/dist/agent-supervision.d.ts +81 -0
- package/dist/agent-supervision.js +1 -0
- package/dist/attention.d.ts +44 -0
- package/dist/attention.js +1 -0
- package/dist/bot-access-policy.d.ts +29 -0
- package/dist/bot-access-policy.js +1 -0
- package/dist/bot-conversation-read.d.ts +67 -0
- package/dist/bot-conversation-read.js +9 -0
- package/dist/bot-direct-step.d.ts +11 -0
- package/dist/bot-direct-step.js +1 -0
- package/dist/bot-git.d.ts +55 -0
- package/dist/bot-git.js +1 -0
- package/dist/bot-model-selection.d.ts +13 -0
- package/dist/bot-model-selection.js +1 -0
- package/dist/browser-window.d.ts +48 -0
- package/dist/browser-window.js +23 -0
- package/dist/capability-admission.d.ts +20 -0
- package/dist/capability-admission.js +1 -0
- package/dist/compaction-history-selection.d.ts +15 -0
- package/dist/compaction-history-selection.js +30 -0
- package/dist/compaction.d.ts +5 -0
- package/dist/compaction.js +6 -0
- package/dist/context-accounting.d.ts +3 -0
- package/dist/conversation-execution.d.ts +68 -0
- package/dist/conversation-execution.js +222 -0
- package/dist/delegation-coordination.d.ts +81 -0
- package/dist/delegation-coordination.js +1 -0
- package/dist/delegation.d.ts +260 -7
- package/dist/delegation.js +97 -39
- package/dist/document-reference.d.ts +111 -0
- package/dist/document-reference.js +1 -0
- package/dist/evidence-inspection.d.ts +84 -0
- package/dist/evidence-inspection.js +1 -0
- package/dist/gemini-standard-pricing.json +105 -0
- package/dist/goal.d.ts +50 -2
- package/dist/group-chat.d.ts +87 -0
- package/dist/group-chat.js +1 -0
- package/dist/hook-observation.d.ts +2 -0
- package/dist/hook-observation.js +19 -0
- package/dist/index.d.ts +117 -25
- package/dist/index.js +41 -0
- package/dist/input-prediction.d.ts +86 -0
- package/dist/input-prediction.js +48 -0
- package/dist/intent-coordination.d.ts +201 -0
- package/dist/intent-coordination.js +1 -0
- package/dist/interactive-result.d.ts +363 -0
- package/dist/interactive-result.js +215 -0
- package/dist/interactive-verification.d.ts +41 -0
- package/dist/interactive-verification.js +65 -0
- package/dist/local-git.d.ts +44 -0
- package/dist/local-git.js +3 -0
- package/dist/local-image.d.ts +53 -0
- package/dist/local-image.js +5 -0
- package/dist/local-read.d.ts +9 -0
- package/dist/local-read.js +1 -0
- package/dist/memory.d.ts +117 -12
- package/dist/memory.js +12 -0
- package/dist/model-reasoning.d.ts +16 -0
- package/dist/model-reasoning.js +25 -0
- package/dist/model-routing.d.ts +39 -3
- package/dist/model-routing.js +31 -5
- package/dist/native-process.d.ts +21 -0
- package/dist/native-process.js +51 -0
- package/dist/parent-coordination.d.ts +104 -0
- package/dist/parent-coordination.js +2 -0
- package/dist/persistent-workspace.d.ts +519 -0
- package/dist/persistent-workspace.js +1 -0
- package/dist/project-agent-failure.d.ts +30 -0
- package/dist/project-agent-failure.js +44 -0
- package/dist/project-input-recovery.d.ts +83 -0
- package/dist/project-input-recovery.js +25 -0
- package/dist/project-matter.d.ts +359 -0
- package/dist/project-matter.js +1 -0
- package/dist/project-recovery.d.ts +43 -0
- package/dist/project-recovery.js +1 -0
- package/dist/project.d.ts +233 -0
- package/dist/project.js +134 -5
- package/dist/prompt-skill.d.ts +31 -0
- package/dist/prompt-skill.js +1 -0
- package/dist/quiet-reply.d.ts +9 -0
- package/dist/quiet-reply.js +43 -0
- package/dist/remote-access.d.ts +15 -0
- package/dist/remote-access.js +1 -1
- package/dist/reply-delivery.d.ts +28 -0
- package/dist/reply-delivery.js +1 -0
- package/dist/resource-edit-execution.d.ts +68 -0
- package/dist/resource-edit-execution.js +96 -0
- package/dist/resource-edit.d.ts +237 -0
- package/dist/resource-edit.js +134 -0
- package/dist/resource-feedback-transport.d.ts +26 -0
- package/dist/resource-feedback-transport.js +94 -0
- package/dist/resource-feedback.d.ts +110 -0
- package/dist/resource-feedback.js +168 -0
- package/dist/resource-file-replace.d.ts +36 -0
- package/dist/resource-file-replace.js +40 -0
- package/dist/resource-reference-hints.d.ts +3 -0
- package/dist/resource-reference-hints.js +58 -0
- package/dist/resource-window.d.ts +222 -0
- package/dist/resource-window.js +252 -0
- package/dist/routine.d.ts +82 -0
- package/dist/routine.js +1 -0
- package/dist/runtime-session-facts.d.ts +58 -0
- package/dist/runtime-session-facts.js +57 -0
- package/dist/session-control.d.ts +211 -0
- package/dist/session-control.js +48 -0
- package/dist/session-facts.d.ts +29 -0
- package/dist/session-facts.js +35 -0
- package/dist/skill-marketplace.d.ts +39 -4
- package/dist/spend-budget.d.ts +69 -0
- package/dist/spend-budget.js +1 -0
- package/dist/system-context.d.ts +7 -0
- package/dist/task-overview.d.ts +91 -0
- package/dist/task-overview.js +325 -17
- package/dist/tool-activity-preview.d.ts +4 -0
- package/dist/tool-activity-preview.js +72 -0
- package/dist/updater.d.ts +13 -3
- package/dist/usage-accounting.d.ts +42 -1
- package/dist/user-anchor.d.ts +17 -0
- package/dist/user-anchor.js +1 -0
- package/dist/work-coordination.d.ts +188 -0
- package/dist/work-coordination.js +1 -0
- package/dist/work-hook.d.ts +3 -0
- package/dist/work-hook.js +76 -0
- package/dist/working-plan.d.ts +18 -0
- package/dist/working-plan.js +1 -0
- package/dist/workspace.d.ts +35 -0
- package/dist/workspace.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
export const INTERACTIVE_PUBLISH_CAPABILITY = 'local.interactive.publish';
|
|
2
|
+
export const INTERACTIVE_INSPECT_CAPABILITY = 'local.interactive.inspect';
|
|
3
|
+
export const INTERACTIVE_PUBLISH_TOOL = 'publish_interactive_result';
|
|
4
|
+
export const INTERACTIVE_INSPECT_TOOL = 'inspect_interactive_result';
|
|
5
|
+
export const INTERACTIVE_RESULT_SCHEMA_VERSION = 1;
|
|
6
|
+
export const INTERACTIVE_RESULT_LIMITS = Object.freeze({
|
|
7
|
+
programBytes: 64 * 1024, fallbackBytes: 32 * 1024, inputBytes: 512 * 1024, bindings: 16,
|
|
8
|
+
astNodes: 1000, astDepth: 24, expandedNodes: 300, expandedDepth: 12, stateFields: 64,
|
|
9
|
+
stateBytes: 64 * 1024, collectionItems: 500, textChars: 8192, tablePageRows: 100,
|
|
10
|
+
tablePageCells: 1000, chartSeries: 6, chartPoints: 500, evaluationSteps: 40_000,
|
|
11
|
+
workerTimeoutMs: 2000, resultsPerBot: 256, storeBytes: 128 * 1024 * 1024,
|
|
12
|
+
manifestBytes: 2 * 1024 * 1024, contentRepairs: 2, localActionSteps: 16,
|
|
13
|
+
});
|
|
14
|
+
const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v)
|
|
15
|
+
&& [Object.prototype, null].includes(Object.getPrototypeOf(v))
|
|
16
|
+
&& Object.values(Object.getOwnPropertyDescriptors(v)).every(d => 'value' in d);
|
|
17
|
+
const keys = (v, allowed) => Object.keys(v).every(key => allowed.includes(key));
|
|
18
|
+
const safeKey = (v) => typeof v === 'string' && /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(v) && !['constructor', 'prototype', '__proto__'].includes(v);
|
|
19
|
+
export const interactiveBindingId = safeKey;
|
|
20
|
+
export const interactiveToken = (v) => typeof v === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,255}$/.test(v) && !v.includes('..');
|
|
21
|
+
export const interactiveDigest = (v) => typeof v === 'string' && /^sha256:[a-f0-9]{64}$/.test(v);
|
|
22
|
+
export function normalizeInteractiveMaterialNotice(raw) {
|
|
23
|
+
if (!object(raw) || !keys(raw, ['source', 'format', 'selectorRoots', 'dataLevel', 'truncated', 'redacted']) || !object(raw.source)
|
|
24
|
+
|| !interactiveDigest(raw.source.expectedContentVersion) || typeof raw.truncated !== 'boolean' || typeof raw.redacted !== 'boolean'
|
|
25
|
+
|| !['D0_public', 'D1_internal', 'D2_sensitive', 'D3_private', 'D4_regulated'].includes(raw.dataLevel))
|
|
26
|
+
return;
|
|
27
|
+
const source = raw.source;
|
|
28
|
+
let admitted;
|
|
29
|
+
if (source.kind === 'tool-result' && raw.format === 'peer-tool-observation-1' && keys(source, ['kind', 'conversationId', 'toolCallId', 'expectedContentVersion'])
|
|
30
|
+
&& interactiveToken(source.conversationId) && interactiveToken(source.toolCallId))
|
|
31
|
+
admitted = { kind: source.kind, conversationId: source.conversationId, toolCallId: source.toolCallId, expectedContentVersion: source.expectedContentVersion };
|
|
32
|
+
else if (source.kind === 'user-material' && raw.format === 'peer-user-upload-1' && keys(source, ['kind', 'messageId', 'attachmentId', 'expectedContentVersion'])
|
|
33
|
+
&& interactiveToken(source.messageId) && interactiveToken(source.attachmentId))
|
|
34
|
+
admitted = { kind: source.kind, messageId: source.messageId, attachmentId: source.attachmentId, expectedContentVersion: source.expectedContentVersion };
|
|
35
|
+
else
|
|
36
|
+
return;
|
|
37
|
+
const roots = raw.selectorRoots, allowed = source.kind === 'tool-result' ? ['payload', 'json'] : ['text', 'json'];
|
|
38
|
+
if (!Array.isArray(roots) || !roots.length || roots.length > 2 || roots.some(value => !allowed.includes(value)) || new Set(roots).size !== roots.length)
|
|
39
|
+
return;
|
|
40
|
+
return { source: admitted, format: raw.format, selectorRoots: [...roots],
|
|
41
|
+
dataLevel: raw.dataLevel, truncated: raw.truncated, redacted: raw.redacted };
|
|
42
|
+
}
|
|
43
|
+
const integer = (v, min = 0, max = Number.MAX_SAFE_INTEGER) => Number.isSafeInteger(v) && Number(v) >= min && Number(v) <= max;
|
|
44
|
+
const bytes = (v) => new TextEncoder().encode(v).byteLength;
|
|
45
|
+
const text = (v, max) => typeof v === 'string' && !!v.trim() && !v.includes('\0') && bytes(v) <= max;
|
|
46
|
+
export function normalizeInteractiveOwner(raw) {
|
|
47
|
+
if (!object(raw) || !keys(raw, ['workspaceId', 'conversationId']) || !interactiveToken(raw.workspaceId) || !interactiveToken(raw.conversationId))
|
|
48
|
+
return;
|
|
49
|
+
return { workspaceId: raw.workspaceId, conversationId: raw.conversationId };
|
|
50
|
+
}
|
|
51
|
+
export function normalizeInteractiveReference(raw) {
|
|
52
|
+
if (!object(raw) || !keys(raw, ['owner', 'resultId', 'contentVersion']) || !interactiveToken(raw.resultId) || !interactiveDigest(raw.contentVersion))
|
|
53
|
+
return;
|
|
54
|
+
const owner = normalizeInteractiveOwner(raw.owner);
|
|
55
|
+
return owner ? { owner, resultId: raw.resultId, contentVersion: raw.contentVersion } : undefined;
|
|
56
|
+
}
|
|
57
|
+
/** Syntax and budget only. The host must match the actual immutable freeze receipt. */
|
|
58
|
+
export function normalizeInteractiveFollowup(raw) {
|
|
59
|
+
if (!object(raw) || !keys(raw, ['followupId', 'recipient', 'result', 'specHash', 'stateRevision', 'stateDigest', 'selectionDigest', 'values', 'dataLevel', 'capturedAt', 'excerpt'])
|
|
60
|
+
|| !interactiveToken(raw.followupId) || !interactiveDigest(raw.specHash) || !interactiveDigest(raw.stateDigest) || !interactiveDigest(raw.selectionDigest)
|
|
61
|
+
|| !integer(raw.stateRevision) || !object(raw.values) || !Object.keys(raw.values).length || Object.keys(raw.values).length > INTERACTIVE_RESULT_LIMITS.stateFields
|
|
62
|
+
|| Object.entries(raw.values).some(([key, value]) => !/^\$[A-Za-z_][A-Za-z0-9_]{0,63}$/.test(key)
|
|
63
|
+
|| !(typeof value === 'string' && value.length <= INTERACTIVE_RESULT_LIMITS.textChars && !value.includes('\0') || typeof value === 'boolean' || typeof value === 'number' && Number.isFinite(value)))
|
|
64
|
+
|| !['D0_public', 'D1_internal', 'D2_sensitive', 'D3_private', 'D4_regulated'].includes(raw.dataLevel)
|
|
65
|
+
|| typeof raw.capturedAt !== 'string' || raw.capturedAt.length > 40 || !Number.isFinite(Date.parse(raw.capturedAt)) || !text(raw.excerpt, 8192))
|
|
66
|
+
return;
|
|
67
|
+
const recipient = normalizeInteractiveOwner(raw.recipient), result = normalizeInteractiveReference(raw.result);
|
|
68
|
+
if (!recipient || !result || recipient.workspaceId !== result.owner.workspaceId || recipient.conversationId !== result.owner.conversationId)
|
|
69
|
+
return;
|
|
70
|
+
const value = { followupId: raw.followupId, recipient, result, specHash: raw.specHash, stateRevision: raw.stateRevision,
|
|
71
|
+
stateDigest: raw.stateDigest, selectionDigest: raw.selectionDigest, values: Object.fromEntries(Object.entries(raw.values).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)),
|
|
72
|
+
dataLevel: raw.dataLevel, capturedAt: new Date(raw.capturedAt).toISOString(), excerpt: raw.excerpt };
|
|
73
|
+
return bytes(JSON.stringify(value)) <= 32 * 1024 ? value : undefined;
|
|
74
|
+
}
|
|
75
|
+
export function normalizeInteractiveViewHandle(raw) {
|
|
76
|
+
if (!object(raw) || !keys(raw, ['viewId', 'windowId', 'generation']) || !interactiveToken(raw.viewId)
|
|
77
|
+
|| !interactiveToken(raw.windowId) || !interactiveToken(raw.generation))
|
|
78
|
+
return;
|
|
79
|
+
return { viewId: raw.viewId, windowId: raw.windowId, generation: raw.generation };
|
|
80
|
+
}
|
|
81
|
+
export function normalizeInteractiveWriter(raw) {
|
|
82
|
+
if (!object(raw) || !keys(raw, ['viewId', 'generation', 'token']) || !interactiveToken(raw.viewId)
|
|
83
|
+
|| !interactiveToken(raw.generation) || !interactiveToken(raw.token))
|
|
84
|
+
return;
|
|
85
|
+
return { viewId: raw.viewId, generation: raw.generation, token: raw.token };
|
|
86
|
+
}
|
|
87
|
+
export function normalizeInteractivePublicationReference(raw) {
|
|
88
|
+
if (!object(raw) || !keys(raw, ['owner', 'conversationId', 'toolCallId']) || !interactiveToken(raw.conversationId) || !interactiveToken(raw.toolCallId))
|
|
89
|
+
return;
|
|
90
|
+
const owner = normalizeInteractiveOwner(raw.owner);
|
|
91
|
+
return owner ? { owner, conversationId: raw.conversationId, toolCallId: raw.toolCallId } : undefined;
|
|
92
|
+
}
|
|
93
|
+
export function normalizeInteractiveSelector(raw) {
|
|
94
|
+
if (!object(raw) || !keys(raw, ['path', 'fields', 'start', 'limit']))
|
|
95
|
+
return;
|
|
96
|
+
for (const field of ['path', 'fields'])
|
|
97
|
+
if (raw[field] !== undefined && (!Array.isArray(raw[field]) || raw[field].length > (field === 'path' ? 8 : 32)
|
|
98
|
+
|| !raw[field].every(safeKey) || new Set(raw[field]).size !== raw[field].length))
|
|
99
|
+
return;
|
|
100
|
+
if (raw.start !== undefined && !integer(raw.start, 0, 500) || raw.limit !== undefined && !integer(raw.limit, 1, 500))
|
|
101
|
+
return;
|
|
102
|
+
return { ...(raw.path ? { path: [...raw.path] } : {}), ...(raw.fields ? { fields: [...raw.fields] } : {}),
|
|
103
|
+
...(raw.start !== undefined ? { start: raw.start } : {}), ...(raw.limit !== undefined ? { limit: raw.limit } : {}) };
|
|
104
|
+
}
|
|
105
|
+
function jsonValue(raw, depth = 0, active = new Set(), budget = { nodes: 0 }) {
|
|
106
|
+
if (depth > 16 || ++budget.nodes > INTERACTIVE_RESULT_LIMITS.evaluationSteps)
|
|
107
|
+
return false;
|
|
108
|
+
if (raw === null || typeof raw === 'boolean' || typeof raw === 'string' && raw.length <= 8192 || typeof raw === 'number' && Number.isFinite(raw))
|
|
109
|
+
return true;
|
|
110
|
+
if (!raw || typeof raw !== 'object' || active.has(raw))
|
|
111
|
+
return false;
|
|
112
|
+
active.add(raw);
|
|
113
|
+
const valid = Array.isArray(raw) ? raw.length <= 500 && raw.every(value => jsonValue(value, depth + 1, active, budget))
|
|
114
|
+
: object(raw) && Object.keys(raw).length <= 500 && Object.entries(raw).every(([key, value]) => !['__proto__', 'constructor', 'prototype'].includes(key) && jsonValue(value, depth + 1, active, budget));
|
|
115
|
+
active.delete(raw);
|
|
116
|
+
return valid;
|
|
117
|
+
}
|
|
118
|
+
export function normalizeInteractiveDraft(raw) {
|
|
119
|
+
if (!object(raw) || !keys(raw, ['publication', 'title', 'textFallback', 'program', 'inputs'])
|
|
120
|
+
|| !text(raw.title, 640) || raw.title.length > 160 || !text(raw.textFallback, INTERACTIVE_RESULT_LIMITS.fallbackBytes)
|
|
121
|
+
|| !text(raw.program, INTERACTIVE_RESULT_LIMITS.programBytes) || !object(raw.publication)
|
|
122
|
+
|| !Array.isArray(raw.inputs) || raw.inputs.length > INTERACTIVE_RESULT_LIMITS.bindings)
|
|
123
|
+
return;
|
|
124
|
+
let publication;
|
|
125
|
+
if (raw.publication.kind === 'create' && keys(raw.publication, ['kind']))
|
|
126
|
+
publication = { kind: 'create' };
|
|
127
|
+
else if (raw.publication.kind === 'revise' && keys(raw.publication, ['kind', 'base'])) {
|
|
128
|
+
const base = normalizeInteractiveReference(raw.publication.base);
|
|
129
|
+
if (!base)
|
|
130
|
+
return;
|
|
131
|
+
publication = { kind: 'revise', base };
|
|
132
|
+
}
|
|
133
|
+
else
|
|
134
|
+
return;
|
|
135
|
+
const inputs = [];
|
|
136
|
+
for (const binding of raw.inputs) {
|
|
137
|
+
if (!object(binding) || !keys(binding, ['bindingId', 'source', 'selector']) || !safeKey(binding.bindingId) || !object(binding.source))
|
|
138
|
+
return;
|
|
139
|
+
const s = binding.source;
|
|
140
|
+
let source;
|
|
141
|
+
if (s.kind === 'tool-result' && keys(s, ['kind', 'conversationId', 'toolCallId', 'expectedContentVersion'])
|
|
142
|
+
&& interactiveToken(s.conversationId) && interactiveToken(s.toolCallId) && interactiveDigest(s.expectedContentVersion)) {
|
|
143
|
+
source = { kind: 'tool-result', conversationId: s.conversationId, toolCallId: s.toolCallId, expectedContentVersion: s.expectedContentVersion };
|
|
144
|
+
}
|
|
145
|
+
else if (s.kind === 'user-material' && keys(s, ['kind', 'messageId', 'attachmentId', 'expectedContentVersion'])
|
|
146
|
+
&& interactiveToken(s.messageId) && interactiveToken(s.attachmentId) && interactiveDigest(s.expectedContentVersion)) {
|
|
147
|
+
source = { kind: 'user-material', messageId: s.messageId, attachmentId: s.attachmentId, expectedContentVersion: s.expectedContentVersion };
|
|
148
|
+
}
|
|
149
|
+
else if (s.kind === 'model-data' && keys(s, ['kind', 'value']) && jsonValue(s.value)) {
|
|
150
|
+
source = { kind: 'model-data', value: JSON.parse(JSON.stringify(s.value)) };
|
|
151
|
+
}
|
|
152
|
+
else
|
|
153
|
+
return;
|
|
154
|
+
const selector = binding.selector === undefined ? undefined : normalizeInteractiveSelector(binding.selector);
|
|
155
|
+
if (binding.selector !== undefined && !selector)
|
|
156
|
+
return;
|
|
157
|
+
inputs.push({ bindingId: binding.bindingId, source, ...(selector ? { selector } : {}) });
|
|
158
|
+
}
|
|
159
|
+
if (new Set(inputs.map(row => row.bindingId)).size !== inputs.length || bytes(JSON.stringify(inputs)) > INTERACTIVE_RESULT_LIMITS.inputBytes)
|
|
160
|
+
return;
|
|
161
|
+
return { publication, title: raw.title.trim(), textFallback: raw.textFallback, program: raw.program, inputs };
|
|
162
|
+
}
|
|
163
|
+
export function normalizeInteractiveInspect(raw) {
|
|
164
|
+
if (!object(raw) || !keys(raw, ['target', 'view', 'bindingId', 'selector', 'followupId', 'offset', 'limit']) || !object(raw.target)
|
|
165
|
+
|| !keys(raw.target, ['kind', 'reference']) || !['metadata', 'text', 'program', 'data', 'evaluate'].includes(raw.view))
|
|
166
|
+
return;
|
|
167
|
+
let target;
|
|
168
|
+
if (raw.target.kind === 'result') {
|
|
169
|
+
const reference = normalizeInteractiveReference(raw.target.reference);
|
|
170
|
+
if (!reference)
|
|
171
|
+
return;
|
|
172
|
+
target = { kind: 'result', reference };
|
|
173
|
+
}
|
|
174
|
+
else if (raw.target.kind === 'publication') {
|
|
175
|
+
const reference = normalizeInteractivePublicationReference(raw.target.reference);
|
|
176
|
+
if (!reference || raw.view !== 'metadata')
|
|
177
|
+
return;
|
|
178
|
+
target = { kind: 'publication', reference };
|
|
179
|
+
}
|
|
180
|
+
else
|
|
181
|
+
return;
|
|
182
|
+
if (raw.bindingId !== undefined && (!safeKey(raw.bindingId) || raw.view !== 'data') || raw.view === 'data' && !safeKey(raw.bindingId)
|
|
183
|
+
|| raw.followupId !== undefined && (!interactiveToken(raw.followupId) || raw.view !== 'evaluate')
|
|
184
|
+
|| raw.offset !== undefined && !integer(raw.offset, 0, INTERACTIVE_RESULT_LIMITS.inputBytes)
|
|
185
|
+
|| raw.limit !== undefined && !integer(raw.limit, 1, 4000))
|
|
186
|
+
return;
|
|
187
|
+
const selector = raw.selector === undefined ? undefined : normalizeInteractiveSelector(raw.selector);
|
|
188
|
+
if (raw.selector !== undefined && (!selector || raw.view !== 'data'))
|
|
189
|
+
return;
|
|
190
|
+
return { target, view: raw.view, ...(raw.bindingId ? { bindingId: raw.bindingId } : {}),
|
|
191
|
+
...(selector ? { selector } : {}), ...(raw.followupId ? { followupId: raw.followupId } : {}),
|
|
192
|
+
...(raw.offset !== undefined ? { offset: raw.offset } : {}), ...(raw.limit !== undefined ? { limit: raw.limit } : {}) };
|
|
193
|
+
}
|
|
194
|
+
/** An opaque, version-pinned locator. Hosts must revalidate the canonical publication receipt. */
|
|
195
|
+
export function interactiveArtifactRef(ref) {
|
|
196
|
+
const value = normalizeInteractiveReference(ref);
|
|
197
|
+
if (!value)
|
|
198
|
+
throw new TypeError('invalid_interactive_reference');
|
|
199
|
+
return `interactive-result://${value.owner.workspaceId}/${value.owner.conversationId}/${value.resultId}/${value.contentVersion.slice(7)}`;
|
|
200
|
+
}
|
|
201
|
+
export function parseInteractiveArtifactRef(raw) {
|
|
202
|
+
if (typeof raw !== 'string' || raw.length > 1024)
|
|
203
|
+
return;
|
|
204
|
+
const match = /^interactive-result:\/\/([^/]+)\/([^/]+)\/([^/]+)\/([a-f0-9]{64})$/.exec(raw);
|
|
205
|
+
return match ? normalizeInteractiveReference({ owner: { workspaceId: match[1], conversationId: match[2] }, resultId: match[3], contentVersion: `sha256:${match[4]}` }) : undefined;
|
|
206
|
+
}
|
|
207
|
+
export function normalizeInteractiveUserArtifact(raw) {
|
|
208
|
+
if (!object(raw) || !keys(raw, ['kind', 'ref', 'label', 'reference', 'specHash']) || raw.kind !== 'interactive'
|
|
209
|
+
|| !text(raw.label, 640) || raw.label.length > 160 || !interactiveDigest(raw.specHash))
|
|
210
|
+
return;
|
|
211
|
+
const reference = normalizeInteractiveReference(raw.reference);
|
|
212
|
+
if (!reference || raw.ref !== interactiveArtifactRef(reference))
|
|
213
|
+
return;
|
|
214
|
+
return { kind: 'interactive', ref: raw.ref, label: raw.label, reference, specHash: raw.specHash };
|
|
215
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type InteractiveInspectRequest, type InteractiveOwner } from './interactive-result.ts';
|
|
2
|
+
import { type SessionExecutionIdentity } from './session-control.ts';
|
|
3
|
+
/** Opaque host-only lifetime binding; never model context or execution permission. */
|
|
4
|
+
export interface InteractiveReviewBinding {
|
|
5
|
+
readonly token: string;
|
|
6
|
+
}
|
|
7
|
+
export interface InteractiveInspectionReceipt {
|
|
8
|
+
readonly schemaVersion: 1;
|
|
9
|
+
readonly evidenceId: string;
|
|
10
|
+
readonly owner: InteractiveOwner;
|
|
11
|
+
readonly execution: SessionExecutionIdentity;
|
|
12
|
+
readonly conversationId: string;
|
|
13
|
+
readonly toolCallId: string;
|
|
14
|
+
readonly specHash: string;
|
|
15
|
+
readonly request: InteractiveInspectRequest;
|
|
16
|
+
readonly review: {
|
|
17
|
+
readonly verifierRunId: string;
|
|
18
|
+
readonly sourceRevision: string;
|
|
19
|
+
readonly targetsDigest: string;
|
|
20
|
+
};
|
|
21
|
+
readonly range?: {
|
|
22
|
+
readonly offset: number;
|
|
23
|
+
readonly returned: number;
|
|
24
|
+
readonly total: number;
|
|
25
|
+
readonly truncated: boolean;
|
|
26
|
+
};
|
|
27
|
+
readonly stateSource?: {
|
|
28
|
+
readonly kind: 'initial' | 'frozen-followup';
|
|
29
|
+
readonly stateDigest: string;
|
|
30
|
+
readonly followupId?: string;
|
|
31
|
+
readonly stateRevision?: number;
|
|
32
|
+
readonly selectionDigest?: string;
|
|
33
|
+
};
|
|
34
|
+
readonly computationTruncated?: boolean;
|
|
35
|
+
readonly outputDigest: string;
|
|
36
|
+
readonly observedAt: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function normalizeInteractiveReviewBinding(raw: unknown): InteractiveReviewBinding | undefined;
|
|
39
|
+
export declare function interactiveInspectionEvidenceRef(evidenceId: string): string;
|
|
40
|
+
export declare function isInteractiveInspectionEvidenceRef(raw: unknown): raw is string;
|
|
41
|
+
export declare function normalizeInteractiveInspectionReceipt(raw: unknown): InteractiveInspectionReceipt | undefined;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { interactiveDigest, interactiveToken, normalizeInteractiveInspect, normalizeInteractiveOwner } from "./interactive-result.js";
|
|
2
|
+
import { normalizeSessionExecutionIdentity } from "./session-control.js";
|
|
3
|
+
const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v)
|
|
4
|
+
&& [Object.prototype, null].includes(Object.getPrototypeOf(v)) && Object.values(Object.getOwnPropertyDescriptors(v)).every(d => 'value' in d);
|
|
5
|
+
const keys = (v, allowed) => Object.keys(v).every(key => allowed.includes(key));
|
|
6
|
+
const integer = (v) => Number.isSafeInteger(v) && Number(v) >= 0 && Number(v) <= 512 * 1024;
|
|
7
|
+
export function normalizeInteractiveReviewBinding(raw) {
|
|
8
|
+
return object(raw) && keys(raw, ['token']) && interactiveToken(raw.token) ? { token: raw.token } : undefined;
|
|
9
|
+
}
|
|
10
|
+
const INSPECTION_REF_PREFIX = 'interactive-inspection://';
|
|
11
|
+
export function interactiveInspectionEvidenceRef(evidenceId) {
|
|
12
|
+
if (!interactiveToken(evidenceId))
|
|
13
|
+
throw TypeError('invalid inspection evidence ID');
|
|
14
|
+
return `${INSPECTION_REF_PREFIX}${evidenceId}`;
|
|
15
|
+
}
|
|
16
|
+
export function isInteractiveInspectionEvidenceRef(raw) {
|
|
17
|
+
return typeof raw === 'string' && raw.startsWith(INSPECTION_REF_PREFIX) && interactiveToken(raw.slice(INSPECTION_REF_PREFIX.length));
|
|
18
|
+
}
|
|
19
|
+
export function normalizeInteractiveInspectionReceipt(raw) {
|
|
20
|
+
if (!object(raw) || !keys(raw, ['schemaVersion', 'evidenceId', 'owner', 'execution', 'conversationId', 'toolCallId', 'specHash', 'request', 'review', 'range', 'stateSource', 'computationTruncated', 'outputDigest', 'observedAt'])
|
|
21
|
+
|| raw.schemaVersion !== 1 || !interactiveToken(raw.evidenceId) || !interactiveToken(raw.conversationId) || !interactiveToken(raw.toolCallId)
|
|
22
|
+
|| !interactiveDigest(raw.specHash) || !interactiveDigest(raw.outputDigest) || typeof raw.observedAt !== 'string' || raw.observedAt.length > 40 || !Number.isFinite(Date.parse(raw.observedAt))
|
|
23
|
+
|| !object(raw.review) || !keys(raw.review, ['verifierRunId', 'sourceRevision', 'targetsDigest']) || !interactiveToken(raw.review.verifierRunId)
|
|
24
|
+
|| typeof raw.review.sourceRevision !== 'string' || !/^[a-f0-9]{64}$/.test(raw.review.sourceRevision) || !interactiveDigest(raw.review.targetsDigest)
|
|
25
|
+
|| raw.computationTruncated !== undefined && typeof raw.computationTruncated !== 'boolean')
|
|
26
|
+
return;
|
|
27
|
+
const owner = normalizeInteractiveOwner(raw.owner), execution = normalizeSessionExecutionIdentity(raw.execution), request = normalizeInteractiveInspect(raw.request);
|
|
28
|
+
if (!owner || !execution || !request || request.target.kind !== 'result'
|
|
29
|
+
|| owner.workspaceId !== request.target.reference.owner.workspaceId || owner.conversationId !== request.target.reference.owner.conversationId)
|
|
30
|
+
return;
|
|
31
|
+
let range;
|
|
32
|
+
if (raw.range !== undefined) {
|
|
33
|
+
const r = raw.range;
|
|
34
|
+
if (!object(r) || !keys(r, ['offset', 'returned', 'total', 'truncated']) || ![r.offset, r.returned, r.total].every(integer)
|
|
35
|
+
|| Number(r.returned) > (request.limit ?? 4000) || Number(r.offset) + Number(r.returned) > Number(r.total) || typeof r.truncated !== 'boolean'
|
|
36
|
+
|| r.offset !== (request.offset ?? 0) || r.truncated !== (Number(r.offset) + Number(r.returned) < Number(r.total)))
|
|
37
|
+
return;
|
|
38
|
+
range = { offset: Number(r.offset), returned: Number(r.returned), total: Number(r.total), truncated: r.truncated };
|
|
39
|
+
}
|
|
40
|
+
if ((request.view === 'metadata') === !!range)
|
|
41
|
+
return;
|
|
42
|
+
let stateSource;
|
|
43
|
+
if (raw.stateSource !== undefined) {
|
|
44
|
+
const s = raw.stateSource;
|
|
45
|
+
if (!object(s) || !keys(s, ['kind', 'stateDigest', 'followupId', 'stateRevision', 'selectionDigest']) || !interactiveDigest(s.stateDigest))
|
|
46
|
+
return;
|
|
47
|
+
if (s.kind === 'initial' && keys(s, ['kind', 'stateDigest']) && request.followupId === undefined)
|
|
48
|
+
stateSource = { kind: 'initial', stateDigest: s.stateDigest };
|
|
49
|
+
else if (s.kind === 'frozen-followup' && interactiveToken(s.followupId) && s.followupId === request.followupId
|
|
50
|
+
&& Number.isSafeInteger(s.stateRevision) && Number(s.stateRevision) >= 0 && interactiveDigest(s.selectionDigest))
|
|
51
|
+
stateSource = {
|
|
52
|
+
kind: 'frozen-followup', followupId: s.followupId, stateRevision: Number(s.stateRevision), stateDigest: s.stateDigest, selectionDigest: s.selectionDigest
|
|
53
|
+
};
|
|
54
|
+
else
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if ((request.view === 'evaluate') !== !!stateSource || (request.view === 'evaluate'
|
|
58
|
+
? typeof raw.computationTruncated !== 'boolean' : raw.computationTruncated !== undefined))
|
|
59
|
+
return;
|
|
60
|
+
const result = { schemaVersion: 1, evidenceId: raw.evidenceId, owner, execution, conversationId: raw.conversationId,
|
|
61
|
+
toolCallId: raw.toolCallId, specHash: raw.specHash, request, review: { verifierRunId: raw.review.verifierRunId,
|
|
62
|
+
sourceRevision: raw.review.sourceRevision, targetsDigest: raw.review.targetsDigest }, ...(range ? { range } : {}), ...(stateSource ? { stateSource } : {}),
|
|
63
|
+
...(raw.computationTruncated !== undefined ? { computationTruncated: raw.computationTruncated } : {}), outputDigest: raw.outputDigest, observedAt: new Date(raw.observedAt).toISOString() };
|
|
64
|
+
return new TextEncoder().encode(JSON.stringify(result)).byteLength <= 16 * 1024 ? result : undefined;
|
|
65
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** ADR106: bounded repository observations; never arbitrary commands. */
|
|
2
|
+
export declare const LOCAL_GIT_CAPABILITY: "local.git.query";
|
|
3
|
+
export declare const LOCAL_GIT_TOOL: "git_query";
|
|
4
|
+
export type GitReadOperation = 'snapshot' | 'status' | 'log';
|
|
5
|
+
export interface GitReadQuery {
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly operation?: GitReadOperation;
|
|
8
|
+
readonly limit?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface GitReadObservation {
|
|
11
|
+
readonly repositoryPath: string;
|
|
12
|
+
readonly gitDirectory: string;
|
|
13
|
+
readonly commonDirectory: string;
|
|
14
|
+
readonly configurationSources: readonly string[];
|
|
15
|
+
readonly operation: GitReadOperation;
|
|
16
|
+
readonly startedAt: string;
|
|
17
|
+
readonly finishedAt: string;
|
|
18
|
+
readonly head: string | null;
|
|
19
|
+
readonly branch: string | null;
|
|
20
|
+
readonly unborn: boolean;
|
|
21
|
+
readonly origin: readonly string[];
|
|
22
|
+
readonly consistent: boolean;
|
|
23
|
+
readonly atomic: false;
|
|
24
|
+
readonly status?: {
|
|
25
|
+
readonly clean: boolean | null;
|
|
26
|
+
readonly submoduleCount: number;
|
|
27
|
+
readonly submodulesInspected: false;
|
|
28
|
+
readonly filtersDisabled: boolean;
|
|
29
|
+
readonly changed: number;
|
|
30
|
+
readonly untracked: number;
|
|
31
|
+
readonly entries: readonly {
|
|
32
|
+
readonly index: string;
|
|
33
|
+
readonly worktree: string;
|
|
34
|
+
readonly path: string;
|
|
35
|
+
readonly from?: string;
|
|
36
|
+
}[];
|
|
37
|
+
readonly truncated: boolean;
|
|
38
|
+
};
|
|
39
|
+
readonly commits: readonly {
|
|
40
|
+
readonly hash: string;
|
|
41
|
+
readonly committedAt: string;
|
|
42
|
+
readonly subject: string;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** ADR 90: local images are factual context, never instructions or persisted pixels. */
|
|
2
|
+
export declare const LOCAL_IMAGE_CAPABILITY: "local.image.read";
|
|
3
|
+
export declare const LOCAL_IMAGE_TOOL: "view_image";
|
|
4
|
+
export declare const LOCAL_IMAGE_MAX_BYTES: number;
|
|
5
|
+
export declare const LOCAL_IMAGE_MAX_PIXELS = 24000000;
|
|
6
|
+
export type LocalImageMediaType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp';
|
|
7
|
+
export interface LocalImageMetadata {
|
|
8
|
+
path: string;
|
|
9
|
+
mediaType: LocalImageMediaType;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
byteLength: number;
|
|
13
|
+
sha256: string;
|
|
14
|
+
artifactRef: string;
|
|
15
|
+
}
|
|
16
|
+
/** Ephemeral host sideband. Object identity must also be validated by its Provider. */
|
|
17
|
+
export interface LocalImageObservation extends LocalImageMetadata {
|
|
18
|
+
kind: 'local_image';
|
|
19
|
+
dataUrl: string;
|
|
20
|
+
}
|
|
21
|
+
import type { ClientToolResult, PermissionGrant } from './index.ts';
|
|
22
|
+
export interface LocalImagePermissionScope {
|
|
23
|
+
capabilityId: typeof LOCAL_IMAGE_CAPABILITY;
|
|
24
|
+
path: string;
|
|
25
|
+
workspacePath: string | null;
|
|
26
|
+
action: 'read_image_for_model';
|
|
27
|
+
fileIdentity?: {
|
|
28
|
+
dev: number;
|
|
29
|
+
ino: number;
|
|
30
|
+
size: number;
|
|
31
|
+
mtimeMs: number;
|
|
32
|
+
ctimeMs: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Local host-issued exact-image read authority; no pixels are persisted. */
|
|
36
|
+
export interface ImageReadGrant {
|
|
37
|
+
policyRevision?: string;
|
|
38
|
+
schemaVersion: 1;
|
|
39
|
+
grantId: string;
|
|
40
|
+
workspaceId: string | null;
|
|
41
|
+
conversationId: string;
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
scope: LocalImagePermissionScope;
|
|
44
|
+
}
|
|
45
|
+
/** Concrete image grant; legacy grant scopes remain unchanged. */
|
|
46
|
+
export interface LocalImagePermissionGrant extends PermissionGrant {
|
|
47
|
+
scope: LocalImagePermissionScope | typeof LOCAL_IMAGE_CAPABILITY;
|
|
48
|
+
}
|
|
49
|
+
export interface LocalImageToolResult extends ClientToolResult {
|
|
50
|
+
modelContext?: {
|
|
51
|
+
visualObservations: readonly LocalImageObservation[];
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** ADR 90: local images are factual context, never instructions or persisted pixels. */
|
|
2
|
+
export const LOCAL_IMAGE_CAPABILITY = 'local.image.read';
|
|
3
|
+
export const LOCAL_IMAGE_TOOL = 'view_image';
|
|
4
|
+
export const LOCAL_IMAGE_MAX_BYTES = 8 * 1024 * 1024;
|
|
5
|
+
export const LOCAL_IMAGE_MAX_PIXELS = 24_000_000;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** ADR106/131: the existing Git Provider's concrete local read approval shape.
|
|
2
|
+
* This is an audit scope, never a deserializable execution authority token.
|
|
3
|
+
*/
|
|
4
|
+
export interface LocalReadPermissionScope {
|
|
5
|
+
readonly kind: 'file-read';
|
|
6
|
+
readonly capabilityId: string;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly workspacePath: string | null;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/memory.d.ts
CHANGED
|
@@ -2,9 +2,45 @@
|
|
|
2
2
|
* Project memory contracts. Entries are facts for continuity, not instructions.
|
|
3
3
|
*/
|
|
4
4
|
import type { MessageDisposition } from './delegation.ts';
|
|
5
|
-
export type MemoryKind = 'fact' | 'preference' | 'decision' | 'procedure' | 'responsibility';
|
|
5
|
+
export type MemoryKind = 'fact' | 'preference' | 'decision' | 'procedure' | 'responsibility' | 'project_preference' | 'user_preference' | 'user_profile' | 'cross_project_rule';
|
|
6
6
|
export type MemoryTrust = 'verified' | 'stated' | 'inferred';
|
|
7
|
-
export type MemoryStatus = 'active' | '
|
|
7
|
+
export type MemoryStatus = 'active' | 'needs_reverify' | 'conflicted' | 'quarantined' | 'archived';
|
|
8
|
+
export type LegacyMemoryStatus = Extract<MemoryStatus, 'active' | 'conflicted'> | 'forgotten' | 'expired';
|
|
9
|
+
export type MemoryScopeKey = 'global' | `project:${string}`;
|
|
10
|
+
export type MemoryRevision = string;
|
|
11
|
+
export declare function isMemoryScopeKey(value: unknown): value is MemoryScopeKey;
|
|
12
|
+
export declare function isMemoryRevision(value: unknown): value is MemoryRevision;
|
|
13
|
+
export interface MemoryRef {
|
|
14
|
+
readonly scopeKey: MemoryScopeKey;
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly revision: MemoryRevision;
|
|
17
|
+
}
|
|
18
|
+
export type MemorySourceKind = 'user_message_span' | 'local_user_edit' | 'independent_verification' | 'workspace_file' | 'web' | 'attachment' | 'mcp' | 'model' | 'unknown';
|
|
19
|
+
export interface MemoryProvenance {
|
|
20
|
+
readonly sourceKind: MemorySourceKind;
|
|
21
|
+
readonly sources: readonly string[];
|
|
22
|
+
readonly taintSet: readonly MemorySourceKind[];
|
|
23
|
+
readonly refs: readonly MemoryRef[];
|
|
24
|
+
}
|
|
25
|
+
export type MemoryErrorCode = 'parse_warning' | 'quarantined' | 'revision_conflict' | 'commit_unknown' | 'memory_governance_unavailable' | 'invalid_scope' | 'path_escape' | 'duplicate_id' | 'memory_disabled' | 'invalid_id' | 'invalid_revision' | 'needs_reverify' | 'not_eligible' | 'missing_id' | 'not_found' | 'cancelled' | 'revoked' | 'purged' | 'storage_unavailable';
|
|
26
|
+
export type MemoryMutationStatus = 'prepared' | 'committed' | 'conflict' | 'blocked';
|
|
27
|
+
export interface MemoryMutationReceipt {
|
|
28
|
+
readonly mutationId: string;
|
|
29
|
+
readonly scopeKey: MemoryScopeKey;
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly revision?: MemoryRevision;
|
|
32
|
+
readonly previousRevision?: MemoryRevision;
|
|
33
|
+
readonly status: MemoryMutationStatus;
|
|
34
|
+
readonly code?: MemoryErrorCode;
|
|
35
|
+
readonly reason?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface MemoryHealth {
|
|
38
|
+
readonly scopeKey: MemoryScopeKey;
|
|
39
|
+
readonly code: MemoryErrorCode;
|
|
40
|
+
readonly line?: number;
|
|
41
|
+
readonly column?: number;
|
|
42
|
+
readonly reason?: string;
|
|
43
|
+
}
|
|
8
44
|
export interface MemoryValidityFields {
|
|
9
45
|
readonly expiresAt?: string;
|
|
10
46
|
readonly topicKey?: string;
|
|
@@ -28,7 +64,7 @@ export interface MemoryItem extends MemoryValidityFields {
|
|
|
28
64
|
readonly trust: MemoryTrust;
|
|
29
65
|
readonly sourceRefs: readonly string[];
|
|
30
66
|
readonly pinned: boolean;
|
|
31
|
-
readonly status:
|
|
67
|
+
readonly status: LegacyMemoryStatus;
|
|
32
68
|
readonly confirmedCount: number;
|
|
33
69
|
readonly createdAt: string;
|
|
34
70
|
readonly lastUsedAt?: string;
|
|
@@ -51,7 +87,22 @@ export interface MemorySnapshot {
|
|
|
51
87
|
readonly createdAt: string;
|
|
52
88
|
}
|
|
53
89
|
/** 记忆页跨进程载荷。渲染层不读存储。 */
|
|
90
|
+
export type MemorySourceOrigin = 'direct_user_chat' | 'group_chat' | 'daemon_routine' | 'matter_delivery' | 'external_tool_output' | 'unknown';
|
|
54
91
|
export interface ProjectMemoryRecord extends MemoryValidityFields {
|
|
92
|
+
readonly revision?: MemoryRevision;
|
|
93
|
+
readonly importance?: 1 | 2 | 3 | 4 | 5;
|
|
94
|
+
readonly applicability?: {
|
|
95
|
+
readonly condition?: string;
|
|
96
|
+
readonly paths?: readonly string[];
|
|
97
|
+
};
|
|
98
|
+
readonly supersedes?: readonly string[];
|
|
99
|
+
readonly sources?: readonly {
|
|
100
|
+
readonly kind: string;
|
|
101
|
+
readonly ref: string;
|
|
102
|
+
readonly quote: string;
|
|
103
|
+
}[];
|
|
104
|
+
readonly useCount?: number;
|
|
105
|
+
readonly correctionCount?: number;
|
|
55
106
|
readonly id: string;
|
|
56
107
|
readonly scope: 'project' | 'user';
|
|
57
108
|
readonly workspaceId?: string;
|
|
@@ -60,7 +111,7 @@ export interface ProjectMemoryRecord extends MemoryValidityFields {
|
|
|
60
111
|
readonly trust: MemoryTrust;
|
|
61
112
|
readonly sourceRefs: readonly string[];
|
|
62
113
|
readonly pinned: boolean;
|
|
63
|
-
readonly status:
|
|
114
|
+
readonly status: LegacyMemoryStatus;
|
|
64
115
|
readonly confirmedCount: number;
|
|
65
116
|
readonly createdAt: string;
|
|
66
117
|
readonly updatedAt: string;
|
|
@@ -68,29 +119,65 @@ export interface ProjectMemoryRecord extends MemoryValidityFields {
|
|
|
68
119
|
readonly anchorMessageId?: string;
|
|
69
120
|
readonly forgetReason?: string;
|
|
70
121
|
}
|
|
71
|
-
export interface
|
|
72
|
-
readonly
|
|
122
|
+
export interface EffectiveMemoryPolicy {
|
|
123
|
+
readonly workspaceId: string;
|
|
124
|
+
readonly settingsRevision: string;
|
|
125
|
+
readonly profileRevision: string;
|
|
126
|
+
readonly policyEpoch: number;
|
|
127
|
+
readonly globalEnabled: boolean | null;
|
|
128
|
+
readonly projectEnabled: boolean | null;
|
|
129
|
+
readonly rawAutoCurate: boolean | null;
|
|
130
|
+
readonly rawLearnPreferences: boolean | null;
|
|
73
131
|
readonly useMemory: boolean;
|
|
132
|
+
readonly collectEpisodes: boolean;
|
|
133
|
+
readonly autoCurate: boolean;
|
|
74
134
|
readonly learnPreferences: boolean;
|
|
135
|
+
readonly reasonCodes: readonly string[];
|
|
136
|
+
readonly rootStatus: {
|
|
137
|
+
readonly status: string;
|
|
138
|
+
readonly readOnly: boolean;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export interface ProjectMemoryPolicyResult {
|
|
142
|
+
readonly ok: boolean;
|
|
143
|
+
readonly code?: string;
|
|
144
|
+
readonly policy?: EffectiveMemoryPolicy;
|
|
75
145
|
}
|
|
76
146
|
export interface ProjectMemoryListRequest {
|
|
147
|
+
readonly includeInactive?: boolean;
|
|
77
148
|
readonly workspaceId: string;
|
|
78
149
|
readonly kind?: MemoryKind;
|
|
79
150
|
readonly trust?: MemoryTrust;
|
|
80
|
-
readonly status?:
|
|
151
|
+
readonly status?: LegacyMemoryStatus;
|
|
81
152
|
readonly ids?: readonly string[];
|
|
153
|
+
readonly references?: readonly MemoryRef[];
|
|
82
154
|
}
|
|
83
155
|
export interface ProjectMemoryListResult {
|
|
156
|
+
readonly managedTopics?: boolean;
|
|
84
157
|
readonly ok: boolean;
|
|
85
158
|
readonly code?: string;
|
|
86
159
|
readonly items?: readonly ProjectMemoryRecord[];
|
|
87
|
-
readonly
|
|
160
|
+
readonly policy?: EffectiveMemoryPolicy;
|
|
88
161
|
}
|
|
89
162
|
export interface ProjectMemoryPinRequest {
|
|
90
163
|
readonly workspaceId: string;
|
|
91
164
|
readonly id: string;
|
|
92
165
|
readonly pinned: boolean;
|
|
93
166
|
}
|
|
167
|
+
export interface ProjectMemoryPurgeRequest {
|
|
168
|
+
readonly workspaceId: string;
|
|
169
|
+
readonly id: string;
|
|
170
|
+
readonly expectedRevision: string;
|
|
171
|
+
readonly confirmed: true;
|
|
172
|
+
}
|
|
173
|
+
export interface MemoryGovernanceResult {
|
|
174
|
+
readonly ok: boolean;
|
|
175
|
+
readonly code?: string;
|
|
176
|
+
readonly status?: 'purged';
|
|
177
|
+
readonly batchId?: string;
|
|
178
|
+
readonly expired?: number;
|
|
179
|
+
readonly proposed?: number;
|
|
180
|
+
}
|
|
94
181
|
export interface ProjectMemoryForgetRequest {
|
|
95
182
|
readonly workspaceId: string;
|
|
96
183
|
readonly id: string;
|
|
@@ -102,6 +189,7 @@ export interface ProjectMemoryRestoreRequest {
|
|
|
102
189
|
readonly resolveConflict?: boolean;
|
|
103
190
|
}
|
|
104
191
|
export interface ProjectMemoryEditRequest {
|
|
192
|
+
readonly expectedRevision?: string;
|
|
105
193
|
readonly workspaceId: string;
|
|
106
194
|
readonly id: string;
|
|
107
195
|
readonly text: string;
|
|
@@ -124,14 +212,19 @@ export interface ProjectMemoryExportResult {
|
|
|
124
212
|
}
|
|
125
213
|
export interface ProjectMemorySetSwitchesRequest {
|
|
126
214
|
readonly workspaceId: string;
|
|
127
|
-
readonly
|
|
128
|
-
readonly
|
|
129
|
-
readonly learnPreferences?: boolean;
|
|
215
|
+
readonly patch: Partial<Record<'globalEnabled' | 'projectEnabled' | 'autoCurate' | 'learnPreferences', boolean>>;
|
|
216
|
+
readonly expected: Pick<EffectiveMemoryPolicy, 'settingsRevision' | 'profileRevision'>;
|
|
130
217
|
}
|
|
218
|
+
export type MemoryPolicyCommitStatus = 'unchanged' | 'applied' | 'conflict' | 'invalid' | 'failed' | 'unconfirmed';
|
|
131
219
|
export interface ProjectMemorySetSwitchesResult {
|
|
132
220
|
readonly ok: boolean;
|
|
133
221
|
readonly code?: string;
|
|
134
|
-
readonly
|
|
222
|
+
readonly settingsRevision?: string;
|
|
223
|
+
readonly profileRevision?: string;
|
|
224
|
+
readonly policyEpoch?: number;
|
|
225
|
+
readonly settingsCommit?: MemoryPolicyCommitStatus;
|
|
226
|
+
readonly profileCommit?: MemoryPolicyCommitStatus;
|
|
227
|
+
readonly effective?: EffectiveMemoryPolicy;
|
|
135
228
|
}
|
|
136
229
|
export type MemoryAdmission = {
|
|
137
230
|
readonly ok: true;
|
|
@@ -147,3 +240,15 @@ export type MemoryAdmission = {
|
|
|
147
240
|
export declare function assessMemoryCandidate(item: MemoryItem, options?: {
|
|
148
241
|
readonly resolvableRefs?: readonly string[];
|
|
149
242
|
}): MemoryAdmission;
|
|
243
|
+
export interface MemoryReviewCandidate {
|
|
244
|
+
readonly action?: 'stale' | 'merge';
|
|
245
|
+
readonly id: string;
|
|
246
|
+
readonly revision: number;
|
|
247
|
+
readonly text: string;
|
|
248
|
+
}
|
|
249
|
+
export type MemoryCandidateChoice = 'project' | 'global' | 'ignore';
|
|
250
|
+
export interface MemoryLearnedRequest {
|
|
251
|
+
readonly workspaceId: string;
|
|
252
|
+
readonly turnId: string;
|
|
253
|
+
readonly reference: MemoryRef;
|
|
254
|
+
}
|