@moxt-ai/mobius 0.0.357 → 0.0.359
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 +244 -190
- 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 +18 -5
- package/dist/engine/acp/harness/codex/borrowed-agent.js.map +1 -1
- package/dist/engine/acp/harness/codex/history.js +1 -1
- package/dist/engine/acp/harness/codex/history.js.map +1 -1
- package/dist/engine/acp/harness/codex/items.js +1 -1
- package/dist/engine/acp/harness/codex/owned-agent.d.ts.map +1 -1
- package/dist/engine/acp/harness/codex/owned-agent.js +3 -2
- package/dist/engine/acp/harness/codex/owned-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 +241 -183
- package/dist/engine.js.map +4 -4
- package/package.json +2 -2
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.359",
|
|
2090
2090
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
2091
2091
|
type: "module",
|
|
2092
2092
|
bin: {
|
|
@@ -75740,17 +75740,20 @@ var init_borrowed_agent = __esm({
|
|
|
75740
75740
|
this.#seen.set(key, text2);
|
|
75741
75741
|
continue;
|
|
75742
75742
|
}
|
|
75743
|
+
if (item.type === "plan" && turn.status === "inProgress") {
|
|
75744
|
+
continue;
|
|
75745
|
+
}
|
|
75743
75746
|
const previous = this.#seen.get(key);
|
|
75744
|
-
const value = item.type === "agentMessage" ? item.text : reasoningText(item) ?? JSON.stringify(item);
|
|
75747
|
+
const value = item.type === "agentMessage" || item.type === "plan" ? item.text : reasoningText(item) ?? JSON.stringify(item);
|
|
75745
75748
|
this.#seen.set(key, value);
|
|
75746
75749
|
if (baseline || value === previous) {
|
|
75747
75750
|
continue;
|
|
75748
75751
|
}
|
|
75749
|
-
if (item.type === "agentMessage" || reasoningText(item) !== null) {
|
|
75752
|
+
if (item.type === "agentMessage" || item.type === "plan" || reasoningText(item) !== null) {
|
|
75750
75753
|
const text2 = previous !== void 0 && value.startsWith(previous) ? value.slice(previous.length) : value;
|
|
75751
75754
|
if (text2.length > 0) {
|
|
75752
75755
|
await this.#emit({
|
|
75753
|
-
sessionUpdate: item.type === "
|
|
75756
|
+
sessionUpdate: item.type === "reasoning" ? "agent_thought_chunk" : "agent_message_chunk",
|
|
75754
75757
|
messageId: item.id,
|
|
75755
75758
|
content: { type: "text", text: text2 }
|
|
75756
75759
|
});
|
|
@@ -75795,6 +75798,7 @@ var init_borrowed_agent = __esm({
|
|
|
75795
75798
|
content,
|
|
75796
75799
|
clientId: randomUUID7(),
|
|
75797
75800
|
completion: Promise.withResolvers(),
|
|
75801
|
+
settled: Promise.withResolvers(),
|
|
75798
75802
|
input: { kind: "awaiting" }
|
|
75799
75803
|
};
|
|
75800
75804
|
this.#pending = pending;
|
|
@@ -75832,7 +75836,6 @@ var init_borrowed_agent = __esm({
|
|
|
75832
75836
|
throw cause;
|
|
75833
75837
|
} finally {
|
|
75834
75838
|
signal.removeEventListener("abort", abort);
|
|
75835
|
-
this.#pending = null;
|
|
75836
75839
|
if (outcome === "cancelled") {
|
|
75837
75840
|
try {
|
|
75838
75841
|
await this.#removeQueuedInput(pending.clientId);
|
|
@@ -75840,6 +75843,8 @@ var init_borrowed_agent = __esm({
|
|
|
75840
75843
|
console.error("The cancelled Codex queued input could not be removed", cause);
|
|
75841
75844
|
}
|
|
75842
75845
|
}
|
|
75846
|
+
this.#pending = null;
|
|
75847
|
+
pending.settled.resolve();
|
|
75843
75848
|
}
|
|
75844
75849
|
};
|
|
75845
75850
|
#removeQueuedInput = async (clientId) => {
|
|
@@ -75899,7 +75904,11 @@ var init_borrowed_agent = __esm({
|
|
|
75899
75904
|
);
|
|
75900
75905
|
};
|
|
75901
75906
|
cancel = async () => {
|
|
75902
|
-
this.#pending
|
|
75907
|
+
const pending = this.#pending;
|
|
75908
|
+
if (pending !== null) {
|
|
75909
|
+
pending.completion.resolve({ stopReason: "cancelled" });
|
|
75910
|
+
await pending.settled.promise;
|
|
75911
|
+
}
|
|
75903
75912
|
};
|
|
75904
75913
|
close = async () => {
|
|
75905
75914
|
this.#lifecycle = { kind: "closed" };
|
|
@@ -76542,7 +76551,7 @@ var init_owned_agent = __esm({
|
|
|
76542
76551
|
}
|
|
76543
76552
|
return;
|
|
76544
76553
|
}
|
|
76545
|
-
if (item.type === "agentMessage") {
|
|
76554
|
+
if (item.type === "agentMessage" || item.type === "plan") {
|
|
76546
76555
|
if (method === "item/started") {
|
|
76547
76556
|
this.#agentMessages.set(item.id, "started");
|
|
76548
76557
|
return;
|
|
@@ -76963,7 +76972,7 @@ async function replayCodexHistory(client2, threadId, emit, signal) {
|
|
|
76963
76972
|
});
|
|
76964
76973
|
}
|
|
76965
76974
|
}
|
|
76966
|
-
} else if (item.type === "agentMessage") {
|
|
76975
|
+
} else if (item.type === "agentMessage" || item.type === "plan") {
|
|
76967
76976
|
await emit(agentMessageUpdate(item.id, item.text));
|
|
76968
76977
|
} else if (item.type === "reasoning") {
|
|
76969
76978
|
const text2 = reasoningText(item);
|
|
@@ -77663,16 +77672,19 @@ var init_agent = __esm({
|
|
|
77663
77672
|
*/
|
|
77664
77673
|
close = () => {
|
|
77665
77674
|
if (this.#closePromise === null) {
|
|
77666
|
-
this.#appServer.detach();
|
|
77667
77675
|
this.#closePromise = (async () => {
|
|
77668
|
-
await this.#sessionAgent.close();
|
|
77669
|
-
const child = this.#appServer.child();
|
|
77670
77676
|
try {
|
|
77671
|
-
|
|
77672
|
-
await stopProcessTree(child, captured);
|
|
77677
|
+
await this.#sessionAgent.close();
|
|
77673
77678
|
} finally {
|
|
77674
|
-
this.#
|
|
77675
|
-
this.#
|
|
77679
|
+
this.#appServer.detach();
|
|
77680
|
+
const child = this.#appServer.child();
|
|
77681
|
+
try {
|
|
77682
|
+
const captured = await captureProcessTree(child);
|
|
77683
|
+
await stopProcessTree(child, captured);
|
|
77684
|
+
} finally {
|
|
77685
|
+
this.#connection?.close();
|
|
77686
|
+
this.#onBackgroundActivity?.("none");
|
|
77687
|
+
}
|
|
77676
77688
|
}
|
|
77677
77689
|
})();
|
|
77678
77690
|
}
|
|
@@ -82842,6 +82854,7 @@ var init_adapter_registry = __esm({
|
|
|
82842
82854
|
resolve = (agent) => {
|
|
82843
82855
|
const existing = this.#adapters.get(agent.id);
|
|
82844
82856
|
if (existing !== void 0) {
|
|
82857
|
+
existing.refreshAgent(agent);
|
|
82845
82858
|
return existing;
|
|
82846
82859
|
}
|
|
82847
82860
|
const adapter = this.#resolve(agent, this.#dependencies);
|
|
@@ -83414,6 +83427,9 @@ var init_session_events = __esm({
|
|
|
83414
83427
|
get connection() {
|
|
83415
83428
|
return this.#connection.connection;
|
|
83416
83429
|
}
|
|
83430
|
+
get termination() {
|
|
83431
|
+
return this.#connection.termination;
|
|
83432
|
+
}
|
|
83417
83433
|
initialize = (signal) => this.#connection.initialize(signal);
|
|
83418
83434
|
agentSettingsModelEffort = () => this.#connection.agentSettingsModelEffort();
|
|
83419
83435
|
race = (operation, exitMessage, signal) => this.#connection.race(operation, exitMessage, signal);
|
|
@@ -83543,6 +83559,7 @@ var init_live_sessions = __esm({
|
|
|
83543
83559
|
"ACP agent exited while cancelling a prompt",
|
|
83544
83560
|
bounded
|
|
83545
83561
|
);
|
|
83562
|
+
return "retained";
|
|
83546
83563
|
};
|
|
83547
83564
|
closeSession = async (target, signal) => {
|
|
83548
83565
|
const session = this.#find(target);
|
|
@@ -83749,7 +83766,7 @@ var init_live_sessions = __esm({
|
|
|
83749
83766
|
});
|
|
83750
83767
|
|
|
83751
83768
|
// src/engine/acp/adapter/native-session-lookup.ts
|
|
83752
|
-
async function findNativeSession(list,
|
|
83769
|
+
async function findNativeSession(list, cwd, nativeSessionId, budget, signal) {
|
|
83753
83770
|
const decoded = lookupSchema.safeParse({ nativeSessionId, budget });
|
|
83754
83771
|
if (!decoded.success) {
|
|
83755
83772
|
throw new AcpExecutionError(
|
|
@@ -83763,9 +83780,9 @@ async function findNativeSession(list, query, nativeSessionId, budget) {
|
|
|
83763
83780
|
let inspected = 0;
|
|
83764
83781
|
const visited = /* @__PURE__ */ new Set();
|
|
83765
83782
|
for (let pageNumber = 0; pageNumber < limits.maximumPages; pageNumber += 1) {
|
|
83766
|
-
|
|
83767
|
-
const page = await list(
|
|
83768
|
-
|
|
83783
|
+
signal.throwIfAborted();
|
|
83784
|
+
const page = await list(cwd, cursor, signal);
|
|
83785
|
+
signal.throwIfAborted();
|
|
83769
83786
|
inspected += page.sessions.length;
|
|
83770
83787
|
const found = page.sessions.find((session) => session.sessionId === decoded.data.nativeSessionId);
|
|
83771
83788
|
if (found !== void 0) {
|
|
@@ -84546,51 +84563,56 @@ var AcpQuerySession;
|
|
|
84546
84563
|
var init_query_session = __esm({
|
|
84547
84564
|
"src/engine/acp/adapter/query-session.ts"() {
|
|
84548
84565
|
"use strict";
|
|
84549
|
-
init_value_utils();
|
|
84550
84566
|
init_acp_error();
|
|
84551
84567
|
init_native_session();
|
|
84552
84568
|
init_session_capabilities();
|
|
84553
84569
|
init_agent_initialization();
|
|
84554
84570
|
AcpQuerySession = class _AcpQuerySession {
|
|
84555
|
-
#
|
|
84571
|
+
#cwd;
|
|
84572
|
+
#sessionId;
|
|
84556
84573
|
#events;
|
|
84557
84574
|
#connection;
|
|
84575
|
+
#lifecycle = { kind: "open" };
|
|
84558
84576
|
#capabilities = unsupportedSessionCapabilities();
|
|
84559
84577
|
#configOptions = [];
|
|
84560
|
-
constructor(
|
|
84561
|
-
this.#
|
|
84578
|
+
constructor(agent, cwd, sessionId, events, connector) {
|
|
84579
|
+
this.#cwd = cwd;
|
|
84580
|
+
this.#sessionId = sessionId;
|
|
84562
84581
|
this.#events = events;
|
|
84563
84582
|
this.#connection = connector.connectQuerySession({
|
|
84564
|
-
agent
|
|
84565
|
-
cwd
|
|
84566
|
-
sessionId: () =>
|
|
84583
|
+
agent,
|
|
84584
|
+
cwd,
|
|
84585
|
+
sessionId: () => sessionId,
|
|
84567
84586
|
configOptions: () => this.#configOptions,
|
|
84568
84587
|
onEvent: async (event) => {
|
|
84569
|
-
this.#events.append(
|
|
84588
|
+
this.#events.append(sessionId, { type: "acp", payload: event.payload });
|
|
84570
84589
|
if (event.kind === "configuration") {
|
|
84571
84590
|
this.#configOptions = event.configOptions;
|
|
84572
84591
|
}
|
|
84573
84592
|
}
|
|
84574
84593
|
});
|
|
84594
|
+
void this.#connection.termination.then(() => {
|
|
84595
|
+
this.#lifecycle = { kind: "terminated" };
|
|
84596
|
+
});
|
|
84575
84597
|
}
|
|
84576
|
-
static start = async (
|
|
84598
|
+
static start = async (agent, cwd, sessionId, events, connector, signal) => {
|
|
84577
84599
|
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
84578
|
-
await validateAgentRuntime(
|
|
84579
|
-
const runtime = new _AcpQuerySession(
|
|
84600
|
+
await validateAgentRuntime(agent, signal);
|
|
84601
|
+
const runtime = new _AcpQuerySession(agent, cwd, sessionId, events, connector);
|
|
84580
84602
|
try {
|
|
84581
84603
|
const initialized = await initializeAgentConnection(
|
|
84582
84604
|
runtime.#connection,
|
|
84583
|
-
|
|
84584
|
-
|
|
84585
|
-
|
|
84605
|
+
agent.id,
|
|
84606
|
+
agent.agentVersion,
|
|
84607
|
+
signal
|
|
84586
84608
|
);
|
|
84587
84609
|
runtime.#capabilities = initialized.capabilities;
|
|
84588
84610
|
return runtime;
|
|
84589
84611
|
} catch (error62) {
|
|
84590
84612
|
await runtime.closeProcess();
|
|
84591
|
-
|
|
84613
|
+
signal.throwIfAborted();
|
|
84592
84614
|
if (error62 instanceof RetryableAcpInitializationError && attempt === 1) {
|
|
84593
|
-
console.warn(`[${
|
|
84615
|
+
console.warn(`[${agent.id}-acp] ACP agent initialization failed; retrying once`);
|
|
84594
84616
|
continue;
|
|
84595
84617
|
}
|
|
84596
84618
|
if (error62 instanceof AcpExecutionError) {
|
|
@@ -84602,7 +84624,18 @@ var init_query_session = __esm({
|
|
|
84602
84624
|
throw new AcpExecutionError("ACP agent initialization failed");
|
|
84603
84625
|
};
|
|
84604
84626
|
capabilities = () => this.#capabilities;
|
|
84605
|
-
|
|
84627
|
+
hasTerminated = () => {
|
|
84628
|
+
switch (this.#lifecycle.kind) {
|
|
84629
|
+
case "open":
|
|
84630
|
+
return false;
|
|
84631
|
+
case "terminated":
|
|
84632
|
+
return true;
|
|
84633
|
+
default: {
|
|
84634
|
+
const unreachable3 = this.#lifecycle;
|
|
84635
|
+
return unreachable3;
|
|
84636
|
+
}
|
|
84637
|
+
}
|
|
84638
|
+
};
|
|
84606
84639
|
listNativeSessions = async (cursor, signal) => {
|
|
84607
84640
|
if (!this.#capabilities.listSessions) {
|
|
84608
84641
|
throw new AcpExecutionError(
|
|
@@ -84628,7 +84661,7 @@ var init_query_session = __esm({
|
|
|
84628
84661
|
}
|
|
84629
84662
|
return decoded.data;
|
|
84630
84663
|
};
|
|
84631
|
-
previewEvents = async (nativeSessionId, eventLimit, signal) => {
|
|
84664
|
+
previewEvents = async (nativeSessionId, eventLimit, additionalDirectories, signal) => {
|
|
84632
84665
|
if (!this.#capabilities.loadSession) {
|
|
84633
84666
|
throw new AcpExecutionError(
|
|
84634
84667
|
"This Agent restores context but does not provide message history.",
|
|
@@ -84636,14 +84669,14 @@ var init_query_session = __esm({
|
|
|
84636
84669
|
"native_history_unsupported"
|
|
84637
84670
|
);
|
|
84638
84671
|
}
|
|
84639
|
-
this.#events.reset(this.#
|
|
84672
|
+
this.#events.reset(this.#sessionId);
|
|
84640
84673
|
this.#connection.events.select(nativeSessionId);
|
|
84641
84674
|
await this.#connection.race(
|
|
84642
84675
|
this.#connection.connection.agent.request(
|
|
84643
84676
|
methods12.agent.session.load,
|
|
84644
84677
|
{
|
|
84645
|
-
additionalDirectories: [...
|
|
84646
|
-
cwd: this.#
|
|
84678
|
+
additionalDirectories: [...additionalDirectories],
|
|
84679
|
+
cwd: this.#cwd,
|
|
84647
84680
|
mcpServers: [],
|
|
84648
84681
|
sessionId: nativeSessionId
|
|
84649
84682
|
},
|
|
@@ -84654,14 +84687,16 @@ var init_query_session = __esm({
|
|
|
84654
84687
|
);
|
|
84655
84688
|
await this.#connection.events.drained();
|
|
84656
84689
|
signal.throwIfAborted();
|
|
84657
|
-
return this.#events.page(this.#
|
|
84690
|
+
return this.#events.page(this.#sessionId, eventLimit, null);
|
|
84658
84691
|
};
|
|
84659
84692
|
closeProcess = async () => await this.#connection.closeProcess();
|
|
84693
|
+
discardEvents = () => this.#events.remove(this.#sessionId);
|
|
84660
84694
|
};
|
|
84661
84695
|
}
|
|
84662
84696
|
});
|
|
84663
84697
|
|
|
84664
84698
|
// src/engine/acp/adapter/query-processes.ts
|
|
84699
|
+
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
84665
84700
|
var AgentQueryProcesses;
|
|
84666
84701
|
var init_query_processes = __esm({
|
|
84667
84702
|
"src/engine/acp/adapter/query-processes.ts"() {
|
|
@@ -84669,121 +84704,99 @@ var init_query_processes = __esm({
|
|
|
84669
84704
|
init_session_event_store();
|
|
84670
84705
|
init_operation_drain();
|
|
84671
84706
|
init_retained_agent_processes();
|
|
84672
|
-
init_acp_error();
|
|
84673
84707
|
init_query_session();
|
|
84674
84708
|
AgentQueryProcesses = class {
|
|
84675
84709
|
#eventPreviewsBySession = /* @__PURE__ */ new Map();
|
|
84676
|
-
#
|
|
84710
|
+
#processesByAgent = /* @__PURE__ */ new Map();
|
|
84711
|
+
#agent;
|
|
84677
84712
|
#processes;
|
|
84678
84713
|
#store = new MemorySessionEventStore();
|
|
84679
84714
|
#connector;
|
|
84680
|
-
constructor(processes, connector) {
|
|
84715
|
+
constructor(agent, processes, connector) {
|
|
84716
|
+
this.#agent = agent;
|
|
84681
84717
|
this.#processes = processes;
|
|
84682
84718
|
this.#connector = connector;
|
|
84683
|
-
this.#processesByQuery = new RetainedAgentProcesses({
|
|
84684
|
-
touch: processes.touch,
|
|
84685
|
-
changed: processes.notifyChanged
|
|
84686
|
-
});
|
|
84687
84719
|
}
|
|
84688
|
-
|
|
84689
|
-
|
|
84690
|
-
|
|
84691
|
-
|
|
84720
|
+
refreshAgent = (agent) => {
|
|
84721
|
+
this.#agent = agent;
|
|
84722
|
+
};
|
|
84723
|
+
retire = async (readers, cwd, runtime) => {
|
|
84724
|
+
readers.detach(cwd, runtime);
|
|
84725
|
+
try {
|
|
84726
|
+
await this.#processes.retire(runtime, () => runtime.closeProcess());
|
|
84727
|
+
} finally {
|
|
84728
|
+
runtime.discardEvents();
|
|
84692
84729
|
}
|
|
84693
|
-
await this.#processes.retire(runtime, () => runtime.closeProcess());
|
|
84694
84730
|
};
|
|
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);
|
|
84731
|
+
async #ensure(agent, readers, cwd, signal) {
|
|
84732
|
+
signal.throwIfAborted();
|
|
84733
|
+
const pending = readers.pending(cwd);
|
|
84721
84734
|
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();
|
|
84735
|
+
return await waitForSharedOperation(pending, signal);
|
|
84737
84736
|
}
|
|
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);
|
|
84737
|
+
const existing = readers.get(cwd);
|
|
84738
|
+
if (existing !== void 0 && !existing.hasTerminated()) {
|
|
84739
|
+
readers.touch(cwd, existing);
|
|
84752
84740
|
return existing;
|
|
84753
84741
|
}
|
|
84754
|
-
await
|
|
84755
|
-
|
|
84756
|
-
|
|
84757
|
-
|
|
84758
|
-
|
|
84759
|
-
|
|
84742
|
+
return await readers.prepare(cwd, async () => {
|
|
84743
|
+
if (existing !== void 0) {
|
|
84744
|
+
await this.retire(readers, cwd, existing);
|
|
84745
|
+
}
|
|
84746
|
+
const readerId = randomUUID14();
|
|
84747
|
+
const runtime = await this.#processes.startRetained(
|
|
84748
|
+
signal,
|
|
84749
|
+
() => AcpQuerySession.start(agent, cwd, readerId, this.#store, this.#connector, signal),
|
|
84750
|
+
{
|
|
84751
|
+
isBusy: () => readers.isBusy(cwd),
|
|
84752
|
+
retire: (runtime2) => this.retire(readers, cwd, runtime2),
|
|
84753
|
+
retireIdle: (runtime2) => this.retire(readers, cwd, runtime2)
|
|
84754
|
+
}
|
|
84755
|
+
);
|
|
84756
|
+
readers.retain(cwd, runtime);
|
|
84757
|
+
return runtime;
|
|
84758
|
+
});
|
|
84760
84759
|
}
|
|
84761
|
-
#use = async (
|
|
84762
|
-
|
|
84763
|
-
|
|
84764
|
-
|
|
84765
|
-
|
|
84760
|
+
#use = async (cwd, signal, operation) => {
|
|
84761
|
+
const agent = this.#agent;
|
|
84762
|
+
let readers = this.#processesByAgent.get(agent);
|
|
84763
|
+
if (readers === void 0) {
|
|
84764
|
+
readers = new RetainedAgentProcesses({
|
|
84765
|
+
touch: this.#processes.touch,
|
|
84766
|
+
changed: this.#processes.notifyChanged
|
|
84767
|
+
});
|
|
84768
|
+
this.#processesByAgent.set(agent, readers);
|
|
84769
|
+
}
|
|
84770
|
+
const current = readers;
|
|
84771
|
+
return await current.use(cwd, async () => await operation(await this.#ensure(agent, current, cwd, signal)));
|
|
84772
|
+
};
|
|
84773
|
+
capabilities = async (cwd, signal) => await this.#use(cwd, signal, async (runtime) => runtime.capabilities());
|
|
84774
|
+
listNativeSessions = async (cwd, cursor, signal) => await this.#use(cwd, signal, async (runtime) => await runtime.listNativeSessions(cursor, signal));
|
|
84775
|
+
previewSessionEvents = async (cwd, additionalDirectories, request, signal) => {
|
|
84776
|
+
signal.throwIfAborted();
|
|
84777
|
+
const agent = this.#agent;
|
|
84778
|
+
const { nativeSessionId, eventLimit, cursor, sessionId } = request;
|
|
84766
84779
|
if (cursor !== null) {
|
|
84767
|
-
const preview = this.#eventPreviewsBySession.get(
|
|
84780
|
+
const preview = this.#eventPreviewsBySession.get(sessionId);
|
|
84768
84781
|
if (preview === void 0 || preview.nativeSessionId !== nativeSessionId) {
|
|
84769
84782
|
throw new Error("The native event cursor is invalid");
|
|
84770
84783
|
}
|
|
84771
|
-
return preview.store.page(
|
|
84784
|
+
return preview.store.page(sessionId, eventLimit, cursor);
|
|
84772
84785
|
}
|
|
84773
84786
|
const store = new MemorySessionEventStore();
|
|
84774
|
-
const previous = this.#eventPreviewsBySession.get(
|
|
84787
|
+
const previous = this.#eventPreviewsBySession.get(sessionId);
|
|
84775
84788
|
previous?.store.close();
|
|
84776
|
-
this.#eventPreviewsBySession.set(
|
|
84789
|
+
this.#eventPreviewsBySession.set(sessionId, { nativeSessionId, store });
|
|
84777
84790
|
try {
|
|
84778
84791
|
return await this.#processes.runTransient(
|
|
84779
|
-
|
|
84780
|
-
async () => await AcpQuerySession.start(
|
|
84781
|
-
async (runtime) => await runtime.previewEvents(nativeSessionId, eventLimit,
|
|
84792
|
+
signal,
|
|
84793
|
+
async () => await AcpQuerySession.start(agent, cwd, sessionId, store, this.#connector, signal),
|
|
84794
|
+
async (runtime) => await runtime.previewEvents(nativeSessionId, eventLimit, additionalDirectories, signal),
|
|
84782
84795
|
async (runtime) => await runtime.closeProcess()
|
|
84783
84796
|
);
|
|
84784
84797
|
} catch (error62) {
|
|
84785
|
-
if (this.#eventPreviewsBySession.get(
|
|
84786
|
-
this.#eventPreviewsBySession.delete(
|
|
84798
|
+
if (this.#eventPreviewsBySession.get(sessionId)?.store === store) {
|
|
84799
|
+
this.#eventPreviewsBySession.delete(sessionId);
|
|
84787
84800
|
}
|
|
84788
84801
|
store.close();
|
|
84789
84802
|
throw error62;
|
|
@@ -84791,8 +84804,11 @@ var init_query_processes = __esm({
|
|
|
84791
84804
|
};
|
|
84792
84805
|
close = async () => {
|
|
84793
84806
|
await Promise.all(
|
|
84794
|
-
this.#
|
|
84807
|
+
[...this.#processesByAgent.values()].flatMap(
|
|
84808
|
+
(readers) => readers.entries().map(async ([cwd, runtime]) => await this.retire(readers, cwd, runtime))
|
|
84809
|
+
)
|
|
84795
84810
|
);
|
|
84811
|
+
this.#processesByAgent.clear();
|
|
84796
84812
|
for (const preview of this.#eventPreviewsBySession.values()) {
|
|
84797
84813
|
preview.store.close();
|
|
84798
84814
|
}
|
|
@@ -84817,12 +84833,13 @@ var init_adapter = __esm({
|
|
|
84817
84833
|
#queryProcesses;
|
|
84818
84834
|
#connector;
|
|
84819
84835
|
#liveSessions;
|
|
84820
|
-
constructor(dependencies) {
|
|
84836
|
+
constructor(agent, dependencies) {
|
|
84821
84837
|
this.#connector = new AcpSessionConnector(dependencies.contentExternalizer);
|
|
84822
84838
|
this.#liveSessions = new AcpLiveSessions(dependencies.contentExternalizer);
|
|
84823
|
-
this.#queryProcesses = new AgentQueryProcesses(dependencies.processes, this.#connector);
|
|
84839
|
+
this.#queryProcesses = new AgentQueryProcesses(agent, dependencies.processes, this.#connector);
|
|
84824
84840
|
}
|
|
84825
|
-
|
|
84841
|
+
refreshAgent = (agent) => this.#queryProcesses.refreshAgent(agent);
|
|
84842
|
+
getCapabilities = (cwd, signal) => this.#queryProcesses.capabilities(cwd, signal);
|
|
84826
84843
|
connectSession = (options) => this.#liveSessions.connectSession(options);
|
|
84827
84844
|
cancel = (...args) => this.#liveSessions.cancel(...args);
|
|
84828
84845
|
closeSession = (...args) => this.#liveSessions.closeSession(...args);
|
|
@@ -84830,9 +84847,9 @@ var init_adapter = __esm({
|
|
|
84830
84847
|
steer = (...args) => this.#liveSessions.steer(...args);
|
|
84831
84848
|
renameSession = (...args) => this.#liveSessions.renameSession(...args);
|
|
84832
84849
|
configureSession = (...args) => this.#liveSessions.configureSession(...args);
|
|
84833
|
-
listSessions =
|
|
84834
|
-
findSession = (
|
|
84835
|
-
readSessionHistory =
|
|
84850
|
+
listSessions = (cwd, cursor, signal) => this.#queryProcesses.listNativeSessions(cwd, cursor, signal);
|
|
84851
|
+
findSession = (cwd, nativeSessionId, budget, signal) => findNativeSession(this.listSessions, cwd, nativeSessionId, budget, signal);
|
|
84852
|
+
readSessionHistory = (cwd, additionalDirectories, request, signal) => this.#queryProcesses.previewSessionEvents(cwd, additionalDirectories, request, signal);
|
|
84836
84853
|
close = async () => await runCleanup(
|
|
84837
84854
|
() => this.#queryProcesses.close(),
|
|
84838
84855
|
() => this.#liveSessions.close()
|
|
@@ -90769,13 +90786,15 @@ var init_adapter2 = __esm({
|
|
|
90769
90786
|
init_session_events();
|
|
90770
90787
|
init_tool_event();
|
|
90771
90788
|
CodexAdapter = class {
|
|
90789
|
+
#agent;
|
|
90772
90790
|
#queryProcesses;
|
|
90773
90791
|
#connector;
|
|
90774
90792
|
#liveSessions;
|
|
90775
90793
|
#dependencies;
|
|
90776
90794
|
#contentExternalizer;
|
|
90777
90795
|
#previewCache = null;
|
|
90778
|
-
constructor(dependencies) {
|
|
90796
|
+
constructor(agent, dependencies) {
|
|
90797
|
+
this.#agent = agent;
|
|
90779
90798
|
this.#dependencies = dependencies;
|
|
90780
90799
|
this.#contentExternalizer = {
|
|
90781
90800
|
update: async (sessionId, update, signal) => {
|
|
@@ -90787,18 +90806,25 @@ var init_adapter2 = __esm({
|
|
|
90787
90806
|
};
|
|
90788
90807
|
this.#connector = new AcpSessionConnector(this.#contentExternalizer, fitCodexToolEvent);
|
|
90789
90808
|
this.#liveSessions = new AcpLiveSessions(this.#contentExternalizer, fitCodexToolEvent);
|
|
90790
|
-
this.#queryProcesses = new AgentQueryProcesses(dependencies.processes, this.#connector);
|
|
90809
|
+
this.#queryProcesses = new AgentQueryProcesses(agent, dependencies.processes, this.#connector);
|
|
90791
90810
|
}
|
|
90792
|
-
|
|
90811
|
+
refreshAgent = (agent) => {
|
|
90812
|
+
this.#agent = agent;
|
|
90813
|
+
this.#queryProcesses.refreshAgent(agent);
|
|
90814
|
+
};
|
|
90815
|
+
getCapabilities = (cwd, signal) => this.#queryProcesses.capabilities(cwd, signal);
|
|
90793
90816
|
connectSession = (options) => this.#liveSessions.connectSession(options);
|
|
90794
|
-
cancel = (
|
|
90817
|
+
cancel = async (target, signal) => {
|
|
90818
|
+
await this.#liveSessions.closeSession(target, signal);
|
|
90819
|
+
return "closed";
|
|
90820
|
+
};
|
|
90795
90821
|
closeSession = (...args) => this.#liveSessions.closeSession(...args);
|
|
90796
90822
|
prompt = (...args) => this.#liveSessions.prompt(...args);
|
|
90797
90823
|
steer = (...args) => this.#liveSessions.steer(...args);
|
|
90798
90824
|
renameSession = (...args) => this.#liveSessions.renameSession(...args);
|
|
90799
90825
|
configureSession = (...args) => this.#liveSessions.configureSession(...args);
|
|
90800
|
-
listSessions =
|
|
90801
|
-
findSession = (
|
|
90826
|
+
listSessions = (cwd, cursor, signal) => this.#queryProcesses.listNativeSessions(cwd, cursor, signal);
|
|
90827
|
+
findSession = (cwd, nativeSessionId, budget, signal) => findNativeSession(this.listSessions, cwd, nativeSessionId, budget, signal);
|
|
90802
90828
|
close = async () => {
|
|
90803
90829
|
await runCleanup(
|
|
90804
90830
|
() => this.#queryProcesses.close(),
|
|
@@ -90806,9 +90832,9 @@ var init_adapter2 = __esm({
|
|
|
90806
90832
|
() => this.#previewCache?.close()
|
|
90807
90833
|
);
|
|
90808
90834
|
};
|
|
90809
|
-
readSessionHistory = async (
|
|
90810
|
-
const
|
|
90811
|
-
const signal = AbortSignal.any([
|
|
90835
|
+
readSessionHistory = async (cwd, _additionalDirectories, request, cancellation) => {
|
|
90836
|
+
const agent = this.#agent;
|
|
90837
|
+
const signal = AbortSignal.any([cancellation, AbortSignal.timeout(6e4)]);
|
|
90812
90838
|
const { sessionId } = request;
|
|
90813
90839
|
signal.throwIfAborted();
|
|
90814
90840
|
nativeSessionIdSchema.parse(request.nativeSessionId);
|
|
@@ -90895,12 +90921,13 @@ var init_adapter3 = __esm({
|
|
|
90895
90921
|
#queryProcesses;
|
|
90896
90922
|
#connector;
|
|
90897
90923
|
#liveSessions;
|
|
90898
|
-
constructor(dependencies) {
|
|
90924
|
+
constructor(agent, dependencies) {
|
|
90899
90925
|
this.#connector = new AcpSessionConnector(dependencies.contentExternalizer);
|
|
90900
90926
|
this.#liveSessions = new AcpLiveSessions(dependencies.contentExternalizer);
|
|
90901
|
-
this.#queryProcesses = new AgentQueryProcesses(dependencies.processes, this.#connector);
|
|
90927
|
+
this.#queryProcesses = new AgentQueryProcesses(agent, dependencies.processes, this.#connector);
|
|
90902
90928
|
}
|
|
90903
|
-
|
|
90929
|
+
refreshAgent = (agent) => this.#queryProcesses.refreshAgent(agent);
|
|
90930
|
+
getCapabilities = (cwd, signal) => this.#queryProcesses.capabilities(cwd, signal);
|
|
90904
90931
|
connectSession = (options) => this.#liveSessions.connectSession(options);
|
|
90905
90932
|
cancel = (...args) => this.#liveSessions.cancel(...args);
|
|
90906
90933
|
closeSession = (...args) => this.#liveSessions.closeSession(...args);
|
|
@@ -90908,9 +90935,9 @@ var init_adapter3 = __esm({
|
|
|
90908
90935
|
steer = (...args) => this.#liveSessions.steer(...args);
|
|
90909
90936
|
renameSession = (...args) => this.#liveSessions.renameSession(...args);
|
|
90910
90937
|
configureSession = (...args) => this.#liveSessions.configureSession(...args);
|
|
90911
|
-
listSessions =
|
|
90912
|
-
findSession = (
|
|
90913
|
-
readSessionHistory =
|
|
90938
|
+
listSessions = (cwd, cursor, signal) => this.#queryProcesses.listNativeSessions(cwd, cursor, signal);
|
|
90939
|
+
findSession = (cwd, nativeSessionId, budget, signal) => findNativeSession(this.listSessions, cwd, nativeSessionId, budget, signal);
|
|
90940
|
+
readSessionHistory = (cwd, additionalDirectories, request, signal) => this.#queryProcesses.previewSessionEvents(cwd, additionalDirectories, request, signal);
|
|
90914
90941
|
close = async () => await runCleanup(
|
|
90915
90942
|
() => this.#queryProcesses.close(),
|
|
90916
90943
|
() => this.#liveSessions.close()
|
|
@@ -90931,11 +90958,11 @@ var init_registry = __esm({
|
|
|
90931
90958
|
harnessAdapters = (agent, dependencies) => {
|
|
90932
90959
|
switch (agent.id) {
|
|
90933
90960
|
case "codex":
|
|
90934
|
-
return new CodexAdapter(dependencies);
|
|
90961
|
+
return new CodexAdapter(agent, dependencies);
|
|
90935
90962
|
case "claude":
|
|
90936
|
-
return new ClaudeAdapter(dependencies);
|
|
90963
|
+
return new ClaudeAdapter(agent, dependencies);
|
|
90937
90964
|
case "pi":
|
|
90938
|
-
return new PiAdapter(dependencies);
|
|
90965
|
+
return new PiAdapter(agent, dependencies);
|
|
90939
90966
|
default:
|
|
90940
90967
|
throw new AcpExecutionError(
|
|
90941
90968
|
`Agent "${agent.id}" has no registered harness adapter.`,
|
|
@@ -94309,8 +94336,9 @@ var init_agent_session = __esm({
|
|
|
94309
94336
|
await this.#interactions.cancelPendingInteractions();
|
|
94310
94337
|
signal.throwIfAborted();
|
|
94311
94338
|
if (this.#turn.running) {
|
|
94312
|
-
await this.#adapter.cancel(this.#target(), signal);
|
|
94339
|
+
return await this.#adapter.cancel(this.#target(), signal);
|
|
94313
94340
|
}
|
|
94341
|
+
return "retained";
|
|
94314
94342
|
};
|
|
94315
94343
|
respondPermission = async (options) => {
|
|
94316
94344
|
await this.#interactions.respondPermission(options);
|
|
@@ -94980,7 +95008,18 @@ var init_session_manager = __esm({
|
|
|
94980
95008
|
await this.#executions.cancel(sessionId, async () => {
|
|
94981
95009
|
const runtime = this.#executionProcesses.get(sessionId);
|
|
94982
95010
|
if (runtime !== void 0) {
|
|
94983
|
-
await runtime.cancel(signal2);
|
|
95011
|
+
const outcome = await runtime.cancel(signal2);
|
|
95012
|
+
switch (outcome) {
|
|
95013
|
+
case "retained":
|
|
95014
|
+
break;
|
|
95015
|
+
case "closed":
|
|
95016
|
+
await this.#stopSessionProcess(sessionId, runtime);
|
|
95017
|
+
break;
|
|
95018
|
+
default: {
|
|
95019
|
+
const unreachable3 = outcome;
|
|
95020
|
+
throw new AcpExecutionError("Unexpected cancellation outcome", { cause: unreachable3 });
|
|
95021
|
+
}
|
|
95022
|
+
}
|
|
94984
95023
|
}
|
|
94985
95024
|
});
|
|
94986
95025
|
});
|
|
@@ -95363,7 +95402,7 @@ var init_local_authorization_error = __esm({
|
|
|
95363
95402
|
});
|
|
95364
95403
|
|
|
95365
95404
|
// src/engine/session/native/native-session-browser.ts
|
|
95366
|
-
import { randomUUID as
|
|
95405
|
+
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
95367
95406
|
function nextForkTitle(sourceTitle, sessions) {
|
|
95368
95407
|
let highest = 0;
|
|
95369
95408
|
for (const session of sessions) {
|
|
@@ -95421,12 +95460,17 @@ var init_native_session_browser = __esm({
|
|
|
95421
95460
|
(scoped) => this.#sessions.withNativeSessionOperation(
|
|
95422
95461
|
scoped,
|
|
95423
95462
|
nativeSessionId,
|
|
95424
|
-
(target) => target.adapter.readSessionHistory(
|
|
95425
|
-
|
|
95426
|
-
|
|
95427
|
-
|
|
95428
|
-
|
|
95429
|
-
|
|
95463
|
+
(target) => target.adapter.readSessionHistory(
|
|
95464
|
+
target.cwd,
|
|
95465
|
+
target.additionalDirectories,
|
|
95466
|
+
{
|
|
95467
|
+
nativeSessionId,
|
|
95468
|
+
eventLimit,
|
|
95469
|
+
cursor,
|
|
95470
|
+
sessionId: target.sessionId
|
|
95471
|
+
},
|
|
95472
|
+
target.signal
|
|
95473
|
+
)
|
|
95430
95474
|
)
|
|
95431
95475
|
);
|
|
95432
95476
|
#execute = async (command, signal) => {
|
|
@@ -95457,7 +95501,7 @@ var init_native_session_browser = __esm({
|
|
|
95457
95501
|
queuedCancellation: "before-start"
|
|
95458
95502
|
};
|
|
95459
95503
|
}
|
|
95460
|
-
const capabilities = await options.adapter.getCapabilities(
|
|
95504
|
+
const capabilities = await options.adapter.getCapabilities(cwd, signal);
|
|
95461
95505
|
if (!capabilities.listSessions) {
|
|
95462
95506
|
throw new AcpExecutionError(
|
|
95463
95507
|
"This Agent does not support native session listing",
|
|
@@ -95472,7 +95516,7 @@ var init_native_session_browser = __esm({
|
|
|
95472
95516
|
if (authorized === null) {
|
|
95473
95517
|
return null;
|
|
95474
95518
|
}
|
|
95475
|
-
const entryId = decodeIdentifier(
|
|
95519
|
+
const entryId = decodeIdentifier(randomUUID15());
|
|
95476
95520
|
if (this.#entries.size >= 5e3) {
|
|
95477
95521
|
this.#entries.clear();
|
|
95478
95522
|
}
|
|
@@ -95511,7 +95555,7 @@ var init_native_session_browser = __esm({
|
|
|
95511
95555
|
}
|
|
95512
95556
|
cursor = known.cursor;
|
|
95513
95557
|
}
|
|
95514
|
-
const page = await options.adapter.listSessions(
|
|
95558
|
+
const page = await options.adapter.listSessions(cwd, cursor, signal);
|
|
95515
95559
|
const entries = [];
|
|
95516
95560
|
for (const info of page.sessions) {
|
|
95517
95561
|
const entry = await register(info);
|
|
@@ -95528,7 +95572,7 @@ var init_native_session_browser = __esm({
|
|
|
95528
95572
|
"invalid_native_session_response"
|
|
95529
95573
|
);
|
|
95530
95574
|
}
|
|
95531
|
-
nextCursor = decodeIdentifier(
|
|
95575
|
+
nextCursor = decodeIdentifier(randomUUID15());
|
|
95532
95576
|
if (this.#cursors.size >= 500) {
|
|
95533
95577
|
this.#cursors.clear();
|
|
95534
95578
|
}
|
|
@@ -95546,10 +95590,15 @@ var init_native_session_browser = __esm({
|
|
|
95546
95590
|
};
|
|
95547
95591
|
}
|
|
95548
95592
|
if (command.action === "find") {
|
|
95549
|
-
const found = await options.adapter.findSession(
|
|
95550
|
-
|
|
95551
|
-
|
|
95552
|
-
|
|
95593
|
+
const found = await options.adapter.findSession(
|
|
95594
|
+
cwd,
|
|
95595
|
+
command.nativeSessionId,
|
|
95596
|
+
{
|
|
95597
|
+
maximumPages: 500,
|
|
95598
|
+
maximumEntries: 500
|
|
95599
|
+
},
|
|
95600
|
+
signal
|
|
95601
|
+
);
|
|
95553
95602
|
const entry = await register(found);
|
|
95554
95603
|
if (entry !== null) {
|
|
95555
95604
|
return { ...envelope2, action: "find", entry };
|
|
@@ -95687,10 +95736,15 @@ var init_native_session_browser = __esm({
|
|
|
95687
95736
|
}
|
|
95688
95737
|
};
|
|
95689
95738
|
resolveTarget = async (command, options, selected) => {
|
|
95690
|
-
const info = await options.adapter.findSession(
|
|
95691
|
-
|
|
95692
|
-
|
|
95693
|
-
|
|
95739
|
+
const info = await options.adapter.findSession(
|
|
95740
|
+
options.cwd,
|
|
95741
|
+
selected.nativeSessionId,
|
|
95742
|
+
{
|
|
95743
|
+
maximumPages: 100,
|
|
95744
|
+
maximumEntries: null
|
|
95745
|
+
},
|
|
95746
|
+
options.signal
|
|
95747
|
+
).catch((cause) => {
|
|
95694
95748
|
options.signal.throwIfAborted();
|
|
95695
95749
|
if (cause instanceof AcpExecutionError && cause.code === "native_session_not_found") {
|
|
95696
95750
|
throw new AcpExecutionError(
|
|
@@ -95977,7 +96031,7 @@ var init_prompt_lifecycle = __esm({
|
|
|
95977
96031
|
});
|
|
95978
96032
|
|
|
95979
96033
|
// src/engine/session/turn/execution-receipts.ts
|
|
95980
|
-
import { createHash as createHash7, randomUUID as
|
|
96034
|
+
import { createHash as createHash7, randomUUID as randomUUID16 } from "node:crypto";
|
|
95981
96035
|
var MAX_TERMINAL_RECEIPTS, ExecutionReceipts;
|
|
95982
96036
|
var init_execution_receipts = __esm({
|
|
95983
96037
|
"src/engine/session/turn/execution-receipts.ts"() {
|
|
@@ -96124,7 +96178,7 @@ var init_execution_receipts = __esm({
|
|
|
96124
96178
|
).digest("hex");
|
|
96125
96179
|
this.#save(commandId, {
|
|
96126
96180
|
admissionOrder: this.#nextAdmissionOrder(),
|
|
96127
|
-
attemptId:
|
|
96181
|
+
attemptId: randomUUID16(),
|
|
96128
96182
|
commandHash,
|
|
96129
96183
|
sessionId,
|
|
96130
96184
|
started: false,
|
|
@@ -96206,7 +96260,7 @@ var init_execution_receipts = __esm({
|
|
|
96206
96260
|
if (identity2 !== void 0) {
|
|
96207
96261
|
return identity2.sessionId === sessionId && identity2.commandHash === commandHash ? { kind: "expired" } : { kind: "conflict" };
|
|
96208
96262
|
}
|
|
96209
|
-
const attemptId =
|
|
96263
|
+
const attemptId = randomUUID16();
|
|
96210
96264
|
this.#save(commandId, {
|
|
96211
96265
|
admissionOrder: this.#nextAdmissionOrder(),
|
|
96212
96266
|
attemptId,
|
|
@@ -96341,7 +96395,7 @@ var init_runtime_turn_activity = __esm({
|
|
|
96341
96395
|
});
|
|
96342
96396
|
|
|
96343
96397
|
// src/engine/session/turn/active-turn.ts
|
|
96344
|
-
import { randomUUID as
|
|
96398
|
+
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
96345
96399
|
var ActiveRuntimeTurn;
|
|
96346
96400
|
var init_active_turn = __esm({
|
|
96347
96401
|
"src/engine/session/turn/active-turn.ts"() {
|
|
@@ -96356,7 +96410,7 @@ var init_active_turn = __esm({
|
|
|
96356
96410
|
#dispatch;
|
|
96357
96411
|
#sequence = 0;
|
|
96358
96412
|
#interaction = null;
|
|
96359
|
-
#epoch = decodeIdentifier(
|
|
96413
|
+
#epoch = decodeIdentifier(randomUUID17());
|
|
96360
96414
|
constructor(command, attemptId) {
|
|
96361
96415
|
this.attemptId = attemptId;
|
|
96362
96416
|
this.command = command;
|
|
@@ -96965,11 +97019,11 @@ var init_session_layer = __esm({
|
|
|
96965
97019
|
});
|
|
96966
97020
|
|
|
96967
97021
|
// src/engine/storage/files/scratch-directory.ts
|
|
96968
|
-
import { randomUUID as
|
|
97022
|
+
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
96969
97023
|
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
97024
|
import { dirname as dirname12, join as join30 } from "node:path";
|
|
96971
97025
|
async function atomicWrite(path8, bytes, signal) {
|
|
96972
|
-
const temporary = `${path8}.${
|
|
97026
|
+
const temporary = `${path8}.${randomUUID18()}.tmp`;
|
|
96973
97027
|
try {
|
|
96974
97028
|
await writeFile2(temporary, bytes, { mode: 384, signal });
|
|
96975
97029
|
signal.throwIfAborted();
|
|
@@ -96985,7 +97039,7 @@ var init_scratch_directory = __esm({
|
|
|
96985
97039
|
ScratchDirectory = class {
|
|
96986
97040
|
#root;
|
|
96987
97041
|
constructor(parent) {
|
|
96988
|
-
this.#root = join30(parent,
|
|
97042
|
+
this.#root = join30(parent, randomUUID18());
|
|
96989
97043
|
}
|
|
96990
97044
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
96991
97045
|
refreshLease = async (leaseMilliseconds) => {
|
|
@@ -99177,7 +99231,7 @@ var init_native_sessions = __esm({
|
|
|
99177
99231
|
});
|
|
99178
99232
|
|
|
99179
99233
|
// src/engine/session/prompt/apply-session-configuration.ts
|
|
99180
|
-
import { randomUUID as
|
|
99234
|
+
import { randomUUID as randomUUID19 } from "node:crypto";
|
|
99181
99235
|
function invalidSessionConfiguration(message) {
|
|
99182
99236
|
return new AcpExecutionError(message, {}, "invalid_session_configuration");
|
|
99183
99237
|
}
|
|
@@ -99315,7 +99369,7 @@ async function applySessionConfigurationSelection(sessions, options, selection,
|
|
|
99315
99369
|
booleanValue: selection.booleanValue,
|
|
99316
99370
|
configId: selection.configId,
|
|
99317
99371
|
cwd,
|
|
99318
|
-
requestId: `cfg_${
|
|
99372
|
+
requestId: `cfg_${randomUUID19()}`,
|
|
99319
99373
|
sessionId,
|
|
99320
99374
|
signal,
|
|
99321
99375
|
value: selection.value,
|
|
@@ -100899,7 +100953,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
|
|
|
100899
100953
|
const catalogAgent = await resolveCatalogAgent(config2, agentId, resolveSignal);
|
|
100900
100954
|
const environment = sessionId === void 0 ? void 0 : config2.sessionEnvironment?.({ sessionId, agentId });
|
|
100901
100955
|
const agent = environment === void 0 ? catalogAgent : catalogAgent.withEnvironment({ ...catalogAgent.environment, ...environment });
|
|
100902
|
-
return { agent, adapter: adapters.resolve(
|
|
100956
|
+
return { agent, adapter: adapters.resolve(catalogAgent) };
|
|
100903
100957
|
};
|
|
100904
100958
|
const layer = buildSessionLayer({
|
|
100905
100959
|
processes,
|
|
@@ -101284,7 +101338,7 @@ var init_engine = __esm({
|
|
|
101284
101338
|
});
|
|
101285
101339
|
|
|
101286
101340
|
// src/storage/daemon/version-data.ts
|
|
101287
|
-
import { randomUUID as
|
|
101341
|
+
import { randomUUID as randomUUID20 } from "node:crypto";
|
|
101288
101342
|
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
101343
|
import { join as join33, relative as relative3, sep as sep5 } from "node:path";
|
|
101290
101344
|
async function prepareVersionDataDirectory(root, version2, signal) {
|
|
@@ -101375,7 +101429,7 @@ async function discardVersionData(root, version2, signal) {
|
|
|
101375
101429
|
return;
|
|
101376
101430
|
}
|
|
101377
101431
|
const versions = join33(root, STATE_ROOT_LAYOUT.versions);
|
|
101378
|
-
const discarded = join33(versions, `.${version2}-discarded-${
|
|
101432
|
+
const discarded = join33(versions, `.${version2}-discarded-${randomUUID20()}`);
|
|
101379
101433
|
try {
|
|
101380
101434
|
await rename5(join33(versions, version2), discarded);
|
|
101381
101435
|
} catch (cause) {
|
|
@@ -101389,7 +101443,7 @@ async function discardVersionData(root, version2, signal) {
|
|
|
101389
101443
|
async function writeCurrentDataVersion(root, version2, signal) {
|
|
101390
101444
|
await validateLocalPath(root, true, true, signal);
|
|
101391
101445
|
await validateLocalPath(join33(root, STATE_ROOT_LAYOUT.versions, version2), true, true, signal);
|
|
101392
|
-
const temporary = join33(root, `.current-data-${
|
|
101446
|
+
const temporary = join33(root, `.current-data-${randomUUID20()}.txt`);
|
|
101393
101447
|
try {
|
|
101394
101448
|
await writeFile3(temporary, `versions/${version2}
|
|
101395
101449
|
`, { mode: 384, flag: "wx", signal });
|
|
@@ -102993,7 +103047,7 @@ var init_quit = __esm({
|
|
|
102993
103047
|
});
|
|
102994
103048
|
|
|
102995
103049
|
// src/daemon/upgrades/upgrade.ts
|
|
102996
|
-
import { randomUUID as
|
|
103050
|
+
import { randomUUID as randomUUID21 } from "node:crypto";
|
|
102997
103051
|
import { setInterval as setInterval2, setTimeout as setTimeout4 } from "node:timers/promises";
|
|
102998
103052
|
async function reportDaemonUpgradeAvailability(send2, signal) {
|
|
102999
103053
|
if (!process.connected) {
|
|
@@ -103052,7 +103106,7 @@ async function requestDaemonReleaseUpgrade(stateDirectory, currentVersion, signa
|
|
|
103052
103106
|
return await requestInstalledDaemonReleaseSwitch(stateDirectory, launch, signal);
|
|
103053
103107
|
}
|
|
103054
103108
|
async function requestInstalledDaemonReleaseSwitch(stateDirectory, launch, signal) {
|
|
103055
|
-
const id =
|
|
103109
|
+
const id = randomUUID21();
|
|
103056
103110
|
const response = decodeKnownLifecycleResponse(
|
|
103057
103111
|
await sendLocalRequest(stateDirectory, "manager", { kind: "switch", id, context: "npm", launch }, signal)
|
|
103058
103112
|
);
|