@episoda/cli 0.2.198 → 0.2.200

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.
@@ -1,2 +1,17 @@
1
+ /**
2
+ * Episoda Daemon Process
3
+ *
4
+ * Main entry point for the persistent daemon that:
5
+ * - Maintains WebSocket connections to multiple projects
6
+ * - Listens for IPC commands from CLI
7
+ * - Handles graceful shutdown
8
+ * - Survives terminal close
9
+ *
10
+ * This file is spawned by daemon-manager.ts in detached mode.
11
+ */
12
+ /**
13
+ * Main entry point
14
+ */
15
+ declare function runDaemonProcess(): Promise<void>;
1
16
 
2
- export { }
17
+ export { runDaemonProcess };
@@ -9,6 +9,10 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __commonJS = (cb, mod) => function __require() {
10
10
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
11
  };
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
12
16
  var __copyProps = (to, from, except, desc) => {
13
17
  if (from && typeof from === "object" || typeof from === "function") {
14
18
  for (let key of __getOwnPropNames(from))
@@ -25,6 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
29
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
30
  mod
27
31
  ));
32
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
33
 
29
34
  // ../core/dist/command-protocol.js
30
35
  var require_command_protocol = __commonJS({
@@ -3046,7 +3051,7 @@ var require_package = __commonJS({
3046
3051
  "package.json"(exports2, module2) {
3047
3052
  module2.exports = {
3048
3053
  name: "@episoda/cli",
3049
- version: "0.2.198",
3054
+ version: "0.2.200",
3050
3055
  description: "CLI tool for Episoda local development workflow orchestration",
3051
3056
  main: "dist/index.js",
3052
3057
  types: "dist/index.d.ts",
@@ -3111,6 +3116,13 @@ var require_package = __commonJS({
3111
3116
  }
3112
3117
  });
3113
3118
 
3119
+ // src/daemon/daemon-process.ts
3120
+ var daemon_process_exports = {};
3121
+ __export(daemon_process_exports, {
3122
+ runDaemonProcess: () => runDaemonProcess
3123
+ });
3124
+ module.exports = __toCommonJS(daemon_process_exports);
3125
+
3114
3126
  // src/daemon/machine-id.ts
3115
3127
  var fs = __toESM(require("fs"));
3116
3128
  var path = __toESM(require("path"));
@@ -13011,6 +13023,22 @@ function handlePtyKill(payload) {
13011
13023
  console.warn(`[PTY] Kill failed for ${agent_run_id}; performed fallback cleanup`);
13012
13024
  }
13013
13025
  }
13026
+ function handlePtyStdin(payload) {
13027
+ const { agent_run_id, module_uid, text } = payload;
13028
+ const target = sessions.get(agent_run_id);
13029
+ if (!target) {
13030
+ return { success: false, error: `No active PTY session found for agent_run_id ${agent_run_id}` };
13031
+ }
13032
+ if (module_uid && target.moduleUid !== module_uid) {
13033
+ return { success: false, error: `PTY session ${agent_run_id} belongs to ${target.moduleUid}, not ${module_uid}` };
13034
+ }
13035
+ try {
13036
+ target.pty.write(`${text.replace(/\n/g, "\r")}\r`);
13037
+ return { success: true };
13038
+ } catch (error) {
13039
+ return { success: false, error: error?.message || "Failed to write PTY stdin" };
13040
+ }
13041
+ }
13014
13042
  function createCredentialBootstrap(payload, agentRunId) {
13015
13043
  const bootstrap = payload.credential_bootstrap;
13016
13044
  if (!bootstrap?.oauth?.access_token) {
@@ -15207,6 +15235,17 @@ var ProjectMessageRouter = class {
15207
15235
  handlePtyKill(payload);
15208
15236
  }
15209
15237
  });
15238
+ client.on("pty_stdin", async (message) => {
15239
+ if (message.type === "pty_stdin") {
15240
+ const payload = message.payload;
15241
+ console.log(`[Daemon] EP1476: Received pty_stdin for run ${payload.agent_run_id}${payload.module_uid ? ` (module ${payload.module_uid})` : ""}`);
15242
+ client.updateActivity();
15243
+ const result = handlePtyStdin(payload);
15244
+ if (!result.success) {
15245
+ console.warn(`[Daemon] EP1476: pty_stdin failed for run ${payload.agent_run_id}: ${result.error}`);
15246
+ }
15247
+ }
15248
+ });
15210
15249
  }
15211
15250
  };
15212
15251
 
@@ -15626,6 +15665,9 @@ var Daemon = class _Daemon {
15626
15665
  */
15627
15666
  async start() {
15628
15667
  console.log("[Daemon] Starting Episoda daemon...");
15668
+ if (process.env.EPISODA_DAEMON_SUPERVISED) {
15669
+ console.log("[Daemon] EP1477: Running in supervised foreground mode");
15670
+ }
15629
15671
  this.machineId = await getMachineId();
15630
15672
  console.log(`[Daemon] Machine ID: ${this.machineId}`);
15631
15673
  const config = await (0, import_core22.loadConfig)();
@@ -17152,7 +17194,7 @@ process.on("uncaughtException", (error) => {
17152
17194
  logCrashDiagnostics("Uncaught exception", error);
17153
17195
  process.exit(1);
17154
17196
  });
17155
- async function main() {
17197
+ async function runDaemonProcess() {
17156
17198
  if (!process.env.EPISODA_DAEMON_MODE) {
17157
17199
  console.error("This script should only be run by daemon-manager");
17158
17200
  process.exit(1);
@@ -17162,8 +17204,14 @@ async function main() {
17162
17204
  await new Promise(() => {
17163
17205
  });
17164
17206
  }
17165
- main().catch((error) => {
17166
- console.error("[Daemon] Fatal error:", error);
17167
- process.exit(1);
17207
+ if (require.main === module) {
17208
+ runDaemonProcess().catch((error) => {
17209
+ console.error("[Daemon] Fatal error:", error);
17210
+ process.exit(1);
17211
+ });
17212
+ }
17213
+ // Annotate the CommonJS export names for ESM import in node:
17214
+ 0 && (module.exports = {
17215
+ runDaemonProcess
17168
17216
  });
17169
17217
  //# sourceMappingURL=daemon-process.js.map