effect-agent 0.1.0-beta.155 → 0.1.0-beta.157
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-BjmupLN3.d.mts → Admin-BbTZHSLu.d.mts} +23 -11
- package/dist/{Agent-1DMSO_Fl.mjs → Agent-BMATXYsI.mjs} +9 -2
- package/dist/Agent-BMATXYsI.mjs.map +1 -0
- package/dist/{AgentRuntime-BAjT5gXl.d.mts → AgentRuntime-BPlAn5nA.d.mts} +6 -6
- package/dist/{AgentRuntime-IF_1GoUf.mjs → AgentRuntime-GQACxY_m.mjs} +21 -5
- package/dist/AgentRuntime-GQACxY_m.mjs.map +1 -0
- package/dist/{Digest-CaJ2RIsF.d.mts → Digest-CNHImGy0.d.mts} +2 -2
- package/dist/{DurableAgentRuntime-BQzYkFVy.mjs → DurableAgentRuntime-BAQvZK1e.mjs} +30 -18
- package/dist/DurableAgentRuntime-BAQvZK1e.mjs.map +1 -0
- package/dist/{EventSource-C8CKwQy5.d.mts → EventSource-CETtQTiH.d.mts} +3 -3
- package/dist/InMemory.d.mts +1 -1
- package/dist/{PreparedInputAdmission-CU1PzUVD.d.mts → PreparedInputAdmission-Swp9t800.d.mts} +4 -4
- package/dist/{Records-BrEpibum.d.mts → Records-BxGWRs-t.d.mts} +2 -2
- package/dist/{RunEvent-DV_llBcq.d.mts → RunEvent-D0aepYwN.d.mts} +2 -2
- package/dist/{RunEventSink-D5aVhISG.d.mts → RunEventSink-DsbcGXog.d.mts} +2 -2
- package/dist/{RunOptions-CkRYnlJa.d.mts → RunOptions-GjDlAuKh.d.mts} +5 -2
- package/dist/{Schedule-B_z7PMg-.d.mts → Schedule-B94iS2X3.d.mts} +2 -2
- package/dist/{Subagent-Dld4W1BY.d.mts → Subagent-CLaMeZKu.d.mts} +6 -6
- package/dist/{Subagent-CmFtZaeI.mjs → Subagent-JjcidJ7q.mjs} +2 -2
- package/dist/{Subagent-CmFtZaeI.mjs.map → Subagent-JjcidJ7q.mjs.map} +1 -1
- package/dist/{Subscription-BomcQ9_W.d.mts → Subscription-DaMCppa_.d.mts} +4 -4
- package/dist/{SubscriptionInput-gpZSR9vB.d.mts → SubscriptionInput-B0ZtrQoY.d.mts} +3 -3
- package/dist/{ThreadHistory-ZEu_ja6L.d.mts → ThreadHistory-FD-o4TsR.d.mts} +2 -2
- package/dist/{Usage-Dx0aknfk.d.mts → Usage-BNjPR7Zr.d.mts} +9 -1
- package/dist/{WorkerAdmission-CNbm4o_x.mjs → WorkerAdmission-N9hZV85Q.mjs} +2 -2
- package/dist/{WorkerAdmission-CNbm4o_x.mjs.map → WorkerAdmission-N9hZV85Q.mjs.map} +1 -1
- package/dist/{agent-registration-U3kmV7nW.mjs → agent-registration-BIOzAej4.mjs} +10 -1
- package/dist/agent-registration-BIOzAej4.mjs.map +1 -0
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/Redaction.d.mts +1 -1
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/Subagent.d.mts +1 -1
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/capabilities/ToolDiscovery.d.mts +5 -0
- package/dist/capabilities/ToolDiscovery.mjs +18 -9
- package/dist/capabilities/ToolDiscovery.mjs.map +1 -1
- package/dist/capabilities/WebSearch.d.mts +5 -1
- package/dist/capabilities/WebSearch.mjs +9 -1
- package/dist/capabilities/WebSearch.mjs.map +1 -1
- package/dist/core/Agent.mjs +1 -1
- package/dist/core/RunEvent.d.mts +1 -1
- package/dist/core/Usage.d.mts +1 -1
- package/dist/core/Usage.mjs +22 -1
- package/dist/core/Usage.mjs.map +1 -1
- package/dist/durable/ActivityStore.d.mts +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 +3 -3
- package/dist/durable/Digest.d.mts +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/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/LifecyclePublication.d.mts +1 -1
- package/dist/durable/LifecyclePublication.mjs +2 -2
- package/dist/durable/LifecyclePublication.mjs.map +1 -1
- package/dist/durable/MessageDelivery.d.mts +4 -4
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +3 -3
- package/dist/durable/PersistentHistory.d.mts +2 -2
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/Records.d.mts +1 -1
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/RunJournal.d.mts +1 -1
- package/dist/durable/Schedule.d.mts +1 -1
- package/dist/durable/ScheduleStoreConformance.d.mts +1 -1
- package/dist/durable/ScheduleTransition.d.mts +1 -1
- package/dist/durable/Scheduling.d.mts +3 -3
- package/dist/durable/SqlMemoryStore.d.mts +715 -5
- package/dist/durable/SqlMemoryStore.mjs +313 -123
- package/dist/durable/SqlMemoryStore.mjs.map +1 -1
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +2 -2
- 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 +1 -1
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionTools.d.mts +4 -4
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/Subscriptions.d.mts +6 -6
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
- package/dist/durable/ThreadInvariants.d.mts +2 -2
- package/dist/durable/ThreadProjection.d.mts +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/WorkerAdmission.d.mts +2 -2
- 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/RunEventSink.d.mts +1 -1
- package/dist/engine/RunOptions.d.mts +1 -1
- package/dist/engine/RunOptions.mjs +1 -0
- package/dist/engine/RunOptions.mjs.map +1 -1
- package/dist/engine/ThreadHistory.d.mts +1 -1
- package/dist/index.d.mts +15 -15
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
- package/src/capabilities/ToolDiscovery.ts +24 -10
- package/src/capabilities/WebSearch.ts +15 -0
- package/src/core/Agent.ts +16 -2
- package/src/core/Usage.ts +41 -0
- package/src/durable/DurableAgentRuntime.ts +40 -12
- package/src/durable/LifecyclePublication.ts +15 -2
- package/src/durable/SqlMemoryStore.ts +462 -188
- package/src/durable/internal/agent-registration.ts +11 -0
- package/src/engine/RunOptions.ts +3 -0
- package/src/engine/internal/agent-runtime.ts +68 -5
- package/dist/Agent-1DMSO_Fl.mjs.map +0 -1
- package/dist/AgentRuntime-IF_1GoUf.mjs.map +0 -1
- package/dist/DurableAgentRuntime-BQzYkFVy.mjs.map +0 -1
- package/dist/agent-registration-U3kmV7nW.mjs.map +0 -1
|
@@ -3,9 +3,9 @@ import { d as SubagentReservationAmounts, l as SubagentGrant, o as SubagentDeleg
|
|
|
3
3
|
import { a as Receipt, i as QueueSequence, n as JoinedToHost, r as Principal, t as IdempotencyKey } from "./Receipt-BAHyigAF.mjs";
|
|
4
4
|
import { r as Update } from "./AgentUpdates-DMJ-_xow.mjs";
|
|
5
5
|
import { c as Selection, l as Snapshot } from "./ToolExposure-r2eOWk4F.mjs";
|
|
6
|
-
import { l as RunUsageSummary, r as ModelCallUsage } from "./Usage-
|
|
7
|
-
import { a as ExhaustedLimit } from "./RunEvent-
|
|
8
|
-
import { t as ThreadHistory } from "./ThreadHistory-
|
|
6
|
+
import { l as RunUsageSummary, r as ModelCallUsage } from "./Usage-BNjPR7Zr.mjs";
|
|
7
|
+
import { a as ExhaustedLimit } from "./RunEvent-D0aepYwN.mjs";
|
|
8
|
+
import { t as ThreadHistory } from "./ThreadHistory-FD-o4TsR.mjs";
|
|
9
9
|
import { a as FailureDiagnostic_d_exports, r as Diagnostic } from "./FailureDiagnostic-CaAkzGHL.mjs";
|
|
10
10
|
import { a as AgentInputError } from "./AgentError-Bn1ytXRD.mjs";
|
|
11
11
|
import { t as ToolParameterRejection } from "./ToolResult-BKdqWRff.mjs";
|
|
@@ -13,14 +13,14 @@ import { t as AgentPolicy } from "./AgentPolicy-CnXWWwdg.mjs";
|
|
|
13
13
|
import { E as RunDispositionDeclaration, _ as InstructionSource, c as Definition, m as InputPromptSource, n as Any, r as AnyDefinition, t as Agent_d_exports, y as ModelServices } from "./Agent-BCyrGaWg.mjs";
|
|
14
14
|
import { t as RunPolicyUsage } from "./RunPolicyUsage-CUudVtg_.mjs";
|
|
15
15
|
import { c as WorkerError, f as WorkerRef, n as AssignmentTerminal } from "./Worker-2r2zGDkh.mjs";
|
|
16
|
-
import { G as RunToolAuthorization, O as RunCostEstimator, h as RunApprovalHook, x as RunContextPreparation } from "./RunOptions-
|
|
16
|
+
import { G as RunToolAuthorization, O as RunCostEstimator, h as RunApprovalHook, x as RunContextPreparation } from "./RunOptions-GjDlAuKh.mjs";
|
|
17
17
|
import { o as MessagingError, r as InputMessage } from "./Messaging-Dkg87ebg.mjs";
|
|
18
18
|
import { t as MessagingHost } from "./MessagingHost-B4jqlJmx.mjs";
|
|
19
19
|
import "./Messaging-B1zumorg.mjs";
|
|
20
20
|
import { d as WorkerReportPreparationFailure, f as WorkerReporting, o as SubagentHost } from "./SubagentHost--HBuY8fF.mjs";
|
|
21
|
-
import { p as RuntimeBinding, r as AgentCompletionProjectionRequirements, s as AgentRuntimeRequirements } from "./AgentRuntime-
|
|
22
|
-
import { $ as ToolApprovalRequested, E as ModelResponseRecorded, H as SettlementFailureDiagnostic, J as SubmissionSettled, K as SubagentRequested, L as RunCompleted, M as RecordEnvelope, N as RecordId, Q as ToolApprovalDecided, V as RunStartedRecord, W as SubagentJoined, Y as SubmissionSettledRecord, a as BatchId, ct as UserInputRecorded, d as CanonicalSequence, dt as WorkerInputCompleted, et as ToolCallPrepared, f as CompactionCreated, ft as WorkerInputRequested, g as DeploymentId, h as DefinitionDigests, j as ProducerId, k as PersistedJson, l as CanonicalRecordEnvelope, lt as WorkerAdmission, m as DefinitionDigestInput, q as SubagentStarted, r as AgentUpdateEmitted, rt as ToolCallSettled, s as CanonicalBatch, t as AbortRequested, vt as WorkerStopRequested } from "./Records-
|
|
23
|
-
import { t as DigestError } from "./Digest-
|
|
21
|
+
import { p as RuntimeBinding, r as AgentCompletionProjectionRequirements, s as AgentRuntimeRequirements } from "./AgentRuntime-BPlAn5nA.mjs";
|
|
22
|
+
import { $ as ToolApprovalRequested, E as ModelResponseRecorded, H as SettlementFailureDiagnostic, J as SubmissionSettled, K as SubagentRequested, L as RunCompleted, M as RecordEnvelope, N as RecordId, Q as ToolApprovalDecided, V as RunStartedRecord, W as SubagentJoined, Y as SubmissionSettledRecord, a as BatchId, ct as UserInputRecorded, d as CanonicalSequence, dt as WorkerInputCompleted, et as ToolCallPrepared, f as CompactionCreated, ft as WorkerInputRequested, g as DeploymentId, h as DefinitionDigests, j as ProducerId, k as PersistedJson, l as CanonicalRecordEnvelope, lt as WorkerAdmission, m as DefinitionDigestInput, q as SubagentStarted, r as AgentUpdateEmitted, rt as ToolCallSettled, s as CanonicalBatch, t as AbortRequested, vt as WorkerStopRequested } from "./Records-BxGWRs-t.mjs";
|
|
23
|
+
import { t as DigestError } from "./Digest-CNHImGy0.mjs";
|
|
24
24
|
import { n as DurableRuntimeFailpoint, r as DurableRuntimeFailpointError } from "./DurableFailpoint-Cnr3wx1L.mjs";
|
|
25
25
|
import { o as OperationDenied } from "./OperationAuthorizer-TzcQtpX5.mjs";
|
|
26
26
|
import { s as ToolReconciler } from "./ToolReconciler-BmVRAHKs.mjs";
|
|
@@ -1496,8 +1496,12 @@ declare const LifecyclePublicationBatch: Schema.NonEmptyArray<typeof LifecyclePu
|
|
|
1496
1496
|
type LifecyclePublicationBatch = typeof LifecyclePublicationBatch.Type;
|
|
1497
1497
|
/** Native recovery state, independent of Attempts. Hosts serialize drains per storage owner. */
|
|
1498
1498
|
interface LifecyclePublicationStorage {
|
|
1499
|
-
/** Select up to `limit` due owners, with a bounded pending prefix for each selected owner.
|
|
1500
|
-
|
|
1499
|
+
/** Select up to `limit` due owners, with a bounded pending prefix for each selected owner.
|
|
1500
|
+
* `retainedOnly` excludes unmaterialized source facts, for a precommitted start prefix.
|
|
1501
|
+
*/
|
|
1502
|
+
readonly pending: (nowMillis: number, limit: number, options?: {
|
|
1503
|
+
readonly retainedOnly?: boolean;
|
|
1504
|
+
}) => Effect.Effect<ReadonlyArray<LifecyclePublicationBatch>, LifecyclePublicationError>;
|
|
1501
1505
|
/** Atomically acknowledge the exact batch, retaining its identities and fingerprints. */
|
|
1502
1506
|
readonly acknowledge: (publications: LifecyclePublicationBatch) => Effect.Effect<void, LifecyclePublicationError>;
|
|
1503
1507
|
/**
|
|
@@ -1507,6 +1511,12 @@ interface LifecyclePublicationStorage {
|
|
|
1507
1511
|
*/
|
|
1508
1512
|
readonly claim: (publications: LifecyclePublicationBatch, nowMillis: number, timeoutMillis: number) => Effect.Effect<boolean, LifecyclePublicationError>;
|
|
1509
1513
|
readonly pendingDeadline: Effect.Effect<Option.Option<number>, LifecyclePublicationError>;
|
|
1514
|
+
/**
|
|
1515
|
+
* Deadline for `pending(..., { retainedOnly: true })`, excluding unmaterialized source facts.
|
|
1516
|
+
* Source-backed stores provide this when `pendingDeadline` also includes source intent.
|
|
1517
|
+
* Otherwise `pendingDeadline` already describes retained work.
|
|
1518
|
+
*/
|
|
1519
|
+
readonly retainedPendingDeadline?: Effect.Effect<Option.Option<number>, LifecyclePublicationError>;
|
|
1510
1520
|
/** Explicit operator retry after repairing a parked owner's destination. */
|
|
1511
1521
|
readonly retryParked: (ownerThreadId: ThreadId, nowMillis: number) => Effect.Effect<void, LifecyclePublicationError>;
|
|
1512
1522
|
}
|
|
@@ -1532,7 +1542,9 @@ declare const lifecyclePublicationLayer: Layer.Layer<never, never, Crypto.Crypto
|
|
|
1532
1542
|
* Finish independent owner batches before surfacing failures; interruption stops the wave.
|
|
1533
1543
|
* Acknowledgements are exact and idempotent. No producer or external Tool is re-executed here.
|
|
1534
1544
|
*/
|
|
1535
|
-
declare const drainLifecyclePublications: (storage: LifecyclePublicationStorage, timeoutMillis?: any, limit?: any
|
|
1545
|
+
declare const drainLifecyclePublications: (storage: LifecyclePublicationStorage, timeoutMillis?: any, limit?: any, options?: {
|
|
1546
|
+
readonly retainedOnly?: boolean;
|
|
1547
|
+
} | undefined) => Effect.Effect<number, LifecyclePublicationError, LifecyclePublicationHandler | SubmissionLedger | ThreadStore>;
|
|
1536
1548
|
declare namespace ThreadStore_d_exports {
|
|
1537
1549
|
export { AppendConflict, AppendResult, CheckpointRejected, FenceRejected, FencedAppendRequest, LoadCheckpointRequest, MAX_THREAD_EXPORT_RECORDS, SaveCheckpointRequest, SaveRecoveryCheckpointRequest, SelectedThreadRead, ThreadCheckpoint, ThreadCheckpoints, ThreadExport, ThreadExportRequest, ThreadIdentity, ThreadIdentityRequest, ThreadMaterialization, ThreadNotMaterialized, ThreadObservation, ThreadOutstanding, ThreadOutstandingRequest, ThreadPeerCountRequest, ThreadRead, ThreadReadRequest, ThreadRecordRequest, ThreadRecoveryCheckpoints, ThreadRunInputRequest, ThreadSelection, ThreadStore, ThreadStoreDiagnostic, ThreadStoreError, ThreadStoreFailure, ThreadTail, ThreadTailRequest, ThreadWorkerStateRequest, getRecord, getRunInput, readOutstanding, readWorkerState };
|
|
1538
1550
|
}
|
|
@@ -4252,4 +4264,4 @@ declare const RetryRefused_base: Schema.Class<RetryRefused, Schema.TaggedStruct<
|
|
|
4252
4264
|
declare class RetryRefused extends RetryRefused_base {}
|
|
4253
4265
|
//#endregion
|
|
4254
4266
|
export { RepairSubagentStartLink as $, runDurationBatchId as $i, DurableApprovalFailure as $n, ThreadRecoveryCheckpoints as $r, ParentLinkage as $t, AwaitChildSettlement as A, turnResultsBatchId as Aa, JournalBoundary as Ai, SuspensionReason as An, CheckpointRejected as Ar, ChildReservationConflict as At, MarkUnknown as B, DurableBindingFailure as Ba, compactionBatchId as Bi, settlementFailureFromRecord as Bn, ThreadExport as Br, InputAppliedMarker as Bt, renderRecoveryExplanation as C, turnBatchId as Ca, drainLifecyclePublications as Ci, SubmissionLookupByKey as Cn, isolateRecovery as Cr, ApprovalDecisionIntent as Ct, ApplyUnknownResolutions as D, turnResponseBatch as Da, SettledSubmission as Di, SubmissionWorkItem as Dn, threadCreatedRecordId as Dr, ChildAttachmentSnapshot as Dt, ApplyJoinAccounting as E, turnPreparedBatchId as Ea, PendingSubmission as Ei, SubmissionState as En, threadCreatedBatchId as Er, BeginChildBudgetReleaseRequest as Et, CompleteMaterialization as F, AgentAttemptContext as Fa, TurnCommitInput as Fi, UnknownResolutionIntent as Fn, SaveCheckpointRequest as Fr, Claim as Ft, PropagateChildAbort as G, compileBindingContracts as Ga, modelResponseInterruptedRecordId as Gi, submissionSettlementBatchId as Gn, ThreadNotMaterialized as Gr, MarkInputAppliedRequest as Gt, OpenDelegationCallEvidence as H, ExecutableAgentBinding as Ha, firstWorkerInputRecordId as Hi, submissionAbortRecordId as Hn, ThreadIdentity as Hr, JoiningClaim as Ht, DeclaredPendingBatchEvidence as I, AgentRegistration as Ia, agentUpdateRecordId as Ii, WaitingChild as In, SaveRecoveryCheckpointRequest as Ir, ClaimHandoff as It, Recovery_d_exports as J, projectRunJournal as Ji, workerTerminalFromRecord as Jn, ThreadOutstandingRequest as Jr, MarkUnknownRequest as Jt, RecoveryDecision as K, compileRegistrations as Ka, modelResponseRecordId as Ki, submissionSettlementId as Kn, ThreadObservation as Kr, MarkJoinedRequest as Kt, DelegationAdmissionEvidence as L, BindingSelection as La, approvalDecisionBatchId as Li, WaitingForChildSuspension as Ln, SelectedThreadRead as Lr, ClaimJoiningRequest as Lt, AwaitParentEstablishment as M, workerOriginRecordId as Ma, RunJournalProjection as Mi, UnknownResolution as Mn, FencedAppendRequest as Mr, ChildReservationStatus as Mt, AwaitUnknownResolution as N, workerReportRecordId as Na, RunJournalUsage as Ni, UnknownResolutionCommand as Nn, LoadCheckpointRequest as Nr, ChildSettledNotification as Nt, AwaitApprovalDecision as O, turnResponseBatchId as Oa, SubmissionStatus as Oi, SuspendRequest as On, AppendConflict as Or, ChildBudgetReservationRequest as Ot, CompleteChildAdmission as P, AgentRegistration_d_exports as Pa, RunJournal_d_exports as Pi, UnknownResolutionConflict as Pn, MAX_THREAD_EXPORT_RECORDS as Pr, ChildSettledOutcome as Pt, RepairReadiness as Q, runCompletionDigest as Qi, DurableAgentRuntime_d_exports as Qn, ThreadRecordRequest as Qr, OwnershipToken as Qt, EnsureWaitingForChild as R, BindingUnavailable as Ra, childIdempotencyKeyFor as Ri, WorkerLedgerState as Rn, ThreadCheckpoint as Rr, ClaimRequest as Rt, recoveryDecisionMeaning as S, turnApprovalsBatchId as Sa, LifecyclePublication_d_exports as Si, SubmissionLookupById as Sn, childReservationIdFor as Sr, ApprovalDecisionCommand as St, ApplyInput as T, turnIdForRun as Ta, lifecyclePublicationLayer as Ti, SubmissionSnapshot as Tn, recoveryRepairRecordId as Tr, AttachChildToReservationRequest as Tt, OpenToolCallEvidence as U, ReplayVersions as Ua, markUnknownBatchId as Ui, submissionInputBatchId as Un, ThreadIdentityRequest as Ur, LedgerCapabilities as Ut, NoAction as V, DurableWorkerBinding as Va, compactionRecordId as Vi, submissionAbortBatchId as Vn, ThreadExportRequest as Vr, JoinSnapshot as Vt, PendingApprovalEvidence as W, ResolvedBinding as Wa, modelResponseInterruptedBatchId as Wi, submissionInputRecordId as Wn, ThreadMaterialization as Wr, LedgerError as Wt, RepairInputMarker as X, promptFromCanonicalRecords as Xi, DurableAbortFailure as Xn, ThreadRead as Xr, OwnershipRenewal as Xt, ReleaseOrphanChildReservation as Y, projectRunJournalStream as Yi, ApprovalSuspensionError as Yn, ThreadPeerCountRequest as Yr, OwnershipLost as Yt, RepairJoinMarker as Z, runCompletedRecordId as Zi, DurableAgentRuntime as Zn, ThreadReadRequest as Zr, OwnershipSnapshot as Zt, RetryCommand as _, toolCallResultBatchId as _a, LifecyclePublicationError as _i, SubmissionAdmissionFence as _n, RecoveryBlocked as _r, AdmissionPolicyError as _t, IntegrityCheck as a, subagentJoinedRecordId as aa, ThreadStoreFailure as ai, ReservedChildBudget as an, DurableObserveOptions as ar, SettleAborted as at, obligationSeverityOf as b, toolStepSettledBatchId as ba, LifecyclePublicationSource as bi, SubmissionLedger_d_exports as bn, RecoverySweepOptions as br, AdmissionResult as bt, IntegrityReport as c, subagentRequestedBatchId as ca, ThreadTailRequest as ci, ResolutionCompletedWithResult as cn, DurableRetryFailure as cr, AbortCommand as ct, ObligationReport as d, subagentStartedRecordId as da, getRunInput as di, RevertJoiningRequest as dn, DurableSubmitAgent as dr, AdmissionAdmitted as dt, runDurationRecordId as ea, ThreadRunInputRequest as ei, RecoverySnapshot as en, DurableApprovalResolver as er, ResumeFromTurnBoundary as et, ObligationSeverity as f, toolApprovalDecisionRecordId as fa, readOutstanding as fi, Settlement as fn, DurableSubmitFailure as fr, AdmissionConflict as ft, RecoveryExplanation as g, toolCallResolvedRecordId as ga, LifecyclePublicationConfig as gi, SettlementReservationSnapshot as gn, DurableWorkerRequirements as gr, AdmissionNotAdmitted as gt, RecoveryDisposition as h, toolCallResolutionBatchId as ha, LifecyclePublicationBatch as hi, SettlementReservation as hn, DurableWorkerFailure as hr, AdmissionIndeterminate as ht, ExplainedUnknownCall as i, subagentJoinBatchId as ia, ThreadStoreError as ii, RenewOwnershipRequest as in, DurableObligationFailure as ir, RevertJoining as it, AwaitHostSettlement as j, workerInputRecordId as ja, RunJournalError as ji, SuspensionSnapshot as jn, FenceRejected as jr, ChildReservationId as jt, AwaitChildAdmissionResolution as k, turnResultsBatch as ka, SubmissionStatus_d_exports as ki, SuspensionOutcome as kn, AppendResult as kr, ChildBudgetReservationSnapshot as kt, ObligationBlockedOn as l, subagentRequestedRecordId as la, ThreadWorkerStateRequest as li, ResolutionNeverHappened as ln, DurableRuntimeConfig as lr, AbortIntent as lt, RECOVERY_DECISION_MEANINGS as m, toolCallPreparedRecordId as ma, LifecyclePublication as mi, SettlementFinalization as mn, DurableVerifyFailure as mr, AdmissionGroup as mt, ExplainedEvidence as n, runStartedBatchId as na, ThreadStore as ni, ReleaseChildBudgetRequest as nn, DurableAwaitFailure as nr, ResumeSuspended as nt, IntegrityCheckName as o, subagentLineageBatchId as oa, ThreadStore_d_exports as oi, ReservedSettlement as on, DurableProgressFailure as or, SettleJoinedWithHost as ot, ObligationThresholds as p, toolApprovalRequestRecordId as pa, readWorkerState as pi, SettlementConflict as pn, DurableSubmitOptions as pr, AdmissionFence as pt, RecoveryEvidence as q, definitionDigestsEqual as qa, peerMessageRecordId as qi, submissionSettlementRecordId as qn, ThreadOutstanding as qr, MarkReadyRequest as qt, ExplainedSubmission as r, runStartedRecordId as ra, ThreadStoreDiagnostic as ri, ReleaseOwnershipRequest as rn, DurableExplainFailure as rr, ResumeWaitingParent as rt, IntegrityCheckStatus as s, subagentLineageRecordId as sa, ThreadTail as si, ResolutionAbortSubmission as sn, DurableResolveFailure as sr, classifyRecovery as st, Admin_d_exports as t, runIdForSubmission as ta, ThreadSelection as ti, RecoverySnapshotRequest as tn, DurableApprovalSuspension as tr, ResumePendingToolBatch as tt, ObligationEntry as u, subagentStartedBatchId as ua, getRecord as ui, ResolutionSafeToRetry as un, DurableRuntimeConfigOptions as ur, AbortIntentRequest as ut, RetryRefusalReason as v, toolCallSettledRecordId as va, LifecyclePublicationFact as vi, SubmissionLedger as vn, RecoveryFailure as vr, AdmissionRequest as vt, AppendReservedSettlement as w, turnCanonicalBatch as wa, lifecyclePublicationBatchMaxFacts as wi, SubmissionScheduling as wn, recoveryRepairBatchId as wr, ApprovalPendingSuspension as wt, predictRecoveryDisposition as x, toolStepSettledRecordId as xa, LifecyclePublicationStorage as xi, SubmissionLookup as xn, RecoverySweepResult as xr, ApprovalConflict as xt, RetryRefused as y, toolCallUnknownRecordId as ya, LifecyclePublicationHandler as yi, SubmissionLedgerFailure as yn, RecoveryReport as yr, AdmissionResolution as yt, FinalizeLedgerFromHistory as z, CurrentBindingSelection as za, childThreadIdFor as zi, WorkerStopCommand as zn, ThreadCheckpoints as zr, DEFAULT_OWNERSHIP_LEASE_DURATION as zt };
|
|
4255
|
-
//# sourceMappingURL=Admin-
|
|
4267
|
+
//# sourceMappingURL=Admin-BbTZHSLu.d.mts.map
|
|
@@ -59,9 +59,16 @@ function make(id, options) {
|
|
|
59
59
|
if (!Object.hasOwn(options.toolkit.tools, declaration.tool)) throw new Error(`Unknown completion Tool ${declaration.tool}`);
|
|
60
60
|
completionNames.add(declaration.tool);
|
|
61
61
|
}
|
|
62
|
+
const tools = Object.values(options.toolkit.tools);
|
|
63
|
+
const readonlyTools = tools.map((tool) => Tool.isProviderDefined(tool) && !tool.requiresHandler && [
|
|
64
|
+
"web_search",
|
|
65
|
+
"web_search_preview",
|
|
66
|
+
"file_search"
|
|
67
|
+
].includes(tool.providerName) ? tool.annotate(Tool.Readonly, true) : tool);
|
|
68
|
+
const toolkit = readonlyTools.some((tool, index) => tool !== tools[index]) ? Toolkit.make(...readonlyTools) : options.toolkit;
|
|
62
69
|
return Object.freeze({
|
|
63
70
|
...options,
|
|
64
|
-
toolkit: withUpdateTool(
|
|
71
|
+
toolkit: withUpdateTool(toolkit, options.updates),
|
|
65
72
|
policy: AgentPolicy.resolve(options.policy),
|
|
66
73
|
policyOverrides: Object.freeze({ ...options.policy }),
|
|
67
74
|
toolExposure: options.toolExposure === void 0 ? void 0 : Object.freeze({
|
|
@@ -83,4 +90,4 @@ const withModel = (definition, model) => Object.freeze({
|
|
|
83
90
|
//#endregion
|
|
84
91
|
export { make as a, isModelResolver as i, ToolInspection as n, withModel as o, inspectTools as r, Agent_exports as t };
|
|
85
92
|
|
|
86
|
-
//# sourceMappingURL=Agent-
|
|
93
|
+
//# sourceMappingURL=Agent-BMATXYsI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Agent-BMATXYsI.mjs","names":[],"sources":["../src/core/internal/agent-updates.ts","../src/core/Agent.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { Tool, Toolkit } from \"effect/unstable/ai\";\n\nimport { Emitter, UpdateError } from \"../AgentUpdates.ts\";\n\n/** Definition-owned native Tool. Runtime supplies its handler under the same identity. */\nexport const updateTool = <S extends Schema.Top>(schema: S) =>\n Tool.make(\"emit_update\", {\n description:\n \"Emit a structured intermediate update. Success acknowledges acceptance by this Run; \" +\n \"parent delivery and processing are separate. This does not complete the task.\",\n parameters: Schema.Struct({ value: schema }),\n success: Schema.Struct({ emitted: Schema.Literal(true) }),\n failure: UpdateError,\n failureMode: \"return\",\n }).addDependency(Emitter);\n\nexport type UpdateToolkit<\n T extends Toolkit.Any,\n S extends Schema.Top | undefined,\n> = S extends Schema.Top\n ? Toolkit.Toolkit<T[\"tools\"] & { readonly emit_update: ReturnType<typeof updateTool<S>> }>\n : T;\n\nexport const withUpdateTool = (\n toolkit: Toolkit.Any,\n schema: Schema.Top | undefined,\n): Toolkit.Any => {\n if (schema === undefined) return toolkit;\n if (Object.hasOwn(toolkit.tools, \"emit_update\"))\n throw new TypeError(\"emit_update is reserved for Agent updates\");\n\n return Toolkit.make(...Object.values(toolkit.tools), updateTool(schema));\n};\n","import type { Effect, Layer, Option, Schema } from \"effect\";\nimport * as S from \"effect/Schema\";\nimport {\n type AiError,\n type LanguageModel,\n type Model,\n type Prompt,\n Tool,\n Toolkit,\n} from \"effect/unstable/ai\";\n\nimport type { AgentInputError, AgentOutputError, AgentRunDispositionError } from \"./AgentError.ts\";\nimport { AgentPolicy, type AgentPolicyInput } from \"./AgentPolicy.ts\";\nimport { AgentId } from \"./Identifiers.ts\";\nimport { type UpdateToolkit, withUpdateTool } from \"./internal/agent-updates.ts\";\nimport type { Configuration } from \"./ToolExposure.ts\";\n\n/** Prompt input produced directly or by an Effect that preserves its failure and requirements. */\nexport type InstructionResult<E = never, R = never> =\n | Prompt.RawInput\n | Effect.Effect<Prompt.RawInput, E, R>;\n\n/** Static prompt input or an input-dependent source evaluated once while preparing a run. */\nexport type InstructionSource<Input, E = never, R = never> =\n | Prompt.RawInput\n | ((input: Input) => InstructionResult<E, R>);\n\n/** Definition-owned projection from decoded Agent input to model-visible prompt content. */\nexport type InputPromptSource<Input, E = never, R = never> = (\n input: Input,\n) => InstructionResult<E, R>;\n\n/** Native services needed to execute and identify model calls. */\nexport type ModelServices = LanguageModel.LanguageModel | Model.ProviderName | Model.ModelName;\n\n/**\n * An optional capability on a provided LanguageModel service. The runtime supplies\n * only model-visible task context and eligible Tool descriptions after validating input.\n * The resolver owns retaining one choice per Thread, including across Runs and\n * recovery; it captures client requirements and returns a closed native Layer\n * that the interpreter acquires for the Run. Context hooks may prepare prompts\n * but cannot replace this model through a per-Turn modelCall.\n * Selection failures remain AiError values and all selector/client services stay in R.\n */\nexport interface ModelResolver extends LanguageModel.LanguageModel {\n readonly resolve: (request: {\n readonly threadId: string;\n readonly state: Schema.JsonObject;\n }) => Effect.Effect<Layer.Layer<ModelServices>, AiError.AiError>;\n}\n\n/** Detect the deferred resolver capability on a trusted, host-provided model service. */\nexport const isModelResolver = (model: LanguageModel.LanguageModel): model is ModelResolver =>\n \"resolve\" in model && typeof model.resolve === \"function\";\n\n/** Accepts native model Layers that provide generation and model identity. */\nexport type NativeModel<ModelValue> =\n ModelValue extends Layer.Layer<infer Provides, never, infer _Requires>\n ? ModelServices extends Provides\n ? ModelValue\n : never\n : never;\n\n/** Definition-owned boundary for selecting and validating an application run disposition. */\nexport interface RunDispositionDeclaration<Output, DispositionSchema extends Schema.Top> {\n /**\n * Opt background workers into one retained assignment. The encoded disposition must be\n * Worker.AssignmentDisposition: completed seals the worker, waiting leaves it steerable.\n * Failures and exhausted Runs seal as failed; aborting an active Run seals as cancelled.\n * The worker origin retains this choice. Omission preserves reusable workers.\n */\n readonly workerLifecycle?: \"assignment\" | undefined;\n /** Canonical Schema used to validate and encode the selected disposition. */\n readonly schema: DispositionSchema;\n /** Pure selection from decoded output. `undefined` declares none, except for assignments. */\n readonly fromOutput: (output: Output) => unknown;\n}\n\n/** Values available to a Definition-owned completion Tool projector after canonical decoding. */\nexport interface CompletionProjectionInput<Parameters = unknown, Result = unknown> {\n readonly parameters: Parameters;\n readonly result: Result;\n}\n\n/**\n * One application Tool whose successful result can complete its owning Agent when it is the\n * only application call. Provider-executed calls may accompany it only with terminal results.\n * Mixed, wholly unexecuted application batches are rejected with failed Tool results so the\n * model can correct them within ordinary Run budgets; completed provider results are retained.\n * Missing provider results and invalid pending resumed batches fail closed. The completion\n * designation never permits side-effect replay.\n */\nexport interface CompletionToolDeclaration<\n Parameters = unknown,\n Result = unknown,\n Output = unknown,\n> {\n readonly tool: string;\n /** Require native Tool use on every model Turn and this Tool for final completion. */\n readonly required?: boolean | undefined;\n readonly project: (input: CompletionProjectionInput<Parameters, Result>) => Output;\n}\n\ntype CompletionToolFor<ToolkitValue extends Toolkit.Any, Output> = {\n readonly [Name in keyof ToolkitValue[\"tools\"] & string]: CompletionToolDeclaration<\n Tool.Parameters<ToolkitValue[\"tools\"][Name]>,\n Tool.Success<ToolkitValue[\"tools\"][Name]>,\n Output\n > & { readonly tool: Name };\n}[keyof ToolkitValue[\"tools\"] & string];\n\n/**\n * An ordinary action Tool whose canonical success may satisfy the whole request.\n * Projectors must be pure and deterministic: recovery re-evaluates them. None preserves\n * ordinary continuation; Some is validated as the Agent output. These Tools must be the sole\n * application call; terminal provider results may accompany them. They never receive the\n * required completion Tool's exhaustion allowance.\n */\nexport interface CompletionFromToolDeclaration<\n Parameters = unknown,\n Result = unknown,\n Output = unknown,\n> {\n readonly tool: string;\n readonly project: (input: CompletionProjectionInput<Parameters, Result>) => Option.Option<Output>;\n}\n\ntype CompletionFromToolFor<ToolkitValue extends Toolkit.Any, Output> = {\n readonly [Name in keyof ToolkitValue[\"tools\"] & string]: CompletionFromToolDeclaration<\n Tool.Parameters<ToolkitValue[\"tools\"][Name]>,\n Tool.Success<ToolkitValue[\"tools\"][Name]>,\n Output\n > & { readonly tool: Name };\n}[keyof ToolkitValue[\"tools\"] & string];\n\n/** Immutable, model-agnostic schemas, behavior, tools, and bounds for an agent. */\nexport interface Definition<\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions,\n ToolkitValue extends Toolkit.Any,\n RunDispositionValue = undefined,\n InputPromptValue = undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n> {\n /** Stable agent identity; changing it creates a distinct definition identity. */\n readonly id: AgentId;\n /** Canonical Schema for intermediate updates emitted by this Agent. */\n readonly updates?: UpdatesSchema;\n /** Canonical schema used to decode and encode run input. */\n readonly input: InputSchema;\n /** Canonical schema used to decode the final model output. */\n readonly output: OutputSchema;\n /**\n * Evaluated once while preparing each Run. OpenAI, xAI and native adapters advertising support\n * preserve chronological system messages, omitting exact repeats only when no distinct system\n * instruction intervenes. The actual selected model determines support on each call. Other\n * adapters group systems first and keep the last exact repeat, including provider options;\n * Anthropic requires an upstream adapter with mid-conversation system-message support.\n * Stored history is unchanged.\n */\n readonly instructions: Instructions;\n /** Optional projection from decoded input to model-visible native Effect AI prompt content. */\n readonly inputPrompt?: InputPromptValue | undefined;\n /** Native Effect AI toolkit whose failures and requirements remain visible. */\n readonly toolkit: ToolkitValue;\n readonly toolExposure?: Configuration | undefined;\n /** Finite execution bounds enforced by the runtime. */\n readonly policy: AgentPolicy;\n /** Explicit policy fields, retained so delegated runs can inherit omitted fields. */\n readonly policyOverrides?: Partial<AgentPolicyInput> | undefined;\n /** Optional successful Tool result that projects directly to the Agent output and settles. */\n readonly completion?: CompletionToolDeclaration | undefined;\n readonly completionFromTools?: ReadonlyArray<CompletionFromToolDeclaration> | undefined;\n readonly runDisposition?: RunDispositionValue | undefined;\n readonly description?: string | undefined;\n readonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\n/** Options for a model-agnostic agent definition. */\nexport interface DefinitionOptions<\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n RunDispositionValue extends\n | RunDispositionDeclaration<OutputSchema[\"Type\"], Schema.Top>\n | undefined = undefined,\n InputPromptValue extends InputPromptSource<InputSchema[\"Type\"], unknown, unknown> | undefined =\n undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n> {\n readonly updates?: UpdatesSchema;\n readonly input: InputSchema;\n readonly output: OutputSchema;\n readonly instructions: Instructions;\n readonly inputPrompt?: InputPromptValue | undefined;\n readonly toolkit: ToolkitValue;\n readonly toolExposure?: Configuration | undefined;\n readonly policy?: Partial<AgentPolicyInput> | undefined;\n readonly completion?: CompletionToolFor<ToolkitValue, OutputSchema[\"Type\"]> | undefined;\n readonly completionFromTools?:\n | ReadonlyArray<CompletionFromToolFor<ToolkitValue, OutputSchema[\"Type\"]>>\n | undefined;\n readonly runDisposition?: RunDispositionValue | undefined;\n readonly description?: string | undefined;\n readonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\ntype AnyDefinitionShape = Definition<\n Schema.Top,\n Schema.Top,\n unknown,\n Toolkit.Any,\n RunDispositionDeclaration<never, Schema.Top> | undefined,\n unknown,\n Schema.Top | undefined\n>;\n\n/** Immutable pairing of an agent definition with a native model Layer or thread resolver. */\nexport interface Binding<DefinitionValue extends AnyDefinitionShape, ModelValue> {\n readonly definition: DefinitionValue;\n readonly model: NativeModel<ModelValue>;\n}\n\ntype InstructionEffect<Instructions, Input> = Instructions extends (input: Input) => infer Result\n ? Result\n : Instructions;\n\ntype InputPromptEffect<InputPrompt, Input> = InputPrompt extends (input: Input) => infer Result\n ? Result\n : never;\n\ntype EffectError<Value> =\n Value extends Effect.Effect<infer _Success, infer Error, infer _Services> ? Error : never;\n\ntype EffectServices<Value> =\n Value extends Effect.Effect<infer _Success, infer _Error, infer Services> ? Services : never;\n\ntype ModelRequirements<Value> =\n Value extends Layer.Layer<infer _Provides, infer _Error, infer Services> ? Services : never;\n\n/** Constructors and type projections for definitions and runnable model bindings. */\n\n/** Type-erased definition used at generic framework boundaries. */\nexport type AnyDefinition = AnyDefinitionShape;\n\n/** Read-only interpreter program or binding used at inspection and projection boundaries. */\nexport interface Any {\n readonly definition: AnyDefinition;\n readonly model?: unknown;\n}\n\n/** Native Tool configuration for inspection; it does not predict an invocation's outcome. */\nexport const ToolInspection = S.Struct({\n name: S.String,\n failureMode: S.Literals([\"error\", \"return\"]),\n /** False for provider-executed Tools, whose results do not pass through local handlers. */\n requiresHandler: S.Boolean,\n});\n\nexport type ToolInspection = typeof ToolInspection.Type;\n\n/**\n * Inspect registered native Tools in declaration order without acquiring handlers or a Model.\n * This is the full Definition toolkit, before run-specific visibility or exposure filtering.\n * `failureMode` is Effect AI's configured mode, including its `\"error\"` default. Handler-level\n * recovery, programmatic invocation and Subagent containment can change where failures go;\n * consult execution diagnostics for the actual route. No arguments, results or services are read.\n */\nexport const inspectTools = (agent: AnyDefinition | Any): ReadonlyArray<ToolInspection> => {\n const definition = \"definition\" in agent ? agent.definition : agent;\n\n return Object.values(definition.toolkit.tools).map((tool) =>\n ToolInspection.make({\n name: tool.name,\n failureMode: tool.failureMode,\n requiresHandler: !Tool.isProviderDefined(tool) || tool.requiresHandler,\n }),\n );\n};\n\ntype DefinitionOf<AgentValue extends AnyDefinition | Any> = AgentValue extends {\n readonly definition: infer DefinitionValue extends AnyDefinition;\n}\n ? DefinitionValue\n : AgentValue;\n\ntype RunDispositionSchemaOf<DefinitionValue extends AnyDefinition> = [\n Exclude<DefinitionValue[\"runDisposition\"], undefined>,\n] extends [never]\n ? never\n : Exclude<DefinitionValue[\"runDisposition\"], undefined> extends RunDispositionDeclaration<\n never,\n infer DispositionSchema\n >\n ? DispositionSchema\n : never;\n\n/** Literal Agent ID, retained by Agent.make. */\nexport type Name<A extends AnyDefinition | Any> = DefinitionOf<A>[\"id\"] extends AgentId &\n (infer N extends string)\n ? N\n : string;\n\n/** Declared update Schema, or never for Agents without updates. */\nexport type UpdatesSchema<A extends AnyDefinition | Any> = Exclude<\n DefinitionOf<A>[\"updates\"],\n undefined\n>;\n\n/** Decoded intermediate update value. */\nexport type Update<A extends AnyDefinition | Any> = UpdatesSchema<A>[\"Type\"];\n\n/** Decoded input type of a definition or binding. */\nexport type Input<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"input\"][\"Type\"];\n\n/** Encoded input accepted by the primary execution operations. */\nexport type EncodedInput<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"input\"][\"Encoded\"];\n\n/** Decoded output type of a definition or binding. */\nexport type Output<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"output\"][\"Type\"];\n\n/** Input Schema carried by a definition or binding. */\nexport type InputSchema<AgentValue extends AnyDefinition | Any> = DefinitionOf<AgentValue>[\"input\"];\n\n/** Output Schema carried by a definition or binding. */\nexport type OutputSchema<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"output\"];\n\n/** Application run-disposition Schema carried by a definition or binding, or `never`. */\nexport type RunDispositionSchema<AgentValue extends AnyDefinition | Any> = RunDispositionSchemaOf<\n DefinitionOf<AgentValue>\n>;\n\n/** Decoded application run disposition declared by a definition or binding. */\nexport type RunDisposition<AgentValue extends AnyDefinition | Any> = [\n RunDispositionSchema<AgentValue>,\n] extends [never]\n ? never\n : RunDispositionSchema<AgentValue>[\"Type\"];\n\n/** Validation failure admitted only by definitions that declare a run disposition. */\nexport type RunDispositionFailure<AgentValue extends AnyDefinition | Any> = [\n RunDispositionSchemaOf<DefinitionOf<AgentValue>>,\n] extends [never]\n ? never\n : AgentRunDispositionError;\n\n/** Effect AI tool map carried by a definition or binding. */\nexport type Tools<AgentValue extends AnyDefinition | Any> = Toolkit.Tools<\n DefinitionOf<AgentValue>[\"toolkit\"]\n>;\n\ntype ApplicationTools<A extends AnyDefinition> = [UpdatesSchema<A>] extends [never]\n ? Tools<A>\n : Omit<Tools<A>, \"emit_update\">;\n\ntype ToolMapValues<ToolMap extends Record<string, Tool.Any>> = ToolMap extends unknown\n ? ToolMap[keyof ToolMap]\n : never;\n\n/** All possible tools, including keys present in only one definition or binding branch. */\nexport type ToolUnion<AgentValue extends AnyDefinition | Any> = ToolMapValues<Tools<AgentValue>>;\n\n/** Instruction, tool-handler, and Schema services required before a Model is bound. */\nexport type DefinitionRequirements<DefinitionValue extends AnyDefinition> =\n DefinitionValue extends unknown\n ?\n | EffectServices<InstructionEffect<DefinitionValue[\"instructions\"], Input<DefinitionValue>>>\n | EffectServices<InputPromptEffect<DefinitionValue[\"inputPrompt\"], Input<DefinitionValue>>>\n | Tool.HandlersFor<ApplicationTools<DefinitionValue>>\n | Tool.HandlerServices<ToolMapValues<ApplicationTools<DefinitionValue>>>\n // The interpreter canonically re-encodes decoded Tool parameters before recording them.\n | Tool.ParametersSchema<ToolUnion<DefinitionValue>>[\"EncodingServices\"]\n | Tool.SuccessSchema<ToolUnion<DefinitionValue>>[\"DecodingServices\"]\n | DefinitionValue[\"input\"][\"DecodingServices\"]\n | DefinitionValue[\"input\"][\"EncodingServices\"]\n | DefinitionValue[\"output\"][\"DecodingServices\"]\n | DefinitionValue[\"output\"][\"EncodingServices\"]\n | UpdatesSchema<DefinitionValue>[\"DecodingServices\"]\n | UpdatesSchema<DefinitionValue>[\"EncodingServices\"]\n | RunDispositionSchemaOf<DefinitionValue>[\"DecodingServices\"]\n | RunDispositionSchemaOf<DefinitionValue>[\"EncodingServices\"]\n : never;\n\n/** Definition services plus native model services, or a binding's model Layer requirements. */\nexport type Requirements<AgentValue extends AnyDefinition | Any> =\n | DefinitionRequirements<DefinitionOf<AgentValue>>\n | (AgentValue extends { readonly model: infer ModelValue }\n ? ModelRequirements<ModelValue>\n : ModelServices);\n\n// Distribute after unwrapping bindings too: withModel may itself contain a definition union.\ntype DefinitionFailure<DefinitionValue extends AnyDefinition> = DefinitionValue extends unknown\n ?\n | EffectError<InstructionEffect<DefinitionValue[\"instructions\"], Input<DefinitionValue>>>\n | EffectError<InputPromptEffect<DefinitionValue[\"inputPrompt\"], Input<DefinitionValue>>>\n | Tool.HandlerError<ToolUnion<DefinitionValue>>\n : never;\n\n/** Failures from every possible definition, preserving each branch's instruction input type. */\nexport type Failure<AgentValue extends AnyDefinition | Any> =\n | DefinitionFailure<DefinitionOf<AgentValue>>\n | AiError.AiError\n | AgentInputError\n | AgentOutputError\n | RunDispositionFailure<AgentValue>;\n\n/** Validate an agent ID and return a shallowly frozen, model-agnostic definition. */\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n DispositionSchema extends Schema.Top,\n InputPromptValue extends InputPromptSource<InputSchema[\"Type\"], unknown, unknown> | undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n InputPromptValue,\n UpdatesSchema\n > & {\n readonly runDisposition: RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>;\n readonly inputPrompt: InputPromptValue;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n InputPromptValue,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n DispositionSchema extends Schema.Top,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n undefined,\n UpdatesSchema\n > & {\n readonly runDisposition: RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>;\n readonly inputPrompt?: undefined;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n undefined,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n InputPromptValue extends InputPromptSource<InputSchema[\"Type\"], unknown, unknown> | undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n undefined,\n InputPromptValue,\n UpdatesSchema\n > & {\n readonly inputPrompt: InputPromptValue;\n readonly runDisposition?: undefined;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n undefined,\n InputPromptValue,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n undefined,\n undefined,\n UpdatesSchema\n > & {\n readonly inputPrompt?: undefined;\n readonly runDisposition?: undefined;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n undefined,\n undefined,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make(\n id: string,\n options: {\n readonly updates?: Schema.Top | undefined;\n readonly input: Schema.Top;\n readonly output: Schema.Top;\n readonly instructions: unknown;\n readonly inputPrompt?: unknown;\n readonly toolkit: Toolkit.Any;\n readonly toolExposure?: Configuration | undefined;\n readonly policy?: Partial<AgentPolicyInput> | undefined;\n readonly completion?: CompletionToolDeclaration | undefined;\n readonly completionFromTools?: ReadonlyArray<CompletionFromToolDeclaration> | undefined;\n readonly runDisposition?: RunDispositionDeclaration<never, Schema.Top> | undefined;\n readonly description?: string | undefined;\n readonly metadata?: Readonly<Record<string, string>> | undefined;\n },\n): AnyDefinition {\n const completionNames = new Set<string>();\n\n for (const declaration of options.completionFromTools ?? []) {\n if (declaration.tool === options.completion?.tool || completionNames.has(declaration.tool)) {\n throw new Error(`Tool ${declaration.tool} has more than one completion declaration`);\n }\n if (!Object.hasOwn(options.toolkit.tools, declaration.tool)) {\n throw new Error(`Unknown completion Tool ${declaration.tool}`);\n }\n completionNames.add(declaration.tool);\n }\n\n const tools = Object.values(options.toolkit.tools);\n\n const readonlyTools = tools.map((tool) =>\n Tool.isProviderDefined(tool) &&\n !tool.requiresHandler &&\n [\"web_search\", \"web_search_preview\", \"file_search\"].includes(tool.providerName)\n ? tool.annotate(Tool.Readonly, true)\n : tool,\n );\n\n const toolkit = readonlyTools.some((tool, index) => tool !== tools[index])\n ? Toolkit.make(...readonlyTools)\n : options.toolkit;\n\n return Object.freeze({\n ...options,\n toolkit: withUpdateTool(toolkit, options.updates),\n policy: AgentPolicy.resolve(options.policy),\n policyOverrides: Object.freeze({ ...options.policy }),\n toolExposure:\n options.toolExposure === undefined\n ? undefined\n : Object.freeze({\n ...options.toolExposure,\n initialToolNames: Object.freeze([...(options.toolExposure.initialToolNames ?? [])]),\n }),\n id: S.decodeSync(AgentId)(id),\n metadata: options.metadata === undefined ? undefined : Object.freeze({ ...options.metadata }),\n completion:\n options.completion === undefined ? undefined : Object.freeze({ ...options.completion }),\n completionFromTools:\n options.completionFromTools === undefined\n ? undefined\n : Object.freeze(\n options.completionFromTools.map((declaration) => Object.freeze({ ...declaration })),\n ),\n runDisposition:\n options.runDisposition === undefined\n ? undefined\n : Object.freeze({ ...options.runDisposition }),\n });\n}\n\n/** Bind a native model or thread resolver without acquiring or hiding its requirements. */\nexport const withModel = <DefinitionValue extends AnyDefinition, ModelValue>(\n definition: DefinitionValue,\n model: NativeModel<ModelValue>,\n): Binding<DefinitionValue, ModelValue> =>\n Object.freeze({\n definition,\n model,\n });\n"],"mappings":";;;;;;;;;AAMA,MAAa,cAAoC,WAC/C,KAAK,KAAK,eAAe;CACvB,aACE;CAEF,YAAY,OAAO,OAAO,EAAE,OAAO,OAAO,CAAC;CAC3C,SAAS,OAAO,OAAO,EAAE,SAAS,OAAO,QAAQ,IAAI,EAAE,CAAC;CACxD,SAAS;CACT,aAAa;AACf,CAAC,CAAC,CAAC,cAAc,OAAO;AAS1B,MAAa,kBACX,SACA,WACgB;CAChB,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI,OAAO,OAAO,QAAQ,OAAO,aAAa,GAC5C,MAAM,IAAI,UAAU,2CAA2C;CAEjE,OAAO,QAAQ,KAAK,GAAG,OAAO,OAAO,QAAQ,KAAK,GAAG,WAAW,MAAM,CAAC;AACzE;;;;;;;;;;;ACmBA,MAAa,mBAAmB,UAC9B,aAAa,SAAS,OAAO,MAAM,YAAY;;AAyMjD,MAAa,iBAAiB,EAAE,OAAO;CACrC,MAAM,EAAE;CACR,aAAa,EAAE,SAAS,CAAC,SAAS,QAAQ,CAAC;;CAE3C,iBAAiB,EAAE;AACrB,CAAC;;;;;;;;AAWD,MAAa,gBAAgB,UAA8D;CACzF,MAAM,aAAa,gBAAgB,QAAQ,MAAM,aAAa;CAE9D,OAAO,OAAO,OAAO,WAAW,QAAQ,KAAK,CAAC,CAAC,KAAK,SAClD,eAAe,KAAK;EAClB,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,iBAAiB,CAAC,KAAK,kBAAkB,IAAI,KAAK,KAAK;CACzD,CAAC,CACH;AACF;AAqQA,SAAgB,KACd,IACA,SAee;CACf,MAAM,kCAAkB,IAAI,IAAY;CAExC,KAAK,MAAM,eAAe,QAAQ,uBAAuB,CAAC,GAAG;EAC3D,IAAI,YAAY,SAAS,QAAQ,YAAY,QAAQ,gBAAgB,IAAI,YAAY,IAAI,GACvF,MAAM,IAAI,MAAM,QAAQ,YAAY,KAAK,0CAA0C;EAErF,IAAI,CAAC,OAAO,OAAO,QAAQ,QAAQ,OAAO,YAAY,IAAI,GACxD,MAAM,IAAI,MAAM,2BAA2B,YAAY,MAAM;EAE/D,gBAAgB,IAAI,YAAY,IAAI;CACtC;CAEA,MAAM,QAAQ,OAAO,OAAO,QAAQ,QAAQ,KAAK;CAEjD,MAAM,gBAAgB,MAAM,KAAK,SAC/B,KAAK,kBAAkB,IAAI,KAC3B,CAAC,KAAK,mBACN;EAAC;EAAc;EAAsB;CAAa,CAAC,CAAC,SAAS,KAAK,YAAY,IAC1E,KAAK,SAAS,KAAK,UAAU,IAAI,IACjC,IACN;CAEA,MAAM,UAAU,cAAc,MAAM,MAAM,UAAU,SAAS,MAAM,MAAM,IACrE,QAAQ,KAAK,GAAG,aAAa,IAC7B,QAAQ;CAEZ,OAAO,OAAO,OAAO;EACnB,GAAG;EACH,SAAS,eAAe,SAAS,QAAQ,OAAO;EAChD,QAAQ,YAAY,QAAQ,QAAQ,MAAM;EAC1C,iBAAiB,OAAO,OAAO,EAAE,GAAG,QAAQ,OAAO,CAAC;EACpD,cACE,QAAQ,iBAAiB,KAAA,IACrB,KAAA,IACA,OAAO,OAAO;GACZ,GAAG,QAAQ;GACX,kBAAkB,OAAO,OAAO,CAAC,GAAI,QAAQ,aAAa,oBAAoB,CAAC,CAAE,CAAC;EACpF,CAAC;EACP,IAAI,EAAE,WAAW,OAAO,CAAC,CAAC,EAAE;EAC5B,UAAU,QAAQ,aAAa,KAAA,IAAY,KAAA,IAAY,OAAO,OAAO,EAAE,GAAG,QAAQ,SAAS,CAAC;EAC5F,YACE,QAAQ,eAAe,KAAA,IAAY,KAAA,IAAY,OAAO,OAAO,EAAE,GAAG,QAAQ,WAAW,CAAC;EACxF,qBACE,QAAQ,wBAAwB,KAAA,IAC5B,KAAA,IACA,OAAO,OACL,QAAQ,oBAAoB,KAAK,gBAAgB,OAAO,OAAO,EAAE,GAAG,YAAY,CAAC,CAAC,CACpF;EACN,gBACE,QAAQ,mBAAmB,KAAA,IACvB,KAAA,IACA,OAAO,OAAO,EAAE,GAAG,QAAQ,eAAe,CAAC;CACnD,CAAC;AACH;;AAGA,MAAa,aACX,YACA,UAEA,OAAO,OAAO;CACZ;CACA;AACF,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { d as ToolCallId, r as DelegationId, s as RunId, t as AgentId, u as ThreadId } from "./Identifiers-CN2s30fF.mjs";
|
|
2
2
|
import { i as SubagentBudgetReservation, l as SubagentGrant, u as SubagentParentLink } from "./SubagentContract-DdT7Cqe6.mjs";
|
|
3
3
|
import { i as UpdateError, n as Emitter } from "./AgentUpdates-DMJ-_xow.mjs";
|
|
4
|
-
import { c as RunUsageReport, s as RunTotals } from "./Usage-
|
|
5
|
-
import { u as RunEvent } from "./RunEvent-
|
|
6
|
-
import { n as ThreadHistoryError, t as ThreadHistory } from "./ThreadHistory-
|
|
4
|
+
import { c as RunUsageReport, s as RunTotals } from "./Usage-BNjPR7Zr.mjs";
|
|
5
|
+
import { u as RunEvent } from "./RunEvent-D0aepYwN.mjs";
|
|
6
|
+
import { n as ThreadHistoryError, t as ThreadHistory } from "./ThreadHistory-FD-o4TsR.mjs";
|
|
7
7
|
import { n as CurrentToolCatalog } from "./ToolExposure-UCN12eCd.mjs";
|
|
8
8
|
import { s as ToolBroker } from "./ToolBroker-DWs4tZra.mjs";
|
|
9
9
|
import { a as AgentInputError, c as AgentPolicyError, d as AgentToolAuthorizationDenied, f as ContextBudgetError, m as ModelProtocolError, n as AgentApprovalPending, p as ContextOverflowError, s as AgentOutputError, t as AgentApprovalDenied, u as AgentToolAuthorizationCheckError } from "./AgentError-Bn1ytXRD.mjs";
|
|
@@ -13,10 +13,10 @@ import { a as WorkerBudgetScope } from "./Worker-2r2zGDkh.mjs";
|
|
|
13
13
|
import { a as ContextWindow } from "./ContextWindow-DRQ5Mbm2.mjs";
|
|
14
14
|
import { n as CompactionError } from "./ContextCompactor-CPlStZRc.mjs";
|
|
15
15
|
import { t as DurableStep } from "./DurableStep-Cry_iol4.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-
|
|
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-GjDlAuKh.mjs";
|
|
17
17
|
import { t as MessagingHost } from "./MessagingHost-B4jqlJmx.mjs";
|
|
18
18
|
import { o as SubagentHost } from "./SubagentHost--HBuY8fF.mjs";
|
|
19
|
-
import { t as RunEventSink } from "./RunEventSink-
|
|
19
|
+
import { t as RunEventSink } from "./RunEventSink-DsbcGXog.mjs";
|
|
20
20
|
import { AiError, LanguageModel, Model, Prompt, Tool, Toolkit } from "effect/unstable/ai";
|
|
21
21
|
import { Cause, Context, Effect, Layer, Option, Schema, Scope, Stream, Tracer } from "effect";
|
|
22
22
|
//#region src/engine/internal/tool-telemetry.d.ts
|
|
@@ -343,4 +343,4 @@ declare namespace AgentRuntime_d_exports {
|
|
|
343
343
|
}
|
|
344
344
|
//#endregion
|
|
345
345
|
export { start as A, decodeFinalOutput as C, renderInputPrompt as D, projectCompletionOutput as E, withTerminalDefectEvent as F, stream as M, streamUnknown as N, run as O, streamWithUsageAccountingUnknown as P, ToolCallWaiting as S, projectCompletionFromToolOutput 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, startUnknown as j, runUnknown 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 };
|
|
346
|
-
//# sourceMappingURL=AgentRuntime-
|
|
346
|
+
//# sourceMappingURL=AgentRuntime-BPlAn5nA.d.mts.map
|
|
@@ -4,7 +4,7 @@ import { n as utf8ByteLength } from "./utf8-DchGZRBd.mjs";
|
|
|
4
4
|
import { ToolParameterRejection, TruncatedToolResult, applyToolResultBounds, unserializableToolResult } from "./core/ToolResult.mjs";
|
|
5
5
|
import { IdempotencyKey } from "./core/Receipt.mjs";
|
|
6
6
|
import { Emitter, Update, UpdateError } from "./core/AgentUpdates.mjs";
|
|
7
|
-
import { i as isModelResolver } from "./Agent-
|
|
7
|
+
import { i as isModelResolver } from "./Agent-BMATXYsI.mjs";
|
|
8
8
|
import { AgentApprovalDenied, AgentApprovalPending, AgentInputError, AgentOutputError, AgentPolicyError, AgentRunDispositionError, AgentToolAuthorizationDenied, ContextBudgetError, ContextOverflowError, ModelProtocolError } from "./core/AgentError.mjs";
|
|
9
9
|
import { IdGenerator as IdGenerator$1 } from "./core/IdGenerator.mjs";
|
|
10
10
|
import { DelegationDepth, SubagentParentLink, getToolExecutionKind, isSubagentToolAllowed } from "./core/SubagentContract.mjs";
|
|
@@ -769,6 +769,7 @@ const AgentResultSchema = (output) => Schema.Struct({
|
|
|
769
769
|
/** Direct usage only: budget counters never absorb descendant consumption. */
|
|
770
770
|
const runTotalsOf = (context) => RunTotals.make({
|
|
771
771
|
modelCalls: context.modelCalls,
|
|
772
|
+
...context.webSearchCalls === void 0 ? {} : { webSearchCalls: context.webSearchCalls },
|
|
772
773
|
inputTokens: context.inputTokens,
|
|
773
774
|
outputTokens: context.outputTokens,
|
|
774
775
|
costMicrousd: context.costMicrousd,
|
|
@@ -1072,7 +1073,8 @@ const decodeResumeUsage = Effect.fn("AgentRuntime.decodeResumeUsage")((input) =>
|
|
|
1072
1073
|
"pricingStatus",
|
|
1073
1074
|
"unobservedModelCalls",
|
|
1074
1075
|
"children",
|
|
1075
|
-
"modelRestarts"
|
|
1076
|
+
"modelRestarts",
|
|
1077
|
+
"webSearchCalls"
|
|
1076
1078
|
].map((key) => [key, read(key, true)]).filter(([, value]) => value !== void 0)),
|
|
1077
1079
|
modelCalls: read("modelCalls"),
|
|
1078
1080
|
inputTokens: read("inputTokens"),
|
|
@@ -1882,6 +1884,7 @@ const outgoingModelPrompt = (policy, context, prepared, turn, declaredToolCalls,
|
|
|
1882
1884
|
});
|
|
1883
1885
|
return Prompt.fromMessages([...prepared.content, systemMessagesInHistory ? Prompt.systemMessage({ content: status }) : Prompt.userMessage({ content: [Prompt.textPart({ text: status })] })]);
|
|
1884
1886
|
});
|
|
1887
|
+
const isWebSearchAction = Schema.is(Schema.Struct({ action: Schema.Struct({ type: Schema.Literal("search") }) }));
|
|
1885
1888
|
const ProviderUsage = Schema.Struct({
|
|
1886
1889
|
inputTokens: Schema.Struct({
|
|
1887
1890
|
uncached: Schema.optional(Schema.Natural),
|
|
@@ -1902,6 +1905,7 @@ const consumeUsage = (agent, context, usage, toolCallCount, turn, options, respo
|
|
|
1902
1905
|
limit: "usage",
|
|
1903
1906
|
message: "A completed model response did not report usage"
|
|
1904
1907
|
});
|
|
1908
|
+
const webSearchCalls = yield* decodeProviderUsageTotal(response.webSearchCalls ?? 0);
|
|
1905
1909
|
const providerUsage = yield* Schema.decodeEffect(ProviderUsage)(usage).pipe(Effect.mapError(() => invalidProviderUsage()));
|
|
1906
1910
|
const reportedUncached = providerUsage.inputTokens.uncached ?? 0;
|
|
1907
1911
|
const cacheRead = providerUsage.inputTokens.cacheRead ?? 0;
|
|
@@ -1934,7 +1938,8 @@ const consumeUsage = (agent, context, usage, toolCallCount, turn, options, respo
|
|
|
1934
1938
|
provider,
|
|
1935
1939
|
model,
|
|
1936
1940
|
usage,
|
|
1937
|
-
...response
|
|
1941
|
+
...response,
|
|
1942
|
+
webSearchCalls
|
|
1938
1943
|
});
|
|
1939
1944
|
const costMicrousd = typeof estimate === "number" ? estimate : estimate.costMicrousd;
|
|
1940
1945
|
if (!Number.isSafeInteger(costMicrousd) || costMicrousd < 0) return yield* AgentPolicyError.make({
|
|
@@ -1950,6 +1955,7 @@ const consumeUsage = (agent, context, usage, toolCallCount, turn, options, respo
|
|
|
1950
1955
|
message: "Model cost estimation returned an invalid service tier or pricing version"
|
|
1951
1956
|
});
|
|
1952
1957
|
const modelUsage = ModelCallUsage.make({
|
|
1958
|
+
webSearchCalls,
|
|
1953
1959
|
provider,
|
|
1954
1960
|
model,
|
|
1955
1961
|
...response.response === void 0 ? {} : { response: ModelResponseIdentity.make(response.response) },
|
|
@@ -1978,6 +1984,7 @@ const consumeUsage = (agent, context, usage, toolCallCount, turn, options, respo
|
|
|
1978
1984
|
costMicrousd
|
|
1979
1985
|
});
|
|
1980
1986
|
const modelCalls = yield* decodeProviderUsageTotal(context.modelCalls + 1);
|
|
1987
|
+
const cumulativeWebSearchCalls = context.webSearchCalls === void 0 ? void 0 : yield* decodeProviderUsageTotal(context.webSearchCalls + webSearchCalls);
|
|
1981
1988
|
const cumulativeInputTokens = yield* decodeProviderUsageTotal(context.inputTokens + inputTokens);
|
|
1982
1989
|
const cumulativeOutputTokens = yield* decodeProviderUsageTotal(context.outputTokens + outputTokens);
|
|
1983
1990
|
const cumulativeCostMicrousd = context.costMicrousd + costMicrousd;
|
|
@@ -1990,6 +1997,7 @@ const consumeUsage = (agent, context, usage, toolCallCount, turn, options, respo
|
|
|
1990
1997
|
context.usageStatus = combineStatus(context.usageStatus, modelUsage.usageStatus ?? "unknown");
|
|
1991
1998
|
context.pricingStatus = combineStatus(context.pricingStatus, pricingStatus === "estimated" ? "complete" : "unknown");
|
|
1992
1999
|
context.modelCalls = modelCalls;
|
|
2000
|
+
context.webSearchCalls = cumulativeWebSearchCalls;
|
|
1993
2001
|
context.inputTokens = cumulativeInputTokens;
|
|
1994
2002
|
context.outputTokens = cumulativeOutputTokens;
|
|
1995
2003
|
context.lastInputTokens = inputTokens;
|
|
@@ -2564,6 +2572,7 @@ const eventsForPart = Effect.fnUntraced(function* (context, turnId, turn, tools,
|
|
|
2564
2572
|
if (parameterPart !== void 0 && (parameterPart.name !== part.name || parameterPart.providerExecuted !== part.providerExecuted)) return yield* ModelProtocolError.make({ message: `Completed Tool parameters did not match Tool Call ${part.id}` });
|
|
2565
2573
|
const toolCallId = yield* decodeToolCallId(part.id);
|
|
2566
2574
|
const tool = tools[part.name];
|
|
2575
|
+
if (Tool.isProviderDefined(tool) && !tool.requiresHandler && !part.providerExecuted) return yield* ModelProtocolError.make({ message: `Tool ${part.name} must execute at the provider` });
|
|
2567
2576
|
const decoded = yield* Effect.result(decodeToolCallParameters(tool, part.name, part.params, "model"));
|
|
2568
2577
|
let parameters;
|
|
2569
2578
|
if (Result.isFailure(decoded)) {
|
|
@@ -3078,6 +3087,12 @@ const makeTurn = (agent, context, prompt, turn, priorToolCalls, options, restart
|
|
|
3078
3087
|
return consumeUsage(agent, context, trace.usage, toolCallCount, turn, options, {
|
|
3079
3088
|
response: trace.response,
|
|
3080
3089
|
finishMetadata: trace.finishMetadata,
|
|
3090
|
+
webSearchCalls: new Set(trace.parts.flatMap((part) => {
|
|
3091
|
+
if (part.type !== "tool-call" && part.type !== "tool-result" || !part.providerExecuted) return [];
|
|
3092
|
+
const tool = agent.definition.toolkit.tools[part.name];
|
|
3093
|
+
if (tool === void 0 || !Tool.isProviderDefined(tool) || !["web_search", "web_search_preview"].includes(tool.providerName)) return [];
|
|
3094
|
+
return !tool.id.startsWith("openai.") || isWebSearchAction(part.type === "tool-call" ? part.params : part.result) ? [part.id] : [];
|
|
3095
|
+
})).size,
|
|
3081
3096
|
purpose: "turn"
|
|
3082
3097
|
}).pipe(withCallModel, Effect.tapCause(() => context.modelCalls === priorModelCalls ? noteIncompleteUsage(context, turn) : Effect.void));
|
|
3083
3098
|
});
|
|
@@ -3337,7 +3352,7 @@ const makeTurn = (agent, context, prompt, turn, priorToolCalls, options, restart
|
|
|
3337
3352
|
if (trace.finishReason !== "stop") return failRunEventStream(ModelProtocolError.make({ message: `Model stopped without a final answer (${trace.finishReason})` }));
|
|
3338
3353
|
return afterValidatedResponse(settleOrFollowUp(historyWithResponse()));
|
|
3339
3354
|
}));
|
|
3340
|
-
const restartSignal = policy.restartOnJoinedInput === true && context.modelRestarts < 2 && (options.durability === void 0 || options.durability.commitModelRestart !== void 0) && !Object.values(modelToolkit.tools).some(Tool.isProviderDefined) ? options.input?.awaitJoin : void 0;
|
|
3355
|
+
const restartSignal = policy.restartOnJoinedInput === true && context.modelRestarts < 2 && (options.durability === void 0 || options.durability.commitModelRestart !== void 0) && !Object.values(modelToolkit.tools).some((tool) => Tool.isProviderDefined(tool) && !Context.get(tool.annotations, Tool.Readonly)) ? options.input?.awaitJoin : void 0;
|
|
3341
3356
|
const disposableResponse = restartSignal !== void 0 ? response.pipe(Stream.interruptWhen(restartSignal.pipe(Effect.tap(() => Effect.sync(() => {
|
|
3342
3357
|
restartRequested = true;
|
|
3343
3358
|
activeModelSpan?.attribute("effect_agent.model.outcome", "aborted");
|
|
@@ -3735,6 +3750,7 @@ function streamWithCompletion(agentValue, input, runOptions = {}, onCompleted, o
|
|
|
3735
3750
|
durationDeadlineMillis,
|
|
3736
3751
|
history: options.history ?? Prompt.empty,
|
|
3737
3752
|
modelCalls: resumeUsage?.modelCalls ?? 0,
|
|
3753
|
+
webSearchCalls: resumeUsage === void 0 || resumeUsage.modelCalls === 0 ? 0 : resumeUsage.webSearchCalls,
|
|
3738
3754
|
modelRestarts: resumeUsage?.modelRestarts ?? 0,
|
|
3739
3755
|
usageStatus: resumeUsage?.usageStatus ?? (resumeUsage === void 0 ? "complete" : "unknown"),
|
|
3740
3756
|
pricingStatus: resumeUsage?.pricingStatus ?? (resumeUsage === void 0 ? "complete" : "unknown"),
|
|
@@ -4785,4 +4801,4 @@ var AgentRuntime_exports = /* @__PURE__ */ __exportAll({
|
|
|
4785
4801
|
//#endregion
|
|
4786
4802
|
export { stream as _, SubagentDurability as a, withTerminalDefectEvent as b, decodeFinalOutput as c, projectCompletionOutput as d, renderInputPrompt as f, startUnknown as g, start as h, AgentSpawner as i, encodeRunDisposition as l, runUnknown as m, AgentChildPending as n, SubagentDurabilityError as o, run as p, AgentResultSchema as r, ToolCallWaiting as s, AgentRuntime_exports as t, projectCompletionFromToolOutput as u, streamUnknown as v, streamWithUsageAccountingUnknown as y };
|
|
4787
4803
|
|
|
4788
|
-
//# sourceMappingURL=AgentRuntime-
|
|
4804
|
+
//# sourceMappingURL=AgentRuntime-GQACxY_m.mjs.map
|