@moxt-ai/mobius 0.0.357 → 0.0.358
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/cli.js +236 -185
- package/dist/cli.js.map +3 -3
- package/dist/engine/acp/adapter/adapter-registry.d.ts +1 -1
- package/dist/engine/acp/adapter/adapter-registry.d.ts.map +1 -1
- package/dist/engine/acp/adapter/adapter-registry.js +2 -1
- package/dist/engine/acp/adapter/adapter-registry.js.map +1 -1
- package/dist/engine/acp/adapter/claude/adapter.d.ts +8 -35
- package/dist/engine/acp/adapter/claude/adapter.d.ts.map +1 -1
- package/dist/engine/acp/adapter/claude/adapter.js +7 -6
- package/dist/engine/acp/adapter/claude/adapter.js.map +1 -1
- package/dist/engine/acp/adapter/codex/adapter.d.ts +8 -35
- package/dist/engine/acp/adapter/codex/adapter.d.ts.map +1 -1
- package/dist/engine/acp/adapter/codex/adapter.js +21 -9
- package/dist/engine/acp/adapter/codex/adapter.js.map +1 -1
- package/dist/engine/acp/adapter/live-sessions.d.ts +1 -1
- package/dist/engine/acp/adapter/live-sessions.d.ts.map +1 -1
- package/dist/engine/acp/adapter/live-sessions.js +1 -0
- package/dist/engine/acp/adapter/live-sessions.js.map +1 -1
- package/dist/engine/acp/adapter/native-session-lookup.d.ts +2 -2
- package/dist/engine/acp/adapter/native-session-lookup.d.ts.map +1 -1
- package/dist/engine/acp/adapter/native-session-lookup.js +4 -4
- package/dist/engine/acp/adapter/native-session-lookup.js.map +1 -1
- package/dist/engine/acp/adapter/pi/adapter.d.ts +8 -35
- package/dist/engine/acp/adapter/pi/adapter.d.ts.map +1 -1
- package/dist/engine/acp/adapter/pi/adapter.js +7 -6
- package/dist/engine/acp/adapter/pi/adapter.js.map +1 -1
- package/dist/engine/acp/adapter/query-processes.d.ts +10 -7
- package/dist/engine/acp/adapter/query-processes.d.ts.map +1 -1
- package/dist/engine/acp/adapter/query-processes.js +66 -79
- package/dist/engine/acp/adapter/query-processes.js.map +1 -1
- package/dist/engine/acp/adapter/query-session.d.ts +6 -4
- package/dist/engine/acp/adapter/query-session.d.ts.map +1 -1
- package/dist/engine/acp/adapter/query-session.js +37 -22
- package/dist/engine/acp/adapter/query-session.js.map +1 -1
- package/dist/engine/acp/adapter/registry.js +3 -3
- package/dist/engine/acp/adapter/registry.js.map +1 -1
- package/dist/engine/acp/adapter/session-events.d.ts +1 -0
- package/dist/engine/acp/adapter/session-events.d.ts.map +1 -1
- package/dist/engine/acp/adapter/session-events.js +3 -0
- package/dist/engine/acp/adapter/session-events.js.map +1 -1
- package/dist/engine/acp/harness/codex/agent.d.ts.map +1 -1
- package/dist/engine/acp/harness/codex/agent.js +14 -8
- package/dist/engine/acp/harness/codex/agent.js.map +1 -1
- package/dist/engine/acp/harness/codex/borrowed-agent.d.ts.map +1 -1
- package/dist/engine/acp/harness/codex/borrowed-agent.js +8 -2
- package/dist/engine/acp/harness/codex/borrowed-agent.js.map +1 -1
- package/dist/engine/acp/native-history/preview-contract.d.ts +6 -13
- package/dist/engine/acp/native-history/preview-contract.d.ts.map +1 -1
- package/dist/engine/runtime/run.js +1 -1
- package/dist/engine/runtime/run.js.map +1 -1
- package/dist/engine/session/live/agent-session.d.ts +1 -1
- package/dist/engine/session/live/agent-session.d.ts.map +1 -1
- package/dist/engine/session/live/agent-session.js +2 -1
- package/dist/engine/session/live/agent-session.js.map +1 -1
- package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
- package/dist/engine/session/manager/session-manager.js +14 -1
- package/dist/engine/session/manager/session-manager.js.map +1 -1
- package/dist/engine/session/native/native-session-browser.d.ts.map +1 -1
- package/dist/engine/session/native/native-session-browser.js +8 -8
- package/dist/engine/session/native/native-session-browser.js.map +1 -1
- package/dist/engine.js +233 -178
- package/dist/engine.js.map +4 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2086,7 +2086,7 @@ var init_package = __esm({
|
|
|
2086
2086
|
"package.json"() {
|
|
2087
2087
|
package_default = {
|
|
2088
2088
|
name: "@moxt-ai/mobius",
|
|
2089
|
-
version: "0.0.
|
|
2089
|
+
version: "0.0.358",
|
|
2090
2090
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
2091
2091
|
type: "module",
|
|
2092
2092
|
bin: {
|
|
@@ -75795,6 +75795,7 @@ var init_borrowed_agent = __esm({
|
|
|
75795
75795
|
content,
|
|
75796
75796
|
clientId: randomUUID7(),
|
|
75797
75797
|
completion: Promise.withResolvers(),
|
|
75798
|
+
settled: Promise.withResolvers(),
|
|
75798
75799
|
input: { kind: "awaiting" }
|
|
75799
75800
|
};
|
|
75800
75801
|
this.#pending = pending;
|
|
@@ -75832,7 +75833,6 @@ var init_borrowed_agent = __esm({
|
|
|
75832
75833
|
throw cause;
|
|
75833
75834
|
} finally {
|
|
75834
75835
|
signal.removeEventListener("abort", abort);
|
|
75835
|
-
this.#pending = null;
|
|
75836
75836
|
if (outcome === "cancelled") {
|
|
75837
75837
|
try {
|
|
75838
75838
|
await this.#removeQueuedInput(pending.clientId);
|
|
@@ -75840,6 +75840,8 @@ var init_borrowed_agent = __esm({
|
|
|
75840
75840
|
console.error("The cancelled Codex queued input could not be removed", cause);
|
|
75841
75841
|
}
|
|
75842
75842
|
}
|
|
75843
|
+
this.#pending = null;
|
|
75844
|
+
pending.settled.resolve();
|
|
75843
75845
|
}
|
|
75844
75846
|
};
|
|
75845
75847
|
#removeQueuedInput = async (clientId) => {
|
|
@@ -75899,7 +75901,11 @@ var init_borrowed_agent = __esm({
|
|
|
75899
75901
|
);
|
|
75900
75902
|
};
|
|
75901
75903
|
cancel = async () => {
|
|
75902
|
-
this.#pending
|
|
75904
|
+
const pending = this.#pending;
|
|
75905
|
+
if (pending !== null) {
|
|
75906
|
+
pending.completion.resolve({ stopReason: "cancelled" });
|
|
75907
|
+
await pending.settled.promise;
|
|
75908
|
+
}
|
|
75903
75909
|
};
|
|
75904
75910
|
close = async () => {
|
|
75905
75911
|
this.#lifecycle = { kind: "closed" };
|
|
@@ -77663,16 +77669,19 @@ var init_agent = __esm({
|
|
|
77663
77669
|
*/
|
|
77664
77670
|
close = () => {
|
|
77665
77671
|
if (this.#closePromise === null) {
|
|
77666
|
-
this.#appServer.detach();
|
|
77667
77672
|
this.#closePromise = (async () => {
|
|
77668
|
-
await this.#sessionAgent.close();
|
|
77669
|
-
const child = this.#appServer.child();
|
|
77670
77673
|
try {
|
|
77671
|
-
|
|
77672
|
-
await stopProcessTree(child, captured);
|
|
77674
|
+
await this.#sessionAgent.close();
|
|
77673
77675
|
} finally {
|
|
77674
|
-
this.#
|
|
77675
|
-
this.#
|
|
77676
|
+
this.#appServer.detach();
|
|
77677
|
+
const child = this.#appServer.child();
|
|
77678
|
+
try {
|
|
77679
|
+
const captured = await captureProcessTree(child);
|
|
77680
|
+
await stopProcessTree(child, captured);
|
|
77681
|
+
} finally {
|
|
77682
|
+
this.#connection?.close();
|
|
77683
|
+
this.#onBackgroundActivity?.("none");
|
|
77684
|
+
}
|
|
77676
77685
|
}
|
|
77677
77686
|
})();
|
|
77678
77687
|
}
|
|
@@ -82842,6 +82851,7 @@ var init_adapter_registry = __esm({
|
|
|
82842
82851
|
resolve = (agent) => {
|
|
82843
82852
|
const existing = this.#adapters.get(agent.id);
|
|
82844
82853
|
if (existing !== void 0) {
|
|
82854
|
+
existing.refreshAgent(agent);
|
|
82845
82855
|
return existing;
|
|
82846
82856
|
}
|
|
82847
82857
|
const adapter = this.#resolve(agent, this.#dependencies);
|
|
@@ -83414,6 +83424,9 @@ var init_session_events = __esm({
|
|
|
83414
83424
|
get connection() {
|
|
83415
83425
|
return this.#connection.connection;
|
|
83416
83426
|
}
|
|
83427
|
+
get termination() {
|
|
83428
|
+
return this.#connection.termination;
|
|
83429
|
+
}
|
|
83417
83430
|
initialize = (signal) => this.#connection.initialize(signal);
|
|
83418
83431
|
agentSettingsModelEffort = () => this.#connection.agentSettingsModelEffort();
|
|
83419
83432
|
race = (operation, exitMessage, signal) => this.#connection.race(operation, exitMessage, signal);
|
|
@@ -83543,6 +83556,7 @@ var init_live_sessions = __esm({
|
|
|
83543
83556
|
"ACP agent exited while cancelling a prompt",
|
|
83544
83557
|
bounded
|
|
83545
83558
|
);
|
|
83559
|
+
return "retained";
|
|
83546
83560
|
};
|
|
83547
83561
|
closeSession = async (target, signal) => {
|
|
83548
83562
|
const session = this.#find(target);
|
|
@@ -83749,7 +83763,7 @@ var init_live_sessions = __esm({
|
|
|
83749
83763
|
});
|
|
83750
83764
|
|
|
83751
83765
|
// src/engine/acp/adapter/native-session-lookup.ts
|
|
83752
|
-
async function findNativeSession(list,
|
|
83766
|
+
async function findNativeSession(list, cwd, nativeSessionId, budget, signal) {
|
|
83753
83767
|
const decoded = lookupSchema.safeParse({ nativeSessionId, budget });
|
|
83754
83768
|
if (!decoded.success) {
|
|
83755
83769
|
throw new AcpExecutionError(
|
|
@@ -83763,9 +83777,9 @@ async function findNativeSession(list, query, nativeSessionId, budget) {
|
|
|
83763
83777
|
let inspected = 0;
|
|
83764
83778
|
const visited = /* @__PURE__ */ new Set();
|
|
83765
83779
|
for (let pageNumber = 0; pageNumber < limits.maximumPages; pageNumber += 1) {
|
|
83766
|
-
|
|
83767
|
-
const page = await list(
|
|
83768
|
-
|
|
83780
|
+
signal.throwIfAborted();
|
|
83781
|
+
const page = await list(cwd, cursor, signal);
|
|
83782
|
+
signal.throwIfAborted();
|
|
83769
83783
|
inspected += page.sessions.length;
|
|
83770
83784
|
const found = page.sessions.find((session) => session.sessionId === decoded.data.nativeSessionId);
|
|
83771
83785
|
if (found !== void 0) {
|
|
@@ -84546,51 +84560,56 @@ var AcpQuerySession;
|
|
|
84546
84560
|
var init_query_session = __esm({
|
|
84547
84561
|
"src/engine/acp/adapter/query-session.ts"() {
|
|
84548
84562
|
"use strict";
|
|
84549
|
-
init_value_utils();
|
|
84550
84563
|
init_acp_error();
|
|
84551
84564
|
init_native_session();
|
|
84552
84565
|
init_session_capabilities();
|
|
84553
84566
|
init_agent_initialization();
|
|
84554
84567
|
AcpQuerySession = class _AcpQuerySession {
|
|
84555
|
-
#
|
|
84568
|
+
#cwd;
|
|
84569
|
+
#sessionId;
|
|
84556
84570
|
#events;
|
|
84557
84571
|
#connection;
|
|
84572
|
+
#lifecycle = { kind: "open" };
|
|
84558
84573
|
#capabilities = unsupportedSessionCapabilities();
|
|
84559
84574
|
#configOptions = [];
|
|
84560
|
-
constructor(
|
|
84561
|
-
this.#
|
|
84575
|
+
constructor(agent, cwd, sessionId, events, connector) {
|
|
84576
|
+
this.#cwd = cwd;
|
|
84577
|
+
this.#sessionId = sessionId;
|
|
84562
84578
|
this.#events = events;
|
|
84563
84579
|
this.#connection = connector.connectQuerySession({
|
|
84564
|
-
agent
|
|
84565
|
-
cwd
|
|
84566
|
-
sessionId: () =>
|
|
84580
|
+
agent,
|
|
84581
|
+
cwd,
|
|
84582
|
+
sessionId: () => sessionId,
|
|
84567
84583
|
configOptions: () => this.#configOptions,
|
|
84568
84584
|
onEvent: async (event) => {
|
|
84569
|
-
this.#events.append(
|
|
84585
|
+
this.#events.append(sessionId, { type: "acp", payload: event.payload });
|
|
84570
84586
|
if (event.kind === "configuration") {
|
|
84571
84587
|
this.#configOptions = event.configOptions;
|
|
84572
84588
|
}
|
|
84573
84589
|
}
|
|
84574
84590
|
});
|
|
84591
|
+
void this.#connection.termination.then(() => {
|
|
84592
|
+
this.#lifecycle = { kind: "terminated" };
|
|
84593
|
+
});
|
|
84575
84594
|
}
|
|
84576
|
-
static start = async (
|
|
84595
|
+
static start = async (agent, cwd, sessionId, events, connector, signal) => {
|
|
84577
84596
|
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
84578
|
-
await validateAgentRuntime(
|
|
84579
|
-
const runtime = new _AcpQuerySession(
|
|
84597
|
+
await validateAgentRuntime(agent, signal);
|
|
84598
|
+
const runtime = new _AcpQuerySession(agent, cwd, sessionId, events, connector);
|
|
84580
84599
|
try {
|
|
84581
84600
|
const initialized = await initializeAgentConnection(
|
|
84582
84601
|
runtime.#connection,
|
|
84583
|
-
|
|
84584
|
-
|
|
84585
|
-
|
|
84602
|
+
agent.id,
|
|
84603
|
+
agent.agentVersion,
|
|
84604
|
+
signal
|
|
84586
84605
|
);
|
|
84587
84606
|
runtime.#capabilities = initialized.capabilities;
|
|
84588
84607
|
return runtime;
|
|
84589
84608
|
} catch (error62) {
|
|
84590
84609
|
await runtime.closeProcess();
|
|
84591
|
-
|
|
84610
|
+
signal.throwIfAborted();
|
|
84592
84611
|
if (error62 instanceof RetryableAcpInitializationError && attempt === 1) {
|
|
84593
|
-
console.warn(`[${
|
|
84612
|
+
console.warn(`[${agent.id}-acp] ACP agent initialization failed; retrying once`);
|
|
84594
84613
|
continue;
|
|
84595
84614
|
}
|
|
84596
84615
|
if (error62 instanceof AcpExecutionError) {
|
|
@@ -84602,7 +84621,18 @@ var init_query_session = __esm({
|
|
|
84602
84621
|
throw new AcpExecutionError("ACP agent initialization failed");
|
|
84603
84622
|
};
|
|
84604
84623
|
capabilities = () => this.#capabilities;
|
|
84605
|
-
|
|
84624
|
+
hasTerminated = () => {
|
|
84625
|
+
switch (this.#lifecycle.kind) {
|
|
84626
|
+
case "open":
|
|
84627
|
+
return false;
|
|
84628
|
+
case "terminated":
|
|
84629
|
+
return true;
|
|
84630
|
+
default: {
|
|
84631
|
+
const unreachable3 = this.#lifecycle;
|
|
84632
|
+
return unreachable3;
|
|
84633
|
+
}
|
|
84634
|
+
}
|
|
84635
|
+
};
|
|
84606
84636
|
listNativeSessions = async (cursor, signal) => {
|
|
84607
84637
|
if (!this.#capabilities.listSessions) {
|
|
84608
84638
|
throw new AcpExecutionError(
|
|
@@ -84628,7 +84658,7 @@ var init_query_session = __esm({
|
|
|
84628
84658
|
}
|
|
84629
84659
|
return decoded.data;
|
|
84630
84660
|
};
|
|
84631
|
-
previewEvents = async (nativeSessionId, eventLimit, signal) => {
|
|
84661
|
+
previewEvents = async (nativeSessionId, eventLimit, additionalDirectories, signal) => {
|
|
84632
84662
|
if (!this.#capabilities.loadSession) {
|
|
84633
84663
|
throw new AcpExecutionError(
|
|
84634
84664
|
"This Agent restores context but does not provide message history.",
|
|
@@ -84636,14 +84666,14 @@ var init_query_session = __esm({
|
|
|
84636
84666
|
"native_history_unsupported"
|
|
84637
84667
|
);
|
|
84638
84668
|
}
|
|
84639
|
-
this.#events.reset(this.#
|
|
84669
|
+
this.#events.reset(this.#sessionId);
|
|
84640
84670
|
this.#connection.events.select(nativeSessionId);
|
|
84641
84671
|
await this.#connection.race(
|
|
84642
84672
|
this.#connection.connection.agent.request(
|
|
84643
84673
|
methods12.agent.session.load,
|
|
84644
84674
|
{
|
|
84645
|
-
additionalDirectories: [...
|
|
84646
|
-
cwd: this.#
|
|
84675
|
+
additionalDirectories: [...additionalDirectories],
|
|
84676
|
+
cwd: this.#cwd,
|
|
84647
84677
|
mcpServers: [],
|
|
84648
84678
|
sessionId: nativeSessionId
|
|
84649
84679
|
},
|
|
@@ -84654,14 +84684,16 @@ var init_query_session = __esm({
|
|
|
84654
84684
|
);
|
|
84655
84685
|
await this.#connection.events.drained();
|
|
84656
84686
|
signal.throwIfAborted();
|
|
84657
|
-
return this.#events.page(this.#
|
|
84687
|
+
return this.#events.page(this.#sessionId, eventLimit, null);
|
|
84658
84688
|
};
|
|
84659
84689
|
closeProcess = async () => await this.#connection.closeProcess();
|
|
84690
|
+
discardEvents = () => this.#events.remove(this.#sessionId);
|
|
84660
84691
|
};
|
|
84661
84692
|
}
|
|
84662
84693
|
});
|
|
84663
84694
|
|
|
84664
84695
|
// src/engine/acp/adapter/query-processes.ts
|
|
84696
|
+
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
84665
84697
|
var AgentQueryProcesses;
|
|
84666
84698
|
var init_query_processes = __esm({
|
|
84667
84699
|
"src/engine/acp/adapter/query-processes.ts"() {
|
|
@@ -84669,121 +84701,99 @@ var init_query_processes = __esm({
|
|
|
84669
84701
|
init_session_event_store();
|
|
84670
84702
|
init_operation_drain();
|
|
84671
84703
|
init_retained_agent_processes();
|
|
84672
|
-
init_acp_error();
|
|
84673
84704
|
init_query_session();
|
|
84674
84705
|
AgentQueryProcesses = class {
|
|
84675
84706
|
#eventPreviewsBySession = /* @__PURE__ */ new Map();
|
|
84676
|
-
#
|
|
84707
|
+
#processesByAgent = /* @__PURE__ */ new Map();
|
|
84708
|
+
#agent;
|
|
84677
84709
|
#processes;
|
|
84678
84710
|
#store = new MemorySessionEventStore();
|
|
84679
84711
|
#connector;
|
|
84680
|
-
constructor(processes, connector) {
|
|
84712
|
+
constructor(agent, processes, connector) {
|
|
84713
|
+
this.#agent = agent;
|
|
84681
84714
|
this.#processes = processes;
|
|
84682
84715
|
this.#connector = connector;
|
|
84683
|
-
this.#processesByQuery = new RetainedAgentProcesses({
|
|
84684
|
-
touch: processes.touch,
|
|
84685
|
-
changed: processes.notifyChanged
|
|
84686
|
-
});
|
|
84687
84716
|
}
|
|
84688
|
-
|
|
84689
|
-
|
|
84690
|
-
|
|
84691
|
-
|
|
84717
|
+
refreshAgent = (agent) => {
|
|
84718
|
+
this.#agent = agent;
|
|
84719
|
+
};
|
|
84720
|
+
retire = async (readers, cwd, runtime) => {
|
|
84721
|
+
readers.detach(cwd, runtime);
|
|
84722
|
+
try {
|
|
84723
|
+
await this.#processes.retire(runtime, () => runtime.closeProcess());
|
|
84724
|
+
} finally {
|
|
84725
|
+
runtime.discardEvents();
|
|
84692
84726
|
}
|
|
84693
|
-
await this.#processes.retire(runtime, () => runtime.closeProcess());
|
|
84694
84727
|
};
|
|
84695
|
-
async #
|
|
84696
|
-
|
|
84697
|
-
|
|
84698
|
-
() => AcpQuerySession.start(options, this.#store, this.#connector),
|
|
84699
|
-
{
|
|
84700
|
-
isBusy: () => this.#processesByQuery.isBusy(options.sessionId),
|
|
84701
|
-
retire: (runtime2) => this.retire(options.sessionId, runtime2),
|
|
84702
|
-
retireIdle: (runtime2) => this.retire(options.sessionId, runtime2)
|
|
84703
|
-
}
|
|
84704
|
-
);
|
|
84705
|
-
this.#processesByQuery.retain(options.sessionId, runtime);
|
|
84706
|
-
return runtime;
|
|
84707
|
-
}
|
|
84708
|
-
async #startPreparation(options) {
|
|
84709
|
-
return await this.#processesByQuery.prepare(options.sessionId, async () => {
|
|
84710
|
-
return await this.#startRetained(options);
|
|
84711
|
-
});
|
|
84712
|
-
}
|
|
84713
|
-
async #replacePreparation(existing, options) {
|
|
84714
|
-
return await this.#processesByQuery.prepare(options.sessionId, async () => {
|
|
84715
|
-
await this.retire(options.sessionId, existing);
|
|
84716
|
-
return await this.#startRetained(options);
|
|
84717
|
-
});
|
|
84718
|
-
}
|
|
84719
|
-
#prepare = async (options) => {
|
|
84720
|
-
const pending = this.#processesByQuery.pending(options.sessionId);
|
|
84728
|
+
async #ensure(agent, readers, cwd, signal) {
|
|
84729
|
+
signal.throwIfAborted();
|
|
84730
|
+
const pending = readers.pending(cwd);
|
|
84721
84731
|
if (pending !== void 0) {
|
|
84722
|
-
|
|
84723
|
-
if (runtime2.belongsTo(options.agent.id, options.cwd, options.additionalDirectories)) {
|
|
84724
|
-
this.#processesByQuery.touch(options.sessionId, runtime2);
|
|
84725
|
-
return runtime2.capabilities();
|
|
84726
|
-
}
|
|
84727
|
-
return await this.#prepare(options);
|
|
84728
|
-
}
|
|
84729
|
-
const existing = this.#processesByQuery.get(options.sessionId);
|
|
84730
|
-
if (existing !== void 0) {
|
|
84731
|
-
if (existing.belongsTo(options.agent.id, options.cwd, options.additionalDirectories)) {
|
|
84732
|
-
this.#processesByQuery.touch(options.sessionId, existing);
|
|
84733
|
-
return existing.capabilities();
|
|
84734
|
-
}
|
|
84735
|
-
const runtime2 = await this.#replacePreparation(existing, options);
|
|
84736
|
-
return runtime2.capabilities();
|
|
84732
|
+
return await waitForSharedOperation(pending, signal);
|
|
84737
84733
|
}
|
|
84738
|
-
const
|
|
84739
|
-
|
|
84740
|
-
|
|
84741
|
-
async #ensure(options) {
|
|
84742
|
-
const existing = this.#processesByQuery.get(options.sessionId);
|
|
84743
|
-
if (existing !== void 0) {
|
|
84744
|
-
if (!existing.belongsTo(options.agent.id, options.cwd, options.additionalDirectories)) {
|
|
84745
|
-
throw new AcpExecutionError(
|
|
84746
|
-
"The agent or workspace cannot change after a conversation has started",
|
|
84747
|
-
{},
|
|
84748
|
-
"session_identity_mismatch"
|
|
84749
|
-
);
|
|
84750
|
-
}
|
|
84751
|
-
this.#processesByQuery.touch(options.sessionId, existing);
|
|
84734
|
+
const existing = readers.get(cwd);
|
|
84735
|
+
if (existing !== void 0 && !existing.hasTerminated()) {
|
|
84736
|
+
readers.touch(cwd, existing);
|
|
84752
84737
|
return existing;
|
|
84753
84738
|
}
|
|
84754
|
-
await
|
|
84755
|
-
|
|
84756
|
-
|
|
84757
|
-
|
|
84758
|
-
|
|
84759
|
-
|
|
84739
|
+
return await readers.prepare(cwd, async () => {
|
|
84740
|
+
if (existing !== void 0) {
|
|
84741
|
+
await this.retire(readers, cwd, existing);
|
|
84742
|
+
}
|
|
84743
|
+
const readerId = randomUUID14();
|
|
84744
|
+
const runtime = await this.#processes.startRetained(
|
|
84745
|
+
signal,
|
|
84746
|
+
() => AcpQuerySession.start(agent, cwd, readerId, this.#store, this.#connector, signal),
|
|
84747
|
+
{
|
|
84748
|
+
isBusy: () => readers.isBusy(cwd),
|
|
84749
|
+
retire: (runtime2) => this.retire(readers, cwd, runtime2),
|
|
84750
|
+
retireIdle: (runtime2) => this.retire(readers, cwd, runtime2)
|
|
84751
|
+
}
|
|
84752
|
+
);
|
|
84753
|
+
readers.retain(cwd, runtime);
|
|
84754
|
+
return runtime;
|
|
84755
|
+
});
|
|
84760
84756
|
}
|
|
84761
|
-
#use = async (
|
|
84762
|
-
|
|
84763
|
-
|
|
84764
|
-
|
|
84765
|
-
|
|
84757
|
+
#use = async (cwd, signal, operation) => {
|
|
84758
|
+
const agent = this.#agent;
|
|
84759
|
+
let readers = this.#processesByAgent.get(agent);
|
|
84760
|
+
if (readers === void 0) {
|
|
84761
|
+
readers = new RetainedAgentProcesses({
|
|
84762
|
+
touch: this.#processes.touch,
|
|
84763
|
+
changed: this.#processes.notifyChanged
|
|
84764
|
+
});
|
|
84765
|
+
this.#processesByAgent.set(agent, readers);
|
|
84766
|
+
}
|
|
84767
|
+
const current = readers;
|
|
84768
|
+
return await current.use(cwd, async () => await operation(await this.#ensure(agent, current, cwd, signal)));
|
|
84769
|
+
};
|
|
84770
|
+
capabilities = async (cwd, signal) => await this.#use(cwd, signal, async (runtime) => runtime.capabilities());
|
|
84771
|
+
listNativeSessions = async (cwd, cursor, signal) => await this.#use(cwd, signal, async (runtime) => await runtime.listNativeSessions(cursor, signal));
|
|
84772
|
+
previewSessionEvents = async (cwd, additionalDirectories, request, signal) => {
|
|
84773
|
+
signal.throwIfAborted();
|
|
84774
|
+
const agent = this.#agent;
|
|
84775
|
+
const { nativeSessionId, eventLimit, cursor, sessionId } = request;
|
|
84766
84776
|
if (cursor !== null) {
|
|
84767
|
-
const preview = this.#eventPreviewsBySession.get(
|
|
84777
|
+
const preview = this.#eventPreviewsBySession.get(sessionId);
|
|
84768
84778
|
if (preview === void 0 || preview.nativeSessionId !== nativeSessionId) {
|
|
84769
84779
|
throw new Error("The native event cursor is invalid");
|
|
84770
84780
|
}
|
|
84771
|
-
return preview.store.page(
|
|
84781
|
+
return preview.store.page(sessionId, eventLimit, cursor);
|
|
84772
84782
|
}
|
|
84773
84783
|
const store = new MemorySessionEventStore();
|
|
84774
|
-
const previous = this.#eventPreviewsBySession.get(
|
|
84784
|
+
const previous = this.#eventPreviewsBySession.get(sessionId);
|
|
84775
84785
|
previous?.store.close();
|
|
84776
|
-
this.#eventPreviewsBySession.set(
|
|
84786
|
+
this.#eventPreviewsBySession.set(sessionId, { nativeSessionId, store });
|
|
84777
84787
|
try {
|
|
84778
84788
|
return await this.#processes.runTransient(
|
|
84779
|
-
|
|
84780
|
-
async () => await AcpQuerySession.start(
|
|
84781
|
-
async (runtime) => await runtime.previewEvents(nativeSessionId, eventLimit,
|
|
84789
|
+
signal,
|
|
84790
|
+
async () => await AcpQuerySession.start(agent, cwd, sessionId, store, this.#connector, signal),
|
|
84791
|
+
async (runtime) => await runtime.previewEvents(nativeSessionId, eventLimit, additionalDirectories, signal),
|
|
84782
84792
|
async (runtime) => await runtime.closeProcess()
|
|
84783
84793
|
);
|
|
84784
84794
|
} catch (error62) {
|
|
84785
|
-
if (this.#eventPreviewsBySession.get(
|
|
84786
|
-
this.#eventPreviewsBySession.delete(
|
|
84795
|
+
if (this.#eventPreviewsBySession.get(sessionId)?.store === store) {
|
|
84796
|
+
this.#eventPreviewsBySession.delete(sessionId);
|
|
84787
84797
|
}
|
|
84788
84798
|
store.close();
|
|
84789
84799
|
throw error62;
|
|
@@ -84791,8 +84801,11 @@ var init_query_processes = __esm({
|
|
|
84791
84801
|
};
|
|
84792
84802
|
close = async () => {
|
|
84793
84803
|
await Promise.all(
|
|
84794
|
-
this.#
|
|
84804
|
+
[...this.#processesByAgent.values()].flatMap(
|
|
84805
|
+
(readers) => readers.entries().map(async ([cwd, runtime]) => await this.retire(readers, cwd, runtime))
|
|
84806
|
+
)
|
|
84795
84807
|
);
|
|
84808
|
+
this.#processesByAgent.clear();
|
|
84796
84809
|
for (const preview of this.#eventPreviewsBySession.values()) {
|
|
84797
84810
|
preview.store.close();
|
|
84798
84811
|
}
|
|
@@ -84817,12 +84830,13 @@ var init_adapter = __esm({
|
|
|
84817
84830
|
#queryProcesses;
|
|
84818
84831
|
#connector;
|
|
84819
84832
|
#liveSessions;
|
|
84820
|
-
constructor(dependencies) {
|
|
84833
|
+
constructor(agent, dependencies) {
|
|
84821
84834
|
this.#connector = new AcpSessionConnector(dependencies.contentExternalizer);
|
|
84822
84835
|
this.#liveSessions = new AcpLiveSessions(dependencies.contentExternalizer);
|
|
84823
|
-
this.#queryProcesses = new AgentQueryProcesses(dependencies.processes, this.#connector);
|
|
84836
|
+
this.#queryProcesses = new AgentQueryProcesses(agent, dependencies.processes, this.#connector);
|
|
84824
84837
|
}
|
|
84825
|
-
|
|
84838
|
+
refreshAgent = (agent) => this.#queryProcesses.refreshAgent(agent);
|
|
84839
|
+
getCapabilities = (cwd, signal) => this.#queryProcesses.capabilities(cwd, signal);
|
|
84826
84840
|
connectSession = (options) => this.#liveSessions.connectSession(options);
|
|
84827
84841
|
cancel = (...args) => this.#liveSessions.cancel(...args);
|
|
84828
84842
|
closeSession = (...args) => this.#liveSessions.closeSession(...args);
|
|
@@ -84830,9 +84844,9 @@ var init_adapter = __esm({
|
|
|
84830
84844
|
steer = (...args) => this.#liveSessions.steer(...args);
|
|
84831
84845
|
renameSession = (...args) => this.#liveSessions.renameSession(...args);
|
|
84832
84846
|
configureSession = (...args) => this.#liveSessions.configureSession(...args);
|
|
84833
|
-
listSessions =
|
|
84834
|
-
findSession = (
|
|
84835
|
-
readSessionHistory =
|
|
84847
|
+
listSessions = (cwd, cursor, signal) => this.#queryProcesses.listNativeSessions(cwd, cursor, signal);
|
|
84848
|
+
findSession = (cwd, nativeSessionId, budget, signal) => findNativeSession(this.listSessions, cwd, nativeSessionId, budget, signal);
|
|
84849
|
+
readSessionHistory = (cwd, additionalDirectories, request, signal) => this.#queryProcesses.previewSessionEvents(cwd, additionalDirectories, request, signal);
|
|
84836
84850
|
close = async () => await runCleanup(
|
|
84837
84851
|
() => this.#queryProcesses.close(),
|
|
84838
84852
|
() => this.#liveSessions.close()
|
|
@@ -90769,13 +90783,15 @@ var init_adapter2 = __esm({
|
|
|
90769
90783
|
init_session_events();
|
|
90770
90784
|
init_tool_event();
|
|
90771
90785
|
CodexAdapter = class {
|
|
90786
|
+
#agent;
|
|
90772
90787
|
#queryProcesses;
|
|
90773
90788
|
#connector;
|
|
90774
90789
|
#liveSessions;
|
|
90775
90790
|
#dependencies;
|
|
90776
90791
|
#contentExternalizer;
|
|
90777
90792
|
#previewCache = null;
|
|
90778
|
-
constructor(dependencies) {
|
|
90793
|
+
constructor(agent, dependencies) {
|
|
90794
|
+
this.#agent = agent;
|
|
90779
90795
|
this.#dependencies = dependencies;
|
|
90780
90796
|
this.#contentExternalizer = {
|
|
90781
90797
|
update: async (sessionId, update, signal) => {
|
|
@@ -90787,18 +90803,25 @@ var init_adapter2 = __esm({
|
|
|
90787
90803
|
};
|
|
90788
90804
|
this.#connector = new AcpSessionConnector(this.#contentExternalizer, fitCodexToolEvent);
|
|
90789
90805
|
this.#liveSessions = new AcpLiveSessions(this.#contentExternalizer, fitCodexToolEvent);
|
|
90790
|
-
this.#queryProcesses = new AgentQueryProcesses(dependencies.processes, this.#connector);
|
|
90806
|
+
this.#queryProcesses = new AgentQueryProcesses(agent, dependencies.processes, this.#connector);
|
|
90791
90807
|
}
|
|
90792
|
-
|
|
90808
|
+
refreshAgent = (agent) => {
|
|
90809
|
+
this.#agent = agent;
|
|
90810
|
+
this.#queryProcesses.refreshAgent(agent);
|
|
90811
|
+
};
|
|
90812
|
+
getCapabilities = (cwd, signal) => this.#queryProcesses.capabilities(cwd, signal);
|
|
90793
90813
|
connectSession = (options) => this.#liveSessions.connectSession(options);
|
|
90794
|
-
cancel = (
|
|
90814
|
+
cancel = async (target, signal) => {
|
|
90815
|
+
await this.#liveSessions.closeSession(target, signal);
|
|
90816
|
+
return "closed";
|
|
90817
|
+
};
|
|
90795
90818
|
closeSession = (...args) => this.#liveSessions.closeSession(...args);
|
|
90796
90819
|
prompt = (...args) => this.#liveSessions.prompt(...args);
|
|
90797
90820
|
steer = (...args) => this.#liveSessions.steer(...args);
|
|
90798
90821
|
renameSession = (...args) => this.#liveSessions.renameSession(...args);
|
|
90799
90822
|
configureSession = (...args) => this.#liveSessions.configureSession(...args);
|
|
90800
|
-
listSessions =
|
|
90801
|
-
findSession = (
|
|
90823
|
+
listSessions = (cwd, cursor, signal) => this.#queryProcesses.listNativeSessions(cwd, cursor, signal);
|
|
90824
|
+
findSession = (cwd, nativeSessionId, budget, signal) => findNativeSession(this.listSessions, cwd, nativeSessionId, budget, signal);
|
|
90802
90825
|
close = async () => {
|
|
90803
90826
|
await runCleanup(
|
|
90804
90827
|
() => this.#queryProcesses.close(),
|
|
@@ -90806,9 +90829,9 @@ var init_adapter2 = __esm({
|
|
|
90806
90829
|
() => this.#previewCache?.close()
|
|
90807
90830
|
);
|
|
90808
90831
|
};
|
|
90809
|
-
readSessionHistory = async (
|
|
90810
|
-
const
|
|
90811
|
-
const signal = AbortSignal.any([
|
|
90832
|
+
readSessionHistory = async (cwd, _additionalDirectories, request, cancellation) => {
|
|
90833
|
+
const agent = this.#agent;
|
|
90834
|
+
const signal = AbortSignal.any([cancellation, AbortSignal.timeout(6e4)]);
|
|
90812
90835
|
const { sessionId } = request;
|
|
90813
90836
|
signal.throwIfAborted();
|
|
90814
90837
|
nativeSessionIdSchema.parse(request.nativeSessionId);
|
|
@@ -90895,12 +90918,13 @@ var init_adapter3 = __esm({
|
|
|
90895
90918
|
#queryProcesses;
|
|
90896
90919
|
#connector;
|
|
90897
90920
|
#liveSessions;
|
|
90898
|
-
constructor(dependencies) {
|
|
90921
|
+
constructor(agent, dependencies) {
|
|
90899
90922
|
this.#connector = new AcpSessionConnector(dependencies.contentExternalizer);
|
|
90900
90923
|
this.#liveSessions = new AcpLiveSessions(dependencies.contentExternalizer);
|
|
90901
|
-
this.#queryProcesses = new AgentQueryProcesses(dependencies.processes, this.#connector);
|
|
90924
|
+
this.#queryProcesses = new AgentQueryProcesses(agent, dependencies.processes, this.#connector);
|
|
90902
90925
|
}
|
|
90903
|
-
|
|
90926
|
+
refreshAgent = (agent) => this.#queryProcesses.refreshAgent(agent);
|
|
90927
|
+
getCapabilities = (cwd, signal) => this.#queryProcesses.capabilities(cwd, signal);
|
|
90904
90928
|
connectSession = (options) => this.#liveSessions.connectSession(options);
|
|
90905
90929
|
cancel = (...args) => this.#liveSessions.cancel(...args);
|
|
90906
90930
|
closeSession = (...args) => this.#liveSessions.closeSession(...args);
|
|
@@ -90908,9 +90932,9 @@ var init_adapter3 = __esm({
|
|
|
90908
90932
|
steer = (...args) => this.#liveSessions.steer(...args);
|
|
90909
90933
|
renameSession = (...args) => this.#liveSessions.renameSession(...args);
|
|
90910
90934
|
configureSession = (...args) => this.#liveSessions.configureSession(...args);
|
|
90911
|
-
listSessions =
|
|
90912
|
-
findSession = (
|
|
90913
|
-
readSessionHistory =
|
|
90935
|
+
listSessions = (cwd, cursor, signal) => this.#queryProcesses.listNativeSessions(cwd, cursor, signal);
|
|
90936
|
+
findSession = (cwd, nativeSessionId, budget, signal) => findNativeSession(this.listSessions, cwd, nativeSessionId, budget, signal);
|
|
90937
|
+
readSessionHistory = (cwd, additionalDirectories, request, signal) => this.#queryProcesses.previewSessionEvents(cwd, additionalDirectories, request, signal);
|
|
90914
90938
|
close = async () => await runCleanup(
|
|
90915
90939
|
() => this.#queryProcesses.close(),
|
|
90916
90940
|
() => this.#liveSessions.close()
|
|
@@ -90931,11 +90955,11 @@ var init_registry = __esm({
|
|
|
90931
90955
|
harnessAdapters = (agent, dependencies) => {
|
|
90932
90956
|
switch (agent.id) {
|
|
90933
90957
|
case "codex":
|
|
90934
|
-
return new CodexAdapter(dependencies);
|
|
90958
|
+
return new CodexAdapter(agent, dependencies);
|
|
90935
90959
|
case "claude":
|
|
90936
|
-
return new ClaudeAdapter(dependencies);
|
|
90960
|
+
return new ClaudeAdapter(agent, dependencies);
|
|
90937
90961
|
case "pi":
|
|
90938
|
-
return new PiAdapter(dependencies);
|
|
90962
|
+
return new PiAdapter(agent, dependencies);
|
|
90939
90963
|
default:
|
|
90940
90964
|
throw new AcpExecutionError(
|
|
90941
90965
|
`Agent "${agent.id}" has no registered harness adapter.`,
|
|
@@ -94309,8 +94333,9 @@ var init_agent_session = __esm({
|
|
|
94309
94333
|
await this.#interactions.cancelPendingInteractions();
|
|
94310
94334
|
signal.throwIfAborted();
|
|
94311
94335
|
if (this.#turn.running) {
|
|
94312
|
-
await this.#adapter.cancel(this.#target(), signal);
|
|
94336
|
+
return await this.#adapter.cancel(this.#target(), signal);
|
|
94313
94337
|
}
|
|
94338
|
+
return "retained";
|
|
94314
94339
|
};
|
|
94315
94340
|
respondPermission = async (options) => {
|
|
94316
94341
|
await this.#interactions.respondPermission(options);
|
|
@@ -94980,7 +95005,18 @@ var init_session_manager = __esm({
|
|
|
94980
95005
|
await this.#executions.cancel(sessionId, async () => {
|
|
94981
95006
|
const runtime = this.#executionProcesses.get(sessionId);
|
|
94982
95007
|
if (runtime !== void 0) {
|
|
94983
|
-
await runtime.cancel(signal2);
|
|
95008
|
+
const outcome = await runtime.cancel(signal2);
|
|
95009
|
+
switch (outcome) {
|
|
95010
|
+
case "retained":
|
|
95011
|
+
break;
|
|
95012
|
+
case "closed":
|
|
95013
|
+
await this.#stopSessionProcess(sessionId, runtime);
|
|
95014
|
+
break;
|
|
95015
|
+
default: {
|
|
95016
|
+
const unreachable3 = outcome;
|
|
95017
|
+
throw new AcpExecutionError("Unexpected cancellation outcome", { cause: unreachable3 });
|
|
95018
|
+
}
|
|
95019
|
+
}
|
|
94984
95020
|
}
|
|
94985
95021
|
});
|
|
94986
95022
|
});
|
|
@@ -95363,7 +95399,7 @@ var init_local_authorization_error = __esm({
|
|
|
95363
95399
|
});
|
|
95364
95400
|
|
|
95365
95401
|
// src/engine/session/native/native-session-browser.ts
|
|
95366
|
-
import { randomUUID as
|
|
95402
|
+
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
95367
95403
|
function nextForkTitle(sourceTitle, sessions) {
|
|
95368
95404
|
let highest = 0;
|
|
95369
95405
|
for (const session of sessions) {
|
|
@@ -95421,12 +95457,17 @@ var init_native_session_browser = __esm({
|
|
|
95421
95457
|
(scoped) => this.#sessions.withNativeSessionOperation(
|
|
95422
95458
|
scoped,
|
|
95423
95459
|
nativeSessionId,
|
|
95424
|
-
(target) => target.adapter.readSessionHistory(
|
|
95425
|
-
|
|
95426
|
-
|
|
95427
|
-
|
|
95428
|
-
|
|
95429
|
-
|
|
95460
|
+
(target) => target.adapter.readSessionHistory(
|
|
95461
|
+
target.cwd,
|
|
95462
|
+
target.additionalDirectories,
|
|
95463
|
+
{
|
|
95464
|
+
nativeSessionId,
|
|
95465
|
+
eventLimit,
|
|
95466
|
+
cursor,
|
|
95467
|
+
sessionId: target.sessionId
|
|
95468
|
+
},
|
|
95469
|
+
target.signal
|
|
95470
|
+
)
|
|
95430
95471
|
)
|
|
95431
95472
|
);
|
|
95432
95473
|
#execute = async (command, signal) => {
|
|
@@ -95457,7 +95498,7 @@ var init_native_session_browser = __esm({
|
|
|
95457
95498
|
queuedCancellation: "before-start"
|
|
95458
95499
|
};
|
|
95459
95500
|
}
|
|
95460
|
-
const capabilities = await options.adapter.getCapabilities(
|
|
95501
|
+
const capabilities = await options.adapter.getCapabilities(cwd, signal);
|
|
95461
95502
|
if (!capabilities.listSessions) {
|
|
95462
95503
|
throw new AcpExecutionError(
|
|
95463
95504
|
"This Agent does not support native session listing",
|
|
@@ -95472,7 +95513,7 @@ var init_native_session_browser = __esm({
|
|
|
95472
95513
|
if (authorized === null) {
|
|
95473
95514
|
return null;
|
|
95474
95515
|
}
|
|
95475
|
-
const entryId = decodeIdentifier(
|
|
95516
|
+
const entryId = decodeIdentifier(randomUUID15());
|
|
95476
95517
|
if (this.#entries.size >= 5e3) {
|
|
95477
95518
|
this.#entries.clear();
|
|
95478
95519
|
}
|
|
@@ -95511,7 +95552,7 @@ var init_native_session_browser = __esm({
|
|
|
95511
95552
|
}
|
|
95512
95553
|
cursor = known.cursor;
|
|
95513
95554
|
}
|
|
95514
|
-
const page = await options.adapter.listSessions(
|
|
95555
|
+
const page = await options.adapter.listSessions(cwd, cursor, signal);
|
|
95515
95556
|
const entries = [];
|
|
95516
95557
|
for (const info of page.sessions) {
|
|
95517
95558
|
const entry = await register(info);
|
|
@@ -95528,7 +95569,7 @@ var init_native_session_browser = __esm({
|
|
|
95528
95569
|
"invalid_native_session_response"
|
|
95529
95570
|
);
|
|
95530
95571
|
}
|
|
95531
|
-
nextCursor = decodeIdentifier(
|
|
95572
|
+
nextCursor = decodeIdentifier(randomUUID15());
|
|
95532
95573
|
if (this.#cursors.size >= 500) {
|
|
95533
95574
|
this.#cursors.clear();
|
|
95534
95575
|
}
|
|
@@ -95546,10 +95587,15 @@ var init_native_session_browser = __esm({
|
|
|
95546
95587
|
};
|
|
95547
95588
|
}
|
|
95548
95589
|
if (command.action === "find") {
|
|
95549
|
-
const found = await options.adapter.findSession(
|
|
95550
|
-
|
|
95551
|
-
|
|
95552
|
-
|
|
95590
|
+
const found = await options.adapter.findSession(
|
|
95591
|
+
cwd,
|
|
95592
|
+
command.nativeSessionId,
|
|
95593
|
+
{
|
|
95594
|
+
maximumPages: 500,
|
|
95595
|
+
maximumEntries: 500
|
|
95596
|
+
},
|
|
95597
|
+
signal
|
|
95598
|
+
);
|
|
95553
95599
|
const entry = await register(found);
|
|
95554
95600
|
if (entry !== null) {
|
|
95555
95601
|
return { ...envelope2, action: "find", entry };
|
|
@@ -95687,10 +95733,15 @@ var init_native_session_browser = __esm({
|
|
|
95687
95733
|
}
|
|
95688
95734
|
};
|
|
95689
95735
|
resolveTarget = async (command, options, selected) => {
|
|
95690
|
-
const info = await options.adapter.findSession(
|
|
95691
|
-
|
|
95692
|
-
|
|
95693
|
-
|
|
95736
|
+
const info = await options.adapter.findSession(
|
|
95737
|
+
options.cwd,
|
|
95738
|
+
selected.nativeSessionId,
|
|
95739
|
+
{
|
|
95740
|
+
maximumPages: 100,
|
|
95741
|
+
maximumEntries: null
|
|
95742
|
+
},
|
|
95743
|
+
options.signal
|
|
95744
|
+
).catch((cause) => {
|
|
95694
95745
|
options.signal.throwIfAborted();
|
|
95695
95746
|
if (cause instanceof AcpExecutionError && cause.code === "native_session_not_found") {
|
|
95696
95747
|
throw new AcpExecutionError(
|
|
@@ -95977,7 +96028,7 @@ var init_prompt_lifecycle = __esm({
|
|
|
95977
96028
|
});
|
|
95978
96029
|
|
|
95979
96030
|
// src/engine/session/turn/execution-receipts.ts
|
|
95980
|
-
import { createHash as createHash7, randomUUID as
|
|
96031
|
+
import { createHash as createHash7, randomUUID as randomUUID16 } from "node:crypto";
|
|
95981
96032
|
var MAX_TERMINAL_RECEIPTS, ExecutionReceipts;
|
|
95982
96033
|
var init_execution_receipts = __esm({
|
|
95983
96034
|
"src/engine/session/turn/execution-receipts.ts"() {
|
|
@@ -96124,7 +96175,7 @@ var init_execution_receipts = __esm({
|
|
|
96124
96175
|
).digest("hex");
|
|
96125
96176
|
this.#save(commandId, {
|
|
96126
96177
|
admissionOrder: this.#nextAdmissionOrder(),
|
|
96127
|
-
attemptId:
|
|
96178
|
+
attemptId: randomUUID16(),
|
|
96128
96179
|
commandHash,
|
|
96129
96180
|
sessionId,
|
|
96130
96181
|
started: false,
|
|
@@ -96206,7 +96257,7 @@ var init_execution_receipts = __esm({
|
|
|
96206
96257
|
if (identity2 !== void 0) {
|
|
96207
96258
|
return identity2.sessionId === sessionId && identity2.commandHash === commandHash ? { kind: "expired" } : { kind: "conflict" };
|
|
96208
96259
|
}
|
|
96209
|
-
const attemptId =
|
|
96260
|
+
const attemptId = randomUUID16();
|
|
96210
96261
|
this.#save(commandId, {
|
|
96211
96262
|
admissionOrder: this.#nextAdmissionOrder(),
|
|
96212
96263
|
attemptId,
|
|
@@ -96341,7 +96392,7 @@ var init_runtime_turn_activity = __esm({
|
|
|
96341
96392
|
});
|
|
96342
96393
|
|
|
96343
96394
|
// src/engine/session/turn/active-turn.ts
|
|
96344
|
-
import { randomUUID as
|
|
96395
|
+
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
96345
96396
|
var ActiveRuntimeTurn;
|
|
96346
96397
|
var init_active_turn = __esm({
|
|
96347
96398
|
"src/engine/session/turn/active-turn.ts"() {
|
|
@@ -96356,7 +96407,7 @@ var init_active_turn = __esm({
|
|
|
96356
96407
|
#dispatch;
|
|
96357
96408
|
#sequence = 0;
|
|
96358
96409
|
#interaction = null;
|
|
96359
|
-
#epoch = decodeIdentifier(
|
|
96410
|
+
#epoch = decodeIdentifier(randomUUID17());
|
|
96360
96411
|
constructor(command, attemptId) {
|
|
96361
96412
|
this.attemptId = attemptId;
|
|
96362
96413
|
this.command = command;
|
|
@@ -96965,11 +97016,11 @@ var init_session_layer = __esm({
|
|
|
96965
97016
|
});
|
|
96966
97017
|
|
|
96967
97018
|
// src/engine/storage/files/scratch-directory.ts
|
|
96968
|
-
import { randomUUID as
|
|
97019
|
+
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
96969
97020
|
import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile7, realpath as realpath8, rename as rename4, rm as rm3, stat as stat8, utimes, writeFile as writeFile2 } from "node:fs/promises";
|
|
96970
97021
|
import { dirname as dirname12, join as join30 } from "node:path";
|
|
96971
97022
|
async function atomicWrite(path8, bytes, signal) {
|
|
96972
|
-
const temporary = `${path8}.${
|
|
97023
|
+
const temporary = `${path8}.${randomUUID18()}.tmp`;
|
|
96973
97024
|
try {
|
|
96974
97025
|
await writeFile2(temporary, bytes, { mode: 384, signal });
|
|
96975
97026
|
signal.throwIfAborted();
|
|
@@ -96985,7 +97036,7 @@ var init_scratch_directory = __esm({
|
|
|
96985
97036
|
ScratchDirectory = class {
|
|
96986
97037
|
#root;
|
|
96987
97038
|
constructor(parent) {
|
|
96988
|
-
this.#root = join30(parent,
|
|
97039
|
+
this.#root = join30(parent, randomUUID18());
|
|
96989
97040
|
}
|
|
96990
97041
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
96991
97042
|
refreshLease = async (leaseMilliseconds) => {
|
|
@@ -99177,7 +99228,7 @@ var init_native_sessions = __esm({
|
|
|
99177
99228
|
});
|
|
99178
99229
|
|
|
99179
99230
|
// src/engine/session/prompt/apply-session-configuration.ts
|
|
99180
|
-
import { randomUUID as
|
|
99231
|
+
import { randomUUID as randomUUID19 } from "node:crypto";
|
|
99181
99232
|
function invalidSessionConfiguration(message) {
|
|
99182
99233
|
return new AcpExecutionError(message, {}, "invalid_session_configuration");
|
|
99183
99234
|
}
|
|
@@ -99315,7 +99366,7 @@ async function applySessionConfigurationSelection(sessions, options, selection,
|
|
|
99315
99366
|
booleanValue: selection.booleanValue,
|
|
99316
99367
|
configId: selection.configId,
|
|
99317
99368
|
cwd,
|
|
99318
|
-
requestId: `cfg_${
|
|
99369
|
+
requestId: `cfg_${randomUUID19()}`,
|
|
99319
99370
|
sessionId,
|
|
99320
99371
|
signal,
|
|
99321
99372
|
value: selection.value,
|
|
@@ -100899,7 +100950,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
|
|
|
100899
100950
|
const catalogAgent = await resolveCatalogAgent(config2, agentId, resolveSignal);
|
|
100900
100951
|
const environment = sessionId === void 0 ? void 0 : config2.sessionEnvironment?.({ sessionId, agentId });
|
|
100901
100952
|
const agent = environment === void 0 ? catalogAgent : catalogAgent.withEnvironment({ ...catalogAgent.environment, ...environment });
|
|
100902
|
-
return { agent, adapter: adapters.resolve(
|
|
100953
|
+
return { agent, adapter: adapters.resolve(catalogAgent) };
|
|
100903
100954
|
};
|
|
100904
100955
|
const layer = buildSessionLayer({
|
|
100905
100956
|
processes,
|
|
@@ -101284,7 +101335,7 @@ var init_engine = __esm({
|
|
|
101284
101335
|
});
|
|
101285
101336
|
|
|
101286
101337
|
// src/storage/daemon/version-data.ts
|
|
101287
|
-
import { randomUUID as
|
|
101338
|
+
import { randomUUID as randomUUID20 } from "node:crypto";
|
|
101288
101339
|
import { cp as cp2, lstat as lstat5, mkdtemp, readFile as readFile8, rename as rename5, rm as rm4, writeFile as writeFile3 } from "node:fs/promises";
|
|
101289
101340
|
import { join as join33, relative as relative3, sep as sep5 } from "node:path";
|
|
101290
101341
|
async function prepareVersionDataDirectory(root, version2, signal) {
|
|
@@ -101375,7 +101426,7 @@ async function discardVersionData(root, version2, signal) {
|
|
|
101375
101426
|
return;
|
|
101376
101427
|
}
|
|
101377
101428
|
const versions = join33(root, STATE_ROOT_LAYOUT.versions);
|
|
101378
|
-
const discarded = join33(versions, `.${version2}-discarded-${
|
|
101429
|
+
const discarded = join33(versions, `.${version2}-discarded-${randomUUID20()}`);
|
|
101379
101430
|
try {
|
|
101380
101431
|
await rename5(join33(versions, version2), discarded);
|
|
101381
101432
|
} catch (cause) {
|
|
@@ -101389,7 +101440,7 @@ async function discardVersionData(root, version2, signal) {
|
|
|
101389
101440
|
async function writeCurrentDataVersion(root, version2, signal) {
|
|
101390
101441
|
await validateLocalPath(root, true, true, signal);
|
|
101391
101442
|
await validateLocalPath(join33(root, STATE_ROOT_LAYOUT.versions, version2), true, true, signal);
|
|
101392
|
-
const temporary = join33(root, `.current-data-${
|
|
101443
|
+
const temporary = join33(root, `.current-data-${randomUUID20()}.txt`);
|
|
101393
101444
|
try {
|
|
101394
101445
|
await writeFile3(temporary, `versions/${version2}
|
|
101395
101446
|
`, { mode: 384, flag: "wx", signal });
|
|
@@ -102993,7 +103044,7 @@ var init_quit = __esm({
|
|
|
102993
103044
|
});
|
|
102994
103045
|
|
|
102995
103046
|
// src/daemon/upgrades/upgrade.ts
|
|
102996
|
-
import { randomUUID as
|
|
103047
|
+
import { randomUUID as randomUUID21 } from "node:crypto";
|
|
102997
103048
|
import { setInterval as setInterval2, setTimeout as setTimeout4 } from "node:timers/promises";
|
|
102998
103049
|
async function reportDaemonUpgradeAvailability(send2, signal) {
|
|
102999
103050
|
if (!process.connected) {
|
|
@@ -103052,7 +103103,7 @@ async function requestDaemonReleaseUpgrade(stateDirectory, currentVersion, signa
|
|
|
103052
103103
|
return await requestInstalledDaemonReleaseSwitch(stateDirectory, launch, signal);
|
|
103053
103104
|
}
|
|
103054
103105
|
async function requestInstalledDaemonReleaseSwitch(stateDirectory, launch, signal) {
|
|
103055
|
-
const id =
|
|
103106
|
+
const id = randomUUID21();
|
|
103056
103107
|
const response = decodeKnownLifecycleResponse(
|
|
103057
103108
|
await sendLocalRequest(stateDirectory, "manager", { kind: "switch", id, context: "npm", launch }, signal)
|
|
103058
103109
|
);
|