@axiom-lattice/core 4.2.9 → 4.2.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/index.d.mts +60 -4
- package/dist/index.d.ts +60 -4
- package/dist/index.js +173 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +169 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1668,6 +1668,7 @@ __export(index_exports, {
|
|
|
1668
1668
|
InMemoryTenantStore: () => InMemoryTenantStore,
|
|
1669
1669
|
InMemoryThreadMessageQueueStore: () => InMemoryThreadMessageQueueStore,
|
|
1670
1670
|
InMemoryThreadStore: () => InMemoryThreadStore,
|
|
1671
|
+
InMemoryUserPushSubscriptionStore: () => InMemoryUserPushSubscriptionStore,
|
|
1671
1672
|
InMemoryUserStore: () => InMemoryUserStore,
|
|
1672
1673
|
InMemoryUserTenantLinkStore: () => InMemoryUserTenantLinkStore,
|
|
1673
1674
|
LINE_NUMBER_WIDTH: () => LINE_NUMBER_WIDTH,
|
|
@@ -1709,6 +1710,7 @@ __export(index_exports, {
|
|
|
1709
1710
|
Protocols: () => Protocols,
|
|
1710
1711
|
QueueLatticeManager: () => QueueLatticeManager,
|
|
1711
1712
|
QueueMode: () => QueueMode,
|
|
1713
|
+
ROOM_COORDINATOR_KEY: () => ROOM_COORDINATOR_KEY,
|
|
1712
1714
|
RemoteSandboxInstance: () => RemoteSandboxInstance,
|
|
1713
1715
|
RemoteSandboxProvider: () => RemoteSandboxProvider,
|
|
1714
1716
|
RoomAgentMessageService: () => RoomAgentMessageService,
|
|
@@ -1737,6 +1739,7 @@ __export(index_exports, {
|
|
|
1737
1739
|
TaskStatus: () => TaskStatus,
|
|
1738
1740
|
TeamAgentGraphBuilder: () => TeamAgentGraphBuilder,
|
|
1739
1741
|
TenantPluginCatalog: () => TenantPluginCatalog,
|
|
1742
|
+
ThreadEndError: () => ThreadEndError,
|
|
1740
1743
|
ThreadStatus: () => ThreadStatus2,
|
|
1741
1744
|
TokenCache: () => TokenCache,
|
|
1742
1745
|
ToolLatticeManager: () => ToolLatticeManager,
|
|
@@ -1934,6 +1937,7 @@ __export(index_exports, {
|
|
|
1934
1937
|
resolvePath: () => resolvePath,
|
|
1935
1938
|
resolveSandboxPluginConnections: () => resolveSandboxPluginConnections,
|
|
1936
1939
|
resolveTenantPluginSkill: () => resolveTenantPluginSkill,
|
|
1940
|
+
roomCoordinatorConfig: () => roomCoordinatorConfig,
|
|
1937
1941
|
runRemotePackDirectory: () => runRemotePackDirectory,
|
|
1938
1942
|
safeTaskResponseId: () => safeTaskResponseId,
|
|
1939
1943
|
sandboxLatticeManager: () => sandboxLatticeManager,
|
|
@@ -4711,6 +4715,40 @@ function validDate2(value) {
|
|
|
4711
4715
|
}
|
|
4712
4716
|
}
|
|
4713
4717
|
|
|
4718
|
+
// src/store_lattice/InMemoryUserPushSubscriptionStore.ts
|
|
4719
|
+
var InMemoryUserPushSubscriptionStore = class {
|
|
4720
|
+
constructor() {
|
|
4721
|
+
this.entries = /* @__PURE__ */ new Map();
|
|
4722
|
+
}
|
|
4723
|
+
/** Lists defensive copies of every subscription for a user. */
|
|
4724
|
+
async list(tenantId2, userId) {
|
|
4725
|
+
return [...this.entries.values()].filter((entry) => entry.tenantId === tenantId2 && entry.userId === userId).map((entry) => structuredClone(entry));
|
|
4726
|
+
}
|
|
4727
|
+
/** Saves (upserts) a subscription keyed by tenant + user + endpoint. */
|
|
4728
|
+
async save(input) {
|
|
4729
|
+
const key5 = entryKey(input.tenantId, input.userId, input.endpoint);
|
|
4730
|
+
const existing = this.entries.get(key5);
|
|
4731
|
+
const next = {
|
|
4732
|
+
id: existing?.id ?? crypto.randomUUID(),
|
|
4733
|
+
tenantId: input.tenantId,
|
|
4734
|
+
userId: input.userId,
|
|
4735
|
+
endpoint: input.endpoint,
|
|
4736
|
+
keys: { p256dh: input.keys.p256dh, auth: input.keys.auth },
|
|
4737
|
+
...input.userAgent === void 0 ? {} : { userAgent: input.userAgent },
|
|
4738
|
+
createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
4739
|
+
};
|
|
4740
|
+
this.entries.set(key5, next);
|
|
4741
|
+
return structuredClone(next);
|
|
4742
|
+
}
|
|
4743
|
+
/** Deletes a subscription by endpoint. Returns whether a row was removed. */
|
|
4744
|
+
async delete(tenantId2, userId, endpoint) {
|
|
4745
|
+
return this.entries.delete(entryKey(tenantId2, userId, endpoint));
|
|
4746
|
+
}
|
|
4747
|
+
};
|
|
4748
|
+
function entryKey(tenantId2, userId, endpoint) {
|
|
4749
|
+
return JSON.stringify([tenantId2, userId, endpoint]);
|
|
4750
|
+
}
|
|
4751
|
+
|
|
4714
4752
|
// src/store_lattice/InMemoryUserStore.ts
|
|
4715
4753
|
var InMemoryUserStore = class {
|
|
4716
4754
|
constructor() {
|
|
@@ -6332,6 +6370,7 @@ var defaultProjectMembershipStore = new InMemoryProjectMembershipStore(defaultPr
|
|
|
6332
6370
|
var defaultProjectBotMembershipStore = new InMemoryProjectBotMembershipStore(defaultProjectRoomCoordinator);
|
|
6333
6371
|
var defaultProjectRoomMessageStore = new InMemoryProjectRoomMessageStore(defaultProjectRoomCoordinator);
|
|
6334
6372
|
var defaultProjectRoomReadStateStore = new InMemoryProjectRoomReadStateStore();
|
|
6373
|
+
var defaultUserPushSubscriptionStore = new InMemoryUserPushSubscriptionStore();
|
|
6335
6374
|
storeLatticeManager.registerLattice("default", "thread", defaultThreadStore);
|
|
6336
6375
|
storeLatticeManager.registerLattice(
|
|
6337
6376
|
"default",
|
|
@@ -6351,6 +6390,7 @@ storeLatticeManager.registerLattice("default", "projectMembership", defaultProje
|
|
|
6351
6390
|
storeLatticeManager.registerLattice("default", "projectBotMembership", defaultProjectBotMembershipStore);
|
|
6352
6391
|
storeLatticeManager.registerLattice("default", "projectRoomMessage", defaultProjectRoomMessageStore);
|
|
6353
6392
|
storeLatticeManager.registerLattice("default", "projectRoomReadState", defaultProjectRoomReadStateStore);
|
|
6393
|
+
storeLatticeManager.registerLattice("default", "userPushSubscription", defaultUserPushSubscriptionStore);
|
|
6354
6394
|
var defaultUserStore = new InMemoryUserStore();
|
|
6355
6395
|
var defaultTenantStore = new InMemoryTenantStore();
|
|
6356
6396
|
var defaultUserTenantLinkStore = new InMemoryUserTenantLinkStore();
|
|
@@ -15486,7 +15526,7 @@ function hasExplicitAllowedTools(policy) {
|
|
|
15486
15526
|
return Object.prototype.hasOwnProperty.call(policy, "allowedTools");
|
|
15487
15527
|
}
|
|
15488
15528
|
function hasActiveRuntimePolicy(runtime) {
|
|
15489
|
-
return
|
|
15529
|
+
return Object.keys(runtime.middleware).length > 0;
|
|
15490
15530
|
}
|
|
15491
15531
|
function tenantIdFromRequest(request) {
|
|
15492
15532
|
if (!isRecord8(request) || !isRecord8(request.runtime)) return void 0;
|
|
@@ -16643,6 +16683,17 @@ var ChunkBuffer = class {
|
|
|
16643
16683
|
|
|
16644
16684
|
// src/chunk_buffer_lattice/InMemoryChunkBuffer.ts
|
|
16645
16685
|
var import_protocols8 = require("@axiom-lattice/protocols");
|
|
16686
|
+
|
|
16687
|
+
// src/chunk_buffer_lattice/types.ts
|
|
16688
|
+
var ThreadEndError = class extends Error {
|
|
16689
|
+
constructor(message, code) {
|
|
16690
|
+
super(message);
|
|
16691
|
+
this.name = "ThreadEndError";
|
|
16692
|
+
this.code = code;
|
|
16693
|
+
}
|
|
16694
|
+
};
|
|
16695
|
+
|
|
16696
|
+
// src/chunk_buffer_lattice/InMemoryChunkBuffer.ts
|
|
16646
16697
|
var import_rxjs = require("rxjs");
|
|
16647
16698
|
var import_rxjs_for_await = require("rxjs-for-await");
|
|
16648
16699
|
var import_operators = require("rxjs/operators");
|
|
@@ -16756,12 +16807,12 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
|
|
|
16756
16807
|
buffer2.chunks$.complete();
|
|
16757
16808
|
}
|
|
16758
16809
|
}
|
|
16759
|
-
async abortThread(threadId) {
|
|
16810
|
+
async abortThread(threadId, message, code = "aborted") {
|
|
16760
16811
|
const buffer2 = this.getBufferIfValid(threadId);
|
|
16761
16812
|
if (buffer2) {
|
|
16762
16813
|
buffer2.status = "aborted" /* ABORTED */;
|
|
16763
16814
|
buffer2.updatedAt = Date.now();
|
|
16764
|
-
buffer2.chunks$.error(new
|
|
16815
|
+
buffer2.chunks$.error(new ThreadEndError(message ?? "Thread aborted", code));
|
|
16765
16816
|
}
|
|
16766
16817
|
}
|
|
16767
16818
|
async isThreadActive(threadId) {
|
|
@@ -17714,6 +17765,17 @@ var CapabilityBundleMerger = class {
|
|
|
17714
17765
|
};
|
|
17715
17766
|
|
|
17716
17767
|
// src/capability/CapabilityRuntimeResolver.ts
|
|
17768
|
+
var EMPTY_CAPABILITY_RUNTIME_REVISION = createCapabilityRevision([], {});
|
|
17769
|
+
function emptyCapabilityRuntime(expectedRevision) {
|
|
17770
|
+
if (expectedRevision !== void 0 && expectedRevision !== "" && expectedRevision !== EMPTY_CAPABILITY_RUNTIME_REVISION) {
|
|
17771
|
+
throw new CapabilityRuntimeResolutionError(
|
|
17772
|
+
"CAPABILITY_RUNTIME_REVISION_MISMATCH",
|
|
17773
|
+
"Capability runtime revision no longer matches the checkpoint",
|
|
17774
|
+
{ expectedRevision, actualRevision: EMPTY_CAPABILITY_RUNTIME_REVISION }
|
|
17775
|
+
);
|
|
17776
|
+
}
|
|
17777
|
+
return { revision: EMPTY_CAPABILITY_RUNTIME_REVISION, middleware: {} };
|
|
17778
|
+
}
|
|
17717
17779
|
var CapabilityRuntimeResolutionError = class extends Error {
|
|
17718
17780
|
/**
|
|
17719
17781
|
* Creates a runtime resolution error.
|
|
@@ -17894,14 +17956,7 @@ var CapabilityRuntimeResolver = class {
|
|
|
17894
17956
|
};
|
|
17895
17957
|
}
|
|
17896
17958
|
emptyRuntime(expectedRevision) {
|
|
17897
|
-
|
|
17898
|
-
throw new CapabilityRuntimeResolutionError(
|
|
17899
|
-
"CAPABILITY_RUNTIME_REVISION_MISMATCH",
|
|
17900
|
-
"Capability runtime revision no longer matches the checkpoint",
|
|
17901
|
-
{ expectedRevision, actualRevision: "" }
|
|
17902
|
-
);
|
|
17903
|
-
}
|
|
17904
|
-
return { revision: "", middleware: {} };
|
|
17959
|
+
return emptyCapabilityRuntime(expectedRevision);
|
|
17905
17960
|
}
|
|
17906
17961
|
};
|
|
17907
17962
|
|
|
@@ -18140,6 +18195,10 @@ function requireTrustedCapabilityRevision(value) {
|
|
|
18140
18195
|
}
|
|
18141
18196
|
return value;
|
|
18142
18197
|
}
|
|
18198
|
+
function trustedCapabilityRevision(value) {
|
|
18199
|
+
if (value === "") return void 0;
|
|
18200
|
+
return requireTrustedCapabilityRevision(value);
|
|
18201
|
+
}
|
|
18143
18202
|
function finalAiMessageMarker(state) {
|
|
18144
18203
|
if (!isPlainRecord(state) || !isPlainRecord(state.values) || !Array.isArray(state.values.messages)) {
|
|
18145
18204
|
return void 0;
|
|
@@ -18355,7 +18414,9 @@ var Agent = class {
|
|
|
18355
18414
|
throw error;
|
|
18356
18415
|
}
|
|
18357
18416
|
} catch (error) {
|
|
18358
|
-
|
|
18417
|
+
const endCode = signal?.aborted ? "aborted" : "stream_error";
|
|
18418
|
+
const endMessage = endCode === "stream_error" ? error instanceof Error ? error.message : "Stream processing error" : "Thread aborted";
|
|
18419
|
+
await this.chunkBuffer.abortThread(this.thread_id, endMessage, endCode);
|
|
18359
18420
|
throw error;
|
|
18360
18421
|
}
|
|
18361
18422
|
};
|
|
@@ -18414,7 +18475,7 @@ var Agent = class {
|
|
|
18414
18475
|
const interruptedExecutionContext = commandRunStatus === "interrupted" /* INTERRUPTED */ ? this.processingExecutionContext(interruptedMessages, true) : void 0;
|
|
18415
18476
|
const interruptedConfig = interruptedExecutionContext?.customRunConfig;
|
|
18416
18477
|
const queuedCapabilityRevision = typeof interruptedConfig === "object" && interruptedConfig !== null ? interruptedConfig.capabilityRuntimeRevision : void 0;
|
|
18417
|
-
const expectedCapabilityRevision = interruptedExecutionContext?.trustedRunContext !== void 0 ?
|
|
18478
|
+
const expectedCapabilityRevision = interruptedExecutionContext?.trustedRunContext !== void 0 ? trustedCapabilityRevision(queuedCapabilityRevision) : typeof queuedCapabilityRevision === "string" ? queuedCapabilityRevision : void 0;
|
|
18418
18479
|
try {
|
|
18419
18480
|
const preRunMarker = finalAiMessageMarker(preRunState);
|
|
18420
18481
|
await this.agentStreamExecutor({
|
|
@@ -18780,7 +18841,8 @@ var Agent = class {
|
|
|
18780
18841
|
consumedInputMessageIds: rows.map(({ id }) => id)
|
|
18781
18842
|
};
|
|
18782
18843
|
}
|
|
18783
|
-
|
|
18844
|
+
const unmarkedCommandRows = rows.filter((row2) => row2.trusted_run_context === void 0 && row2.execution_mode === void 0 && row2.command !== void 0);
|
|
18845
|
+
if (markedRows.length !== 1 || markedRows.length + unmarkedCommandRows.length !== rows.length) {
|
|
18784
18846
|
throw new TrustedRunContextRecoveryError("Trusted processing rows are inconsistent");
|
|
18785
18847
|
}
|
|
18786
18848
|
const row = markedRows[0];
|
|
@@ -18939,14 +19001,7 @@ var Agent = class {
|
|
|
18939
19001
|
});
|
|
18940
19002
|
let capabilityRuntime;
|
|
18941
19003
|
if (this.queue_project_id === null) {
|
|
18942
|
-
|
|
18943
|
-
throw new CapabilityRuntimeResolutionError(
|
|
18944
|
-
"CAPABILITY_RUNTIME_REVISION_MISMATCH",
|
|
18945
|
-
"Capability runtime revision no longer matches the checkpoint",
|
|
18946
|
-
{ expectedRevision, actualRevision: "" }
|
|
18947
|
-
);
|
|
18948
|
-
}
|
|
18949
|
-
capabilityRuntime = { revision: "", middleware: {} };
|
|
19004
|
+
capabilityRuntime = emptyCapabilityRuntime(expectedRevision);
|
|
18950
19005
|
} else {
|
|
18951
19006
|
capabilityRuntime = await resolver.resolve({
|
|
18952
19007
|
tenantId: this.tenant_id,
|
|
@@ -19077,7 +19132,7 @@ var Agent = class {
|
|
|
19077
19132
|
const persistedConfig = recoveryContext?.customRunConfig;
|
|
19078
19133
|
const queuedRevision = typeof persistedConfig === "object" && persistedConfig !== null ? persistedConfig.capabilityRuntimeRevision : void 0;
|
|
19079
19134
|
if (recoveryContext?.trustedRunContext !== void 0) {
|
|
19080
|
-
return
|
|
19135
|
+
return trustedCapabilityRevision(queuedRevision);
|
|
19081
19136
|
}
|
|
19082
19137
|
const persistedRevision = typeof queuedRevision === "string" && queuedRevision.length > 0 ? queuedRevision : void 0;
|
|
19083
19138
|
if (persistedRevision !== void 0 && recoveryContext.checkpointCapabilityRevision !== void 0 && persistedRevision !== recoveryContext.checkpointCapabilityRevision) {
|
|
@@ -19096,7 +19151,7 @@ var Agent = class {
|
|
|
19096
19151
|
const emittedToolCallIds = /* @__PURE__ */ new Set();
|
|
19097
19152
|
for await (const chunk2 of agentStream) {
|
|
19098
19153
|
if (signal?.aborted) {
|
|
19099
|
-
await this.chunkBuffer.abortThread(this.thread_id);
|
|
19154
|
+
await this.chunkBuffer.abortThread(this.thread_id, "Thread aborted", "aborted");
|
|
19100
19155
|
throw new Error("Agent execution was aborted");
|
|
19101
19156
|
}
|
|
19102
19157
|
let data;
|
|
@@ -19214,6 +19269,7 @@ var Agent = class {
|
|
|
19214
19269
|
this.abortController.abort();
|
|
19215
19270
|
this.abortController = null;
|
|
19216
19271
|
}
|
|
19272
|
+
void this.chunkBuffer.abortThread(this.thread_id, "Thread superseded", "superseded");
|
|
19217
19273
|
}
|
|
19218
19274
|
/**
|
|
19219
19275
|
* Enqueue a message for this thread.
|
|
@@ -19596,16 +19652,18 @@ var Agent = class {
|
|
|
19596
19652
|
}
|
|
19597
19653
|
if (runStatus === "busy" /* BUSY */) {
|
|
19598
19654
|
this.abortController = new AbortController();
|
|
19655
|
+
const resumeSignal = this.abortController.signal;
|
|
19599
19656
|
try {
|
|
19600
19657
|
const executionContext = this.processingExecutionContext(processingMessages, true);
|
|
19601
19658
|
const customRunConfig = executionContext.customRunConfig;
|
|
19602
|
-
if (typeof customRunConfig.capabilityRuntimeRevision !== "string"
|
|
19659
|
+
if (typeof customRunConfig.capabilityRuntimeRevision !== "string") {
|
|
19603
19660
|
throw new Error("Capability runtime revision is missing from the checkpoint message");
|
|
19604
19661
|
}
|
|
19662
|
+
const resumeRunConfig = executionContext.trustedRunContext !== void 0 && customRunConfig.capabilityRuntimeRevision === "" ? { ...customRunConfig, capabilityRuntimeRevision: void 0 } : customRunConfig;
|
|
19605
19663
|
await this.resumeGraphFromCheckpoint(
|
|
19606
|
-
|
|
19664
|
+
resumeRunConfig,
|
|
19607
19665
|
executionContext.trustedRunContext,
|
|
19608
|
-
|
|
19666
|
+
resumeSignal
|
|
19609
19667
|
);
|
|
19610
19668
|
const state = await this.getCurrentState();
|
|
19611
19669
|
const resumedStatus = await this.getRunStatus(state);
|
|
@@ -19649,7 +19707,12 @@ var Agent = class {
|
|
|
19649
19707
|
};
|
|
19650
19708
|
} catch (error) {
|
|
19651
19709
|
console.error(`[Agent] Failed to resume graph for thread ${this.thread_id}:`, error);
|
|
19652
|
-
|
|
19710
|
+
const endCode = resumeSignal.aborted ? "aborted" : "stream_error";
|
|
19711
|
+
await this.chunkBuffer.abortThread(
|
|
19712
|
+
this.thread_id,
|
|
19713
|
+
endCode === "aborted" ? "Thread aborted" : error instanceof Error ? error.message : "Resume failed",
|
|
19714
|
+
endCode
|
|
19715
|
+
);
|
|
19653
19716
|
throw error;
|
|
19654
19717
|
} finally {
|
|
19655
19718
|
this.abortController = null;
|
|
@@ -19699,7 +19762,7 @@ var Agent = class {
|
|
|
19699
19762
|
this.abortController.abort();
|
|
19700
19763
|
this.abortController = null;
|
|
19701
19764
|
}
|
|
19702
|
-
await this.chunkBuffer.abortThread(this.thread_id);
|
|
19765
|
+
await this.chunkBuffer.abortThread(this.thread_id, "Thread aborted", "aborted");
|
|
19703
19766
|
const store = this.getQueueStore();
|
|
19704
19767
|
await store.clearMessages(this.thread_id, this.queueScope());
|
|
19705
19768
|
}
|
|
@@ -27686,6 +27749,13 @@ When a bot is @mentioned, that bot answers; you stay silent unless asked.
|
|
|
27686
27749
|
- Someone @mentions a bot \u2192 let that bot respond. Only correct or summarize when the bot fails or the user asks you.
|
|
27687
27750
|
- @team mention \u2192 treat as addressed to you; you may summarize and optionally propose task work.
|
|
27688
27751
|
|
|
27752
|
+
## Clarifying questions
|
|
27753
|
+
When you need more information before acting, ask the user directly in your room
|
|
27754
|
+
reply text and then stop. Do NOT use HITL/approval tools such as
|
|
27755
|
+
\`ask_user_to_clarify\`: project rooms are asynchronous and have no interactive
|
|
27756
|
+
approval UI, so an interrupt would stall the room with no visible prompt. The
|
|
27757
|
+
user's next room message continues the conversation.
|
|
27758
|
+
|
|
27689
27759
|
## Task policy
|
|
27690
27760
|
- Turn actionable, verifiable room requests into persistent Project Tasks (task middleware), UNLESS they are simple, immediate, single-response work handled conversationally per the Delegation decision below.
|
|
27691
27761
|
- A task must have an owner. Prefer assigning to a room bot via Project Task assignment.
|
|
@@ -30378,14 +30448,6 @@ var roomCoordinatorConfig = {
|
|
|
30378
30448
|
enabled: true,
|
|
30379
30449
|
config: { readAll: true }
|
|
30380
30450
|
},
|
|
30381
|
-
{
|
|
30382
|
-
id: "ask_user_to_clarify",
|
|
30383
|
-
type: "ask_user_to_clarify",
|
|
30384
|
-
name: "Ask User",
|
|
30385
|
-
description: "Wait for user input at approval gates",
|
|
30386
|
-
enabled: true,
|
|
30387
|
-
config: {}
|
|
30388
|
-
},
|
|
30389
30451
|
{
|
|
30390
30452
|
id: "project_room",
|
|
30391
30453
|
type: "project_room",
|
|
@@ -35856,6 +35918,7 @@ var INPUT_KEYS = [
|
|
|
35856
35918
|
"idempotencyKey"
|
|
35857
35919
|
];
|
|
35858
35920
|
var REPLY_INPUT_KEYS = ["tenantId", "membershipId", "text", "sourceRoomMessageId", "inputMessageId", "sourceId", "idempotencyKey"];
|
|
35921
|
+
var INTERRUPT_INPUT_KEYS = ["tenantId", "membershipId", "text", "sourceRoomMessageId", "inputMessageId"];
|
|
35859
35922
|
var RoomAgentMessageService = class {
|
|
35860
35923
|
/**
|
|
35861
35924
|
* Creates a room writer over the durable membership and message stores.
|
|
@@ -35888,6 +35951,21 @@ var RoomAgentMessageService = class {
|
|
|
35888
35951
|
}
|
|
35889
35952
|
return this.persistDerived(snapshot);
|
|
35890
35953
|
}
|
|
35954
|
+
/**
|
|
35955
|
+
* Persists a pending HITL interrupt (question/notice) as an Agent-authored room message.
|
|
35956
|
+
*
|
|
35957
|
+
* @param input Exact correlation IDs, target membership, and question text.
|
|
35958
|
+
* @returns A deep clone of the canonical idempotent room message.
|
|
35959
|
+
*/
|
|
35960
|
+
postInterrupt(input) {
|
|
35961
|
+
const snapshot = exactStringRecord(input, INTERRUPT_INPUT_KEYS, "Invalid project room interrupt input");
|
|
35962
|
+
const sourceId = `interrupt:${snapshot.inputMessageId}`;
|
|
35963
|
+
return this.persistDerived({
|
|
35964
|
+
...snapshot,
|
|
35965
|
+
sourceId,
|
|
35966
|
+
idempotencyKey: `room-interrupt:${snapshot.sourceRoomMessageId}:${snapshot.membershipId}:${sourceId}`
|
|
35967
|
+
});
|
|
35968
|
+
}
|
|
35891
35969
|
async persistDerived(input) {
|
|
35892
35970
|
const source = snapshotSource(await this.deps.messages.findById(input.tenantId, input.sourceRoomMessageId));
|
|
35893
35971
|
if (!source || source.id !== input.sourceRoomMessageId || source.tenantId !== input.tenantId) throw new Error("Invalid project room message");
|
|
@@ -35966,24 +36044,37 @@ function date(value) {
|
|
|
35966
36044
|
}
|
|
35967
36045
|
function snapshotSource(value) {
|
|
35968
36046
|
const values = exactValues(value, ["id", "tenantId", "workspaceId", "projectId", "roomId", "author", "content", "mentions", "source", "createdAt"], ["replyToMessageId", "sourceId", "idempotencyKey"]);
|
|
35969
|
-
const author =
|
|
36047
|
+
const author = snapshotSourceAuthor(values?.author);
|
|
35970
36048
|
const content = exactValues(values?.content, ["type", "text"]);
|
|
35971
36049
|
const createdAt = date(values?.createdAt);
|
|
35972
36050
|
const mentions = snapshotMentions(values?.mentions);
|
|
35973
|
-
if (!values ||
|
|
36051
|
+
if (!values || !author || !sourceOriginMatches(author, values.source) || content?.type !== "text" || typeof content.text !== "string" || !mentions || !createdAt || ["id", "tenantId", "workspaceId", "projectId", "roomId"].some((key5) => typeof values[key5] !== "string" || !values[key5])) return void 0;
|
|
35974
36052
|
return {
|
|
35975
36053
|
id: values.id,
|
|
35976
36054
|
tenantId: values.tenantId,
|
|
35977
36055
|
workspaceId: values.workspaceId,
|
|
35978
36056
|
projectId: values.projectId,
|
|
35979
36057
|
roomId: values.roomId,
|
|
35980
|
-
author
|
|
36058
|
+
author,
|
|
35981
36059
|
content: { type: "text", text: content.text },
|
|
35982
36060
|
mentions,
|
|
35983
|
-
source:
|
|
36061
|
+
source: values.source,
|
|
35984
36062
|
createdAt
|
|
35985
36063
|
};
|
|
35986
36064
|
}
|
|
36065
|
+
function snapshotSourceAuthor(value) {
|
|
36066
|
+
const human = exactValues(value, ["type", "userId"]);
|
|
36067
|
+
if (human?.type === "human" && typeof human.userId === "string" && human.userId.length > 0) {
|
|
36068
|
+
return { type: "human", userId: human.userId };
|
|
36069
|
+
}
|
|
36070
|
+
const system = exactValues(value, ["type"]);
|
|
36071
|
+
return system?.type === "system" ? { type: "system" } : void 0;
|
|
36072
|
+
}
|
|
36073
|
+
function sourceOriginMatches(author, source) {
|
|
36074
|
+
if (author.type === "human") return source === "user";
|
|
36075
|
+
if (author.type === "system") return source === "task";
|
|
36076
|
+
return false;
|
|
36077
|
+
}
|
|
35987
36078
|
function snapshotMentions(value) {
|
|
35988
36079
|
const rows = (0, import_protocols27.snapshotExactArray)(value);
|
|
35989
36080
|
if (!rows) return void 0;
|
|
@@ -41611,6 +41702,17 @@ function createAskUserToClarifyTool() {
|
|
|
41611
41702
|
}
|
|
41612
41703
|
|
|
41613
41704
|
// src/middlewares/askUserClarifyMiddleware.ts
|
|
41705
|
+
function isRecord9(value) {
|
|
41706
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41707
|
+
}
|
|
41708
|
+
function isProjectRoomRun(request) {
|
|
41709
|
+
if (!isRecord9(request) || !isRecord9(request.runtime)) return false;
|
|
41710
|
+
const runtime = request.runtime;
|
|
41711
|
+
const configurable = isRecord9(runtime.configurable) ? runtime.configurable.runConfig : void 0;
|
|
41712
|
+
const context = isRecord9(runtime.context) ? runtime.context.runConfig : void 0;
|
|
41713
|
+
const runConfig = isRecord9(configurable) ? configurable : isRecord9(context) ? context : void 0;
|
|
41714
|
+
return isRecord9(runConfig?.projectRoom);
|
|
41715
|
+
}
|
|
41614
41716
|
function createAskUserClarifyMiddleware() {
|
|
41615
41717
|
return (0, import_langchain83.createMiddleware)({
|
|
41616
41718
|
name: "AskUserClarifyMiddleware",
|
|
@@ -41621,6 +41723,13 @@ function createAskUserClarifyMiddleware() {
|
|
|
41621
41723
|
if (toolName2 !== "ask_user_to_clarify") {
|
|
41622
41724
|
return handler(request);
|
|
41623
41725
|
}
|
|
41726
|
+
if (isProjectRoomRun(request)) {
|
|
41727
|
+
return new import_langchain83.ToolMessage({
|
|
41728
|
+
content: "You are replying inside a project room, which has no interactive clarification UI. Ask your clarifying questions directly in your reply text and stop; the user's next room message will continue the conversation.",
|
|
41729
|
+
tool_call_id: toolCall?.id,
|
|
41730
|
+
name: toolName2
|
|
41731
|
+
});
|
|
41732
|
+
}
|
|
41624
41733
|
const parsed = inputSchema.safeParse(toolCall?.args);
|
|
41625
41734
|
if (!parsed.success) {
|
|
41626
41735
|
return new import_langchain83.ToolMessage({
|
|
@@ -43681,12 +43790,20 @@ function createTaskMiddleware(options = {}) {
|
|
|
43681
43790
|
sourceId: trustedProject?.projectRoom?.sourceRoomMessageId ?? trustedProject?.projectTask?.inputMessageId ?? input.sourceId,
|
|
43682
43791
|
context: trustedProject?.projectTask ? {
|
|
43683
43792
|
...trustedSharedContext(input.context),
|
|
43684
|
-
source: "project_task"
|
|
43793
|
+
source: "project_task",
|
|
43794
|
+
created_by: {
|
|
43795
|
+
assistantId: trustedProject.projectTask.assistantId,
|
|
43796
|
+
membershipId: trustedProject.projectTask.membershipId
|
|
43797
|
+
}
|
|
43685
43798
|
} : trustedProject?.projectRoom ? {
|
|
43686
43799
|
...trustedSharedContext(input.context),
|
|
43687
43800
|
source: "project_room",
|
|
43688
43801
|
room_id: trustedProject.projectRoom.roomId,
|
|
43689
|
-
source_message_id: trustedProject.projectRoom.sourceRoomMessageId
|
|
43802
|
+
source_message_id: trustedProject.projectRoom.sourceRoomMessageId,
|
|
43803
|
+
created_by: {
|
|
43804
|
+
assistantId: trustedProject.projectRoom.assistantId,
|
|
43805
|
+
membershipId: trustedProject.projectRoom.membershipId
|
|
43806
|
+
}
|
|
43690
43807
|
} : input.context,
|
|
43691
43808
|
requireReview: input.requireReview,
|
|
43692
43809
|
dependencies: input.dependencies,
|
|
@@ -44509,6 +44626,15 @@ function createTaskMiddleware(options = {}) {
|
|
|
44509
44626
|
if (!needsReview) {
|
|
44510
44627
|
const callerError2 = await revalidateCaller();
|
|
44511
44628
|
if (callerError2) return callerError2;
|
|
44629
|
+
if (existing.status === "interrupted" && !reviewInterruption(existing)) {
|
|
44630
|
+
const resumed = await lifecycle.resumeInterruption({
|
|
44631
|
+
tenantId: tenantId2,
|
|
44632
|
+
taskId: input.id,
|
|
44633
|
+
actor,
|
|
44634
|
+
threadId: statusThreadId
|
|
44635
|
+
});
|
|
44636
|
+
if (!resumed.success) return lifecycleMutationResponse(resumed);
|
|
44637
|
+
}
|
|
44512
44638
|
const result = existing.status === "completed" ? await lifecycle.repairCompletion(completionInput) : await lifecycle.completeAgentTask(completionInput);
|
|
44513
44639
|
return lifecycleMutationResponse(result);
|
|
44514
44640
|
}
|
|
@@ -47286,6 +47412,7 @@ registerBuiltinPlugins();
|
|
|
47286
47412
|
InMemoryTenantStore,
|
|
47287
47413
|
InMemoryThreadMessageQueueStore,
|
|
47288
47414
|
InMemoryThreadStore,
|
|
47415
|
+
InMemoryUserPushSubscriptionStore,
|
|
47289
47416
|
InMemoryUserStore,
|
|
47290
47417
|
InMemoryUserTenantLinkStore,
|
|
47291
47418
|
LINE_NUMBER_WIDTH,
|
|
@@ -47327,6 +47454,7 @@ registerBuiltinPlugins();
|
|
|
47327
47454
|
Protocols,
|
|
47328
47455
|
QueueLatticeManager,
|
|
47329
47456
|
QueueMode,
|
|
47457
|
+
ROOM_COORDINATOR_KEY,
|
|
47330
47458
|
RemoteSandboxInstance,
|
|
47331
47459
|
RemoteSandboxProvider,
|
|
47332
47460
|
RoomAgentMessageService,
|
|
@@ -47355,6 +47483,7 @@ registerBuiltinPlugins();
|
|
|
47355
47483
|
TaskStatus,
|
|
47356
47484
|
TeamAgentGraphBuilder,
|
|
47357
47485
|
TenantPluginCatalog,
|
|
47486
|
+
ThreadEndError,
|
|
47358
47487
|
ThreadStatus,
|
|
47359
47488
|
TokenCache,
|
|
47360
47489
|
ToolLatticeManager,
|
|
@@ -47552,6 +47681,7 @@ registerBuiltinPlugins();
|
|
|
47552
47681
|
resolvePath,
|
|
47553
47682
|
resolveSandboxPluginConnections,
|
|
47554
47683
|
resolveTenantPluginSkill,
|
|
47684
|
+
roomCoordinatorConfig,
|
|
47555
47685
|
runRemotePackDirectory,
|
|
47556
47686
|
safeTaskResponseId,
|
|
47557
47687
|
sandboxLatticeManager,
|