@shipers-dev/dayline 0.97.0 → 0.100.0

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.
Files changed (2) hide show
  1. package/dist/index.js +616 -154
  2. package/package.json +9 -2
package/dist/index.js CHANGED
@@ -18333,17 +18333,37 @@ var init_esm = __esm(() => {
18333
18333
 
18334
18334
  // src/paths.ts
18335
18335
  import { join as join4 } from "path";
18336
- var HOME, MULTI_DIR, CONFIG_PATH, PID_PATH, PORT_PATH, LOG_PATH, SKILLS_DIR, STOP_PATH, TASKS_DB_PATH;
18336
+ function daylineDir() {
18337
+ return process.env.DAYLINE_HOME || join4(HOME, ".dayline");
18338
+ }
18339
+ function hash32(text) {
18340
+ let h = 2166136261;
18341
+ for (let i = 0;i < text.length; i++) {
18342
+ h ^= text.charCodeAt(i);
18343
+ h = Math.imul(h, 16777619) >>> 0;
18344
+ }
18345
+ return h >>> 0;
18346
+ }
18347
+ function daemonPortFor(dir) {
18348
+ if (dir === join4(HOME, ".dayline"))
18349
+ return DEFAULT_DAEMON_PORT;
18350
+ return DERIVED_PORT_BASE + hash32(dir) % DERIVED_PORT_SPAN;
18351
+ }
18352
+ function daemonPort() {
18353
+ return daemonPortFor(daylineDir());
18354
+ }
18355
+ var HOME, DAYLINE_DIR, CONFIG_PATH, PID_PATH, PORT_PATH, LOG_PATH, SKILLS_DIR, STOP_PATH, TASKS_DB_PATH, DEFAULT_DAEMON_PORT = 47832, DERIVED_PORT_BASE = 48000, DERIVED_PORT_SPAN = 1000, DAEMON_PORT;
18337
18356
  var init_paths = __esm(() => {
18338
18357
  HOME = process.env.HOME || process.env.USERPROFILE || ".";
18339
- MULTI_DIR = process.env.MULTI_HOME || join4(HOME, ".multi");
18340
- CONFIG_PATH = join4(MULTI_DIR, "config.json");
18341
- PID_PATH = join4(MULTI_DIR, "agent.pid");
18342
- PORT_PATH = join4(MULTI_DIR, "agent.port");
18343
- LOG_PATH = join4(MULTI_DIR, "logs", "agent.log");
18344
- SKILLS_DIR = join4(MULTI_DIR, "skills");
18345
- STOP_PATH = join4(MULTI_DIR, "stop.flag");
18346
- TASKS_DB_PATH = join4(MULTI_DIR, "tasks.db");
18358
+ DAYLINE_DIR = daylineDir();
18359
+ CONFIG_PATH = join4(DAYLINE_DIR, "config.json");
18360
+ PID_PATH = join4(DAYLINE_DIR, "agent.pid");
18361
+ PORT_PATH = join4(DAYLINE_DIR, "agent.port");
18362
+ LOG_PATH = join4(DAYLINE_DIR, "logs", "agent.log");
18363
+ SKILLS_DIR = join4(DAYLINE_DIR, "skills");
18364
+ STOP_PATH = join4(DAYLINE_DIR, "stop.flag");
18365
+ TASKS_DB_PATH = join4(DAYLINE_DIR, "tasks.db");
18366
+ DAEMON_PORT = daemonPort();
18347
18367
  });
18348
18368
 
18349
18369
  // src/errors.ts
@@ -18579,7 +18599,7 @@ function ensureGitignoreEntry(workingDir, entry) {
18579
18599
  } catch {}
18580
18600
  }
18581
18601
  function indexPath(workingDir) {
18582
- return join5(workingDir, ".multi", "worktrees", "_index.json");
18602
+ return join5(workingDir, ".dayline", "worktrees", "_index.json");
18583
18603
  }
18584
18604
  function readIndex(workingDir) {
18585
18605
  try {
@@ -18620,10 +18640,10 @@ async function ensureWorktree(workingDir, issueKey, issueId, opts) {
18620
18640
  if (!await isGitRepo(workingDir)) {
18621
18641
  return { path: workingDir, branch: "", created: false };
18622
18642
  }
18623
- ensureGitignoreEntry(workingDir, ".multi/");
18643
+ ensureGitignoreEntry(workingDir, ".dayline/");
18624
18644
  const slug = worktreeSlug(opts?.worktreeName ?? issueKey);
18625
18645
  const branch = `multi/${slug}`;
18626
- const wtDir = join5(workingDir, ".multi", "worktrees");
18646
+ const wtDir = join5(workingDir, ".dayline", "worktrees");
18627
18647
  const wtPath = join5(wtDir, slug);
18628
18648
  let baseRef = "HEAD";
18629
18649
  const explicit = opts?.baseBranch || opts?.parentBranch || null;
@@ -18689,7 +18709,9 @@ async function linkIgnoredFiles(workingDir, wtPath) {
18689
18709
  `).map((l) => l.trim()).filter(Boolean);
18690
18710
  for (const raw of entries2) {
18691
18711
  const rel = raw.endsWith("/") ? raw.slice(0, -1) : raw;
18692
- if (!rel || rel === ".multi" || rel.startsWith(".multi/"))
18712
+ if (!rel || rel === ".dayline" || rel.startsWith(".dayline/"))
18713
+ continue;
18714
+ if (rel === ".multi" || rel.startsWith(".multi/"))
18693
18715
  continue;
18694
18716
  if (rel === ".git" || rel.startsWith(".git/"))
18695
18717
  continue;
@@ -18713,7 +18735,7 @@ async function removeWorktree(workingDir, issueKey, opts = {}) {
18713
18735
  }
18714
18736
  const key = worktreeSlug(issueKey);
18715
18737
  const branch = `multi/${key}`;
18716
- const wtPath = join5(workingDir, ".multi", "worktrees", key);
18738
+ const wtPath = join5(workingDir, ".dayline", "worktrees", key);
18717
18739
  if (existsSync3(wtPath)) {
18718
18740
  const dirty = await isDirty(wtPath);
18719
18741
  if (dirty && !opts.force) {
@@ -37790,7 +37812,6 @@ var init_workspace_mutex = __esm(() => {
37790
37812
 
37791
37813
  // src/_impl/adapter-pidfile.ts
37792
37814
  import { existsSync as existsSync5, mkdirSync as mkdirSync5, readdirSync as readdirSync2, readFileSync as readFileSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync5 } from "fs";
37793
- import { homedir } from "os";
37794
37815
  import { join as join7 } from "path";
37795
37816
  import { spawnSync } from "child_process";
37796
37817
  function ensureDir() {
@@ -37964,7 +37985,8 @@ function killDaemonChildren(daemonPid, log3 = () => {}) {
37964
37985
  }
37965
37986
  var ADAPTERS_DIR;
37966
37987
  var init_adapter_pidfile = __esm(() => {
37967
- ADAPTERS_DIR = join7(homedir(), ".multi", "adapters");
37988
+ init_paths();
37989
+ ADAPTERS_DIR = join7(daylineDir(), "adapters");
37968
37990
  });
37969
37991
 
37970
37992
  // src/_impl/acp-runner.ts
@@ -38643,11 +38665,11 @@ function extractText2(content) {
38643
38665
  return content.text;
38644
38666
  return "";
38645
38667
  }
38646
- var HOME3, LOG_PATH2;
38668
+ var LOG_PATH2;
38647
38669
  var init_acpx_runner = __esm(() => {
38648
38670
  init_adapter_pidfile();
38649
- HOME3 = process.env.HOME || process.env.USERPROFILE || ".";
38650
- LOG_PATH2 = join9(HOME3, ".multi", "logs", "agent.log");
38671
+ init_paths();
38672
+ LOG_PATH2 = join9(daylineDir(), "logs", "agent.log");
38651
38673
  });
38652
38674
 
38653
38675
  // ../../node_modules/zod/index.js
@@ -39245,7 +39267,7 @@ function normalizeKey(issueKey) {
39245
39267
  return issueKey.toLowerCase().replace(/[^a-z0-9\-_\/]/g, "-");
39246
39268
  }
39247
39269
  function worktreePath(baseWorkingDir, issueKey) {
39248
- return join10(baseWorkingDir, ".multi", "worktrees", normalizeKey(issueKey));
39270
+ return join10(baseWorkingDir, ".dayline", "worktrees", normalizeKey(issueKey));
39249
39271
  }
39250
39272
  function branchFor(issueKey) {
39251
39273
  return `multi/${normalizeKey(issueKey)}`;
@@ -39365,13 +39387,12 @@ var init_git_enforce = __esm(() => {
39365
39387
  // src/_impl/outbox.ts
39366
39388
  import { Database as Database2 } from "bun:sqlite";
39367
39389
  import { existsSync as existsSync11, mkdirSync as mkdirSync8 } from "fs";
39368
- import { homedir as homedir2 } from "os";
39369
39390
  import { join as join11 } from "path";
39370
39391
  function ensureDb() {
39371
39392
  if (db)
39372
39393
  return db;
39373
- if (!existsSync11(MULTI_DIR3))
39374
- mkdirSync8(MULTI_DIR3, { recursive: true });
39394
+ if (!existsSync11(DAYLINE_DIR3))
39395
+ mkdirSync8(DAYLINE_DIR3, { recursive: true });
39375
39396
  db = new Database2(TASKS_DB_PATH2);
39376
39397
  db.exec(`
39377
39398
  CREATE TABLE IF NOT EXISTS stream_outbox (
@@ -39528,11 +39549,12 @@ function startOutboxFlusher(apiUrl, wsId) {
39528
39549
  clearTimeout(timer);
39529
39550
  };
39530
39551
  }
39531
- var MULTI_DIR3, TASKS_DB_PATH2, BATCH_SIZE = 100, FLUSH_INTERVAL_MS = 2000, MAX_BACKOFF_MS = 30000, db = null, kickFlusher = null, PERMANENT_REJECT_REASONS;
39552
+ var DAYLINE_DIR3, TASKS_DB_PATH2, BATCH_SIZE = 100, FLUSH_INTERVAL_MS = 2000, MAX_BACKOFF_MS = 30000, db = null, kickFlusher = null, PERMANENT_REJECT_REASONS;
39532
39553
  var init_outbox = __esm(() => {
39533
39554
  init_client();
39534
- MULTI_DIR3 = join11(homedir2(), ".multi");
39535
- TASKS_DB_PATH2 = join11(MULTI_DIR3, "tasks.db");
39555
+ init_paths();
39556
+ DAYLINE_DIR3 = daylineDir();
39557
+ TASKS_DB_PATH2 = join11(DAYLINE_DIR3, "tasks.db");
39536
39558
  PERMANENT_REJECT_REASONS = new Set(["issue_not_found", "project_not_found", "forbidden", "no_workspace"]);
39537
39559
  });
39538
39560
 
@@ -39540,7 +39562,7 @@ var init_outbox = __esm(() => {
39540
39562
  import { mkdirSync as mkdirSync9, existsSync as existsSync12, writeFileSync as writeFileSync7, readFileSync as readFileSync10, appendFileSync as appendFileSync4, unlinkSync as unlinkSync6, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
39541
39563
  import { join as join12, dirname as dirname9 } from "path";
39542
39564
  function ensureDirs() {
39543
- for (const d of [MULTI_DIR4, join12(MULTI_DIR4, "logs"), SKILLS_DIR2]) {
39565
+ for (const d of [DAYLINE_DIR4, join12(DAYLINE_DIR4, "logs"), SKILLS_DIR2]) {
39544
39566
  if (!existsSync12(d))
39545
39567
  mkdirSync9(d, { recursive: true });
39546
39568
  }
@@ -39818,8 +39840,8 @@ async function handleRunTask(apiUrl, deviceId, task, detected, ctx) {
39818
39840
  await postStream(apiUrl, issueId, "progress", { message: `Device ${deviceId} picked up ${isFollowup ? "follow-up" : "task"}` });
39819
39841
  let attachmentRefs = [];
39820
39842
  if (task.from_comment_id && task.tenant_workspace_id && task.project_id) {
39821
- const baseDir = workingDir || join12(MULTI_DIR4, "tmp", issueId);
39822
- const inDir = join12(baseDir, ".multi-in", task.from_comment_id);
39843
+ const baseDir = workingDir || join12(DAYLINE_DIR4, "tmp", issueId);
39844
+ const inDir = join12(baseDir, ".dayline-in", task.from_comment_id);
39823
39845
  try {
39824
39846
  attachmentRefs = await downloadCommentAttachments(apiUrl, task.tenant_workspace_id, task.project_id, issueId, task.from_comment_id, inDir);
39825
39847
  if (attachmentRefs.length)
@@ -39828,7 +39850,7 @@ async function handleRunTask(apiUrl, deviceId, task, detected, ctx) {
39828
39850
  log3(`[from_comment_id] attachment fetch failed — comments table may be gone (Phase 6): ${String(e).slice(0, 200)}`);
39829
39851
  }
39830
39852
  }
39831
- const outDir = join12(workingDir || join12(MULTI_DIR4, "tmp", issueId), ".multi-out");
39853
+ const outDir = join12(workingDir || join12(DAYLINE_DIR4, "tmp", issueId), ".dayline-out");
39832
39854
  let hadError = false;
39833
39855
  let hasAssistantText = false;
39834
39856
  let memorySummary = null;
@@ -40363,7 +40385,7 @@ ${userPart}` : userPart;
40363
40385
  }
40364
40386
  });
40365
40387
  if (files.length > 0)
40366
- log3(` [Phase 4.5] agent wrote ${files.length} file(s) to .multi-out; attachments via chat upload not wired in this path`);
40388
+ log3(` [Phase 4.5] agent wrote ${files.length} file(s) to .dayline-out; attachments via chat upload not wired in this path`);
40367
40389
  }
40368
40390
  if (ctx) {
40369
40391
  const fullText = turn.blocks.filter((b) => b.kind === "text").map((b) => b.text).join(`
@@ -41229,7 +41251,7 @@ async function resolveAcpAdapter(agentType, detectedPath) {
41229
41251
  return [bin];
41230
41252
  }
41231
41253
  } catch {}
41232
- const global = join12(HOME4, ".bun", "install", "global", "node_modules", ".bin", name);
41254
+ const global = join12(HOME3, ".bun", "install", "global", "node_modules", ".bin", name);
41233
41255
  if (existsSync12(global))
41234
41256
  return [global];
41235
41257
  }
@@ -41239,7 +41261,7 @@ async function postStream(_apiUrl, issueId, event_type, payload) {
41239
41261
  try {
41240
41262
  ensureDirs();
41241
41263
  const date6 = new Date().toISOString().slice(0, 10);
41242
- const path = join12(MULTI_DIR4, "logs", `events-${date6}.ndjson`);
41264
+ const path = join12(DAYLINE_DIR4, "logs", `events-${date6}.ndjson`);
41243
41265
  appendFileSync4(path, JSON.stringify({ ts: Date.now(), issue_id: issueId, event_type, payload }) + `
41244
41266
  `);
41245
41267
  } catch {}
@@ -41482,7 +41504,7 @@ function buildArgs(type3, prompt) {
41482
41504
  return [prompt];
41483
41505
  }
41484
41506
  }
41485
- var HOME4, MULTI_DIR4, CONFIG_PATH2, LOG_PATH3, SKILLS_DIR2, conflictAttempts, enforceWorktreeCheckpointE = (apiUrl, issueId, baseWorkingDir, issueKey, mode) => enforceCommitAndPush(baseWorkingDir, issueKey, mode).pipe(exports_Effect.tap((res) => exports_Effect.sync(() => {
41507
+ var HOME3, DAYLINE_DIR4, CONFIG_PATH2, LOG_PATH3, SKILLS_DIR2, conflictAttempts, enforceWorktreeCheckpointE = (apiUrl, issueId, baseWorkingDir, issueKey, mode) => enforceCommitAndPush(baseWorkingDir, issueKey, mode).pipe(exports_Effect.tap((res) => exports_Effect.sync(() => {
41486
41508
  if (!res.ran)
41487
41509
  return;
41488
41510
  if (res.committed) {
@@ -41553,11 +41575,12 @@ var init_run_task = __esm(() => {
41553
41575
  init_esm();
41554
41576
  init_git_enforce();
41555
41577
  init_outbox();
41556
- HOME4 = process.env.HOME || process.env.USERPROFILE || ".";
41557
- MULTI_DIR4 = join12(HOME4, ".multi");
41558
- CONFIG_PATH2 = join12(MULTI_DIR4, "config.json");
41559
- LOG_PATH3 = join12(MULTI_DIR4, "logs", "agent.log");
41560
- SKILLS_DIR2 = join12(MULTI_DIR4, "skills");
41578
+ init_paths();
41579
+ HOME3 = process.env.HOME || process.env.USERPROFILE || ".";
41580
+ DAYLINE_DIR4 = daylineDir();
41581
+ CONFIG_PATH2 = join12(DAYLINE_DIR4, "config.json");
41582
+ LOG_PATH3 = join12(DAYLINE_DIR4, "logs", "agent.log");
41583
+ SKILLS_DIR2 = join12(DAYLINE_DIR4, "skills");
41561
41584
  conflictAttempts = new Map;
41562
41585
  });
41563
41586
 
@@ -42395,7 +42418,6 @@ __export(exports_worktree_create, {
42395
42418
  materialiseWorktree: () => materialiseWorktree,
42396
42419
  removeWorktree: () => removeWorktree2
42397
42420
  });
42398
- import { homedir as homedir3 } from "os";
42399
42421
  import { existsSync as existsSync13, mkdirSync as mkdirSync10, readFileSync as readFileSync11, symlinkSync as symlinkSync3, writeFileSync as writeFileSync8, appendFileSync as appendFileSync5 } from "fs";
42400
42422
  import { dirname as dirname10, join as join14 } from "path";
42401
42423
  function loadOrInitConfig(repoRoot, log4) {
@@ -42518,7 +42540,7 @@ async function materialiseWorktree(opts) {
42518
42540
  const head5 = await run5(["git", "rev-parse", "--abbrev-ref", "HEAD"], repoRoot);
42519
42541
  baseBranch = head5.ok ? head5.stdout : "HEAD";
42520
42542
  }
42521
- const worktreesDir = join14(homedir3(), ".multi", "worktrees");
42543
+ const worktreesDir = join14(daylineDir(), "worktrees");
42522
42544
  const path = join14(worktreesDir, name);
42523
42545
  if (existsSync13(path)) {
42524
42546
  throw new Error(`worktree path already exists: ${path}`);
@@ -42561,6 +42583,7 @@ var CONFIG_FILENAME = "multi.config.jsonc", CONFIG_TEMPLATE = `{
42561
42583
  `, CITY_CODENAMES;
42562
42584
  var init_worktree_create = __esm(() => {
42563
42585
  init_main();
42586
+ init_paths();
42564
42587
  CITY_CODENAMES = [
42565
42588
  "raleigh",
42566
42589
  "yokohama",
@@ -42759,7 +42782,7 @@ class ChatPeer {
42759
42782
  constructor(opts) {
42760
42783
  this.opts = opts;
42761
42784
  this.chatId = opts.chatId;
42762
- this.snapshotPath = join15(MULTI_DIR, "chats", `${opts.chatId}.loro`);
42785
+ this.snapshotPath = join15(daylineDir(), "chats", `${opts.chatId}.loro`);
42763
42786
  this.doc = this.loadFromDisk();
42764
42787
  for (const m of listMessages(this.doc))
42765
42788
  this.seenIds.add(m.id);
@@ -42800,6 +42823,7 @@ class ChatPeer {
42800
42823
  const msg = {
42801
42824
  id: crypto.randomUUID(),
42802
42825
  author: { kind: "agent", id: authorAgentId, name: authorName },
42826
+ kind: "text",
42803
42827
  text: "",
42804
42828
  ts: Math.floor(Date.now() / 1000),
42805
42829
  mentions: [],
@@ -42859,6 +42883,9 @@ class ChatPeer {
42859
42883
  getDoc() {
42860
42884
  return this.doc;
42861
42885
  }
42886
+ async messages() {
42887
+ return listMessages(this.doc);
42888
+ }
42862
42889
  findMessage(id3) {
42863
42890
  for (const m of listMessages(this.doc))
42864
42891
  if (m.id === id3)
@@ -42971,7 +42998,7 @@ class ChatPeer {
42971
42998
  }
42972
42999
  };
42973
43000
  }
42974
- buildSnapshotGreet() {
43001
+ async buildSnapshotGreet() {
42975
43002
  const snap = exportSnapshot(this.doc);
42976
43003
  const frame = new Uint8Array(1 + snap.byteLength);
42977
43004
  frame[0] = FRAME_LORO;
@@ -43089,6 +43116,418 @@ var init_chat_peer = __esm(() => {
43089
43116
  init_chat_doc();
43090
43117
  });
43091
43118
 
43119
+ // src/_impl/chat-peer-binary.ts
43120
+ import { existsSync as existsSync15, readdirSync as readdirSync4 } from "fs";
43121
+ import { createRequire as createRequire2 } from "module";
43122
+ import { dirname as dirname12, join as join16 } from "path";
43123
+ function packageForHost() {
43124
+ const target = TARGETS[`${process.platform}-${process.arch}`];
43125
+ return target ? `@shipers-dev/dayline-chat-peer-${target}` : null;
43126
+ }
43127
+ function binName() {
43128
+ return process.platform === "win32" ? "dayline-chat-peer.exe" : "dayline-chat-peer";
43129
+ }
43130
+ function candidatesIn(targetDir) {
43131
+ const bin = binName();
43132
+ let triples = [];
43133
+ try {
43134
+ triples = readdirSync4(targetDir, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name.includes("-")).map((e) => e.name);
43135
+ } catch {}
43136
+ const out = [];
43137
+ for (const profile of ["release", "debug"]) {
43138
+ out.push(join16(targetDir, profile, bin));
43139
+ for (const triple of triples)
43140
+ out.push(join16(targetDir, triple, profile, bin));
43141
+ }
43142
+ return out;
43143
+ }
43144
+ function devBuild() {
43145
+ let dir = dirname12(new URL(import.meta.url).pathname);
43146
+ for (let i = 0;i < 6; i++) {
43147
+ for (const candidate of candidatesIn(join16(dir, "target"))) {
43148
+ if (existsSync15(candidate))
43149
+ return candidate;
43150
+ }
43151
+ const parent = dirname12(dir);
43152
+ if (parent === dir)
43153
+ break;
43154
+ dir = parent;
43155
+ }
43156
+ return null;
43157
+ }
43158
+ function resolveChatPeerBinary() {
43159
+ const override = process.env.DAYLINE_CHAT_PEER_BIN;
43160
+ if (override)
43161
+ return existsSync15(override) ? override : null;
43162
+ const pkg = packageForHost();
43163
+ if (pkg) {
43164
+ try {
43165
+ const manifest = require_.resolve(`${pkg}/package.json`);
43166
+ const candidate = join16(dirname12(manifest), "bin", binName());
43167
+ if (existsSync15(candidate))
43168
+ return candidate;
43169
+ } catch {}
43170
+ }
43171
+ return devBuild();
43172
+ }
43173
+ var require_, TARGETS;
43174
+ var init_chat_peer_binary = __esm(() => {
43175
+ require_ = createRequire2(import.meta.url);
43176
+ TARGETS = {
43177
+ "darwin-arm64": "darwin-arm64",
43178
+ "darwin-x64": "darwin-x64",
43179
+ "linux-x64": "linux-x64",
43180
+ "linux-arm64": "linux-arm64",
43181
+ "win32-x64": "win32-x64"
43182
+ };
43183
+ });
43184
+
43185
+ // src/_impl/chat-peer-ipc.ts
43186
+ class ChatPeerSidecar {
43187
+ binary;
43188
+ log;
43189
+ static instance = null;
43190
+ child = null;
43191
+ pending = new Map;
43192
+ chats = new Map;
43193
+ nextId = 1;
43194
+ buf = new Uint8Array(0);
43195
+ spawning = false;
43196
+ constructor(binary, log4) {
43197
+ this.binary = binary;
43198
+ this.log = log4;
43199
+ }
43200
+ static shared(log4) {
43201
+ if (ChatPeerSidecar.instance)
43202
+ return ChatPeerSidecar.instance;
43203
+ const binary = resolveChatPeerBinary();
43204
+ if (!binary)
43205
+ return null;
43206
+ ChatPeerSidecar.instance = new ChatPeerSidecar(binary, log4);
43207
+ return ChatPeerSidecar.instance;
43208
+ }
43209
+ static reset() {
43210
+ try {
43211
+ ChatPeerSidecar.instance?.child?.kill();
43212
+ } catch {}
43213
+ ChatPeerSidecar.instance = null;
43214
+ }
43215
+ registerChat(chatId, handlers) {
43216
+ this.chats.set(chatId, handlers);
43217
+ this.ensureChild();
43218
+ }
43219
+ unregisterChat(chatId) {
43220
+ this.chats.delete(chatId);
43221
+ }
43222
+ notify(method, params, bin) {
43223
+ this.send({ id: null, method, params }, bin);
43224
+ }
43225
+ request(method, params, bin) {
43226
+ const id3 = this.nextId++;
43227
+ return new Promise((resolve2, reject) => {
43228
+ this.pending.set(id3, { resolve: resolve2, reject });
43229
+ this.send({ id: id3, method, params }, bin);
43230
+ });
43231
+ }
43232
+ send(msg, bin) {
43233
+ const child = this.ensureChild();
43234
+ if (!child)
43235
+ return;
43236
+ const json2 = new TextEncoder().encode(JSON.stringify(msg));
43237
+ const body = bin ?? new Uint8Array(0);
43238
+ const frame = new Uint8Array(8 + json2.byteLength + body.byteLength);
43239
+ const view = new DataView(frame.buffer);
43240
+ view.setUint32(0, json2.byteLength, false);
43241
+ view.setUint32(4, body.byteLength, false);
43242
+ frame.set(json2, 8);
43243
+ frame.set(body, 8 + json2.byteLength);
43244
+ try {
43245
+ child.stdin.write(frame);
43246
+ } catch (e) {
43247
+ this.log(`[chat-peer] write failed: ${e.message}`);
43248
+ }
43249
+ }
43250
+ ensureChild() {
43251
+ if (this.child)
43252
+ return this.child;
43253
+ if (this.spawning)
43254
+ return null;
43255
+ this.spawning = true;
43256
+ try {
43257
+ const child = Bun.spawn([this.binary], {
43258
+ stdio: ["pipe", "pipe", "inherit"],
43259
+ env: { ...process.env }
43260
+ });
43261
+ this.child = child;
43262
+ this.log(`[chat-peer] sidecar started (pid ${child.pid})`);
43263
+ this.readLoop(child);
43264
+ child.exited.then((code) => {
43265
+ if (this.child !== child)
43266
+ return;
43267
+ this.child = null;
43268
+ this.log(`[chat-peer] sidecar exited (${code}); reviving ${this.chats.size} chat(s)`);
43269
+ for (const [, p] of this.pending)
43270
+ p.reject(new Error("chat peer sidecar exited"));
43271
+ this.pending.clear();
43272
+ this.spawning = false;
43273
+ for (const [, handlers] of this.chats) {
43274
+ try {
43275
+ handlers.revive();
43276
+ } catch {}
43277
+ }
43278
+ });
43279
+ return child;
43280
+ } catch (e) {
43281
+ this.log(`[chat-peer] spawn failed: ${e.message}`);
43282
+ return null;
43283
+ } finally {
43284
+ this.spawning = false;
43285
+ }
43286
+ }
43287
+ async readLoop(child) {
43288
+ const reader = child.stdout.getReader();
43289
+ try {
43290
+ for (;; ) {
43291
+ const { done: done9, value: value3 } = await reader.read();
43292
+ if (done9)
43293
+ return;
43294
+ if (value3)
43295
+ this.consume(value3);
43296
+ }
43297
+ } catch (e) {
43298
+ this.log(`[chat-peer] read failed: ${e.message}`);
43299
+ }
43300
+ }
43301
+ consume(chunk3) {
43302
+ const merged = new Uint8Array(this.buf.byteLength + chunk3.byteLength);
43303
+ merged.set(this.buf, 0);
43304
+ merged.set(chunk3, this.buf.byteLength);
43305
+ this.buf = merged;
43306
+ for (;; ) {
43307
+ if (this.buf.byteLength < 8)
43308
+ return;
43309
+ const view = new DataView(this.buf.buffer, this.buf.byteOffset, this.buf.byteLength);
43310
+ const jsonLen = view.getUint32(0, false);
43311
+ const binLen = view.getUint32(4, false);
43312
+ const total = 8 + jsonLen + binLen;
43313
+ if (this.buf.byteLength < total)
43314
+ return;
43315
+ const json2 = this.buf.subarray(8, 8 + jsonLen);
43316
+ const bin = this.buf.subarray(8 + jsonLen, total);
43317
+ const binCopy = new Uint8Array(bin);
43318
+ let msg = null;
43319
+ try {
43320
+ msg = JSON.parse(new TextDecoder().decode(json2));
43321
+ } catch {
43322
+ this.log("[chat-peer] unparseable frame from sidecar");
43323
+ }
43324
+ this.buf = this.buf.slice(total);
43325
+ if (msg)
43326
+ this.deliver(msg, binCopy);
43327
+ }
43328
+ }
43329
+ deliver(msg, bin) {
43330
+ if (typeof msg.id === "number") {
43331
+ const p = this.pending.get(msg.id);
43332
+ if (!p)
43333
+ return;
43334
+ this.pending.delete(msg.id);
43335
+ if (msg.ok)
43336
+ p.resolve({ result: msg.result, bin });
43337
+ else
43338
+ p.reject(new Error(String(msg.error ?? "sidecar error")));
43339
+ return;
43340
+ }
43341
+ const handlers = msg.chat_id ? this.chats.get(msg.chat_id) : undefined;
43342
+ switch (msg.event) {
43343
+ case "user_message":
43344
+ if (handlers && msg.message)
43345
+ handlers.onUserMessage(msg.message);
43346
+ return;
43347
+ case "fanout":
43348
+ if (handlers) {
43349
+ handlers.onFanout(bin, typeof msg.except === "number" ? msg.except : null);
43350
+ }
43351
+ return;
43352
+ case "log":
43353
+ this.log(String(msg.line ?? ""));
43354
+ return;
43355
+ case "error":
43356
+ this.log(`[chat-peer] ${String(msg.message ?? "")}`);
43357
+ return;
43358
+ default:
43359
+ return;
43360
+ }
43361
+ }
43362
+ }
43363
+ var init_chat_peer_ipc = __esm(() => {
43364
+ init_chat_peer_binary();
43365
+ });
43366
+
43367
+ // src/_impl/chat-peer-remote.ts
43368
+ class RemoteChatPeer {
43369
+ opts;
43370
+ sidecar;
43371
+ chatId;
43372
+ nextHandle = 1;
43373
+ nextToken = 1;
43374
+ localSubs = new Map;
43375
+ closed = false;
43376
+ constructor(opts, sidecar) {
43377
+ this.opts = opts;
43378
+ this.sidecar = sidecar;
43379
+ this.chatId = opts.chatId;
43380
+ }
43381
+ start() {
43382
+ this.sidecar.registerChat(this.chatId, {
43383
+ onUserMessage: (msg) => {
43384
+ this.opts.onUserMessage?.(msg, this);
43385
+ },
43386
+ onFanout: (frame, except) => this.broadcastLocal(frame, except),
43387
+ revive: () => this.create()
43388
+ });
43389
+ this.create();
43390
+ }
43391
+ create() {
43392
+ if (this.closed)
43393
+ return;
43394
+ this.sidecar.notify("create", {
43395
+ chat_id: this.chatId,
43396
+ api_url: this.opts.apiUrl,
43397
+ auth_token: this.opts.authToken,
43398
+ workspace_id: this.opts.workspaceId,
43399
+ device_id: this.opts.deviceId ?? null,
43400
+ primary_agent_id: this.opts.primaryAgentId,
43401
+ want_user_messages: Boolean(this.opts.onUserMessage)
43402
+ });
43403
+ }
43404
+ close() {
43405
+ this.closed = true;
43406
+ this.sidecar.notify("close", { chat_id: this.chatId });
43407
+ this.sidecar.unregisterChat(this.chatId);
43408
+ }
43409
+ handle() {
43410
+ return `h${this.nextHandle++}`;
43411
+ }
43412
+ appendAndPush(msg) {
43413
+ const handle = this.handle();
43414
+ this.sidecar.notify("append", { chat_id: this.chatId, handle, msg });
43415
+ return handle;
43416
+ }
43417
+ appendStructured(msg) {
43418
+ return this.appendAndPush(msg);
43419
+ }
43420
+ flush() {
43421
+ this.sidecar.notify("flush", { chat_id: this.chatId });
43422
+ }
43423
+ beginPartialAgentMessage(authorAgentId, authorName) {
43424
+ const msg = {
43425
+ id: crypto.randomUUID(),
43426
+ author: { kind: "agent", id: authorAgentId, name: authorName },
43427
+ kind: "text",
43428
+ text: "",
43429
+ ts: Math.floor(Date.now() / 1000),
43430
+ mentions: [],
43431
+ attachments: [],
43432
+ partial: true
43433
+ };
43434
+ return { msgId: msg.id, containerId: this.appendAndPush(msg) };
43435
+ }
43436
+ appendPartialText(containerId, chunk3) {
43437
+ this.sidecar.notify("append_text", { chat_id: this.chatId, handle: containerId, chunk: chunk3 });
43438
+ }
43439
+ finalizePartialMessage(containerId) {
43440
+ this.sidecar.notify("finalize", { chat_id: this.chatId, handle: containerId });
43441
+ }
43442
+ upsertPlan(authorAgentId, authorName, entries2, containerId) {
43443
+ if (containerId) {
43444
+ this.patchMessage(containerId, { plan_entries: entries2 });
43445
+ return containerId;
43446
+ }
43447
+ const msg = {
43448
+ id: crypto.randomUUID(),
43449
+ author: { kind: "agent", id: authorAgentId, name: authorName },
43450
+ kind: "plan",
43451
+ text: "",
43452
+ ts: Math.floor(Date.now() / 1000),
43453
+ mentions: [],
43454
+ attachments: [],
43455
+ partial: false,
43456
+ plan_entries: entries2
43457
+ };
43458
+ return this.appendAndPush(msg);
43459
+ }
43460
+ patchMessage(containerId, patch9) {
43461
+ this.sidecar.notify("patch", { chat_id: this.chatId, handle: containerId, patch: patch9 });
43462
+ }
43463
+ markDelivered(msgId) {
43464
+ this.sidecar.notify("mark_delivered", { chat_id: this.chatId, msg_id: msgId });
43465
+ }
43466
+ async messages() {
43467
+ const { result } = await this.sidecar.request("messages", { chat_id: this.chatId });
43468
+ return result?.messages ?? [];
43469
+ }
43470
+ async awaitMessage(id3, timeoutMs = 5000) {
43471
+ const { result } = await this.sidecar.request("await_message", {
43472
+ chat_id: this.chatId,
43473
+ msg_id: id3,
43474
+ timeout_ms: timeoutMs
43475
+ });
43476
+ return result?.message ?? null;
43477
+ }
43478
+ async buildSnapshotGreet() {
43479
+ const { bin } = await this.sidecar.request("snapshot_greet", { chat_id: this.chatId });
43480
+ return bin;
43481
+ }
43482
+ hasLocalSubscribers() {
43483
+ return this.localSubs.size > 0;
43484
+ }
43485
+ addLocalSubscriber(send) {
43486
+ const token = this.nextToken++;
43487
+ this.localSubs.set(token, send);
43488
+ return { token, close: () => {
43489
+ this.localSubs.delete(token);
43490
+ } };
43491
+ }
43492
+ ingestLocalUpdate(update5, fromToken) {
43493
+ if (typeof fromToken !== "number")
43494
+ return;
43495
+ this.sidecar.notify("ingest_local_update", { chat_id: this.chatId, from_token: fromToken }, update5);
43496
+ }
43497
+ broadcastLocal(frame, except) {
43498
+ for (const [token, send] of this.localSubs) {
43499
+ if (token === except)
43500
+ continue;
43501
+ try {
43502
+ send(frame);
43503
+ } catch {}
43504
+ }
43505
+ }
43506
+ }
43507
+
43508
+ // src/_impl/chat-peer-factory.ts
43509
+ function createChatPeer(opts) {
43510
+ const mode = process.env.DAYLINE_CHAT_PEER ?? "auto";
43511
+ if (mode === "ts")
43512
+ return new ChatPeer(opts);
43513
+ const sidecar = ChatPeerSidecar.shared(opts.log);
43514
+ if (sidecar)
43515
+ return new RemoteChatPeer(opts, sidecar);
43516
+ if (mode === "rust") {
43517
+ throw new Error("DAYLINE_CHAT_PEER=rust but no dayline-chat-peer binary was found for this platform");
43518
+ }
43519
+ if (!warned) {
43520
+ warned = true;
43521
+ opts.log("[chat-peer] no sidecar binary for this platform; using the in-process peer");
43522
+ }
43523
+ return new ChatPeer(opts);
43524
+ }
43525
+ var warned = false;
43526
+ var init_chat_peer_factory = __esm(() => {
43527
+ init_chat_peer();
43528
+ init_chat_peer_ipc();
43529
+ });
43530
+
43092
43531
  // src/_impl/chat-turn.ts
43093
43532
  async function handleChatTurn(opts) {
43094
43533
  const detected = await detectAgents();
@@ -43858,8 +44297,8 @@ var init_chat_plan_actions = __esm(() => {
43858
44297
  });
43859
44298
 
43860
44299
  // src/_impl/chat-attachments.ts
43861
- import { existsSync as existsSync15, mkdirSync as mkdirSync12, writeFileSync as writeFileSync10 } from "fs";
43862
- import { dirname as dirname12, join as join16 } from "path";
44300
+ import { existsSync as existsSync16, mkdirSync as mkdirSync12, writeFileSync as writeFileSync10 } from "fs";
44301
+ import { dirname as dirname13, join as join17 } from "path";
43863
44302
  function safeName(n) {
43864
44303
  return n.replace(/[^A-Za-z0-9._-]+/g, "_").slice(0, 80) || "file";
43865
44304
  }
@@ -43868,18 +44307,18 @@ async function downloadUserAttachments(opts) {
43868
44307
  const atts = message.attachments || [];
43869
44308
  if (atts.length === 0)
43870
44309
  return [];
43871
- const baseRel = join16(".multi", "attachments", message.id);
43872
- const baseAbs = join16(cwd, baseRel);
43873
- if (!existsSync15(baseAbs))
44310
+ const baseRel = join17(".dayline", "attachments", message.id);
44311
+ const baseAbs = join17(cwd, baseRel);
44312
+ if (!existsSync16(baseAbs))
43874
44313
  mkdirSync12(baseAbs, { recursive: true });
43875
44314
  const out = [];
43876
44315
  for (const a of atts) {
43877
44316
  if (!a.url)
43878
44317
  continue;
43879
44318
  const fname = safeName(a.name);
43880
- const relPath = join16(baseRel, fname);
43881
- const absPath = join16(cwd, relPath);
43882
- if (existsSync15(absPath)) {
44319
+ const relPath = join17(baseRel, fname);
44320
+ const absPath = join17(cwd, relPath);
44321
+ if (existsSync16(absPath)) {
43883
44322
  out.push({ attachment: a, absPath, relPath });
43884
44323
  continue;
43885
44324
  }
@@ -43893,8 +44332,8 @@ async function downloadUserAttachments(opts) {
43893
44332
  continue;
43894
44333
  }
43895
44334
  const buf = new Uint8Array(await res.arrayBuffer());
43896
- if (!existsSync15(dirname12(absPath)))
43897
- mkdirSync12(dirname12(absPath), { recursive: true });
44335
+ if (!existsSync16(dirname13(absPath)))
44336
+ mkdirSync12(dirname13(absPath), { recursive: true });
43898
44337
  writeFileSync10(absPath, buf);
43899
44338
  out.push({ attachment: a, absPath, relPath });
43900
44339
  } catch (e) {
@@ -44498,7 +44937,7 @@ ${agentsBlock}`;
44498
44937
  }
44499
44938
  var issueContextSent;
44500
44939
  var init_chat_supervisor = __esm(() => {
44501
- init_chat_peer();
44940
+ init_chat_peer_factory();
44502
44941
  init_chat_turn();
44503
44942
  init_chat_turn_registry();
44504
44943
  init_chat_plan_actions();
@@ -44547,7 +44986,7 @@ function ensureSession(wsId, chatId, ctx) {
44547
44986
  clearIdle(existing);
44548
44987
  return existing;
44549
44988
  }
44550
- const peer = new ChatPeer({
44989
+ const peer = createChatPeer({
44551
44990
  apiUrl: ctx.apiUrl,
44552
44991
  authToken: ctx.authToken,
44553
44992
  workspaceId: wsId,
@@ -44602,7 +45041,7 @@ async function runTurn(s, k, messageId, ctx, chatId) {
44602
45041
  }
44603
45042
  var DEFAULT_IDLE_TTL_MS, sessions, idleTtlMs, chatSessionRegistry;
44604
45043
  var init_chat_session_registry = __esm(() => {
44605
- init_chat_peer();
45044
+ init_chat_peer_factory();
44606
45045
  init_chat_supervisor();
44607
45046
  DEFAULT_IDLE_TTL_MS = 10 * 60 * 1000;
44608
45047
  sessions = new Map;
@@ -45260,7 +45699,7 @@ import { parseArgs } from "util";
45260
45699
  // package.json
45261
45700
  var package_default = {
45262
45701
  name: "@shipers-dev/dayline",
45263
- version: "0.97.0",
45702
+ version: "0.100.0",
45264
45703
  type: "module",
45265
45704
  bin: {
45266
45705
  dayline: "./dist/index.js"
@@ -45269,7 +45708,7 @@ var package_default = {
45269
45708
  "dist"
45270
45709
  ],
45271
45710
  scripts: {
45272
- dev: "MULTI_HOME=${MULTI_HOME:-$HOME/.multi-dev} MULTI_API=${MULTI_API:-http://127.0.0.1:8787} bun run src/index.ts connect",
45711
+ dev: "DAYLINE_HOME=${DAYLINE_HOME:-$HOME/.dayline-dev} MULTI_API=${MULTI_API:-http://127.0.0.1:8787} bun run src/index.ts connect",
45273
45712
  build: "bun build src/index.ts --outdir=dist --target=node --sourcemap=none --external loro-crdt",
45274
45713
  test: "bun test",
45275
45714
  prepublishOnly: "bun run build",
@@ -45285,6 +45724,13 @@ var package_default = {
45285
45724
  },
45286
45725
  devDependencies: {
45287
45726
  "@multi/lib": "workspace:*"
45727
+ },
45728
+ optionalDependencies: {
45729
+ "@shipers-dev/dayline-chat-peer-darwin-arm64": "0.1.0",
45730
+ "@shipers-dev/dayline-chat-peer-darwin-x64": "0.1.0",
45731
+ "@shipers-dev/dayline-chat-peer-linux-x64": "0.1.0",
45732
+ "@shipers-dev/dayline-chat-peer-linux-arm64": "0.1.0",
45733
+ "@shipers-dev/dayline-chat-peer-win32-x64": "0.1.0"
45288
45734
  }
45289
45735
  };
45290
45736
 
@@ -45350,7 +45796,7 @@ class Config3 extends exports_Effect.Service()("cli/Config", {
45350
45796
  effect: exports_Effect.gen(function* () {
45351
45797
  const fs2 = yield* FileSystem;
45352
45798
  const ensureDirs = exports_Effect.gen(function* () {
45353
- yield* fs2.mkdirp(MULTI_DIR);
45799
+ yield* fs2.mkdirp(DAYLINE_DIR);
45354
45800
  yield* fs2.mkdirp(dirname2(LOG_PATH));
45355
45801
  yield* fs2.mkdirp(SKILLS_DIR);
45356
45802
  });
@@ -45497,7 +45943,7 @@ CREATE INDEX IF NOT EXISTS idx_tasks_issue ON tasks(issue_id);
45497
45943
  class TasksDb extends exports_Effect.Service()("cli/TasksDb", {
45498
45944
  effect: exports_Effect.gen(function* () {
45499
45945
  const fs3 = yield* FileSystem;
45500
- yield* fs3.mkdirp(MULTI_DIR);
45946
+ yield* fs3.mkdirp(DAYLINE_DIR);
45501
45947
  const db = yield* exports_Effect.try({
45502
45948
  try: () => {
45503
45949
  const d = new Database(TASKS_DB_PATH);
@@ -45570,17 +46016,18 @@ init_esm();
45570
46016
 
45571
46017
  // src/_impl/materializer.ts
45572
46018
  init_client();
46019
+ init_paths();
45573
46020
  import { mkdirSync as mkdirSync4, existsSync as existsSync4, writeFileSync as writeFileSync4, readFileSync as readFileSync4, rmSync as rmSync2, symlinkSync as symlinkSync2, lstatSync } from "fs";
45574
46021
  import { join as join6, dirname as dirname5 } from "path";
45575
46022
  var HOME2 = process.env.HOME || process.env.USERPROFILE || ".";
45576
- var MULTI_DIR2 = join6(HOME2, ".multi");
45577
- var MULTI_SKILLS = join6(MULTI_DIR2, "skills");
45578
- var MULTI_AGENTS = join6(MULTI_DIR2, "agents");
45579
- var STATE_PATH = join6(MULTI_DIR2, "materialized.json");
46023
+ var DAYLINE_DIR2 = daylineDir();
46024
+ var DAYLINE_SKILLS = join6(DAYLINE_DIR2, "skills");
46025
+ var DAYLINE_AGENTS = join6(DAYLINE_DIR2, "agents");
46026
+ var STATE_PATH = join6(DAYLINE_DIR2, "materialized.json");
45580
46027
  var CLAUDE_DIR = join6(HOME2, ".claude");
45581
46028
  var CLAUDE_SKILLS = join6(CLAUDE_DIR, "skills");
45582
46029
  var CLAUDE_AGENTS = join6(CLAUDE_DIR, "agents");
45583
- var MARKER = ".multi-managed";
46030
+ var MARKER = ".dayline-managed";
45584
46031
  function slugify(s) {
45585
46032
  return s.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "unnamed";
45586
46033
  }
@@ -45592,7 +46039,7 @@ function loadState() {
45592
46039
  }
45593
46040
  }
45594
46041
  function saveState(s) {
45595
- mkdirSync4(MULTI_DIR2, { recursive: true });
46042
+ mkdirSync4(DAYLINE_DIR2, { recursive: true });
45596
46043
  writeFileSync4(STATE_PATH, JSON.stringify(s, null, 2));
45597
46044
  }
45598
46045
  function safeRmManaged(path) {
@@ -45616,7 +46063,7 @@ function safeRmManaged(path) {
45616
46063
  } catch {}
45617
46064
  }
45618
46065
  function writeManagedSkill(slug, skill) {
45619
- const dir = join6(MULTI_SKILLS, slug);
46066
+ const dir = join6(DAYLINE_SKILLS, slug);
45620
46067
  mkdirSync4(dir, { recursive: true });
45621
46068
  writeFileSync4(join6(dir, MARKER), `skill_id=${skill.id}
45622
46069
  revision=${Date.now()}
@@ -45693,7 +46140,7 @@ async function materializeBundle(apiUrl, wsId, deviceId, log3) {
45693
46140
  }
45694
46141
  for (const old of prev.skill_slugs) {
45695
46142
  if (!newSkillSlugs.includes(old)) {
45696
- safeRmManaged(join6(MULTI_SKILLS, old));
46143
+ safeRmManaged(join6(DAYLINE_SKILLS, old));
45697
46144
  safeRmManaged(join6(CLAUDE_SKILLS, old));
45698
46145
  }
45699
46146
  }
@@ -45786,7 +46233,7 @@ class Config4 extends exports_Effect.Service()("cli/Config", {
45786
46233
  effect: exports_Effect.gen(function* () {
45787
46234
  const fs3 = yield* FileSystem;
45788
46235
  const ensureDirs = exports_Effect.gen(function* () {
45789
- yield* fs3.mkdirp(MULTI_DIR);
46236
+ yield* fs3.mkdirp(DAYLINE_DIR);
45790
46237
  yield* fs3.mkdirp(dirname7(LOG_PATH));
45791
46238
  yield* fs3.mkdirp(SKILLS_DIR);
45792
46239
  });
@@ -45983,6 +46430,7 @@ class Materializer2 extends exports_Effect.Service()("cli/Materializer", {
45983
46430
  init_errors();
45984
46431
 
45985
46432
  // src/_impl/web-url.ts
46433
+ var DEV_WEB_PORT = 5173;
45986
46434
  function webUrlFor(apiUrl) {
45987
46435
  const override = process.env.MULTI_WEB || process.env.MULTI_WEB_URL;
45988
46436
  if (override)
@@ -45993,8 +46441,11 @@ function webUrlFor(apiUrl) {
45993
46441
  } catch {
45994
46442
  return "https://dayline.ai";
45995
46443
  }
45996
- if (u.hostname === "localhost" || u.hostname === "127.0.0.1" || u.hostname.endsWith(".local")) {
45997
- return u.origin;
46444
+ if (u.hostname === "localhost" || u.hostname === "127.0.0.1") {
46445
+ return `${u.protocol}//localhost:${DEV_WEB_PORT}`;
46446
+ }
46447
+ if (u.hostname.endsWith(".local")) {
46448
+ return `${u.protocol}//${u.hostname}:${DEV_WEB_PORT}`;
45998
46449
  }
45999
46450
  if (u.hostname.startsWith("api.")) {
46000
46451
  return `${u.protocol}//${u.hostname.slice(4)}`;
@@ -46063,7 +46514,16 @@ var setupCmd = exports_Effect.fn("setupCmd")(function* (name, apiUrl) {
46063
46514
  const a = approved.data;
46064
46515
  console.log(`
46065
46516
  ✅ Device paired. ID: ${a.device_id}`);
46066
- yield* config2.save({ deviceId: a.device_id, authToken: a.token, dispatchSecret: a.dispatch_secret, apiUrl });
46517
+ yield* config2.save({
46518
+ deviceId: a.device_id,
46519
+ authToken: a.token,
46520
+ dispatchSecret: a.dispatch_secret,
46521
+ sessionToken: a.session ?? undefined,
46522
+ apiUrl
46523
+ });
46524
+ if (!a.session) {
46525
+ console.log(" (no device session issued — native clients will ask you to pair again)");
46526
+ }
46067
46527
  yield* api2.setAuthToken(a.token);
46068
46528
  const workspaceId = a.workspace_id || undefined;
46069
46529
  if (workspaceId) {
@@ -46106,7 +46566,7 @@ import { existsSync as existsSync9, readFileSync as readFileSync9, unlinkSync as
46106
46566
  init_paths();
46107
46567
  import { closeSync, existsSync as existsSync8, mkdirSync as mkdirSync7, openSync, readFileSync as readFileSync8, unlinkSync as unlinkSync4, writeSync } from "fs";
46108
46568
  import { dirname as dirname8 } from "path";
46109
- var DEFAULT_DAEMON_PORT = 47832;
46569
+ var DEFAULT_DAEMON_PORT2 = DAEMON_PORT;
46110
46570
  var isAlive = (pid) => {
46111
46571
  if (!Number.isFinite(pid) || pid <= 0)
46112
46572
  return false;
@@ -46242,9 +46702,9 @@ var killStaleDaemons = (pidPath = PID_PATH, portPath = PORT_PATH) => {
46242
46702
  const port = (() => {
46243
46703
  try {
46244
46704
  const p = Number(readFileSync8(portPath, "utf8").trim());
46245
- return Number.isFinite(p) && p > 0 ? p : DEFAULT_DAEMON_PORT;
46705
+ return Number.isFinite(p) && p > 0 ? p : DEFAULT_DAEMON_PORT2;
46246
46706
  } catch {
46247
- return DEFAULT_DAEMON_PORT;
46707
+ return DEFAULT_DAEMON_PORT2;
46248
46708
  }
46249
46709
  })();
46250
46710
  const candidates = new Set;
@@ -46418,9 +46878,9 @@ init_client();
46418
46878
  init_detect();
46419
46879
  init_run_task();
46420
46880
  import { Database as Database3 } from "bun:sqlite";
46421
- import { existsSync as existsSync16, mkdirSync as mkdirSync13, writeFileSync as writeFileSync11, unlinkSync as unlinkSync7 } from "fs";
46422
- import { homedir as homedir4 } from "os";
46423
- import { join as join17 } from "path";
46881
+ import { existsSync as existsSync17, mkdirSync as mkdirSync13, writeFileSync as writeFileSync11, unlinkSync as unlinkSync7 } from "fs";
46882
+ import { homedir } from "os";
46883
+ import { join as join18 } from "path";
46424
46884
  init_adapter_pidfile();
46425
46885
 
46426
46886
  // src/_impl/runs-projection.ts
@@ -46461,7 +46921,7 @@ function projectRun(row) {
46461
46921
  if (inline) {
46462
46922
  branch = str(p.base_branch);
46463
46923
  } else if (baseDir && slug) {
46464
- workingDir = join13(baseDir, ".multi", "worktrees", slug);
46924
+ workingDir = join13(baseDir, ".dayline", "worktrees", slug);
46465
46925
  branch = `multi/${slug}`;
46466
46926
  } else if (slug) {
46467
46927
  branch = `multi/${slug}`;
@@ -46783,7 +47243,7 @@ init_lib();
46783
47243
  // package.json
46784
47244
  var package_default2 = {
46785
47245
  name: "@shipers-dev/dayline",
46786
- version: "0.97.0",
47246
+ version: "0.100.0",
46787
47247
  type: "module",
46788
47248
  bin: {
46789
47249
  dayline: "./dist/index.js"
@@ -46792,7 +47252,7 @@ var package_default2 = {
46792
47252
  "dist"
46793
47253
  ],
46794
47254
  scripts: {
46795
- dev: "MULTI_HOME=${MULTI_HOME:-$HOME/.multi-dev} MULTI_API=${MULTI_API:-http://127.0.0.1:8787} bun run src/index.ts connect",
47255
+ dev: "DAYLINE_HOME=${DAYLINE_HOME:-$HOME/.dayline-dev} MULTI_API=${MULTI_API:-http://127.0.0.1:8787} bun run src/index.ts connect",
46796
47256
  build: "bun build src/index.ts --outdir=dist --target=node --sourcemap=none --external loro-crdt",
46797
47257
  test: "bun test",
46798
47258
  prepublishOnly: "bun run build",
@@ -46808,6 +47268,13 @@ var package_default2 = {
46808
47268
  },
46809
47269
  devDependencies: {
46810
47270
  "@multi/lib": "workspace:*"
47271
+ },
47272
+ optionalDependencies: {
47273
+ "@shipers-dev/dayline-chat-peer-darwin-arm64": "0.1.0",
47274
+ "@shipers-dev/dayline-chat-peer-darwin-x64": "0.1.0",
47275
+ "@shipers-dev/dayline-chat-peer-linux-x64": "0.1.0",
47276
+ "@shipers-dev/dayline-chat-peer-linux-arm64": "0.1.0",
47277
+ "@shipers-dev/dayline-chat-peer-win32-x64": "0.1.0"
46811
47278
  }
46812
47279
  };
46813
47280
 
@@ -46816,7 +47283,7 @@ var CLI_VERSION = package_default2.version;
46816
47283
  function findBunBinary() {
46817
47284
  const tryPath = (p) => {
46818
47285
  try {
46819
- return existsSync16(p) ? p : null;
47286
+ return existsSync17(p) ? p : null;
46820
47287
  } catch {
46821
47288
  return null;
46822
47289
  }
@@ -46830,7 +47297,7 @@ function findBunBinary() {
46830
47297
  if (fromWhich)
46831
47298
  return fromWhich;
46832
47299
  const candidates = [
46833
- join17(homedir4(), ".bun", "bin", "bun"),
47300
+ join18(homedir(), ".bun", "bin", "bun"),
46834
47301
  "/opt/homebrew/bin/bun",
46835
47302
  "/usr/local/bin/bun",
46836
47303
  "/home/linuxbrew/.linuxbrew/bin/bun"
@@ -46842,24 +47309,17 @@ function findBunBinary() {
46842
47309
  }
46843
47310
  return null;
46844
47311
  }
46845
- var MULTI_DIR5 = join17(homedir4(), ".multi");
46846
- var PID_PATH2 = join17(MULTI_DIR5, "agent.pid");
46847
- var PORT_PATH2 = join17(MULTI_DIR5, "agent.port");
46848
- var STOP_PATH2 = join17(MULTI_DIR5, "stop.flag");
46849
- var DAEMON_PORT = 47832;
46850
- var TASKS_DB_PATH3 = join17(MULTI_DIR5, "tasks.db");
46851
- var LOCAL_SERVER_DIR = process.env.MULTI_HOME || join17(homedir4(), ".multi");
46852
- var LOCAL_SERVER_PATH = join17(LOCAL_SERVER_DIR, "local-server.json");
47312
+ var LOCAL_SERVER_PATH = join18(DAYLINE_DIR, "local-server.json");
46853
47313
  function ensureDirs2() {
46854
- if (!existsSync16(MULTI_DIR5))
46855
- mkdirSync13(MULTI_DIR5, { recursive: true });
46856
- const logs = join17(MULTI_DIR5, "logs");
46857
- if (!existsSync16(logs))
47314
+ if (!existsSync17(DAYLINE_DIR))
47315
+ mkdirSync13(DAYLINE_DIR, { recursive: true });
47316
+ const logs = join18(DAYLINE_DIR, "logs");
47317
+ if (!existsSync17(logs))
46858
47318
  mkdirSync13(logs, { recursive: true });
46859
47319
  }
46860
47320
  function openTasksDb() {
46861
47321
  ensureDirs2();
46862
- const db2 = new Database3(TASKS_DB_PATH3);
47322
+ const db2 = new Database3(TASKS_DB_PATH);
46863
47323
  const existing = db2.query("PRAGMA table_info(tasks)").all();
46864
47324
  if (existing.length) {
46865
47325
  const have = new Set(existing.map((c) => c.name));
@@ -47024,8 +47484,8 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
47024
47484
  if (cfg.authToken)
47025
47485
  setAuthToken(cfg.authToken);
47026
47486
  ensureDirs2();
47027
- if (existsSync16(STOP_PATH2))
47028
- unlinkSync7(STOP_PATH2);
47487
+ if (existsSync17(STOP_PATH))
47488
+ unlinkSync7(STOP_PATH);
47029
47489
  const reaped = reapStaleAdapters((m) => log3(m));
47030
47490
  if (reaped > 0)
47031
47491
  log3(`reaped ${reaped} stale adapter${reaped === 1 ? "" : "s"}`);
@@ -47105,7 +47565,7 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
47105
47565
  probe.stop();
47106
47566
  },
47107
47567
  catch: () => new DaemonError({
47108
- message: `daemon port ${port} is already in use — stop whatever is bound to 127.0.0.1:${port} (if a stale daemon, remove ~/.multi/agent.pid)`
47568
+ message: `daemon port ${port} is already in use — stop whatever is bound to 127.0.0.1:${port} (if a stale daemon, remove ~/.dayline/agent.pid)`
47109
47569
  })
47110
47570
  });
47111
47571
  const server = Bun.serve({
@@ -47598,7 +48058,7 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
47598
48058
  deviceId: cfg.deviceId,
47599
48059
  log: log3
47600
48060
  });
47601
- const greet = peer.buildSnapshotGreet();
48061
+ const greet = await peer.buildSnapshotGreet();
47602
48062
  return new Response(greet.subarray(1), {
47603
48063
  headers: { "content-type": "application/octet-stream" }
47604
48064
  });
@@ -47623,7 +48083,7 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
47623
48083
  deviceId: cfg.deviceId,
47624
48084
  log: log3
47625
48085
  });
47626
- const messages = listMessages2(peer.getDoc());
48086
+ const messages = await peer.messages();
47627
48087
  return Response.json({ chat_id: chatId, messages });
47628
48088
  } catch (e) {
47629
48089
  const msg = e.message ?? String(e);
@@ -47679,7 +48139,7 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
47679
48139
  }
47680
48140
  };
47681
48141
  const body = new ReadableStream({
47682
- start(controller) {
48142
+ async start(controller) {
47683
48143
  const send = (frame) => {
47684
48144
  try {
47685
48145
  controller.enqueue(encoder.encode(frame));
@@ -47688,28 +48148,30 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
47688
48148
  teardown();
47689
48149
  }
47690
48150
  };
47691
- const reproject = () => {
48151
+ const reproject = async () => {
47692
48152
  try {
47693
- for (const changed of differ3.delta(listMessages2(peer.getDoc()))) {
48153
+ for (const changed of differ3.delta(await peer.messages())) {
47694
48154
  send(encodeSseEvent("message", changed));
47695
48155
  }
47696
48156
  } catch (e) {
47697
48157
  log3(`[chat-stream ${chatId}] reproject failed: ${e.message}`);
47698
48158
  }
47699
48159
  };
48160
+ let seeded = false;
47700
48161
  const scheduleReproject = () => {
47701
- if (done9 || coalesceTimer)
48162
+ if (done9 || !seeded || coalesceTimer)
47702
48163
  return;
47703
48164
  coalesceTimer = setTimeout(() => {
47704
48165
  coalesceTimer = null;
47705
48166
  reproject();
47706
48167
  }, 75);
47707
48168
  };
47708
- const messages = listMessages2(peer.getDoc());
48169
+ subscription = peer.addLocalSubscriber(scheduleReproject);
48170
+ const messages = await peer.messages();
47709
48171
  differ3.delta(messages);
48172
+ seeded = true;
47710
48173
  send(encodeSseEvent("snapshot", { chat_id: chatId, messages }));
47711
- subscription = peer.addLocalSubscriber(scheduleReproject);
47712
- catchupTimer = setTimeout(reproject, 1000);
48174
+ catchupTimer = setTimeout(() => void reproject(), 1000);
47713
48175
  ping = setInterval(() => {
47714
48176
  send(`: ping
47715
48177
 
@@ -47962,8 +48424,8 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
47962
48424
  if (!path || !path.startsWith("/")) {
47963
48425
  return Response.json({ ok: false, code: "bad_path", message: "absolute path required" }, { status: 400 });
47964
48426
  }
47965
- const { existsSync: existsSync17, statSync: statSync3, mkdirSync: mkdirSync14 } = await import("node:fs");
47966
- if (!existsSync17(path) || !statSync3(path).isDirectory()) {
48427
+ const { existsSync: existsSync18, statSync: statSync3, mkdirSync: mkdirSync14 } = await import("node:fs");
48428
+ if (!existsSync18(path) || !statSync3(path).isDirectory()) {
47967
48429
  return Response.json({ ok: false, code: "missing", message: "directory does not exist" }, { status: 404 });
47968
48430
  }
47969
48431
  const { spawn: spawn3 } = await import("node:child_process");
@@ -48058,7 +48520,7 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
48058
48520
  ws.data.peerToken = sub.token;
48059
48521
  ws.data.unsubscribe = sub.close;
48060
48522
  try {
48061
- ws.sendBinary(peer.buildSnapshotGreet());
48523
+ ws.sendBinary(await peer.buildSnapshotGreet());
48062
48524
  } catch {}
48063
48525
  },
48064
48526
  async message(ws, message) {
@@ -48095,10 +48557,10 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
48095
48557
  });
48096
48558
  log3(`Local server: http://127.0.0.1:${port}`);
48097
48559
  try {
48098
- writeFileSync11(PORT_PATH2, String(port));
48560
+ writeFileSync11(PORT_PATH, String(port));
48099
48561
  } catch {}
48100
48562
  try {
48101
- writeFileSync11(PID_PATH2, String(process.pid));
48563
+ writeFileSync11(PID_PATH, String(process.pid));
48102
48564
  } catch {}
48103
48565
  let funnelUrl = yield* exports_Effect.try({
48104
48566
  try: () => ensureFunnel(port),
@@ -48113,7 +48575,7 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
48113
48575
  yield* exports_Effect.forkIn(daemonScope)(exports_Effect.gen(function* () {
48114
48576
  while (true) {
48115
48577
  yield* exports_Effect.sleep(exports_Duration.seconds(150));
48116
- if (existsSync16(STOP_PATH2)) {
48578
+ if (existsSync17(STOP_PATH)) {
48117
48579
  yield* exports_Deferred.succeed(stopDeferred, "stop flag");
48118
48580
  return;
48119
48581
  }
@@ -48126,8 +48588,8 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
48126
48588
  }
48127
48589
  }).pipe(exports_Effect.catchAllCause((c) => exports_Effect.sync(() => log3(`funnel liveness crash: ${exports_Cause.pretty(c)}`)))));
48128
48590
  try {
48129
- if (!existsSync16(LOCAL_SERVER_DIR))
48130
- mkdirSync13(LOCAL_SERVER_DIR, { recursive: true });
48591
+ if (!existsSync17(DAYLINE_DIR))
48592
+ mkdirSync13(DAYLINE_DIR, { recursive: true });
48131
48593
  writeFileSync11(LOCAL_SERVER_PATH, JSON.stringify({
48132
48594
  url: `http://127.0.0.1:${port}`,
48133
48595
  port,
@@ -48157,7 +48619,7 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
48157
48619
  yield* exports_Effect.forkIn(daemonScope)(exports_Effect.gen(function* () {
48158
48620
  while (true) {
48159
48621
  yield* exports_Effect.sleep(exports_Duration.seconds(5));
48160
- if (existsSync16(STOP_PATH2)) {
48622
+ if (existsSync17(STOP_PATH)) {
48161
48623
  yield* exports_Deferred.succeed(stopDeferred, "stop flag");
48162
48624
  return;
48163
48625
  }
@@ -48200,13 +48662,13 @@ var daemonProgram = ({ cfg, apiUrl }) => exports_Effect.gen(function* () {
48200
48662
  log3(`adapter shutdown sweep failed: ${String(e)}`);
48201
48663
  }
48202
48664
  yield* exports_Scope.close(daemonScope, exports_Exit.void).pipe(exports_Effect.catchAll(() => exports_Effect.void));
48203
- if (existsSync16(PID_PATH2))
48204
- unlinkSync7(PID_PATH2);
48205
- if (existsSync16(STOP_PATH2))
48206
- unlinkSync7(STOP_PATH2);
48207
- if (existsSync16(PORT_PATH2))
48208
- unlinkSync7(PORT_PATH2);
48209
- if (existsSync16(LOCAL_SERVER_PATH))
48665
+ if (existsSync17(PID_PATH))
48666
+ unlinkSync7(PID_PATH);
48667
+ if (existsSync17(STOP_PATH))
48668
+ unlinkSync7(STOP_PATH);
48669
+ if (existsSync17(PORT_PATH))
48670
+ unlinkSync7(PORT_PATH);
48671
+ if (existsSync17(LOCAL_SERVER_PATH))
48210
48672
  unlinkSync7(LOCAL_SERVER_PATH);
48211
48673
  db2.close();
48212
48674
  log3("disconnected");
@@ -48224,15 +48686,15 @@ init_detect();
48224
48686
  init_outbox();
48225
48687
 
48226
48688
  // src/_impl/pair-flow.ts
48227
- import { existsSync as existsSync17, mkdirSync as mkdirSync14, writeFileSync as writeFileSync12 } from "fs";
48228
- import { homedir as homedir5 } from "os";
48229
- import { join as join18 } from "path";
48230
- var LOCAL_SERVER_DIR2 = process.env.MULTI_HOME || join18(homedir5(), ".multi");
48231
- var LOCAL_SERVER_PATH2 = join18(LOCAL_SERVER_DIR2, "local-server.json");
48689
+ import { existsSync as existsSync18, mkdirSync as mkdirSync14, writeFileSync as writeFileSync12 } from "fs";
48690
+ import { join as join19 } from "path";
48691
+ init_paths();
48692
+ var LOCAL_SERVER_DIR = daylineDir();
48693
+ var LOCAL_SERVER_PATH2 = join19(LOCAL_SERVER_DIR, "local-server.json");
48232
48694
  function writePairingInfo(payload) {
48233
48695
  try {
48234
- if (!existsSync17(LOCAL_SERVER_DIR2))
48235
- mkdirSync14(LOCAL_SERVER_DIR2, { recursive: true });
48696
+ if (!existsSync18(LOCAL_SERVER_DIR))
48697
+ mkdirSync14(LOCAL_SERVER_DIR, { recursive: true });
48236
48698
  writeFileSync12(LOCAL_SERVER_PATH2, JSON.stringify(payload, null, 2));
48237
48699
  } catch {}
48238
48700
  }
@@ -48367,15 +48829,15 @@ ${err?.stack ?? ""}`);
48367
48829
 
48368
48830
  // src/commands/service.ts
48369
48831
  init_esm();
48370
- import { existsSync as existsSync18, readFileSync as readFileSync13 } from "fs";
48371
- import { homedir as homedir6, platform, tmpdir } from "os";
48372
- import { join as join19 } from "path";
48832
+ import { existsSync as existsSync19, readFileSync as readFileSync13 } from "fs";
48833
+ import { homedir as homedir2, platform, tmpdir } from "os";
48834
+ import { join as join20 } from "path";
48373
48835
  init_errors();
48374
48836
  init_paths();
48375
48837
  var LABEL = "dev.shipers.multi.daemon";
48376
- var HOME5 = homedir6();
48377
- var PLIST_PATH = join19(HOME5, "Library", "LaunchAgents", `${LABEL}.plist`);
48378
- var SYSTEMD_UNIT_PATH = join19(HOME5, ".config", "systemd", "user", "multi-daemon.service");
48838
+ var HOME4 = homedir2();
48839
+ var PLIST_PATH = join20(HOME4, "Library", "LaunchAgents", `${LABEL}.plist`);
48840
+ var SYSTEMD_UNIT_PATH = join20(HOME4, ".config", "systemd", "user", "multi-daemon.service");
48379
48841
  var isMac = () => platform() === "darwin";
48380
48842
  var isLinux = () => platform() === "linux";
48381
48843
  var isRunningPid = (pid) => {
@@ -48388,7 +48850,7 @@ var isRunningPid = (pid) => {
48388
48850
  };
48389
48851
  var readPid = () => {
48390
48852
  try {
48391
- if (!existsSync18(PID_PATH))
48853
+ if (!existsSync19(PID_PATH))
48392
48854
  return null;
48393
48855
  const n = Number(readFileSync13(PID_PATH, "utf8").trim());
48394
48856
  return Number.isFinite(n) && n > 0 ? n : null;
@@ -48413,13 +48875,13 @@ function pickStableBinary(candidates, exists4) {
48413
48875
  return null;
48414
48876
  }
48415
48877
  function stableCandidates(fromWhich) {
48416
- const home = homedir6();
48878
+ const home = homedir2();
48417
48879
  return [
48418
48880
  fromWhich,
48419
- join19(home, ".bun/bin/dayline"),
48881
+ join20(home, ".bun/bin/dayline"),
48420
48882
  "/opt/homebrew/bin/dayline",
48421
48883
  "/usr/local/bin/dayline",
48422
- join19(home, ".npm-global/bin/dayline")
48884
+ join20(home, ".npm-global/bin/dayline")
48423
48885
  ];
48424
48886
  }
48425
48887
  var resolveBinary = exports_Effect.fn("service.resolveBinary")(function* () {
@@ -48427,7 +48889,7 @@ var resolveBinary = exports_Effect.fn("service.resolveBinary")(function* () {
48427
48889
  yield* exports_Effect.promise(() => proc.exited);
48428
48890
  const out = yield* exports_Effect.promise(() => new Response(proc.stdout).text());
48429
48891
  const fromWhich = out.trim();
48430
- const stable = pickStableBinary(stableCandidates(fromWhich), existsSync18);
48892
+ const stable = pickStableBinary(stableCandidates(fromWhich), existsSync19);
48431
48893
  if (stable)
48432
48894
  return stable;
48433
48895
  console.log("Installing @shipers-dev/dayline globally so the service has a stable binary…");
@@ -48439,7 +48901,7 @@ var resolveBinary = exports_Effect.fn("service.resolveBinary")(function* () {
48439
48901
  });
48440
48902
  yield* exports_Effect.promise(() => add6.exited);
48441
48903
  }
48442
- const afterInstall = pickStableBinary(stableCandidates(""), existsSync18);
48904
+ const afterInstall = pickStableBinary(stableCandidates(""), existsSync19);
48443
48905
  if (afterInstall)
48444
48906
  return afterInstall;
48445
48907
  return yield* exports_Effect.fail(new DaemonError({
@@ -48463,7 +48925,7 @@ var buildPlist = (binary, env) => {
48463
48925
  const envEntries = Object.entries(env).map(([k, v]) => ` <key>${k}</key>
48464
48926
  <string>${escapeXml(v)}</string>`).join(`
48465
48927
  `);
48466
- const logDir = join19(MULTI_DIR, "logs");
48928
+ const logDir = join20(DAYLINE_DIR, "logs");
48467
48929
  return `<?xml version="1.0" encoding="UTF-8"?>
48468
48930
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
48469
48931
  <plist version="1.0">
@@ -48480,11 +48942,11 @@ var buildPlist = (binary, env) => {
48480
48942
  <key>KeepAlive</key>
48481
48943
  <true/>
48482
48944
  <key>WorkingDirectory</key>
48483
- <string>${escapeXml(HOME5)}</string>
48945
+ <string>${escapeXml(HOME4)}</string>
48484
48946
  <key>StandardOutPath</key>
48485
- <string>${escapeXml(join19(logDir, "launchd.out.log"))}</string>
48947
+ <string>${escapeXml(join20(logDir, "launchd.out.log"))}</string>
48486
48948
  <key>StandardErrorPath</key>
48487
- <string>${escapeXml(join19(logDir, "launchd.err.log"))}</string>
48949
+ <string>${escapeXml(join20(logDir, "launchd.err.log"))}</string>
48488
48950
  <key>EnvironmentVariables</key>
48489
48951
  <dict>
48490
48952
  ${envEntries}
@@ -48508,7 +48970,7 @@ Type=simple
48508
48970
  ExecStart=${binary} connect
48509
48971
  Restart=always
48510
48972
  RestartSec=3
48511
- WorkingDirectory=${HOME5}
48973
+ WorkingDirectory=${HOME4}
48512
48974
  ${envLines}
48513
48975
 
48514
48976
  [Install]
@@ -48542,7 +49004,7 @@ var installMac = exports_Effect.fn("service.installMac")(function* (binary) {
48542
49004
  const fs3 = yield* FileSystem;
48543
49005
  const env = collectServiceEnv();
48544
49006
  const plist = buildPlist(binary, env);
48545
- yield* fs3.mkdirp(join19(MULTI_DIR, "logs"));
49007
+ yield* fs3.mkdirp(join20(DAYLINE_DIR, "logs"));
48546
49008
  yield* fs3.writeText(PLIST_PATH, plist);
48547
49009
  yield* run6("launchctl", ["unload", PLIST_PATH]).pipe(exports_Effect.ignore);
48548
49010
  yield* run6("launchctl", ["load", "-w", PLIST_PATH]);
@@ -48553,7 +49015,7 @@ var installLinux = exports_Effect.fn("service.installLinux")(function* (binary)
48553
49015
  const fs3 = yield* FileSystem;
48554
49016
  const env = collectServiceEnv();
48555
49017
  const unit = buildSystemdUnit(binary, env);
48556
- yield* fs3.mkdirp(join19(MULTI_DIR, "logs"));
49018
+ yield* fs3.mkdirp(join20(DAYLINE_DIR, "logs"));
48557
49019
  yield* fs3.writeText(SYSTEMD_UNIT_PATH, unit);
48558
49020
  yield* run6("systemctl", ["--user", "daemon-reload"]);
48559
49021
  yield* run6("systemctl", ["--user", "enable", "--now", "multi-daemon.service"]);
@@ -48563,7 +49025,7 @@ var installLinux = exports_Effect.fn("service.installLinux")(function* (binary)
48563
49025
  });
48564
49026
  var uninstallMac = exports_Effect.fn("service.uninstallMac")(function* () {
48565
49027
  const fs3 = yield* FileSystem;
48566
- if (existsSync18(PLIST_PATH)) {
49028
+ if (existsSync19(PLIST_PATH)) {
48567
49029
  yield* run6("launchctl", ["unload", PLIST_PATH]).pipe(exports_Effect.ignore);
48568
49030
  yield* fs3.remove(PLIST_PATH);
48569
49031
  console.log(`\uD83D\uDDD1 Removed ${PLIST_PATH}`);
@@ -48573,7 +49035,7 @@ var uninstallMac = exports_Effect.fn("service.uninstallMac")(function* () {
48573
49035
  });
48574
49036
  var uninstallLinux = exports_Effect.fn("service.uninstallLinux")(function* () {
48575
49037
  const fs3 = yield* FileSystem;
48576
- if (existsSync18(SYSTEMD_UNIT_PATH)) {
49038
+ if (existsSync19(SYSTEMD_UNIT_PATH)) {
48577
49039
  yield* run6("systemctl", ["--user", "disable", "--now", "multi-daemon.service"]).pipe(exports_Effect.ignore);
48578
49040
  yield* fs3.remove(SYSTEMD_UNIT_PATH);
48579
49041
  yield* run6("systemctl", ["--user", "daemon-reload"]).pipe(exports_Effect.ignore);
@@ -48602,7 +49064,7 @@ var serviceCmd = exports_Effect.fn("serviceCmd")(function* (sub) {
48602
49064
  }
48603
49065
  case "start": {
48604
49066
  if (isMac()) {
48605
- if (!existsSync18(PLIST_PATH)) {
49067
+ if (!existsSync19(PLIST_PATH)) {
48606
49068
  return yield* exports_Effect.fail(new DaemonError({
48607
49069
  message: "Not installed. Run: dayline service install"
48608
49070
  }));
@@ -48628,7 +49090,7 @@ var serviceCmd = exports_Effect.fn("serviceCmd")(function* (sub) {
48628
49090
  }
48629
49091
  case "status":
48630
49092
  case undefined: {
48631
- const installed = isMac() ? existsSync18(PLIST_PATH) : existsSync18(SYSTEMD_UNIT_PATH);
49093
+ const installed = isMac() ? existsSync19(PLIST_PATH) : existsSync19(SYSTEMD_UNIT_PATH);
48632
49094
  const pid = readPid();
48633
49095
  const running3 = pid !== null && isRunningPid(pid);
48634
49096
  console.log(`Service: ${isMac() ? "launchd" : "systemd --user"}`);