@dudousxd/nestjs-agent 1.17.1 → 1.18.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/{chat-queue.service-Bqq00NN1.d.cts → chat-queue.service-5LIogd9K.d.cts} +27 -1
- package/dist/{chat-queue.service-Bqq00NN1.d.ts → chat-queue.service-5LIogd9K.d.ts} +27 -1
- package/dist/durable/index.cjs +61 -11
- 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 +61 -11
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +390 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -5
- package/dist/index.d.ts +78 -5
- package/dist/index.js +383 -11
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/durable/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgentStore, AgentRunInput, AgentLoopResult, LlmStepEnvelope, BufferedModelTurnResult, ToolStepEnvelope, AgentRunner, TokenStreamSink, AgentRunStartOptions, HumanReply } from '@dudousxd/nestjs-agent-core';
|
|
2
2
|
import { RunGateway, WorkflowCtx } from '@dudousxd/nestjs-durable-core';
|
|
3
|
-
import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-
|
|
3
|
+
import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-5LIogd9K.cjs';
|
|
4
4
|
import { WorkflowService } from '@dudousxd/nestjs-durable';
|
|
5
5
|
import { DynamicModule } from '@nestjs/common';
|
|
6
6
|
import '@standard-schema/spec';
|
package/dist/durable/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgentStore, AgentRunInput, AgentLoopResult, LlmStepEnvelope, BufferedModelTurnResult, ToolStepEnvelope, AgentRunner, TokenStreamSink, AgentRunStartOptions, HumanReply } from '@dudousxd/nestjs-agent-core';
|
|
2
2
|
import { RunGateway, WorkflowCtx } from '@dudousxd/nestjs-durable-core';
|
|
3
|
-
import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-
|
|
3
|
+
import { A as AgentDepsFactory, C as ChatQueueService, a as AgentSurface, b as AgentModuleOptions } from '../chat-queue.service-5LIogd9K.js';
|
|
4
4
|
import { WorkflowService } from '@dudousxd/nestjs-durable';
|
|
5
5
|
import { DynamicModule } from '@nestjs/common';
|
|
6
6
|
import '@standard-schema/spec';
|
package/dist/durable/index.js
CHANGED
|
@@ -1883,6 +1883,9 @@ var AgentService = class {
|
|
|
1883
1883
|
actor: params.actor,
|
|
1884
1884
|
...params.transient === true ? {
|
|
1885
1885
|
transient: true
|
|
1886
|
+
} : {},
|
|
1887
|
+
...params.newThreadId !== void 0 ? {
|
|
1888
|
+
id: params.newThreadId
|
|
1886
1889
|
} : {}
|
|
1887
1890
|
});
|
|
1888
1891
|
threadId = created.id;
|
|
@@ -2307,6 +2310,38 @@ var AgentService = class {
|
|
|
2307
2310
|
});
|
|
2308
2311
|
throw new RunNotActiveException(runId);
|
|
2309
2312
|
}
|
|
2313
|
+
/** Who owns the thread, or `null` when there is no such (live) thread. */
|
|
2314
|
+
async threadOwner(threadId) {
|
|
2315
|
+
return this.store.ownerOfThread(threadId);
|
|
2316
|
+
}
|
|
2317
|
+
/**
|
|
2318
|
+
* May `actor` continue the run whose stream is `runId` — the AG-UI resume? Only the actor whose
|
|
2319
|
+
* thread is streaming it (`403` otherwise), and only while it still is: a run that is over is
|
|
2320
|
+
* waiting on no one (`409 run_not_active`), whatever an old interrupt id says.
|
|
2321
|
+
*/
|
|
2322
|
+
async assertResumable(actor, runId) {
|
|
2323
|
+
const owner = await this.store.ownerOfActiveStream(runId);
|
|
2324
|
+
if (owner === null) {
|
|
2325
|
+
throw new RunNotActiveException(runId);
|
|
2326
|
+
}
|
|
2327
|
+
if (owner !== actor.id) {
|
|
2328
|
+
throw new ForbiddenException("run belongs to another actor");
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
/**
|
|
2332
|
+
* Everything {@link approve} / {@link reject} check before they signal — who may decide, and
|
|
2333
|
+
* that the request has not lapsed — without signalling. For a caller that settles several
|
|
2334
|
+
* decisions at once and must refuse all of them if one is refused (an AG-UI resume).
|
|
2335
|
+
*/
|
|
2336
|
+
async checkDecision(actor, toolCallId2) {
|
|
2337
|
+
await this.assertMayDecide(actor, toolCallId2);
|
|
2338
|
+
await this.assertNotExpired(toolCallId2);
|
|
2339
|
+
}
|
|
2340
|
+
/** Everything {@link answer} checks before it signals, without signalling — see {@link checkDecision}. */
|
|
2341
|
+
async checkAnswer(actor, toolCallId2, answers2) {
|
|
2342
|
+
await this.assertOwnsToolCall(actor, toolCallId2);
|
|
2343
|
+
await this.assertAnswersFit(toolCallId2, answers2);
|
|
2344
|
+
}
|
|
2310
2345
|
async cancel(actor, runId) {
|
|
2311
2346
|
await this.assertOwnsActiveStream(actor, runId);
|
|
2312
2347
|
return this.runner.cancel(runId);
|
|
@@ -5849,15 +5884,28 @@ var BASE_CONTROLLERS = [
|
|
|
5849
5884
|
ConfigController,
|
|
5850
5885
|
AttachmentsController
|
|
5851
5886
|
];
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5887
|
+
function adapterControllers(adapters) {
|
|
5888
|
+
return (adapters ?? []).flatMap((adapter) => adapter.controllers);
|
|
5889
|
+
}
|
|
5890
|
+
__name(adapterControllers, "adapterControllers");
|
|
5891
|
+
function adapterProviders(adapters) {
|
|
5892
|
+
return (adapters ?? []).flatMap((adapter) => adapter.providers ?? []);
|
|
5893
|
+
}
|
|
5894
|
+
__name(adapterProviders, "adapterProviders");
|
|
5895
|
+
function controllersForSurface(surface, adapters) {
|
|
5896
|
+
return surface === "engine" ? [] : [
|
|
5897
|
+
...BASE_CONTROLLERS,
|
|
5898
|
+
...adapterControllers(adapters)
|
|
5899
|
+
];
|
|
5855
5900
|
}
|
|
5856
5901
|
__name(controllersForSurface, "controllersForSurface");
|
|
5857
5902
|
var GUARDS_METADATA = "__guards__";
|
|
5858
|
-
function applyGuards(guards) {
|
|
5903
|
+
function applyGuards(guards, adapters) {
|
|
5859
5904
|
const resolved = guards ?? [];
|
|
5860
|
-
for (const controller of
|
|
5905
|
+
for (const controller of [
|
|
5906
|
+
...BASE_CONTROLLERS,
|
|
5907
|
+
...adapterControllers(adapters)
|
|
5908
|
+
]) {
|
|
5861
5909
|
Reflect.defineMetadata(GUARDS_METADATA, resolved, controller);
|
|
5862
5910
|
}
|
|
5863
5911
|
}
|
|
@@ -5883,7 +5931,7 @@ var AgentModule = class _AgentModule {
|
|
|
5883
5931
|
}
|
|
5884
5932
|
static forRoot(options) {
|
|
5885
5933
|
const path = options.path ?? DEFAULT_PATH;
|
|
5886
|
-
applyGuards(options.guards);
|
|
5934
|
+
applyGuards(options.guards, options.adapters);
|
|
5887
5935
|
return {
|
|
5888
5936
|
module: _AgentModule,
|
|
5889
5937
|
global: true,
|
|
@@ -5891,21 +5939,22 @@ var AgentModule = class _AgentModule {
|
|
|
5891
5939
|
DiscoveryModule,
|
|
5892
5940
|
routerFor(path)
|
|
5893
5941
|
],
|
|
5894
|
-
controllers: controllersForSurface(options.surface),
|
|
5942
|
+
controllers: controllersForSurface(options.surface, options.adapters),
|
|
5895
5943
|
providers: [
|
|
5896
5944
|
{
|
|
5897
5945
|
provide: AGENT_OPTIONS7,
|
|
5898
5946
|
useValue: options
|
|
5899
5947
|
},
|
|
5900
5948
|
...sharedProviders(options.durable ?? false),
|
|
5901
|
-
...guardProviders(options.guards)
|
|
5949
|
+
...guardProviders(options.guards),
|
|
5950
|
+
...adapterProviders(options.adapters)
|
|
5902
5951
|
],
|
|
5903
5952
|
exports: exportsFor()
|
|
5904
5953
|
};
|
|
5905
5954
|
}
|
|
5906
5955
|
static forRootAsync(options) {
|
|
5907
5956
|
const path = options.path ?? DEFAULT_PATH;
|
|
5908
|
-
applyGuards(options.guards);
|
|
5957
|
+
applyGuards(options.guards, options.adapters);
|
|
5909
5958
|
return {
|
|
5910
5959
|
module: _AgentModule,
|
|
5911
5960
|
global: true,
|
|
@@ -5914,7 +5963,7 @@ var AgentModule = class _AgentModule {
|
|
|
5914
5963
|
routerFor(path),
|
|
5915
5964
|
...options.imports ?? []
|
|
5916
5965
|
],
|
|
5917
|
-
controllers: controllersForSurface(options.surface),
|
|
5966
|
+
controllers: controllersForSurface(options.surface, options.adapters),
|
|
5918
5967
|
providers: [
|
|
5919
5968
|
{
|
|
5920
5969
|
provide: AGENT_OPTIONS7,
|
|
@@ -5932,7 +5981,8 @@ var AgentModule = class _AgentModule {
|
|
|
5932
5981
|
inject: options.inject ?? []
|
|
5933
5982
|
},
|
|
5934
5983
|
...sharedProviders(options.durable ?? false),
|
|
5935
|
-
...guardProviders(options.guards)
|
|
5984
|
+
...guardProviders(options.guards),
|
|
5985
|
+
...adapterProviders(options.adapters)
|
|
5936
5986
|
],
|
|
5937
5987
|
exports: exportsFor()
|
|
5938
5988
|
};
|