@staff0rd/assist 0.536.0 → 0.538.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.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.536.0",
9
+ version: "0.538.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -22601,7 +22601,8 @@ function requestClaudeSession(prompt, cwd, options2) {
22601
22601
  type: "create",
22602
22602
  prompt,
22603
22603
  cwd,
22604
- inPlace: options2?.inPlace === true
22604
+ inPlace: options2?.inPlace === true,
22605
+ launchedFrom: options2?.launchedFrom ?? process.env.ASSIST_SESSION_ID
22605
22606
  });
22606
22607
  }
22607
22608
 
@@ -30632,7 +30633,7 @@ function createSession(id, prompt, cwd, design, harness, holdPty) {
30632
30633
  design
30633
30634
  };
30634
30635
  }
30635
- function createRunSession(id, { runName, runArgs, cwd, meta, launchedFrom }) {
30636
+ function createRunSession(id, { runName, runArgs, cwd, meta }) {
30636
30637
  const serverMeta = meta ?? serverRunMeta(runName, cwd);
30637
30638
  return {
30638
30639
  ...sessionBase(id, "running"),
@@ -30642,7 +30643,6 @@ function createRunSession(id, { runName, runArgs, cwd, meta, launchedFrom }) {
30642
30643
  runName,
30643
30644
  runArgs,
30644
30645
  cwd,
30645
- launchedFrom,
30646
30646
  server: serverMeta.server || void 0,
30647
30647
  serverPort: serverMeta.port,
30648
30648
  serverOrigin: serverMeta.origin
@@ -32033,7 +32033,8 @@ function wireSessionWatchers(session, notify2, onStatusChange) {
32033
32033
  }
32034
32034
 
32035
32035
  // src/commands/sessions/daemon/registerSpawnedSession.ts
32036
- function registerSpawnedSession(session, sessions, clients, onStatusChange, notify2) {
32036
+ function registerSpawnedSession(session, sessions, clients, onStatusChange, notify2, context) {
32037
+ if (context?.launchedFrom) session.launchedFrom = context.launchedFrom;
32037
32038
  sessions.set(session.id, session);
32038
32039
  wirePtyEvents(session, clients, onStatusChange);
32039
32040
  notify2();
@@ -32076,12 +32077,13 @@ var sessionLimits = {
32076
32077
 
32077
32078
  // src/commands/sessions/daemon/makeSessionSpawner.ts
32078
32079
  function makeSessionSpawner(sessions, clients, counter, onStatusChange, notify2) {
32079
- const register = (allocateId) => (create) => registerSpawnedSession(
32080
+ const register = (allocateId) => (create, context) => registerSpawnedSession(
32080
32081
  create(allocateId()),
32081
32082
  sessions,
32082
32083
  clients,
32083
32084
  onStatusChange(),
32084
- notify2
32085
+ notify2,
32086
+ context
32085
32087
  );
32086
32088
  return {
32087
32089
  spawn: register(() => sessionLimits.nextId(sessions.size, counter)),
@@ -33241,6 +33243,7 @@ function resetCardForRun(session, assistArgs) {
33241
33243
  session.usageSeeded = false;
33242
33244
  setStatus2(session, "running");
33243
33245
  session.restored = void 0;
33246
+ session.launchedFrom = void 0;
33244
33247
  }
33245
33248
 
33246
33249
  // src/commands/sessions/daemon/startReusedRunPty.ts
@@ -33321,16 +33324,19 @@ function releaseReason(durability, session) {
33321
33324
  }
33322
33325
 
33323
33326
  // src/commands/sessions/daemon/worktree/allocateAndBind.ts
33324
- function allocateAndBind(ctx, cwd, create, options2 = {}) {
33327
+ function allocateAndBind(ctx, cwd, create, options2 = {}, context) {
33325
33328
  const alloc = allocateTree(cwd, boundTreeRoots(ctx.sessions), options2);
33326
33329
  const needsSeeding = alloc.kind === "worktree" && alloc.created === true;
33327
- const id = ctx.spawnWith((sid) => create(sid, alloc.cwd, needsSeeding));
33330
+ const id = ctx.spawnWith(
33331
+ (sid) => create(sid, alloc.cwd, needsSeeding),
33332
+ context
33333
+ );
33328
33334
  bindNewWorktree(ctx.sessions.get(id), alloc, ctx.notify, ctx.startHeld);
33329
33335
  return id;
33330
33336
  }
33331
33337
 
33332
33338
  // src/commands/sessions/daemon/worktree/ensureWatcher.ts
33333
- function ensureWatcher(ctx, cwd) {
33339
+ function ensureWatcher(ctx, cwd, launchedFrom) {
33334
33340
  if (!cwd) return void 0;
33335
33341
  const repoRoot2 = findRepoRoot(cwd) ?? cwd;
33336
33342
  const cfg = worktreeConfigFor(repoRoot2);
@@ -33347,7 +33353,8 @@ function ensureWatcher(ctx, cwd) {
33347
33353
  ctx,
33348
33354
  clone,
33349
33355
  (sid, resolvedCwd) => createWatcherSession(sid, resolvedCwd ?? clone),
33350
- { inPlace: true }
33356
+ { inPlace: true },
33357
+ { launchedFrom }
33351
33358
  );
33352
33359
  daemonLog(
33353
33360
  `spawned watcher session ${id} running /watch in the clone ${clone}`
@@ -33441,7 +33448,7 @@ function reuseSessionForRun(session, itemId2, clients, onStatusChange, tree) {
33441
33448
  onStatusChange
33442
33449
  );
33443
33450
  if (!started) return;
33444
- if (tree) ensureWatcher(tree, originCwd);
33451
+ if (tree) ensureWatcher(tree, originCwd, session.id);
33445
33452
  attachReusedRun(session, alloc, clients, onStatusChange, tree);
33446
33453
  daemonLog(
33447
33454
  `session ${session.id} reused for backlog run ${itemId2}: ${session.name}`
@@ -33764,7 +33771,7 @@ async function forwardWindowsCreate(conn, state, client, data) {
33764
33771
  }
33765
33772
  function stripOutboundSessionId(data) {
33766
33773
  const stripped = { ...data };
33767
- for (const key of ["sessionId", "joinSessionId"])
33774
+ for (const key of ["sessionId", "joinSessionId", "launchedFrom"])
33768
33775
  if (typeof stripped[key] === "string")
33769
33776
  stripped[key] = stripWindowsSessionId(stripped[key]);
33770
33777
  return stripped;
@@ -34237,7 +34244,8 @@ function joinableStream(sessions, targetId) {
34237
34244
  function spawnIntoStream(ctx, target, prompt, harness) {
34238
34245
  const holdUntilSeeded = target.pendingStart !== void 0;
34239
34246
  const id = ctx.spawnWith(
34240
- (sid) => createSession(sid, prompt, target.cwd, false, harness, holdUntilSeeded)
34247
+ (sid) => createSession(sid, prompt, target.cwd, false, harness, holdUntilSeeded),
34248
+ { launchedFrom: target.id }
34241
34249
  );
34242
34250
  const joined = ctx.sessions.get(id);
34243
34251
  if (joined && target.worktree) joined.worktree = { ...target.worktree };
@@ -34283,8 +34291,7 @@ function createAssistSession(id, assistArgs, cwd, meta, holdPty) {
34283
34291
  ),
34284
34292
  scrollback: "",
34285
34293
  assistArgs,
34286
- cwd,
34287
- launchedFrom: meta?.launchedFrom
34294
+ cwd
34288
34295
  };
34289
34296
  }
34290
34297
 
@@ -34380,15 +34387,16 @@ function cloneForReapedTree(missingCwd) {
34380
34387
  }
34381
34388
 
34382
34389
  // src/commands/sessions/daemon/worktree/spawnInTree.ts
34383
- function spawnInTree(ctx, prompt, cwd, design, harness, inPlace) {
34390
+ function spawnInTree(ctx, { prompt, cwd, design, harness, inPlace }, context) {
34384
34391
  return allocateAndBind(
34385
34392
  ctx,
34386
34393
  cwd,
34387
34394
  (sid, resolvedCwd, holdUntilSeeded) => createSession(sid, prompt, resolvedCwd, design, harness, holdUntilSeeded),
34388
- { inPlace }
34395
+ { inPlace },
34396
+ context
34389
34397
  );
34390
34398
  }
34391
- function spawnAssistInTree(ctx, assistArgs, cwd, meta) {
34399
+ function spawnAssistInTree(ctx, assistArgs, cwd, meta, context) {
34392
34400
  const id = allocateAndBind(
34393
34401
  ctx,
34394
34402
  cwd,
@@ -34398,9 +34406,10 @@ function spawnAssistInTree(ctx, assistArgs, cwd, meta) {
34398
34406
  commits: isCommittingArgs(assistArgs),
34399
34407
  draftLike: isDraftCommand(assistArgs[0]),
34400
34408
  inPlace: meta?.inPlace
34401
- }
34409
+ },
34410
+ context
34402
34411
  );
34403
- if (isBacklogRunArgs(assistArgs)) ensureWatcher(ctx, cwd);
34412
+ if (isBacklogRunArgs(assistArgs)) ensureWatcher(ctx, cwd, id);
34404
34413
  return id;
34405
34414
  }
34406
34415
  function resumeInTree(ctx, sessionId, cwd, name) {
@@ -34530,20 +34539,20 @@ var SessionManager = class {
34530
34539
  this.onStatusChange
34531
34540
  );
34532
34541
  }
34533
- spawn(prompt, cwd, design, harness, inPlace) {
34534
- return spawnInTree(this.treeCtx(), prompt, cwd, design, harness, inPlace);
34542
+ spawn(request = {}, context) {
34543
+ return spawnInTree(this.treeCtx(), request, context);
34535
34544
  }
34536
34545
  addAgent(targetId, prompt, harness) {
34537
34546
  return addAgentToStream(this.treeCtx(), targetId, prompt, harness);
34538
34547
  }
34539
- spawnRun(request) {
34540
- return this.spawnWith((id) => createRunSession(id, request));
34548
+ spawnRun(request, context) {
34549
+ return this.spawnWith((id) => createRunSession(id, request), context);
34541
34550
  }
34542
34551
  liveServerRun(origin, excludeId) {
34543
34552
  return liveServerRun(this.sessions, origin, excludeId);
34544
34553
  }
34545
- spawnAssist(assistArgs, cwd, meta) {
34546
- return spawnAssistInTree(this.treeCtx(), assistArgs, cwd, meta);
34554
+ spawnAssist(assistArgs, cwd, meta, context) {
34555
+ return spawnAssistInTree(this.treeCtx(), assistArgs, cwd, meta, context);
34547
34556
  }
34548
34557
  resume(sessionId, cwd, name) {
34549
34558
  return resumeInTree(this.treeCtx(), sessionId, cwd, name);
@@ -34644,13 +34653,20 @@ function creator(isNew, spawn13) {
34644
34653
  };
34645
34654
  }
34646
34655
 
34656
+ // src/commands/sessions/daemon/spawnContextFrom.ts
34657
+ function spawnContextFrom(d) {
34658
+ return {
34659
+ launchedFrom: d.launchedFrom ?? d.joinSessionId
34660
+ };
34661
+ }
34662
+
34647
34663
  // src/commands/sessions/daemon/handleCreateRun.ts
34648
34664
  function handleCreateRun(client, m, d) {
34649
34665
  if (m.windowsProxy.route(client, d)) return;
34650
34666
  const runName = d.runName;
34651
34667
  const cwd = d.cwd;
34652
34668
  const runArgs = d.runArgs ?? [];
34653
- const launchedFrom = d.launchedFrom;
34669
+ const context = spawnContextFrom(d);
34654
34670
  const meta = serverRunMeta(runName, cwd);
34655
34671
  if (meta.server && meta.origin) {
34656
34672
  const existing = m.liveServerRun(meta.origin);
@@ -34662,7 +34678,7 @@ function handleCreateRun(client, m, d) {
34662
34678
  type: "run-conflict",
34663
34679
  runName,
34664
34680
  cwd,
34665
- launchedFrom,
34681
+ launchedFrom: context.launchedFrom,
34666
34682
  existing: serverConflictInfo(existing)
34667
34683
  });
34668
34684
  return;
@@ -34676,7 +34692,7 @@ function handleCreateRun(client, m, d) {
34676
34692
  }
34677
34693
  sendTo(client, {
34678
34694
  type: "created",
34679
- sessionId: m.spawnRun({ runName, runArgs, cwd, meta, launchedFrom }),
34695
+ sessionId: m.spawnRun({ runName, runArgs, cwd, meta }, context),
34680
34696
  isNew: true
34681
34697
  });
34682
34698
  }
@@ -34795,11 +34811,14 @@ function spawnCreate(m, d) {
34795
34811
  );
34796
34812
  }
34797
34813
  return m.spawn(
34798
- prompt,
34799
- d.cwd,
34800
- design,
34801
- harness,
34802
- d.inPlace === true
34814
+ {
34815
+ prompt,
34816
+ cwd: d.cwd,
34817
+ design,
34818
+ harness,
34819
+ inPlace: d.inPlace === true
34820
+ },
34821
+ spawnContextFrom(d)
34803
34822
  );
34804
34823
  }
34805
34824
 
@@ -34823,9 +34842,9 @@ var messageHandlers = {
34823
34842
  {
34824
34843
  title: d.title,
34825
34844
  subtitle: d.subtitle,
34826
- inPlace: d.inPlace === true,
34827
- launchedFrom: d.launchedFrom
34828
- }
34845
+ inPlace: d.inPlace === true
34846
+ },
34847
+ spawnContextFrom(d)
34829
34848
  )
34830
34849
  ),
34831
34850
  resume: creator(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.536.0",
3
+ "version": "0.538.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {