effect-durable-agent 0.4.0 → 0.5.0
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/{compaction-Dlq4wgZE.js → compaction-Bo0IdR4c.js} +3 -3
- package/dist/{compaction-Dlq4wgZE.js.map → compaction-Bo0IdR4c.js.map} +1 -1
- package/dist/{delivery-DoHIy6rQ.d.ts → delivery-Cvn0tFHG.d.ts} +2 -2
- package/dist/domain/command-queues.d.ts +1 -1
- package/dist/domain/message-transcript.d.ts +1 -1
- package/dist/domain/reduced-state.d.ts +1 -1
- package/dist/domain/run-scheduling.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{reduced-state-DNfEwxu7.d.ts → reduced-state-abeH0MOf.d.ts} +480 -480
- package/dist/services/compaction.d.ts +1 -1
- package/dist/services/compaction.js +1 -1
- package/dist/services/decider.d.ts +1 -1
- package/dist/services/model-call.d.ts +1 -1
- package/dist/services/prompt-projector.d.ts +1 -1
- package/dist/services/run-scheduler.d.ts +1 -1
- package/dist/services/runtime-layer.d.ts +1 -1
- package/dist/services/runtime-layer.js +2 -2
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +1 -1
- package/dist/services/session-event-observer.d.ts +1 -1
- package/dist/services/session-query.d.ts +1 -1
- package/dist/services/session-query.js +1 -1
- package/dist/services/session-state.d.ts +1 -1
- package/dist/services/session-state.js +1 -1
- package/dist/services/sink-registry.d.ts +1 -1
- package/dist/services/tool-registry.d.ts +1 -1
- package/dist/{session-state-urBjAvsy.js → session-state-DqRkcZOy.js} +107 -14
- package/dist/session-state-DqRkcZOy.js.map +1 -0
- package/dist/testkit/layers.d.ts +1 -1
- package/dist/testkit/layers.js +2 -2
- package/dist/websocket/events.d.ts +1 -1
- package/dist/websocket.d.ts +1 -1
- package/package.json +1 -1
- package/dist/session-state-urBjAvsy.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $t as PromptPrefixSummaryCompactionExecutorOptions, Bt as CompactionError, Gt as CompactionPlan, Ht as CompactionExecutorInput, Jt as CompactionPolicyShape, Kt as CompactionPolicy, Qt as LanguageModelSummaryCompactionExecutorOptions, Ut as CompactionExecutorShape, Vt as CompactionExecutor, Wt as CompactionOutput, Xt as CompactionRunnerInput, Yt as CompactionRunner, Zt as CompactionRunnerShape, an as promptPrefixSummaryCompactionExecutor, en as defaultCompactionCharsPerToken, in as defaultCompactionThresholdTokens, nn as defaultCompactionRetainTailTokens, qt as CompactionPolicyInput, rn as defaultCompactionSummaryInstructions, tn as defaultCompactionMinSummarizableTokens, zt as ApproximateTokenThresholdCompactionPolicyOptions } from "../reduced-state-
|
|
1
|
+
import { $t as PromptPrefixSummaryCompactionExecutorOptions, Bt as CompactionError, Gt as CompactionPlan, Ht as CompactionExecutorInput, Jt as CompactionPolicyShape, Kt as CompactionPolicy, Qt as LanguageModelSummaryCompactionExecutorOptions, Ut as CompactionExecutorShape, Vt as CompactionExecutor, Wt as CompactionOutput, Xt as CompactionRunnerInput, Yt as CompactionRunner, Zt as CompactionRunnerShape, an as promptPrefixSummaryCompactionExecutor, en as defaultCompactionCharsPerToken, in as defaultCompactionThresholdTokens, nn as defaultCompactionRetainTailTokens, qt as CompactionPolicyInput, rn as defaultCompactionSummaryInstructions, tn as defaultCompactionMinSummarizableTokens, zt as ApproximateTokenThresholdCompactionPolicyOptions } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
export { ApproximateTokenThresholdCompactionPolicyOptions, CompactionError, CompactionExecutor, CompactionExecutorInput, CompactionExecutorShape, CompactionOutput, CompactionPlan, CompactionPolicy, CompactionPolicyInput, CompactionPolicyShape, CompactionRunner, CompactionRunnerInput, CompactionRunnerShape, LanguageModelSummaryCompactionExecutorOptions, PromptPrefixSummaryCompactionExecutorOptions, defaultCompactionCharsPerToken, defaultCompactionMinSummarizableTokens, defaultCompactionRetainTailTokens, defaultCompactionSummaryInstructions, defaultCompactionThresholdTokens, promptPrefixSummaryCompactionExecutor };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as CompactionPolicy, c as defaultCompactionMinSummarizableTokens, d as defaultCompactionThresholdTokens, f as promptPrefixSummaryCompactionExecutor, i as CompactionPlan, l as defaultCompactionRetainTailTokens, n as CompactionExecutor, o as CompactionRunner, r as CompactionOutput, s as defaultCompactionCharsPerToken, t as CompactionError, u as defaultCompactionSummaryInstructions } from "../compaction-
|
|
1
|
+
import { a as CompactionPolicy, c as defaultCompactionMinSummarizableTokens, d as defaultCompactionThresholdTokens, f as promptPrefixSummaryCompactionExecutor, i as CompactionPlan, l as defaultCompactionRetainTailTokens, n as CompactionExecutor, o as CompactionRunner, r as CompactionOutput, s as defaultCompactionCharsPerToken, t as CompactionError, u as defaultCompactionSummaryInstructions } from "../compaction-Bo0IdR4c.js";
|
|
2
2
|
export { CompactionError, CompactionExecutor, CompactionOutput, CompactionPlan, CompactionPolicy, CompactionRunner, defaultCompactionCharsPerToken, defaultCompactionMinSummarizableTokens, defaultCompactionRetainTailTokens, defaultCompactionSummaryInstructions, defaultCompactionThresholdTokens, promptPrefixSummaryCompactionExecutor };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $n as deciderMarkerDedupeKey, Gn as EDADeciderItem, Hn as EDADecider, Jn as EDADeciderView, Kn as EDADeciderOutcome, Qn as deciderIdempotencyKeyViolation, Un as EDADeciderDefinition, Wn as EDADeciderError, Xn as EDAErasedDecision, Yn as EDADecision, Zn as EDAEventDraft, ar as maxDeciderResultBytes, er as deciderNamePattern, ir as maxDeciderIdempotencyKeyLength, nr as encodeDeciderJson, qn as EDADeciderRegistry, rr as makeEDADeciderRegistry, tr as edaReservedDeciderNamePrefix } from "../reduced-state-
|
|
1
|
+
import { $n as deciderMarkerDedupeKey, Gn as EDADeciderItem, Hn as EDADecider, Jn as EDADeciderView, Kn as EDADeciderOutcome, Qn as deciderIdempotencyKeyViolation, Un as EDADeciderDefinition, Wn as EDADeciderError, Xn as EDAErasedDecision, Yn as EDADecision, Zn as EDAEventDraft, ar as maxDeciderResultBytes, er as deciderNamePattern, ir as maxDeciderIdempotencyKeyLength, nr as encodeDeciderJson, qn as EDADeciderRegistry, rr as makeEDADeciderRegistry, tr as edaReservedDeciderNamePrefix } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
export { EDADecider, EDADeciderDefinition, EDADeciderError, EDADeciderItem, EDADeciderOutcome, EDADeciderRegistry, EDADeciderView, EDADecision, EDAErasedDecision, EDAEventDraft, deciderIdempotencyKeyViolation, deciderMarkerDedupeKey, deciderNamePattern, edaReservedDeciderNamePrefix, encodeDeciderJson, makeEDADeciderRegistry, maxDeciderIdempotencyKeyLength, maxDeciderResultBytes };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sn as EDAModelToolkit } from "../reduced-state-
|
|
1
|
+
import { sn as EDAModelToolkit } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as LanguageModel from "effect/ai/LanguageModel";
|
|
4
4
|
import * as Prompt from "effect/ai/Prompt";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { cr as EDAProjectedPromptContext, dr as EDAPromptProjectorShape, fr as EDA_PROMPT_OPTIONS_KEY, gr as nativeCompactionSummaryMessage, hr as isEDACacheBreakpoint, lr as EDAPromptProjectionInput, mr as getNativeCompaction, pr as buildEDAPrompt, sr as EDANativeCompaction, ur as EDAPromptProjector } from "../reduced-state-
|
|
1
|
+
import { cr as EDAProjectedPromptContext, dr as EDAPromptProjectorShape, fr as EDA_PROMPT_OPTIONS_KEY, gr as nativeCompactionSummaryMessage, hr as isEDACacheBreakpoint, lr as EDAPromptProjectionInput, mr as getNativeCompaction, pr as buildEDAPrompt, sr as EDANativeCompaction, ur as EDAPromptProjector } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
export { EDANativeCompaction, EDAProjectedPromptContext, EDAPromptProjectionInput, EDAPromptProjector, EDAPromptProjectorShape, EDA_PROMPT_OPTIONS_KEY, buildEDAPrompt, getNativeCompaction, isEDACacheBreakpoint, nativeCompactionSummaryMessage };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Ct as RunSchedulingDeliveryError, St as RunSchedulingDelivery, Tn as LocalRunResolution, bt as RunScheduler, jn as RunSchedulingInput, kn as RunResolution, wn as DeferredRunResolution, xt as RunSchedulerShape } from "../reduced-state-
|
|
1
|
+
import { Ct as RunSchedulingDeliveryError, St as RunSchedulingDelivery, Tn as LocalRunResolution, bt as RunScheduler, jn as RunSchedulingInput, kn as RunResolution, wn as DeferredRunResolution, xt as RunSchedulerShape } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
export { DeferredRunResolution, LocalRunResolution, type RunResolution, RunScheduler, RunSchedulerShape, RunSchedulingDelivery, RunSchedulingDeliveryError, type RunSchedulingInput };
|
|
@@ -2,7 +2,7 @@ import { g as SessionId } from "../core-BcimKMIv.js";
|
|
|
2
2
|
import { i as EDAAppEvents, o as EDASessionStore, s as EDASessionStoreError } from "../session-store-DaSHeg8Q.js";
|
|
3
3
|
import { t as ModelResolver } from "../model-resolver-O8Kn27GH.js";
|
|
4
4
|
import { r as EDAReducerRegistry } from "../reducer-registry-Bqn5B4JO.js";
|
|
5
|
-
import { $ as SessionCommandAdmissionError, At as EDASink, Hn as EDADecider, J as EDARuntimeConfig, Kt as CompactionPolicy, Sn as SessionEventObserver, Vt as CompactionExecutor, bt as RunScheduler, q as EDARuntime, sn as EDAModelToolkit, un as EDAToolRegistryShape, ur as EDAPromptProjector } from "../reduced-state-
|
|
5
|
+
import { $ as SessionCommandAdmissionError, At as EDASink, Hn as EDADecider, J as EDARuntimeConfig, Kt as CompactionPolicy, Sn as SessionEventObserver, Vt as CompactionExecutor, bt as RunScheduler, q as EDARuntime, sn as EDAModelToolkit, un as EDAToolRegistryShape, ur as EDAPromptProjector } from "../reduced-state-abeH0MOf.js";
|
|
6
6
|
import { t as IdGenerator } from "../id-generator-BKGoKjt-.js";
|
|
7
7
|
import { t as EDAKeepAlive } from "../keep-alive-_zFCUvt3.js";
|
|
8
8
|
import { n as SinkCheckpointStore } from "../sink-checkpoint-store-CUvIVvlZ.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RunSchedulingWakeup } from "./run-scheduling-wakeup.js";
|
|
2
2
|
import { RunScheduler } from "./run-scheduler.js";
|
|
3
|
-
import { d as InferenceRunner, f as ToolExecutor, l as SessionState, p as LiveEventBus, u as TurnRunner } from "../session-state-
|
|
3
|
+
import { d as InferenceRunner, f as ToolExecutor, l as SessionState, p as LiveEventBus, u as TurnRunner } from "../session-state-DqRkcZOy.js";
|
|
4
4
|
import { t as RegisteredAppEvents } from "../session-admission-DC98zwtj.js";
|
|
5
5
|
import { EDASessionStore, registerAppEvents } from "./session-store.js";
|
|
6
|
-
import { a as CompactionPolicy, n as CompactionExecutor, o as CompactionRunner } from "../compaction-
|
|
6
|
+
import { a as CompactionPolicy, n as CompactionExecutor, o as CompactionRunner } from "../compaction-Bo0IdR4c.js";
|
|
7
7
|
import { EDAPromptProjector } from "./prompt-projector.js";
|
|
8
8
|
import { n as SessionContext, t as EventFactory } from "../event-factory-BUoBwqAy.js";
|
|
9
9
|
import { EDAToolRegistry } from "./tool-registry.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { G as CommittedCommandTerminalEvent, J as EDARuntimeConfig, K as EDACommandTerminalEvent, X as EDARuntimeShape, Y as EDARuntimeError, Z as EDARuntimeSubmit, q as EDARuntime } from "../reduced-state-
|
|
1
|
+
import { G as CommittedCommandTerminalEvent, J as EDARuntimeConfig, K as EDACommandTerminalEvent, X as EDARuntimeShape, Y as EDARuntimeError, Z as EDARuntimeSubmit, q as EDARuntime } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
export { CommittedCommandTerminalEvent, EDACommandTerminalEvent, EDARuntime, EDARuntimeConfig, EDARuntimeError, EDARuntimeShape, EDARuntimeSubmit };
|
package/dist/services/runtime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DurablePosition, SequenceNumber, durablePosition } from "../types/core.js";
|
|
2
2
|
import { d as NonNegativeInt, h as SystemPromptText, u as ModelSelectionPayload } from "../envelope-BSI_Xh-f.js";
|
|
3
3
|
import { w as CommandFailedEvent, x as CommandCompletedEvent, y as CommandCancelledEvent } from "../durable-Da57Rcml.js";
|
|
4
|
-
import { l as SessionState } from "../session-state-
|
|
4
|
+
import { l as SessionState } from "../session-state-DqRkcZOy.js";
|
|
5
5
|
import { annotateEdaSpan, committedBatchAttributes } from "./tracing.js";
|
|
6
6
|
import { EDASessionQuery } from "./session-query.js";
|
|
7
7
|
import * as Context from "effect/Context";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Cn as SessionEventObserverShape, Sn as SessionEventObserver } from "../reduced-state-
|
|
1
|
+
import { Cn as SessionEventObserverShape, Sn as SessionEventObserver } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
export { SessionEventObserver, SessionEventObserverShape };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _n as EDASessionEventPage, bn as EDASessionSnapshot, vn as EDASessionQuery, yn as EDASessionQueryShape } from "../reduced-state-
|
|
1
|
+
import { _n as EDASessionEventPage, bn as EDASessionSnapshot, vn as EDASessionQuery, yn as EDASessionQueryShape } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
export { EDASessionEventPage, EDASessionQuery, EDASessionQueryShape, EDASessionSnapshot };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SequenceNumber } from "../types/core.js";
|
|
2
2
|
import { f as PositionedEvent } from "../envelope-BSI_Xh-f.js";
|
|
3
3
|
import { Xn as durableEventEnvelope } from "../durable-Da57Rcml.js";
|
|
4
|
-
import { l as SessionState, p as LiveEventBus } from "../session-state-
|
|
4
|
+
import { l as SessionState, p as LiveEventBus } from "../session-state-DqRkcZOy.js";
|
|
5
5
|
import { ReducedStateSchema } from "../domain/reduced-state-schema.js";
|
|
6
6
|
import { EDASessionStore } from "./session-store.js";
|
|
7
7
|
import { annotateEdaSpan } from "./tracing.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as SessionCommandAdmissionError, Q as EDASubmittable, Vn as SessionCommandAdmissionConflict, at as SessionDecideError, ct as SessionForkedCommand, dt as SessionRunInput, et as SessionCommandCancelled, ft as SessionState, ht as SessionStateSnapshotData, it as SessionCommandResult, lt as SessionNoRunnableCommand, mt as SessionStateShape, nt as SessionCommandFailed, ot as SessionDrainProcessed, pt as SessionStateError, rt as SessionCommandOutcome, st as SessionDrainResult, tt as SessionCommandCompleted, ut as SessionNoRunnableReason } from "../reduced-state-
|
|
1
|
+
import { $ as SessionCommandAdmissionError, Q as EDASubmittable, Vn as SessionCommandAdmissionConflict, at as SessionDecideError, ct as SessionForkedCommand, dt as SessionRunInput, et as SessionCommandCancelled, ft as SessionState, ht as SessionStateSnapshotData, it as SessionCommandResult, lt as SessionNoRunnableCommand, mt as SessionStateShape, nt as SessionCommandFailed, ot as SessionDrainProcessed, pt as SessionStateError, rt as SessionCommandOutcome, st as SessionDrainResult, tt as SessionCommandCompleted, ut as SessionNoRunnableReason } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
export { EDASubmittable, SessionCommandAdmissionConflict, SessionCommandAdmissionError, SessionCommandCancelled, SessionCommandCompleted, SessionCommandFailed, SessionCommandOutcome, SessionCommandResult, SessionDecideError, SessionDrainProcessed, SessionDrainResult, SessionForkedCommand, SessionNoRunnableCommand, SessionNoRunnableReason, SessionRunInput, SessionState, SessionStateError, SessionStateShape, SessionStateSnapshotData };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as SessionForkedCommand, c as SessionRunInput, i as SessionCommandOutcome, l as SessionState, n as SessionCommandCompleted, o as SessionNoRunnableCommand, r as SessionCommandFailed, s as SessionNoRunnableReason, t as SessionCommandCancelled } from "../session-state-
|
|
1
|
+
import { a as SessionForkedCommand, c as SessionRunInput, i as SessionCommandOutcome, l as SessionState, n as SessionCommandCompleted, o as SessionNoRunnableCommand, r as SessionCommandFailed, s as SessionNoRunnableReason, t as SessionCommandCancelled } from "../session-state-DqRkcZOy.js";
|
|
2
2
|
import { n as SessionCommandAdmissionConflict } from "../session-admission-DC98zwtj.js";
|
|
3
3
|
export { SessionCommandAdmissionConflict, SessionCommandCancelled, SessionCommandCompleted, SessionCommandFailed, SessionCommandOutcome, SessionForkedCommand, SessionNoRunnableCommand, SessionNoRunnableReason, SessionRunInput, SessionState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { At as EDASink, Dt as EDAProjectedSink, Et as EDAProjectedDurableSinkDefinition, Ft as EDASinkRawDurableBatch, It as EDASinkRegistry, Lt as EDASinkRegistryShape, Mt as EDASinkContext, Nt as EDASinkDurableBatch, Ot as EDARawDurableSinkDefinition, Pt as EDASinkInterests, Rt as EDASinkRunnerStartInput, Tt as EDAEphemeralSinkDefinition, jt as EDASinkCheckpoint, kt as EDARawSink, wt as EDADurableSinkDefinition } from "../reduced-state-
|
|
1
|
+
import { At as EDASink, Dt as EDAProjectedSink, Et as EDAProjectedDurableSinkDefinition, Ft as EDASinkRawDurableBatch, It as EDASinkRegistry, Lt as EDASinkRegistryShape, Mt as EDASinkContext, Nt as EDASinkDurableBatch, Ot as EDARawDurableSinkDefinition, Pt as EDASinkInterests, Rt as EDASinkRunnerStartInput, Tt as EDAEphemeralSinkDefinition, jt as EDASinkCheckpoint, kt as EDARawSink, wt as EDADurableSinkDefinition } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
export { EDADurableSinkDefinition, EDAEphemeralSinkDefinition, EDAProjectedDurableSinkDefinition, EDAProjectedSink, EDARawDurableSinkDefinition, EDARawSink, EDASink, EDASinkCheckpoint, EDASinkContext, EDASinkDurableBatch, EDASinkInterests, EDASinkRawDurableBatch, EDASinkRegistry, EDASinkRegistryShape, EDASinkRunnerStartInput };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { cn as EDAToolExecutionContext, dn as ToolParamsSchema, fn as ToolRecovery, gn as toolRecoveryPolicy, hn as maxToolCallAttempts, ln as EDAToolRegistry, mn as makeEDAToolkit, pn as ToolRecoveryPolicy, sn as EDAModelToolkit, un as EDAToolRegistryShape } from "../reduced-state-
|
|
1
|
+
import { cn as EDAToolExecutionContext, dn as ToolParamsSchema, fn as ToolRecovery, gn as toolRecoveryPolicy, hn as maxToolCallAttempts, ln as EDAToolRegistry, mn as makeEDAToolkit, pn as ToolRecoveryPolicy, sn as EDAModelToolkit, un as EDAToolRegistryShape } from "../reduced-state-abeH0MOf.js";
|
|
2
2
|
export { EDAModelToolkit, EDAToolExecutionContext, EDAToolRegistry, EDAToolRegistryShape, ToolParamsSchema, ToolRecovery, ToolRecoveryPolicy, makeEDAToolkit, maxToolCallAttempts, toolRecoveryPolicy };
|
|
@@ -6,13 +6,13 @@ import { ModelResolver } from "./services/model-resolver.js";
|
|
|
6
6
|
import { makeEDARunTrace } from "./types/tracing.js";
|
|
7
7
|
import { S as schemaV1, _ as UnixEpochMillis, c as FailurePayload, d as NonNegativeInt, f as PositionedEvent, g as ToolName, h as SystemPromptText, p as ProviderPartId, r as EventDedupeKey, t as DurableEventEnvelope, u as ModelSelectionPayload, y as effectDurableAgentNamespace } from "./envelope-BSI_Xh-f.js";
|
|
8
8
|
import { CancelPendingMessageCommand, PromotePendingMessageCommand, ResumePendingMessagesCommand, StopTurnCommand, SubmitMessageCommand } from "./types/commands.js";
|
|
9
|
-
import { H as DeciderAcceptedEvent, Jt as ToolCallCreatedEvent, Kn as deciderAcceptedEventType, Qn as inferenceFailedEventType, Sr as toolCallRejectedEventType, Tr as turnFailedEventType, Xn as durableEventEnvelope, Zn as inferenceCompletedEventType, _ as CommandAdmittedEvent, _n as TurnStoppedEvent, br as toolCallCreatedEventType, hn as TurnStartedEvent, pn as TurnFailedEvent, un as TurnCompletedEvent } from "./durable-Da57Rcml.js";
|
|
9
|
+
import { H as DeciderAcceptedEvent, Jt as ToolCallCreatedEvent, Kn as deciderAcceptedEventType, Qn as inferenceFailedEventType, Sr as toolCallRejectedEventType, Tr as turnFailedEventType, Xn as durableEventEnvelope, Zn as inferenceCompletedEventType, _ as CommandAdmittedEvent, _n as TurnStoppedEvent, br as toolCallCreatedEventType, er as interpretLegacyAttemptForReduction, hn as TurnStartedEvent, pn as TurnFailedEvent, un as TurnCompletedEvent } from "./durable-Da57Rcml.js";
|
|
10
10
|
import { n as assertNeverError, t as assertNever } from "./assert-never-CoyUpoRB.js";
|
|
11
11
|
import { activeTurnIdentityForCommand, classifyRecoverableWork, decodeReducedStateCheckpoint, encodeReducedStateCheckpoint, foldReducedState, frameworkReducedStateReducerName, initialReducedState, reducedStateCheckpointEventSeqs } from "./domain/reduced-state.js";
|
|
12
12
|
import { ContextProjection, emptyContextProjection } from "./domain/context-projection.js";
|
|
13
13
|
import { a as jsonBytes, n as SessionCommandAdmissionConflict, o as makeAppEventAdmission, r as appEventConflict, t as RegisteredAppEvents } from "./session-admission-DC98zwtj.js";
|
|
14
14
|
import { CommittedDurableEvent, EDASessionStore, EDASessionStoreError, hasEDASessionStoreError, queryCommittedEvents } from "./services/session-store.js";
|
|
15
|
-
import { o as CompactionRunner, p as makeUsagePayload } from "./compaction-
|
|
15
|
+
import { o as CompactionRunner, p as makeUsagePayload } from "./compaction-Bo0IdR4c.js";
|
|
16
16
|
import { EDAPromptProjector, buildEDAPrompt } from "./services/prompt-projector.js";
|
|
17
17
|
import { n as SessionContext, t as EventFactory } from "./event-factory-BUoBwqAy.js";
|
|
18
18
|
import { EDAToolRegistry, toolRecoveryPolicy } from "./services/tool-registry.js";
|
|
@@ -206,6 +206,7 @@ const decideRunContinuation = (input) => {
|
|
|
206
206
|
steerings
|
|
207
207
|
};
|
|
208
208
|
};
|
|
209
|
+
/** Steering messages pending for a run, in effective order. */
|
|
209
210
|
const pendingSteerings = (state, runId) => {
|
|
210
211
|
const current = state.commandQueues.pendingSteers.filter((message) => message.targetRunId === void 0 || message.targetRunId === runId);
|
|
211
212
|
const currentIds = new Set(current.map((message) => message.messageId));
|
|
@@ -220,8 +221,70 @@ const countRejectedTurns = (state, runId) => {
|
|
|
220
221
|
};
|
|
221
222
|
//#endregion
|
|
222
223
|
//#region src/domain/recovery-policy.ts
|
|
223
|
-
/**
|
|
224
|
-
|
|
224
|
+
/**
|
|
225
|
+
* One step of folding `runId`'s last turn from the session's events in log order. Events are read
|
|
226
|
+
* as `ReducedState` reads them: framework events only, retained attempt events as inferences, and
|
|
227
|
+
* the latest inference terminal wins.
|
|
228
|
+
*/
|
|
229
|
+
const stepRunLastTurn = (runId, last, entry) => {
|
|
230
|
+
if (entry.namespace !== "effect-durable-agent") return last;
|
|
231
|
+
const event = interpretLegacyAttemptForReduction(entry);
|
|
232
|
+
if (event.type === "TurnStarted") return event.payload.runId === runId ? {
|
|
233
|
+
runId,
|
|
234
|
+
turnId: event.payload.turnId,
|
|
235
|
+
toolDecisions: 0
|
|
236
|
+
} : last;
|
|
237
|
+
const inLastTurn = (payload) => last !== void 0 && payload.runId === runId && payload.turnId === last.turnId;
|
|
238
|
+
switch (event.type) {
|
|
239
|
+
case "InferenceStarted": return last !== void 0 && inLastTurn(event.payload) ? {
|
|
240
|
+
...last,
|
|
241
|
+
inference: {
|
|
242
|
+
inferenceId: event.payload.inferenceId,
|
|
243
|
+
completed: false
|
|
244
|
+
}
|
|
245
|
+
} : last;
|
|
246
|
+
case "InferenceFailed": return last?.inference !== void 0 && inLastTurn(event.payload) && event.payload.inferenceId === last.inference.inferenceId ? {
|
|
247
|
+
...last,
|
|
248
|
+
inference: {
|
|
249
|
+
inferenceId: last.inference.inferenceId,
|
|
250
|
+
completed: false
|
|
251
|
+
}
|
|
252
|
+
} : last;
|
|
253
|
+
case "InferenceCompleted": {
|
|
254
|
+
if (last?.inference === void 0 || !inLastTurn(event.payload) || event.payload.inferenceId !== last.inference.inferenceId) return last;
|
|
255
|
+
const usage = event.payload.usage;
|
|
256
|
+
return {
|
|
257
|
+
...last,
|
|
258
|
+
inference: {
|
|
259
|
+
inferenceId: last.inference.inferenceId,
|
|
260
|
+
completed: true,
|
|
261
|
+
...usage === void 0 ? {} : { usage }
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
case "ToolCallCreated":
|
|
266
|
+
case "ToolCallRejected": return last !== void 0 && inLastTurn(event.payload) ? {
|
|
267
|
+
...last,
|
|
268
|
+
toolDecisions: last.toolDecisions + 1
|
|
269
|
+
} : last;
|
|
270
|
+
case "TurnCompleted": return last !== void 0 && inLastTurn(event.payload) ? {
|
|
271
|
+
...last,
|
|
272
|
+
terminal: "Completed"
|
|
273
|
+
} : last;
|
|
274
|
+
case "TurnFailed":
|
|
275
|
+
case "TurnStopped": return last !== void 0 && inLastTurn(event.payload) ? {
|
|
276
|
+
...last,
|
|
277
|
+
terminal: "Failed"
|
|
278
|
+
} : last;
|
|
279
|
+
default: return last;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Pure startup-recovery policy over one canonical durable snapshot. `lastTurn`, folded from the
|
|
284
|
+
* log for the plan's continuation run, lets the plan complete a run that already answered instead
|
|
285
|
+
* of replacing it; without it the run is continued.
|
|
286
|
+
*/
|
|
287
|
+
const planSessionRecovery = (state, lastTurn) => {
|
|
225
288
|
const recoverable = classifyRecoverableWork(state);
|
|
226
289
|
const pendingCommandsById = new Set(state.commandQueues.pendingCommands.map((command) => command.commandId));
|
|
227
290
|
const resumeOwnedMessageIds = new Set([...Array.from(state.commands.values()), ...state.commandQueues.pendingCommands].flatMap((command) => ("terminal" in command ? command.terminal === void 0 : true) && command.command?._tag === "ResumePendingMessages" ? command.command.messageIds : []));
|
|
@@ -234,32 +297,50 @@ const planSessionRecovery = (state) => {
|
|
|
234
297
|
return (tag === "SubmitMessage" || tag === "ResumePendingMessages") && recoverable.activeRuns.some((run) => !stoppedRunIds.has(run.runId) && run.commandIds.includes(command.commandId));
|
|
235
298
|
});
|
|
236
299
|
const continuationRun = recoverable.activeRuns.find((run) => continuationCommand !== void 0 && !stoppedRunIds.has(run.runId) && run.commandIds.includes(continuationCommand.commandId));
|
|
300
|
+
const completion = continuationCommand === void 0 || continuationRun === void 0 ? void 0 : planAnsweredRunCompletion(state, recoverable, continuationCommand, continuationRun, lastTurn);
|
|
237
301
|
const sourceMessageIds = continuationCommand === void 0 ? [] : runSchedulingInputMessageIds(state, {
|
|
238
302
|
_tag: "Command",
|
|
239
303
|
commandId: continuationCommand.commandId
|
|
240
304
|
});
|
|
241
305
|
const eligibleSteerIds = continuationRun === void 0 ? [] : state.commandQueues.pendingSteers.filter((message) => message.targetRunId === void 0 || message.targetRunId === continuationRun.runId || continuationRun.commandIds.some((commandId) => state.runs.get(message.targetRunId)?.commandIds.includes(commandId) === true)).map((message) => message.messageId);
|
|
242
|
-
const continuationInputMessageIds = Array.from(/* @__PURE__ */ new Set([...sourceMessageIds, ...eligibleSteerIds]));
|
|
306
|
+
const continuationInputMessageIds = completion === void 0 ? Array.from(/* @__PURE__ */ new Set([...sourceMessageIds, ...eligibleSteerIds])) : [];
|
|
243
307
|
const continuationInputIds = new Set(continuationInputMessageIds);
|
|
244
308
|
const messageIdsToResume = state.commandQueues.pendingSteers.filter((message) => !pausedMessageIds.has(message.messageId) && !continuationInputIds.has(message.messageId) && !(state.runSchedulingRequest?.work._tag === "Recovery" && state.runSchedulingRequest.work.inputMessageIds.includes(message.messageId)) && !pendingCommandsById.has(message.commandId) && !resumeOwnedMessageIds.has(message.messageId)).map((message) => message.messageId);
|
|
245
309
|
return {
|
|
246
|
-
activeCommands: recoverable.activeCommands,
|
|
247
|
-
activeRuns: recoverable.activeRuns,
|
|
248
|
-
activeTurns: recoverable.activeTurns,
|
|
310
|
+
activeCommands: recoverable.activeCommands.filter((command) => command.commandId !== completion?.command.commandId),
|
|
311
|
+
activeRuns: recoverable.activeRuns.filter((run) => run.runId !== completion?.run.runId),
|
|
312
|
+
activeTurns: recoverable.activeTurns.filter((turn) => turn.turnId !== completion?.openTurn?.turnId),
|
|
249
313
|
activeInferences: recoverable.activeInferences,
|
|
250
314
|
openToolCalls: recoverable.openToolCalls,
|
|
251
315
|
pendingStopRequests: recoverable.pendingStopRequests,
|
|
252
316
|
openCompactions: recoverable.openCompactions,
|
|
253
317
|
messageIdsToPause,
|
|
254
318
|
messageIdsToResume,
|
|
255
|
-
...
|
|
319
|
+
...completion === void 0 ? {} : { completion },
|
|
320
|
+
...continuationCommand === void 0 || continuationRun === void 0 || completion !== void 0 ? {} : { continuation: {
|
|
256
321
|
command: continuationCommand,
|
|
257
322
|
run: continuationRun,
|
|
258
323
|
inputMessageIds: continuationInputMessageIds
|
|
259
324
|
} }
|
|
260
325
|
};
|
|
261
326
|
};
|
|
262
|
-
|
|
327
|
+
/**
|
|
328
|
+
* `decideRunContinuation`'s `CompleteRun` over the run's durable last turn: its inference
|
|
329
|
+
* completed, it decided no tool calls (no feedback to answer), and no steering is pending.
|
|
330
|
+
*/
|
|
331
|
+
const planAnsweredRunCompletion = (state, recoverable, command, run, lastTurn) => {
|
|
332
|
+
if (lastTurn?.runId !== run.runId || lastTurn.terminal === "Failed" || lastTurn.inference?.completed !== true || lastTurn.toolDecisions > 0 || pendingSteerings(state, run.runId).length > 0 || recoverable.activeInferences.some((inference) => inference.runId === run.runId) || recoverable.openToolCalls.some((tool) => tool.decision?.runId === run.runId)) return;
|
|
333
|
+
const usage = lastTurn.inference.usage;
|
|
334
|
+
return {
|
|
335
|
+
command,
|
|
336
|
+
run,
|
|
337
|
+
...lastTurn.terminal === void 0 ? { openTurn: {
|
|
338
|
+
turnId: lastTurn.turnId,
|
|
339
|
+
...usage === void 0 ? {} : { usage }
|
|
340
|
+
} } : {}
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
const isSessionRecoveryPlanEmpty = (plan) => plan.activeCommands.length === 0 && plan.activeRuns.length === 0 && plan.activeTurns.length === 0 && plan.activeInferences.length === 0 && plan.openToolCalls.length === 0 && plan.pendingStopRequests.length === 0 && plan.openCompactions.length === 0 && plan.messageIdsToPause.length === 0 && plan.messageIdsToResume.length === 0 && plan.continuation === void 0 && plan.completion === void 0;
|
|
263
344
|
//#endregion
|
|
264
345
|
//#region src/domain/run-terminal-policy.ts
|
|
265
346
|
/** Normal live-run failure policy. This is not startup recovery. */
|
|
@@ -1206,7 +1287,7 @@ const isMetadataRecord = (value) => typeof value === "object" && value !== null
|
|
|
1206
1287
|
const hasProviderMetadata = (metadata) => Object.keys(metadata).length > 0;
|
|
1207
1288
|
const responseContextToParts = (entries) => entries.flatMap((entry) => {
|
|
1208
1289
|
switch (entry._tag) {
|
|
1209
|
-
case "Text": return entry.text.length === 0 ? [] : [Response.makePart("text", {
|
|
1290
|
+
case "Text": return entry.text.length === 0 && !hasProviderMetadata(entry.metadata) ? [] : [Response.makePart("text", {
|
|
1210
1291
|
text: entry.text,
|
|
1211
1292
|
metadata: entry.metadata
|
|
1212
1293
|
})];
|
|
@@ -2699,7 +2780,8 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
2699
2780
|
}).pipe(Effect.catchTag("ToolExecutionEventNotCreated", (error) => Effect.die(error)));
|
|
2700
2781
|
});
|
|
2701
2782
|
const recoverSession = Effect.fnUntraced(function* (reduced, reason, input) {
|
|
2702
|
-
const
|
|
2783
|
+
const candidate = planSessionRecovery(reduced).continuation?.run;
|
|
2784
|
+
const plan = candidate === void 0 ? planSessionRecovery(reduced) : planSessionRecovery(reduced, yield* store.eventsAfter(SequenceNumber.make(candidate.startedSeq - 1)).pipe(Stream.runFold(() => void 0, (last, entry) => stepRunLastTurn(candidate.runId, last, entry.event))));
|
|
2703
2785
|
input = {
|
|
2704
2786
|
...input,
|
|
2705
2787
|
modelSelection: plan.continuation?.run.modelSelection ?? input.modelSelection
|
|
@@ -2714,7 +2796,8 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
2714
2796
|
"eda.recovery.pending_stop_requests": plan.pendingStopRequests.length,
|
|
2715
2797
|
"eda.recovery.open_compactions": plan.openCompactions.length,
|
|
2716
2798
|
"eda.recovery.messages_to_pause": plan.messageIdsToPause.length,
|
|
2717
|
-
"eda.recovery.messages_to_resume": plan.messageIdsToResume.length
|
|
2799
|
+
"eda.recovery.messages_to_resume": plan.messageIdsToResume.length,
|
|
2800
|
+
"eda.recovery.completed_answered_run": plan.completion !== void 0
|
|
2718
2801
|
});
|
|
2719
2802
|
const recoveryEvents = [];
|
|
2720
2803
|
for (const tool of plan.openToolCalls) {
|
|
@@ -2781,6 +2864,16 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
2781
2864
|
compactionId: compaction.compactionId,
|
|
2782
2865
|
error: FailurePayload.make({ message: "runtime restarted before compaction completed" })
|
|
2783
2866
|
}) : yield* events.compactionCompleted({ compactionId: compaction.compactionId }));
|
|
2867
|
+
if (plan.completion !== void 0) {
|
|
2868
|
+
const { command, run, openTurn } = plan.completion;
|
|
2869
|
+
if (openTurn !== void 0) recoveryEvents.push(yield* events.turnCompleted({
|
|
2870
|
+
runId: run.runId,
|
|
2871
|
+
turnId: openTurn.turnId,
|
|
2872
|
+
...openTurn.usage === void 0 ? {} : { usage: openTurn.usage }
|
|
2873
|
+
}));
|
|
2874
|
+
recoveryEvents.push(yield* events.runCompleted({ runId: run.runId }));
|
|
2875
|
+
recoveryEvents.push(yield* events.commandCompleted({ commandId: command.commandId }));
|
|
2876
|
+
}
|
|
2784
2877
|
if (plan.messageIdsToResume.length > 0) recoveryEvents.push(yield* events.commandAdmitted({ command: new ResumePendingMessagesCommand({
|
|
2785
2878
|
commandId: yield* ids.makeCommandId(),
|
|
2786
2879
|
messageIds: plan.messageIdsToResume
|
|
@@ -3512,4 +3605,4 @@ const isSessionNoRunnableCommand = (result) => "_tag" in result && result._tag =
|
|
|
3512
3605
|
//#endregion
|
|
3513
3606
|
export { SessionForkedCommand as a, SessionRunInput as c, InferenceRunner as d, ToolExecutor as f, SessionCommandOutcome as i, SessionState as l, SessionCommandCompleted as n, SessionNoRunnableCommand as o, LiveEventBus as p, SessionCommandFailed as r, SessionNoRunnableReason as s, SessionCommandCancelled as t, TurnRunner as u };
|
|
3514
3607
|
|
|
3515
|
-
//# sourceMappingURL=session-state-
|
|
3608
|
+
//# sourceMappingURL=session-state-DqRkcZOy.js.map
|