@moxt-ai/mobius 0.0.388 → 0.0.390
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-Z4WUPVBL.js → chunk-KWRP3J26.js} +2 -2
- package/dist/{chunk-Z4WUPVBL.js.map → chunk-KWRP3J26.js.map} +1 -1
- package/dist/{chunk-7BSIM5AK.js → chunk-ZW763PCS.js} +181 -122
- package/dist/{chunk-7BSIM5AK.js.map → chunk-ZW763PCS.js.map} +4 -4
- package/dist/{cli-O57WJIFN.js → cli-K2JBHPL5.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 +0 -1
- package/dist/engine/runtime/command/registry/prompt.js.map +1 -1
- package/dist/engine/runtime/command/registry/session.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/session.js +1 -2
- package/dist/engine/runtime/command/registry/session.js.map +1 -1
- package/dist/engine/session/api/session-api.d.ts +6 -3
- 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 +16 -4
- package/dist/engine/session/live/agent-session.d.ts.map +1 -1
- package/dist/engine/session/live/agent-session.js +45 -37
- package/dist/engine/session/live/agent-session.js.map +1 -1
- package/dist/engine/session/live/configuration-revision.d.ts +11 -0
- package/dist/engine/session/live/configuration-revision.d.ts.map +1 -0
- package/dist/engine/session/live/configuration-revision.js +24 -0
- package/dist/engine/session/live/configuration-revision.js.map +1 -0
- package/dist/engine/session/manager/session-manager.d.ts +6 -1
- package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
- package/dist/engine/session/manager/session-manager.js +38 -34
- package/dist/engine/session/manager/session-manager.js.map +1 -1
- package/dist/engine/session/prompt/apply-session-configuration.d.ts.map +1 -1
- package/dist/engine/session/prompt/apply-session-configuration.js +1 -2
- package/dist/engine/session/prompt/apply-session-configuration.js.map +1 -1
- package/dist/engine/session/prompt/execute-prompt.d.ts +1 -2
- package/dist/engine/session/prompt/execute-prompt.d.ts.map +1 -1
- package/dist/engine/session/prompt/execute-prompt.js +7 -4
- package/dist/engine/session/prompt/execute-prompt.js.map +1 -1
- package/dist/engine/session/turn/active-executions.d.ts +27 -10
- package/dist/engine/session/turn/active-executions.d.ts.map +1 -1
- package/dist/engine/session/turn/active-executions.js +78 -22
- package/dist/engine/session/turn/active-executions.js.map +1 -1
- package/dist/engine/session/turn/active-turn.d.ts +0 -2
- package/dist/engine/session/turn/active-turn.d.ts.map +1 -1
- package/dist/engine/session/turn/active-turn.js +0 -2
- package/dist/engine/session/turn/active-turn.js.map +1 -1
- package/dist/engine/session/turn/session-execution.d.ts +0 -2
- package/dist/engine/session/turn/session-execution.d.ts.map +1 -1
- package/dist/engine/session/turn/session-execution.js +0 -2
- 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 +1 -1
- 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-O57WJIFN.js.map → cli-K2JBHPL5.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-KWRP3J26.js";
|
|
7
7
|
|
|
8
8
|
// src/engine/runtime/relay/runtime-revocation.ts
|
|
9
9
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -85244,7 +85244,7 @@ var PreparedSession = class {
|
|
|
85244
85244
|
prompted;
|
|
85245
85245
|
restored;
|
|
85246
85246
|
configurationRevision;
|
|
85247
|
-
constructor(agentName, agentVersion, capabilities, commands, configOptions, prompted, restored,
|
|
85247
|
+
constructor(agentName, agentVersion, capabilities, commands, configOptions, prompted, restored, configurationRevision2) {
|
|
85248
85248
|
this.agentName = agentName;
|
|
85249
85249
|
this.agentVersion = agentVersion;
|
|
85250
85250
|
this.capabilities = capabilities;
|
|
@@ -85252,7 +85252,7 @@ var PreparedSession = class {
|
|
|
85252
85252
|
this.configOptions = configOptions;
|
|
85253
85253
|
this.prompted = prompted;
|
|
85254
85254
|
this.restored = restored;
|
|
85255
|
-
this.configurationRevision =
|
|
85255
|
+
this.configurationRevision = configurationRevision2;
|
|
85256
85256
|
}
|
|
85257
85257
|
};
|
|
85258
85258
|
var AgentSettingsSnapshot = class {
|
|
@@ -86026,21 +86026,21 @@ var SqliteSessionStore = class {
|
|
|
86026
86026
|
};
|
|
86027
86027
|
};
|
|
86028
86028
|
|
|
86029
|
-
// src/engine/session/live/
|
|
86030
|
-
|
|
86031
|
-
var
|
|
86032
|
-
|
|
86033
|
-
|
|
86034
|
-
|
|
86035
|
-
|
|
86036
|
-
|
|
86037
|
-
|
|
86038
|
-
|
|
86039
|
-
|
|
86040
|
-
|
|
86041
|
-
|
|
86042
|
-
|
|
86043
|
-
|
|
86029
|
+
// src/engine/session/live/configuration-revision.ts
|
|
86030
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
86031
|
+
var configurationRevision = (options) => {
|
|
86032
|
+
const canonical = options.map(
|
|
86033
|
+
(option) => JSON.stringify(
|
|
86034
|
+
option.type === "boolean" ? [option.id, option.type, option.category, option.booleanValue] : [
|
|
86035
|
+
option.id,
|
|
86036
|
+
option.type,
|
|
86037
|
+
option.category,
|
|
86038
|
+
option.currentValue,
|
|
86039
|
+
option.values.map((value) => value.value).toSorted()
|
|
86040
|
+
]
|
|
86041
|
+
)
|
|
86042
|
+
).toSorted();
|
|
86043
|
+
return createHash6("sha256").update(JSON.stringify(canonical)).digest("hex");
|
|
86044
86044
|
};
|
|
86045
86045
|
|
|
86046
86046
|
// src/engine/session/live/session-restore.ts
|
|
@@ -86192,6 +86192,7 @@ async function restoreSession(session, signal, recovery, origin) {
|
|
|
86192
86192
|
}
|
|
86193
86193
|
|
|
86194
86194
|
// src/engine/session/live/agent-session.ts
|
|
86195
|
+
var SESSION_CONTROL_COMMAND_ID = "session-control";
|
|
86195
86196
|
var AgentSession = class _AgentSession {
|
|
86196
86197
|
// The restore surface: AgentSessionRestore members expose private state to
|
|
86197
86198
|
// session-restore.ts only. The class keeps the fields private.
|
|
@@ -86236,6 +86237,7 @@ var AgentSession = class _AgentSession {
|
|
|
86236
86237
|
#cwd;
|
|
86237
86238
|
#environment;
|
|
86238
86239
|
#getObserver;
|
|
86240
|
+
#agentCommand;
|
|
86239
86241
|
#interactions;
|
|
86240
86242
|
#mobiusSessionId;
|
|
86241
86243
|
#metrics;
|
|
@@ -86244,7 +86246,6 @@ var AgentSession = class _AgentSession {
|
|
|
86244
86246
|
#agentVersion = "";
|
|
86245
86247
|
#capabilities = unsupportedSessionCapabilities();
|
|
86246
86248
|
#commands = [];
|
|
86247
|
-
#configRevision = crypto.randomUUID();
|
|
86248
86249
|
#configurationChanges = new SerialTaskQueue();
|
|
86249
86250
|
#configOptions = [];
|
|
86250
86251
|
#sessionConfigurations = new SessionConfigurations();
|
|
@@ -86256,8 +86257,8 @@ var AgentSession = class _AgentSession {
|
|
|
86256
86257
|
#restored = false;
|
|
86257
86258
|
#sessionTitle = null;
|
|
86258
86259
|
#sessionUpdatedAt = "";
|
|
86259
|
-
|
|
86260
|
-
|
|
86260
|
+
constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, agentCommand, store, metrics, adapter, externalize) {
|
|
86261
|
+
this.#agentCommand = () => agentCommand(this.#mobiusSessionId);
|
|
86261
86262
|
this.#additionalDirectories = [...additionalDirectories];
|
|
86262
86263
|
this.#adapter = adapter;
|
|
86263
86264
|
this.#agentId = agent.id;
|
|
@@ -86272,7 +86273,7 @@ var AgentSession = class _AgentSession {
|
|
|
86272
86273
|
cwd: () => this.#cwd,
|
|
86273
86274
|
getToolCall: (toolCallId) => this.#store.events.getToolCall(this.#mobiusSessionId, toolCallId),
|
|
86274
86275
|
sessionId: () => this.#mobiusSessionId,
|
|
86275
|
-
commandId: () => this.#
|
|
86276
|
+
commandId: () => this.#agentCommand() ?? SESSION_CONTROL_COMMAND_ID,
|
|
86276
86277
|
assertNativeSession: this.assertNativeSession,
|
|
86277
86278
|
observer: getObserver,
|
|
86278
86279
|
recordSessionEvent: this.recordLifecycleEvent
|
|
@@ -86307,7 +86308,7 @@ var AgentSession = class _AgentSession {
|
|
|
86307
86308
|
}
|
|
86308
86309
|
};
|
|
86309
86310
|
}
|
|
86310
|
-
static async #start(options, getObserver, store, initialize, metrics, adapter) {
|
|
86311
|
+
static async #start(options, getObserver, agentCommand, store, initialize, metrics, adapter) {
|
|
86311
86312
|
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
86312
86313
|
await metrics.measure(
|
|
86313
86314
|
"executable-validation",
|
|
@@ -86321,6 +86322,7 @@ var AgentSession = class _AgentSession {
|
|
|
86321
86322
|
options.additionalDirectories,
|
|
86322
86323
|
options.sessionId,
|
|
86323
86324
|
getObserver,
|
|
86325
|
+
agentCommand,
|
|
86324
86326
|
store,
|
|
86325
86327
|
metrics,
|
|
86326
86328
|
adapter,
|
|
@@ -86347,9 +86349,10 @@ var AgentSession = class _AgentSession {
|
|
|
86347
86349
|
}
|
|
86348
86350
|
throw new AcpExecutionError("ACP agent initialization failed");
|
|
86349
86351
|
}
|
|
86350
|
-
static start = async (options, recovery, getObserver, store, metrics, adapter, capabilities = unsupportedSessionCapabilities()) => await _AgentSession.#start(
|
|
86352
|
+
static start = async (options, recovery, getObserver, agentCommand, store, metrics, adapter, capabilities = unsupportedSessionCapabilities()) => await _AgentSession.#start(
|
|
86351
86353
|
options,
|
|
86352
86354
|
getObserver,
|
|
86355
|
+
agentCommand,
|
|
86353
86356
|
store,
|
|
86354
86357
|
async (runtime) => {
|
|
86355
86358
|
runtime.#capabilities = capabilities;
|
|
@@ -86360,8 +86363,6 @@ var AgentSession = class _AgentSession {
|
|
|
86360
86363
|
);
|
|
86361
86364
|
belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
|
|
86362
86365
|
usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
|
|
86363
|
-
canRebind = () => !this.#prompted && !this.#turn.running;
|
|
86364
|
-
hasRunningTurn = () => this.#turn.running;
|
|
86365
86366
|
writeStoredSession = (updatedAt) => {
|
|
86366
86367
|
this.#store.write(
|
|
86367
86368
|
new StoredSession(
|
|
@@ -86453,7 +86454,7 @@ var AgentSession = class _AgentSession {
|
|
|
86453
86454
|
this.#configOptions,
|
|
86454
86455
|
this.#prompted,
|
|
86455
86456
|
this.#restored,
|
|
86456
|
-
this.#
|
|
86457
|
+
configurationRevision(this.#configOptions)
|
|
86457
86458
|
);
|
|
86458
86459
|
ensureHistoryLoaded = async (signal) => {
|
|
86459
86460
|
if (!this.#capabilities.loadSession) {
|
|
@@ -86638,38 +86639,45 @@ var AgentSession = class _AgentSession {
|
|
|
86638
86639
|
this.#mobiusSessionId = sessionId;
|
|
86639
86640
|
};
|
|
86640
86641
|
#applyConfiguration = async (selection, signal) => {
|
|
86641
|
-
const
|
|
86642
|
+
const before = this.#configOptions;
|
|
86642
86643
|
const configured = await this.#writeNativeHistory(
|
|
86643
86644
|
async () => await this.#adapter.configureSession({ ...this.#target(), selection, signal })
|
|
86644
86645
|
);
|
|
86645
|
-
if (this.#
|
|
86646
|
+
if (this.#configOptions === before) {
|
|
86646
86647
|
this.#configOptions = configured;
|
|
86647
|
-
this.#configRevision = crypto.randomUUID();
|
|
86648
86648
|
await this.#publishConfiguration();
|
|
86649
86649
|
}
|
|
86650
86650
|
};
|
|
86651
|
-
// The revision check and Agent mutation share one queue
|
|
86651
|
+
// The revision check and Agent mutation share one queue with the settings the Runtime applies itself.
|
|
86652
86652
|
// A lost response may have committed: reread after a conflict, never replay an edit blindly.
|
|
86653
86653
|
configure = async (options) => this.#configurationChanges.run(async (signal) => {
|
|
86654
|
-
if (options.expectedConfigurationRevision !==
|
|
86654
|
+
if (options.expectedConfigurationRevision !== configurationRevision(this.#configOptions)) {
|
|
86655
86655
|
throw new AcpExecutionError(
|
|
86656
86656
|
"Session settings changed. Review the current settings before applying your selection again.",
|
|
86657
86657
|
{},
|
|
86658
86658
|
"session_configuration_conflict"
|
|
86659
86659
|
);
|
|
86660
86660
|
}
|
|
86661
|
+
return await this.#change(options, signal);
|
|
86662
|
+
}, options.signal);
|
|
86663
|
+
/** Applies a setting the Runtime owns, whatever the configuration's current revision. */
|
|
86664
|
+
applyConfiguration = async (change) => this.#configurationChanges.run(async (signal) => await this.#change(change, signal), change.signal);
|
|
86665
|
+
#change = async (change, signal) => {
|
|
86661
86666
|
await this.#applyConfiguration(
|
|
86662
|
-
|
|
86667
|
+
change.valueType === "boolean" ? { type: "boolean", configId: change.configId, booleanValue: change.booleanValue } : { type: "select", configId: change.configId, value: change.value },
|
|
86663
86668
|
signal
|
|
86664
86669
|
);
|
|
86665
|
-
const applied = this.#configOptions.find((option) => option.id ===
|
|
86670
|
+
const applied = this.#configOptions.find((option) => option.id === change.configId);
|
|
86666
86671
|
if (applied === void 0) {
|
|
86667
86672
|
throw new AcpExecutionError("The requested ACP configuration option is unavailable");
|
|
86668
86673
|
}
|
|
86669
86674
|
this.#sessionConfigurations.select(applied);
|
|
86670
86675
|
this.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
|
|
86671
|
-
return {
|
|
86672
|
-
|
|
86676
|
+
return {
|
|
86677
|
+
configOptions: this.#configOptions,
|
|
86678
|
+
configurationRevision: configurationRevision(this.#configOptions)
|
|
86679
|
+
};
|
|
86680
|
+
};
|
|
86673
86681
|
#publishConfiguration = async () => {
|
|
86674
86682
|
const event = this.#store.events.append(this.#mobiusSessionId, {
|
|
86675
86683
|
type: "acp",
|
|
@@ -86692,7 +86700,8 @@ var AgentSession = class _AgentSession {
|
|
|
86692
86700
|
cwd: this.#cwd,
|
|
86693
86701
|
additionalDirectories: this.#additionalDirectories
|
|
86694
86702
|
});
|
|
86695
|
-
prompt
|
|
86703
|
+
/** Loads what the Agent needs before it can receive a prompt; the Agent does not receive it yet. */
|
|
86704
|
+
preparePrompt = async (signal) => {
|
|
86696
86705
|
if (!this.#capabilities.loadSession && this.#sessionLoad.kind === "not-requested") {
|
|
86697
86706
|
this.#sessionLoad = {
|
|
86698
86707
|
kind: "loaded",
|
|
@@ -86708,8 +86717,14 @@ var AgentSession = class _AgentSession {
|
|
|
86708
86717
|
};
|
|
86709
86718
|
}
|
|
86710
86719
|
if (this.#capabilities.loadSession && this.#sessionLoad.kind !== "execution-only") {
|
|
86711
|
-
await this.#completedHistory(
|
|
86720
|
+
await this.#completedHistory(signal);
|
|
86712
86721
|
}
|
|
86722
|
+
};
|
|
86723
|
+
/**
|
|
86724
|
+
* Hands a prepared prompt to the Agent. Precondition: `preparePrompt` completed and the Session's execution
|
|
86725
|
+
* authority records this command as started.
|
|
86726
|
+
*/
|
|
86727
|
+
prompt = async (options) => {
|
|
86713
86728
|
validatePromptContent(options, this.#capabilities);
|
|
86714
86729
|
options.signal.throwIfAborted();
|
|
86715
86730
|
if (this.#sessionTitle === null || this.#sessionTitle.length === 0) {
|
|
@@ -86717,8 +86732,6 @@ var AgentSession = class _AgentSession {
|
|
|
86717
86732
|
}
|
|
86718
86733
|
this.#prompted = true;
|
|
86719
86734
|
this.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
|
|
86720
|
-
const running = new RunningAgentTurn(options.commandId);
|
|
86721
|
-
this.#turn = running;
|
|
86722
86735
|
const lifecycle = options.lifecycle;
|
|
86723
86736
|
if (lifecycle !== void 0) {
|
|
86724
86737
|
await this.recordLifecycleEvent({
|
|
@@ -86776,10 +86789,12 @@ var AgentSession = class _AgentSession {
|
|
|
86776
86789
|
throw error62;
|
|
86777
86790
|
}
|
|
86778
86791
|
throw failure2;
|
|
86779
|
-
} finally {
|
|
86780
|
-
this.#turn = new IdleAgentTurn();
|
|
86781
86792
|
}
|
|
86782
86793
|
};
|
|
86794
|
+
/**
|
|
86795
|
+
* Adds a steering prompt to the prompt the Agent holds. Precondition: the Session's execution authority accepts
|
|
86796
|
+
* steering into `options.targetCommandId`.
|
|
86797
|
+
*/
|
|
86783
86798
|
steer = async (options) => {
|
|
86784
86799
|
if (!this.#capabilities.steering) {
|
|
86785
86800
|
throw new AcpExecutionError(
|
|
@@ -86788,9 +86803,6 @@ var AgentSession = class _AgentSession {
|
|
|
86788
86803
|
"steering_unsupported"
|
|
86789
86804
|
);
|
|
86790
86805
|
}
|
|
86791
|
-
if (!this.#turn.running || this.#turn.commandId !== options.targetCommandId) {
|
|
86792
|
-
throw new AcpExecutionError("The target turn is no longer active", {}, "steering_target_unavailable");
|
|
86793
|
-
}
|
|
86794
86806
|
validatePromptContent(options, this.#capabilities);
|
|
86795
86807
|
options.signal.throwIfAborted();
|
|
86796
86808
|
const lifecycle = options.lifecycle;
|
|
@@ -86850,7 +86862,7 @@ var AgentSession = class _AgentSession {
|
|
|
86850
86862
|
signal.throwIfAborted();
|
|
86851
86863
|
await this.#interactions.cancelPendingInteractions();
|
|
86852
86864
|
signal.throwIfAborted();
|
|
86853
|
-
if (this.#
|
|
86865
|
+
if (this.#agentCommand() !== void 0) {
|
|
86854
86866
|
return await this.#adapter.cancel({ ...this.#target(), signal });
|
|
86855
86867
|
}
|
|
86856
86868
|
return "retained";
|
|
@@ -86895,7 +86907,6 @@ var AgentSession = class _AgentSession {
|
|
|
86895
86907
|
this.#configOptions = event.kind === "configuration" ? event.configOptions : this.#configOptions.map(
|
|
86896
86908
|
(option) => option.category === "mode" ? { ...option, currentValue: event.modeId } : option
|
|
86897
86909
|
);
|
|
86898
|
-
this.#configRevision = crypto.randomUUID();
|
|
86899
86910
|
this.#captureSelectedConfigurationValues();
|
|
86900
86911
|
}
|
|
86901
86912
|
if (this.#sessionLoad.kind === "capturing") {
|
|
@@ -86978,7 +86989,6 @@ var AgentSession = class _AgentSession {
|
|
|
86978
86989
|
openSessionWithReplay = async (signal) => (await this.#loadSession(signal)).opened;
|
|
86979
86990
|
setConfigOptions(options) {
|
|
86980
86991
|
this.#configOptions = options;
|
|
86981
|
-
this.#configRevision = crypto.randomUUID();
|
|
86982
86992
|
}
|
|
86983
86993
|
setNativeHistoryOwnership(ownership) {
|
|
86984
86994
|
this.#nativeHistoryOwnership = ownership;
|
|
@@ -87000,7 +87010,7 @@ var AgentSession = class _AgentSession {
|
|
|
87000
87010
|
emitConfigUpdate = async () => {
|
|
87001
87011
|
await this.#getObserver().onConfig({
|
|
87002
87012
|
configOptions: this.#configOptions,
|
|
87003
|
-
configurationRevision: this.#
|
|
87013
|
+
configurationRevision: configurationRevision(this.#configOptions),
|
|
87004
87014
|
kind: SESSION_CONFIG_UPDATED_KIND,
|
|
87005
87015
|
requestId: `agent-update-${crypto.randomUUID()}`,
|
|
87006
87016
|
sessionId: this.#mobiusSessionId
|
|
@@ -87031,32 +87041,83 @@ function nativeSessionQuery(options) {
|
|
|
87031
87041
|
// src/engine/session/turn/active-executions.ts
|
|
87032
87042
|
var ActiveExecutions = class {
|
|
87033
87043
|
#entries = /* @__PURE__ */ new Map();
|
|
87034
|
-
|
|
87035
|
-
|
|
87036
|
-
|
|
87037
|
-
|
|
87038
|
-
|
|
87039
|
-
|
|
87040
|
-
|
|
87041
|
-
|
|
87042
|
-
|
|
87043
|
-
|
|
87044
|
-
|
|
87045
|
-
|
|
87044
|
+
#statusChanged;
|
|
87045
|
+
constructor(statusChanged) {
|
|
87046
|
+
this.#statusChanged = statusChanged;
|
|
87047
|
+
}
|
|
87048
|
+
status = (sessionId) => {
|
|
87049
|
+
const execution = this.#entries.get(sessionId);
|
|
87050
|
+
return execution === void 0 ? { kind: "idle" } : { commandId: execution.commandId, kind: "working" };
|
|
87051
|
+
};
|
|
87052
|
+
isBusy = (sessionId) => this.#entries.has(sessionId);
|
|
87053
|
+
/** A steering prompt can join only the named execution while the Agent holds it and no one is stopping it. */
|
|
87054
|
+
acceptsSteering = (sessionId, targetCommandId) => {
|
|
87055
|
+
const execution = this.#entries.get(sessionId);
|
|
87056
|
+
return execution?.commandId === targetCommandId && execution.phase === "started" && execution.cancellation.kind === "none";
|
|
87057
|
+
};
|
|
87058
|
+
/** The command whose prompt the Session's Agent holds, if any. */
|
|
87059
|
+
agentCommand = (sessionId) => {
|
|
87060
|
+
const execution = this.#entries.get(sessionId);
|
|
87061
|
+
return execution?.phase === "started" ? execution.commandId : void 0;
|
|
87062
|
+
};
|
|
87063
|
+
cancellationRequested = (sessionId, commandId) => {
|
|
87064
|
+
const execution = this.#entries.get(sessionId);
|
|
87065
|
+
return execution?.commandId === commandId && execution.cancellation.kind === "requested";
|
|
87066
|
+
};
|
|
87067
|
+
cancellation = (sessionId) => {
|
|
87068
|
+
const cancellation = this.#entries.get(sessionId)?.cancellation;
|
|
87069
|
+
return cancellation?.kind === "requested" ? cancellation.completion : void 0;
|
|
87070
|
+
};
|
|
87071
|
+
begin = (sessionId, commandId) => {
|
|
87072
|
+
if (this.#entries.has(sessionId)) {
|
|
87073
|
+
throw new Error("A Session executes one command at a time");
|
|
87074
|
+
}
|
|
87075
|
+
this.#entries.set(sessionId, { commandId, phase: "preparing", cancellation: { kind: "none" } });
|
|
87076
|
+
this.#statusChanged(sessionId, this.status(sessionId));
|
|
87077
|
+
};
|
|
87078
|
+
/** The Agent receives the prompt. A cancelled execution must not start. */
|
|
87079
|
+
start = (sessionId, commandId) => {
|
|
87080
|
+
const execution = this.#entries.get(sessionId);
|
|
87081
|
+
if (execution?.commandId !== commandId || execution.phase !== "preparing") {
|
|
87082
|
+
throw new Error("Only the Session's preparing execution can start");
|
|
87083
|
+
}
|
|
87084
|
+
if (execution.cancellation.kind !== "none") {
|
|
87085
|
+
throw new Error("A cancelled execution cannot start");
|
|
87086
|
+
}
|
|
87087
|
+
this.#entries.set(sessionId, { ...execution, phase: "started" });
|
|
87088
|
+
};
|
|
87089
|
+
settle = (sessionId, commandId) => {
|
|
87090
|
+
const execution = this.#entries.get(sessionId);
|
|
87091
|
+
if (execution?.commandId === commandId) {
|
|
87092
|
+
this.#entries.set(sessionId, { ...execution, phase: "settled" });
|
|
87093
|
+
}
|
|
87094
|
+
};
|
|
87095
|
+
/**
|
|
87096
|
+
* Records a cancellation of the named execution and asks `stop` to end it once. Another command's cancellation,
|
|
87097
|
+
* or one for an idle Session, has nothing to stop. A cancelled execution that has not started never starts.
|
|
87098
|
+
*/
|
|
87099
|
+
cancel = (sessionId, commandId, stop) => {
|
|
87100
|
+
const execution = this.#entries.get(sessionId);
|
|
87101
|
+
if (execution?.commandId !== commandId) {
|
|
87046
87102
|
return Promise.resolve();
|
|
87047
87103
|
}
|
|
87048
|
-
if (
|
|
87049
|
-
return
|
|
87104
|
+
if (execution.cancellation.kind === "requested") {
|
|
87105
|
+
return execution.cancellation.completion;
|
|
87050
87106
|
}
|
|
87051
87107
|
const completion = Promise.withResolvers();
|
|
87052
|
-
this.#entries.set(
|
|
87108
|
+
this.#entries.set(sessionId, {
|
|
87109
|
+
...execution,
|
|
87110
|
+
cancellation: { kind: "requested", completion: completion.promise }
|
|
87111
|
+
});
|
|
87053
87112
|
void (async () => await stop())().then(completion.resolve, completion.reject);
|
|
87054
87113
|
return completion.promise;
|
|
87055
87114
|
};
|
|
87056
|
-
finish = (
|
|
87057
|
-
if (this.
|
|
87058
|
-
|
|
87115
|
+
finish = (sessionId, commandId) => {
|
|
87116
|
+
if (this.#entries.get(sessionId)?.commandId !== commandId) {
|
|
87117
|
+
return;
|
|
87059
87118
|
}
|
|
87119
|
+
this.#entries.delete(sessionId);
|
|
87120
|
+
this.#statusChanged(sessionId, this.status(sessionId));
|
|
87060
87121
|
};
|
|
87061
87122
|
};
|
|
87062
87123
|
|
|
@@ -87071,7 +87132,7 @@ var SessionManager2 = class {
|
|
|
87071
87132
|
touch: (runtime) => this.#processes.touch(runtime),
|
|
87072
87133
|
changed: () => this.#processes.notifyChanged()
|
|
87073
87134
|
});
|
|
87074
|
-
#executions
|
|
87135
|
+
#executions;
|
|
87075
87136
|
#agentSettingsObserver = new NullSessionObserver();
|
|
87076
87137
|
#nativeOperations = /* @__PURE__ */ new Set();
|
|
87077
87138
|
#sessionClosures = /* @__PURE__ */ new Map();
|
|
@@ -87080,7 +87141,6 @@ var SessionManager2 = class {
|
|
|
87080
87141
|
#closedSessions = /* @__PURE__ */ new Set();
|
|
87081
87142
|
#store;
|
|
87082
87143
|
#sessionIdentity;
|
|
87083
|
-
#onSessionStatusChanged;
|
|
87084
87144
|
#onSessionClosed;
|
|
87085
87145
|
#timer;
|
|
87086
87146
|
#observer;
|
|
@@ -87097,7 +87157,9 @@ var SessionManager2 = class {
|
|
|
87097
87157
|
this.#processes = processes;
|
|
87098
87158
|
this.#store = store;
|
|
87099
87159
|
this.#sessionIdentity = sessionIdentity;
|
|
87100
|
-
this.#
|
|
87160
|
+
this.#executions = new ActiveExecutions(
|
|
87161
|
+
(sessionId, status) => onSessionStatusChanged({ kind: "session.status.changed", sessionId, status })
|
|
87162
|
+
);
|
|
87101
87163
|
this.#onSessionClosed = onSessionClosed;
|
|
87102
87164
|
this.#timer = timer;
|
|
87103
87165
|
}
|
|
@@ -87198,6 +87260,7 @@ var SessionManager2 = class {
|
|
|
87198
87260
|
effectiveOptions,
|
|
87199
87261
|
recovery,
|
|
87200
87262
|
() => this.#observer,
|
|
87263
|
+
this.#executions.agentCommand,
|
|
87201
87264
|
this.#store,
|
|
87202
87265
|
metrics,
|
|
87203
87266
|
options.adapter,
|
|
@@ -87220,6 +87283,7 @@ var SessionManager2 = class {
|
|
|
87220
87283
|
options,
|
|
87221
87284
|
recovery,
|
|
87222
87285
|
() => this.#observer,
|
|
87286
|
+
this.#executions.agentCommand,
|
|
87223
87287
|
this.#store,
|
|
87224
87288
|
metrics,
|
|
87225
87289
|
options.adapter,
|
|
@@ -87239,6 +87303,7 @@ var SessionManager2 = class {
|
|
|
87239
87303
|
options,
|
|
87240
87304
|
recovery,
|
|
87241
87305
|
() => this.#observer,
|
|
87306
|
+
this.#executions.agentCommand,
|
|
87242
87307
|
this.#store,
|
|
87243
87308
|
unmeasuredOperationMetrics,
|
|
87244
87309
|
options.adapter,
|
|
@@ -87253,11 +87318,10 @@ var SessionManager2 = class {
|
|
|
87253
87318
|
}
|
|
87254
87319
|
if (desired.type === "boolean") {
|
|
87255
87320
|
if (current.booleanValue !== desired.booleanValue) {
|
|
87256
|
-
await runtime.
|
|
87321
|
+
await runtime.applyConfiguration({
|
|
87257
87322
|
...options,
|
|
87258
87323
|
booleanValue: desired.booleanValue,
|
|
87259
87324
|
configId: desired.id,
|
|
87260
|
-
expectedConfigurationRevision: null,
|
|
87261
87325
|
requestId: `execution-prepare-${desired.id}`,
|
|
87262
87326
|
value: "",
|
|
87263
87327
|
valueType: "boolean"
|
|
@@ -87266,11 +87330,10 @@ var SessionManager2 = class {
|
|
|
87266
87330
|
continue;
|
|
87267
87331
|
}
|
|
87268
87332
|
if (current.currentValue !== desired.currentValue && current.values.some((value) => value.value === desired.currentValue)) {
|
|
87269
|
-
await runtime.
|
|
87333
|
+
await runtime.applyConfiguration({
|
|
87270
87334
|
...options,
|
|
87271
87335
|
booleanValue: false,
|
|
87272
87336
|
configId: desired.id,
|
|
87273
|
-
expectedConfigurationRevision: null,
|
|
87274
87337
|
requestId: `execution-prepare-${desired.id}`,
|
|
87275
87338
|
value: desired.currentValue,
|
|
87276
87339
|
valueType: "select"
|
|
@@ -87310,6 +87373,7 @@ var SessionManager2 = class {
|
|
|
87310
87373
|
options,
|
|
87311
87374
|
recovery,
|
|
87312
87375
|
() => this.#observer,
|
|
87376
|
+
this.#executions.agentCommand,
|
|
87313
87377
|
this.#store,
|
|
87314
87378
|
unmeasuredOperationMetrics,
|
|
87315
87379
|
options.adapter,
|
|
@@ -87368,7 +87432,7 @@ var SessionManager2 = class {
|
|
|
87368
87432
|
}
|
|
87369
87433
|
return runtime3.prepared();
|
|
87370
87434
|
}
|
|
87371
|
-
if (
|
|
87435
|
+
if (existing.prepared().prompted || this.#executions.isBusy(options2.sessionId)) {
|
|
87372
87436
|
throw new AcpExecutionError(
|
|
87373
87437
|
"The agent or workspace cannot change after a conversation has started",
|
|
87374
87438
|
{},
|
|
@@ -87400,6 +87464,7 @@ var SessionManager2 = class {
|
|
|
87400
87464
|
},
|
|
87401
87465
|
{ kind: "interactive-only" },
|
|
87402
87466
|
() => this.#agentSettingsObserver,
|
|
87467
|
+
() => void 0,
|
|
87403
87468
|
new MemorySessionStore(),
|
|
87404
87469
|
unmeasuredOperationMetrics,
|
|
87405
87470
|
options2.adapter
|
|
@@ -87412,11 +87477,10 @@ var SessionManager2 = class {
|
|
|
87412
87477
|
(option) => option.id === "model" || option.category === "model"
|
|
87413
87478
|
);
|
|
87414
87479
|
const modelIsFixed = modelOption2?.type === "select" && modelOption2.values.length < 2 && modelOption2.currentValue === model;
|
|
87415
|
-
const configOptions = model === void 0 || modelIsFixed ? prepared.configOptions : (await runtime.
|
|
87480
|
+
const configOptions = model === void 0 || modelIsFixed ? prepared.configOptions : (await runtime.applyConfiguration({
|
|
87416
87481
|
...options2,
|
|
87417
87482
|
booleanValue: false,
|
|
87418
87483
|
configId: modelOption2?.id ?? "model",
|
|
87419
|
-
expectedConfigurationRevision: null,
|
|
87420
87484
|
requestId: "agent-settings-model",
|
|
87421
87485
|
sessionId: `agent-settings-${crypto.randomUUID()}`,
|
|
87422
87486
|
value: model,
|
|
@@ -87484,7 +87548,7 @@ var SessionManager2 = class {
|
|
|
87484
87548
|
this.#executionProcesses.touch(options2.sessionId, runtime);
|
|
87485
87549
|
return runtime.prepared();
|
|
87486
87550
|
}
|
|
87487
|
-
if (
|
|
87551
|
+
if (this.#executions.isBusy(options2.sessionId)) {
|
|
87488
87552
|
throw new AcpExecutionError(
|
|
87489
87553
|
"The execution environment cannot change while a conversation turn is running",
|
|
87490
87554
|
{},
|
|
@@ -87493,12 +87557,20 @@ var SessionManager2 = class {
|
|
|
87493
87557
|
}
|
|
87494
87558
|
return (await this.#replaceExecutionPreparation(existing, options2)).prepared();
|
|
87495
87559
|
});
|
|
87560
|
+
/** Applies a client's edit only while the Session's configuration still has the revision the client read. */
|
|
87496
87561
|
configureSession = async (options) => this.#operations.run(options, async (options2) => {
|
|
87497
87562
|
return await this.#executionProcesses.use(options2.sessionId, async () => {
|
|
87498
87563
|
const runtime = await this.ensureSession(options2);
|
|
87499
87564
|
return await runtime.configure(options2);
|
|
87500
87565
|
});
|
|
87501
87566
|
});
|
|
87567
|
+
/** Applies a setting the Runtime owns, such as one a prompt or a preparation requested. */
|
|
87568
|
+
applySessionConfiguration = async (change) => this.#operations.run(change, async (change2) => {
|
|
87569
|
+
return await this.#executionProcesses.use(change2.sessionId, async () => {
|
|
87570
|
+
const runtime = await this.ensureSession(change2);
|
|
87571
|
+
return await runtime.applyConfiguration(change2);
|
|
87572
|
+
});
|
|
87573
|
+
});
|
|
87502
87574
|
renameSession = async (options, title2) => await this.#executionProcesses.use(
|
|
87503
87575
|
options.sessionId,
|
|
87504
87576
|
async () => this.#operations.run(options, async (options2) => {
|
|
@@ -87536,15 +87608,17 @@ var SessionManager2 = class {
|
|
|
87536
87608
|
}
|
|
87537
87609
|
});
|
|
87538
87610
|
});
|
|
87611
|
+
/** Whether a steering prompt can join the named execution: the one rule every steering check asks. */
|
|
87612
|
+
acceptsSteering = (sessionId, targetCommandId) => this.#executions.acceptsSteering(sessionId, targetCommandId);
|
|
87539
87613
|
steerPrompt = async (options) => this.#operations.run(options, async (options2) => {
|
|
87540
|
-
if (this
|
|
87614
|
+
if (!this.acceptsSteering(options2.sessionId, options2.targetCommandId)) {
|
|
87541
87615
|
throw new AcpExecutionError("The target turn is no longer active", {}, "steering_target_unavailable");
|
|
87542
87616
|
}
|
|
87543
87617
|
const pending = this.#executionProcesses.pending(options2.sessionId);
|
|
87544
87618
|
if (pending !== void 0) {
|
|
87545
87619
|
await waitForSharedOperation(pending, options2.signal);
|
|
87546
87620
|
}
|
|
87547
|
-
if (this
|
|
87621
|
+
if (!this.acceptsSteering(options2.sessionId, options2.targetCommandId)) {
|
|
87548
87622
|
throw new AcpExecutionError("The target turn is no longer active", {}, "steering_target_unavailable");
|
|
87549
87623
|
}
|
|
87550
87624
|
const runtime = this.#executionProcesses.get(options2.sessionId);
|
|
@@ -87583,13 +87657,8 @@ var SessionManager2 = class {
|
|
|
87583
87657
|
throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
|
|
87584
87658
|
}
|
|
87585
87659
|
this.#executions.begin(options2.sessionId, options2.commandId);
|
|
87586
|
-
const cancelled = () => options2.cancellationRequested?.() === true || this.#executions.
|
|
87660
|
+
const cancelled = () => options2.cancellationRequested?.() === true || this.#executions.cancellationRequested(options2.sessionId, options2.commandId);
|
|
87587
87661
|
try {
|
|
87588
|
-
this.#onSessionStatusChanged({
|
|
87589
|
-
kind: "session.status.changed",
|
|
87590
|
-
sessionId: options2.sessionId,
|
|
87591
|
-
status: { commandId: options2.commandId, kind: "working" }
|
|
87592
|
-
});
|
|
87593
87662
|
if (cancelled()) {
|
|
87594
87663
|
return { stopReason: "cancelled" };
|
|
87595
87664
|
}
|
|
@@ -87601,6 +87670,11 @@ var SessionManager2 = class {
|
|
|
87601
87670
|
return { stopReason: "cancelled" };
|
|
87602
87671
|
}
|
|
87603
87672
|
try {
|
|
87673
|
+
await runtime.preparePrompt(options2.signal);
|
|
87674
|
+
if (cancelled()) {
|
|
87675
|
+
return { stopReason: "cancelled" };
|
|
87676
|
+
}
|
|
87677
|
+
this.#executions.start(options2.sessionId, options2.commandId);
|
|
87604
87678
|
const result = await runtime.prompt({
|
|
87605
87679
|
...options2,
|
|
87606
87680
|
cancellationRequested: cancelled
|
|
@@ -87612,6 +87686,8 @@ var SessionManager2 = class {
|
|
|
87612
87686
|
return { stopReason: "cancelled" };
|
|
87613
87687
|
}
|
|
87614
87688
|
throw error62;
|
|
87689
|
+
} finally {
|
|
87690
|
+
this.#executions.settle(options2.sessionId, options2.commandId);
|
|
87615
87691
|
}
|
|
87616
87692
|
} catch (error62) {
|
|
87617
87693
|
const failedRuntime = this.#executionProcesses.get(options2.sessionId);
|
|
@@ -87636,11 +87712,6 @@ var SessionManager2 = class {
|
|
|
87636
87712
|
await this.#executions.cancellation(options2.sessionId);
|
|
87637
87713
|
} finally {
|
|
87638
87714
|
this.#executions.finish(options2.sessionId, options2.commandId);
|
|
87639
|
-
this.#onSessionStatusChanged({
|
|
87640
|
-
kind: "session.status.changed",
|
|
87641
|
-
sessionId: options2.sessionId,
|
|
87642
|
-
status: { kind: "idle" }
|
|
87643
|
-
});
|
|
87644
87715
|
this.#executionProcesses.touch(options2.sessionId);
|
|
87645
87716
|
this.#processes.notifyChanged();
|
|
87646
87717
|
}
|
|
@@ -87718,10 +87789,7 @@ var SessionManager2 = class {
|
|
|
87718
87789
|
const stored = this.#store.read(sessionId);
|
|
87719
87790
|
return stored instanceof FoundStoredSession ? [stored.session] : [];
|
|
87720
87791
|
});
|
|
87721
|
-
sessionStatus = (sessionId) =>
|
|
87722
|
-
const commandId = this.#executions.command(sessionId);
|
|
87723
|
-
return commandId === void 0 ? { kind: "idle" } : { commandId, kind: "working" };
|
|
87724
|
-
};
|
|
87792
|
+
sessionStatus = (sessionId) => this.#executions.status(sessionId);
|
|
87725
87793
|
listSessions = (limit) => this.#store.list().filter((session) => session.prompted).slice(0, limit);
|
|
87726
87794
|
findLinkedSessions = (agentId, nativeSessionId) => this.#store.findNative(agentId, nativeSessionId);
|
|
87727
87795
|
interactionSnapshot = (options) => {
|
|
@@ -87867,7 +87935,7 @@ var SessionManager2 = class {
|
|
|
87867
87935
|
});
|
|
87868
87936
|
}
|
|
87869
87937
|
if (linked.some(
|
|
87870
|
-
(entry) => this.#executions.
|
|
87938
|
+
(entry) => this.#executions.isBusy(entry.sessionId) || this.#executionProcesses.pending(entry.sessionId) !== void 0
|
|
87871
87939
|
)) {
|
|
87872
87940
|
throw new AcpExecutionError(
|
|
87873
87941
|
"Wait for the native session's running operation to finish",
|
|
@@ -88284,7 +88352,7 @@ var NativeSessionService = class {
|
|
|
88284
88352
|
};
|
|
88285
88353
|
|
|
88286
88354
|
// src/engine/session/prompt/prompt-artifacts.ts
|
|
88287
|
-
import { createHash as
|
|
88355
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
88288
88356
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
88289
88357
|
var PromptArtifactError = class extends OperationError {
|
|
88290
88358
|
constructor(code, message, options = {}) {
|
|
@@ -88310,7 +88378,7 @@ async function resolvePromptArtifacts(read, attachments, signal) {
|
|
|
88310
88378
|
signal.throwIfAborted();
|
|
88311
88379
|
const artifact = await read(attachment, signal);
|
|
88312
88380
|
const { bytes } = artifact;
|
|
88313
|
-
if (bytes.byteLength !== attachment.byteLength ||
|
|
88381
|
+
if (bytes.byteLength !== attachment.byteLength || createHash7("sha256").update(bytes).digest("hex") !== attachment.contentKey) {
|
|
88314
88382
|
throw new PromptArtifactError(
|
|
88315
88383
|
"artifact_integrity_failed",
|
|
88316
88384
|
"The prompt attachment failed integrity validation"
|
|
@@ -88532,7 +88600,7 @@ async function settleAbandonedTurn(projection, operations, cancellation) {
|
|
|
88532
88600
|
}
|
|
88533
88601
|
|
|
88534
88602
|
// src/engine/session/turn/execution-receipts.ts
|
|
88535
|
-
import { createHash as
|
|
88603
|
+
import { createHash as createHash8, randomUUID as randomUUID15 } from "node:crypto";
|
|
88536
88604
|
var MAX_TERMINAL_RECEIPTS = 1024;
|
|
88537
88605
|
function executionStarted(state) {
|
|
88538
88606
|
switch (state.kind) {
|
|
@@ -88705,7 +88773,7 @@ var ExecutionReceipts = class {
|
|
|
88705
88773
|
type: "lifecycle-metadata",
|
|
88706
88774
|
payload: { kind: "prompt.completed", commandId, stopReason: "cancelled", execution: "not-started" }
|
|
88707
88775
|
};
|
|
88708
|
-
const commandHash =
|
|
88776
|
+
const commandHash = createHash8("sha256").update(
|
|
88709
88777
|
encodeSessionCancelBeforeStartCommand({
|
|
88710
88778
|
commandId,
|
|
88711
88779
|
kind: "session.cancel-before-start",
|
|
@@ -88790,7 +88858,7 @@ var ExecutionReceipts = class {
|
|
|
88790
88858
|
return recovered;
|
|
88791
88859
|
};
|
|
88792
88860
|
claimExecution = (commandId, sessionId, commandJson) => {
|
|
88793
|
-
const commandHash =
|
|
88861
|
+
const commandHash = createHash8("sha256").update(commandJson).digest("hex");
|
|
88794
88862
|
let existing = this.#executions.get(commandId);
|
|
88795
88863
|
const previous = this.outcome(commandId);
|
|
88796
88864
|
if (existing?.sessionId === sessionId && !executionStarted(existing.state) && previous?.type === "lifecycle-metadata" && previous.payload.kind === "prompt.failed-before-start" && previous.payload.code === "runtime_restarted") {
|
|
@@ -88953,8 +89021,6 @@ var ActiveRuntimeTurn = class {
|
|
|
88953
89021
|
this.#admission = { kind: "queued", promotion: Promise.withResolvers() };
|
|
88954
89022
|
};
|
|
88955
89023
|
isQueued = () => (this.#admission.kind === "queued" || this.#admission.kind === "admitted" && this.#admission.disposition === SessionPromptDisposition.Queue) && !this.#started() && !this.#controller.signal.aborted;
|
|
88956
|
-
/** Whether the command's execution was handed to the Agent. */
|
|
88957
|
-
hasStarted = () => this.#started();
|
|
88958
89024
|
abortRuntime = () => {
|
|
88959
89025
|
this.#controller.abort();
|
|
88960
89026
|
};
|
|
@@ -89116,8 +89182,6 @@ var SessionExecutionState = class {
|
|
|
89116
89182
|
}
|
|
89117
89183
|
return event;
|
|
89118
89184
|
};
|
|
89119
|
-
/** A steering prompt can join only a target whose execution already started. */
|
|
89120
|
-
steerTargetStarted = (command) => this.#turnsByCommandId.get(command.targetCommandId)?.hasStarted() ?? false;
|
|
89121
89185
|
turns = () => [...this.#turnsByCommandId.values()];
|
|
89122
89186
|
close = async () => {
|
|
89123
89187
|
const turns = [...this.#turnsByCommandId.values()];
|
|
@@ -89202,7 +89266,6 @@ var SessionTurns = class {
|
|
|
89202
89266
|
this.recordEvent(event.payload.event);
|
|
89203
89267
|
}
|
|
89204
89268
|
};
|
|
89205
|
-
steerTargetStarted = (command) => this.#bySessionId.get(command.sessionId)?.steerTargetStarted(command) ?? false;
|
|
89206
89269
|
executionSnapshot = async (matches) => {
|
|
89207
89270
|
for (const session of this.#bySessionId.values()) {
|
|
89208
89271
|
const matching = [];
|
|
@@ -89533,7 +89596,7 @@ function buildSessionLayer(options) {
|
|
|
89533
89596
|
}
|
|
89534
89597
|
|
|
89535
89598
|
// src/engine/session/content/external-content-store.ts
|
|
89536
|
-
import { createHash as
|
|
89599
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
89537
89600
|
import { extname as extname2, join as join29 } from "node:path";
|
|
89538
89601
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
89539
89602
|
|
|
@@ -89668,7 +89731,7 @@ var LocalExternalContentStore = class {
|
|
|
89668
89731
|
const active = AbortSignal.any([signal, this.#lifetime.signal]);
|
|
89669
89732
|
active.throwIfAborted();
|
|
89670
89733
|
const metadata = metadataSchema.parse({ kind, mediaType, name: name2 });
|
|
89671
|
-
const key =
|
|
89734
|
+
const key = createHash9("sha256").update(bytes).digest("hex");
|
|
89672
89735
|
const request = `mobius-content:${kind}:${key}`;
|
|
89673
89736
|
const existing = this.#entries.get(request);
|
|
89674
89737
|
if (existing !== void 0 && existing.expiresAt > Date.now()) {
|
|
@@ -90388,7 +90451,7 @@ var SessionError = class extends OperationError {
|
|
|
90388
90451
|
};
|
|
90389
90452
|
|
|
90390
90453
|
// src/engine/session/settings/discover-agent-settings.ts
|
|
90391
|
-
import { createHash as
|
|
90454
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
90392
90455
|
|
|
90393
90456
|
// src/engine/agent/settings/agent-settings-base.ts
|
|
90394
90457
|
var AgentSettingsLaunchSelectionResult = class {
|
|
@@ -90706,7 +90769,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
90706
90769
|
unsupportedModelIds: modelEffort.unsupportedModelIds,
|
|
90707
90770
|
valuesByModel: {}
|
|
90708
90771
|
};
|
|
90709
|
-
return
|
|
90772
|
+
return createHash10("sha256").update(
|
|
90710
90773
|
JSON.stringify({
|
|
90711
90774
|
adapterVersion: agent.adapterVersion,
|
|
90712
90775
|
agentId: agent.id,
|
|
@@ -90862,7 +90925,7 @@ function createAgentSettingsCommands(context) {
|
|
|
90862
90925
|
}
|
|
90863
90926
|
|
|
90864
90927
|
// src/engine/runtime/command/registry/content-write/index.ts
|
|
90865
|
-
import { createHash as
|
|
90928
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
90866
90929
|
function createContentWriteCommands(context) {
|
|
90867
90930
|
const pending = /* @__PURE__ */ new Map();
|
|
90868
90931
|
const operations = /* @__PURE__ */ new Set();
|
|
@@ -90892,7 +90955,7 @@ function createContentWriteCommands(context) {
|
|
|
90892
90955
|
pending.set(message.requestId, {
|
|
90893
90956
|
bytes: new Uint8Array(message.byteLength),
|
|
90894
90957
|
command: message,
|
|
90895
|
-
hash:
|
|
90958
|
+
hash: createHash11("sha256"),
|
|
90896
90959
|
receivedBytes: 0,
|
|
90897
90960
|
sequence: 0
|
|
90898
90961
|
});
|
|
@@ -91712,13 +91775,12 @@ async function applySessionConfigurationSelection(sessions, options, selection,
|
|
|
91712
91775
|
if (sessionConfigurationMatches(option, selection)) {
|
|
91713
91776
|
return options;
|
|
91714
91777
|
}
|
|
91715
|
-
return (await sessions.
|
|
91778
|
+
return (await sessions.applySessionConfiguration({
|
|
91716
91779
|
adapter,
|
|
91717
91780
|
additionalDirectories,
|
|
91718
91781
|
agent,
|
|
91719
91782
|
booleanValue: selection.booleanValue,
|
|
91720
91783
|
configId: selection.configId,
|
|
91721
|
-
expectedConfigurationRevision: null,
|
|
91722
91784
|
cwd,
|
|
91723
91785
|
requestId: `cfg_${randomUUID18()}`,
|
|
91724
91786
|
sessionId,
|
|
@@ -91774,7 +91836,6 @@ async function executePrompt({
|
|
|
91774
91836
|
epoch,
|
|
91775
91837
|
waitForSessionAvailability,
|
|
91776
91838
|
signal,
|
|
91777
|
-
steerTargetStarted,
|
|
91778
91839
|
cancellationRequested
|
|
91779
91840
|
}) {
|
|
91780
91841
|
try {
|
|
@@ -91801,6 +91862,9 @@ async function executePrompt({
|
|
|
91801
91862
|
"prompt_queue_target_unavailable"
|
|
91802
91863
|
);
|
|
91803
91864
|
}
|
|
91865
|
+
if (availability.disposition === SessionPromptDisposition.Steer && !sessions.acceptsSteering(command.sessionId, command.targetCommandId)) {
|
|
91866
|
+
throw new AcpExecutionError("The steering target is unavailable", {}, "prompt_queue_target_unavailable");
|
|
91867
|
+
}
|
|
91804
91868
|
const appliedSettings = command.sessionConfigurations === void 0 ? void 0 : agentForSessionConfiguration(agent, command.sessionConfigurations);
|
|
91805
91869
|
const executionAgent = appliedSettings?.agent ?? agent;
|
|
91806
91870
|
const sessionConfigurations = appliedSettings?.sessionConfigurations;
|
|
@@ -91832,9 +91896,6 @@ async function executePrompt({
|
|
|
91832
91896
|
prepared = await sessions.prepareExecutionSession(preparation);
|
|
91833
91897
|
}
|
|
91834
91898
|
signal.throwIfAborted();
|
|
91835
|
-
if (availability.disposition === SessionPromptDisposition.Steer && !steerTargetStarted()) {
|
|
91836
|
-
throw new AcpExecutionError("The steering target is unavailable", {}, "prompt_queue_target_unavailable");
|
|
91837
|
-
}
|
|
91838
91899
|
const lifecycle = eventProjection.lifecycle(
|
|
91839
91900
|
command.sessionId,
|
|
91840
91901
|
command.commandId,
|
|
@@ -91991,7 +92052,6 @@ var sessionPromptCommand = {
|
|
|
91991
92052
|
queueChanged();
|
|
91992
92053
|
}),
|
|
91993
92054
|
signal: turn.signal,
|
|
91994
|
-
steerTargetStarted: () => context.sessionTurns.steerTargetStarted(message),
|
|
91995
92055
|
cancellationRequested: turn.cancellationRequested
|
|
91996
92056
|
}).catch((error62) => {
|
|
91997
92057
|
console.error("Mobius daemon turn failed", error62);
|
|
@@ -92065,11 +92125,10 @@ async function prepareSession(command, recovery, closed, config2, resolveAgent,
|
|
|
92065
92125
|
const configuration = command.configuration;
|
|
92066
92126
|
const snapshot = configuration === void 0 ? prepared : await metrics.measure(
|
|
92067
92127
|
"configuration",
|
|
92068
|
-
async () => await sessions.
|
|
92128
|
+
async () => await sessions.applySessionConfiguration({
|
|
92069
92129
|
...preparation,
|
|
92070
92130
|
booleanValue: configuration.booleanValue,
|
|
92071
92131
|
configId: configuration.configId,
|
|
92072
|
-
expectedConfigurationRevision: null,
|
|
92073
92132
|
requestId: command.requestId,
|
|
92074
92133
|
value: configuration.value,
|
|
92075
92134
|
valueType: configuration.valueType
|
|
@@ -93596,4 +93655,4 @@ export {
|
|
|
93596
93655
|
* MIT Licensed
|
|
93597
93656
|
*)
|
|
93598
93657
|
*/
|
|
93599
|
-
//# sourceMappingURL=chunk-
|
|
93658
|
+
//# sourceMappingURL=chunk-ZW763PCS.js.map
|