@dudousxd/nestjs-agent 1.16.1 → 1.17.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/README.md +15 -0
- package/dist/durable/index.cjs +460 -400
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +1 -0
- package/dist/durable/index.d.ts +1 -0
- package/dist/durable/index.js +107 -47
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +442 -392
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +64 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/durable/index.d.cts
CHANGED
|
@@ -23,6 +23,7 @@ declare class AgentRunWorkflow {
|
|
|
23
23
|
private readonly store;
|
|
24
24
|
private readonly runs?;
|
|
25
25
|
private readonly queue?;
|
|
26
|
+
private readonly logger;
|
|
26
27
|
constructor(factory: AgentDepsFactory, store: AgentStore, runs?: RunGateway | undefined, queue?: ChatQueueService | undefined);
|
|
27
28
|
/**
|
|
28
29
|
* Move the thread past this settling turn — to the next queued message, started here as a
|
package/dist/durable/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare class AgentRunWorkflow {
|
|
|
23
23
|
private readonly store;
|
|
24
24
|
private readonly runs?;
|
|
25
25
|
private readonly queue?;
|
|
26
|
+
private readonly logger;
|
|
26
27
|
constructor(factory: AgentDepsFactory, store: AgentStore, runs?: RunGateway | undefined, queue?: ChatQueueService | undefined);
|
|
27
28
|
/**
|
|
28
29
|
* Move the thread past this settling turn — to the next queued message, started here as a
|
package/dist/durable/index.js
CHANGED
|
@@ -2,10 +2,10 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/durable/agent-run.workflow.ts
|
|
5
|
-
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_STORE as AGENT_STORE2, RunCancelledError, agentFailureCode, encodeStreamEvent as encodeStreamEvent3, isReplayIntegrityError, publishAgentRunFailed, releaseThreadRun, runAgentLoop, settleAll, settleUnsettledDelegation } from "@dudousxd/nestjs-agent-core";
|
|
5
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_STORE as AGENT_STORE2, RUN_ENDED_BEFORE_TOOL_CALL, RunCancelledError, agentFailureCode, encodeStreamEvent as encodeStreamEvent3, isReplayIntegrityError, publishAgentRunFailed, releaseThreadRun, runAgentLoop, settleAll, settleDeadRun, settleUnsettledDelegation, streamFailure } from "@dudousxd/nestjs-agent-core";
|
|
6
6
|
import { RUN_GATEWAY, Workflow } from "@dudousxd/nestjs-durable";
|
|
7
7
|
import { isWorkflowControlFlowSignal } from "@dudousxd/nestjs-durable-core";
|
|
8
|
-
import { Inject as Inject3, Injectable as Injectable3, Optional as Optional2 } from "@nestjs/common";
|
|
8
|
+
import { Inject as Inject3, Injectable as Injectable3, Logger as Logger2, Optional as Optional2 } from "@nestjs/common";
|
|
9
9
|
|
|
10
10
|
// src/agent-deps.ts
|
|
11
11
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -451,7 +451,7 @@ function queueFrame(items, paused, started) {
|
|
|
451
451
|
__name(queueFrame, "queueFrame");
|
|
452
452
|
|
|
453
453
|
// src/durable/agent-run.steps.ts
|
|
454
|
-
import { AGENT_DEPS_FACTORY, createFrameBuffer, createUiCollector, encodeStreamEvent as encodeStreamEvent2, invokeWithTransientRetry, observeTurnFrames, publishAgentToolRetry, stampToolKinds, traceLlmTurn, traceToolExecution, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput } from "@dudousxd/nestjs-agent-core";
|
|
454
|
+
import { AGENT_DEPS_FACTORY, createFrameBuffer, createUiCollector, encodeStreamEvent as encodeStreamEvent2, invokeWithTransientRetry, observeTurnFrames, publishAgentToolRetry, stampToolKinds, toolCallContext, traceLlmTurn, traceToolExecution, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput } from "@dudousxd/nestjs-agent-core";
|
|
455
455
|
import { Step } from "@dudousxd/nestjs-durable";
|
|
456
456
|
import { Inject as Inject2, Injectable as Injectable2 } from "@nestjs/common";
|
|
457
457
|
|
|
@@ -578,7 +578,7 @@ var AgentRunSteps = class {
|
|
|
578
578
|
await (await opened).write(encodeStreamEvent2(event));
|
|
579
579
|
});
|
|
580
580
|
const ctx = {
|
|
581
|
-
...input.ctx,
|
|
581
|
+
...toolCallContext(input.ctx, input.toolCallId),
|
|
582
582
|
emitUi: ui.emit
|
|
583
583
|
};
|
|
584
584
|
const localClassify = deps.toolTransientRetry !== false ? deps.toolTransientRetry?.classify : void 0;
|
|
@@ -672,6 +672,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
672
672
|
store;
|
|
673
673
|
runs;
|
|
674
674
|
queue;
|
|
675
|
+
logger = new Logger2(_AgentRunWorkflow.name);
|
|
675
676
|
constructor(factory, store, runs, queue) {
|
|
676
677
|
this.factory = factory;
|
|
677
678
|
this.store = store;
|
|
@@ -950,30 +951,42 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
950
951
|
throw error;
|
|
951
952
|
}
|
|
952
953
|
if (isReplayIntegrityError(error)) {
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
};
|
|
954
|
+
const detail = error.message;
|
|
955
|
+
const code2 = agentFailureCode(error);
|
|
956
|
+
this.logger.error(`agent run ${ctx.runId} failed (${code2}): ${detail}`);
|
|
957
957
|
publishAgentRunFailed({
|
|
958
958
|
runId: ctx.runId,
|
|
959
|
-
|
|
959
|
+
code: code2,
|
|
960
|
+
message: detail
|
|
961
|
+
});
|
|
962
|
+
await settleDeadRun(this.store, {
|
|
963
|
+
runId: ctx.runId,
|
|
964
|
+
threadId: input.threadId,
|
|
965
|
+
failure: {
|
|
966
|
+
code: code2,
|
|
967
|
+
message: detail
|
|
968
|
+
}
|
|
960
969
|
});
|
|
961
|
-
await (await hooks.openSink()).fail(
|
|
970
|
+
await (await hooks.openSink()).fail(streamFailure(error));
|
|
962
971
|
throw error;
|
|
963
972
|
}
|
|
964
973
|
const message = error instanceof Error ? error.message : String(error);
|
|
965
974
|
const code = agentFailureCode(error);
|
|
975
|
+
this.logger.error(`agent run ${ctx.runId} failed (${code}): ${message}`);
|
|
966
976
|
publishAgentRunFailed({
|
|
967
977
|
runId: ctx.runId,
|
|
968
978
|
code,
|
|
969
979
|
message
|
|
970
980
|
});
|
|
971
|
-
await stepOf(ctx)("persist:run:fail", () =>
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
981
|
+
await stepOf(ctx)("persist:run:fail", async () => {
|
|
982
|
+
await this.store.recordRunEnd?.({
|
|
983
|
+
runId: ctx.runId,
|
|
984
|
+
status: "failed",
|
|
985
|
+
errorCode: code,
|
|
986
|
+
errorMessage: message
|
|
987
|
+
});
|
|
988
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(ctx.runId, RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
989
|
+
});
|
|
977
990
|
const queueFrame2 = await this.advanceQueue(ctx, input, "failed", message);
|
|
978
991
|
await stepOf(ctx)("deactivate", () => releaseThreadRun(this.store, input.threadId, ctx.runId));
|
|
979
992
|
await this.settleDetachedParent(ctx, input, {
|
|
@@ -984,10 +997,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
|
|
|
984
997
|
if (queueFrame2 !== void 0) {
|
|
985
998
|
await writer.write(encodeStreamEvent3(queueFrame2));
|
|
986
999
|
}
|
|
987
|
-
await writer.fail(
|
|
988
|
-
code,
|
|
989
|
-
message
|
|
990
|
-
});
|
|
1000
|
+
await writer.fail(streamFailure(error));
|
|
991
1001
|
throw error;
|
|
992
1002
|
}
|
|
993
1003
|
}
|
|
@@ -1021,7 +1031,7 @@ import { randomUUID } from "crypto";
|
|
|
1021
1031
|
import { AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE3, encodeStreamEvent as encodeStreamEvent4, releaseThreadRun as releaseThreadRun2 } from "@dudousxd/nestjs-agent-core";
|
|
1022
1032
|
import { RUN_GATEWAY as RUN_GATEWAY2, WorkflowService } from "@dudousxd/nestjs-durable";
|
|
1023
1033
|
import { isWorkflowControlFlowSignal as isWorkflowControlFlowSignal2 } from "@dudousxd/nestjs-durable-core";
|
|
1024
|
-
import { Inject as Inject4, Injectable as Injectable4, Logger as
|
|
1034
|
+
import { Inject as Inject4, Injectable as Injectable4, Logger as Logger3, Optional as Optional3 } from "@nestjs/common";
|
|
1025
1035
|
|
|
1026
1036
|
// src/in-process-sink.ts
|
|
1027
1037
|
import { AgentStreamError } from "@dudousxd/nestjs-agent-core";
|
|
@@ -1138,7 +1148,7 @@ var DurableAgentRunner = class _DurableAgentRunner {
|
|
|
1138
1148
|
store;
|
|
1139
1149
|
sink;
|
|
1140
1150
|
queue;
|
|
1141
|
-
logger = new
|
|
1151
|
+
logger = new Logger3(_DurableAgentRunner.name);
|
|
1142
1152
|
constructor(workflows, runs, store, sink, queue) {
|
|
1143
1153
|
this.workflows = workflows;
|
|
1144
1154
|
this.runs = runs;
|
|
@@ -1364,7 +1374,7 @@ AgentDurableModule = _ts_decorate5([
|
|
|
1364
1374
|
|
|
1365
1375
|
// src/agent.module.ts
|
|
1366
1376
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER13, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS7, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER3, AGENT_REGISTRY as AGENT_REGISTRY6, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK4, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE7, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
1367
|
-
import { Global as Global2, Logger as
|
|
1377
|
+
import { Global as Global2, Logger as Logger8, Module as Module2 } from "@nestjs/common";
|
|
1368
1378
|
import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
|
|
1369
1379
|
|
|
1370
1380
|
// src/agent-deps.factory.ts
|
|
@@ -1626,8 +1636,28 @@ AgentDepsFactory2 = _ts_decorate6([
|
|
|
1626
1636
|
], AgentDepsFactory2);
|
|
1627
1637
|
|
|
1628
1638
|
// src/agent.service.ts
|
|
1629
|
-
import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE5, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval, readElicitationQuestions, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
1630
|
-
import { BadRequestException, ConflictException, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as Inject6, Injectable as Injectable6, NotFoundException, NotImplementedException as NotImplementedException2, Optional as Optional5 } from "@nestjs/common";
|
|
1639
|
+
import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE5, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval, readElicitationQuestions, settleDeadRun as settleDeadRun2, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
1640
|
+
import { BadRequestException, ConflictException as ConflictException2, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as Inject6, Injectable as Injectable6, NotFoundException, NotImplementedException as NotImplementedException2, Optional as Optional5 } from "@nestjs/common";
|
|
1641
|
+
|
|
1642
|
+
// src/run-not-active.exception.ts
|
|
1643
|
+
import { RUN_NOT_ACTIVE_CODE, RUN_NOT_ACTIVE_MESSAGE } from "@dudousxd/nestjs-agent-core";
|
|
1644
|
+
import { ConflictException } from "@nestjs/common";
|
|
1645
|
+
var RunNotActiveException = class extends ConflictException {
|
|
1646
|
+
static {
|
|
1647
|
+
__name(this, "RunNotActiveException");
|
|
1648
|
+
}
|
|
1649
|
+
runId;
|
|
1650
|
+
code = RUN_NOT_ACTIVE_CODE;
|
|
1651
|
+
constructor(runId) {
|
|
1652
|
+
super({
|
|
1653
|
+
statusCode: 409,
|
|
1654
|
+
code: RUN_NOT_ACTIVE_CODE,
|
|
1655
|
+
message: RUN_NOT_ACTIVE_MESSAGE
|
|
1656
|
+
}), this.runId = runId;
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
|
|
1660
|
+
// src/agent.service.ts
|
|
1631
1661
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
1632
1662
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1633
1663
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1824,7 +1854,7 @@ var AgentService = class {
|
|
|
1824
1854
|
};
|
|
1825
1855
|
}
|
|
1826
1856
|
await this.requireQueue().publish(result.threadId);
|
|
1827
|
-
throw new
|
|
1857
|
+
throw new ConflictException2({
|
|
1828
1858
|
statusCode: 409,
|
|
1829
1859
|
code: "run_active",
|
|
1830
1860
|
message: `thread ${result.threadId} already has a turn running`
|
|
@@ -1884,6 +1914,11 @@ var AgentService = class {
|
|
|
1884
1914
|
}
|
|
1885
1915
|
const mode = params.mode ?? "auto";
|
|
1886
1916
|
const { live, stale } = await queue.holder(threadId, this.runner);
|
|
1917
|
+
if (stale !== null) {
|
|
1918
|
+
await settleDeadRun2(this.store, {
|
|
1919
|
+
runId: stale
|
|
1920
|
+
});
|
|
1921
|
+
}
|
|
1887
1922
|
if (live === null && mode !== "queue") {
|
|
1888
1923
|
const runId = crypto.randomUUID();
|
|
1889
1924
|
if (await queue.queueStore().claimActiveStream(threadId, runId, stale !== null ? {
|
|
@@ -1896,7 +1931,7 @@ var AgentService = class {
|
|
|
1896
1931
|
}
|
|
1897
1932
|
}
|
|
1898
1933
|
if (params.regenerate === true) {
|
|
1899
|
-
throw new
|
|
1934
|
+
throw new ConflictException2({
|
|
1900
1935
|
statusCode: 409,
|
|
1901
1936
|
code: "run_active",
|
|
1902
1937
|
message: "cannot regenerate while a turn is running on this thread"
|
|
@@ -2244,8 +2279,29 @@ var AgentService = class {
|
|
|
2244
2279
|
async signalToolCall(toolCallId2, reply) {
|
|
2245
2280
|
await this.assertNotExpired(toolCallId2);
|
|
2246
2281
|
const runId = await this.resolveRunForToolCall(toolCallId2);
|
|
2282
|
+
await this.assertRunWaiting(runId);
|
|
2247
2283
|
return this.runner.signal(runId, toolCallId2, reply);
|
|
2248
2284
|
}
|
|
2285
|
+
/**
|
|
2286
|
+
* Refuse a decision addressed at a run that is over (`409 run_not_active`). The runtime would take
|
|
2287
|
+
* the signal and buffer it for a run that never comes back — the person's "yes" is accepted, the
|
|
2288
|
+
* card says so, and nothing runs. Settles the calls the dead run left awaiting a decision on the
|
|
2289
|
+
* way out, so the card stops asking. A runner that cannot say whether a run is alive is taken at
|
|
2290
|
+
* its word that it is, and so is one that fails to answer.
|
|
2291
|
+
*/
|
|
2292
|
+
async assertRunWaiting(runId) {
|
|
2293
|
+
if (typeof this.runner.isRunActive !== "function") {
|
|
2294
|
+
return;
|
|
2295
|
+
}
|
|
2296
|
+
const active = await this.runner.isRunActive(runId).catch(() => true);
|
|
2297
|
+
if (active) {
|
|
2298
|
+
return;
|
|
2299
|
+
}
|
|
2300
|
+
await settleDeadRun2(this.store, {
|
|
2301
|
+
runId
|
|
2302
|
+
});
|
|
2303
|
+
throw new RunNotActiveException(runId);
|
|
2304
|
+
}
|
|
2249
2305
|
async cancel(actor, runId) {
|
|
2250
2306
|
await this.assertOwnsActiveStream(actor, runId);
|
|
2251
2307
|
return this.runner.cancel(runId);
|
|
@@ -2929,7 +2985,7 @@ AttachmentsController = _ts_decorate10([
|
|
|
2929
2985
|
], AttachmentsController);
|
|
2930
2986
|
|
|
2931
2987
|
// src/controller/chat.controller.ts
|
|
2932
|
-
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError as AgentStreamError2 } from "@dudousxd/nestjs-agent-core";
|
|
2988
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError as AgentStreamError2, streamFailure as streamFailure2 } from "@dudousxd/nestjs-agent-core";
|
|
2933
2989
|
import { BadRequestException as BadRequestException3, Body, Controller as Controller3, Get as Get3, Inject as Inject9, Param, Post as Post2, Query, Req as Req2, Res } from "@nestjs/common";
|
|
2934
2990
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
2935
2991
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3125,10 +3181,7 @@ data: ${line}
|
|
|
3125
3181
|
const payload = error instanceof AgentStreamError2 ? {
|
|
3126
3182
|
code: error.code,
|
|
3127
3183
|
message: error.message
|
|
3128
|
-
} :
|
|
3129
|
-
code: "run_failed",
|
|
3130
|
-
message: error instanceof Error ? error.message : "stream error"
|
|
3131
|
-
};
|
|
3184
|
+
} : streamFailure2(error);
|
|
3132
3185
|
res.write(`event: error
|
|
3133
3186
|
data: ${JSON.stringify(payload)}
|
|
3134
3187
|
|
|
@@ -4453,7 +4506,7 @@ ToolsController = _ts_decorate21([
|
|
|
4453
4506
|
|
|
4454
4507
|
// src/discovery/agent-discovery.service.ts
|
|
4455
4508
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
|
|
4456
|
-
import { Inject as Inject20, Injectable as Injectable8, Logger as
|
|
4509
|
+
import { Inject as Inject20, Injectable as Injectable8, Logger as Logger4 } from "@nestjs/common";
|
|
4457
4510
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
4458
4511
|
|
|
4459
4512
|
// src/decorator/agent.decorator.ts
|
|
@@ -4504,7 +4557,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
4504
4557
|
scanner;
|
|
4505
4558
|
registry;
|
|
4506
4559
|
contributors;
|
|
4507
|
-
logger = new
|
|
4560
|
+
logger = new Logger4(_AgentDiscoveryService.name);
|
|
4508
4561
|
constructor(discovery, scanner, registry, contributors) {
|
|
4509
4562
|
this.discovery = discovery;
|
|
4510
4563
|
this.scanner = scanner;
|
|
@@ -4637,7 +4690,7 @@ AgentDiscoveryService = _ts_decorate22([
|
|
|
4637
4690
|
|
|
4638
4691
|
// src/discovery/ai-tool-discovery.service.ts
|
|
4639
4692
|
import { AGENT_OPTIONS as AGENT_OPTIONS6, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
4640
|
-
import { Inject as Inject21, Injectable as Injectable9, Logger as
|
|
4693
|
+
import { Inject as Inject21, Injectable as Injectable9, Logger as Logger5 } from "@nestjs/common";
|
|
4641
4694
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
4642
4695
|
import { z } from "zod";
|
|
4643
4696
|
|
|
@@ -4691,7 +4744,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4691
4744
|
registry;
|
|
4692
4745
|
agents;
|
|
4693
4746
|
options;
|
|
4694
|
-
logger = new
|
|
4747
|
+
logger = new Logger5(_AiToolDiscoveryService.name);
|
|
4695
4748
|
constructor(discovery, registry, agents, options) {
|
|
4696
4749
|
this.discovery = discovery;
|
|
4697
4750
|
this.registry = registry;
|
|
@@ -4842,7 +4895,7 @@ AiToolDiscoveryService = _ts_decorate23([
|
|
|
4842
4895
|
|
|
4843
4896
|
// src/discovery/skill-discovery.service.ts
|
|
4844
4897
|
import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
|
|
4845
|
-
import { Inject as Inject22, Injectable as Injectable10, Logger as
|
|
4898
|
+
import { Inject as Inject22, Injectable as Injectable10, Logger as Logger6 } from "@nestjs/common";
|
|
4846
4899
|
import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
|
|
4847
4900
|
|
|
4848
4901
|
// src/decorator/skill.decorator.ts
|
|
@@ -4891,7 +4944,7 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
4891
4944
|
}
|
|
4892
4945
|
discovery;
|
|
4893
4946
|
declared;
|
|
4894
|
-
logger = new
|
|
4947
|
+
logger = new Logger6(_SkillDiscoveryService.name);
|
|
4895
4948
|
constructor(discovery, declared) {
|
|
4896
4949
|
this.discovery = discovery;
|
|
4897
4950
|
this.declared = declared;
|
|
@@ -5001,8 +5054,8 @@ var LedgerQuotaProvider = class {
|
|
|
5001
5054
|
};
|
|
5002
5055
|
|
|
5003
5056
|
// src/runner/inline-agent-runner.ts
|
|
5004
|
-
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_STORE as AGENT_STORE6, RunCancelledError as RunCancelledError2, agentFailureCode as agentFailureCode2, encodeStreamEvent as encodeStreamEvent5, publishAgentRunFailed as publishAgentRunFailed2, releaseThreadRun as releaseThreadRun3, runAgentLoop as runAgentLoop2, settleAll as settleAll2, settleUnsettledDelegation as settleUnsettledDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
5005
|
-
import { Inject as Inject23, Injectable as Injectable11, Logger as
|
|
5057
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_STORE as AGENT_STORE6, RUN_ENDED_BEFORE_TOOL_CALL as RUN_ENDED_BEFORE_TOOL_CALL2, RunCancelledError as RunCancelledError2, agentFailureCode as agentFailureCode2, encodeStreamEvent as encodeStreamEvent5, publishAgentRunFailed as publishAgentRunFailed2, releaseThreadRun as releaseThreadRun3, runAgentLoop as runAgentLoop2, settleAll as settleAll2, settleUnsettledDelegation as settleUnsettledDelegation2, streamFailure as streamFailure3 } from "@dudousxd/nestjs-agent-core";
|
|
5058
|
+
import { Inject as Inject23, Injectable as Injectable11, Logger as Logger7, Optional as Optional10 } from "@nestjs/common";
|
|
5006
5059
|
function _ts_decorate25(decorators, target, key, desc) {
|
|
5007
5060
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5008
5061
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -5036,7 +5089,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5036
5089
|
factory;
|
|
5037
5090
|
store;
|
|
5038
5091
|
queue;
|
|
5039
|
-
logger = new
|
|
5092
|
+
logger = new Logger7(_InlineAgentRunner.name);
|
|
5040
5093
|
pending = /* @__PURE__ */ new Map();
|
|
5041
5094
|
/**
|
|
5042
5095
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -5056,7 +5109,15 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5056
5109
|
* that was running it is gone (a restart), and a thread it still holds is a stale claim.
|
|
5057
5110
|
*/
|
|
5058
5111
|
async isRunActive(runId) {
|
|
5059
|
-
|
|
5112
|
+
if (this.live.has(runId)) {
|
|
5113
|
+
return true;
|
|
5114
|
+
}
|
|
5115
|
+
for (const key of this.pending.keys()) {
|
|
5116
|
+
if (key.startsWith(`${runId}:`)) {
|
|
5117
|
+
return true;
|
|
5118
|
+
}
|
|
5119
|
+
}
|
|
5120
|
+
return false;
|
|
5060
5121
|
}
|
|
5061
5122
|
async start(input, options = {}) {
|
|
5062
5123
|
const runId = options.runId ?? crypto.randomUUID();
|
|
@@ -5099,13 +5160,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5099
5160
|
errorCode: code,
|
|
5100
5161
|
errorMessage: message
|
|
5101
5162
|
});
|
|
5163
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, RUN_ENDED_BEFORE_TOOL_CALL2)).catch(() => 0);
|
|
5102
5164
|
const writer = await deps.sink.open(runId);
|
|
5103
5165
|
await this.settleQueue(writer, input, runId, "failed", message);
|
|
5104
5166
|
await releaseThreadRun3(this.store, input.threadId, runId);
|
|
5105
|
-
await writer.fail(
|
|
5106
|
-
code,
|
|
5107
|
-
message
|
|
5108
|
-
});
|
|
5167
|
+
await writer.fail(streamFailure3(error));
|
|
5109
5168
|
}).finally(() => {
|
|
5110
5169
|
this.cancelled.delete(runId);
|
|
5111
5170
|
this.live.delete(runId);
|
|
@@ -5379,6 +5438,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5379
5438
|
errorMessage: message
|
|
5380
5439
|
}
|
|
5381
5440
|
});
|
|
5441
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, RUN_ENDED_BEFORE_TOOL_CALL2)).catch(() => 0);
|
|
5382
5442
|
await settleUnsettledDelegation2({
|
|
5383
5443
|
store: this.store,
|
|
5384
5444
|
delivery: deliverTo,
|
|
@@ -5543,7 +5603,7 @@ function _ts_decorate26(decorators, target, key, desc) {
|
|
|
5543
5603
|
}
|
|
5544
5604
|
__name(_ts_decorate26, "_ts_decorate");
|
|
5545
5605
|
var DEFAULT_PATH = "agent";
|
|
5546
|
-
var logger = new
|
|
5606
|
+
var logger = new Logger8("AgentModule");
|
|
5547
5607
|
function externalStoreWrapper(modules) {
|
|
5548
5608
|
for (const module of modules.values()) {
|
|
5549
5609
|
if (module.metatype === AgentModule) continue;
|