@axiom-lattice/protocols 4.1.1 → 4.1.2
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 +6 -0
- package/dist/index.d.mts +717 -18
- package/dist/index.d.ts +717 -18
- package/dist/index.js +409 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +388 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/BindingProtocol.ts +87 -11
- package/src/ChannelInstallationStoreProtocol.ts +23 -4
- package/src/ExactDataSnapshot.ts +119 -0
- package/src/ProjectBotMembershipStoreProtocol.ts +48 -0
- package/src/ProjectMembershipStoreProtocol.ts +58 -0
- package/src/ProjectRoomMessageStoreProtocol.ts +26 -0
- package/src/ProjectRoomProtocol.ts +143 -0
- package/src/ProjectRoomRealtimeProtocol.ts +349 -0
- package/src/ProjectRoomStoreProtocol.ts +16 -0
- package/src/TaskStoreProtocol.ts +66 -2
- package/src/TaskWorkItemProtocol.ts +86 -0
- package/src/TrustedRunContextProtocol.ts +119 -0
- package/src/__tests__/BindingProtocol.test.ts +36 -0
- package/src/__tests__/ExactDataSnapshot.test.ts +105 -0
- package/src/__tests__/ProjectRoomProtocol.test.ts +48 -0
- package/src/__tests__/ProjectRoomRealtimeProtocol.test.ts +185 -0
- package/src/__tests__/ProjectRoomStores.test.ts +363 -0
- package/src/__tests__/ProjectTaskProtocol.test.ts +29 -0
- package/src/__tests__/TaskWorkItemProtocol.test.ts +42 -0
- package/src/__tests__/TrustedRunContextProtocol.test.ts +265 -0
- package/src/index.ts +8 -0
- package/type-tests/task-work-item-store-compatibility.ts +14 -2
package/dist/index.js
CHANGED
|
@@ -21,6 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AgentType: () => AgentType,
|
|
24
|
+
ChannelBindingMigrationConflictError: () => ChannelBindingMigrationConflictError,
|
|
25
|
+
DuplicateChannelBindingSubjectError: () => DuplicateChannelBindingSubjectError,
|
|
24
26
|
EXECUTION_RESULT_EVENT_KEY_PATTERN: () => EXECUTION_RESULT_EVENT_KEY_PATTERN,
|
|
25
27
|
EXECUTION_RESULT_EVENT_KEY_PATTERN_SOURCE: () => EXECUTION_RESULT_EVENT_KEY_PATTERN_SOURCE,
|
|
26
28
|
EXECUTION_RESULT_EVENT_KEY_PREFIX: () => EXECUTION_RESULT_EVENT_KEY_PREFIX,
|
|
@@ -30,12 +32,17 @@ __export(index_exports, {
|
|
|
30
32
|
McpMessageType: () => McpMessageType,
|
|
31
33
|
MemoryType: () => MemoryType,
|
|
32
34
|
MessageChunkTypes: () => MessageChunkTypes,
|
|
35
|
+
PROJECT_TASK_LIFECYCLE_ACTIONS: () => PROJECT_TASK_LIFECYCLE_ACTIONS,
|
|
36
|
+
ProjectRoomBrokerCapacityError: () => ProjectRoomBrokerCapacityError,
|
|
37
|
+
ProjectRoomCursorError: () => ProjectRoomCursorError,
|
|
38
|
+
ProjectTaskStoreUnsupportedError: () => ProjectTaskStoreUnsupportedError,
|
|
33
39
|
QueueType: () => QueueType,
|
|
34
40
|
ScheduleExecutionType: () => ScheduleExecutionType,
|
|
35
41
|
ScheduleType: () => ScheduleType,
|
|
36
42
|
ScheduledTaskStatus: () => ScheduledTaskStatus,
|
|
37
43
|
UIComponentType: () => UIComponentType,
|
|
38
44
|
assertGenericProjectConfig: () => assertGenericProjectConfig,
|
|
45
|
+
descriptorDataValue: () => descriptorDataValue,
|
|
39
46
|
getSubAgentsFromConfig: () => getSubAgentsFromConfig,
|
|
40
47
|
getToolsFromConfig: () => getToolsFromConfig,
|
|
41
48
|
hasTools: () => hasTools,
|
|
@@ -43,12 +50,25 @@ __export(index_exports, {
|
|
|
43
50
|
isDeepAgentConfig: () => isDeepAgentConfig,
|
|
44
51
|
isExecutionResultEventKey: () => isExecutionResultEventKey,
|
|
45
52
|
isProcessingAgentConfig: () => isProcessingAgentConfig,
|
|
53
|
+
isProjectRoomEventId: () => isProjectRoomEventId,
|
|
46
54
|
isTeamAgentConfig: () => isTeamAgentConfig,
|
|
47
55
|
isWorkflowAgentConfig: () => isWorkflowAgentConfig,
|
|
48
56
|
parseAgentWebAppGenUIBlock: () => parseAgentWebAppGenUIBlock,
|
|
57
|
+
parseProjectRoomEventId: () => parseProjectRoomEventId,
|
|
58
|
+
parseQueuedExecutionMode: () => parseQueuedExecutionMode,
|
|
49
59
|
parseTaskBeliefState: () => parseTaskBeliefState,
|
|
60
|
+
parseTrustedRunContext: () => parseTrustedRunContext,
|
|
50
61
|
replaceTaskBeliefState: () => replaceTaskBeliefState,
|
|
51
|
-
|
|
62
|
+
requireProjectTaskWorkItemStore: () => requireProjectTaskWorkItemStore,
|
|
63
|
+
snapshotExactArray: () => snapshotExactArray,
|
|
64
|
+
snapshotExactRecord: () => snapshotExactRecord,
|
|
65
|
+
snapshotProjectRoomBotMembershipRealtime: () => snapshotProjectRoomBotMembershipRealtime,
|
|
66
|
+
snapshotProjectRoomMembershipRealtime: () => snapshotProjectRoomMembershipRealtime,
|
|
67
|
+
snapshotProjectRoomMessageRealtime: () => snapshotProjectRoomMessageRealtime,
|
|
68
|
+
taskBeliefStatesEqual: () => taskBeliefStatesEqual,
|
|
69
|
+
toProjectRoomPublicBotMembership: () => toProjectRoomPublicBotMembership,
|
|
70
|
+
toProjectRoomPublicMembership: () => toProjectRoomPublicMembership,
|
|
71
|
+
toProjectRoomPublicMessage: () => toProjectRoomPublicMessage
|
|
52
72
|
});
|
|
53
73
|
module.exports = __toCommonJS(index_exports);
|
|
54
74
|
|
|
@@ -195,6 +215,21 @@ function assertGenericProjectConfig(config) {
|
|
|
195
215
|
}
|
|
196
216
|
}
|
|
197
217
|
|
|
218
|
+
// src/BindingProtocol.ts
|
|
219
|
+
var DuplicateChannelBindingSubjectError = class extends Error {
|
|
220
|
+
constructor() {
|
|
221
|
+
super("A binding already exists for this channel subject");
|
|
222
|
+
this.name = "DuplicateChannelBindingSubjectError";
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
var ChannelBindingMigrationConflictError = class extends Error {
|
|
226
|
+
constructor(conflicts) {
|
|
227
|
+
super(`Channel binding migration found ${conflicts.length} duplicate subject(s)`);
|
|
228
|
+
this.name = "ChannelBindingMigrationConflictError";
|
|
229
|
+
this.conflicts = conflicts;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
198
233
|
// src/TaskWorkItemProtocol.ts
|
|
199
234
|
var EXECUTION_RESULT_EVENT_KEY_PREFIX = "execution-result:";
|
|
200
235
|
var EXECUTION_RESULT_EVENT_KEY_PATTERN_SOURCE = "^execution-result:[A-Za-z0-9._:-]+$";
|
|
@@ -203,6 +238,35 @@ var MAX_PENDING_EXECUTION_RESULTS_LIMIT = 1e3;
|
|
|
203
238
|
function isExecutionResultEventKey(value) {
|
|
204
239
|
return typeof value === "string" && EXECUTION_RESULT_EVENT_KEY_PATTERN.test(value);
|
|
205
240
|
}
|
|
241
|
+
var PROJECT_TASK_LIFECYCLE_ACTIONS = [
|
|
242
|
+
"in_progress",
|
|
243
|
+
"interrupted",
|
|
244
|
+
"failed",
|
|
245
|
+
"completed",
|
|
246
|
+
"cancelled",
|
|
247
|
+
"reassigned"
|
|
248
|
+
];
|
|
249
|
+
var ProjectTaskStoreUnsupportedError = class extends Error {
|
|
250
|
+
constructor(missingMethods) {
|
|
251
|
+
super(`Project Task WorkItem store is missing: ${missingMethods.join(", ")}`);
|
|
252
|
+
this.missingMethods = missingMethods;
|
|
253
|
+
this.code = "PROJECT_TASK_STORE_UNSUPPORTED";
|
|
254
|
+
this.name = "ProjectTaskStoreUnsupportedError";
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
function requireProjectTaskWorkItemStore(store) {
|
|
258
|
+
const missingMethods = ["createIfTaskSnapshot", "listProjectLifecycleEvents"].filter((name) => {
|
|
259
|
+
try {
|
|
260
|
+
return typeof Reflect.get(store, name) !== "function";
|
|
261
|
+
} catch {
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
if (missingMethods.length > 0) {
|
|
266
|
+
throw new ProjectTaskStoreUnsupportedError(missingMethods);
|
|
267
|
+
}
|
|
268
|
+
return store;
|
|
269
|
+
}
|
|
206
270
|
|
|
207
271
|
// src/TaskBeliefProtocol.ts
|
|
208
272
|
var BELIEF_HEADING = "## Belief State";
|
|
@@ -460,9 +524,334 @@ function hasOnlyKeys(value, required, optional) {
|
|
|
460
524
|
const keys = Object.keys(value);
|
|
461
525
|
return required.every((key) => key in value) && keys.every((key) => required.includes(key) || optional.includes(key));
|
|
462
526
|
}
|
|
527
|
+
|
|
528
|
+
// src/ExactDataSnapshot.ts
|
|
529
|
+
function ownDescriptorField(descriptor, key) {
|
|
530
|
+
const field = Object.getOwnPropertyDescriptor(descriptor, key);
|
|
531
|
+
return field && Object.prototype.hasOwnProperty.call(field, "value") ? field.value : void 0;
|
|
532
|
+
}
|
|
533
|
+
function descriptorDataValue(descriptor) {
|
|
534
|
+
if (typeof descriptor !== "object" || descriptor === null) return void 0;
|
|
535
|
+
try {
|
|
536
|
+
const keys = Reflect.ownKeys(descriptor);
|
|
537
|
+
if (!keys.includes("value") || !keys.includes("enumerable") || keys.includes("get") || keys.includes("set")) return void 0;
|
|
538
|
+
const valueField = Object.getOwnPropertyDescriptor(descriptor, "value");
|
|
539
|
+
if (!valueField || !Object.prototype.hasOwnProperty.call(valueField, "value") || ownDescriptorField(descriptor, "enumerable") !== true) return void 0;
|
|
540
|
+
return { ok: true, value: valueField.value };
|
|
541
|
+
} catch {
|
|
542
|
+
return void 0;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function snapshotExactRecord(value, required, optional = []) {
|
|
546
|
+
try {
|
|
547
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
548
|
+
const keys = Reflect.ownKeys(value);
|
|
549
|
+
const allowed = /* @__PURE__ */ new Set([...required, ...optional]);
|
|
550
|
+
if (required.some((key) => !keys.includes(key)) || keys.some((key) => typeof key !== "string" || !allowed.has(key))) return void 0;
|
|
551
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
552
|
+
const descriptorKeys = Reflect.ownKeys(descriptors);
|
|
553
|
+
if (descriptorKeys.length !== keys.length || keys.some((key) => !descriptorKeys.includes(key))) return void 0;
|
|
554
|
+
const result = {};
|
|
555
|
+
for (const key of keys) {
|
|
556
|
+
if (typeof key !== "string") return void 0;
|
|
557
|
+
const descriptor = descriptors[key];
|
|
558
|
+
const data = descriptorDataValue(descriptor);
|
|
559
|
+
if (!data) return void 0;
|
|
560
|
+
Object.defineProperty(result, key, {
|
|
561
|
+
value: data.value,
|
|
562
|
+
enumerable: true,
|
|
563
|
+
configurable: true,
|
|
564
|
+
writable: true
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
return result;
|
|
568
|
+
} catch {
|
|
569
|
+
return void 0;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
function snapshotExactArray(value) {
|
|
573
|
+
try {
|
|
574
|
+
if (!Array.isArray(value)) return void 0;
|
|
575
|
+
const keys = Reflect.ownKeys(value);
|
|
576
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
577
|
+
const descriptorKeys = Reflect.ownKeys(descriptors);
|
|
578
|
+
if (descriptorKeys.length !== keys.length || keys.some((key) => !descriptorKeys.includes(key))) return void 0;
|
|
579
|
+
const lengthDescriptorField = Object.getOwnPropertyDescriptor(descriptors, "length");
|
|
580
|
+
const lengthDescriptor = lengthDescriptorField && Object.prototype.hasOwnProperty.call(lengthDescriptorField, "value") ? lengthDescriptorField.value : void 0;
|
|
581
|
+
if (typeof lengthDescriptor !== "object" || lengthDescriptor === null || Reflect.ownKeys(lengthDescriptor).some((key) => key === "get" || key === "set") || !Object.prototype.hasOwnProperty.call(lengthDescriptor, "value")) return void 0;
|
|
582
|
+
const length = ownDescriptorField(lengthDescriptor, "value");
|
|
583
|
+
if (ownDescriptorField(lengthDescriptor, "enumerable") !== false || ownDescriptorField(lengthDescriptor, "configurable") !== false || ownDescriptorField(lengthDescriptor, "writable") !== true || !Number.isSafeInteger(length) || typeof length !== "number" || length < 0 || keys.length !== length + 1) return void 0;
|
|
584
|
+
const result = [];
|
|
585
|
+
for (let index = 0; index < length; index += 1) {
|
|
586
|
+
const key = String(index);
|
|
587
|
+
const descriptor = descriptors[key];
|
|
588
|
+
const data = descriptorDataValue(descriptor);
|
|
589
|
+
if (!keys.includes(key) || !data) return void 0;
|
|
590
|
+
result.push(data.value);
|
|
591
|
+
}
|
|
592
|
+
if (keys.some((key) => typeof key !== "string" || key !== "length" && !/^(0|[1-9]\d*)$/.test(key))) return void 0;
|
|
593
|
+
return result;
|
|
594
|
+
} catch {
|
|
595
|
+
return void 0;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// src/ProjectRoomRealtimeProtocol.ts
|
|
600
|
+
var ProjectRoomCursorError = class extends Error {
|
|
601
|
+
constructor(code) {
|
|
602
|
+
super(`Project Room realtime cursor requires resynchronization: ${code}`);
|
|
603
|
+
this.code = code;
|
|
604
|
+
this.name = "ProjectRoomCursorError";
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
var ProjectRoomBrokerCapacityError = class extends Error {
|
|
608
|
+
constructor() {
|
|
609
|
+
super("Project Room realtime event sequence is exhausted");
|
|
610
|
+
this.name = "ProjectRoomBrokerCapacityError";
|
|
611
|
+
this.code = "PROJECT_ROOM_EVENT_SEQUENCE_EXHAUSTED";
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
var PROJECT_ROOM_EVENT_ID_PATTERN = /^([0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}):([1-9][0-9]*)$/i;
|
|
615
|
+
function parseProjectRoomEventId(value) {
|
|
616
|
+
if (typeof value !== "string") return void 0;
|
|
617
|
+
const match = PROJECT_ROOM_EVENT_ID_PATTERN.exec(value);
|
|
618
|
+
if (!match) return void 0;
|
|
619
|
+
const sequence = Number(match[2]);
|
|
620
|
+
if (!Number.isSafeInteger(sequence)) return void 0;
|
|
621
|
+
if (match[1] !== match[1].toLowerCase()) return void 0;
|
|
622
|
+
return { epoch: match[1], sequence };
|
|
623
|
+
}
|
|
624
|
+
function isProjectRoomEventId(value) {
|
|
625
|
+
return parseProjectRoomEventId(value) !== void 0;
|
|
626
|
+
}
|
|
627
|
+
function isoDate(value) {
|
|
628
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
629
|
+
try {
|
|
630
|
+
const time = Date.prototype.getTime.call(value);
|
|
631
|
+
return Number.isFinite(time) ? new Date(time).toISOString() : void 0;
|
|
632
|
+
} catch {
|
|
633
|
+
return void 0;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function stringField(record, key) {
|
|
637
|
+
return typeof record[key] === "string" ? record[key] : void 0;
|
|
638
|
+
}
|
|
639
|
+
function isOneOf(value, values) {
|
|
640
|
+
return typeof value === "string" && values.includes(value);
|
|
641
|
+
}
|
|
642
|
+
var messageSources = ["user", "agent", "task", "routine", "system"];
|
|
643
|
+
var humanRoles = ["owner", "admin", "member", "viewer"];
|
|
644
|
+
var membershipStatuses = ["active", "removed"];
|
|
645
|
+
var botRoles = ["coordinator", "specialist"];
|
|
646
|
+
var botStatuses = ["active", "paused", "removed"];
|
|
647
|
+
function mapPublicMessageRecord(record) {
|
|
648
|
+
const id = stringField(record, "id");
|
|
649
|
+
const roomId = stringField(record, "roomId");
|
|
650
|
+
const source = stringField(record, "source");
|
|
651
|
+
const createdAt = isoDate(record.createdAt);
|
|
652
|
+
const content = snapshotExactRecord(record.content, ["type", "text"]);
|
|
653
|
+
const mentions = snapshotPublicMentions(record.mentions);
|
|
654
|
+
const author = snapshotExactRecord(record.author, ["type"], ["userId", "membershipId", "assistantId"]);
|
|
655
|
+
if (!id || !roomId || !isOneOf(source, messageSources) || !createdAt || !content || content.type !== "text" || typeof content.text !== "string" || !mentions || !author || typeof author.type !== "string") return void 0;
|
|
656
|
+
const publicAuthor = author.type === "human" && typeof author.userId === "string" ? { type: "human", userId: author.userId } : author.type === "bot" && typeof author.membershipId === "string" ? { type: "bot", membershipId: author.membershipId } : author.type === "system" ? { type: "system" } : void 0;
|
|
657
|
+
if (!publicAuthor) return void 0;
|
|
658
|
+
const result = { id, roomId, author: publicAuthor, content: { type: "text", text: content.text }, mentions, source, createdAt };
|
|
659
|
+
if (record.replyToMessageId !== void 0) {
|
|
660
|
+
if (typeof record.replyToMessageId !== "string") return void 0;
|
|
661
|
+
result.replyToMessageId = record.replyToMessageId;
|
|
662
|
+
}
|
|
663
|
+
return result;
|
|
664
|
+
}
|
|
665
|
+
function snapshotPublicMentions(value) {
|
|
666
|
+
const rows = snapshotExactArray(value);
|
|
667
|
+
if (!rows) return void 0;
|
|
668
|
+
const result = [];
|
|
669
|
+
for (const row of rows) {
|
|
670
|
+
const team = snapshotExactRecord(row, ["type"]);
|
|
671
|
+
if (team?.type === "team") {
|
|
672
|
+
result.push({ type: "team" });
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
const bot = snapshotExactRecord(row, ["type", "membershipId"]);
|
|
676
|
+
if (bot?.type === "bot" && typeof bot.membershipId === "string") {
|
|
677
|
+
result.push({ type: "bot", membershipId: bot.membershipId });
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
return void 0;
|
|
681
|
+
}
|
|
682
|
+
return result;
|
|
683
|
+
}
|
|
684
|
+
function mapPublicMembershipRecord(record) {
|
|
685
|
+
const joinedAt = isoDate(record.joinedAt);
|
|
686
|
+
const updatedAt = isoDate(record.updatedAt);
|
|
687
|
+
if (typeof record.id !== "string" || typeof record.userId !== "string" || !isOneOf(record.role, humanRoles) || !isOneOf(record.status, membershipStatuses) || !joinedAt || !updatedAt) return void 0;
|
|
688
|
+
return { id: record.id, userId: record.userId, role: record.role, status: record.status, joinedAt, updatedAt };
|
|
689
|
+
}
|
|
690
|
+
function mapPublicBotMembershipRecord(record) {
|
|
691
|
+
const joinedAt = isoDate(record.joinedAt);
|
|
692
|
+
const updatedAt = isoDate(record.updatedAt);
|
|
693
|
+
if (typeof record.id !== "string" || !isOneOf(record.role, botRoles) || typeof record.title !== "string" || typeof record.mentionName !== "string" || !isOneOf(record.status, botStatuses) || !joinedAt || !updatedAt || record.responsibility !== void 0 && typeof record.responsibility !== "string") return void 0;
|
|
694
|
+
return { id: record.id, role: record.role, title: record.title, ...record.responsibility === void 0 ? {} : { responsibility: record.responsibility }, mentionName: record.mentionName, status: record.status, joinedAt, updatedAt };
|
|
695
|
+
}
|
|
696
|
+
function toProjectRoomPublicMessage(value) {
|
|
697
|
+
const record = snapshotExactRecord(value, [
|
|
698
|
+
"id",
|
|
699
|
+
"tenantId",
|
|
700
|
+
"workspaceId",
|
|
701
|
+
"projectId",
|
|
702
|
+
"roomId",
|
|
703
|
+
"author",
|
|
704
|
+
"content",
|
|
705
|
+
"mentions",
|
|
706
|
+
"source",
|
|
707
|
+
"createdAt"
|
|
708
|
+
], ["replyToMessageId", "sourceId", "idempotencyKey"]);
|
|
709
|
+
if (!record) return void 0;
|
|
710
|
+
return mapPublicMessageRecord(record);
|
|
711
|
+
}
|
|
712
|
+
function snapshotProjectRoomMessageRealtime(value) {
|
|
713
|
+
const record = snapshotExactRecord(value, ["id", "tenantId", "workspaceId", "projectId", "roomId", "author", "content", "mentions", "source", "createdAt"], ["replyToMessageId", "sourceId", "idempotencyKey"]);
|
|
714
|
+
if (!record) return void 0;
|
|
715
|
+
const publicMessage = mapPublicMessageRecord(record);
|
|
716
|
+
if (!publicMessage || typeof record.tenantId !== "string" || typeof record.projectId !== "string") return void 0;
|
|
717
|
+
return { scope: { tenantId: record.tenantId, roomId: publicMessage.roomId, projectId: record.projectId }, publicMessage };
|
|
718
|
+
}
|
|
719
|
+
function toProjectRoomPublicMembership(value) {
|
|
720
|
+
const record = snapshotExactRecord(
|
|
721
|
+
value,
|
|
722
|
+
["id", "tenantId", "projectId", "userId", "role", "status", "joinedAt", "updatedAt"]
|
|
723
|
+
);
|
|
724
|
+
if (!record || typeof record.id !== "string" || typeof record.userId !== "string" || !isOneOf(record.role, humanRoles) || !isOneOf(record.status, membershipStatuses)) return void 0;
|
|
725
|
+
const joinedAt = isoDate(record.joinedAt);
|
|
726
|
+
const updatedAt = isoDate(record.updatedAt);
|
|
727
|
+
if (!joinedAt || !updatedAt) return void 0;
|
|
728
|
+
return {
|
|
729
|
+
id: record.id,
|
|
730
|
+
userId: record.userId,
|
|
731
|
+
role: record.role,
|
|
732
|
+
status: record.status,
|
|
733
|
+
joinedAt,
|
|
734
|
+
updatedAt
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
function snapshotProjectRoomMembershipRealtime(value) {
|
|
738
|
+
const record = snapshotExactRecord(value, ["id", "tenantId", "projectId", "userId", "role", "status", "joinedAt", "updatedAt"]);
|
|
739
|
+
if (!record) return void 0;
|
|
740
|
+
const publicMembership = mapPublicMembershipRecord(record);
|
|
741
|
+
if (!publicMembership || typeof record.tenantId !== "string" || typeof record.projectId !== "string") return void 0;
|
|
742
|
+
return { scope: { tenantId: record.tenantId, projectId: record.projectId }, publicMembership };
|
|
743
|
+
}
|
|
744
|
+
function toProjectRoomPublicBotMembership(value) {
|
|
745
|
+
const record = snapshotExactRecord(
|
|
746
|
+
value,
|
|
747
|
+
["id", "tenantId", "workspaceId", "projectId", "roomId", "assistantId", "role", "title", "mentionName", "status", "roomThreadId", "joinedAt", "updatedAt"],
|
|
748
|
+
["responsibility"]
|
|
749
|
+
);
|
|
750
|
+
if (!record || typeof record.id !== "string" || !isOneOf(record.role, botRoles) || typeof record.title !== "string" || typeof record.mentionName !== "string" || !isOneOf(record.status, botStatuses)) return void 0;
|
|
751
|
+
if (record.responsibility !== void 0 && typeof record.responsibility !== "string") return void 0;
|
|
752
|
+
const joinedAt = isoDate(record.joinedAt);
|
|
753
|
+
const updatedAt = isoDate(record.updatedAt);
|
|
754
|
+
if (!joinedAt || !updatedAt) return void 0;
|
|
755
|
+
const result = {
|
|
756
|
+
id: record.id,
|
|
757
|
+
role: record.role,
|
|
758
|
+
title: record.title,
|
|
759
|
+
mentionName: record.mentionName,
|
|
760
|
+
status: record.status,
|
|
761
|
+
joinedAt,
|
|
762
|
+
updatedAt
|
|
763
|
+
};
|
|
764
|
+
if (record.responsibility !== void 0) result.responsibility = record.responsibility;
|
|
765
|
+
return result;
|
|
766
|
+
}
|
|
767
|
+
function snapshotProjectRoomBotMembershipRealtime(value) {
|
|
768
|
+
const record = snapshotExactRecord(value, ["id", "tenantId", "workspaceId", "projectId", "roomId", "assistantId", "role", "title", "mentionName", "status", "roomThreadId", "joinedAt", "updatedAt"], ["responsibility"]);
|
|
769
|
+
if (!record) return void 0;
|
|
770
|
+
const publicMembership = mapPublicBotMembershipRecord(record);
|
|
771
|
+
if (!publicMembership || typeof record.tenantId !== "string" || typeof record.roomId !== "string" || typeof record.projectId !== "string") return void 0;
|
|
772
|
+
return { scope: { tenantId: record.tenantId, roomId: record.roomId, projectId: record.projectId }, publicMembership };
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// src/TrustedRunContextProtocol.ts
|
|
776
|
+
function parseTrustedRunContext(value) {
|
|
777
|
+
const contextValues = snapshotExactRecord(value, [], ["projectRoom", "projectTask"]);
|
|
778
|
+
if (!contextValues || Object.keys(contextValues).length !== 1) {
|
|
779
|
+
throw new Error("Invalid trusted agent run context");
|
|
780
|
+
}
|
|
781
|
+
if (Object.prototype.hasOwnProperty.call(contextValues, "projectTask")) {
|
|
782
|
+
const requiredKeys2 = [
|
|
783
|
+
"tenantId",
|
|
784
|
+
"workspaceId",
|
|
785
|
+
"projectId",
|
|
786
|
+
"roomId",
|
|
787
|
+
"membershipId",
|
|
788
|
+
"assistantId",
|
|
789
|
+
"taskId",
|
|
790
|
+
"threadId",
|
|
791
|
+
"inputMessageId"
|
|
792
|
+
];
|
|
793
|
+
const projectTaskValues = snapshotExactRecord(contextValues.projectTask, requiredKeys2);
|
|
794
|
+
if (!projectTaskValues || requiredKeys2.some((key) => typeof projectTaskValues[key] !== "string" || projectTaskValues[key].length === 0)) {
|
|
795
|
+
throw new Error("Invalid trusted agent run context");
|
|
796
|
+
}
|
|
797
|
+
return {
|
|
798
|
+
projectTask: {
|
|
799
|
+
tenantId: projectTaskValues.tenantId,
|
|
800
|
+
workspaceId: projectTaskValues.workspaceId,
|
|
801
|
+
projectId: projectTaskValues.projectId,
|
|
802
|
+
roomId: projectTaskValues.roomId,
|
|
803
|
+
membershipId: projectTaskValues.membershipId,
|
|
804
|
+
assistantId: projectTaskValues.assistantId,
|
|
805
|
+
taskId: projectTaskValues.taskId,
|
|
806
|
+
threadId: projectTaskValues.threadId,
|
|
807
|
+
inputMessageId: projectTaskValues.inputMessageId
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
const projectRoomValue = contextValues?.projectRoom;
|
|
812
|
+
const requiredKeys = [
|
|
813
|
+
"tenantId",
|
|
814
|
+
"workspaceId",
|
|
815
|
+
"projectId",
|
|
816
|
+
"roomId",
|
|
817
|
+
"sourceRoomMessageId",
|
|
818
|
+
"membershipId",
|
|
819
|
+
"assistantId",
|
|
820
|
+
"inputMessageId",
|
|
821
|
+
"role",
|
|
822
|
+
"title"
|
|
823
|
+
];
|
|
824
|
+
const projectRoomValues = snapshotExactRecord(projectRoomValue, requiredKeys, ["responsibility"]);
|
|
825
|
+
const hasResponsibility = projectRoomValues !== void 0 && Object.prototype.hasOwnProperty.call(projectRoomValues, "responsibility");
|
|
826
|
+
if (!projectRoomValues || requiredKeys.some((key) => typeof projectRoomValues[key] !== "string" || projectRoomValues[key].length === 0) || hasResponsibility && projectRoomValues.responsibility !== void 0 && (typeof projectRoomValues.responsibility !== "string" || projectRoomValues.responsibility.length === 0) || projectRoomValues.role !== "coordinator" && projectRoomValues.role !== "specialist") {
|
|
827
|
+
throw new Error("Invalid trusted agent run context");
|
|
828
|
+
}
|
|
829
|
+
const parsedProjectRoom = {
|
|
830
|
+
tenantId: projectRoomValues.tenantId,
|
|
831
|
+
workspaceId: projectRoomValues.workspaceId,
|
|
832
|
+
projectId: projectRoomValues.projectId,
|
|
833
|
+
roomId: projectRoomValues.roomId,
|
|
834
|
+
sourceRoomMessageId: projectRoomValues.sourceRoomMessageId,
|
|
835
|
+
membershipId: projectRoomValues.membershipId,
|
|
836
|
+
assistantId: projectRoomValues.assistantId,
|
|
837
|
+
inputMessageId: projectRoomValues.inputMessageId,
|
|
838
|
+
role: projectRoomValues.role,
|
|
839
|
+
title: projectRoomValues.title
|
|
840
|
+
};
|
|
841
|
+
if (hasResponsibility && typeof projectRoomValues.responsibility === "string") {
|
|
842
|
+
parsedProjectRoom.responsibility = projectRoomValues.responsibility;
|
|
843
|
+
}
|
|
844
|
+
return { projectRoom: parsedProjectRoom };
|
|
845
|
+
}
|
|
846
|
+
function parseQueuedExecutionMode(value) {
|
|
847
|
+
if (value !== "followup") throw new Error("Invalid queued execution mode");
|
|
848
|
+
return value;
|
|
849
|
+
}
|
|
463
850
|
// Annotate the CommonJS export names for ESM import in node:
|
|
464
851
|
0 && (module.exports = {
|
|
465
852
|
AgentType,
|
|
853
|
+
ChannelBindingMigrationConflictError,
|
|
854
|
+
DuplicateChannelBindingSubjectError,
|
|
466
855
|
EXECUTION_RESULT_EVENT_KEY_PATTERN,
|
|
467
856
|
EXECUTION_RESULT_EVENT_KEY_PATTERN_SOURCE,
|
|
468
857
|
EXECUTION_RESULT_EVENT_KEY_PREFIX,
|
|
@@ -472,12 +861,17 @@ function hasOnlyKeys(value, required, optional) {
|
|
|
472
861
|
McpMessageType,
|
|
473
862
|
MemoryType,
|
|
474
863
|
MessageChunkTypes,
|
|
864
|
+
PROJECT_TASK_LIFECYCLE_ACTIONS,
|
|
865
|
+
ProjectRoomBrokerCapacityError,
|
|
866
|
+
ProjectRoomCursorError,
|
|
867
|
+
ProjectTaskStoreUnsupportedError,
|
|
475
868
|
QueueType,
|
|
476
869
|
ScheduleExecutionType,
|
|
477
870
|
ScheduleType,
|
|
478
871
|
ScheduledTaskStatus,
|
|
479
872
|
UIComponentType,
|
|
480
873
|
assertGenericProjectConfig,
|
|
874
|
+
descriptorDataValue,
|
|
481
875
|
getSubAgentsFromConfig,
|
|
482
876
|
getToolsFromConfig,
|
|
483
877
|
hasTools,
|
|
@@ -485,11 +879,24 @@ function hasOnlyKeys(value, required, optional) {
|
|
|
485
879
|
isDeepAgentConfig,
|
|
486
880
|
isExecutionResultEventKey,
|
|
487
881
|
isProcessingAgentConfig,
|
|
882
|
+
isProjectRoomEventId,
|
|
488
883
|
isTeamAgentConfig,
|
|
489
884
|
isWorkflowAgentConfig,
|
|
490
885
|
parseAgentWebAppGenUIBlock,
|
|
886
|
+
parseProjectRoomEventId,
|
|
887
|
+
parseQueuedExecutionMode,
|
|
491
888
|
parseTaskBeliefState,
|
|
889
|
+
parseTrustedRunContext,
|
|
492
890
|
replaceTaskBeliefState,
|
|
493
|
-
|
|
891
|
+
requireProjectTaskWorkItemStore,
|
|
892
|
+
snapshotExactArray,
|
|
893
|
+
snapshotExactRecord,
|
|
894
|
+
snapshotProjectRoomBotMembershipRealtime,
|
|
895
|
+
snapshotProjectRoomMembershipRealtime,
|
|
896
|
+
snapshotProjectRoomMessageRealtime,
|
|
897
|
+
taskBeliefStatesEqual,
|
|
898
|
+
toProjectRoomPublicBotMembership,
|
|
899
|
+
toProjectRoomPublicMembership,
|
|
900
|
+
toProjectRoomPublicMessage
|
|
494
901
|
});
|
|
495
902
|
//# sourceMappingURL=index.js.map
|