@axiom-lattice/protocols 4.1.3 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +22 -0
- package/dist/index.d.mts +103 -7
- package/dist/index.d.ts +103 -7
- package/dist/index.js +92 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/AgentWebAppRuntimeProtocol.ts +2 -1
- package/src/AgentWebAppStoreProtocol.ts +31 -0
- package/src/AgentWebAppStreamProjection.ts +104 -0
- package/src/McpLatticeProtocol.ts +7 -1
- package/src/McpServerConfigStoreProtocol.ts +2 -1
- package/src/ProjectRoomMessageStoreProtocol.ts +8 -0
- package/src/ProjectRoomReadStateProtocol.ts +20 -0
- package/src/ProjectRoomRealtimeProtocol.ts +28 -3
- package/src/__tests__/ProjectRoomReadStateProtocol.test.ts +16 -0
- package/src/__tests__/ProjectRoomStores.test.ts +4 -0
- package/src/index.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -451,6 +451,85 @@ function hasOnlyKeys(value, required, optional) {
|
|
|
451
451
|
return required.every((key) => key in value) && keys.every((key) => required.includes(key) || optional.includes(key));
|
|
452
452
|
}
|
|
453
453
|
|
|
454
|
+
// src/AgentWebAppStreamProjection.ts
|
|
455
|
+
function createAgentWebAppStreamProjectionContext(options = {}) {
|
|
456
|
+
return { startedToolIds: /* @__PURE__ */ new Set(), allowInterrupts: options.allowInterrupts ?? true, allowGenUI: options.allowGenUI ?? false };
|
|
457
|
+
}
|
|
458
|
+
function projectAgentWebAppChunk(chunk, context) {
|
|
459
|
+
if (chunk.type === MessageChunkTypes.AI) {
|
|
460
|
+
const events = [];
|
|
461
|
+
const startedToolIds = context?.startedToolIds ?? /* @__PURE__ */ new Set();
|
|
462
|
+
if (typeof chunk.data.content === "string" && chunk.data.content) events.push({ type: "message.delta", text: chunk.data.content });
|
|
463
|
+
if (context?.allowGenUI && Array.isArray(chunk.data.content)) {
|
|
464
|
+
for (const value of chunk.data.content) {
|
|
465
|
+
const block = parseAgentWebAppGenUIBlock(value);
|
|
466
|
+
if (block) events.push({ type: "genui.render", block });
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
for (const call of chunk.data.tool_call_chunks ?? []) {
|
|
470
|
+
if (call.id && call.name && !startedToolIds.has(call.id)) {
|
|
471
|
+
startedToolIds.add(call.id);
|
|
472
|
+
events.push({ type: "tool.started", id: call.id, name: call.name });
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
for (const call of chunk.data.tool_calls ?? []) {
|
|
476
|
+
if (!startedToolIds.has(call.id)) {
|
|
477
|
+
startedToolIds.add(call.id);
|
|
478
|
+
events.push({ type: "tool.started", id: call.id, name: call.name });
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return events;
|
|
482
|
+
}
|
|
483
|
+
if (chunk.type === MessageChunkTypes.TOOL && chunk.data.tool_call_id) {
|
|
484
|
+
return [{ type: "tool.completed", id: chunk.data.tool_call_id }];
|
|
485
|
+
}
|
|
486
|
+
if (chunk.type === MessageChunkTypes.INTERRUPT) {
|
|
487
|
+
if (context && !context.allowInterrupts) return [{ type: "stream.completed" }];
|
|
488
|
+
const interrupt = publicInterrupt(chunk);
|
|
489
|
+
return interrupt ? [{ type: "interrupt.created", interrupt }, { type: "stream.completed" }] : [{ type: "stream.completed" }];
|
|
490
|
+
}
|
|
491
|
+
if (chunk.type === MessageChunkTypes.MESSAGE_COMPLETED) {
|
|
492
|
+
return [
|
|
493
|
+
{ type: "message.completed", messageId: chunk.data.id },
|
|
494
|
+
{ type: "stream.completed" }
|
|
495
|
+
];
|
|
496
|
+
}
|
|
497
|
+
if (chunk.type === MessageChunkTypes.MESSAGE_FAILED) {
|
|
498
|
+
return [
|
|
499
|
+
{ type: "error", error: { code: "STREAM_FAILED", message: "Stream failed", retryable: true } },
|
|
500
|
+
{ type: "stream.completed" }
|
|
501
|
+
];
|
|
502
|
+
}
|
|
503
|
+
return [];
|
|
504
|
+
}
|
|
505
|
+
function publicInterrupt(chunk) {
|
|
506
|
+
const value = parseInterruptContent(chunk.data.content);
|
|
507
|
+
if (!value) return void 0;
|
|
508
|
+
const topLevelId = chunk.id;
|
|
509
|
+
const id = typeof topLevelId === "string" ? topLevelId : chunk.data.id;
|
|
510
|
+
if (!id) return void 0;
|
|
511
|
+
return {
|
|
512
|
+
id,
|
|
513
|
+
type: typeof value.type === "string" ? value.type : "input",
|
|
514
|
+
prompt: typeof value.prompt === "string" ? value.prompt : typeof value.message === "string" ? value.message : "Input required",
|
|
515
|
+
...isRecord2(value.data) ? { data: value.data } : {}
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
function parseInterruptContent(content) {
|
|
519
|
+
if (!content) return {};
|
|
520
|
+
if (isRecord2(content)) return content;
|
|
521
|
+
if (typeof content !== "string") return void 0;
|
|
522
|
+
try {
|
|
523
|
+
const parsed = JSON.parse(content);
|
|
524
|
+
return isRecord2(parsed) ? parsed : { prompt: content };
|
|
525
|
+
} catch {
|
|
526
|
+
return { prompt: content };
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
function isRecord2(value) {
|
|
530
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
531
|
+
}
|
|
532
|
+
|
|
454
533
|
// src/ExactDataSnapshot.ts
|
|
455
534
|
function ownDescriptorField(descriptor, key) {
|
|
456
535
|
const field = Object.getOwnPropertyDescriptor(descriptor, key);
|
|
@@ -550,6 +629,11 @@ function parseProjectRoomEventId(value) {
|
|
|
550
629
|
function isProjectRoomEventId(value) {
|
|
551
630
|
return parseProjectRoomEventId(value) !== void 0;
|
|
552
631
|
}
|
|
632
|
+
var PROJECT_ROOM_USER_CHANNEL_PROJECT = "__user_channel__";
|
|
633
|
+
function projectRoomUserEventScope(tenantId, userId) {
|
|
634
|
+
if (!tenantId || !userId) throw new TypeError("Project Room user scope requires non-empty identifiers");
|
|
635
|
+
return { tenantId, roomId: `__user__:${userId}`, projectId: PROJECT_ROOM_USER_CHANNEL_PROJECT };
|
|
636
|
+
}
|
|
553
637
|
function isoDate(value) {
|
|
554
638
|
if (typeof value !== "object" || value === null) return void 0;
|
|
555
639
|
try {
|
|
@@ -786,6 +870,7 @@ export {
|
|
|
786
870
|
McpMessageType,
|
|
787
871
|
MemoryType,
|
|
788
872
|
MessageChunkTypes,
|
|
873
|
+
PROJECT_ROOM_USER_CHANNEL_PROJECT,
|
|
789
874
|
PROJECT_TASK_LIFECYCLE_ACTIONS,
|
|
790
875
|
ProjectRoomBrokerCapacityError,
|
|
791
876
|
ProjectRoomCursorError,
|
|
@@ -796,6 +881,7 @@ export {
|
|
|
796
881
|
ScheduledTaskStatus,
|
|
797
882
|
UIComponentType,
|
|
798
883
|
assertGenericProjectConfig,
|
|
884
|
+
createAgentWebAppStreamProjectionContext,
|
|
799
885
|
descriptorDataValue,
|
|
800
886
|
getSubAgentsFromConfig,
|
|
801
887
|
getToolsFromConfig,
|
|
@@ -812,6 +898,8 @@ export {
|
|
|
812
898
|
parseQueuedExecutionMode,
|
|
813
899
|
parseTaskBeliefState,
|
|
814
900
|
parseTrustedRunContext,
|
|
901
|
+
projectAgentWebAppChunk,
|
|
902
|
+
projectRoomUserEventScope,
|
|
815
903
|
replaceTaskBeliefState,
|
|
816
904
|
requireProjectTaskWorkItemStore,
|
|
817
905
|
snapshotExactArray,
|