@morty-build/cli 0.4.29 → 0.4.31
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/{chunk-MNUDTG5G.js → chunk-M7MJMWZ4.js} +200 -91
- package/dist/{chunk-MNUDTG5G.js.map → chunk-M7MJMWZ4.js.map} +3 -3
- package/dist/{chunk-SIONM2MQ.js → chunk-VVUR5KEG.js} +2 -2
- package/dist/{chunk-SIONM2MQ.js.map → chunk-VVUR5KEG.js.map} +1 -1
- package/dist/{cli-2AK6HJDW.js → cli-WX4DANUN.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/engine/runtime/command/registry/history.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/history.js +1 -24
- package/dist/engine/runtime/command/registry/history.js.map +1 -1
- package/dist/engine/session/api/session-layer.d.ts.map +1 -1
- package/dist/engine/session/api/session-layer.js +1 -0
- package/dist/engine/session/api/session-layer.js.map +1 -1
- package/dist/engine/session/history/session-event-history-projection.d.ts +1 -4
- package/dist/engine/session/history/session-event-history-projection.d.ts.map +1 -1
- package/dist/engine/session/history/session-event-history-projection.js +41 -2
- package/dist/engine/session/history/session-event-history-projection.js.map +1 -1
- package/dist/engine/session/history/session-history.d.ts +7 -2
- package/dist/engine/session/history/session-history.d.ts.map +1 -1
- package/dist/engine/session/history/session-history.js +85 -1
- package/dist/engine/session/history/session-history.js.map +1 -1
- package/dist/engine/session/live/agent-session.d.ts +9 -3
- package/dist/engine/session/live/agent-session.d.ts.map +1 -1
- package/dist/engine/session/live/agent-session.js +10 -7
- package/dist/engine/session/live/agent-session.js.map +1 -1
- package/dist/engine/session/manager/session-manager.d.ts +4 -1
- package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
- package/dist/engine/session/manager/session-manager.js +12 -6
- package/dist/engine/session/manager/session-manager.js.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.d.ts +2 -4
- package/dist/engine/session/prompt/prompt-lifecycle.d.ts.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.js +0 -2
- package/dist/engine/session/prompt/prompt-lifecycle.js.map +1 -1
- package/dist/engine/session/turn/execution-receipts.d.ts +18 -6
- package/dist/engine/session/turn/execution-receipts.d.ts.map +1 -1
- package/dist/engine/session/turn/execution-receipts.js +19 -17
- package/dist/engine/session/turn/execution-receipts.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +1 -1
- /package/dist/{cli-2AK6HJDW.js.map → cli-WX4DANUN.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
__export,
|
|
4
4
|
__using,
|
|
5
5
|
package_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VVUR5KEG.js";
|
|
7
7
|
|
|
8
8
|
// src/engine/runtime/relay/runtime-revocation.ts
|
|
9
9
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -20853,7 +20853,14 @@ var sharedSessionEventFields = {
|
|
|
20853
20853
|
sessionId: identifierStringSchema
|
|
20854
20854
|
};
|
|
20855
20855
|
var sessionLiveEventFields = { ...sharedSessionEventFields, position: positionSchema };
|
|
20856
|
-
var sessionEventSchema = external_exports.
|
|
20856
|
+
var sessionEventSchema = external_exports.discriminatedUnion("type", [
|
|
20857
|
+
external_exports.object({ ...sharedSessionEventFields, payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly(),
|
|
20858
|
+
external_exports.object({
|
|
20859
|
+
...sharedSessionEventFields,
|
|
20860
|
+
payload: lifecycleMetadataSchema,
|
|
20861
|
+
type: external_exports.literal("lifecycle-metadata")
|
|
20862
|
+
}).readonly()
|
|
20863
|
+
]);
|
|
20857
20864
|
var sessionLiveEventSchema = external_exports.discriminatedUnion("type", [
|
|
20858
20865
|
external_exports.object({ ...sessionLiveEventFields, payload: acpSessionUpdateSchema, type: external_exports.literal("acp") }).readonly(),
|
|
20859
20866
|
external_exports.object({
|
|
@@ -20899,15 +20906,9 @@ function isRecord2(value) {
|
|
|
20899
20906
|
var sessionEventBatchSchema = external_exports.array(sessionEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
20900
20907
|
var sessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
20901
20908
|
var sessionEventEnvelopeSchema = external_exports.object({ events: sessionLiveEventBatchSchema, kind: external_exports.literal(SESSION_EVENT_KIND) }).readonly();
|
|
20902
|
-
var promptMessageOutcomeSchema = external_exports.object({
|
|
20903
|
-
payload: external_exports.discriminatedUnion("kind", [promptCompletedSchema, promptFailedSchema]),
|
|
20904
|
-
recordedAt: external_exports.iso.datetime({ offset: true })
|
|
20905
|
-
}).readonly();
|
|
20906
20909
|
var sessionEventLogPageSchema = external_exports.object({
|
|
20907
20910
|
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
20908
20911
|
nextCursor: external_exports.string().min(1).max(512).nullable(),
|
|
20909
|
-
// Retained settled prompts whose user message is on this page; empty outside Session history.
|
|
20910
|
-
promptOutcomes: external_exports.array(promptMessageOutcomeSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
20911
20912
|
sessionGenerationId: identifierStringSchema,
|
|
20912
20913
|
tailCursor: external_exports.string().max(512),
|
|
20913
20914
|
// The generation-scoped live position covered by this snapshot, including
|
|
@@ -20980,8 +20981,7 @@ function sanitizeConsumableSessionEventLogPage(value) {
|
|
|
20980
20981
|
const input2 = inputValue(value);
|
|
20981
20982
|
return isRecord2(input2) ? {
|
|
20982
20983
|
...input2,
|
|
20983
|
-
events: decodedEntries(input2["events"], sessionEventSchema, MAX_EVENT_COUNT)
|
|
20984
|
-
promptOutcomes: decodedEntries(input2["promptOutcomes"], promptMessageOutcomeSchema, MAX_EVENT_COUNT)
|
|
20984
|
+
events: decodedEntries(input2["events"], sessionEventSchema, MAX_EVENT_COUNT)
|
|
20985
20985
|
} : input2;
|
|
20986
20986
|
}
|
|
20987
20987
|
var knownSessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
@@ -72898,19 +72898,19 @@ function presentToolItem(item) {
|
|
|
72898
72898
|
}
|
|
72899
72899
|
return null;
|
|
72900
72900
|
}
|
|
72901
|
-
function toolCallUpdate(item,
|
|
72901
|
+
function toolCallUpdate(item, lifecycle2) {
|
|
72902
72902
|
const presentation = presentToolItem(item);
|
|
72903
72903
|
if (presentation === null) {
|
|
72904
72904
|
return null;
|
|
72905
72905
|
}
|
|
72906
72906
|
return {
|
|
72907
|
-
content: item.type === "imageView" &&
|
|
72907
|
+
content: item.type === "imageView" && lifecycle2 === "started" ? [] : [...presentation.content],
|
|
72908
72908
|
kind: presentation.kind,
|
|
72909
72909
|
locations: [...presentation.locations],
|
|
72910
72910
|
rawInput: presentation.rawInput,
|
|
72911
72911
|
rawOutput: presentation.rawOutput,
|
|
72912
72912
|
...item.type === "collabAgentToolCall" ? { name: item.tool === "spawnAgent" ? "spawn_agent" : "wait_agent" } : item.type === "subAgentActivity" ? { name: "spawn_agent" } : {},
|
|
72913
|
-
status: item.type === "imageView" &&
|
|
72913
|
+
status: item.type === "imageView" && lifecycle2 === "started" ? "in_progress" : lifecycle2 === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
|
|
72914
72914
|
title: presentation.title,
|
|
72915
72915
|
toolCallId: item.id
|
|
72916
72916
|
};
|
|
@@ -80237,8 +80237,8 @@ function normalizeConfigOptions(value, modes) {
|
|
|
80237
80237
|
return normalized.slice(0, MAXIMUM_CONFIG_OPTIONS);
|
|
80238
80238
|
}
|
|
80239
80239
|
function normalizeStandardLifecycle(response) {
|
|
80240
|
-
const
|
|
80241
|
-
return normalizeConfigOptions(
|
|
80240
|
+
const lifecycle2 = isRecord7(response) ? response : {};
|
|
80241
|
+
return normalizeConfigOptions(lifecycle2["configOptions"], lifecycle2["modes"]);
|
|
80242
80242
|
}
|
|
80243
80243
|
function replaceStandardConfigOptions(current, value) {
|
|
80244
80244
|
const next = normalizeConfigOptions(value, void 0);
|
|
@@ -81256,6 +81256,10 @@ function projectNewEvent(liveEvent2, eventId) {
|
|
|
81256
81256
|
}
|
|
81257
81257
|
return { ...event, eventId };
|
|
81258
81258
|
}
|
|
81259
|
+
function projectLifecycleEvent(liveEvent2) {
|
|
81260
|
+
const { position: _position, ...event } = liveEvent2;
|
|
81261
|
+
return event;
|
|
81262
|
+
}
|
|
81259
81263
|
function replaceAcpPayload(event, payload) {
|
|
81260
81264
|
return { ...event, payload };
|
|
81261
81265
|
}
|
|
@@ -81326,11 +81330,13 @@ function mergeTextChunk(previous, incoming) {
|
|
|
81326
81330
|
}
|
|
81327
81331
|
var SessionEventHistoryProjection = class {
|
|
81328
81332
|
#toolCallEventIds = /* @__PURE__ */ new Map();
|
|
81333
|
+
/** The turns this history holds: open until their ending is recorded, where the turn ended. */
|
|
81334
|
+
#turns = /* @__PURE__ */ new Map();
|
|
81329
81335
|
#latestEvent = null;
|
|
81330
81336
|
apply = (liveEvent2, resolve19) => {
|
|
81331
81337
|
if (liveEvent2.type === "lifecycle-metadata") {
|
|
81332
81338
|
this.#latestEvent = null;
|
|
81333
|
-
return
|
|
81339
|
+
return this.#turnLifecycle(liveEvent2);
|
|
81334
81340
|
}
|
|
81335
81341
|
if (liveEvent2.type === "acp" && liveEvent2.payload.sessionUpdate === "tool_call_update") {
|
|
81336
81342
|
const targetEventId = this.#toolCallEventIds.get(liveEvent2.payload.toolCallId);
|
|
@@ -81369,6 +81375,40 @@ var SessionEventHistoryProjection = class {
|
|
|
81369
81375
|
}
|
|
81370
81376
|
return void 0;
|
|
81371
81377
|
};
|
|
81378
|
+
/**
|
|
81379
|
+
* Keeps the lifecycle that delimits each turn, where it happened. A turn's ending is history only once, after its
|
|
81380
|
+
* start: an ending restated for a client, or one for a turn this history does not hold, has no place in it.
|
|
81381
|
+
* Interaction and queue changes are current state, not history.
|
|
81382
|
+
*/
|
|
81383
|
+
#turnLifecycle = (liveEvent2) => {
|
|
81384
|
+
const payload = liveEvent2.payload;
|
|
81385
|
+
switch (payload.kind) {
|
|
81386
|
+
case "prompt.requested":
|
|
81387
|
+
case "prompt.started":
|
|
81388
|
+
case "prompt.delegated":
|
|
81389
|
+
if (this.#turns.get(payload.commandId) === "ended") {
|
|
81390
|
+
return { kind: "skip" };
|
|
81391
|
+
}
|
|
81392
|
+
this.#turns.set(payload.commandId, "open");
|
|
81393
|
+
return { events: [projectLifecycleEvent(liveEvent2)], kind: "append" };
|
|
81394
|
+
case "prompt.completed":
|
|
81395
|
+
case "prompt.failed":
|
|
81396
|
+
case "prompt.failed-before-start":
|
|
81397
|
+
if (this.#turns.get(payload.commandId) !== "open") {
|
|
81398
|
+
return { kind: "skip" };
|
|
81399
|
+
}
|
|
81400
|
+
this.#turns.set(payload.commandId, "ended");
|
|
81401
|
+
return { events: [projectLifecycleEvent(liveEvent2)], kind: "append" };
|
|
81402
|
+
case "session.queue.changed":
|
|
81403
|
+
case "session.permission.requested":
|
|
81404
|
+
case "session.permission.resolved":
|
|
81405
|
+
case "session.elicitation.requested":
|
|
81406
|
+
case "session.elicitation.resolved":
|
|
81407
|
+
return { kind: "skip" };
|
|
81408
|
+
default:
|
|
81409
|
+
return payload;
|
|
81410
|
+
}
|
|
81411
|
+
};
|
|
81372
81412
|
#replace = (current, replacement) => {
|
|
81373
81413
|
if (this.#latestEvent?.eventId === current.eventId) {
|
|
81374
81414
|
this.#latestEvent = replacement;
|
|
@@ -89392,13 +89432,88 @@ var AgentSettingsSnapshot = class {
|
|
|
89392
89432
|
};
|
|
89393
89433
|
|
|
89394
89434
|
// src/engine/session/history/session-history.ts
|
|
89435
|
+
function lifecycle(payload) {
|
|
89436
|
+
return { payload, type: "lifecycle-metadata" };
|
|
89437
|
+
}
|
|
89438
|
+
function turnStart(turn, content, steers) {
|
|
89439
|
+
const { commandId } = turn.outcome;
|
|
89440
|
+
const requested = content.sessionUpdate === "user_message_chunk" ? lifecycle({
|
|
89441
|
+
commandId,
|
|
89442
|
+
content: [content.content],
|
|
89443
|
+
kind: "prompt.requested",
|
|
89444
|
+
...steers === null ? { disposition: "append" } : { disposition: "steer", targetCommandId: steers }
|
|
89445
|
+
}) : null;
|
|
89446
|
+
const started = lifecycle({ attemptId: turn.attemptId, commandId, epoch: turn.attemptId, kind: "prompt.started" });
|
|
89447
|
+
return [
|
|
89448
|
+
...requested === null ? [] : [{ event: requested, recordedAt: turn.startedAt }],
|
|
89449
|
+
{ event: started, recordedAt: turn.startedAt }
|
|
89450
|
+
];
|
|
89451
|
+
}
|
|
89452
|
+
var turnEnd = (turn) => ({
|
|
89453
|
+
event: lifecycle(turn.outcome),
|
|
89454
|
+
recordedAt: turn.recordedAt
|
|
89455
|
+
});
|
|
89456
|
+
var ReplayedTurns = class {
|
|
89457
|
+
#byMessage;
|
|
89458
|
+
#open = null;
|
|
89459
|
+
/** The user message the latest replayed event belongs to; undefined after any other event. */
|
|
89460
|
+
#userMessage;
|
|
89461
|
+
constructor(turns) {
|
|
89462
|
+
this.#byMessage = new Map(turns.map((turn) => [turn.outcome.messageId, turn]));
|
|
89463
|
+
}
|
|
89464
|
+
/** The lifecycle that precedes `update` in history. */
|
|
89465
|
+
before = (update) => {
|
|
89466
|
+
if (update.sessionUpdate !== "user_message_chunk") {
|
|
89467
|
+
this.#userMessage = void 0;
|
|
89468
|
+
return [];
|
|
89469
|
+
}
|
|
89470
|
+
const messageId = update.messageId ?? null;
|
|
89471
|
+
if (this.#userMessage?.messageId === messageId) {
|
|
89472
|
+
return [];
|
|
89473
|
+
}
|
|
89474
|
+
this.#userMessage = { messageId };
|
|
89475
|
+
const turn = messageId === null ? void 0 : this.#byMessage.get(messageId);
|
|
89476
|
+
const steered = turn?.outcome.kind === "prompt.completed" && promptCompletion(turn.outcome).kind === "steered";
|
|
89477
|
+
const open6 = this.#open;
|
|
89478
|
+
if (turn !== void 0 && steered && open6 !== null) {
|
|
89479
|
+
return [...turnStart(turn, update, open6.outcome.commandId), turnEnd(turn)];
|
|
89480
|
+
}
|
|
89481
|
+
const ended = this.end();
|
|
89482
|
+
if (turn === void 0 || steered) {
|
|
89483
|
+
return ended;
|
|
89484
|
+
}
|
|
89485
|
+
this.#open = turn;
|
|
89486
|
+
return [...ended, ...turnStart(turn, update, null)];
|
|
89487
|
+
};
|
|
89488
|
+
/** The ending of the turn still open where the replay ends. */
|
|
89489
|
+
end = () => {
|
|
89490
|
+
const open6 = this.#open;
|
|
89491
|
+
this.#open = null;
|
|
89492
|
+
return open6 === null ? [] : [turnEnd(open6)];
|
|
89493
|
+
};
|
|
89494
|
+
};
|
|
89395
89495
|
var HistoryReplayCapture = class {
|
|
89396
89496
|
#events;
|
|
89397
89497
|
#sessionId;
|
|
89398
|
-
|
|
89498
|
+
#replayed;
|
|
89499
|
+
constructor(events, sessionId, settledTurns = []) {
|
|
89399
89500
|
this.#events = events;
|
|
89400
89501
|
this.#sessionId = sessionId;
|
|
89502
|
+
this.#replayed = new ReplayedTurns(settledTurns);
|
|
89401
89503
|
}
|
|
89504
|
+
/** Records an update the Agent replays from its own history, with the lifecycle of the turn it belongs to. */
|
|
89505
|
+
replay = (rawUpdate) => {
|
|
89506
|
+
for (const { event, recordedAt } of this.#replayed.before(rawUpdate)) {
|
|
89507
|
+
this.#events.append(this.#sessionId, event, recordedAt);
|
|
89508
|
+
}
|
|
89509
|
+
this.#events.append(this.#sessionId, { payload: rawUpdate, type: "acp" });
|
|
89510
|
+
};
|
|
89511
|
+
/** Ends the replay: the last replayed turn ends where the Agent's history does. */
|
|
89512
|
+
finishReplay = () => {
|
|
89513
|
+
for (const { event, recordedAt } of this.#replayed.end()) {
|
|
89514
|
+
this.#events.append(this.#sessionId, event, recordedAt);
|
|
89515
|
+
}
|
|
89516
|
+
};
|
|
89402
89517
|
record = async (rawUpdate, onRecorded = () => Promise.resolve()) => {
|
|
89403
89518
|
const event = this.#events.append(this.#sessionId, { payload: rawUpdate, type: "acp" });
|
|
89404
89519
|
await onRecorded(event);
|
|
@@ -90387,6 +90502,7 @@ var AgentSession = class _AgentSession {
|
|
|
90387
90502
|
#environment;
|
|
90388
90503
|
#getObserver;
|
|
90389
90504
|
#agentCommand;
|
|
90505
|
+
#settledTurns;
|
|
90390
90506
|
#interactions;
|
|
90391
90507
|
#mortySessionId;
|
|
90392
90508
|
#metrics;
|
|
@@ -90406,8 +90522,9 @@ var AgentSession = class _AgentSession {
|
|
|
90406
90522
|
#restored = false;
|
|
90407
90523
|
#sessionTitle = null;
|
|
90408
90524
|
#sessionUpdatedAt = "";
|
|
90409
|
-
constructor(agent2, cwd, additionalDirectories, mortySessionId, getObserver,
|
|
90410
|
-
this.#agentCommand = () => agentCommand(this.#mortySessionId);
|
|
90525
|
+
constructor(agent2, cwd, additionalDirectories, mortySessionId, getObserver, execution, store, metrics, adapter, externalize) {
|
|
90526
|
+
this.#agentCommand = () => execution.agentCommand(this.#mortySessionId);
|
|
90527
|
+
this.#settledTurns = () => execution.settledTurns(this.#mortySessionId);
|
|
90411
90528
|
this.#additionalDirectories = [...additionalDirectories];
|
|
90412
90529
|
this.#adapter = adapter;
|
|
90413
90530
|
this.#agentId = agent2.id;
|
|
@@ -90466,7 +90583,7 @@ var AgentSession = class _AgentSession {
|
|
|
90466
90583
|
}
|
|
90467
90584
|
};
|
|
90468
90585
|
}
|
|
90469
|
-
static async #start(options, getObserver,
|
|
90586
|
+
static async #start(options, getObserver, execution, store, initialize, metrics, adapter) {
|
|
90470
90587
|
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
90471
90588
|
await metrics.measure(
|
|
90472
90589
|
"executable-validation",
|
|
@@ -90480,7 +90597,7 @@ var AgentSession = class _AgentSession {
|
|
|
90480
90597
|
options.additionalDirectories,
|
|
90481
90598
|
options.sessionId,
|
|
90482
90599
|
getObserver,
|
|
90483
|
-
|
|
90600
|
+
execution,
|
|
90484
90601
|
store,
|
|
90485
90602
|
metrics,
|
|
90486
90603
|
adapter,
|
|
@@ -90507,10 +90624,10 @@ var AgentSession = class _AgentSession {
|
|
|
90507
90624
|
}
|
|
90508
90625
|
throw new AcpExecutionError("ACP agent initialization failed");
|
|
90509
90626
|
}
|
|
90510
|
-
static start = async (options, recovery, getObserver,
|
|
90627
|
+
static start = async (options, recovery, getObserver, execution, store, metrics, adapter, capabilities = unsupportedSessionCapabilities()) => await _AgentSession.#start(
|
|
90511
90628
|
options,
|
|
90512
90629
|
getObserver,
|
|
90513
|
-
|
|
90630
|
+
execution,
|
|
90514
90631
|
store,
|
|
90515
90632
|
async (runtime) => {
|
|
90516
90633
|
runtime.#capabilities = capabilities;
|
|
@@ -90673,7 +90790,7 @@ var AgentSession = class _AgentSession {
|
|
|
90673
90790
|
return await waitForSharedOperation(this.#sessionLoad.completion, signal);
|
|
90674
90791
|
}
|
|
90675
90792
|
this.#store.events.reset(this.#mortySessionId);
|
|
90676
|
-
const history = new HistoryReplayCapture(this.#store.events, this.#mortySessionId);
|
|
90793
|
+
const history = new HistoryReplayCapture(this.#store.events, this.#mortySessionId, this.#settledTurns());
|
|
90677
90794
|
const completion = Promise.resolve().then(async () => {
|
|
90678
90795
|
try {
|
|
90679
90796
|
const opened = await this.#writeNativeHistory(
|
|
@@ -90684,6 +90801,7 @@ var AgentSession = class _AgentSession {
|
|
|
90684
90801
|
);
|
|
90685
90802
|
signal.throwIfAborted();
|
|
90686
90803
|
this.#capabilities = opened.capabilities;
|
|
90804
|
+
history.finishReplay();
|
|
90687
90805
|
const loaded = { history, kind: "loaded", opened };
|
|
90688
90806
|
this.#sessionLoad = loaded;
|
|
90689
90807
|
return loaded;
|
|
@@ -90887,30 +91005,30 @@ var AgentSession = class _AgentSession {
|
|
|
90887
91005
|
}
|
|
90888
91006
|
this.#prompted = true;
|
|
90889
91007
|
this.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
|
|
90890
|
-
const
|
|
90891
|
-
if (
|
|
91008
|
+
const lifecycle2 = options.lifecycle;
|
|
91009
|
+
if (lifecycle2 !== void 0) {
|
|
90892
91010
|
await this.recordLifecycleEvent({
|
|
90893
91011
|
payload: {
|
|
90894
91012
|
commandId: options.commandId,
|
|
90895
|
-
content:
|
|
90896
|
-
...
|
|
91013
|
+
content: lifecycle2.content,
|
|
91014
|
+
...lifecycle2.disposition === void 0 ? {} : { disposition: lifecycle2.disposition },
|
|
90897
91015
|
kind: "prompt.requested",
|
|
90898
|
-
...
|
|
90899
|
-
...
|
|
91016
|
+
...lifecycle2.context === void 0 ? {} : { context: lifecycle2.context },
|
|
91017
|
+
...lifecycle2.targetCommandId === void 0 ? {} : { targetCommandId: lifecycle2.targetCommandId }
|
|
90900
91018
|
},
|
|
90901
91019
|
type: "lifecycle-metadata"
|
|
90902
91020
|
});
|
|
90903
91021
|
await this.recordLifecycleEvent({
|
|
90904
91022
|
payload: {
|
|
90905
|
-
attemptId:
|
|
91023
|
+
attemptId: lifecycle2.attemptId,
|
|
90906
91024
|
commandId: options.commandId,
|
|
90907
|
-
epoch:
|
|
91025
|
+
epoch: lifecycle2.epoch,
|
|
90908
91026
|
kind: "prompt.started"
|
|
90909
91027
|
},
|
|
90910
91028
|
type: "lifecycle-metadata"
|
|
90911
91029
|
});
|
|
90912
91030
|
}
|
|
90913
|
-
this.#delegableCommandId =
|
|
91031
|
+
this.#delegableCommandId = lifecycle2 === void 0 ? null : options.commandId;
|
|
90914
91032
|
try {
|
|
90915
91033
|
const result = await this.#writeNativeHistory(async () => {
|
|
90916
91034
|
try {
|
|
@@ -90920,7 +91038,7 @@ var AgentSession = class _AgentSession {
|
|
|
90920
91038
|
}
|
|
90921
91039
|
});
|
|
90922
91040
|
this.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
|
|
90923
|
-
if (
|
|
91041
|
+
if (lifecycle2 !== void 0) {
|
|
90924
91042
|
const messageId = result._meta?.messageId;
|
|
90925
91043
|
await this.recordLifecycleEvent({
|
|
90926
91044
|
payload: {
|
|
@@ -90935,7 +91053,7 @@ var AgentSession = class _AgentSession {
|
|
|
90935
91053
|
return result;
|
|
90936
91054
|
} catch (error62) {
|
|
90937
91055
|
const failure2 = error62 instanceof AcpExecutionError ? error62 : new AcpExecutionError("ACP agent execution failed", { cause: error62 });
|
|
90938
|
-
if (
|
|
91056
|
+
if (lifecycle2 !== void 0) {
|
|
90939
91057
|
const message = failure2 instanceof AcpPromptExecutionError ? { messageId: failure2.messageId } : {};
|
|
90940
91058
|
await this.recordLifecycleEvent({
|
|
90941
91059
|
payload: options.cancellationRequested?.() === true ? {
|
|
@@ -90944,7 +91062,7 @@ var AgentSession = class _AgentSession {
|
|
|
90944
91062
|
...message,
|
|
90945
91063
|
stopReason: "cancelled"
|
|
90946
91064
|
} : {
|
|
90947
|
-
attemptId:
|
|
91065
|
+
attemptId: lifecycle2.attemptId,
|
|
90948
91066
|
code: failure2.code,
|
|
90949
91067
|
commandId: options.commandId,
|
|
90950
91068
|
kind: "prompt.failed",
|
|
@@ -90974,24 +91092,24 @@ var AgentSession = class _AgentSession {
|
|
|
90974
91092
|
}
|
|
90975
91093
|
validatePromptContent(options, this.#capabilities);
|
|
90976
91094
|
options.signal.throwIfAborted();
|
|
90977
|
-
const
|
|
90978
|
-
if (
|
|
91095
|
+
const lifecycle2 = options.lifecycle;
|
|
91096
|
+
if (lifecycle2 !== void 0) {
|
|
90979
91097
|
await this.recordLifecycleEvent({
|
|
90980
91098
|
payload: {
|
|
90981
91099
|
commandId: options.commandId,
|
|
90982
|
-
content:
|
|
90983
|
-
...
|
|
91100
|
+
content: lifecycle2.content,
|
|
91101
|
+
...lifecycle2.disposition === void 0 ? {} : { disposition: lifecycle2.disposition },
|
|
90984
91102
|
kind: "prompt.requested",
|
|
90985
|
-
...
|
|
90986
|
-
...
|
|
91103
|
+
...lifecycle2.context === void 0 ? {} : { context: lifecycle2.context },
|
|
91104
|
+
...lifecycle2.targetCommandId === void 0 ? {} : { targetCommandId: lifecycle2.targetCommandId }
|
|
90987
91105
|
},
|
|
90988
91106
|
type: "lifecycle-metadata"
|
|
90989
91107
|
});
|
|
90990
91108
|
await this.recordLifecycleEvent({
|
|
90991
91109
|
payload: {
|
|
90992
|
-
attemptId:
|
|
91110
|
+
attemptId: lifecycle2.attemptId,
|
|
90993
91111
|
commandId: options.commandId,
|
|
90994
|
-
epoch:
|
|
91112
|
+
epoch: lifecycle2.epoch,
|
|
90995
91113
|
kind: "prompt.started"
|
|
90996
91114
|
},
|
|
90997
91115
|
type: "lifecycle-metadata"
|
|
@@ -90999,7 +91117,7 @@ var AgentSession = class _AgentSession {
|
|
|
90999
91117
|
}
|
|
91000
91118
|
try {
|
|
91001
91119
|
const outcome = await this.#adapter.steer({ ...this.#target(), content: options, signal: options.signal });
|
|
91002
|
-
if (
|
|
91120
|
+
if (lifecycle2 !== void 0) {
|
|
91003
91121
|
await this.recordLifecycleEvent({
|
|
91004
91122
|
payload: {
|
|
91005
91123
|
commandId: options.commandId,
|
|
@@ -91014,10 +91132,10 @@ var AgentSession = class _AgentSession {
|
|
|
91014
91132
|
return outcome.outcome;
|
|
91015
91133
|
} catch (error62) {
|
|
91016
91134
|
const failure2 = error62 instanceof AcpExecutionError ? error62 : new AcpExecutionError("ACP agent execution failed", { cause: error62 });
|
|
91017
|
-
if (
|
|
91135
|
+
if (lifecycle2 !== void 0) {
|
|
91018
91136
|
await this.recordLifecycleEvent({
|
|
91019
91137
|
payload: {
|
|
91020
|
-
attemptId:
|
|
91138
|
+
attemptId: lifecycle2.attemptId,
|
|
91021
91139
|
code: failure2.code,
|
|
91022
91140
|
commandId: options.commandId,
|
|
91023
91141
|
kind: "prompt.failed",
|
|
@@ -91081,7 +91199,7 @@ var AgentSession = class _AgentSession {
|
|
|
91081
91199
|
this.#captureSelectedConfigurationValues();
|
|
91082
91200
|
}
|
|
91083
91201
|
if (this.#sessionLoad.kind === "capturing") {
|
|
91084
|
-
|
|
91202
|
+
this.#sessionLoad.history.replay(event.payload);
|
|
91085
91203
|
} else if (this.#sessionLoad.kind === "loaded" || this.#sessionLoad.kind === "execution-only") {
|
|
91086
91204
|
await this.#sessionLoad.history.record(event.payload, async (liveEvent2) => {
|
|
91087
91205
|
await this.#getObserver().onSessionEvent?.(liveEvent2);
|
|
@@ -91304,6 +91422,11 @@ var SessionManager2 = class {
|
|
|
91304
91422
|
changed: () => this.#processes.notifyChanged()
|
|
91305
91423
|
});
|
|
91306
91424
|
#executions;
|
|
91425
|
+
#settledTurns;
|
|
91426
|
+
#executionRecord = {
|
|
91427
|
+
agentCommand: (sessionId) => this.#executions.agentCommand(sessionId),
|
|
91428
|
+
settledTurns: (sessionId) => this.#settledTurns(sessionId)
|
|
91429
|
+
};
|
|
91307
91430
|
#lastTurn;
|
|
91308
91431
|
#agentSettingsObserver = new NullSessionObserver();
|
|
91309
91432
|
#nativeOperations = /* @__PURE__ */ new Set();
|
|
@@ -91324,6 +91447,7 @@ var SessionManager2 = class {
|
|
|
91324
91447
|
onSessionStatusChanged,
|
|
91325
91448
|
onSessionClosed = () => void 0,
|
|
91326
91449
|
lastTurn = () => void 0,
|
|
91450
|
+
settledTurns = () => [],
|
|
91327
91451
|
timer
|
|
91328
91452
|
}) {
|
|
91329
91453
|
this.#observer = observer;
|
|
@@ -91331,6 +91455,7 @@ var SessionManager2 = class {
|
|
|
91331
91455
|
this.#store = store;
|
|
91332
91456
|
this.#sessionIdentity = sessionIdentity;
|
|
91333
91457
|
this.#lastTurn = lastTurn;
|
|
91458
|
+
this.#settledTurns = settledTurns;
|
|
91334
91459
|
this.#executions = new ActiveExecutions(
|
|
91335
91460
|
(sessionId, status) => onSessionStatusChanged({
|
|
91336
91461
|
kind: "session.status.changed",
|
|
@@ -91433,7 +91558,7 @@ var SessionManager2 = class {
|
|
|
91433
91558
|
effectiveOptions,
|
|
91434
91559
|
recovery,
|
|
91435
91560
|
() => this.#observer,
|
|
91436
|
-
this.#
|
|
91561
|
+
this.#executionRecord,
|
|
91437
91562
|
this.#store,
|
|
91438
91563
|
metrics,
|
|
91439
91564
|
options.adapter,
|
|
@@ -91456,7 +91581,7 @@ var SessionManager2 = class {
|
|
|
91456
91581
|
options,
|
|
91457
91582
|
recovery,
|
|
91458
91583
|
() => this.#observer,
|
|
91459
|
-
this.#
|
|
91584
|
+
this.#executionRecord,
|
|
91460
91585
|
this.#store,
|
|
91461
91586
|
metrics,
|
|
91462
91587
|
options.adapter,
|
|
@@ -91476,7 +91601,7 @@ var SessionManager2 = class {
|
|
|
91476
91601
|
options,
|
|
91477
91602
|
recovery,
|
|
91478
91603
|
() => this.#observer,
|
|
91479
|
-
this.#
|
|
91604
|
+
this.#executionRecord,
|
|
91480
91605
|
this.#store,
|
|
91481
91606
|
unmeasuredOperationMetrics,
|
|
91482
91607
|
options.adapter,
|
|
@@ -91532,7 +91657,7 @@ var SessionManager2 = class {
|
|
|
91532
91657
|
options,
|
|
91533
91658
|
recovery,
|
|
91534
91659
|
() => this.#observer,
|
|
91535
|
-
this.#
|
|
91660
|
+
this.#executionRecord,
|
|
91536
91661
|
this.#store,
|
|
91537
91662
|
unmeasuredOperationMetrics,
|
|
91538
91663
|
options.adapter,
|
|
@@ -91650,7 +91775,7 @@ var SessionManager2 = class {
|
|
|
91650
91775
|
},
|
|
91651
91776
|
{ kind: "interactive-only" },
|
|
91652
91777
|
() => this.#agentSettingsObserver,
|
|
91653
|
-
() => void 0,
|
|
91778
|
+
{ agentCommand: () => void 0, settledTurns: () => [] },
|
|
91654
91779
|
new MemorySessionStore(),
|
|
91655
91780
|
unmeasuredOperationMetrics,
|
|
91656
91781
|
options2.adapter
|
|
@@ -92792,8 +92917,6 @@ var PromptLifecycle = class {
|
|
|
92792
92917
|
payload: this.#executions.hasStarted(commandId, sessionId) ? { kind: "prompt.failed", attemptId, commandId, code, message } : { kind: "prompt.failed-before-start", commandId, code, message }
|
|
92793
92918
|
});
|
|
92794
92919
|
};
|
|
92795
|
-
/** The recorded terminal events of the Session's settled prompts that name the user message they recorded. */
|
|
92796
|
-
promptOutcomes = (sessionId) => this.#executions.promptOutcomes(sessionId);
|
|
92797
92920
|
promptRequestRecovery = (sessionId) => ({
|
|
92798
92921
|
queuedPromptRequests: [...this.#queued.values()].filter(
|
|
92799
92922
|
(request) => request.sessionId === sessionId && !this.#executions.hasStarted(request.commandId, sessionId)
|
|
@@ -93075,21 +93198,23 @@ var ExecutionReceipts = class {
|
|
|
93075
93198
|
const command2 = this.#read(commandId);
|
|
93076
93199
|
return command2?.sessionId === sessionId && command2.fate.kind === "started" ? command2.fate.startedAt : void 0;
|
|
93077
93200
|
};
|
|
93078
|
-
/**
|
|
93079
|
-
|
|
93080
|
-
|
|
93081
|
-
|
|
93082
|
-
|
|
93083
|
-
|
|
93084
|
-
for (const command2 of this.#ledger.session(sessionId)) {
|
|
93085
|
-
const outcome = this.restatedOutcome(command2.commandId);
|
|
93086
|
-
const event = outcome?.event;
|
|
93087
|
-
if (outcome?.recordedAt !== void 0 && event?.type === "lifecycle-metadata" && (event.payload.kind === "prompt.completed" || event.payload.kind === "prompt.failed") && event.payload.messageId !== void 0) {
|
|
93088
|
-
outcomes.push({ payload: event.payload, recordedAt: outcome.recordedAt });
|
|
93089
|
-
}
|
|
93201
|
+
/** The Session's settled turns, in admission order, whose outcomes the ledger keeps with their user message. */
|
|
93202
|
+
settledTurns = (sessionId) => this.#ledger.session(sessionId).flatMap((command2) => {
|
|
93203
|
+
const outcome = this.restatedOutcome(command2.commandId);
|
|
93204
|
+
const event = outcome?.event;
|
|
93205
|
+
if (outcome?.recordedAt === void 0 || event?.type !== "lifecycle-metadata" || event.payload.kind !== "prompt.completed" && event.payload.kind !== "prompt.failed" || event.payload.messageId === void 0) {
|
|
93206
|
+
return [];
|
|
93090
93207
|
}
|
|
93091
|
-
|
|
93092
|
-
|
|
93208
|
+
const fate = this.#withShutdownSettlement(command2).fate;
|
|
93209
|
+
return [
|
|
93210
|
+
{
|
|
93211
|
+
attemptId: command2.attemptId,
|
|
93212
|
+
outcome: { ...event.payload, messageId: event.payload.messageId },
|
|
93213
|
+
recordedAt: outcome.recordedAt,
|
|
93214
|
+
startedAt: fate.kind === "settled-after-start" ? fate.startedAt : outcome.recordedAt
|
|
93215
|
+
}
|
|
93216
|
+
];
|
|
93217
|
+
});
|
|
93093
93218
|
/** A command that started stays started after its outcome is no longer kept. */
|
|
93094
93219
|
hasStarted = (commandId, sessionId) => {
|
|
93095
93220
|
const standing = this.#standing(commandId, sessionId);
|
|
@@ -93912,6 +94037,7 @@ function buildSessionLayer(options) {
|
|
|
93912
94037
|
onSessionStatusChanged: sink.publishStatus,
|
|
93913
94038
|
onSessionClosed: sink.publishClosed,
|
|
93914
94039
|
lastTurn: operations.lastTurn,
|
|
94040
|
+
settledTurns: operations.settledTurns,
|
|
93915
94041
|
timer
|
|
93916
94042
|
});
|
|
93917
94043
|
const eventProjection = new PromptLifecycle(
|
|
@@ -95576,15 +95702,6 @@ async function resolveSessionDirectories(directories, bindingId, directoryId, ad
|
|
|
95576
95702
|
}
|
|
95577
95703
|
|
|
95578
95704
|
// src/engine/runtime/command/registry/history.ts
|
|
95579
|
-
function onPage(outcomes, events) {
|
|
95580
|
-
const messageIds = /* @__PURE__ */ new Set();
|
|
95581
|
-
for (const event of events) {
|
|
95582
|
-
if (event.type === "acp" && event.payload.sessionUpdate === "user_message_chunk" && event.payload.messageId !== void 0 && event.payload.messageId !== null) {
|
|
95583
|
-
messageIds.add(event.payload.messageId);
|
|
95584
|
-
}
|
|
95585
|
-
}
|
|
95586
|
-
return outcomes.filter(({ payload }) => payload.messageId !== void 0 && messageIds.has(payload.messageId));
|
|
95587
|
-
}
|
|
95588
95705
|
async function loadHistoryPage(sessionId, eventLimit, initialCursor, queuedPromptRequests, load) {
|
|
95589
95706
|
let cursor = initialCursor;
|
|
95590
95707
|
let loaded = [];
|
|
@@ -95625,7 +95742,6 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, queuedPromp
|
|
|
95625
95742
|
return {
|
|
95626
95743
|
events: {
|
|
95627
95744
|
events: orderedEvents.map(({ event }) => event),
|
|
95628
|
-
promptOutcomes: [],
|
|
95629
95745
|
nextCursor,
|
|
95630
95746
|
sessionGenerationId,
|
|
95631
95747
|
tailCursor: orderedEvents.at(-1)?.event.eventId ?? "",
|
|
@@ -95659,7 +95775,6 @@ async function executeSessionHistoryPageLoad(socket, command2, config2, resolveA
|
|
|
95659
95775
|
signal
|
|
95660
95776
|
};
|
|
95661
95777
|
const recovery = eventProjection.promptRequestRecovery(command2.sessionId);
|
|
95662
|
-
const settled = eventProjection.promptOutcomes(command2.sessionId);
|
|
95663
95778
|
const events = await loadHistoryPage(
|
|
95664
95779
|
command2.sessionId,
|
|
95665
95780
|
command2.eventLimit,
|
|
@@ -95669,13 +95784,7 @@ async function executeSessionHistoryPageLoad(socket, command2, config2, resolveA
|
|
|
95669
95784
|
);
|
|
95670
95785
|
signal.throwIfAborted();
|
|
95671
95786
|
send(socket, {
|
|
95672
|
-
events
|
|
95673
|
-
...events,
|
|
95674
|
-
events: {
|
|
95675
|
-
...events.events,
|
|
95676
|
-
promptOutcomes: onPage(settled, events.events.events)
|
|
95677
|
-
}
|
|
95678
|
-
},
|
|
95787
|
+
events,
|
|
95679
95788
|
kind: SESSION_HISTORY_PAGE_LOADED_KIND,
|
|
95680
95789
|
requestId: command2.requestId,
|
|
95681
95790
|
sessionId: command2.sessionId
|
|
@@ -96374,7 +96483,7 @@ async function executePrompt({
|
|
|
96374
96483
|
prepared = await sessions.prepareExecutionSession(preparation);
|
|
96375
96484
|
}
|
|
96376
96485
|
signal.throwIfAborted();
|
|
96377
|
-
const
|
|
96486
|
+
const lifecycle2 = eventProjection.lifecycle(command2.sessionId, command2.commandId, attemptId, epoch, dispatch);
|
|
96378
96487
|
const attachments = await resolvePromptArtifacts(readArtifact, command2.attachments, signal);
|
|
96379
96488
|
const skipped = command2.attachments.length - attachments.images.length - attachments.resources.length;
|
|
96380
96489
|
if (skipped > 0) {
|
|
@@ -96393,7 +96502,7 @@ async function executePrompt({
|
|
|
96393
96502
|
commandId: command2.commandId,
|
|
96394
96503
|
cwd: resolved.cwd,
|
|
96395
96504
|
images: attachments.images,
|
|
96396
|
-
lifecycle,
|
|
96505
|
+
lifecycle: lifecycle2,
|
|
96397
96506
|
prompt: command2.prompt,
|
|
96398
96507
|
resources: attachments.resources,
|
|
96399
96508
|
sessionId: command2.sessionId,
|
|
@@ -96411,7 +96520,7 @@ async function executePrompt({
|
|
|
96411
96520
|
commandId: command2.commandId,
|
|
96412
96521
|
cwd: resolved.cwd,
|
|
96413
96522
|
images: attachments.images,
|
|
96414
|
-
lifecycle,
|
|
96523
|
+
lifecycle: lifecycle2,
|
|
96415
96524
|
prompt: command2.prompt,
|
|
96416
96525
|
resources: attachments.resources,
|
|
96417
96526
|
sessionId: command2.sessionId,
|
|
@@ -98296,4 +98405,4 @@ export {
|
|
|
98296
98405
|
* MIT Licensed
|
|
98297
98406
|
*)
|
|
98298
98407
|
*/
|
|
98299
|
-
//# sourceMappingURL=chunk-
|
|
98408
|
+
//# sourceMappingURL=chunk-M7MJMWZ4.js.map
|