@dudousxd/nestjs-agent-core 0.31.0 → 0.33.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 +202 -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 +199 -0
- package/dist/index.js.map +1 -1
- package/dist/{processors-C3Qx3ZdF.d.ts → processors-C1jir8eB.d.ts} +1 -1
- package/dist/{processors-DdnRmmlq.d.cts → processors-DvZDW5zS.d.cts} +1 -1
- package/dist/{tool-B0J4Fjyd.d.cts → tool-CMTuoJ2v.d.cts} +584 -97
- package/dist/{tool-B0J4Fjyd.d.ts → tool-CMTuoJ2v.d.ts} +584 -97
- package/package.json +1 -1
package/dist/genui/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as Catalog, J as JsonSchema, G as GenuiValidation, b as GenuiIssue } from '../catalog-CrzetM3_.cjs';
|
|
2
2
|
export { A as AjvLike, c as COMPONENT_NAME, d as CatalogOptions, C as ComponentDefinition, e as JsonSchemaValidator, P as PropsSchema, f as ajvValidator, g as builtinJsonSchemaValidator, h as defineCatalog, i as defineComponent, j as formatIssues, k as isStandardSchema, t as toJsonSchema, l as toSnakeCase, m as toolNameFor, v as validateProps, n as validatePropsSync } from '../catalog-CrzetM3_.cjs';
|
|
3
3
|
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
4
|
-
import { A as Actor, T as ToolSpec, a as ToolHandler, b as ToolPresentation } from '../tool-
|
|
4
|
+
import { A as Actor, T as ToolSpec, a as ToolHandler, b as ToolPresentation } from '../tool-CMTuoJ2v.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* One node of a composed UI: a catalog component, its props, and — for components declared with
|
package/dist/genui/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as Catalog, J as JsonSchema, G as GenuiValidation, b as GenuiIssue } from '../catalog-CrzetM3_.js';
|
|
2
2
|
export { A as AjvLike, c as COMPONENT_NAME, d as CatalogOptions, C as ComponentDefinition, e as JsonSchemaValidator, P as PropsSchema, f as ajvValidator, g as builtinJsonSchemaValidator, h as defineCatalog, i as defineComponent, j as formatIssues, k as isStandardSchema, t as toJsonSchema, l as toSnakeCase, m as toolNameFor, v as validateProps, n as validatePropsSync } from '../catalog-CrzetM3_.js';
|
|
3
3
|
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
4
|
-
import { A as Actor, T as ToolSpec, a as ToolHandler, b as ToolPresentation } from '../tool-
|
|
4
|
+
import { A as Actor, T as ToolSpec, a as ToolHandler, b as ToolPresentation } from '../tool-CMTuoJ2v.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* One node of a composed UI: a catalog component, its props, and — for components declared with
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InputProcessor, O as OutputProcessor } from '../processors-
|
|
2
|
-
import { A as Actor, a as ToolHandler } from '../tool-
|
|
1
|
+
import { I as InputProcessor, O as OutputProcessor } from '../processors-DvZDW5zS.cjs';
|
|
2
|
+
import { A as Actor, a as ToolHandler } from '../tool-CMTuoJ2v.cjs';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InputProcessor, O as OutputProcessor } from '../processors-
|
|
2
|
-
import { A as Actor, a as ToolHandler } from '../tool-
|
|
1
|
+
import { I as InputProcessor, O as OutputProcessor } from '../processors-C1jir8eB.js';
|
|
2
|
+
import { A as Actor, a as ToolHandler } from '../tool-CMTuoJ2v.js';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -123,6 +123,7 @@ __export(src_exports, {
|
|
|
123
123
|
gateFollowUps: () => gateFollowUps,
|
|
124
124
|
gateTail: () => gateTail,
|
|
125
125
|
invokeWithTransientRetry: () => invokeWithTransientRetry,
|
|
126
|
+
isChatQueueStore: () => isChatQueueStore,
|
|
126
127
|
isControlFlowSignal: () => isControlFlowSignal,
|
|
127
128
|
isReplayIntegrityError: () => isReplayIntegrityError,
|
|
128
129
|
isToolEnabled: () => isToolEnabled,
|
|
@@ -151,12 +152,14 @@ __export(src_exports, {
|
|
|
151
152
|
publishAgentToolCall: () => publishAgentToolCall,
|
|
152
153
|
publishAgentToolRetry: () => publishAgentToolRetry,
|
|
153
154
|
questionOptions: () => questionOptions,
|
|
155
|
+
queuedMessageView: () => queuedMessageView,
|
|
154
156
|
quotaPeriodRange: () => quotaPeriodRange,
|
|
155
157
|
quotaUsedRatio: () => quotaUsedRatio,
|
|
156
158
|
quotaWarning: () => quotaWarning,
|
|
157
159
|
readElicitationInput: () => readElicitationInput,
|
|
158
160
|
readElicitationQuestions: () => readElicitationQuestions,
|
|
159
161
|
releaseGatedFrames: () => releaseGatedFrames,
|
|
162
|
+
releaseThreadRun: () => releaseThreadRun,
|
|
160
163
|
rememberInputSchema: () => rememberInputSchema,
|
|
161
164
|
rememberToolDefinition: () => rememberToolDefinition,
|
|
162
165
|
renderElicitationAnswers: () => renderElicitationAnswers,
|
|
@@ -494,6 +497,56 @@ __name(mergeUi, "mergeUi");
|
|
|
494
497
|
// src/tool-presentation.ts
|
|
495
498
|
var ALL_AGENTS = "*";
|
|
496
499
|
|
|
500
|
+
// src/spi/chat-queue.ts
|
|
501
|
+
var CHAT_QUEUE_METHODS = [
|
|
502
|
+
"enqueueMessage",
|
|
503
|
+
"listQueue",
|
|
504
|
+
"getQueuedMessage",
|
|
505
|
+
"updateQueuedMessage",
|
|
506
|
+
"moveQueuedMessage",
|
|
507
|
+
"removeQueuedMessage",
|
|
508
|
+
"clearQueue",
|
|
509
|
+
"queuePause",
|
|
510
|
+
"setQueuePause",
|
|
511
|
+
"activeRunForThread",
|
|
512
|
+
"claimActiveStream",
|
|
513
|
+
"releaseActiveStream"
|
|
514
|
+
];
|
|
515
|
+
function isChatQueueStore(store) {
|
|
516
|
+
const candidate = store;
|
|
517
|
+
return CHAT_QUEUE_METHODS.every((method) => typeof candidate[method] === "function");
|
|
518
|
+
}
|
|
519
|
+
__name(isChatQueueStore, "isChatQueueStore");
|
|
520
|
+
async function releaseThreadRun(store, threadId, runId) {
|
|
521
|
+
if (isChatQueueStore(store)) {
|
|
522
|
+
await store.releaseActiveStream(threadId, runId);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
await store.setActiveStream(threadId, null);
|
|
526
|
+
}
|
|
527
|
+
__name(releaseThreadRun, "releaseThreadRun");
|
|
528
|
+
function queuedMessageView(message) {
|
|
529
|
+
return {
|
|
530
|
+
id: message.id,
|
|
531
|
+
content: message.content,
|
|
532
|
+
...message.attachments !== void 0 && message.attachments.length > 0 ? {
|
|
533
|
+
attachments: message.attachments
|
|
534
|
+
} : {},
|
|
535
|
+
...message.agentName !== void 0 ? {
|
|
536
|
+
agentName: message.agentName
|
|
537
|
+
} : {},
|
|
538
|
+
...message.model !== void 0 ? {
|
|
539
|
+
model: message.model
|
|
540
|
+
} : {},
|
|
541
|
+
...message.interrupt === true ? {
|
|
542
|
+
interrupt: true
|
|
543
|
+
} : {},
|
|
544
|
+
createdAt: message.createdAt,
|
|
545
|
+
updatedAt: message.updatedAt
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
__name(queuedMessageView, "queuedMessageView");
|
|
549
|
+
|
|
497
550
|
// src/spi/quota-provider.ts
|
|
498
551
|
function exhaustedWindow(windows) {
|
|
499
552
|
for (const window of windows) {
|
|
@@ -4884,6 +4937,9 @@ var InMemoryAgentStore = class {
|
|
|
4884
4937
|
__name(this, "InMemoryAgentStore");
|
|
4885
4938
|
}
|
|
4886
4939
|
threads = /* @__PURE__ */ new Map();
|
|
4940
|
+
/** Each thread's waiting messages, in run order. */
|
|
4941
|
+
queues = /* @__PURE__ */ new Map();
|
|
4942
|
+
pauses = /* @__PURE__ */ new Map();
|
|
4887
4943
|
toolCalls = /* @__PURE__ */ new Map();
|
|
4888
4944
|
usage = [];
|
|
4889
4945
|
runs = /* @__PURE__ */ new Map();
|
|
@@ -5140,6 +5196,149 @@ var InMemoryAgentStore = class {
|
|
|
5140
5196
|
}
|
|
5141
5197
|
}
|
|
5142
5198
|
}
|
|
5199
|
+
async claimActiveStream(threadId, runId, options = {}) {
|
|
5200
|
+
const row = this.threads.get(threadId);
|
|
5201
|
+
if (row === void 0) {
|
|
5202
|
+
return false;
|
|
5203
|
+
}
|
|
5204
|
+
const holder = row.activeStreamId;
|
|
5205
|
+
if (holder !== void 0 && holder !== runId && holder !== options.replacing) {
|
|
5206
|
+
return false;
|
|
5207
|
+
}
|
|
5208
|
+
row.activeStreamId = runId;
|
|
5209
|
+
return true;
|
|
5210
|
+
}
|
|
5211
|
+
async releaseActiveStream(threadId, runId) {
|
|
5212
|
+
const row = this.threads.get(threadId);
|
|
5213
|
+
if (row?.activeStreamId !== runId) {
|
|
5214
|
+
return false;
|
|
5215
|
+
}
|
|
5216
|
+
delete row.activeStreamId;
|
|
5217
|
+
return true;
|
|
5218
|
+
}
|
|
5219
|
+
async enqueueMessage(input) {
|
|
5220
|
+
const ts = this.now();
|
|
5221
|
+
const message = {
|
|
5222
|
+
id: crypto.randomUUID(),
|
|
5223
|
+
threadId: input.threadId,
|
|
5224
|
+
actor: input.actor,
|
|
5225
|
+
content: input.content,
|
|
5226
|
+
...input.attachments !== void 0 && input.attachments.length > 0 ? {
|
|
5227
|
+
attachments: input.attachments
|
|
5228
|
+
} : {},
|
|
5229
|
+
...input.agentName !== void 0 ? {
|
|
5230
|
+
agentName: input.agentName
|
|
5231
|
+
} : {},
|
|
5232
|
+
...input.model !== void 0 ? {
|
|
5233
|
+
model: input.model
|
|
5234
|
+
} : {},
|
|
5235
|
+
...input.pageContext !== void 0 ? {
|
|
5236
|
+
pageContext: input.pageContext
|
|
5237
|
+
} : {},
|
|
5238
|
+
...input.interrupt === true ? {
|
|
5239
|
+
interrupt: true
|
|
5240
|
+
} : {},
|
|
5241
|
+
createdAt: ts,
|
|
5242
|
+
updatedAt: ts
|
|
5243
|
+
};
|
|
5244
|
+
const queue = this.queues.get(input.threadId) ?? [];
|
|
5245
|
+
if (input.at === "head") {
|
|
5246
|
+
queue.unshift(message);
|
|
5247
|
+
} else {
|
|
5248
|
+
queue.push(message);
|
|
5249
|
+
}
|
|
5250
|
+
this.queues.set(input.threadId, queue);
|
|
5251
|
+
return {
|
|
5252
|
+
...message
|
|
5253
|
+
};
|
|
5254
|
+
}
|
|
5255
|
+
async listQueue(threadId) {
|
|
5256
|
+
return (this.queues.get(threadId) ?? []).map((message) => ({
|
|
5257
|
+
...message
|
|
5258
|
+
}));
|
|
5259
|
+
}
|
|
5260
|
+
async getQueuedMessage(id) {
|
|
5261
|
+
const found = this.findQueued(id);
|
|
5262
|
+
return found === void 0 ? null : {
|
|
5263
|
+
...found.message
|
|
5264
|
+
};
|
|
5265
|
+
}
|
|
5266
|
+
async updateQueuedMessage(id, patch) {
|
|
5267
|
+
const found = this.findQueued(id);
|
|
5268
|
+
if (found === void 0) {
|
|
5269
|
+
return null;
|
|
5270
|
+
}
|
|
5271
|
+
const { message } = found;
|
|
5272
|
+
if (patch.content !== void 0) {
|
|
5273
|
+
message.content = patch.content;
|
|
5274
|
+
}
|
|
5275
|
+
if (patch.attachments !== void 0) {
|
|
5276
|
+
if (patch.attachments === null || patch.attachments.length === 0) {
|
|
5277
|
+
delete message.attachments;
|
|
5278
|
+
} else {
|
|
5279
|
+
message.attachments = patch.attachments;
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
if (patch.interrupt !== void 0) {
|
|
5283
|
+
if (patch.interrupt) {
|
|
5284
|
+
message.interrupt = true;
|
|
5285
|
+
} else {
|
|
5286
|
+
delete message.interrupt;
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
message.updatedAt = this.now();
|
|
5290
|
+
return {
|
|
5291
|
+
...message
|
|
5292
|
+
};
|
|
5293
|
+
}
|
|
5294
|
+
async moveQueuedMessage(id, index) {
|
|
5295
|
+
const found = this.findQueued(id);
|
|
5296
|
+
if (found === void 0) {
|
|
5297
|
+
return false;
|
|
5298
|
+
}
|
|
5299
|
+
const { queue, position, message } = found;
|
|
5300
|
+
queue.splice(position, 1);
|
|
5301
|
+
const target = Math.max(0, Math.min(queue.length, Math.trunc(index)));
|
|
5302
|
+
queue.splice(target, 0, message);
|
|
5303
|
+
return true;
|
|
5304
|
+
}
|
|
5305
|
+
async removeQueuedMessage(id) {
|
|
5306
|
+
const found = this.findQueued(id);
|
|
5307
|
+
if (found === void 0) {
|
|
5308
|
+
return false;
|
|
5309
|
+
}
|
|
5310
|
+
found.queue.splice(found.position, 1);
|
|
5311
|
+
return true;
|
|
5312
|
+
}
|
|
5313
|
+
async clearQueue(threadId) {
|
|
5314
|
+
const count = this.queues.get(threadId)?.length ?? 0;
|
|
5315
|
+
this.queues.delete(threadId);
|
|
5316
|
+
return count;
|
|
5317
|
+
}
|
|
5318
|
+
async queuePause(threadId) {
|
|
5319
|
+
return this.pauses.get(threadId) ?? null;
|
|
5320
|
+
}
|
|
5321
|
+
async setQueuePause(threadId, pause) {
|
|
5322
|
+
if (pause === null) {
|
|
5323
|
+
this.pauses.delete(threadId);
|
|
5324
|
+
} else {
|
|
5325
|
+
this.pauses.set(threadId, pause);
|
|
5326
|
+
}
|
|
5327
|
+
}
|
|
5328
|
+
findQueued(id) {
|
|
5329
|
+
for (const queue of this.queues.values()) {
|
|
5330
|
+
const position = queue.findIndex((message2) => message2.id === id);
|
|
5331
|
+
const message = queue[position];
|
|
5332
|
+
if (message !== void 0) {
|
|
5333
|
+
return {
|
|
5334
|
+
queue,
|
|
5335
|
+
position,
|
|
5336
|
+
message
|
|
5337
|
+
};
|
|
5338
|
+
}
|
|
5339
|
+
}
|
|
5340
|
+
return void 0;
|
|
5341
|
+
}
|
|
5143
5342
|
async appendMessage(input) {
|
|
5144
5343
|
const row = this.threads.get(input.threadId);
|
|
5145
5344
|
if (row === void 0) {
|
|
@@ -5657,6 +5856,7 @@ var InMemoryAgentStore = class {
|
|
|
5657
5856
|
gateFollowUps,
|
|
5658
5857
|
gateTail,
|
|
5659
5858
|
invokeWithTransientRetry,
|
|
5859
|
+
isChatQueueStore,
|
|
5660
5860
|
isControlFlowSignal,
|
|
5661
5861
|
isReplayIntegrityError,
|
|
5662
5862
|
isToolEnabled,
|
|
@@ -5685,12 +5885,14 @@ var InMemoryAgentStore = class {
|
|
|
5685
5885
|
publishAgentToolCall,
|
|
5686
5886
|
publishAgentToolRetry,
|
|
5687
5887
|
questionOptions,
|
|
5888
|
+
queuedMessageView,
|
|
5688
5889
|
quotaPeriodRange,
|
|
5689
5890
|
quotaUsedRatio,
|
|
5690
5891
|
quotaWarning,
|
|
5691
5892
|
readElicitationInput,
|
|
5692
5893
|
readElicitationQuestions,
|
|
5693
5894
|
releaseGatedFrames,
|
|
5895
|
+
releaseThreadRun,
|
|
5694
5896
|
rememberInputSchema,
|
|
5695
5897
|
rememberToolDefinition,
|
|
5696
5898
|
renderElicitationAnswers,
|