@dudousxd/nestjs-agent-core 0.30.0 → 0.32.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/dist/genui/index.d.cts +1 -1
- package/dist/genui/index.d.ts +1 -1
- package/dist/guardrails/index.d.cts +2 -2
- package/dist/guardrails/index.d.ts +2 -2
- package/dist/index.cjs +200 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -333
- package/dist/index.d.ts +43 -333
- package/dist/index.js +196 -0
- package/dist/index.js.map +1 -1
- package/dist/{processors-8c9g9J6R.d.ts → processors-BIVqOR1Q.d.ts} +1 -1
- package/dist/{processors-DdwZ0NFG.d.cts → processors-DQJ5sWw7.d.cts} +1 -1
- package/dist/{tool-CfnSyIQf.d.cts → tool-BhhzEI40.d.cts} +581 -97
- package/dist/{tool-CfnSyIQf.d.ts → tool-BhhzEI40.d.ts} +581 -97
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -289,6 +289,59 @@ function mergeUi(...lists) {
|
|
|
289
289
|
}
|
|
290
290
|
__name(mergeUi, "mergeUi");
|
|
291
291
|
|
|
292
|
+
// src/tool-presentation.ts
|
|
293
|
+
var ALL_AGENTS = "*";
|
|
294
|
+
|
|
295
|
+
// src/spi/chat-queue.ts
|
|
296
|
+
var CHAT_QUEUE_METHODS = [
|
|
297
|
+
"enqueueMessage",
|
|
298
|
+
"listQueue",
|
|
299
|
+
"getQueuedMessage",
|
|
300
|
+
"updateQueuedMessage",
|
|
301
|
+
"moveQueuedMessage",
|
|
302
|
+
"removeQueuedMessage",
|
|
303
|
+
"clearQueue",
|
|
304
|
+
"queuePause",
|
|
305
|
+
"setQueuePause",
|
|
306
|
+
"activeRunForThread",
|
|
307
|
+
"claimActiveStream",
|
|
308
|
+
"releaseActiveStream"
|
|
309
|
+
];
|
|
310
|
+
function isChatQueueStore(store) {
|
|
311
|
+
const candidate = store;
|
|
312
|
+
return CHAT_QUEUE_METHODS.every((method) => typeof candidate[method] === "function");
|
|
313
|
+
}
|
|
314
|
+
__name(isChatQueueStore, "isChatQueueStore");
|
|
315
|
+
async function releaseThreadRun(store, threadId, runId) {
|
|
316
|
+
if (isChatQueueStore(store)) {
|
|
317
|
+
await store.releaseActiveStream(threadId, runId);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
await store.setActiveStream(threadId, null);
|
|
321
|
+
}
|
|
322
|
+
__name(releaseThreadRun, "releaseThreadRun");
|
|
323
|
+
function queuedMessageView(message) {
|
|
324
|
+
return {
|
|
325
|
+
id: message.id,
|
|
326
|
+
content: message.content,
|
|
327
|
+
...message.attachments !== void 0 && message.attachments.length > 0 ? {
|
|
328
|
+
attachments: message.attachments
|
|
329
|
+
} : {},
|
|
330
|
+
...message.agentName !== void 0 ? {
|
|
331
|
+
agentName: message.agentName
|
|
332
|
+
} : {},
|
|
333
|
+
...message.model !== void 0 ? {
|
|
334
|
+
model: message.model
|
|
335
|
+
} : {},
|
|
336
|
+
...message.interrupt === true ? {
|
|
337
|
+
interrupt: true
|
|
338
|
+
} : {},
|
|
339
|
+
createdAt: message.createdAt,
|
|
340
|
+
updatedAt: message.updatedAt
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
__name(queuedMessageView, "queuedMessageView");
|
|
344
|
+
|
|
292
345
|
// src/spi/quota-provider.ts
|
|
293
346
|
function exhaustedWindow(windows) {
|
|
294
347
|
for (const window of windows) {
|
|
@@ -4679,6 +4732,9 @@ var InMemoryAgentStore = class {
|
|
|
4679
4732
|
__name(this, "InMemoryAgentStore");
|
|
4680
4733
|
}
|
|
4681
4734
|
threads = /* @__PURE__ */ new Map();
|
|
4735
|
+
/** Each thread's waiting messages, in run order. */
|
|
4736
|
+
queues = /* @__PURE__ */ new Map();
|
|
4737
|
+
pauses = /* @__PURE__ */ new Map();
|
|
4682
4738
|
toolCalls = /* @__PURE__ */ new Map();
|
|
4683
4739
|
usage = [];
|
|
4684
4740
|
runs = /* @__PURE__ */ new Map();
|
|
@@ -4935,6 +4991,142 @@ var InMemoryAgentStore = class {
|
|
|
4935
4991
|
}
|
|
4936
4992
|
}
|
|
4937
4993
|
}
|
|
4994
|
+
async claimActiveStream(threadId, runId, options = {}) {
|
|
4995
|
+
const row = this.threads.get(threadId);
|
|
4996
|
+
if (row === void 0) {
|
|
4997
|
+
return false;
|
|
4998
|
+
}
|
|
4999
|
+
const holder = row.activeStreamId;
|
|
5000
|
+
if (holder !== void 0 && holder !== runId && holder !== options.replacing) {
|
|
5001
|
+
return false;
|
|
5002
|
+
}
|
|
5003
|
+
row.activeStreamId = runId;
|
|
5004
|
+
return true;
|
|
5005
|
+
}
|
|
5006
|
+
async releaseActiveStream(threadId, runId) {
|
|
5007
|
+
const row = this.threads.get(threadId);
|
|
5008
|
+
if (row?.activeStreamId !== runId) {
|
|
5009
|
+
return false;
|
|
5010
|
+
}
|
|
5011
|
+
delete row.activeStreamId;
|
|
5012
|
+
return true;
|
|
5013
|
+
}
|
|
5014
|
+
async enqueueMessage(input) {
|
|
5015
|
+
const ts = this.now();
|
|
5016
|
+
const message = {
|
|
5017
|
+
id: crypto.randomUUID(),
|
|
5018
|
+
threadId: input.threadId,
|
|
5019
|
+
actor: input.actor,
|
|
5020
|
+
content: input.content,
|
|
5021
|
+
...input.attachments !== void 0 && input.attachments.length > 0 ? {
|
|
5022
|
+
attachments: input.attachments
|
|
5023
|
+
} : {},
|
|
5024
|
+
...input.agentName !== void 0 ? {
|
|
5025
|
+
agentName: input.agentName
|
|
5026
|
+
} : {},
|
|
5027
|
+
...input.model !== void 0 ? {
|
|
5028
|
+
model: input.model
|
|
5029
|
+
} : {},
|
|
5030
|
+
...input.pageContext !== void 0 ? {
|
|
5031
|
+
pageContext: input.pageContext
|
|
5032
|
+
} : {},
|
|
5033
|
+
...input.interrupt === true ? {
|
|
5034
|
+
interrupt: true
|
|
5035
|
+
} : {},
|
|
5036
|
+
createdAt: ts,
|
|
5037
|
+
updatedAt: ts
|
|
5038
|
+
};
|
|
5039
|
+
const queue = this.queues.get(input.threadId) ?? [];
|
|
5040
|
+
if (input.at === "head") {
|
|
5041
|
+
queue.unshift(message);
|
|
5042
|
+
} else {
|
|
5043
|
+
queue.push(message);
|
|
5044
|
+
}
|
|
5045
|
+
this.queues.set(input.threadId, queue);
|
|
5046
|
+
return {
|
|
5047
|
+
...message
|
|
5048
|
+
};
|
|
5049
|
+
}
|
|
5050
|
+
async listQueue(threadId) {
|
|
5051
|
+
return (this.queues.get(threadId) ?? []).map((message) => ({
|
|
5052
|
+
...message
|
|
5053
|
+
}));
|
|
5054
|
+
}
|
|
5055
|
+
async getQueuedMessage(id) {
|
|
5056
|
+
const found = this.findQueued(id);
|
|
5057
|
+
return found === void 0 ? null : {
|
|
5058
|
+
...found.message
|
|
5059
|
+
};
|
|
5060
|
+
}
|
|
5061
|
+
async updateQueuedMessage(id, patch) {
|
|
5062
|
+
const found = this.findQueued(id);
|
|
5063
|
+
if (found === void 0) {
|
|
5064
|
+
return null;
|
|
5065
|
+
}
|
|
5066
|
+
const { message } = found;
|
|
5067
|
+
if (patch.content !== void 0) {
|
|
5068
|
+
message.content = patch.content;
|
|
5069
|
+
}
|
|
5070
|
+
if (patch.attachments !== void 0) {
|
|
5071
|
+
if (patch.attachments === null || patch.attachments.length === 0) {
|
|
5072
|
+
delete message.attachments;
|
|
5073
|
+
} else {
|
|
5074
|
+
message.attachments = patch.attachments;
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5077
|
+
message.updatedAt = this.now();
|
|
5078
|
+
return {
|
|
5079
|
+
...message
|
|
5080
|
+
};
|
|
5081
|
+
}
|
|
5082
|
+
async moveQueuedMessage(id, index) {
|
|
5083
|
+
const found = this.findQueued(id);
|
|
5084
|
+
if (found === void 0) {
|
|
5085
|
+
return false;
|
|
5086
|
+
}
|
|
5087
|
+
const { queue, position, message } = found;
|
|
5088
|
+
queue.splice(position, 1);
|
|
5089
|
+
const target = Math.max(0, Math.min(queue.length, Math.trunc(index)));
|
|
5090
|
+
queue.splice(target, 0, message);
|
|
5091
|
+
return true;
|
|
5092
|
+
}
|
|
5093
|
+
async removeQueuedMessage(id) {
|
|
5094
|
+
const found = this.findQueued(id);
|
|
5095
|
+
if (found === void 0) {
|
|
5096
|
+
return false;
|
|
5097
|
+
}
|
|
5098
|
+
found.queue.splice(found.position, 1);
|
|
5099
|
+
return true;
|
|
5100
|
+
}
|
|
5101
|
+
async clearQueue(threadId) {
|
|
5102
|
+
const count = this.queues.get(threadId)?.length ?? 0;
|
|
5103
|
+
this.queues.delete(threadId);
|
|
5104
|
+
return count;
|
|
5105
|
+
}
|
|
5106
|
+
async queuePause(threadId) {
|
|
5107
|
+
return this.pauses.get(threadId) ?? null;
|
|
5108
|
+
}
|
|
5109
|
+
async setQueuePause(threadId, pause) {
|
|
5110
|
+
if (pause === null) {
|
|
5111
|
+
this.pauses.delete(threadId);
|
|
5112
|
+
} else {
|
|
5113
|
+
this.pauses.set(threadId, pause);
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
findQueued(id) {
|
|
5117
|
+
for (const queue of this.queues.values()) {
|
|
5118
|
+
const position = queue.findIndex((message2) => message2.id === id);
|
|
5119
|
+
const message = queue[position];
|
|
5120
|
+
if (message !== void 0) {
|
|
5121
|
+
return {
|
|
5122
|
+
queue,
|
|
5123
|
+
position,
|
|
5124
|
+
message
|
|
5125
|
+
};
|
|
5126
|
+
}
|
|
5127
|
+
}
|
|
5128
|
+
return void 0;
|
|
5129
|
+
}
|
|
4938
5130
|
async appendMessage(input) {
|
|
4939
5131
|
const row = this.threads.get(input.threadId);
|
|
4940
5132
|
if (row === void 0) {
|
|
@@ -5376,6 +5568,7 @@ export {
|
|
|
5376
5568
|
AGENT_SPAN_EVENTS,
|
|
5377
5569
|
AGENT_STORE,
|
|
5378
5570
|
AGENT_TOOL_REGISTRY,
|
|
5571
|
+
ALL_AGENTS,
|
|
5379
5572
|
APPROVAL_EXPIRED_REASON,
|
|
5380
5573
|
ASK_TOOL_DESCRIPTION,
|
|
5381
5574
|
ASK_TOOL_NAME,
|
|
@@ -5450,6 +5643,7 @@ export {
|
|
|
5450
5643
|
gateFollowUps,
|
|
5451
5644
|
gateTail,
|
|
5452
5645
|
invokeWithTransientRetry,
|
|
5646
|
+
isChatQueueStore,
|
|
5453
5647
|
isControlFlowSignal,
|
|
5454
5648
|
isReplayIntegrityError,
|
|
5455
5649
|
isToolEnabled,
|
|
@@ -5478,12 +5672,14 @@ export {
|
|
|
5478
5672
|
publishAgentToolCall,
|
|
5479
5673
|
publishAgentToolRetry,
|
|
5480
5674
|
questionOptions,
|
|
5675
|
+
queuedMessageView,
|
|
5481
5676
|
quotaPeriodRange,
|
|
5482
5677
|
quotaUsedRatio,
|
|
5483
5678
|
quotaWarning,
|
|
5484
5679
|
readElicitationInput,
|
|
5485
5680
|
readElicitationQuestions,
|
|
5486
5681
|
releaseGatedFrames,
|
|
5682
|
+
releaseThreadRun,
|
|
5487
5683
|
rememberInputSchema,
|
|
5488
5684
|
rememberToolDefinition,
|
|
5489
5685
|
renderElicitationAnswers,
|