chatroom-cli 1.53.2 → 1.53.4
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/index.js +177 -97
- package/dist/index.js.map +20 -18
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -26655,7 +26655,7 @@ function resolveCursorCliModel(model) {
|
|
|
26655
26655
|
const prefix = `${CURSOR_PROVIDER}/`;
|
|
26656
26656
|
return model.startsWith(prefix) ? model.slice(prefix.length) : model;
|
|
26657
26657
|
}
|
|
26658
|
-
var CURSOR_COMMAND = "agent", CURSOR_PROVIDER = "cursor", CURSOR_MODELS, CursorAgentService;
|
|
26658
|
+
var CURSOR_COMMAND = "agent", CURSOR_PROVIDER = "cursor", NO_SUBAGENT_DIRECTIVE = "NEVER spawn subagents. Follow the chatroom instructions strictly.", CURSOR_MODELS, CursorAgentService;
|
|
26659
26659
|
var init_cursor_agent_service = __esm(() => {
|
|
26660
26660
|
init_base_cli_agent_service();
|
|
26661
26661
|
init_cursor_stream_reader();
|
|
@@ -26736,9 +26736,12 @@ var init_cursor_agent_service = __esm(() => {
|
|
|
26736
26736
|
if (options.model) {
|
|
26737
26737
|
args2.push("--model", resolveCursorCliModel(options.model));
|
|
26738
26738
|
}
|
|
26739
|
-
const
|
|
26739
|
+
const systemPrompt = options.systemPrompt ? `${NO_SUBAGENT_DIRECTIVE}
|
|
26740
26740
|
|
|
26741
|
-
${options.
|
|
26741
|
+
${options.systemPrompt}` : NO_SUBAGENT_DIRECTIVE;
|
|
26742
|
+
const fullPrompt = `${systemPrompt}
|
|
26743
|
+
|
|
26744
|
+
${options.prompt}`;
|
|
26742
26745
|
const childProcess = this.deps.spawn(CURSOR_COMMAND, args2, {
|
|
26743
26746
|
cwd: options.workingDir,
|
|
26744
26747
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -27512,65 +27515,7 @@ function resolveCursorSdkModel(model) {
|
|
|
27512
27515
|
const prefix = `${CURSOR_PROVIDER2}/`;
|
|
27513
27516
|
return model.startsWith(prefix) ? model.slice(prefix.length) : model;
|
|
27514
27517
|
}
|
|
27515
|
-
var
|
|
27516
|
-
var init_cursor_models = __esm(() => {
|
|
27517
|
-
CURSOR_SDK_FALLBACK_MODELS = [
|
|
27518
|
-
"claude-4.6-opus-high",
|
|
27519
|
-
"claude-4.6-opus-high-thinking",
|
|
27520
|
-
"claude-4.6-opus-max",
|
|
27521
|
-
"claude-4.6-opus-max-thinking",
|
|
27522
|
-
"claude-4.5-opus-high",
|
|
27523
|
-
"claude-4.5-opus-high-thinking",
|
|
27524
|
-
"claude-4.6-sonnet-medium",
|
|
27525
|
-
"claude-4.6-sonnet-medium-thinking",
|
|
27526
|
-
"claude-4.5-sonnet",
|
|
27527
|
-
"claude-4.5-sonnet-thinking",
|
|
27528
|
-
"claude-4-sonnet",
|
|
27529
|
-
"claude-4-sonnet-thinking",
|
|
27530
|
-
"claude-4-sonnet-1m",
|
|
27531
|
-
"claude-4-sonnet-1m-thinking",
|
|
27532
|
-
"gpt-5.4-low",
|
|
27533
|
-
"gpt-5.4-medium",
|
|
27534
|
-
"gpt-5.4-medium-fast",
|
|
27535
|
-
"gpt-5.4-high",
|
|
27536
|
-
"gpt-5.4-high-fast",
|
|
27537
|
-
"gpt-5.4-xhigh",
|
|
27538
|
-
"gpt-5.4-xhigh-fast",
|
|
27539
|
-
"gpt-5.3-codex-low",
|
|
27540
|
-
"gpt-5.3-codex-low-fast",
|
|
27541
|
-
"gpt-5.3-codex",
|
|
27542
|
-
"gpt-5.3-codex-fast",
|
|
27543
|
-
"gpt-5.3-codex-high",
|
|
27544
|
-
"gpt-5.3-codex-high-fast",
|
|
27545
|
-
"gpt-5.3-codex-xhigh",
|
|
27546
|
-
"gpt-5.3-codex-xhigh-fast",
|
|
27547
|
-
"gpt-5.3-codex-spark-preview",
|
|
27548
|
-
"gpt-5.2",
|
|
27549
|
-
"gpt-5.2-high",
|
|
27550
|
-
"gpt-5.2-codex-low",
|
|
27551
|
-
"gpt-5.2-codex-low-fast",
|
|
27552
|
-
"gpt-5.2-codex",
|
|
27553
|
-
"gpt-5.2-codex-fast",
|
|
27554
|
-
"gpt-5.2-codex-high",
|
|
27555
|
-
"gpt-5.2-codex-high-fast",
|
|
27556
|
-
"gpt-5.2-codex-xhigh",
|
|
27557
|
-
"gpt-5.2-codex-xhigh-fast",
|
|
27558
|
-
"gpt-5.1-high",
|
|
27559
|
-
"gpt-5.1-codex-max",
|
|
27560
|
-
"gpt-5.1-codex-max-high",
|
|
27561
|
-
"gpt-5.1-codex-mini",
|
|
27562
|
-
"gemini-3.1-pro",
|
|
27563
|
-
"gemini-3-pro",
|
|
27564
|
-
"gemini-3-flash",
|
|
27565
|
-
"grok",
|
|
27566
|
-
"kimi-k2.5",
|
|
27567
|
-
"auto",
|
|
27568
|
-
"composer-2.5",
|
|
27569
|
-
"composer-2",
|
|
27570
|
-
"composer-1.5",
|
|
27571
|
-
"composer-1"
|
|
27572
|
-
];
|
|
27573
|
-
});
|
|
27518
|
+
var CURSOR_PROVIDER2 = "cursor";
|
|
27574
27519
|
|
|
27575
27520
|
// src/infrastructure/services/remote-agents/cursor-sdk/cursor-sdk-stream-adapter.ts
|
|
27576
27521
|
class CursorSdkStreamAdapter {
|
|
@@ -27735,12 +27680,11 @@ function buildLogPrefix(context4) {
|
|
|
27735
27680
|
function resolveModelId(model) {
|
|
27736
27681
|
return model ? resolveCursorSdkModel(model) : DEFAULT_MODEL;
|
|
27737
27682
|
}
|
|
27738
|
-
var _sdkCache, _sdkLoadError, CURSOR_SDK_COMMAND = "cursor-sdk", DEFAULT_MODEL = "composer-2.5", AGENT_CREATE_TIMEOUT_MS = 60000, SEND_TIMEOUT_MS = 60000, RUN_WAIT_TIMEOUT_MS = 3600000, MODELS_LIST_TIMEOUT_MS = 1e4, RUN_CANCEL_TIMEOUT_MS = 5000, cachedSdkPackageVersion, CursorSdkAgentService;
|
|
27683
|
+
var NO_SUBAGENT_DIRECTIVE2 = "NEVER spawn subagents. Follow the chatroom instructions strictly.", _sdkCache, _sdkLoadError, CURSOR_SDK_COMMAND = "cursor-sdk", DEFAULT_MODEL = "composer-2.5", AGENT_CREATE_TIMEOUT_MS = 60000, SEND_TIMEOUT_MS = 60000, RUN_WAIT_TIMEOUT_MS = 3600000, MODELS_LIST_TIMEOUT_MS = 1e4, RUN_CANCEL_TIMEOUT_MS = 5000, cachedSdkPackageVersion, CursorSdkAgentService;
|
|
27739
27684
|
var init_cursor_sdk_agent_service = __esm(() => {
|
|
27740
27685
|
init_esm();
|
|
27741
27686
|
init_base_cli_agent_service();
|
|
27742
27687
|
init_detection_result();
|
|
27743
|
-
init_cursor_models();
|
|
27744
27688
|
CursorSdkAgentService = class CursorSdkAgentService extends BaseCLIAgentService {
|
|
27745
27689
|
id = "cursor-sdk";
|
|
27746
27690
|
displayName = "Cursor (SDK)";
|
|
@@ -27777,15 +27721,14 @@ var init_cursor_sdk_agent_service = __esm(() => {
|
|
|
27777
27721
|
async listModels() {
|
|
27778
27722
|
const apiKey = process.env.CURSOR_API_KEY?.trim();
|
|
27779
27723
|
if (!apiKey)
|
|
27780
|
-
return [
|
|
27724
|
+
return [];
|
|
27781
27725
|
try {
|
|
27782
27726
|
const { Cursor } = await loadSdk();
|
|
27783
27727
|
const models = await withTimeout(Cursor.models.list({ apiKey }), MODELS_LIST_TIMEOUT_MS, "Cursor.models.list");
|
|
27784
|
-
|
|
27785
|
-
return ids3.length > 0 ? ids3 : [...CURSOR_SDK_FALLBACK_MODELS];
|
|
27728
|
+
return models.map((m) => m.id).filter((id3) => id3.length > 0);
|
|
27786
27729
|
} catch (err) {
|
|
27787
|
-
console.warn(`[cursor-sdk] Cursor.models.list failed
|
|
27788
|
-
return [
|
|
27730
|
+
console.warn(`[cursor-sdk] Cursor.models.list failed:`, err instanceof Error ? err.message : err);
|
|
27731
|
+
return [];
|
|
27789
27732
|
}
|
|
27790
27733
|
}
|
|
27791
27734
|
async resumeTurn(pid, prompt) {
|
|
@@ -27847,9 +27790,12 @@ var init_cursor_sdk_agent_service = __esm(() => {
|
|
|
27847
27790
|
const context4 = options.context;
|
|
27848
27791
|
const agentName = stored.agentName;
|
|
27849
27792
|
const modelId = resolveModelId(options.model ?? stored.model);
|
|
27850
|
-
const
|
|
27793
|
+
const systemPrompt = options.systemPrompt ? `${NO_SUBAGENT_DIRECTIVE2}
|
|
27851
27794
|
|
|
27852
|
-
${options.
|
|
27795
|
+
${options.systemPrompt}` : NO_SUBAGENT_DIRECTIVE2;
|
|
27796
|
+
const fullPrompt = `${systemPrompt}
|
|
27797
|
+
|
|
27798
|
+
${options.prompt}`;
|
|
27853
27799
|
let agent;
|
|
27854
27800
|
try {
|
|
27855
27801
|
const { Agent } = await loadSdk();
|
|
@@ -27889,7 +27835,17 @@ ${options.prompt}` : options.prompt;
|
|
|
27889
27835
|
return keeper;
|
|
27890
27836
|
}
|
|
27891
27837
|
startRunningSession(args2) {
|
|
27892
|
-
const {
|
|
27838
|
+
const {
|
|
27839
|
+
pid,
|
|
27840
|
+
keeper,
|
|
27841
|
+
agent,
|
|
27842
|
+
context: context4,
|
|
27843
|
+
agentName,
|
|
27844
|
+
model,
|
|
27845
|
+
workingDir,
|
|
27846
|
+
initialPrompt,
|
|
27847
|
+
forceFirstTurn
|
|
27848
|
+
} = args2;
|
|
27893
27849
|
const entry = this.registerProcess(pid, context4);
|
|
27894
27850
|
const logPrefix = buildLogPrefix(context4);
|
|
27895
27851
|
const session = {
|
|
@@ -28015,7 +27971,7 @@ ${options.prompt}` : options.prompt;
|
|
|
28015
27971
|
process.stderr.write(`${logPrefix} spawn-error] ${reason}
|
|
28016
27972
|
`);
|
|
28017
27973
|
} finally {
|
|
28018
|
-
if (!session.agentClosed && !session.preserveForResume) {
|
|
27974
|
+
if (!session.agentClosed && session.aborted && !session.preserveForResume) {
|
|
28019
27975
|
try {
|
|
28020
27976
|
agent.close();
|
|
28021
27977
|
session.agentClosed = true;
|
|
@@ -28038,16 +27994,19 @@ ${options.prompt}` : options.prompt;
|
|
|
28038
27994
|
const context4 = options.context;
|
|
28039
27995
|
const agentName = buildAgentName(context4);
|
|
28040
27996
|
const modelId = resolveModelId(options.model);
|
|
28041
|
-
const
|
|
27997
|
+
const systemPrompt = options.systemPrompt ? `${NO_SUBAGENT_DIRECTIVE2}
|
|
28042
27998
|
|
|
28043
|
-
${options.
|
|
27999
|
+
${options.systemPrompt}` : NO_SUBAGENT_DIRECTIVE2;
|
|
28000
|
+
const fullPrompt = `${systemPrompt}
|
|
28001
|
+
|
|
28002
|
+
${options.prompt}`;
|
|
28044
28003
|
let agent;
|
|
28045
28004
|
try {
|
|
28046
28005
|
const { Agent } = await loadSdk();
|
|
28047
28006
|
agent = await withTimeout(Agent.create({
|
|
28048
28007
|
apiKey,
|
|
28049
28008
|
name: agentName,
|
|
28050
|
-
model: { id: modelId },
|
|
28009
|
+
model: { id: modelId, params: [{ id: "fast", value: "false" }] },
|
|
28051
28010
|
local: { cwd: options.workingDir, settingSources: [] }
|
|
28052
28011
|
}), AGENT_CREATE_TIMEOUT_MS, "Agent.create");
|
|
28053
28012
|
} catch (err) {
|
|
@@ -83819,7 +83778,7 @@ function isProcessAlive(kill, pid) {
|
|
|
83819
83778
|
}
|
|
83820
83779
|
}
|
|
83821
83780
|
|
|
83822
|
-
// src/
|
|
83781
|
+
// src/domain/agent-lifecycle/entities/stop-reason.ts
|
|
83823
83782
|
function resolveStopReason(code2, signal) {
|
|
83824
83783
|
if (signal !== null)
|
|
83825
83784
|
return "agent_process.signal";
|
|
@@ -83828,11 +83787,59 @@ function resolveStopReason(code2, signal) {
|
|
|
83828
83787
|
return "agent_process.crashed";
|
|
83829
83788
|
}
|
|
83830
83789
|
|
|
83790
|
+
// src/domain/agent-lifecycle/policies/preserve-session.ts
|
|
83791
|
+
function shouldRetainHarnessSessionForReconnect(reason) {
|
|
83792
|
+
switch (reason) {
|
|
83793
|
+
case "user.stop":
|
|
83794
|
+
case "agent_process.exited_clean":
|
|
83795
|
+
case "agent_process.signal":
|
|
83796
|
+
case "agent_process.crashed":
|
|
83797
|
+
return true;
|
|
83798
|
+
default:
|
|
83799
|
+
return false;
|
|
83800
|
+
}
|
|
83801
|
+
}
|
|
83802
|
+
function shouldPreserveHarnessTeardown(reason, supportsSessionResume, hasHarnessSessionId) {
|
|
83803
|
+
return hasHarnessSessionId && supportsSessionResume && shouldRetainHarnessSessionForReconnect(reason);
|
|
83804
|
+
}
|
|
83805
|
+
|
|
83806
|
+
// src/domain/agent-lifecycle/policies/decide-resume-path.ts
|
|
83807
|
+
function decideResumePathOnRestart(input) {
|
|
83808
|
+
if (!input.supportsSessionResume) {
|
|
83809
|
+
return "cold";
|
|
83810
|
+
}
|
|
83811
|
+
if (input.wantResume && input.hasStoredSnapshot) {
|
|
83812
|
+
return "daemon_memory";
|
|
83813
|
+
}
|
|
83814
|
+
return "cold";
|
|
83815
|
+
}
|
|
83816
|
+
function shouldAutoRestartAfterProcessExit(stopReason) {
|
|
83817
|
+
switch (stopReason) {
|
|
83818
|
+
case "user.stop":
|
|
83819
|
+
case "platform.team_switch":
|
|
83820
|
+
case "daemon.shutdown":
|
|
83821
|
+
case "daemon.respawn":
|
|
83822
|
+
return false;
|
|
83823
|
+
default:
|
|
83824
|
+
return true;
|
|
83825
|
+
}
|
|
83826
|
+
}
|
|
83827
|
+
|
|
83828
|
+
// src/domain/agent-lifecycle/index.ts
|
|
83829
|
+
var init_agent_lifecycle = () => {};
|
|
83830
|
+
|
|
83831
83831
|
// ../../services/backend/src/domain/entities/harness/claude.config.ts
|
|
83832
83832
|
var claudeCapabilities;
|
|
83833
83833
|
var init_claude_config = __esm(() => {
|
|
83834
83834
|
claudeCapabilities = {
|
|
83835
|
-
|
|
83835
|
+
runtimeKind: "cli",
|
|
83836
|
+
supportsSessionResume: false,
|
|
83837
|
+
lifecycle: {
|
|
83838
|
+
turnCompleted: false,
|
|
83839
|
+
outputActivity: true,
|
|
83840
|
+
processExited: true
|
|
83841
|
+
},
|
|
83842
|
+
wireEvents: []
|
|
83836
83843
|
};
|
|
83837
83844
|
});
|
|
83838
83845
|
|
|
@@ -83840,7 +83847,14 @@ var init_claude_config = __esm(() => {
|
|
|
83840
83847
|
var commandcodeCapabilities;
|
|
83841
83848
|
var init_commandcode_config = __esm(() => {
|
|
83842
83849
|
commandcodeCapabilities = {
|
|
83843
|
-
|
|
83850
|
+
runtimeKind: "cli",
|
|
83851
|
+
supportsSessionResume: false,
|
|
83852
|
+
lifecycle: {
|
|
83853
|
+
turnCompleted: true,
|
|
83854
|
+
outputActivity: true,
|
|
83855
|
+
processExited: true
|
|
83856
|
+
},
|
|
83857
|
+
wireEvents: ["wire.log.agent_end"]
|
|
83844
83858
|
};
|
|
83845
83859
|
});
|
|
83846
83860
|
|
|
@@ -83848,7 +83862,14 @@ var init_commandcode_config = __esm(() => {
|
|
|
83848
83862
|
var copilotCapabilities;
|
|
83849
83863
|
var init_copilot_config = __esm(() => {
|
|
83850
83864
|
copilotCapabilities = {
|
|
83851
|
-
|
|
83865
|
+
runtimeKind: "cli",
|
|
83866
|
+
supportsSessionResume: false,
|
|
83867
|
+
lifecycle: {
|
|
83868
|
+
turnCompleted: true,
|
|
83869
|
+
outputActivity: true,
|
|
83870
|
+
processExited: true
|
|
83871
|
+
},
|
|
83872
|
+
wireEvents: ["wire.log.agent_end"]
|
|
83852
83873
|
};
|
|
83853
83874
|
});
|
|
83854
83875
|
|
|
@@ -83856,7 +83877,14 @@ var init_copilot_config = __esm(() => {
|
|
|
83856
83877
|
var cursorCapabilities;
|
|
83857
83878
|
var init_cursor_config = __esm(() => {
|
|
83858
83879
|
cursorCapabilities = {
|
|
83859
|
-
|
|
83880
|
+
runtimeKind: "cli",
|
|
83881
|
+
supportsSessionResume: false,
|
|
83882
|
+
lifecycle: {
|
|
83883
|
+
turnCompleted: true,
|
|
83884
|
+
outputActivity: true,
|
|
83885
|
+
processExited: true
|
|
83886
|
+
},
|
|
83887
|
+
wireEvents: ["wire.log.agent_end"]
|
|
83860
83888
|
};
|
|
83861
83889
|
});
|
|
83862
83890
|
|
|
@@ -83864,7 +83892,14 @@ var init_cursor_config = __esm(() => {
|
|
|
83864
83892
|
var cursorSdkCapabilities;
|
|
83865
83893
|
var init_cursor_sdk_config = __esm(() => {
|
|
83866
83894
|
cursorSdkCapabilities = {
|
|
83867
|
-
|
|
83895
|
+
runtimeKind: "sdk",
|
|
83896
|
+
supportsSessionResume: true,
|
|
83897
|
+
lifecycle: {
|
|
83898
|
+
turnCompleted: true,
|
|
83899
|
+
outputActivity: true,
|
|
83900
|
+
processExited: true
|
|
83901
|
+
},
|
|
83902
|
+
wireEvents: ["sdk.cursor.message", "sdk.cursor.run.completed", "wire.log.agent_end"]
|
|
83868
83903
|
};
|
|
83869
83904
|
});
|
|
83870
83905
|
|
|
@@ -83872,7 +83907,14 @@ var init_cursor_sdk_config = __esm(() => {
|
|
|
83872
83907
|
var opencodeCapabilities;
|
|
83873
83908
|
var init_opencode_config = __esm(() => {
|
|
83874
83909
|
opencodeCapabilities = {
|
|
83875
|
-
|
|
83910
|
+
runtimeKind: "cli",
|
|
83911
|
+
supportsSessionResume: false,
|
|
83912
|
+
lifecycle: {
|
|
83913
|
+
turnCompleted: false,
|
|
83914
|
+
outputActivity: true,
|
|
83915
|
+
processExited: true
|
|
83916
|
+
},
|
|
83917
|
+
wireEvents: []
|
|
83876
83918
|
};
|
|
83877
83919
|
});
|
|
83878
83920
|
|
|
@@ -83880,7 +83922,14 @@ var init_opencode_config = __esm(() => {
|
|
|
83880
83922
|
var opencodeSdkCapabilities;
|
|
83881
83923
|
var init_opencode_sdk_config = __esm(() => {
|
|
83882
83924
|
opencodeSdkCapabilities = {
|
|
83883
|
-
|
|
83925
|
+
runtimeKind: "sdk",
|
|
83926
|
+
supportsSessionResume: true,
|
|
83927
|
+
lifecycle: {
|
|
83928
|
+
turnCompleted: true,
|
|
83929
|
+
outputActivity: true,
|
|
83930
|
+
processExited: true
|
|
83931
|
+
},
|
|
83932
|
+
wireEvents: ["sdk.opencode.session.idle", "sdk.opencode.session.event"]
|
|
83884
83933
|
};
|
|
83885
83934
|
});
|
|
83886
83935
|
|
|
@@ -83888,7 +83937,22 @@ var init_opencode_sdk_config = __esm(() => {
|
|
|
83888
83937
|
var piCapabilities;
|
|
83889
83938
|
var init_pi_config = __esm(() => {
|
|
83890
83939
|
piCapabilities = {
|
|
83891
|
-
|
|
83940
|
+
runtimeKind: "cli",
|
|
83941
|
+
supportsSessionResume: true,
|
|
83942
|
+
lifecycle: {
|
|
83943
|
+
turnCompleted: true,
|
|
83944
|
+
outputActivity: true,
|
|
83945
|
+
processExited: true
|
|
83946
|
+
},
|
|
83947
|
+
wireEvents: [
|
|
83948
|
+
"wire.ndjson.agent_start",
|
|
83949
|
+
"wire.ndjson.agent_end",
|
|
83950
|
+
"wire.ndjson.message_update",
|
|
83951
|
+
"wire.ndjson.tool_execution_start",
|
|
83952
|
+
"wire.ndjson.tool_execution_end",
|
|
83953
|
+
"wire.ndjson.get_state",
|
|
83954
|
+
"wire.log.agent_end"
|
|
83955
|
+
]
|
|
83892
83956
|
};
|
|
83893
83957
|
});
|
|
83894
83958
|
|
|
@@ -84010,11 +84074,11 @@ class AgentProcessManager {
|
|
|
84010
84074
|
const key = agentKey2(opts.chatroomId, opts.role);
|
|
84011
84075
|
const slot = this.slots.get(key);
|
|
84012
84076
|
if (slot?.resumeInFlight) {
|
|
84013
|
-
console.log(`[AgentProcessManager]
|
|
84077
|
+
console.log(`[AgentProcessManager] lifecycle.turn.completed: skipping duplicate resume for ${opts.role} (resume already in flight)`);
|
|
84014
84078
|
return;
|
|
84015
84079
|
}
|
|
84016
84080
|
const capabilities = getHarnessCapabilities(opts.harness);
|
|
84017
|
-
console.log(`[AgentProcessManager]
|
|
84081
|
+
console.log(`[AgentProcessManager] lifecycle.turn.completed: role=${opts.role} pid=${opts.pid} harness=${opts.harness} supportsResume=${capabilities.supportsSessionResume}`);
|
|
84018
84082
|
if (capabilities.supportsSessionResume) {
|
|
84019
84083
|
const service = this.deps.agentServices.get(opts.harness);
|
|
84020
84084
|
if (service?.resumeTurn) {
|
|
@@ -84082,6 +84146,18 @@ class AgentProcessManager {
|
|
|
84082
84146
|
const harness = slot.harness;
|
|
84083
84147
|
const model = slot.model;
|
|
84084
84148
|
const workingDir = slot.workingDir;
|
|
84149
|
+
const harnessSessionId = slot.harnessSessionId;
|
|
84150
|
+
if (harness && harnessSessionId && getHarnessCapabilities(harness).supportsSessionResume && shouldRetainHarnessSessionForReconnect(stopReason)) {
|
|
84151
|
+
const service = this.deps.agentServices.get(harness);
|
|
84152
|
+
const harnessMeta = service ? this.readHarnessReconnectMetadata(service, opts.pid) : undefined;
|
|
84153
|
+
this.recordLastHarnessSession(key, {
|
|
84154
|
+
harnessSessionId,
|
|
84155
|
+
harness,
|
|
84156
|
+
agentName: harnessMeta?.agentName ?? "",
|
|
84157
|
+
workingDir: workingDir ?? "",
|
|
84158
|
+
model: model ?? harnessMeta?.model
|
|
84159
|
+
});
|
|
84160
|
+
}
|
|
84085
84161
|
slot.state = "idle";
|
|
84086
84162
|
slot.pid = undefined;
|
|
84087
84163
|
slot.startedAt = undefined;
|
|
@@ -84108,13 +84184,10 @@ class AgentProcessManager {
|
|
|
84108
84184
|
for (const service of this.deps.agentServices.values()) {
|
|
84109
84185
|
service.untrack(opts.pid);
|
|
84110
84186
|
}
|
|
84111
|
-
|
|
84112
|
-
|
|
84113
|
-
|
|
84114
|
-
|
|
84115
|
-
return;
|
|
84116
|
-
}
|
|
84117
|
-
if (isDaemonRespawn) {
|
|
84187
|
+
if (!shouldAutoRestartAfterProcessExit(stopReason)) {
|
|
84188
|
+
if (stopReason === "user.stop" || stopReason === "platform.team_switch" || stopReason === "daemon.shutdown") {
|
|
84189
|
+
this.deps.crashLoop.clear(opts.chatroomId, opts.role);
|
|
84190
|
+
}
|
|
84118
84191
|
return;
|
|
84119
84192
|
}
|
|
84120
84193
|
if (!harness || !workingDir) {
|
|
@@ -84473,7 +84546,12 @@ class AgentProcessManager {
|
|
|
84473
84546
|
return { success: false, error: `Unknown agent harness: ${opts.agentHarness}` };
|
|
84474
84547
|
}
|
|
84475
84548
|
let spawnResult;
|
|
84476
|
-
|
|
84549
|
+
const resumePath = decideResumePathOnRestart({
|
|
84550
|
+
supportsSessionResume: getHarnessCapabilities(opts.agentHarness).supportsSessionResume,
|
|
84551
|
+
wantResume,
|
|
84552
|
+
hasStoredSnapshot: this.lastHarnessSessions.has(key)
|
|
84553
|
+
});
|
|
84554
|
+
if (resumePath === "daemon_memory") {
|
|
84477
84555
|
spawnResult = await this.tryDaemonMemoryResume({
|
|
84478
84556
|
key,
|
|
84479
84557
|
chatroomId: opts.chatroomId,
|
|
@@ -84590,7 +84668,8 @@ class AgentProcessManager {
|
|
|
84590
84668
|
try {
|
|
84591
84669
|
const harness = slot.harness;
|
|
84592
84670
|
const service = harness ? this.deps.agentServices.get(harness) : undefined;
|
|
84593
|
-
const
|
|
84671
|
+
const supportsResume = harness ? getHarnessCapabilities(harness).supportsSessionResume : false;
|
|
84672
|
+
const preserveForResume = shouldPreserveHarnessTeardown(opts.reason, supportsResume, Boolean(slot.harnessSessionId));
|
|
84594
84673
|
if (harness && slot.harnessSessionId) {
|
|
84595
84674
|
if (preserveForResume) {
|
|
84596
84675
|
const harnessMeta = service ? this.readHarnessReconnectMetadata(service, pid) : undefined;
|
|
@@ -84668,6 +84747,7 @@ var AGENT_EXIT_RETRY_INTERVAL_MS = 1e4;
|
|
|
84668
84747
|
var init_agent_process_manager = __esm(() => {
|
|
84669
84748
|
init_orphan_tracker();
|
|
84670
84749
|
init_api3();
|
|
84750
|
+
init_agent_lifecycle();
|
|
84671
84751
|
init_types();
|
|
84672
84752
|
init_generator();
|
|
84673
84753
|
});
|
|
@@ -87367,4 +87447,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
87367
87447
|
});
|
|
87368
87448
|
program2.parse();
|
|
87369
87449
|
|
|
87370
|
-
//# debugId=
|
|
87450
|
+
//# debugId=9CE84CC04C561C2A64756E2164756E21
|