@tangle-network/agent-runtime 0.247.0 → 0.249.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/{activation-DizpINK3.d.ts → activation-CZz7kkgd.d.ts} +2 -2
- package/dist/{activation-DYqnl8zq.js → activation-ygjQvYwG.js} +32 -2
- package/dist/activation-ygjQvYwG.js.map +1 -0
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +1 -1
- package/dist/{coordination-driver-BV4AAUns.js → coordination-driver-B61Hh6B1.js} +142 -10
- package/dist/coordination-driver-B61Hh6B1.js.map +1 -0
- package/dist/{delegate-DQAzB5Xv.js → delegate-A6EYmMxy.js} +2 -2
- package/dist/{delegate-DQAzB5Xv.js.map → delegate-A6EYmMxy.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +1 -1
- package/dist/{graph-DcBmMLIp.js → graph-CXwmMtTx.js} +2 -2
- package/dist/{graph-DcBmMLIp.js.map → graph-CXwmMtTx.js.map} +1 -1
- package/dist/{index-DLzlXwr6.d.ts → index-BV5EmjCL.d.ts} +8 -5
- package/dist/index.d.ts +8 -6
- package/dist/index.js +27 -44
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +18 -11
- package/dist/intelligence.js +88 -33
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +6 -6
- package/dist/{loop-runner-bin-iqq1azfy.js → loop-runner-bin-C1O16oIq.js} +2 -2
- package/dist/{loop-runner-bin-iqq1azfy.js.map → loop-runner-bin-C1O16oIq.js.map} +1 -1
- package/dist/{loop-runner-bin-HbMECmxT.d.ts → loop-runner-bin-q0akFXYX.d.ts} +3 -3
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +2 -2
- package/dist/mcp/index.d.ts +5 -5
- package/dist/mcp/index.js +3 -3
- package/dist/{openai-tools-DvLk_Ddg.d.ts → openai-tools-zrajPyXe.d.ts} +2 -2
- package/dist/profiles.d.ts +2 -2
- package/dist/{provision-supervisor-BgQx2Avp.js → provision-supervisor-D7gC-Veu.js} +2 -2
- package/dist/{provision-supervisor-BgQx2Avp.js.map → provision-supervisor-D7gC-Veu.js.map} +1 -1
- package/dist/run-layout-hKAJGF4g.js.map +1 -1
- package/dist/{runtime-HpTXhB3g.js → runtime-BVZIbtyL.js} +6 -6
- package/dist/{runtime-HpTXhB3g.js.map → runtime-BVZIbtyL.js.map} +1 -1
- package/dist/{server-OOE7mXrN.js → server-DHS1Gxt2.js} +2 -2
- package/dist/{server-OOE7mXrN.js.map → server-DHS1Gxt2.js.map} +1 -1
- package/dist/{stream-agent-turn-CcumM0Bu.d.ts → stream-agent-turn-D9IbZMys.d.ts} +2 -2
- package/dist/{substrate-CQ0hfewn.d.ts → substrate-Ctmos75o.d.ts} +2 -2
- package/dist/{supervise-DZEOpzRw.js → supervise-CnFk7_wb.js} +18 -4
- package/dist/supervise-CnFk7_wb.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +11 -11
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-BUhz284C.d.ts → types-BmxS-W-f.d.ts} +22 -11
- package/package.json +4 -4
- package/dist/activation-DYqnl8zq.js.map +0 -1
- package/dist/coordination-driver-BV4AAUns.js.map +0 -1
- package/dist/supervise-DZEOpzRw.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { $t as RuntimeStreamEventCollector, Ai as AgentRuntimeEventSink, At as EvalRunEvent, Bi as RunAgentTaskOptions, Bt as RuntimeEventOtelOptions, Ci as startRuntimeRun, Di as AgentExecutionBackend, Ei as AgentBackendInput, Fi as BackendErrorDetail, Ft as LoopSpanNode, Gi as RuntimeStreamEvent, Gt as createOtelExporter, Hi as RuntimeCanonicalStreamEvent, Ht as buildLoopSpanNodes, Ii as KnowledgeReadinessDecision, It as OtelAttribute, Jt as loopEventToOtelSpan, Kt as exportEvalRuns, Li as OpenAIChatResponseFormat, Lt as OtelExportConfig, Mi as AgentTaskRunResult, Mt as EvalRunsExportConfig, Ni as AgentTaskSpec, Nt as EvalRunsExportResult, Oi as AgentKnowledgeProvider, Pi as AgentTaskStatus, Pt as INTELLIGENCE_WIRE_VERSION, Qt as RuntimeEventCollector, Ri as OpenAIChatTool, Rt as OtelExporter, Si as RuntimeRunStatus, Ti as AgentBackendContext, Ui as RuntimeSession, Ut as buildRuntimeEventOtelSpans, Vi as RunAgentTaskStreamOptions, Vt as buildLoopOtelSpans, Wi as RuntimeSessionStore, Wt as createOpenInferenceFileExporter, Xt as padTraceId, Yt as padSpanId, Zt as toOtelAttributes, _i as RuntimeRunCost, an as createRuntimeEventCollector, at as SupervisedResult, bi as RuntimeRunPersistenceAdapter, cn as sanitizeKnowledgeReadinessReport, en as RuntimeStreamEventSink, g as ExecutorFactory, gi as RuntimeRunCompleteInput, i as Budget, in as SanitizedKnowledgeRequirement, ji as AgentTaskContext, jt as EvalRunGeneration, ki as AgentRuntimeEvent, ln as sanitizeRuntimeStreamEvent, nn as RuntimeTelemetryOptions, on as createRuntimeStreamEventCollector, qt as generateSpanId, rn as SanitizedKnowledgeReadinessReport, sn as sanitizeAgentRuntimeEvent, tn as RuntimeStreamEventSummary, vi as RuntimeRunHandle, wi as AgentAdapter, xi as RuntimeRunRow, yi as RuntimeRunOptions, zi as OpenAIChatToolChoice, zt as OtelSpan } from "./types-
|
|
1
|
+
import { $t as RuntimeStreamEventCollector, Ai as AgentRuntimeEventSink, At as EvalRunEvent, Bi as RunAgentTaskOptions, Bt as RuntimeEventOtelOptions, Ci as startRuntimeRun, Di as AgentExecutionBackend, Ei as AgentBackendInput, Fi as BackendErrorDetail, Ft as LoopSpanNode, Gi as RuntimeStreamEvent, Gt as createOtelExporter, Hi as RuntimeCanonicalStreamEvent, Ht as buildLoopSpanNodes, Ii as KnowledgeReadinessDecision, It as OtelAttribute, Jt as loopEventToOtelSpan, Kt as exportEvalRuns, Li as OpenAIChatResponseFormat, Lt as OtelExportConfig, Mi as AgentTaskRunResult, Mt as EvalRunsExportConfig, Ni as AgentTaskSpec, Nt as EvalRunsExportResult, Oi as AgentKnowledgeProvider, Pi as AgentTaskStatus, Pt as INTELLIGENCE_WIRE_VERSION, Qt as RuntimeEventCollector, Ri as OpenAIChatTool, Rt as OtelExporter, Si as RuntimeRunStatus, Ti as AgentBackendContext, Ui as RuntimeSession, Ut as buildRuntimeEventOtelSpans, Vi as RunAgentTaskStreamOptions, Vt as buildLoopOtelSpans, Wi as RuntimeSessionStore, Wt as createOpenInferenceFileExporter, Xt as padTraceId, Yt as padSpanId, Zt as toOtelAttributes, _i as RuntimeRunCost, an as createRuntimeEventCollector, at as SupervisedResult, bi as RuntimeRunPersistenceAdapter, cn as sanitizeKnowledgeReadinessReport, en as RuntimeStreamEventSink, g as ExecutorFactory, gi as RuntimeRunCompleteInput, i as Budget, in as SanitizedKnowledgeRequirement, ji as AgentTaskContext, jt as EvalRunGeneration, ki as AgentRuntimeEvent, ln as sanitizeRuntimeStreamEvent, nn as RuntimeTelemetryOptions, on as createRuntimeStreamEventCollector, qt as generateSpanId, rn as SanitizedKnowledgeReadinessReport, sn as sanitizeAgentRuntimeEvent, tn as RuntimeStreamEventSummary, vi as RuntimeRunHandle, wi as AgentAdapter, xi as RuntimeRunRow, yi as RuntimeRunOptions, zi as OpenAIChatToolChoice, zt as OtelSpan } from "./types-BmxS-W-f.js";
|
|
2
2
|
import { i as SurfaceImprovementEdit } from "./improvement-adapter-D5gwwoXQ.js";
|
|
3
3
|
import { o as ImprovementProposalSource } from "./types-zWfqDjeL.js";
|
|
4
|
-
import { Bp as BackendTransportError, Gp as RetainedInteractiveAdmissionError, Hp as JudgeError, Jp as RetainedRunDispatchBindingError, Kp as RetainedInteractiveBindingError, Rp as AgentEvalError, Up as NotFoundError, Vp as ConfigError, Wp as PlannerError, Xa as SuperviseOptions, Xp as ValidationError, Yp as RuntimeRunStateError, nr as StructuralRolloutPolicy, qp as RetainedRunAdmissionError, sm as DeliverableSpec, wo as SupervisorProfile, zp as AgentEvalErrorCode } from "./index-
|
|
4
|
+
import { Bp as BackendTransportError, Gp as RetainedInteractiveAdmissionError, Hp as JudgeError, Jp as RetainedRunDispatchBindingError, Kp as RetainedInteractiveBindingError, Rp as AgentEvalError, Up as NotFoundError, Vp as ConfigError, Wp as PlannerError, Xa as SuperviseOptions, Xp as ValidationError, Yp as RuntimeRunStateError, nr as StructuralRolloutPolicy, qp as RetainedRunAdmissionError, sm as DeliverableSpec, wo as SupervisorProfile, zp as AgentEvalErrorCode } from "./index-BV5EmjCL.js";
|
|
5
5
|
import { a as RuntimeHookErrorContext, c as RuntimeHookTarget, d as defineRuntimeHooks, f as notifyRuntimeDecisionPoint, i as RuntimeHookContext, l as RuntimeHooks, n as RuntimeDecisionKind, o as RuntimeHookEvent, p as notifyRuntimeHookEvent, r as RuntimeDecisionPoint, s as RuntimeHookPhase, t as RuntimeDecisionEvidenceRef, u as composeRuntimeHooks } from "./runtime-hooks-Bj6wJHlH.js";
|
|
6
|
-
import { $t as WorktreeCheckRunner, er as Redactor, f as ExecutorConfig } from "./stream-agent-turn-
|
|
6
|
+
import { $t as WorktreeCheckRunner, er as Redactor, f as ExecutorConfig } from "./stream-agent-turn-D9IbZMys.js";
|
|
7
7
|
import { y as AgentCandidateOutputArtifactPort } from "./types-CuXu5zuS.js";
|
|
8
|
-
import { $ as ImprovementMaterializedProfilePopulationCandidate, A as ImproveCodeResult, B as ImproveMethodSource, C as TrainingBoundaryResult, Ct as CandidateGenerator, D as ImproveCandidateValidator, E as ImproveCandidateValidationInput, F as ImproveMethodContext, G as ImproveProfileSurface, H as ImproveOptions, I as ImproveMethodFactory, J as ImproveScenarioPartitions, K as ImproveResult, L as ImproveMethodLineage, M as ImproveCost, N as ImproveCustomCodeGeneratorOptions, O as ImproveCodeBaseOptions, P as ImproveLineage, Q as ImprovementCodeCandidate, R as ImproveMethodOptions, S as ProfileTrainerRequest, St as defaultBuildPrompt, T as createCommandProfileTrainer, U as ImproveProfileAgent, V as ImproveOptimizationRunOptions, W as ImproveProfileComponents, X as ImproveSurface, Y as ImproveSkillsOptions, Z as ImprovementCandidate, _ as CheckpointServingPort, _t as AgenticGeneratorShotReceipt, at as ImprovementProfilePopulationCandidate, b as ImproveTrainingResult, bt as agenticGenerator, ct as ImprovementProfilePopulationLineageNode, dt as DeepReadonly, et as ImprovementProfileCandidate, ft as ReadonlyAgentProfile, g as improve, gt as AgenticGeneratorShotExecution, ht as AgenticGeneratorShotDisposition, i as AgentImprovementActivationTransition, it as ImprovementProfilePopulationArtifactSource, j as ImproveCodeRunOptions, k as ImproveCodeOptions, lt as ImprovementProfilePopulationObservationSource, mt as AgenticGeneratorOptions, n as AgentImprovementActivationResultStore, nt as ImprovementProfileCandidatePopulationAvailable, ot as ImprovementProfilePopulationCandidateSource, pt as AgenticGeneratorExecutorForWorktree, q as ImproveRuntimeCodeGeneratorOptions, rt as ImprovementProfileCandidatePopulationUnavailable, st as ImprovementProfilePopulationLineage, t as AgentImprovementActivationReconciliation, tt as ImprovementProfileCandidatePopulation, ut as ImprovementRefusedProfilePopulationCandidate, v as ControlledTrainingCommand, vt as Verifier, w as TrainingDatasetDocument, x as ProfileTrainer, xt as commandVerifier, y as ImproveTrainingOptions, yt as VerifyResult, z as ImproveMethodResult } from "./activation-
|
|
9
|
-
import { _ as researchLoopRunner, a as DELEGATED_LOOP_MODES, c as DelegatedLoopResult, d as ResearchLoopRunnerOptions, f as RunDelegatedLoopOptions, g as isDelegatedLoopMode, h as auditLoopRunner, i as runLoopRunnerCli, l as DelegatedLoopRunner, m as WorktreeLoopRunnerOptions, n as LoopRunnerCliResult, o as DelegatedLoopMode, p as VetoedFact, r as parseLoopRunnerArgv, s as DelegatedLoopRegistry, t as LoopRunnerCliArgs, u as ResearchLoopResult, v as runDelegatedLoop, y as worktreeLoopRunner } from "./loop-runner-bin-
|
|
10
|
-
import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "./openai-tools-
|
|
8
|
+
import { $ as ImprovementMaterializedProfilePopulationCandidate, A as ImproveCodeResult, B as ImproveMethodSource, C as TrainingBoundaryResult, Ct as CandidateGenerator, D as ImproveCandidateValidator, E as ImproveCandidateValidationInput, F as ImproveMethodContext, G as ImproveProfileSurface, H as ImproveOptions, I as ImproveMethodFactory, J as ImproveScenarioPartitions, K as ImproveResult, L as ImproveMethodLineage, M as ImproveCost, N as ImproveCustomCodeGeneratorOptions, O as ImproveCodeBaseOptions, P as ImproveLineage, Q as ImprovementCodeCandidate, R as ImproveMethodOptions, S as ProfileTrainerRequest, St as defaultBuildPrompt, T as createCommandProfileTrainer, U as ImproveProfileAgent, V as ImproveOptimizationRunOptions, W as ImproveProfileComponents, X as ImproveSurface, Y as ImproveSkillsOptions, Z as ImprovementCandidate, _ as CheckpointServingPort, _t as AgenticGeneratorShotReceipt, at as ImprovementProfilePopulationCandidate, b as ImproveTrainingResult, bt as agenticGenerator, ct as ImprovementProfilePopulationLineageNode, dt as DeepReadonly, et as ImprovementProfileCandidate, ft as ReadonlyAgentProfile, g as improve, gt as AgenticGeneratorShotExecution, ht as AgenticGeneratorShotDisposition, i as AgentImprovementActivationTransition, it as ImprovementProfilePopulationArtifactSource, j as ImproveCodeRunOptions, k as ImproveCodeOptions, lt as ImprovementProfilePopulationObservationSource, mt as AgenticGeneratorOptions, n as AgentImprovementActivationResultStore, nt as ImprovementProfileCandidatePopulationAvailable, ot as ImprovementProfilePopulationCandidateSource, pt as AgenticGeneratorExecutorForWorktree, q as ImproveRuntimeCodeGeneratorOptions, rt as ImprovementProfileCandidatePopulationUnavailable, st as ImprovementProfilePopulationLineage, t as AgentImprovementActivationReconciliation, tt as ImprovementProfileCandidatePopulation, ut as ImprovementRefusedProfilePopulationCandidate, v as ControlledTrainingCommand, vt as Verifier, w as TrainingDatasetDocument, x as ProfileTrainer, xt as commandVerifier, y as ImproveTrainingOptions, yt as VerifyResult, z as ImproveMethodResult } from "./activation-CZz7kkgd.js";
|
|
9
|
+
import { _ as researchLoopRunner, a as DELEGATED_LOOP_MODES, c as DelegatedLoopResult, d as ResearchLoopRunnerOptions, f as RunDelegatedLoopOptions, g as isDelegatedLoopMode, h as auditLoopRunner, i as runLoopRunnerCli, l as DelegatedLoopRunner, m as WorktreeLoopRunnerOptions, n as LoopRunnerCliResult, o as DelegatedLoopMode, p as VetoedFact, r as parseLoopRunnerArgv, s as DelegatedLoopRegistry, t as LoopRunnerCliArgs, u as ResearchLoopResult, v as runDelegatedLoop, y as worktreeLoopRunner } from "./loop-runner-bin-q0akFXYX.js";
|
|
10
|
+
import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "./openai-tools-zrajPyXe.js";
|
|
11
11
|
import { AgentCandidateBundle, AgentCandidateCapturedArtifact, AgentCandidateKnowledge, AgentProfile, Sha256Digest } from "@tangle-network/agent-interface";
|
|
12
12
|
import { AgentProfile as AgentProfile$1, ControlBudget, ControlDecision, ControlEvalResult, ControlEvalResult as ControlEvalResult$1, ControlRunResult, ControlStep, DataAcquisitionPlan, KnowledgeReadinessReport, KnowledgeReadinessReport as KnowledgeReadinessReport$1, KnowledgeRequirement, MaximumCharge, ProposalFinding, RunRecord, RunRecord as RunRecord$1 } from "@tangle-network/agent-eval";
|
|
13
13
|
import { GepaOptimizationMethodConfig, ProfileDispatchFn, Scenario, SkillOptOptimizationMethodConfig } from "@tangle-network/agent-eval/campaign";
|
|
@@ -555,6 +555,8 @@ interface PersonaConversationResult {
|
|
|
555
555
|
tokensKnown?: false;
|
|
556
556
|
/** Absent means every worker call reported provider-billed cost, including a known zero. */
|
|
557
557
|
costUsdKnown?: false;
|
|
558
|
+
/** Worker-only external estimate, kept separate from observed provider-billed spend. */
|
|
559
|
+
estimatedCostUsd?: number;
|
|
558
560
|
}
|
|
559
561
|
/**
|
|
560
562
|
* Run one worker profile against one persona as a multi-round conversation.
|
package/dist/index.js
CHANGED
|
@@ -2,15 +2,15 @@ import { $r as writeAllBytes, Jn as defaultRedactorIdentityMaterial, Qr as readC
|
|
|
2
2
|
import { a as JudgeError, c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBindingError, f as RuntimeRunStateError, i as ConfigError, l as RetainedInteractiveBindingError, m as ValidationError, o as NotFoundError, r as BackendTransportError, s as PlannerError, t as AgentEvalError, u as RetainedRunAdmissionError } from "./errors-DodWX-cb.js";
|
|
3
3
|
import { F as InMemoryRuntimeSessionStore, I as newRuntimeSession, L as nowIso, M as createIterableBackend, N as createSandboxPromptBackend, O as optimizerMethod, P as normalizeBackendStreamEvent, R as startOrResumeRuntimeSession, j as streamAgentTurn, k as strategyAuthorMethod, z as touchSession } from "./structural-rollout-z1A0okaB.js";
|
|
4
4
|
import { t as assertExecutableAgentProfile } from "./model-policy-BbSCSak0.js";
|
|
5
|
-
import {
|
|
5
|
+
import { a as createRuntimeUsageTotals, i as addRuntimeUsage, o as isUsageAmount, t as createAgentImprovementActivationResult } from "./activation-ygjQvYwG.js";
|
|
6
|
+
import { Lt as McpSpawnFault, Rt as connectStdioMcp } from "./runtime-BVZIbtyL.js";
|
|
6
7
|
import { i as notifyRuntimeHookEvent, n as defineRuntimeHooks, r as notifyRuntimeDecisionPoint, t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
|
|
7
8
|
import { B as assertCandidateValidator, G as applyRolloutPolicyToProfile, H as parseExecutionRef, J as serializeRolloutPolicy, K as normalizeRolloutPolicy, L as improve, Q as defaultBuildPrompt, R as createCommandProfileTrainer, U as rawTraceDistiller, W as ROLLOUT_POLICY_EXTENSION, X as agenticGenerator, Y as structuralRolloutPolicyFromProfile, Z as commandVerifier, q as parseRolloutPolicy, z as withMethodRuntimeControls } from "./improvement-cycle-B049YmQ8.js";
|
|
8
9
|
import { a as canonicalCandidateBytes$1, d as omitTopLevelDigest, l as embeddedCandidateArtifact, o as canonicalCandidateDigest$1, u as immutableCandidateValue } from "./protected-redaction-Fn1ETfJ-.js";
|
|
9
10
|
import { d as persistCandidateOutputArtifact } from "./prepare-CibQrhfi.js";
|
|
10
|
-
import { t as createAgentImprovementActivationResult } from "./activation-DYqnl8zq.js";
|
|
11
11
|
import { i as sealAgentCandidateBundle, t as captureAgentCandidateWorkspace } from "./workspace-archive-DSRT4Tro.js";
|
|
12
|
-
import { n as supervise } from "./supervise-
|
|
13
|
-
import { a as isDelegatedLoopMode, c as worktreeLoopRunner, i as auditLoopRunner, n as runLoopRunnerCli, o as researchLoopRunner, r as DELEGATED_LOOP_MODES, s as runDelegatedLoop, t as parseLoopRunnerArgv } from "./loop-runner-bin-
|
|
12
|
+
import { n as supervise } from "./supervise-CnFk7_wb.js";
|
|
13
|
+
import { a as isDelegatedLoopMode, c as worktreeLoopRunner, i as auditLoopRunner, n as runLoopRunnerCli, o as researchLoopRunner, r as DELEGATED_LOOP_MODES, s as runDelegatedLoop, t as parseLoopRunnerArgv } from "./loop-runner-bin-C1O16oIq.js";
|
|
14
14
|
import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "./openai-tools-DoQ32vpe.js";
|
|
15
15
|
import { agentCandidateKnowledgeSchema, agentProfileSchema, canonicalAgentProfileDigest, sha256DigestSchema } from "@tangle-network/agent-interface";
|
|
16
16
|
import { FAILURE_CLASSES, acquisitionPlansForKnowledgeGaps, blockingKnowledgeEval, canonicalJson, runAgentControlLoop, scoreKnowledgeReadiness, userQuestionsForKnowledgeGaps } from "@tangle-network/agent-eval";
|
|
@@ -1231,14 +1231,7 @@ function profileRuntimeBackend(profile, factory, counter) {
|
|
|
1231
1231
|
...backend,
|
|
1232
1232
|
async *stream(input, context) {
|
|
1233
1233
|
for await (const event of backend.stream(input, context)) {
|
|
1234
|
-
if (event.type === "llm_call")
|
|
1235
|
-
counter.sawLlmCall = true;
|
|
1236
|
-
counter.tokensIn += event.tokensIn ?? 0;
|
|
1237
|
-
counter.tokensOut += event.tokensOut ?? 0;
|
|
1238
|
-
counter.costUsd += event.costUsd ?? 0;
|
|
1239
|
-
if (event.tokensKnown === false || event.tokensIn === void 0 || event.tokensOut === void 0) counter.tokensKnown = false;
|
|
1240
|
-
if (event.usdKnown === false || event.costUsd === void 0) counter.usdKnown = false;
|
|
1241
|
-
}
|
|
1234
|
+
if (event.type === "llm_call") addRuntimeUsage(counter, event);
|
|
1242
1235
|
yield event;
|
|
1243
1236
|
}
|
|
1244
1237
|
}
|
|
@@ -1269,14 +1262,7 @@ function scriptedPersonaBackend(turns) {
|
|
|
1269
1262
|
* until `maxTurns`. Returns the persistent transcript + worker-only usage.
|
|
1270
1263
|
*/
|
|
1271
1264
|
async function runPersonaConversation(opts) {
|
|
1272
|
-
const counter =
|
|
1273
|
-
tokensIn: 0,
|
|
1274
|
-
tokensOut: 0,
|
|
1275
|
-
costUsd: 0,
|
|
1276
|
-
sawLlmCall: false,
|
|
1277
|
-
tokensKnown: true,
|
|
1278
|
-
usdKnown: true
|
|
1279
|
-
};
|
|
1265
|
+
const counter = createRuntimeUsageTotals();
|
|
1280
1266
|
const workerName = opts.workerName ?? "agent";
|
|
1281
1267
|
const worker = profileRuntimeBackend(opts.worker, opts.executorFor(opts.worker, "worker"), counter);
|
|
1282
1268
|
let persona;
|
|
@@ -1307,10 +1293,10 @@ async function runPersonaConversation(opts) {
|
|
|
1307
1293
|
seed: opts.seed ?? "Begin.",
|
|
1308
1294
|
signal: opts.signal
|
|
1309
1295
|
});
|
|
1310
|
-
const fallbackCostKnown =
|
|
1296
|
+
const fallbackCostKnown = counter.llmCalls === 0 && opts.persona.kind === "scripted" && result.spentCreditsCents > 0;
|
|
1311
1297
|
const costUsd = fallbackCostKnown ? result.spentCreditsCents / 100 : counter.costUsd;
|
|
1312
|
-
const tokensKnown = counter.
|
|
1313
|
-
const costUsdKnown = counter.
|
|
1298
|
+
const tokensKnown = counter.llmCalls > 0 && counter.tokensKnown !== false;
|
|
1299
|
+
const costUsdKnown = counter.llmCalls > 0 ? counter.usdKnown !== false : fallbackCostKnown;
|
|
1314
1300
|
return {
|
|
1315
1301
|
transcript: result.transcript,
|
|
1316
1302
|
turns: result.turns,
|
|
@@ -1319,7 +1305,8 @@ async function runPersonaConversation(opts) {
|
|
|
1319
1305
|
tokensIn: counter.tokensIn,
|
|
1320
1306
|
tokensOut: counter.tokensOut,
|
|
1321
1307
|
...tokensKnown ? {} : { tokensKnown: false },
|
|
1322
|
-
...costUsdKnown ? {} : { costUsdKnown: false }
|
|
1308
|
+
...costUsdKnown ? {} : { costUsdKnown: false },
|
|
1309
|
+
...counter.estimatedCostUsd !== void 0 ? { estimatedCostUsd: counter.estimatedCostUsd } : {}
|
|
1323
1310
|
};
|
|
1324
1311
|
}
|
|
1325
1312
|
/**
|
|
@@ -2994,19 +2981,10 @@ function startRuntimeRun(options) {
|
|
|
2994
2981
|
let resultSummary;
|
|
2995
2982
|
let error;
|
|
2996
2983
|
let completionMetadata;
|
|
2997
|
-
const ledger =
|
|
2998
|
-
tokensIn: 0,
|
|
2999
|
-
tokensOut: 0,
|
|
3000
|
-
costUsd: 0,
|
|
3001
|
-
wallMs: 0,
|
|
3002
|
-
llmCalls: 0
|
|
3003
|
-
};
|
|
2984
|
+
const ledger = createRuntimeUsageTotals();
|
|
3004
2985
|
const snapshotCost = () => ({
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
costUsd: ledger.costUsd,
|
|
3008
|
-
wallMs: (completedAtMs ?? now()) - startedAtMs,
|
|
3009
|
-
llmCalls: ledger.llmCalls
|
|
2986
|
+
...ledger,
|
|
2987
|
+
wallMs: (completedAtMs ?? now()) - startedAtMs
|
|
3010
2988
|
});
|
|
3011
2989
|
const buildRow = (extraMetadata) => ({
|
|
3012
2990
|
id,
|
|
@@ -3034,10 +3012,7 @@ function startRuntimeRun(options) {
|
|
|
3034
3012
|
},
|
|
3035
3013
|
observe(event) {
|
|
3036
3014
|
if (event.type !== "llm_call") return;
|
|
3037
|
-
ledger
|
|
3038
|
-
if (typeof event.tokensIn === "number" && Number.isFinite(event.tokensIn)) ledger.tokensIn += event.tokensIn;
|
|
3039
|
-
if (typeof event.tokensOut === "number" && Number.isFinite(event.tokensOut)) ledger.tokensOut += event.tokensOut;
|
|
3040
|
-
if (typeof event.costUsd === "number" && Number.isFinite(event.costUsd)) ledger.costUsd += event.costUsd;
|
|
3015
|
+
addRuntimeUsage(ledger, event);
|
|
3041
3016
|
},
|
|
3042
3017
|
cost: snapshotCost,
|
|
3043
3018
|
complete(input) {
|
|
@@ -3052,10 +3027,18 @@ function startRuntimeRun(options) {
|
|
|
3052
3027
|
error = input.error;
|
|
3053
3028
|
completionMetadata = input.metadata;
|
|
3054
3029
|
if (input.cost) {
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3030
|
+
for (const key of [
|
|
3031
|
+
"tokensIn",
|
|
3032
|
+
"tokensOut",
|
|
3033
|
+
"costUsd",
|
|
3034
|
+
"llmCalls",
|
|
3035
|
+
"estimatedCostUsd"
|
|
3036
|
+
]) {
|
|
3037
|
+
const value = input.cost[key];
|
|
3038
|
+
if (isUsageAmount(value)) ledger[key] = value;
|
|
3039
|
+
}
|
|
3040
|
+
if (input.cost.tokensKnown === false) ledger.tokensKnown = false;
|
|
3041
|
+
if (input.cost.usdKnown === false) ledger.usdKnown = false;
|
|
3059
3042
|
}
|
|
3060
3043
|
},
|
|
3061
3044
|
toRow(metadata) {
|