@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.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(index_exports, {
|
|
|
32
32
|
McpMessageType: () => McpMessageType,
|
|
33
33
|
MemoryType: () => MemoryType,
|
|
34
34
|
MessageChunkTypes: () => MessageChunkTypes,
|
|
35
|
+
PROJECT_ROOM_USER_CHANNEL_PROJECT: () => PROJECT_ROOM_USER_CHANNEL_PROJECT,
|
|
35
36
|
PROJECT_TASK_LIFECYCLE_ACTIONS: () => PROJECT_TASK_LIFECYCLE_ACTIONS,
|
|
36
37
|
ProjectRoomBrokerCapacityError: () => ProjectRoomBrokerCapacityError,
|
|
37
38
|
ProjectRoomCursorError: () => ProjectRoomCursorError,
|
|
@@ -42,6 +43,7 @@ __export(index_exports, {
|
|
|
42
43
|
ScheduledTaskStatus: () => ScheduledTaskStatus,
|
|
43
44
|
UIComponentType: () => UIComponentType,
|
|
44
45
|
assertGenericProjectConfig: () => assertGenericProjectConfig,
|
|
46
|
+
createAgentWebAppStreamProjectionContext: () => createAgentWebAppStreamProjectionContext,
|
|
45
47
|
descriptorDataValue: () => descriptorDataValue,
|
|
46
48
|
getSubAgentsFromConfig: () => getSubAgentsFromConfig,
|
|
47
49
|
getToolsFromConfig: () => getToolsFromConfig,
|
|
@@ -58,6 +60,8 @@ __export(index_exports, {
|
|
|
58
60
|
parseQueuedExecutionMode: () => parseQueuedExecutionMode,
|
|
59
61
|
parseTaskBeliefState: () => parseTaskBeliefState,
|
|
60
62
|
parseTrustedRunContext: () => parseTrustedRunContext,
|
|
63
|
+
projectAgentWebAppChunk: () => projectAgentWebAppChunk,
|
|
64
|
+
projectRoomUserEventScope: () => projectRoomUserEventScope,
|
|
61
65
|
replaceTaskBeliefState: () => replaceTaskBeliefState,
|
|
62
66
|
requireProjectTaskWorkItemStore: () => requireProjectTaskWorkItemStore,
|
|
63
67
|
snapshotExactArray: () => snapshotExactArray,
|
|
@@ -525,6 +529,85 @@ function hasOnlyKeys(value, required, optional) {
|
|
|
525
529
|
return required.every((key) => key in value) && keys.every((key) => required.includes(key) || optional.includes(key));
|
|
526
530
|
}
|
|
527
531
|
|
|
532
|
+
// src/AgentWebAppStreamProjection.ts
|
|
533
|
+
function createAgentWebAppStreamProjectionContext(options = {}) {
|
|
534
|
+
return { startedToolIds: /* @__PURE__ */ new Set(), allowInterrupts: options.allowInterrupts ?? true, allowGenUI: options.allowGenUI ?? false };
|
|
535
|
+
}
|
|
536
|
+
function projectAgentWebAppChunk(chunk, context) {
|
|
537
|
+
if (chunk.type === MessageChunkTypes.AI) {
|
|
538
|
+
const events = [];
|
|
539
|
+
const startedToolIds = context?.startedToolIds ?? /* @__PURE__ */ new Set();
|
|
540
|
+
if (typeof chunk.data.content === "string" && chunk.data.content) events.push({ type: "message.delta", text: chunk.data.content });
|
|
541
|
+
if (context?.allowGenUI && Array.isArray(chunk.data.content)) {
|
|
542
|
+
for (const value of chunk.data.content) {
|
|
543
|
+
const block = parseAgentWebAppGenUIBlock(value);
|
|
544
|
+
if (block) events.push({ type: "genui.render", block });
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
for (const call of chunk.data.tool_call_chunks ?? []) {
|
|
548
|
+
if (call.id && call.name && !startedToolIds.has(call.id)) {
|
|
549
|
+
startedToolIds.add(call.id);
|
|
550
|
+
events.push({ type: "tool.started", id: call.id, name: call.name });
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
for (const call of chunk.data.tool_calls ?? []) {
|
|
554
|
+
if (!startedToolIds.has(call.id)) {
|
|
555
|
+
startedToolIds.add(call.id);
|
|
556
|
+
events.push({ type: "tool.started", id: call.id, name: call.name });
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return events;
|
|
560
|
+
}
|
|
561
|
+
if (chunk.type === MessageChunkTypes.TOOL && chunk.data.tool_call_id) {
|
|
562
|
+
return [{ type: "tool.completed", id: chunk.data.tool_call_id }];
|
|
563
|
+
}
|
|
564
|
+
if (chunk.type === MessageChunkTypes.INTERRUPT) {
|
|
565
|
+
if (context && !context.allowInterrupts) return [{ type: "stream.completed" }];
|
|
566
|
+
const interrupt = publicInterrupt(chunk);
|
|
567
|
+
return interrupt ? [{ type: "interrupt.created", interrupt }, { type: "stream.completed" }] : [{ type: "stream.completed" }];
|
|
568
|
+
}
|
|
569
|
+
if (chunk.type === MessageChunkTypes.MESSAGE_COMPLETED) {
|
|
570
|
+
return [
|
|
571
|
+
{ type: "message.completed", messageId: chunk.data.id },
|
|
572
|
+
{ type: "stream.completed" }
|
|
573
|
+
];
|
|
574
|
+
}
|
|
575
|
+
if (chunk.type === MessageChunkTypes.MESSAGE_FAILED) {
|
|
576
|
+
return [
|
|
577
|
+
{ type: "error", error: { code: "STREAM_FAILED", message: "Stream failed", retryable: true } },
|
|
578
|
+
{ type: "stream.completed" }
|
|
579
|
+
];
|
|
580
|
+
}
|
|
581
|
+
return [];
|
|
582
|
+
}
|
|
583
|
+
function publicInterrupt(chunk) {
|
|
584
|
+
const value = parseInterruptContent(chunk.data.content);
|
|
585
|
+
if (!value) return void 0;
|
|
586
|
+
const topLevelId = chunk.id;
|
|
587
|
+
const id = typeof topLevelId === "string" ? topLevelId : chunk.data.id;
|
|
588
|
+
if (!id) return void 0;
|
|
589
|
+
return {
|
|
590
|
+
id,
|
|
591
|
+
type: typeof value.type === "string" ? value.type : "input",
|
|
592
|
+
prompt: typeof value.prompt === "string" ? value.prompt : typeof value.message === "string" ? value.message : "Input required",
|
|
593
|
+
...isRecord2(value.data) ? { data: value.data } : {}
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
function parseInterruptContent(content) {
|
|
597
|
+
if (!content) return {};
|
|
598
|
+
if (isRecord2(content)) return content;
|
|
599
|
+
if (typeof content !== "string") return void 0;
|
|
600
|
+
try {
|
|
601
|
+
const parsed = JSON.parse(content);
|
|
602
|
+
return isRecord2(parsed) ? parsed : { prompt: content };
|
|
603
|
+
} catch {
|
|
604
|
+
return { prompt: content };
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
function isRecord2(value) {
|
|
608
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
609
|
+
}
|
|
610
|
+
|
|
528
611
|
// src/ExactDataSnapshot.ts
|
|
529
612
|
function ownDescriptorField(descriptor, key) {
|
|
530
613
|
const field = Object.getOwnPropertyDescriptor(descriptor, key);
|
|
@@ -624,6 +707,11 @@ function parseProjectRoomEventId(value) {
|
|
|
624
707
|
function isProjectRoomEventId(value) {
|
|
625
708
|
return parseProjectRoomEventId(value) !== void 0;
|
|
626
709
|
}
|
|
710
|
+
var PROJECT_ROOM_USER_CHANNEL_PROJECT = "__user_channel__";
|
|
711
|
+
function projectRoomUserEventScope(tenantId, userId) {
|
|
712
|
+
if (!tenantId || !userId) throw new TypeError("Project Room user scope requires non-empty identifiers");
|
|
713
|
+
return { tenantId, roomId: `__user__:${userId}`, projectId: PROJECT_ROOM_USER_CHANNEL_PROJECT };
|
|
714
|
+
}
|
|
627
715
|
function isoDate(value) {
|
|
628
716
|
if (typeof value !== "object" || value === null) return void 0;
|
|
629
717
|
try {
|
|
@@ -861,6 +949,7 @@ function parseQueuedExecutionMode(value) {
|
|
|
861
949
|
McpMessageType,
|
|
862
950
|
MemoryType,
|
|
863
951
|
MessageChunkTypes,
|
|
952
|
+
PROJECT_ROOM_USER_CHANNEL_PROJECT,
|
|
864
953
|
PROJECT_TASK_LIFECYCLE_ACTIONS,
|
|
865
954
|
ProjectRoomBrokerCapacityError,
|
|
866
955
|
ProjectRoomCursorError,
|
|
@@ -871,6 +960,7 @@ function parseQueuedExecutionMode(value) {
|
|
|
871
960
|
ScheduledTaskStatus,
|
|
872
961
|
UIComponentType,
|
|
873
962
|
assertGenericProjectConfig,
|
|
963
|
+
createAgentWebAppStreamProjectionContext,
|
|
874
964
|
descriptorDataValue,
|
|
875
965
|
getSubAgentsFromConfig,
|
|
876
966
|
getToolsFromConfig,
|
|
@@ -887,6 +977,8 @@ function parseQueuedExecutionMode(value) {
|
|
|
887
977
|
parseQueuedExecutionMode,
|
|
888
978
|
parseTaskBeliefState,
|
|
889
979
|
parseTrustedRunContext,
|
|
980
|
+
projectAgentWebAppChunk,
|
|
981
|
+
projectRoomUserEventScope,
|
|
890
982
|
replaceTaskBeliefState,
|
|
891
983
|
requireProjectTaskWorkItemStore,
|
|
892
984
|
snapshotExactArray,
|