@moxt-ai/mobius 0.0.445 → 0.0.449
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-ERFISXVP.js → chunk-INP7WEGL.js} +2 -2
- package/dist/{chunk-ERFISXVP.js.map → chunk-INP7WEGL.js.map} +1 -1
- package/dist/{chunk-TMQPBQLB.js → chunk-LGPB3HHD.js} +439 -27
- package/dist/{chunk-TMQPBQLB.js.map → chunk-LGPB3HHD.js.map} +4 -4
- package/dist/{cli-Z2J7V3PA.js → cli-6H5E6DK2.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/engine/acp/adapter/execution-connections.d.ts.map +1 -1
- package/dist/engine/acp/adapter/execution-connections.js +2 -0
- package/dist/engine/acp/adapter/execution-connections.js.map +1 -1
- package/dist/engine/acp/adapter/session-events.d.ts +7 -1
- package/dist/engine/acp/adapter/session-events.d.ts.map +1 -1
- package/dist/engine/acp/adapter/session-events.js +65 -0
- package/dist/engine/acp/adapter/session-events.js.map +1 -1
- package/dist/engine/acp/agent/in-process-endpoint.d.ts +28 -0
- package/dist/engine/acp/agent/in-process-endpoint.d.ts.map +1 -1
- package/dist/engine/acp/agent/in-process-endpoint.js +7 -0
- package/dist/engine/acp/agent/in-process-endpoint.js.map +1 -1
- package/dist/engine/runtime/command/registry/interactions.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/interactions.js +7 -0
- package/dist/engine/runtime/command/registry/interactions.js.map +1 -1
- package/dist/engine/session/api/session-api.d.ts +2 -0
- package/dist/engine/session/api/session-api.d.ts.map +1 -1
- package/dist/engine/session/api/session-api.js.map +1 -1
- package/dist/engine/session/live/agent-session.d.ts +7 -0
- package/dist/engine/session/live/agent-session.d.ts.map +1 -1
- package/dist/engine/session/live/agent-session.js +143 -2
- package/dist/engine/session/live/agent-session.js.map +1 -1
- package/dist/engine/session/manager/session-manager.d.ts +2 -0
- package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
- package/dist/engine/session/manager/session-manager.js +59 -8
- package/dist/engine/session/manager/session-manager.js.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.d.ts.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.js +5 -1
- package/dist/engine/session/prompt/prompt-lifecycle.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +2 -2
- /package/dist/{cli-Z2J7V3PA.js.map → cli-6H5E6DK2.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-INP7WEGL.js";
|
|
7
7
|
|
|
8
8
|
// src/engine/runtime/relay/runtime-revocation.ts
|
|
9
9
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -20759,6 +20759,26 @@ var promptExecutionContextSchema = external_exports.object({
|
|
|
20759
20759
|
directoryId: DIRECTORY_IDENTIFIER,
|
|
20760
20760
|
additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly()
|
|
20761
20761
|
}).readonly();
|
|
20762
|
+
var promptInitiatorSchema = external_exports.object({
|
|
20763
|
+
kind: external_exports.literal("agent"),
|
|
20764
|
+
reason: external_exports.enum(["background-task", "other"]).catch("other"),
|
|
20765
|
+
// The command a client submitted whose background work led the Agent to start this one, followed through
|
|
20766
|
+
// earlier commands the Agent started itself. Absent when the Runtime cannot tell.
|
|
20767
|
+
continues: identifierStringSchema.optional().catch(void 0)
|
|
20768
|
+
}).readonly();
|
|
20769
|
+
var SESSION_BACKGROUND_TASK_MAX_COUNT = 100;
|
|
20770
|
+
var sessionBackgroundTaskSchema = external_exports.object({
|
|
20771
|
+
// Agent-owned identity.
|
|
20772
|
+
taskId: external_exports.string().min(1).max(2048),
|
|
20773
|
+
kind: external_exports.enum(["subagent", "shell", "other"]).catch("other"),
|
|
20774
|
+
state: external_exports.enum(["running", "awaiting-results"]).catch("running"),
|
|
20775
|
+
// The command a client submitted that this work belongs to, followed through commands the Agent started
|
|
20776
|
+
// itself. Absent when the Runtime cannot tell.
|
|
20777
|
+
commandId: identifierStringSchema.optional().catch(void 0),
|
|
20778
|
+
// The tool call that started the work, when the Agent reported one.
|
|
20779
|
+
toolCallId: external_exports.string().min(1).max(2048).optional().catch(void 0),
|
|
20780
|
+
description: external_exports.string().max(500).optional().catch(void 0)
|
|
20781
|
+
}).readonly();
|
|
20762
20782
|
var promptCompletedSchema = external_exports.object({
|
|
20763
20783
|
...lifecycleBase,
|
|
20764
20784
|
kind: external_exports.literal("prompt.completed"),
|
|
@@ -20778,6 +20798,13 @@ var lifecycleMetadataSchema = external_exports.discriminatedUnion("kind", [
|
|
|
20778
20798
|
// `changedByCommandId` names the command whose admission to or departure from the queue changed it. Runtimes
|
|
20779
20799
|
// before it existed omit it, so a reader must treat an unnamed change as possibly any command's.
|
|
20780
20800
|
external_exports.object({ changedByCommandId: identifierStringSchema.optional(), kind: external_exports.literal("session.queue.changed") }).readonly(),
|
|
20801
|
+
// The Session's complete outstanding background work, replacing the last one recorded. An empty list means none
|
|
20802
|
+
// remains, including after the Agent process that ran it ended. A new Session generation starts with none.
|
|
20803
|
+
// Runtimes before it existed never record it.
|
|
20804
|
+
external_exports.object({
|
|
20805
|
+
kind: external_exports.literal("session.background.changed"),
|
|
20806
|
+
tasks: external_exports.array(sessionBackgroundTaskSchema).max(SESSION_BACKGROUND_TASK_MAX_COUNT).readonly()
|
|
20807
|
+
}).readonly(),
|
|
20781
20808
|
external_exports.object({ event: sessionPermissionRequestedEventSchema, kind: external_exports.literal("session.permission.requested") }).readonly(),
|
|
20782
20809
|
external_exports.object({ event: sessionPermissionResolvedEventSchema, kind: external_exports.literal("session.permission.resolved") }).readonly(),
|
|
20783
20810
|
external_exports.object({ event: sessionElicitationRequestedEventSchema, kind: external_exports.literal("session.elicitation.requested") }).readonly(),
|
|
@@ -20790,7 +20817,14 @@ var lifecycleMetadataSchema = external_exports.discriminatedUnion("kind", [
|
|
|
20790
20817
|
context: promptExecutionContextSchema.optional(),
|
|
20791
20818
|
targetCommandId: identifierStringSchema.optional()
|
|
20792
20819
|
}).readonly(),
|
|
20793
|
-
external_exports.object({
|
|
20820
|
+
external_exports.object({
|
|
20821
|
+
...lifecycleBase,
|
|
20822
|
+
attemptId: identifierStringSchema,
|
|
20823
|
+
epoch: identifierStringSchema,
|
|
20824
|
+
// An initiator a reader cannot decode leaves the command one a client submitted, as before it existed.
|
|
20825
|
+
initiator: promptInitiatorSchema.optional().catch(void 0),
|
|
20826
|
+
kind: external_exports.literal("prompt.started")
|
|
20827
|
+
}).readonly(),
|
|
20794
20828
|
// The Runtime did not run this prompt itself: it handed it to the native session's owner, another client of the
|
|
20795
20829
|
// Agent such as the Codex app, which runs queued input on its own terms. `queued`: the owner holds the prompt and
|
|
20796
20830
|
// may keep holding it; Codex pauses its queue after an interrupted turn until its user continues. `started`: the
|
|
@@ -20816,6 +20850,7 @@ var isPromptTerminal = (payload) => {
|
|
|
20816
20850
|
case "prompt.started":
|
|
20817
20851
|
case "prompt.delegated":
|
|
20818
20852
|
case "session.queue.changed":
|
|
20853
|
+
case "session.background.changed":
|
|
20819
20854
|
case "session.permission.requested":
|
|
20820
20855
|
case "session.permission.resolved":
|
|
20821
20856
|
case "session.elicitation.requested":
|
|
@@ -26776,6 +26811,8 @@ function acpEndpointTerminationError(termination) {
|
|
|
26776
26811
|
}
|
|
26777
26812
|
}
|
|
26778
26813
|
}
|
|
26814
|
+
var BACKGROUND_TASKS_META = "mobius.backgroundTasks";
|
|
26815
|
+
var AGENT_TURN_META = "mobius.agentTurn";
|
|
26779
26816
|
|
|
26780
26817
|
// src/engine/acp/connection/agent-operation.ts
|
|
26781
26818
|
var promptFailureIdentitySchema = external_exports.object({ messageId: external_exports.string().min(1).max(2048) });
|
|
@@ -63857,9 +63894,44 @@ async function readFullHistory(transcript, sessionId, signal) {
|
|
|
63857
63894
|
}
|
|
63858
63895
|
|
|
63859
63896
|
// src/engine/acp/harness/claude/upstream/dist/environment-session-revision.js
|
|
63897
|
+
var LOCAL_COMMAND_TAGS = [
|
|
63898
|
+
"local-command-caveat",
|
|
63899
|
+
"command-name",
|
|
63900
|
+
"command-message",
|
|
63901
|
+
"command-args",
|
|
63902
|
+
"local-command-stdout",
|
|
63903
|
+
"local-command-stderr"
|
|
63904
|
+
];
|
|
63905
|
+
function isLocalCommandRecord(message) {
|
|
63906
|
+
const payload = message.message;
|
|
63907
|
+
if (message.type !== "user" || typeof payload !== "object" || payload === null || !("content" in payload) || typeof payload.content !== "string") {
|
|
63908
|
+
return false;
|
|
63909
|
+
}
|
|
63910
|
+
const text2 = payload.content;
|
|
63911
|
+
let position = 0;
|
|
63912
|
+
let tags = 0;
|
|
63913
|
+
for (; ; ) {
|
|
63914
|
+
while (position < text2.length && /\s/u.test(text2.charAt(position))) {
|
|
63915
|
+
position += 1;
|
|
63916
|
+
}
|
|
63917
|
+
if (position === text2.length) {
|
|
63918
|
+
return tags > 0;
|
|
63919
|
+
}
|
|
63920
|
+
const tag = LOCAL_COMMAND_TAGS.find((name2) => text2.startsWith(`<${name2}>`, position));
|
|
63921
|
+
if (tag === void 0) {
|
|
63922
|
+
return false;
|
|
63923
|
+
}
|
|
63924
|
+
const end = text2.indexOf(`</${tag}>`, position + tag.length + 2);
|
|
63925
|
+
if (end === -1) {
|
|
63926
|
+
return false;
|
|
63927
|
+
}
|
|
63928
|
+
position = end + tag.length + 3;
|
|
63929
|
+
tags += 1;
|
|
63930
|
+
}
|
|
63931
|
+
}
|
|
63860
63932
|
async function getEnvironmentSessionRevision(environment, sessionId, ownMessageIds, signal) {
|
|
63861
63933
|
const messages = await getEnvironmentSessionMessages(environment, sessionId, signal);
|
|
63862
|
-
return messages.findLast((message) => !ownMessageIds.has(message.uuid) && !isTaskNotificationOrigin(message.nativeOrigin))?.uuid ?? "";
|
|
63934
|
+
return messages.findLast((message) => !ownMessageIds.has(message.uuid) && !isTaskNotificationOrigin(message.nativeOrigin) && !isLocalCommandRecord(message))?.uuid ?? "";
|
|
63863
63935
|
}
|
|
63864
63936
|
|
|
63865
63937
|
// src/engine/acp/harness/claude/upstream/dist/session-config-ids.js
|
|
@@ -67604,6 +67676,8 @@ var ClaudeAcpAgent = class {
|
|
|
67604
67676
|
const backgroundTasks = /* @__PURE__ */ new Set();
|
|
67605
67677
|
const awaitingBackgroundResults = /* @__PURE__ */ new Set();
|
|
67606
67678
|
let processingBackgroundResults = /* @__PURE__ */ new Set();
|
|
67679
|
+
const backgroundTaskDetails = /* @__PURE__ */ new Map();
|
|
67680
|
+
let publishedBackgroundTasks = "[]";
|
|
67607
67681
|
let hasBackgroundLevel = false;
|
|
67608
67682
|
const reportBackgroundActivity = () => this.reportBackgroundActivity(session, backgroundTasks.size > 0 ? "running" : awaitingBackgroundResults.size > 0 ? "awaiting-results" : "none");
|
|
67609
67683
|
let lastAssistantTotalUsage = null;
|
|
@@ -67772,6 +67846,70 @@ var ClaudeAcpAgent = class {
|
|
|
67772
67846
|
};
|
|
67773
67847
|
const findUnsettledTurn = (uuid3) => (session.turnQueue ?? []).find((t) => t.promptUuid === uuid3 && !t.settled);
|
|
67774
67848
|
const firstUnsettledQueuedTurn = () => (session.turnQueue ?? []).find((t) => !t.settled);
|
|
67849
|
+
const publishBackgroundTasks = async () => {
|
|
67850
|
+
const report = (taskId, state) => {
|
|
67851
|
+
const details = backgroundTaskDetails.get(taskId);
|
|
67852
|
+
if (details?.ambient === true) {
|
|
67853
|
+
return [];
|
|
67854
|
+
}
|
|
67855
|
+
return [
|
|
67856
|
+
{
|
|
67857
|
+
taskId,
|
|
67858
|
+
kind: details?.kind ?? "other",
|
|
67859
|
+
state,
|
|
67860
|
+
...details?.toolUseId === void 0 ? {} : { toolUseId: details.toolUseId },
|
|
67861
|
+
...details?.description === void 0 ? {} : { description: details.description }
|
|
67862
|
+
}
|
|
67863
|
+
];
|
|
67864
|
+
};
|
|
67865
|
+
const tasks = [
|
|
67866
|
+
...[...backgroundTasks].flatMap((taskId) => report(taskId, "running")),
|
|
67867
|
+
...[...awaitingBackgroundResults].filter((taskId) => !backgroundTasks.has(taskId)).flatMap((taskId) => report(taskId, "awaiting-results"))
|
|
67868
|
+
];
|
|
67869
|
+
const encoded = JSON.stringify(tasks);
|
|
67870
|
+
if (encoded === publishedBackgroundTasks) {
|
|
67871
|
+
return;
|
|
67872
|
+
}
|
|
67873
|
+
publishedBackgroundTasks = encoded;
|
|
67874
|
+
await this.client.sessionUpdate({
|
|
67875
|
+
sessionId: params.sessionId,
|
|
67876
|
+
update: { sessionUpdate: "session_info_update", _meta: { [BACKGROUND_TASKS_META2]: tasks } }
|
|
67877
|
+
});
|
|
67878
|
+
};
|
|
67879
|
+
const noPromptInFlight = () => !(session.activeTurn && !session.activeTurn.settled) && firstUnsettledQueuedTurn() === void 0 && (session.pendingOrphanResults ?? 0) === 0 && (session.orphanCommands?.size ?? 0) === 0;
|
|
67880
|
+
const startAgentTurn = async () => {
|
|
67881
|
+
if (session.agentTurn !== void 0 || !noPromptInFlight()) {
|
|
67882
|
+
return;
|
|
67883
|
+
}
|
|
67884
|
+
await publishBackgroundTasks();
|
|
67885
|
+
session.agentTurn = { cancelled: false };
|
|
67886
|
+
const taskIds = [...awaitingBackgroundResults];
|
|
67887
|
+
const started = {
|
|
67888
|
+
stage: "started",
|
|
67889
|
+
reason: taskIds.length > 0 ? "background-task" : "other",
|
|
67890
|
+
taskIds
|
|
67891
|
+
};
|
|
67892
|
+
await this.client.sessionUpdate({
|
|
67893
|
+
sessionId: params.sessionId,
|
|
67894
|
+
update: { sessionUpdate: "session_info_update", _meta: { [AGENT_TURN_META2]: started } }
|
|
67895
|
+
});
|
|
67896
|
+
};
|
|
67897
|
+
const endAgentTurn = async () => {
|
|
67898
|
+
const agentTurn = session.agentTurn;
|
|
67899
|
+
if (agentTurn === void 0) {
|
|
67900
|
+
return;
|
|
67901
|
+
}
|
|
67902
|
+
session.agentTurn = void 0;
|
|
67903
|
+
await publishBackgroundTasks();
|
|
67904
|
+
const ended = {
|
|
67905
|
+
stage: "ended",
|
|
67906
|
+
stopReason: agentTurn.cancelled ? "cancelled" : "end_turn"
|
|
67907
|
+
};
|
|
67908
|
+
await this.client.sessionUpdate({
|
|
67909
|
+
sessionId: params.sessionId,
|
|
67910
|
+
update: { sessionUpdate: "session_info_update", _meta: { [AGENT_TURN_META2]: ended } }
|
|
67911
|
+
});
|
|
67912
|
+
};
|
|
67775
67913
|
const turnAwaitingSubagents = (turn) => {
|
|
67776
67914
|
if (!turn.spawnedTaskIds?.size) {
|
|
67777
67915
|
return false;
|
|
@@ -67886,6 +68024,10 @@ var ClaudeAcpAgent = class {
|
|
|
67886
68024
|
let pendingNext = null;
|
|
67887
68025
|
try {
|
|
67888
68026
|
while (true) {
|
|
68027
|
+
await publishBackgroundTasks();
|
|
68028
|
+
if (session.agentTurn !== void 0 && !noPromptInFlight()) {
|
|
68029
|
+
await endAgentTurn();
|
|
68030
|
+
}
|
|
67889
68031
|
pendingNext ??= session.query.next().then((result) => ({ kind: "message", result }));
|
|
67890
68032
|
const nextMessage = pendingNext;
|
|
67891
68033
|
let onAbort;
|
|
@@ -67997,6 +68139,7 @@ var ClaudeAcpAgent = class {
|
|
|
67997
68139
|
switch (message.subtype) {
|
|
67998
68140
|
case "init":
|
|
67999
68141
|
processingBackgroundResults = new Set(awaitingBackgroundResults);
|
|
68142
|
+
await startAgentTurn();
|
|
68000
68143
|
if (message.capabilities?.includes("msg_lifecycle_v1")) {
|
|
68001
68144
|
session.msgLifecycleV1 = true;
|
|
68002
68145
|
}
|
|
@@ -68078,6 +68221,9 @@ var ClaudeAcpAgent = class {
|
|
|
68078
68221
|
}
|
|
68079
68222
|
case "session_state_changed": {
|
|
68080
68223
|
session.lastSessionState = message.state;
|
|
68224
|
+
if (message.state === "running") {
|
|
68225
|
+
await startAgentTurn();
|
|
68226
|
+
}
|
|
68081
68227
|
if (message.state === "idle") {
|
|
68082
68228
|
disarmResultWatchdog();
|
|
68083
68229
|
const boundary = session.idleBoundary;
|
|
@@ -68102,6 +68248,9 @@ var ClaudeAcpAgent = class {
|
|
|
68102
68248
|
failActive(RequestError.internalError(errorKindData("no_result"), TURN_NO_RESULT_MESSAGE));
|
|
68103
68249
|
}
|
|
68104
68250
|
await session.titles.onTurnEnd(session);
|
|
68251
|
+
if (noPromptInFlight()) {
|
|
68252
|
+
await endAgentTurn();
|
|
68253
|
+
}
|
|
68105
68254
|
}
|
|
68106
68255
|
break;
|
|
68107
68256
|
}
|
|
@@ -68219,6 +68368,12 @@ var ClaudeAcpAgent = class {
|
|
|
68219
68368
|
parentToolUseId: message.tool_use_id,
|
|
68220
68369
|
isSubagent: !!message.subagent_type
|
|
68221
68370
|
});
|
|
68371
|
+
backgroundTaskDetails.set(message.task_id, {
|
|
68372
|
+
kind: message.subagent_type ? "subagent" : message.task_type === "local_bash" ? "shell" : "other",
|
|
68373
|
+
ambient: message.ambient === true || message.skip_transcript === true,
|
|
68374
|
+
...message.tool_use_id === void 0 ? {} : { toolUseId: message.tool_use_id },
|
|
68375
|
+
...message.description.length === 0 ? {} : { description: message.description }
|
|
68376
|
+
});
|
|
68222
68377
|
if (message.subagent_type && session.activeTurn && !session.activeTurn.settled) {
|
|
68223
68378
|
session.activeTurn.spawnedTaskIds ??= /* @__PURE__ */ new Set();
|
|
68224
68379
|
session.activeTurn.spawnedTaskIds.add(message.task_id);
|
|
@@ -68239,6 +68394,7 @@ var ClaudeAcpAgent = class {
|
|
|
68239
68394
|
if (message.skip_transcript) {
|
|
68240
68395
|
backgroundTasks.delete(message.task_id);
|
|
68241
68396
|
awaitingBackgroundResults.delete(message.task_id);
|
|
68397
|
+
backgroundTaskDetails.delete(message.task_id);
|
|
68242
68398
|
} else if (backgroundTasks.delete(message.task_id)) {
|
|
68243
68399
|
awaitingBackgroundResults.add(message.task_id);
|
|
68244
68400
|
}
|
|
@@ -68526,6 +68682,9 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68526
68682
|
if (message.origin?.kind === "task-notification") {
|
|
68527
68683
|
for (const id of processingBackgroundResults) {
|
|
68528
68684
|
awaitingBackgroundResults.delete(id);
|
|
68685
|
+
if (!backgroundTasks.has(id)) {
|
|
68686
|
+
backgroundTaskDetails.delete(id);
|
|
68687
|
+
}
|
|
68529
68688
|
}
|
|
68530
68689
|
processingBackgroundResults.clear();
|
|
68531
68690
|
reportBackgroundActivity();
|
|
@@ -68925,6 +69084,9 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68925
69084
|
return;
|
|
68926
69085
|
}
|
|
68927
69086
|
session.cancelled = true;
|
|
69087
|
+
if (session.agentTurn !== void 0) {
|
|
69088
|
+
session.agentTurn.cancelled = true;
|
|
69089
|
+
}
|
|
68928
69090
|
session.pendingExitPlanModeInterruption = void 0;
|
|
68929
69091
|
session.pendingExitPlanContextReset = void 0;
|
|
68930
69092
|
if (session.queryClosed) {
|
|
@@ -71333,6 +71495,8 @@ async function runPromptWithCancellation(agent2, params, signal) {
|
|
|
71333
71495
|
signal.removeEventListener("abort", onAbort);
|
|
71334
71496
|
}
|
|
71335
71497
|
}
|
|
71498
|
+
var BACKGROUND_TASKS_META2 = "mobius.backgroundTasks";
|
|
71499
|
+
var AGENT_TURN_META2 = "mobius.agentTurn";
|
|
71336
71500
|
function createClaudeAcpApp(options = {}) {
|
|
71337
71501
|
let agent2 = null;
|
|
71338
71502
|
const app = agent({ name: "claude-code-acp" }).onConnect((connection) => {
|
|
@@ -80778,6 +80942,48 @@ function applyConfigurationChanges(base, changes) {
|
|
|
80778
80942
|
}
|
|
80779
80943
|
|
|
80780
80944
|
// src/engine/acp/adapter/session-events.ts
|
|
80945
|
+
var harnessText = external_exports.string().min(1).max(2048);
|
|
80946
|
+
var backgroundTaskReportsSchema = external_exports.array(
|
|
80947
|
+
external_exports.object({
|
|
80948
|
+
taskId: harnessText,
|
|
80949
|
+
kind: external_exports.enum(["subagent", "shell", "other"]).catch("other"),
|
|
80950
|
+
state: external_exports.enum(["running", "awaiting-results"]),
|
|
80951
|
+
toolUseId: harnessText.optional().catch(void 0),
|
|
80952
|
+
description: external_exports.string().optional().catch(void 0)
|
|
80953
|
+
}).readonly()
|
|
80954
|
+
).max(1e3).readonly();
|
|
80955
|
+
var agentTurnReportSchema = external_exports.discriminatedUnion("stage", [
|
|
80956
|
+
external_exports.object({
|
|
80957
|
+
stage: external_exports.literal("started"),
|
|
80958
|
+
reason: external_exports.enum(["background-task", "other"]).catch("other"),
|
|
80959
|
+
taskIds: external_exports.array(harnessText).max(1e3).readonly()
|
|
80960
|
+
}).readonly(),
|
|
80961
|
+
external_exports.object({ stage: external_exports.literal("ended"), stopReason: external_exports.enum(["end_turn", "cancelled"]) }).readonly()
|
|
80962
|
+
]);
|
|
80963
|
+
function harnessReports(update) {
|
|
80964
|
+
if (update.sessionUpdate !== "session_info_update") {
|
|
80965
|
+
return null;
|
|
80966
|
+
}
|
|
80967
|
+
const meta3 = update._meta;
|
|
80968
|
+
if (meta3 === void 0 || meta3 === null || !(AGENT_TURN_META in meta3) && !(BACKGROUND_TASKS_META in meta3)) {
|
|
80969
|
+
return null;
|
|
80970
|
+
}
|
|
80971
|
+
const decode6 = (key, schema) => {
|
|
80972
|
+
if (!(key in meta3)) {
|
|
80973
|
+
return null;
|
|
80974
|
+
}
|
|
80975
|
+
const decoded = schema.safeParse(meta3[key]);
|
|
80976
|
+
if (!decoded.success) {
|
|
80977
|
+
console.warn("[acp] Dropped a harness report that does not decode", { key });
|
|
80978
|
+
return null;
|
|
80979
|
+
}
|
|
80980
|
+
return decoded.data;
|
|
80981
|
+
};
|
|
80982
|
+
return {
|
|
80983
|
+
agentTurn: decode6(AGENT_TURN_META, agentTurnReportSchema),
|
|
80984
|
+
backgroundTasks: decode6(BACKGROUND_TASKS_META, backgroundTaskReportsSchema)
|
|
80985
|
+
};
|
|
80986
|
+
}
|
|
80781
80987
|
function withMobiusFields(update, eventUpdate) {
|
|
80782
80988
|
if (typeof eventUpdate !== "object" || eventUpdate === null) {
|
|
80783
80989
|
return eventUpdate;
|
|
@@ -80820,6 +81026,16 @@ var AdapterSessionConnection = class {
|
|
|
80820
81026
|
if (notification.sessionId !== this.#updates.sessionId()) {
|
|
80821
81027
|
throw new AcpExecutionError("ACP agent referenced an unknown session", {}, "invalid_agent_session");
|
|
80822
81028
|
}
|
|
81029
|
+
const reports = harnessReports(notification.update);
|
|
81030
|
+
if (reports !== null) {
|
|
81031
|
+
if (reports.backgroundTasks !== null) {
|
|
81032
|
+
await options.onBackgroundTasks?.(reports.backgroundTasks);
|
|
81033
|
+
}
|
|
81034
|
+
if (reports.agentTurn !== null) {
|
|
81035
|
+
await options.onAgentTurn?.(reports.agentTurn);
|
|
81036
|
+
}
|
|
81037
|
+
return;
|
|
81038
|
+
}
|
|
80823
81039
|
const signal = AbortSignal.any([this.#lifetime.signal, AbortSignal.timeout(3e4)]);
|
|
80824
81040
|
const externalized = options.externalizeUpdate === void 0 ? await externalizer.update(notification.sessionId, notification.update, signal) : await options.externalizeUpdate(notification.update, signal);
|
|
80825
81041
|
signal.throwIfAborted();
|
|
@@ -81109,6 +81325,8 @@ var AcpExecutionConnections = class {
|
|
|
81109
81325
|
...params.onBackgroundActivity === void 0 ? {} : { onBackgroundActivity: params.onBackgroundActivity },
|
|
81110
81326
|
...params.onPromptDelegation === void 0 ? {} : { onPromptDelegation: params.onPromptDelegation },
|
|
81111
81327
|
...params.onPromptSuggestion === void 0 ? {} : { onPromptSuggestion: params.onPromptSuggestion },
|
|
81328
|
+
...params.onAgentTurn === void 0 ? {} : { onAgentTurn: params.onAgentTurn },
|
|
81329
|
+
...params.onBackgroundTasks === void 0 ? {} : { onBackgroundTasks: params.onBackgroundTasks },
|
|
81112
81330
|
interactions: params.interactions
|
|
81113
81331
|
},
|
|
81114
81332
|
this.#externalizer,
|
|
@@ -89156,6 +89374,9 @@ var unmeasuredOperationMetrics = Object.freeze({
|
|
|
89156
89374
|
snapshot: () => Object.freeze([])
|
|
89157
89375
|
});
|
|
89158
89376
|
|
|
89377
|
+
// src/engine/session/live/agent-session.ts
|
|
89378
|
+
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
89379
|
+
|
|
89159
89380
|
// ../mobius-sdk/src/conversation-title.ts
|
|
89160
89381
|
var CONVERSATION_TITLE_CHARACTER_LIMIT = 42;
|
|
89161
89382
|
function conversationTitleFromText(text2) {
|
|
@@ -90336,6 +90557,19 @@ var AgentSession = class _AgentSession {
|
|
|
90336
90557
|
}
|
|
90337
90558
|
hasBackgroundActivity = () => this.#backgroundActivity !== "none";
|
|
90338
90559
|
#backgroundActivity = "none";
|
|
90560
|
+
/**
|
|
90561
|
+
* The Turn the Agent is running on its own, with no prompt from any client. It has a command of the Runtime's
|
|
90562
|
+
* own, recorded with the same lifecycle events a client's prompt has.
|
|
90563
|
+
*/
|
|
90564
|
+
#agentTurn = null;
|
|
90565
|
+
/** The last command a client's prompt started; the Agent's own work continues it unless its work says otherwise. */
|
|
90566
|
+
#lastClientCommandId = void 0;
|
|
90567
|
+
/** The client command each piece of outstanding background work belongs to, fixed when it is first reported. */
|
|
90568
|
+
#backgroundTaskCommands = /* @__PURE__ */ new Map();
|
|
90569
|
+
/** The background work last recorded, so a report that changes nothing records nothing. */
|
|
90570
|
+
#recordedBackground = [];
|
|
90571
|
+
/** The command the Turn the Agent started on its own runs under, while it runs. */
|
|
90572
|
+
agentTurnCommand = () => this.#agentTurn?.commandId;
|
|
90339
90573
|
/** The command whose prompt the Agent is running, which only the Agent can report as delegated. */
|
|
90340
90574
|
#delegableCommandId = null;
|
|
90341
90575
|
#modelEffort = null;
|
|
@@ -90391,7 +90625,7 @@ var AgentSession = class _AgentSession {
|
|
|
90391
90625
|
cwd: () => this.#cwd,
|
|
90392
90626
|
getToolCall: (toolCallId) => this.#store.events.getToolCall(this.#mobiusSessionId, toolCallId),
|
|
90393
90627
|
sessionId: () => this.#mobiusSessionId,
|
|
90394
|
-
commandId: () => this.#agentCommand() ?? SESSION_CONTROL_COMMAND_ID,
|
|
90628
|
+
commandId: () => this.#agentCommand() ?? this.#agentTurn?.commandId ?? SESSION_CONTROL_COMMAND_ID,
|
|
90395
90629
|
assertNativeSession: this.assertNativeSession,
|
|
90396
90630
|
observer: getObserver,
|
|
90397
90631
|
recordSessionEvent: this.recordLifecycleEvent
|
|
@@ -90419,6 +90653,12 @@ var AgentSession = class _AgentSession {
|
|
|
90419
90653
|
void this.#recordNativeHistoryRevision();
|
|
90420
90654
|
}
|
|
90421
90655
|
},
|
|
90656
|
+
onAgentTurn: async (report) => {
|
|
90657
|
+
await this.#recordAgentTurn(report);
|
|
90658
|
+
},
|
|
90659
|
+
onBackgroundTasks: async (tasks) => {
|
|
90660
|
+
await this.#recordBackgroundTasks(tasks);
|
|
90661
|
+
},
|
|
90422
90662
|
onPromptDelegation: async (stage) => {
|
|
90423
90663
|
const commandId = this.#delegableCommandId;
|
|
90424
90664
|
if (commandId !== null) {
|
|
@@ -90840,6 +91080,9 @@ var AgentSession = class _AgentSession {
|
|
|
90840
91080
|
});
|
|
90841
91081
|
}
|
|
90842
91082
|
this.#delegableCommandId = lifecycle === void 0 ? null : options.commandId;
|
|
91083
|
+
if (lifecycle !== void 0) {
|
|
91084
|
+
this.#lastClientCommandId = options.commandId;
|
|
91085
|
+
}
|
|
90843
91086
|
try {
|
|
90844
91087
|
const result = await this.#writeNativeHistory(async () => {
|
|
90845
91088
|
try {
|
|
@@ -91081,6 +91324,122 @@ var AgentSession = class _AgentSession {
|
|
|
91081
91324
|
await this.#adapter.releaseSession({ ...this.#target(), signal: AbortSignal.timeout(3e4) });
|
|
91082
91325
|
}
|
|
91083
91326
|
this.#backgroundActivity = "none";
|
|
91327
|
+
const agentTurn = this.#agentTurn;
|
|
91328
|
+
if (agentTurn !== null) {
|
|
91329
|
+
this.#agentTurn = null;
|
|
91330
|
+
await this.recordLifecycleEvent({
|
|
91331
|
+
payload: {
|
|
91332
|
+
attemptId: agentTurn.attemptId,
|
|
91333
|
+
code: "agent_process_closed",
|
|
91334
|
+
commandId: agentTurn.commandId,
|
|
91335
|
+
kind: "prompt.failed",
|
|
91336
|
+
message: "The Agent process ended before the work it started on its own finished"
|
|
91337
|
+
},
|
|
91338
|
+
type: "lifecycle-metadata"
|
|
91339
|
+
});
|
|
91340
|
+
this.#getObserver().onAgentTurn?.(this.#mobiusSessionId, null);
|
|
91341
|
+
}
|
|
91342
|
+
await this.#recordBackgroundTasks([]);
|
|
91343
|
+
};
|
|
91344
|
+
/**
|
|
91345
|
+
* Cancels the Turn the Agent started on its own when `commandId` names it; returns whether it did. Its end is
|
|
91346
|
+
* recorded when the Agent reports it, as for any interrupted work.
|
|
91347
|
+
*/
|
|
91348
|
+
cancelAgentTurn = async (commandId, signal) => {
|
|
91349
|
+
if (this.#agentTurn?.commandId !== commandId) {
|
|
91350
|
+
return false;
|
|
91351
|
+
}
|
|
91352
|
+
await this.#interactions.cancelPendingInteractions();
|
|
91353
|
+
signal.throwIfAborted();
|
|
91354
|
+
await this.#adapter.cancel({ ...this.#target(), signal });
|
|
91355
|
+
return true;
|
|
91356
|
+
};
|
|
91357
|
+
#recordAgentTurn = async (report) => {
|
|
91358
|
+
switch (report.stage) {
|
|
91359
|
+
case "started": {
|
|
91360
|
+
if (this.#agentTurn !== null) {
|
|
91361
|
+
return;
|
|
91362
|
+
}
|
|
91363
|
+
const continues = report.taskIds.flatMap((taskId) => {
|
|
91364
|
+
const commandId = this.#backgroundTaskCommands.get(taskId);
|
|
91365
|
+
return commandId === void 0 ? [] : [commandId];
|
|
91366
|
+
})[0] ?? this.#lastClientCommandId;
|
|
91367
|
+
const agentTurn = { attemptId: randomUUID14(), commandId: `agent-${randomUUID14()}`, continues };
|
|
91368
|
+
this.#agentTurn = agentTurn;
|
|
91369
|
+
await this.recordLifecycleEvent({
|
|
91370
|
+
payload: {
|
|
91371
|
+
attemptId: agentTurn.attemptId,
|
|
91372
|
+
commandId: agentTurn.commandId,
|
|
91373
|
+
epoch: randomUUID14(),
|
|
91374
|
+
initiator: {
|
|
91375
|
+
kind: "agent",
|
|
91376
|
+
reason: report.reason,
|
|
91377
|
+
...continues === void 0 ? {} : { continues }
|
|
91378
|
+
},
|
|
91379
|
+
kind: "prompt.started"
|
|
91380
|
+
},
|
|
91381
|
+
type: "lifecycle-metadata"
|
|
91382
|
+
});
|
|
91383
|
+
this.#getObserver().onAgentTurn?.(this.#mobiusSessionId, agentTurn.commandId);
|
|
91384
|
+
return;
|
|
91385
|
+
}
|
|
91386
|
+
case "ended": {
|
|
91387
|
+
const agentTurn = this.#agentTurn;
|
|
91388
|
+
if (agentTurn === null) {
|
|
91389
|
+
return;
|
|
91390
|
+
}
|
|
91391
|
+
this.#agentTurn = null;
|
|
91392
|
+
await this.recordLifecycleEvent({
|
|
91393
|
+
payload: {
|
|
91394
|
+
commandId: agentTurn.commandId,
|
|
91395
|
+
kind: "prompt.completed",
|
|
91396
|
+
stopReason: report.stopReason
|
|
91397
|
+
},
|
|
91398
|
+
type: "lifecycle-metadata"
|
|
91399
|
+
});
|
|
91400
|
+
this.#getObserver().onAgentTurn?.(this.#mobiusSessionId, null);
|
|
91401
|
+
return;
|
|
91402
|
+
}
|
|
91403
|
+
default: {
|
|
91404
|
+
const unreachable2 = report;
|
|
91405
|
+
throw new AcpExecutionError("Unexpected Agent Turn report", { cause: unreachable2 });
|
|
91406
|
+
}
|
|
91407
|
+
}
|
|
91408
|
+
};
|
|
91409
|
+
/**
|
|
91410
|
+
* Records the Session's outstanding background work when it changed. Each piece belongs to the client command that
|
|
91411
|
+
* was running, or that the Agent's own Turn continued, when it was first reported.
|
|
91412
|
+
*/
|
|
91413
|
+
#recordBackgroundTasks = async (reports) => {
|
|
91414
|
+
const owner = this.#agentCommand() ?? this.#agentTurn?.continues ?? this.#lastClientCommandId;
|
|
91415
|
+
const current = new Set(reports.map((report) => report.taskId));
|
|
91416
|
+
for (const taskId of this.#backgroundTaskCommands.keys()) {
|
|
91417
|
+
if (!current.has(taskId)) {
|
|
91418
|
+
this.#backgroundTaskCommands.delete(taskId);
|
|
91419
|
+
}
|
|
91420
|
+
}
|
|
91421
|
+
const tasks = reports.slice(0, SESSION_BACKGROUND_TASK_MAX_COUNT).map((report) => {
|
|
91422
|
+
if (owner !== void 0 && !this.#backgroundTaskCommands.has(report.taskId)) {
|
|
91423
|
+
this.#backgroundTaskCommands.set(report.taskId, owner);
|
|
91424
|
+
}
|
|
91425
|
+
const commandId = this.#backgroundTaskCommands.get(report.taskId);
|
|
91426
|
+
return {
|
|
91427
|
+
kind: report.kind,
|
|
91428
|
+
state: report.state,
|
|
91429
|
+
taskId: report.taskId,
|
|
91430
|
+
...commandId === void 0 ? {} : { commandId },
|
|
91431
|
+
...report.toolUseId === void 0 ? {} : { toolCallId: report.toolUseId },
|
|
91432
|
+
...report.description === void 0 ? {} : { description: truncate(report.description, 500) }
|
|
91433
|
+
};
|
|
91434
|
+
});
|
|
91435
|
+
if (JSON.stringify(tasks) === JSON.stringify(this.#recordedBackground)) {
|
|
91436
|
+
return;
|
|
91437
|
+
}
|
|
91438
|
+
this.#recordedBackground = tasks;
|
|
91439
|
+
await this.recordLifecycleEvent({
|
|
91440
|
+
payload: { kind: "session.background.changed", tasks },
|
|
91441
|
+
type: "lifecycle-metadata"
|
|
91442
|
+
});
|
|
91084
91443
|
};
|
|
91085
91444
|
agentSettingsModelEffort = () => this.#modelEffort;
|
|
91086
91445
|
#sessionParams = (signal) => ({
|
|
@@ -91236,7 +91595,11 @@ var SessionManager2 = class {
|
|
|
91236
91595
|
#store;
|
|
91237
91596
|
#onSessionClosed;
|
|
91238
91597
|
#timer;
|
|
91239
|
-
|
|
91598
|
+
/** What each Session's Agent process reports to: the runtime's observer, plus the Agent Turns this manager tracks. */
|
|
91599
|
+
#runtimeObserver;
|
|
91600
|
+
#onSessionStatusChanged;
|
|
91601
|
+
/** The command of the Turn each Session's Agent is running on its own; no client's prompt holds it. */
|
|
91602
|
+
#agentTurns = /* @__PURE__ */ new Map();
|
|
91240
91603
|
/** Each Session's next-prompt suggestions. They outlive the Session's Agent process. */
|
|
91241
91604
|
promptSuggestions;
|
|
91242
91605
|
constructor({
|
|
@@ -91248,7 +91611,8 @@ var SessionManager2 = class {
|
|
|
91248
91611
|
lastTurn = () => void 0,
|
|
91249
91612
|
timer
|
|
91250
91613
|
}) {
|
|
91251
|
-
this.#
|
|
91614
|
+
this.#runtimeObserver = this.#observing(observer);
|
|
91615
|
+
this.#onSessionStatusChanged = onSessionStatusChanged;
|
|
91252
91616
|
this.#processes = processes;
|
|
91253
91617
|
this.#store = store;
|
|
91254
91618
|
this.#lastTurn = lastTurn;
|
|
@@ -91271,11 +91635,42 @@ var SessionManager2 = class {
|
|
|
91271
91635
|
return await runtime.recordControlEvent(event);
|
|
91272
91636
|
};
|
|
91273
91637
|
setObserver = (observer) => {
|
|
91274
|
-
this.#
|
|
91638
|
+
this.#runtimeObserver = this.#observing(observer);
|
|
91275
91639
|
};
|
|
91640
|
+
#observing(observer) {
|
|
91641
|
+
return {
|
|
91642
|
+
...observer.onBackgroundActivity === void 0 ? {} : { onBackgroundActivity: observer.onBackgroundActivity },
|
|
91643
|
+
...observer.onSessionEvent === void 0 ? {} : { onSessionEvent: observer.onSessionEvent },
|
|
91644
|
+
onAgentTurn: (sessionId, commandId) => {
|
|
91645
|
+
observer.onAgentTurn?.(sessionId, commandId);
|
|
91646
|
+
this.#agentTurnChanged(sessionId, commandId);
|
|
91647
|
+
},
|
|
91648
|
+
onCommands: observer.onCommands,
|
|
91649
|
+
onConfig: observer.onConfig,
|
|
91650
|
+
onElicitation: observer.onElicitation,
|
|
91651
|
+
onElicitationResolved: observer.onElicitationResolved,
|
|
91652
|
+
onInfo: observer.onInfo,
|
|
91653
|
+
onPermission: observer.onPermission,
|
|
91654
|
+
onPermissionResolved: observer.onPermissionResolved
|
|
91655
|
+
};
|
|
91656
|
+
}
|
|
91657
|
+
#agentTurnChanged(sessionId, commandId) {
|
|
91658
|
+
if (commandId === null) {
|
|
91659
|
+
this.#agentTurns.delete(sessionId);
|
|
91660
|
+
} else {
|
|
91661
|
+
this.#agentTurns.set(sessionId, commandId);
|
|
91662
|
+
}
|
|
91663
|
+
this.#onSessionStatusChanged({
|
|
91664
|
+
kind: "session.status.changed",
|
|
91665
|
+
sessionId,
|
|
91666
|
+
status: this.sessionStatus(sessionId)
|
|
91667
|
+
});
|
|
91668
|
+
}
|
|
91669
|
+
/** Whether `commandId` names the Turn the Session's Agent is running on its own. */
|
|
91670
|
+
isAgentTurn = (sessionId, commandId) => this.#agentTurns.get(sessionId) === commandId;
|
|
91276
91671
|
#retention(sessionId) {
|
|
91277
91672
|
return {
|
|
91278
|
-
isBusy: () => this.#executionProcesses.get(sessionId)?.hasBackgroundActivity() === true || this.#executions.isBusy(sessionId) || this.#executionProcesses.isBusy(sessionId),
|
|
91673
|
+
isBusy: () => this.#executionProcesses.get(sessionId)?.hasBackgroundActivity() === true || this.#agentTurns.has(sessionId) || this.#executions.isBusy(sessionId) || this.#executionProcesses.isBusy(sessionId),
|
|
91279
91674
|
retire: (runtime) => this.#retireSessionProcess(sessionId, runtime, () => runtime.close()),
|
|
91280
91675
|
retireIdle: (runtime) => this.#stopSessionProcess(sessionId, runtime)
|
|
91281
91676
|
};
|
|
@@ -91346,7 +91741,7 @@ var SessionManager2 = class {
|
|
|
91346
91741
|
async (capabilities) => await AgentSession.start(
|
|
91347
91742
|
options,
|
|
91348
91743
|
recovery,
|
|
91349
|
-
() => this.#
|
|
91744
|
+
() => this.#runtimeObserver,
|
|
91350
91745
|
this.#executions.agentCommand,
|
|
91351
91746
|
this.#store,
|
|
91352
91747
|
metrics,
|
|
@@ -91370,7 +91765,7 @@ var SessionManager2 = class {
|
|
|
91370
91765
|
async (capabilities) => await AgentSession.start(
|
|
91371
91766
|
options,
|
|
91372
91767
|
recovery,
|
|
91373
|
-
() => this.#
|
|
91768
|
+
() => this.#runtimeObserver,
|
|
91374
91769
|
this.#executions.agentCommand,
|
|
91375
91770
|
this.#store,
|
|
91376
91771
|
metrics,
|
|
@@ -91391,7 +91786,7 @@ var SessionManager2 = class {
|
|
|
91391
91786
|
async (capabilities) => await AgentSession.start(
|
|
91392
91787
|
options,
|
|
91393
91788
|
recovery,
|
|
91394
|
-
() => this.#
|
|
91789
|
+
() => this.#runtimeObserver,
|
|
91395
91790
|
this.#executions.agentCommand,
|
|
91396
91791
|
this.#store,
|
|
91397
91792
|
unmeasuredOperationMetrics,
|
|
@@ -91448,7 +91843,7 @@ var SessionManager2 = class {
|
|
|
91448
91843
|
async (capabilities) => await AgentSession.start(
|
|
91449
91844
|
options,
|
|
91450
91845
|
recovery,
|
|
91451
|
-
() => this.#
|
|
91846
|
+
() => this.#runtimeObserver,
|
|
91452
91847
|
this.#executions.agentCommand,
|
|
91453
91848
|
this.#store,
|
|
91454
91849
|
unmeasuredOperationMetrics,
|
|
@@ -91717,6 +92112,10 @@ var SessionManager2 = class {
|
|
|
91717
92112
|
);
|
|
91718
92113
|
/** Cancels the named command's Agent execution; a command that is not executing has nothing to stop. */
|
|
91719
92114
|
cancelPrompt = async (sessionId, commandId, signal = AbortSignal.timeout(3e4)) => this.#operations.run({ signal }, async ({ signal: signal2 }) => {
|
|
92115
|
+
if (this.#agentTurns.get(sessionId) === commandId) {
|
|
92116
|
+
await this.#executionProcesses.get(sessionId)?.cancelAgentTurn(commandId, signal2);
|
|
92117
|
+
return;
|
|
92118
|
+
}
|
|
91720
92119
|
await this.#executions.cancel(sessionId, commandId, async () => {
|
|
91721
92120
|
const runtime = this.#executionProcesses.get(sessionId);
|
|
91722
92121
|
if (runtime !== void 0) {
|
|
@@ -91912,11 +92311,18 @@ var SessionManager2 = class {
|
|
|
91912
92311
|
return stored instanceof FoundStoredSession ? [stored.session] : [];
|
|
91913
92312
|
});
|
|
91914
92313
|
sessionStatus = (sessionId) => this.#reported(sessionId, this.#executions.status(sessionId));
|
|
91915
|
-
/**
|
|
92314
|
+
/**
|
|
92315
|
+
* A Session whose Agent runs a Turn of its own is working on that command while no client's prompt runs. An idle
|
|
92316
|
+
* Session whose last started command failed says so, so a client that did not watch it still knows.
|
|
92317
|
+
*/
|
|
91916
92318
|
#reported = (sessionId, status) => {
|
|
91917
92319
|
if (status.kind !== "idle") {
|
|
91918
92320
|
return status;
|
|
91919
92321
|
}
|
|
92322
|
+
const agentTurn = this.#agentTurns.get(sessionId);
|
|
92323
|
+
if (agentTurn !== void 0) {
|
|
92324
|
+
return { commandId: agentTurn, kind: "working" };
|
|
92325
|
+
}
|
|
91920
92326
|
const lastTurn = this.#lastTurn(sessionId);
|
|
91921
92327
|
return lastTurn?.state === "failed" ? {
|
|
91922
92328
|
...status,
|
|
@@ -92181,7 +92587,7 @@ var PromptLifecycle = class {
|
|
|
92181
92587
|
record = (recorded) => {
|
|
92182
92588
|
this.#recordActiveTurn(recorded);
|
|
92183
92589
|
const sessionId = recorded.sessionId;
|
|
92184
|
-
if (recorded.type === "lifecycle-metadata" && isPromptTerminal(recorded.payload)) {
|
|
92590
|
+
if (recorded.type === "lifecycle-metadata" && isPromptTerminal(recorded.payload) && this.#queued.has(recorded.payload.commandId)) {
|
|
92185
92591
|
this.#terminal.set(recorded.payload.commandId, recorded);
|
|
92186
92592
|
const pending = this.#publications.get(sessionId) ?? [];
|
|
92187
92593
|
pending.push(recorded);
|
|
@@ -92324,7 +92730,7 @@ async function settleAbandonedTurn(projection, operations, cancellation) {
|
|
|
92324
92730
|
}
|
|
92325
92731
|
|
|
92326
92732
|
// src/engine/session/turn/execution-receipts.ts
|
|
92327
|
-
import { createHash as createHash7, randomUUID as
|
|
92733
|
+
import { createHash as createHash7, randomUUID as randomUUID15 } from "node:crypto";
|
|
92328
92734
|
var MAX_TERMINAL_RECEIPTS = 1024;
|
|
92329
92735
|
function executionStarted(state) {
|
|
92330
92736
|
switch (state.kind) {
|
|
@@ -92626,7 +93032,7 @@ var ExecutionReceipts = class {
|
|
|
92626
93032
|
).digest("hex");
|
|
92627
93033
|
this.#save(commandId, {
|
|
92628
93034
|
admissionOrder: this.#nextAdmissionOrder(),
|
|
92629
|
-
attemptId:
|
|
93035
|
+
attemptId: randomUUID15(),
|
|
92630
93036
|
commandHash,
|
|
92631
93037
|
sessionId,
|
|
92632
93038
|
state: {
|
|
@@ -92738,7 +93144,7 @@ var ExecutionReceipts = class {
|
|
|
92738
93144
|
default:
|
|
92739
93145
|
return unexpectedStanding(standing);
|
|
92740
93146
|
}
|
|
92741
|
-
const attemptId =
|
|
93147
|
+
const attemptId = randomUUID15();
|
|
92742
93148
|
this.#save(commandId, {
|
|
92743
93149
|
admissionOrder: this.#nextAdmissionOrder(),
|
|
92744
93150
|
attemptId,
|
|
@@ -92851,11 +93257,11 @@ var RuntimeTurnActivity = class {
|
|
|
92851
93257
|
};
|
|
92852
93258
|
|
|
92853
93259
|
// src/engine/session/turn/active-turn.ts
|
|
92854
|
-
import { randomUUID as
|
|
93260
|
+
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
92855
93261
|
var ActiveRuntimeTurn = class {
|
|
92856
93262
|
attemptId;
|
|
92857
93263
|
command;
|
|
92858
|
-
epoch = decodeIdentifier(
|
|
93264
|
+
epoch = decodeIdentifier(randomUUID16());
|
|
92859
93265
|
#controller;
|
|
92860
93266
|
#finished = Promise.withResolvers();
|
|
92861
93267
|
#started;
|
|
@@ -93502,11 +93908,11 @@ import { extname as extname2, join as join29 } from "node:path";
|
|
|
93502
93908
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
93503
93909
|
|
|
93504
93910
|
// src/engine/storage/files/scratch-directory.ts
|
|
93505
|
-
import { randomUUID as
|
|
93911
|
+
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
93506
93912
|
import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile7, realpath as realpath7, rename as rename4, rm as rm5, stat as stat6, utimes, writeFile as writeFile2 } from "node:fs/promises";
|
|
93507
93913
|
import { dirname as dirname11, join as join28 } from "node:path";
|
|
93508
93914
|
async function atomicWrite(path6, bytes, signal) {
|
|
93509
|
-
const temporary = `${path6}.${
|
|
93915
|
+
const temporary = `${path6}.${randomUUID17()}.tmp`;
|
|
93510
93916
|
try {
|
|
93511
93917
|
await writeFile2(temporary, bytes, { mode: 384, signal });
|
|
93512
93918
|
signal.throwIfAborted();
|
|
@@ -93518,7 +93924,7 @@ async function atomicWrite(path6, bytes, signal) {
|
|
|
93518
93924
|
var ScratchDirectory = class {
|
|
93519
93925
|
#root;
|
|
93520
93926
|
constructor(parent) {
|
|
93521
|
-
this.#root = join28(parent,
|
|
93927
|
+
this.#root = join28(parent, randomUUID17());
|
|
93522
93928
|
}
|
|
93523
93929
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
93524
93930
|
refreshLease = async (leaseMilliseconds) => {
|
|
@@ -94005,7 +94411,7 @@ var AgentProcessPool = class {
|
|
|
94005
94411
|
};
|
|
94006
94412
|
|
|
94007
94413
|
// src/engine/session/settings/agent-settings-cache.ts
|
|
94008
|
-
import { createHash as createHash9, randomUUID as
|
|
94414
|
+
import { createHash as createHash9, randomUUID as randomUUID18 } from "node:crypto";
|
|
94009
94415
|
import { join as join30 } from "node:path";
|
|
94010
94416
|
var CACHE_FILE_LIMIT = 32 * 1024 * 1024;
|
|
94011
94417
|
var CACHE_FORMAT = 1;
|
|
@@ -94078,7 +94484,7 @@ var AgentSettingsCache = class {
|
|
|
94078
94484
|
return this.#generation;
|
|
94079
94485
|
}
|
|
94080
94486
|
invalidate = async (signal) => {
|
|
94081
|
-
await writeInstallationFile(this.#generationPath,
|
|
94487
|
+
await writeInstallationFile(this.#generationPath, randomUUID18(), signal);
|
|
94082
94488
|
this.#generation += 1;
|
|
94083
94489
|
};
|
|
94084
94490
|
open = async (agent2, signal) => {
|
|
@@ -95299,6 +95705,12 @@ var sessionCancelCommand = {
|
|
|
95299
95705
|
if (message.kind !== SESSION_CANCEL_KIND) {
|
|
95300
95706
|
throw new Error("Command kind mismatch");
|
|
95301
95707
|
}
|
|
95708
|
+
if (sessions.isAgentTurn(message.sessionId, message.commandId)) {
|
|
95709
|
+
void sessions.cancelPrompt(message.sessionId, message.commandId, signal).catch((error62) => {
|
|
95710
|
+
console.error("Mobius daemon could not cancel the Agent's own turn", error62);
|
|
95711
|
+
});
|
|
95712
|
+
return;
|
|
95713
|
+
}
|
|
95302
95714
|
const turn = sessionTurns.get(message.commandId, message.sessionId);
|
|
95303
95715
|
if (turn === void 0) {
|
|
95304
95716
|
void settleAbandonedTurn(eventProjection, operations, message).catch((error62) => {
|
|
@@ -95588,7 +96000,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId, ad
|
|
|
95588
96000
|
}
|
|
95589
96001
|
|
|
95590
96002
|
// src/engine/session/prompt/apply-session-configuration.ts
|
|
95591
|
-
import { randomUUID as
|
|
96003
|
+
import { randomUUID as randomUUID19 } from "node:crypto";
|
|
95592
96004
|
function invalidSessionConfiguration(message) {
|
|
95593
96005
|
return new AcpExecutionError(message, {}, "invalid_session_configuration");
|
|
95594
96006
|
}
|
|
@@ -95713,7 +96125,7 @@ async function applySessionConfigurationSelection(sessions, options, selection,
|
|
|
95713
96125
|
booleanValue: selection.booleanValue,
|
|
95714
96126
|
configId: selection.configId,
|
|
95715
96127
|
cwd,
|
|
95716
|
-
requestId: `cfg_${
|
|
96128
|
+
requestId: `cfg_${randomUUID19()}`,
|
|
95717
96129
|
sessionId,
|
|
95718
96130
|
signal,
|
|
95719
96131
|
value: selection.value,
|
|
@@ -97699,4 +98111,4 @@ export {
|
|
|
97699
98111
|
* MIT Licensed
|
|
97700
98112
|
*)
|
|
97701
98113
|
*/
|
|
97702
|
-
//# sourceMappingURL=chunk-
|
|
98114
|
+
//# sourceMappingURL=chunk-LGPB3HHD.js.map
|