chatroom-cli 1.58.6 → 1.59.1

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 CHANGED
@@ -28762,6 +28762,747 @@ var init_claude = __esm(() => {
28762
28762
  init_claude_code_agent_service();
28763
28763
  });
28764
28764
 
28765
+ // src/infrastructure/services/remote-agents/wire-native-stream-adapter.ts
28766
+ function wireNativeStreamAdapter(args2) {
28767
+ args2.adapter.setAssistantTextCapture((text) => {
28768
+ for (const cb of args2.assistantTextCallbacks)
28769
+ cb(text);
28770
+ });
28771
+ args2.adapter.onOutput(() => {
28772
+ args2.entry.lastOutputAt = Date.now();
28773
+ for (const cb of args2.outputCallbacks)
28774
+ cb();
28775
+ });
28776
+ args2.adapter.onAgentEnd(() => {
28777
+ for (const cb of args2.agentEndCallbacks)
28778
+ cb();
28779
+ });
28780
+ }
28781
+
28782
+ // src/infrastructure/services/remote-agents/with-timeout.ts
28783
+ async function withTimeout(p, ms, label) {
28784
+ let timer;
28785
+ try {
28786
+ return await Promise.race([
28787
+ p,
28788
+ new Promise((_, reject) => {
28789
+ timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
28790
+ })
28791
+ ]);
28792
+ } finally {
28793
+ if (timer)
28794
+ clearTimeout(timer);
28795
+ }
28796
+ }
28797
+
28798
+ // src/infrastructure/services/remote-agents/claude-sdk/claude-sdk-package.ts
28799
+ import { existsSync, readFileSync as readFileSync3 } from "node:fs";
28800
+ import { createRequire as createRequire3 } from "node:module";
28801
+ import { dirname as dirname2, join as join7 } from "node:path";
28802
+ import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
28803
+ function resolveChatroomCliRoot(moduleRef = import.meta.url) {
28804
+ const filePath = moduleRef.startsWith("file:") ? fileURLToPath2(moduleRef) : moduleRef;
28805
+ let dir = dirname2(filePath);
28806
+ while (dir !== dirname2(dir)) {
28807
+ const packageJsonPath = join7(dir, "package.json");
28808
+ if (existsSync(packageJsonPath)) {
28809
+ const pkg = JSON.parse(readFileSync3(packageJsonPath, "utf8"));
28810
+ if (pkg.name === "chatroom-cli") {
28811
+ return dir;
28812
+ }
28813
+ }
28814
+ dir = dirname2(dir);
28815
+ }
28816
+ throw new ClaudeSdkPackageError(`Could not locate chatroom-cli package root while resolving ${CLAUDE_AGENT_SDK_PKG}. ${REINSTALL_HINT}`);
28817
+ }
28818
+ function readPinnedSdkVersion(chatroomCliRoot) {
28819
+ const pkg = JSON.parse(readFileSync3(join7(chatroomCliRoot, "package.json"), "utf8"));
28820
+ const specifier = pkg.dependencies?.[CLAUDE_AGENT_SDK_PKG];
28821
+ const pinned = specifier?.replace(/^[\^~>=<]+/, "").trim() ?? "";
28822
+ const match17 = pinned.match(/^(\d+\.\d+\.\d+)/);
28823
+ if (!match17) {
28824
+ throw new ClaudeSdkPackageError(`chatroom-cli must pin an exact ${CLAUDE_AGENT_SDK_PKG} version (found "${specifier ?? "none"}"). ${REINSTALL_HINT}`);
28825
+ }
28826
+ return match17[1];
28827
+ }
28828
+ function readInstalledSdkVersion(entryPath) {
28829
+ const packageJsonPath = join7(dirname2(entryPath), "package.json");
28830
+ const pkg = JSON.parse(readFileSync3(packageJsonPath, "utf8"));
28831
+ return pkg.version;
28832
+ }
28833
+ function resolvePlatformPackageName() {
28834
+ const key = `${process.platform}-${process.arch}`;
28835
+ const map18 = {
28836
+ "darwin-arm64": "@anthropic-ai/claude-agent-sdk-darwin-arm64",
28837
+ "darwin-x64": "@anthropic-ai/claude-agent-sdk-darwin-x64",
28838
+ "linux-arm64": "@anthropic-ai/claude-agent-sdk-linux-arm64",
28839
+ "linux-x64": "@anthropic-ai/claude-agent-sdk-linux-x64",
28840
+ "win32-arm64": "@anthropic-ai/claude-agent-sdk-win32-arm64",
28841
+ "win32-x64": "@anthropic-ai/claude-agent-sdk-win32-x64"
28842
+ };
28843
+ const pkg = map18[key];
28844
+ if (!pkg) {
28845
+ throw new ClaudeSdkPackageError(`Unsupported platform for ${CLAUDE_AGENT_SDK_PKG}: ${key}. ${REINSTALL_HINT}`);
28846
+ }
28847
+ return pkg;
28848
+ }
28849
+ function resolveNativeCliBinaryPath(sdkEntryPath) {
28850
+ const require3 = createRequire3(sdkEntryPath);
28851
+ const platformPkg = resolvePlatformPackageName();
28852
+ const binaryName = process.platform === "win32" ? "claude.exe" : "claude";
28853
+ let pkgDir;
28854
+ try {
28855
+ pkgDir = dirname2(require3.resolve(`${platformPkg}/package.json`));
28856
+ } catch {
28857
+ throw new ClaudeSdkPackageError(`Native CLI binary package ${platformPkg} is not installed. ${REINSTALL_HINT}`);
28858
+ }
28859
+ const binaryPath = join7(pkgDir, binaryName);
28860
+ if (!existsSync(binaryPath)) {
28861
+ throw new ClaudeSdkPackageError(`Native CLI binary is missing: ${binaryPath}. ${REINSTALL_HINT}`);
28862
+ }
28863
+ return binaryPath;
28864
+ }
28865
+ async function resolvePathToClaudeCodeExecutable(moduleRef = import.meta.url) {
28866
+ if (cachedExecutablePath)
28867
+ return cachedExecutablePath;
28868
+ const chatroomCliRoot = resolveChatroomCliRoot(moduleRef);
28869
+ const require3 = createRequire3(join7(chatroomCliRoot, "package.json"));
28870
+ const sdkEntryPath = require3.resolve(CLAUDE_AGENT_SDK_PKG, { paths: [chatroomCliRoot] });
28871
+ const embeddedPath = resolveNativeCliBinaryPath(sdkEntryPath);
28872
+ const { extractFromBunfs } = await import("@anthropic-ai/claude-agent-sdk/extract");
28873
+ cachedExecutablePath = extractFromBunfs(embeddedPath);
28874
+ return cachedExecutablePath;
28875
+ }
28876
+ async function importBundledClaudeSdk(moduleRef = import.meta.url) {
28877
+ const chatroomCliRoot = resolveChatroomCliRoot(moduleRef);
28878
+ const require3 = createRequire3(join7(chatroomCliRoot, "package.json"));
28879
+ const pinnedVersion = readPinnedSdkVersion(chatroomCliRoot);
28880
+ const entryPath = require3.resolve(CLAUDE_AGENT_SDK_PKG, { paths: [chatroomCliRoot] });
28881
+ const installedVersion = readInstalledSdkVersion(entryPath);
28882
+ if (installedVersion !== pinnedVersion) {
28883
+ throw new ClaudeSdkPackageError(`${CLAUDE_AGENT_SDK_PKG}@${installedVersion} does not match chatroom-cli pin (${pinnedVersion}). ${REINSTALL_HINT}`);
28884
+ }
28885
+ if (!existsSync(entryPath)) {
28886
+ throw new ClaudeSdkPackageError(`${CLAUDE_AGENT_SDK_PKG} entry file is missing: ${entryPath}. ${REINSTALL_HINT}`);
28887
+ }
28888
+ return import(pathToFileURL(entryPath).href);
28889
+ }
28890
+ function getBundledClaudeSdkVersion(moduleRef = import.meta.url) {
28891
+ const chatroomCliRoot = resolveChatroomCliRoot(moduleRef);
28892
+ const require3 = createRequire3(join7(chatroomCliRoot, "package.json"));
28893
+ const entryPath = require3.resolve(CLAUDE_AGENT_SDK_PKG, { paths: [chatroomCliRoot] });
28894
+ return readInstalledSdkVersion(entryPath);
28895
+ }
28896
+ function formatClaudeSdkLoadError(err) {
28897
+ if (err instanceof ClaudeSdkPackageError) {
28898
+ return err.message;
28899
+ }
28900
+ const message = err instanceof Error ? err.message : String(err);
28901
+ if (message.includes("Native CLI binary")) {
28902
+ return `${message} ${REINSTALL_HINT}`;
28903
+ }
28904
+ return message;
28905
+ }
28906
+ var CLAUDE_AGENT_SDK_PKG = "@anthropic-ai/claude-agent-sdk", REINSTALL_HINT = "Reinstall chatroom-cli: npm install -g chatroom-cli@latest", ClaudeSdkPackageError, cachedExecutablePath;
28907
+ var init_claude_sdk_package = __esm(() => {
28908
+ ClaudeSdkPackageError = class ClaudeSdkPackageError extends Error {
28909
+ code = "CLAUDE_SDK_PACKAGE_INCOMPLETE";
28910
+ constructor(message) {
28911
+ super(message);
28912
+ this.name = "ClaudeSdkPackageError";
28913
+ }
28914
+ };
28915
+ });
28916
+
28917
+ // src/infrastructure/services/remote-agents/assistant-text-capture.ts
28918
+ function createAssistantTextCapture() {
28919
+ let onAssistantText;
28920
+ return {
28921
+ setAssistantTextCapture(cb) {
28922
+ onAssistantText = cb;
28923
+ },
28924
+ captureAssistantText(text) {
28925
+ onAssistantText?.(text);
28926
+ }
28927
+ };
28928
+ }
28929
+
28930
+ // src/infrastructure/services/remote-agents/native-stream-adapter-base.ts
28931
+ class NativeStreamAdapterBase {
28932
+ logPrefix;
28933
+ emitLogLine;
28934
+ agentEndCallbacks = [];
28935
+ outputCallbacks = [];
28936
+ agentEndEmitted = false;
28937
+ assistantTextCapture = createAssistantTextCapture();
28938
+ constructor(logPrefix, emitLogLine) {
28939
+ this.logPrefix = logPrefix;
28940
+ this.emitLogLine = emitLogLine;
28941
+ }
28942
+ setAssistantTextCapture(cb) {
28943
+ this.assistantTextCapture.setAssistantTextCapture(cb);
28944
+ }
28945
+ onAgentEnd(cb) {
28946
+ this.agentEndCallbacks.push(cb);
28947
+ }
28948
+ onOutput(cb) {
28949
+ this.outputCallbacks.push(cb);
28950
+ }
28951
+ notifyOutput() {
28952
+ for (const cb of this.outputCallbacks)
28953
+ cb();
28954
+ }
28955
+ writeLine(line) {
28956
+ this.emitLogLine?.(line);
28957
+ }
28958
+ }
28959
+ var init_native_stream_adapter_base = () => {};
28960
+
28961
+ // src/infrastructure/services/remote-agents/claude-sdk/claude-sdk-stream-adapter.ts
28962
+ var ClaudeSdkStreamAdapter;
28963
+ var init_claude_sdk_stream_adapter = __esm(() => {
28964
+ init_native_stream_adapter_base();
28965
+ ClaudeSdkStreamAdapter = class ClaudeSdkStreamAdapter extends NativeStreamAdapterBase {
28966
+ textBuffer = "";
28967
+ thinkingBuffer = "";
28968
+ handleMessage(message) {
28969
+ this.notifyOutput();
28970
+ switch (message.type) {
28971
+ case "stream_event":
28972
+ this.handleStreamEvent(message);
28973
+ break;
28974
+ case "assistant":
28975
+ this.handleAssistant(message);
28976
+ break;
28977
+ case "user":
28978
+ this.handleUser(message);
28979
+ break;
28980
+ case "system":
28981
+ if (message.subtype === "init") {
28982
+ this.writeLine(formatAgentLogLine(this.logPrefix, "system: init"));
28983
+ }
28984
+ break;
28985
+ case "result":
28986
+ if (message.is_error) {
28987
+ const errors2 = "errors" in message && Array.isArray(message.errors) ? message.errors.join("; ") : "turn failed";
28988
+ this.writeLine(formatAgentLogLine(this.logPrefix, "run-error", errors2));
28989
+ }
28990
+ break;
28991
+ default:
28992
+ break;
28993
+ }
28994
+ }
28995
+ finish() {
28996
+ this.flushText();
28997
+ this.flushThinking();
28998
+ this.emitAgentEnd();
28999
+ }
29000
+ handleStreamEvent(message) {
29001
+ const event = message.event;
29002
+ if (event.type === "content_block_delta") {
29003
+ const delta = event.delta;
29004
+ if (delta.type === "text_delta") {
29005
+ this.appendText(delta.text);
29006
+ } else if (delta.type === "thinking_delta") {
29007
+ this.appendThinking(delta.thinking);
29008
+ }
29009
+ }
29010
+ }
29011
+ handleAssistant(message) {
29012
+ if (message.error) {
29013
+ this.writeLine(formatAgentLogLine(this.logPrefix, "run-error", `assistant error: ${message.error}`));
29014
+ }
29015
+ for (const block of message.message.content) {
29016
+ if (block.type === "text") {
29017
+ this.appendText(block.text);
29018
+ this.flushText();
29019
+ } else if (block.type === "thinking") {
29020
+ this.appendThinking(block.thinking);
29021
+ this.flushThinking();
29022
+ } else if (block.type === "tool_use") {
29023
+ this.flushText();
29024
+ this.flushThinking();
29025
+ const bashCmd = resolveBashCommandForLog(block.name, block.input);
29026
+ if (bashCmd !== null) {
29027
+ this.writeLine(formatAgentLogLine(this.logPrefix, BASH_TOOL_KIND, formatBashRunningPayload(bashCmd)));
29028
+ break;
29029
+ }
29030
+ const argsStr = block.input != null ? ` args: ${JSON.stringify(block.input)}` : "";
29031
+ this.writeLine(formatAgentLogLine(this.logPrefix, "tool", `${block.name}${argsStr}`));
29032
+ }
29033
+ }
29034
+ }
29035
+ handleUser(message) {
29036
+ if (message.tool_use_result === undefined)
29037
+ return;
29038
+ const content = message.message.content;
29039
+ const blocks = Array.isArray(content) ? content : [content];
29040
+ for (const block of blocks) {
29041
+ if (typeof block === "string")
29042
+ continue;
29043
+ if (block.type === "tool_result") {
29044
+ const resultStr = typeof block.content === "string" ? block.content : JSON.stringify(block.content);
29045
+ this.writeLine(formatAgentLogLine(this.logPrefix, "tool_result", `tool result: ${resultStr}`));
29046
+ }
29047
+ }
29048
+ }
29049
+ emitAgentEnd() {
29050
+ if (this.agentEndEmitted)
29051
+ return;
29052
+ this.agentEndEmitted = true;
29053
+ this.writeLine(formatAgentLogLine(this.logPrefix, "agent_end"));
29054
+ for (const cb of this.agentEndCallbacks)
29055
+ cb();
29056
+ }
29057
+ appendText(delta) {
29058
+ this.flushThinking();
29059
+ this.textBuffer += delta;
29060
+ this.assistantTextCapture.captureAssistantText(delta);
29061
+ if (this.textBuffer.includes(`
29062
+ `))
29063
+ this.flushText();
29064
+ }
29065
+ appendThinking(delta) {
29066
+ this.flushText();
29067
+ this.thinkingBuffer += delta;
29068
+ if (this.thinkingBuffer.includes(`
29069
+ `))
29070
+ this.flushThinking();
29071
+ }
29072
+ flushText() {
29073
+ if (!this.textBuffer)
29074
+ return;
29075
+ const lines = this.textBuffer.split(`
29076
+ `);
29077
+ const remaining = this.textBuffer.endsWith(`
29078
+ `) ? "" : lines.pop() ?? "";
29079
+ for (const line of lines) {
29080
+ if (line.length > 0) {
29081
+ this.writeLine(formatAgentLogLine(this.logPrefix, "text", line));
29082
+ }
29083
+ }
29084
+ this.textBuffer = remaining;
29085
+ }
29086
+ flushThinking() {
29087
+ if (!this.thinkingBuffer)
29088
+ return;
29089
+ const lines = this.thinkingBuffer.split(`
29090
+ `);
29091
+ const remaining = this.thinkingBuffer.endsWith(`
29092
+ `) ? "" : lines.pop() ?? "";
29093
+ for (const line of lines) {
29094
+ if (line.length > 0) {
29095
+ this.writeLine(formatAgentLogLine(this.logPrefix, "thinking", line));
29096
+ }
29097
+ }
29098
+ this.thinkingBuffer = remaining;
29099
+ }
29100
+ writeLine(line) {
29101
+ process.stderr.write(`${line}
29102
+ `);
29103
+ this.emitLogLine?.(line);
29104
+ }
29105
+ };
29106
+ });
29107
+
29108
+ // src/infrastructure/services/remote-agents/claude-sdk/claude-sdk-agent-service.ts
29109
+ async function loadSdk() {
29110
+ if (_sdkCache)
29111
+ return _sdkCache;
29112
+ if (_sdkLoadError)
29113
+ throw _sdkLoadError;
29114
+ try {
29115
+ _sdkCache = await importBundledClaudeSdk();
29116
+ return _sdkCache;
29117
+ } catch (err) {
29118
+ _sdkLoadError = err;
29119
+ throw err;
29120
+ }
29121
+ }
29122
+ function getSdkPackageVersion() {
29123
+ if (cachedSdkPackageVersion)
29124
+ return cachedSdkPackageVersion;
29125
+ cachedSdkPackageVersion = getBundledClaudeSdkVersion();
29126
+ return cachedSdkPackageVersion;
29127
+ }
29128
+ function waitForResumeOrAbort(session2) {
29129
+ if (session2.aborted)
29130
+ return Promise.resolve(null);
29131
+ const queued = session2.pendingResumePrompt;
29132
+ if (queued !== undefined) {
29133
+ session2.pendingResumePrompt = undefined;
29134
+ return Promise.resolve(queued);
29135
+ }
29136
+ return Promise.race([
29137
+ new Promise((resolve2) => {
29138
+ session2.resumeResolve = (prompt) => {
29139
+ session2.resumeResolve = undefined;
29140
+ session2.abortResolve = undefined;
29141
+ resolve2(prompt);
29142
+ };
29143
+ }),
29144
+ new Promise((resolve2) => {
29145
+ session2.abortResolve = () => {
29146
+ session2.resumeResolve = undefined;
29147
+ session2.abortResolve = undefined;
29148
+ resolve2(null);
29149
+ };
29150
+ })
29151
+ ]);
29152
+ }
29153
+ function writeSpawnError(logPrefix, err, emitLogLine) {
29154
+ const line = formatAgentLogLine(logPrefix, "spawn-error", formatClaudeSdkLoadError(err));
29155
+ process.stderr.write(`${line}
29156
+ `);
29157
+ emitLogLine?.(line);
29158
+ console.error(`[${new Date().toISOString()}] ${logPrefix} spawn-error]`, err);
29159
+ }
29160
+ function captureSessionId(message, session2) {
29161
+ if ("session_id" in message && typeof message.session_id === "string") {
29162
+ session2.sessionId = message.session_id;
29163
+ }
29164
+ }
29165
+ var CLAUDE_SDK_COMMAND = "claude-sdk", DEFAULT_MAX_TURNS2 = 200, TURN_TIMEOUT_MS = 3600000, _sdkCache, _sdkLoadError, cachedSdkPackageVersion, ClaudeSdkAgentService;
29166
+ var init_claude_sdk_agent_service = __esm(() => {
29167
+ init_esm();
29168
+ init_base_cli_agent_service();
29169
+ init_claude_models();
29170
+ init_detection_result();
29171
+ init_claude_sdk_package();
29172
+ init_claude_sdk_stream_adapter();
29173
+ ClaudeSdkAgentService = class ClaudeSdkAgentService extends BaseCLIAgentService {
29174
+ id = "claude-sdk";
29175
+ displayName = "Claude Code (SDK)";
29176
+ command = CLAUDE_SDK_COMMAND;
29177
+ sessions = new Map;
29178
+ constructor(deps) {
29179
+ super(deps);
29180
+ }
29181
+ async isInstalled() {
29182
+ try {
29183
+ await loadSdk();
29184
+ await resolvePathToClaudeCodeExecutable();
29185
+ return true;
29186
+ } catch (err) {
29187
+ console.warn(`[claude-sdk] unavailable: ${formatClaudeSdkLoadError(err)}`);
29188
+ return false;
29189
+ }
29190
+ }
29191
+ detectInstallationEffect() {
29192
+ return exports_Effect.promise(async () => {
29193
+ const installed = await this.isInstalled();
29194
+ return installed ? DetectionResult.Installed() : DetectionResult.NotInstalled();
29195
+ });
29196
+ }
29197
+ async getVersion() {
29198
+ const match17 = getSdkPackageVersion().match(/^(\d+)\.(\d+)\.(\d+)/);
29199
+ if (!match17)
29200
+ return null;
29201
+ return {
29202
+ version: `${match17[1]}.${match17[2]}.${match17[3]}`,
29203
+ major: parseInt(match17[1], 10)
29204
+ };
29205
+ }
29206
+ async listModels() {
29207
+ const dynamic = await fetchClaudeModels();
29208
+ if (dynamic)
29209
+ return dynamic;
29210
+ return [...CLAUDE_FALLBACK_MODELS];
29211
+ }
29212
+ async resumeTurn(pid, prompt) {
29213
+ const session2 = this.sessions.get(pid);
29214
+ if (!session2) {
29215
+ throw new Error(`No claude-sdk session for pid=${pid}`);
29216
+ }
29217
+ if (session2.resumeResolve) {
29218
+ const resolve2 = session2.resumeResolve;
29219
+ session2.resumeResolve = undefined;
29220
+ session2.abortResolve = undefined;
29221
+ resolve2(prompt);
29222
+ return;
29223
+ }
29224
+ session2.pendingResumePrompt = prompt;
29225
+ }
29226
+ async stop(pid, _options) {
29227
+ const session2 = this.sessions.get(pid);
29228
+ if (session2) {
29229
+ session2.aborted = true;
29230
+ session2.abortResolve?.();
29231
+ try {
29232
+ await withTimeout(session2.activeQuery?.interrupt() ?? Promise.resolve(), 5000, "interrupt");
29233
+ } catch (err) {
29234
+ console.warn(`[claude-sdk] interrupt for pid=${pid} failed:`, err instanceof Error ? err.message : err);
29235
+ }
29236
+ try {
29237
+ session2.keeper.kill();
29238
+ } catch {}
29239
+ this.sessions.delete(pid);
29240
+ }
29241
+ await super.stop(pid);
29242
+ }
29243
+ spawnKeeper(workingDir) {
29244
+ const keeper = this.deps.spawn(process.execPath, ["-e", "setInterval(()=>{},2147483647)"], {
29245
+ cwd: workingDir,
29246
+ stdio: "ignore",
29247
+ shell: false,
29248
+ detached: true
29249
+ });
29250
+ if (!keeper.pid) {
29251
+ keeper.kill();
29252
+ throw new Error("Failed to spawn claude-sdk keeper process");
29253
+ }
29254
+ return keeper;
29255
+ }
29256
+ startRunningSession(args2) {
29257
+ const {
29258
+ pid,
29259
+ keeper,
29260
+ context: context5,
29261
+ workingDir,
29262
+ model,
29263
+ initialPrompt,
29264
+ deferInitialTurn = false,
29265
+ storedSystemPrompt,
29266
+ executablePath
29267
+ } = args2;
29268
+ const entry = this.registerProcess(pid, context5);
29269
+ const logPrefix = buildAgentLogPrefix("claude-sdk", context5);
29270
+ const sdkSession = {
29271
+ keeper,
29272
+ aborted: false,
29273
+ storedSystemPrompt
29274
+ };
29275
+ this.sessions.set(pid, sdkSession);
29276
+ const exitCallbacks = [];
29277
+ const outputCallbacks = [];
29278
+ const agentEndCallbacks = [];
29279
+ const logLineCallbacks = [];
29280
+ const assistantTextCallbacks = [];
29281
+ const emitLogLine = (line) => {
29282
+ for (const cb of logLineCallbacks)
29283
+ cb(line);
29284
+ };
29285
+ const finishExit = (code2, signal) => {
29286
+ sdkSession.activeQuery = undefined;
29287
+ this.sessions.delete(pid);
29288
+ this.deleteProcess(pid);
29289
+ for (const cb of exitCallbacks) {
29290
+ cb({ code: code2, signal, context: context5 });
29291
+ }
29292
+ };
29293
+ this.runTurnLoop({
29294
+ sdkSession,
29295
+ entry,
29296
+ logPrefix,
29297
+ workingDir,
29298
+ model,
29299
+ executablePath,
29300
+ initialPrompt,
29301
+ deferInitialTurn,
29302
+ finishExit,
29303
+ outputCallbacks,
29304
+ agentEndCallbacks,
29305
+ assistantTextCallbacks,
29306
+ emitLogLine
29307
+ });
29308
+ return {
29309
+ pid,
29310
+ harnessSessionId: undefined,
29311
+ onExit: (cb) => {
29312
+ exitCallbacks.push(cb);
29313
+ },
29314
+ onOutput: (cb) => {
29315
+ outputCallbacks.push(cb);
29316
+ },
29317
+ onAgentEnd: (cb) => {
29318
+ agentEndCallbacks.push(cb);
29319
+ },
29320
+ onLogLine: (cb) => {
29321
+ logLineCallbacks.push(cb);
29322
+ },
29323
+ onAssistantText: (cb) => {
29324
+ assistantTextCallbacks.push(cb);
29325
+ }
29326
+ };
29327
+ }
29328
+ runTurnLoop(args2) {
29329
+ const {
29330
+ sdkSession,
29331
+ logPrefix,
29332
+ workingDir,
29333
+ model,
29334
+ executablePath,
29335
+ initialPrompt,
29336
+ deferInitialTurn = false,
29337
+ finishExit,
29338
+ entry,
29339
+ outputCallbacks,
29340
+ agentEndCallbacks,
29341
+ assistantTextCallbacks,
29342
+ emitLogLine
29343
+ } = args2;
29344
+ let exited = false;
29345
+ this.executeTurnLoop({
29346
+ sdkSession,
29347
+ logPrefix,
29348
+ workingDir,
29349
+ model,
29350
+ executablePath,
29351
+ initialPrompt,
29352
+ deferInitialTurn,
29353
+ finishExit,
29354
+ entry,
29355
+ outputCallbacks,
29356
+ agentEndCallbacks,
29357
+ assistantTextCallbacks,
29358
+ emitLogLine,
29359
+ isExited: () => exited,
29360
+ markExited: () => {
29361
+ exited = true;
29362
+ }
29363
+ }).catch((err) => {
29364
+ writeSpawnError(logPrefix, err, emitLogLine);
29365
+ if (exited)
29366
+ return;
29367
+ exited = true;
29368
+ try {
29369
+ sdkSession.keeper.kill();
29370
+ } catch {}
29371
+ finishExit(1, null);
29372
+ });
29373
+ }
29374
+ async executeTurnLoop(args2) {
29375
+ const {
29376
+ sdkSession,
29377
+ logPrefix,
29378
+ workingDir,
29379
+ model,
29380
+ executablePath,
29381
+ initialPrompt,
29382
+ deferInitialTurn,
29383
+ finishExit,
29384
+ entry,
29385
+ outputCallbacks,
29386
+ agentEndCallbacks,
29387
+ assistantTextCallbacks,
29388
+ emitLogLine,
29389
+ isExited,
29390
+ markExited
29391
+ } = args2;
29392
+ let exitCode = 0;
29393
+ let exitSignal = null;
29394
+ let nextPrompt = deferInitialTurn ? null : initialPrompt;
29395
+ let isFirstQuery = true;
29396
+ try {
29397
+ const { query } = await loadSdk();
29398
+ while (!sdkSession.aborted) {
29399
+ try {
29400
+ if (nextPrompt === null) {
29401
+ const deferredResume = await waitForResumeOrAbort(sdkSession);
29402
+ if (deferredResume === null || sdkSession.aborted) {
29403
+ if (sdkSession.aborted) {
29404
+ exitCode = 1;
29405
+ exitSignal = "SIGTERM";
29406
+ }
29407
+ break;
29408
+ }
29409
+ nextPrompt = deferredResume;
29410
+ }
29411
+ const adapter = new ClaudeSdkStreamAdapter(logPrefix, emitLogLine);
29412
+ wireNativeStreamAdapter({
29413
+ adapter,
29414
+ assistantTextCallbacks,
29415
+ outputCallbacks,
29416
+ agentEndCallbacks,
29417
+ entry
29418
+ });
29419
+ const queryInstance = query({
29420
+ prompt: nextPrompt,
29421
+ options: {
29422
+ cwd: workingDir,
29423
+ model,
29424
+ maxTurns: DEFAULT_MAX_TURNS2,
29425
+ pathToClaudeCodeExecutable: executablePath,
29426
+ includePartialMessages: true,
29427
+ systemPrompt: isFirstQuery ? sdkSession.storedSystemPrompt : undefined,
29428
+ resume: !isFirstQuery ? sdkSession.sessionId : undefined,
29429
+ settingSources: []
29430
+ }
29431
+ });
29432
+ sdkSession.activeQuery = queryInstance;
29433
+ isFirstQuery = false;
29434
+ nextPrompt = null;
29435
+ await withTimeout((async () => {
29436
+ for await (const message of queryInstance) {
29437
+ if (sdkSession.aborted)
29438
+ break;
29439
+ captureSessionId(message, sdkSession);
29440
+ adapter.handleMessage(message);
29441
+ if (message.type === "result")
29442
+ break;
29443
+ }
29444
+ })(), TURN_TIMEOUT_MS, "query");
29445
+ sdkSession.activeQuery = undefined;
29446
+ if (sdkSession.aborted) {
29447
+ exitCode = 1;
29448
+ exitSignal = "SIGTERM";
29449
+ break;
29450
+ }
29451
+ adapter.finish();
29452
+ } catch (turnErr) {
29453
+ exitCode = 1;
29454
+ writeSpawnError(logPrefix, turnErr, emitLogLine);
29455
+ break;
29456
+ }
29457
+ }
29458
+ } catch (err) {
29459
+ exitCode = 1;
29460
+ writeSpawnError(logPrefix, err, emitLogLine);
29461
+ } finally {
29462
+ if (isExited())
29463
+ return;
29464
+ markExited();
29465
+ try {
29466
+ sdkSession.keeper.kill();
29467
+ } catch {}
29468
+ finishExit(exitCode, exitSignal);
29469
+ }
29470
+ }
29471
+ async spawn(options) {
29472
+ const deferInitialTurn = options.deferInitialTurn ?? false;
29473
+ const keeper = this.spawnKeeper(options.workingDir);
29474
+ const pid = keeper.pid;
29475
+ const context5 = options.context;
29476
+ const fullPrompt = deferInitialTurn ? "" : options.prompt;
29477
+ let executablePath;
29478
+ try {
29479
+ await loadSdk();
29480
+ executablePath = await resolvePathToClaudeCodeExecutable();
29481
+ } catch (err) {
29482
+ keeper.kill();
29483
+ this.deleteProcess(pid);
29484
+ throw err;
29485
+ }
29486
+ return this.startRunningSession({
29487
+ pid,
29488
+ keeper,
29489
+ context: context5,
29490
+ workingDir: options.workingDir,
29491
+ model: options.model,
29492
+ initialPrompt: fullPrompt,
29493
+ deferInitialTurn,
29494
+ storedSystemPrompt: options.systemPrompt,
29495
+ executablePath
29496
+ });
29497
+ }
29498
+ };
29499
+ });
29500
+
29501
+ // src/infrastructure/services/remote-agents/claude-sdk/index.ts
29502
+ var init_claude_sdk = __esm(() => {
29503
+ init_claude_sdk_agent_service();
29504
+ });
29505
+
28765
29506
  // src/infrastructure/services/remote-agents/commandcode/command-code-stream-reader.ts
28766
29507
  import { createInterface as createInterface3 } from "node:readline";
28767
29508
 
@@ -28962,23 +29703,6 @@ var init_commandcode = __esm(() => {
28962
29703
  init_command_code_agent_service();
28963
29704
  });
28964
29705
 
28965
- // src/infrastructure/services/remote-agents/wire-native-stream-adapter.ts
28966
- function wireNativeStreamAdapter(args2) {
28967
- args2.adapter.setAssistantTextCapture((text) => {
28968
- for (const cb of args2.assistantTextCallbacks)
28969
- cb(text);
28970
- });
28971
- args2.adapter.onOutput(() => {
28972
- args2.entry.lastOutputAt = Date.now();
28973
- for (const cb of args2.outputCallbacks)
28974
- cb();
28975
- });
28976
- args2.adapter.onAgentEnd(() => {
28977
- for (const cb of args2.agentEndCallbacks)
28978
- cb();
28979
- });
28980
- }
28981
-
28982
29706
  // src/infrastructure/services/remote-agents/cursor-sdk/cursor-models.ts
28983
29707
  function resolveCursorSdkModel(model) {
28984
29708
  const prefix = `${CURSOR_PROVIDER2}/`;
@@ -29006,68 +29730,68 @@ __export(exports_cursor_sdk_package, {
29006
29730
  getBundledCursorSdkVersion: () => getBundledCursorSdkVersion,
29007
29731
  formatCursorSdkLoadError: () => formatCursorSdkLoadError
29008
29732
  });
29009
- import { existsSync, readFileSync as readFileSync3 } from "node:fs";
29010
- import { createRequire as createRequire3 } from "node:module";
29011
- import { dirname as dirname2, join as join7 } from "node:path";
29012
- import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
29013
- function resolveChatroomCliRoot(moduleRef = import.meta.url) {
29014
- const filePath = moduleRef.startsWith("file:") ? fileURLToPath2(moduleRef) : moduleRef;
29015
- let dir = dirname2(filePath);
29016
- while (dir !== dirname2(dir)) {
29017
- const packageJsonPath = join7(dir, "package.json");
29018
- if (existsSync(packageJsonPath)) {
29019
- const pkg = JSON.parse(readFileSync3(packageJsonPath, "utf8"));
29733
+ import { existsSync as existsSync2, readFileSync as readFileSync4 } from "node:fs";
29734
+ import { createRequire as createRequire4 } from "node:module";
29735
+ import { dirname as dirname3, join as join8 } from "node:path";
29736
+ import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
29737
+ function resolveChatroomCliRoot2(moduleRef = import.meta.url) {
29738
+ const filePath = moduleRef.startsWith("file:") ? fileURLToPath3(moduleRef) : moduleRef;
29739
+ let dir = dirname3(filePath);
29740
+ while (dir !== dirname3(dir)) {
29741
+ const packageJsonPath = join8(dir, "package.json");
29742
+ if (existsSync2(packageJsonPath)) {
29743
+ const pkg = JSON.parse(readFileSync4(packageJsonPath, "utf8"));
29020
29744
  if (pkg.name === "chatroom-cli") {
29021
29745
  return dir;
29022
29746
  }
29023
29747
  }
29024
- dir = dirname2(dir);
29748
+ dir = dirname3(dir);
29025
29749
  }
29026
- throw new CursorSdkPackageError(`Could not locate chatroom-cli package root while resolving @cursor/sdk. ${REINSTALL_HINT}`);
29750
+ throw new CursorSdkPackageError(`Could not locate chatroom-cli package root while resolving @cursor/sdk. ${REINSTALL_HINT2}`);
29027
29751
  }
29028
- function readPinnedSdkVersion(chatroomCliRoot) {
29029
- const pkg = JSON.parse(readFileSync3(join7(chatroomCliRoot, "package.json"), "utf8"));
29752
+ function readPinnedSdkVersion2(chatroomCliRoot) {
29753
+ const pkg = JSON.parse(readFileSync4(join8(chatroomCliRoot, "package.json"), "utf8"));
29030
29754
  const specifier = pkg.dependencies?.["@cursor/sdk"];
29031
29755
  const pinned = specifier?.replace(/^[\^~>=<]+/, "").trim() ?? "";
29032
29756
  const match17 = pinned.match(/^(\d+\.\d+\.\d+)/);
29033
29757
  if (!match17) {
29034
- throw new CursorSdkPackageError(`chatroom-cli must pin an exact @cursor/sdk version (found "${specifier ?? "none"}"). ${REINSTALL_HINT}`);
29758
+ throw new CursorSdkPackageError(`chatroom-cli must pin an exact @cursor/sdk version (found "${specifier ?? "none"}"). ${REINSTALL_HINT2}`);
29035
29759
  }
29036
29760
  return match17[1];
29037
29761
  }
29038
- function readInstalledSdkVersion(entryPath) {
29039
- const packageJsonPath = join7(dirname2(entryPath), "..", "..", "package.json");
29040
- const pkg = JSON.parse(readFileSync3(packageJsonPath, "utf8"));
29762
+ function readInstalledSdkVersion2(entryPath) {
29763
+ const packageJsonPath = join8(dirname3(entryPath), "..", "..", "package.json");
29764
+ const pkg = JSON.parse(readFileSync4(packageJsonPath, "utf8"));
29041
29765
  return pkg.version;
29042
29766
  }
29043
29767
  function resolveSdkEsmImportPath(cjsEntryPath) {
29044
29768
  const importPath = cjsEntryPath.includes("/dist/cjs/") ? cjsEntryPath.replace("/dist/cjs/", "/dist/esm/") : cjsEntryPath;
29045
- if (!existsSync(importPath)) {
29046
- throw new CursorSdkPackageError(`@cursor/sdk ESM entry file is missing: ${importPath}. ${REINSTALL_HINT}`);
29769
+ if (!existsSync2(importPath)) {
29770
+ throw new CursorSdkPackageError(`@cursor/sdk ESM entry file is missing: ${importPath}. ${REINSTALL_HINT2}`);
29047
29771
  }
29048
29772
  return importPath;
29049
29773
  }
29050
29774
  async function importBundledCursorSdk(moduleRef = import.meta.url) {
29051
- const chatroomCliRoot = resolveChatroomCliRoot(moduleRef);
29052
- const require3 = createRequire3(join7(chatroomCliRoot, "package.json"));
29053
- const pinnedVersion = readPinnedSdkVersion(chatroomCliRoot);
29775
+ const chatroomCliRoot = resolveChatroomCliRoot2(moduleRef);
29776
+ const require3 = createRequire4(join8(chatroomCliRoot, "package.json"));
29777
+ const pinnedVersion = readPinnedSdkVersion2(chatroomCliRoot);
29054
29778
  const entryPath = require3.resolve("@cursor/sdk", { paths: [chatroomCliRoot] });
29055
- const installedVersion = readInstalledSdkVersion(entryPath);
29779
+ const installedVersion = readInstalledSdkVersion2(entryPath);
29056
29780
  if (installedVersion !== pinnedVersion) {
29057
- throw new CursorSdkPackageError(`@cursor/sdk@${installedVersion} does not match chatroom-cli pin (${pinnedVersion}). ${REINSTALL_HINT}`);
29781
+ throw new CursorSdkPackageError(`@cursor/sdk@${installedVersion} does not match chatroom-cli pin (${pinnedVersion}). ${REINSTALL_HINT2}`);
29058
29782
  }
29059
- if (!existsSync(entryPath)) {
29060
- throw new CursorSdkPackageError(`@cursor/sdk entry file is missing: ${entryPath}. ${REINSTALL_HINT}`);
29783
+ if (!existsSync2(entryPath)) {
29784
+ throw new CursorSdkPackageError(`@cursor/sdk entry file is missing: ${entryPath}. ${REINSTALL_HINT2}`);
29061
29785
  }
29062
- const sdk = await import(pathToFileURL(resolveSdkEsmImportPath(entryPath)).href);
29786
+ const sdk = await import(pathToFileURL2(resolveSdkEsmImportPath(entryPath)).href);
29063
29787
  sdk.configureCursorSdk({ local: { useHttp1ForAgent: true } });
29064
29788
  return sdk;
29065
29789
  }
29066
29790
  function getBundledCursorSdkVersion(moduleRef = import.meta.url) {
29067
- const chatroomCliRoot = resolveChatroomCliRoot(moduleRef);
29068
- const require3 = createRequire3(join7(chatroomCliRoot, "package.json"));
29791
+ const chatroomCliRoot = resolveChatroomCliRoot2(moduleRef);
29792
+ const require3 = createRequire4(join8(chatroomCliRoot, "package.json"));
29069
29793
  const entryPath = require3.resolve("@cursor/sdk", { paths: [chatroomCliRoot] });
29070
- return readInstalledSdkVersion(entryPath);
29794
+ return readInstalledSdkVersion2(entryPath);
29071
29795
  }
29072
29796
  function formatCursorSdkLoadError(err) {
29073
29797
  if (err instanceof CursorSdkPackageError) {
@@ -29076,11 +29800,11 @@ function formatCursorSdkLoadError(err) {
29076
29800
  const message = err instanceof Error ? err.message : String(err);
29077
29801
  const chunkMatch = message.match(/(\d+)\.index\.js/);
29078
29802
  if (chunkMatch) {
29079
- return `@cursor/sdk installation is incomplete (missing ${chunkMatch[1]}.index.js). ${REINSTALL_HINT}`;
29803
+ return `@cursor/sdk installation is incomplete (missing ${chunkMatch[1]}.index.js). ${REINSTALL_HINT2}`;
29080
29804
  }
29081
29805
  return message;
29082
29806
  }
29083
- var REINSTALL_HINT = "Reinstall chatroom-cli: npm install -g chatroom-cli@latest", CursorSdkPackageError;
29807
+ var REINSTALL_HINT2 = "Reinstall chatroom-cli: npm install -g chatroom-cli@latest", CursorSdkPackageError;
29084
29808
  var init_cursor_sdk_package = __esm(() => {
29085
29809
  CursorSdkPackageError = class CursorSdkPackageError extends Error {
29086
29810
  code = "CURSOR_SDK_PACKAGE_INCOMPLETE";
@@ -29103,50 +29827,6 @@ function closeCursorAgentOnFailure(agent, session2, exitCode, force = false) {
29103
29827
  } catch {}
29104
29828
  }
29105
29829
 
29106
- // src/infrastructure/services/remote-agents/assistant-text-capture.ts
29107
- function createAssistantTextCapture() {
29108
- let onAssistantText;
29109
- return {
29110
- setAssistantTextCapture(cb) {
29111
- onAssistantText = cb;
29112
- },
29113
- captureAssistantText(text) {
29114
- onAssistantText?.(text);
29115
- }
29116
- };
29117
- }
29118
-
29119
- // src/infrastructure/services/remote-agents/native-stream-adapter-base.ts
29120
- class NativeStreamAdapterBase {
29121
- logPrefix;
29122
- emitLogLine;
29123
- agentEndCallbacks = [];
29124
- outputCallbacks = [];
29125
- agentEndEmitted = false;
29126
- assistantTextCapture = createAssistantTextCapture();
29127
- constructor(logPrefix, emitLogLine) {
29128
- this.logPrefix = logPrefix;
29129
- this.emitLogLine = emitLogLine;
29130
- }
29131
- setAssistantTextCapture(cb) {
29132
- this.assistantTextCapture.setAssistantTextCapture(cb);
29133
- }
29134
- onAgentEnd(cb) {
29135
- this.agentEndCallbacks.push(cb);
29136
- }
29137
- onOutput(cb) {
29138
- this.outputCallbacks.push(cb);
29139
- }
29140
- notifyOutput() {
29141
- for (const cb of this.outputCallbacks)
29142
- cb();
29143
- }
29144
- writeLine(line) {
29145
- this.emitLogLine?.(line);
29146
- }
29147
- }
29148
- var init_native_stream_adapter_base = () => {};
29149
-
29150
29830
  // src/infrastructure/services/remote-agents/cursor-sdk/cursor-sdk-stream-adapter.ts
29151
29831
  var CursorSdkStreamAdapter;
29152
29832
  var init_cursor_sdk_stream_adapter = __esm(() => {
@@ -29230,47 +29910,31 @@ var init_cursor_sdk_stream_adapter = __esm(() => {
29230
29910
  };
29231
29911
  });
29232
29912
 
29233
- // src/infrastructure/services/remote-agents/with-timeout.ts
29234
- async function withTimeout(p, ms, label) {
29235
- let timer;
29236
- try {
29237
- return await Promise.race([
29238
- p,
29239
- new Promise((_, reject) => {
29240
- timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
29241
- })
29242
- ]);
29243
- } finally {
29244
- if (timer)
29245
- clearTimeout(timer);
29246
- }
29247
- }
29248
-
29249
29913
  // src/infrastructure/services/remote-agents/cursor-sdk/cursor-sdk-agent-service.ts
29250
29914
  import { randomUUID } from "node:crypto";
29251
- async function loadSdk() {
29252
- if (_sdkCache)
29253
- return _sdkCache;
29254
- if (_sdkLoadError)
29255
- throw _sdkLoadError;
29915
+ async function loadSdk2() {
29916
+ if (_sdkCache2)
29917
+ return _sdkCache2;
29918
+ if (_sdkLoadError2)
29919
+ throw _sdkLoadError2;
29256
29920
  try {
29257
- _sdkCache = await importBundledCursorSdk();
29258
- return _sdkCache;
29921
+ _sdkCache2 = await importBundledCursorSdk();
29922
+ return _sdkCache2;
29259
29923
  } catch (err) {
29260
- _sdkLoadError = err;
29924
+ _sdkLoadError2 = err;
29261
29925
  throw err;
29262
29926
  }
29263
29927
  }
29264
- function getSdkPackageVersion() {
29265
- if (cachedSdkPackageVersion)
29266
- return cachedSdkPackageVersion;
29267
- cachedSdkPackageVersion = getBundledCursorSdkVersion();
29268
- return cachedSdkPackageVersion;
29928
+ function getSdkPackageVersion2() {
29929
+ if (cachedSdkPackageVersion2)
29930
+ return cachedSdkPackageVersion2;
29931
+ cachedSdkPackageVersion2 = getBundledCursorSdkVersion();
29932
+ return cachedSdkPackageVersion2;
29269
29933
  }
29270
29934
  function buildAgentName(context5) {
29271
29935
  return `${context5.role}@${context5.chatroomId.slice(-6)}`;
29272
29936
  }
29273
- function waitForResumeOrAbort(session2) {
29937
+ function waitForResumeOrAbort2(session2) {
29274
29938
  if (session2.aborted)
29275
29939
  return Promise.resolve(null);
29276
29940
  const queued = session2.pendingResumePrompt;
@@ -29298,14 +29962,14 @@ function waitForResumeOrAbort(session2) {
29298
29962
  function resolveModelId(model) {
29299
29963
  return model ? resolveCursorSdkModel(model) : DEFAULT_MODEL;
29300
29964
  }
29301
- function writeSpawnError(logPrefix, err, emitLogLine) {
29965
+ function writeSpawnError2(logPrefix, err, emitLogLine) {
29302
29966
  const line = formatAgentLogLine(logPrefix, "spawn-error", formatCursorSdkLoadError(err));
29303
29967
  process.stderr.write(`${line}
29304
29968
  `);
29305
29969
  emitLogLine?.(line);
29306
29970
  console.error(`[${new Date().toISOString()}] ${logPrefix} spawn-error]`, err);
29307
29971
  }
29308
- 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 = 60000, RUN_CANCEL_TIMEOUT_MS = 5000, cachedSdkPackageVersion, CursorSdkAgentService;
29972
+ var NO_SUBAGENT_DIRECTIVE2 = "NEVER spawn subagents. Follow the chatroom instructions strictly.", _sdkCache2, _sdkLoadError2, 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 = 60000, RUN_CANCEL_TIMEOUT_MS = 5000, cachedSdkPackageVersion2, CursorSdkAgentService;
29309
29973
  var init_cursor_sdk_agent_service = __esm(() => {
29310
29974
  init_esm();
29311
29975
  init_base_cli_agent_service();
@@ -29324,7 +29988,7 @@ var init_cursor_sdk_agent_service = __esm(() => {
29324
29988
  if (!process.env.CURSOR_API_KEY?.trim())
29325
29989
  return false;
29326
29990
  try {
29327
- await loadSdk();
29991
+ await loadSdk2();
29328
29992
  return true;
29329
29993
  } catch (err) {
29330
29994
  console.warn(`[cursor-sdk] unavailable: ${formatCursorSdkLoadError(err)}`);
@@ -29338,7 +30002,7 @@ var init_cursor_sdk_agent_service = __esm(() => {
29338
30002
  });
29339
30003
  }
29340
30004
  async getVersion() {
29341
- const match17 = getSdkPackageVersion().match(/^(\d+)\.(\d+)\.(\d+)/);
30005
+ const match17 = getSdkPackageVersion2().match(/^(\d+)\.(\d+)\.(\d+)/);
29342
30006
  if (!match17)
29343
30007
  return null;
29344
30008
  return {
@@ -29351,7 +30015,7 @@ var init_cursor_sdk_agent_service = __esm(() => {
29351
30015
  if (!apiKey)
29352
30016
  return [];
29353
30017
  try {
29354
- const { Cursor } = await loadSdk();
30018
+ const { Cursor } = await loadSdk2();
29355
30019
  const models = await withTimeout(Cursor.models.list({ apiKey }), MODELS_LIST_TIMEOUT_MS, "Cursor.models.list");
29356
30020
  const listedModelIds = models.map((m) => m.id).filter((id3) => id3.length > 0);
29357
30021
  return normalizeCursorSdkListedModels(listedModelIds);
@@ -29428,7 +30092,7 @@ ${options.systemPrompt}` : NO_SUBAGENT_DIRECTIVE2;
29428
30092
  ${options.prompt}`;
29429
30093
  let agent;
29430
30094
  try {
29431
- const { Agent } = await loadSdk();
30095
+ const { Agent } = await loadSdk2();
29432
30096
  agent = await withTimeout(Agent.resume(stored.harnessSessionId, {
29433
30097
  apiKey,
29434
30098
  model: { id: modelId },
@@ -29578,7 +30242,7 @@ ${options.prompt}`;
29578
30242
  while (!session2.aborted) {
29579
30243
  try {
29580
30244
  if (nextPrompt === null) {
29581
- const deferredResume = await waitForResumeOrAbort(session2);
30245
+ const deferredResume = await waitForResumeOrAbort2(session2);
29582
30246
  if (deferredResume === null || session2.aborted) {
29583
30247
  if (session2.aborted) {
29584
30248
  exitCode = 1;
@@ -29616,7 +30280,7 @@ ${deferredResume}` : deferredResume;
29616
30280
  }
29617
30281
  } catch (streamErr) {
29618
30282
  exitCode = 1;
29619
- writeSpawnError(logPrefix, streamErr, emitLogLine);
30283
+ writeSpawnError2(logPrefix, streamErr, emitLogLine);
29620
30284
  break;
29621
30285
  }
29622
30286
  if (session2.aborted) {
@@ -29629,7 +30293,7 @@ ${deferredResume}` : deferredResume;
29629
30293
  result = await withTimeout(run3.wait(), RUN_WAIT_TIMEOUT_MS, "run.wait");
29630
30294
  } catch (waitErr) {
29631
30295
  exitCode = 1;
29632
- writeSpawnError(logPrefix, waitErr, emitLogLine);
30296
+ writeSpawnError2(logPrefix, waitErr, emitLogLine);
29633
30297
  break;
29634
30298
  }
29635
30299
  adapter.flushPendingOutput();
@@ -29646,13 +30310,13 @@ ${deferredResume}` : deferredResume;
29646
30310
  nextPrompt = null;
29647
30311
  } catch (turnErr) {
29648
30312
  exitCode = 1;
29649
- writeSpawnError(logPrefix, turnErr, emitLogLine);
30313
+ writeSpawnError2(logPrefix, turnErr, emitLogLine);
29650
30314
  break;
29651
30315
  }
29652
30316
  }
29653
30317
  } catch (err) {
29654
30318
  exitCode = 1;
29655
- writeSpawnError(logPrefix, err, emitLogLine);
30319
+ writeSpawnError2(logPrefix, err, emitLogLine);
29656
30320
  } finally {
29657
30321
  if (exited)
29658
30322
  return;
@@ -29664,7 +30328,7 @@ ${deferredResume}` : deferredResume;
29664
30328
  finishExit(exitCode, exitSignal);
29665
30329
  }
29666
30330
  })().catch((err) => {
29667
- writeSpawnError(logPrefix, err, emitLogLine);
30331
+ writeSpawnError2(logPrefix, err, emitLogLine);
29668
30332
  if (exited)
29669
30333
  return;
29670
30334
  exited = true;
@@ -29694,7 +30358,7 @@ ${options.systemPrompt}` : NO_SUBAGENT_DIRECTIVE2;
29694
30358
  ${options.prompt}`;
29695
30359
  let agent;
29696
30360
  try {
29697
- const { Agent } = await loadSdk();
30361
+ const { Agent } = await loadSdk2();
29698
30362
  agent = await withTimeout(Agent.create({
29699
30363
  apiKey,
29700
30364
  name: agentName,
@@ -32140,27 +32804,27 @@ var init_session_event_forwarder = __esm(() => {
32140
32804
  });
32141
32805
 
32142
32806
  // src/infrastructure/services/remote-agents/opencode-sdk/session-metadata-store.ts
32143
- import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync4, writeFileSync } from "node:fs";
32807
+ import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync5, writeFileSync } from "node:fs";
32144
32808
  import { homedir as homedir2 } from "node:os";
32145
- import { dirname as dirname3, join as join8 } from "node:path";
32809
+ import { dirname as dirname4, join as join9 } from "node:path";
32146
32810
 
32147
32811
  class FileSessionMetadataStore {
32148
32812
  filePath;
32149
32813
  constructor(filePath) {
32150
- this.filePath = filePath ?? join8(homedir2(), ".chatroom", "opencode-sdk-sessions.json");
32814
+ this.filePath = filePath ?? join9(homedir2(), ".chatroom", "opencode-sdk-sessions.json");
32151
32815
  }
32152
32816
  load() {
32153
32817
  try {
32154
- if (existsSync2(this.filePath)) {
32155
- return JSON.parse(readFileSync4(this.filePath, "utf-8"));
32818
+ if (existsSync3(this.filePath)) {
32819
+ return JSON.parse(readFileSync5(this.filePath, "utf-8"));
32156
32820
  }
32157
32821
  } catch {}
32158
32822
  return {};
32159
32823
  }
32160
32824
  save(sessions) {
32161
32825
  try {
32162
- const dir = dirname3(this.filePath);
32163
- if (!existsSync2(dir)) {
32826
+ const dir = dirname4(this.filePath);
32827
+ if (!existsSync3(dir)) {
32164
32828
  mkdirSync(dir, { recursive: true });
32165
32829
  }
32166
32830
  writeFileSync(this.filePath, JSON.stringify(sessions, null, 2));
@@ -32694,47 +33358,47 @@ __export(exports_pi_sdk_package, {
32694
33358
  getBundledPiSdkVersion: () => getBundledPiSdkVersion,
32695
33359
  formatPiSdkLoadError: () => formatPiSdkLoadError
32696
33360
  });
32697
- import { existsSync as existsSync3, readFileSync as readFileSync5 } from "node:fs";
32698
- import { dirname as dirname4, join as join9 } from "node:path";
32699
- import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
32700
- function resolveChatroomCliRoot2(moduleRef = import.meta.url) {
32701
- const filePath = moduleRef.startsWith("file:") ? fileURLToPath3(moduleRef) : moduleRef;
32702
- let dir = dirname4(filePath);
32703
- while (dir !== dirname4(dir)) {
32704
- const packageJsonPath = join9(dir, "package.json");
32705
- if (existsSync3(packageJsonPath)) {
32706
- const pkg = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
33361
+ import { existsSync as existsSync4, readFileSync as readFileSync6 } from "node:fs";
33362
+ import { dirname as dirname5, join as join10 } from "node:path";
33363
+ import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL3 } from "node:url";
33364
+ function resolveChatroomCliRoot3(moduleRef = import.meta.url) {
33365
+ const filePath = moduleRef.startsWith("file:") ? fileURLToPath4(moduleRef) : moduleRef;
33366
+ let dir = dirname5(filePath);
33367
+ while (dir !== dirname5(dir)) {
33368
+ const packageJsonPath = join10(dir, "package.json");
33369
+ if (existsSync4(packageJsonPath)) {
33370
+ const pkg = JSON.parse(readFileSync6(packageJsonPath, "utf8"));
32707
33371
  if (pkg.name === "chatroom-cli") {
32708
33372
  return dir;
32709
33373
  }
32710
33374
  }
32711
- dir = dirname4(dir);
33375
+ dir = dirname5(dir);
32712
33376
  }
32713
- throw new PiSdkPackageError(`Could not locate chatroom-cli package root while resolving ${PI_CODING_AGENT_PKG}. ${REINSTALL_HINT2}`);
33377
+ throw new PiSdkPackageError(`Could not locate chatroom-cli package root while resolving ${PI_CODING_AGENT_PKG}. ${REINSTALL_HINT3}`);
32714
33378
  }
32715
- function readPinnedSdkVersion2(chatroomCliRoot) {
32716
- const pkg = JSON.parse(readFileSync5(join9(chatroomCliRoot, "package.json"), "utf8"));
33379
+ function readPinnedSdkVersion3(chatroomCliRoot) {
33380
+ const pkg = JSON.parse(readFileSync6(join10(chatroomCliRoot, "package.json"), "utf8"));
32717
33381
  const specifier = pkg.dependencies?.[PI_CODING_AGENT_PKG];
32718
33382
  const pinned = specifier?.replace(/^[\^~>=<]+/, "").trim() ?? "";
32719
33383
  const match17 = pinned.match(/^(\d+\.\d+\.\d+)/);
32720
33384
  if (!match17) {
32721
- throw new PiSdkPackageError(`chatroom-cli must pin an exact ${PI_CODING_AGENT_PKG} version (found "${specifier ?? "none"}"). ${REINSTALL_HINT2}`);
33385
+ throw new PiSdkPackageError(`chatroom-cli must pin an exact ${PI_CODING_AGENT_PKG} version (found "${specifier ?? "none"}"). ${REINSTALL_HINT3}`);
32722
33386
  }
32723
33387
  return match17[1];
32724
33388
  }
32725
- function readInstalledSdkVersion2(entryPath) {
32726
- const packageJsonPath = join9(dirname4(entryPath), "..", "package.json");
32727
- const pkg = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
33389
+ function readInstalledSdkVersion3(entryPath) {
33390
+ const packageJsonPath = join10(dirname5(entryPath), "..", "package.json");
33391
+ const pkg = JSON.parse(readFileSync6(packageJsonPath, "utf8"));
32728
33392
  return pkg.version;
32729
33393
  }
32730
33394
  function resolvePiSdkEntryPathFromNodeModules(chatroomCliRoot) {
32731
33395
  let dir = chatroomCliRoot;
32732
- while (dir !== dirname4(dir)) {
32733
- const entryPath = join9(dir, "node_modules", PI_CODING_AGENT_PKG, "dist", "index.js");
32734
- if (existsSync3(entryPath)) {
33396
+ while (dir !== dirname5(dir)) {
33397
+ const entryPath = join10(dir, "node_modules", PI_CODING_AGENT_PKG, "dist", "index.js");
33398
+ if (existsSync4(entryPath)) {
32735
33399
  return entryPath;
32736
33400
  }
32737
- dir = dirname4(dir);
33401
+ dir = dirname5(dir);
32738
33402
  }
32739
33403
  return;
32740
33404
  }
@@ -32742,32 +33406,32 @@ function resolvePiSdkEntryPath(chatroomCliRoot) {
32742
33406
  const resolveMeta = import.meta.resolve;
32743
33407
  if (typeof resolveMeta === "function") {
32744
33408
  try {
32745
- const parentUrl = pathToFileURL2(join9(chatroomCliRoot, "package.json")).href;
32746
- return fileURLToPath3(resolveMeta(PI_CODING_AGENT_PKG, parentUrl));
33409
+ const parentUrl = pathToFileURL3(join10(chatroomCliRoot, "package.json")).href;
33410
+ return fileURLToPath4(resolveMeta(PI_CODING_AGENT_PKG, parentUrl));
32747
33411
  } catch {}
32748
33412
  }
32749
33413
  const entryPath = resolvePiSdkEntryPathFromNodeModules(chatroomCliRoot);
32750
33414
  if (entryPath) {
32751
33415
  return entryPath;
32752
33416
  }
32753
- throw new PiSdkPackageError(`Could not resolve ${PI_CODING_AGENT_PKG} from ${chatroomCliRoot}. ${REINSTALL_HINT2}`);
33417
+ throw new PiSdkPackageError(`Could not resolve ${PI_CODING_AGENT_PKG} from ${chatroomCliRoot}. ${REINSTALL_HINT3}`);
32754
33418
  }
32755
33419
  async function importBundledPiSdk(moduleRef = import.meta.url) {
32756
- const chatroomCliRoot = resolveChatroomCliRoot2(moduleRef);
32757
- const pinnedVersion = readPinnedSdkVersion2(chatroomCliRoot);
33420
+ const chatroomCliRoot = resolveChatroomCliRoot3(moduleRef);
33421
+ const pinnedVersion = readPinnedSdkVersion3(chatroomCliRoot);
32758
33422
  const entryPath = resolvePiSdkEntryPath(chatroomCliRoot);
32759
- const installedVersion = readInstalledSdkVersion2(entryPath);
33423
+ const installedVersion = readInstalledSdkVersion3(entryPath);
32760
33424
  if (installedVersion !== pinnedVersion) {
32761
- throw new PiSdkPackageError(`${PI_CODING_AGENT_PKG}@${installedVersion} does not match chatroom-cli pin (${pinnedVersion}). ${REINSTALL_HINT2}`);
33425
+ throw new PiSdkPackageError(`${PI_CODING_AGENT_PKG}@${installedVersion} does not match chatroom-cli pin (${pinnedVersion}). ${REINSTALL_HINT3}`);
32762
33426
  }
32763
- if (!existsSync3(entryPath)) {
32764
- throw new PiSdkPackageError(`${PI_CODING_AGENT_PKG} entry file is missing: ${entryPath}. ${REINSTALL_HINT2}`);
33427
+ if (!existsSync4(entryPath)) {
33428
+ throw new PiSdkPackageError(`${PI_CODING_AGENT_PKG} entry file is missing: ${entryPath}. ${REINSTALL_HINT3}`);
32765
33429
  }
32766
- return import(pathToFileURL2(entryPath).href);
33430
+ return import(pathToFileURL3(entryPath).href);
32767
33431
  }
32768
33432
  function getBundledPiSdkVersion(moduleRef = import.meta.url) {
32769
- const chatroomCliRoot = resolveChatroomCliRoot2(moduleRef);
32770
- return readInstalledSdkVersion2(resolvePiSdkEntryPath(chatroomCliRoot));
33433
+ const chatroomCliRoot = resolveChatroomCliRoot3(moduleRef);
33434
+ return readInstalledSdkVersion3(resolvePiSdkEntryPath(chatroomCliRoot));
32771
33435
  }
32772
33436
  function formatPiSdkLoadError(err) {
32773
33437
  if (err instanceof PiSdkPackageError) {
@@ -32775,7 +33439,7 @@ function formatPiSdkLoadError(err) {
32775
33439
  }
32776
33440
  return err instanceof Error ? err.message : String(err);
32777
33441
  }
32778
- var PI_CODING_AGENT_PKG = "@earendil-works/pi-coding-agent", REINSTALL_HINT2 = "Reinstall chatroom-cli: npm install -g chatroom-cli@latest", PiSdkPackageError;
33442
+ var PI_CODING_AGENT_PKG = "@earendil-works/pi-coding-agent", REINSTALL_HINT3 = "Reinstall chatroom-cli: npm install -g chatroom-cli@latest", PiSdkPackageError;
32779
33443
  var init_pi_sdk_package = __esm(() => {
32780
33444
  PiSdkPackageError = class PiSdkPackageError extends Error {
32781
33445
  code = "PI_SDK_PACKAGE_INCOMPLETE";
@@ -32894,26 +33558,26 @@ var init_pi_sdk_stream_adapter = __esm(() => {
32894
33558
  });
32895
33559
 
32896
33560
  // src/infrastructure/services/remote-agents/pi-sdk/pi-sdk-agent-service.ts
32897
- async function loadSdk2() {
32898
- if (_sdkCache2)
32899
- return _sdkCache2;
32900
- if (_sdkLoadError2)
32901
- throw _sdkLoadError2;
33561
+ async function loadSdk3() {
33562
+ if (_sdkCache3)
33563
+ return _sdkCache3;
33564
+ if (_sdkLoadError3)
33565
+ throw _sdkLoadError3;
32902
33566
  try {
32903
- _sdkCache2 = await importBundledPiSdk();
32904
- return _sdkCache2;
33567
+ _sdkCache3 = await importBundledPiSdk();
33568
+ return _sdkCache3;
32905
33569
  } catch (err) {
32906
- _sdkLoadError2 = err;
33570
+ _sdkLoadError3 = err;
32907
33571
  throw err;
32908
33572
  }
32909
33573
  }
32910
- function getSdkPackageVersion2() {
32911
- if (cachedSdkPackageVersion2)
32912
- return cachedSdkPackageVersion2;
32913
- cachedSdkPackageVersion2 = getBundledPiSdkVersion();
32914
- return cachedSdkPackageVersion2;
33574
+ function getSdkPackageVersion3() {
33575
+ if (cachedSdkPackageVersion3)
33576
+ return cachedSdkPackageVersion3;
33577
+ cachedSdkPackageVersion3 = getBundledPiSdkVersion();
33578
+ return cachedSdkPackageVersion3;
32915
33579
  }
32916
- function waitForResumeOrAbort2(session2) {
33580
+ function waitForResumeOrAbort3(session2) {
32917
33581
  if (session2.aborted)
32918
33582
  return Promise.resolve(null);
32919
33583
  const queued = session2.pendingResumePrompt;
@@ -32950,14 +33614,14 @@ function resolveModel(modelRegistry, model) {
32950
33614
  }
32951
33615
  return modelRegistry.getAvailable()[0];
32952
33616
  }
32953
- function writeSpawnError2(logPrefix, err, emitLogLine) {
33617
+ function writeSpawnError3(logPrefix, err, emitLogLine) {
32954
33618
  const line = formatAgentLogLine(logPrefix, "spawn-error", formatPiSdkLoadError(err));
32955
33619
  process.stderr.write(`${line}
32956
33620
  `);
32957
33621
  emitLogLine?.(line);
32958
33622
  console.error(`[${new Date().toISOString()}] ${logPrefix} spawn-error]`, err);
32959
33623
  }
32960
- var PI_SDK_COMMAND = "pi-sdk", SESSION_CREATE_TIMEOUT_MS2 = 60000, PROMPT_TIMEOUT_MS = 3600000, _sdkCache2, _sdkLoadError2, cachedSdkPackageVersion2, PiSdkAgentService;
33624
+ var PI_SDK_COMMAND = "pi-sdk", SESSION_CREATE_TIMEOUT_MS2 = 60000, PROMPT_TIMEOUT_MS = 3600000, _sdkCache3, _sdkLoadError3, cachedSdkPackageVersion3, PiSdkAgentService;
32961
33625
  var init_pi_sdk_agent_service = __esm(() => {
32962
33626
  init_esm();
32963
33627
  init_base_cli_agent_service();
@@ -32975,7 +33639,7 @@ var init_pi_sdk_agent_service = __esm(() => {
32975
33639
  }
32976
33640
  async isInstalled() {
32977
33641
  try {
32978
- const { ModelRegistry, AuthStorage } = await loadSdk2();
33642
+ const { ModelRegistry, AuthStorage } = await loadSdk3();
32979
33643
  const authStorage = AuthStorage.create();
32980
33644
  const modelRegistry = ModelRegistry.create(authStorage);
32981
33645
  return modelRegistry.getAvailable().length > 0;
@@ -32991,7 +33655,7 @@ var init_pi_sdk_agent_service = __esm(() => {
32991
33655
  });
32992
33656
  }
32993
33657
  async getVersion() {
32994
- const match17 = getSdkPackageVersion2().match(/^(\d+)\.(\d+)\.(\d+)/);
33658
+ const match17 = getSdkPackageVersion3().match(/^(\d+)\.(\d+)\.(\d+)/);
32995
33659
  if (!match17)
32996
33660
  return null;
32997
33661
  return {
@@ -33001,7 +33665,7 @@ var init_pi_sdk_agent_service = __esm(() => {
33001
33665
  }
33002
33666
  async listModels() {
33003
33667
  try {
33004
- const { ModelRegistry, AuthStorage } = await loadSdk2();
33668
+ const { ModelRegistry, AuthStorage } = await loadSdk3();
33005
33669
  const authStorage = AuthStorage.create();
33006
33670
  const modelRegistry = ModelRegistry.create(authStorage);
33007
33671
  return modelRegistry.getAvailable().map((entry) => `${entry.provider}/${entry.id}`);
@@ -33066,7 +33730,7 @@ var init_pi_sdk_agent_service = __esm(() => {
33066
33730
  getAgentDir,
33067
33731
  ModelRegistry,
33068
33732
  SessionManager
33069
- } = await loadSdk2();
33733
+ } = await loadSdk3();
33070
33734
  const authStorage = AuthStorage.create();
33071
33735
  const modelRegistry = ModelRegistry.create(authStorage);
33072
33736
  const resolvedModel = resolveModel(modelRegistry, args2.model);
@@ -33182,7 +33846,7 @@ var init_pi_sdk_agent_service = __esm(() => {
33182
33846
  while (!sdkSession.aborted) {
33183
33847
  try {
33184
33848
  if (nextPrompt === null) {
33185
- const deferredResume = await waitForResumeOrAbort2(sdkSession);
33849
+ const deferredResume = await waitForResumeOrAbort3(sdkSession);
33186
33850
  if (deferredResume === null || sdkSession.aborted) {
33187
33851
  if (sdkSession.aborted) {
33188
33852
  exitCode = 1;
@@ -33220,13 +33884,13 @@ ${deferredResume}` : deferredResume;
33220
33884
  nextPrompt = null;
33221
33885
  } catch (turnErr) {
33222
33886
  exitCode = 1;
33223
- writeSpawnError2(logPrefix, turnErr, emitLogLine);
33887
+ writeSpawnError3(logPrefix, turnErr, emitLogLine);
33224
33888
  break;
33225
33889
  }
33226
33890
  }
33227
33891
  } catch (err) {
33228
33892
  exitCode = 1;
33229
- writeSpawnError2(logPrefix, err, emitLogLine);
33893
+ writeSpawnError3(logPrefix, err, emitLogLine);
33230
33894
  } finally {
33231
33895
  if (exited)
33232
33896
  return;
@@ -33241,7 +33905,7 @@ ${deferredResume}` : deferredResume;
33241
33905
  finishExit(exitCode, exitSignal);
33242
33906
  }
33243
33907
  })().catch((err) => {
33244
- writeSpawnError2(logPrefix, err, emitLogLine);
33908
+ writeSpawnError3(logPrefix, err, emitLogLine);
33245
33909
  if (exited)
33246
33910
  return;
33247
33911
  exited = true;
@@ -33321,6 +33985,7 @@ function initHarnessRegistry() {
33321
33985
  registerHarness(new CursorAgentService);
33322
33986
  registerHarness(new CursorSdkAgentService);
33323
33987
  registerHarness(new ClaudeCodeAgentService);
33988
+ registerHarness(new ClaudeSdkAgentService);
33324
33989
  registerHarness(new CommandCodeAgentService);
33325
33990
  registerHarness(new CopilotAgentService);
33326
33991
  initialized = true;
@@ -33328,6 +33993,7 @@ function initHarnessRegistry() {
33328
33993
  var initialized = false;
33329
33994
  var init_init_registry = __esm(() => {
33330
33995
  init_claude();
33996
+ init_claude_sdk();
33331
33997
  init_commandcode();
33332
33998
  init_copilot();
33333
33999
  init_cursor();
@@ -33415,16 +34081,16 @@ var MACHINE_CONFIG_VERSION = "1";
33415
34081
  import { randomUUID as randomUUID2 } from "node:crypto";
33416
34082
  import * as fs4 from "node:fs/promises";
33417
34083
  import { homedir as homedir3, hostname as hostname2 } from "node:os";
33418
- import { join as join10 } from "node:path";
34084
+ import { join as join11 } from "node:path";
33419
34085
  function chatroomConfigDir() {
33420
- return join10(homedir3(), ".chatroom");
34086
+ return join11(homedir3(), ".chatroom");
33421
34087
  }
33422
34088
  async function ensureConfigDir2() {
33423
34089
  const dir = chatroomConfigDir();
33424
34090
  await fs4.mkdir(dir, { recursive: true, mode: 448 });
33425
34091
  }
33426
34092
  function getMachineConfigPath() {
33427
- return join10(chatroomConfigDir(), MACHINE_FILE);
34093
+ return join11(chatroomConfigDir(), MACHINE_FILE);
33428
34094
  }
33429
34095
  async function loadConfigFile() {
33430
34096
  const configPath = getMachineConfigPath();
@@ -33516,7 +34182,7 @@ var init_storage2 = __esm(() => {
33516
34182
  // src/infrastructure/machine/daemon-state.ts
33517
34183
  import * as fs5 from "node:fs/promises";
33518
34184
  import { homedir as homedir4 } from "node:os";
33519
- import { join as join11 } from "node:path";
34185
+ import { join as join12 } from "node:path";
33520
34186
  function agentKey(chatroomId, role) {
33521
34187
  return `${chatroomId}/${role}`;
33522
34188
  }
@@ -33524,7 +34190,7 @@ async function ensureStateDir() {
33524
34190
  await fs5.mkdir(STATE_DIR, { recursive: true, mode: 448 });
33525
34191
  }
33526
34192
  function stateFilePath(machineId) {
33527
- return join11(STATE_DIR, `${machineId}.json`);
34193
+ return join12(STATE_DIR, `${machineId}.json`);
33528
34194
  }
33529
34195
  async function loadDaemonState(machineId) {
33530
34196
  const filePath = stateFilePath(machineId);
@@ -33606,8 +34272,8 @@ async function loadEventCursor(machineId) {
33606
34272
  }
33607
34273
  var CHATROOM_DIR2, STATE_DIR, STATE_VERSION = "1";
33608
34274
  var init_daemon_state = __esm(() => {
33609
- CHATROOM_DIR2 = join11(homedir4(), ".chatroom");
33610
- STATE_DIR = join11(CHATROOM_DIR2, "machines", "state");
34275
+ CHATROOM_DIR2 = join12(homedir4(), ".chatroom");
34276
+ STATE_DIR = join12(CHATROOM_DIR2, "machines", "state");
33611
34277
  });
33612
34278
 
33613
34279
  // src/infrastructure/machine/index.ts
@@ -34049,9 +34715,9 @@ var init_init = __esm(() => {
34049
34715
  });
34050
34716
 
34051
34717
  // src/tools/output.ts
34052
- import { join as join12 } from "node:path";
34718
+ import { join as join13 } from "node:path";
34053
34719
  function resolveChatroomDir(workingDir) {
34054
- return join12(workingDir, CHATROOM_DIR3);
34720
+ return join13(workingDir, CHATROOM_DIR3);
34055
34721
  }
34056
34722
  async function ensureChatroomDir(deps, workingDir) {
34057
34723
  const dir = resolveChatroomDir(workingDir);
@@ -34059,7 +34725,7 @@ async function ensureChatroomDir(deps, workingDir) {
34059
34725
  return dir;
34060
34726
  }
34061
34727
  async function ensureGitignore(deps, workingDir) {
34062
- const gitignorePath = join12(workingDir, ".gitignore");
34728
+ const gitignorePath = join13(workingDir, ".gitignore");
34063
34729
  const entry = CHATROOM_DIR3;
34064
34730
  let content = "";
34065
34731
  try {
@@ -34089,7 +34755,7 @@ function formatOutputTimestamp(date = new Date) {
34089
34755
  function generateOutputPath(workingDir, toolName, extension, date) {
34090
34756
  const timestamp = formatOutputTimestamp(date);
34091
34757
  const filename = `${toolName}-${timestamp}.${extension}`;
34092
- return join12(resolveChatroomDir(workingDir), filename);
34758
+ return join13(resolveChatroomDir(workingDir), filename);
34093
34759
  }
34094
34760
  var CHATROOM_DIR3 = ".chatroom";
34095
34761
  var init_output = () => {};
@@ -34898,8 +35564,8 @@ var init_index_esm = __esm(() => {
34898
35564
  var ENVIRONMENT_IS_NODE = typeof process == "object" && process.versions?.node && process.type != "renderer";
34899
35565
  var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
34900
35566
  if (ENVIRONMENT_IS_NODE) {
34901
- const { createRequire: createRequire4 } = await import("module");
34902
- var require3 = createRequire4(import.meta.url);
35567
+ const { createRequire: createRequire5 } = await import("module");
35568
+ var require3 = createRequire5(import.meta.url);
34903
35569
  }
34904
35570
  var thisProgram = "./this.program";
34905
35571
  var _scriptName = import.meta.url;
@@ -40105,7 +40771,7 @@ var require_filesystem = __commonJS((exports, module) => {
40105
40771
  var LDD_PATH = "/usr/bin/ldd";
40106
40772
  var SELF_PATH = "/proc/self/exe";
40107
40773
  var MAX_LENGTH = 2048;
40108
- var readFileSync6 = (path2) => {
40774
+ var readFileSync7 = (path2) => {
40109
40775
  const fd = fs6.openSync(path2, "r");
40110
40776
  const buffer = Buffer.alloc(MAX_LENGTH);
40111
40777
  const bytesRead = fs6.readSync(fd, buffer, 0, MAX_LENGTH, 0);
@@ -40128,7 +40794,7 @@ var require_filesystem = __commonJS((exports, module) => {
40128
40794
  module.exports = {
40129
40795
  LDD_PATH,
40130
40796
  SELF_PATH,
40131
- readFileSync: readFileSync6,
40797
+ readFileSync: readFileSync7,
40132
40798
  readFile: readFile4
40133
40799
  };
40134
40800
  });
@@ -40171,7 +40837,7 @@ var require_elf = __commonJS((exports, module) => {
40171
40837
  var require_detect_libc = __commonJS((exports, module) => {
40172
40838
  var childProcess = __require("child_process");
40173
40839
  var { isLinux, getReport } = require_process();
40174
- var { LDD_PATH, SELF_PATH, readFile: readFile4, readFileSync: readFileSync6 } = require_filesystem();
40840
+ var { LDD_PATH, SELF_PATH, readFile: readFile4, readFileSync: readFileSync7 } = require_filesystem();
40175
40841
  var { interpreterPath } = require_elf();
40176
40842
  var cachedFamilyInterpreter;
40177
40843
  var cachedFamilyFilesystem;
@@ -40262,7 +40928,7 @@ var require_detect_libc = __commonJS((exports, module) => {
40262
40928
  }
40263
40929
  cachedFamilyFilesystem = null;
40264
40930
  try {
40265
- const lddContent = readFileSync6(LDD_PATH);
40931
+ const lddContent = readFileSync7(LDD_PATH);
40266
40932
  cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
40267
40933
  } catch (e) {}
40268
40934
  return cachedFamilyFilesystem;
@@ -40285,7 +40951,7 @@ var require_detect_libc = __commonJS((exports, module) => {
40285
40951
  }
40286
40952
  cachedFamilyInterpreter = null;
40287
40953
  try {
40288
- const selfContent = readFileSync6(SELF_PATH);
40954
+ const selfContent = readFileSync7(SELF_PATH);
40289
40955
  const path2 = interpreterPath(selfContent);
40290
40956
  cachedFamilyInterpreter = familyFromInterpreterPath(path2);
40291
40957
  } catch (e) {}
@@ -40347,7 +41013,7 @@ var require_detect_libc = __commonJS((exports, module) => {
40347
41013
  }
40348
41014
  cachedVersionFilesystem = null;
40349
41015
  try {
40350
- const lddContent = readFileSync6(LDD_PATH);
41016
+ const lddContent = readFileSync7(LDD_PATH);
40351
41017
  const versionMatch = lddContent.match(RE_GLIBC_VERSION);
40352
41018
  if (versionMatch) {
40353
41019
  cachedVersionFilesystem = versionMatch[1];
@@ -46545,12 +47211,12 @@ var init_pdfium_renderer = __esm(() => {
46545
47211
  });
46546
47212
 
46547
47213
  // ../../node_modules/.pnpm/@llamaindex+liteparse@1.5.3/node_modules/@llamaindex/liteparse/dist/src/engines/pdf/pdfjsImporter.js
46548
- import { fileURLToPath as fileURLToPath4 } from "node:url";
46549
- import { dirname as dirname5 } from "node:path";
47214
+ import { fileURLToPath as fileURLToPath5 } from "node:url";
47215
+ import { dirname as dirname6 } from "node:path";
46550
47216
  async function importPdfJs() {
46551
47217
  const pdfUrl = new URL("../../vendor/pdfjs/pdf.mjs", import.meta.url);
46552
47218
  const pdfjs = await import(pdfUrl.href);
46553
- const dirPath = dirname5(fileURLToPath4(pdfUrl));
47219
+ const dirPath = dirname6(fileURLToPath5(pdfUrl));
46554
47220
  return {
46555
47221
  fn: pdfjs.getDocument,
46556
47222
  dir: dirPath
@@ -67899,7 +68565,7 @@ function applyMarkupTags(markup, text) {
67899
68565
  // ../../node_modules/.pnpm/@llamaindex+liteparse@1.5.3/node_modules/@llamaindex/liteparse/dist/src/processing/gridDebugLogger.js
67900
68566
  import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
67901
68567
  import { mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
67902
- import { dirname as dirname6 } from "path";
68568
+ import { dirname as dirname7 } from "path";
67903
68569
 
67904
68570
  class GridDebugLogger {
67905
68571
  config;
@@ -68226,14 +68892,14 @@ class GridDebugLogger {
68226
68892
  flushSync() {
68227
68893
  if (!this.config.outputPath || this.entries.length === 0)
68228
68894
  return;
68229
- mkdirSync2(dirname6(this.config.outputPath), { recursive: true });
68895
+ mkdirSync2(dirname7(this.config.outputPath), { recursive: true });
68230
68896
  writeFileSync2(this.config.outputPath, this.formatEntries(), "utf-8");
68231
68897
  this.entries = [];
68232
68898
  }
68233
68899
  async flush() {
68234
68900
  if (!this.config.outputPath || this.entries.length === 0)
68235
68901
  return;
68236
- await mkdir4(dirname6(this.config.outputPath), { recursive: true });
68902
+ await mkdir4(dirname7(this.config.outputPath), { recursive: true });
68237
68903
  await writeFile4(this.config.outputPath, this.formatEntries(), "utf-8");
68238
68904
  this.entries = [];
68239
68905
  }
@@ -76409,6 +77075,22 @@ var init_next_step = __esm(() => {
76409
77075
  // ../../services/backend/prompts/sections/session-vs-chatroom-task.ts
76410
77076
  var init_session_vs_chatroom_task = () => {};
76411
77077
 
77078
+ // ../../services/backend/src/domain/entities/harness/claude-sdk.config.ts
77079
+ var claudeSdkCapabilities;
77080
+ var init_claude_sdk_config = __esm(() => {
77081
+ claudeSdkCapabilities = {
77082
+ runtimeKind: "sdk",
77083
+ supportsDaemonMemoryResume: false,
77084
+ supportsNativeIntegration: true,
77085
+ lifecycle: {
77086
+ turnCompleted: true,
77087
+ outputActivity: true,
77088
+ processExited: true
77089
+ },
77090
+ wireEvents: ["sdk.claude.message"]
77091
+ };
77092
+ });
77093
+
76412
77094
  // ../../services/backend/src/domain/entities/harness/claude.config.ts
76413
77095
  var claudeCapabilities;
76414
77096
  var init_claude_config = __esm(() => {
@@ -76572,6 +77254,7 @@ function isNativeHarness(harness) {
76572
77254
  }
76573
77255
  var HARNESS_CAPABILITIES;
76574
77256
  var init_types = __esm(() => {
77257
+ init_claude_sdk_config();
76575
77258
  init_claude_config();
76576
77259
  init_commandcode_config();
76577
77260
  init_copilot_config();
@@ -76583,6 +77266,7 @@ var init_types = __esm(() => {
76583
77266
  init_pi_config();
76584
77267
  HARNESS_CAPABILITIES = {
76585
77268
  claude: claudeCapabilities,
77269
+ "claude-sdk": claudeSdkCapabilities,
76586
77270
  commandcode: commandcodeCapabilities,
76587
77271
  copilot: copilotCapabilities,
76588
77272
  cursor: cursorCapabilities,
@@ -79341,35 +80025,35 @@ function formatTimestamp() {
79341
80025
  import { createHash as createHash2 } from "node:crypto";
79342
80026
  import {
79343
80027
  appendFileSync,
79344
- existsSync as existsSync4,
80028
+ existsSync as existsSync5,
79345
80029
  mkdirSync as mkdirSync4,
79346
- readFileSync as readFileSync6,
80030
+ readFileSync as readFileSync7,
79347
80031
  renameSync,
79348
80032
  unlinkSync,
79349
80033
  writeFileSync as writeFileSync3
79350
80034
  } from "node:fs";
79351
80035
  import { homedir as homedir5 } from "node:os";
79352
- import { join as join14 } from "node:path";
80036
+ import { join as join15 } from "node:path";
79353
80037
  function getUrlHash() {
79354
80038
  const url2 = getConvexUrl();
79355
80039
  return createHash2("sha256").update(url2).digest("hex").substring(0, 8);
79356
80040
  }
79357
80041
  function getChildPidsFilePath() {
79358
- const dir = join14(homedir5(), ".chatroom");
79359
- return join14(dir, `daemon-children-${getUrlHash()}.pids`);
80042
+ const dir = join15(homedir5(), ".chatroom");
80043
+ return join15(dir, `daemon-children-${getUrlHash()}.pids`);
79360
80044
  }
79361
80045
  function ensureChatroomDir2() {
79362
- const dir = join14(homedir5(), ".chatroom");
79363
- if (!existsSync4(dir)) {
80046
+ const dir = join15(homedir5(), ".chatroom");
80047
+ if (!existsSync5(dir)) {
79364
80048
  mkdirSync4(dir, { recursive: true, mode: 448 });
79365
80049
  }
79366
80050
  }
79367
80051
  function readPids() {
79368
80052
  const filePath = getChildPidsFilePath();
79369
- if (!existsSync4(filePath))
80053
+ if (!existsSync5(filePath))
79370
80054
  return [];
79371
80055
  try {
79372
- return readFileSync6(filePath, "utf-8").split(`
80056
+ return readFileSync7(filePath, "utf-8").split(`
79373
80057
  `).map((line) => parseInt(line.trim(), 10)).filter((n) => Number.isFinite(n) && n > 0);
79374
80058
  } catch {
79375
80059
  return [];
@@ -79387,9 +80071,9 @@ function trackChildPid(pid) {
79387
80071
  function untrackChildPid(pid) {
79388
80072
  try {
79389
80073
  const filePath = getChildPidsFilePath();
79390
- if (!existsSync4(filePath))
80074
+ if (!existsSync5(filePath))
79391
80075
  return;
79392
- const remaining = readFileSync6(filePath, "utf-8").split(`
80076
+ const remaining = readFileSync7(filePath, "utf-8").split(`
79393
80077
  `).filter((line) => {
79394
80078
  const n = parseInt(line.trim(), 10);
79395
80079
  return Number.isFinite(n) && n > 0 && n !== pid;
@@ -79406,7 +80090,7 @@ function untrackChildPid(pid) {
79406
80090
  function clearTrackedPids() {
79407
80091
  try {
79408
80092
  const filePath = getChildPidsFilePath();
79409
- if (existsSync4(filePath)) {
80093
+ if (existsSync5(filePath)) {
79410
80094
  unlinkSync(filePath);
79411
80095
  }
79412
80096
  } catch {}
@@ -79691,7 +80375,7 @@ var init_log_observer_sync = __esm(() => {
79691
80375
  // src/commands/machine/daemon-start/handlers/process/output-store.ts
79692
80376
  import { appendFile as appendFile2, mkdir as mkdir7, readFile as readFile6, rm } from "node:fs/promises";
79693
80377
  import { tmpdir } from "node:os";
79694
- import { join as join15 } from "node:path";
80378
+ import { join as join16 } from "node:path";
79695
80379
 
79696
80380
  class TempFileOutputStore {
79697
80381
  state;
@@ -79754,7 +80438,7 @@ function createOutputStore(runId) {
79754
80438
  if (!RUN_ID_RE.test(runId)) {
79755
80439
  throw new Error(`Invalid runId: ${runId}`);
79756
80440
  }
79757
- const filePath = join15(TEMP_DIR, `${runId}.log`);
80441
+ const filePath = join16(TEMP_DIR, `${runId}.log`);
79758
80442
  return new TempFileOutputStore(filePath);
79759
80443
  }
79760
80444
  async function ensureTempDir() {
@@ -79768,7 +80452,7 @@ async function cleanOrphanTempFiles() {
79768
80452
  var TAIL_WINDOW_BYTES, TEMP_DIR, RUN_ID_RE, MAX_TAIL_LINES_V2 = 50;
79769
80453
  var init_output_store = __esm(() => {
79770
80454
  TAIL_WINDOW_BYTES = 32 * 1024;
79771
- TEMP_DIR = join15(tmpdir(), "chatroom-cli", "runs");
80455
+ TEMP_DIR = join16(tmpdir(), "chatroom-cli", "runs");
79772
80456
  RUN_ID_RE = /^[a-z0-9]+$/i;
79773
80457
  });
79774
80458
 
@@ -80863,9 +81547,9 @@ var init_local_actions = __esm(() => {
80863
81547
 
80864
81548
  // src/commands/machine/pid.ts
80865
81549
  import { createHash as createHash3 } from "node:crypto";
80866
- import { existsSync as existsSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync4, unlinkSync as unlinkSync2, mkdirSync as mkdirSync5 } from "node:fs";
81550
+ import { existsSync as existsSync6, readFileSync as readFileSync8, writeFileSync as writeFileSync4, unlinkSync as unlinkSync2, mkdirSync as mkdirSync5 } from "node:fs";
80867
81551
  import { homedir as homedir6 } from "node:os";
80868
- import { join as join16 } from "node:path";
81552
+ import { join as join17 } from "node:path";
80869
81553
  function getUrlHash2() {
80870
81554
  const url2 = getConvexUrl();
80871
81555
  return createHash3("sha256").update(url2).digest("hex").substring(0, 8);
@@ -80874,12 +81558,12 @@ function getPidFileName() {
80874
81558
  return `daemon-${getUrlHash2()}.pid`;
80875
81559
  }
80876
81560
  function ensureChatroomDir3() {
80877
- if (!existsSync5(CHATROOM_DIR4)) {
81561
+ if (!existsSync6(CHATROOM_DIR4)) {
80878
81562
  mkdirSync5(CHATROOM_DIR4, { recursive: true, mode: 448 });
80879
81563
  }
80880
81564
  }
80881
81565
  function getPidFilePath() {
80882
- return join16(CHATROOM_DIR4, getPidFileName());
81566
+ return join17(CHATROOM_DIR4, getPidFileName());
80883
81567
  }
80884
81568
  function isProcessRunning(pid) {
80885
81569
  try {
@@ -80891,11 +81575,11 @@ function isProcessRunning(pid) {
80891
81575
  }
80892
81576
  function readPid() {
80893
81577
  const pidPath = getPidFilePath();
80894
- if (!existsSync5(pidPath)) {
81578
+ if (!existsSync6(pidPath)) {
80895
81579
  return null;
80896
81580
  }
80897
81581
  try {
80898
- const content = readFileSync7(pidPath, "utf-8").trim();
81582
+ const content = readFileSync8(pidPath, "utf-8").trim();
80899
81583
  const pid = parseInt(content, 10);
80900
81584
  if (isNaN(pid) || pid <= 0) {
80901
81585
  return null;
@@ -80913,7 +81597,7 @@ function writePid() {
80913
81597
  function removePid() {
80914
81598
  const pidPath = getPidFilePath();
80915
81599
  try {
80916
- if (existsSync5(pidPath)) {
81600
+ if (existsSync6(pidPath)) {
80917
81601
  unlinkSync2(pidPath);
80918
81602
  }
80919
81603
  } catch {}
@@ -80976,7 +81660,7 @@ function releaseLock() {
80976
81660
  var CHATROOM_DIR4, LOCK_RETRY_INTERVAL_MS = 500, LOCK_RETRY_MAX_WAIT_MS = 15000;
80977
81661
  var init_pid = __esm(() => {
80978
81662
  init_client2();
80979
- CHATROOM_DIR4 = join16(homedir6(), ".chatroom");
81663
+ CHATROOM_DIR4 = join17(homedir6(), ".chatroom");
80980
81664
  });
80981
81665
 
80982
81666
  // src/commands/machine/daemon-start/workspace-cache.ts
@@ -81889,16 +82573,16 @@ var init_jsonc = __esm(() => {
81889
82573
 
81890
82574
  // src/infrastructure/services/workspace/workspace-resolver.ts
81891
82575
  import { readFile as readFile7, readdir, stat as stat2 } from "node:fs/promises";
81892
- import { join as join17, basename, resolve as resolve3 } from "node:path";
82576
+ import { join as join18, basename, resolve as resolve3 } from "node:path";
81893
82577
  async function resolveGlobPatternStar(rootDir, cleaned) {
81894
- const parentDir = join17(rootDir, cleaned.slice(0, -2));
82578
+ const parentDir = join18(rootDir, cleaned.slice(0, -2));
81895
82579
  try {
81896
82580
  const entries2 = await readdir(parentDir, { withFileTypes: true });
81897
82581
  const dirs = [];
81898
82582
  for (const entry of entries2) {
81899
82583
  if (!entry.isDirectory())
81900
82584
  continue;
81901
- const dirPath = join17(parentDir, entry.name);
82585
+ const dirPath = join18(parentDir, entry.name);
81902
82586
  if (resolve3(dirPath).startsWith(resolve3(rootDir))) {
81903
82587
  dirs.push(dirPath);
81904
82588
  }
@@ -81909,7 +82593,7 @@ async function resolveGlobPatternStar(rootDir, cleaned) {
81909
82593
  }
81910
82594
  }
81911
82595
  async function resolveLiteralPath(rootDir, cleaned) {
81912
- const dir = join17(rootDir, cleaned);
82596
+ const dir = join18(rootDir, cleaned);
81913
82597
  try {
81914
82598
  if (!resolve3(dir).startsWith(resolve3(rootDir)))
81915
82599
  return [];
@@ -81929,7 +82613,7 @@ async function resolveGlobPattern(rootDir, pattern) {
81929
82613
  }
81930
82614
  async function readPackageJson(dir) {
81931
82615
  try {
81932
- const content = await readFile7(join17(dir, "package.json"), "utf-8");
82616
+ const content = await readFile7(join18(dir, "package.json"), "utf-8");
81933
82617
  const pkg = JSON.parse(content);
81934
82618
  return {
81935
82619
  name: pkg.name || basename(dir),
@@ -81941,7 +82625,7 @@ async function readPackageJson(dir) {
81941
82625
  }
81942
82626
  async function readPnpmWorkspacePatterns(rootDir) {
81943
82627
  try {
81944
- const content = await readFile7(join17(rootDir, "pnpm-workspace.yaml"), "utf-8");
82628
+ const content = await readFile7(join18(rootDir, "pnpm-workspace.yaml"), "utf-8");
81945
82629
  const patterns = [];
81946
82630
  let inPackages = false;
81947
82631
  for (const line of content.split(`
@@ -81968,7 +82652,7 @@ async function readPnpmWorkspacePatterns(rootDir) {
81968
82652
  }
81969
82653
  async function readPackageJsonWorkspacePatterns(rootDir) {
81970
82654
  try {
81971
- const content = await readFile7(join17(rootDir, "package.json"), "utf-8");
82655
+ const content = await readFile7(join18(rootDir, "package.json"), "utf-8");
81972
82656
  const pkg = JSON.parse(content);
81973
82657
  if (!pkg.workspaces)
81974
82658
  return [];
@@ -82017,11 +82701,11 @@ var init_workspace_resolver = () => {};
82017
82701
 
82018
82702
  // src/infrastructure/services/workspace/command-discovery.ts
82019
82703
  import { access as access4, readFile as readFile8 } from "node:fs/promises";
82020
- import { join as join18, relative, basename as basename2 } from "node:path";
82704
+ import { join as join19, relative, basename as basename2 } from "node:path";
82021
82705
  async function detectPackageManager(workingDir) {
82022
82706
  for (const { file, manager } of LOCKFILE_MAP) {
82023
82707
  try {
82024
- await access4(join18(workingDir, file));
82708
+ await access4(join19(workingDir, file));
82025
82709
  return manager;
82026
82710
  } catch {}
82027
82711
  }
@@ -82090,7 +82774,7 @@ function collectRootScriptCommands(scripts, pm, scriptPrefix, rootSw) {
82090
82774
  }
82091
82775
  async function readRootPackageJson(workingDir, pm, scriptPrefix) {
82092
82776
  let rootPackageName = basename2(workingDir);
82093
- const pkg = await readJsonFile(join18(workingDir, "package.json"), "root package.json");
82777
+ const pkg = await readJsonFile(join19(workingDir, "package.json"), "root package.json");
82094
82778
  if (!pkg)
82095
82779
  return { commands: [], rootPackageName };
82096
82780
  if (pkg.name)
@@ -82106,7 +82790,7 @@ async function readRootPackageJson(workingDir, pm, scriptPrefix) {
82106
82790
  }
82107
82791
  async function readTurboJson(workingDir, _turboPrefix, _rootSubWorkspace) {
82108
82792
  const turboTaskNames = [];
82109
- const turbo = await readJsonFile(join18(workingDir, "turbo.json"), "turbo.json");
82793
+ const turbo = await readJsonFile(join19(workingDir, "turbo.json"), "turbo.json");
82110
82794
  if (!turbo?.tasks || typeof turbo.tasks !== "object")
82111
82795
  return turboTaskNames;
82112
82796
  for (const taskName of Object.keys(turbo.tasks)) {
@@ -83110,16 +83794,16 @@ var SEND_TIMEOUT_MS2 = 60000, RUN_WAIT_TIMEOUT_MS2 = 3600000;
83110
83794
  var init_cursor_session = () => {};
83111
83795
 
83112
83796
  // src/infrastructure/harnesses/cursor-sdk/cursor-harness.ts
83113
- async function loadSdk3() {
83114
- if (_sdkCache3)
83115
- return _sdkCache3;
83116
- if (_sdkLoadError3)
83117
- throw _sdkLoadError3;
83797
+ async function loadSdk4() {
83798
+ if (_sdkCache4)
83799
+ return _sdkCache4;
83800
+ if (_sdkLoadError4)
83801
+ throw _sdkLoadError4;
83118
83802
  try {
83119
- _sdkCache3 = await importBundledCursorSdk();
83120
- return _sdkCache3;
83803
+ _sdkCache4 = await importBundledCursorSdk();
83804
+ return _sdkCache4;
83121
83805
  } catch (err) {
83122
- _sdkLoadError3 = err;
83806
+ _sdkLoadError4 = err;
83123
83807
  throw err;
83124
83808
  }
83125
83809
  }
@@ -83154,7 +83838,7 @@ class CursorSdkHarness {
83154
83838
  const apiKey = process.env.CURSOR_API_KEY?.trim();
83155
83839
  if (!apiKey)
83156
83840
  return [];
83157
- const { Cursor } = await loadSdk3();
83841
+ const { Cursor } = await loadSdk4();
83158
83842
  const listed = await withTimeout(Cursor.models.list({ apiKey }), MODELS_LIST_TIMEOUT_MS2, "Cursor.models.list");
83159
83843
  const modelIds = normalizeCursorSdkListedModels(listed.map((m) => m.id).filter((id3) => id3.length > 0));
83160
83844
  return [
@@ -83172,7 +83856,7 @@ class CursorSdkHarness {
83172
83856
  if (!apiKey)
83173
83857
  throw new Error("CURSOR_API_KEY is not set");
83174
83858
  const modelId = resolveCursorSdkModel(config3.model ?? DEFAULT_MODEL2);
83175
- const { Agent } = await loadSdk3();
83859
+ const { Agent } = await loadSdk4();
83176
83860
  const agent = await withTimeout(Agent.create({
83177
83861
  apiKey,
83178
83862
  model: { id: modelId },
@@ -83196,7 +83880,7 @@ class CursorSdkHarness {
83196
83880
  const apiKey = process.env.CURSOR_API_KEY?.trim();
83197
83881
  if (!apiKey)
83198
83882
  throw new Error("CURSOR_API_KEY is not set");
83199
- const { Agent } = await loadSdk3();
83883
+ const { Agent } = await loadSdk4();
83200
83884
  const agent = await withTimeout(Agent.resume(sessionId, {
83201
83885
  apiKey,
83202
83886
  model: { id: DEFAULT_MODEL2 },
@@ -83226,9 +83910,9 @@ class CursorSdkHarness {
83226
83910
  this.sessions.clear();
83227
83911
  }
83228
83912
  }
83229
- var DEFAULT_MODEL2 = "composer-2.5", MODELS_LIST_TIMEOUT_MS2 = 60000, AGENT_CREATE_TIMEOUT_MS2 = 60000, _sdkCache3, _sdkLoadError3, startCursorSdkHarness = async (config3) => {
83913
+ var DEFAULT_MODEL2 = "composer-2.5", MODELS_LIST_TIMEOUT_MS2 = 60000, AGENT_CREATE_TIMEOUT_MS2 = 60000, _sdkCache4, _sdkLoadError4, startCursorSdkHarness = async (config3) => {
83230
83914
  try {
83231
- await loadSdk3();
83915
+ await loadSdk4();
83232
83916
  } catch (err) {
83233
83917
  throw new Error(`cursor-sdk unavailable: ${formatCursorSdkLoadError(err)}`);
83234
83918
  }
@@ -83893,16 +84577,16 @@ var PROMPT_TIMEOUT_MS2 = 3600000;
83893
84577
  var init_pi_session = () => {};
83894
84578
 
83895
84579
  // src/infrastructure/harnesses/pi-sdk/pi-harness.ts
83896
- async function loadSdk4() {
83897
- if (_sdkCache4)
83898
- return _sdkCache4;
83899
- if (_sdkLoadError4)
83900
- throw _sdkLoadError4;
84580
+ async function loadSdk5() {
84581
+ if (_sdkCache5)
84582
+ return _sdkCache5;
84583
+ if (_sdkLoadError5)
84584
+ throw _sdkLoadError5;
83901
84585
  try {
83902
- _sdkCache4 = await importBundledPiSdk();
83903
- return _sdkCache4;
84586
+ _sdkCache5 = await importBundledPiSdk();
84587
+ return _sdkCache5;
83904
84588
  } catch (err) {
83905
- _sdkLoadError4 = err;
84589
+ _sdkLoadError5 = err;
83906
84590
  throw err;
83907
84591
  }
83908
84592
  }
@@ -83974,7 +84658,7 @@ class PiSdkHarness {
83974
84658
  const existing = this.sessions.get(sessionId);
83975
84659
  if (existing)
83976
84660
  return existing;
83977
- const { createAgentSession, DefaultResourceLoader, getAgentDir, SessionManager } = await loadSdk4();
84661
+ const { createAgentSession, DefaultResourceLoader, getAgentDir, SessionManager } = await loadSdk5();
83978
84662
  const sessions = await SessionManager.list(this.cwd, getPiSessionDir(this.cwd));
83979
84663
  const match17 = sessions.find((s) => s.id === sessionId);
83980
84664
  if (!match17) {
@@ -84022,7 +84706,7 @@ class PiSdkHarness {
84022
84706
  this.sessions.clear();
84023
84707
  }
84024
84708
  async createAgentSession(systemPrompt, model) {
84025
- const { createAgentSession, DefaultResourceLoader, getAgentDir, SessionManager } = await loadSdk4();
84709
+ const { createAgentSession, DefaultResourceLoader, getAgentDir, SessionManager } = await loadSdk5();
84026
84710
  const resolvedModel = resolveModel2(this.modelRegistry, model ?? DEFAULT_MODEL3);
84027
84711
  if (!resolvedModel) {
84028
84712
  throw new Error("No Pi model available — configure provider credentials in ~/.pi/agent/auth.json");
@@ -84044,9 +84728,9 @@ class PiSdkHarness {
84044
84728
  return session2;
84045
84729
  }
84046
84730
  }
84047
- var SESSION_CREATE_TIMEOUT_MS3 = 60000, DEFAULT_MODEL3 = "opencode/big-pickle", _sdkCache4, _sdkLoadError4, startPiSdkHarness = async (config3) => {
84731
+ var SESSION_CREATE_TIMEOUT_MS3 = 60000, DEFAULT_MODEL3 = "opencode/big-pickle", _sdkCache5, _sdkLoadError5, startPiSdkHarness = async (config3) => {
84048
84732
  try {
84049
- const { AuthStorage, ModelRegistry } = await loadSdk4();
84733
+ const { AuthStorage, ModelRegistry } = await loadSdk5();
84050
84734
  const authStorage = AuthStorage.create();
84051
84735
  const modelRegistry = ModelRegistry.create(authStorage);
84052
84736
  if (modelRegistry.getAvailable().length === 0) {
@@ -103776,6 +104460,7 @@ var init_assigned_task_monitor_contract = __esm(() => {
103776
104460
  workingDir: exports_external.string().optional(),
103777
104461
  assignedTo: exports_external.string().optional(),
103778
104462
  lastSeenAction: exports_external.string().nullable().optional(),
104463
+ lastStatus: exports_external.string().nullable().optional(),
103779
104464
  spawnedAgentPid: exports_external.number().optional(),
103780
104465
  desiredState: exports_external.string().optional(),
103781
104466
  sessionAugmentation: sessionAugmentationSchema.optional()
@@ -103937,7 +104622,7 @@ function bootstrapMonitorRowFromSignal(signal) {
103937
104622
  participant: {
103938
104623
  lastSeenAction: signal.lastSeenAction ?? null,
103939
104624
  lastSeenAt: null,
103940
- lastStatus: null
104625
+ lastStatus: signal.lastStatus ?? null
103941
104626
  }
103942
104627
  };
103943
104628
  }
@@ -103953,7 +104638,7 @@ function patchMonitorRowFromSignal(existing, signal) {
103953
104638
  participant: {
103954
104639
  lastSeenAction: signal.lastSeenAction ?? existing.participant?.lastSeenAction ?? null,
103955
104640
  lastSeenAt: existing.participant?.lastSeenAt ?? null,
103956
- lastStatus: existing.participant?.lastStatus ?? null
104641
+ lastStatus: signal.lastStatus ?? existing.participant?.lastStatus ?? null
103957
104642
  }
103958
104643
  };
103959
104644
  }
@@ -106204,4 +106889,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
106204
106889
  });
106205
106890
  program2.parse();
106206
106891
 
106207
- //# debugId=2E6B4710975E536E64756E2164756E21
106892
+ //# debugId=8C344CD05121AB9864756E2164756E21