@axiom-lattice/protocols 4.1.0 → 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 +12 -0
- package/dist/index.d.mts +1021 -26
- package/dist/index.d.ts +1021 -26
- package/dist/index.js +448 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +420 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/BindingProtocol.ts +87 -11
- package/src/CapabilityBundleStoreProtocol.ts +78 -0
- package/src/CapabilityRuntimeProtocol.ts +82 -0
- package/src/ChannelInstallationStoreProtocol.ts +23 -4
- package/src/ExactDataSnapshot.ts +119 -0
- package/src/PluginProtocol.ts +59 -7
- 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/SkillStoreProtocol.ts +30 -0
- package/src/TaskBeliefProtocol.ts +6 -1
- package/src/TaskStoreProtocol.ts +66 -2
- package/src/TaskWorkItemProtocol.ts +138 -0
- package/src/TrustedRunContextProtocol.ts +119 -0
- package/src/WorkspaceStoreProtocol.ts +33 -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 +111 -0
- package/src/__tests__/TrustedRunContextProtocol.test.ts +265 -0
- package/src/__tests__/capability-bundle-types.test.ts +177 -0
- package/src/index.ts +13 -0
- package/tsconfig.type-tests.json +9 -0
- package/type-tests/task-work-item-store-compatibility.ts +37 -0
package/dist/index.mjs
CHANGED
|
@@ -125,6 +125,75 @@ var McpMessageType = /* @__PURE__ */ ((McpMessageType2) => {
|
|
|
125
125
|
return McpMessageType2;
|
|
126
126
|
})(McpMessageType || {});
|
|
127
127
|
|
|
128
|
+
// src/WorkspaceStoreProtocol.ts
|
|
129
|
+
var InvalidProjectCapabilityBundleConfigError = class extends Error {
|
|
130
|
+
/** Creates the reserved-config error returned by generic Project writes. */
|
|
131
|
+
constructor() {
|
|
132
|
+
super("Use the project capability-bundles endpoint to update capability bundle IDs");
|
|
133
|
+
/** Stable machine-readable error code. */
|
|
134
|
+
this.code = "INVALID_BUNDLE_CONFIG";
|
|
135
|
+
this.name = "InvalidProjectCapabilityBundleConfigError";
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
function assertGenericProjectConfig(config) {
|
|
139
|
+
if (config !== void 0 && Object.prototype.hasOwnProperty.call(config, "capabilityBundleIds")) {
|
|
140
|
+
throw new InvalidProjectCapabilityBundleConfigError();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/BindingProtocol.ts
|
|
145
|
+
var DuplicateChannelBindingSubjectError = class extends Error {
|
|
146
|
+
constructor() {
|
|
147
|
+
super("A binding already exists for this channel subject");
|
|
148
|
+
this.name = "DuplicateChannelBindingSubjectError";
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var ChannelBindingMigrationConflictError = class extends Error {
|
|
152
|
+
constructor(conflicts) {
|
|
153
|
+
super(`Channel binding migration found ${conflicts.length} duplicate subject(s)`);
|
|
154
|
+
this.name = "ChannelBindingMigrationConflictError";
|
|
155
|
+
this.conflicts = conflicts;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// src/TaskWorkItemProtocol.ts
|
|
160
|
+
var EXECUTION_RESULT_EVENT_KEY_PREFIX = "execution-result:";
|
|
161
|
+
var EXECUTION_RESULT_EVENT_KEY_PATTERN_SOURCE = "^execution-result:[A-Za-z0-9._:-]+$";
|
|
162
|
+
var EXECUTION_RESULT_EVENT_KEY_PATTERN = new RegExp(EXECUTION_RESULT_EVENT_KEY_PATTERN_SOURCE);
|
|
163
|
+
var MAX_PENDING_EXECUTION_RESULTS_LIMIT = 1e3;
|
|
164
|
+
function isExecutionResultEventKey(value) {
|
|
165
|
+
return typeof value === "string" && EXECUTION_RESULT_EVENT_KEY_PATTERN.test(value);
|
|
166
|
+
}
|
|
167
|
+
var PROJECT_TASK_LIFECYCLE_ACTIONS = [
|
|
168
|
+
"in_progress",
|
|
169
|
+
"interrupted",
|
|
170
|
+
"failed",
|
|
171
|
+
"completed",
|
|
172
|
+
"cancelled",
|
|
173
|
+
"reassigned"
|
|
174
|
+
];
|
|
175
|
+
var ProjectTaskStoreUnsupportedError = class extends Error {
|
|
176
|
+
constructor(missingMethods) {
|
|
177
|
+
super(`Project Task WorkItem store is missing: ${missingMethods.join(", ")}`);
|
|
178
|
+
this.missingMethods = missingMethods;
|
|
179
|
+
this.code = "PROJECT_TASK_STORE_UNSUPPORTED";
|
|
180
|
+
this.name = "ProjectTaskStoreUnsupportedError";
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
function requireProjectTaskWorkItemStore(store) {
|
|
184
|
+
const missingMethods = ["createIfTaskSnapshot", "listProjectLifecycleEvents"].filter((name) => {
|
|
185
|
+
try {
|
|
186
|
+
return typeof Reflect.get(store, name) !== "function";
|
|
187
|
+
} catch {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
if (missingMethods.length > 0) {
|
|
192
|
+
throw new ProjectTaskStoreUnsupportedError(missingMethods);
|
|
193
|
+
}
|
|
194
|
+
return store;
|
|
195
|
+
}
|
|
196
|
+
|
|
128
197
|
// src/TaskBeliefProtocol.ts
|
|
129
198
|
var BELIEF_HEADING = "## Belief State";
|
|
130
199
|
var ACCEPTANCE_HEADING = "## Acceptance Criteria";
|
|
@@ -381,28 +450,378 @@ function hasOnlyKeys(value, required, optional) {
|
|
|
381
450
|
const keys = Object.keys(value);
|
|
382
451
|
return required.every((key) => key in value) && keys.every((key) => required.includes(key) || optional.includes(key));
|
|
383
452
|
}
|
|
453
|
+
|
|
454
|
+
// src/ExactDataSnapshot.ts
|
|
455
|
+
function ownDescriptorField(descriptor, key) {
|
|
456
|
+
const field = Object.getOwnPropertyDescriptor(descriptor, key);
|
|
457
|
+
return field && Object.prototype.hasOwnProperty.call(field, "value") ? field.value : void 0;
|
|
458
|
+
}
|
|
459
|
+
function descriptorDataValue(descriptor) {
|
|
460
|
+
if (typeof descriptor !== "object" || descriptor === null) return void 0;
|
|
461
|
+
try {
|
|
462
|
+
const keys = Reflect.ownKeys(descriptor);
|
|
463
|
+
if (!keys.includes("value") || !keys.includes("enumerable") || keys.includes("get") || keys.includes("set")) return void 0;
|
|
464
|
+
const valueField = Object.getOwnPropertyDescriptor(descriptor, "value");
|
|
465
|
+
if (!valueField || !Object.prototype.hasOwnProperty.call(valueField, "value") || ownDescriptorField(descriptor, "enumerable") !== true) return void 0;
|
|
466
|
+
return { ok: true, value: valueField.value };
|
|
467
|
+
} catch {
|
|
468
|
+
return void 0;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
function snapshotExactRecord(value, required, optional = []) {
|
|
472
|
+
try {
|
|
473
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
474
|
+
const keys = Reflect.ownKeys(value);
|
|
475
|
+
const allowed = /* @__PURE__ */ new Set([...required, ...optional]);
|
|
476
|
+
if (required.some((key) => !keys.includes(key)) || keys.some((key) => typeof key !== "string" || !allowed.has(key))) return void 0;
|
|
477
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
478
|
+
const descriptorKeys = Reflect.ownKeys(descriptors);
|
|
479
|
+
if (descriptorKeys.length !== keys.length || keys.some((key) => !descriptorKeys.includes(key))) return void 0;
|
|
480
|
+
const result = {};
|
|
481
|
+
for (const key of keys) {
|
|
482
|
+
if (typeof key !== "string") return void 0;
|
|
483
|
+
const descriptor = descriptors[key];
|
|
484
|
+
const data = descriptorDataValue(descriptor);
|
|
485
|
+
if (!data) return void 0;
|
|
486
|
+
Object.defineProperty(result, key, {
|
|
487
|
+
value: data.value,
|
|
488
|
+
enumerable: true,
|
|
489
|
+
configurable: true,
|
|
490
|
+
writable: true
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
return result;
|
|
494
|
+
} catch {
|
|
495
|
+
return void 0;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
function snapshotExactArray(value) {
|
|
499
|
+
try {
|
|
500
|
+
if (!Array.isArray(value)) return void 0;
|
|
501
|
+
const keys = Reflect.ownKeys(value);
|
|
502
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
503
|
+
const descriptorKeys = Reflect.ownKeys(descriptors);
|
|
504
|
+
if (descriptorKeys.length !== keys.length || keys.some((key) => !descriptorKeys.includes(key))) return void 0;
|
|
505
|
+
const lengthDescriptorField = Object.getOwnPropertyDescriptor(descriptors, "length");
|
|
506
|
+
const lengthDescriptor = lengthDescriptorField && Object.prototype.hasOwnProperty.call(lengthDescriptorField, "value") ? lengthDescriptorField.value : void 0;
|
|
507
|
+
if (typeof lengthDescriptor !== "object" || lengthDescriptor === null || Reflect.ownKeys(lengthDescriptor).some((key) => key === "get" || key === "set") || !Object.prototype.hasOwnProperty.call(lengthDescriptor, "value")) return void 0;
|
|
508
|
+
const length = ownDescriptorField(lengthDescriptor, "value");
|
|
509
|
+
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;
|
|
510
|
+
const result = [];
|
|
511
|
+
for (let index = 0; index < length; index += 1) {
|
|
512
|
+
const key = String(index);
|
|
513
|
+
const descriptor = descriptors[key];
|
|
514
|
+
const data = descriptorDataValue(descriptor);
|
|
515
|
+
if (!keys.includes(key) || !data) return void 0;
|
|
516
|
+
result.push(data.value);
|
|
517
|
+
}
|
|
518
|
+
if (keys.some((key) => typeof key !== "string" || key !== "length" && !/^(0|[1-9]\d*)$/.test(key))) return void 0;
|
|
519
|
+
return result;
|
|
520
|
+
} catch {
|
|
521
|
+
return void 0;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// src/ProjectRoomRealtimeProtocol.ts
|
|
526
|
+
var ProjectRoomCursorError = class extends Error {
|
|
527
|
+
constructor(code) {
|
|
528
|
+
super(`Project Room realtime cursor requires resynchronization: ${code}`);
|
|
529
|
+
this.code = code;
|
|
530
|
+
this.name = "ProjectRoomCursorError";
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
var ProjectRoomBrokerCapacityError = class extends Error {
|
|
534
|
+
constructor() {
|
|
535
|
+
super("Project Room realtime event sequence is exhausted");
|
|
536
|
+
this.name = "ProjectRoomBrokerCapacityError";
|
|
537
|
+
this.code = "PROJECT_ROOM_EVENT_SEQUENCE_EXHAUSTED";
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
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;
|
|
541
|
+
function parseProjectRoomEventId(value) {
|
|
542
|
+
if (typeof value !== "string") return void 0;
|
|
543
|
+
const match = PROJECT_ROOM_EVENT_ID_PATTERN.exec(value);
|
|
544
|
+
if (!match) return void 0;
|
|
545
|
+
const sequence = Number(match[2]);
|
|
546
|
+
if (!Number.isSafeInteger(sequence)) return void 0;
|
|
547
|
+
if (match[1] !== match[1].toLowerCase()) return void 0;
|
|
548
|
+
return { epoch: match[1], sequence };
|
|
549
|
+
}
|
|
550
|
+
function isProjectRoomEventId(value) {
|
|
551
|
+
return parseProjectRoomEventId(value) !== void 0;
|
|
552
|
+
}
|
|
553
|
+
function isoDate(value) {
|
|
554
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
555
|
+
try {
|
|
556
|
+
const time = Date.prototype.getTime.call(value);
|
|
557
|
+
return Number.isFinite(time) ? new Date(time).toISOString() : void 0;
|
|
558
|
+
} catch {
|
|
559
|
+
return void 0;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
function stringField(record, key) {
|
|
563
|
+
return typeof record[key] === "string" ? record[key] : void 0;
|
|
564
|
+
}
|
|
565
|
+
function isOneOf(value, values) {
|
|
566
|
+
return typeof value === "string" && values.includes(value);
|
|
567
|
+
}
|
|
568
|
+
var messageSources = ["user", "agent", "task", "routine", "system"];
|
|
569
|
+
var humanRoles = ["owner", "admin", "member", "viewer"];
|
|
570
|
+
var membershipStatuses = ["active", "removed"];
|
|
571
|
+
var botRoles = ["coordinator", "specialist"];
|
|
572
|
+
var botStatuses = ["active", "paused", "removed"];
|
|
573
|
+
function mapPublicMessageRecord(record) {
|
|
574
|
+
const id = stringField(record, "id");
|
|
575
|
+
const roomId = stringField(record, "roomId");
|
|
576
|
+
const source = stringField(record, "source");
|
|
577
|
+
const createdAt = isoDate(record.createdAt);
|
|
578
|
+
const content = snapshotExactRecord(record.content, ["type", "text"]);
|
|
579
|
+
const mentions = snapshotPublicMentions(record.mentions);
|
|
580
|
+
const author = snapshotExactRecord(record.author, ["type"], ["userId", "membershipId", "assistantId"]);
|
|
581
|
+
if (!id || !roomId || !isOneOf(source, messageSources) || !createdAt || !content || content.type !== "text" || typeof content.text !== "string" || !mentions || !author || typeof author.type !== "string") return void 0;
|
|
582
|
+
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;
|
|
583
|
+
if (!publicAuthor) return void 0;
|
|
584
|
+
const result = { id, roomId, author: publicAuthor, content: { type: "text", text: content.text }, mentions, source, createdAt };
|
|
585
|
+
if (record.replyToMessageId !== void 0) {
|
|
586
|
+
if (typeof record.replyToMessageId !== "string") return void 0;
|
|
587
|
+
result.replyToMessageId = record.replyToMessageId;
|
|
588
|
+
}
|
|
589
|
+
return result;
|
|
590
|
+
}
|
|
591
|
+
function snapshotPublicMentions(value) {
|
|
592
|
+
const rows = snapshotExactArray(value);
|
|
593
|
+
if (!rows) return void 0;
|
|
594
|
+
const result = [];
|
|
595
|
+
for (const row of rows) {
|
|
596
|
+
const team = snapshotExactRecord(row, ["type"]);
|
|
597
|
+
if (team?.type === "team") {
|
|
598
|
+
result.push({ type: "team" });
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
const bot = snapshotExactRecord(row, ["type", "membershipId"]);
|
|
602
|
+
if (bot?.type === "bot" && typeof bot.membershipId === "string") {
|
|
603
|
+
result.push({ type: "bot", membershipId: bot.membershipId });
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
return void 0;
|
|
607
|
+
}
|
|
608
|
+
return result;
|
|
609
|
+
}
|
|
610
|
+
function mapPublicMembershipRecord(record) {
|
|
611
|
+
const joinedAt = isoDate(record.joinedAt);
|
|
612
|
+
const updatedAt = isoDate(record.updatedAt);
|
|
613
|
+
if (typeof record.id !== "string" || typeof record.userId !== "string" || !isOneOf(record.role, humanRoles) || !isOneOf(record.status, membershipStatuses) || !joinedAt || !updatedAt) return void 0;
|
|
614
|
+
return { id: record.id, userId: record.userId, role: record.role, status: record.status, joinedAt, updatedAt };
|
|
615
|
+
}
|
|
616
|
+
function mapPublicBotMembershipRecord(record) {
|
|
617
|
+
const joinedAt = isoDate(record.joinedAt);
|
|
618
|
+
const updatedAt = isoDate(record.updatedAt);
|
|
619
|
+
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;
|
|
620
|
+
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 };
|
|
621
|
+
}
|
|
622
|
+
function toProjectRoomPublicMessage(value) {
|
|
623
|
+
const record = snapshotExactRecord(value, [
|
|
624
|
+
"id",
|
|
625
|
+
"tenantId",
|
|
626
|
+
"workspaceId",
|
|
627
|
+
"projectId",
|
|
628
|
+
"roomId",
|
|
629
|
+
"author",
|
|
630
|
+
"content",
|
|
631
|
+
"mentions",
|
|
632
|
+
"source",
|
|
633
|
+
"createdAt"
|
|
634
|
+
], ["replyToMessageId", "sourceId", "idempotencyKey"]);
|
|
635
|
+
if (!record) return void 0;
|
|
636
|
+
return mapPublicMessageRecord(record);
|
|
637
|
+
}
|
|
638
|
+
function snapshotProjectRoomMessageRealtime(value) {
|
|
639
|
+
const record = snapshotExactRecord(value, ["id", "tenantId", "workspaceId", "projectId", "roomId", "author", "content", "mentions", "source", "createdAt"], ["replyToMessageId", "sourceId", "idempotencyKey"]);
|
|
640
|
+
if (!record) return void 0;
|
|
641
|
+
const publicMessage = mapPublicMessageRecord(record);
|
|
642
|
+
if (!publicMessage || typeof record.tenantId !== "string" || typeof record.projectId !== "string") return void 0;
|
|
643
|
+
return { scope: { tenantId: record.tenantId, roomId: publicMessage.roomId, projectId: record.projectId }, publicMessage };
|
|
644
|
+
}
|
|
645
|
+
function toProjectRoomPublicMembership(value) {
|
|
646
|
+
const record = snapshotExactRecord(
|
|
647
|
+
value,
|
|
648
|
+
["id", "tenantId", "projectId", "userId", "role", "status", "joinedAt", "updatedAt"]
|
|
649
|
+
);
|
|
650
|
+
if (!record || typeof record.id !== "string" || typeof record.userId !== "string" || !isOneOf(record.role, humanRoles) || !isOneOf(record.status, membershipStatuses)) return void 0;
|
|
651
|
+
const joinedAt = isoDate(record.joinedAt);
|
|
652
|
+
const updatedAt = isoDate(record.updatedAt);
|
|
653
|
+
if (!joinedAt || !updatedAt) return void 0;
|
|
654
|
+
return {
|
|
655
|
+
id: record.id,
|
|
656
|
+
userId: record.userId,
|
|
657
|
+
role: record.role,
|
|
658
|
+
status: record.status,
|
|
659
|
+
joinedAt,
|
|
660
|
+
updatedAt
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
function snapshotProjectRoomMembershipRealtime(value) {
|
|
664
|
+
const record = snapshotExactRecord(value, ["id", "tenantId", "projectId", "userId", "role", "status", "joinedAt", "updatedAt"]);
|
|
665
|
+
if (!record) return void 0;
|
|
666
|
+
const publicMembership = mapPublicMembershipRecord(record);
|
|
667
|
+
if (!publicMembership || typeof record.tenantId !== "string" || typeof record.projectId !== "string") return void 0;
|
|
668
|
+
return { scope: { tenantId: record.tenantId, projectId: record.projectId }, publicMembership };
|
|
669
|
+
}
|
|
670
|
+
function toProjectRoomPublicBotMembership(value) {
|
|
671
|
+
const record = snapshotExactRecord(
|
|
672
|
+
value,
|
|
673
|
+
["id", "tenantId", "workspaceId", "projectId", "roomId", "assistantId", "role", "title", "mentionName", "status", "roomThreadId", "joinedAt", "updatedAt"],
|
|
674
|
+
["responsibility"]
|
|
675
|
+
);
|
|
676
|
+
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;
|
|
677
|
+
if (record.responsibility !== void 0 && typeof record.responsibility !== "string") return void 0;
|
|
678
|
+
const joinedAt = isoDate(record.joinedAt);
|
|
679
|
+
const updatedAt = isoDate(record.updatedAt);
|
|
680
|
+
if (!joinedAt || !updatedAt) return void 0;
|
|
681
|
+
const result = {
|
|
682
|
+
id: record.id,
|
|
683
|
+
role: record.role,
|
|
684
|
+
title: record.title,
|
|
685
|
+
mentionName: record.mentionName,
|
|
686
|
+
status: record.status,
|
|
687
|
+
joinedAt,
|
|
688
|
+
updatedAt
|
|
689
|
+
};
|
|
690
|
+
if (record.responsibility !== void 0) result.responsibility = record.responsibility;
|
|
691
|
+
return result;
|
|
692
|
+
}
|
|
693
|
+
function snapshotProjectRoomBotMembershipRealtime(value) {
|
|
694
|
+
const record = snapshotExactRecord(value, ["id", "tenantId", "workspaceId", "projectId", "roomId", "assistantId", "role", "title", "mentionName", "status", "roomThreadId", "joinedAt", "updatedAt"], ["responsibility"]);
|
|
695
|
+
if (!record) return void 0;
|
|
696
|
+
const publicMembership = mapPublicBotMembershipRecord(record);
|
|
697
|
+
if (!publicMembership || typeof record.tenantId !== "string" || typeof record.roomId !== "string" || typeof record.projectId !== "string") return void 0;
|
|
698
|
+
return { scope: { tenantId: record.tenantId, roomId: record.roomId, projectId: record.projectId }, publicMembership };
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// src/TrustedRunContextProtocol.ts
|
|
702
|
+
function parseTrustedRunContext(value) {
|
|
703
|
+
const contextValues = snapshotExactRecord(value, [], ["projectRoom", "projectTask"]);
|
|
704
|
+
if (!contextValues || Object.keys(contextValues).length !== 1) {
|
|
705
|
+
throw new Error("Invalid trusted agent run context");
|
|
706
|
+
}
|
|
707
|
+
if (Object.prototype.hasOwnProperty.call(contextValues, "projectTask")) {
|
|
708
|
+
const requiredKeys2 = [
|
|
709
|
+
"tenantId",
|
|
710
|
+
"workspaceId",
|
|
711
|
+
"projectId",
|
|
712
|
+
"roomId",
|
|
713
|
+
"membershipId",
|
|
714
|
+
"assistantId",
|
|
715
|
+
"taskId",
|
|
716
|
+
"threadId",
|
|
717
|
+
"inputMessageId"
|
|
718
|
+
];
|
|
719
|
+
const projectTaskValues = snapshotExactRecord(contextValues.projectTask, requiredKeys2);
|
|
720
|
+
if (!projectTaskValues || requiredKeys2.some((key) => typeof projectTaskValues[key] !== "string" || projectTaskValues[key].length === 0)) {
|
|
721
|
+
throw new Error("Invalid trusted agent run context");
|
|
722
|
+
}
|
|
723
|
+
return {
|
|
724
|
+
projectTask: {
|
|
725
|
+
tenantId: projectTaskValues.tenantId,
|
|
726
|
+
workspaceId: projectTaskValues.workspaceId,
|
|
727
|
+
projectId: projectTaskValues.projectId,
|
|
728
|
+
roomId: projectTaskValues.roomId,
|
|
729
|
+
membershipId: projectTaskValues.membershipId,
|
|
730
|
+
assistantId: projectTaskValues.assistantId,
|
|
731
|
+
taskId: projectTaskValues.taskId,
|
|
732
|
+
threadId: projectTaskValues.threadId,
|
|
733
|
+
inputMessageId: projectTaskValues.inputMessageId
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
const projectRoomValue = contextValues?.projectRoom;
|
|
738
|
+
const requiredKeys = [
|
|
739
|
+
"tenantId",
|
|
740
|
+
"workspaceId",
|
|
741
|
+
"projectId",
|
|
742
|
+
"roomId",
|
|
743
|
+
"sourceRoomMessageId",
|
|
744
|
+
"membershipId",
|
|
745
|
+
"assistantId",
|
|
746
|
+
"inputMessageId",
|
|
747
|
+
"role",
|
|
748
|
+
"title"
|
|
749
|
+
];
|
|
750
|
+
const projectRoomValues = snapshotExactRecord(projectRoomValue, requiredKeys, ["responsibility"]);
|
|
751
|
+
const hasResponsibility = projectRoomValues !== void 0 && Object.prototype.hasOwnProperty.call(projectRoomValues, "responsibility");
|
|
752
|
+
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") {
|
|
753
|
+
throw new Error("Invalid trusted agent run context");
|
|
754
|
+
}
|
|
755
|
+
const parsedProjectRoom = {
|
|
756
|
+
tenantId: projectRoomValues.tenantId,
|
|
757
|
+
workspaceId: projectRoomValues.workspaceId,
|
|
758
|
+
projectId: projectRoomValues.projectId,
|
|
759
|
+
roomId: projectRoomValues.roomId,
|
|
760
|
+
sourceRoomMessageId: projectRoomValues.sourceRoomMessageId,
|
|
761
|
+
membershipId: projectRoomValues.membershipId,
|
|
762
|
+
assistantId: projectRoomValues.assistantId,
|
|
763
|
+
inputMessageId: projectRoomValues.inputMessageId,
|
|
764
|
+
role: projectRoomValues.role,
|
|
765
|
+
title: projectRoomValues.title
|
|
766
|
+
};
|
|
767
|
+
if (hasResponsibility && typeof projectRoomValues.responsibility === "string") {
|
|
768
|
+
parsedProjectRoom.responsibility = projectRoomValues.responsibility;
|
|
769
|
+
}
|
|
770
|
+
return { projectRoom: parsedProjectRoom };
|
|
771
|
+
}
|
|
772
|
+
function parseQueuedExecutionMode(value) {
|
|
773
|
+
if (value !== "followup") throw new Error("Invalid queued execution mode");
|
|
774
|
+
return value;
|
|
775
|
+
}
|
|
384
776
|
export {
|
|
385
777
|
AgentType,
|
|
778
|
+
ChannelBindingMigrationConflictError,
|
|
779
|
+
DuplicateChannelBindingSubjectError,
|
|
780
|
+
EXECUTION_RESULT_EVENT_KEY_PATTERN,
|
|
781
|
+
EXECUTION_RESULT_EVENT_KEY_PATTERN_SOURCE,
|
|
782
|
+
EXECUTION_RESULT_EVENT_KEY_PREFIX,
|
|
783
|
+
InvalidProjectCapabilityBundleConfigError,
|
|
386
784
|
LoggerType,
|
|
785
|
+
MAX_PENDING_EXECUTION_RESULTS_LIMIT,
|
|
387
786
|
McpMessageType,
|
|
388
787
|
MemoryType,
|
|
389
788
|
MessageChunkTypes,
|
|
789
|
+
PROJECT_TASK_LIFECYCLE_ACTIONS,
|
|
790
|
+
ProjectRoomBrokerCapacityError,
|
|
791
|
+
ProjectRoomCursorError,
|
|
792
|
+
ProjectTaskStoreUnsupportedError,
|
|
390
793
|
QueueType,
|
|
391
794
|
ScheduleExecutionType,
|
|
392
795
|
ScheduleType,
|
|
393
796
|
ScheduledTaskStatus,
|
|
394
797
|
UIComponentType,
|
|
798
|
+
assertGenericProjectConfig,
|
|
799
|
+
descriptorDataValue,
|
|
395
800
|
getSubAgentsFromConfig,
|
|
396
801
|
getToolsFromConfig,
|
|
397
802
|
hasTools,
|
|
398
803
|
isA2ARemoteAgentConfig,
|
|
399
804
|
isDeepAgentConfig,
|
|
805
|
+
isExecutionResultEventKey,
|
|
400
806
|
isProcessingAgentConfig,
|
|
807
|
+
isProjectRoomEventId,
|
|
401
808
|
isTeamAgentConfig,
|
|
402
809
|
isWorkflowAgentConfig,
|
|
403
810
|
parseAgentWebAppGenUIBlock,
|
|
811
|
+
parseProjectRoomEventId,
|
|
812
|
+
parseQueuedExecutionMode,
|
|
404
813
|
parseTaskBeliefState,
|
|
814
|
+
parseTrustedRunContext,
|
|
405
815
|
replaceTaskBeliefState,
|
|
406
|
-
|
|
816
|
+
requireProjectTaskWorkItemStore,
|
|
817
|
+
snapshotExactArray,
|
|
818
|
+
snapshotExactRecord,
|
|
819
|
+
snapshotProjectRoomBotMembershipRealtime,
|
|
820
|
+
snapshotProjectRoomMembershipRealtime,
|
|
821
|
+
snapshotProjectRoomMessageRealtime,
|
|
822
|
+
taskBeliefStatesEqual,
|
|
823
|
+
toProjectRoomPublicBotMembership,
|
|
824
|
+
toProjectRoomPublicMembership,
|
|
825
|
+
toProjectRoomPublicMessage
|
|
407
826
|
};
|
|
408
827
|
//# sourceMappingURL=index.mjs.map
|