@dudousxd/nestjs-agent 1.37.0 → 1.38.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/a2ui/index.d.cts +1 -1
- package/dist/a2ui/index.d.ts +1 -1
- package/dist/durable/index.cjs +52 -3
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.js +70 -21
- package/dist/durable/index.js.map +1 -1
- package/dist/{index-4caNqEQ-.d.cts → index-BJFM1tG8.d.cts} +17 -1
- package/dist/{index-yC_Ra3CE.d.ts → index-De98CGXa.d.ts} +17 -1
- package/dist/index.cjs +37 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +54 -20
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -7,8 +7,8 @@ export * from '@dudousxd/nestjs-agent-core';
|
|
|
7
7
|
export { FunctionalToolDefinition } from '@dudousxd/nestjs-agent-core';
|
|
8
8
|
import { A2uiOptions } from '@dudousxd/nestjs-agent-core/a2ui';
|
|
9
9
|
import { Request, Response } from 'express';
|
|
10
|
-
import { A as AgentService, a as ActionProposalService } from './index-
|
|
11
|
-
export { b as A2uiAdapterOptions, c as A2uiRunHandler, d as AttachmentLimits, C as ChatParams, e as ChatSendMode, f as ChatSendResult, D as DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, g as DEFAULT_MAX_ATTACHMENT_BYTES, F as ForkThreadParams, M as MAX_ATTACHMENTS_PER_MESSAGE, N as NO_USER_MESSAGE_CODE, Q as QueuedSend, T as ThreadDefaultAgentReader, h as ThreadModelReader, i as a2uiAdapter, j as attachmentLimits } from './index-
|
|
10
|
+
import { A as AgentService, a as ActionProposalService } from './index-BJFM1tG8.cjs';
|
|
11
|
+
export { b as A2uiAdapterOptions, c as A2uiRunHandler, d as AttachmentLimits, C as ChatParams, e as ChatSendMode, f as ChatSendResult, D as DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, g as DEFAULT_MAX_ATTACHMENT_BYTES, F as ForkThreadParams, M as MAX_ATTACHMENTS_PER_MESSAGE, N as NO_USER_MESSAGE_CODE, Q as QueuedSend, T as ThreadDefaultAgentReader, h as ThreadModelReader, i as a2uiAdapter, j as attachmentLimits } from './index-BJFM1tG8.cjs';
|
|
12
12
|
import { AgentGenui } from './genui/index.cjs';
|
|
13
13
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
14
14
|
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export * from '@dudousxd/nestjs-agent-core';
|
|
|
7
7
|
export { FunctionalToolDefinition } from '@dudousxd/nestjs-agent-core';
|
|
8
8
|
import { A2uiOptions } from '@dudousxd/nestjs-agent-core/a2ui';
|
|
9
9
|
import { Request, Response } from 'express';
|
|
10
|
-
import { A as AgentService, a as ActionProposalService } from './index-
|
|
11
|
-
export { b as A2uiAdapterOptions, c as A2uiRunHandler, d as AttachmentLimits, C as ChatParams, e as ChatSendMode, f as ChatSendResult, D as DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, g as DEFAULT_MAX_ATTACHMENT_BYTES, F as ForkThreadParams, M as MAX_ATTACHMENTS_PER_MESSAGE, N as NO_USER_MESSAGE_CODE, Q as QueuedSend, T as ThreadDefaultAgentReader, h as ThreadModelReader, i as a2uiAdapter, j as attachmentLimits } from './index-
|
|
10
|
+
import { A as AgentService, a as ActionProposalService } from './index-De98CGXa.js';
|
|
11
|
+
export { b as A2uiAdapterOptions, c as A2uiRunHandler, d as AttachmentLimits, C as ChatParams, e as ChatSendMode, f as ChatSendResult, D as DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, g as DEFAULT_MAX_ATTACHMENT_BYTES, F as ForkThreadParams, M as MAX_ATTACHMENTS_PER_MESSAGE, N as NO_USER_MESSAGE_CODE, Q as QueuedSend, T as ThreadDefaultAgentReader, h as ThreadModelReader, i as a2uiAdapter, j as attachmentLimits } from './index-De98CGXa.js';
|
|
12
12
|
import { AgentGenui } from './genui/index.js';
|
|
13
13
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
14
14
|
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
package/dist/index.js
CHANGED
|
@@ -70,7 +70,7 @@ var init_kit = __esm({
|
|
|
70
70
|
|
|
71
71
|
// src/agent.module.ts
|
|
72
72
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER14, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_DURABLE_RUNNER, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL3, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS10, 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_SINK3, 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, ClosedRolesPolicy, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3, personalAgentGate, personalAgentScopes } from "@dudousxd/nestjs-agent-core";
|
|
73
|
-
import { Global, Logger as
|
|
73
|
+
import { Global, Logger as Logger9, Module as Module2 } from "@nestjs/common";
|
|
74
74
|
import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
|
|
75
75
|
|
|
76
76
|
// src/agent-deps.factory.ts
|
|
@@ -807,8 +807,8 @@ AgentDepsFactory2 = _ts_decorate2([
|
|
|
807
807
|
var AGENT_SERVICE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:agent-service");
|
|
808
808
|
|
|
809
809
|
// src/agent.service.ts
|
|
810
|
-
import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE4, DEFAULT_TEXT_ACTION_PROPOSAL_VOCABULARY as DEFAULT_TEXT_ACTION_PROPOSAL_VOCABULARY2, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval as mayDecideApproval2, readElicitationQuestions, settleDeadRun, textActionProposalReply as textActionProposalReply2, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
811
|
-
import { BadRequestException as BadRequestException2, ConflictException as ConflictException2, ForbiddenException as ForbiddenException2, GoneException, HttpException, HttpStatus, Inject as Inject5, Injectable as Injectable4, NotFoundException as NotFoundException2, NotImplementedException as NotImplementedException3, Optional as Optional3, PayloadTooLargeException, UnsupportedMediaTypeException } from "@nestjs/common";
|
|
810
|
+
import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE4, DEFAULT_TEXT_ACTION_PROPOSAL_VOCABULARY as DEFAULT_TEXT_ACTION_PROPOSAL_VOCABULARY2, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval as mayDecideApproval2, readElicitationQuestions, recordAiUsage, settleDeadRun, textActionProposalReply as textActionProposalReply2, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
811
|
+
import { BadRequestException as BadRequestException2, ConflictException as ConflictException2, ForbiddenException as ForbiddenException2, GoneException, HttpException, HttpStatus, Inject as Inject5, Injectable as Injectable4, Logger as Logger2, NotFoundException as NotFoundException2, NotImplementedException as NotImplementedException3, Optional as Optional3, PayloadTooLargeException, UnsupportedMediaTypeException } from "@nestjs/common";
|
|
812
812
|
|
|
813
813
|
// src/agent-deps.ts
|
|
814
814
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -1631,6 +1631,7 @@ function _ts_param4(paramIndex, decorator) {
|
|
|
1631
1631
|
};
|
|
1632
1632
|
}
|
|
1633
1633
|
__name(_ts_param4, "_ts_param");
|
|
1634
|
+
var usageLogger = new Logger2("AgentService");
|
|
1634
1635
|
var NO_USER_MESSAGE_CODE = "no_user_message";
|
|
1635
1636
|
function sendableParams(params) {
|
|
1636
1637
|
const message = params.message;
|
|
@@ -2874,6 +2875,31 @@ var AgentService2 = class {
|
|
|
2874
2875
|
throw new ForbiddenException2("run belongs to another actor");
|
|
2875
2876
|
}
|
|
2876
2877
|
}
|
|
2878
|
+
/**
|
|
2879
|
+
* Record AI spend that did not come from an agent turn — a transcription, a TTS render, a batch of
|
|
2880
|
+
* embeddings, a direct OpenAI/OpenRouter SDK call — on the same ledger the agent's turns write, so
|
|
2881
|
+
* cost, quota and the dashboard see one figure.
|
|
2882
|
+
*
|
|
2883
|
+
* Never throws into the caller's flow by default: a failed write or an invalid input is logged and
|
|
2884
|
+
* answered with `{ recorded: false, error }`. Pass `{ throwOnError: true }` where losing the row
|
|
2885
|
+
* must fail the caller.
|
|
2886
|
+
*
|
|
2887
|
+
* Counted against `actorRef` like an agent turn: the ledger is the budget (`LedgerQuotaProvider`),
|
|
2888
|
+
* so its tokens count in the token windows (a row with no tokens adds 0 there) and its `costUsd` in
|
|
2889
|
+
* the USD windows. A `QuotaStore` counter is bumped only where loop deps carry one (`AgentModule`
|
|
2890
|
+
* wires none). `actorRef: null` is platform cost, recorded under `PLATFORM_ACTOR_REF` and counted
|
|
2891
|
+
* against nobody.
|
|
2892
|
+
*/
|
|
2893
|
+
recordUsage(input, options = {}) {
|
|
2894
|
+
return recordAiUsage({
|
|
2895
|
+
store: this.store,
|
|
2896
|
+
quota: this.deps.forAgent().quota,
|
|
2897
|
+
day: utcDay(),
|
|
2898
|
+
input,
|
|
2899
|
+
options,
|
|
2900
|
+
warn: /* @__PURE__ */ __name((message) => usageLogger.warn(message), "warn")
|
|
2901
|
+
});
|
|
2902
|
+
}
|
|
2877
2903
|
};
|
|
2878
2904
|
AgentService2 = _ts_decorate5([
|
|
2879
2905
|
Injectable4(),
|
|
@@ -4780,7 +4806,7 @@ ToolsController = _ts_decorate19([
|
|
|
4780
4806
|
|
|
4781
4807
|
// src/discovery/agent-discovery.service.ts
|
|
4782
4808
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
|
|
4783
|
-
import { Inject as Inject19, Injectable as Injectable6, Logger as
|
|
4809
|
+
import { Inject as Inject19, Injectable as Injectable6, Logger as Logger3 } from "@nestjs/common";
|
|
4784
4810
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
4785
4811
|
|
|
4786
4812
|
// src/decorator/agent.decorator.ts
|
|
@@ -4849,7 +4875,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
4849
4875
|
scanner;
|
|
4850
4876
|
registry;
|
|
4851
4877
|
contributors;
|
|
4852
|
-
logger = new
|
|
4878
|
+
logger = new Logger3(_AgentDiscoveryService.name);
|
|
4853
4879
|
constructor(discovery, scanner, registry, contributors) {
|
|
4854
4880
|
this.discovery = discovery;
|
|
4855
4881
|
this.scanner = scanner;
|
|
@@ -5031,7 +5057,7 @@ AgentDiscoveryService = _ts_decorate20([
|
|
|
5031
5057
|
|
|
5032
5058
|
// src/discovery/ai-tool-discovery.service.ts
|
|
5033
5059
|
import { AGENT_OPTIONS as AGENT_OPTIONS7, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
5034
|
-
import { Inject as Inject20, Injectable as Injectable7, Logger as
|
|
5060
|
+
import { Inject as Inject20, Injectable as Injectable7, Logger as Logger4 } from "@nestjs/common";
|
|
5035
5061
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
5036
5062
|
import { z } from "zod";
|
|
5037
5063
|
|
|
@@ -5098,7 +5124,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
5098
5124
|
registry;
|
|
5099
5125
|
agents;
|
|
5100
5126
|
options;
|
|
5101
|
-
logger = new
|
|
5127
|
+
logger = new Logger4(_AiToolDiscoveryService.name);
|
|
5102
5128
|
constructor(discovery, registry, agents, options) {
|
|
5103
5129
|
this.discovery = discovery;
|
|
5104
5130
|
this.registry = registry;
|
|
@@ -5264,7 +5290,7 @@ AiToolDiscoveryService = _ts_decorate21([
|
|
|
5264
5290
|
|
|
5265
5291
|
// src/discovery/skill-discovery.service.ts
|
|
5266
5292
|
import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
|
|
5267
|
-
import { Inject as Inject21, Injectable as Injectable8, Logger as
|
|
5293
|
+
import { Inject as Inject21, Injectable as Injectable8, Logger as Logger5 } from "@nestjs/common";
|
|
5268
5294
|
import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
|
|
5269
5295
|
|
|
5270
5296
|
// src/decorator/skill.decorator.ts
|
|
@@ -5319,7 +5345,7 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
5319
5345
|
}
|
|
5320
5346
|
discovery;
|
|
5321
5347
|
declared;
|
|
5322
|
-
logger = new
|
|
5348
|
+
logger = new Logger5(_SkillDiscoveryService.name);
|
|
5323
5349
|
constructor(discovery, declared) {
|
|
5324
5350
|
this.discovery = discovery;
|
|
5325
5351
|
this.declared = declared;
|
|
@@ -5627,7 +5653,7 @@ var LedgerQuotaProvider = class {
|
|
|
5627
5653
|
|
|
5628
5654
|
// src/pricing-boot.service.ts
|
|
5629
5655
|
import { AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS8, AGENT_PRICING_STORE as AGENT_PRICING_STORE2, ensureModelPricing } from "@dudousxd/nestjs-agent-core";
|
|
5630
|
-
import { Inject as Inject22, Injectable as Injectable9, Logger as
|
|
5656
|
+
import { Inject as Inject22, Injectable as Injectable9, Logger as Logger6, Optional as Optional9 } from "@nestjs/common";
|
|
5631
5657
|
function _ts_decorate23(decorators, target, key, desc) {
|
|
5632
5658
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5633
5659
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -5654,7 +5680,7 @@ function _ts_param22(paramIndex, decorator) {
|
|
|
5654
5680
|
};
|
|
5655
5681
|
}
|
|
5656
5682
|
__name(_ts_param22, "_ts_param");
|
|
5657
|
-
var logger = new
|
|
5683
|
+
var logger = new Logger6("AgentPricing");
|
|
5658
5684
|
var PricingBootService = class {
|
|
5659
5685
|
static {
|
|
5660
5686
|
__name(this, "PricingBootService");
|
|
@@ -5717,7 +5743,7 @@ PricingBootService = _ts_decorate23([
|
|
|
5717
5743
|
// src/proposals/action-proposal-worker.service.ts
|
|
5718
5744
|
import { randomUUID } from "crypto";
|
|
5719
5745
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_OPTIONS as AGENT_OPTIONS9, AGENT_STORE as AGENT_STORE5, ActionProposalExecutor, ActionProposalWorker, assertIndependentActionCapabilities as assertIndependentActionCapabilities2 } from "@dudousxd/nestjs-agent-core";
|
|
5720
|
-
import { Inject as Inject23, Injectable as Injectable10, Logger as
|
|
5746
|
+
import { Inject as Inject23, Injectable as Injectable10, Logger as Logger7 } from "@nestjs/common";
|
|
5721
5747
|
function _ts_decorate24(decorators, target, key, desc) {
|
|
5722
5748
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5723
5749
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -5752,7 +5778,7 @@ var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
|
5752
5778
|
options;
|
|
5753
5779
|
deps;
|
|
5754
5780
|
worker;
|
|
5755
|
-
logger = new
|
|
5781
|
+
logger = new Logger7(_ActionProposalWorkerService.name);
|
|
5756
5782
|
settledListeners = /* @__PURE__ */ new Set();
|
|
5757
5783
|
admittedListeners = /* @__PURE__ */ new Set();
|
|
5758
5784
|
/**
|
|
@@ -6012,8 +6038,8 @@ ActionProposalController = _ts_decorate25([
|
|
|
6012
6038
|
var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-queue");
|
|
6013
6039
|
|
|
6014
6040
|
// src/runner/inline-agent-runner.ts
|
|
6015
|
-
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_STORE as AGENT_STORE6, RUN_ENDED_BEFORE_TOOL_CALL, RunCancelledError, agentFailureCode, agentRunContext, encodeStreamEvent as encodeStreamEvent2, publishAgentRunCancelled, publishAgentRunFailed, releaseThreadRun, runAgentLoop, runDurationMs, settleAll, settleUnsettledDelegation, streamFailure as streamFailure2 } from "@dudousxd/nestjs-agent-core";
|
|
6016
|
-
import { Inject as Inject25, Injectable as Injectable11, Logger as
|
|
6041
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_STORE as AGENT_STORE6, RUN_ENDED_BEFORE_TOOL_CALL, RunCancelledError, agentFailureCode, agentRunContext, encodeStreamEvent as encodeStreamEvent2, publishAgentRunCancelled, publishAgentRunFailed, releaseThreadRun, runAgentLoop, runDurationMs, runEndTimings, settleAll, settleUnsettledDelegation, streamFailure as streamFailure2 } from "@dudousxd/nestjs-agent-core";
|
|
6042
|
+
import { Inject as Inject25, Injectable as Injectable11, Logger as Logger8, Optional as Optional10 } from "@nestjs/common";
|
|
6017
6043
|
function _ts_decorate26(decorators, target, key, desc) {
|
|
6018
6044
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6019
6045
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -6047,7 +6073,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6047
6073
|
factory;
|
|
6048
6074
|
store;
|
|
6049
6075
|
queue;
|
|
6050
|
-
logger = new
|
|
6076
|
+
logger = new Logger8(_InlineAgentRunner.name);
|
|
6051
6077
|
pending = /* @__PURE__ */ new Map();
|
|
6052
6078
|
/**
|
|
6053
6079
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -6084,10 +6110,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6084
6110
|
}
|
|
6085
6111
|
async start(input, options = {}) {
|
|
6086
6112
|
const runId = options.runId ?? crypto.randomUUID();
|
|
6113
|
+
const acceptedAt = Date.now();
|
|
6087
6114
|
const day = input.day ?? utcDay();
|
|
6088
6115
|
const deps = this.factory.forAgent(input.agentName);
|
|
6089
6116
|
this.live.add(runId);
|
|
6090
6117
|
const hooks = this.topLevelHooks({
|
|
6118
|
+
acceptedAt,
|
|
6091
6119
|
runId,
|
|
6092
6120
|
deps,
|
|
6093
6121
|
actor: input.actor,
|
|
@@ -6109,8 +6137,9 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6109
6137
|
const timed = durationMs !== void 0 ? {
|
|
6110
6138
|
durationMs
|
|
6111
6139
|
} : {};
|
|
6140
|
+
const measured = runEndTimings(error);
|
|
6112
6141
|
if (error instanceof RunCancelledError) {
|
|
6113
|
-
await this.settleCancelled(runId, input, deps, durationMs);
|
|
6142
|
+
await this.settleCancelled(runId, input, deps, durationMs, measured);
|
|
6114
6143
|
return;
|
|
6115
6144
|
}
|
|
6116
6145
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -6122,6 +6151,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6122
6151
|
code,
|
|
6123
6152
|
message,
|
|
6124
6153
|
...timed,
|
|
6154
|
+
...measured,
|
|
6125
6155
|
context: agentRunContext(input)
|
|
6126
6156
|
});
|
|
6127
6157
|
await this.store.recordRunEnd?.({
|
|
@@ -6199,7 +6229,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6199
6229
|
* the stream ENDED after a `cancelled` frame rather than failed, so a client that retries failed
|
|
6200
6230
|
* streams does not retry this one.
|
|
6201
6231
|
*/
|
|
6202
|
-
async settleCancelled(runId, input, deps, durationMs) {
|
|
6232
|
+
async settleCancelled(runId, input, deps, durationMs, measured = {}) {
|
|
6203
6233
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
6204
6234
|
const timed = durationMs !== void 0 ? {
|
|
6205
6235
|
durationMs
|
|
@@ -6208,6 +6238,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6208
6238
|
runId,
|
|
6209
6239
|
threadId: input.threadId,
|
|
6210
6240
|
...timed,
|
|
6241
|
+
...measured,
|
|
6211
6242
|
context: agentRunContext(input)
|
|
6212
6243
|
});
|
|
6213
6244
|
const writer = await deps.sink.open(runId);
|
|
@@ -6300,9 +6331,10 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6300
6331
|
});
|
|
6301
6332
|
}
|
|
6302
6333
|
topLevelHooks(args) {
|
|
6303
|
-
const { runId, deps, actor, day, threadId, chainBelow, input } = args;
|
|
6334
|
+
const { runId, deps, actor, day, threadId, chainBelow, input, acceptedAt } = args;
|
|
6304
6335
|
return {
|
|
6305
6336
|
runId,
|
|
6337
|
+
queueMs: /* @__PURE__ */ __name(() => Date.now() - acceptedAt, "queueMs"),
|
|
6306
6338
|
// The loop ends the stream when the turn completes. Just before, the thread passes to the next
|
|
6307
6339
|
// queued message (or is released), and the reader is told which — so by the time a client
|
|
6308
6340
|
// sees the run end, the thread is already free or already running what it queued.
|
|
@@ -6427,10 +6459,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
6427
6459
|
const timed = durationMs !== void 0 ? {
|
|
6428
6460
|
durationMs
|
|
6429
6461
|
} : {};
|
|
6462
|
+
const measured = runEndTimings(error);
|
|
6430
6463
|
const settled = {
|
|
6431
6464
|
runId,
|
|
6432
6465
|
threadId: subThread.id,
|
|
6433
6466
|
...timed,
|
|
6467
|
+
...measured,
|
|
6434
6468
|
context: agentRunContext(childInput)
|
|
6435
6469
|
};
|
|
6436
6470
|
if (cancelled) {
|
|
@@ -6619,7 +6653,7 @@ function _ts_decorate27(decorators, target, key, desc) {
|
|
|
6619
6653
|
}
|
|
6620
6654
|
__name(_ts_decorate27, "_ts_decorate");
|
|
6621
6655
|
var DEFAULT_PATH = "agent";
|
|
6622
|
-
var logger2 = new
|
|
6656
|
+
var logger2 = new Logger9("AgentModule");
|
|
6623
6657
|
function externalWrapper(modules, token) {
|
|
6624
6658
|
for (const module of modules.values()) {
|
|
6625
6659
|
if (module.metatype === AgentModule) continue;
|