effect-agent 0.1.0-beta.93 → 0.1.0-beta.95
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/{Agent-RklVROrm.mjs → Agent-CG_VMrtA.mjs} +2 -2
- package/dist/{Agent-RklVROrm.mjs.map → Agent-CG_VMrtA.mjs.map} +1 -1
- package/dist/{Agent-CN0EWRsR.d.mts → Agent-CM6JubNX.d.mts} +2 -2
- package/dist/{AgentPolicy-CetmQrf3.d.mts → AgentPolicy-BqDoSXO6.d.mts} +2 -2
- package/dist/{AgentRuntime-BPjQM1Nv.mjs → AgentRuntime-Cdvqw7l_.mjs} +88 -32
- package/dist/AgentRuntime-Cdvqw7l_.mjs.map +1 -0
- package/dist/{AgentRuntime-uxR_a4VM.d.mts → AgentRuntime-CufqQ4JM.d.mts} +8 -8
- package/dist/{ContextCompactor-Dxu5zhOL.d.mts → ContextCompactor-WwSIG_Z2.d.mts} +2 -2
- package/dist/{DurableAgentRuntime-CdrBuKZY.mjs → DurableAgentRuntime-BaGsWDHO.mjs} +9 -5
- package/dist/DurableAgentRuntime-BaGsWDHO.mjs.map +1 -0
- package/dist/{EventSource-c6GRTCsl.d.mts → EventSource-DVfX1GRH.d.mts} +3 -3
- package/dist/{Messaging-CkcIdt4I.d.mts → Messaging-QMYhp297.d.mts} +3 -3
- package/dist/{MessagingHost-CRk0kXzT.d.mts → MessagingHost-gAxs5gme.d.mts} +3 -3
- package/dist/{Output-D6SkedVx.d.mts → Output-CjocJzsl.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-QzFbW2LQ.d.mts → PreparedInputAdmission-DoWaMC2R.d.mts} +4 -4
- package/dist/{Records-vFp_ZQ9Y.d.mts → Records-B84j3Jq_.d.mts} +21 -9
- package/dist/{Records-C9cezOEf.mjs → Records-CsEsSW2o.mjs} +5 -2
- package/dist/Records-CsEsSW2o.mjs.map +1 -0
- package/dist/{RunJournal-lwbrh2hZ.mjs → RunJournal-yYpUlTOE.mjs} +3 -2
- package/dist/RunJournal-yYpUlTOE.mjs.map +1 -0
- package/dist/{RunOptions-g1aigcKI.d.mts → RunOptions-CE-G3niT.d.mts} +14 -8
- package/dist/{Schedule-BkZvKyMw.d.mts → Schedule-DCYBfhgT.d.mts} +2 -2
- package/dist/{Scheduling-D0QqOoeT.mjs → Scheduling-CUuYc3-D.mjs} +3 -3
- package/dist/{Scheduling-D0QqOoeT.mjs.map → Scheduling-CUuYc3-D.mjs.map} +1 -1
- package/dist/{Subagent-CnTzCy8k.mjs → Subagent-Cbfzylz1.mjs} +3 -3
- package/dist/{Subagent-CnTzCy8k.mjs.map → Subagent-Cbfzylz1.mjs.map} +1 -1
- package/dist/{Subagent-DyfzHNdv.d.mts → Subagent-DscbtbNY.d.mts} +6 -6
- package/dist/{SubagentHost-CJUBQlcc.d.mts → SubagentHost-DaFMZnVR.d.mts} +4 -4
- package/dist/{Subscription-CKQ0KDHN.d.mts → Subscription-C8IHdmFk.d.mts} +4 -4
- package/dist/{SubscriptionInput-Cth8F_7b.d.mts → SubscriptionInput-DhM3jUW2.d.mts} +3 -3
- package/dist/{ToolResult-DmmgoChv.d.mts → ToolResult-BKdqWRff.d.mts} +20 -3
- package/dist/{Worker-CaPYykpe.d.mts → Worker--j87JI__.d.mts} +2 -2
- package/dist/capabilities/Approval.mjs +1 -1
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/Messaging.d.mts +2 -2
- package/dist/capabilities/ModelContext.mjs +1 -1
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/Subagent.d.mts +2 -2
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/capabilities/ToolDiscovery.d.mts +19 -4
- package/dist/capabilities/ToolDiscovery.mjs +33 -14
- package/dist/capabilities/ToolDiscovery.mjs.map +1 -1
- package/dist/core/Agent.d.mts +1 -1
- package/dist/core/Agent.mjs +1 -1
- package/dist/core/AgentPolicy.d.mts +1 -1
- package/dist/core/Thread.mjs +1 -1
- package/dist/core/ToolResult.d.mts +2 -2
- package/dist/core/ToolResult.mjs +17 -1
- package/dist/core/ToolResult.mjs.map +1 -1
- package/dist/core/Worker.d.mts +1 -1
- package/dist/core/Worker.mjs +1 -1
- package/dist/durable/ActivityStore.d.mts +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/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +1 -1
- package/dist/durable/CommittedActivity.mjs +1 -1
- package/dist/durable/Digest.d.mts +1 -1
- package/dist/durable/Digest.mjs +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +1 -1
- 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/GitHubWorkflowSource.mjs +1 -1
- package/dist/durable/MessageDelivery.d.mts +23 -23
- package/dist/durable/MessageDelivery.mjs +1 -1
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +40 -40
- package/dist/durable/MessageDeliveryStoreConformance.mjs +1 -1
- package/dist/durable/PersistentHistory.d.mts +1 -1
- package/dist/durable/PersistentHistory.mjs +2 -2
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/Records.d.mts +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/RunJournal.d.mts +1 -1
- package/dist/durable/RunJournal.mjs +1 -1
- package/dist/durable/Schedule.d.mts +1 -1
- package/dist/durable/Schedule.mjs +1 -1
- package/dist/durable/ScheduleStoreConformance.d.mts +1 -1
- package/dist/durable/ScheduleStoreConformance.mjs +1 -1
- package/dist/durable/ScheduleTransition.d.mts +1 -1
- package/dist/durable/ScheduleTransition.mjs +1 -1
- package/dist/durable/Scheduling.d.mts +2 -2
- package/dist/durable/Scheduling.mjs +1 -1
- package/dist/durable/SqlStorageV2Upgrade.d.mts +2 -2
- package/dist/durable/SqlStorageV2Upgrade.mjs +1 -1
- package/dist/durable/SqlSubscriptionStore.d.mts +2 -2
- package/dist/durable/SqlSubscriptionStore.mjs +1 -1
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedger.mjs +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.mjs +2 -2
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/Subscription.mjs +1 -1
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionInput.mjs +1 -1
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
- package/dist/durable/SubscriptionTools.d.mts +3 -3
- 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/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistory.mjs +1 -1
- package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
- package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
- package/dist/durable/ThreadInvariants.d.mts +1 -1
- package/dist/durable/ThreadInvariants.mjs +1 -1
- package/dist/durable/ThreadProjection.d.mts +1 -1
- package/dist/durable/ThreadProjection.mjs +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +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 +1 -1
- package/dist/durable/ToolReconciler.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +4 -4
- package/dist/engine/AgentRuntime.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/engine/Compaction.d.mts +1 -1
- package/dist/engine/ContextCompactor.d.mts +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/RunOptions.mjs.map +1 -1
- package/dist/engine/SubagentHost.d.mts +1 -1
- package/dist/index.d.mts +18 -18
- package/dist/index.mjs +8 -8
- package/package.json +1 -1
- package/src/capabilities/ToolDiscovery.ts +48 -18
- package/src/core/ToolResult.ts +20 -0
- package/src/durable/DurableAgentRuntime.ts +7 -0
- package/src/durable/Records.ts +3 -0
- package/src/durable/RunJournal.ts +5 -0
- package/src/engine/RunOptions.ts +9 -3
- package/src/engine/internal/agent-runtime.ts +254 -67
- package/dist/AgentRuntime-BPjQM1Nv.mjs.map +0 -1
- package/dist/DurableAgentRuntime-CdrBuKZY.mjs.map +0 -1
- package/dist/Records-C9cezOEf.mjs.map +0 -1
- package/dist/RunJournal-lwbrh2hZ.mjs.map +0 -1
|
@@ -4,11 +4,11 @@ import { SubagentBudgetExhausted, SubagentReservations } from "./capabilities/Su
|
|
|
4
4
|
import { a as Receipt, n as JoinedToHost, t as IdempotencyKey } from "./Receipt-BAHyigAF.mjs";
|
|
5
5
|
import { s as RunTotals } from "./Usage-Dx0aknfk.mjs";
|
|
6
6
|
import { t as ThreadHistory } from "./ThreadHistory-tS1KwxHR.mjs";
|
|
7
|
-
import { T as RunDispositionDeclaration, _ as InstructionSource, c as Definition, m as InputPromptSource, r as AnyDefinition } from "./Agent-
|
|
8
|
-
import { a as WorkerError, c as WorkerRef, l as WorkerReport, n as WorkerBudgetScope, r as WorkerCompletion } from "./Worker
|
|
9
|
-
import { V as RunSubagentDigests, x as RunContextPreparation } from "./RunOptions-
|
|
10
|
-
import { i as SubagentHost, l as WorkerReporting } from "./SubagentHost-
|
|
11
|
-
import { S as ToolCallWaiting, _ as SubagentDurability, b as SubagentDurabilityError, c as AgentSpawner, h as SpawnRunOptions, l as AgentSpawnerParent, o as AgentRuntimeFailure, p as RuntimeBinding, s as AgentRuntimeRequirements } from "./AgentRuntime-
|
|
7
|
+
import { T as RunDispositionDeclaration, _ as InstructionSource, c as Definition, m as InputPromptSource, r as AnyDefinition } from "./Agent-CM6JubNX.mjs";
|
|
8
|
+
import { a as WorkerError, c as WorkerRef, l as WorkerReport, n as WorkerBudgetScope, r as WorkerCompletion } from "./Worker--j87JI__.mjs";
|
|
9
|
+
import { V as RunSubagentDigests, x as RunContextPreparation } from "./RunOptions-CE-G3niT.mjs";
|
|
10
|
+
import { i as SubagentHost, l as WorkerReporting } from "./SubagentHost-DaFMZnVR.mjs";
|
|
11
|
+
import { S as ToolCallWaiting, _ as SubagentDurability, b as SubagentDurabilityError, c as AgentSpawner, h as SpawnRunOptions, l as AgentSpawnerParent, o as AgentRuntimeFailure, p as RuntimeBinding, s as AgentRuntimeRequirements } from "./AgentRuntime-CufqQ4JM.mjs";
|
|
12
12
|
import { t as RunEventSink } from "./RunEventSink-D5aVhISG.mjs";
|
|
13
13
|
import { Tool, Toolkit } from "effect/unstable/ai";
|
|
14
14
|
import { Crypto, Duration, Effect, Layer, Schema, Scope, Stream } from "effect";
|
|
@@ -823,4 +823,4 @@ declare function background<const Name extends string, Input extends Schema.Top,
|
|
|
823
823
|
declare function background<const Name extends string, Input extends Schema.Top, Output extends Schema.Top, Parameters extends Schema.Top, Success extends Schema.Top, Failure extends Schema.Top, Prepare, Project, const Selected extends BackgroundOptions>(declaration: Declaration<Name, Input, Output, Parameters, Success, Failure, Prepare, Project>, selected: Selected): ReturnType<typeof background$1<Name, Input, Output, Parameters, Success, Failure, Prepare, Project, Selected>>;
|
|
824
824
|
//#endregion
|
|
825
825
|
export { cancel as A, delegationAllocationFromPolicy as B, reporting as C, Worker as D, BackgroundTools as E, start as F, SubagentPolicy as I, SubagentPolicyInput as L, inspect as M, list as N, WorkerObservation as O, observe as P, SubagentPrestartDenied as R, make as S, BackgroundOptions as T, delegationCapsFromPolicy as V, SubagentTools as _, SubagentDelegation as a, define as b, SubagentFailureMode as c, SubagentResult as d, SubagentResultContext as f, SubagentToolFailure as g, SubagentTool as h, SubagentDefineOptions as i, followUp as j, awaitWorker as k, SubagentLayerRequirements as l, SubagentRuntimeOptions as m, SubagentContainedFailure as n, SubagentDurableAccounting as o, SubagentReturnModeFailure as p, SubagentDeclarationOptions as r, SubagentDurableOptions as s, SubagentChildRunFailure as t, SubagentPrepareContext as u, Subagent_d_exports as v, reportingToWorker as w, layer as x, background as y, SubagentProjectionFailure as z };
|
|
826
|
-
//# sourceMappingURL=Subagent-
|
|
826
|
+
//# sourceMappingURL=Subagent-DscbtbNY.d.mts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { c as SettlementId, r as DelegationId, s as RunId, u as ThreadId } from "./Identifiers-CN2s30fF.mjs";
|
|
2
2
|
import { i as SubagentBudgetReservation } from "./SubagentContract-DdT7Cqe6.mjs";
|
|
3
3
|
import { a as Receipt, n as JoinedToHost, t as IdempotencyKey } from "./Receipt-BAHyigAF.mjs";
|
|
4
|
-
import { t as AgentPolicy } from "./AgentPolicy-
|
|
5
|
-
import { r as AnyDefinition } from "./Agent-
|
|
6
|
-
import { a as WorkerError, c as WorkerRef, d as WorkerStarted, f as WorkerSummary, i as WorkerContext, n as WorkerBudgetScope, o as WorkerHistoryEntry, r as WorkerCompletion, s as WorkerPage, u as WorkerSource } from "./Worker
|
|
4
|
+
import { t as AgentPolicy } from "./AgentPolicy-BqDoSXO6.mjs";
|
|
5
|
+
import { r as AnyDefinition } from "./Agent-CM6JubNX.mjs";
|
|
6
|
+
import { a as WorkerError, c as WorkerRef, d as WorkerStarted, f as WorkerSummary, i as WorkerContext, n as WorkerBudgetScope, o as WorkerHistoryEntry, r as WorkerCompletion, s as WorkerPage, u as WorkerSource } from "./Worker--j87JI__.mjs";
|
|
7
7
|
import { Context, Effect, Option, Schema, Stream } from "effect";
|
|
8
8
|
declare namespace SubagentHost_d_exports {
|
|
9
9
|
export { BackgroundReporting, FollowUpWorkerRequest, StartWorkerRequest, SubagentHost, WorkerObservation, WorkerReceiptRequest, WorkerReportPreparationFailure, WorkerReporting, WorkerRunReport };
|
|
@@ -137,4 +137,4 @@ declare class SubagentHost extends SubagentHost_base {
|
|
|
137
137
|
}
|
|
138
138
|
//#endregion
|
|
139
139
|
export { SubagentHost_d_exports as a, WorkerReportPreparationFailure as c, SubagentHost as i, WorkerReporting as l, FollowUpWorkerRequest as n, WorkerObservation as o, StartWorkerRequest as r, WorkerReceiptRequest as s, BackgroundReporting as t, WorkerRunReport as u };
|
|
140
|
-
//# sourceMappingURL=SubagentHost-
|
|
140
|
+
//# sourceMappingURL=SubagentHost-DaFMZnVR.d.mts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { d as SubagentReservationAmounts, l as SubagentGrant, o as SubagentDelegationCaps, s as SubagentExecutionFailure } from "./SubagentContract-DdT7Cqe6.mjs";
|
|
2
2
|
import { a as Receipt, r as Principal } from "./Receipt-BAHyigAF.mjs";
|
|
3
3
|
import { r as Update } from "./AgentUpdates-DMJ-_xow.mjs";
|
|
4
|
-
import { t as AgentPolicy } from "./AgentPolicy-
|
|
5
|
-
import { _ as Digest, h as DefinitionDigests } from "./Records-
|
|
6
|
-
import { t as ScheduleAuthorizationDecision } from "./Schedule-
|
|
4
|
+
import { t as AgentPolicy } from "./AgentPolicy-BqDoSXO6.mjs";
|
|
5
|
+
import { _ as Digest, h as DefinitionDigests } from "./Records-B84j3Jq_.mjs";
|
|
6
|
+
import { t as ScheduleAuthorizationDecision } from "./Schedule-DCYBfhgT.mjs";
|
|
7
7
|
import { Context, Effect, Schema } from "effect";
|
|
8
8
|
declare namespace Subscription_d_exports {
|
|
9
9
|
export { AcceptedEvent, DeliveryChange, EventAcknowledgement, EventSourceVersion, PreparedInput, SourcePartition, SourceRecovery, SubscriptionAuthorizer, SubscriptionChange, SubscriptionConfiguration, SubscriptionDelivery, SubscriptionDeliveryKey, SubscriptionDeliverySnapshot, SubscriptionError, SubscriptionFailpoint, SubscriptionFailpointError, SubscriptionKey, SubscriptionLimits, SubscriptionName, SubscriptionRecord, SubscriptionRefusal, SubscriptionRetentionPolicy, SubscriptionScanCursors, SubscriptionScope, SubscriptionSnapshot, SubscriptionSourceError, SubscriptionStore, SubscriptionStoreFailure, defaultSubscriptionLimits, subscriptionDeliveryKeyString, subscriptionKeyString };
|
|
@@ -918,4 +918,4 @@ declare const subscriptionKeyString: (key: SubscriptionKey) => string;
|
|
|
918
918
|
declare const subscriptionDeliveryKeyString: (key: SubscriptionDeliveryKey) => string;
|
|
919
919
|
//#endregion
|
|
920
920
|
export { defaultSubscriptionLimits as A, SubscriptionScanCursors as C, SubscriptionStore as D, SubscriptionSourceError as E, subscriptionKeyString as M, SubscriptionStoreFailure as O, SubscriptionRetentionPolicy as S, SubscriptionSnapshot as T, SubscriptionKey as _, PreparedInput as a, SubscriptionRecord as b, SubscriptionAuthorizer as c, SubscriptionDelivery as d, SubscriptionDeliveryKey as f, SubscriptionFailpointError as g, SubscriptionFailpoint as h, EventSourceVersion as i, subscriptionDeliveryKeyString as j, Subscription_d_exports as k, SubscriptionChange as l, SubscriptionError as m, DeliveryChange as n, SourcePartition as o, SubscriptionDeliverySnapshot as p, EventAcknowledgement as r, SourceRecovery as s, AcceptedEvent as t, SubscriptionConfiguration as u, SubscriptionLimits as v, SubscriptionScope as w, SubscriptionRefusal as x, SubscriptionName as y };
|
|
921
|
-
//# sourceMappingURL=Subscription-
|
|
921
|
+
//# sourceMappingURL=Subscription-C8IHdmFk.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as AgentId } from "./Identifiers-CN2s30fF.mjs";
|
|
2
|
-
import { O as PersistedJson, h as DefinitionDigests } from "./Records-
|
|
3
|
-
import { E as SubscriptionSourceError, b as SubscriptionRecord, i as EventSourceVersion, m as SubscriptionError, t as AcceptedEvent, u as SubscriptionConfiguration } from "./Subscription-
|
|
2
|
+
import { O as PersistedJson, h as DefinitionDigests } from "./Records-B84j3Jq_.mjs";
|
|
3
|
+
import { E as SubscriptionSourceError, b as SubscriptionRecord, i as EventSourceVersion, m as SubscriptionError, t as AcceptedEvent, u as SubscriptionConfiguration } from "./Subscription-C8IHdmFk.mjs";
|
|
4
4
|
import { Context, Effect, Schema, Scope } from "effect";
|
|
5
5
|
declare namespace SubscriptionInput_d_exports {
|
|
6
6
|
export { SubscriptionInputBinding, SubscriptionInputBindings, makeSubscriptionInputBinding, resolveSubscriptionInput };
|
|
@@ -38,4 +38,4 @@ declare const makeSubscriptionInputBinding: <Event extends Schema.Top, Parameter
|
|
|
38
38
|
}) => Effect.Effect<SubscriptionInputBinding, never, Exclude<R, Scope.Scope> | Exclude<Continuation["DecodingServices"], Scope.Scope> | Exclude<Continuation["EncodingServices"], Scope.Scope> | Exclude<Event["DecodingServices"], Scope.Scope> | Exclude<Input["EncodingServices"], Scope.Scope> | Exclude<Parameters["DecodingServices"], Scope.Scope>>;
|
|
39
39
|
//#endregion
|
|
40
40
|
export { resolveSubscriptionInput as a, makeSubscriptionInputBinding as i, SubscriptionInputBindings as n, SubscriptionInput_d_exports as r, SubscriptionInputBinding as t };
|
|
41
|
-
//# sourceMappingURL=SubscriptionInput-
|
|
41
|
+
//# sourceMappingURL=SubscriptionInput-DhM3jUW2.d.mts.map
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
+
import { AiError } from "effect/unstable/ai";
|
|
2
3
|
declare namespace ToolResult_d_exports {
|
|
3
|
-
export { ToolResultBounds, TruncatedToolResult, UnserializableToolResult, applyToolResultBounds, unserializableToolResult };
|
|
4
|
+
export { ToolParameterRejection, ToolResultBounds, TruncatedToolResult, UnserializableToolResult, applyToolResultBounds, unserializableToolResult };
|
|
4
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Engine-owned evidence that a fresh model call failed parameter validation.
|
|
8
|
+
* Retain the exact JSON arguments beside the native error so recovery can distinguish
|
|
9
|
+
* a rejected request from damaged executable parameters. This never authorizes execution.
|
|
10
|
+
*/
|
|
11
|
+
declare const ToolParameterRejection: Schema.Struct<{
|
|
12
|
+
readonly toolCallId: Schema.brand<Schema.NonEmptyString, "@effect-agent/core/ToolCallId">;
|
|
13
|
+
readonly parameters: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
14
|
+
readonly error: Schema.toEncoded<Schema.Struct<{
|
|
15
|
+
readonly _tag: Schema.tag<"AiError">;
|
|
16
|
+
readonly module: Schema.String;
|
|
17
|
+
readonly method: Schema.String;
|
|
18
|
+
readonly reason: typeof AiError.ToolParameterValidationError;
|
|
19
|
+
}>>;
|
|
20
|
+
}>;
|
|
21
|
+
type ToolParameterRejection = typeof ToolParameterRejection.Type;
|
|
5
22
|
declare const ToolResultBounds_base: Schema.Class<ToolResultBounds, Schema.Struct<{
|
|
6
23
|
readonly maxBytes: Schema.Int;
|
|
7
24
|
}>, {}>;
|
|
@@ -57,5 +74,5 @@ declare const unserializableToolResult: (cause: unknown) => typeof Unserializabl
|
|
|
57
74
|
*/
|
|
58
75
|
declare const applyToolResultBounds: (encodedJson: string, bounds: ToolResultBounds) => string;
|
|
59
76
|
//#endregion
|
|
60
|
-
export {
|
|
61
|
-
//# sourceMappingURL=ToolResult-
|
|
77
|
+
export { UnserializableToolResult as a, TruncatedToolResult as i, ToolResultBounds as n, applyToolResultBounds as o, ToolResult_d_exports as r, unserializableToolResult as s, ToolParameterRejection as t };
|
|
78
|
+
//# sourceMappingURL=ToolResult-BKdqWRff.d.mts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { l as SubagentGrant, p as WorkerOperationTool, s as SubagentExecutionFailure } from "./SubagentContract-DdT7Cqe6.mjs";
|
|
2
2
|
import { a as Receipt } from "./Receipt-BAHyigAF.mjs";
|
|
3
3
|
import { r as Update } from "./AgentUpdates-DMJ-_xow.mjs";
|
|
4
|
-
import { t as AgentPolicy } from "./AgentPolicy-
|
|
4
|
+
import { t as AgentPolicy } from "./AgentPolicy-BqDoSXO6.mjs";
|
|
5
5
|
import { Schema } from "effect";
|
|
6
6
|
declare namespace Worker_d_exports {
|
|
7
7
|
export { FrameworkMessage, WorkerBudgetScope, WorkerCompletion, WorkerContext, WorkerError, WorkerHistoryEntry, WorkerOperationTool, WorkerPage, WorkerRef, WorkerReport, WorkerSource, WorkerStarted, WorkerSummary, WorkerUpdate };
|
|
@@ -225,4 +225,4 @@ declare const FrameworkMessage: Schema.Union<readonly [Schema.Struct<{
|
|
|
225
225
|
type FrameworkMessage = typeof FrameworkMessage.Type;
|
|
226
226
|
//#endregion
|
|
227
227
|
export { WorkerError as a, WorkerRef as c, WorkerStarted as d, WorkerSummary as f, WorkerContext as i, WorkerReport as l, Worker_d_exports as m, WorkerBudgetScope as n, WorkerHistoryEntry as o, WorkerUpdate as p, WorkerCompletion as r, WorkerPage as s, FrameworkMessage as t, WorkerSource as u };
|
|
228
|
-
//# sourceMappingURL=Worker
|
|
228
|
+
//# sourceMappingURL=Worker--j87JI__.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
|
|
3
2
|
import { RunId, ThreadId, ToolCallId } from "../core/Identifiers.mjs";
|
|
3
|
+
import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
|
|
4
4
|
import { RedactedPreview, Redactor } from "./Redaction.mjs";
|
|
5
5
|
import { Clock, Context, DateTime, Duration, Effect, Layer, Ref, Schema } from "effect";
|
|
6
6
|
//#region src/capabilities/Approval.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as CommandDrainPolicy } from "../RunOptions-
|
|
1
|
+
import { o as CommandDrainPolicy } from "../RunOptions-CE-G3niT.mjs";
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
3
|
declare namespace Commands_d_exports {
|
|
4
4
|
export { FollowUpCommand, RunCommand, RunCommandQueue, RunCommandQueueClosed, RunCommandQueueConfig, SteeringCommand, makeRunCommandQueue };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as MessagingError, d as InboxPage, f as InputMessage, g as MessageStatus, h as MessageRef, m as MessageAdmission, p as MessageAddress, u as InboxEntry, v as PeerName } from "../MessagingHost-
|
|
2
|
-
import { a as inspect, c as reply, d as retryTool, f as send, i as inboxTool, l as replyTool, n as Peer, o as inspectTool, p as sendTool, r as inbox, s as peer, u as retry } from "../Messaging-
|
|
1
|
+
import { _ as MessagingError, d as InboxPage, f as InputMessage, g as MessageStatus, h as MessageRef, m as MessageAdmission, p as MessageAddress, u as InboxEntry, v as PeerName } from "../MessagingHost-gAxs5gme.mjs";
|
|
2
|
+
import { a as inspect, c as reply, d as retryTool, f as send, i as inboxTool, l as replyTool, n as Peer, o as inspectTool, p as sendTool, r as inbox, s as peer, u as retry } from "../Messaging-QMYhp297.mjs";
|
|
3
3
|
export { InboxEntry, InboxPage, InputMessage, MessageAddress, MessageAdmission, MessageRef, MessageStatus, MessagingError, Peer, PeerName, inbox, inboxTool, inspect, inspectTool, peer, reply, replyTool, retry, retryTool, send, sendTool };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
|
|
3
2
|
import { ThreadId } from "../core/Identifiers.mjs";
|
|
3
|
+
import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
|
|
4
4
|
import { Thread, ThreadMessage, ThreadText } from "../core/Thread.mjs";
|
|
5
5
|
import { Crypto, Effect, Encoding, Schema } from "effect";
|
|
6
6
|
//#region src/capabilities/ModelContext.ts
|
|
@@ -2,7 +2,7 @@ import { c as ThreadLimitExceeded, i as ThreadEncodingError, s as ThreadHistoryD
|
|
|
2
2
|
import { RedactionError, Redactor } from "./Redaction.mjs";
|
|
3
3
|
import { ApprovalAudit, ApprovalAuditLimitExceeded, ApprovalDecisionMismatch, ApprovalRequestDraft, ApprovalResolver, ApprovalResolverError } from "./Approval.mjs";
|
|
4
4
|
import { BudgetExceeded, UsageBudgetNode } from "./Budget.mjs";
|
|
5
|
-
import { M as RunOptions, R as RunSchedulingHook, _ as RunBudgetHook, b as RunContextHook, g as RunApprovalRequest, h as RunApprovalHook, j as RunInputHook, w as RunContextRequest } from "../RunOptions-
|
|
5
|
+
import { M as RunOptions, R as RunSchedulingHook, _ as RunBudgetHook, b as RunContextHook, g as RunApprovalRequest, h as RunApprovalHook, j as RunInputHook, w as RunContextRequest } from "../RunOptions-CE-G3niT.mjs";
|
|
6
6
|
import { RunCommandQueue } from "./Commands.mjs";
|
|
7
7
|
import { Prompt } from "effect/unstable/ai";
|
|
8
8
|
import { Effect, Schema } from "effect";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { c as SubagentExecutionFailureClassification, l as SubagentGrant, s as SubagentExecutionFailure } from "../SubagentContract-DdT7Cqe6.mjs";
|
|
2
|
-
import { l as WorkerReport, r as WorkerCompletion } from "../Worker
|
|
3
|
-
import { A as cancel, B as delegationAllocationFromPolicy, C as reporting, D as Worker, E as BackgroundTools, F as start, I as SubagentPolicy, L as SubagentPolicyInput, M as inspect, N as list, O as WorkerObservation, P as observe, R as SubagentPrestartDenied, S as make, T as BackgroundOptions, V as delegationCapsFromPolicy, _ as SubagentTools, a as SubagentDelegation, b as define, c as SubagentFailureMode, d as SubagentResult, f as SubagentResultContext, g as SubagentToolFailure, h as SubagentTool, i as SubagentDefineOptions, j as followUp, k as awaitWorker, l as SubagentLayerRequirements, m as SubagentRuntimeOptions, n as SubagentContainedFailure, o as SubagentDurableAccounting, p as SubagentReturnModeFailure, r as SubagentDeclarationOptions, s as SubagentDurableOptions, t as SubagentChildRunFailure, u as SubagentPrepareContext, w as reportingToWorker, x as layer, y as background, z as SubagentProjectionFailure } from "../Subagent-
|
|
2
|
+
import { l as WorkerReport, r as WorkerCompletion } from "../Worker--j87JI__.mjs";
|
|
3
|
+
import { A as cancel, B as delegationAllocationFromPolicy, C as reporting, D as Worker, E as BackgroundTools, F as start, I as SubagentPolicy, L as SubagentPolicyInput, M as inspect, N as list, O as WorkerObservation, P as observe, R as SubagentPrestartDenied, S as make, T as BackgroundOptions, V as delegationCapsFromPolicy, _ as SubagentTools, a as SubagentDelegation, b as define, c as SubagentFailureMode, d as SubagentResult, f as SubagentResultContext, g as SubagentToolFailure, h as SubagentTool, i as SubagentDefineOptions, j as followUp, k as awaitWorker, l as SubagentLayerRequirements, m as SubagentRuntimeOptions, n as SubagentContainedFailure, o as SubagentDurableAccounting, p as SubagentReturnModeFailure, r as SubagentDeclarationOptions, s as SubagentDurableOptions, t as SubagentChildRunFailure, u as SubagentPrepareContext, w as reportingToWorker, x as layer, y as background, z as SubagentProjectionFailure } from "../Subagent-DscbtbNY.mjs";
|
|
4
4
|
export { type BackgroundOptions, type BackgroundTools, SubagentChildRunFailure, SubagentContainedFailure, SubagentDeclarationOptions, SubagentDefineOptions, SubagentDelegation, SubagentDurableAccounting, SubagentDurableOptions, SubagentExecutionFailure, SubagentExecutionFailureClassification, SubagentFailureMode, SubagentGrant, SubagentLayerRequirements, SubagentPolicy, type SubagentPolicyInput, SubagentPrepareContext, SubagentPrestartDenied, SubagentProjectionFailure, SubagentResult, SubagentResultContext, SubagentReturnModeFailure, SubagentRuntimeOptions, SubagentTool, SubagentToolFailure, SubagentTools, Worker, WorkerCompletion, WorkerObservation, WorkerReport, awaitWorker as await, background, cancel, define, delegationAllocationFromPolicy, delegationCapsFromPolicy, followUp, inspect, layer, list, make, observe, reporting, reportingToWorker, start };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SubagentExecutionFailure, SubagentExecutionFailureClassification, SubagentGrant } from "../core/SubagentContract.mjs";
|
|
2
2
|
import { WorkerCompletion, WorkerReport } from "../core/Worker.mjs";
|
|
3
3
|
import "./SubagentReservations.mjs";
|
|
4
|
-
import { C as delegationCapsFromPolicy, S as delegationAllocationFromPolicy, _ as reporting, a as define, b as SubagentPrestartDenied, c as Worker, d as cancel, f as followUp, g as start, h as observe, i as background, l as WorkerObservation, m as list, n as SubagentResult, o as layer, p as inspect, s as make, t as SubagentDurableAccounting, u as awaitWorker, v as reportingToWorker, x as SubagentProjectionFailure, y as SubagentPolicy } from "../Subagent-
|
|
4
|
+
import { C as delegationCapsFromPolicy, S as delegationAllocationFromPolicy, _ as reporting, a as define, b as SubagentPrestartDenied, c as Worker, d as cancel, f as followUp, g as start, h as observe, i as background, l as WorkerObservation, m as list, n as SubagentResult, o as layer, p as inspect, s as make, t as SubagentDurableAccounting, u as awaitWorker, v as reportingToWorker, x as SubagentProjectionFailure, y as SubagentPolicy } from "../Subagent-Cbfzylz1.mjs";
|
|
5
5
|
export { SubagentDurableAccounting, SubagentExecutionFailure, SubagentExecutionFailureClassification, SubagentGrant, SubagentPolicy, SubagentPrestartDenied, SubagentProjectionFailure, SubagentResult, Worker, WorkerCompletion, WorkerObservation, WorkerReport, awaitWorker as await, background, cancel, define, delegationAllocationFromPolicy, delegationCapsFromPolicy, followUp, inspect, layer, list, make, observe, reporting, reportingToWorker, start };
|
|
@@ -38,23 +38,34 @@ declare const Match_base: Schema.Class<Match, Schema.Struct<{
|
|
|
38
38
|
* transformations do not change the wire values documented for application handlers.
|
|
39
39
|
*/
|
|
40
40
|
declare class Match extends Match_base {}
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Only documented nativeToolName values activate schemas; Code Mode aliases activate their
|
|
43
|
+
* owning Tool. A byte-limited result is successful, including when no matches fit: an empty
|
|
44
|
+
* toolNames array clears the non-pinned selection under the engine's replacement contract.
|
|
45
|
+
*/
|
|
42
46
|
declare const Result: Schema.Struct<{
|
|
43
47
|
readonly toolNames: Schema.$Array<Schema.NonEmptyString>;
|
|
44
48
|
readonly matches: Schema.$Array<typeof Match>;
|
|
49
|
+
/** Present when the byte budget omits complete matches, with guidance for continuing. */
|
|
50
|
+
readonly notice: Schema.optionalKey<Schema.String>;
|
|
45
51
|
}>;
|
|
46
52
|
declare const ToolDiscoveryError_base: Schema.Class<ToolDiscoveryError, Schema.TaggedStruct<"ToolDiscoveryError", {
|
|
47
|
-
readonly reason: Schema.Literals<readonly ["invalid-catalogue", "invalid-matches", "unknown-match", "invalid-schema"
|
|
53
|
+
readonly reason: Schema.Literals<readonly ["invalid-catalogue", "invalid-matches", "unknown-match", "invalid-schema"]>;
|
|
48
54
|
readonly message: Schema.String;
|
|
49
55
|
}>, import("effect/Cause").YieldableError>;
|
|
50
|
-
/** Invalid custom results
|
|
56
|
+
/** Invalid custom results and unsupported documentation remain typed failures. */
|
|
51
57
|
declare class ToolDiscoveryError extends ToolDiscoveryError_base {}
|
|
52
58
|
interface Options<Failure extends Schema.Top = typeof Schema.Never, Requirements = never> {
|
|
53
59
|
/** Optional generic instructions. Namespace names and hints are never appended here. */
|
|
54
60
|
readonly description?: string | undefined;
|
|
55
61
|
/** Maximum returned catalogue entries, default 8 and at most 64. */
|
|
56
62
|
readonly maxResults?: number | undefined;
|
|
57
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Complete JSON-encoded result budget, including any notice: default 32768, minimum 256,
|
|
65
|
+
* maximum 262144 UTF-8 bytes. Within the first maxResults candidates, retain whole matches
|
|
66
|
+
* in rank order when they fit; skip oversized matches and try later candidates. Overflow
|
|
67
|
+
* returns a successful result with an actionable notice, never partial schemas.
|
|
68
|
+
*/
|
|
58
69
|
readonly maxResultBytes?: number | undefined;
|
|
59
70
|
/** Short category hints returned only for namespaces present in the visible catalogue. */
|
|
60
71
|
readonly namespaceDescriptions?: Readonly<Record<string, string>> | undefined;
|
|
@@ -84,6 +95,8 @@ declare const make: <Failure extends Schema.Top = typeof Schema.Never, Requireme
|
|
|
84
95
|
readonly success: Schema.Struct<{
|
|
85
96
|
readonly toolNames: Schema.$Array<Schema.NonEmptyString>;
|
|
86
97
|
readonly matches: Schema.$Array<typeof Match>;
|
|
98
|
+
/** Present when the byte budget omits complete matches, with guidance for continuing. */
|
|
99
|
+
readonly notice: Schema.optionalKey<Schema.String>;
|
|
87
100
|
}>;
|
|
88
101
|
readonly failure: Schema.Union<readonly [Schema.Codec<Failure["Type"], Failure["Encoded"], Failure["DecodingServices"], Failure["EncodingServices"]>, typeof ToolDiscoveryError]>;
|
|
89
102
|
readonly failureMode: "error";
|
|
@@ -97,6 +110,8 @@ declare const make: <Failure extends Schema.Top = typeof Schema.Never, Requireme
|
|
|
97
110
|
readonly success: Schema.Struct<{
|
|
98
111
|
readonly toolNames: Schema.$Array<Schema.NonEmptyString>;
|
|
99
112
|
readonly matches: Schema.$Array<typeof Match>;
|
|
113
|
+
/** Present when the byte budget omits complete matches, with guidance for continuing. */
|
|
114
|
+
readonly notice: Schema.optionalKey<Schema.String>;
|
|
100
115
|
}>;
|
|
101
116
|
readonly failure: Schema.Union<readonly [Schema.Codec<Failure["Type"], Failure["Encoded"], Failure["DecodingServices"], Failure["EncodingServices"]>, typeof ToolDiscoveryError]>;
|
|
102
117
|
readonly failureMode: "error";
|
|
@@ -44,19 +44,24 @@ var Match = class extends Schema.Class("@effect-agent/capabilities/ToolDiscovery
|
|
|
44
44
|
parameters: Schema.Json,
|
|
45
45
|
success: Schema.Json
|
|
46
46
|
}) {};
|
|
47
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Only documented nativeToolName values activate schemas; Code Mode aliases activate their
|
|
49
|
+
* owning Tool. A byte-limited result is successful, including when no matches fit: an empty
|
|
50
|
+
* toolNames array clears the non-pinned selection under the engine's replacement contract.
|
|
51
|
+
*/
|
|
48
52
|
const Result = Schema.Struct({
|
|
49
53
|
toolNames: Schema.Array(Name).check(Schema.isMaxLength(64), Schema.isUnique()),
|
|
50
|
-
matches: Schema.Array(Match).check(Schema.isMaxLength(64))
|
|
54
|
+
matches: Schema.Array(Match).check(Schema.isMaxLength(64)),
|
|
55
|
+
/** Present when the byte budget omits complete matches, with guidance for continuing. */
|
|
56
|
+
notice: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(192)))
|
|
51
57
|
});
|
|
52
|
-
/** Invalid custom results
|
|
58
|
+
/** Invalid custom results and unsupported documentation remain typed failures. */
|
|
53
59
|
var ToolDiscoveryError = class extends Schema.TaggedError()("ToolDiscoveryError", {
|
|
54
60
|
reason: Schema.Literals([
|
|
55
61
|
"invalid-catalogue",
|
|
56
62
|
"invalid-matches",
|
|
57
63
|
"unknown-match",
|
|
58
|
-
"invalid-schema"
|
|
59
|
-
"limit-exceeded"
|
|
64
|
+
"invalid-schema"
|
|
60
65
|
]),
|
|
61
66
|
message: Schema.String.check(Schema.isMaxLength(1024))
|
|
62
67
|
}) {};
|
|
@@ -72,6 +77,13 @@ const Bounds = Schema.Struct({
|
|
|
72
77
|
})),
|
|
73
78
|
namespaceDescriptions: Schema.Record(Namespace, NamespaceDescription)
|
|
74
79
|
});
|
|
80
|
+
const resultByteLength = Effect.fnUntraced(function* (result) {
|
|
81
|
+
const encoded = yield* Schema.encodeEffect(Schema.fromJsonString(Result))(result).pipe(Effect.mapError(() => ToolDiscoveryError.make({
|
|
82
|
+
reason: "invalid-schema",
|
|
83
|
+
message: "Discovery documentation could not be encoded"
|
|
84
|
+
})));
|
|
85
|
+
return utf8ByteLength(encoded);
|
|
86
|
+
});
|
|
75
87
|
const entryId = (entry) => entry.kind === "native" ? `native:${entry.tool.name}` : `code-mode:${entry.nativeToolName}:${entry.namespace}.${entry.method}`;
|
|
76
88
|
const compare = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
77
89
|
const defaultSearch = (request, catalogue, entries) => {
|
|
@@ -188,15 +200,22 @@ const make = (options = {}) => {
|
|
|
188
200
|
toolNames: [...new Set(matches.map((match) => match.nativeToolName))],
|
|
189
201
|
matches
|
|
190
202
|
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
203
|
+
if ((yield* resultByteLength(result)) <= bounds.maxResultBytes) return result;
|
|
204
|
+
let bounded = {
|
|
205
|
+
toolNames: [],
|
|
206
|
+
matches: [],
|
|
207
|
+
notice: "Result byte limit reached. Narrow the search or namespace; if one tool still cannot fit, ask the host to increase maxResultBytes."
|
|
208
|
+
};
|
|
209
|
+
for (const match of matches) {
|
|
210
|
+
const candidates = [...bounded.matches, match];
|
|
211
|
+
const candidate = {
|
|
212
|
+
...bounded,
|
|
213
|
+
toolNames: [...new Set(candidates.map((entry) => entry.nativeToolName))],
|
|
214
|
+
matches: candidates
|
|
215
|
+
};
|
|
216
|
+
if ((yield* resultByteLength(candidate)) <= bounds.maxResultBytes) bounded = candidate;
|
|
217
|
+
}
|
|
218
|
+
return bounded;
|
|
200
219
|
}) });
|
|
201
220
|
}));
|
|
202
221
|
return Object.freeze({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolDiscovery.mjs","names":[],"sources":["../../src/capabilities/ToolDiscovery.ts"],"sourcesContent":["import { Effect, Schema, type Scope } from \"effect\";\nimport { Tool, Toolkit } from \"effect/unstable/ai\";\n\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { DiscoveryTool, PinnedTool } from \"../core/ToolExposure.ts\";\nimport { ToolExecutionClass } from \"../engine/DurableStep.ts\";\nimport { CurrentToolCatalog, type CatalogEntry } from \"../engine/ToolExposure.ts\";\n\nconst Name = Schema.NonEmptyString.check(Schema.isMaxLength(256));\nconst Namespace = Schema.NonEmptyString.check(Schema.isMaxLength(128));\nconst Description = Schema.String.check(Schema.isMaxLength(2_048));\nconst NamespaceDescription = Schema.String.check(Schema.isMaxLength(512));\nconst EntryId = Schema.NonEmptyString.check(Schema.isMaxLength(1_024));\n\n/** Search text is bounded and literal; namespace selects one exact host-declared group. */\nexport const Parameters = Schema.Struct({\n query: Schema.NonEmptyString.check(Schema.isMaxLength(512), Schema.isPattern(/\\S/)),\n namespace: Schema.optionalKey(Namespace),\n});\n\n/** Metadata given to custom search only after host visibility and inherited grants are applied. */\nexport class Descriptor extends Schema.Class<Descriptor>(\n \"@effect-agent/capabilities/ToolDiscovery/Descriptor\",\n)({\n id: EntryId,\n kind: Schema.Literals([\"native\", \"code-mode\"]),\n name: Name,\n nativeToolName: Name,\n namespace: Schema.optionalKey(Namespace),\n method: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(128))),\n description: Schema.optionalKey(Description),\n namespaceDescription: Schema.optionalKey(NamespaceDescription),\n}) {}\n\n/**\n * Selected metadata and canonical encoded Tool Schemas. Provider-specific model schema\n * transformations do not change the wire values documented for application handlers.\n */\nexport class Match extends Schema.Class<Match>(\"@effect-agent/capabilities/ToolDiscovery/Match\")({\n ...Descriptor.fields,\n parameters: Schema.Json,\n success: Schema.Json,\n}) {}\n\n/** Only nativeToolName values activate schemas; Code Mode aliases activate their owning Tool. */\nexport const Result = Schema.Struct({\n toolNames: Schema.Array(Name).check(Schema.isMaxLength(64), Schema.isUnique()),\n matches: Schema.Array(Match).check(Schema.isMaxLength(64)),\n});\n\n/** Invalid custom results, unsupported documentation, and bounded output failures remain typed. */\nexport class ToolDiscoveryError extends Schema.TaggedError<ToolDiscoveryError>()(\n \"ToolDiscoveryError\",\n {\n reason: Schema.Literals([\n \"invalid-catalogue\",\n \"invalid-matches\",\n \"unknown-match\",\n \"invalid-schema\",\n \"limit-exceeded\",\n ]),\n message: Schema.String.check(Schema.isMaxLength(1_024)),\n },\n) {}\n\nconst MatchIds = Schema.Array(EntryId).check(Schema.isMaxLength(1_024), Schema.isUnique());\n\nconst Bounds = Schema.Struct({\n maxResults: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 64 })),\n maxResultBytes: Schema.Int.check(Schema.isBetween({ minimum: 256, maximum: 256 * 1024 })),\n namespaceDescriptions: Schema.Record(Namespace, NamespaceDescription),\n});\n\nexport interface Options<Failure extends Schema.Top = typeof Schema.Never, Requirements = never> {\n /** Optional generic instructions. Namespace names and hints are never appended here. */\n readonly description?: string | undefined;\n /** Maximum returned catalogue entries, default 8 and at most 64. */\n readonly maxResults?: number | undefined;\n /** Complete JSON-encoded result budget, default 32768 and at most 262144 UTF-8 bytes. */\n readonly maxResultBytes?: number | undefined;\n /** Short category hints returned only for namespaces present in the visible catalogue. */\n readonly namespaceDescriptions?: Readonly<Record<string, string>> | undefined;\n /** Schema of the custom search's expected failures; defaults to Schema.Never. */\n readonly failure?: Failure | undefined;\n /**\n * Rank unique Descriptor.id values, never tool names. Native tools and each Code Mode alias\n * have distinct identities. Every returned id is checked before the result limit is applied.\n * The catalogue is already filtered by the optional exact namespace and current authority.\n * Services are captured with the handler Layer; temporary resources close after each search.\n */\n readonly search?:\n | ((\n request: typeof Parameters.Type,\n catalogue: ReadonlyArray<Descriptor>,\n ) => Effect.Effect<ReadonlyArray<string>, Failure[\"Type\"], Requirements>)\n | undefined;\n}\n\nconst entryId = (entry: CatalogEntry): string =>\n entry.kind === \"native\"\n ? `native:${entry.tool.name}`\n : `code-mode:${entry.nativeToolName}:${entry.namespace}.${entry.method}`;\n\nconst compare = (left: string, right: string): number => (left < right ? -1 : left > right ? 1 : 0);\n\nconst defaultSearch = (\n request: typeof Parameters.Type,\n catalogue: ReadonlyArray<Descriptor>,\n entries: ReadonlyMap<string, CatalogEntry>,\n): ReadonlyArray<string> => {\n const terms = request.query.trim().toLowerCase().split(/\\s+/);\n\n return catalogue\n .filter((entry) => {\n const original = entries.get(entry.id);\n\n if (original === undefined) return false;\n\n const text = [\n entry.name,\n entry.namespace ?? \"\",\n entry.method ?? \"\",\n Tool.getDescription(original.tool) ?? \"\",\n entry.namespaceDescription ?? \"\",\n ]\n .join(\" \")\n .toLowerCase();\n\n return terms.every((term) => text.includes(term));\n })\n .map((entry) => entry.id);\n};\n\n/**\n * Build one native discover_tools Tool and its singleton Toolkit/handler Layer. Include the\n * Tool beside the application's existing native Tools. The engine owns catalogue authority\n * and applies successful native selections after a complete Tool batch; the handler mutates\n * no exposure state. Default search matches all case-insensitive whitespace-separated terms\n * against names, descriptions, methods and namespace hints, ordered by catalogue id.\n */\nexport const make = <Failure extends Schema.Top = typeof Schema.Never, Requirements = never>(\n options: Options<Failure, Requirements> = {},\n) => {\n const bounds = Schema.decodeSync(Bounds)({\n maxResults: options.maxResults ?? 8,\n maxResultBytes: options.maxResultBytes ?? 32 * 1024,\n namespaceDescriptions: options.namespaceDescriptions ?? {},\n });\n\n const search = options.search;\n\n const declaredFailure: Schema.Codec<\n Failure[\"Type\"],\n Failure[\"Encoded\"],\n Failure[\"DecodingServices\"],\n Failure[\"EncodingServices\"]\n > = options.failure ?? Schema.Never;\n\n const tool = Tool.make(\"discover_tools\", {\n description:\n options.description ??\n \"Find available tools using short search terms and an optional exact namespace. All terms must match a name, description or namespace hint, ignoring case. Returned native tools become available next turn. Code Mode matches document namespace methods and select their owning execution tool.\",\n parameters: Parameters,\n success: Result,\n failure: Schema.Union([declaredFailure, ToolDiscoveryError]),\n failureMode: \"error\",\n dependencies: [CurrentToolCatalog],\n })\n .annotate(DiscoveryTool, true)\n .annotate(PinnedTool, true)\n .annotate(Tool.Readonly, true)\n .annotate(ToolExecutionClass, \"readonly\");\n\n // Restore the known singleton name; native ToolsByName leaves its conditional deferred\n // over the generic failure Schema. This assertion changes no Schema or runtime value.\n const toolkit = Toolkit.make(tool) as unknown as Toolkit.Toolkit<{\n readonly discover_tools: typeof tool;\n }>;\n\n const handlers = toolkit.toLayer(\n Effect.gen(function* () {\n const searchServices = yield* Effect.context<Exclude<Requirements, Scope.Scope>>();\n\n return toolkit.of({\n discover_tools: Effect.fn(\"ToolDiscovery.discover_tools\")(function* (request) {\n const snapshot = yield* CurrentToolCatalog;\n\n const entries = snapshot.entries\n .filter(\n (entry) => request.namespace === undefined || entry.namespace === request.namespace,\n )\n .toSorted((left, right) => compare(entryId(left), entryId(right)));\n\n const catalogue: Array<Descriptor> = [];\n const byId = new Map<string, CatalogEntry>();\n\n for (const entry of entries) {\n const id = entryId(entry);\n\n if (byId.has(id)) {\n return yield* ToolDiscoveryError.make({\n reason: \"invalid-catalogue\",\n message: \"The visible catalogue contains duplicate entry identities\",\n });\n }\n const description = Tool.getDescription(entry.tool);\n\n const namespaceDescription =\n entry.namespace === undefined ||\n !Object.hasOwn(bounds.namespaceDescriptions, entry.namespace)\n ? undefined\n : bounds.namespaceDescriptions[entry.namespace];\n\n const descriptor = yield* Schema.decodeEffect(Descriptor)({\n id,\n kind: entry.kind,\n name: entry.tool.name,\n nativeToolName: entry.nativeToolName,\n ...(entry.namespace === undefined ? {} : { namespace: entry.namespace }),\n ...(entry.kind === \"code-mode\" ? { method: entry.method } : {}),\n ...(description === undefined\n ? {}\n : {\n description:\n description.length > 2_048 ? `${description.slice(0, 2_047)}…` : description,\n }),\n ...(namespaceDescription === undefined ? {} : { namespaceDescription }),\n }).pipe(\n Effect.mapError(() =>\n ToolDiscoveryError.make({\n reason: \"invalid-catalogue\",\n message: \"The visible catalogue contains invalid metadata\",\n }),\n ),\n );\n\n catalogue.push(Object.freeze(descriptor));\n byId.set(id, entry);\n }\n\n const ids =\n search === undefined\n ? defaultSearch(request, catalogue, byId)\n : yield* Effect.scoped(search(request, Object.freeze(catalogue))).pipe(\n Effect.provideContext(searchServices),\n );\n\n const checkedIds = yield* Schema.decodeEffect(MatchIds)(ids).pipe(\n Effect.mapError(() =>\n ToolDiscoveryError.make({\n reason: \"invalid-matches\",\n message: \"Search must return at most 1024 unique catalogue entry ids\",\n }),\n ),\n );\n\n if (checkedIds.some((id) => !byId.has(id))) {\n return yield* ToolDiscoveryError.make({\n reason: \"unknown-match\",\n message: \"Search returned an entry outside the visible catalogue\",\n });\n }\n\n const descriptors = new Map(catalogue.map((descriptor) => [descriptor.id, descriptor]));\n const matches: Array<Match> = [];\n\n for (const id of checkedIds.slice(0, bounds.maxResults)) {\n const entry = byId.get(id);\n const descriptor = descriptors.get(id);\n\n if (entry === undefined || descriptor === undefined) {\n return yield* ToolDiscoveryError.make({\n reason: \"unknown-match\",\n message: \"Search returned an entry outside the visible catalogue\",\n });\n }\n if (Tool.isProviderDefined(entry.tool)) {\n return yield* ToolDiscoveryError.make({\n reason: \"invalid-schema\",\n message: \"Provider-defined Tools do not expose application handler documentation\",\n });\n }\n\n const schemas = yield* Effect.try({\n try: () => ({\n parameters: Tool.getJsonSchema(entry.tool),\n success: Tool.getJsonSchemaFromSchema(entry.tool.successSchema),\n }),\n catch: () =>\n ToolDiscoveryError.make({\n reason: \"invalid-schema\",\n message: \"A selected Tool cannot be documented as JSON Schema\",\n }),\n });\n\n const match = yield* Schema.decodeUnknownEffect(Match)({\n ...descriptor,\n ...schemas,\n }).pipe(\n Effect.mapError(() =>\n ToolDiscoveryError.make({\n reason: \"invalid-schema\",\n message: \"A selected Tool's documentation is outside the JSON surface\",\n }),\n ),\n );\n\n matches.push(match);\n }\n\n const result = {\n toolNames: [...new Set(matches.map((match) => match.nativeToolName))],\n matches,\n };\n\n const encoded = yield* Schema.encodeEffect(Schema.fromJsonString(Result))(result).pipe(\n Effect.mapError(() =>\n ToolDiscoveryError.make({\n reason: \"invalid-schema\",\n message: \"Discovery documentation could not be encoded\",\n }),\n ),\n );\n\n if (utf8ByteLength(encoded) > bounds.maxResultBytes) {\n return yield* ToolDiscoveryError.make({\n reason: \"limit-exceeded\",\n message: \"Selected documentation exceeds the result byte limit; narrow the search\",\n });\n }\n\n return result;\n }),\n });\n }),\n );\n\n return Object.freeze({ tool, toolkit, handlers });\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAQA,MAAM,OAAO,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;AAChE,MAAM,YAAY,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;AACrE,MAAM,cAAc,OAAO,OAAO,MAAM,OAAO,YAAY,IAAK,CAAC;AACjE,MAAM,uBAAuB,OAAO,OAAO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O,mBAAmB,KAAK;KACpC,QAAQ;KACR,SAAS;IACX,CAAC;IAEH,IAAI,KAAK,kBAAkB,MAAM,IAAI,GACnC,OAAO,OAAO,mBAAmB,KAAK;KACpC,QAAQ;KACR,SAAS;IACX,CAAC;IAGH,MAAM,UAAU,OAAO,OAAO,IAAI;KAChC,YAAY;MACV,YAAY,KAAK,cAAc,MAAM,IAAI;MACzC,SAAS,KAAK,wBAAwB,MAAM,KAAK,aAAa;KAChE;KACA,aACE,mBAAmB,KAAK;MACtB,QAAQ;MACR,SAAS;KACX,CAAC;IACL,CAAC;IAED,MAAM,QAAQ,OAAO,OAAO,oBAAoB,KAAK,CAAC,CAAC;KACrD,GAAG;KACH,GAAG;IACL,CAAC,CAAC,CAAC,KACD,OAAO,eACL,mBAAmB,KAAK;KACtB,QAAQ;KACR,SAAS;IACX,CAAC,CACH,CACF;IAEA,QAAQ,KAAK,KAAK;GACpB;GAEA,MAAM,SAAS;IACb,WAAW,CAAC,GAAG,IAAI,IAAI,QAAQ,KAAK,UAAU,MAAM,cAAc,CAAC,CAAC;IACpE;GACF;GAEA,MAAM,UAAU,OAAO,OAAO,aAAa,OAAO,eAAe,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAChF,OAAO,eACL,mBAAmB,KAAK;IACtB,QAAQ;IACR,SAAS;GACX,CAAC,CACH,CACF;GAEA,IAAI,eAAe,OAAO,IAAI,OAAO,gBACnC,OAAO,OAAO,mBAAmB,KAAK;IACpC,QAAQ;IACR,SAAS;GACX,CAAC;GAGH,OAAO;EACT,CAAC,EACH,CAAC;CACH,CAAC,CACH;CAEA,OAAO,OAAO,OAAO;EAAE;EAAM;EAAS;CAAS,CAAC;AAClD"}
|
|
1
|
+
{"version":3,"file":"ToolDiscovery.mjs","names":[],"sources":["../../src/capabilities/ToolDiscovery.ts"],"sourcesContent":["import { Effect, Schema, type Scope } from \"effect\";\nimport { Tool, Toolkit } from \"effect/unstable/ai\";\n\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { DiscoveryTool, PinnedTool } from \"../core/ToolExposure.ts\";\nimport { ToolExecutionClass } from \"../engine/DurableStep.ts\";\nimport { CurrentToolCatalog, type CatalogEntry } from \"../engine/ToolExposure.ts\";\n\nconst Name = Schema.NonEmptyString.check(Schema.isMaxLength(256));\nconst Namespace = Schema.NonEmptyString.check(Schema.isMaxLength(128));\nconst Description = Schema.String.check(Schema.isMaxLength(2_048));\nconst NamespaceDescription = Schema.String.check(Schema.isMaxLength(512));\nconst EntryId = Schema.NonEmptyString.check(Schema.isMaxLength(1_024));\n\n/** Search text is bounded and literal; namespace selects one exact host-declared group. */\nexport const Parameters = Schema.Struct({\n query: Schema.NonEmptyString.check(Schema.isMaxLength(512), Schema.isPattern(/\\S/)),\n namespace: Schema.optionalKey(Namespace),\n});\n\n/** Metadata given to custom search only after host visibility and inherited grants are applied. */\nexport class Descriptor extends Schema.Class<Descriptor>(\n \"@effect-agent/capabilities/ToolDiscovery/Descriptor\",\n)({\n id: EntryId,\n kind: Schema.Literals([\"native\", \"code-mode\"]),\n name: Name,\n nativeToolName: Name,\n namespace: Schema.optionalKey(Namespace),\n method: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(128))),\n description: Schema.optionalKey(Description),\n namespaceDescription: Schema.optionalKey(NamespaceDescription),\n}) {}\n\n/**\n * Selected metadata and canonical encoded Tool Schemas. Provider-specific model schema\n * transformations do not change the wire values documented for application handlers.\n */\nexport class Match extends Schema.Class<Match>(\"@effect-agent/capabilities/ToolDiscovery/Match\")({\n ...Descriptor.fields,\n parameters: Schema.Json,\n success: Schema.Json,\n}) {}\n\n/**\n * Only documented nativeToolName values activate schemas; Code Mode aliases activate their\n * owning Tool. A byte-limited result is successful, including when no matches fit: an empty\n * toolNames array clears the non-pinned selection under the engine's replacement contract.\n */\nexport const Result = Schema.Struct({\n toolNames: Schema.Array(Name).check(Schema.isMaxLength(64), Schema.isUnique()),\n matches: Schema.Array(Match).check(Schema.isMaxLength(64)),\n /** Present when the byte budget omits complete matches, with guidance for continuing. */\n notice: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(192))),\n});\n\n/** Invalid custom results and unsupported documentation remain typed failures. */\nexport class ToolDiscoveryError extends Schema.TaggedError<ToolDiscoveryError>()(\n \"ToolDiscoveryError\",\n {\n reason: Schema.Literals([\n \"invalid-catalogue\",\n \"invalid-matches\",\n \"unknown-match\",\n \"invalid-schema\",\n ]),\n message: Schema.String.check(Schema.isMaxLength(1_024)),\n },\n) {}\n\nconst MatchIds = Schema.Array(EntryId).check(Schema.isMaxLength(1_024), Schema.isUnique());\n\nconst Bounds = Schema.Struct({\n maxResults: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 64 })),\n maxResultBytes: Schema.Int.check(Schema.isBetween({ minimum: 256, maximum: 256 * 1024 })),\n namespaceDescriptions: Schema.Record(Namespace, NamespaceDescription),\n});\n\nconst resultByteLength = Effect.fnUntraced(function* (result: typeof Result.Type) {\n const encoded = yield* Schema.encodeEffect(Schema.fromJsonString(Result))(result).pipe(\n Effect.mapError(() =>\n ToolDiscoveryError.make({\n reason: \"invalid-schema\",\n message: \"Discovery documentation could not be encoded\",\n }),\n ),\n );\n\n return utf8ByteLength(encoded);\n});\n\nexport interface Options<Failure extends Schema.Top = typeof Schema.Never, Requirements = never> {\n /** Optional generic instructions. Namespace names and hints are never appended here. */\n readonly description?: string | undefined;\n /** Maximum returned catalogue entries, default 8 and at most 64. */\n readonly maxResults?: number | undefined;\n /**\n * Complete JSON-encoded result budget, including any notice: default 32768, minimum 256,\n * maximum 262144 UTF-8 bytes. Within the first maxResults candidates, retain whole matches\n * in rank order when they fit; skip oversized matches and try later candidates. Overflow\n * returns a successful result with an actionable notice, never partial schemas.\n */\n readonly maxResultBytes?: number | undefined;\n /** Short category hints returned only for namespaces present in the visible catalogue. */\n readonly namespaceDescriptions?: Readonly<Record<string, string>> | undefined;\n /** Schema of the custom search's expected failures; defaults to Schema.Never. */\n readonly failure?: Failure | undefined;\n /**\n * Rank unique Descriptor.id values, never tool names. Native tools and each Code Mode alias\n * have distinct identities. Every returned id is checked before the result limit is applied.\n * The catalogue is already filtered by the optional exact namespace and current authority.\n * Services are captured with the handler Layer; temporary resources close after each search.\n */\n readonly search?:\n | ((\n request: typeof Parameters.Type,\n catalogue: ReadonlyArray<Descriptor>,\n ) => Effect.Effect<ReadonlyArray<string>, Failure[\"Type\"], Requirements>)\n | undefined;\n}\n\nconst entryId = (entry: CatalogEntry): string =>\n entry.kind === \"native\"\n ? `native:${entry.tool.name}`\n : `code-mode:${entry.nativeToolName}:${entry.namespace}.${entry.method}`;\n\nconst compare = (left: string, right: string): number => (left < right ? -1 : left > right ? 1 : 0);\n\nconst defaultSearch = (\n request: typeof Parameters.Type,\n catalogue: ReadonlyArray<Descriptor>,\n entries: ReadonlyMap<string, CatalogEntry>,\n): ReadonlyArray<string> => {\n const terms = request.query.trim().toLowerCase().split(/\\s+/);\n\n return catalogue\n .filter((entry) => {\n const original = entries.get(entry.id);\n\n if (original === undefined) return false;\n\n const text = [\n entry.name,\n entry.namespace ?? \"\",\n entry.method ?? \"\",\n Tool.getDescription(original.tool) ?? \"\",\n entry.namespaceDescription ?? \"\",\n ]\n .join(\" \")\n .toLowerCase();\n\n return terms.every((term) => text.includes(term));\n })\n .map((entry) => entry.id);\n};\n\n/**\n * Build one native discover_tools Tool and its singleton Toolkit/handler Layer. Include the\n * Tool beside the application's existing native Tools. The engine owns catalogue authority\n * and applies successful native selections after a complete Tool batch; the handler mutates\n * no exposure state. Default search matches all case-insensitive whitespace-separated terms\n * against names, descriptions, methods and namespace hints, ordered by catalogue id.\n */\nexport const make = <Failure extends Schema.Top = typeof Schema.Never, Requirements = never>(\n options: Options<Failure, Requirements> = {},\n) => {\n const bounds = Schema.decodeSync(Bounds)({\n maxResults: options.maxResults ?? 8,\n maxResultBytes: options.maxResultBytes ?? 32 * 1024,\n namespaceDescriptions: options.namespaceDescriptions ?? {},\n });\n\n const search = options.search;\n\n const declaredFailure: Schema.Codec<\n Failure[\"Type\"],\n Failure[\"Encoded\"],\n Failure[\"DecodingServices\"],\n Failure[\"EncodingServices\"]\n > = options.failure ?? Schema.Never;\n\n const tool = Tool.make(\"discover_tools\", {\n description:\n options.description ??\n \"Find available tools using short search terms and an optional exact namespace. All terms must match a name, description or namespace hint, ignoring case. Returned native tools become available next turn. Code Mode matches document namespace methods and select their owning execution tool.\",\n parameters: Parameters,\n success: Result,\n failure: Schema.Union([declaredFailure, ToolDiscoveryError]),\n failureMode: \"error\",\n dependencies: [CurrentToolCatalog],\n })\n .annotate(DiscoveryTool, true)\n .annotate(PinnedTool, true)\n .annotate(Tool.Readonly, true)\n .annotate(ToolExecutionClass, \"readonly\");\n\n // Restore the known singleton name; native ToolsByName leaves its conditional deferred\n // over the generic failure Schema. This assertion changes no Schema or runtime value.\n const toolkit = Toolkit.make(tool) as unknown as Toolkit.Toolkit<{\n readonly discover_tools: typeof tool;\n }>;\n\n const handlers = toolkit.toLayer(\n Effect.gen(function* () {\n const searchServices = yield* Effect.context<Exclude<Requirements, Scope.Scope>>();\n\n return toolkit.of({\n discover_tools: Effect.fn(\"ToolDiscovery.discover_tools\")(function* (request) {\n const snapshot = yield* CurrentToolCatalog;\n\n const entries = snapshot.entries\n .filter(\n (entry) => request.namespace === undefined || entry.namespace === request.namespace,\n )\n .toSorted((left, right) => compare(entryId(left), entryId(right)));\n\n const catalogue: Array<Descriptor> = [];\n const byId = new Map<string, CatalogEntry>();\n\n for (const entry of entries) {\n const id = entryId(entry);\n\n if (byId.has(id)) {\n return yield* ToolDiscoveryError.make({\n reason: \"invalid-catalogue\",\n message: \"The visible catalogue contains duplicate entry identities\",\n });\n }\n const description = Tool.getDescription(entry.tool);\n\n const namespaceDescription =\n entry.namespace === undefined ||\n !Object.hasOwn(bounds.namespaceDescriptions, entry.namespace)\n ? undefined\n : bounds.namespaceDescriptions[entry.namespace];\n\n const descriptor = yield* Schema.decodeEffect(Descriptor)({\n id,\n kind: entry.kind,\n name: entry.tool.name,\n nativeToolName: entry.nativeToolName,\n ...(entry.namespace === undefined ? {} : { namespace: entry.namespace }),\n ...(entry.kind === \"code-mode\" ? { method: entry.method } : {}),\n ...(description === undefined\n ? {}\n : {\n description:\n description.length > 2_048 ? `${description.slice(0, 2_047)}…` : description,\n }),\n ...(namespaceDescription === undefined ? {} : { namespaceDescription }),\n }).pipe(\n Effect.mapError(() =>\n ToolDiscoveryError.make({\n reason: \"invalid-catalogue\",\n message: \"The visible catalogue contains invalid metadata\",\n }),\n ),\n );\n\n catalogue.push(Object.freeze(descriptor));\n byId.set(id, entry);\n }\n\n const ids =\n search === undefined\n ? defaultSearch(request, catalogue, byId)\n : yield* Effect.scoped(search(request, Object.freeze(catalogue))).pipe(\n Effect.provideContext(searchServices),\n );\n\n const checkedIds = yield* Schema.decodeEffect(MatchIds)(ids).pipe(\n Effect.mapError(() =>\n ToolDiscoveryError.make({\n reason: \"invalid-matches\",\n message: \"Search must return at most 1024 unique catalogue entry ids\",\n }),\n ),\n );\n\n if (checkedIds.some((id) => !byId.has(id))) {\n return yield* ToolDiscoveryError.make({\n reason: \"unknown-match\",\n message: \"Search returned an entry outside the visible catalogue\",\n });\n }\n\n const descriptors = new Map(catalogue.map((descriptor) => [descriptor.id, descriptor]));\n const matches: Array<Match> = [];\n\n for (const id of checkedIds.slice(0, bounds.maxResults)) {\n const entry = byId.get(id);\n const descriptor = descriptors.get(id);\n\n if (entry === undefined || descriptor === undefined) {\n return yield* ToolDiscoveryError.make({\n reason: \"unknown-match\",\n message: \"Search returned an entry outside the visible catalogue\",\n });\n }\n if (Tool.isProviderDefined(entry.tool)) {\n return yield* ToolDiscoveryError.make({\n reason: \"invalid-schema\",\n message: \"Provider-defined Tools do not expose application handler documentation\",\n });\n }\n\n const schemas = yield* Effect.try({\n try: () => ({\n parameters: Tool.getJsonSchema(entry.tool),\n success: Tool.getJsonSchemaFromSchema(entry.tool.successSchema),\n }),\n catch: () =>\n ToolDiscoveryError.make({\n reason: \"invalid-schema\",\n message: \"A selected Tool cannot be documented as JSON Schema\",\n }),\n });\n\n const match = yield* Schema.decodeUnknownEffect(Match)({\n ...descriptor,\n ...schemas,\n }).pipe(\n Effect.mapError(() =>\n ToolDiscoveryError.make({\n reason: \"invalid-schema\",\n message: \"A selected Tool's documentation is outside the JSON surface\",\n }),\n ),\n );\n\n matches.push(match);\n }\n\n const result = {\n toolNames: [...new Set(matches.map((match) => match.nativeToolName))],\n matches,\n };\n\n if ((yield* resultByteLength(result)) <= bounds.maxResultBytes) return result;\n\n // Validate every selected schema before packing. A byte limit must not mask an\n // invalid catalogue/schema. The empty notice envelope fits the minimum 256 bytes.\n let bounded: typeof Result.Type = {\n toolNames: [],\n matches: [],\n notice:\n \"Result byte limit reached. Narrow the search or namespace; if one tool still cannot fit, ask the host to increase maxResultBytes.\",\n };\n\n for (const match of matches) {\n const candidates = [...bounded.matches, match];\n\n const candidate = {\n ...bounded,\n toolNames: [...new Set(candidates.map((entry) => entry.nativeToolName))],\n matches: candidates,\n };\n\n if ((yield* resultByteLength(candidate)) <= bounds.maxResultBytes) bounded = candidate;\n }\n\n return bounded;\n }),\n });\n }),\n );\n\n return Object.freeze({ tool, toolkit, handlers });\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAQA,MAAM,OAAO,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;AAChE,MAAM,YAAY,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;AACrE,MAAM,cAAc,OAAO,OAAO,MAAM,OAAO,YAAY,IAAK,CAAC;AACjE,MAAM,uBAAuB,OAAO,OAAO,MAAM,OAAO,YAAY,GAAG,CAAC;AACxE,MAAM,UAAU,OAAO,eAAe,MAAM,OAAO,YAAY,IAAK,CAAC;;AAGrE,MAAa,aAAa,OAAO,OAAO;CACtC,OAAO,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,GAAG,OAAO,UAAU,IAAI,CAAC;CAClF,WAAW,OAAO,YAAY,SAAS;AAC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O,OAAO;EAAE;EAAM;EAAS;CAAS,CAAC;AAClD"}
|
package/dist/core/Agent.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as Tools, C as Requirements, D as RunDispositionSchema, E as RunDispositionFailure, F as withModel, M as UpdatesSchema, N as inspectTools, O as ToolInspection, P as make, S as OutputSchema, T as RunDispositionDeclaration, _ as InstructionSource, a as CompletionFromToolDeclaration, b as NativeModel, c as Definition, d as EncodedInput, f as Failure, g as InstructionResult, h as InputSchema, i as Binding, j as Update, k as ToolUnion, l as DefinitionOptions, m as InputPromptSource, n as Any, o as CompletionProjectionInput, p as Input, r as AnyDefinition, s as CompletionToolDeclaration, u as DefinitionRequirements, v as ModelServices, w as RunDisposition, x as Output, y as Name } from "../Agent-
|
|
1
|
+
import { A as Tools, C as Requirements, D as RunDispositionSchema, E as RunDispositionFailure, F as withModel, M as UpdatesSchema, N as inspectTools, O as ToolInspection, P as make, S as OutputSchema, T as RunDispositionDeclaration, _ as InstructionSource, a as CompletionFromToolDeclaration, b as NativeModel, c as Definition, d as EncodedInput, f as Failure, g as InstructionResult, h as InputSchema, i as Binding, j as Update, k as ToolUnion, l as DefinitionOptions, m as InputPromptSource, n as Any, o as CompletionProjectionInput, p as Input, r as AnyDefinition, s as CompletionToolDeclaration, u as DefinitionRequirements, v as ModelServices, w as RunDisposition, x as Output, y as Name } from "../Agent-CM6JubNX.mjs";
|
|
2
2
|
export { Any, AnyDefinition, Binding, CompletionFromToolDeclaration, CompletionProjectionInput, CompletionToolDeclaration, Definition, DefinitionOptions, DefinitionRequirements, EncodedInput, Failure, Input, InputPromptSource, InputSchema, InstructionResult, InstructionSource, ModelServices, Name, NativeModel, Output, OutputSchema, Requirements, RunDisposition, RunDispositionDeclaration, RunDispositionFailure, RunDispositionSchema, ToolInspection, ToolUnion, Tools, Update, UpdatesSchema, inspectTools, make, withModel };
|
package/dist/core/Agent.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as withModel, i as make, n as ToolInspection, r as inspectTools } from "../Agent-
|
|
1
|
+
import { a as withModel, i as make, n as ToolInspection, r as inspectTools } from "../Agent-CG_VMrtA.mjs";
|
|
2
2
|
export { ToolInspection, inspectTools, make, withModel };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as CompactionPolicyInput, i as CompactionPolicy, n as AgentPolicyInput, t as AgentPolicy } from "../AgentPolicy-
|
|
1
|
+
import { a as CompactionPolicyInput, i as CompactionPolicy, n as AgentPolicyInput, t as AgentPolicy } from "../AgentPolicy-BqDoSXO6.mjs";
|
|
2
2
|
export { AgentPolicy, AgentPolicyInput, CompactionPolicy, CompactionPolicyInput };
|
package/dist/core/Thread.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
|
|
3
2
|
import { RunId, ThreadId } from "./Identifiers.mjs";
|
|
3
|
+
import { n as utf8ByteLength } from "../utf8-DchGZRBd.mjs";
|
|
4
4
|
import { Prompt } from "effect/unstable/ai";
|
|
5
5
|
import { Clock, Context, DateTime, Effect, Layer, Schema, SynchronizedRef } from "effect";
|
|
6
6
|
//#region src/core/Thread.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { ToolResultBounds, TruncatedToolResult, UnserializableToolResult, applyToolResultBounds, unserializableToolResult };
|
|
1
|
+
import { a as UnserializableToolResult, i as TruncatedToolResult, n as ToolResultBounds, o as applyToolResultBounds, s as unserializableToolResult, t as ToolParameterRejection } from "../ToolResult-BKdqWRff.mjs";
|
|
2
|
+
export { ToolParameterRejection, ToolResultBounds, TruncatedToolResult, UnserializableToolResult, applyToolResultBounds, unserializableToolResult };
|
package/dist/core/ToolResult.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { ToolCallId } from "./Identifiers.mjs";
|
|
2
3
|
import { n as utf8ByteLength, t as codePointUtf8Length } from "../utf8-DchGZRBd.mjs";
|
|
3
4
|
import * as Schema from "effect/Schema";
|
|
5
|
+
import { AiError } from "effect/unstable/ai";
|
|
4
6
|
//#region src/core/ToolResult.ts
|
|
5
7
|
var ToolResult_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
ToolParameterRejection: () => ToolParameterRejection,
|
|
6
9
|
ToolResultBounds: () => ToolResultBounds,
|
|
7
10
|
TruncatedToolResult: () => TruncatedToolResult,
|
|
8
11
|
UnserializableToolResult: () => UnserializableToolResult,
|
|
@@ -10,6 +13,19 @@ var ToolResult_exports = /* @__PURE__ */ __exportAll({
|
|
|
10
13
|
unserializableToolResult: () => unserializableToolResult
|
|
11
14
|
});
|
|
12
15
|
/**
|
|
16
|
+
* Engine-owned evidence that a fresh model call failed parameter validation.
|
|
17
|
+
* Retain the exact JSON arguments beside the native error so recovery can distinguish
|
|
18
|
+
* a rejected request from damaged executable parameters. This never authorizes execution.
|
|
19
|
+
*/
|
|
20
|
+
const ToolParameterRejection = Schema.Struct({
|
|
21
|
+
toolCallId: ToolCallId,
|
|
22
|
+
parameters: Schema.Json,
|
|
23
|
+
error: Schema.toEncoded(Schema.Struct({
|
|
24
|
+
...AiError.AiError.fields,
|
|
25
|
+
reason: AiError.ToolParameterValidationError
|
|
26
|
+
}))
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
13
29
|
* The minimal `TruncatedToolResult` envelope (empty head/tail, a 16-digit
|
|
14
30
|
* `originalBytes`) encodes to at most 81 UTF-8 bytes; 256 guarantees every
|
|
15
31
|
* accepted bound fits the envelope plus some real content, so the bound is a
|
|
@@ -135,6 +151,6 @@ const applyToolResultBounds = (encodedJson, bounds) => {
|
|
|
135
151
|
}
|
|
136
152
|
};
|
|
137
153
|
//#endregion
|
|
138
|
-
export { ToolResultBounds, TruncatedToolResult, UnserializableToolResult, applyToolResultBounds, ToolResult_exports as t, unserializableToolResult };
|
|
154
|
+
export { ToolParameterRejection, ToolResultBounds, TruncatedToolResult, UnserializableToolResult, applyToolResultBounds, ToolResult_exports as t, unserializableToolResult };
|
|
139
155
|
|
|
140
156
|
//# sourceMappingURL=ToolResult.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolResult.mjs","names":[],"sources":["../../src/core/ToolResult.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nimport { codePointUtf8Length, utf8ByteLength } from \"./internal/utf8.ts\";\n\n/**\n * The minimal `TruncatedToolResult` envelope (empty head/tail, a 16-digit\n * `originalBytes`) encodes to at most 81 UTF-8 bytes; 256 guarantees every\n * accepted bound fits the envelope plus some real content, so the bound is a\n * hard resource guard rather than a best-effort one.\n */\nconst ENVELOPE_FLOOR_BYTES = 256;\n\n/** Byte bound applied to one encoded application Tool result before it enters history. */\nexport class ToolResultBounds extends Schema.Class<ToolResultBounds>(\"ToolResultBounds\")({\n maxBytes: Schema.Int.check(Schema.isGreaterThanOrEqualTo(ENVELOPE_FLOOR_BYTES)),\n}) {}\n\n/**\n * Canonical envelope replacing an encoded Tool result that exceeded its\n * policy bounds. `head` and `tail` are an exact prefix and suffix of the\n * original encoded JSON text; the middle is dropped, never paraphrased.\n */\nexport class TruncatedToolResult extends Schema.Class<TruncatedToolResult>(\"TruncatedToolResult\")({\n truncatedToolResult: Schema.Literal(true),\n originalBytes: Schema.Natural,\n head: Schema.String,\n tail: Schema.String,\n}) {}\n\n/**\n * Canonical fail-closed sentinel replacing an encoded Tool result that could\n * not be JSON-serialized at all (cyclic value, BigInt, `undefined`, throwing\n * `toJSON`). The original value never enters history or durable records —\n * an unserializable value is unbounded by construction, so the bound seam\n * replaces it wholesale rather than passing it through (runtime spec §9).\n */\nexport class UnserializableToolResult extends Schema.Class<UnserializableToolResult>(\n \"UnserializableToolResult\",\n)({\n unserializableToolResult: Schema.Literal(true),\n reason: Schema.String.check(Schema.isMaxLength(256)),\n}) {}\n\n/**\n * Build the encoded sentinel for a serialization failure. Total by\n * construction — the cause is untrusted (a hostile `toString` or an\n * accessor-backed `Error.message` can itself throw on this last-resort\n * path) — and byte-bound: the complete encoded sentinel stays within the\n * 256-byte `ToolResultBounds` schema floor, so it fits every accepted\n * policy without the caller re-applying bounds.\n */\nexport const unserializableToolResult = (\n cause: unknown,\n): typeof UnserializableToolResult.Encoded => {\n let reason: string;\n\n try {\n const message = cause instanceof Error ? cause.message : cause;\n\n reason = typeof message === \"string\" ? message : String(message);\n } catch {\n reason = \"unserializable value\";\n }\n\n const build = (clipped: string): typeof UnserializableToolResult.Encoded =>\n Schema.encodeSync(UnserializableToolResult)(\n UnserializableToolResult.make({\n unserializableToolResult: true,\n reason: clipped,\n }),\n );\n\n // JSON escaping inflates bytes, so shrink by whole code points until the\n // encoded sentinel fits the floor; the empty reason always fits.\n let clipped = takePrefixWithinBytes(reason, 128);\n let sentinel = build(clipped);\n\n while (clipped.length > 0 && utf8ByteLength(JSON.stringify(sentinel)) > 256) {\n const last = clipped.codePointAt(clipped.length - 1);\n\n clipped = clipped.slice(0, clipped.length - (last !== undefined && last > 0xffff ? 2 : 1));\n sentinel = build(clipped);\n }\n\n return sentinel;\n};\n\nconst takePrefixWithinBytes = (value: string, maxBytes: number): string => {\n let bytes = 0;\n let index = 0;\n\n while (index < value.length) {\n const codePoint = value.codePointAt(index) ?? 0;\n const width = codePointUtf8Length(codePoint);\n\n if (bytes + width > maxBytes) break;\n bytes += width;\n index += codePoint > 0xffff ? 2 : 1;\n }\n\n return value.slice(0, index);\n};\n\nconst takeSuffixWithinBytes = (value: string, maxBytes: number): string => {\n let bytes = 0;\n let index = value.length;\n\n while (index > 0) {\n const unit = value.charCodeAt(index - 1);\n const isLowSurrogate = unit >= 0xdc00 && unit <= 0xdfff;\n const pairStart = isLowSurrogate && index >= 2 ? index - 2 : index - 1;\n const codePoint = value.codePointAt(pairStart) ?? 0;\n const width = codePointUtf8Length(codePoint);\n\n if (bytes + width > maxBytes) break;\n bytes += width;\n index = pairStart;\n }\n\n return value.slice(index);\n};\n\n/**\n * Bound one encoded Tool result to `bounds.maxBytes` UTF-8 bytes.\n *\n * Within bounds the input is returned unchanged. Over bounds the result is\n * the JSON-encoded `TruncatedToolResult` envelope preserving an exact prefix\n * and suffix of the input, split ~50/50 across the byte budget left after\n * the envelope's own overhead and shrunk deterministically until the encoded\n * envelope itself fits. Slicing never splits a UTF-16 surrogate pair, so the\n * envelope always re-encodes as valid JSON.\n *\n * The Schema-level 256-byte floor on `ToolResultBounds.maxBytes` guarantees\n * every accepted bound fits the minimal envelope (at most 81 bytes), so the\n * returned value never exceeds `maxBytes` for a decodable bound. The\n * minimal-envelope fallback below survives purely as defense in depth.\n */\nexport const applyToolResultBounds = (encodedJson: string, bounds: ToolResultBounds): string => {\n const originalBytes = utf8ByteLength(encodedJson);\n\n if (originalBytes <= bounds.maxBytes) return encodedJson;\n\n const render = (head: string, tail: string): string =>\n JSON.stringify(\n Schema.encodeSync(TruncatedToolResult)(\n TruncatedToolResult.make({ truncatedToolResult: true, originalBytes, head, tail }),\n ),\n );\n\n const minimal = render(\"\", \"\");\n const contentBudget = bounds.maxBytes - utf8ByteLength(minimal);\n\n if (contentBudget <= 0) return minimal;\n let headBudget = Math.floor(contentBudget / 2);\n let tailBudget = contentBudget - headBudget;\n\n for (;;) {\n const head = takePrefixWithinBytes(encodedJson, headBudget);\n const tail = takeSuffixWithinBytes(encodedJson, tailBudget);\n const output = render(head, tail);\n const outputBytes = utf8ByteLength(output);\n\n if (outputBytes <= bounds.maxBytes) return output;\n if (headBudget === 0 && tailBudget === 0) return minimal;\n const shrink = Math.max(1, Math.ceil((outputBytes - bounds.maxBytes) / 2));\n\n headBudget = Math.max(0, headBudget - shrink);\n tailBudget = Math.max(0, tailBudget - shrink);\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ToolResult.mjs","names":[],"sources":["../../src/core/ToolResult.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\nimport { AiError } from \"effect/unstable/ai\";\n\nimport { ToolCallId } from \"./Identifiers.ts\";\nimport { codePointUtf8Length, utf8ByteLength } from \"./internal/utf8.ts\";\n\n/**\n * Engine-owned evidence that a fresh model call failed parameter validation.\n * Retain the exact JSON arguments beside the native error so recovery can distinguish\n * a rejected request from damaged executable parameters. This never authorizes execution.\n */\nexport const ToolParameterRejection = Schema.Struct({\n toolCallId: ToolCallId,\n parameters: Schema.Json,\n error: Schema.toEncoded(\n Schema.Struct({\n ...AiError.AiError.fields,\n reason: AiError.ToolParameterValidationError,\n }),\n ),\n});\n\nexport type ToolParameterRejection = typeof ToolParameterRejection.Type;\n\n/**\n * The minimal `TruncatedToolResult` envelope (empty head/tail, a 16-digit\n * `originalBytes`) encodes to at most 81 UTF-8 bytes; 256 guarantees every\n * accepted bound fits the envelope plus some real content, so the bound is a\n * hard resource guard rather than a best-effort one.\n */\nconst ENVELOPE_FLOOR_BYTES = 256;\n\n/** Byte bound applied to one encoded application Tool result before it enters history. */\nexport class ToolResultBounds extends Schema.Class<ToolResultBounds>(\"ToolResultBounds\")({\n maxBytes: Schema.Int.check(Schema.isGreaterThanOrEqualTo(ENVELOPE_FLOOR_BYTES)),\n}) {}\n\n/**\n * Canonical envelope replacing an encoded Tool result that exceeded its\n * policy bounds. `head` and `tail` are an exact prefix and suffix of the\n * original encoded JSON text; the middle is dropped, never paraphrased.\n */\nexport class TruncatedToolResult extends Schema.Class<TruncatedToolResult>(\"TruncatedToolResult\")({\n truncatedToolResult: Schema.Literal(true),\n originalBytes: Schema.Natural,\n head: Schema.String,\n tail: Schema.String,\n}) {}\n\n/**\n * Canonical fail-closed sentinel replacing an encoded Tool result that could\n * not be JSON-serialized at all (cyclic value, BigInt, `undefined`, throwing\n * `toJSON`). The original value never enters history or durable records —\n * an unserializable value is unbounded by construction, so the bound seam\n * replaces it wholesale rather than passing it through (runtime spec §9).\n */\nexport class UnserializableToolResult extends Schema.Class<UnserializableToolResult>(\n \"UnserializableToolResult\",\n)({\n unserializableToolResult: Schema.Literal(true),\n reason: Schema.String.check(Schema.isMaxLength(256)),\n}) {}\n\n/**\n * Build the encoded sentinel for a serialization failure. Total by\n * construction — the cause is untrusted (a hostile `toString` or an\n * accessor-backed `Error.message` can itself throw on this last-resort\n * path) — and byte-bound: the complete encoded sentinel stays within the\n * 256-byte `ToolResultBounds` schema floor, so it fits every accepted\n * policy without the caller re-applying bounds.\n */\nexport const unserializableToolResult = (\n cause: unknown,\n): typeof UnserializableToolResult.Encoded => {\n let reason: string;\n\n try {\n const message = cause instanceof Error ? cause.message : cause;\n\n reason = typeof message === \"string\" ? message : String(message);\n } catch {\n reason = \"unserializable value\";\n }\n\n const build = (clipped: string): typeof UnserializableToolResult.Encoded =>\n Schema.encodeSync(UnserializableToolResult)(\n UnserializableToolResult.make({\n unserializableToolResult: true,\n reason: clipped,\n }),\n );\n\n // JSON escaping inflates bytes, so shrink by whole code points until the\n // encoded sentinel fits the floor; the empty reason always fits.\n let clipped = takePrefixWithinBytes(reason, 128);\n let sentinel = build(clipped);\n\n while (clipped.length > 0 && utf8ByteLength(JSON.stringify(sentinel)) > 256) {\n const last = clipped.codePointAt(clipped.length - 1);\n\n clipped = clipped.slice(0, clipped.length - (last !== undefined && last > 0xffff ? 2 : 1));\n sentinel = build(clipped);\n }\n\n return sentinel;\n};\n\nconst takePrefixWithinBytes = (value: string, maxBytes: number): string => {\n let bytes = 0;\n let index = 0;\n\n while (index < value.length) {\n const codePoint = value.codePointAt(index) ?? 0;\n const width = codePointUtf8Length(codePoint);\n\n if (bytes + width > maxBytes) break;\n bytes += width;\n index += codePoint > 0xffff ? 2 : 1;\n }\n\n return value.slice(0, index);\n};\n\nconst takeSuffixWithinBytes = (value: string, maxBytes: number): string => {\n let bytes = 0;\n let index = value.length;\n\n while (index > 0) {\n const unit = value.charCodeAt(index - 1);\n const isLowSurrogate = unit >= 0xdc00 && unit <= 0xdfff;\n const pairStart = isLowSurrogate && index >= 2 ? index - 2 : index - 1;\n const codePoint = value.codePointAt(pairStart) ?? 0;\n const width = codePointUtf8Length(codePoint);\n\n if (bytes + width > maxBytes) break;\n bytes += width;\n index = pairStart;\n }\n\n return value.slice(index);\n};\n\n/**\n * Bound one encoded Tool result to `bounds.maxBytes` UTF-8 bytes.\n *\n * Within bounds the input is returned unchanged. Over bounds the result is\n * the JSON-encoded `TruncatedToolResult` envelope preserving an exact prefix\n * and suffix of the input, split ~50/50 across the byte budget left after\n * the envelope's own overhead and shrunk deterministically until the encoded\n * envelope itself fits. Slicing never splits a UTF-16 surrogate pair, so the\n * envelope always re-encodes as valid JSON.\n *\n * The Schema-level 256-byte floor on `ToolResultBounds.maxBytes` guarantees\n * every accepted bound fits the minimal envelope (at most 81 bytes), so the\n * returned value never exceeds `maxBytes` for a decodable bound. The\n * minimal-envelope fallback below survives purely as defense in depth.\n */\nexport const applyToolResultBounds = (encodedJson: string, bounds: ToolResultBounds): string => {\n const originalBytes = utf8ByteLength(encodedJson);\n\n if (originalBytes <= bounds.maxBytes) return encodedJson;\n\n const render = (head: string, tail: string): string =>\n JSON.stringify(\n Schema.encodeSync(TruncatedToolResult)(\n TruncatedToolResult.make({ truncatedToolResult: true, originalBytes, head, tail }),\n ),\n );\n\n const minimal = render(\"\", \"\");\n const contentBudget = bounds.maxBytes - utf8ByteLength(minimal);\n\n if (contentBudget <= 0) return minimal;\n let headBudget = Math.floor(contentBudget / 2);\n let tailBudget = contentBudget - headBudget;\n\n for (;;) {\n const head = takePrefixWithinBytes(encodedJson, headBudget);\n const tail = takeSuffixWithinBytes(encodedJson, tailBudget);\n const output = render(head, tail);\n const outputBytes = utf8ByteLength(output);\n\n if (outputBytes <= bounds.maxBytes) return output;\n if (headBudget === 0 && tailBudget === 0) return minimal;\n const shrink = Math.max(1, Math.ceil((outputBytes - bounds.maxBytes) / 2));\n\n headBudget = Math.max(0, headBudget - shrink);\n tailBudget = Math.max(0, tailBudget - shrink);\n }\n};\n"],"mapp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B,GAAG,OAAO;CAC/B,IAAI,aAAa,KAAK,MAAM,gBAAgB,CAAC;CAC7C,IAAI,aAAa,gBAAgB;CAEjC,SAAS;EAGP,MAAM,SAAS,OAFF,sBAAsB,aAAa,UAEvB,GADZ,sBAAsB,aAAa,UACjB,CAAC;EAChC,MAAM,cAAc,eAAe,MAAM;EAEzC,IAAI,eAAe,OAAO,UAAU,OAAO;EAC3C,IAAI,eAAe,KAAK,eAAe,GAAG,OAAO;EACjD,MAAM,SAAS,KAAK,IAAI,GAAG,KAAK,MAAM,cAAc,OAAO,YAAY,CAAC,CAAC;EAEzE,aAAa,KAAK,IAAI,GAAG,aAAa,MAAM;EAC5C,aAAa,KAAK,IAAI,GAAG,aAAa,MAAM;CAC9C;AACF"}
|
package/dist/core/Worker.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { p as WorkerOperationTool } from "../SubagentContract-DdT7Cqe6.mjs";
|
|
2
|
-
import { a as WorkerError, c as WorkerRef, d as WorkerStarted, f as WorkerSummary, i as WorkerContext, l as WorkerReport, n as WorkerBudgetScope, o as WorkerHistoryEntry, p as WorkerUpdate, r as WorkerCompletion, s as WorkerPage, t as FrameworkMessage, u as WorkerSource } from "../Worker
|
|
2
|
+
import { a as WorkerError, c as WorkerRef, d as WorkerStarted, f as WorkerSummary, i as WorkerContext, l as WorkerReport, n as WorkerBudgetScope, o as WorkerHistoryEntry, p as WorkerUpdate, r as WorkerCompletion, s as WorkerPage, t as FrameworkMessage, u as WorkerSource } from "../Worker--j87JI__.mjs";
|
|
3
3
|
export { FrameworkMessage, WorkerBudgetScope, WorkerCompletion, WorkerContext, WorkerError, WorkerHistoryEntry, WorkerOperationTool, WorkerPage, WorkerRef, WorkerReport, WorkerSource, WorkerStarted, WorkerSummary, WorkerUpdate };
|
package/dist/core/Worker.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { AgentPolicy } from "./AgentPolicy.mjs";
|
|
3
2
|
import { AgentId, DelegationId, RunId, SettlementId, ThreadId, ToolCallId } from "./Identifiers.mjs";
|
|
3
|
+
import { AgentPolicy } from "./AgentPolicy.mjs";
|
|
4
4
|
import { Receipt } from "./Receipt.mjs";
|
|
5
5
|
import { Update } from "./AgentUpdates.mjs";
|
|
6
6
|
import { SubagentExecutionFailure, SubagentGrant, WorkerOperationTool } from "./SubagentContract.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as Digest } from "../Records-
|
|
1
|
+
import { _ as Digest } from "../Records-B84j3Jq_.mjs";
|
|
2
2
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
3
3
|
declare namespace ActivityStore_d_exports {
|
|
4
4
|
export { ActivityBusy, ActivityClaim, ActivityClaimRequest, ActivityMutationFailpoint, ActivityMutationFailure, ActivityMutationPoint, ActivityOwnershipLost, ActivityProcessorKey, ActivityProcessorStore, ActivityProgress, ActivityStoreError, ActivityStoreFailure, ActivityWorkConflict, PreparedActivity };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { ThreadId } from "../core/Identifiers.mjs";
|
|
3
|
-
import { T as PersistedJson, h as Digest, k as RecordId, u as CanonicalSequence } from "../Records-
|
|
3
|
+
import { T as PersistedJson, h as Digest, k as RecordId, u as CanonicalSequence } from "../Records-CsEsSW2o.mjs";
|
|
4
4
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
5
5
|
//#region src/durable/ActivityStore.ts
|
|
6
6
|
var ActivityStore_exports = /* @__PURE__ */ __exportAll({
|