@steerable/agent-shell 0.12.8 → 0.13.1
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/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/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 +329 -35
- 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 +34 -0
- package/dist/memory/injector.js +111 -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/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/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 +129 -17
- package/dist/sidecar/types.d.ts +6 -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/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,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures any ScopedStore exposes complete Phase9ScopedStore operations.
|
|
3
|
+
*
|
|
4
|
+
* SqliteScopedStore and MysqlScopedStore implement Phase9ScopedStore directly
|
|
5
|
+
* against durable SQL tables; lightweight unit-test doubles fall back to
|
|
6
|
+
* scope-isolated in-memory maps without losing tenant/user isolation.
|
|
7
|
+
*/
|
|
8
|
+
import { randomUUID } from 'node:crypto';
|
|
9
|
+
const tenantStates = new Map();
|
|
10
|
+
function stateForTenant(tenantId) {
|
|
11
|
+
let s = tenantStates.get(tenantId);
|
|
12
|
+
if (!s) {
|
|
13
|
+
s = {
|
|
14
|
+
settings: new Map(),
|
|
15
|
+
credentials: new Map(),
|
|
16
|
+
reconciliations: new Map(),
|
|
17
|
+
surfaces: new Map(),
|
|
18
|
+
receipts: [],
|
|
19
|
+
deliverables: new Map(),
|
|
20
|
+
memoryDocs: new Map(),
|
|
21
|
+
memoryEntries: new Map(),
|
|
22
|
+
revokedHashes: new Set(),
|
|
23
|
+
refinementMeta: new Map(),
|
|
24
|
+
};
|
|
25
|
+
tenantStates.set(tenantId, s);
|
|
26
|
+
}
|
|
27
|
+
return s;
|
|
28
|
+
}
|
|
29
|
+
export function resetPhase9FallbackState() {
|
|
30
|
+
tenantStates.clear();
|
|
31
|
+
}
|
|
32
|
+
export function ensurePhase9Store(store) {
|
|
33
|
+
if (typeof store.upsertPackCredential === 'function' &&
|
|
34
|
+
typeof store.createPendingReconciliation === 'function' &&
|
|
35
|
+
typeof store.upsertChatUiSurface === 'function' &&
|
|
36
|
+
typeof store.saveChatDeliverable === 'function' &&
|
|
37
|
+
typeof store.upsertMemoryEntry === 'function' &&
|
|
38
|
+
typeof store.getCustomSetting === 'function') {
|
|
39
|
+
return store;
|
|
40
|
+
}
|
|
41
|
+
const scope = store.scope ?? { tenantId: 'local', userId: 'local' };
|
|
42
|
+
const st = stateForTenant(scope.tenantId);
|
|
43
|
+
const uPrefix = `${scope.userId}\u0000`;
|
|
44
|
+
const fallback = {
|
|
45
|
+
async getCustomSetting(key) {
|
|
46
|
+
if (typeof store.getCustomSetting === 'function')
|
|
47
|
+
return store.getCustomSetting(key);
|
|
48
|
+
return st.settings.get(`${uPrefix}${key}`) ?? null;
|
|
49
|
+
},
|
|
50
|
+
async setCustomSetting(key, value) {
|
|
51
|
+
if (typeof store.setCustomSetting === 'function')
|
|
52
|
+
return store.setCustomSetting(key, value);
|
|
53
|
+
if (value === null)
|
|
54
|
+
st.settings.delete(`${uPrefix}${key}`);
|
|
55
|
+
else
|
|
56
|
+
st.settings.set(`${uPrefix}${key}`, value);
|
|
57
|
+
},
|
|
58
|
+
async upsertPackCredential(input) {
|
|
59
|
+
const updatedAt = new Date().toISOString();
|
|
60
|
+
const rec = {
|
|
61
|
+
tenantId: scope.tenantId,
|
|
62
|
+
ownerUserId: input.ownerUserId,
|
|
63
|
+
sourceId: input.sourceId,
|
|
64
|
+
authKind: input.authKind,
|
|
65
|
+
cipherText: input.cipherText,
|
|
66
|
+
iv: input.iv,
|
|
67
|
+
authTag: input.authTag,
|
|
68
|
+
updatedBy: input.updatedBy,
|
|
69
|
+
updatedAt,
|
|
70
|
+
};
|
|
71
|
+
st.credentials.set(`${input.ownerUserId}\u0000${input.sourceId}`, rec);
|
|
72
|
+
return rec;
|
|
73
|
+
},
|
|
74
|
+
async getPackCredential(ownerUserId, sourceId) {
|
|
75
|
+
return st.credentials.get(`${ownerUserId}\u0000${sourceId}`) ?? null;
|
|
76
|
+
},
|
|
77
|
+
async listPackCredentials(ownerUserIds) {
|
|
78
|
+
const ids = new Set(ownerUserIds && ownerUserIds.length > 0 ? ownerUserIds : [scope.userId, '__tenant__']);
|
|
79
|
+
return [...st.credentials.values()]
|
|
80
|
+
.filter((r) => ids.has(r.ownerUserId))
|
|
81
|
+
.sort((a, b) => a.sourceId.localeCompare(b.sourceId));
|
|
82
|
+
},
|
|
83
|
+
async deletePackCredential(ownerUserId, sourceId) {
|
|
84
|
+
return st.credentials.delete(`${ownerUserId}\u0000${sourceId}`);
|
|
85
|
+
},
|
|
86
|
+
async createPendingReconciliation(input) {
|
|
87
|
+
const id = input.id ?? randomUUID();
|
|
88
|
+
const rec = {
|
|
89
|
+
id,
|
|
90
|
+
chatId: input.chatId,
|
|
91
|
+
toolName: input.toolName,
|
|
92
|
+
argsDigest: input.argsDigest,
|
|
93
|
+
argsPreview: input.argsPreview,
|
|
94
|
+
errorDetail: input.errorDetail,
|
|
95
|
+
status: 'pending',
|
|
96
|
+
resolutionNote: null,
|
|
97
|
+
resolvedBy: null,
|
|
98
|
+
createdAt: new Date().toISOString(),
|
|
99
|
+
resolvedAt: null,
|
|
100
|
+
};
|
|
101
|
+
st.reconciliations.set(`${uPrefix}${id}`, rec);
|
|
102
|
+
return rec;
|
|
103
|
+
},
|
|
104
|
+
async listPendingReconciliations(chatId, options) {
|
|
105
|
+
const out = [];
|
|
106
|
+
for (const [k, rec] of st.reconciliations.entries()) {
|
|
107
|
+
if (!k.startsWith(uPrefix) || rec.chatId !== chatId)
|
|
108
|
+
continue;
|
|
109
|
+
if (!options?.includeResolved && rec.status !== 'pending')
|
|
110
|
+
continue;
|
|
111
|
+
out.push(rec);
|
|
112
|
+
}
|
|
113
|
+
return out.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
114
|
+
},
|
|
115
|
+
async resolvePendingReconciliation(input) {
|
|
116
|
+
const key = `${uPrefix}${input.reconciliationId}`;
|
|
117
|
+
const existing = st.reconciliations.get(key);
|
|
118
|
+
if (!existing || existing.chatId !== input.chatId)
|
|
119
|
+
return null;
|
|
120
|
+
const updated = {
|
|
121
|
+
...existing,
|
|
122
|
+
status: input.status,
|
|
123
|
+
resolutionNote: input.resolutionNote ?? null,
|
|
124
|
+
resolvedBy: input.resolvedBy,
|
|
125
|
+
resolvedAt: new Date().toISOString(),
|
|
126
|
+
};
|
|
127
|
+
st.reconciliations.set(key, updated);
|
|
128
|
+
return updated;
|
|
129
|
+
},
|
|
130
|
+
async upsertChatUiSurface(input) {
|
|
131
|
+
const key = `${uPrefix}${input.chatId}\u0000${input.spec.surfaceId}`;
|
|
132
|
+
const existing = st.surfaces.get(key);
|
|
133
|
+
const rec = {
|
|
134
|
+
chatId: input.chatId,
|
|
135
|
+
surfaceId: input.spec.surfaceId,
|
|
136
|
+
revision: existing ? existing.revision + 1 : 1,
|
|
137
|
+
title: { ...input.spec.title },
|
|
138
|
+
spec: input.spec,
|
|
139
|
+
state: input.state ?? existing?.state ?? {},
|
|
140
|
+
status: input.status ?? existing?.status ?? 'active',
|
|
141
|
+
updatedAt: new Date().toISOString(),
|
|
142
|
+
};
|
|
143
|
+
st.surfaces.set(key, rec);
|
|
144
|
+
return rec;
|
|
145
|
+
},
|
|
146
|
+
async getChatUiSurface(chatId, surfaceId) {
|
|
147
|
+
return st.surfaces.get(`${uPrefix}${chatId}\u0000${surfaceId}`) ?? null;
|
|
148
|
+
},
|
|
149
|
+
async listChatUiSurfaces(chatId) {
|
|
150
|
+
const prefix = `${uPrefix}${chatId}\u0000`;
|
|
151
|
+
const out = [];
|
|
152
|
+
for (const [k, v] of st.surfaces.entries()) {
|
|
153
|
+
if (k.startsWith(prefix))
|
|
154
|
+
out.push(v);
|
|
155
|
+
}
|
|
156
|
+
return out.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
157
|
+
},
|
|
158
|
+
async recordChatUiReceipt(input) {
|
|
159
|
+
const rec = {
|
|
160
|
+
id: randomUUID(),
|
|
161
|
+
chatId: input.chatId,
|
|
162
|
+
surfaceId: input.surfaceId,
|
|
163
|
+
revision: input.revision,
|
|
164
|
+
actionId: input.actionId,
|
|
165
|
+
toolName: input.toolName,
|
|
166
|
+
payload: input.payload,
|
|
167
|
+
sourceFingerprints: input.sourceFingerprints,
|
|
168
|
+
result: input.result,
|
|
169
|
+
actorId: input.actorId,
|
|
170
|
+
createdAt: new Date().toISOString(),
|
|
171
|
+
};
|
|
172
|
+
st.receipts.push(rec);
|
|
173
|
+
return rec;
|
|
174
|
+
},
|
|
175
|
+
async listChatUiReceipts(chatId, surfaceId) {
|
|
176
|
+
return st.receipts
|
|
177
|
+
.filter((r) => r.chatId === chatId && (!surfaceId || r.surfaceId === surfaceId))
|
|
178
|
+
.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
179
|
+
},
|
|
180
|
+
async saveChatDeliverable(input) {
|
|
181
|
+
const id = input.id ?? randomUUID();
|
|
182
|
+
const rec = {
|
|
183
|
+
id,
|
|
184
|
+
chatId: input.chatId,
|
|
185
|
+
messageId: input.messageId ?? null,
|
|
186
|
+
filePath: input.filePath,
|
|
187
|
+
fileName: input.fileName,
|
|
188
|
+
mimeType: input.mimeType,
|
|
189
|
+
sizeBytes: input.sizeBytes,
|
|
190
|
+
sha256: input.sha256,
|
|
191
|
+
verificationStatus: input.verificationStatus,
|
|
192
|
+
verifierId: input.verifierId ?? null,
|
|
193
|
+
issues: [...(input.issues ?? [])],
|
|
194
|
+
summary: input.summary ?? null,
|
|
195
|
+
reportPath: input.reportPath ?? null,
|
|
196
|
+
sourceRefs: [...(input.sourceRefs ?? [])],
|
|
197
|
+
toolCalls: [...(input.toolCalls ?? [])],
|
|
198
|
+
createdAt: new Date().toISOString(),
|
|
199
|
+
};
|
|
200
|
+
st.deliverables.set(`${uPrefix}${id}`, rec);
|
|
201
|
+
return rec;
|
|
202
|
+
},
|
|
203
|
+
async listChatDeliverables(chatId) {
|
|
204
|
+
const out = [];
|
|
205
|
+
for (const [k, v] of st.deliverables.entries()) {
|
|
206
|
+
if (k.startsWith(uPrefix) && v.chatId === chatId)
|
|
207
|
+
out.push(v);
|
|
208
|
+
}
|
|
209
|
+
return out.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
210
|
+
},
|
|
211
|
+
async getMemoryDocument(scopeKind, scopeId) {
|
|
212
|
+
return st.memoryDocs.get(`${uPrefix}${scopeKind}\u0000${scopeId}`) ?? null;
|
|
213
|
+
},
|
|
214
|
+
async putMemoryDocument(input) {
|
|
215
|
+
const rec = {
|
|
216
|
+
scopeKind: input.scopeKind,
|
|
217
|
+
scopeId: input.scopeId,
|
|
218
|
+
contentMarkdown: input.contentMarkdown,
|
|
219
|
+
contentSha256: input.contentSha256,
|
|
220
|
+
updatedBy: input.updatedBy,
|
|
221
|
+
sourceChatId: input.sourceChatId ?? null,
|
|
222
|
+
updatedAt: new Date().toISOString(),
|
|
223
|
+
};
|
|
224
|
+
st.memoryDocs.set(`${uPrefix}${input.scopeKind}\u0000${input.scopeId}`, rec);
|
|
225
|
+
return rec;
|
|
226
|
+
},
|
|
227
|
+
async listMemoryEntries(scopeKind, scopeId, includeRevoked = false) {
|
|
228
|
+
const out = [];
|
|
229
|
+
for (const [k, v] of st.memoryEntries.entries()) {
|
|
230
|
+
if (!k.startsWith(uPrefix))
|
|
231
|
+
continue;
|
|
232
|
+
if (scopeKind && v.scopeKind !== scopeKind)
|
|
233
|
+
continue;
|
|
234
|
+
if (scopeId !== undefined && v.scopeId !== scopeId)
|
|
235
|
+
continue;
|
|
236
|
+
if (!includeRevoked && v.status !== 'active')
|
|
237
|
+
continue;
|
|
238
|
+
out.push(v);
|
|
239
|
+
}
|
|
240
|
+
return out.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
241
|
+
},
|
|
242
|
+
async upsertMemoryEntry(input) {
|
|
243
|
+
const hashKey = `${uPrefix}${input.scopeKind}\u0000${input.scopeId}\u0000${input.contentSha256}`;
|
|
244
|
+
const now = new Date().toISOString();
|
|
245
|
+
if (st.revokedHashes.has(hashKey)) {
|
|
246
|
+
return {
|
|
247
|
+
skippedRevoked: true,
|
|
248
|
+
entry: {
|
|
249
|
+
id: input.id ?? randomUUID(),
|
|
250
|
+
scopeKind: input.scopeKind,
|
|
251
|
+
scopeId: input.scopeId,
|
|
252
|
+
content: input.content,
|
|
253
|
+
contentSha256: input.contentSha256,
|
|
254
|
+
sourceChatId: input.sourceChatId ?? null,
|
|
255
|
+
status: 'revoked',
|
|
256
|
+
createdAt: now,
|
|
257
|
+
updatedAt: now,
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
for (const [k, existing] of st.memoryEntries.entries()) {
|
|
262
|
+
if (k.startsWith(uPrefix) &&
|
|
263
|
+
existing.scopeKind === input.scopeKind &&
|
|
264
|
+
existing.scopeId === input.scopeId &&
|
|
265
|
+
existing.contentSha256 === input.contentSha256) {
|
|
266
|
+
const updated = {
|
|
267
|
+
...existing,
|
|
268
|
+
content: input.content,
|
|
269
|
+
status: 'active',
|
|
270
|
+
updatedAt: now,
|
|
271
|
+
};
|
|
272
|
+
st.memoryEntries.set(k, updated);
|
|
273
|
+
return { skippedRevoked: false, entry: updated };
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const id = input.id ?? randomUUID();
|
|
277
|
+
const entry = {
|
|
278
|
+
id,
|
|
279
|
+
scopeKind: input.scopeKind,
|
|
280
|
+
scopeId: input.scopeId,
|
|
281
|
+
content: input.content,
|
|
282
|
+
contentSha256: input.contentSha256,
|
|
283
|
+
sourceChatId: input.sourceChatId ?? null,
|
|
284
|
+
status: 'active',
|
|
285
|
+
createdAt: now,
|
|
286
|
+
updatedAt: now,
|
|
287
|
+
};
|
|
288
|
+
st.memoryEntries.set(`${uPrefix}${id}`, entry);
|
|
289
|
+
return { skippedRevoked: false, entry };
|
|
290
|
+
},
|
|
291
|
+
async revokeMemoryEntry(entryId) {
|
|
292
|
+
const key = `${uPrefix}${entryId}`;
|
|
293
|
+
const existing = st.memoryEntries.get(key);
|
|
294
|
+
if (!existing)
|
|
295
|
+
return null;
|
|
296
|
+
const updated = {
|
|
297
|
+
...existing,
|
|
298
|
+
status: 'revoked',
|
|
299
|
+
updatedAt: new Date().toISOString(),
|
|
300
|
+
};
|
|
301
|
+
st.memoryEntries.set(key, updated);
|
|
302
|
+
st.revokedHashes.add(`${uPrefix}${existing.scopeKind}\u0000${existing.scopeId}\u0000${existing.contentSha256}`);
|
|
303
|
+
return updated;
|
|
304
|
+
},
|
|
305
|
+
async isMemoryHashRevoked(scopeKind, scopeId, contentSha256) {
|
|
306
|
+
return st.revokedHashes.has(`${uPrefix}${scopeKind}\u0000${scopeId}\u0000${contentSha256}`);
|
|
307
|
+
},
|
|
308
|
+
async clearMemoryScope(scopeKind, scopeId) {
|
|
309
|
+
let deleted = 0;
|
|
310
|
+
for (const [k, v] of [...st.memoryEntries.entries()]) {
|
|
311
|
+
if (!k.startsWith(uPrefix))
|
|
312
|
+
continue;
|
|
313
|
+
if (scopeKind && v.scopeKind !== scopeKind)
|
|
314
|
+
continue;
|
|
315
|
+
if (scopeId !== undefined && v.scopeId !== scopeId)
|
|
316
|
+
continue;
|
|
317
|
+
st.revokedHashes.add(`${uPrefix}${v.scopeKind}\u0000${v.scopeId}\u0000${v.contentSha256}`);
|
|
318
|
+
st.memoryEntries.delete(k);
|
|
319
|
+
deleted += 1;
|
|
320
|
+
}
|
|
321
|
+
for (const [k, v] of [...st.memoryDocs.entries()]) {
|
|
322
|
+
if (!k.startsWith(uPrefix))
|
|
323
|
+
continue;
|
|
324
|
+
if (scopeKind && v.scopeKind !== scopeKind)
|
|
325
|
+
continue;
|
|
326
|
+
if (scopeId !== undefined && v.scopeId !== scopeId)
|
|
327
|
+
continue;
|
|
328
|
+
st.memoryDocs.delete(k);
|
|
329
|
+
}
|
|
330
|
+
return deleted;
|
|
331
|
+
},
|
|
332
|
+
async getMemoryRefinementMeta(scopeKind, scopeId) {
|
|
333
|
+
return (st.refinementMeta.get(`${uPrefix}${scopeKind}\u0000${scopeId}`) ?? {
|
|
334
|
+
scopeKind,
|
|
335
|
+
scopeId,
|
|
336
|
+
refinedSessionCount: 0,
|
|
337
|
+
lastRefinedAt: null,
|
|
338
|
+
lastStatus: null,
|
|
339
|
+
});
|
|
340
|
+
},
|
|
341
|
+
async setMemoryRefinementMeta(input) {
|
|
342
|
+
const rec = {
|
|
343
|
+
scopeKind: input.scopeKind,
|
|
344
|
+
scopeId: input.scopeId,
|
|
345
|
+
refinedSessionCount: input.refinedSessionCount,
|
|
346
|
+
lastRefinedAt: input.lastRefinedAt ?? null,
|
|
347
|
+
lastStatus: input.lastStatus ?? null,
|
|
348
|
+
};
|
|
349
|
+
st.refinementMeta.set(`${uPrefix}${input.scopeKind}\u0000${input.scopeId}`, rec);
|
|
350
|
+
return rec;
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
return Object.assign(Object.create(store), store, fallback);
|
|
354
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 9 host storage record contracts shared by SqliteScopedStore and
|
|
3
|
+
* external storage drivers (such as Team Edition MysqlScopedStore).
|
|
4
|
+
*/
|
|
5
|
+
import type { UiSurfaceSpec, VerifierIssue } from '../scenario/pack.js';
|
|
6
|
+
export type CredentialOwnerScope = 'tenant' | 'user';
|
|
7
|
+
export interface PackCredentialRecord {
|
|
8
|
+
readonly tenantId: string;
|
|
9
|
+
readonly ownerUserId: string;
|
|
10
|
+
readonly sourceId: string;
|
|
11
|
+
readonly authKind: string;
|
|
12
|
+
readonly cipherText: string;
|
|
13
|
+
readonly iv: string;
|
|
14
|
+
readonly authTag: string;
|
|
15
|
+
readonly updatedBy: string;
|
|
16
|
+
readonly updatedAt: string;
|
|
17
|
+
}
|
|
18
|
+
export interface PendingReconciliationRecord {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly chatId: string;
|
|
21
|
+
readonly toolName: string;
|
|
22
|
+
readonly argsDigest: string;
|
|
23
|
+
readonly argsPreview: string;
|
|
24
|
+
readonly errorDetail: string;
|
|
25
|
+
readonly status: 'pending' | 'confirmed_executed' | 'confirmed_not_executed';
|
|
26
|
+
readonly resolutionNote: string | null;
|
|
27
|
+
readonly resolvedBy: string | null;
|
|
28
|
+
readonly createdAt: string;
|
|
29
|
+
readonly resolvedAt: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface ChatUiSurfaceRecord {
|
|
32
|
+
readonly chatId: string;
|
|
33
|
+
readonly surfaceId: string;
|
|
34
|
+
readonly revision: number;
|
|
35
|
+
readonly title: Record<string, string>;
|
|
36
|
+
readonly spec: UiSurfaceSpec;
|
|
37
|
+
readonly state: Record<string, unknown>;
|
|
38
|
+
readonly status: 'active' | 'submitted' | 'archived';
|
|
39
|
+
readonly updatedAt: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ChatUiReceiptRecord {
|
|
42
|
+
readonly id: string;
|
|
43
|
+
readonly chatId: string;
|
|
44
|
+
readonly surfaceId: string;
|
|
45
|
+
readonly revision: number;
|
|
46
|
+
readonly actionId: string;
|
|
47
|
+
readonly toolName: string;
|
|
48
|
+
readonly payload: Record<string, unknown>;
|
|
49
|
+
readonly sourceFingerprints: Record<string, string>;
|
|
50
|
+
readonly result: Record<string, unknown>;
|
|
51
|
+
readonly actorId: string;
|
|
52
|
+
readonly createdAt: string;
|
|
53
|
+
}
|
|
54
|
+
export interface ChatDeliverableRecord {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly chatId: string;
|
|
57
|
+
readonly messageId: string | null;
|
|
58
|
+
readonly filePath: string;
|
|
59
|
+
readonly fileName: string;
|
|
60
|
+
readonly mimeType: string;
|
|
61
|
+
readonly sizeBytes: number;
|
|
62
|
+
readonly sha256: string;
|
|
63
|
+
readonly verificationStatus: 'verified' | 'warnings' | 'failed' | 'unverified';
|
|
64
|
+
readonly verifierId: string | null;
|
|
65
|
+
readonly issues: VerifierIssue[];
|
|
66
|
+
readonly summary: string | null;
|
|
67
|
+
readonly reportPath: string | null;
|
|
68
|
+
readonly sourceRefs: string[];
|
|
69
|
+
readonly toolCalls: Array<{
|
|
70
|
+
id?: string;
|
|
71
|
+
tool: string;
|
|
72
|
+
summary?: string;
|
|
73
|
+
}>;
|
|
74
|
+
readonly createdAt: string;
|
|
75
|
+
}
|
|
76
|
+
export type MemoryScopeKind = 'user' | 'workspace' | 'tenant' | 'project' | 'agent';
|
|
77
|
+
export interface MemoryDocumentRecord {
|
|
78
|
+
readonly scopeKind: MemoryScopeKind;
|
|
79
|
+
readonly scopeId: string;
|
|
80
|
+
readonly contentMarkdown: string;
|
|
81
|
+
readonly contentSha256: string;
|
|
82
|
+
readonly updatedBy: string;
|
|
83
|
+
readonly sourceChatId: string | null;
|
|
84
|
+
readonly updatedAt: string;
|
|
85
|
+
}
|
|
86
|
+
export interface MemoryEntryRecord {
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly scopeKind: MemoryScopeKind;
|
|
89
|
+
readonly scopeId: string;
|
|
90
|
+
readonly content: string;
|
|
91
|
+
readonly contentSha256: string;
|
|
92
|
+
readonly sourceChatId: string | null;
|
|
93
|
+
readonly status: 'active' | 'revoked';
|
|
94
|
+
readonly createdAt: string;
|
|
95
|
+
readonly updatedAt: string;
|
|
96
|
+
}
|
|
97
|
+
export interface MemoryRefinementMetaRecord {
|
|
98
|
+
readonly scopeKind: MemoryScopeKind;
|
|
99
|
+
readonly scopeId: string;
|
|
100
|
+
readonly refinedSessionCount: number;
|
|
101
|
+
readonly lastRefinedAt: string | null;
|
|
102
|
+
readonly lastStatus: string | null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* First-class persistence operations implemented by all production
|
|
106
|
+
* StorageDrivers (SQLite and MySQL).
|
|
107
|
+
*/
|
|
108
|
+
export interface Phase9ScopedStore {
|
|
109
|
+
getCustomSetting(key: string): Promise<string | null>;
|
|
110
|
+
setCustomSetting(key: string, value: string | null): Promise<void>;
|
|
111
|
+
upsertPackCredential(input: {
|
|
112
|
+
ownerUserId: string;
|
|
113
|
+
sourceId: string;
|
|
114
|
+
authKind: string;
|
|
115
|
+
cipherText: string;
|
|
116
|
+
iv: string;
|
|
117
|
+
authTag: string;
|
|
118
|
+
updatedBy: string;
|
|
119
|
+
}): Promise<PackCredentialRecord>;
|
|
120
|
+
getPackCredential(ownerUserId: string, sourceId: string): Promise<PackCredentialRecord | null>;
|
|
121
|
+
listPackCredentials(ownerUserIds?: readonly string[]): Promise<PackCredentialRecord[]>;
|
|
122
|
+
deletePackCredential(ownerUserId: string, sourceId: string): Promise<boolean>;
|
|
123
|
+
createPendingReconciliation(input: {
|
|
124
|
+
id?: string;
|
|
125
|
+
chatId: string;
|
|
126
|
+
toolName: string;
|
|
127
|
+
argsDigest: string;
|
|
128
|
+
argsPreview: string;
|
|
129
|
+
errorDetail: string;
|
|
130
|
+
}): Promise<PendingReconciliationRecord>;
|
|
131
|
+
listPendingReconciliations(chatId: string, options?: {
|
|
132
|
+
includeResolved?: boolean;
|
|
133
|
+
}): Promise<PendingReconciliationRecord[]>;
|
|
134
|
+
resolvePendingReconciliation(input: {
|
|
135
|
+
chatId: string;
|
|
136
|
+
reconciliationId: string;
|
|
137
|
+
status: 'confirmed_executed' | 'confirmed_not_executed';
|
|
138
|
+
resolutionNote?: string | null;
|
|
139
|
+
resolvedBy: string;
|
|
140
|
+
}): Promise<PendingReconciliationRecord | null>;
|
|
141
|
+
upsertChatUiSurface(input: {
|
|
142
|
+
chatId: string;
|
|
143
|
+
spec: UiSurfaceSpec;
|
|
144
|
+
state?: Record<string, unknown>;
|
|
145
|
+
status?: 'active' | 'submitted' | 'archived';
|
|
146
|
+
}): Promise<ChatUiSurfaceRecord>;
|
|
147
|
+
getChatUiSurface(chatId: string, surfaceId: string): Promise<ChatUiSurfaceRecord | null>;
|
|
148
|
+
listChatUiSurfaces(chatId: string): Promise<ChatUiSurfaceRecord[]>;
|
|
149
|
+
recordChatUiReceipt(input: {
|
|
150
|
+
chatId: string;
|
|
151
|
+
surfaceId: string;
|
|
152
|
+
revision: number;
|
|
153
|
+
actionId: string;
|
|
154
|
+
toolName: string;
|
|
155
|
+
payload: Record<string, unknown>;
|
|
156
|
+
sourceFingerprints: Record<string, string>;
|
|
157
|
+
result: Record<string, unknown>;
|
|
158
|
+
actorId: string;
|
|
159
|
+
}): Promise<ChatUiReceiptRecord>;
|
|
160
|
+
listChatUiReceipts(chatId: string, surfaceId?: string): Promise<ChatUiReceiptRecord[]>;
|
|
161
|
+
saveChatDeliverable(input: {
|
|
162
|
+
id?: string;
|
|
163
|
+
chatId: string;
|
|
164
|
+
messageId?: string | null;
|
|
165
|
+
filePath: string;
|
|
166
|
+
fileName: string;
|
|
167
|
+
mimeType: string;
|
|
168
|
+
sizeBytes: number;
|
|
169
|
+
sha256: string;
|
|
170
|
+
verificationStatus: 'verified' | 'warnings' | 'failed' | 'unverified';
|
|
171
|
+
verifierId?: string | null;
|
|
172
|
+
issues?: readonly VerifierIssue[];
|
|
173
|
+
summary?: string | null;
|
|
174
|
+
reportPath?: string | null;
|
|
175
|
+
sourceRefs?: readonly string[];
|
|
176
|
+
toolCalls?: ReadonlyArray<{
|
|
177
|
+
id?: string;
|
|
178
|
+
tool: string;
|
|
179
|
+
summary?: string;
|
|
180
|
+
}>;
|
|
181
|
+
}): Promise<ChatDeliverableRecord>;
|
|
182
|
+
listChatDeliverables(chatId: string): Promise<ChatDeliverableRecord[]>;
|
|
183
|
+
getMemoryDocument(scopeKind: MemoryScopeKind, scopeId: string): Promise<MemoryDocumentRecord | null>;
|
|
184
|
+
putMemoryDocument(input: {
|
|
185
|
+
scopeKind: MemoryScopeKind;
|
|
186
|
+
scopeId: string;
|
|
187
|
+
contentMarkdown: string;
|
|
188
|
+
contentSha256: string;
|
|
189
|
+
updatedBy: string;
|
|
190
|
+
sourceChatId?: string | null;
|
|
191
|
+
}): Promise<MemoryDocumentRecord>;
|
|
192
|
+
listMemoryEntries(scopeKind?: MemoryScopeKind, scopeId?: string, includeRevoked?: boolean): Promise<MemoryEntryRecord[]>;
|
|
193
|
+
upsertMemoryEntry(input: {
|
|
194
|
+
id?: string;
|
|
195
|
+
scopeKind: MemoryScopeKind;
|
|
196
|
+
scopeId: string;
|
|
197
|
+
content: string;
|
|
198
|
+
contentSha256: string;
|
|
199
|
+
sourceChatId?: string | null;
|
|
200
|
+
}): Promise<{
|
|
201
|
+
entry: MemoryEntryRecord;
|
|
202
|
+
skippedRevoked: boolean;
|
|
203
|
+
}>;
|
|
204
|
+
revokeMemoryEntry(entryId: string): Promise<MemoryEntryRecord | null>;
|
|
205
|
+
isMemoryHashRevoked(scopeKind: MemoryScopeKind, scopeId: string, contentSha256: string): Promise<boolean>;
|
|
206
|
+
clearMemoryScope(scopeKind?: MemoryScopeKind, scopeId?: string): Promise<number>;
|
|
207
|
+
getMemoryRefinementMeta(scopeKind: MemoryScopeKind, scopeId: string): Promise<MemoryRefinementMetaRecord>;
|
|
208
|
+
setMemoryRefinementMeta(input: {
|
|
209
|
+
scopeKind: MemoryScopeKind;
|
|
210
|
+
scopeId: string;
|
|
211
|
+
refinedSessionCount: number;
|
|
212
|
+
lastRefinedAt?: string | null;
|
|
213
|
+
lastStatus?: string | null;
|
|
214
|
+
}): Promise<MemoryRefinementMetaRecord>;
|
|
215
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|