cyberlegion 1.9.0 → 2.0.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.d.mts CHANGED
@@ -1,7 +1,6 @@
1
- import { Exec, Exec as Exec$1, MuxAdapter, MuxPlacement, MuxProbe, NudgeOptions, probeMultiplexer } from "cyber-mux";
1
+ import { Exec, Exec as Exec$2, MuxAdapter, MuxPlacement, MuxProbe, NudgeOptions, probeMultiplexer } from "cyber-mux";
2
2
  import { assertDistinctFromPrimary, gitWorktreeAdapter, resolvePrimaryRoot } from "cyber-mux/worktree";
3
3
  import { ReleaseResult } from "cyber-agentkit/worktrees";
4
- //#region src/store/store.d.ts
5
4
  interface Message {
6
5
  id: string;
7
6
  from: string;
@@ -40,11 +39,25 @@ interface AgentRecord {
40
39
  holder: string;
41
40
  };
42
41
  } | null;
42
+ /** A checkout the unit works in but does not own: a `--cwd` spawn into an existing checkout, or a
43
+ * session registered in a worktree another unit's record owns. `owner` is that unit's id, when one
44
+ * owned the root at the time of recording. Close never removes, prunes, or releases it — it is read
45
+ * only, so a sweep can judge the unit by the work there. Absent on records from before it existed. */
46
+ sharedWorktree?: {
47
+ root: string;
48
+ branch?: string;
49
+ primaryRoot?: string;
50
+ owner?: string;
51
+ };
43
52
  /** Where this session lives, tagged with its multiplexer so `prune` runs the right liveness check.
44
- * `null` for a session in no pane and for a standing record. `window`/`session` are tmux-only. */
53
+ * `null` for a session in no pane and for a standing record. `window`/`session` are tmux-only.
54
+ * `terminal` is herdr-only: the pane's herdr terminal id, which survives a `herdr pane move` that
55
+ * gives the pane a new id (#272), so prune and touch follow a moved pane by it. Absent on records
56
+ * written before it existed, which are judged by `id` alone. */
45
57
  pane?: {
46
58
  mux: 'tmux' | 'herdr';
47
59
  id: string;
60
+ terminal?: string;
48
61
  window?: string;
49
62
  session?: string;
50
63
  } | null;
@@ -218,13 +231,11 @@ interface Store extends MailboxStore {
218
231
  /** `withLock` held across an async `fn` until its promise settles (`store/lock.ts`). */
219
232
  withLockAsync<T>(name: string, fn: () => Promise<T>): Promise<T>;
220
233
  }
221
- //#endregion
222
- //#region src/identity.d.ts
223
- export declare const realExec: Exec$1;
234
+ export declare const realExec: Exec$2;
224
235
  interface IdContext {
225
236
  store: Store;
226
237
  env?: NodeJS.ProcessEnv;
227
- exec?: Exec$1;
238
+ exec?: Exec$2;
228
239
  now?: () => number;
229
240
  /** The argv that re-invokes this very CLI — node, its loader flags, and the entry script
230
241
  * (`selfInvocation`). `unit spawn` puts a `cyberlegion` shim over it on the new session's PATH,
@@ -259,15 +270,25 @@ export declare function resolveRecipient(store: Store, to: string): string;
259
270
  */
260
271
  export declare function resolveAgent(store: Store, ref: string): AgentRecord;
261
272
  export declare function bumpLastSeen(ctx: IdContext, id: string): void;
262
- /** Refresh this session's own last-seen if it is registered — best-effort, never throws. */
273
+ /**
274
+ * Refresh this session's own last-seen if it is registered — best-effort, never throws. In a herdr
275
+ * pane whose calling pane herdr reported, it also heals the record's pane to the id and terminal
276
+ * herdr gave, so a unit whose pane moved fixes its own record on its next turn (#272).
277
+ */
263
278
  export declare function touch(ctx: IdContext): void;
264
- /** Mark agents whose session is gone as exited. Reconcile-culls against the current mux's live set
265
- * first, then judges each remaining record (covers the other mux and sessions outside any
266
- * multiplexer pane): a pane-bound record by its pane alone — a live or unprobeable pane keeps it
267
- * whatever its last-seen — and a pane-less record by the staleness timer, its only signal. */
268
- export declare function prune(ctx: IdContext): AgentRecord[];
269
- //#endregion
270
- //#region src/agentdef/resolve.d.ts
279
+ /** A record `prune` changed: `exited` when it was marked and kept, `deleted` when it was removed. */
280
+ type PrunedRecord = AgentRecord & {
281
+ pruned: 'exited' | 'deleted';
282
+ };
283
+ /**
284
+ * Mark agents whose session is gone as exited, then delete every exited unit with nothing left to
285
+ * work from. Reconcile-culls against the current mux's live set first, then judges each remaining
286
+ * record (covers the other mux and sessions outside any multiplexer pane): a pane-bound record by its
287
+ * pane alone — a live or unprobeable pane keeps it whatever its last-seen — and a pane-less record by
288
+ * the staleness timer, its only signal. An exited unit whose worktree is still on disk is kept, since
289
+ * `unit close` owns removing that worktree; every other exited unit is deleted with `deleteExited`.
290
+ */
291
+ export declare function prune(ctx: IdContext): PrunedRecord[];
271
292
  interface AgentDef {
272
293
  name: string;
273
294
  description?: string;
@@ -298,8 +319,6 @@ export declare function listAgentDefs(input?: {
298
319
  cwd?: string;
299
320
  searchRoots?: string[];
300
321
  }): AgentDef[];
301
- //#endregion
302
- //#region src/agentdef/realize.d.ts
303
322
  interface RealizeLaunchOptions {
304
323
  /** Overrides def.model when present. */
305
324
  model?: string;
@@ -330,8 +349,6 @@ interface RealizedLaunch {
330
349
  * def's own tags, which win over the harness default. The def's effort and instructions each go
331
350
  * through the harness's own control (see `cursorModel`, `modelAndEffortArgs`, `instructionArgs`). */
332
351
  export declare function realizeLaunch(def: AgentDef, opts?: RealizeLaunchOptions): RealizedLaunch;
333
- //#endregion
334
- //#region src/decommission.d.ts
335
352
  interface DecommissionInput {
336
353
  id: string;
337
354
  /** Discard uncommitted changes in the worktree. Refused for a unit on the primary checkout, which close never alters. */
@@ -383,8 +400,6 @@ interface DecommissionResult {
383
400
  * is not reported as retained: it is no pool path a next unit could be spawned into.
384
401
  */
385
402
  export declare function decommission(ctx: IdContext, input: DecommissionInput): Promise<DecommissionResult>;
386
- //#endregion
387
- //#region src/runtime/inject-inbox.d.ts
388
403
  type HookEvent = 'SessionStart';
389
404
  interface InjectPayload {
390
405
  hookSpecificOutput: {
@@ -402,8 +417,6 @@ interface InjectPayload {
402
417
  * firing in the child (`unit/lifecycle`, superseding ADR-0027).
403
418
  */
404
419
  export declare function injectInbox(ctx: IdContext, event: string): InjectPayload | null;
405
- //#endregion
406
- //#region src/install.d.ts
407
420
  type RetiredEvent = 'PostToolUse';
408
421
  type InstallStatus = 'registered' | 'already present' | 'provided by plugin' | 'removed project hook';
409
422
  interface InstallResult {
@@ -418,8 +431,6 @@ interface InstallResult {
418
431
  * plugin ships it (removing an earlier project copy), otherwise register the PATH-first project hook.
419
432
  */
420
433
  export declare function install(harness: Harness, projectDir?: string, pin?: string): InstallResult[];
421
- //#endregion
422
- //#region src/message.d.ts
423
434
  interface MsgContext {
424
435
  store: Store;
425
436
  now?: () => number;
@@ -454,8 +465,6 @@ export declare function peek(ctx: MsgContext, meId: string, msgId: string): Mess
454
465
  export declare function ack(ctx: MsgContext, meId: string, msgId: string): Message;
455
466
  /** Permanently remove a message (unread or already-acked) from the caller's inbox. */
456
467
  export declare function deleteMessage(ctx: MsgContext, meId: string, msgId: string): void;
457
- //#endregion
458
- //#region src/mux-select.d.ts
459
468
  /**
460
469
  * Backend selection via cyber-mux's two-mode mux probe, normalized through the transitional
461
470
  * `$CYBERLEGION_MUX*` → `$CYBER_MUX*` env seam (`mux-env.ts`) — tmux/herdr map to their existing
@@ -469,8 +478,6 @@ export declare function deleteMessage(ctx: MsgContext, meId: string, msgId: stri
469
478
  * `screen`) falls through to the plain "no backend" refusal, unchanged from before the migration.
470
479
  */
471
480
  export declare function selectSessionAdapter(env: NodeJS.ProcessEnv, exec?: Exec): MuxAdapter;
472
- //#endregion
473
- //#region src/output.d.ts
474
481
  type Format = 'toon' | 'json';
475
482
  /** One TOON-encoded object: `key: value` lines, blank/undefined fields dropped. */
476
483
  export declare function toonObject(fields: Record<string, unknown>): string;
@@ -492,18 +499,16 @@ export declare function emit(format: Format, payload: EmitPayload): void;
492
499
  export declare function nextStep(msg: string): void;
493
500
  /** A structured, fail-loud error: stderr + exit 1. Never prompts, never partially writes. */
494
501
  export declare function fail(msg: string): never;
495
- //#endregion
496
- //#region src/paths.d.ts
497
502
  /** Walk up from `cwd` to the nearest git repo root; fall back to `cwd`. */
498
503
  export declare function projectRoot(cwd?: string): string;
499
504
  /** Runs a command synchronously in `cwd`; returns trimmed stdout, or null on any failure. */
500
- type Exec$2 = (cmd: string, args: string[]) => string | null;
505
+ type Exec$1 = (cmd: string, args: string[]) => string | null;
501
506
  interface RootOptions {
502
507
  root?: string;
503
508
  space?: string;
504
509
  cwd?: string;
505
510
  env?: NodeJS.ProcessEnv;
506
- exec?: Exec$2;
511
+ exec?: Exec$1;
507
512
  }
508
513
  /**
509
514
  * Resolve the cyberlegion hub root. Precedence: explicit --root/--space, then `$CYBERLEGION_ROOT`,
@@ -545,8 +550,6 @@ export declare const paths: {
545
550
  messageFile: (root: string, toId: string, msgId: string) => string;
546
551
  messageReadFile: (root: string, toId: string, msgId: string) => string;
547
552
  };
548
- //#endregion
549
- //#region src/project.d.ts
550
553
  interface ProjectContext {
551
554
  store: Store;
552
555
  exec?: Exec;
@@ -568,8 +571,6 @@ export declare function listProjects(store: Store): ProjectRecord[];
568
571
  * and an ambiguous name names its candidates rather than picking one.
569
572
  */
570
573
  export declare function resolveProject(ctx: ProjectContext, ref: string): ProjectRecord;
571
- //#endregion
572
- //#region src/service.d.ts
573
574
  interface ServiceContext extends IdContext {
574
575
  /** Whether a unit's session is still there. Defaults to asking its multiplexer (`sessionLive`). */
575
576
  isLive?: (unit: AgentRecord) => boolean;
@@ -707,8 +708,6 @@ type StartResult<T> = {
707
708
  export declare function startService<T extends {
708
709
  unit: string;
709
710
  }>(ctx: ServiceContext, projectRef: string, name: string, input: StartInput<T>): Promise<StartResult<T>>;
710
- //#endregion
711
- //#region src/console/trust.d.ts
712
711
  interface TrustOptions {
713
712
  /** Time between screen reads. */
714
713
  pollMs?: number;
@@ -748,8 +747,6 @@ type TrustOutcome =
748
747
  state: 'stuck';
749
748
  message: string;
750
749
  };
751
- //#endregion
752
- //#region src/session.d.ts
753
750
  interface SpawnInput {
754
751
  harness?: string;
755
752
  task?: string;
@@ -856,8 +853,6 @@ interface FirstTurn {
856
853
  trust: TrustOutcome['state'];
857
854
  trustBlocked?: string;
858
855
  }
859
- //#endregion
860
- //#region src/store/file-store.d.ts
861
856
  /** The on-disk `Store` implementation — current per-writer sharded `.json` layout (ADR-0020):
862
857
  * one file per message/agent, collision-free filenames, ack = atomic rename into `read/`. */
863
858
  export declare class FileStore implements Store {
@@ -891,8 +886,6 @@ export declare class FileStore implements Store {
891
886
  withLock<T>(name: string, fn: () => T): T;
892
887
  withLockAsync<T>(name: string, fn: () => Promise<T>): Promise<T>;
893
888
  }
894
- //#endregion
895
- //#region src/wake/await.d.ts
896
889
  interface AwaitInput {
897
890
  meId: string;
898
891
  thread: string;
@@ -925,8 +918,6 @@ type AwaitOutcome = {
925
918
  * elapsed across re-arms with no match. The caller should exit non-zero.
926
919
  */
927
920
  export declare function awaitReply(ctx: MsgContext, input: AwaitInput): Promise<AwaitOutcome>;
928
- //#endregion
929
- //#region src/wake/watch.d.ts
930
921
  interface WatchInput {
931
922
  meId: string;
932
923
  thread?: string;
@@ -943,5 +934,4 @@ interface WatchOptions {
943
934
  * `watch` prints stays unread and still surfaces later in `mail inbox`/`mail await`.
944
935
  */
945
936
  export declare function watchMail(ctx: MsgContext, input: WatchInput, onMessage: (msg: InboxItem) => void, opts?: WatchOptions): Promise<void>;
946
- //#endregion
947
937
  export { type AcquireInput, type AcquireResult, type AgentDef, type AgentRecord, type AwaitInput, type AwaitOutcome, type DecommissionInput, type DecommissionResult, type Exec, type Format, type Harness, type HookEvent, type IdContext, type InboxItem, type InboxQuery, type InboxSnapshot, type Message, type MuxProbe, type OwnershipErrorCode, type ProjectContext, type ProjectRecord, type RegisterInput, type RootOptions, type SendInput, type ServiceContext, type ServiceHealth, type ServiceLease, type ServiceView, type SpawnInput, type SpawnResult, type StartInput, type StartResult, type Store, assertDistinctFromPrimary, gitWorktreeAdapter, probeMultiplexer, resolvePrimaryRoot };