effect-durable-agent 0.1.0-alpha.18 → 0.1.0-alpha.19
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/{commands-p8venTWs.d.ts → commands-3OD-p8dD.d.ts} +7 -8
- package/dist/{compaction-Db6eoLce.js → compaction-Bell28K8.js} +2 -4
- package/dist/{compaction-Db6eoLce.js.map → compaction-Bell28K8.js.map} +1 -1
- package/dist/{context-projection-Dr_kA41k.d.ts → context-projection-D_uRtK3r.d.ts} +15 -16
- package/dist/{core-C-6xHzRx.d.ts → core-BcimKMIv.d.ts} +1 -2
- package/dist/domain/command-queues.d.ts +3 -4
- package/dist/domain/command-queues.js.map +1 -1
- package/dist/domain/context-projection.d.ts +1 -1
- package/dist/domain/message-transcript.d.ts +1 -1
- package/dist/domain/message-transcript.js.map +1 -1
- package/dist/domain/model-usage.d.ts +1 -1
- package/dist/domain/reduced-state-schema.d.ts +2 -2
- package/dist/domain/reduced-state.d.ts +2 -2
- package/dist/domain/run-scheduling.d.ts +1 -1
- package/dist/domain/run-scheduling.js.map +1 -1
- package/dist/durable-DRY7AcsF.js.map +1 -1
- package/dist/{durable-DeQBR5wA.d.ts → durable-DoG_e4iL.d.ts} +1486 -1487
- package/dist/envelope-BCzKUq_z.js.map +1 -1
- package/dist/{envelope-VXFEC8zr.d.ts → envelope-Che6KatU.d.ts} +29 -30
- package/dist/event-factory-CKuWhjS4.js.map +1 -1
- package/dist/{events-D3OAPXgS.d.ts → events-sxIzJY26.d.ts} +124 -122
- package/dist/{id-generator--x6itQZ2.d.ts → id-generator-BKGoKjt-.d.ts} +2 -3
- package/dist/index.d.ts +7 -7
- package/dist/{keep-alive-Chl5SJxy.d.ts → keep-alive-_zFCUvt3.d.ts} +1 -2
- package/dist/{model-resolver-ci5D5WQv.d.ts → model-resolver-BHYVHsam.d.ts} +3 -3
- package/dist/{model-usage-CNcnhj72.d.ts → model-usage-0GeHwaaU.d.ts} +2 -3
- package/dist/reduced-state-DFIYylAq.js.map +1 -1
- package/dist/{reduced-state-xY-tYuGo.d.ts → reduced-state-DrSHn_47.d.ts} +8023 -8019
- package/dist/{reduced-state-schema-CgW0mzpS.d.ts → reduced-state-schema-CPEmuHLY.d.ts} +152 -152
- package/dist/{reducer-registry-bRbc4COf.d.ts → reducer-registry-C3ZidOI1.d.ts} +8 -7
- package/dist/{run-scheduling-wakeup-CY5hfgMR.d.ts → run-scheduling-wakeup-COUj3r_B.d.ts} +2 -3
- package/dist/services/compaction.d.ts +1 -1
- package/dist/services/compaction.js +1 -1
- package/dist/services/id-generator.d.ts +1 -1
- package/dist/services/id-generator.js +2 -1
- package/dist/services/id-generator.js.map +1 -1
- package/dist/services/keep-alive.d.ts +1 -1
- package/dist/services/keep-alive.js.map +1 -1
- package/dist/services/model-resolver.d.ts +1 -1
- package/dist/services/model-resolver.js.map +1 -1
- package/dist/services/prompt-projector.d.ts +1 -1
- package/dist/services/prompt-projector.js.map +1 -1
- package/dist/services/reducer-registry.d.ts +1 -1
- package/dist/services/reducer-registry.js.map +1 -1
- package/dist/services/run-scheduler.d.ts +1 -1
- package/dist/services/run-scheduler.js.map +1 -1
- package/dist/services/run-scheduling-wakeup.d.ts +1 -1
- package/dist/services/run-scheduling-wakeup.js.map +1 -1
- package/dist/services/runtime-layer.d.ts +11 -31
- package/dist/services/runtime-layer.js +3 -3
- package/dist/services/runtime-layer.js.map +1 -1
- package/dist/services/runtime.d.ts +1 -1
- package/dist/services/runtime.js +1 -1
- package/dist/services/runtime.js.map +1 -1
- package/dist/services/session-event-observer.d.ts +1 -1
- package/dist/services/session-event-observer.js.map +1 -1
- package/dist/services/session-query.d.ts +1 -1
- package/dist/services/session-query.js +5 -7
- package/dist/services/session-query.js.map +1 -1
- package/dist/services/session-state.d.ts +1 -1
- package/dist/services/session-state.js +1 -1
- package/dist/services/session-store.d.ts +1 -1
- package/dist/services/session-store.js +5 -3
- package/dist/services/session-store.js.map +1 -1
- package/dist/services/sink-checkpoint-store.d.ts +1 -1
- package/dist/services/sink-checkpoint-store.js +2 -1
- package/dist/services/sink-checkpoint-store.js.map +1 -1
- package/dist/services/sink-registry.d.ts +1 -1
- package/dist/services/sink-registry.js +1 -1
- package/dist/services/tool-registry.d.ts +1 -1
- package/dist/services/tool-registry.js.map +1 -1
- package/dist/services/tracing.d.ts +3 -3
- package/dist/services/tracing.js.map +1 -1
- package/dist/{session-event-observer-BWppl2Fr.d.ts → session-event-observer-BDwja1jX.d.ts} +3 -3
- package/dist/{session-state-8PJZvuR3.js → session-state-BBzzJrDC.js} +78 -50
- package/dist/{session-state-8PJZvuR3.js.map → session-state-BBzzJrDC.js.map} +1 -1
- package/dist/{session-store-CERvTeaV.d.ts → session-store-B_vh581h.d.ts} +9 -9
- package/dist/{sink-checkpoint-store-DTiswoqy.d.ts → sink-checkpoint-store-2SxoNMbI.d.ts} +3 -4
- package/dist/{sink-registry-B4yxTmlI.js → sink-registry-ogHu2Sw7.js} +2 -2
- package/dist/{sink-registry-B4yxTmlI.js.map → sink-registry-ogHu2Sw7.js.map} +1 -1
- package/dist/testkit/layers.d.ts +13 -13
- package/dist/testkit/layers.js +3 -3
- package/dist/testkit/layers.js.map +1 -1
- package/dist/{tool-registry-D4ALie3K.d.ts → tool-registry-DDxbmMpY.d.ts} +5 -5
- package/dist/{tracing-BXHAkxkx.d.ts → tracing-BwjbF285.d.ts} +1 -2
- package/dist/types/commands.d.ts +1 -1
- package/dist/types/commands.js.map +1 -1
- package/dist/types/core.d.ts +1 -1
- package/dist/types/core.js.map +1 -1
- package/dist/types/events/durable.d.ts +1 -1
- package/dist/types/events.d.ts +4 -4
- package/dist/types/tracing.d.ts +1 -1
- package/dist/types/tracing.js.map +1 -1
- package/dist/websocket.d.ts +197 -187
- package/dist/websocket.js +4 -3
- package/dist/websocket.js.map +1 -1
- package/package.json +7 -7
|
@@ -10,7 +10,7 @@ import { Jn as inferenceCompletedEventType, Kt as ToolCallCreatedEvent, Sr as tu
|
|
|
10
10
|
import { a as encodeReducedStateCheckpoint, h as assertNeverError, i as decodeReducedStateCheckpoint, l as initialReducedState, m as assertNever, n as activeTurnIdentityForCommand, o as foldReducedState, p as reducedStateCheckpointEventSeqs, r as classifyRecoverableWork, s as frameworkReducedStateReducerName } from "./reduced-state-DFIYylAq.js";
|
|
11
11
|
import { ContextProjection, emptyContextProjection } from "./domain/context-projection.js";
|
|
12
12
|
import { CommittedDurableEvent, EDASessionStore, EDASessionStoreError, hasEDASessionStoreError, queryCommittedEvents } from "./services/session-store.js";
|
|
13
|
-
import { d as makeUsagePayload, o as CompactionRunner } from "./compaction-
|
|
13
|
+
import { d as makeUsagePayload, o as CompactionRunner } from "./compaction-Bell28K8.js";
|
|
14
14
|
import { IdGenerator } from "./services/id-generator.js";
|
|
15
15
|
import { n as SessionContext, t as EventFactory } from "./event-factory-CKuWhjS4.js";
|
|
16
16
|
import { annotateEdaSpan, committedBatchAttributes, edaTraceContextFromSpan, eventBatchAttributes, toEdaExternalSpan, usageAttributes } from "./services/tracing.js";
|
|
@@ -18,7 +18,7 @@ import { EDAKeepAlive } from "./services/keep-alive.js";
|
|
|
18
18
|
import { SessionEventObserver } from "./services/session-event-observer.js";
|
|
19
19
|
import { EDAPromptProjector, buildEDAPrompt } from "./services/prompt-projector.js";
|
|
20
20
|
import { EDAReducerRegistry, decodeReducerState, encodeReducerState, reducerSchemaVersion } from "./services/reducer-registry.js";
|
|
21
|
-
import { n as EDASinkRegistry } from "./sink-registry-
|
|
21
|
+
import { n as EDASinkRegistry } from "./sink-registry-ogHu2Sw7.js";
|
|
22
22
|
import { EDAToolRegistry } from "./services/tool-registry.js";
|
|
23
23
|
import * as Context from "effect/Context";
|
|
24
24
|
import * as Effect from "effect/Effect";
|
|
@@ -233,7 +233,7 @@ const planSessionRecovery = (state) => {
|
|
|
233
233
|
const pendingMessageIds = new Set([...state.commandQueues.pendingQueue, ...state.commandQueues.pendingSteers].map((message) => message.messageId));
|
|
234
234
|
const sourceMessageIds = continuationCommand?.command?._tag === "ResumePendingMessages" ? continuationCommand.command.messageIds.filter((messageId) => pendingMessageIds.has(messageId)) : continuationCommand === void 0 ? [] : [...state.commandQueues.pendingQueue, ...state.commandQueues.pendingSteers].filter((message) => message.commandId === continuationCommand.commandId).map((message) => message.messageId);
|
|
235
235
|
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);
|
|
236
|
-
const continuationInputMessageIds = Array.from(new Set([...sourceMessageIds, ...eligibleSteerIds]));
|
|
236
|
+
const continuationInputMessageIds = Array.from(/* @__PURE__ */ new Set([...sourceMessageIds, ...eligibleSteerIds]));
|
|
237
237
|
const continuationInputIds = new Set(continuationInputMessageIds);
|
|
238
238
|
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);
|
|
239
239
|
return {
|
|
@@ -267,10 +267,13 @@ const activeTurnEphemeralReplayCapacity = 4096;
|
|
|
267
267
|
/** Unbounded in-memory fanout plus bounded active-turn ephemeral replay. */
|
|
268
268
|
var LiveEventBus = class LiveEventBus extends Context.Service()("@effect-durable-agent/LiveEventBus") {
|
|
269
269
|
static Live = Layer.effect(LiveEventBus, Effect.gen(function* () {
|
|
270
|
-
|
|
270
|
+
const pubsub = yield* Effect.acquireRelease(PubSub.unbounded(), PubSub.shutdown);
|
|
271
|
+
const activeTurnReplay = yield* Ref.make({
|
|
271
272
|
events: [],
|
|
272
273
|
overflowed: false
|
|
273
|
-
})
|
|
274
|
+
});
|
|
275
|
+
const observer = yield* SessionEventObserver;
|
|
276
|
+
return makeLiveBus(pubsub, activeTurnReplay, observer);
|
|
274
277
|
}));
|
|
275
278
|
/** Live bus for hosts that do not install an append-driven observer. */
|
|
276
279
|
static Noop = LiveEventBus.Live.pipe(Layer.provide(SessionEventObserver.Noop));
|
|
@@ -665,7 +668,8 @@ const recordToolParamsEnd = (state, input) => {
|
|
|
665
668
|
};
|
|
666
669
|
const recordToolCall = (state, input) => {
|
|
667
670
|
const draft = state.drafts.get(input.providerPartId);
|
|
668
|
-
const
|
|
671
|
+
const toolCallId = draft?.toolCallId ?? input.toolCallId;
|
|
672
|
+
const decision = makeToolCallDecision(state, input, toolCallId);
|
|
669
673
|
const nextDraft = draft === void 0 ? void 0 : markDraft(draft, decision);
|
|
670
674
|
const nextDrafts = nextDraft === void 0 ? state.drafts : new Map(state.drafts).set(input.providerPartId, nextDraft);
|
|
671
675
|
return {
|
|
@@ -1039,7 +1043,8 @@ const makeLiveInferenceRunner = Effect.gen(function* () {
|
|
|
1039
1043
|
type: "error",
|
|
1040
1044
|
error: failurePayloadFromUnknown(/* @__PURE__ */ new Error("Provider stream ended without a finish part"))
|
|
1041
1045
|
});
|
|
1042
|
-
|
|
1046
|
+
const terminal = yield* interpretEmissions(eventSink, stepped.emissions, stepped.next, []);
|
|
1047
|
+
return yield* requireTerminal(terminal);
|
|
1043
1048
|
});
|
|
1044
1049
|
return { runInference: Effect.fn("agent.inference")(function* (input) {
|
|
1045
1050
|
const languageModel = yield* models.resolve(input.modelSelection);
|
|
@@ -1704,10 +1709,11 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
1704
1709
|
const commitInitialSystemPrompt = (systemPrompt) => Effect.gen(function* () {
|
|
1705
1710
|
if (systemPrompt === void 0) return;
|
|
1706
1711
|
if ((yield* Ref.get(state)).reduced.lastSeq > SequenceNumber.make(0)) return;
|
|
1707
|
-
|
|
1712
|
+
const event = yield* events.systemMessageCommitted({
|
|
1708
1713
|
messageId: yield* ids.makeMessageId(),
|
|
1709
1714
|
content: systemPrompt
|
|
1710
|
-
})
|
|
1715
|
+
});
|
|
1716
|
+
yield* appendDurable(event);
|
|
1711
1717
|
});
|
|
1712
1718
|
const publishEphemeralCore = (event) => withAppendGate(Effect.gen(function* () {
|
|
1713
1719
|
const current = yield* Ref.get(state);
|
|
@@ -1818,7 +1824,8 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
1818
1824
|
const committed = yield* withAppendGate(Effect.gen(function* () {
|
|
1819
1825
|
const preparedByIdempotencyKey = /* @__PURE__ */ new Map();
|
|
1820
1826
|
const preparedByCommandId = /* @__PURE__ */ new Map();
|
|
1821
|
-
|
|
1827
|
+
const durableEvents = (yield* Effect.forEach(input, (item) => isEDACommand(item) ? prepareCommandAdmission(item, preparedByIdempotencyKey, preparedByCommandId) : Effect.succeed([item]))).flat();
|
|
1828
|
+
return yield* commitDurableEntriesWithinGate(durableEvents.map((event) => ({ event })));
|
|
1822
1829
|
}));
|
|
1823
1830
|
yield* annotateEdaSpan(committedBatchAttributes(committed));
|
|
1824
1831
|
if (commandCount > 0) yield* wakeAfterCommandAdmission();
|
|
@@ -1882,25 +1889,29 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
1882
1889
|
return next;
|
|
1883
1890
|
});
|
|
1884
1891
|
const cancelCommand = (commandId, reason) => Effect.gen(function* () {
|
|
1885
|
-
const
|
|
1892
|
+
const event = yield* events.commandCancelled({
|
|
1886
1893
|
commandId,
|
|
1887
1894
|
reason
|
|
1888
|
-
})
|
|
1895
|
+
});
|
|
1896
|
+
const committed = yield* appendDurable(event);
|
|
1889
1897
|
return SessionCommandCancelled.make({ committed });
|
|
1890
1898
|
});
|
|
1891
1899
|
const failInterruptedTurnIfOpen = (active, reason) => Effect.gen(function* () {
|
|
1892
1900
|
if ((yield* currentReduced()).turns.get(active.turnId)?.terminal !== void 0) return;
|
|
1893
|
-
|
|
1901
|
+
const event = yield* events.turnFailed({
|
|
1894
1902
|
runId: active.runId,
|
|
1895
1903
|
turnId: active.turnId,
|
|
1896
1904
|
error: interruptionFailure("turn", reason, {
|
|
1897
1905
|
runId: active.runId,
|
|
1898
1906
|
turnId: active.turnId
|
|
1899
1907
|
})
|
|
1900
|
-
})
|
|
1908
|
+
});
|
|
1909
|
+
return yield* appendDurable(event);
|
|
1901
1910
|
});
|
|
1902
1911
|
const completeRunAndCommand = (commandId, runId) => Effect.gen(function* () {
|
|
1903
|
-
const
|
|
1912
|
+
const runCompleted = yield* events.runCompleted({ runId });
|
|
1913
|
+
const commandCompleted = yield* events.commandCompleted({ commandId });
|
|
1914
|
+
const committed = yield* appendDurableBatch([runCompleted, commandCompleted]);
|
|
1904
1915
|
return SessionCommandCompleted.make({ committed: committed.at(-1) });
|
|
1905
1916
|
});
|
|
1906
1917
|
const failRunAndCommandWithError = (commandId, runId, error) => Effect.gen(function* () {
|
|
@@ -1912,7 +1923,8 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
1912
1923
|
commandId,
|
|
1913
1924
|
error
|
|
1914
1925
|
});
|
|
1915
|
-
const
|
|
1926
|
+
const current = yield* currentReduced();
|
|
1927
|
+
const failurePlan = planRunFailure(current);
|
|
1916
1928
|
const resumeEvents = [];
|
|
1917
1929
|
if (failurePlan.messageIdsToResume.length > 0) {
|
|
1918
1930
|
const resumeCommandId = yield* ids.makeCommandId();
|
|
@@ -1930,23 +1942,27 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
1930
1942
|
});
|
|
1931
1943
|
const failRunAndCommand = (commandId, runId, turn) => Effect.gen(function* () {
|
|
1932
1944
|
if (turn.outcome._tag !== "TurnRunFailed") return yield* Effect.die(/* @__PURE__ */ new Error("Cannot fail run from a completed turn"));
|
|
1933
|
-
|
|
1945
|
+
const failed = yield* requireTurnFailed(turn.outcome.committed);
|
|
1946
|
+
return yield* failRunAndCommandWithError(commandId, runId, failed.event.payload.error);
|
|
1934
1947
|
});
|
|
1935
1948
|
const interruptRunAndCommand = (active, reason) => Effect.gen(function* () {
|
|
1936
1949
|
const failurePlan = planRunFailure(yield* currentReduced());
|
|
1950
|
+
const runFailed = yield* events.runFailed({
|
|
1951
|
+
runId: active.runId,
|
|
1952
|
+
error: interruptionFailure("run", reason, { runId: active.runId })
|
|
1953
|
+
});
|
|
1954
|
+
const commandCancelled = yield* events.commandCancelled({
|
|
1955
|
+
commandId: active.commandId,
|
|
1956
|
+
reason
|
|
1957
|
+
});
|
|
1958
|
+
const resume = failurePlan.messageIdsToResume.length === 0 ? [] : [yield* events.commandAdmitted({ command: new ResumePendingMessagesCommand({
|
|
1959
|
+
commandId: yield* ids.makeCommandId(),
|
|
1960
|
+
messageIds: failurePlan.messageIdsToResume
|
|
1961
|
+
}) })];
|
|
1937
1962
|
const committed = yield* appendDurableBatch([
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
}),
|
|
1942
|
-
yield* events.commandCancelled({
|
|
1943
|
-
commandId: active.commandId,
|
|
1944
|
-
reason
|
|
1945
|
-
}),
|
|
1946
|
-
...failurePlan.messageIdsToResume.length === 0 ? [] : [yield* events.commandAdmitted({ command: new ResumePendingMessagesCommand({
|
|
1947
|
-
commandId: yield* ids.makeCommandId(),
|
|
1948
|
-
messageIds: failurePlan.messageIdsToResume
|
|
1949
|
-
}) })]
|
|
1963
|
+
runFailed,
|
|
1964
|
+
commandCancelled,
|
|
1965
|
+
...resume
|
|
1950
1966
|
]);
|
|
1951
1967
|
return SessionCommandCancelled.make({ committed: committed.at(-1) });
|
|
1952
1968
|
});
|
|
@@ -2154,13 +2170,14 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
2154
2170
|
modelSelection: input.modelSelection,
|
|
2155
2171
|
trace: activeRunTrace.runTrace
|
|
2156
2172
|
});
|
|
2173
|
+
const startedEvents = yield* appendDurableBatch([
|
|
2174
|
+
commandStarted,
|
|
2175
|
+
...userMessage === void 0 ? [] : [userMessage],
|
|
2176
|
+
runStarted
|
|
2177
|
+
]);
|
|
2157
2178
|
return yield* startTurn({
|
|
2158
2179
|
commandId,
|
|
2159
|
-
commandStarted:
|
|
2160
|
-
commandStarted,
|
|
2161
|
-
...userMessage === void 0 ? [] : [userMessage],
|
|
2162
|
-
runStarted
|
|
2163
|
-
]))[0],
|
|
2180
|
+
commandStarted: startedEvents[0],
|
|
2164
2181
|
inputMessageIds: [messageId],
|
|
2165
2182
|
runId,
|
|
2166
2183
|
modelSelection: input.modelSelection,
|
|
@@ -2194,12 +2211,13 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
2194
2211
|
runId
|
|
2195
2212
|
});
|
|
2196
2213
|
return yield* closeRunTraceOnFailure(activeRunTrace, Effect.gen(function* () {
|
|
2197
|
-
const
|
|
2214
|
+
const runStarted = yield* events.runStarted({
|
|
2198
2215
|
runId,
|
|
2199
2216
|
commandIds: [command.commandId, ...pending.map((message) => message.commandId)],
|
|
2200
2217
|
modelSelection: input.modelSelection,
|
|
2201
2218
|
trace: activeRunTrace.runTrace
|
|
2202
|
-
})
|
|
2219
|
+
});
|
|
2220
|
+
const started = yield* appendDurableBatch([commandStarted, runStarted]);
|
|
2203
2221
|
return yield* startTurn({
|
|
2204
2222
|
commandId: command.commandId,
|
|
2205
2223
|
commandStarted: started[0],
|
|
@@ -2577,7 +2595,8 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
2577
2595
|
return (yield* startedBoundaryGuard({
|
|
2578
2596
|
start: events.commandStarted({ commandId }),
|
|
2579
2597
|
body: (started) => Effect.gen(function* () {
|
|
2580
|
-
const
|
|
2598
|
+
const completed = yield* events.commandCompleted({ commandId });
|
|
2599
|
+
const committed = yield* appendDurableBatch([completed]);
|
|
2581
2600
|
return {
|
|
2582
2601
|
started,
|
|
2583
2602
|
outcome: SessionCommandCompleted.make({ committed: committed.at(-1) })
|
|
@@ -2594,13 +2613,14 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
2594
2613
|
})).value;
|
|
2595
2614
|
});
|
|
2596
2615
|
const failControlCommand = (commandId, code, message) => Effect.gen(function* () {
|
|
2597
|
-
const
|
|
2616
|
+
const failed = yield* events.commandFailed({
|
|
2598
2617
|
commandId,
|
|
2599
2618
|
error: FailurePayload.make({
|
|
2600
2619
|
code,
|
|
2601
2620
|
message
|
|
2602
2621
|
})
|
|
2603
|
-
})
|
|
2622
|
+
});
|
|
2623
|
+
const committed = yield* appendDurable(failed);
|
|
2604
2624
|
return SessionCommandFailed.make({ committed });
|
|
2605
2625
|
});
|
|
2606
2626
|
const cancelPendingMessage = Effect.fn(function* (command) {
|
|
@@ -2720,25 +2740,30 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
2720
2740
|
return (yield* startedBoundaryGuard({
|
|
2721
2741
|
start: events.commandStarted({ commandId: stopCommandId }),
|
|
2722
2742
|
body: (started) => Effect.uninterruptible(Effect.gen(function* () {
|
|
2723
|
-
const
|
|
2724
|
-
|
|
2743
|
+
const beforeStop = yield* currentReduced();
|
|
2744
|
+
const requested = activeTurnIdentityForCommand(beforeStop, active.commandId);
|
|
2745
|
+
const requestedEvent = yield* events.stopTurnRequested({
|
|
2725
2746
|
commandId: stopCommandId,
|
|
2726
2747
|
...requested === void 0 ? {} : {
|
|
2727
2748
|
runId: requested.runId,
|
|
2728
2749
|
turnId: requested.turnId
|
|
2729
2750
|
}
|
|
2730
|
-
})
|
|
2751
|
+
});
|
|
2752
|
+
yield* appendDurable(requestedEvent);
|
|
2731
2753
|
yield* Scope.close(active.turnScope, Exit.interrupt());
|
|
2732
2754
|
yield* Ref.set(executionState, { _tag: "Idle" });
|
|
2733
2755
|
yield* appendUserInterruption(active, stopCommandId, "interrupted");
|
|
2734
2756
|
yield* Scope.close(active.runScope, Exit.interrupt());
|
|
2735
|
-
const
|
|
2736
|
-
const
|
|
2757
|
+
const afterStop = yield* currentReduced();
|
|
2758
|
+
const applied = activeTurnIdentityForCommand(afterStop, active.commandId);
|
|
2759
|
+
const appliedEvent = yield* events.stopTurnApplied({
|
|
2737
2760
|
commandId: stopCommandId,
|
|
2738
2761
|
runId: active.runId,
|
|
2739
2762
|
turnId: active.turnId,
|
|
2740
2763
|
...applied?.turnId === active.turnId && applied.inferenceId !== void 0 ? { inferenceId: applied.inferenceId } : {}
|
|
2741
|
-
})
|
|
2764
|
+
});
|
|
2765
|
+
const completedEvent = yield* events.commandCompleted({ commandId: stopCommandId });
|
|
2766
|
+
const committed = yield* appendDurableBatch([appliedEvent, completedEvent]);
|
|
2742
2767
|
return {
|
|
2743
2768
|
started,
|
|
2744
2769
|
outcome: SessionCommandCompleted.make({ committed: committed.at(-1) })
|
|
@@ -2765,19 +2790,22 @@ const makeLiveSessionState = Effect.gen(function* () {
|
|
|
2765
2790
|
return (yield* startedBoundaryGuard({
|
|
2766
2791
|
start: events.commandStarted({ commandId: stopCommandId }),
|
|
2767
2792
|
body: (started) => Effect.uninterruptible(Effect.gen(function* () {
|
|
2768
|
-
|
|
2793
|
+
const requestedEvent = yield* events.stopTurnRequested({
|
|
2769
2794
|
commandId: stopCommandId,
|
|
2770
2795
|
runId: active.runId,
|
|
2771
2796
|
turnId: active.turnId
|
|
2772
|
-
})
|
|
2797
|
+
});
|
|
2798
|
+
yield* appendDurable(requestedEvent);
|
|
2773
2799
|
yield* Ref.set(executionState, { _tag: "Idle" });
|
|
2774
2800
|
yield* appendUserInterruption(active, stopCommandId, "interrupted");
|
|
2775
2801
|
yield* Scope.close(active.runScope, Exit.interrupt());
|
|
2776
|
-
const
|
|
2802
|
+
const appliedEvent = yield* events.stopTurnApplied({
|
|
2777
2803
|
commandId: stopCommandId,
|
|
2778
2804
|
runId: active.runId,
|
|
2779
2805
|
turnId: active.turnId
|
|
2780
|
-
})
|
|
2806
|
+
});
|
|
2807
|
+
const completedEvent = yield* events.commandCompleted({ commandId: stopCommandId });
|
|
2808
|
+
const committed = yield* appendDurableBatch([appliedEvent, completedEvent]);
|
|
2781
2809
|
return {
|
|
2782
2810
|
started,
|
|
2783
2811
|
outcome: SessionCommandCompleted.make({ committed: committed.at(-1) })
|
|
@@ -3167,4 +3195,4 @@ const isSessionNoRunnableCommand = (result) => "_tag" in result && result._tag =
|
|
|
3167
3195
|
//#endregion
|
|
3168
3196
|
export { SessionCommandOutcome as a, SessionNoRunnableReason as c, TurnRunner as d, InferenceRunner as f, SessionCommandFailed as i, SessionRunInput as l, LiveEventBus as m, SessionCommandCancelled as n, SessionForkedCommand as o, ToolExecutor as p, SessionCommandCompleted as r, SessionNoRunnableCommand as s, SessionCommandAdmissionConflict as t, SessionState as u };
|
|
3169
3197
|
|
|
3170
|
-
//# sourceMappingURL=session-state-
|
|
3198
|
+
//# sourceMappingURL=session-state-BBzzJrDC.js.map
|