@adhdev/daemon-standalone 1.0.28-rc.17 → 1.0.28-rc.19

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.
@@ -9,14 +9,15 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
9
9
  // src/index.ts
10
10
  import { randomUUID } from "crypto";
11
11
  import * as fs4 from "fs";
12
- import * as os3 from "os";
13
12
  import * as path2 from "path";
14
13
  import {
15
14
  SessionHostClient,
16
15
  formatRuntimeOwner,
17
16
  getDefaultSessionHostEndpoint as getDefaultSessionHostEndpoint2,
18
17
  resolveAttachableRuntimeRecord,
19
- resolveRuntimeRecord
18
+ resolveInstanceConfigDir as resolveInstanceConfigDir2,
19
+ resolveRuntimeRecord,
20
+ resolveSessionHostIpcKey
20
21
  } from "@adhdev/session-host-core";
21
22
 
22
23
  // src/server.ts
@@ -385,15 +386,15 @@ var PtySessionRuntime = class {
385
386
 
386
387
  // src/storage.ts
387
388
  import * as fs2 from "fs";
388
- import * as os2 from "os";
389
389
  import * as path from "path";
390
+ import { resolveInstanceConfigDir } from "@adhdev/session-host-core";
390
391
  var SessionHostStorage = class {
391
392
  rootDir;
392
393
  runtimesDir;
393
394
  tombstonesDir;
394
395
  constructor(options = {}) {
395
396
  const appName = options.appName || "adhdev";
396
- this.rootDir = path.join(os2.homedir(), ".adhdev", "session-host", appName);
397
+ this.rootDir = options.rootDir || path.join(resolveInstanceConfigDir(process.env), "session-host", appName);
397
398
  this.runtimesDir = path.join(this.rootDir, "runtimes");
398
399
  this.tombstonesDir = path.join(this.rootDir, "tombstones");
399
400
  }
@@ -698,7 +699,10 @@ var SessionHostServer = class extends EventEmitter {
698
699
  constructor(options = {}) {
699
700
  super();
700
701
  this.endpoint = options.endpoint || getDefaultSessionHostEndpoint(options.appName || "adhdev");
701
- this.storage = new SessionHostStorage({ appName: options.appName || "adhdev" });
702
+ this.storage = new SessionHostStorage({
703
+ appName: options.appName || "adhdev",
704
+ rootDir: options.storageRootDir
705
+ });
702
706
  }
703
707
  async start() {
704
708
  if (this.endpoint.kind === "unix") {
@@ -1386,8 +1390,16 @@ var SessionHostServer = class extends EventEmitter {
1386
1390
 
1387
1391
  // src/index.ts
1388
1392
  var SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
1393
+ var INSTANCE_CONFIG_DIR = resolveInstanceConfigDir2(process.env);
1394
+ var INSTANCE_IPC_KEY = resolveSessionHostIpcKey(INSTANCE_CONFIG_DIR);
1395
+ function getSessionHostEndpoint() {
1396
+ return getDefaultSessionHostEndpoint2(SESSION_HOST_APP_NAME, { ipcKey: INSTANCE_IPC_KEY });
1397
+ }
1398
+ function getSessionHostStorageRoot() {
1399
+ return path2.join(INSTANCE_CONFIG_DIR, "session-host", SESSION_HOST_APP_NAME);
1400
+ }
1389
1401
  function getSessionHostPidFile(appName) {
1390
- const dir = path2.join(os3.homedir(), ".adhdev");
1402
+ const dir = INSTANCE_CONFIG_DIR;
1391
1403
  if (!fs4.existsSync(dir)) fs4.mkdirSync(dir, { recursive: true });
1392
1404
  return path2.join(dir, `${appName}-session-host.pid`);
1393
1405
  }
@@ -1415,7 +1427,11 @@ function parseArgs(argv) {
1415
1427
  };
1416
1428
  }
1417
1429
  async function runServer() {
1418
- const server = new SessionHostServer({ appName: SESSION_HOST_APP_NAME });
1430
+ const server = new SessionHostServer({
1431
+ appName: SESSION_HOST_APP_NAME,
1432
+ endpoint: getSessionHostEndpoint(),
1433
+ storageRootDir: getSessionHostStorageRoot()
1434
+ });
1419
1435
  writeSessionHostPid(SESSION_HOST_APP_NAME);
1420
1436
  await server.start();
1421
1437
  process.on("SIGINT", async () => {
@@ -1436,7 +1452,7 @@ async function runServer() {
1436
1452
  });
1437
1453
  }
1438
1454
  async function listRuntimes(showAll = false) {
1439
- const client = new SessionHostClient({ endpoint: getDefaultSessionHostEndpoint2(SESSION_HOST_APP_NAME) });
1455
+ const client = new SessionHostClient({ endpoint: getSessionHostEndpoint() });
1440
1456
  try {
1441
1457
  const response = await client.request({
1442
1458
  type: "list_sessions",
@@ -1467,7 +1483,7 @@ async function listRuntimes(showAll = false) {
1467
1483
  }
1468
1484
  }
1469
1485
  async function attachRuntime(target, readOnly = false, takeover = false) {
1470
- const client = new SessionHostClient({ endpoint: getDefaultSessionHostEndpoint2(SESSION_HOST_APP_NAME) });
1486
+ const client = new SessionHostClient({ endpoint: getSessionHostEndpoint() });
1471
1487
  const clientId = `local-terminal-${process.pid}-${randomUUID().slice(0, 8)}`;
1472
1488
  let lastSeq = 0;
1473
1489
  let restoredRawMode = false;
@@ -1705,7 +1721,7 @@ async function main() {
1705
1721
  if (!target) {
1706
1722
  throw new Error("runtime target is required: adhdev-sessiond resume <runtimeId|runtimeKey>");
1707
1723
  }
1708
- const client = new SessionHostClient({ endpoint: getDefaultSessionHostEndpoint2(SESSION_HOST_APP_NAME) });
1724
+ const client = new SessionHostClient({ endpoint: getSessionHostEndpoint() });
1709
1725
  try {
1710
1726
  const listResponse = await client.request({ type: "list_sessions", payload: {} });
1711
1727
  if (!listResponse.success || !listResponse.result) {