@yielded/agent 0.1.0-beta.172 → 0.1.0-beta.174
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-BX9ns28E.d.mts → Admin-BHmp2V9p.d.mts} +25 -16
- package/dist/{Agent-9aBoIi74.d.mts → Agent-B39jRnFv.d.mts} +2 -2
- package/dist/{Agent-0WvBWWbM.mjs → Agent-BiRbr73L.mjs} +7 -6
- package/dist/Agent-BiRbr73L.mjs.map +1 -0
- package/dist/{AgentRuntime-CQ-qcETl.mjs → AgentRuntime-B6qZlD3f.mjs} +199 -191
- package/dist/AgentRuntime-B6qZlD3f.mjs.map +1 -0
- package/dist/{AgentRuntime-BfP14534.d.mts → AgentRuntime-BD3ZHAMq.d.mts} +10 -10
- package/dist/{Digest-DCuPlhNk.mjs → Digest-EpeqWEdv.mjs} +41 -14
- package/dist/Digest-EpeqWEdv.mjs.map +1 -0
- package/dist/{DurableAgentRuntime-BAmSkWYr.mjs → DurableAgentRuntime-CBBjRNJN.mjs} +1447 -1424
- package/dist/DurableAgentRuntime-CBBjRNJN.mjs.map +1 -0
- package/dist/{EventSource-BwliwQz9.d.mts → EventSource-C9aaJaXT.d.mts} +2 -2
- package/dist/{MessageDelivery-CeSDfHZa.d.mts → MessageDelivery-BGDm-c46.d.mts} +4 -4
- package/dist/{Messaging-C_6OOg_s.d.mts → Messaging-SVu6rWV8.d.mts} +12 -6
- package/dist/{MessagingHost-B8oKM7AC.d.mts → MessagingHost-C6SOAcoG.d.mts} +2 -2
- package/dist/{Output-Dsx6k52t.d.mts → Output-CRamN1Fy.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-CxSJSiTl.d.mts → PreparedInputAdmission-BvDqlgiP.d.mts} +3 -3
- package/dist/{RunContinuation-DHYNAQFi.mjs → RunContinuation-4ZATcVLB.mjs} +113 -56
- package/dist/RunContinuation-4ZATcVLB.mjs.map +1 -0
- package/dist/{RunContinuation-FHM7XPjq.d.mts → RunContinuation-CTJ1jGrO.d.mts} +6 -6
- package/dist/{RunJournal-kfKVxJj7.mjs → RunJournal-CNZqA3Ge.mjs} +33 -5
- package/dist/RunJournal-CNZqA3Ge.mjs.map +1 -0
- package/dist/{RunOptions-D8zxFIrZ.d.mts → RunOptions-Be77lKVZ.d.mts} +2 -2
- package/dist/{RunStorage-uqPxps09.mjs → RunStorage-BHjuuERI.mjs} +9 -6
- package/dist/RunStorage-BHjuuERI.mjs.map +1 -0
- package/dist/{Scheduling-CVyfXlBR.mjs → Scheduling-NG8slKdI.mjs} +11 -11
- package/dist/Scheduling-NG8slKdI.mjs.map +1 -0
- package/dist/{Subagent-vpffemql.mjs → Subagent-CTIpnzlB.mjs} +53 -40
- package/dist/Subagent-CTIpnzlB.mjs.map +1 -0
- package/dist/{Subagent-E6tvd7-k.d.mts → Subagent-DKhZA72u.d.mts} +19 -8
- package/dist/{SubagentHost-B6w2m-SI.d.mts → SubagentHost-D1xBgn9g.d.mts} +2 -2
- package/dist/{Subscription-DONig54Q.d.mts → Subscription-BNg9VCRl.d.mts} +2 -2
- package/dist/{SubscriptionInput-mJIRxWJM.d.mts → SubscriptionInput-BUoXv-_K.d.mts} +2 -2
- package/dist/{ThreadImport-CoQTZywm.d.mts → ThreadImport-CMgzttvr.d.mts} +43 -43
- package/dist/{ThreadImport-DckUMEqJ.mjs → ThreadImport-CodYoJoa.mjs} +7 -7
- package/dist/ThreadImport-CodYoJoa.mjs.map +1 -0
- package/dist/{ThreadStore-CEekRa80.mjs → ThreadStore-59uDGXul.mjs} +163 -84
- package/dist/ThreadStore-59uDGXul.mjs.map +1 -0
- package/dist/{ThreadTransfer-B4gTQLIl.mjs → ThreadTransfer-3jigUl3g.mjs} +3 -3
- package/dist/{ThreadTransfer-B4gTQLIl.mjs.map → ThreadTransfer-3jigUl3g.mjs.map} +1 -1
- package/dist/{WorkerAdmission-DFVbbVh2.mjs → WorkerAdmission-DDYJdOsU.mjs} +4 -4
- package/dist/{WorkerAdmission-DFVbbVh2.mjs.map → WorkerAdmission-DDYJdOsU.mjs.map} +1 -1
- package/dist/{agent-registration-ByMZ_cK5.mjs → agent-registration-DRbyhAu-.mjs} +69 -56
- package/dist/agent-registration-DRbyhAu-.mjs.map +1 -0
- package/dist/capabilities/Approval.mjs +2 -2
- package/dist/capabilities/Approval.mjs.map +1 -1
- package/dist/capabilities/BrowserUse.d.mts +102 -1867
- package/dist/capabilities/BrowserUse.mjs +74 -798
- package/dist/capabilities/BrowserUse.mjs.map +1 -1
- package/dist/capabilities/Budget.mjs +3 -1
- package/dist/capabilities/Budget.mjs.map +1 -1
- package/dist/capabilities/CodeMode.d.mts +1 -1
- package/dist/capabilities/CodeMode.mjs +16 -9
- package/dist/capabilities/CodeMode.mjs.map +1 -1
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/McpClient.mjs +1 -1
- package/dist/capabilities/McpClient.mjs.map +1 -1
- package/dist/capabilities/Messaging.d.mts +1 -1
- package/dist/capabilities/Messaging.mjs +4 -4
- package/dist/capabilities/Messaging.mjs.map +1 -1
- package/dist/capabilities/ModelContext.mjs +7 -5
- package/dist/capabilities/ModelContext.mjs.map +1 -1
- package/dist/capabilities/Redaction.mjs +49 -19
- package/dist/capabilities/Redaction.mjs.map +1 -1
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/RunHooks.mjs +1 -1
- package/dist/capabilities/RunHooks.mjs.map +1 -1
- package/dist/capabilities/Subagent.d.mts +1 -1
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/capabilities/SubagentReservations.mjs +3 -1
- package/dist/capabilities/SubagentReservations.mjs.map +1 -1
- package/dist/capabilities/WebCapture.mjs.map +1 -1
- package/dist/capabilities/WebSearch.mjs +7 -7
- package/dist/capabilities/WebSearch.mjs.map +1 -1
- package/dist/core/Agent.d.mts +1 -1
- package/dist/core/Agent.mjs +1 -1
- package/dist/core/AgentUpdates.mjs +8 -8
- package/dist/core/AgentUpdates.mjs.map +1 -1
- package/dist/core/Thread.mjs +1 -1
- package/dist/core/Thread.mjs.map +1 -1
- package/dist/core/Usage.mjs +2 -2
- package/dist/core/Usage.mjs.map +1 -1
- package/dist/durable/Admin.d.mts +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 +2 -2
- 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 +6 -6
- package/dist/durable/EventSource.mjs.map +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/LifecyclePublication.d.mts +1 -1
- package/dist/durable/LifecyclePublication.mjs +1 -1
- package/dist/durable/MessageDelivery.d.mts +1 -1
- package/dist/durable/MessageDelivery.mjs +1 -1
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +2 -2
- package/dist/durable/MessageDeliveryStoreConformance.mjs +1 -1
- package/dist/durable/PersistentHistory.d.mts +1 -1
- package/dist/durable/PersistentHistory.mjs +3 -3
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/RecordFormat.mjs +2 -2
- package/dist/durable/RecordFormat.mjs.map +1 -1
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/RunContinuation.d.mts +2 -2
- package/dist/durable/RunContinuation.mjs +2 -2
- package/dist/durable/RunJournal.d.mts +1 -1
- package/dist/durable/RunJournal.mjs +1 -1
- package/dist/durable/RunStorage.d.mts +1 -1
- package/dist/durable/RunStorage.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 +2 -2
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedger.mjs +5 -1
- package/dist/durable/SubmissionLedger.mjs.map +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.mjs +4 -4
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionInput.mjs +3 -3
- package/dist/durable/SubscriptionInput.mjs.map +1 -1
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionStoreConformance.mjs +2 -2
- package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -1
- package/dist/durable/SubscriptionTools.d.mts +2 -2
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/Subscriptions.d.mts +5 -5
- package/dist/durable/Subscriptions.mjs +2 -2
- package/dist/durable/Subscriptions.mjs.map +1 -1
- package/dist/durable/ThreadArchiveRange.d.mts +1 -1
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistory.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/ThreadInvariants.mjs.map +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 +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.mjs +3 -3
- package/dist/durable/ThreadTransfer.d.mts +1 -1
- package/dist/durable/ThreadTransfer.mjs +1 -1
- package/dist/durable/ThreadWork.d.mts +1 -1
- package/dist/durable/ThreadWork.mjs +4 -4
- package/dist/durable/ThreadWork.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 +2 -2
- package/dist/engine/AgentRuntime.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/engine/MessagingHost.d.mts +1 -1
- package/dist/engine/Output.d.mts +1 -1
- package/dist/engine/RunOptions.d.mts +1 -1
- package/dist/engine/SubagentHost.d.mts +1 -1
- package/dist/index.d.mts +19 -19
- package/dist/index.mjs +14 -14
- package/dist/{run-context-reader-OcsZr4bk.d.mts → run-context-reader-CC7ZD95F.d.mts} +2 -2
- package/package.json +1 -1
- package/src/capabilities/Approval.ts +58 -60
- package/src/capabilities/BrowserUse.ts +89 -944
- package/src/capabilities/Budget.ts +8 -1
- package/src/capabilities/CodeMode.ts +57 -33
- package/src/capabilities/McpClient.ts +2 -2
- package/src/capabilities/Messaging.ts +51 -55
- package/src/capabilities/ModelContext.ts +5 -2
- package/src/capabilities/Redaction.ts +64 -34
- package/src/capabilities/RunHooks.ts +52 -55
- package/src/capabilities/Subagent.ts +33 -33
- package/src/capabilities/SubagentReservations.ts +9 -1
- package/src/capabilities/WebCapture.ts +6 -0
- package/src/capabilities/WebSearch.ts +10 -7
- package/src/capabilities/internal/subagent-background.ts +202 -158
- package/src/core/Agent.ts +11 -6
- package/src/core/AgentUpdates.ts +8 -8
- package/src/core/Thread.ts +9 -10
- package/src/core/Usage.ts +7 -8
- package/src/core/internal/agent-updates.ts +1 -0
- package/src/durable/DurableAgentRuntime.ts +645 -625
- package/src/durable/EventSource.ts +15 -9
- package/src/durable/RecordFormat.ts +5 -3
- package/src/durable/RunContinuation.ts +233 -81
- package/src/durable/RunJournal.ts +10 -9
- package/src/durable/RunStorage.ts +122 -124
- package/src/durable/Scheduling.ts +639 -651
- package/src/durable/SubmissionLedger.ts +4 -0
- package/src/durable/SubscriptionInput.ts +5 -3
- package/src/durable/SubscriptionStoreConformance.ts +23 -23
- package/src/durable/Subscriptions.ts +18 -19
- package/src/durable/ThreadImport.ts +18 -19
- package/src/durable/ThreadInvariants.ts +2 -1
- package/src/durable/ThreadStore.ts +215 -111
- package/src/durable/ThreadWork.ts +1 -2
- package/src/durable/internal/StorageOwner.ts +10 -4
- package/src/durable/internal/agent-registration.ts +96 -89
- package/src/durable/internal/canonical-json.ts +61 -20
- package/src/durable/internal/prompt-history-cache.ts +13 -4
- package/src/durable/internal/record-encoding.ts +120 -64
- package/src/durable/internal/schedule-time.ts +6 -6
- package/src/durable/internal/usage-totals.ts +38 -0
- package/src/durable/internal/worker-host.ts +69 -74
- package/src/engine/internal/agent-runtime.ts +1067 -1018
- package/src/engine/internal/provisional-text.ts +12 -10
- package/src/engine/internal/tool-exposure.ts +22 -18
- package/src/engine/internal/tool-telemetry.ts +12 -7
- package/dist/Agent-0WvBWWbM.mjs.map +0 -1
- package/dist/AgentRuntime-CQ-qcETl.mjs.map +0 -1
- package/dist/Digest-DCuPlhNk.mjs.map +0 -1
- package/dist/DurableAgentRuntime-BAmSkWYr.mjs.map +0 -1
- package/dist/RunContinuation-DHYNAQFi.mjs.map +0 -1
- package/dist/RunJournal-kfKVxJj7.mjs.map +0 -1
- package/dist/RunStorage-uqPxps09.mjs.map +0 -1
- package/dist/Scheduling-CVyfXlBR.mjs.map +0 -1
- package/dist/Subagent-vpffemql.mjs.map +0 -1
- package/dist/ThreadImport-DckUMEqJ.mjs.map +0 -1
- package/dist/ThreadStore-CEekRa80.mjs.map +0 -1
- package/dist/agent-registration-ByMZ_cK5.mjs.map +0 -1
|
@@ -8,14 +8,14 @@ import { n as CurrentToolCatalog } from "./ToolExposure-DFQKf9ET.mjs";
|
|
|
8
8
|
import { s as ToolBroker } from "./ToolBroker-P5t4ZN78.mjs";
|
|
9
9
|
import { c as AgentOutputError, f as AgentToolAuthorizationCheckError, g as ModelProtocolError, h as ContextOverflowError, l as AgentPersistenceCapacityError, m as ContextBudgetError, n as AgentApprovalPending, o as AgentInputError, p as AgentToolAuthorizationDenied, t as AgentApprovalDenied, u as AgentPolicyError } from "./AgentError-CBH7_MjG.mjs";
|
|
10
10
|
import { t as AgentPolicy } from "./AgentPolicy-B4lbCU2T.mjs";
|
|
11
|
-
import { A as ToolUnion, C as OutputSchema, D as RunDispositionFailure, E as RunDispositionDeclaration, N as UpdatesSchema, O as RunDispositionSchema, S as Output, _ as InstructionSource, a as CompletionFromToolDeclaration, c as Definition, d as EncodedInput, f as Failure, m as InputPromptSource, n as Any, r as AnyDefinition, s as CompletionToolDeclaration, t as Agent_d_exports, w as Requirements } from "./Agent-
|
|
11
|
+
import { A as ToolUnion, C as OutputSchema, D as RunDispositionFailure, E as RunDispositionDeclaration, N as UpdatesSchema, O as RunDispositionSchema, S as Output, _ as InstructionSource, a as CompletionFromToolDeclaration, c as Definition, d as EncodedInput, f as Failure, m as InputPromptSource, n as Any, r as AnyDefinition, s as CompletionToolDeclaration, t as Agent_d_exports, w as Requirements } from "./Agent-B39jRnFv.mjs";
|
|
12
12
|
import { a as WorkerBudgetScope } from "./Worker-CHRaIsWu.mjs";
|
|
13
13
|
import { a as ContextWindow } from "./ContextWindow-Cvv8N9Xy.mjs";
|
|
14
14
|
import { n as CompactionError } from "./ContextCompactor-Bz91grmO.mjs";
|
|
15
15
|
import { t as DurableStep } from "./DurableStep-DXGn7KQ4.mjs";
|
|
16
|
-
import { B as RunSubagentChildIdentity, H as RunSubagentEstablishRequest, M as RunOptions, S as RunContextPreparationError, W as RunSubagentJoinRequest, i as ChildEstablishStatus, l as ModelUsageAccounting, t as AgentUpdateAcceptance, x as RunContextPreparation } from "./RunOptions-
|
|
17
|
-
import { t as MessagingHost } from "./MessagingHost-
|
|
18
|
-
import { o as SubagentHost } from "./SubagentHost-
|
|
16
|
+
import { B as RunSubagentChildIdentity, H as RunSubagentEstablishRequest, M as RunOptions, S as RunContextPreparationError, W as RunSubagentJoinRequest, i as ChildEstablishStatus, l as ModelUsageAccounting, t as AgentUpdateAcceptance, x as RunContextPreparation } from "./RunOptions-Be77lKVZ.mjs";
|
|
17
|
+
import { t as MessagingHost } from "./MessagingHost-C6SOAcoG.mjs";
|
|
18
|
+
import { o as SubagentHost } from "./SubagentHost-D1xBgn9g.mjs";
|
|
19
19
|
import { t as RunEventSink } from "./RunEventSink-shh6Qf9E.mjs";
|
|
20
20
|
import * as Tool$1 from "effect/ai/Tool";
|
|
21
21
|
import * as Toolkit$1 from "effect/ai/Toolkit";
|
|
@@ -122,16 +122,16 @@ declare const decodeFinalOutput: <AgentValue extends Any>(agent: AgentValue, tex
|
|
|
122
122
|
}, AgentOutputError, OutputSchema<AgentValue>["DecodingServices"]>;
|
|
123
123
|
declare const projectCompletionOutput: <AgentValue extends Any>(agent: AgentValue, declaration: CompletionToolDeclaration<unknown, unknown, unknown>, parameters: unknown, result: unknown) => Effect.Effect<{
|
|
124
124
|
encoded: Schema.Json;
|
|
125
|
-
decoded:
|
|
126
|
-
}, AgentOutputError | ModelProtocolError,
|
|
125
|
+
decoded: AgentValue["definition"]["output"]["Type"];
|
|
126
|
+
}, AgentOutputError | ModelProtocolError, AgentValue["definition"]["output"]["DecodingServices"] | AgentValue["definition"]["output"]["EncodingServices"] | AgentCompletionProjectionRequirements<AgentValue>>;
|
|
127
127
|
/** Reconstruct optional action completion identically for live execution and canonical recovery. */
|
|
128
128
|
declare const projectCompletionFromToolOutput: <AgentValue extends Any>(agent: AgentValue, declaration: CompletionFromToolDeclaration<unknown, unknown, unknown>, parameters: unknown, result: unknown) => Effect.Effect<Option.None<{
|
|
129
129
|
encoded: Schema.Json;
|
|
130
|
-
decoded:
|
|
130
|
+
decoded: AgentValue["definition"]["output"]["Type"];
|
|
131
131
|
}> | Option.Some<{
|
|
132
132
|
encoded: Schema.Json;
|
|
133
|
-
decoded:
|
|
134
|
-
}>, AgentOutputError | ModelProtocolError,
|
|
133
|
+
decoded: AgentValue["definition"]["output"]["Type"];
|
|
134
|
+
}>, AgentOutputError | ModelProtocolError, AgentValue["definition"]["output"]["DecodingServices"] | AgentValue["definition"]["output"]["EncodingServices"] | AgentCompletionProjectionRequirements<AgentValue>>;
|
|
135
135
|
declare function encodeRunDisposition<AgentValue extends Any>(agent: AgentValue, output: Output<AgentValue>): Effect.Effect<Schema.Json | undefined, RunDispositionFailure<AgentValue>, RunDispositionSchema<AgentValue>["EncodingServices"]>;
|
|
136
136
|
/**
|
|
137
137
|
* Scoped detached execution whose observers cannot backpressure Run
|
|
@@ -359,4 +359,4 @@ declare namespace AgentRuntime_d_exports {
|
|
|
359
359
|
}
|
|
360
360
|
//#endregion
|
|
361
361
|
export { runUnknown as A, decodeFinalOutput as C, projectCompletionOutput as D, projectCompletionFromToolOutput as E, streamWithUsageAccountingUnknown as F, withTerminalDefectEvent as I, startUnknown as M, stream as N, renderInputPrompt as O, streamUnknown as P, ToolCallWaiting as S, executeWithUsageAccountingUnknown as T, SubagentDurability as _, AgentResultSchema as a, SubagentDurabilityError as b, AgentSpawner as c, DetachedRun as d, EngineProvidedToolServices as f, SpawnedChildRun as g, SpawnRunOptions as h, AgentResult as i, start as j, run as k, AgentSpawnerParent as l, SpawnDelegation as m, AgentChildPending as n, AgentRuntimeFailure as o, RuntimeBinding as p, AgentCompletionProjectionRequirements as r, AgentRuntimeRequirements as s, AgentRuntime_d_exports as t, AgentSpawnerService as u, SubagentDurabilityDurable as v, encodeRunDisposition as w, SubagentDurabilityService as x, SubagentDurabilityEphemeral as y };
|
|
362
|
-
//# sourceMappingURL=AgentRuntime-
|
|
362
|
+
//# sourceMappingURL=AgentRuntime-BD3ZHAMq.d.mts.map
|
|
@@ -1,39 +1,66 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { n as utf8ByteLength } from "./utf8-B5pAmhTo.mjs";
|
|
3
3
|
import { b as Digest, v as DefinitionDigests } from "./Records-BiuJDWNe.mjs";
|
|
4
|
-
import { Array, Crypto, Effect, Schema } from "effect";
|
|
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
|
|
7
|
+
var CanonicalJsonLimitError = class extends Schema.TaggedError()("CanonicalJsonLimitError", { message: Schema.String }) {};
|
|
8
|
+
const boundsFailures = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
const exceeded = (bound) => {
|
|
10
|
+
const message = `Canonical JSON exceeds its ${bound} bound`;
|
|
11
|
+
const error = new RangeError(message);
|
|
12
|
+
boundsFailures.set(error, message);
|
|
13
|
+
throw error;
|
|
14
|
+
};
|
|
7
15
|
/** Values have already crossed their Schema boundary; visit each serialized occurrence. */
|
|
8
|
-
const
|
|
16
|
+
const serialize = (value, limits) => {
|
|
9
17
|
let nodes = 0;
|
|
10
18
|
let textUnits = 0;
|
|
11
19
|
const charge = (length) => {
|
|
12
|
-
if (limits !== void 0 && (textUnits += length) > limits.textUnits)
|
|
20
|
+
if (limits !== void 0 && (textUnits += length) > limits.textUnits) return exceeded("text");
|
|
13
21
|
};
|
|
14
22
|
const visit = (value, depth) => {
|
|
15
|
-
if (limits !== void 0 && (depth > limits.depth || ++nodes > limits.nodes))
|
|
23
|
+
if (limits !== void 0 && (depth > limits.depth || ++nodes > limits.nodes)) return exceeded("traversal");
|
|
16
24
|
if (value === null || typeof value === "boolean" || typeof value === "number" || typeof value === "string") {
|
|
17
25
|
const encoded = JSON.stringify(value);
|
|
18
26
|
charge(encoded.length);
|
|
19
27
|
return encoded;
|
|
20
28
|
}
|
|
21
29
|
if (Array.isArray(value)) {
|
|
22
|
-
if (limits !== void 0 && value.length > limits.collectionLength)
|
|
30
|
+
if (limits !== void 0 && value.length > limits.collectionLength) return exceeded("collection");
|
|
23
31
|
charge(2 + Math.max(0, value.length - 1));
|
|
24
|
-
|
|
32
|
+
let json = "[";
|
|
33
|
+
for (let index = 0; index < value.length; index++) {
|
|
34
|
+
if (index > 0) json += ",";
|
|
35
|
+
json += visit(value[index], depth + 1);
|
|
36
|
+
}
|
|
37
|
+
return `${json}]`;
|
|
25
38
|
}
|
|
26
|
-
const
|
|
27
|
-
if (limits !== void 0 &&
|
|
28
|
-
charge(2 + Math.max(0,
|
|
29
|
-
|
|
39
|
+
const keys = Object.keys(value).sort();
|
|
40
|
+
if (limits !== void 0 && keys.length > limits.collectionLength) return exceeded("collection");
|
|
41
|
+
charge(2 + Math.max(0, keys.length - 1));
|
|
42
|
+
let json = "{";
|
|
43
|
+
for (let index = 0; index < keys.length; index++) {
|
|
44
|
+
const key = keys[index];
|
|
30
45
|
const encodedKey = JSON.stringify(key);
|
|
31
46
|
charge(encodedKey.length + 1);
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
if (index > 0) json += ",";
|
|
48
|
+
json += `${encodedKey}:${visit(value[key], depth + 1)}`;
|
|
49
|
+
}
|
|
50
|
+
return `${json}}`;
|
|
34
51
|
};
|
|
35
52
|
return visit(value, 0);
|
|
36
53
|
};
|
|
54
|
+
const canonicalJson$1 = (value) => serialize(value);
|
|
55
|
+
const boundedCanonicalJson = (value, limits) => {
|
|
56
|
+
try {
|
|
57
|
+
return Result.succeed(serialize(value, limits));
|
|
58
|
+
} catch (cause) {
|
|
59
|
+
const message = Predicate.isObjectKeyword(cause) ? boundsFailures.get(cause) : void 0;
|
|
60
|
+
if (message !== void 0) return Result.fail(CanonicalJsonLimitError.make({ message }));
|
|
61
|
+
throw cause;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
37
64
|
//#endregion
|
|
38
65
|
//#region src/durable/Digest.ts
|
|
39
66
|
var Digest_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -75,6 +102,6 @@ const digestDefinitions = (definitions) => Effect.all({
|
|
|
75
102
|
tools: digestDefinition(definitions.tools)
|
|
76
103
|
}).pipe(Effect.map((digests) => DefinitionDigests.make(digests)));
|
|
77
104
|
//#endregion
|
|
78
|
-
export { digestDefinition as a,
|
|
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 };
|
|
79
106
|
|
|
80
|
-
//# sourceMappingURL=Digest-
|
|
107
|
+
//# sourceMappingURL=Digest-EpeqWEdv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Digest-EpeqWEdv.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,QA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