chatroom-cli 1.61.1 → 1.61.3
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 +148 -29
- package/dist/index.js.map +12 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29106,6 +29106,7 @@ var init_claude_sdk_stream_adapter = __esm(() => {
|
|
|
29106
29106
|
});
|
|
29107
29107
|
|
|
29108
29108
|
// src/infrastructure/services/remote-agents/claude-sdk/claude-sdk-agent-service.ts
|
|
29109
|
+
import { randomUUID } from "node:crypto";
|
|
29109
29110
|
async function loadSdk() {
|
|
29110
29111
|
if (_sdkCache)
|
|
29111
29112
|
return _sdkCache;
|
|
@@ -29157,9 +29158,24 @@ function writeSpawnError(logPrefix, err, emitLogLine) {
|
|
|
29157
29158
|
emitLogLine?.(line);
|
|
29158
29159
|
console.error(`[${new Date().toISOString()}] ${logPrefix} spawn-error]`, err);
|
|
29159
29160
|
}
|
|
29160
|
-
function
|
|
29161
|
-
if ("session_id" in message
|
|
29162
|
-
|
|
29161
|
+
function notifyResumableSessionId(message, session2, correlationId, callbacks) {
|
|
29162
|
+
if (!("session_id" in message) || typeof message.session_id !== "string") {
|
|
29163
|
+
return;
|
|
29164
|
+
}
|
|
29165
|
+
const resumableId = message.session_id;
|
|
29166
|
+
const previousResumableId = session2.sessionId;
|
|
29167
|
+
if (previousResumableId === resumableId) {
|
|
29168
|
+
return;
|
|
29169
|
+
}
|
|
29170
|
+
session2.sessionId = resumableId;
|
|
29171
|
+
const info = {
|
|
29172
|
+
correlationId,
|
|
29173
|
+
resumableId,
|
|
29174
|
+
source: previousResumableId ? "provider_rotated" : "provider_allocated",
|
|
29175
|
+
...previousResumableId ? { previousResumableId } : {}
|
|
29176
|
+
};
|
|
29177
|
+
for (const cb of callbacks) {
|
|
29178
|
+
cb(info);
|
|
29163
29179
|
}
|
|
29164
29180
|
}
|
|
29165
29181
|
var CLAUDE_SDK_COMMAND = "claude-sdk", DEFAULT_MAX_TURNS2 = 200, TURN_TIMEOUT_MS = 3600000, _sdkCache, _sdkLoadError, cachedSdkPackageVersion, ClaudeSdkAgentService;
|
|
@@ -29263,14 +29279,16 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
29263
29279
|
initialPrompt,
|
|
29264
29280
|
deferInitialTurn = false,
|
|
29265
29281
|
storedSystemPrompt,
|
|
29266
|
-
executablePath
|
|
29282
|
+
executablePath,
|
|
29283
|
+
resumedProviderSessionId
|
|
29267
29284
|
} = args2;
|
|
29268
29285
|
const entry = this.registerProcess(pid, context5);
|
|
29269
29286
|
const logPrefix = buildAgentLogPrefix("claude-sdk", context5);
|
|
29270
29287
|
const sdkSession = {
|
|
29271
29288
|
keeper,
|
|
29272
29289
|
aborted: false,
|
|
29273
|
-
storedSystemPrompt
|
|
29290
|
+
storedSystemPrompt,
|
|
29291
|
+
...resumedProviderSessionId ? { sessionId: resumedProviderSessionId, resumeOnFirstQuery: true } : {}
|
|
29274
29292
|
};
|
|
29275
29293
|
this.sessions.set(pid, sdkSession);
|
|
29276
29294
|
const exitCallbacks = [];
|
|
@@ -29278,10 +29296,12 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
29278
29296
|
const agentEndCallbacks = [];
|
|
29279
29297
|
const logLineCallbacks = [];
|
|
29280
29298
|
const assistantTextCallbacks = [];
|
|
29299
|
+
const sessionIdUpdatedCallbacks = [];
|
|
29281
29300
|
const emitLogLine = (line) => {
|
|
29282
29301
|
for (const cb of logLineCallbacks)
|
|
29283
29302
|
cb(line);
|
|
29284
29303
|
};
|
|
29304
|
+
const harnessSessionId = randomUUID();
|
|
29285
29305
|
const finishExit = (code2, signal) => {
|
|
29286
29306
|
sdkSession.activeQuery = undefined;
|
|
29287
29307
|
this.sessions.delete(pid);
|
|
@@ -29292,6 +29312,8 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
29292
29312
|
};
|
|
29293
29313
|
this.runTurnLoop({
|
|
29294
29314
|
sdkSession,
|
|
29315
|
+
correlationId: harnessSessionId,
|
|
29316
|
+
sessionIdUpdatedCallbacks,
|
|
29295
29317
|
entry,
|
|
29296
29318
|
logPrefix,
|
|
29297
29319
|
workingDir,
|
|
@@ -29307,7 +29329,7 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
29307
29329
|
});
|
|
29308
29330
|
return {
|
|
29309
29331
|
pid,
|
|
29310
|
-
harnessSessionId
|
|
29332
|
+
harnessSessionId,
|
|
29311
29333
|
onExit: (cb) => {
|
|
29312
29334
|
exitCallbacks.push(cb);
|
|
29313
29335
|
},
|
|
@@ -29322,12 +29344,24 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
29322
29344
|
},
|
|
29323
29345
|
onAssistantText: (cb) => {
|
|
29324
29346
|
assistantTextCallbacks.push(cb);
|
|
29347
|
+
},
|
|
29348
|
+
onHarnessSessionIdUpdated: (cb) => {
|
|
29349
|
+
sessionIdUpdatedCallbacks.push(cb);
|
|
29350
|
+
if (resumedProviderSessionId) {
|
|
29351
|
+
cb({
|
|
29352
|
+
correlationId: harnessSessionId,
|
|
29353
|
+
resumableId: resumedProviderSessionId,
|
|
29354
|
+
source: "provider_allocated"
|
|
29355
|
+
});
|
|
29356
|
+
}
|
|
29325
29357
|
}
|
|
29326
29358
|
};
|
|
29327
29359
|
}
|
|
29328
29360
|
runTurnLoop(args2) {
|
|
29329
29361
|
const {
|
|
29330
29362
|
sdkSession,
|
|
29363
|
+
correlationId,
|
|
29364
|
+
sessionIdUpdatedCallbacks,
|
|
29331
29365
|
logPrefix,
|
|
29332
29366
|
workingDir,
|
|
29333
29367
|
model,
|
|
@@ -29344,6 +29378,8 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
29344
29378
|
let exited = false;
|
|
29345
29379
|
this.executeTurnLoop({
|
|
29346
29380
|
sdkSession,
|
|
29381
|
+
correlationId,
|
|
29382
|
+
sessionIdUpdatedCallbacks,
|
|
29347
29383
|
logPrefix,
|
|
29348
29384
|
workingDir,
|
|
29349
29385
|
model,
|
|
@@ -29374,6 +29410,8 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
29374
29410
|
async executeTurnLoop(args2) {
|
|
29375
29411
|
const {
|
|
29376
29412
|
sdkSession,
|
|
29413
|
+
correlationId,
|
|
29414
|
+
sessionIdUpdatedCallbacks,
|
|
29377
29415
|
logPrefix,
|
|
29378
29416
|
workingDir,
|
|
29379
29417
|
model,
|
|
@@ -29416,6 +29454,7 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
29416
29454
|
agentEndCallbacks,
|
|
29417
29455
|
entry
|
|
29418
29456
|
});
|
|
29457
|
+
const useResume = Boolean(sdkSession.sessionId) && (!isFirstQuery || sdkSession.resumeOnFirstQuery === true);
|
|
29419
29458
|
const queryInstance = query({
|
|
29420
29459
|
prompt: nextPrompt,
|
|
29421
29460
|
options: {
|
|
@@ -29424,19 +29463,25 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
29424
29463
|
maxTurns: DEFAULT_MAX_TURNS2,
|
|
29425
29464
|
pathToClaudeCodeExecutable: executablePath,
|
|
29426
29465
|
includePartialMessages: true,
|
|
29427
|
-
systemPrompt: isFirstQuery ? sdkSession.storedSystemPrompt : undefined,
|
|
29428
|
-
resume:
|
|
29429
|
-
settingSources: []
|
|
29466
|
+
systemPrompt: isFirstQuery && !sdkSession.resumeOnFirstQuery ? sdkSession.storedSystemPrompt : undefined,
|
|
29467
|
+
resume: useResume ? sdkSession.sessionId : undefined,
|
|
29468
|
+
settingSources: [],
|
|
29469
|
+
permissionMode: "bypassPermissions",
|
|
29470
|
+
allowDangerouslySkipPermissions: true,
|
|
29471
|
+
canUseTool: async (_toolName, input) => ({ behavior: "allow", updatedInput: input })
|
|
29430
29472
|
}
|
|
29431
29473
|
});
|
|
29432
29474
|
sdkSession.activeQuery = queryInstance;
|
|
29475
|
+
if (sdkSession.resumeOnFirstQuery) {
|
|
29476
|
+
sdkSession.resumeOnFirstQuery = false;
|
|
29477
|
+
}
|
|
29433
29478
|
isFirstQuery = false;
|
|
29434
29479
|
nextPrompt = null;
|
|
29435
29480
|
await withTimeout((async () => {
|
|
29436
29481
|
for await (const message of queryInstance) {
|
|
29437
29482
|
if (sdkSession.aborted)
|
|
29438
29483
|
break;
|
|
29439
|
-
|
|
29484
|
+
notifyResumableSessionId(message, sdkSession, correlationId, sessionIdUpdatedCallbacks);
|
|
29440
29485
|
adapter.handleMessage(message);
|
|
29441
29486
|
if (message.type === "result")
|
|
29442
29487
|
break;
|
|
@@ -29495,6 +29540,30 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
29495
29540
|
executablePath
|
|
29496
29541
|
});
|
|
29497
29542
|
}
|
|
29543
|
+
async resumeFromDaemonMemory(options, stored) {
|
|
29544
|
+
try {
|
|
29545
|
+
const keeper = this.spawnKeeper(stored.workingDir);
|
|
29546
|
+
const pid = keeper.pid;
|
|
29547
|
+
await loadSdk();
|
|
29548
|
+
const executablePath = await resolvePathToClaudeCodeExecutable();
|
|
29549
|
+
return this.startRunningSession({
|
|
29550
|
+
pid,
|
|
29551
|
+
keeper,
|
|
29552
|
+
context: options.context,
|
|
29553
|
+
workingDir: stored.workingDir,
|
|
29554
|
+
model: options.model ?? stored.model,
|
|
29555
|
+
initialPrompt: options.prompt,
|
|
29556
|
+
deferInitialTurn: false,
|
|
29557
|
+
storedSystemPrompt: options.systemPrompt,
|
|
29558
|
+
executablePath,
|
|
29559
|
+
resumedProviderSessionId: stored.harnessSessionId
|
|
29560
|
+
});
|
|
29561
|
+
} catch (err) {
|
|
29562
|
+
writeSpawnError(buildAgentLogPrefix("claude-sdk", options.context), err, (line) => process.stderr.write(`${line}
|
|
29563
|
+
`));
|
|
29564
|
+
return this.spawn(options);
|
|
29565
|
+
}
|
|
29566
|
+
}
|
|
29498
29567
|
};
|
|
29499
29568
|
});
|
|
29500
29569
|
|
|
@@ -29911,7 +29980,7 @@ var init_cursor_sdk_stream_adapter = __esm(() => {
|
|
|
29911
29980
|
});
|
|
29912
29981
|
|
|
29913
29982
|
// src/infrastructure/services/remote-agents/cursor-sdk/cursor-sdk-agent-service.ts
|
|
29914
|
-
import { randomUUID } from "node:crypto";
|
|
29983
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
29915
29984
|
async function loadSdk2() {
|
|
29916
29985
|
if (_sdkCache2)
|
|
29917
29986
|
return _sdkCache2;
|
|
@@ -30260,7 +30329,7 @@ ${deferredResume}` : deferredResume;
|
|
|
30260
30329
|
}
|
|
30261
30330
|
const run3 = await withTimeout(agent.send(nextPrompt, {
|
|
30262
30331
|
local: { force: isFirstTurn },
|
|
30263
|
-
idempotencyKey:
|
|
30332
|
+
idempotencyKey: randomUUID2()
|
|
30264
30333
|
}), SEND_TIMEOUT_MS, "agent.send");
|
|
30265
30334
|
session2.run = run3;
|
|
30266
30335
|
isFirstTurn = false;
|
|
@@ -34092,7 +34161,7 @@ var init_detection = __esm(() => {
|
|
|
34092
34161
|
var MACHINE_CONFIG_VERSION = "1";
|
|
34093
34162
|
|
|
34094
34163
|
// src/infrastructure/machine/storage.ts
|
|
34095
|
-
import { randomUUID as
|
|
34164
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
34096
34165
|
import * as fs4 from "node:fs/promises";
|
|
34097
34166
|
import { homedir as homedir3, hostname as hostname2 } from "node:os";
|
|
34098
34167
|
import { join as join11 } from "node:path";
|
|
@@ -34149,7 +34218,7 @@ async function createNewEndpointConfig() {
|
|
|
34149
34218
|
const now = new Date().toISOString();
|
|
34150
34219
|
const availableHarnesses = await detectAvailableHarnesses();
|
|
34151
34220
|
return {
|
|
34152
|
-
machineId:
|
|
34221
|
+
machineId: randomUUID3(),
|
|
34153
34222
|
hostname: hostname2(),
|
|
34154
34223
|
os: process.platform,
|
|
34155
34224
|
registeredAt: now,
|
|
@@ -77106,7 +77175,7 @@ var claudeSdkCapabilities;
|
|
|
77106
77175
|
var init_claude_sdk_config = __esm(() => {
|
|
77107
77176
|
claudeSdkCapabilities = {
|
|
77108
77177
|
runtimeKind: "sdk",
|
|
77109
|
-
supportsDaemonMemoryResume:
|
|
77178
|
+
supportsDaemonMemoryResume: true,
|
|
77110
77179
|
supportsNativeIntegration: true,
|
|
77111
77180
|
lifecycle: {
|
|
77112
77181
|
turnCompleted: true,
|
|
@@ -82506,7 +82575,7 @@ var init_pid = __esm(() => {
|
|
|
82506
82575
|
});
|
|
82507
82576
|
|
|
82508
82577
|
// src/infrastructure/harnesses/cursor-sdk/cursor-session.ts
|
|
82509
|
-
import { randomUUID as
|
|
82578
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
82510
82579
|
|
|
82511
82580
|
class CursorSdkSession {
|
|
82512
82581
|
opencodeSessionId;
|
|
@@ -82533,13 +82602,13 @@ class CursorSdkSession {
|
|
|
82533
82602
|
throw new Error("Session is closed");
|
|
82534
82603
|
const text = input.parts.map((p) => p.text).join(`
|
|
82535
82604
|
`);
|
|
82536
|
-
const messageId =
|
|
82605
|
+
const messageId = randomUUID4();
|
|
82537
82606
|
const isFirstTurn = this.turnCount === 0;
|
|
82538
82607
|
this.turnCount += 1;
|
|
82539
82608
|
const modelId = input.model ? resolveModelFromPrompt(input.model.providerID, input.model.modelID) : undefined;
|
|
82540
82609
|
const run3 = await withTimeout(this.agent.send(text, {
|
|
82541
82610
|
local: { force: isFirstTurn },
|
|
82542
|
-
idempotencyKey:
|
|
82611
|
+
idempotencyKey: randomUUID4(),
|
|
82543
82612
|
...modelId ? { model: { id: modelId } } : {}
|
|
82544
82613
|
}), SEND_TIMEOUT_MS2, "agent.send");
|
|
82545
82614
|
for await (const message of run3.stream()) {
|
|
@@ -83308,7 +83377,7 @@ var init_opencode_harness = __esm(() => {
|
|
|
83308
83377
|
});
|
|
83309
83378
|
|
|
83310
83379
|
// src/infrastructure/harnesses/pi-sdk/pi-session.ts
|
|
83311
|
-
import { randomUUID as
|
|
83380
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
83312
83381
|
|
|
83313
83382
|
class PiSdkSession {
|
|
83314
83383
|
opencodeSessionId;
|
|
@@ -83335,7 +83404,7 @@ class PiSdkSession {
|
|
|
83335
83404
|
throw new Error("Session is closed");
|
|
83336
83405
|
const text = input.parts.map((p) => p.text).join(`
|
|
83337
83406
|
`);
|
|
83338
|
-
const messageId =
|
|
83407
|
+
const messageId = randomUUID5();
|
|
83339
83408
|
const onSessionEvent = (event) => {
|
|
83340
83409
|
if (this.closed)
|
|
83341
83410
|
return;
|
|
@@ -86685,6 +86754,11 @@ var init_native_task_delivery_coordinator = __esm(() => {
|
|
|
86685
86754
|
init_convex_error();
|
|
86686
86755
|
});
|
|
86687
86756
|
|
|
86757
|
+
// src/domain/agent-lifecycle/resolve-resumable-harness-session-id.ts
|
|
86758
|
+
function resolveResumableHarnessSessionId(snapshot) {
|
|
86759
|
+
return snapshot.resumableHarnessSessionId ?? snapshot.harnessSessionId;
|
|
86760
|
+
}
|
|
86761
|
+
|
|
86688
86762
|
// src/domain/agent-lifecycle/entities/stop-reason.ts
|
|
86689
86763
|
function resolveStopReason(code2, signal) {
|
|
86690
86764
|
if (signal !== null)
|
|
@@ -87440,6 +87514,7 @@ class AgentProcessManager {
|
|
|
87440
87514
|
pid: slot.pid,
|
|
87441
87515
|
harness: slot.harness,
|
|
87442
87516
|
harnessSessionId: slot.harnessSessionId,
|
|
87517
|
+
resumableHarnessSessionId: slot.resumableHarnessSessionId,
|
|
87443
87518
|
model: slot.model,
|
|
87444
87519
|
workingDir: slot.workingDir,
|
|
87445
87520
|
startedAt: slot.startedAt,
|
|
@@ -87462,6 +87537,7 @@ class AgentProcessManager {
|
|
|
87462
87537
|
slot.pid = undefined;
|
|
87463
87538
|
slot.harness = undefined;
|
|
87464
87539
|
slot.harnessSessionId = undefined;
|
|
87540
|
+
slot.resumableHarnessSessionId = undefined;
|
|
87465
87541
|
slot.model = undefined;
|
|
87466
87542
|
slot.workingDir = undefined;
|
|
87467
87543
|
slot.startedAt = undefined;
|
|
@@ -87689,6 +87765,7 @@ class AgentProcessManager {
|
|
|
87689
87765
|
model: slot.model,
|
|
87690
87766
|
workingDir: slot.workingDir,
|
|
87691
87767
|
harnessSessionId: slot.harnessSessionId,
|
|
87768
|
+
resumableHarnessSessionId: slot.resumableHarnessSessionId,
|
|
87692
87769
|
wantResume: slot.wantResume,
|
|
87693
87770
|
recentLogLines: slot.recentLogLines,
|
|
87694
87771
|
stopReason,
|
|
@@ -87700,6 +87777,7 @@ class AgentProcessManager {
|
|
|
87700
87777
|
const harnessMeta = service3 && slot.pid ? this.readHarnessReconnectMetadata(service3, slot.pid) : undefined;
|
|
87701
87778
|
this.recordLastHarnessSession(key, {
|
|
87702
87779
|
harnessSessionId,
|
|
87780
|
+
resumableHarnessSessionId: ctx.resumableHarnessSessionId,
|
|
87703
87781
|
harness,
|
|
87704
87782
|
agentName: harnessMeta?.agentName ?? "",
|
|
87705
87783
|
workingDir: ctx.workingDir ?? "",
|
|
@@ -87836,7 +87914,8 @@ class AgentProcessManager {
|
|
|
87836
87914
|
this.clearHarnessSessionAfterResumePhaseFailure(key, opts);
|
|
87837
87915
|
}
|
|
87838
87916
|
const wantResume = this.resolveCursorSdkReopenWantResume(hadRunError, attempt, ctx);
|
|
87839
|
-
const
|
|
87917
|
+
const stored = this.lastHarnessSessions.get(key);
|
|
87918
|
+
const storedSessionId = stored ? resolveResumableHarnessSessionId(stored) : undefined;
|
|
87840
87919
|
await this.emitSessionReopenRetry(opts.chatroomId, opts.role, attempt, attempt > 1 ? lastError : undefined, storedSessionId);
|
|
87841
87920
|
const result = await this.ensureRunning({
|
|
87842
87921
|
chatroomId: opts.chatroomId,
|
|
@@ -88086,7 +88165,8 @@ class AgentProcessManager {
|
|
|
88086
88165
|
return null;
|
|
88087
88166
|
}
|
|
88088
88167
|
try {
|
|
88089
|
-
|
|
88168
|
+
const resumableId = resolveResumableHarnessSessionId(stored);
|
|
88169
|
+
await this.emitSessionResumeRequested(opts.chatroomId, opts.role, opts.agentHarness, resumableId);
|
|
88090
88170
|
const spawnResult = await opts.service.resumeFromDaemonMemory({
|
|
88091
88171
|
workingDir: stored.workingDir,
|
|
88092
88172
|
prompt: createSpawnPrompt(opts.initPrompt),
|
|
@@ -88099,17 +88179,17 @@ class AgentProcessManager {
|
|
|
88099
88179
|
},
|
|
88100
88180
|
resolvedConvexUrl: this.deps.convexUrl
|
|
88101
88181
|
}, {
|
|
88102
|
-
harnessSessionId:
|
|
88182
|
+
harnessSessionId: resumableId,
|
|
88103
88183
|
agentName: stored.agentName,
|
|
88104
88184
|
workingDir: stored.workingDir,
|
|
88105
88185
|
model: stored.model
|
|
88106
88186
|
});
|
|
88107
|
-
await this.emitSessionResumed(opts.chatroomId, opts.role,
|
|
88187
|
+
await this.emitSessionResumed(opts.chatroomId, opts.role, resumableId);
|
|
88108
88188
|
return spawnResult;
|
|
88109
88189
|
} catch (err) {
|
|
88110
88190
|
const reason = err instanceof Error ? err.message : String(err);
|
|
88111
88191
|
this.clearLastHarnessSession(opts.key);
|
|
88112
|
-
await this.emitSessionResumeFailed(opts.chatroomId, opts.role, reason, stored
|
|
88192
|
+
await this.emitSessionResumeFailed(opts.chatroomId, opts.role, reason, resolveResumableHarnessSessionId(stored));
|
|
88113
88193
|
return null;
|
|
88114
88194
|
}
|
|
88115
88195
|
}
|
|
@@ -88120,16 +88200,16 @@ class AgentProcessManager {
|
|
|
88120
88200
|
}
|
|
88121
88201
|
if (stored.workingDir !== opts.workingDir) {
|
|
88122
88202
|
this.clearLastHarnessSession(opts.key);
|
|
88123
|
-
this.emitSessionResumeFailed(opts.chatroomId, opts.role, "working directory changed", stored
|
|
88203
|
+
this.emitSessionResumeFailed(opts.chatroomId, opts.role, "working directory changed", resolveResumableHarnessSessionId(stored));
|
|
88124
88204
|
return "working directory changed";
|
|
88125
88205
|
}
|
|
88126
88206
|
if (stored.harness !== opts.agentHarness || !stored.agentName) {
|
|
88127
88207
|
this.clearLastHarnessSession(opts.key);
|
|
88128
|
-
this.emitSessionResumeFailed(opts.chatroomId, opts.role, stored.harness !== opts.agentHarness ? "harness changed" : "incomplete session in daemon memory", stored
|
|
88208
|
+
this.emitSessionResumeFailed(opts.chatroomId, opts.role, stored.harness !== opts.agentHarness ? "harness changed" : "incomplete session in daemon memory", resolveResumableHarnessSessionId(stored));
|
|
88129
88209
|
return "validation failed";
|
|
88130
88210
|
}
|
|
88131
88211
|
if (!opts.service.resumeFromDaemonMemory) {
|
|
88132
|
-
this.emitSessionResumeFailed(opts.chatroomId, opts.role, "daemon-memory session resume not yet supported", stored
|
|
88212
|
+
this.emitSessionResumeFailed(opts.chatroomId, opts.role, "daemon-memory session resume not yet supported", resolveResumableHarnessSessionId(stored));
|
|
88133
88213
|
return "not supported";
|
|
88134
88214
|
}
|
|
88135
88215
|
return null;
|
|
@@ -88195,6 +88275,36 @@ class AgentProcessManager {
|
|
|
88195
88275
|
console.log(` ⚠️ Failed to emit sessionReopenRetry event: ${err.message}`);
|
|
88196
88276
|
}
|
|
88197
88277
|
}
|
|
88278
|
+
applyHarnessSessionIdUpdate(key, slot, chatroomId, role, info) {
|
|
88279
|
+
if (!slot.harnessSessionId || slot.harnessSessionId !== info.correlationId) {
|
|
88280
|
+
return;
|
|
88281
|
+
}
|
|
88282
|
+
slot.resumableHarnessSessionId = info.resumableId;
|
|
88283
|
+
const stored = this.lastHarnessSessions.get(key);
|
|
88284
|
+
if (stored?.harnessSessionId === info.correlationId) {
|
|
88285
|
+
this.recordLastHarnessSession(key, {
|
|
88286
|
+
...stored,
|
|
88287
|
+
resumableHarnessSessionId: info.resumableId
|
|
88288
|
+
});
|
|
88289
|
+
}
|
|
88290
|
+
this.emitHarnessSessionIdUpdated(chatroomId, role, info);
|
|
88291
|
+
}
|
|
88292
|
+
async emitHarnessSessionIdUpdated(chatroomId, role, info) {
|
|
88293
|
+
try {
|
|
88294
|
+
await this.deps.backend.mutation(api.machines.emitHarnessSessionIdUpdated, {
|
|
88295
|
+
sessionId: this.deps.sessionId,
|
|
88296
|
+
machineId: this.deps.machineId,
|
|
88297
|
+
chatroomId,
|
|
88298
|
+
role,
|
|
88299
|
+
correlationId: info.correlationId,
|
|
88300
|
+
...info.previousResumableId ? { previousResumableId: info.previousResumableId } : {},
|
|
88301
|
+
resumableId: info.resumableId,
|
|
88302
|
+
source: info.source
|
|
88303
|
+
});
|
|
88304
|
+
} catch (err) {
|
|
88305
|
+
console.log(` ⚠️ Failed to emit harnessSessionIdUpdated event: ${err.message}`);
|
|
88306
|
+
}
|
|
88307
|
+
}
|
|
88198
88308
|
resetSlotIdle(slot) {
|
|
88199
88309
|
slot.state = "idle";
|
|
88200
88310
|
slot.pendingOperation = undefined;
|
|
@@ -88337,9 +88447,11 @@ class AgentProcessManager {
|
|
|
88337
88447
|
slot.pid = pid;
|
|
88338
88448
|
slot.harness = opts.agentHarness;
|
|
88339
88449
|
slot.harnessSessionId = spawnResult.harnessSessionId;
|
|
88450
|
+
slot.resumableHarnessSessionId = undefined;
|
|
88340
88451
|
if (spawnResult.harnessSessionId) {
|
|
88341
88452
|
this.recordLastHarnessSession(key, {
|
|
88342
88453
|
harnessSessionId: spawnResult.harnessSessionId,
|
|
88454
|
+
resumableHarnessSessionId: undefined,
|
|
88343
88455
|
harness: opts.agentHarness,
|
|
88344
88456
|
agentName: spawnResult.harnessReconnect?.agentName ?? "",
|
|
88345
88457
|
workingDir: opts.workingDir,
|
|
@@ -88391,6 +88503,12 @@ class AgentProcessManager {
|
|
|
88391
88503
|
}));
|
|
88392
88504
|
});
|
|
88393
88505
|
}
|
|
88506
|
+
if (spawnResult.onHarnessSessionIdUpdated) {
|
|
88507
|
+
spawnResult.onHarnessSessionIdUpdated((info) => {
|
|
88508
|
+
const slotKey = agentKey3(opts.chatroomId, opts.role);
|
|
88509
|
+
this.applyHarnessSessionIdUpdate(slotKey, slot, opts.chatroomId, opts.role, info);
|
|
88510
|
+
});
|
|
88511
|
+
}
|
|
88394
88512
|
let lastReportedTokenAt = 0;
|
|
88395
88513
|
spawnResult.onOutput(() => {
|
|
88396
88514
|
const now = this.deps.clock.now();
|
|
@@ -88477,6 +88595,7 @@ class AgentProcessManager {
|
|
|
88477
88595
|
const harnessMeta = service3 ? this.readHarnessReconnectMetadata(service3, pid) : undefined;
|
|
88478
88596
|
this.recordLastHarnessSession(key, {
|
|
88479
88597
|
harnessSessionId: slot.harnessSessionId,
|
|
88598
|
+
resumableHarnessSessionId: slot.resumableHarnessSessionId,
|
|
88480
88599
|
harness,
|
|
88481
88600
|
agentName: harnessMeta?.agentName ?? "",
|
|
88482
88601
|
workingDir: slot.workingDir ?? "",
|
|
@@ -107736,4 +107855,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
107736
107855
|
});
|
|
107737
107856
|
program2.parse();
|
|
107738
107857
|
|
|
107739
|
-
//# debugId=
|
|
107858
|
+
//# debugId=6FC50BA17F0D043E64756E2164756E21
|