@moxt-ai/mobius 0.0.387 → 0.0.389
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-A62FEGIN.js → chunk-77O2RBRQ.js} +232 -188
- package/dist/{chunk-A62FEGIN.js.map → chunk-77O2RBRQ.js.map} +4 -4
- package/dist/{chunk-S7PKNDIS.js → chunk-Z6ERJZ2H.js} +2 -2
- package/dist/{chunk-S7PKNDIS.js.map → chunk-Z6ERJZ2H.js.map} +1 -1
- package/dist/{cli-43LPJ5ID.js → cli-I4NLPVNV.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/engine/runtime/command/registry/prompt.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/prompt.js +1 -3
- package/dist/engine/runtime/command/registry/prompt.js.map +1 -1
- package/dist/engine/runtime/relay/session-event-publisher.d.ts.map +1 -1
- package/dist/engine/runtime/relay/session-event-publisher.js +2 -4
- package/dist/engine/runtime/relay/session-event-publisher.js.map +1 -1
- package/dist/engine/session/api/session-layer.js +3 -3
- package/dist/engine/session/api/session-layer.js.map +1 -1
- package/dist/engine/session/live/agent-session.d.ts +13 -3
- package/dist/engine/session/live/agent-session.d.ts.map +1 -1
- package/dist/engine/session/live/agent-session.js +27 -23
- 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 +27 -28
- package/dist/engine/session/manager/session-manager.js.map +1 -1
- package/dist/engine/session/prompt/execute-prompt.d.ts +7 -8
- package/dist/engine/session/prompt/execute-prompt.d.ts.map +1 -1
- package/dist/engine/session/prompt/execute-prompt.js +14 -11
- package/dist/engine/session/prompt/execute-prompt.js.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.d.ts +8 -4
- package/dist/engine/session/prompt/prompt-lifecycle.d.ts.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.js +18 -17
- package/dist/engine/session/prompt/prompt-lifecycle.js.map +1 -1
- package/dist/engine/session/turn/active-executions.d.ts +27 -8
- package/dist/engine/session/turn/active-executions.d.ts.map +1 -1
- package/dist/engine/session/turn/active-executions.js +76 -22
- package/dist/engine/session/turn/active-executions.js.map +1 -1
- package/dist/engine/session/turn/active-turn.d.ts +10 -8
- package/dist/engine/session/turn/active-turn.d.ts.map +1 -1
- package/dist/engine/session/turn/active-turn.js +45 -36
- package/dist/engine/session/turn/active-turn.js.map +1 -1
- package/dist/engine/session/turn/execution-receipts.d.ts +6 -2
- package/dist/engine/session/turn/execution-receipts.d.ts.map +1 -1
- package/dist/engine/session/turn/execution-receipts.js +18 -32
- package/dist/engine/session/turn/execution-receipts.js.map +1 -1
- package/dist/engine/session/turn/session-execution.d.ts +4 -2
- package/dist/engine/session/turn/session-execution.d.ts.map +1 -1
- package/dist/engine/session/turn/session-execution.js +8 -7
- package/dist/engine/session/turn/session-execution.js.map +1 -1
- package/dist/engine/session/turn/session-turns.d.ts +0 -1
- package/dist/engine/session/turn/session-turns.d.ts.map +1 -1
- package/dist/engine/session/turn/session-turns.js +0 -1
- package/dist/engine/session/turn/session-turns.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +2 -2
- package/dist/engine/session/live/agent-turn.d.ts +0 -14
- package/dist/engine/session/live/agent-turn.d.ts.map +0 -1
- package/dist/engine/session/live/agent-turn.js +0 -16
- package/dist/engine/session/live/agent-turn.js.map +0 -1
- /package/dist/{cli-43LPJ5ID.js.map → cli-I4NLPVNV.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SESSION_CLOSED_ERROR_CODE } from "@moxt-ai/mobius-sdk/protocol";
|
|
1
|
+
import { isPromptTerminal, SESSION_CLOSED_ERROR_CODE } from "@moxt-ai/mobius-sdk/protocol";
|
|
2
2
|
import { isTextPromptResourceMediaType } from "./prompt-artifacts.js";
|
|
3
3
|
function promptContent(command) {
|
|
4
4
|
const content = [];
|
|
@@ -27,16 +27,17 @@ function promptContent(command) {
|
|
|
27
27
|
}
|
|
28
28
|
export class PromptLifecycle {
|
|
29
29
|
#sink;
|
|
30
|
+
/** Terminal events held until their command's admission and execution state are released. */
|
|
30
31
|
#terminal = new Map();
|
|
31
32
|
#publications = new Map();
|
|
32
33
|
#queued = new Map();
|
|
33
34
|
#recordActiveTurn;
|
|
34
|
-
#
|
|
35
|
+
#executions;
|
|
35
36
|
#recordLifecycle;
|
|
36
|
-
constructor(sink, recordLifecycle, recordActiveTurn,
|
|
37
|
+
constructor(sink, recordLifecycle, recordActiveTurn, executions) {
|
|
37
38
|
this.#recordLifecycle = recordLifecycle;
|
|
38
39
|
this.#recordActiveTurn = recordActiveTurn;
|
|
39
|
-
this.#
|
|
40
|
+
this.#executions = executions;
|
|
40
41
|
this.#sink = sink;
|
|
41
42
|
}
|
|
42
43
|
requested = (command) => {
|
|
@@ -53,8 +54,8 @@ export class PromptLifecycle {
|
|
|
53
54
|
...(command.targetCommandId.length === 0 ? {} : { targetCommandId: command.targetCommandId }),
|
|
54
55
|
});
|
|
55
56
|
};
|
|
56
|
-
/**
|
|
57
|
-
|
|
57
|
+
/** The lifecycle metadata the Agent session records when it starts this claimed command. */
|
|
58
|
+
lifecycle = (sessionId, commandId, attemptId, epoch, disposition) => {
|
|
58
59
|
const request = this.#queued.get(commandId);
|
|
59
60
|
if (request?.sessionId === sessionId) {
|
|
60
61
|
return {
|
|
@@ -71,10 +72,7 @@ export class PromptLifecycle {
|
|
|
71
72
|
record = (recorded) => {
|
|
72
73
|
this.#recordActiveTurn(recorded);
|
|
73
74
|
const sessionId = recorded.sessionId;
|
|
74
|
-
if (recorded.type === "lifecycle-metadata" &&
|
|
75
|
-
(recorded.payload.kind === "prompt.completed" ||
|
|
76
|
-
recorded.payload.kind === "prompt.failed" ||
|
|
77
|
-
recorded.payload.kind === "prompt.failed-before-start")) {
|
|
75
|
+
if (recorded.type === "lifecycle-metadata" && isPromptTerminal(recorded.payload)) {
|
|
78
76
|
// Publish termination after prompt admission and execution state are settled.
|
|
79
77
|
this.#terminal.set(recorded.payload.commandId, recorded);
|
|
80
78
|
const pending = this.#publications.get(sessionId) ?? [];
|
|
@@ -129,7 +127,7 @@ export class PromptLifecycle {
|
|
|
129
127
|
};
|
|
130
128
|
completed = async (sessionId, commandId, stopReason) => {
|
|
131
129
|
const request = this.#queued.get(commandId);
|
|
132
|
-
if (request?.sessionId !== sessionId || this.#
|
|
130
|
+
if (request?.sessionId !== sessionId || this.#executions.isTerminalExecution(commandId, sessionId)) {
|
|
133
131
|
return;
|
|
134
132
|
}
|
|
135
133
|
const recorded = await this.#recordLifecycle(sessionId, {
|
|
@@ -138,21 +136,24 @@ export class PromptLifecycle {
|
|
|
138
136
|
kind: "prompt.completed",
|
|
139
137
|
commandId,
|
|
140
138
|
stopReason,
|
|
141
|
-
...(this.#hasStarted(commandId, sessionId) ? {} : { execution: "not-started" }),
|
|
139
|
+
...(this.#executions.hasStarted(commandId, sessionId) ? {} : { execution: "not-started" }),
|
|
142
140
|
},
|
|
143
141
|
});
|
|
144
142
|
if (!recorded) {
|
|
145
143
|
this.#sink.publishOperationFailure(sessionId, commandId, "cancelled", "The prompt was cancelled before execution");
|
|
146
144
|
}
|
|
147
145
|
};
|
|
148
|
-
failed
|
|
146
|
+
/** Settles a failed command; whether it failed before or after starting is its receipt's fact. */
|
|
147
|
+
failed = async (sessionId, commandId, attemptId, code, message) => {
|
|
149
148
|
const request = this.#queued.get(commandId);
|
|
150
|
-
if (request?.sessionId !== sessionId || this.#
|
|
149
|
+
if (request?.sessionId !== sessionId || this.#executions.isTerminalExecution(commandId, sessionId)) {
|
|
151
150
|
return;
|
|
152
151
|
}
|
|
153
152
|
const recorded = await this.#recordLifecycle(sessionId, {
|
|
154
153
|
type: "lifecycle-metadata",
|
|
155
|
-
payload:
|
|
154
|
+
payload: this.#executions.hasStarted(commandId, sessionId)
|
|
155
|
+
? { kind: "prompt.failed", attemptId, commandId, code, message }
|
|
156
|
+
: { kind: "prompt.failed-before-start", commandId, code, message },
|
|
156
157
|
});
|
|
157
158
|
if (!recorded || code === SESSION_CLOSED_ERROR_CODE) {
|
|
158
159
|
this.#sink.publishOperationFailure(sessionId, commandId, code, message);
|
|
@@ -160,7 +161,7 @@ export class PromptLifecycle {
|
|
|
160
161
|
};
|
|
161
162
|
promptRequestRecovery = (sessionId) => ({
|
|
162
163
|
queuedPromptRequests: [...this.#queued.values()]
|
|
163
|
-
.filter((request) => request.sessionId === sessionId && !this.#hasStarted(request.commandId, sessionId))
|
|
164
|
+
.filter((request) => request.sessionId === sessionId && !this.#executions.hasStarted(request.commandId, sessionId))
|
|
164
165
|
.map(({ commandId, content, disposition, targetCommandId }) => ({
|
|
165
166
|
commandId,
|
|
166
167
|
content,
|
|
@@ -180,7 +181,7 @@ export async function settleAbandonedTurn(projection, operations, cancellation)
|
|
|
180
181
|
console.warn("Mobius daemon ignored cancellation for an inactive turn");
|
|
181
182
|
return;
|
|
182
183
|
}
|
|
183
|
-
await projection.failed(cancellation.sessionId, cancellation.commandId, "agent_execution_abandoned", "The local Agent execution was abandoned before it completed");
|
|
184
|
+
await projection.failed(cancellation.sessionId, cancellation.commandId, attemptId, "agent_execution_abandoned", "The local Agent execution was abandoned before it completed");
|
|
184
185
|
projection.publishTerminal(cancellation.sessionId, cancellation.commandId);
|
|
185
186
|
}
|
|
186
187
|
//# sourceMappingURL=prompt-lifecycle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-lifecycle.js","sourceRoot":"","sources":["../../../../src/engine/session/prompt/prompt-lifecycle.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-lifecycle.js","sourceRoot":"","sources":["../../../../src/engine/session/prompt/prompt-lifecycle.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,C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each Session is executing and in what phase. Every reader asks it: steering
|
|
4
|
+
* joins only a started execution, the Agent process may change only while no execution holds the Session, a
|
|
5
|
+
* cancellation stops only the execution it names, and the Session's working/idle status is derived from it.
|
|
6
|
+
*
|
|
7
|
+
* Contract: admission is the only owner of whether a Session is busy, so `begin` requires an idle Session. Each
|
|
8
|
+
* transition names its command and is ignored for any other. All operations are synchronous, so a check and the
|
|
9
|
+
* transition that relies on it cannot be separated by another caller.
|
|
4
10
|
*/
|
|
5
11
|
export declare class ActiveExecutions {
|
|
6
12
|
#private;
|
|
7
|
-
|
|
8
|
-
readonly
|
|
9
|
-
readonly isBusy: (
|
|
10
|
-
|
|
11
|
-
readonly
|
|
12
|
-
|
|
13
|
+
constructor(statusChanged: (sessionId: string, status: SessionStatus) => void);
|
|
14
|
+
readonly status: (sessionId: string) => SessionStatus;
|
|
15
|
+
readonly isBusy: (sessionId: string) => boolean;
|
|
16
|
+
/** A steering prompt can join only the named execution while the Agent holds it and no one is stopping it. */
|
|
17
|
+
readonly acceptsSteering: (sessionId: string, targetCommandId: string) => boolean;
|
|
18
|
+
/** The command whose prompt the Session's Agent holds, if any. */
|
|
19
|
+
readonly agentCommand: (sessionId: string) => string | undefined;
|
|
20
|
+
readonly cancellationRequested: (sessionId: string, commandId: string) => boolean;
|
|
21
|
+
readonly cancellation: (sessionId: string) => Promise<void> | undefined;
|
|
22
|
+
readonly begin: (sessionId: string, commandId: string) => void;
|
|
23
|
+
/** The Agent receives the prompt. A cancelled execution must not start. */
|
|
24
|
+
readonly start: (sessionId: string, commandId: string) => void;
|
|
25
|
+
readonly settle: (sessionId: string, commandId: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Records a cancellation of the named execution and asks `stop` to end it once. Another command's cancellation,
|
|
28
|
+
* or one for an idle Session, has nothing to stop. A cancelled execution that has not started never starts.
|
|
29
|
+
*/
|
|
30
|
+
readonly cancel: (sessionId: string, commandId: string, stop: () => Promise<void>) => Promise<void>;
|
|
31
|
+
readonly finish: (sessionId: string, commandId: string) => void;
|
|
13
32
|
}
|
|
14
33
|
//# sourceMappingURL=active-executions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-executions.d.ts","sourceRoot":"","sources":["../../../../src/engine/session/turn/active-executions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"active-executions.d.ts","sourceRoot":"","sources":["../../../../src/engine/session/turn/active-executions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAiBlE;;;;;;;;GAQG;AACH,qBAAa,gBAAgB;;IAIzB,YAAY,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,EAE5E;IAED,QAAQ,CAAC,MAAM,cAAe,MAAM,KAAG,aAAa,CAGlD;IAEF,QAAQ,CAAC,MAAM,cAAe,MAAM,KAAG,OAAO,CAAiC;IAE/E,8GAA8G;IAC9G,QAAQ,CAAC,eAAe,cAAe,MAAM,mBAAmB,MAAM,KAAG,OAAO,CAO9E;IAEF,kEAAkE;IAClE,QAAQ,CAAC,YAAY,cAAe,MAAM,KAAG,MAAM,GAAG,SAAS,CAG7D;IAEF,QAAQ,CAAC,qBAAqB,cAAe,MAAM,aAAa,MAAM,KAAG,OAAO,CAG9E;IAEF,QAAQ,CAAC,YAAY,cAAe,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAGpE;IAEF,QAAQ,CAAC,KAAK,cAAe,MAAM,aAAa,MAAM,KAAG,IAAI,CAM3D;IAEF,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,cAAe,MAAM,aAAa,MAAM,KAAG,IAAI,CAS3D;IAEF,QAAQ,CAAC,MAAM,cAAe,MAAM,aAAa,MAAM,KAAG,IAAI,CAK5D;IAEF;;;OAGG;IACH,QAAQ,CAAC,MAAM,cAAe,MAAM,aAAa,MAAM,QAAQ,MAAM,OAAO,CAAC,IAAI,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC,CAehG;IAEF,QAAQ,CAAC,MAAM,cAAe,MAAM,aAAa,MAAM,KAAG,IAAI,CAM5D;CACL"}
|
|
@@ -1,39 +1,93 @@
|
|
|
1
|
-
import { AcpExecutionError } from "../../acp/acp-error.js";
|
|
2
1
|
/**
|
|
3
|
-
* The
|
|
4
|
-
*
|
|
2
|
+
* The single authority for which command each Session is executing and in what phase. Every reader asks it: steering
|
|
3
|
+
* joins only a started execution, the Agent process may change only while no execution holds the Session, a
|
|
4
|
+
* cancellation stops only the execution it names, and the Session's working/idle status is derived from it.
|
|
5
|
+
*
|
|
6
|
+
* Contract: admission is the only owner of whether a Session is busy, so `begin` requires an idle Session. Each
|
|
7
|
+
* transition names its command and is ignored for any other. All operations are synchronous, so a check and the
|
|
8
|
+
* transition that relies on it cannot be separated by another caller.
|
|
5
9
|
*/
|
|
6
10
|
export class ActiveExecutions {
|
|
7
11
|
#entries = new Map();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
#statusChanged;
|
|
13
|
+
constructor(statusChanged) {
|
|
14
|
+
this.#statusChanged = statusChanged;
|
|
15
|
+
}
|
|
16
|
+
status = (sessionId) => {
|
|
17
|
+
const execution = this.#entries.get(sessionId);
|
|
18
|
+
return execution === undefined ? { kind: "idle" } : { commandId: execution.commandId, kind: "working" };
|
|
19
|
+
};
|
|
20
|
+
isBusy = (sessionId) => this.#entries.has(sessionId);
|
|
21
|
+
/** A steering prompt can join only the named execution while the Agent holds it and no one is stopping it. */
|
|
22
|
+
acceptsSteering = (sessionId, targetCommandId) => {
|
|
23
|
+
const execution = this.#entries.get(sessionId);
|
|
24
|
+
return (execution?.commandId === targetCommandId &&
|
|
25
|
+
execution.phase === "started" &&
|
|
26
|
+
execution.cancellation.kind === "none");
|
|
27
|
+
};
|
|
28
|
+
/** The command whose prompt the Session's Agent holds, if any. */
|
|
29
|
+
agentCommand = (sessionId) => {
|
|
30
|
+
const execution = this.#entries.get(sessionId);
|
|
31
|
+
return execution?.phase === "started" ? execution.commandId : undefined;
|
|
32
|
+
};
|
|
33
|
+
cancellationRequested = (sessionId, commandId) => {
|
|
34
|
+
const execution = this.#entries.get(sessionId);
|
|
35
|
+
return execution?.commandId === commandId && execution.cancellation.kind === "requested";
|
|
36
|
+
};
|
|
37
|
+
cancellation = (sessionId) => {
|
|
38
|
+
const cancellation = this.#entries.get(sessionId)?.cancellation;
|
|
39
|
+
return cancellation?.kind === "requested" ? cancellation.completion : undefined;
|
|
40
|
+
};
|
|
41
|
+
begin = (sessionId, commandId) => {
|
|
42
|
+
if (this.#entries.has(sessionId)) {
|
|
43
|
+
throw new Error("A Session executes one command at a time");
|
|
44
|
+
}
|
|
45
|
+
this.#entries.set(sessionId, { commandId, phase: "preparing", cancellation: { kind: "none" } });
|
|
46
|
+
this.#statusChanged(sessionId, this.status(sessionId));
|
|
47
|
+
};
|
|
48
|
+
/** The Agent receives the prompt. A cancelled execution must not start. */
|
|
49
|
+
start = (sessionId, commandId) => {
|
|
50
|
+
const execution = this.#entries.get(sessionId);
|
|
51
|
+
if (execution?.commandId !== commandId || execution.phase !== "preparing") {
|
|
52
|
+
throw new Error("Only the Session's preparing execution can start");
|
|
53
|
+
}
|
|
54
|
+
if (execution.cancellation.kind !== "none") {
|
|
55
|
+
throw new Error("A cancelled execution cannot start");
|
|
56
|
+
}
|
|
57
|
+
this.#entries.set(sessionId, { ...execution, phase: "started" });
|
|
58
|
+
};
|
|
59
|
+
settle = (sessionId, commandId) => {
|
|
60
|
+
const execution = this.#entries.get(sessionId);
|
|
61
|
+
if (execution?.commandId === commandId) {
|
|
62
|
+
this.#entries.set(sessionId, { ...execution, phase: "settled" });
|
|
17
63
|
}
|
|
18
|
-
this.#entries.set(id, { kind: "running", commandId });
|
|
19
64
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Records a cancellation of the named execution and asks `stop` to end it once. Another command's cancellation,
|
|
67
|
+
* or one for an idle Session, has nothing to stop. A cancelled execution that has not started never starts.
|
|
68
|
+
*/
|
|
69
|
+
cancel = (sessionId, commandId, stop) => {
|
|
70
|
+
const execution = this.#entries.get(sessionId);
|
|
71
|
+
if (execution?.commandId !== commandId) {
|
|
23
72
|
return Promise.resolve();
|
|
24
73
|
}
|
|
25
|
-
if (
|
|
26
|
-
return
|
|
74
|
+
if (execution.cancellation.kind === "requested") {
|
|
75
|
+
return execution.cancellation.completion;
|
|
27
76
|
}
|
|
28
77
|
const completion = Promise.withResolvers();
|
|
29
|
-
this.#entries.set(
|
|
78
|
+
this.#entries.set(sessionId, {
|
|
79
|
+
...execution,
|
|
80
|
+
cancellation: { kind: "requested", completion: completion.promise },
|
|
81
|
+
});
|
|
30
82
|
void (async () => await stop())().then(completion.resolve, completion.reject);
|
|
31
83
|
return completion.promise;
|
|
32
84
|
};
|
|
33
|
-
finish = (
|
|
34
|
-
if (this.
|
|
35
|
-
|
|
85
|
+
finish = (sessionId, commandId) => {
|
|
86
|
+
if (this.#entries.get(sessionId)?.commandId !== commandId) {
|
|
87
|
+
return;
|
|
36
88
|
}
|
|
89
|
+
this.#entries.delete(sessionId);
|
|
90
|
+
this.#statusChanged(sessionId, this.status(sessionId));
|
|
37
91
|
};
|
|
38
92
|
}
|
|
39
93
|
//# sourceMappingURL=active-executions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-executions.js","sourceRoot":"","sources":["../../../../src/engine/session/turn/active-executions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"active-executions.js","sourceRoot":"","sources":["../../../../src/engine/session/turn/active-executions.ts"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AACH,MAAM,OAAO,gBAAgB;IAChB,QAAQ,GAAG,IAAI,GAAG,EAAqB,CAAC;IACxC,cAAc,CAAqD;IAE5E,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AAE,UAAU,CAAC,MAAM,CAAC,CAAC;QAC9E,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC,CAAC;IAEO,MAAM,GAAG,CAAC,SAAiB,EAAE,SAAiB,EAAQ,EAAE;QAC7D,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,SAAS,KAAK,SAAS,EAAE,CAAC;YACxD,OAAO;QACX,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAChC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC;CACL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type NativeSessionResult, type
|
|
1
|
+
import { type NativeSessionResult, type SessionElicitationRequestedEvent, type SessionElicitationResolvedEvent, type SessionPermissionRequestedEvent, type SessionPermissionResolvedEvent, type SessionPromptCommand, type SessionPromptDispositionCommand } from "@moxt-ai/mobius-sdk/protocol";
|
|
2
2
|
type ActiveTurnSnapshot = Extract<NativeSessionResult, {
|
|
3
3
|
readonly action: "active-turn";
|
|
4
4
|
}>["turn"];
|
|
@@ -16,24 +16,26 @@ export declare class ActiveRuntimeTurn {
|
|
|
16
16
|
#private;
|
|
17
17
|
readonly attemptId: string;
|
|
18
18
|
readonly command: SessionPromptCommand;
|
|
19
|
-
|
|
19
|
+
readonly epoch: string & import("zod").$brand<"Identifier">;
|
|
20
|
+
/** `started` reads the command's execution receipt, the single owner of whether the command started. */
|
|
21
|
+
constructor(command: SessionPromptCommand, attemptId: string, started: () => boolean);
|
|
20
22
|
readonly enqueue: () => void;
|
|
21
23
|
readonly isQueued: () => boolean;
|
|
22
24
|
readonly abortRuntime: () => void;
|
|
23
25
|
readonly finish: () => void;
|
|
24
|
-
readonly activate: (execution: string) => {
|
|
25
|
-
readonly epoch: string;
|
|
26
|
-
readonly sequence: 0;
|
|
27
|
-
};
|
|
28
26
|
readonly promoteQueuedPrompt: (command: SessionPromptDispositionCommand) => "accepted" | "already-started" | "unavailable";
|
|
29
27
|
readonly admit: () => string;
|
|
30
28
|
readonly queuePromotion: () => Promise<void> | null;
|
|
31
29
|
readonly effectiveDisposition: () => string;
|
|
30
|
+
/** A steering prompt joins the execution of the turn it steers; every other prompt owns its execution. */
|
|
31
|
+
readonly execution: () => string;
|
|
32
32
|
readonly recordEvent: (event: RecordedSessionEvent) => RecordedSessionEvent;
|
|
33
|
-
readonly recordSteeringPrompt: (command: SessionPromptCommand) => boolean;
|
|
34
33
|
readonly snapshot: () => ActiveTurnSnapshot;
|
|
35
|
-
readonly matches: (cancellation: SessionCancelCommand) => boolean;
|
|
36
34
|
readonly matchesInteraction: (interactionId: string, sessionId: string) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Before the command starts, cancellation withdraws it by aborting its own admission and preparation. Once it
|
|
37
|
+
* started, the Agent execution it belongs to must be asked to stop.
|
|
38
|
+
*/
|
|
37
39
|
readonly requestCancellation: () => TurnCancellation;
|
|
38
40
|
readonly cancellationRequested: () => boolean;
|
|
39
41
|
get signal(): AbortSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-turn.d.ts","sourceRoot":"","sources":["../../../../src/engine/session/turn/active-turn.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,mBAAmB,EAKxB,KAAK,
|
|
1
|
+
{"version":3,"file":"active-turn.d.ts","sourceRoot":"","sources":["../../../../src/engine/session/turn/active-turn.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,mBAAmB,EAKxB,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,8BAA8B,EACnC,KAAK,oBAAoB,EAEzB,KAAK,+BAA+B,EACvC,MAAM,8BAA8B,CAAC;AAEtC,KAAK,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,EAAE;IAAE,QAAQ,CAA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EF,QAAQ,CAAC,QAAQ,QAAO,kBAAkB,CAWxC;IAEF,QAAQ,CAAC,kBAAkB,kBAAmB,MAAM,aAAa,MAAM,KAAG,OAAO,CACc;IAE/F;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,QAAO,gBAAgB,CAUjD;IAEF,QAAQ,CAAC,qBAAqB,QAAO,OAAO,CAAgC;IAE5E,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,IAAI,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAE9B;CACJ"}
|
|
@@ -3,27 +3,30 @@ import { decodeIdentifier, SESSION_ELICITATION_REQUESTED_KIND, SESSION_ELICITATI
|
|
|
3
3
|
export class ActiveRuntimeTurn {
|
|
4
4
|
attemptId;
|
|
5
5
|
command;
|
|
6
|
+
epoch = decodeIdentifier(randomUUID());
|
|
6
7
|
#controller;
|
|
7
8
|
#finished = Promise.withResolvers();
|
|
9
|
+
#started;
|
|
8
10
|
#cancellationRequested = false;
|
|
9
|
-
#
|
|
11
|
+
#admission = { kind: "waiting" };
|
|
10
12
|
#sequence = 0;
|
|
11
13
|
#interaction = null;
|
|
12
|
-
|
|
13
|
-
constructor(command, attemptId) {
|
|
14
|
+
/** `started` reads the command's execution receipt, the single owner of whether the command started. */
|
|
15
|
+
constructor(command, attemptId, started) {
|
|
14
16
|
this.attemptId = attemptId;
|
|
15
17
|
this.command = command;
|
|
16
18
|
this.#controller = new AbortController();
|
|
17
|
-
this.#
|
|
19
|
+
this.#started = started;
|
|
18
20
|
}
|
|
19
21
|
enqueue = () => {
|
|
20
|
-
if (this.#
|
|
21
|
-
throw new Error("Only a
|
|
22
|
+
if (this.#admission.kind !== "waiting") {
|
|
23
|
+
throw new Error("Only a waiting prompt can enter the queue");
|
|
22
24
|
}
|
|
23
|
-
this.#
|
|
25
|
+
this.#admission = { kind: "queued", promotion: Promise.withResolvers() };
|
|
24
26
|
};
|
|
25
|
-
isQueued = () => (this.#
|
|
26
|
-
(this.#
|
|
27
|
+
isQueued = () => (this.#admission.kind === "queued" ||
|
|
28
|
+
(this.#admission.kind === "admitted" && this.#admission.disposition === SessionPromptDisposition.Queue)) &&
|
|
29
|
+
!this.#started() &&
|
|
27
30
|
!this.#controller.signal.aborted;
|
|
28
31
|
abortRuntime = () => {
|
|
29
32
|
this.#controller.abort();
|
|
@@ -31,30 +34,24 @@ export class ActiveRuntimeTurn {
|
|
|
31
34
|
finish = () => {
|
|
32
35
|
this.#finished.resolve();
|
|
33
36
|
};
|
|
34
|
-
activate = (execution) => {
|
|
35
|
-
this.#dispatch = { kind: "running", execution };
|
|
36
|
-
return { epoch: this.#epoch, sequence: 0 };
|
|
37
|
-
};
|
|
38
37
|
promoteQueuedPrompt = (command) => {
|
|
39
38
|
if (command.commandId !== this.command.commandId ||
|
|
40
39
|
command.sessionId !== this.command.sessionId ||
|
|
41
40
|
this.#controller.signal.aborted) {
|
|
42
41
|
return "unavailable";
|
|
43
42
|
}
|
|
44
|
-
switch (this.#
|
|
43
|
+
switch (this.#admission.kind) {
|
|
45
44
|
case "queued": {
|
|
46
|
-
const promotion = this.#
|
|
47
|
-
this.#
|
|
45
|
+
const promotion = this.#admission.promotion;
|
|
46
|
+
this.#admission = { kind: "promoted" };
|
|
48
47
|
promotion.resolve();
|
|
49
48
|
return "accepted";
|
|
50
49
|
}
|
|
51
50
|
case "promoted":
|
|
52
51
|
return "accepted";
|
|
53
52
|
case "admitted":
|
|
54
|
-
return this.#
|
|
55
|
-
case "
|
|
56
|
-
return "already-started";
|
|
57
|
-
case "pending":
|
|
53
|
+
return this.#admission.disposition === SessionPromptDisposition.Steer ? "accepted" : "already-started";
|
|
54
|
+
case "waiting":
|
|
58
55
|
return "unavailable";
|
|
59
56
|
}
|
|
60
57
|
};
|
|
@@ -62,16 +59,30 @@ export class ActiveRuntimeTurn {
|
|
|
62
59
|
const disposition = this.effectiveDisposition();
|
|
63
60
|
// Claim the dispatch before asynchronous Agent preparation so a late promotion
|
|
64
61
|
// cannot change a disposition that execution has already selected.
|
|
65
|
-
this.#
|
|
62
|
+
this.#admission = { kind: "admitted", disposition };
|
|
66
63
|
return disposition;
|
|
67
64
|
};
|
|
68
65
|
queuePromotion = () => {
|
|
69
|
-
if (this.#
|
|
70
|
-
return this.#
|
|
66
|
+
if (this.#admission.kind === "queued") {
|
|
67
|
+
return this.#admission.promotion.promise;
|
|
68
|
+
}
|
|
69
|
+
return this.#admission.kind === "promoted" ? Promise.resolve() : null;
|
|
70
|
+
};
|
|
71
|
+
effectiveDisposition = () => {
|
|
72
|
+
switch (this.#admission.kind) {
|
|
73
|
+
case "waiting":
|
|
74
|
+
case "queued":
|
|
75
|
+
return this.command.disposition;
|
|
76
|
+
case "promoted":
|
|
77
|
+
return SessionPromptDisposition.Steer;
|
|
78
|
+
case "admitted":
|
|
79
|
+
return this.#admission.disposition;
|
|
71
80
|
}
|
|
72
|
-
return this.#dispatch.kind === "promoted" ? Promise.resolve() : null;
|
|
73
81
|
};
|
|
74
|
-
|
|
82
|
+
/** A steering prompt joins the execution of the turn it steers; every other prompt owns its execution. */
|
|
83
|
+
execution = () => this.effectiveDisposition() === SessionPromptDisposition.Steer
|
|
84
|
+
? this.command.targetCommandId
|
|
85
|
+
: this.command.commandId;
|
|
75
86
|
recordEvent = (event) => {
|
|
76
87
|
if (event.sessionId !== this.command.sessionId ||
|
|
77
88
|
("commandId" in event && event.commandId !== this.command.commandId)) {
|
|
@@ -86,35 +97,33 @@ export class ActiveRuntimeTurn {
|
|
|
86
97
|
}
|
|
87
98
|
return event;
|
|
88
99
|
};
|
|
89
|
-
recordSteeringPrompt = (command) => {
|
|
90
|
-
return (this.#dispatch.kind === "running" &&
|
|
91
|
-
command.sessionId === this.command.sessionId &&
|
|
92
|
-
command.targetCommandId === this.command.commandId);
|
|
93
|
-
};
|
|
94
100
|
snapshot = () => {
|
|
95
|
-
if (this.#
|
|
101
|
+
if (!this.#started()) {
|
|
96
102
|
return null;
|
|
97
103
|
}
|
|
98
104
|
return {
|
|
99
105
|
commandId: decodeIdentifier(this.command.commandId),
|
|
100
|
-
epoch: this
|
|
106
|
+
epoch: this.epoch,
|
|
101
107
|
interaction: this.#interaction,
|
|
102
108
|
sequence: this.#sequence,
|
|
103
109
|
state: "running",
|
|
104
110
|
};
|
|
105
111
|
};
|
|
106
|
-
matches = (cancellation) => cancellation.commandId === this.command.commandId && cancellation.sessionId === this.command.sessionId;
|
|
107
112
|
matchesInteraction = (interactionId, sessionId) => this.command.sessionId === sessionId && this.#interaction?.interactionId === interactionId;
|
|
113
|
+
/**
|
|
114
|
+
* Before the command starts, cancellation withdraws it by aborting its own admission and preparation. Once it
|
|
115
|
+
* started, the Agent execution it belongs to must be asked to stop.
|
|
116
|
+
*/
|
|
108
117
|
requestCancellation = () => {
|
|
109
118
|
if (this.#cancellationRequested) {
|
|
110
119
|
return { kind: "already-requested" };
|
|
111
120
|
}
|
|
112
121
|
this.#cancellationRequested = true;
|
|
113
|
-
if (this.#
|
|
114
|
-
this.#controller.abort(new Error("The
|
|
122
|
+
if (!this.#started()) {
|
|
123
|
+
this.#controller.abort(new Error("The Agent turn was cancelled before it started"));
|
|
115
124
|
return { kind: "pending" };
|
|
116
125
|
}
|
|
117
|
-
return { kind: "running", execution: this
|
|
126
|
+
return { kind: "running", execution: this.execution() };
|
|
118
127
|
};
|
|
119
128
|
cancellationRequested = () => this.#cancellationRequested;
|
|
120
129
|
get signal() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-turn.js","sourceRoot":"","sources":["../../../../src/engine/session/turn/active-turn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACH,gBAAgB,EAEhB,kCAAkC,EAClC,iCAAiC,EACjC,iCAAiC,EACjC,gCAAgC,
|
|
1
|
+
{"version":3,"file":"active-turn.js","sourceRoot":"","sources":["../../../../src/engine/session/turn/active-turn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAA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AAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC,CAAC;YACpF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC/B,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;IAC5D,CAAC,CAAC;IAEO,qBAAqB,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAE5E,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IACnC,CAAC;IAED,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;IAClC,CAAC;CACJ"}
|
|
@@ -31,14 +31,18 @@ export declare class ExecutionReceipts {
|
|
|
31
31
|
readonly hasStarted: (commandId: string, sessionId: string) => boolean;
|
|
32
32
|
/** Reserves an unseen command for cancellation before a delayed prompt can claim its identity. */
|
|
33
33
|
readonly recordCancellationBeforeAdmission: (commandId: string, sessionId: string) => SessionEventPayload | undefined;
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Receipts follow their command's recorded lifecycle. `prompt.started` is recorded where the command is handed
|
|
36
|
+
* to the Agent, so the started mark and the event clients see are one transition; a terminal event settles the
|
|
37
|
+
* receipt. Nothing else marks a command started.
|
|
38
|
+
*/
|
|
39
|
+
readonly record: (event: SessionLiveEvent) => void;
|
|
35
40
|
readonly recover: () => readonly {
|
|
36
41
|
readonly sessionId: string;
|
|
37
42
|
readonly event: SessionEventPayload;
|
|
38
43
|
readonly recordedAt: string;
|
|
39
44
|
}[];
|
|
40
45
|
readonly claimExecution: (commandId: string, sessionId: string, commandJson: string) => RuntimeExecutionReceipt;
|
|
41
|
-
readonly markExecutionStarted: (commandId: string) => void;
|
|
42
46
|
/** Only commands without a terminal result can still be cancelled. */
|
|
43
47
|
readonly findUnsettledAttemptId: (commandId: string, sessionId: string) => string | null;
|
|
44
48
|
readonly isTerminalExecution: (commandId: string, sessionId: string) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-receipts.d.ts","sourceRoot":"","sources":["../../../../src/engine/session/turn/execution-receipts.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"execution-receipts.d.ts","sourceRoot":"","sources":["../../../../src/engine/session/turn/execution-receipts.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,eAAe,EAIpB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACxB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;AAI9F,MAAM,MAAM,uBAAuB,GAC7B,QAAQ,CAAC;IACL,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,UAAU,CAAC;CACpB,CAAC,GACF,QAAQ,CAAC;IACL,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAC;CAC5C,CAAC,GACF;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAmDnC,qBAAa,iBAAiB;;IAO1B,YAAY,KAAK,EAAE,qBAAqB,EAAE,OAAO,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAsB,EAW3F;IAwCD,QAAQ,CAAC,aAAa,QAAO,IAAI,CAE/B;IACF,QAAQ,CAAC,OAAO,cAAe,MAAM,KAAG,mBAAmB,GAAG,SAAS,CAIrE;IACF,oGAAoG;IACpG,QAAQ,CAAC,QAAQ,cAAe,MAAM,aAAa,MAAM,KAAG,eAAe,CAwBzE;IACF;;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