@pellux/goodvibes-sdk 0.33.9 → 0.33.11
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/browser-knowledge.d.ts +18 -1
- package/dist/browser-knowledge.d.ts.map +1 -1
- package/dist/browser-knowledge.js +9 -1
- package/dist/contracts/artifacts/operator-contract.json +271 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/platform/companion/companion-chat-manager.d.ts +27 -2
- package/dist/platform/companion/companion-chat-manager.d.ts.map +1 -1
- package/dist/platform/companion/companion-chat-manager.js +142 -10
- package/dist/platform/companion/companion-chat-routes.d.ts.map +1 -1
- package/dist/platform/companion/companion-chat-routes.js +38 -3
- package/dist/platform/companion/companion-chat-types.d.ts +12 -0
- package/dist/platform/companion/companion-chat-types.d.ts.map +1 -1
- package/dist/platform/companion/index.d.ts +2 -2
- package/dist/platform/companion/index.d.ts.map +1 -1
- package/dist/platform/control-plane/conversation-message.d.ts +6 -0
- package/dist/platform/control-plane/conversation-message.d.ts.map +1 -1
- package/dist/platform/control-plane/conversation-message.js +0 -8
- package/dist/platform/control-plane/method-catalog-control-core.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-control-core.js +6 -1
- package/dist/platform/control-plane/method-catalog-knowledge.d.ts.map +1 -1
- package/dist/platform/control-plane/method-catalog-knowledge.js +16 -7
- package/dist/platform/control-plane/operator-contract-schemas-runtime.d.ts.map +1 -1
- package/dist/platform/control-plane/operator-contract-schemas-runtime.js +18 -1
- package/dist/platform/control-plane/routes/operator.js +2 -2
- package/dist/platform/daemon/facade-composition.d.ts.map +1 -1
- package/dist/platform/daemon/facade-composition.js +1 -0
- package/dist/platform/daemon/http/router-route-contexts.d.ts.map +1 -1
- package/dist/platform/daemon/http/router-route-contexts.js +8 -8
- package/dist/platform/knowledge/graphql-schema.d.ts +1 -1
- package/dist/platform/knowledge/graphql-schema.d.ts.map +1 -1
- package/dist/platform/knowledge/graphql-schema.js +13 -11
- package/dist/platform/knowledge/graphql.d.ts.map +1 -1
- package/dist/platform/knowledge/graphql.js +51 -25
- package/dist/platform/knowledge/index.d.ts +1 -1
- package/dist/platform/knowledge/index.d.ts.map +1 -1
- package/dist/platform/knowledge/map-filters.d.ts +3 -0
- package/dist/platform/knowledge/map-filters.d.ts.map +1 -1
- package/dist/platform/knowledge/map-filters.js +20 -0
- package/dist/platform/knowledge/map.d.ts +2 -0
- package/dist/platform/knowledge/map.d.ts.map +1 -1
- package/dist/platform/knowledge/map.js +1 -6
- package/dist/platform/knowledge/packet.d.ts +6 -5
- package/dist/platform/knowledge/packet.d.ts.map +1 -1
- package/dist/platform/knowledge/packet.js +13 -8
- package/dist/platform/knowledge/projections.d.ts +12 -1
- package/dist/platform/knowledge/projections.d.ts.map +1 -1
- package/dist/platform/knowledge/projections.js +153 -91
- package/dist/platform/knowledge/service.d.ts +27 -7
- package/dist/platform/knowledge/service.d.ts.map +1 -1
- package/dist/platform/knowledge/service.js +66 -6
- package/dist/platform/knowledge/spaces.d.ts +6 -0
- package/dist/platform/knowledge/spaces.d.ts.map +1 -1
- package/dist/platform/knowledge/spaces.js +9 -0
- package/dist/platform/knowledge/types.d.ts +2 -0
- package/dist/platform/knowledge/types.d.ts.map +1 -1
- package/dist/platform/version.js +1 -1
- package/package.json +9 -9
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* for that specific session — never the global TUI event feed.
|
|
20
20
|
* - A GC sweep closes sessions that have been idle beyond the TTL.
|
|
21
21
|
*/
|
|
22
|
+
import { Buffer } from 'node:buffer';
|
|
22
23
|
import { randomUUID } from 'node:crypto';
|
|
23
24
|
import { ConversationManager } from '../core/conversation.js';
|
|
24
25
|
import { CompanionChatPersistence, defaultSessionsDir, } from './companion-chat-persistence.js';
|
|
@@ -34,6 +35,16 @@ const DEFAULT_IDLE_ACTIVE_MS = 30 * 60 * 1_000; // 30 minutes with messages
|
|
|
34
35
|
const DEFAULT_IDLE_EMPTY_MS = 5 * 60 * 1_000; // 5 minutes empty session
|
|
35
36
|
const GC_INTERVAL_MS = 60 * 1_000; // sweep every minute
|
|
36
37
|
const MAX_TOOL_ROUNDS_PER_TURN = 8;
|
|
38
|
+
const MAX_ATTACHMENTS_PER_MESSAGE = 8;
|
|
39
|
+
const MAX_INLINE_IMAGE_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
40
|
+
const MAX_INLINE_TEXT_ATTACHMENT_BYTES = 200 * 1024;
|
|
41
|
+
function toNodeBuffer(buffer) {
|
|
42
|
+
if (Buffer.isBuffer(buffer))
|
|
43
|
+
return buffer;
|
|
44
|
+
if (buffer instanceof ArrayBuffer)
|
|
45
|
+
return Buffer.from(new Uint8Array(buffer));
|
|
46
|
+
return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
47
|
+
}
|
|
37
48
|
function assertCompleteProviderModelRoute(input) {
|
|
38
49
|
if ((input.model !== undefined) === (input.provider !== undefined))
|
|
39
50
|
return;
|
|
@@ -50,6 +61,7 @@ export class CompanionChatManager {
|
|
|
50
61
|
permissionManager;
|
|
51
62
|
hookDispatcher;
|
|
52
63
|
runtimeBus;
|
|
64
|
+
artifactStore;
|
|
53
65
|
persistence;
|
|
54
66
|
rateLimiter;
|
|
55
67
|
idleActiveMs;
|
|
@@ -71,6 +83,7 @@ export class CompanionChatManager {
|
|
|
71
83
|
this.permissionManager = config.permissionManager ?? null;
|
|
72
84
|
this.hookDispatcher = config.hookDispatcher ?? null;
|
|
73
85
|
this.runtimeBus = config.runtimeBus ?? null;
|
|
86
|
+
this.artifactStore = config.artifactStore ?? null;
|
|
74
87
|
this.idleActiveMs = config.idleActiveMs ?? DEFAULT_IDLE_ACTIVE_MS;
|
|
75
88
|
this.idleEmptyMs = config.idleEmptyMs ?? DEFAULT_IDLE_EMPTY_MS;
|
|
76
89
|
// Persistence
|
|
@@ -109,15 +122,16 @@ export class CompanionChatManager {
|
|
|
109
122
|
}
|
|
110
123
|
const stored = await this.persistence.loadAll();
|
|
111
124
|
for (const { meta, messages } of stored) {
|
|
125
|
+
const normalizedMessages = messages.map((message) => this.normalizeMessage(message));
|
|
112
126
|
// Skip sessions that were already closed before the restart — they are
|
|
113
127
|
// in a terminal state and don't need to be in memory.
|
|
114
128
|
if (meta.status === 'closed')
|
|
115
129
|
continue;
|
|
116
130
|
const conversation = new ConversationManager();
|
|
117
131
|
// Replay messages into the conversation to restore LLM context
|
|
118
|
-
for (const msg of
|
|
132
|
+
for (const msg of normalizedMessages) {
|
|
119
133
|
if (msg.role === 'user') {
|
|
120
|
-
conversation.addUserMessage(msg
|
|
134
|
+
conversation.addUserMessage(this.buildReplayUserContent(msg));
|
|
121
135
|
}
|
|
122
136
|
else {
|
|
123
137
|
conversation.addAssistantMessage(msg.content);
|
|
@@ -126,7 +140,7 @@ export class CompanionChatManager {
|
|
|
126
140
|
this.sessions.set(meta.id, {
|
|
127
141
|
meta,
|
|
128
142
|
conversation,
|
|
129
|
-
messages:
|
|
143
|
+
messages: normalizedMessages,
|
|
130
144
|
abortController: new AbortController(),
|
|
131
145
|
lastActivityAt: meta.updatedAt,
|
|
132
146
|
subscriberClientId: null,
|
|
@@ -192,6 +206,12 @@ export class CompanionChatManager {
|
|
|
192
206
|
getMessages(sessionId) {
|
|
193
207
|
return this.sessions.get(sessionId)?.messages ?? [];
|
|
194
208
|
}
|
|
209
|
+
normalizeMessage(message) {
|
|
210
|
+
return {
|
|
211
|
+
...message,
|
|
212
|
+
attachments: message.attachments ?? [],
|
|
213
|
+
};
|
|
214
|
+
}
|
|
195
215
|
updateSession(sessionId, input) {
|
|
196
216
|
assertCompleteProviderModelRoute(input);
|
|
197
217
|
const session = this.sessions.get(sessionId);
|
|
@@ -255,8 +275,10 @@ export class CompanionChatManager {
|
|
|
255
275
|
* @param clientId - The SSE/HTTP client identity for per-client rate limiting.
|
|
256
276
|
* Pass '' to skip client-level rate limiting.
|
|
257
277
|
*/
|
|
258
|
-
async postMessage(sessionId, content, clientId = '') {
|
|
259
|
-
return await this._postMessageInternal(sessionId, content, clientId
|
|
278
|
+
async postMessage(sessionId, content, clientId = '', options = {}) {
|
|
279
|
+
return await this._postMessageInternal(sessionId, content, clientId, {
|
|
280
|
+
attachments: options.attachments,
|
|
281
|
+
});
|
|
260
282
|
}
|
|
261
283
|
async postMessageAndWaitForReply(sessionId, content, clientId = '', options = {}) {
|
|
262
284
|
let messageId = '';
|
|
@@ -267,7 +289,10 @@ export class CompanionChatManager {
|
|
|
267
289
|
resolve({ messageId, error: 'Timed out waiting for companion chat reply' });
|
|
268
290
|
}, options.timeoutMs ?? 120_000);
|
|
269
291
|
timeout.unref?.();
|
|
270
|
-
void this._postMessageInternal(sessionId, content, clientId, {
|
|
292
|
+
void this._postMessageInternal(sessionId, content, clientId, {
|
|
293
|
+
pendingReply: { resolve, timeout },
|
|
294
|
+
attachments: options.attachments,
|
|
295
|
+
})
|
|
271
296
|
.then((id) => { messageId = id; })
|
|
272
297
|
.catch((error) => {
|
|
273
298
|
clearTimeout(timeout);
|
|
@@ -279,7 +304,7 @@ export class CompanionChatManager {
|
|
|
279
304
|
});
|
|
280
305
|
return result;
|
|
281
306
|
}
|
|
282
|
-
async _postMessageInternal(sessionId, content, clientId,
|
|
307
|
+
async _postMessageInternal(sessionId, content, clientId, options = {}) {
|
|
283
308
|
const session = this.sessions.get(sessionId);
|
|
284
309
|
if (!session) {
|
|
285
310
|
throw Object.assign(new Error(`Session not found: ${sessionId}`), { code: 'SESSION_NOT_FOUND', status: 404 });
|
|
@@ -289,6 +314,10 @@ export class CompanionChatManager {
|
|
|
289
314
|
}
|
|
290
315
|
// Rate-limit check (throws GoodVibesSdkError on violation)
|
|
291
316
|
this.rateLimiter?.check(sessionId, clientId);
|
|
317
|
+
const attachments = this.resolveAttachments(options.attachments ?? []);
|
|
318
|
+
if (!content.trim() && attachments.length === 0) {
|
|
319
|
+
throw Object.assign(new Error('content or attachments are required'), { code: 'INVALID_INPUT', status: 400 });
|
|
320
|
+
}
|
|
292
321
|
const messageId = randomUUID();
|
|
293
322
|
const now = Date.now();
|
|
294
323
|
const userMsg = {
|
|
@@ -296,18 +325,19 @@ export class CompanionChatManager {
|
|
|
296
325
|
sessionId,
|
|
297
326
|
role: 'user',
|
|
298
327
|
content,
|
|
328
|
+
attachments,
|
|
299
329
|
createdAt: now,
|
|
300
330
|
};
|
|
301
331
|
session.messages.push(userMsg);
|
|
302
|
-
session.conversation.addUserMessage(content);
|
|
332
|
+
session.conversation.addUserMessage(await this.buildProviderUserContent(content, attachments));
|
|
303
333
|
session.lastActivityAt = now;
|
|
304
334
|
this._updateMeta(session, {
|
|
305
335
|
messageCount: session.messages.length,
|
|
306
336
|
updatedAt: now,
|
|
307
337
|
});
|
|
308
338
|
this._persist(sessionId);
|
|
309
|
-
if (pendingReply) {
|
|
310
|
-
this.pendingReplies.set(messageId, pendingReply);
|
|
339
|
+
if (options.pendingReply) {
|
|
340
|
+
this.pendingReplies.set(messageId, options.pendingReply);
|
|
311
341
|
}
|
|
312
342
|
void this._runTurn(session, messageId).catch((error) => {
|
|
313
343
|
logger.warn('[companion-chat] turn execution failed', {
|
|
@@ -318,6 +348,106 @@ export class CompanionChatManager {
|
|
|
318
348
|
});
|
|
319
349
|
return messageId;
|
|
320
350
|
}
|
|
351
|
+
resolveAttachments(inputs) {
|
|
352
|
+
if (inputs.length === 0)
|
|
353
|
+
return [];
|
|
354
|
+
if (inputs.length > MAX_ATTACHMENTS_PER_MESSAGE) {
|
|
355
|
+
throw Object.assign(new Error(`A companion chat message can include at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments.`), { code: 'TOO_MANY_ATTACHMENTS', status: 400 });
|
|
356
|
+
}
|
|
357
|
+
if (!this.artifactStore) {
|
|
358
|
+
throw Object.assign(new Error('Companion chat attachments require an artifact store.'), { code: 'ATTACHMENTS_UNAVAILABLE', status: 501 });
|
|
359
|
+
}
|
|
360
|
+
return inputs.map((input) => {
|
|
361
|
+
const artifactId = input.artifactId.trim();
|
|
362
|
+
if (!artifactId) {
|
|
363
|
+
throw Object.assign(new Error('Attachment artifactId is required.'), {
|
|
364
|
+
code: 'INVALID_ATTACHMENT',
|
|
365
|
+
status: 400,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
const artifact = this.artifactStore.get(artifactId);
|
|
369
|
+
if (!artifact) {
|
|
370
|
+
throw Object.assign(new Error(`Unknown attachment artifact: ${artifactId}`), {
|
|
371
|
+
code: 'UNKNOWN_ARTIFACT',
|
|
372
|
+
status: 404,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
...artifact,
|
|
377
|
+
artifactId: artifact.id,
|
|
378
|
+
...(input.label?.trim() ? { label: input.label.trim() } : {}),
|
|
379
|
+
metadata: {
|
|
380
|
+
...artifact.metadata,
|
|
381
|
+
...(input.metadata ?? {}),
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
formatAttachmentSummary(attachments) {
|
|
387
|
+
if (attachments.length === 0)
|
|
388
|
+
return '';
|
|
389
|
+
const lines = attachments.map((attachment, index) => {
|
|
390
|
+
const name = attachment.label ?? attachment.filename ?? attachment.artifactId;
|
|
391
|
+
return `${index + 1}. ${name} (${attachment.mimeType}, ${attachment.sizeBytes} bytes, artifact ${attachment.artifactId})`;
|
|
392
|
+
});
|
|
393
|
+
return `\n\nAttached file${attachments.length === 1 ? '' : 's'}:\n${lines.join('\n')}`;
|
|
394
|
+
}
|
|
395
|
+
buildReplayUserContent(message) {
|
|
396
|
+
return `${message.content}${this.formatAttachmentSummary(message.attachments ?? [])}`;
|
|
397
|
+
}
|
|
398
|
+
isInlineTextAttachment(attachment) {
|
|
399
|
+
const lower = attachment.mimeType.toLowerCase();
|
|
400
|
+
return attachment.sizeBytes <= MAX_INLINE_TEXT_ATTACHMENT_BYTES
|
|
401
|
+
&& (lower.startsWith('text/')
|
|
402
|
+
|| lower === 'application/json'
|
|
403
|
+
|| lower === 'application/xml'
|
|
404
|
+
|| lower === 'application/yaml'
|
|
405
|
+
|| lower === 'text/csv');
|
|
406
|
+
}
|
|
407
|
+
isInlineImageAttachment(attachment) {
|
|
408
|
+
const lower = attachment.mimeType.toLowerCase();
|
|
409
|
+
return attachment.sizeBytes <= MAX_INLINE_IMAGE_ATTACHMENT_BYTES
|
|
410
|
+
&& (lower === 'image/png'
|
|
411
|
+
|| lower === 'image/jpeg'
|
|
412
|
+
|| lower === 'image/gif'
|
|
413
|
+
|| lower === 'image/webp');
|
|
414
|
+
}
|
|
415
|
+
async buildProviderUserContent(content, attachments) {
|
|
416
|
+
if (attachments.length === 0)
|
|
417
|
+
return content;
|
|
418
|
+
const textSections = [content.trim() ? content : 'Please review the attached file(s).'];
|
|
419
|
+
const imageParts = [];
|
|
420
|
+
for (const attachment of attachments) {
|
|
421
|
+
if (!this.artifactStore)
|
|
422
|
+
continue;
|
|
423
|
+
try {
|
|
424
|
+
if (this.isInlineTextAttachment(attachment)) {
|
|
425
|
+
const { buffer } = await this.artifactStore.readContent(attachment.artifactId);
|
|
426
|
+
const text = toNodeBuffer(buffer).toString('utf-8');
|
|
427
|
+
textSections.push(`\n\n--- Attachment: ${attachment.label ?? attachment.filename ?? attachment.artifactId} ---\n${text}`);
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
if (this.isInlineImageAttachment(attachment)) {
|
|
431
|
+
const { buffer } = await this.artifactStore.readContent(attachment.artifactId);
|
|
432
|
+
imageParts.push({
|
|
433
|
+
type: 'image',
|
|
434
|
+
mediaType: attachment.mimeType,
|
|
435
|
+
data: toNodeBuffer(buffer).toString('base64'),
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
logger.warn('[companion-chat] failed to inline attachment for provider prompt', {
|
|
441
|
+
artifactId: attachment.artifactId,
|
|
442
|
+
error: summarizeError(error),
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
textSections.push(this.formatAttachmentSummary(attachments));
|
|
447
|
+
if (imageParts.length === 0)
|
|
448
|
+
return textSections.join('');
|
|
449
|
+
return [{ type: 'text', text: textSections.join('') }, ...imageParts];
|
|
450
|
+
}
|
|
321
451
|
dispose() {
|
|
322
452
|
if (this.gcTimer) {
|
|
323
453
|
clearInterval(this.gcTimer);
|
|
@@ -347,6 +477,7 @@ export class CompanionChatManager {
|
|
|
347
477
|
body: userMsg?.content ?? '',
|
|
348
478
|
source: 'companion-chat-user',
|
|
349
479
|
timestamp: userMsg?.createdAt ?? Date.now(),
|
|
480
|
+
...(userMsg?.attachments?.length ? { attachments: userMsg.attachments } : {}),
|
|
350
481
|
};
|
|
351
482
|
publish({ type: 'turn.started', sessionId, messageId: userMessageId, turnId, envelope: startEnvelope });
|
|
352
483
|
let assistantContent = '';
|
|
@@ -435,6 +566,7 @@ export class CompanionChatManager {
|
|
|
435
566
|
sessionId,
|
|
436
567
|
role: 'assistant',
|
|
437
568
|
content: assistantContent,
|
|
569
|
+
attachments: [],
|
|
438
570
|
createdAt: now,
|
|
439
571
|
};
|
|
440
572
|
session.messages.push(assistantMsg);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"companion-chat-routes.d.ts","sourceRoot":"","sources":["../../../src/platform/companion/companion-chat-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"companion-chat-routes.d.ts","sourceRoot":"","sources":["../../../src/platform/companion/companion-chat-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAMjF;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAoD1B;AA8MD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAMlF"}
|
|
@@ -225,6 +225,35 @@ export function readCompanionChatMessageBody(body) {
|
|
|
225
225
|
? body['content']
|
|
226
226
|
: '';
|
|
227
227
|
}
|
|
228
|
+
function readCompanionChatAttachments(body) {
|
|
229
|
+
const raw = body['attachments'];
|
|
230
|
+
if (raw === undefined)
|
|
231
|
+
return [];
|
|
232
|
+
if (!Array.isArray(raw)) {
|
|
233
|
+
return Response.json({ error: 'attachments must be an array', code: 'INVALID_INPUT' }, { status: 400 });
|
|
234
|
+
}
|
|
235
|
+
const attachments = [];
|
|
236
|
+
for (const [index, item] of raw.entries()) {
|
|
237
|
+
if (typeof item !== 'object' || item === null || Array.isArray(item)) {
|
|
238
|
+
return Response.json({ error: `attachments[${index}] must be an object`, code: 'INVALID_INPUT' }, { status: 400 });
|
|
239
|
+
}
|
|
240
|
+
const record = item;
|
|
241
|
+
if (typeof record['artifactId'] !== 'string' || record['artifactId'].trim().length === 0) {
|
|
242
|
+
return Response.json({ error: `attachments[${index}].artifactId is required`, code: 'INVALID_INPUT' }, { status: 400 });
|
|
243
|
+
}
|
|
244
|
+
const attachment = {
|
|
245
|
+
artifactId: record['artifactId'].trim(),
|
|
246
|
+
};
|
|
247
|
+
if (typeof record['label'] === 'string' && record['label'].trim()) {
|
|
248
|
+
attachment.label = record['label'].trim();
|
|
249
|
+
}
|
|
250
|
+
if (typeof record['metadata'] === 'object' && record['metadata'] !== null && !Array.isArray(record['metadata'])) {
|
|
251
|
+
attachment.metadata = record['metadata'];
|
|
252
|
+
}
|
|
253
|
+
attachments.push(attachment);
|
|
254
|
+
}
|
|
255
|
+
return attachments;
|
|
256
|
+
}
|
|
228
257
|
// ---------------------------------------------------------------------------
|
|
229
258
|
// POST /api/companion/chat/sessions/:sessionId/messages
|
|
230
259
|
// ---------------------------------------------------------------------------
|
|
@@ -245,17 +274,23 @@ async function handlePostMessage(req, sessionId, context) {
|
|
|
245
274
|
: typeof body['content'] === 'string'
|
|
246
275
|
? body['content']
|
|
247
276
|
: '';
|
|
277
|
+
const attachments = readCompanionChatAttachments(body);
|
|
278
|
+
if (attachments instanceof Response)
|
|
279
|
+
return attachments;
|
|
248
280
|
const input = {
|
|
249
281
|
content: rawContent,
|
|
282
|
+
attachments,
|
|
250
283
|
metadata: typeof body['metadata'] === 'object' && body['metadata'] !== null
|
|
251
284
|
? body['metadata']
|
|
252
285
|
: undefined,
|
|
253
286
|
};
|
|
254
|
-
if (!input.content.trim()) {
|
|
255
|
-
return Response.json({ error: 'content or
|
|
287
|
+
if (!input.content.trim() && attachments.length === 0) {
|
|
288
|
+
return Response.json({ error: 'content, body, or attachments are required', code: 'INVALID_INPUT' }, { status: 400 });
|
|
256
289
|
}
|
|
257
290
|
try {
|
|
258
|
-
const messageId = await context.chatManager.postMessage(sessionId, input.content
|
|
291
|
+
const messageId = await context.chatManager.postMessage(sessionId, input.content, '', {
|
|
292
|
+
attachments: input.attachments,
|
|
293
|
+
});
|
|
259
294
|
return Response.json({ messageId }, { status: 202 });
|
|
260
295
|
}
|
|
261
296
|
catch (err) {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* via CompanionChatPersistence so they survive daemon restarts.
|
|
8
8
|
*/
|
|
9
9
|
import type { ConversationMessageEnvelope } from '../control-plane/conversation-message.js';
|
|
10
|
+
import type { ArtifactDescriptor } from '../artifacts/index.js';
|
|
10
11
|
/**
|
|
11
12
|
* Re-export the shared envelope so chat-mode code can import from one place.
|
|
12
13
|
* The envelope shape is the canonical message unit flowing through
|
|
@@ -16,11 +17,21 @@ export type { ConversationMessageEnvelope } from '../control-plane/conversation-
|
|
|
16
17
|
export type CompanionChatSessionKind = 'companion-chat';
|
|
17
18
|
export type CompanionChatSessionStatus = 'active' | 'closed';
|
|
18
19
|
export type CompanionChatMessageRole = 'user' | 'assistant';
|
|
20
|
+
export interface CompanionChatMessageAttachmentInput {
|
|
21
|
+
readonly artifactId: string;
|
|
22
|
+
readonly label?: string | undefined;
|
|
23
|
+
readonly metadata?: Record<string, unknown> | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface CompanionChatMessageAttachment extends ArtifactDescriptor {
|
|
26
|
+
readonly artifactId: string;
|
|
27
|
+
readonly label?: string | undefined;
|
|
28
|
+
}
|
|
19
29
|
export interface CompanionChatMessage {
|
|
20
30
|
readonly id: string;
|
|
21
31
|
readonly sessionId: string;
|
|
22
32
|
readonly role: CompanionChatMessageRole;
|
|
23
33
|
readonly content: string;
|
|
34
|
+
readonly attachments: readonly CompanionChatMessageAttachment[];
|
|
24
35
|
readonly createdAt: number;
|
|
25
36
|
}
|
|
26
37
|
export interface CompanionChatSession {
|
|
@@ -70,6 +81,7 @@ export interface UpdateCompanionChatSessionOutput {
|
|
|
70
81
|
}
|
|
71
82
|
export interface PostCompanionChatMessageInput {
|
|
72
83
|
readonly content: string;
|
|
84
|
+
readonly attachments?: readonly CompanionChatMessageAttachmentInput[] | undefined;
|
|
73
85
|
readonly metadata?: Record<string, unknown> | undefined;
|
|
74
86
|
}
|
|
75
87
|
export interface PostCompanionChatMessageOutput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"companion-chat-types.d.ts","sourceRoot":"","sources":["../../../src/platform/companion/companion-chat-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"companion-chat-types.d.ts","sourceRoot":"","sources":["../../../src/platform/companion/companion-chat-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAC5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;GAIG;AACH,YAAY,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAE5F,MAAM,MAAM,wBAAwB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ChatMessageRole, CompanionChatTurnEvent, CompanionChatTurnStartedEvent, CompanionChatTurnDeltaEvent, CompanionChatTurnToolCallEvent, CompanionChatTurnToolResultEvent, CompanionChatTurnCompletedEvent, CompanionChatTurnErrorEvent, CreateCompanionChatSessionInput, CreateCompanionChatSessionOutput, ListCompanionChatSessionsInput, ListCompanionChatSessionsOutput, UpdateCompanionChatSessionInput, UpdateCompanionChatSessionOutput, PostCompanionChatMessageInput, PostCompanionChatMessageOutput, GetCompanionChatSessionOutput, ConversationMessageEnvelope, } from './companion-chat-types.js';
|
|
2
|
-
export type { CompanionLLMProvider, CompanionChatEventPublisher, CompanionChatManagerConfig, CompanionProviderMessage, CompanionProviderChunk, } from './companion-chat-manager.js';
|
|
1
|
+
export type { CompanionChatMessage, CompanionChatMessageAttachment, CompanionChatMessageAttachmentInput, CompanionChatSession, CompanionChatSessionKind, CompanionChatSessionStatus, CompanionChatMessageRole, CompanionChatTurnEvent, CompanionChatTurnStartedEvent, CompanionChatTurnDeltaEvent, CompanionChatTurnToolCallEvent, CompanionChatTurnToolResultEvent, CompanionChatTurnCompletedEvent, CompanionChatTurnErrorEvent, CreateCompanionChatSessionInput, CreateCompanionChatSessionOutput, ListCompanionChatSessionsInput, ListCompanionChatSessionsOutput, UpdateCompanionChatSessionInput, UpdateCompanionChatSessionOutput, PostCompanionChatMessageInput, PostCompanionChatMessageOutput, GetCompanionChatSessionOutput, ConversationMessageEnvelope, } from './companion-chat-types.js';
|
|
2
|
+
export type { CompanionLLMProvider, CompanionChatEventPublisher, CompanionChatManagerConfig, CompanionChatArtifactStore, CompanionProviderMessage, CompanionProviderChunk, } from './companion-chat-manager.js';
|
|
3
3
|
export { CompanionChatManager } from './companion-chat-manager.js';
|
|
4
4
|
export { dispatchCompanionChatRoutes } from './companion-chat-routes.js';
|
|
5
5
|
export type { CompanionChatRouteContext } from './companion-chat-route-types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platform/companion/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,gCAAgC,EAChC,+BAA+B,EAC/B,2BAA2B,EAC3B,+BAA+B,EAC/B,gCAAgC,EAChC,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,gCAAgC,EAChC,6BAA6B,EAC7B,8BAA8B,EAC9B,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,oBAAoB,EACpB,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,YAAY,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC/F,YAAY,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,YAAY,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platform/companion/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,mCAAmC,EACnC,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,gCAAgC,EAChC,+BAA+B,EAC/B,2BAA2B,EAC3B,+BAA+B,EAC/B,gCAAgC,EAChC,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,gCAAgC,EAChC,6BAA6B,EAC7B,8BAA8B,EAC9B,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,oBAAoB,EACpB,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,YAAY,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC/F,YAAY,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,YAAY,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ArtifactDescriptor } from '../artifacts/index.js';
|
|
1
2
|
/**
|
|
2
3
|
* conversation-message.ts
|
|
3
4
|
*
|
|
@@ -23,6 +24,11 @@ export interface ConversationMessageEnvelope {
|
|
|
23
24
|
readonly body: string;
|
|
24
25
|
readonly source: MessageSource;
|
|
25
26
|
readonly timestamp: number;
|
|
27
|
+
/** Artifacts attached to this conversation message. */
|
|
28
|
+
readonly attachments?: readonly (ArtifactDescriptor & {
|
|
29
|
+
readonly artifactId: string;
|
|
30
|
+
readonly label?: string | undefined;
|
|
31
|
+
})[] | undefined;
|
|
26
32
|
/** Optional metadata for tool info, model id, etc. */
|
|
27
33
|
readonly metadata?: Readonly<Record<string, unknown>> | undefined;
|
|
28
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-message.d.ts","sourceRoot":"","sources":["../../../src/platform/control-plane/conversation-message.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,qBAAqB,GACrB,0BAA0B,GAC1B,oBAAoB,GACpB,WAAW,GACX,QAAQ,GACR,MAAM,CAAC;AAEX;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CACnE"}
|
|
1
|
+
{"version":3,"file":"conversation-message.d.ts","sourceRoot":"","sources":["../../../src/platform/control-plane/conversation-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,qBAAqB,GACrB,0BAA0B,GAC1B,oBAAoB,GACpB,WAAW,GACX,QAAQ,GACR,MAAM,CAAC;AAEX;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,kBAAkB,GAAG;QACpD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACrC,CAAC,EAAE,GAAG,SAAS,CAAC;IACjB,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CACnE"}
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* conversation-message.ts
|
|
3
|
-
*
|
|
4
|
-
* Shared envelope types for conversation messages flowing through the
|
|
5
|
-
* control-plane gateway. All consumers — SSE companion-chat streams,
|
|
6
|
-
* TUI-surface follow-up listeners, and web-UI clients — depend on this
|
|
7
|
-
* stable shape.
|
|
8
|
-
*/
|
|
9
1
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-catalog-control-core.d.ts","sourceRoot":"","sources":["../../../src/platform/control-plane/method-catalog-control-core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AA4D1E,eAAO,MAAM,0CAA0C,EAAE,SAAS,uBAAuB,
|
|
1
|
+
{"version":3,"file":"method-catalog-control-core.d.ts","sourceRoot":"","sources":["../../../src/platform/control-plane/method-catalog-control-core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AA4D1E,eAAO,MAAM,0CAA0C,EAAE,SAAS,uBAAuB,EAunBxF,CAAC"}
|
|
@@ -591,13 +591,18 @@ export const builtinGatewayControlCoreMethodDescriptors = [
|
|
|
591
591
|
methodDescriptor({
|
|
592
592
|
id: 'companion.chat.messages.create',
|
|
593
593
|
title: 'Send Companion Chat Message',
|
|
594
|
-
description: 'Post a user message to a companion-chat session. Accepts either `body` or `content` in the payload; `body` wins when both are provided.',
|
|
594
|
+
description: 'Post a user message to a companion-chat session. Accepts either `body` or `content` in the payload; `body` wins when both are provided. Attachments reference artifacts created through `artifacts.create`.',
|
|
595
595
|
category: 'companion',
|
|
596
596
|
scopes: ['write:sessions'],
|
|
597
597
|
http: { method: 'POST', path: '/api/companion/chat/sessions/{sessionId}/messages' },
|
|
598
598
|
inputSchema: bodyEnvelopeSchema({
|
|
599
599
|
body: STRING_SCHEMA,
|
|
600
600
|
content: STRING_SCHEMA,
|
|
601
|
+
attachments: arraySchema(objectSchema({
|
|
602
|
+
artifactId: STRING_SCHEMA,
|
|
603
|
+
label: STRING_SCHEMA,
|
|
604
|
+
metadata: objectSchema({}, []),
|
|
605
|
+
}, ['artifactId'])),
|
|
601
606
|
metadata: objectSchema({}, []),
|
|
602
607
|
}, []),
|
|
603
608
|
outputSchema: objectSchema({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-catalog-knowledge.d.ts","sourceRoot":"","sources":["../../../src/platform/control-plane/method-catalog-knowledge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"method-catalog-knowledge.d.ts","sourceRoot":"","sources":["../../../src/platform/control-plane/method-catalog-knowledge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAkE1E,eAAO,MAAM,wCAAwC,EAAE,SAAS,uBAAuB,EAmuBtF,CAAC"}
|
|
@@ -3,6 +3,10 @@ import { builtinGatewayHomeGraphMethodDescriptors } from './method-catalog-homeg
|
|
|
3
3
|
import { GRAPHQL_VARIABLES_SCHEMA, JSON_RECORD_SCHEMA, METADATA_SCHEMA, STRING_LIST_SCHEMA } from './operator-contract-schemas-shared.js';
|
|
4
4
|
import { KNOWLEDGE_BATCH_INGEST_RESULT_SCHEMA, KNOWLEDGE_BROWSER_SYNC_RESULT_SCHEMA, KNOWLEDGE_ASK_OUTPUT_SCHEMA, KNOWLEDGE_CONSOLIDATION_DECISION_SCHEMA, KNOWLEDGE_CANDIDATE_OUTPUT_SCHEMA, KNOWLEDGE_CANDIDATES_OUTPUT_SCHEMA, KNOWLEDGE_CONNECTOR_INGEST_INPUT_SCHEMA, KNOWLEDGE_CONNECTOR_DOCTOR_OUTPUT_SCHEMA, KNOWLEDGE_CONNECTORS_OUTPUT_SCHEMA, KNOWLEDGE_CONNECTOR_ENTITY_OUTPUT_SCHEMA, KNOWLEDGE_EXTRACTION_OUTPUT_SCHEMA, KNOWLEDGE_EXTRACTIONS_OUTPUT_SCHEMA, KNOWLEDGE_GRAPHQL_EXECUTE_OUTPUT_SCHEMA, KNOWLEDGE_GRAPHQL_SCHEMA_OUTPUT_SCHEMA, KNOWLEDGE_INGEST_RESULT_SCHEMA, KNOWLEDGE_ITEM_ENTITY_OUTPUT_SCHEMA, KNOWLEDGE_JOB_OUTPUT_SCHEMA, KNOWLEDGE_JOB_RUN_OUTPUT_SCHEMA, KNOWLEDGE_JOB_RUN_REQUEST_SCHEMA, KNOWLEDGE_JOB_RUNS_OUTPUT_SCHEMA, KNOWLEDGE_JOBS_OUTPUT_SCHEMA, KNOWLEDGE_LINT_OUTPUT_SCHEMA, KNOWLEDGE_MAP_OUTPUT_SCHEMA, KNOWLEDGE_MATERIALIZED_PROJECTION_SCHEMA, KNOWLEDGE_NODES_OUTPUT_SCHEMA, KNOWLEDGE_PACKET_SCHEMA, KNOWLEDGE_PACKET_DETAIL_SCHEMA, KNOWLEDGE_PROJECTION_BUNDLE_SCHEMA, KNOWLEDGE_PROJECTION_TARGETS_OUTPUT_SCHEMA, KNOWLEDGE_REINDEX_OUTPUT_SCHEMA, KNOWLEDGE_REFINEMENT_RUN_OUTPUT_SCHEMA, KNOWLEDGE_REFINEMENT_TASK_OUTPUT_SCHEMA, KNOWLEDGE_REFINEMENT_TASKS_OUTPUT_SCHEMA, KNOWLEDGE_REPORT_OUTPUT_SCHEMA, KNOWLEDGE_REPORTS_OUTPUT_SCHEMA, KNOWLEDGE_SCHEDULE_INPUT_SCHEMA, KNOWLEDGE_SCHEDULE_OUTPUT_SCHEMA, KNOWLEDGE_SCHEDULES_OUTPUT_SCHEMA, KNOWLEDGE_SEARCH_OUTPUT_SCHEMA, KNOWLEDGE_SOURCE_TYPE_SCHEMA, KNOWLEDGE_SOURCES_OUTPUT_SCHEMA, KNOWLEDGE_STATUS_SCHEMA, KNOWLEDGE_ISSUE_REVIEW_OUTPUT_SCHEMA, KNOWLEDGE_ISSUES_OUTPUT_SCHEMA, KNOWLEDGE_USAGE_OUTPUT_SCHEMA, } from './operator-contract-schemas-knowledge.js';
|
|
5
5
|
import { PROJECT_PLANNING_DECISION_OUTPUT_SCHEMA, PROJECT_PLANNING_DECISIONS_OUTPUT_SCHEMA, PROJECT_PLANNING_EVALUATION_SCHEMA, PROJECT_PLANNING_LANGUAGE_OUTPUT_SCHEMA, PROJECT_PLANNING_SPACE_INPUT_SCHEMA, PROJECT_PLANNING_STATE_OUTPUT_SCHEMA, PROJECT_PLANNING_STATUS_SCHEMA, } from './operator-contract-schemas-project-planning.js';
|
|
6
|
+
const KNOWLEDGE_SPACE_INPUT_FIELDS = {
|
|
7
|
+
knowledgeSpaceId: STRING_SCHEMA,
|
|
8
|
+
includeAllSpaces: BOOLEAN_SCHEMA,
|
|
9
|
+
};
|
|
6
10
|
export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
7
11
|
methodDescriptor({
|
|
8
12
|
id: 'knowledge.status',
|
|
@@ -11,7 +15,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
11
15
|
category: 'knowledge',
|
|
12
16
|
scopes: ['read:knowledge'],
|
|
13
17
|
http: { method: 'GET', path: '/api/knowledge/status' },
|
|
14
|
-
inputSchema:
|
|
18
|
+
inputSchema: objectSchema(KNOWLEDGE_SPACE_INPUT_FIELDS),
|
|
15
19
|
outputSchema: KNOWLEDGE_STATUS_SCHEMA,
|
|
16
20
|
}),
|
|
17
21
|
methodDescriptor({
|
|
@@ -21,7 +25,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
21
25
|
category: 'knowledge',
|
|
22
26
|
scopes: ['read:knowledge'],
|
|
23
27
|
http: { method: 'GET', path: '/api/knowledge/sources' },
|
|
24
|
-
inputSchema: objectSchema({ limit: NUMBER_SCHEMA }),
|
|
28
|
+
inputSchema: objectSchema({ limit: NUMBER_SCHEMA, ...KNOWLEDGE_SPACE_INPUT_FIELDS }),
|
|
25
29
|
outputSchema: KNOWLEDGE_SOURCES_OUTPUT_SCHEMA,
|
|
26
30
|
}),
|
|
27
31
|
methodDescriptor({
|
|
@@ -31,7 +35,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
31
35
|
category: 'knowledge',
|
|
32
36
|
scopes: ['read:knowledge'],
|
|
33
37
|
http: { method: 'GET', path: '/api/knowledge/nodes' },
|
|
34
|
-
inputSchema: objectSchema({ limit: NUMBER_SCHEMA }),
|
|
38
|
+
inputSchema: objectSchema({ limit: NUMBER_SCHEMA, ...KNOWLEDGE_SPACE_INPUT_FIELDS }),
|
|
35
39
|
outputSchema: KNOWLEDGE_NODES_OUTPUT_SCHEMA,
|
|
36
40
|
}),
|
|
37
41
|
methodDescriptor({
|
|
@@ -41,7 +45,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
41
45
|
category: 'knowledge',
|
|
42
46
|
scopes: ['read:knowledge'],
|
|
43
47
|
http: { method: 'GET', path: '/api/knowledge/issues' },
|
|
44
|
-
inputSchema: objectSchema({ limit: NUMBER_SCHEMA }),
|
|
48
|
+
inputSchema: objectSchema({ limit: NUMBER_SCHEMA, ...KNOWLEDGE_SPACE_INPUT_FIELDS }),
|
|
45
49
|
outputSchema: KNOWLEDGE_ISSUES_OUTPUT_SCHEMA,
|
|
46
50
|
}),
|
|
47
51
|
methodDescriptor({
|
|
@@ -67,7 +71,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
67
71
|
category: 'knowledge',
|
|
68
72
|
scopes: ['read:knowledge'],
|
|
69
73
|
http: { method: 'GET', path: '/api/knowledge/items/{id}' },
|
|
70
|
-
inputSchema: objectSchema({ id: STRING_SCHEMA }, ['id']),
|
|
74
|
+
inputSchema: objectSchema({ id: STRING_SCHEMA, ...KNOWLEDGE_SPACE_INPUT_FIELDS }, ['id']),
|
|
71
75
|
outputSchema: KNOWLEDGE_ITEM_ENTITY_OUTPUT_SCHEMA,
|
|
72
76
|
}),
|
|
73
77
|
methodDescriptor({
|
|
@@ -220,6 +224,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
220
224
|
inputSchema: bodyEnvelopeSchema({
|
|
221
225
|
query: STRING_SCHEMA,
|
|
222
226
|
limit: NUMBER_SCHEMA,
|
|
227
|
+
...KNOWLEDGE_SPACE_INPUT_FIELDS,
|
|
223
228
|
includeSources: BOOLEAN_SCHEMA,
|
|
224
229
|
includeNodes: BOOLEAN_SCHEMA,
|
|
225
230
|
metadata: METADATA_SCHEMA,
|
|
@@ -256,7 +261,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
256
261
|
category: 'knowledge',
|
|
257
262
|
scopes: ['read:knowledge'],
|
|
258
263
|
http: { method: 'GET', path: '/api/knowledge/extractions' },
|
|
259
|
-
inputSchema: objectSchema({ limit: NUMBER_SCHEMA, sourceId: STRING_SCHEMA }),
|
|
264
|
+
inputSchema: objectSchema({ limit: NUMBER_SCHEMA, sourceId: STRING_SCHEMA, ...KNOWLEDGE_SPACE_INPUT_FIELDS }),
|
|
260
265
|
outputSchema: KNOWLEDGE_EXTRACTIONS_OUTPUT_SCHEMA,
|
|
261
266
|
}),
|
|
262
267
|
methodDescriptor({
|
|
@@ -291,6 +296,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
291
296
|
writeScope: arraySchema(STRING_SCHEMA),
|
|
292
297
|
budgetLimit: NUMBER_SCHEMA,
|
|
293
298
|
detail: KNOWLEDGE_PACKET_DETAIL_SCHEMA,
|
|
299
|
+
...KNOWLEDGE_SPACE_INPUT_FIELDS,
|
|
294
300
|
}, ['task']),
|
|
295
301
|
outputSchema: KNOWLEDGE_PACKET_SCHEMA,
|
|
296
302
|
}),
|
|
@@ -347,7 +353,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
347
353
|
category: 'knowledge',
|
|
348
354
|
scopes: ['read:knowledge'],
|
|
349
355
|
http: { method: 'GET', path: '/api/knowledge/reports' },
|
|
350
|
-
inputSchema: objectSchema({ limit: NUMBER_SCHEMA }),
|
|
356
|
+
inputSchema: objectSchema({ limit: NUMBER_SCHEMA, ...KNOWLEDGE_SPACE_INPUT_FIELDS }),
|
|
351
357
|
outputSchema: KNOWLEDGE_REPORTS_OUTPUT_SCHEMA,
|
|
352
358
|
}),
|
|
353
359
|
methodDescriptor({
|
|
@@ -563,6 +569,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
563
569
|
http: { method: 'GET', path: '/api/knowledge/map' },
|
|
564
570
|
inputSchema: objectSchema({
|
|
565
571
|
limit: NUMBER_SCHEMA,
|
|
572
|
+
...KNOWLEDGE_SPACE_INPUT_FIELDS,
|
|
566
573
|
includeSources: BOOLEAN_SCHEMA,
|
|
567
574
|
includeIssues: BOOLEAN_SCHEMA,
|
|
568
575
|
includeGenerated: BOOLEAN_SCHEMA,
|
|
@@ -594,6 +601,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
594
601
|
kind: STRING_SCHEMA,
|
|
595
602
|
id: STRING_SCHEMA,
|
|
596
603
|
limit: NUMBER_SCHEMA,
|
|
604
|
+
...KNOWLEDGE_SPACE_INPUT_FIELDS,
|
|
597
605
|
}, ['kind']),
|
|
598
606
|
outputSchema: KNOWLEDGE_PROJECTION_BUNDLE_SCHEMA,
|
|
599
607
|
}),
|
|
@@ -609,6 +617,7 @@ export const builtinGatewayKnowledgeMethodDescriptors = [
|
|
|
609
617
|
kind: STRING_SCHEMA,
|
|
610
618
|
id: STRING_SCHEMA,
|
|
611
619
|
limit: NUMBER_SCHEMA,
|
|
620
|
+
...KNOWLEDGE_SPACE_INPUT_FIELDS,
|
|
612
621
|
}, ['kind']),
|
|
613
622
|
outputSchema: KNOWLEDGE_MATERIALIZED_PROJECTION_SCHEMA,
|
|
614
623
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator-contract-schemas-runtime.d.ts","sourceRoot":"","sources":["../../../src/platform/control-plane/operator-contract-schemas-runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operator-contract-schemas-runtime.d.ts","sourceRoot":"","sources":["../../../src/platform/control-plane/operator-contract-schemas-runtime.ts"],"names":[],"mappings":"AA+DA,eAAO,MAAM,iCAAiC,yBAQA,CAAC;AAE/C,eAAO,MAAM,6BAA6B,yBAasB,CAAC;AAEjE,eAAO,MAAM,4BAA4B,yBAmBqI,CAAC;AAE/K,eAAO,MAAM,6BAA6B,yBAYsF,CAAC;AAEjI,eAAO,MAAM,6BAA6B,yBAO4B,CAAC;AAEvE,eAAO,MAAM,2CAA2C,yBAG7B,CAAC;AAE5B,eAAO,MAAM,mCAAmC,yBAOtB,CAAC;AAE3B,eAAO,MAAM,mCAAmC,yBAGnB,CAAC;AAE9B,eAAO,MAAM,oCAAoC,yBAkB/C,CAAC;AAEH,eAAO,MAAM,kCAAkC,yBAqB0D,CAAC;AAE1G,eAAO,MAAM,uBAAuB,yBAWoE,CAAC;AAEzG,eAAO,MAAM,8BAA8B,yBAOjB,CAAC;AAE3B,eAAO,MAAM,mCAAmC,yBAGrB,CAAC;AAE5B,eAAO,MAAM,iCAAiC,yBAGrB,CAAC;AAE1B,eAAO,MAAM,mCAAmC,yBAEjC,CAAC;AAEhB,eAAO,MAAM,+CAA+C,yBAIlB,CAAC;AAE3C,eAAO,MAAM,2CAA2C,yBAMF,CAAC;AAEvD,eAAO,MAAM,0CAA0C;;CAK7C,CAAC;AAUX,eAAO,MAAM,mBAAmB,yBAqByD,CAAC;AAE1F,eAAO,MAAM,oBAAoB,yBAsBsB,CAAC;AAExD,eAAO,MAAM,wBAAwB,yBAgBO,CAAC;AAE7C,eAAO,MAAM,yBAAyB,yBASc,CAAC;AAErD,eAAO,MAAM,kBAAkB,yBAEnB,CAAC;AAEb,eAAO,MAAM,yBAAyB,yBAIM,CAAC;AAE7C,eAAO,MAAM,yBAAyB,yBAUiE,CAAC;AAWxG,eAAO,MAAM,6BAA6B,yBAgB8C,CAAC;AAEzF,eAAO,MAAM,wBAAwB,yBASuG,CAAC;AAE7I,eAAO,MAAM,4BAA4B,yBAIU,CAAC;AAEpD,eAAO,MAAM,6BAA6B,yBAE1B,CAAC;AA0EjB,eAAO,MAAM,gCAAgC,yBAMkB,CAAC;AAEhE,eAAO,MAAM,8BAA8B,yBAcqD,CAAC;AAqEjG,eAAO,MAAM,gCAAgC,yBAKmB,CAAC;AAEjE,eAAO,MAAM,sBAAsB,yBAcyF,CAAC;AAE7H,eAAO,MAAM,4BAA4B,yBASyG,CAAC;AAqBnJ,eAAO,MAAM,0BAA0B,yBAUyH,CAAC;AAEjK,eAAO,MAAM,2BAA2B,yBAIC,CAAC"}
|
|
@@ -24,6 +24,22 @@ const PROVIDER_FAILURE_POLICY_SCHEMA = enumSchema(['ordered-fallbacks', 'fail'])
|
|
|
24
24
|
const EXECUTION_RISK_CLASS_SCHEMA = enumSchema(['safe', 'elevated', 'dangerous']);
|
|
25
25
|
const EXECUTION_NETWORK_POLICY_SCHEMA = enumSchema(['inherit', 'allow', 'deny', 'scoped']);
|
|
26
26
|
const EXECUTION_FILESYSTEM_POLICY_SCHEMA = enumSchema(['inherit', 'workspace-write', 'read-only', 'isolated']);
|
|
27
|
+
const COMPANION_CHAT_ATTACHMENT_SCHEMA = objectSchema({
|
|
28
|
+
id: STRING_SCHEMA,
|
|
29
|
+
artifactId: STRING_SCHEMA,
|
|
30
|
+
kind: STRING_SCHEMA,
|
|
31
|
+
mimeType: STRING_SCHEMA,
|
|
32
|
+
filename: STRING_SCHEMA,
|
|
33
|
+
sizeBytes: NUMBER_SCHEMA,
|
|
34
|
+
sha256: STRING_SCHEMA,
|
|
35
|
+
createdAt: NUMBER_SCHEMA,
|
|
36
|
+
expiresAt: NUMBER_SCHEMA,
|
|
37
|
+
sourceUri: STRING_SCHEMA,
|
|
38
|
+
acquisitionMode: STRING_SCHEMA,
|
|
39
|
+
fetchMode: STRING_SCHEMA,
|
|
40
|
+
label: STRING_SCHEMA,
|
|
41
|
+
metadata: METADATA_SCHEMA,
|
|
42
|
+
}, ['id', 'artifactId', 'kind', 'mimeType', 'sizeBytes', 'sha256', 'createdAt', 'metadata'], { additionalProperties: true });
|
|
27
43
|
export const SHARED_SESSION_PARTICIPANT_SCHEMA = objectSchema({
|
|
28
44
|
surfaceKind: STRING_SCHEMA,
|
|
29
45
|
surfaceId: STRING_SCHEMA,
|
|
@@ -85,8 +101,9 @@ export const COMPANION_CHAT_MESSAGE_SCHEMA = objectSchema({
|
|
|
85
101
|
sessionId: STRING_SCHEMA,
|
|
86
102
|
role: COMPANION_CHAT_MESSAGE_ROLE_SCHEMA,
|
|
87
103
|
content: STRING_SCHEMA,
|
|
104
|
+
attachments: arraySchema(COMPANION_CHAT_ATTACHMENT_SCHEMA),
|
|
88
105
|
createdAt: NUMBER_SCHEMA,
|
|
89
|
-
}, ['id', 'sessionId', 'role', 'content', 'createdAt']);
|
|
106
|
+
}, ['id', 'sessionId', 'role', 'content', 'attachments', 'createdAt']);
|
|
90
107
|
export const COMPANION_CHAT_SESSION_WITH_MESSAGES_SCHEMA = objectSchema({
|
|
91
108
|
session: COMPANION_CHAT_SESSION_SCHEMA,
|
|
92
109
|
messages: arraySchema(COMPANION_CHAT_MESSAGE_SCHEMA),
|