@dudousxd/nestjs-agent 1.22.0 → 1.23.1
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/{chat-queue.service-CTyX_yNr.d.ts → chat-queue.service-CwxJDrBM.d.ts} +44 -4
- package/dist/{chat-queue.service-Dx9OsjcF.d.cts → chat-queue.service-D1z3WjFI.d.cts} +44 -4
- package/dist/durable/index.cjs +64 -19
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +1 -1
- package/dist/durable/index.d.ts +1 -1
- package/dist/durable/index.js +64 -19
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +99 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +99 -27
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DynamicModule, Type, OnApplicationBootstrap, OnModuleInit, ConflictException, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
-
import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-
|
|
3
|
-
export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan,
|
|
2
|
+
import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-D1z3WjFI.cjs';
|
|
3
|
+
export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-D1z3WjFI.cjs';
|
|
4
4
|
import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
|
|
5
|
-
import { AgentStore, Actor, ListActionProposals, ActionProposalMutationView, AgentRunner, AttachmentStagingStore, ModelCatalog, QuotaProvider, QuotaReport, ModelCatalogView, AttachmentRef, PageContext, ChatQueueState, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, ActorResolver, AgentApprovalPort, MessageAttachment, AgentAttachmentConfig, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, AgentRunStartOptions, TokenStreamSink, SinkWriter } from '@dudousxd/nestjs-agent-core';
|
|
5
|
+
import { AgentStore, Actor, ListActionProposals, ActionProposalMutationView, AgentRunner, AttachmentStagingStore, ModelCatalog, QuotaProvider, QuotaReport, ModelCatalogView, AgentHostContext, AttachmentRef, PageContext, ChatQueueState, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, ActorResolver, AgentApprovalPort, MessageAttachment, AgentAttachmentConfig, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, AgentRunStartOptions, TokenStreamSink, SinkWriter } from '@dudousxd/nestjs-agent-core';
|
|
6
6
|
export * from '@dudousxd/nestjs-agent-core';
|
|
7
7
|
export { FunctionalToolDefinition } from '@dudousxd/nestjs-agent-core';
|
|
8
8
|
import { Request, Response } from 'express';
|
|
@@ -96,6 +96,14 @@ interface ChatParams {
|
|
|
96
96
|
uiCapabilities?: UiCapabilities;
|
|
97
97
|
actor: Actor;
|
|
98
98
|
message: string;
|
|
99
|
+
/** The host's own facts about this send — see `AgentRunInput.hostContext`. */
|
|
100
|
+
hostContext?: AgentHostContext;
|
|
101
|
+
/**
|
|
102
|
+
* The HOST already decided this actor may write this thread — a chat-app thread several people
|
|
103
|
+
* share, where anyone in it may continue the conversation. Skips the thread-ownership check of a
|
|
104
|
+
* send; never set it from a request's own claim.
|
|
105
|
+
*/
|
|
106
|
+
authorized?: boolean;
|
|
99
107
|
threadId?: string;
|
|
100
108
|
agentName?: string;
|
|
101
109
|
/**
|
|
@@ -531,7 +539,10 @@ declare class AgUiRunHandler {
|
|
|
531
539
|
protected readonly quietMs: number | undefined;
|
|
532
540
|
constructor(agent: AgentService, actorResolver: ActorResolver, options: AgentModuleOptions, staging: AttachmentStagingStore | undefined, quietMs: number | undefined);
|
|
533
541
|
handle(req: Request, res: Response, body: unknown): Promise<void>;
|
|
534
|
-
/**
|
|
542
|
+
/**
|
|
543
|
+
* The turn's attachments: the ones already staged (by mediaId), then its inline media staged
|
|
544
|
+
* through the bound store — all within the store's limits; say what was not used.
|
|
545
|
+
*/
|
|
535
546
|
private stage;
|
|
536
547
|
/**
|
|
537
548
|
* Deliver what a resume list decided, through the same calls the native decision routes make.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DynamicModule, Type, OnApplicationBootstrap, OnModuleInit, ConflictException, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
-
import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-
|
|
3
|
-
export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan,
|
|
2
|
+
import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, C as ChatQueueService, d as AgentProtocolAdapter, e as AgentSkillsOptions } from './chat-queue.service-CwxJDrBM.js';
|
|
3
|
+
export { f as AGENT_TOOL_BRAND, g as AgentAttachmentsOptions, h as AgentDeps, i as AgentEngine, j as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QueuePlan, k as QueueSettleOutcome, l as QueuedTurn, m as QueuedTurnStarter, n as QuotaLimits, o as QuotaWindowLimits, p as defineTool, q as delegateToolName, r as provideAgentTool, s as provideAgentTools, u as utcDay } from './chat-queue.service-CwxJDrBM.js';
|
|
4
4
|
import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
|
|
5
|
-
import { AgentStore, Actor, ListActionProposals, ActionProposalMutationView, AgentRunner, AttachmentStagingStore, ModelCatalog, QuotaProvider, QuotaReport, ModelCatalogView, AttachmentRef, PageContext, ChatQueueState, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, ActorResolver, AgentApprovalPort, MessageAttachment, AgentAttachmentConfig, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, AgentRunStartOptions, TokenStreamSink, SinkWriter } from '@dudousxd/nestjs-agent-core';
|
|
5
|
+
import { AgentStore, Actor, ListActionProposals, ActionProposalMutationView, AgentRunner, AttachmentStagingStore, ModelCatalog, QuotaProvider, QuotaReport, ModelCatalogView, AgentHostContext, AttachmentRef, PageContext, ChatQueueState, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, ActorResolver, AgentApprovalPort, MessageAttachment, AgentAttachmentConfig, AgentClientConfig, ToolSpec, ToolPresentation, AgentHistoryWindow, AgentIntake, Persona, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, AgentRunStartOptions, TokenStreamSink, SinkWriter } from '@dudousxd/nestjs-agent-core';
|
|
6
6
|
export * from '@dudousxd/nestjs-agent-core';
|
|
7
7
|
export { FunctionalToolDefinition } from '@dudousxd/nestjs-agent-core';
|
|
8
8
|
import { Request, Response } from 'express';
|
|
@@ -96,6 +96,14 @@ interface ChatParams {
|
|
|
96
96
|
uiCapabilities?: UiCapabilities;
|
|
97
97
|
actor: Actor;
|
|
98
98
|
message: string;
|
|
99
|
+
/** The host's own facts about this send — see `AgentRunInput.hostContext`. */
|
|
100
|
+
hostContext?: AgentHostContext;
|
|
101
|
+
/**
|
|
102
|
+
* The HOST already decided this actor may write this thread — a chat-app thread several people
|
|
103
|
+
* share, where anyone in it may continue the conversation. Skips the thread-ownership check of a
|
|
104
|
+
* send; never set it from a request's own claim.
|
|
105
|
+
*/
|
|
106
|
+
authorized?: boolean;
|
|
99
107
|
threadId?: string;
|
|
100
108
|
agentName?: string;
|
|
101
109
|
/**
|
|
@@ -531,7 +539,10 @@ declare class AgUiRunHandler {
|
|
|
531
539
|
protected readonly quietMs: number | undefined;
|
|
532
540
|
constructor(agent: AgentService, actorResolver: ActorResolver, options: AgentModuleOptions, staging: AttachmentStagingStore | undefined, quietMs: number | undefined);
|
|
533
541
|
handle(req: Request, res: Response, body: unknown): Promise<void>;
|
|
534
|
-
/**
|
|
542
|
+
/**
|
|
543
|
+
* The turn's attachments: the ones already staged (by mediaId), then its inline media staged
|
|
544
|
+
* through the bound store — all within the store's limits; say what was not used.
|
|
545
|
+
*/
|
|
535
546
|
private stage;
|
|
536
547
|
/**
|
|
537
548
|
* Deliver what a resume list decided, through the same calls the native decision routes make.
|
package/dist/index.js
CHANGED
|
@@ -1092,6 +1092,9 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
1092
1092
|
} : {},
|
|
1093
1093
|
...input.uiCapabilities !== void 0 ? {
|
|
1094
1094
|
uiCapabilities: input.uiCapabilities
|
|
1095
|
+
} : {},
|
|
1096
|
+
...input.hostContext !== void 0 ? {
|
|
1097
|
+
hostContext: input.hostContext
|
|
1095
1098
|
} : {}
|
|
1096
1099
|
});
|
|
1097
1100
|
await store.setQueuePause(threadId, {
|
|
@@ -1177,6 +1180,9 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
1177
1180
|
...message.uiCapabilities !== void 0 ? {
|
|
1178
1181
|
uiCapabilities: message.uiCapabilities
|
|
1179
1182
|
} : {},
|
|
1183
|
+
...message.hostContext !== void 0 ? {
|
|
1184
|
+
hostContext: message.hostContext
|
|
1185
|
+
} : {},
|
|
1180
1186
|
...message.model !== void 0 ? {
|
|
1181
1187
|
model: message.model
|
|
1182
1188
|
} : {}
|
|
@@ -1547,6 +1553,9 @@ var AgentService = class {
|
|
|
1547
1553
|
}
|
|
1548
1554
|
const created = await this.store.createThread({
|
|
1549
1555
|
actor: params.actor,
|
|
1556
|
+
...agentName !== void 0 ? {
|
|
1557
|
+
agentName
|
|
1558
|
+
} : {},
|
|
1550
1559
|
...params.transient === true ? {
|
|
1551
1560
|
transient: true
|
|
1552
1561
|
} : {},
|
|
@@ -1559,7 +1568,7 @@ var AgentService = class {
|
|
|
1559
1568
|
});
|
|
1560
1569
|
threadId = created.id;
|
|
1561
1570
|
} else {
|
|
1562
|
-
await this.assertOwnsThread(params.actor, threadId);
|
|
1571
|
+
if (params.authorized !== true) await this.assertOwnsThread(params.actor, threadId);
|
|
1563
1572
|
if (params.personaId !== void 0) {
|
|
1564
1573
|
await this.pinThreadPersona(threadId, params.personaId);
|
|
1565
1574
|
}
|
|
@@ -1585,6 +1594,9 @@ var AgentService = class {
|
|
|
1585
1594
|
...params.uiCapabilities !== void 0 ? {
|
|
1586
1595
|
uiCapabilities: params.uiCapabilities
|
|
1587
1596
|
} : {},
|
|
1597
|
+
...params.hostContext !== void 0 ? {
|
|
1598
|
+
hostContext: params.hostContext
|
|
1599
|
+
} : {},
|
|
1588
1600
|
...model !== void 0 ? {
|
|
1589
1601
|
model
|
|
1590
1602
|
} : {}
|
|
@@ -1607,7 +1619,7 @@ var AgentService = class {
|
|
|
1607
1619
|
});
|
|
1608
1620
|
}
|
|
1609
1621
|
if (live === null && mode !== "queue") {
|
|
1610
|
-
const runId = crypto.randomUUID();
|
|
1622
|
+
const runId = this.runner.runIdFor?.(input) ?? crypto.randomUUID();
|
|
1611
1623
|
if (await queue.queueStore().claimActiveStream(threadId, runId, stale !== null ? {
|
|
1612
1624
|
replacing: stale
|
|
1613
1625
|
} : {})) {
|
|
@@ -1675,6 +1687,9 @@ var AgentService = class {
|
|
|
1675
1687
|
...input.uiCapabilities !== void 0 ? {
|
|
1676
1688
|
uiCapabilities: input.uiCapabilities
|
|
1677
1689
|
} : {},
|
|
1690
|
+
...input.hostContext !== void 0 ? {
|
|
1691
|
+
hostContext: input.hostContext
|
|
1692
|
+
} : {},
|
|
1678
1693
|
...interrupting !== void 0 ? {
|
|
1679
1694
|
interrupt: true,
|
|
1680
1695
|
at: "head"
|
|
@@ -5886,11 +5901,11 @@ function isQuotaProvider(quota) {
|
|
|
5886
5901
|
__name(isQuotaProvider, "isQuotaProvider");
|
|
5887
5902
|
function resolveCatalog(options) {
|
|
5888
5903
|
if (options.models !== void 0) return options.models;
|
|
5889
|
-
const carried = options.model
|
|
5904
|
+
const carried = options.model?.catalog;
|
|
5890
5905
|
return carried !== void 0 && typeof carried.list === "function" ? carried : void 0;
|
|
5891
5906
|
}
|
|
5892
5907
|
__name(resolveCatalog, "resolveCatalog");
|
|
5893
|
-
function sharedProviders(durable) {
|
|
5908
|
+
function sharedProviders(durable, engine) {
|
|
5894
5909
|
const providers = [
|
|
5895
5910
|
{
|
|
5896
5911
|
provide: AGENT_TOOL_REGISTRY3,
|
|
@@ -6021,7 +6036,12 @@ function sharedProviders(durable) {
|
|
|
6021
6036
|
ModulesContainer
|
|
6022
6037
|
]
|
|
6023
6038
|
});
|
|
6024
|
-
if (
|
|
6039
|
+
if (engine !== void 0) {
|
|
6040
|
+
providers.push(...engine.providers, {
|
|
6041
|
+
provide: AGENT_RUNNER2,
|
|
6042
|
+
useExisting: engine.runner
|
|
6043
|
+
});
|
|
6044
|
+
} else if (durable) {
|
|
6025
6045
|
providers.push({
|
|
6026
6046
|
provide: AGENT_RUNNER2,
|
|
6027
6047
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
@@ -6046,8 +6066,9 @@ function sharedProviders(durable) {
|
|
|
6046
6066
|
return providers;
|
|
6047
6067
|
}
|
|
6048
6068
|
__name(sharedProviders, "sharedProviders");
|
|
6049
|
-
function exportsFor() {
|
|
6069
|
+
function exportsFor(engine) {
|
|
6050
6070
|
return [
|
|
6071
|
+
...engine?.exports ?? [],
|
|
6051
6072
|
AGENT_OPTIONS9,
|
|
6052
6073
|
AGENT_TOOL_REGISTRY3,
|
|
6053
6074
|
AGENT_REGISTRY6,
|
|
@@ -6097,10 +6118,11 @@ function adapterProviders(adapters) {
|
|
|
6097
6118
|
return (adapters ?? []).flatMap((adapter) => adapter.providers ?? []);
|
|
6098
6119
|
}
|
|
6099
6120
|
__name(adapterProviders, "adapterProviders");
|
|
6100
|
-
function controllersForSurface(surface, adapters) {
|
|
6121
|
+
function controllersForSurface(surface, adapters, engine) {
|
|
6101
6122
|
return surface === "engine" ? [] : [
|
|
6102
6123
|
...BASE_CONTROLLERS,
|
|
6103
|
-
...adapterControllers(adapters)
|
|
6124
|
+
...adapterControllers(adapters),
|
|
6125
|
+
...engine?.controllers ?? []
|
|
6104
6126
|
];
|
|
6105
6127
|
}
|
|
6106
6128
|
__name(controllersForSurface, "controllersForSurface");
|
|
@@ -6130,12 +6152,22 @@ function routerFor(path) {
|
|
|
6130
6152
|
]);
|
|
6131
6153
|
}
|
|
6132
6154
|
__name(routerFor, "routerFor");
|
|
6155
|
+
function assertRunnable(options) {
|
|
6156
|
+
if (options.engine !== void 0 && options.durable === true) {
|
|
6157
|
+
throw new Error(`AgentModule: \`durable: true\` runs turns on the library's loop, but the \`${options.engine.name}\` engine runs them instead. Drop \`durable\` (the engine decides how its turns survive a restart).`);
|
|
6158
|
+
}
|
|
6159
|
+
if (options.engine === void 0 && options.model === void 0) {
|
|
6160
|
+
throw new Error("AgentModule: set `model` (the loop runs the turns) or `engine` (something else does).");
|
|
6161
|
+
}
|
|
6162
|
+
}
|
|
6163
|
+
__name(assertRunnable, "assertRunnable");
|
|
6133
6164
|
var AgentModule = class _AgentModule {
|
|
6134
6165
|
static {
|
|
6135
6166
|
__name(this, "AgentModule");
|
|
6136
6167
|
}
|
|
6137
6168
|
static forRoot(options) {
|
|
6138
6169
|
const path = options.path ?? DEFAULT_PATH;
|
|
6170
|
+
assertRunnable(options);
|
|
6139
6171
|
applyGuards(options.guards, options.adapters);
|
|
6140
6172
|
return {
|
|
6141
6173
|
module: _AgentModule,
|
|
@@ -6144,21 +6176,27 @@ var AgentModule = class _AgentModule {
|
|
|
6144
6176
|
DiscoveryModule,
|
|
6145
6177
|
routerFor(path)
|
|
6146
6178
|
],
|
|
6147
|
-
controllers: controllersForSurface(options.surface, options.adapters),
|
|
6179
|
+
controllers: controllersForSurface(options.surface, options.adapters, options.engine),
|
|
6148
6180
|
providers: [
|
|
6149
6181
|
{
|
|
6150
6182
|
provide: AGENT_OPTIONS9,
|
|
6151
6183
|
useValue: options
|
|
6152
6184
|
},
|
|
6153
|
-
...sharedProviders(options.durable ?? false),
|
|
6185
|
+
...sharedProviders(options.durable ?? false, options.engine),
|
|
6154
6186
|
...guardProviders(options.guards),
|
|
6155
6187
|
...adapterProviders(options.adapters)
|
|
6156
6188
|
],
|
|
6157
|
-
exports: exportsFor()
|
|
6189
|
+
exports: exportsFor(options.engine)
|
|
6158
6190
|
};
|
|
6159
6191
|
}
|
|
6160
6192
|
static forRootAsync(options) {
|
|
6161
6193
|
const path = options.path ?? DEFAULT_PATH;
|
|
6194
|
+
if (options.engine !== void 0) {
|
|
6195
|
+
assertRunnable({
|
|
6196
|
+
engine: options.engine,
|
|
6197
|
+
durable: options.durable ?? false
|
|
6198
|
+
});
|
|
6199
|
+
}
|
|
6162
6200
|
applyGuards(options.guards, options.adapters);
|
|
6163
6201
|
return {
|
|
6164
6202
|
module: _AgentModule,
|
|
@@ -6168,7 +6206,7 @@ var AgentModule = class _AgentModule {
|
|
|
6168
6206
|
routerFor(path),
|
|
6169
6207
|
...options.imports ?? []
|
|
6170
6208
|
],
|
|
6171
|
-
controllers: controllersForSurface(options.surface, options.adapters),
|
|
6209
|
+
controllers: controllersForSurface(options.surface, options.adapters, options.engine),
|
|
6172
6210
|
providers: [
|
|
6173
6211
|
{
|
|
6174
6212
|
provide: AGENT_OPTIONS9,
|
|
@@ -6178,18 +6216,25 @@ var AgentModule = class _AgentModule {
|
|
|
6178
6216
|
// anything today (AgentDurableModule takes its own mirror option — see its doc for why),
|
|
6179
6217
|
// but it's stamped here too so the EFFECTIVE value is always observable off
|
|
6180
6218
|
// AGENT_OPTIONS, sync or async alike.
|
|
6181
|
-
useFactory: /* @__PURE__ */ __name(async (...args) =>
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6219
|
+
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
6220
|
+
const resolved = {
|
|
6221
|
+
...await options.useFactory(...args),
|
|
6222
|
+
durable: options.durable ?? false,
|
|
6223
|
+
surface: options.surface ?? "both",
|
|
6224
|
+
...options.engine !== void 0 ? {
|
|
6225
|
+
engine: options.engine
|
|
6226
|
+
} : {}
|
|
6227
|
+
};
|
|
6228
|
+
assertRunnable(resolved);
|
|
6229
|
+
return resolved;
|
|
6230
|
+
}, "useFactory"),
|
|
6186
6231
|
inject: options.inject ?? []
|
|
6187
6232
|
},
|
|
6188
|
-
...sharedProviders(options.durable ?? false),
|
|
6233
|
+
...sharedProviders(options.durable ?? false, options.engine),
|
|
6189
6234
|
...guardProviders(options.guards),
|
|
6190
6235
|
...adapterProviders(options.adapters)
|
|
6191
6236
|
],
|
|
6192
|
-
exports: exportsFor()
|
|
6237
|
+
exports: exportsFor(options.engine)
|
|
6193
6238
|
};
|
|
6194
6239
|
}
|
|
6195
6240
|
};
|
|
@@ -6324,7 +6369,10 @@ var AgUiRunHandler = class {
|
|
|
6324
6369
|
if (owner !== null && owner !== actor.id) {
|
|
6325
6370
|
throw new ForbiddenException4("thread belongs to another actor");
|
|
6326
6371
|
}
|
|
6327
|
-
if (
|
|
6372
|
+
if (forwarded.regenerate === true && owner === null) {
|
|
6373
|
+
throw invalid("invalid_input", "regenerate needs a thread that already has an exchange");
|
|
6374
|
+
}
|
|
6375
|
+
if (owner !== null && forwarded.regenerate !== true && turn.media.length === 0 && turn.staged.length === 0) {
|
|
6328
6376
|
const decision = await this.agent.handleTextDecision(input.threadId, actor, turn.text);
|
|
6329
6377
|
if ("proposalDecision" in decision) {
|
|
6330
6378
|
this.writeEvents(res, [
|
|
@@ -6339,7 +6387,7 @@ var AgUiRunHandler = class {
|
|
|
6339
6387
|
return;
|
|
6340
6388
|
}
|
|
6341
6389
|
}
|
|
6342
|
-
const refs = await this.stage(actor, turn.media, warnings);
|
|
6390
|
+
const refs = await this.stage(actor, turn.media, warnings, turn.staged);
|
|
6343
6391
|
if (turn.text.trim().length === 0 && refs.length === 0) {
|
|
6344
6392
|
throw invalid("no_user_message", "the user message to answer is empty");
|
|
6345
6393
|
}
|
|
@@ -6375,6 +6423,9 @@ var AgUiRunHandler = class {
|
|
|
6375
6423
|
} : {},
|
|
6376
6424
|
...refs.length > 0 ? {
|
|
6377
6425
|
attachments: refs
|
|
6426
|
+
} : {},
|
|
6427
|
+
...forwarded.regenerate === true ? {
|
|
6428
|
+
regenerate: true
|
|
6378
6429
|
} : {}
|
|
6379
6430
|
});
|
|
6380
6431
|
await this.pipe(res, started.runId, {
|
|
@@ -6386,10 +6437,25 @@ var AgUiRunHandler = class {
|
|
|
6386
6437
|
preamble: warningEvents(warnings)
|
|
6387
6438
|
});
|
|
6388
6439
|
}
|
|
6389
|
-
/**
|
|
6390
|
-
|
|
6440
|
+
/**
|
|
6441
|
+
* The turn's attachments: the ones already staged (by mediaId), then its inline media staged
|
|
6442
|
+
* through the bound store — all within the store's limits; say what was not used.
|
|
6443
|
+
*/
|
|
6444
|
+
async stage(actor, media, warnings, staged = []) {
|
|
6391
6445
|
const refs = [];
|
|
6392
6446
|
const limits = attachmentLimits(this.options, this.staging);
|
|
6447
|
+
for (const ref of staged) {
|
|
6448
|
+
const label = `The attachment ${ref.mediaId} was not used`;
|
|
6449
|
+
if (this.staging === void 0) {
|
|
6450
|
+
warnings.push(`${label}: attachments are not enabled on this agent.`);
|
|
6451
|
+
} else if (refs.length >= limits.maxPerMessage) {
|
|
6452
|
+
warnings.push(`${label}: a message carries at most ${limits.maxPerMessage} attachments.`);
|
|
6453
|
+
} else {
|
|
6454
|
+
refs.push({
|
|
6455
|
+
mediaId: ref.mediaId
|
|
6456
|
+
});
|
|
6457
|
+
}
|
|
6458
|
+
}
|
|
6393
6459
|
for (const item of media) {
|
|
6394
6460
|
const label = `The ${item.kind} "${item.filename}" was not used`;
|
|
6395
6461
|
if (this.staging === void 0) {
|
|
@@ -6402,7 +6468,7 @@ var AgUiRunHandler = class {
|
|
|
6402
6468
|
warnings.push(`${label}: it is larger than ${limits.maxBytes} bytes.`);
|
|
6403
6469
|
} else {
|
|
6404
6470
|
try {
|
|
6405
|
-
const
|
|
6471
|
+
const staged2 = await this.staging.stage({
|
|
6406
6472
|
data: item.data,
|
|
6407
6473
|
filename: item.filename,
|
|
6408
6474
|
contentType: item.contentType,
|
|
@@ -6410,7 +6476,7 @@ var AgUiRunHandler = class {
|
|
|
6410
6476
|
actor
|
|
6411
6477
|
});
|
|
6412
6478
|
refs.push({
|
|
6413
|
-
mediaId:
|
|
6479
|
+
mediaId: staged2.mediaId
|
|
6414
6480
|
});
|
|
6415
6481
|
} catch {
|
|
6416
6482
|
warnings.push(`${label}: it could not be stored.`);
|
|
@@ -6528,11 +6594,17 @@ var AgUiRunHandler = class {
|
|
|
6528
6594
|
res.setHeader("X-Agent-Run-Id", runId);
|
|
6529
6595
|
res.flushHeaders();
|
|
6530
6596
|
let terminal = false;
|
|
6597
|
+
const cursor = {
|
|
6598
|
+
seq: 0
|
|
6599
|
+
};
|
|
6531
6600
|
try {
|
|
6532
6601
|
const frames = agUiFramesFromNdjson(this.agent.subscribe(runId));
|
|
6533
|
-
for await (const event of agUiEvents(frames,
|
|
6602
|
+
for await (const event of agUiEvents(frames, {
|
|
6603
|
+
...options,
|
|
6604
|
+
cursor
|
|
6605
|
+
})) {
|
|
6534
6606
|
if (event.type === "RUN_FINISHED" || event.type === "RUN_ERROR") terminal = true;
|
|
6535
|
-
res.write(agUiSse(event));
|
|
6607
|
+
res.write(agUiSse(event, cursor.seq));
|
|
6536
6608
|
}
|
|
6537
6609
|
} catch {
|
|
6538
6610
|
if (!terminal) {
|