@yielded/agent 0.1.0-beta.174 → 0.1.0-beta.175
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/{Admin-BHmp2V9p.d.mts → Admin-Qa3I1oA5.d.mts} +38 -7
- package/dist/{AgentRuntime-BD3ZHAMq.d.mts → AgentRuntime-CHDyRbSf.d.mts} +3 -3
- package/dist/{AgentRuntime-B6qZlD3f.mjs → AgentRuntime-DaDKMasp.mjs} +123 -114
- package/dist/AgentRuntime-DaDKMasp.mjs.map +1 -0
- package/dist/{Digest-EpeqWEdv.mjs → Digest-C3EODOee.mjs} +2 -2
- package/dist/{Digest-EpeqWEdv.mjs.map → Digest-C3EODOee.mjs.map} +1 -1
- package/dist/{DurableAgentRuntime-CBBjRNJN.mjs → DurableAgentRuntime-CPlw5_7e.mjs} +161 -85
- package/dist/DurableAgentRuntime-CPlw5_7e.mjs.map +1 -0
- package/dist/{EventSource-C9aaJaXT.d.mts → EventSource-BTu68yDW.d.mts} +2 -2
- package/dist/InMemory.d.mts +2 -2
- package/dist/{MessageDelivery-BGDm-c46.d.mts → MessageDelivery-DjAZJ4Fd.d.mts} +4 -4
- package/dist/{MessagingHost-CRUK4JBi.mjs → MessagingHost-CZCyrnvJ.mjs} +27 -26
- package/dist/MessagingHost-CZCyrnvJ.mjs.map +1 -0
- package/dist/{PreparedInputAdmission-BvDqlgiP.d.mts → PreparedInputAdmission-wgY4JMZY.d.mts} +3 -3
- package/dist/{Records-BiuJDWNe.mjs → Records-DzL4Kbtw.mjs} +2 -2
- package/dist/{Records-BiuJDWNe.mjs.map → Records-DzL4Kbtw.mjs.map} +1 -1
- package/dist/{RunContinuation-CTJ1jGrO.d.mts → RunContinuation-3jB5pULC.d.mts} +10 -4
- package/dist/{RunContinuation-4ZATcVLB.mjs → RunContinuation-BiyKJK32.mjs} +74 -40
- package/dist/RunContinuation-BiyKJK32.mjs.map +1 -0
- package/dist/{RunJournal-CNZqA3Ge.mjs → RunJournal-CPMKcfd0.mjs} +84 -79
- package/dist/RunJournal-CPMKcfd0.mjs.map +1 -0
- package/dist/{RunStorage-BHjuuERI.mjs → RunStorage-CzutHJBE.mjs} +3 -2
- package/dist/RunStorage-CzutHJBE.mjs.map +1 -0
- package/dist/{Scheduling-NG8slKdI.mjs → Scheduling-07_dsGED.mjs} +3 -3
- package/dist/{Scheduling-NG8slKdI.mjs.map → Scheduling-07_dsGED.mjs.map} +1 -1
- package/dist/{Subagent-CTIpnzlB.mjs → Subagent-CexndZSp.mjs} +2 -2
- package/dist/{Subagent-CTIpnzlB.mjs.map → Subagent-CexndZSp.mjs.map} +1 -1
- package/dist/{Subagent-DKhZA72u.d.mts → Subagent-xhN_aD1r.d.mts} +3 -3
- package/dist/{Subscription-BNg9VCRl.d.mts → Subscription-DmIHlOJK.d.mts} +2 -2
- package/dist/{SubscriptionInput-BUoXv-_K.d.mts → SubscriptionInput-DgcQhvbe.d.mts} +2 -2
- package/dist/{Thread-dk-QiNml.d.mts → Thread-DzdJAY4J.d.mts} +4 -3
- package/dist/{ThreadHistory-ByxS8HU1.d.mts → ThreadHistory-KPPBJLJb.d.mts} +12 -2
- package/dist/{ThreadImport-CodYoJoa.mjs → ThreadImport-CjlG57vH.mjs} +8 -8
- package/dist/{ThreadImport-CodYoJoa.mjs.map → ThreadImport-CjlG57vH.mjs.map} +1 -1
- package/dist/{ThreadImport-CMgzttvr.d.mts → ThreadImport-DP-vOk2F.d.mts} +4 -4
- package/dist/{ThreadStore-59uDGXul.mjs → ThreadStore-EuUilthA.mjs} +5 -7
- package/dist/ThreadStore-EuUilthA.mjs.map +1 -0
- package/dist/{ThreadTransfer-3jigUl3g.mjs → ThreadTransfer-DB_zsrtJ.mjs} +4 -4
- package/dist/{ThreadTransfer-3jigUl3g.mjs.map → ThreadTransfer-DB_zsrtJ.mjs.map} +1 -1
- package/dist/{WorkerAdmission-DDYJdOsU.mjs → WorkerAdmission-eBeXt_mu.mjs} +5 -5
- package/dist/{WorkerAdmission-DDYJdOsU.mjs.map → WorkerAdmission-eBeXt_mu.mjs.map} +1 -1
- package/dist/{agent-registration-DRbyhAu-.mjs → agent-registration-a6QYaG3h.mjs} +4 -4
- package/dist/{agent-registration-DRbyhAu-.mjs.map → agent-registration-a6QYaG3h.mjs.map} +1 -1
- package/dist/capabilities/Messaging.mjs +1 -1
- package/dist/capabilities/ModelContext.d.mts +1 -1
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/Subagent.d.mts +1 -1
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/core/Thread.d.mts +2 -2
- package/dist/core/Thread.mjs +5 -3
- package/dist/core/Thread.mjs.map +1 -1
- package/dist/durable/ActivityStore.mjs +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/Admin.mjs +1 -1
- package/dist/durable/AgentRegistration.d.mts +1 -1
- package/dist/durable/AgentRegistration.mjs +1 -1
- package/dist/durable/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +1 -1
- package/dist/durable/CommittedActivity.mjs +3 -3
- package/dist/durable/Digest.mjs +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +2 -2
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/EventSource.mjs +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/LifecyclePublication.d.mts +1 -1
- package/dist/durable/LifecyclePublication.mjs +2 -2
- package/dist/durable/MessageDelivery.d.mts +1 -1
- package/dist/durable/MessageDelivery.mjs +2 -2
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +40 -40
- package/dist/durable/MessageDeliveryStoreConformance.mjs +2 -2
- package/dist/durable/PersistentHistory.d.mts +2 -2
- package/dist/durable/PersistentHistory.mjs +4 -4
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/RecordFormat.mjs +1 -1
- package/dist/durable/Records.mjs +1 -1
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/Recovery.mjs +1 -1
- package/dist/durable/RunContinuation.d.mts +2 -2
- package/dist/durable/RunContinuation.mjs +3 -3
- package/dist/durable/RunJournal.d.mts +2 -2
- package/dist/durable/RunJournal.mjs +2 -2
- package/dist/durable/RunStorage.d.mts +1 -1
- package/dist/durable/RunStorage.mjs +1 -1
- package/dist/durable/Schedule.mjs +1 -1
- package/dist/durable/ScheduleStoreConformance.mjs +1 -1
- package/dist/durable/ScheduleTransition.mjs +1 -1
- package/dist/durable/Scheduling.d.mts +1 -1
- package/dist/durable/Scheduling.mjs +1 -1
- package/dist/durable/SettlementPublisher.d.mts +1 -1
- package/dist/durable/SettlementPublisher.mjs +3 -3
- package/dist/durable/SqlMemoryStore.mjs +5 -3
- package/dist/durable/SqlMemoryStore.mjs.map +1 -1
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedger.mjs +7 -3
- package/dist/durable/SubmissionLedger.mjs.map +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.mjs +6 -6
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/Subscription.mjs +2 -2
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionInput.mjs +2 -2
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
- package/dist/durable/SubscriptionTools.d.mts +2 -2
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/SubscriptionTransition.mjs +1 -1
- package/dist/durable/Subscriptions.d.mts +5 -5
- package/dist/durable/Subscriptions.mjs +2 -2
- package/dist/durable/ThreadArchiveRange.d.mts +1 -1
- package/dist/durable/ThreadArchiveRange.mjs +1 -1
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistory.mjs +2 -2
- package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
- package/dist/durable/ThreadImport.d.mts +1 -1
- package/dist/durable/ThreadImport.mjs +1 -1
- package/dist/durable/ThreadInvariants.d.mts +3 -3
- package/dist/durable/ThreadInvariants.mjs +4 -4
- package/dist/durable/ThreadProjection.mjs +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadReader.d.mts +1 -1
- package/dist/durable/ThreadReader.mjs +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStore.mjs +2 -2
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.mjs +4 -4
- package/dist/durable/ThreadTransfer.d.mts +1 -1
- package/dist/durable/ThreadTransfer.mjs +1 -1
- package/dist/durable/ThreadWork.d.mts +2 -2
- package/dist/durable/ThreadWork.mjs +12 -6
- package/dist/durable/ThreadWork.mjs.map +1 -1
- package/dist/durable/ToolReconciler.mjs +1 -1
- package/dist/durable/WakeScheduler.mjs +23 -39
- package/dist/durable/WakeScheduler.mjs.map +1 -1
- package/dist/durable/WorkerAdmission.d.mts +1 -1
- package/dist/durable/WorkerAdmission.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +1 -1
- package/dist/engine/AgentRuntime.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/engine/MessagingHost.mjs +1 -1
- package/dist/engine/Output.mjs +1 -1
- package/dist/engine/ThreadHistory.d.mts +1 -1
- package/dist/engine/ThreadHistory.mjs +3 -2
- package/dist/engine/ThreadHistory.mjs.map +1 -1
- package/dist/index.d.mts +12 -12
- package/dist/index.mjs +13 -13
- package/dist/{output-contract-CMIhu4Cw.mjs → output-contract-DCnLYCdp.mjs} +12 -15
- package/dist/{output-contract-CMIhu4Cw.mjs.map → output-contract-DCnLYCdp.mjs.map} +1 -1
- package/dist/{run-context-reader-CC7ZD95F.d.mts → run-context-reader-DVhJZ1Qe.d.mts} +2 -2
- package/package.json +1 -1
- package/src/core/Thread.ts +143 -146
- package/src/durable/DurableAgentRuntime.ts +381 -206
- package/src/durable/RunContinuation.ts +113 -62
- package/src/durable/RunJournal.ts +99 -108
- package/src/durable/RunStorage.ts +7 -0
- package/src/durable/SqlMemoryStore.ts +8 -6
- package/src/durable/SubmissionLedger.ts +7 -0
- package/src/durable/ThreadStore.ts +9 -7
- package/src/durable/ThreadWork.ts +10 -0
- package/src/durable/WakeScheduler.ts +34 -66
- package/src/durable/internal/usage-totals.ts +28 -31
- package/src/engine/MessagingHost.ts +4 -2
- package/src/engine/ThreadHistory.ts +47 -48
- package/src/engine/internal/agent-runtime.ts +234 -202
- package/src/engine/internal/output-contract.ts +15 -15
- package/src/engine/internal/primitive-delta.ts +2 -3
- package/src/engine/internal/tool-telemetry.ts +3 -5
- package/dist/AgentRuntime-B6qZlD3f.mjs.map +0 -1
- package/dist/DurableAgentRuntime-CBBjRNJN.mjs.map +0 -1
- package/dist/MessagingHost-CRUK4JBi.mjs.map +0 -1
- package/dist/RunContinuation-4ZATcVLB.mjs.map +0 -1
- package/dist/RunJournal-CNZqA3Ge.mjs.map +0 -1
- package/dist/RunStorage-BHjuuERI.mjs.map +0 -1
- package/dist/ThreadStore-59uDGXul.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { n as utf8ByteLength } from "./utf8-B5pAmhTo.mjs";
|
|
3
|
-
import { b as Digest, v as DefinitionDigests } from "./Records-
|
|
3
|
+
import { b as Digest, v as DefinitionDigests } from "./Records-DzL4Kbtw.mjs";
|
|
4
4
|
import { Array, Crypto, Effect, Predicate, Result, Schema } from "effect";
|
|
5
5
|
import { Hex } from "effect/encoding";
|
|
6
6
|
//#region src/durable/internal/canonical-json.ts
|
|
@@ -104,4 +104,4 @@ const digestDefinitions = (definitions) => Effect.all({
|
|
|
104
104
|
//#endregion
|
|
105
105
|
export { digestDefinition as a, boundedCanonicalJson as c, digestCanonicalJson as i, canonicalJson$1 as l, Digest_exports as n, digestDefinitions as o, canonicalJson as r, digestJson as s, DigestError as t };
|
|
106
106
|
|
|
107
|
-
//# sourceMappingURL=Digest-
|
|
107
|
+
//# sourceMappingURL=Digest-C3EODOee.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Digest-
|
|
1
|
+
{"version":3,"file":"Digest-C3EODOee.mjs","names":["canonicalJson","stringifyCanonicalJson"],"sources":["../src/durable/internal/canonical-json.ts","../src/durable/Digest.ts"],"sourcesContent":["import { Array, Predicate, Result, Schema } from \"effect\";\n\ninterface JsonLimits {\n readonly depth: number;\n readonly nodes: number;\n readonly collectionLength: number;\n readonly textUnits: number;\n}\n\nexport class CanonicalJsonLimitError extends Schema.TaggedError<CanonicalJsonLimitError>()(\n \"CanonicalJsonLimitError\",\n { message: Schema.String },\n) {}\n\n// Only this codec's private synchronous aborts become typed bounds failures.\nconst boundsFailures = new WeakMap<object, string>();\n\nconst exceeded = (bound: \"text\" | \"traversal\" | \"collection\"): never => {\n const message = `Canonical JSON exceeds its ${bound} bound`;\n // oxlint-disable-next-line effect/no-native-error -- Private synchronous codec abort; the Result boundary translates only errors owned here.\n const error = new RangeError(message);\n\n boundsFailures.set(error, message);\n // oxlint-disable-next-line effect/no-untyped-throw -- Abort synchronous JSON traversal at the first exceeded bound; the Result boundary catches this owned error.\n throw error;\n};\n\n/** Values have already crossed their Schema boundary; visit each serialized occurrence. */\nconst serialize = (value: Schema.Json, limits?: JsonLimits): string => {\n let nodes = 0;\n let textUnits = 0;\n\n const charge = (length: number) => {\n if (limits !== undefined && (textUnits += length) > limits.textUnits) return exceeded(\"text\");\n };\n\n const visit = (value: Schema.Json, depth: number): string => {\n if (limits !== undefined && (depth > limits.depth || ++nodes > limits.nodes))\n return exceeded(\"traversal\");\n if (\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"number\" ||\n typeof value === \"string\"\n ) {\n const encoded = JSON.stringify(value);\n\n charge(encoded.length);\n\n return encoded;\n }\n if (Array.isArray<Schema.Json>(value)) {\n if (limits !== undefined && value.length > limits.collectionLength)\n return exceeded(\"collection\");\n charge(2 + Math.max(0, value.length - 1));\n\n let json = \"[\";\n\n for (let index = 0; index < value.length; index++) {\n if (index > 0) json += \",\";\n json += visit(value[index], depth + 1);\n }\n\n return `${json}]`;\n }\n\n const keys = Object.keys(value).sort();\n\n if (limits !== undefined && keys.length > limits.collectionLength)\n return exceeded(\"collection\");\n charge(2 + Math.max(0, keys.length - 1));\n let json = \"{\";\n\n for (let index = 0; index < keys.length; index++) {\n const key = keys[index];\n const encodedKey = JSON.stringify(key);\n\n charge(encodedKey.length + 1);\n if (index > 0) json += \",\";\n json += `${encodedKey}:${visit(value[key], depth + 1)}`;\n }\n\n return `${json}}`;\n };\n\n return visit(value, 0);\n};\n\nexport const canonicalJson = (value: Schema.Json): string => serialize(value);\n\nexport const boundedCanonicalJson = (\n value: Schema.Json,\n limits: JsonLimits,\n): Result.Result<string, CanonicalJsonLimitError> => {\n try {\n return Result.succeed(serialize(value, limits));\n } catch (cause) {\n const message = Predicate.isObjectKeyword(cause) ? boundsFailures.get(cause) : undefined;\n\n if (message !== undefined) return Result.fail(CanonicalJsonLimitError.make({ message }));\n // oxlint-disable-next-line effect/no-untyped-throw -- Foreign JSON/getter errors retain their identity for the caller's typed capture boundary.\n throw cause;\n }\n};\n","import type { PlatformError } from \"effect\";\nimport { Crypto, Effect, Schema } from \"effect\";\nimport { Hex } from \"effect/encoding\";\n\nimport { canonicalJson as stringifyCanonicalJson } from \"./internal/canonical-json.ts\";\nimport type { DefinitionDigestInput } from \"./Records.ts\";\nimport { DefinitionDigests, Digest } from \"./Records.ts\";\n\n/** Measure persisted text without allocating a UTF-8 copy. */\nexport { utf8ByteLength } from \"../core/internal/utf8.ts\";\n\nexport class DigestError extends Schema.TaggedError<DigestError>()(\"DigestError\", {\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n}) {}\n\nconst utf8 = new TextEncoder();\nconst decodeDigest = Schema.decodeEffect(Digest);\n\n/** Serialize schema-encoded JSON with the canonical digest's locale-independent key order. */\nexport const canonicalJson = (value: Schema.Json): string => stringifyCanonicalJson(value);\n\nconst digestText = Effect.fnUntraced(function* (\n value: string,\n): Effect.fn.Return<Digest, DigestError, Crypto.Crypto> {\n const crypto = yield* Crypto.Crypto;\n\n const bytes = utf8.encode(value);\n\n const digest = yield* crypto\n .digest(\"SHA-256\", bytes)\n .pipe(\n Effect.mapError((error: PlatformError.PlatformError) =>\n DigestError.make({ message: `SHA-256 failed: ${error.message}`, cause: error }),\n ),\n );\n\n return yield* decodeDigest(Hex.encode(digest)).pipe(\n Effect.mapError(() => DigestError.make({ message: \"SHA-256 returned an invalid digest\" })),\n );\n});\n\n/** Digest a JSON value using a stable, locale-independent object-key ordering (UTF-16 code units, RFC 8785 style). */\nexport const digestJson = (value: Schema.Json): Effect.Effect<Digest, DigestError, Crypto.Crypto> =>\n Effect.suspend(() => digestText(canonicalJson(value)));\n\n/** Hash captured canonical JSON directly, sharing its encoding with accounting and storage. */\nexport const digestCanonicalJson = (json: string) => digestText(json);\n\n/** Digest one schema-encoded Agent, Model, or Toolkit definition. */\nexport const digestDefinition = (definition: Schema.Json) => digestJson(definition);\n\n/** Digest all replay-relevant definitions without hiding which authority changed. */\nexport const digestDefinitions = (\n definitions: DefinitionDigestInput,\n): Effect.Effect<DefinitionDigests, DigestError, Crypto.Crypto> =>\n Effect.all({\n agent: digestDefinition(definitions.agent),\n model: digestDefinition(definitions.model),\n tools: digestDefinition(definitions.tools),\n }).pipe(Effect.map((digests) => DefinitionDigests.make(digests)));\n"],"mappings":";;;;;;AASA,IAAa,0BAAb,cAA6C,OAAO,YAAqC,CAAC,CACxF,2BACA,EAAE,SAAS,OAAO,OAAO,CAC3B,CAAC,CAAC,CAAC;AAGH,MAAM,iCAAiB,IAAI,QAAwB;AAEnD,MAAM,YAAY,UAAsD;CACtE,MAAM,UAAU,8BAA8B,MAAM;CAEpD,MAAM,QAAQ,IAAI,WAAW,OAAO;CAEpC,eAAe,IAAI,OAAO,OAAO;CAEjC,MAAM;AACR;;AAGA,MAAM,aAAa,OAAoB,WAAgC;CACrE,IAAI,QAAQ;CACZ,IAAI,YAAY;CAEhB,MAAM,UAAU,WAAmB;EACjC,IAAI,WAAW,KAAA,MAAc,aAAa,UAAU,OAAO,WAAW,OAAO,SAAS,MAAM;CAC9F;CAEA,MAAM,SAAS,OAAoB,UAA0B;EAC3D,IAAI,WAAW,KAAA,MAAc,QAAQ,OAAO,SAAS,EAAE,QAAQ,OAAO,QACpE,OAAO,SAAS,WAAW;EAC7B,IACE,UAAU,QACV,OAAO,UAAU,aACjB,OAAO,UAAU,YACjB,OAAO,UAAU,UACjB;GACA,MAAM,UAAU,KAAK,UAAU,KAAK;GAEpC,OAAO,QAAQ,MAAM;GAErB,OAAO;EACT;EACA,IAAI,MAAM,QAAqB,KAAK,GAAG;GACrC,IAAI,WAAW,KAAA,KAAa,MAAM,SAAS,OAAO,kBAChD,OAAO,SAAS,YAAY;GAC9B,OAAO,IAAI,KAAK,IAAI,GAAG,MAAM,SAAS,CAAC,CAAC;GAExC,IAAI,OAAO;GAEX,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;IACjD,IAAI,QAAQ,GAAG,QAAQ;IACvB,QAAQ,MAAM,MAAM,QAAQ,QAAQ,CAAC;GACvC;GAEA,OAAO,GAAG,KAAK;EACjB;EAEA,MAAM,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC,KAAK;EAErC,IAAI,WAAW,KAAA,KAAa,KAAK,SAAS,OAAO,kBAC/C,OAAO,SAAS,YAAY;EAC9B,OAAO,IAAI,KAAK,IAAI,GAAG,KAAK,SAAS,CAAC,CAAC;EACvC,IAAI,OAAO;EAEX,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;GAChD,MAAM,MAAM,KAAK;GACjB,MAAM,aAAa,KAAK,UAAU,GAAG;GAErC,OAAO,WAAW,SAAS,CAAC;GAC5B,IAAI,QAAQ,GAAG,QAAQ;GACvB,QAAQ,GAAG,WAAW,GAAG,MAAM,MAAM,MAAM,QAAQ,CAAC;EACtD;EAEA,OAAO,GAAG,KAAK;CACjB;CAEA,OAAO,MAAM,OAAO,CAAC;AACvB;AAEA,MAAaA,mBAAiB,UAA+B,UAAU,KAAK;AAE5E,MAAa,wBACX,OACA,WACmD;CACnD,IAAI;EACF,OAAO,OAAO,QAAQ,UAAU,OAAO,MAAM,CAAC;CAChD,SAAS,OAAO;EACd,MAAM,UAAU,UAAU,gBAAgB,KAAK,IAAI,eAAe,IAAI,KAAK,IAAI,KAAA;EAE/E,IAAI,YAAY,KAAA,GAAW,OAAO,OAAO,KAAK,wBAAwB,KAAK,EAAE,QAAQ,CAAC,CAAC;EAEvF,MAAM;CACR;AACF;;;;;;;;;;;;AC5FA,IAAa,cAAb,cAAiC,OAAO,YAAyB,CAAC,CAAC,eAAe;CAChF,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,OAAO,IAAI,YAAY;AAC7B,MAAM,eAAe,OAAO,aAAa,MAAM;;AAG/C,MAAa,iBAAiB,UAA+BC,gBAAuB,KAAK;AAEzF,MAAM,aAAa,OAAO,WAAW,WACnC,OACsD;CACtD,MAAM,SAAS,OAAO,OAAO;CAE7B,MAAM,QAAQ,KAAK,OAAO,KAAK;CAE/B,MAAM,SAAS,OAAO,OACnB,OAAO,WAAW,KAAK,CAAC,CACxB,KACC,OAAO,UAAU,UACf,YAAY,KAAK;EAAE,SAAS,mBAAmB,MAAM;EAAW,OAAO;CAAM,CAAC,CAChF,CACF;CAEF,OAAO,OAAO,aAAa,IAAI,OAAO,MAAM,CAAC,CAAC,CAAC,KAC7C,OAAO,eAAe,YAAY,KAAK,EAAE,SAAS,qCAAqC,CAAC,CAAC,CAC3F;AACF,CAAC;;AAGD,MAAa,cAAc,UACzB,OAAO,cAAc,WAAW,cAAc,KAAK,CAAC,CAAC;;AAGvD,MAAa,uBAAuB,SAAiB,WAAW,IAAI;;AAGpE,MAAa,oBAAoB,eAA4B,WAAW,UAAU;;AAGlF,MAAa,qBACX,gBAEA,OAAO,IAAI;CACT,OAAO,iBAAiB,YAAY,KAAK;CACzC,OAAO,iBAAiB,YAAY,KAAK;CACzC,OAAO,iBAAiB,YAAY,KAAK;AAC3C,CAAC,CAAC,CAAC,KAAK,OAAO,KAAK,YAAY,kBAAkB,KAAK,OAAO,CAAC,CAAC"}
|
|
@@ -12,37 +12,38 @@ import { DelegationDepth, SubagentBudgetReservation, SubagentDelegationCaps, Sub
|
|
|
12
12
|
import { o as Selection, s as Snapshot } from "./ToolExposure-hTJT2ekj.mjs";
|
|
13
13
|
import { ChildRunUsage, InputTokenUsage, ModelCallUsage, ModelResponseIdentity, ModelUsageGroup, OutputTokenUsage, RunUsageReport, RunUsageSummary, emptyRunTotals, runTotalsFromSummary, sumRunTotals, summarizeModelUsage, unknownRunTotals } from "./core/Usage.mjs";
|
|
14
14
|
import { C as MessageStatus, S as MessageRef, _ as WorkerStop, b as WorkerUpdate, c as WorkerError, f as WorkerRef, l as WorkerHistoryEntry, o as WorkerCompletion, r as FrameworkMessage } from "./Worker-DZjdMjZn.mjs";
|
|
15
|
-
import { a as PeerMessageCapacity, d as MessageAdmission, f as MessagingError, i as PeerDeliveryLifetime, o as PeerRoutes, p as PeerName, r as PeerAuthorizer, t as MessagingHost } from "./MessagingHost-
|
|
15
|
+
import { a as PeerMessageCapacity, d as MessageAdmission, f as MessagingError, i as PeerDeliveryLifetime, o as PeerRoutes, p as PeerName, r as PeerAuthorizer, t as MessagingHost } from "./MessagingHost-CZCyrnvJ.mjs";
|
|
16
16
|
import { SubagentHost } from "./engine/SubagentHost.mjs";
|
|
17
|
+
import { Store, makeMemoryStore } from "./core/Thread.mjs";
|
|
17
18
|
import { ThreadHistory } from "./engine/ThreadHistory.mjs";
|
|
18
19
|
import { n as RunToolVisibility } from "./ToolExposure-DBATXxmL.mjs";
|
|
19
|
-
import { C as boundedValueFootprint, n as AgentChildPending, p as renderInputPrompt, u as executeWithUsageAccountingUnknown } from "./AgentRuntime-
|
|
20
|
+
import { C as boundedValueFootprint, n as AgentChildPending, p as renderInputPrompt, u as executeWithUsageAccountingUnknown } from "./AgentRuntime-DaDKMasp.mjs";
|
|
20
21
|
import { ContextRolloverTool } from "./engine/ContextWindow.mjs";
|
|
21
22
|
import { getToolExecutionClass } from "./engine/DurableStep.mjs";
|
|
22
23
|
import { CompactionError, ContextCompactor } from "./engine/ContextCompactor.mjs";
|
|
23
24
|
import { AgentUpdateAcceptance, CurrentToolFailureObserver, ModelUsageAccounting, RunContextPreparation, RunContextPreparationPassthrough, RunToolAuthorization, RunToolScheduling } from "./engine/RunOptions.mjs";
|
|
24
|
-
import { A as MAX_RUN_EVIDENCE_RECORDS, At as WorkHandoffCompleted, Bt as WorkerReportingIntent, Ct as ToolCallResolved, Dt as ToolStepSettled, Et as ToolOperation, Ft as WorkerInputRequested, G as PromptRecord, H as PeerMessagePrepared, I as ModelCallAborted, It as WorkerOrigin, Mt as WorkerContinuation, Nt as WorkerInputCompleted, O as MAX_RUN_CONTINUATION_BYTES, Ot as ToolUnavailable, P as MAX_RUN_TOOL_CALL_IDENTITIES, Pt as WorkerInputRefused, R as ModelResponseInterrupted, Rt as WorkerReportPrepared, Tt as ToolCallUnknown, U as PersistedJson, V as PROMPT_EVIDENCE_TAGS, Vt as WorkerStopRequested, X as RecordEnvelope, Z as RecordId, _t as SubmissionSettledRecord, at as RunDurationExhausted, bt as ToolApprovalDecided, c as CanonicalBatch, et as RepairAnnotated, f as CanonicalSequence, ft as SubagentJoined, g as DeclaredToolCall, gt as SubmissionSettled, ht as SubagentStarted, i as BatchId, jt as WorkerAdmission, kt as UserInputRecorded, lt as RunStartedRecord, mt as SubagentRequested, n as AgentUpdateEmitted, o as CURRENT_RECORD_FORMAT, p as CompactionCreated, pt as SubagentLineageRecorded, rt as RunContextRecorded, st as RunPolicyUsageReserved, t as AbortRequested, ut as SettlementFailureDiagnostic, v as DefinitionDigests, vt as SubtreeBudgetReserved, w as MAX_PERSISTED_JSON_BYTES, wt as ToolCallSettled, xt as ToolApprovalRequested, zt as WorkerReportRefused } from "./Records-
|
|
25
|
-
import { i as digestCanonicalJson, r as canonicalJson, s as digestJson } from "./Digest-
|
|
25
|
+
import { A as MAX_RUN_EVIDENCE_RECORDS, At as WorkHandoffCompleted, Bt as WorkerReportingIntent, Ct as ToolCallResolved, Dt as ToolStepSettled, Et as ToolOperation, Ft as WorkerInputRequested, G as PromptRecord, H as PeerMessagePrepared, I as ModelCallAborted, It as WorkerOrigin, Mt as WorkerContinuation, Nt as WorkerInputCompleted, O as MAX_RUN_CONTINUATION_BYTES, Ot as ToolUnavailable, P as MAX_RUN_TOOL_CALL_IDENTITIES, Pt as WorkerInputRefused, R as ModelResponseInterrupted, Rt as WorkerReportPrepared, Tt as ToolCallUnknown, U as PersistedJson, V as PROMPT_EVIDENCE_TAGS, Vt as WorkerStopRequested, X as RecordEnvelope, Z as RecordId, _t as SubmissionSettledRecord, at as RunDurationExhausted, bt as ToolApprovalDecided, c as CanonicalBatch, et as RepairAnnotated, f as CanonicalSequence, ft as SubagentJoined, g as DeclaredToolCall, gt as SubmissionSettled, ht as SubagentStarted, i as BatchId, jt as WorkerAdmission, kt as UserInputRecorded, lt as RunStartedRecord, mt as SubagentRequested, n as AgentUpdateEmitted, o as CURRENT_RECORD_FORMAT, p as CompactionCreated, pt as SubagentLineageRecorded, rt as RunContextRecorded, st as RunPolicyUsageReserved, t as AbortRequested, ut as SettlementFailureDiagnostic, v as DefinitionDigests, vt as SubtreeBudgetReserved, w as MAX_PERSISTED_JSON_BYTES, wt as ToolCallSettled, xt as ToolApprovalRequested, zt as WorkerReportRefused } from "./Records-DzL4Kbtw.mjs";
|
|
26
|
+
import { i as digestCanonicalJson, r as canonicalJson, s as digestJson } from "./Digest-C3EODOee.mjs";
|
|
26
27
|
import { AbortCommand, AbortIntentRequest, AdmissionPolicyError, AdmissionRequest, ApprovalDecisionCommand, ApprovalPendingSuspension, BeginChildBudgetReleaseRequest, ChildReservationId, ChildSettledNotification, ClaimHandoff, ClaimRequest, FundingOwnerRequest, LedgerError, MarkReadyRequest, MarkUnknownRequest, ParentLinkage, RecoverySnapshotRequest, ReleaseChildBudgetRequest, RevertJoiningRequest, Settlement, SettlementFinalization, SubmissionLedger, SubmissionLookupById, SubmissionLookupByKey, SubmissionScheduling, UnknownResolutionCommand, WaitingChild, WaitingForChildSuspension, WorkerLedgerState, submissionAbortBatchId, submissionAbortRecordId, submissionInputBatchId, submissionInputRecordId, submissionSettlementBatchId, submissionSettlementId, submissionSettlementRecordId, unknownResolutionKind } from "./durable/SubmissionLedger.mjs";
|
|
27
28
|
import { DeclaredPendingBatchEvidence, OpenDelegationCallEvidence, OpenToolCallEvidence, PendingApprovalEvidence, RecoveryDecision, RecoveryEvidence, classifyRecovery, pendingApprovalForRecovery } from "./durable/Recovery.mjs";
|
|
28
29
|
import { ExplainedEvidence, ExplainedSubmission, ExplainedUnknownCall, ObligationEntry, ObligationReport, RecoveryExplanation, RetryRefused, obligationSeverityOf, predictRecoveryDisposition, recoveryDecisionMeaning } from "./durable/Admin.mjs";
|
|
29
|
-
import { a as compileRegistrations, c as resolveDefinitionBinding, l as resolveWorkerBinding, n as CurrentBindingSelection, o as definitionDigestsEqual, s as makeLegacyWorkerBinding, t as BindingUnavailable, u as toolReplayContracts } from "./agent-registration-
|
|
30
|
-
import { $ as
|
|
31
|
-
import { $ as ThreadTailRequest, B as ThreadPromptRead, F as ThreadIdentityRequest, I as ThreadMaterialization, J as ThreadStore, R as ThreadObservation, U as ThreadReader, V as ThreadRead, X as ThreadStoreError, Y as ThreadStoreDiagnostic, _t as isPreContinuationFact, bt as terminalUsageCharge, gt as executionRunIds, ht as canonicalRunIds, lt as readWorkerState, n as AppendRequest, ot as getRecord, p as MAX_THREAD_EXPORT_PAGE_BYTES, pt as captureRecord, st as getRunInput } from "./ThreadStore-
|
|
30
|
+
import { a as compileRegistrations, c as resolveDefinitionBinding, l as resolveWorkerBinding, n as CurrentBindingSelection, o as definitionDigestsEqual, s as makeLegacyWorkerBinding, t as BindingUnavailable, u as toolReplayContracts } from "./agent-registration-a6QYaG3h.mjs";
|
|
31
|
+
import { $ as makeJournalMetadata, A as subagentRequestedRecordId, B as toolStepSettledRecordId, C as runStartedBatchId, D as subagentLineageBatchId, E as subagentJoinedRecordId, F as toolCallResolutionBatchId, G as turnResponseBatch, I as toolCallResolvedRecordId, K as turnResponseBatchId, L as toolCallResultBatchId, M as subagentStartedRecordId, N as toolApprovalDecisionRecordId, O as subagentLineageRecordId, P as toolApprovalRequestRecordId, R as toolCallUnknownRecordId, S as runIdForSubmission, T as subagentJoinBatchId, U as turnCanonicalBatch, V as turnApprovalsBatchId, W as turnIdForRun, X as workerOriginRecordId, Y as workerInputRecordId, Z as workerReportRecordId, _ as projectRunJournalStream, a as childIdempotencyKeyFor, b as runDurationBatchId, c as compactionRecordId, d as markUnknownBatchId, et as toolCallSettledRecordId, f as modelResponseInterruptedBatchId, h as peerMessageRecordId, i as approvalDecisionBatchId, j as subagentStartedBatchId, k as subagentRequestedBatchId, l as firstWorkerInputRecordId, m as modelResponseRecordId, o as childThreadIdFor, p as modelResponseInterruptedRecordId, q as turnResultsBatch, r as agentUpdateRecordId, s as compactionBatchId, t as RunJournalError, u as initialRunJournal, w as runStartedRecordId, x as runDurationRecordId, y as runCompletedRecordId, z as toolStepSettledBatchId } from "./RunJournal-CPMKcfd0.mjs";
|
|
32
|
+
import { $ as ThreadTailRequest, B as ThreadPromptRead, F as ThreadIdentityRequest, I as ThreadMaterialization, J as ThreadStore, R as ThreadObservation, U as ThreadReader, V as ThreadRead, X as ThreadStoreError, Y as ThreadStoreDiagnostic, _t as isPreContinuationFact, bt as terminalUsageCharge, gt as executionRunIds, ht as canonicalRunIds, lt as readWorkerState, n as AppendRequest, ot as getRecord, p as MAX_THREAD_EXPORT_PAGE_BYTES, pt as captureRecord, st as getRunInput } from "./ThreadStore-EuUilthA.mjs";
|
|
32
33
|
import { ScheduledInputRefused, ScheduledInputRetryable } from "./durable/Schedule.mjs";
|
|
33
34
|
import { PreparedInputAdmission } from "./durable/PreparedInputAdmission.mjs";
|
|
34
35
|
import { PreparedInput } from "./durable/Subscription.mjs";
|
|
35
36
|
import { MessageDeliveryDriver, MessageDeliveryFailpoint, MessageDeliveryRecord, MessageDeliveryStore, prepareMessageDelivery } from "./durable/MessageDelivery.mjs";
|
|
36
37
|
import { DurableRuntimeFailpoint } from "./durable/DurableFailpoint.mjs";
|
|
37
|
-
import { _ as readRunContext, a as canonicalRecordBytes, b as reference, f as runEvidence, g as digestRunHistory, l as readContinuation, m as validateSuffix, n as CurrentRunWriter, s as makeProgressWriter, t as CurrentRunSettlement, u as readRunEvidenceSnapshot, x as resolveEvidence, y as RunContextReader } from "./RunContinuation-
|
|
38
|
+
import { _ as readRunContext, a as canonicalRecordBytes, b as reference, f as runEvidence, g as digestRunHistory, l as readContinuation, m as validateSuffix, n as CurrentRunWriter, s as makeProgressWriter, t as CurrentRunSettlement, u as readRunEvidenceSnapshot, x as resolveEvidence, y as RunContextReader } from "./RunContinuation-BiyKJK32.mjs";
|
|
38
39
|
import { MAX_WORK_CURSOR_CHARS, ThreadWorkDiscovery, ThreadWorkEntry, ThreadWorkRequest, WorkDiscoveryUnavailable, decodeWorkCursor, deliveryPredecessor, encodeWorkCursor, operationEvidence, resolveWorkEvidence, validateWorkPage, workId } from "./durable/ThreadWork.mjs";
|
|
39
40
|
import { WakeScheduler } from "./durable/WakeScheduler.mjs";
|
|
40
41
|
import { n as safeUnknownString, t as inspectForeignDiagnostic } from "./foreign-diagnostic-DBQ1XHKh.mjs";
|
|
41
|
-
import { c as threadCreatedBatchId, l as threadCreatedRecordId, n as WorkerAdmissionPort, o as ensureThreadCreated, r as WorkerAdmissionRequest, s as ensureWorkerOrigin } from "./WorkerAdmission-
|
|
42
|
+
import { c as threadCreatedBatchId, l as threadCreatedRecordId, n as WorkerAdmissionPort, o as ensureThreadCreated, r as WorkerAdmissionRequest, s as ensureWorkerOrigin } from "./WorkerAdmission-eBeXt_mu.mjs";
|
|
42
43
|
import { i as unresolvedToolOperations, n as isUnresolvedToolOperation, r as toolOperationStates, t as initialDispatchBlockedTurns } from "./tool-operations-BXBmagY1.mjs";
|
|
43
44
|
import { WorkerBudgetAuthorizer, WorkerConcurrencyLimit, WorkerConcurrencyResolver, WorkerHostAuthorizer, WorkerHostConfig, WorkerPolicyResolver } from "./durable/WorkerHost.mjs";
|
|
44
45
|
import { OperationAuthorizationRequest, OperationAuthorizer, OperationDenied } from "./durable/OperationAuthorizer.mjs";
|
|
45
|
-
import { o as makeRunWriter, r as RunStorage, s as StorageOwner } from "./RunStorage-
|
|
46
|
+
import { o as makeRunWriter, r as RunStorage, s as StorageOwner } from "./RunStorage-CzutHJBE.mjs";
|
|
46
47
|
import { SettlementPublication } from "./durable/SettlementPublisher.mjs";
|
|
47
48
|
import { PendingSubmission, SettledSubmission } from "./durable/SubmissionStatus.mjs";
|
|
48
49
|
import { DeclaredToolCallEvidence, ToolReconciler } from "./durable/ToolReconciler.mjs";
|
|
@@ -3152,6 +3153,7 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
3152
3153
|
const store = yield* ThreadStore;
|
|
3153
3154
|
const reader = ThreadReader.fromStore(store);
|
|
3154
3155
|
const promptHistory = yield* makePromptHistoryCache();
|
|
3156
|
+
const unclaimedAdmissions = /* @__PURE__ */ new Map();
|
|
3155
3157
|
const workDiscovery = yield* ThreadWorkDiscovery.pipe(Effect.provide(ThreadWorkDiscovery.layer), Effect.provideService(ThreadStore, store));
|
|
3156
3158
|
const runStorage = yield* RunStorage;
|
|
3157
3159
|
const storageOwner = yield* StorageOwner;
|
|
@@ -3175,8 +3177,10 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
3175
3177
|
})));
|
|
3176
3178
|
const operationAuthorizer = yield* OperationAuthorizer;
|
|
3177
3179
|
const toolFailureObserver = yield* CurrentToolFailureObserver;
|
|
3180
|
+
const runServices = Context.make(CurrentToolFailureObserver, toolFailureObserver).pipe(Context.add(RunToolVisibility, runToolVisibility), Context.add(RunToolScheduling, runToolScheduling), Context.add(ContextCompactor, compactor), Context.add(RunContextPreparation, runContextPreparation));
|
|
3181
|
+
const journalServices = Context.make(ThreadReader, reader).pipe(Context.add(Crypto.Crypto, crypto));
|
|
3178
3182
|
const withCrypto = (effect) => Effect.provideService(effect, Crypto.Crypto, crypto);
|
|
3179
|
-
const readInitialJournal = (original, suffix) => initialContext(original).pipe(Effect.
|
|
3183
|
+
const readInitialJournal = (original, suffix) => initialContext(original).pipe(Effect.provideContext(journalServices), Effect.map((history) => history.concat(suffix)));
|
|
3180
3184
|
const resolutionIntentsFor = (snapshot) => {
|
|
3181
3185
|
const intents = /* @__PURE__ */ new Map();
|
|
3182
3186
|
for (const intent of snapshot.unknownResolutions) if (!intents.has(intent.toolCallId) || unknownResolutionKind(intent.resolution) === "factual") intents.set(intent.toolCallId, intent);
|
|
@@ -3286,7 +3290,7 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
3286
3290
|
const resolve = Effect.fnUntraced(function* (ref) {
|
|
3287
3291
|
const found = byId.get(ref.recordId);
|
|
3288
3292
|
if (found === void 0) {
|
|
3289
|
-
yield* resolveEvidence(threadId, ref).pipe(Effect.
|
|
3293
|
+
yield* resolveEvidence(threadId, ref).pipe(Effect.provideContext(journalServices));
|
|
3290
3294
|
return yield* invalid("Required Run evidence is absent from its locator; rebuild the index explicitly");
|
|
3291
3295
|
}
|
|
3292
3296
|
if (!canonicalRunIds(found.record).includes(runId)) return yield* invalid("Run continuation references another owner");
|
|
@@ -3310,7 +3314,7 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
3310
3314
|
const cachedContext = resolvedContext;
|
|
3311
3315
|
if (cachedContext?.threadId === threadId && cachedContext.recordId === cursor.savedContext.recordId) saved = cachedContext.value;
|
|
3312
3316
|
else {
|
|
3313
|
-
saved = yield* readRunContext(initial, input, cursor.savedContext.recordId).pipe(Effect.provide(RunContextReader.layer(threadId)), Effect.
|
|
3317
|
+
saved = yield* readRunContext(initial, input, cursor.savedContext.recordId).pipe(Effect.provide(RunContextReader.layer(threadId)), Effect.provideContext(journalServices), Effect.mapError(() => invalid("Saved original context cannot be resolved from its evidence")));
|
|
3314
3318
|
resolvedContext = {
|
|
3315
3319
|
threadId,
|
|
3316
3320
|
recordId: cursor.savedContext.recordId,
|
|
@@ -3725,7 +3729,7 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
3725
3729
|
const progressWriters = /* @__PURE__ */ new WeakMap();
|
|
3726
3730
|
const activeProgress = /* @__PURE__ */ new Map();
|
|
3727
3731
|
const withProgress = Effect.fnUntraced(function* (writer) {
|
|
3728
|
-
const progress = activeProgress.get(writer.threadId)?.writer ?? (yield* makeProgressWriter(writer.threadId, config.deploymentId).pipe(Effect.
|
|
3732
|
+
const progress = activeProgress.get(writer.threadId)?.writer ?? (yield* makeProgressWriter(writer.threadId, config.deploymentId).pipe(Effect.provideContext(journalServices)));
|
|
3729
3733
|
const owned = {
|
|
3730
3734
|
...writer,
|
|
3731
3735
|
append: (batch) => progress.commit(batch).pipe(Effect.provideService(CurrentRunWriter, writer), Effect.tapError(() => writer.checkActive))
|
|
@@ -3754,7 +3758,7 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
3754
3758
|
const progressStore = ThreadStore.of({
|
|
3755
3759
|
...store,
|
|
3756
3760
|
append: Effect.fnUntraced(function* (request) {
|
|
3757
|
-
const progress = activeProgress.get(request.threadId)?.writer ?? (yield* makeProgressWriter(request.threadId, config.deploymentId).pipe(Effect.
|
|
3761
|
+
const progress = activeProgress.get(request.threadId)?.writer ?? (yield* makeProgressWriter(request.threadId, config.deploymentId).pipe(Effect.provideContext(journalServices)));
|
|
3758
3762
|
let tail = { sequence: request.expectedTailSequence };
|
|
3759
3763
|
return yield* progress.commit(request.batch).pipe(Effect.provideService(CurrentRunWriter, {
|
|
3760
3764
|
threadId: request.threadId,
|
|
@@ -4976,7 +4980,8 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
4976
4980
|
const retainHistory = (entry) => {
|
|
4977
4981
|
if (priorContext === void 0 && entry.sequence < originalInput.sequence) historyEvidence.set(entry.record.recordId, entry);
|
|
4978
4982
|
};
|
|
4979
|
-
|
|
4983
|
+
const freshPrefix = priorContext === void 0 && initialJournal?.prefix !== void 0 && initialJournal.records?.length === 1 && initialJournal.records[0] === originalInput ? initialJournal.prefix.prompt : void 0;
|
|
4984
|
+
let journal = freshPrefix !== void 0 ? initialRunJournal(freshPrefix) : cached !== void 0 && cached.threadId === ctx.threadId && cached.through === projectionThrough && cached.runId === runId && cached.contextRecordId === priorContext?.recordId ? (boundaries.push(...cached.boundaries), cached.contextEvidence.forEach(retainHistory), cached.journal) : yield* projectRunJournalStream(canonical, runId, (boundary) => boundaries.push(boundary), priorContext, journalMetadata, priorContext === void 0 ? retainHistory : void 0);
|
|
4980
4985
|
if (initialJournal?.prefix !== void 0) {
|
|
4981
4986
|
const prompt = initialJournal.prefix.prompt;
|
|
4982
4987
|
journal = {
|
|
@@ -5096,12 +5101,11 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
5096
5101
|
message: `Run usage summary exceeds safe-integer bounds at ${field}`,
|
|
5097
5102
|
cause
|
|
5098
5103
|
})));
|
|
5099
|
-
const addUsageTotal = (field, left, right) => checkedUsageTotal(field, left + right);
|
|
5100
5104
|
const subtractUsageTotal = (field, left, right) => checkedUsageTotal(field, left - right);
|
|
5101
5105
|
const currentUsageSummary = () => Effect.gen(function* () {
|
|
5102
5106
|
const stagedCalls = [...stagedUsage.values()].flatMap((usage) => usage.modelUsage);
|
|
5103
5107
|
let unobservedModelCalls = journal.usage.unobservedModelCalls ?? 0;
|
|
5104
|
-
for (const count of stagedUnobservedCalls.values()) unobservedModelCalls
|
|
5108
|
+
for (const count of stagedUnobservedCalls.values()) unobservedModelCalls += count;
|
|
5105
5109
|
const detailedCalls = [...journal.usage.modelUsage, ...stagedCalls];
|
|
5106
5110
|
const detailed = yield* summarizeModelUsage(detailedCalls, journal.usage.summarizedModelUsage).pipe(Effect.mapError((cause) => RunJournalError.make({
|
|
5107
5111
|
message: "Run detailed usage exceeds safe-integer accounting bounds",
|
|
@@ -5111,11 +5115,11 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
5111
5115
|
let outputTokens = journal.usage.outputTokens;
|
|
5112
5116
|
let costMicrousd = journal.usage.costMicrousd;
|
|
5113
5117
|
for (const usage of stagedUsage.values()) {
|
|
5114
|
-
inputTokens
|
|
5115
|
-
outputTokens
|
|
5116
|
-
costMicrousd
|
|
5118
|
+
inputTokens += usage.inputTokens;
|
|
5119
|
+
outputTokens += usage.outputTokens;
|
|
5120
|
+
costMicrousd += usage.costMicrousd;
|
|
5117
5121
|
}
|
|
5118
|
-
const modelCalls =
|
|
5122
|
+
const modelCalls = journal.usage.modelCalls + stagedCalls.length;
|
|
5119
5123
|
const legacyCalls = yield* subtractUsageTotal("legacy.modelCalls", modelCalls, detailed.modelCalls);
|
|
5120
5124
|
const legacyInput = yield* subtractUsageTotal("legacy.inputTokens", inputTokens, detailed.inputTokens.total);
|
|
5121
5125
|
const legacyOutput = yield* subtractUsageTotal("legacy.outputTokens", outputTokens, detailed.outputTokens.total);
|
|
@@ -5125,48 +5129,52 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
5125
5129
|
if (legacyCalls > 0) {
|
|
5126
5130
|
const existingIndex = byModel.findIndex((group) => group.provider === "unknown" && group.model === "legacy-record" && group.responseModel === void 0 && group.serviceTier === void 0 && group.pricingVersion === void 0);
|
|
5127
5131
|
const existing = existingIndex < 0 ? void 0 : byModel[existingIndex];
|
|
5128
|
-
const legacyGroup = ModelUsageGroup.
|
|
5132
|
+
const legacyGroup = yield* ModelUsageGroup.makeEffect({
|
|
5129
5133
|
provider: "unknown",
|
|
5130
5134
|
model: "legacy-record",
|
|
5131
|
-
modelCalls:
|
|
5132
|
-
inputTokens:
|
|
5133
|
-
total:
|
|
5134
|
-
uncached:
|
|
5135
|
+
modelCalls: (existing?.modelCalls ?? 0) + legacyCalls,
|
|
5136
|
+
inputTokens: {
|
|
5137
|
+
total: (existing?.inputTokens.total ?? 0) + legacyInput,
|
|
5138
|
+
uncached: (existing?.inputTokens.uncached ?? 0) + legacyInput,
|
|
5135
5139
|
cacheRead: existing?.inputTokens.cacheRead ?? 0,
|
|
5136
5140
|
cacheWrite: existing?.inputTokens.cacheWrite ?? 0
|
|
5137
|
-
}
|
|
5138
|
-
outputTokens:
|
|
5139
|
-
total:
|
|
5140
|
-
text:
|
|
5141
|
+
},
|
|
5142
|
+
outputTokens: {
|
|
5143
|
+
total: (existing?.outputTokens.total ?? 0) + legacyOutput,
|
|
5144
|
+
text: (existing?.outputTokens.text ?? 0) + legacyOutput,
|
|
5141
5145
|
reasoning: existing?.outputTokens.reasoning ?? 0
|
|
5142
|
-
}
|
|
5143
|
-
costMicrousd:
|
|
5144
|
-
})
|
|
5146
|
+
},
|
|
5147
|
+
costMicrousd: (existing?.costMicrousd ?? 0) + legacyCost
|
|
5148
|
+
}).pipe(Effect.mapError((cause) => RunJournalError.make({
|
|
5149
|
+
message: "Run legacy usage exceeds safe-integer accounting bounds",
|
|
5150
|
+
cause
|
|
5151
|
+
})));
|
|
5145
5152
|
if (existingIndex < 0) byModel.push(legacyGroup);
|
|
5146
5153
|
else byModel[existingIndex] = legacyGroup;
|
|
5147
5154
|
}
|
|
5148
|
-
|
|
5149
|
-
const text = yield* addUsageTotal("outputTokens.text", detailed.outputTokens.text, legacyOutput);
|
|
5150
|
-
return RunUsageSummary.make({
|
|
5155
|
+
return yield* RunUsageSummary.makeEffect({
|
|
5151
5156
|
...legacyCalls === 0 && detailed.webSearchCalls !== void 0 ? { webSearchCalls: detailed.webSearchCalls } : {},
|
|
5152
5157
|
modelCalls,
|
|
5153
|
-
inputTokens:
|
|
5158
|
+
inputTokens: {
|
|
5154
5159
|
total: inputTokens,
|
|
5155
|
-
uncached,
|
|
5160
|
+
uncached: detailed.inputTokens.uncached + legacyInput,
|
|
5156
5161
|
cacheRead: detailed.inputTokens.cacheRead,
|
|
5157
5162
|
cacheWrite: detailed.inputTokens.cacheWrite
|
|
5158
|
-
}
|
|
5159
|
-
outputTokens:
|
|
5163
|
+
},
|
|
5164
|
+
outputTokens: {
|
|
5160
5165
|
total: outputTokens,
|
|
5161
|
-
text,
|
|
5166
|
+
text: detailed.outputTokens.text + legacyOutput,
|
|
5162
5167
|
reasoning: detailed.outputTokens.reasoning
|
|
5163
|
-
}
|
|
5168
|
+
},
|
|
5164
5169
|
costMicrousd,
|
|
5165
5170
|
byModel,
|
|
5166
5171
|
unobservedModelCalls,
|
|
5167
5172
|
usageStatus: legacyCalls > 0 || unobservedModelCalls > 0 || interruptedUsage ? detailed.usageStatus === "unknown" ? "unknown" : "partial" : detailed.usageStatus,
|
|
5168
5173
|
pricingStatus: legacyCalls > 0 || unobservedModelCalls > 0 || interruptedUsage ? detailed.pricingStatus === "unknown" ? "unknown" : "partial" : detailed.pricingStatus
|
|
5169
|
-
})
|
|
5174
|
+
}).pipe(Effect.mapError((cause) => RunJournalError.make({
|
|
5175
|
+
message: "Run usage summary exceeds safe-integer accounting bounds",
|
|
5176
|
+
cause
|
|
5177
|
+
})));
|
|
5170
5178
|
});
|
|
5171
5179
|
const activeExecution = yield* reader.readExecution({
|
|
5172
5180
|
threadId: ctx.threadId,
|
|
@@ -5232,13 +5240,14 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
5232
5240
|
};
|
|
5233
5241
|
const haltRef = yield* Ref.make(void 0);
|
|
5234
5242
|
const yieldSignal = yield* Deferred.make();
|
|
5235
|
-
const recordHalt = (effect) =>
|
|
5236
|
-
|
|
5237
|
-
const failure =
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5243
|
+
const recordHalt = (effect) => Effect.catchCause(effect, (cause) => {
|
|
5244
|
+
const first = Cause.findErrorOption(cause);
|
|
5245
|
+
const failure = Effect.failCause(Cause.map(cause, (error) => error instanceof ThreadStoreError && error.cause instanceof AgentPersistenceCapacityError ? error.cause : new CoordinatorHalt(error)));
|
|
5246
|
+
return Option.isNone(first) || first.value instanceof ThreadStoreError && first.value.cause instanceof AgentPersistenceCapacityError ? failure : Effect.andThen(Ref.set(haltRef, first.value), failure);
|
|
5247
|
+
});
|
|
5248
|
+
const progress = progressWriters.get(ctx);
|
|
5249
|
+
const checkProgress = progress === void 0 ? Effect.void : progress.check(runId).pipe(Effect.provideService(CurrentRunWriter, ctx));
|
|
5250
|
+
const checkpoint = recordHalt(Effect.flatMap(Ref.get(haltRef), (failure) => failure === void 0 ? checkProgress : Effect.fail(failure)));
|
|
5242
5251
|
const responseGate = yield* Semaphore.make(1);
|
|
5243
5252
|
let deferredResponse;
|
|
5244
5253
|
const acceptResponseDeclarations = (batch) => {
|
|
@@ -6321,12 +6330,12 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6321
6330
|
definitions: submission.agentDigests
|
|
6322
6331
|
}).pipe(Effect.provideService(CurrentRunWriter, ctx))), Effect.catchTag(["LedgerError", "DurableRuntimeFailpointError"], (failure) => Ref.set(haltRef, failure).pipe(Effect.andThen(Effect.fail(UpdateError.make({ reason: "storage" })))))) }), Effect.provideService(ModelUsageAccounting, { noteIncompleteUsage: (turn) => Effect.sync(() => {
|
|
6323
6332
|
stagedUnobservedCalls.set(turn, (stagedUnobservedCalls.get(turn) ?? 0) + 1);
|
|
6324
|
-
}) }), Effect.
|
|
6333
|
+
}) }), (body) => body.pipe(Effect.provideServiceEffect(ThreadHistory, ThreadHistory.makeFromStore), Effect.provideServiceEffect(Store, makeMemoryStore), Effect.scoped), Effect.provideContext(runServices.pipe(Context.add(SubagentHost.forTool, (source) => source.threadId !== submission.threadId || source.agentId !== submission.agentId || source.runId !== runId ? SubagentHost.unavailable : workerRuntime.facet({
|
|
6325
6334
|
source,
|
|
6326
6335
|
policy: agent.definition.policy,
|
|
6327
6336
|
depth: delegationDepth,
|
|
6328
6337
|
...inheritedGrant === void 0 ? {} : { grant: inheritedGrant }
|
|
6329
|
-
}, submission.principal, submission.submissionId)),
|
|
6338
|
+
}, submission.principal, submission.submissionId)), Context.add(MessagingHost.forTool, (source) => source.threadId !== submission.threadId || source.agentId !== submission.agentId || source.runId !== runId ? MessagingHost.unavailable : messagingRuntime.forTool(source, submission.principal)))), Effect.andThen(checkpoint), Effect.catchCause((cause) => Ref.get(haltRef).pipe(Effect.flatMap((failure) => failure === void 0 ? Effect.failCause(cause) : Effect.failCause(Cause.map(cause, (error) => error instanceof CoordinatorHalt ? error : new CoordinatorHalt(failure)))))), Effect.tapCause((cause) => Option.isSome(agentApprovalPendingOption(cause)) && cause.reasons.every(Cause.isFailReason) ? Effect.flatMap(DurableApprovalSuspension, (retain) => retain === void 0 ? Effect.void : halt(retain)) : Effect.void), Effect.as({ _tag: "run" }));
|
|
6330
6339
|
const abortWatcher = halt(Effect.gen(function* () {
|
|
6331
6340
|
while (true) {
|
|
6332
6341
|
yield* Effect.sleep(config.abortPollInterval);
|
|
@@ -6336,11 +6345,14 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6336
6345
|
return { _tag: "aborted" };
|
|
6337
6346
|
}
|
|
6338
6347
|
}));
|
|
6339
|
-
const
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
...
|
|
6343
|
-
|
|
6348
|
+
const result = yield* Effect.raceAllFirst([
|
|
6349
|
+
consume,
|
|
6350
|
+
abortWatcher,
|
|
6351
|
+
...yieldAfter === void 0 && submissionScheduling.yieldTo === void 0 ? [] : [Deferred.await(yieldSignal).pipe(Effect.map((nextSubmissionId) => ({
|
|
6352
|
+
_tag: "yielded",
|
|
6353
|
+
...nextSubmissionId === void 0 ? {} : { nextSubmissionId }
|
|
6354
|
+
})))]
|
|
6355
|
+
]).pipe(Effect.provideService(IdGenerator$1, idGenerator)).pipe(Effect.catchCauseFilter(Cause.findError, (error, cause) => {
|
|
6344
6356
|
if (isCoordinatorHaltCause(cause)) return Effect.failCause(Cause.map(cause, (halt) => halt.failure));
|
|
6345
6357
|
if (cause.reasons.some((reason) => reason._tag === "Fail" && reason.error instanceof AgentInputDecodeError)) return Effect.failCause(Cause.map(cause, () => BindingUnavailable.make({
|
|
6346
6358
|
agentId: agent.definition.id,
|
|
@@ -6428,16 +6440,16 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6428
6440
|
* (Unknown Outcomes, or a durable approval suspension) — no settlement occurs and the
|
|
6429
6441
|
* obligation stays owed.
|
|
6430
6442
|
*/
|
|
6431
|
-
const runAttempt = Effect.fnUntraced(function* (registeredAgent, session, resumeAfterRetention, onHandoff, yieldAfter) {
|
|
6443
|
+
const runAttempt = Effect.fnUntraced(function* (registeredAgent, session, resumeAfterRetention, onHandoff, yieldAfter, freshlyAdmitted = false) {
|
|
6432
6444
|
yield* session.checkActive;
|
|
6433
|
-
const checkpointPrompt = yield* promptHistory.take({ threadId: session.threadId }).pipe(Effect.provideService(ThreadStore, store), Effect.
|
|
6445
|
+
const checkpointPrompt = yield* promptHistory.take({ threadId: session.threadId }).pipe(Effect.provideService(ThreadStore, store), Effect.provideContext(journalServices));
|
|
6434
6446
|
let committedPromptSuffix;
|
|
6435
6447
|
const storageSession = session;
|
|
6436
6448
|
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
6437
6449
|
committedPromptSuffix?.discard();
|
|
6438
6450
|
committedPromptSuffix = void 0;
|
|
6439
6451
|
}));
|
|
6440
|
-
|
|
6452
|
+
const promptSession = {
|
|
6441
6453
|
...storageSession,
|
|
6442
6454
|
append: (batch, executions) => {
|
|
6443
6455
|
const suffix = committedPromptSuffix;
|
|
@@ -6456,12 +6468,45 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6456
6468
|
replayed: result.replayed
|
|
6457
6469
|
}))), Effect.tapCause(() => Effect.sync(() => suffix.discard())));
|
|
6458
6470
|
}
|
|
6459
|
-
}
|
|
6471
|
+
};
|
|
6472
|
+
session = yield* withProgressSession(promptSession);
|
|
6460
6473
|
const { claim, threadId } = session;
|
|
6461
6474
|
const submissionId = claim.submissionId;
|
|
6462
|
-
|
|
6475
|
+
let prepared = freshlyAdmitted && session.withInitialization !== void 0 ? yield* session.withInitialization(Effect.gen(function* () {
|
|
6476
|
+
const snapshot = yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId }));
|
|
6477
|
+
const submission = snapshot.submission;
|
|
6478
|
+
if (submission.state !== "ready" || submission.workerAdmission !== void 0 || submission.messageAdmission !== void 0 || submission.parentLinkage !== void 0 || snapshot.inputApplied !== void 0 || snapshot.abortIntent !== void 0 || snapshot.approvalDecisions.length !== 0) return void 0;
|
|
6479
|
+
yield* ensureThreadCreated$1(threadId, submission.agentId, submission.agentDigests);
|
|
6480
|
+
yield* session.refresh;
|
|
6481
|
+
const before = (yield* session.tail).sequence;
|
|
6482
|
+
const view = yield* recoveryView(threadId, before, [submissionId], runIdForSubmission(submissionId));
|
|
6483
|
+
if (view.progress !== void 0 || view.context !== void 0 || view.operational.length !== 0 || view.records.some(({ record }) => record.payload._tag !== "ThreadCreated")) return void 0;
|
|
6484
|
+
const progress = progressWriters.get(session);
|
|
6485
|
+
const applyInput = applyCanonicalInput(session, submission, session, view.records, void 0);
|
|
6486
|
+
yield* progress === void 0 ? applyInput : progress.withVerifiedEmptyRun(runIdForSubmission(submissionId), before, applyInput).pipe(Effect.provideService(CurrentRunWriter, promptSession));
|
|
6487
|
+
const through = (yield* session.tail).sequence;
|
|
6488
|
+
const added = yield* selectedRange(threadId, [submissionId], through, before);
|
|
6489
|
+
const records = [...view.records, ...added];
|
|
6490
|
+
const accepted = progressWriters.get(session)?.acceptedCheckpoint(runIdForSubmission(submissionId));
|
|
6491
|
+
if (accepted === void 0 || accepted.throughSequence !== through || accepted.progress.runId !== runIdForSubmission(submissionId) || accepted.progress.submissionId !== submissionId) return void 0;
|
|
6492
|
+
const start = yield* makeRunStart(submission, Duration.toMillis(registeredAgent.definition.policy.maxDuration), records, view.operational).pipe(Effect.provideService(CurrentRunWriter, session));
|
|
6493
|
+
return {
|
|
6494
|
+
snapshot,
|
|
6495
|
+
through,
|
|
6496
|
+
view: {
|
|
6497
|
+
...view,
|
|
6498
|
+
records,
|
|
6499
|
+
progress: accepted.progress,
|
|
6500
|
+
progressThrough: accepted.throughSequence,
|
|
6501
|
+
operational: accepted.operational
|
|
6502
|
+
},
|
|
6503
|
+
start
|
|
6504
|
+
};
|
|
6505
|
+
})) : void 0;
|
|
6506
|
+
const preparedInput = prepared !== void 0;
|
|
6507
|
+
const snapshot = prepared?.snapshot ?? (yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId })));
|
|
6463
6508
|
const submission = snapshot.submission;
|
|
6464
|
-
yield* ensureThreadCreated$1(threadId, submission.agentId, submission.agentDigests);
|
|
6509
|
+
if (prepared === void 0) yield* ensureThreadCreated$1(threadId, submission.agentId, submission.agentDigests);
|
|
6465
6510
|
if (submission.workerAdmission?.origin.reporting?.mode === "standard") yield* updateRuntime.repairRun(threadId, submissionId);
|
|
6466
6511
|
if (submission.workerAdmission !== void 0) yield* workerRuntime.ensureOrigin(submission.workerAdmission.origin).pipe(Effect.mapError((cause) => LedgerError.make({
|
|
6467
6512
|
operation: "worker-origin",
|
|
@@ -6469,10 +6514,11 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6469
6514
|
cause
|
|
6470
6515
|
})));
|
|
6471
6516
|
if (submission.state === "admitted") yield* ledger.markReady(MarkReadyRequest.make({ submissionId }));
|
|
6472
|
-
yield* session.refresh;
|
|
6517
|
+
if (prepared === void 0) yield* session.refresh;
|
|
6473
6518
|
const ctx = session;
|
|
6474
|
-
let controlThrough = (yield* session.tail).sequence;
|
|
6475
|
-
const
|
|
6519
|
+
let controlThrough = prepared?.through ?? (yield* session.tail).sequence;
|
|
6520
|
+
const initialThrough = controlThrough;
|
|
6521
|
+
const initialView = prepared?.view ?? (yield* recoveryView(threadId, initialThrough, [submissionId], runIdForSubmission(submissionId)));
|
|
6476
6522
|
let journalMetadata;
|
|
6477
6523
|
const retainControl = controlRecords([submissionId]);
|
|
6478
6524
|
const collectControl = (record) => {
|
|
@@ -6523,8 +6569,8 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6523
6569
|
}
|
|
6524
6570
|
return Option.some(yield* settleAborted(ctx, submission, session.publishSettlement, snapshot.abortIntent, evidence, knownIds));
|
|
6525
6571
|
}
|
|
6526
|
-
yield* applyCanonicalInput(ctx, submission, session, records, snapshot.inputApplied);
|
|
6527
|
-
const start = yield* makeRunStart(submission, Duration.toMillis(agent.definition.policy.maxDuration), yield* refreshControl(), initialView.operational).pipe(Effect.provideService(CurrentRunWriter, ctx));
|
|
6572
|
+
if (prepared === void 0) yield* applyCanonicalInput(ctx, submission, session, records, snapshot.inputApplied);
|
|
6573
|
+
const start = prepared?.start ?? (yield* makeRunStart(submission, Duration.toMillis(agent.definition.policy.maxDuration), yield* refreshControl(), initialView.operational).pipe(Effect.provideService(CurrentRunWriter, ctx)));
|
|
6528
6574
|
const savedRunTiming = start.timing;
|
|
6529
6575
|
const commitStart = Effect.flatMap(CurrentRunStart, (publication) => publication.commit()).pipe(Effect.provideService(CurrentRunStart, start.publication));
|
|
6530
6576
|
const runTiming = workerOrigin === void 0 ? savedRunTiming : {
|
|
@@ -6532,13 +6578,17 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6532
6578
|
deadline: DateTime.makeUnsafe(Math.min(DateTime.toEpochMillis(savedRunTiming.deadline), workerOrigin.expiresAtMillis))
|
|
6533
6579
|
};
|
|
6534
6580
|
let expiredChildObligation = false;
|
|
6581
|
+
let preparedControl = prepared !== void 0;
|
|
6535
6582
|
if ((yield* Clock.currentTimeMillis) >= DateTime.toEpochMillis(runTiming.deadline)) {
|
|
6583
|
+
prepared = void 0;
|
|
6584
|
+
preparedControl = false;
|
|
6536
6585
|
yield* commitStart;
|
|
6537
6586
|
yield* reconcileRetainedChildren(ctx, submission, session);
|
|
6538
6587
|
expiredChildObligation = yield* completeJoinedReleases(submission);
|
|
6539
6588
|
}
|
|
6540
6589
|
const ordinaryCallsResolved = Effect.gen(function* () {
|
|
6541
|
-
const reconciliationRecords = yield* refreshControl();
|
|
6590
|
+
const reconciliationRecords = preparedControl ? records : yield* refreshControl();
|
|
6591
|
+
preparedControl = false;
|
|
6542
6592
|
const reconciliationEvidence = yield* evidenceFor(reconciliationRecords, submissionId, true, snapshot.hostSubmissionId);
|
|
6543
6593
|
if (reconciliationEvidence.openToolCalls.length === 0) return true;
|
|
6544
6594
|
const reconciliationSnapshot = yield* ledger.loadRecoverySnapshot(RecoverySnapshotRequest.make({ submissionId }));
|
|
@@ -6555,7 +6605,7 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6555
6605
|
return true;
|
|
6556
6606
|
});
|
|
6557
6607
|
if (!expiredChildObligation && !(yield* ordinaryCallsResolved)) return Option.none();
|
|
6558
|
-
const continuationRecords = yield* refreshControl();
|
|
6608
|
+
const continuationRecords = prepared === void 0 ? yield* refreshControl() : records;
|
|
6559
6609
|
const continuation = yield* pendingToolBatchFor(continuationRecords, runIdForSubmission(submissionId));
|
|
6560
6610
|
if (continuation !== void 0) {
|
|
6561
6611
|
const current = {
|
|
@@ -6626,14 +6676,16 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6626
6676
|
}
|
|
6627
6677
|
const lineage = {
|
|
6628
6678
|
attemptId: claim.attemptId,
|
|
6629
|
-
inputWasRecorded: evidence.inputRecorded
|
|
6679
|
+
inputWasRecorded: !preparedInput && evidence.inputRecorded
|
|
6630
6680
|
};
|
|
6631
6681
|
let approvalDecisionIntents = snapshot.approvalDecisions;
|
|
6632
6682
|
while (true) {
|
|
6633
|
-
|
|
6683
|
+
const initialization = prepared;
|
|
6684
|
+
prepared = void 0;
|
|
6685
|
+
if (initialization === void 0) yield* session.refresh;
|
|
6634
6686
|
const tail = yield* session.tail;
|
|
6635
|
-
const currentRecords = yield* refreshControl(tail.sequence);
|
|
6636
|
-
const view = yield* recoveryView(threadId, tail.sequence, [submissionId], runIdForSubmission(submissionId), currentRecords);
|
|
6687
|
+
const currentRecords = initialization === void 0 ? yield* refreshControl(tail.sequence) : records;
|
|
6688
|
+
const view = initialization?.view ?? (yield* recoveryView(threadId, tail.sequence, [submissionId], runIdForSubmission(submissionId), currentRecords));
|
|
6637
6689
|
let canonical = Stream.fromIterable(view.records);
|
|
6638
6690
|
let initialJournal;
|
|
6639
6691
|
if (view.context === void 0) {
|
|
@@ -6762,6 +6814,8 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6762
6814
|
if (Option.isNone(claimed)) return Option.none();
|
|
6763
6815
|
const session = claimed.value;
|
|
6764
6816
|
const { claim } = session;
|
|
6817
|
+
const freshlyAdmitted = unclaimedAdmissions.get(claim.submissionId) === threadId;
|
|
6818
|
+
unclaimedAdmissions.delete(claim.submissionId);
|
|
6765
6819
|
firstClaimedSubmissionId ??= claim.submissionId;
|
|
6766
6820
|
const attributes = {
|
|
6767
6821
|
threadId,
|
|
@@ -6800,7 +6854,7 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
6800
6854
|
deferredSubmissionIds: [...handoff?.deferredSubmissionIds ?? [], claim.submissionId],
|
|
6801
6855
|
submissionId: nextSubmissionId
|
|
6802
6856
|
});
|
|
6803
|
-
}, options?.yieldAfter), threadId, claim);
|
|
6857
|
+
}, options?.yieldAfter, freshlyAdmitted), threadId, claim);
|
|
6804
6858
|
}));
|
|
6805
6859
|
while (true) {
|
|
6806
6860
|
resumeAfterRetention = false;
|
|
@@ -7393,7 +7447,7 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
7393
7447
|
cause
|
|
7394
7448
|
})));
|
|
7395
7449
|
});
|
|
7396
|
-
const recoverOwnedWork = Effect.fnUntraced(function* (request, recoveredAdmissions = /* @__PURE__ */ new Map()) {
|
|
7450
|
+
const recoverOwnedWork = Effect.fnUntraced(function* (request, recoveredAdmissions = /* @__PURE__ */ new Map(), deferUnclaimedAdmissions = false) {
|
|
7397
7451
|
const { threadId, work: entry } = yield* Schema.decodeEffect(WorkRecoveryRequest)(request).pipe(Effect.mapError((cause) => ThreadStoreError.make({
|
|
7398
7452
|
operation: "recover work",
|
|
7399
7453
|
message: "Invalid selected work",
|
|
@@ -7420,7 +7474,10 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
7420
7474
|
});
|
|
7421
7475
|
if (owner._tag === "Admission") {
|
|
7422
7476
|
if (entry.id !== workId("admission", owner.submissionId) || entry.stateReference._tag !== "Submission" || entry.stateReference.submissionId !== owner.submissionId) return yield* invalid();
|
|
7423
|
-
|
|
7477
|
+
const original = yield* lookupKnownSubmission("recover work", owner.submissionId);
|
|
7478
|
+
if (original.threadId !== threadId) return yield* invalid();
|
|
7479
|
+
if (deferUnclaimedAdmissions && unclaimedAdmissions.get(owner.submissionId) === threadId && original.state === "ready" && !storageOwner.hasOwner(threadId) && (yield* ledger.readAbortIntent(AbortIntentRequest.make({ submissionId: owner.submissionId }))) === void 0) return report("deferred");
|
|
7480
|
+
unclaimedAdmissions.delete(owner.submissionId);
|
|
7424
7481
|
const submission = yield* recoverAdmission(owner.submissionId);
|
|
7425
7482
|
return report(submission.disposition, submission);
|
|
7426
7483
|
}
|
|
@@ -7626,6 +7683,16 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
7626
7683
|
let complete = false;
|
|
7627
7684
|
let phase = "history";
|
|
7628
7685
|
const outcome = yield* isolateRecovery(Effect.gen(function* () {
|
|
7686
|
+
if (workCursor === void 0 && options?.deferUnclaimedAdmissions === true && workDiscovery.isOnlyFreshAdmission !== void 0 && !storageOwner.hasOwner(threadId)) {
|
|
7687
|
+
const fresh = [...unclaimedAdmissions].find(([, owner]) => owner === threadId);
|
|
7688
|
+
if (fresh !== void 0 && (yield* workDiscovery.isOnlyFreshAdmission({
|
|
7689
|
+
threadId,
|
|
7690
|
+
submissionId: fresh[0]
|
|
7691
|
+
}))) {
|
|
7692
|
+
complete = true;
|
|
7693
|
+
return;
|
|
7694
|
+
}
|
|
7695
|
+
}
|
|
7629
7696
|
for (let pages = 0; pages < 8 && workReports.length < 32; pages++) {
|
|
7630
7697
|
phase = "history";
|
|
7631
7698
|
const workPage = yield* discoverWork({
|
|
@@ -7638,7 +7705,7 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
7638
7705
|
const repaired = yield* recoverOwnedWork({
|
|
7639
7706
|
threadId,
|
|
7640
7707
|
work
|
|
7641
|
-
}, recoveredAdmissions);
|
|
7708
|
+
}, recoveredAdmissions, options?.deferUnclaimedAdmissions === true);
|
|
7642
7709
|
workReports.push(repaired);
|
|
7643
7710
|
if (repaired.submission !== void 0 && !reportedAdmissions.has(repaired.submission.submissionId)) {
|
|
7644
7711
|
reportedAdmissions.add(repaired.submission.submissionId);
|
|
@@ -7745,7 +7812,7 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
7745
7812
|
queueSequence: admitted.queueSequence
|
|
7746
7813
|
});
|
|
7747
7814
|
}
|
|
7748
|
-
const admitted = yield* ledger.admit(request);
|
|
7815
|
+
const admitted = yield* ledger.admit(request, { readyIfInitialized: true });
|
|
7749
7816
|
yield* hit("submit:after-admit");
|
|
7750
7817
|
const receipt = Receipt.make({
|
|
7751
7818
|
receiptId: admitted.receiptId,
|
|
@@ -7754,10 +7821,19 @@ const make = Effect.fnUntraced(function* (bindings) {
|
|
|
7754
7821
|
queueSequence: admitted.queueSequence
|
|
7755
7822
|
});
|
|
7756
7823
|
if (admitted.replayed && admitted.state !== "admitted") return receipt;
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7824
|
+
if (admitted.state === "admitted") {
|
|
7825
|
+
yield* materializeThread(options.threadId);
|
|
7826
|
+
yield* ensureThreadCreated$1(options.threadId, agent.definition.id, options.definitions);
|
|
7827
|
+
yield* hit("submit:after-materialize");
|
|
7828
|
+
yield* ledger.markReady(MarkReadyRequest.make({ submissionId: admitted.submissionId }));
|
|
7829
|
+
}
|
|
7830
|
+
if (!admitted.replayed && messageAdmission === void 0 && options.workerAdmission === void 0) {
|
|
7831
|
+
unclaimedAdmissions.set(admitted.submissionId, options.threadId);
|
|
7832
|
+
if (unclaimedAdmissions.size > 128) {
|
|
7833
|
+
const oldest = unclaimedAdmissions.keys().next().value;
|
|
7834
|
+
if (oldest !== void 0) unclaimedAdmissions.delete(oldest);
|
|
7835
|
+
}
|
|
7836
|
+
}
|
|
7761
7837
|
yield* wake.notify(options.threadId);
|
|
7762
7838
|
return receipt;
|
|
7763
7839
|
});
|
|
@@ -8371,4 +8447,4 @@ var DurableAgentRuntime = class DurableAgentRuntime extends Context.Service()("@
|
|
|
8371
8447
|
//#endregion
|
|
8372
8448
|
export { DurableApprovalSuspension as a, RecoveryFailure as c, WorkRecoveryReport as d, WorkRecoveryRequest as f, recoveryRepairRecordId as g, recoveryRepairBatchId as h, DurableApprovalResolver as i, RecoveryReport as l, isolateRecovery as m, DurableAgentRuntime as n, DurableRuntimeConfig as o, childReservationIdFor as p, DurableAgentRuntime_exports as r, RecoveryBlocked as s, ApprovalSuspensionError as t, RecoverySweepResult as u };
|
|
8373
8449
|
|
|
8374
|
-
//# sourceMappingURL=DurableAgentRuntime-
|
|
8450
|
+
//# sourceMappingURL=DurableAgentRuntime-CPlw5_7e.mjs.map
|