@episoda/cli 0.2.196 → 0.2.197

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.
@@ -3046,7 +3046,7 @@ var require_package = __commonJS({
3046
3046
  "package.json"(exports2, module2) {
3047
3047
  module2.exports = {
3048
3048
  name: "@episoda/cli",
3049
- version: "0.2.196",
3049
+ version: "0.2.197",
3050
3050
  description: "CLI tool for Episoda local development workflow orchestration",
3051
3051
  main: "dist/index.js",
3052
3052
  types: "dist/index.d.ts",
@@ -12891,12 +12891,13 @@ async function handlePtySpawn(payload, client) {
12891
12891
  const { moduleUid, agent_run_id, command, args, stdin, env, cwd, cols = 220, rows = 50 } = payload;
12892
12892
  if (sessions.has(agent_run_id)) {
12893
12893
  console.warn(`[PTY] Session already exists for agent_run_id ${agent_run_id}, ignoring spawn`);
12894
- return;
12894
+ return { success: false, error: "PTY session already exists for this agent run." };
12895
12895
  }
12896
12896
  console.log(`[PTY] Spawning PTY for ${moduleUid} / ${agent_run_id}: ${command} ${args.join(" ")}`);
12897
- const bootstrap = createCredentialBootstrap(payload, agent_run_id);
12897
+ let bootstrap = null;
12898
12898
  let proc;
12899
12899
  try {
12900
+ bootstrap = createCredentialBootstrap(payload, agent_run_id);
12900
12901
  proc = pty.spawn(command, args, {
12901
12902
  name: "xterm-256color",
12902
12903
  cols,
@@ -12909,7 +12910,9 @@ async function handlePtySpawn(payload, client) {
12909
12910
  }
12910
12911
  });
12911
12912
  } catch (err) {
12912
- cleanupCredentialDirs(bootstrap.cleanupDirs);
12913
+ if (bootstrap) {
12914
+ cleanupCredentialDirs(bootstrap.cleanupDirs);
12915
+ }
12913
12916
  console.error(`[PTY] Failed to spawn PTY for ${agent_run_id}:`, err);
12914
12917
  await client.send({
12915
12918
  type: "pty_exit",
@@ -12918,7 +12921,10 @@ async function handlePtySpawn(payload, client) {
12918
12921
  code: -1,
12919
12922
  durationMs: 0
12920
12923
  });
12921
- return;
12924
+ return {
12925
+ success: false,
12926
+ error: err?.message || `Failed to spawn PTY command '${command}'`
12927
+ };
12922
12928
  }
12923
12929
  const session = {
12924
12930
  pty: proc,
@@ -12973,6 +12979,7 @@ async function handlePtySpawn(payload, client) {
12973
12979
  });
12974
12980
  syncCredentialUpdateAfterExit(session, agent_run_id, client);
12975
12981
  });
12982
+ return { success: true };
12976
12983
  }
12977
12984
  function handlePtyResize(payload) {
12978
12985
  const { agent_run_id, cols, rows } = payload;
@@ -15150,18 +15157,35 @@ var ProjectMessageRouter = class {
15150
15157
  if (message.type === "pty_spawn") {
15151
15158
  const payload = message.payload;
15152
15159
  let resolvedPayload = payload;
15153
- if (!payload.cwd && payload.moduleUid) {
15154
- const worktreeInfo = await getWorktreeInfoForModule(payload.moduleUid);
15155
- if (worktreeInfo?.path) {
15156
- resolvedPayload = {
15157
- ...payload,
15158
- cwd: worktreeInfo.path
15159
- };
15160
+ let result = { success: false, error: "PTY spawn failed" };
15161
+ try {
15162
+ if (!payload.cwd && payload.moduleUid) {
15163
+ const worktreeInfo = await getWorktreeInfoForModule(payload.moduleUid);
15164
+ if (worktreeInfo?.path) {
15165
+ resolvedPayload = {
15166
+ ...payload,
15167
+ cwd: worktreeInfo.path
15168
+ };
15169
+ }
15160
15170
  }
15171
+ console.log(`[Daemon] EP1441: Received pty_spawn for ${projectId}: ${payload.agent_run_id}`);
15172
+ client.updateActivity();
15173
+ result = await handlePtySpawn(resolvedPayload, client);
15174
+ } catch (error) {
15175
+ result = {
15176
+ success: false,
15177
+ error: error instanceof Error ? error.message : String(error)
15178
+ };
15179
+ console.error(`[Daemon] EP1471: PTY spawn failed for ${payload.agent_run_id}:`, error);
15161
15180
  }
15162
- console.log(`[Daemon] EP1441: Received pty_spawn for ${projectId}: ${payload.agent_run_id}`);
15163
- client.updateActivity();
15164
- await handlePtySpawn(resolvedPayload, client);
15181
+ await client.send({
15182
+ type: "pty_spawn_ack",
15183
+ requestId: message.id,
15184
+ moduleUid: resolvedPayload.moduleUid,
15185
+ agent_run_id: resolvedPayload.agent_run_id,
15186
+ success: result.success,
15187
+ error: result.error
15188
+ });
15165
15189
  }
15166
15190
  });
15167
15191
  client.on("pty_resize", (message) => {