@tangle-network/agent-runtime 10.0.19 → 10.0.20
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/CHANGELOG.md +4 -0
- package/dist/{activation-DLnZJab0.js → activation-5TrUzeFd.js} +2 -2
- package/dist/{activation-DLnZJab0.js.map → activation-5TrUzeFd.js.map} +1 -1
- package/dist/{activation-BudDVuT6.d.ts → activation-B0arteLE.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +4 -4
- package/dist/{delegate-9b8qGlXp.js → delegate-DnW85VY0.js} +2 -2
- package/dist/{delegate-9b8qGlXp.js.map → delegate-DnW85VY0.js.map} +1 -1
- package/dist/{driver-control-acknowledgers-b5MsXxR5.js → driver-control-acknowledgers-vgmZqgZ-.js} +8 -8
- package/dist/{driver-control-acknowledgers-b5MsXxR5.js.map → driver-control-acknowledgers-vgmZqgZ-.js.map} +1 -1
- package/dist/durable-writer-thread.js +4 -4
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +13 -14
- package/dist/durable.js.map +1 -1
- package/dist/{graph--n31XKWJ.js → graph-DHNPE7kw.js} +8 -8
- package/dist/{graph--n31XKWJ.js.map → graph-DHNPE7kw.js.map} +1 -1
- package/dist/{graph-registry-aMRd94PD.js → graph-registry-DI8o9iCB.js} +1 -1
- package/dist/{graph-registry-SgsCxCTZ.js → graph-registry-qyaNDATw.js} +2 -3
- package/dist/{graph-registry-SgsCxCTZ.js.map → graph-registry-qyaNDATw.js.map} +1 -1
- package/dist/{improve-sIZhpXqE.js → improve-BLFqeD3X.js} +6 -6
- package/dist/{improve-sIZhpXqE.js.map → improve-BLFqeD3X.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -10
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +4 -4
- package/dist/{continuation-CDdjAkpk.js → jsonl-file-B2ESMrTh.js} +396 -4
- package/dist/jsonl-file-B2ESMrTh.js.map +1 -0
- package/dist/kernel.d.ts +1 -1
- package/dist/kernel.js +17 -18
- package/dist/{loop-runner-Bn7lFuQZ.d.ts → loop-runner-BFC781pC.d.ts} +2 -2
- package/dist/{loop-runner-Dt7I2oMa.js → loop-runner-CITvo-q1.js} +2 -2
- package/dist/{loop-runner-Dt7I2oMa.js.map → loop-runner-CITvo-q1.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +6 -6
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-DfDAdtqb.js → provision-supervisor-CyUbiMz8.js} +6 -6
- package/dist/{provision-supervisor-DfDAdtqb.js.map → provision-supervisor-CyUbiMz8.js.map} +1 -1
- package/dist/{result-blob-store-Dke805sV.js → result-blob-store-CJjp44Mz.js} +3 -3
- package/dist/{result-blob-store-Dke805sV.js.map → result-blob-store-CJjp44Mz.js.map} +1 -1
- package/dist/{run-cancellation-B0SgcidY.js → run-cancellation-BNBmsY3a.js} +2 -2
- package/dist/{run-cancellation-B0SgcidY.js.map → run-cancellation-BNBmsY3a.js.map} +1 -1
- package/dist/{run-lock-BOg7BaXF.js → run-lock-Dcr79Wql.js} +2 -2
- package/dist/{run-lock-BOg7BaXF.js.map → run-lock-Dcr79Wql.js.map} +1 -1
- package/dist/{run-reopen-B7TN2aQQ.js → run-reopen-Cr2SHmYa.js} +6 -6
- package/dist/{run-reopen-B7TN2aQQ.js.map → run-reopen-Cr2SHmYa.js.map} +1 -1
- package/dist/{run-state-BNBUy2uK.js → run-state-AYXAe_lX.js} +7 -7
- package/dist/{run-state-BNBUy2uK.js.map → run-state-AYXAe_lX.js.map} +1 -1
- package/dist/{runtime-DXeWY00j.js → runtime-D-FpUoQg.js} +19 -20
- package/dist/{runtime-DXeWY00j.js.map → runtime-D-FpUoQg.js.map} +1 -1
- package/dist/{search-executor-BoQHI2Tz.js → search-executor-BHfb4p6C.js} +4 -4
- package/dist/{search-executor-BoQHI2Tz.js.map → search-executor-BHfb4p6C.js.map} +1 -1
- package/dist/{server-Xkgobp5y.js → server-CAXzZHVz.js} +4 -4
- package/dist/{server-Xkgobp5y.js.map → server-CAXzZHVz.js.map} +1 -1
- package/dist/{settle-record-B5OpVDnC.js → settle-record-BlIw2MU1.js} +3 -3
- package/dist/{settle-record-B5OpVDnC.js.map → settle-record-BlIw2MU1.js.map} +1 -1
- package/dist/{structural-rollout-BSF5tzUm.js → structural-rollout-BVuf5hFl.js} +4 -4
- package/dist/{structural-rollout-BSF5tzUm.js.map → structural-rollout-BVuf5hFl.js.map} +1 -1
- package/dist/{supervise-Drc1Pj1d.js → supervise-Ci8wiyla.js} +13 -13
- package/dist/supervise-Ci8wiyla.js.map +1 -0
- package/dist/{supervise-identity-Cz-Hzg9s.js → supervise-identity-CtxWEk1I.js} +3 -3
- package/dist/{supervise-identity-Cz-Hzg9s.js.map → supervise-identity-CtxWEk1I.js.map} +1 -1
- package/dist/{supervision-discovery-DdRd1lsz.js → supervision-discovery-DKxqbnHf.js} +4 -4
- package/dist/{supervision-discovery-DdRd1lsz.js.map → supervision-discovery-DKxqbnHf.js.map} +1 -1
- package/dist/{supervisor-CwUD7dsm.js → supervisor-KcnH2hC4.js} +10 -592
- package/dist/supervisor-KcnH2hC4.js.map +1 -0
- package/dist/{supervisor-accounting-CPDPG8mH.js → supervisor-accounting-DlDUl58C.js} +600 -8
- package/dist/supervisor-accounting-DlDUl58C.js.map +1 -0
- package/dist/{supervisor-root-contract-Uw2q3nvG.js → supervisor-root-contract-BCbu1A4n.js} +3 -3
- package/dist/{supervisor-root-contract-Uw2q3nvG.js.map → supervisor-root-contract-BCbu1A4n.js.map} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/dist/{failure-cause-C96rzF-d.js → tool-server-n4XYpCok.js} +181 -2
- package/dist/tool-server-n4XYpCok.js.map +1 -0
- package/dist/{top-web-5ThvdyD0.js → top-web-B-sHmI3g.js} +8 -8
- package/dist/{top-web-5ThvdyD0.js.map → top-web-B-sHmI3g.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-BLhsL4qy.d.ts → types-YXZL7Wxi.d.ts} +5 -3
- package/package.json +1 -1
- package/dist/continuation-CDdjAkpk.js.map +0 -1
- package/dist/failure-cause-C96rzF-d.js.map +0 -1
- package/dist/jsonl-file-B8xfYz9M.js +0 -397
- package/dist/jsonl-file-B8xfYz9M.js.map +0 -1
- package/dist/supervise-Drc1Pj1d.js.map +0 -1
- package/dist/supervisor-CwUD7dsm.js.map +0 -1
- package/dist/supervisor-accounting-CPDPG8mH.js.map +0 -1
- package/dist/tool-server-BhsyVDj2.js +0 -174
- package/dist/tool-server-BhsyVDj2.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $y as SanitizedKnowledgeRequirement, AS as AgentEvalError, By as OtelExportConfig, C as RuntimeFailureCause, Cw as RuntimeRunRow, Da as ExecutorFactory, E as Budget, FS as NotFoundError, Gy as createOtelExporter, Hy as OtelExporter, IS as ValidationError, Jy as RuntimeStreamEventCollector, Ky as loopEventToOtelSpan, Lh as ExecutorConfig, MS as BackendTransportError, NS as ConfigError, OS as Redactor, PS as JudgeError, Qy as SanitizedKnowledgeReadinessReport, S as RuntimeStreamEvent, Sw as RuntimeRunPersistenceAdapter, T as RuntimeFailureOwner, Tm as SupervisorProfile, Tw as startRuntimeRun, Uy as OtelSpan, Vy as OtelExportStats, Wy as buildLoopOtelSpans, Xf as IsolatedCheckResult, Xy as RuntimeStreamEventSummary, Yy as RuntimeStreamEventSink, Zy as RuntimeTelemetryOptions, _ as RunAgentTaskOptions, _f as SuperviseOptions, a as AgentKnowledgeProvider, b as RuntimeSession, bw as RuntimeRunHandle, c as AgentTaskContext, d as AgentTaskStatus, eb as createRuntimeEventCollector, g as OpenAIChatToolChoice, h as OpenAIChatTool, i as AgentExecutionBackend, jS as AgentEvalErrorCode, l as AgentTaskRunResult, m as OpenAIChatResponseFormat, n as AgentBackendContext, nb as sanitizeKnowledgeReadinessReport, o as AgentRuntimeEvent, oi as DeepReadonly, p as KnowledgeReadinessDecision, qf as IsolatedCheckBoxEvidence, qy as RuntimeEventCollector, r as AgentBackendInput, s as AgentRuntimeEventSink, si as ReadonlyAgentProfile, t as AgentAdapter, tb as createRuntimeStreamEventCollector, u as AgentTaskSpec, v as RunAgentTaskStreamOptions, vw as RuntimeRunCompleteInput, w as RuntimeFailureCode, wa as SupervisedResult, ww as RuntimeRunStatus, x as RuntimeSessionStore, xw as RuntimeRunOptions, y as RuntimeCanonicalStreamEvent, yw as RuntimeRunCost, zy as OtelAttribute } from "./types-
|
|
2
|
-
import { $ as ImproveCodeBaseOptions, At as SearchPromotion, B as DecideSearchImprovementOptions, Bt as sharedBoxLane, Ct as ImproveSearchOptions, Dt as ImprovementCodeCandidate, Et as ImproveSurface, Ft as SearchLaneOptions, G as ImproveTrainingOptions, Gt as AgenticGeneratorShotExecution, H as decideSearchImprovement, Ht as AgenticGeneratorExecutorForWorktree, It as SearchTraceOptions, J as ProfileTrainerRequest, Jt as VerifyResult, K as ImproveTrainingResult, Kt as AgenticGeneratorShotReceipt, L as improve, Lt as SharedBoxSearchLane, Mt as SearchEnvironmentFault, Nt as SearchLane, Ot as ImprovementProfileCandidate, Pt as SearchLaneKind, Q as ImproveCandidateValidator, R as SearchMethodOptions, Rt as dedicatedLane, St as ImproveSearchMethod, Tt as ImproveSkillsOptions, U as CheckpointServingPort, Ut as AgenticGeneratorOptions, V as SearchImprovementDecision, Vt as subscriptionLane, W as ControlledTrainingCommand, Wt as AgenticGeneratorShotDisposition, X as createCommandProfileTrainer, Xt as commandVerifier, Y as TrainingBoundaryResult, Yt as agenticGenerator, Z as ImproveCandidateValidationInput, Zt as CandidateGenerator, at as ImproveLineage, bt as ImproveSearchAgent, ct as ImproveMethodLineage, dt as ImproveMethodSource, et as ImproveCodeOptions, ft as ImproveOptimizationRunOptions, gt as ImproveProfileSurface, ht as ImproveProfileComponents, i as AgentImprovementActivationTransition, it as ImproveCustomCodeGeneratorOptions, jt as SearchCellContext, kt as SearchDispatchContext, lt as ImproveMethodOptions, mt as ImproveProfileAgent, n as AgentImprovementActivationResultStore, nt as ImproveCodeRunOptions, ot as ImproveMethodContext, q as ProfileTrainer, qt as Verifier, rt as ImproveCost, st as ImproveMethodFactory, t as AgentImprovementActivationReconciliation, tt as ImproveCodeResult, ut as ImproveMethodResult, vt as ImproveRuntimeCodeGeneratorOptions, wt as ImproveSearchResult, xt as ImproveSearchIdentity, yt as ImproveScenarioPartitions, z as searchMethod, zt as routerLane } from "./activation-
|
|
1
|
+
import { $y as SanitizedKnowledgeRequirement, AS as AgentEvalError, By as OtelExportConfig, C as RuntimeFailureCause, Cw as RuntimeRunRow, Da as ExecutorFactory, E as Budget, FS as NotFoundError, Gy as createOtelExporter, Hy as OtelExporter, IS as ValidationError, Jy as RuntimeStreamEventCollector, Ky as loopEventToOtelSpan, Lh as ExecutorConfig, MS as BackendTransportError, NS as ConfigError, OS as Redactor, PS as JudgeError, Qy as SanitizedKnowledgeReadinessReport, S as RuntimeStreamEvent, Sw as RuntimeRunPersistenceAdapter, T as RuntimeFailureOwner, Tm as SupervisorProfile, Tw as startRuntimeRun, Uy as OtelSpan, Vy as OtelExportStats, Wy as buildLoopOtelSpans, Xf as IsolatedCheckResult, Xy as RuntimeStreamEventSummary, Yy as RuntimeStreamEventSink, Zy as RuntimeTelemetryOptions, _ as RunAgentTaskOptions, _f as SuperviseOptions, a as AgentKnowledgeProvider, b as RuntimeSession, bw as RuntimeRunHandle, c as AgentTaskContext, d as AgentTaskStatus, eb as createRuntimeEventCollector, g as OpenAIChatToolChoice, h as OpenAIChatTool, i as AgentExecutionBackend, jS as AgentEvalErrorCode, l as AgentTaskRunResult, m as OpenAIChatResponseFormat, n as AgentBackendContext, nb as sanitizeKnowledgeReadinessReport, o as AgentRuntimeEvent, oi as DeepReadonly, p as KnowledgeReadinessDecision, qf as IsolatedCheckBoxEvidence, qy as RuntimeEventCollector, r as AgentBackendInput, s as AgentRuntimeEventSink, si as ReadonlyAgentProfile, t as AgentAdapter, tb as createRuntimeStreamEventCollector, u as AgentTaskSpec, v as RunAgentTaskStreamOptions, vw as RuntimeRunCompleteInput, w as RuntimeFailureCode, wa as SupervisedResult, ww as RuntimeRunStatus, x as RuntimeSessionStore, xw as RuntimeRunOptions, y as RuntimeCanonicalStreamEvent, yw as RuntimeRunCost, zy as OtelAttribute } from "./types-YXZL7Wxi.js";
|
|
2
|
+
import { $ as ImproveCodeBaseOptions, At as SearchPromotion, B as DecideSearchImprovementOptions, Bt as sharedBoxLane, Ct as ImproveSearchOptions, Dt as ImprovementCodeCandidate, Et as ImproveSurface, Ft as SearchLaneOptions, G as ImproveTrainingOptions, Gt as AgenticGeneratorShotExecution, H as decideSearchImprovement, Ht as AgenticGeneratorExecutorForWorktree, It as SearchTraceOptions, J as ProfileTrainerRequest, Jt as VerifyResult, K as ImproveTrainingResult, Kt as AgenticGeneratorShotReceipt, L as improve, Lt as SharedBoxSearchLane, Mt as SearchEnvironmentFault, Nt as SearchLane, Ot as ImprovementProfileCandidate, Pt as SearchLaneKind, Q as ImproveCandidateValidator, R as SearchMethodOptions, Rt as dedicatedLane, St as ImproveSearchMethod, Tt as ImproveSkillsOptions, U as CheckpointServingPort, Ut as AgenticGeneratorOptions, V as SearchImprovementDecision, Vt as subscriptionLane, W as ControlledTrainingCommand, Wt as AgenticGeneratorShotDisposition, X as createCommandProfileTrainer, Xt as commandVerifier, Y as TrainingBoundaryResult, Yt as agenticGenerator, Z as ImproveCandidateValidationInput, Zt as CandidateGenerator, at as ImproveLineage, bt as ImproveSearchAgent, ct as ImproveMethodLineage, dt as ImproveMethodSource, et as ImproveCodeOptions, ft as ImproveOptimizationRunOptions, gt as ImproveProfileSurface, ht as ImproveProfileComponents, i as AgentImprovementActivationTransition, it as ImproveCustomCodeGeneratorOptions, jt as SearchCellContext, kt as SearchDispatchContext, lt as ImproveMethodOptions, mt as ImproveProfileAgent, n as AgentImprovementActivationResultStore, nt as ImproveCodeRunOptions, ot as ImproveMethodContext, q as ProfileTrainer, qt as Verifier, rt as ImproveCost, st as ImproveMethodFactory, t as AgentImprovementActivationReconciliation, tt as ImproveCodeResult, ut as ImproveMethodResult, vt as ImproveRuntimeCodeGeneratorOptions, wt as ImproveSearchResult, xt as ImproveSearchIdentity, yt as ImproveScenarioPartitions, z as searchMethod, zt as routerLane } from "./activation-B0arteLE.js";
|
|
3
3
|
import { i as SurfaceImprovementEdit } from "./improvement-adapter-D5GRU1eY.js";
|
|
4
4
|
import { a as ImprovementProposalSource } from "./types-qsqfyQoY.js";
|
|
5
5
|
import { T as AgentCandidateOutputArtifactPort } from "./workspace-archive-DS9E9tUr.js";
|
|
6
|
-
import { i as auditLoopRunner, r as DelegatedLoopRunner } from "./loop-runner-
|
|
6
|
+
import { i as auditLoopRunner, r as DelegatedLoopRunner } from "./loop-runner-BFC781pC.js";
|
|
7
7
|
import { a as RuntimeHookContext, c as RuntimeHookPhase, d as composeRuntimeHooks, f as defineRuntimeHooks, i as RuntimeExecutionAdmittedPayload, l as RuntimeHookTarget, o as RuntimeHookErrorContext, s as RuntimeHookEvent, u as RuntimeHooks } from "./runtime-hooks-DPghSHV7.js";
|
|
8
8
|
import { toW3CSpanId as padSpanId, toW3CTraceId as padTraceId } from "@tangle-network/agent-trace-contract";
|
|
9
9
|
import { AgentCandidateBundle, AgentCandidateCapturedArtifact, AgentCandidateKnowledge, AgentProfile, Sha256Digest } from "@tangle-network/agent-interface";
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { B as InMemoryRuntimeSessionStore, C as optimizerMethod, H as nowIso, I as streamAgentTurn, L as createIterableBackend, R as createSandboxPromptBackend, U as startOrResumeRuntimeSession, V as newRuntimeSession, W as touchSession, z as normalizeBackendStreamEvent } from "./structural-rollout-
|
|
1
|
+
import { B as InMemoryRuntimeSessionStore, C as optimizerMethod, H as nowIso, I as streamAgentTurn, L as createIterableBackend, R as createSandboxPromptBackend, U as startOrResumeRuntimeSession, V as newRuntimeSession, W as touchSession, z as normalizeBackendStreamEvent } from "./structural-rollout-BVuf5hFl.js";
|
|
2
2
|
import { a as JudgeError, f as RuntimeRunStateError, i as ConfigError, m as ValidationError, o as NotFoundError, r as BackendTransportError, t as AgentEvalError } from "./errors-DG8yufqX.js";
|
|
3
|
-
import { Zn as createOtelExporter, _i as
|
|
3
|
+
import { Mi as providerMessageText, Zn as createOtelExporter, _i as executableAgentProfileSnapshot, er as loopEventToOtelSpan, ir as sanitizeRuntimeStreamEvent, nr as createRuntimeStreamEventCollector, qn as buildLoopOtelSpans, rr as sanitizeKnowledgeReadinessReport, tr as createRuntimeEventCollector } from "./supervisor-accounting-DlDUl58C.js";
|
|
4
4
|
import { v as sleep } from "./util-qsH5cC9S.js";
|
|
5
|
-
import { c as assertNoCallerArtifactDescriptor, d as agenticGenerator, f as commandVerifier, h as isUsageAmount, i as assertCandidateValidator, l as withMethodRuntimeControls, m as createRuntimeUsageTotals, n as createCommandProfileTrainer, o as parseExecutionRef, p as addRuntimeUsage, r as searchMethod, s as privateValuePaths, t as improve } from "./improve-
|
|
5
|
+
import { c as assertNoCallerArtifactDescriptor, d as agenticGenerator, f as commandVerifier, h as isUsageAmount, i as assertCandidateValidator, l as withMethodRuntimeControls, m as createRuntimeUsageTotals, n as createCommandProfileTrainer, o as parseExecutionRef, p as addRuntimeUsage, r as searchMethod, s as privateValuePaths, t as improve } from "./improve-BLFqeD3X.js";
|
|
6
6
|
import { _ as embeddedCandidateArtifact, a as captureMaterializedWorkspace, m as canonicalCandidateDigest$1, p as canonicalCandidateBytes$1, t as persistCandidateOutputArtifact, v as immutableCandidateValue, y as omitTopLevelDigest } from "./output-artifacts-AqkZ8lO2.js";
|
|
7
7
|
import { m as resolveRedactor, p as defaultRedactorIdentityMaterial } from "./snapshot-BKLziJ5K.js";
|
|
8
|
-
import { n as createAgentImprovementActivationResult } from "./activation-
|
|
8
|
+
import { n as createAgentImprovementActivationResult } from "./activation-5TrUzeFd.js";
|
|
9
9
|
import { t as sealAgentCandidateBundle } from "./bundle-9NLb1WO3.js";
|
|
10
10
|
import { m as captureAgentCandidateWorkspaceFiles } from "./workspace-streams-C7PGLAUd.js";
|
|
11
11
|
import { t as assertExecutableAgentProfile } from "./model-policy-DFuhCC0-.js";
|
|
12
|
-
import { t as supervise } from "./supervise-
|
|
13
|
-
import { n as auditLoopRunner } from "./loop-runner-
|
|
14
|
-
import { l as sharedBoxLane, o as routerLane, r as dedicatedLane, t as SearchEnvironmentFault, u as subscriptionLane, y as decideSearchImprovement } from "./search-executor-
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { a as isolatedCheckBoxEvidenceSchema, o as isolatedCheckResultSchema } from "./graph
|
|
12
|
+
import { t as supervise } from "./supervise-Ci8wiyla.js";
|
|
13
|
+
import { n as auditLoopRunner } from "./loop-runner-CITvo-q1.js";
|
|
14
|
+
import { l as sharedBoxLane, o as routerLane, r as dedicatedLane, t as SearchEnvironmentFault, u as subscriptionLane, y as decideSearchImprovement } from "./search-executor-BHfb4p6C.js";
|
|
15
|
+
import { dt as priceTokens, ft as ROUTER_PRICE_SOURCE } from "./supervisor-KcnH2hC4.js";
|
|
16
|
+
import { i as runtimeFailureCause } from "./tool-server-n4XYpCok.js";
|
|
17
|
+
import { a as isolatedCheckBoxEvidenceSchema, o as isolatedCheckResultSchema } from "./graph-DHNPE7kw.js";
|
|
18
18
|
import { n as defineRuntimeHooks, t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
|
|
19
19
|
import { toW3CSpanId as padSpanId, toW3CTraceId as padTraceId } from "@tangle-network/agent-trace-contract";
|
|
20
20
|
import { agentCandidateKnowledgeSchema, agentProfileSchema, canonicalAgentProfileDigest, sha256DigestSchema } from "@tangle-network/agent-interface";
|
package/dist/intelligence.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OS as Redactor, S as RuntimeStreamEvent, Vy as OtelExportStats, Zy as RuntimeTelemetryOptions, cw as LoopTraceEvent, hg as AgentEnvironmentProviderRegistry, kS as defaultRedactor, mg as AgentEnvironmentProviderRef, si as ReadonlyAgentProfile } from "./types-
|
|
1
|
+
import { OS as Redactor, S as RuntimeStreamEvent, Vy as OtelExportStats, Zy as RuntimeTelemetryOptions, cw as LoopTraceEvent, hg as AgentEnvironmentProviderRegistry, kS as defaultRedactor, mg as AgentEnvironmentProviderRef, si as ReadonlyAgentProfile } from "./types-YXZL7Wxi.js";
|
|
2
2
|
import { b as AgentCandidateExecutionClaimStore, f as PrepareAgentCandidateExecutionOptions, i as CreateProtectedAgentCandidateModelPortOptions, m as ExecutePreparedAgentCandidateOptions, u as parseAgentCandidateProfileActivation } from "./protected-model-port-uN4M48vT.js";
|
|
3
|
-
import { A as AgentProfileMeasuredSurface, C as verifyAgentImprovementProposal, Ct as ImproveSearchOptions, D as AgentImprovementActivationTargetIdentity, E as AGENT_PROFILE_MEASURED_SURFACES, F as isAgentImprovementProfileSurface, I as isAgentProfileMeasuredSurface, M as agentImprovementProfileSurfaceDigest, N as agentImprovementProfileSurfaceInput, O as AgentImprovementProfileSurface, P as agentImprovementTargetProfileDiffs, S as verifyAgentImprovementActivationResult, T as AGENT_IMPROVEMENT_PROFILE_SURFACES, _ as createAgentImprovementActivationResult, _t as ImproveResult, a as AgentImprovementActivationTransitionInput, b as reviewAgentImprovementProposal, c as CreateAgentImprovementActivationOptions, d as ExecuteAgentImprovementActivationInput, f as ExecuteAgentImprovementActivationOptions, g as createAgentImprovementActivation, h as SealedCandidateActivationTransitionInput, j as agentImprovementProfileDiffs, k as AgentImprovementTargetProfileDiffOptions, l as CreateAgentImprovementActivationResultOptions, lt as ImproveMethodOptions, m as ReviewAgentImprovementInput, o as AgentProfileImprovementActivationOperation, p as ProfileImprovementActivationTransitionInput, pt as ImproveOptions, r as AgentImprovementActivationTargetPlan, s as AgentProfileImprovementActivationTargetPlan, u as CreateAgentImprovementProposalOptions, ut as ImproveMethodResult, v as createAgentImprovementProposal, w as verifyAgentImprovementReview, wt as ImproveSearchResult, x as verifyAgentImprovementActivation, y as executeAgentImprovementActivation, yt as ImproveScenarioPartitions } from "./activation-
|
|
3
|
+
import { A as AgentProfileMeasuredSurface, C as verifyAgentImprovementProposal, Ct as ImproveSearchOptions, D as AgentImprovementActivationTargetIdentity, E as AGENT_PROFILE_MEASURED_SURFACES, F as isAgentImprovementProfileSurface, I as isAgentProfileMeasuredSurface, M as agentImprovementProfileSurfaceDigest, N as agentImprovementProfileSurfaceInput, O as AgentImprovementProfileSurface, P as agentImprovementTargetProfileDiffs, S as verifyAgentImprovementActivationResult, T as AGENT_IMPROVEMENT_PROFILE_SURFACES, _ as createAgentImprovementActivationResult, _t as ImproveResult, a as AgentImprovementActivationTransitionInput, b as reviewAgentImprovementProposal, c as CreateAgentImprovementActivationOptions, d as ExecuteAgentImprovementActivationInput, f as ExecuteAgentImprovementActivationOptions, g as createAgentImprovementActivation, h as SealedCandidateActivationTransitionInput, j as agentImprovementProfileDiffs, k as AgentImprovementTargetProfileDiffOptions, l as CreateAgentImprovementActivationResultOptions, lt as ImproveMethodOptions, m as ReviewAgentImprovementInput, o as AgentProfileImprovementActivationOperation, p as ProfileImprovementActivationTransitionInput, pt as ImproveOptions, r as AgentImprovementActivationTargetPlan, s as AgentProfileImprovementActivationTargetPlan, u as CreateAgentImprovementProposalOptions, ut as ImproveMethodResult, v as createAgentImprovementProposal, w as verifyAgentImprovementReview, wt as ImproveSearchResult, x as verifyAgentImprovementActivation, y as executeAgentImprovementActivation, yt as ImproveScenarioPartitions } from "./activation-B0arteLE.js";
|
|
4
4
|
import { d as RunAnalystLoopResult, u as RunAnalystLoopOpts } from "./types-qsqfyQoY.js";
|
|
5
5
|
import { P as AgentCandidateTaskExecution, T as AgentCandidateOutputArtifactPort, d as AgentCandidateExecutionPorts, l as AgentCandidateBenchmarkGraderPort, m as AgentCandidateExecutorPort } from "./workspace-archive-DS9E9tUr.js";
|
|
6
6
|
import { AgentCandidateBenchmarkCellRef, AgentCandidateEvaluationPolicy, AgentCandidateExperiment, AgentCandidateExperimentMaterial, AgentCandidateExperimentMeasurement, AgentCandidateLineage, AgentImprovementActivation, AgentImprovementActivationIntent, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementActivationTargetState, AgentImprovementActivationTargetTransition, AgentImprovementEvaluation, AgentImprovementMeasuredComparison, AgentImprovementProposal, AgentImprovementProposal as AgentImprovementProposal$1, AgentImprovementReview, AgentImprovementReviewDecision, AgentImprovementSource, AgentProfile, AgentProfileDiff, AgentProfileImprovementExecutionRef, AgentProfileImprovementExperiment, AgentProfileImprovementMeasuredComparison, AgentProfileImprovementMeasurement, AgentProfileImprovementModelBinding, AgentProfileImprovementRecordedRunReceipt, AgentProfileImprovementRunReceipt, AgentProfileImprovementTaskMaterial, CandidateExecutionEvidence, CandidateExecutionEvidence as CandidateExecutionEvidence$1, Sha256Digest } from "@tangle-network/agent-interface";
|
package/dist/intelligence.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Qn as flatOtelSpan, Yn as buildRuntimeEventOtelSpans, Yr as authoredAgentIdentity, Zn as createOtelExporter, qn as buildLoopOtelSpans } from "./supervisor-accounting-DlDUl58C.js";
|
|
2
2
|
import { f as defaultRedactor, m as resolveRedactor } from "./snapshot-BKLziJ5K.js";
|
|
3
|
-
import { a as assertProfileTrainingIsHeldOut, h as isUsageAmount, m as createRuntimeUsageTotals, p as addRuntimeUsage, t as improve, u as rethrowAfterCleanup } from "./improve-
|
|
3
|
+
import { a as assertProfileTrainingIsHeldOut, h as isUsageAmount, m as createRuntimeUsageTotals, p as addRuntimeUsage, t as improve, u as rethrowAfterCleanup } from "./improve-BLFqeD3X.js";
|
|
4
4
|
import { _ as parseAgentCandidateProfileActivation, a as applyExactAgentProfileDiff, d as createAgentCandidateProfileActivation, g as omitUndefinedObjectFields, m as materializeAgentCandidateProfilePlan, o as assertCandidateProfileBinding, v as parseExactAgentProfile } from "./profile-Cxl_Ajl2.js";
|
|
5
|
-
import { _ as agentImprovementTargetProfileDiffs, a as reviewAgentImprovementProposal, b as isAgentProfileMeasuredSurface, c as verifyAgentImprovementProposal, d as attachOptimizationActivationReceipt, f as createOptimizationActivationReceipt, g as agentImprovementProfileSurfaceInput, h as agentImprovementProfileSurfaceDigest, i as executeAgentImprovementActivation, l as verifyAgentImprovementReview, m as agentImprovementProfileDiffs, n as createAgentImprovementActivationResult, o as verifyAgentImprovementActivation, p as optimizationActivationReceiptFromMetadata, r as createAgentImprovementProposal, s as verifyAgentImprovementActivationResult, t as createAgentImprovementActivation, u as assertNoCallerOptimizationReceipt, v as assertProfileImprovementTargetsShareIdentity, y as isAgentImprovementProfileSurface } from "./activation-
|
|
5
|
+
import { _ as agentImprovementTargetProfileDiffs, a as reviewAgentImprovementProposal, b as isAgentProfileMeasuredSurface, c as verifyAgentImprovementProposal, d as attachOptimizationActivationReceipt, f as createOptimizationActivationReceipt, g as agentImprovementProfileSurfaceInput, h as agentImprovementProfileSurfaceDigest, i as executeAgentImprovementActivation, l as verifyAgentImprovementReview, m as agentImprovementProfileDiffs, n as createAgentImprovementActivationResult, o as verifyAgentImprovementActivation, p as optimizationActivationReceiptFromMetadata, r as createAgentImprovementProposal, s as verifyAgentImprovementActivationResult, t as createAgentImprovementActivation, u as assertNoCallerOptimizationReceipt, v as assertProfileImprovementTargetsShareIdentity, y as isAgentImprovementProfileSurface } from "./activation-5TrUzeFd.js";
|
|
6
6
|
import { h as canonicalCandidateDocument, m as canonicalCandidateDigest$1, p as canonicalCandidateBytes$1, v as immutableCandidateValue, x as verifyCanonicalCandidateDocument, y as omitTopLevelDigest } from "./output-artifacts-AqkZ8lO2.js";
|
|
7
7
|
import { C as verifiedResourceTextByDigest, S as AGENT_CANDIDATE_EXECUTION_SUPPORT, n as executePreparedAgentCandidate, t as prepareAgentCandidateExecution, w as verifyAgentCandidateBundle, x as exactProcessProviderAsCandidateExecutor, y as createProtectedAgentCandidateModelPort } from "./prepare-DT-ibRsm.js";
|
|
8
|
-
import { W as resolveAgentEnvironmentProvider } from "./supervisor-
|
|
8
|
+
import { W as resolveAgentEnvironmentProvider } from "./supervisor-KcnH2hC4.js";
|
|
9
9
|
import { t as runAnalystLoop } from "./analyst-loop-BZvXCDKy.js";
|
|
10
10
|
import { ATTR, agentIdentityAttributes } from "@tangle-network/agent-trace-contract";
|
|
11
11
|
import { AGENT_IMPROVEMENT_SOURCE_METADATA_KEY, agentCandidateMaterializationReceiptSchema, agentCandidateRunReceiptSchema, agentImprovementSourceMetadata, agentImprovementSourceSchema, agentProfileImprovementArmSchema, agentProfileImprovementExpectedModel, agentProfileImprovementModelBindingSchema, agentProfileImprovementRunReceiptSchema, applyAgentProfileDiff, candidateExecutionEvidenceSchema, numbersApproximatelyEqual } from "@tangle-network/agent-interface";
|
|
@@ -1,8 +1,126 @@
|
|
|
1
|
-
import { f as sha256 } from "./jsonl-file-B8xfYz9M.js";
|
|
2
1
|
import { m as ValidationError } from "./errors-DG8yufqX.js";
|
|
3
|
-
import { u as writeAtomicDurableFile } from "./durable-file-pao7FijS.js";
|
|
2
|
+
import { g as routesToDurableWriter, m as durableCallAsync, u as writeAtomicDurableFile, x as fenceRunWrite, y as runFencedAsync } from "./durable-file-pao7FijS.js";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { closeSync, fstatSync, fsync, fsyncSync, ftruncateSync, openSync, readSync, statSync, writeSync } from "node:fs";
|
|
4
5
|
import { join } from "node:path";
|
|
5
6
|
import { mkdir } from "node:fs/promises";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
// src/runtime/supervise/abortable.ts
|
|
9
|
+
/** Provenance of an explicit cancellation, preserved through every abort link. */
|
|
10
|
+
var RunCancellationReason = class extends Error {
|
|
11
|
+
source;
|
|
12
|
+
operationId;
|
|
13
|
+
operator;
|
|
14
|
+
constructor(source, reason, operationId, operator) {
|
|
15
|
+
super(reason);
|
|
16
|
+
this.source = source;
|
|
17
|
+
this.operationId = operationId;
|
|
18
|
+
this.operator = operator;
|
|
19
|
+
this.name = "RunCancellationReason";
|
|
20
|
+
}
|
|
21
|
+
toString() {
|
|
22
|
+
return this.message;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/** The signal's explicit reason, or the caller's fallback when none was supplied. */
|
|
26
|
+
function abortReason(signal, fallback) {
|
|
27
|
+
const reason = signal.reason;
|
|
28
|
+
if (reason instanceof RunCancellationReason) return reason;
|
|
29
|
+
if (typeof reason === "string" && reason.length > 0) return reason;
|
|
30
|
+
if (reason instanceof Error && reason.name !== "AbortError" && reason.message.length > 0) return reason.message;
|
|
31
|
+
return fallback;
|
|
32
|
+
}
|
|
33
|
+
/** An `AbortError` carrying the signal's own string reason, or `fallback` when it states none. */
|
|
34
|
+
function signalAbortError(signal, fallback) {
|
|
35
|
+
const reason = abortReason(signal, fallback);
|
|
36
|
+
const error = new Error(reason instanceof Error ? reason.message : typeof reason === "string" && reason.length > 0 ? reason : fallback);
|
|
37
|
+
error.name = "AbortError";
|
|
38
|
+
return error;
|
|
39
|
+
}
|
|
40
|
+
/** A parent abort stops the call at once. The timeout still bounds a parent that stays open. */
|
|
41
|
+
function deadlineSignal(parent, ms) {
|
|
42
|
+
const timeout = AbortSignal.timeout(ms);
|
|
43
|
+
return parent === void 0 ? timeout : AbortSignal.any([parent, timeout]);
|
|
44
|
+
}
|
|
45
|
+
/** Cascade source aborts and preserve their reason; release removes the source listeners. */
|
|
46
|
+
function linkAbort(...sources) {
|
|
47
|
+
const controller = new AbortController();
|
|
48
|
+
const listeners = [];
|
|
49
|
+
const release = () => {
|
|
50
|
+
for (const { source, onAbort } of listeners) source.removeEventListener("abort", onAbort);
|
|
51
|
+
listeners.length = 0;
|
|
52
|
+
};
|
|
53
|
+
const abort = (reason) => {
|
|
54
|
+
release();
|
|
55
|
+
controller.abort(reason);
|
|
56
|
+
};
|
|
57
|
+
const alreadyAborted = sources.find((source) => source.aborted);
|
|
58
|
+
if (alreadyAborted !== void 0) {
|
|
59
|
+
controller.abort(abortReason(alreadyAborted, "aborted by parent scope"));
|
|
60
|
+
return {
|
|
61
|
+
signal: controller.signal,
|
|
62
|
+
abort,
|
|
63
|
+
release
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
for (const source of sources) {
|
|
67
|
+
const onAbort = () => abort(abortReason(source, "aborted by parent scope"));
|
|
68
|
+
listeners.push({
|
|
69
|
+
source,
|
|
70
|
+
onAbort
|
|
71
|
+
});
|
|
72
|
+
source.addEventListener("abort", onAbort, { once: true });
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
signal: controller.signal,
|
|
76
|
+
abort,
|
|
77
|
+
release
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Settle work against cancellation once, observing the losing promise.
|
|
81
|
+
* Defer abort one microtask so already-completed work wins. An action's own abort listener
|
|
82
|
+
* cannot win this race: this function subscribes before invoking it.
|
|
83
|
+
*/
|
|
84
|
+
async function runAbortable(act, signal, fallback) {
|
|
85
|
+
const aborted = () => typeof fallback === "string" ? signalAbortError(signal, fallback) : fallback();
|
|
86
|
+
if (signal.aborted) throw aborted();
|
|
87
|
+
return await new Promise((resolve, reject) => {
|
|
88
|
+
let settled = false;
|
|
89
|
+
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
90
|
+
const onAbort = () => {
|
|
91
|
+
queueMicrotask(() => {
|
|
92
|
+
if (settled) return;
|
|
93
|
+
settled = true;
|
|
94
|
+
cleanup();
|
|
95
|
+
reject(aborted());
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
99
|
+
let work;
|
|
100
|
+
try {
|
|
101
|
+
work = Promise.resolve(act());
|
|
102
|
+
} catch (error) {
|
|
103
|
+
cleanup();
|
|
104
|
+
reject(error);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
work.then((value) => {
|
|
108
|
+
if (settled) return;
|
|
109
|
+
settled = true;
|
|
110
|
+
cleanup();
|
|
111
|
+
resolve(value);
|
|
112
|
+
}, (error) => {
|
|
113
|
+
if (settled) return;
|
|
114
|
+
settled = true;
|
|
115
|
+
cleanup();
|
|
116
|
+
reject(error);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// src/content-digest.ts
|
|
121
|
+
function sha256(value) {
|
|
122
|
+
return createHash("sha256").update(value).digest("hex");
|
|
123
|
+
}
|
|
6
124
|
// src/finite-number.ts
|
|
7
125
|
function isFiniteNumber(value) {
|
|
8
126
|
return typeof value === "number" && Number.isFinite(value);
|
|
@@ -446,6 +564,280 @@ function createContinuationKeeper(input) {
|
|
|
446
564
|
}
|
|
447
565
|
};
|
|
448
566
|
}
|
|
449
|
-
|
|
567
|
+
// src/durable/jsonl-append.ts
|
|
568
|
+
async function appendCommittedJsonLine(path, record, options = {}) {
|
|
569
|
+
const encoded = JSON.stringify(record);
|
|
570
|
+
if (encoded === void 0) throw new TypeError("JSONL records must be JSON serializable");
|
|
571
|
+
const stamp = options.journalStamp === true;
|
|
572
|
+
if (routesToDurableWriter()) return durableCallAsync({
|
|
573
|
+
name: "appendCommittedLine",
|
|
574
|
+
args: [
|
|
575
|
+
path,
|
|
576
|
+
encoded,
|
|
577
|
+
stamp
|
|
578
|
+
]
|
|
579
|
+
});
|
|
580
|
+
const written = writeCommittedLine(path, encoded, stamp);
|
|
581
|
+
try {
|
|
582
|
+
await promisify(fsync)(written.fd);
|
|
583
|
+
return written.stamp;
|
|
584
|
+
} finally {
|
|
585
|
+
closeSync(written.fd);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
/** The committed append the durable writer runs: the fenced write, then its fsync on that thread. @internal */
|
|
589
|
+
function appendCommittedLine(path, encoded, journalStamp) {
|
|
590
|
+
const written = writeCommittedLine(path, encoded, journalStamp);
|
|
591
|
+
try {
|
|
592
|
+
fsyncSync(written.fd);
|
|
593
|
+
return written.stamp;
|
|
594
|
+
} finally {
|
|
595
|
+
closeSync(written.fd);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
/** Under one fence: recover the tail, write the whole line, and stamp the file when asked. */
|
|
599
|
+
function writeCommittedLine(path, encoded, journalStamp) {
|
|
600
|
+
let fd;
|
|
601
|
+
try {
|
|
602
|
+
return fenceRunWrite(() => {
|
|
603
|
+
const bytes = Buffer.from(`${prepareJsonlTail(path) ? "\n" : ""}${encoded}\n`);
|
|
604
|
+
fd = openSync(path, "a");
|
|
605
|
+
let offset = 0;
|
|
606
|
+
while (offset < bytes.length) {
|
|
607
|
+
const written = writeSync(fd, bytes, offset, bytes.length - offset);
|
|
608
|
+
if (written <= 0) throw new Error(`append-only file write made no progress at byte ${offset}`);
|
|
609
|
+
offset += written;
|
|
610
|
+
}
|
|
611
|
+
if (!journalStamp) return { fd };
|
|
612
|
+
const stamp = journalFileStamp(fstatSync(fd, { bigint: true }));
|
|
613
|
+
if (journalFileStamp(statSync(path, { bigint: true })) !== stamp) throw new Error("spawn journal changed while acknowledging its append");
|
|
614
|
+
return {
|
|
615
|
+
fd,
|
|
616
|
+
stamp
|
|
617
|
+
};
|
|
618
|
+
});
|
|
619
|
+
} catch (error) {
|
|
620
|
+
if (fd !== void 0) closeSync(fd);
|
|
621
|
+
throw error;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
/** Detect replacement, truncation, and same-size edits; this is not a cross-process write lock. @internal */
|
|
625
|
+
function journalFileStamp(stat) {
|
|
626
|
+
return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
|
|
627
|
+
}
|
|
628
|
+
/** Recover only an uncommitted tail. Caller holds the generation fence. @internal */
|
|
629
|
+
function prepareJsonlTail(path) {
|
|
630
|
+
let fd;
|
|
631
|
+
try {
|
|
632
|
+
fd = openSync(path, "r+");
|
|
633
|
+
} catch (error) {
|
|
634
|
+
if (error.code === "ENOENT") return false;
|
|
635
|
+
throw error;
|
|
636
|
+
}
|
|
637
|
+
try {
|
|
638
|
+
const size = fstatSync(fd).size;
|
|
639
|
+
if (size === 0) return false;
|
|
640
|
+
const last = Buffer.allocUnsafe(1);
|
|
641
|
+
readAt(fd, last, size - 1);
|
|
642
|
+
if (last[0] === 10) return false;
|
|
643
|
+
const chunks = [];
|
|
644
|
+
let end = size;
|
|
645
|
+
let tailStart = 0;
|
|
646
|
+
while (end > 0) {
|
|
647
|
+
const start = Math.max(0, end - 65536);
|
|
648
|
+
const chunk = Buffer.allocUnsafe(end - start);
|
|
649
|
+
readAt(fd, chunk, start);
|
|
650
|
+
const newline = chunk.lastIndexOf(10);
|
|
651
|
+
chunks.push(chunk.subarray(newline + 1));
|
|
652
|
+
if (newline >= 0) {
|
|
653
|
+
tailStart = start + newline + 1;
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
end = start;
|
|
657
|
+
}
|
|
658
|
+
try {
|
|
659
|
+
JSON.parse(Buffer.concat(chunks.reverse()).toString("utf8"));
|
|
660
|
+
return true;
|
|
661
|
+
} catch (error) {
|
|
662
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
663
|
+
ftruncateSync(fd, tailStart);
|
|
664
|
+
fsyncSync(fd);
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
} finally {
|
|
668
|
+
closeSync(fd);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
function readAt(fd, buffer, position) {
|
|
672
|
+
let offset = 0;
|
|
673
|
+
while (offset < buffer.length) {
|
|
674
|
+
const read = readSync(fd, buffer, offset, buffer.length - offset, position + offset);
|
|
675
|
+
if (read === 0) throw new Error("journal changed while preparing its append tail");
|
|
676
|
+
offset += read;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
// src/durable/jsonl-file.ts
|
|
680
|
+
/** Parse in-memory evidence with the same commit boundary as streamed journal reads. */
|
|
681
|
+
function parseCommittedJsonLines(text, source) {
|
|
682
|
+
const lines = text.split("\n");
|
|
683
|
+
const records = [];
|
|
684
|
+
for (const [index, line] of lines.entries()) {
|
|
685
|
+
const record = parseRecord(line, source, index + 1, index < lines.length - 1);
|
|
686
|
+
if (record !== void 0) records.push(record.value);
|
|
687
|
+
}
|
|
688
|
+
return records;
|
|
689
|
+
}
|
|
690
|
+
/** Read a fixed file prefix one record at a time, never allocating the whole journal as a string.
|
|
691
|
+
* A reader cannot chase concurrent appends forever. Missing files are empty only when requested;
|
|
692
|
+
* corruption, short reads, and other I/O errors remain failures. Closing the iterator closes the fd. */
|
|
693
|
+
async function* readCommittedJsonLines(path, options = {}) {
|
|
694
|
+
const fs = await import("node:fs/promises");
|
|
695
|
+
let handle;
|
|
696
|
+
try {
|
|
697
|
+
handle = options.handle ?? await fs.open(path, "r");
|
|
698
|
+
} catch (error) {
|
|
699
|
+
if (options.allowMissing && isNoEntError(error)) return;
|
|
700
|
+
throw error;
|
|
701
|
+
}
|
|
702
|
+
try {
|
|
703
|
+
const start = options.start ?? 0;
|
|
704
|
+
const end = options.end ?? (await handle.stat()).size;
|
|
705
|
+
if (end <= start) return;
|
|
706
|
+
const fragments = [];
|
|
707
|
+
let offset = start;
|
|
708
|
+
let lineNumber = 1;
|
|
709
|
+
const parse = (terminated) => {
|
|
710
|
+
const bytes = Buffer.concat(fragments);
|
|
711
|
+
let line;
|
|
712
|
+
try {
|
|
713
|
+
line = options.strictUtf8 ? new TextDecoder("utf-8", { fatal: true }).decode(bytes) : bytes.toString("utf8");
|
|
714
|
+
} catch (cause) {
|
|
715
|
+
if (!terminated || options.invalid === "skip" && cause instanceof TypeError) return void 0;
|
|
716
|
+
throw new Error(`${path}: malformed UTF-8 at line ${lineNumber}`, { cause });
|
|
717
|
+
}
|
|
718
|
+
return parseRecord(line, path, lineNumber++, terminated, options.allowWhitespaceLines, options.invalid);
|
|
719
|
+
};
|
|
720
|
+
let position = start;
|
|
721
|
+
while (position < end) {
|
|
722
|
+
const buffer = Buffer.alloc(Math.min(65536, end - position));
|
|
723
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, position);
|
|
724
|
+
if (bytesRead === 0) throw new Error(`${path}: journal changed while reading its committed prefix`);
|
|
725
|
+
position += bytesRead;
|
|
726
|
+
const bytes = buffer.subarray(0, bytesRead);
|
|
727
|
+
options.onBytes?.(bytes);
|
|
728
|
+
let start = 0;
|
|
729
|
+
for (let end = bytes.indexOf(10); end !== -1; end = bytes.indexOf(10, start)) {
|
|
730
|
+
fragments.push(bytes.subarray(start, end));
|
|
731
|
+
const record = parse(true);
|
|
732
|
+
offset += fragments.reduce((size, part) => size + part.length, 0) + 1;
|
|
733
|
+
fragments.length = 0;
|
|
734
|
+
options.onCommit?.(offset);
|
|
735
|
+
if (record !== void 0) yield record.value;
|
|
736
|
+
start = end + 1;
|
|
737
|
+
}
|
|
738
|
+
if (start < bytes.length) fragments.push(bytes.subarray(start));
|
|
739
|
+
}
|
|
740
|
+
const record = parse(false);
|
|
741
|
+
if (record !== void 0) {
|
|
742
|
+
options.onCommit?.(end);
|
|
743
|
+
yield record.value;
|
|
744
|
+
}
|
|
745
|
+
} finally {
|
|
746
|
+
if (options.handle === void 0) await handle.close();
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
/** An invalid unterminated tail may be a torn write; other parse failures are not evidence of one. */
|
|
750
|
+
function parseRecord(line, source, lineNumber, terminated, allowWhitespaceLines = false, invalid = "throw") {
|
|
751
|
+
if (line.length === 0 || allowWhitespaceLines && line.trim().length === 0) return void 0;
|
|
752
|
+
try {
|
|
753
|
+
return { value: JSON.parse(line) };
|
|
754
|
+
} catch (cause) {
|
|
755
|
+
if (!(cause instanceof SyntaxError)) throw cause;
|
|
756
|
+
if (!terminated || invalid === "skip") return void 0;
|
|
757
|
+
throw new Error(`${source}: malformed JSONL record at line ${lineNumber}`, { cause });
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
/** Serialize JSONL file updates across processes and aliases using Eval's existing file lock.
|
|
761
|
+
* The caller owns validation and the record format. The lock path names the canonical file,
|
|
762
|
+
* including its first write, so two directory aliases cannot acquire different write heads.
|
|
763
|
+
*
|
|
764
|
+
* The wait bounds one live holder, not the queue. A holder that keeps the lock for the whole
|
|
765
|
+
* bound is stuck and the caller is told; the lock primitive itself takes over a dead holder.
|
|
766
|
+
* Writers that each release are progress, so a caller behind them keeps waiting. A bound on the
|
|
767
|
+
* queue would refuse a caller whenever the writers ahead of it together took that long, which a
|
|
768
|
+
* host with slow disk syncs does to a handful of concurrent writers.
|
|
769
|
+
* @internal
|
|
770
|
+
*/
|
|
771
|
+
async function withJsonlFileLock(path, operation) {
|
|
772
|
+
const fs = await import("node:fs/promises");
|
|
773
|
+
const { dirname } = await import("node:path");
|
|
774
|
+
const { tryAcquireAtomicFileLock } = await import("@tangle-network/agent-eval/ledger-core");
|
|
775
|
+
await fs.mkdir(dirname(path), { recursive: true });
|
|
776
|
+
await (await fs.open(path, "a")).close();
|
|
777
|
+
const canonicalPath = await fs.realpath(path);
|
|
778
|
+
let holder;
|
|
779
|
+
let heldSince = Date.now();
|
|
780
|
+
for (;;) {
|
|
781
|
+
const acquisition = tryAcquireAtomicFileLock({ lockPath: `${canonicalPath}.lock` });
|
|
782
|
+
if (!acquisition.acquired) {
|
|
783
|
+
if (acquisition.reason === "held" && acquisition.holder.nonce !== holder) {
|
|
784
|
+
holder = acquisition.holder.nonce;
|
|
785
|
+
heldSince = Date.now();
|
|
786
|
+
}
|
|
787
|
+
if (Date.now() - heldSince >= 5e3) throw new Error(`journal file lock unavailable after 5000ms: ${canonicalPath}`);
|
|
788
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
789
|
+
continue;
|
|
790
|
+
}
|
|
791
|
+
try {
|
|
792
|
+
return await operation(canonicalPath);
|
|
793
|
+
} finally {
|
|
794
|
+
acquisition.lock.release();
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
/** Read one keyed registry snapshot without an extra whole-file text allocation.
|
|
799
|
+
* Historical registry files allow whitespace-only separators; append journals remain strict.
|
|
800
|
+
* @internal
|
|
801
|
+
*/
|
|
802
|
+
async function readCommittedJsonFile(path) {
|
|
803
|
+
const records = [];
|
|
804
|
+
for await (const record of readCommittedJsonLines(path, {
|
|
805
|
+
allowMissing: true,
|
|
806
|
+
allowWhitespaceLines: true
|
|
807
|
+
})) records.push(record);
|
|
808
|
+
return records;
|
|
809
|
+
}
|
|
810
|
+
/** Replace one keyed row and publish one durable snapshot. The caller holds the file lock.
|
|
811
|
+
* Keep unrelated rows in order and put the replacement last. No revision archive is retained.
|
|
812
|
+
* @internal
|
|
813
|
+
*/
|
|
814
|
+
async function upsertCommittedJsonLine(path, record, key) {
|
|
815
|
+
const encoded = JSON.stringify(record);
|
|
816
|
+
if (encoded === void 0) throw new Error("JSONL records must be JSON serializable");
|
|
817
|
+
const snapshot = JSON.parse(encoded);
|
|
818
|
+
const id = key(snapshot);
|
|
819
|
+
const updated = [];
|
|
820
|
+
for await (const prior of readCommittedJsonLines(path, {
|
|
821
|
+
allowMissing: true,
|
|
822
|
+
allowWhitespaceLines: true
|
|
823
|
+
})) if (key(prior) !== id) updated.push(prior);
|
|
824
|
+
updated.push(snapshot);
|
|
825
|
+
const { writeAtomicDurableFile } = await import("./durable-file-iPCEs_-s.js");
|
|
826
|
+
writeAtomicDurableFile(path, `${updated.map((row) => JSON.stringify(row)).join("\n")}\n`, { preserveMode: true });
|
|
827
|
+
}
|
|
828
|
+
/** Recover a torn tail under the same generation fence as durable publications. @internal */
|
|
829
|
+
async function prepareJsonlAppend(path) {
|
|
830
|
+
return runFencedAsync("prepareJsonlAppend", prepareJsonlTailFenced, path);
|
|
831
|
+
}
|
|
832
|
+
/** The fenced tail recovery the durable writer runs. @internal */
|
|
833
|
+
function prepareJsonlTailFenced(path) {
|
|
834
|
+
return fenceRunWrite(() => prepareJsonlTail(path));
|
|
835
|
+
}
|
|
836
|
+
/** True for a filesystem error meaning "the file is not there yet" — the one condition an
|
|
837
|
+
* append-only reader treats as an empty log rather than a fault. */
|
|
838
|
+
function isNoEntError(error) {
|
|
839
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
840
|
+
}
|
|
841
|
+
export { linkAbort as C, deadlineSignal as S, signalAbortError as T, failedItems as _, readCommittedJsonFile as a, RunCancellationReason as b, withJsonlFileLock as c, journalFileStamp as d, CONTINUATIONS_DIR as f, createContinuationKeeper as g, checkVerdictOf as h, prepareJsonlTailFenced as i, appendCommittedJsonLine as l, bestComposite as m, parseCommittedJsonLines as n, readCommittedJsonLines as o, admitContinuationPolicy as p, prepareJsonlAppend as r, upsertCommittedJsonLine as s, isNoEntError as t, appendCommittedLine as u, isFiniteNumber as v, runAbortable as w, abortReason as x, sha256 as y };
|
|
450
842
|
|
|
451
|
-
//# sourceMappingURL=
|
|
843
|
+
//# sourceMappingURL=jsonl-file-B2ESMrTh.js.map
|