effect-agent 0.1.0-beta.151 → 0.1.0-beta.153
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-CKIdJoP8.d.mts → Admin-BjmupLN3.d.mts} +36 -17
- package/dist/{Agent-Cjd_ZveM.d.mts → Agent-BCyrGaWg.d.mts} +2 -2
- package/dist/{AgentPolicy-BqDoSXO6.d.mts → AgentPolicy-CnXWWwdg.d.mts} +5 -1
- package/dist/{AgentRuntime-sXpKcyxu.d.mts → AgentRuntime-BAjT5gXl.d.mts} +10 -10
- package/dist/{AgentRuntime-D8U9gl9Q.mjs → AgentRuntime-IF_1GoUf.mjs} +54 -11
- package/dist/AgentRuntime-IF_1GoUf.mjs.map +1 -0
- package/dist/{ContextCompactor-WwSIG_Z2.d.mts → ContextCompactor-CPlStZRc.d.mts} +2 -2
- package/dist/{Digest-U69rDHuO.d.mts → Digest-CaJ2RIsF.d.mts} +2 -2
- package/dist/{DurableAgentRuntime-R2LUYnRl.mjs → DurableAgentRuntime-BQzYkFVy.mjs} +186 -89
- package/dist/DurableAgentRuntime-BQzYkFVy.mjs.map +1 -0
- package/dist/{EventSource-CMbXXmwe.d.mts → EventSource-C8CKwQy5.d.mts} +3 -3
- package/dist/InMemory.d.mts +1 -1
- package/dist/{Messaging-ccQURKCf.d.mts → Messaging-B1zumorg.d.mts} +3 -3
- package/dist/{MessagingHost-D04wE-7W.d.mts → MessagingHost-B4jqlJmx.d.mts} +3 -3
- package/dist/{Output-CFD1CPfU.d.mts → Output-WL7JexCm.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-Bt6rgtVu.d.mts → PreparedInputAdmission-CU1PzUVD.d.mts} +4 -4
- package/dist/{Records-B5GFWCpn.d.mts → Records-BrEpibum.d.mts} +17 -6
- package/dist/{RunEvent-DIrzkjLr.d.mts → RunEvent-DV_llBcq.d.mts} +18 -4
- package/dist/{RunJournal-Gd83HYqG.mjs → RunJournal-ixFRCyW3.mjs} +29 -7
- package/dist/RunJournal-ixFRCyW3.mjs.map +1 -0
- package/dist/{RunOptions-Bv9NpkPZ.d.mts → RunOptions-CkRYnlJa.d.mts} +22 -8
- package/dist/{RunPolicyUsage-ClZxyR46.d.mts → RunPolicyUsage-CUudVtg_.d.mts} +3 -1
- package/dist/{Schedule-CtYREFnz.d.mts → Schedule-B_z7PMg-.d.mts} +2 -2
- package/dist/{Subagent-hG9lJ7tJ.mjs → Subagent-CmFtZaeI.mjs} +2 -2
- package/dist/{Subagent-hG9lJ7tJ.mjs.map → Subagent-CmFtZaeI.mjs.map} +1 -1
- package/dist/{Subagent-VHrANXFy.d.mts → Subagent-Dld4W1BY.d.mts} +7 -7
- package/dist/{SubagentHost-C-4A7tA2.d.mts → SubagentHost--HBuY8fF.d.mts} +4 -4
- package/dist/{Subscription-BJAzYNw1.d.mts → Subscription-BomcQ9_W.d.mts} +5 -5
- package/dist/{SubscriptionInput-CkBJt0AS.d.mts → SubscriptionInput-gpZSR9vB.d.mts} +3 -3
- package/dist/{ThreadHistory-tS1KwxHR.d.mts → ThreadHistory-ZEu_ja6L.d.mts} +2 -2
- package/dist/{Worker-fwWkBg12.d.mts → Worker-2r2zGDkh.d.mts} +2 -2
- package/dist/{WorkerAdmission-CJ_oWRuS.mjs → WorkerAdmission-CNbm4o_x.mjs} +3 -3
- package/dist/{WorkerAdmission-CJ_oWRuS.mjs.map → WorkerAdmission-CNbm4o_x.mjs.map} +1 -1
- package/dist/{agent-registration-CKNsrpwo.mjs → agent-registration-U3kmV7nW.mjs} +18 -18
- package/dist/agent-registration-U3kmV7nW.mjs.map +1 -0
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/Messaging.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 +2 -2
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/core/Agent.d.mts +1 -1
- package/dist/core/AgentPolicy.d.mts +1 -1
- package/dist/core/AgentPolicy.mjs +2 -0
- package/dist/core/AgentPolicy.mjs.map +1 -1
- package/dist/core/RunEvent.d.mts +2 -2
- package/dist/core/RunEvent.mjs +10 -1
- package/dist/core/RunEvent.mjs.map +1 -1
- package/dist/core/RunPolicyUsage.d.mts +1 -1
- package/dist/core/RunPolicyUsage.mjs +6 -1
- package/dist/core/RunPolicyUsage.mjs.map +1 -1
- package/dist/core/Worker.d.mts +1 -1
- package/dist/durable/ActivityStore.d.mts +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/AgentRegistration.d.mts +2 -2
- package/dist/durable/AgentRegistration.mjs +3 -2
- package/dist/durable/AgentRegistration.mjs.map +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/MessageDelivery.d.mts +5 -5
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +42 -42
- package/dist/durable/PersistentHistory.d.mts +2 -2
- package/dist/durable/PersistentHistory.mjs +1 -1
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/Records.d.mts +2 -2
- package/dist/durable/Records.mjs +16 -1
- package/dist/durable/Records.mjs.map +1 -1
- package/dist/durable/Recovery.d.mts +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/ScheduleStoreConformance.d.mts +1 -1
- package/dist/durable/ScheduleTransition.d.mts +1 -1
- package/dist/durable/Scheduling.d.mts +3 -3
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +2 -2
- package/dist/durable/SubmissionLedgerConformance.mjs +1 -1
- 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/ThreadInvariants.mjs +1 -1
- 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/ThreadStore.mjs +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.mjs +1 -1
- package/dist/durable/WorkerAdmission.d.mts +3 -3
- package/dist/durable/WorkerAdmission.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +5 -5
- 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/engine/ThreadHistory.d.mts +1 -1
- package/dist/index.d.mts +22 -22
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
- package/src/core/AgentPolicy.ts +2 -0
- package/src/core/RunEvent.ts +9 -0
- package/src/core/RunPolicyUsage.ts +2 -0
- package/src/durable/AgentRegistration.ts +2 -0
- package/src/durable/DurableAgentRuntime.ts +331 -138
- package/src/durable/Records.ts +12 -0
- package/src/durable/RunJournal.ts +88 -27
- package/src/durable/internal/agent-registration.ts +58 -35
- package/src/engine/RunOptions.ts +17 -2
- package/src/engine/internal/agent-runtime.ts +115 -8
- package/dist/AgentRuntime-D8U9gl9Q.mjs.map +0 -1
- package/dist/DurableAgentRuntime-R2LUYnRl.mjs.map +0 -1
- package/dist/RunJournal-Gd83HYqG.mjs.map +0 -1
- package/dist/agent-registration-CKNsrpwo.mjs.map +0 -1
|
@@ -4,23 +4,23 @@ import { a as Receipt, i as QueueSequence, n as JoinedToHost, r as Principal, t
|
|
|
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
6
|
import { l as RunUsageSummary, r as ModelCallUsage } from "./Usage-Dx0aknfk.mjs";
|
|
7
|
-
import { a as ExhaustedLimit } from "./RunEvent-
|
|
8
|
-
import { t as ThreadHistory } from "./ThreadHistory-
|
|
7
|
+
import { a as ExhaustedLimit } from "./RunEvent-DV_llBcq.mjs";
|
|
8
|
+
import { t as ThreadHistory } from "./ThreadHistory-ZEu_ja6L.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";
|
|
12
|
-
import { t as AgentPolicy } from "./AgentPolicy-
|
|
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-
|
|
14
|
-
import { t as RunPolicyUsage } from "./RunPolicyUsage-
|
|
15
|
-
import { c as WorkerError, f as WorkerRef, n as AssignmentTerminal } from "./Worker-
|
|
16
|
-
import { G as RunToolAuthorization, O as RunCostEstimator, h as RunApprovalHook, x as RunContextPreparation } from "./RunOptions-
|
|
12
|
+
import { t as AgentPolicy } from "./AgentPolicy-CnXWWwdg.mjs";
|
|
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
|
+
import { t as RunPolicyUsage } from "./RunPolicyUsage-CUudVtg_.mjs";
|
|
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-CkRYnlJa.mjs";
|
|
17
17
|
import { o as MessagingError, r as InputMessage } from "./Messaging-Dkg87ebg.mjs";
|
|
18
|
-
import { t as MessagingHost } from "./MessagingHost-
|
|
19
|
-
import "./Messaging-
|
|
20
|
-
import { d as WorkerReportPreparationFailure, f as WorkerReporting, o as SubagentHost } from "./SubagentHost
|
|
21
|
-
import { p as RuntimeBinding, r as AgentCompletionProjectionRequirements, s as AgentRuntimeRequirements } from "./AgentRuntime-
|
|
22
|
-
import { $ as
|
|
23
|
-
import { t as DigestError } from "./Digest-
|
|
18
|
+
import { t as MessagingHost } from "./MessagingHost-B4jqlJmx.mjs";
|
|
19
|
+
import "./Messaging-B1zumorg.mjs";
|
|
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-BAjT5gXl.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-BrEpibum.mjs";
|
|
23
|
+
import { t as DigestError } from "./Digest-CaJ2RIsF.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";
|
|
@@ -35,6 +35,22 @@ declare const BindingUnavailable_base: Schema.Class<BindingUnavailable, Schema.T
|
|
|
35
35
|
/** No unique current executable is registered for the stable Agent identity. */
|
|
36
36
|
declare class BindingUnavailable extends BindingUnavailable_base {}
|
|
37
37
|
type DurableBindingFailure = BindingUnavailable;
|
|
38
|
+
/**
|
|
39
|
+
* Submission execution/recovery routing for stable identities shared by current Definitions.
|
|
40
|
+
* Worker declarations and peer-messaging endpoints still require unique Agent identities.
|
|
41
|
+
*/
|
|
42
|
+
interface BindingSelection {
|
|
43
|
+
/** Change when routing changes, so hosts can retry parked work without rewriting admission. */
|
|
44
|
+
readonly key: string;
|
|
45
|
+
/**
|
|
46
|
+
* Select an exact registered Definition using the canonical Submission and authoritative host
|
|
47
|
+
* state. Undefined retains unique-identity resolution. Never grant authority or mutate here;
|
|
48
|
+
* input decoding, replay contracts and current Tool authorization still apply after selection.
|
|
49
|
+
*/
|
|
50
|
+
readonly select: (submission: SubmissionSnapshot) => Effect.Effect<AnyDefinition | undefined, DurableWorkerFailure | BindingUnavailable>;
|
|
51
|
+
}
|
|
52
|
+
/** Captured at runtime construction; callers cannot replace routing during an Attempt. */
|
|
53
|
+
declare const CurrentBindingSelection: Context.Reference<BindingSelection | undefined>;
|
|
38
54
|
/** Exact immutable admission, lineage and delivery evidence; never an executable-code gate. */
|
|
39
55
|
declare const definitionDigestsEqual: (left: DefinitionDigests, right: DefinitionDigests) => boolean;
|
|
40
56
|
/** Change an operation version when its meaning, durable Steps or idempotency keys change. */
|
|
@@ -129,7 +145,7 @@ type RegistrationRequirements<Entries extends ReadonlyArray<AgentRegistration>>
|
|
|
129
145
|
/** Compile heterogeneous Agent descriptors into exact, dependency-closed worker registrations. */
|
|
130
146
|
declare const compileRegistrations: <const Entries extends ReadonlyArray<AgentRegistration>>(entries: Entries) => Effect.Effect<ReadonlyArray<ResolvedBinding>, DigestError, Crypto.Crypto | RegistrationRequirements<Entries>>;
|
|
131
147
|
declare namespace AgentRegistration_d_exports {
|
|
132
|
-
export { AgentAttemptContext, AgentRegistration, BindingUnavailable, DurableBindingFailure, DurableWorkerBinding, ExecutableAgentBinding, ReplayVersions, ResolvedBinding, compileBindingContracts, compileRegistrations, definitionDigestsEqual };
|
|
148
|
+
export { AgentAttemptContext, AgentRegistration, BindingSelection, BindingUnavailable, CurrentBindingSelection, DurableBindingFailure, DurableWorkerBinding, ExecutableAgentBinding, ReplayVersions, ResolvedBinding, compileBindingContracts, compileRegistrations, definitionDigestsEqual };
|
|
133
149
|
}
|
|
134
150
|
//#endregion
|
|
135
151
|
//#region src/durable/internal/journal-checkpoint.d.ts
|
|
@@ -145,6 +161,7 @@ declare const JournalCheckpointSeed_base: Schema.Class<JournalCheckpointSeed, Sc
|
|
|
145
161
|
readonly programmaticToolCalls: Schema.Natural;
|
|
146
162
|
readonly consecutiveToolFailures: Schema.Natural;
|
|
147
163
|
readonly finalizationUsed: Schema.Boolean;
|
|
164
|
+
readonly modelRestarts: Schema.optionalKey<Schema.Int>;
|
|
148
165
|
}>;
|
|
149
166
|
readonly modelCalls: Schema.Natural;
|
|
150
167
|
readonly unobservedModelCalls: Schema.Natural;
|
|
@@ -2092,6 +2109,8 @@ declare class DurableRuntimeConfig extends DurableRuntimeConfig_base {
|
|
|
2092
2109
|
static layer(options: DurableRuntimeConfigOptions): Layer.Layer<DurableRuntimeConfig>;
|
|
2093
2110
|
}
|
|
2094
2111
|
declare const DurableAgentRuntime_base: Context.ServiceClass<DurableAgentRuntime, "@effect-agent/thread/DurableAgentRuntime", {
|
|
2112
|
+
/** Stable registration identity for hosts parking unavailable bindings; never an admission authority. */
|
|
2113
|
+
readonly bindingRegistryKey: string;
|
|
2095
2114
|
/** Acquire an authenticated source Thread facet; its References confer no authority. */
|
|
2096
2115
|
readonly workerHost: (request: {
|
|
2097
2116
|
readonly sourceThreadId: ThreadId;
|
|
@@ -2253,7 +2272,7 @@ declare const DurableAgentRuntime_base: Context.ServiceClass<DurableAgentRuntime
|
|
|
2253
2272
|
declare class DurableAgentRuntime extends DurableAgentRuntime_base {
|
|
2254
2273
|
/**
|
|
2255
2274
|
* Resolve typed registrations and capture their services once in the runtime's Layer Scope.
|
|
2256
|
-
* Every claimed head must
|
|
2275
|
+
* Every claimed head must select exactly one current registered Definition. Worker calls
|
|
2257
2276
|
* cannot replace these registrations or their captured services. Tool authorization is required.
|
|
2258
2277
|
*/
|
|
2259
2278
|
static layerRegistered<const Entries extends ReadonlyArray<AgentRegistration>>(registrations: Entries): Layer.Layer<DurableAgentRuntime, DigestError, Crypto.Crypto | DurableRuntimeConfig | DurableRuntimeFailpoint | RunToolAuthorization | SubmissionLedger | ThreadStore | ToolReconciler | WakeScheduler | Exclude<[Entries[number]] extends [never] ? never : Entries[number] extends (infer T) ? T extends Entries[number] ? T extends unknown ? ("attemptLayer" extends keyof T ? T[keyof T & "attemptLayer"] : undefined) extends (infer T_1) ? T_1 extends ("attemptLayer" extends keyof T ? T[keyof T & "attemptLayer"] : undefined) ? T_1 extends ((context: AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T extends {
|
|
@@ -4232,5 +4251,5 @@ declare const RetryRefused_base: Schema.Class<RetryRefused, Schema.TaggedStruct<
|
|
|
4232
4251
|
*/
|
|
4233
4252
|
declare class RetryRefused extends RetryRefused_base {}
|
|
4234
4253
|
//#endregion
|
|
4235
|
-
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,
|
|
4236
|
-
//# sourceMappingURL=Admin-
|
|
4254
|
+
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-BjmupLN3.d.mts.map
|
|
@@ -2,7 +2,7 @@ import { t as AgentId } from "./Identifiers-CN2s30fF.mjs";
|
|
|
2
2
|
import { i as UpdateError, n as Emitter } from "./AgentUpdates-DMJ-_xow.mjs";
|
|
3
3
|
import { r as Configuration } from "./ToolExposure-r2eOWk4F.mjs";
|
|
4
4
|
import { a as AgentInputError, l as AgentRunDispositionError, s as AgentOutputError } from "./AgentError-Bn1ytXRD.mjs";
|
|
5
|
-
import { n as AgentPolicyInput, t as AgentPolicy } from "./AgentPolicy-
|
|
5
|
+
import { n as AgentPolicyInput, t as AgentPolicy } from "./AgentPolicy-CnXWWwdg.mjs";
|
|
6
6
|
import { AiError, LanguageModel, Model, Prompt, Tool, Toolkit } from "effect/unstable/ai";
|
|
7
7
|
import { Effect, Layer, Option, Schema } from "effect";
|
|
8
8
|
//#region src/core/internal/agent-updates.d.ts
|
|
@@ -256,4 +256,4 @@ declare function make<const Name extends string, InputSchema extends Schema.Top,
|
|
|
256
256
|
declare const withModel: <DefinitionValue extends AnyDefinition, ModelValue>(definition: DefinitionValue, model: NativeModel<ModelValue>) => Binding<DefinitionValue, ModelValue>;
|
|
257
257
|
//#endregion
|
|
258
258
|
export { ToolUnion as A, OutputSchema as C, RunDispositionFailure as D, RunDispositionDeclaration as E, isModelResolver as F, make as I, withModel as L, Update as M, UpdatesSchema as N, RunDispositionSchema as O, inspectTools as P, Output as S, RunDisposition as T, InstructionSource as _, CompletionFromToolDeclaration as a, Name as b, Definition as c, EncodedInput as d, Failure as f, InstructionResult as g, InputSchema as h, Binding as i, Tools as j, ToolInspection as k, DefinitionOptions as l, InputPromptSource as m, Any as n, CompletionProjectionInput as o, Input as p, AnyDefinition as r, CompletionToolDeclaration as s, Agent_d_exports as t, DefinitionRequirements as u, ModelResolver as v, Requirements as w, NativeModel as x, ModelServices as y };
|
|
259
|
-
//# sourceMappingURL=Agent-
|
|
259
|
+
//# sourceMappingURL=Agent-BCyrGaWg.d.mts.map
|
|
@@ -47,6 +47,8 @@ declare const AgentPolicyFields: Schema.Struct<{
|
|
|
47
47
|
readonly contextTokenLimit: Schema.optionalKey<Schema.Int>;
|
|
48
48
|
readonly toolResultBounds: typeof ToolResultBounds;
|
|
49
49
|
readonly runStatus: Schema.Literals<readonly ["appended", "off"]>;
|
|
50
|
+
/** Restart a disposable model call on joined input, at most twice per Run. Default off. */
|
|
51
|
+
readonly restartOnJoinedInput: Schema.optionalKey<Schema.Boolean>;
|
|
50
52
|
readonly compaction: typeof CompactionPolicy;
|
|
51
53
|
}>;
|
|
52
54
|
type AgentPolicyFields = typeof AgentPolicyFields.Type;
|
|
@@ -82,6 +84,8 @@ declare const AgentPolicy_base: Schema.Class<AgentPolicy, Schema.Struct<{
|
|
|
82
84
|
readonly contextTokenLimit: Schema.optionalKey<Schema.Int>;
|
|
83
85
|
readonly toolResultBounds: typeof ToolResultBounds;
|
|
84
86
|
readonly runStatus: Schema.Literals<readonly ["appended", "off"]>;
|
|
87
|
+
/** Restart a disposable model call on joined input, at most twice per Run. Default off. */
|
|
88
|
+
readonly restartOnJoinedInput: Schema.optionalKey<Schema.Boolean>;
|
|
85
89
|
readonly compaction: typeof CompactionPolicy;
|
|
86
90
|
}>, {}>;
|
|
87
91
|
/** Schema class for finite agent run limits. */
|
|
@@ -93,4 +97,4 @@ declare class AgentPolicy extends AgentPolicy_base {
|
|
|
93
97
|
}
|
|
94
98
|
//#endregion
|
|
95
99
|
export { CompactionPolicyInput as a, CompactionPolicy as i, AgentPolicyInput as n, AgentPolicy_d_exports as r, AgentPolicy as t };
|
|
96
|
-
//# sourceMappingURL=AgentPolicy-
|
|
100
|
+
//# sourceMappingURL=AgentPolicy-CnXWWwdg.d.mts.map
|
|
@@ -2,20 +2,20 @@ import { d as ToolCallId, r as DelegationId, s as RunId, t as AgentId, u as Thre
|
|
|
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
4
|
import { c as RunUsageReport, s as RunTotals } from "./Usage-Dx0aknfk.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { n as ThreadHistoryError, t as ThreadHistory } from "./ThreadHistory-
|
|
5
|
+
import { u as RunEvent } from "./RunEvent-DV_llBcq.mjs";
|
|
6
|
+
import { n as ThreadHistoryError, t as ThreadHistory } from "./ThreadHistory-ZEu_ja6L.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";
|
|
10
|
-
import { t as AgentPolicy } from "./AgentPolicy-
|
|
11
|
-
import { A as ToolUnion, C as OutputSchema, D as RunDispositionFailure, E as RunDispositionDeclaration, N as UpdatesSchema, O as RunDispositionSchema, S as Output, _ as InstructionSource, a as CompletionFromToolDeclaration, c as Definition, d as EncodedInput, f as Failure, m as InputPromptSource, n as Any, r as AnyDefinition, s as CompletionToolDeclaration, t as Agent_d_exports, w as Requirements } from "./Agent-
|
|
12
|
-
import { a as WorkerBudgetScope } from "./Worker-
|
|
10
|
+
import { t as AgentPolicy } from "./AgentPolicy-CnXWWwdg.mjs";
|
|
11
|
+
import { A as ToolUnion, C as OutputSchema, D as RunDispositionFailure, E as RunDispositionDeclaration, N as UpdatesSchema, O as RunDispositionSchema, S as Output, _ as InstructionSource, a as CompletionFromToolDeclaration, c as Definition, d as EncodedInput, f as Failure, m as InputPromptSource, n as Any, r as AnyDefinition, s as CompletionToolDeclaration, t as Agent_d_exports, w as Requirements } from "./Agent-BCyrGaWg.mjs";
|
|
12
|
+
import { a as WorkerBudgetScope } from "./Worker-2r2zGDkh.mjs";
|
|
13
13
|
import { a as ContextWindow } from "./ContextWindow-DRQ5Mbm2.mjs";
|
|
14
|
-
import { n as CompactionError } from "./ContextCompactor-
|
|
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-
|
|
17
|
-
import { t as MessagingHost } from "./MessagingHost-
|
|
18
|
-
import { o as SubagentHost } from "./SubagentHost
|
|
16
|
+
import { B as RunSubagentChildIdentity, H as RunSubagentEstablishRequest, M as RunOptions, S as RunContextPreparationError, W as RunSubagentJoinRequest, i as ChildEstablishStatus, l as ModelUsageAccounting, t as AgentUpdateAcceptance, x as RunContextPreparation } from "./RunOptions-CkRYnlJa.mjs";
|
|
17
|
+
import { t as MessagingHost } from "./MessagingHost-B4jqlJmx.mjs";
|
|
18
|
+
import { o as SubagentHost } from "./SubagentHost--HBuY8fF.mjs";
|
|
19
19
|
import { t as RunEventSink } from "./RunEventSink-D5aVhISG.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";
|
|
@@ -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-BAjT5gXl.d.mts.map
|
|
@@ -10,7 +10,7 @@ import { IdGenerator as IdGenerator$1 } from "./core/IdGenerator.mjs";
|
|
|
10
10
|
import { DelegationDepth, SubagentParentLink, getToolExecutionKind, isSubagentToolAllowed } from "./core/SubagentContract.mjs";
|
|
11
11
|
import { a as PinnedTool, c as ToolNames, i as Limits, l as ToolNamespace, n as DiscoveryTool, o as Selection, r as IncludesCatalogDocumentation, s as Snapshot, t as AdditionalToolCatalog } from "./ToolExposure-C93U1sPu.mjs";
|
|
12
12
|
import { InputTokenUsage, ModelCallUsage, ModelResponseIdentity, OutputTokenUsage, RunTotals, RunUsageReport, emptyRunTotals, sumRunTotals, unknownRunTotals } from "./core/Usage.mjs";
|
|
13
|
-
import { AgentUpdateEmitted, ApprovalRequested, BudgetWarning, CompactionPerformed, ModelStarted, ReasoningDelta, RunCompleted, RunFailed, RunStarted, RunSuspended, SubagentCompleted, SubagentFailed, SubagentInterrupted, SubagentJoined, SubagentProgress, SubagentRequested, SubagentStarted, TextDelta, ToolCallDeclared, ToolCallFailed, ToolCallStarted, ToolCallSucceeded, ToolProgress, TurnCompleted, TurnStarted } from "./core/RunEvent.mjs";
|
|
13
|
+
import { AgentUpdateEmitted, ApprovalRequested, BudgetWarning, CompactionPerformed, ModelRestarted, ModelStarted, ReasoningDelta, RunCompleted, RunFailed, RunStarted, RunSuspended, SubagentCompleted, SubagentFailed, SubagentInterrupted, SubagentJoined, SubagentProgress, SubagentRequested, SubagentStarted, TextDelta, ToolCallDeclared, ToolCallFailed, ToolCallStarted, ToolCallSucceeded, ToolProgress, TurnCompleted, TurnStarted } from "./core/RunEvent.mjs";
|
|
14
14
|
import { r as FrameworkMessage, t as AssignmentDisposition } from "./Worker-CfwzMZEK.mjs";
|
|
15
15
|
import { t as MessagingHost } from "./MessagingHost-DfsbMPvq.mjs";
|
|
16
16
|
import { SubagentHost } from "./engine/SubagentHost.mjs";
|
|
@@ -1071,7 +1071,8 @@ const decodeResumeUsage = Effect.fn("AgentRuntime.decodeResumeUsage")((input) =>
|
|
|
1071
1071
|
"usageStatus",
|
|
1072
1072
|
"pricingStatus",
|
|
1073
1073
|
"unobservedModelCalls",
|
|
1074
|
-
"children"
|
|
1074
|
+
"children",
|
|
1075
|
+
"modelRestarts"
|
|
1075
1076
|
].map((key) => [key, read(key, true)]).filter(([, value]) => value !== void 0)),
|
|
1076
1077
|
modelCalls: read("modelCalls"),
|
|
1077
1078
|
inputTokens: read("inputTokens"),
|
|
@@ -1327,7 +1328,7 @@ const agentTelemetryAttributes = (context) => ({
|
|
|
1327
1328
|
"gen_ai.conversation.id": context.threadId
|
|
1328
1329
|
});
|
|
1329
1330
|
/** Label Effect AI's existing span, preserving provider usage, sampling and host async context. */
|
|
1330
|
-
const modelTelemetryTracer = Effect.fnUntraced(function* (context, turnId) {
|
|
1331
|
+
const modelTelemetryTracer = Effect.fnUntraced(function* (context, turnId, onSpan) {
|
|
1331
1332
|
const delegate = yield* Tracer.Tracer;
|
|
1332
1333
|
const model = yield* Model.ModelName;
|
|
1333
1334
|
const provider = yield* Model.ProviderName;
|
|
@@ -1338,6 +1339,7 @@ const modelTelemetryTracer = Effect.fnUntraced(function* (context, turnId) {
|
|
|
1338
1339
|
...options,
|
|
1339
1340
|
name: `chat ${model}`
|
|
1340
1341
|
});
|
|
1342
|
+
onSpan?.(span);
|
|
1341
1343
|
const attributes = {
|
|
1342
1344
|
...agentTelemetryAttributes(context),
|
|
1343
1345
|
"gen_ai.operation.name": "chat",
|
|
@@ -2785,7 +2787,7 @@ const nextTurn = (prompt, turn, toolCalls) => Stream.succeed({
|
|
|
2785
2787
|
turn,
|
|
2786
2788
|
toolCalls
|
|
2787
2789
|
});
|
|
2788
|
-
const makeTurn = (agent, context, prompt, turn, priorToolCalls, options) => Stream.unwrap(Effect.gen(function* () {
|
|
2790
|
+
const makeTurn = (agent, context, prompt, turn, priorToolCalls, options, restarting = false) => Stream.unwrap(Effect.gen(function* () {
|
|
2789
2791
|
const policy = agent.definition.policy;
|
|
2790
2792
|
const bounds = effectiveRunBounds(policy, options);
|
|
2791
2793
|
if (options.beforeTurn !== void 0) yield* options.beforeTurn();
|
|
@@ -2794,7 +2796,7 @@ const makeTurn = (agent, context, prompt, turn, priorToolCalls, options) => Stre
|
|
|
2794
2796
|
limit: "turns",
|
|
2795
2797
|
message: `Agent exceeded its ${bounds.maxTurns} Turn limit`
|
|
2796
2798
|
}));
|
|
2797
|
-
if (context.finalizationUsed) return failRunEventStream(AgentPolicyError.make({
|
|
2799
|
+
if (context.finalizationUsed && !restarting) return failRunEventStream(AgentPolicyError.make({
|
|
2798
2800
|
limit: turn > bounds.maxTurns ? "turns" : priorToolCalls + context.programmaticToolCalls > bounds.maxToolCalls ? "tool-calls" : "tokens",
|
|
2799
2801
|
message: "Agent already used its one grace finalization"
|
|
2800
2802
|
}));
|
|
@@ -2852,6 +2854,8 @@ const makeTurn = (agent, context, prompt, turn, priorToolCalls, options) => Stre
|
|
|
2852
2854
|
const preparedPrefix = yield* snapshotCompactionMessages(modelContext.prompt.content.slice(0, priorCompactionPrefix.length));
|
|
2853
2855
|
if (!Equal.equals(preparedPrefix, priorCompactionPrefix)) return yield* CompactionError.make({ message: "Prepared context changed a prefix already covered by compaction" });
|
|
2854
2856
|
}
|
|
2857
|
+
let restartRequested = false;
|
|
2858
|
+
let activeModelSpan;
|
|
2855
2859
|
const trace = {
|
|
2856
2860
|
responsePartCount: 0,
|
|
2857
2861
|
responsePartBytes: 0,
|
|
@@ -3077,11 +3081,13 @@ const makeTurn = (agent, context, prompt, turn, priorToolCalls, options) => Stre
|
|
|
3077
3081
|
purpose: "turn"
|
|
3078
3082
|
}).pipe(withCallModel, Effect.tapCause(() => context.modelCalls === priorModelCalls ? noteIncompleteUsage(context, turn) : Effect.void));
|
|
3079
3083
|
});
|
|
3084
|
+
let failedUsageCause;
|
|
3080
3085
|
const retainFailedUsage = Effect.fn("AgentRuntime.retainFailedUsage")(function* () {
|
|
3081
3086
|
if (trace.usageConsumed) return;
|
|
3082
3087
|
trace.usageConsumed = true;
|
|
3083
3088
|
if (trace.usage === void 0) return yield* noteIncompleteUsage(context, turn);
|
|
3084
|
-
yield* consumeTurnUsage(0).pipe(Effect.exit);
|
|
3089
|
+
const exit = yield* consumeTurnUsage(0).pipe(Effect.exit);
|
|
3090
|
+
if (Exit.isFailure(exit)) failedUsageCause = exit.cause;
|
|
3085
3091
|
});
|
|
3086
3092
|
const attempt = (basis) => Stream.unwrap(outgoingModelPrompt(policy, context, prepareModelPrompt(Prompt.fromMessages([...basis.content, ...transientContext.content]), outputContract._tag === "rendered" ? outputContract.part : void 0, systemMessagesInHistory, staticInstructions), turn, priorToolCalls, systemMessagesInHistory).pipe(withCallModel, Effect.flatMap((providerPrompt) => Effect.gen(function* () {
|
|
3087
3093
|
const toolChoice = modelToolChoice();
|
|
@@ -3109,9 +3115,11 @@ const makeTurn = (agent, context, prompt, turn, priorToolCalls, options) => Stre
|
|
|
3109
3115
|
toolkit: deferredToolParameterToolkit(requestToolkit),
|
|
3110
3116
|
disableToolCallResolution: true,
|
|
3111
3117
|
...toolChoice === void 0 ? {} : { toolChoice }
|
|
3112
|
-
}), options.budget).pipe((stream) => policy.runStatus === "appended" || options.context !== void 0 || options.transientContext !== void 0 ? stream.pipe(Stream.provideServiceEffect(ResponseIdTracker.ResponseIdTracker, ResponseIdTracker.make)) : stream, Stream.provideServiceEffect(Tracer.Tracer, modelTelemetryTracer(context, turnId
|
|
3118
|
+
}), options.budget).pipe((stream) => policy.runStatus === "appended" || options.context !== void 0 || options.transientContext !== void 0 ? stream.pipe(Stream.provideServiceEffect(ResponseIdTracker.ResponseIdTracker, ResponseIdTracker.make)) : stream, Stream.provideServiceEffect(Tracer.Tracer, modelTelemetryTracer(context, turnId, (span) => {
|
|
3119
|
+
activeModelSpan = span;
|
|
3120
|
+
})), Stream.onStart(Effect.sync(() => {
|
|
3113
3121
|
trace.usageConsumed = false;
|
|
3114
|
-
})), Stream.mapEffect((part) => ownModelResponsePart(part, agent.definition.toolkit, trace, context.bufferLimits).pipe(Effect.flatMap((owned) => eventsForPart(context, turnId, turn, agent.definition.toolkit.tools, trace, owned.ownedPart, owned.retainedBytes)))), Stream.flatMap(Stream.fromIterable), Stream.
|
|
3122
|
+
})), Stream.mapEffect((part) => ownModelResponsePart(part, agent.definition.toolkit, trace, context.bufferLimits).pipe(Effect.flatMap((owned) => eventsForPart(context, turnId, turn, agent.definition.toolkit.tools, trace, owned.ownedPart, owned.retainedBytes)))), Stream.flatMap(Stream.fromIterable), Stream.onExit((exit) => Exit.isFailure(exit) ? retainFailedUsage() : Effect.void))));
|
|
3115
3123
|
}))));
|
|
3116
3124
|
const response = attempt(compactedOutgoing()).pipe(Stream.catch((error) => {
|
|
3117
3125
|
if (!(error instanceof AiError.AiError) || !isContextOverflowMessage(overflowText(error))) return Stream.fail(error);
|
|
@@ -3329,7 +3337,41 @@ const makeTurn = (agent, context, prompt, turn, priorToolCalls, options) => Stre
|
|
|
3329
3337
|
if (trace.finishReason !== "stop") return failRunEventStream(ModelProtocolError.make({ message: `Model stopped without a final answer (${trace.finishReason})` }));
|
|
3330
3338
|
return afterValidatedResponse(settleOrFollowUp(historyWithResponse()));
|
|
3331
3339
|
}));
|
|
3332
|
-
const
|
|
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;
|
|
3341
|
+
const disposableResponse = restartSignal !== void 0 ? response.pipe(Stream.interruptWhen(restartSignal.pipe(Effect.tap(() => Effect.sync(() => {
|
|
3342
|
+
restartRequested = true;
|
|
3343
|
+
activeModelSpan?.attribute("effect_agent.model.outcome", "aborted");
|
|
3344
|
+
activeModelSpan?.attribute("effect_agent.model.abort_reason", "joined-input");
|
|
3345
|
+
}))))) : response;
|
|
3346
|
+
const afterResponse = Stream.unwrap(Effect.gen(function* () {
|
|
3347
|
+
if (!restartRequested) return continuation.pipe(Stream.tapCause(() => retainFailedUsage()));
|
|
3348
|
+
const discarded = ModelRestarted.make({
|
|
3349
|
+
...yield* eventBase(context),
|
|
3350
|
+
turnId,
|
|
3351
|
+
turn,
|
|
3352
|
+
reason: "joined-input"
|
|
3353
|
+
});
|
|
3354
|
+
return Stream.succeed(discarded).pipe(Stream.concat(Stream.unwrap(Effect.gen(function* () {
|
|
3355
|
+
yield* retainFailedUsage();
|
|
3356
|
+
context.modelRestarts++;
|
|
3357
|
+
if (options.durability?.commitModelRestart !== void 0) yield* options.durability.commitModelRestart({
|
|
3358
|
+
turn,
|
|
3359
|
+
turnId,
|
|
3360
|
+
restart: context.modelRestarts
|
|
3361
|
+
});
|
|
3362
|
+
if (failedUsageCause !== void 0) return yield* Effect.failCause(failedUsageCause);
|
|
3363
|
+
const inputs = yield* drainInputs(context, options);
|
|
3364
|
+
const nextPrompt = yield* appendInputs(context, prompt, inputs, options);
|
|
3365
|
+
return Stream.succeed({
|
|
3366
|
+
_tag: "NextTurn",
|
|
3367
|
+
prompt: nextPrompt,
|
|
3368
|
+
turn,
|
|
3369
|
+
toolCalls: priorToolCalls,
|
|
3370
|
+
restarting: true
|
|
3371
|
+
});
|
|
3372
|
+
}))));
|
|
3373
|
+
}));
|
|
3374
|
+
const events = Stream.fromIterable(preEvents).pipe(Stream.concat(started), Stream.concat(disposableResponse), Stream.concat(afterResponse));
|
|
3333
3375
|
return modelServices === void 0 ? events : Stream.provideContext(events, modelServices);
|
|
3334
3376
|
}));
|
|
3335
3377
|
/**
|
|
@@ -3693,6 +3735,7 @@ function streamWithCompletion(agentValue, input, runOptions = {}, onCompleted, o
|
|
|
3693
3735
|
durationDeadlineMillis,
|
|
3694
3736
|
history: options.history ?? Prompt.empty,
|
|
3695
3737
|
modelCalls: resumeUsage?.modelCalls ?? 0,
|
|
3738
|
+
modelRestarts: resumeUsage?.modelRestarts ?? 0,
|
|
3696
3739
|
usageStatus: resumeUsage?.usageStatus ?? (resumeUsage === void 0 ? "complete" : "unknown"),
|
|
3697
3740
|
pricingStatus: resumeUsage?.pricingStatus ?? (resumeUsage === void 0 ? "complete" : "unknown"),
|
|
3698
3741
|
unobservedModelCalls: resumeUsage?.unobservedModelCalls ?? 0,
|
|
@@ -3822,7 +3865,7 @@ function streamWithCompletion(agentValue, input, runOptions = {}, onCompleted, o
|
|
|
3822
3865
|
const current = pending;
|
|
3823
3866
|
pending = void 0;
|
|
3824
3867
|
return current === void 0 ? Cause.done() : Effect.succeed(current);
|
|
3825
|
-
})).pipe(Stream.flatMap((request) => request.resume === void 0 ? makeTurn(agent, context, request.prompt, request.turn, request.toolCalls, options) : makeResumeTurn(agent, context, request.prompt, request.resume, request.toolCalls, options)), Stream.filterMapEffect((output) => Effect.sync(() => {
|
|
3868
|
+
})).pipe(Stream.flatMap((request) => request.resume === void 0 ? makeTurn(agent, context, request.prompt, request.turn, request.toolCalls, options, request.restarting) : makeResumeTurn(agent, context, request.prompt, request.resume, request.toolCalls, options)), Stream.filterMapEffect((output) => Effect.sync(() => {
|
|
3826
3869
|
if (output._tag === "NextTurn") {
|
|
3827
3870
|
pending = output;
|
|
3828
3871
|
return Result.fail(void 0);
|
|
@@ -4742,4 +4785,4 @@ var AgentRuntime_exports = /* @__PURE__ */ __exportAll({
|
|
|
4742
4785
|
//#endregion
|
|
4743
4786
|
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 };
|
|
4744
4787
|
|
|
4745
|
-
//# sourceMappingURL=AgentRuntime-
|
|
4788
|
+
//# sourceMappingURL=AgentRuntime-IF_1GoUf.mjs.map
|