instar 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiQH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAwnDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA66KtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiQH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAwnDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA68KtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
@@ -1947,39 +1947,13 @@ export async function startServer(options) {
1947
1947
  console.log(pc.red(` Port conflict: ${err instanceof Error ? err.message : err}`));
1948
1948
  process.exit(1);
1949
1949
  }
1950
- // Agent worktree convention (Layer 4) — detect worktrees of the
1951
- // shared instar repo that live outside any agent's `.worktrees/`
1952
- // safe area. Signal-only: emits an AttentionItem (or appends to the
1953
- // JSONL fallback when no Telegram adapter is configured) per
1954
- // misplaced entry; never blocks, never moves. Dedupe is via the
1955
- // AttentionQueue's item.id collision (Telegram path) or 24h
1956
- // rolling-window file read (JSONL fallback).
1957
- try {
1958
- const detector = await import('../core/AgentWorktreeDetector.js');
1959
- const repo = detector.resolveDetectorInstarRepo();
1960
- if (repo) {
1961
- const safeRoots = detector.enumerateSafeRoots();
1962
- const detectionResult = await detector.runDetection({
1963
- instarRepo: repo,
1964
- stateDir: config.stateDir,
1965
- safeRoots,
1966
- // No `emitAttention` adapter wired here yet — TelegramAdapter
1967
- // initializes later in this same startServer. The JSONL
1968
- // fallback at `<stateDir>/audit/worktree-detector.jsonl` is the
1969
- // durable trail for v1; an explicit AttentionQueue wireup is a
1970
- // tracked follow-up (Layer 4 spec residual R-?).
1971
- });
1972
- if (detectionResult.emitted > 0) {
1973
- console.log(pc.yellow(` Worktree detector: ${detectionResult.emitted} misplaced worktree(s) flagged (` +
1974
- `enumerated=${detectionResult.enumerated} skipped=${detectionResult.skipped}` +
1975
- `${detectionResult.deduped ? ` deduped=${detectionResult.deduped}` : ''}` +
1976
- `${detectionResult.timedOut ? ' [timeout]' : ''})`));
1977
- }
1978
- }
1979
- }
1980
- catch (err) {
1981
- console.log(pc.yellow(` Worktree detector: skipped (${err instanceof Error ? err.message : String(err)})`));
1982
- }
1950
+ // Agent worktree convention (Layer 4) — detector invocation lives
1951
+ // AFTER the TelegramAdapter setup blocks below, so it can pass
1952
+ // `telegram.createAttentionItem` as the emit-attention callback when
1953
+ // Telegram is configured. The original placement here was deferred
1954
+ // for that reason (see upgrades/side-effects/agent-worktree-
1955
+ // convention-layer-3-4.md). When no Telegram adapter is present the
1956
+ // detector still runs and falls back to the JSONL append.
1983
1957
  let stopHeartbeat;
1984
1958
  try {
1985
1959
  stopHeartbeat = startHeartbeat(config.projectDir);
@@ -2813,6 +2787,63 @@ export async function startServer(options) {
2813
2787
  console.error(`[server] Failed to ensure Agent Updates topic: ${err}`);
2814
2788
  });
2815
2789
  }
2790
+ // Agent worktree convention (Layer 4) — lifeline detector.
2791
+ //
2792
+ // Runs once per server boot. Inspects the canonical instar repo's
2793
+ // worktree list and emits an AttentionItem per worktree that lives
2794
+ // outside any registered agent's `<agent_home>/.worktrees/` safe
2795
+ // area. Signal-only: never blocks, never moves, never deletes.
2796
+ //
2797
+ // Placement is deliberately AFTER both TelegramAdapter setup blocks
2798
+ // (send-only at line ~2810 and full-mode at line ~2897) so we can
2799
+ // pass `telegram.createAttentionItem` as the emit-attention callback.
2800
+ // When Telegram isn't configured the detector still runs and falls
2801
+ // back to the JSONL append at
2802
+ // `<stateDir>/audit/worktree-detector.jsonl` (O_NOFOLLOW + fstat,
2803
+ // 24h rolling-window dedupe).
2804
+ //
2805
+ // Dedupe semantics:
2806
+ // - Telegram path: AttentionQueue's `item.id` collision (a second
2807
+ // emit with the same `worktree-misplaced:sha256(path)` id is a
2808
+ // no-op via the existing `attentionItems` Map lookup in
2809
+ // TelegramAdapter.createAttentionItem).
2810
+ // - JSONL path: 24h rolling-window scan of the fallback file.
2811
+ try {
2812
+ const detector = await import('../core/AgentWorktreeDetector.js');
2813
+ const repo = detector.resolveDetectorInstarRepo();
2814
+ if (repo) {
2815
+ const safeRoots = detector.enumerateSafeRoots();
2816
+ const emitAttention = telegram
2817
+ ? async (item) => {
2818
+ await telegram.createAttentionItem({
2819
+ id: item.id,
2820
+ title: item.title,
2821
+ summary: item.summary,
2822
+ description: item.description,
2823
+ category: item.category,
2824
+ priority: item.priority,
2825
+ sourceContext: item.sourceContext,
2826
+ });
2827
+ }
2828
+ : undefined;
2829
+ const detectionResult = await detector.runDetection({
2830
+ instarRepo: repo,
2831
+ stateDir: config.stateDir,
2832
+ safeRoots,
2833
+ emitAttention,
2834
+ });
2835
+ if (detectionResult.emitted > 0) {
2836
+ const channel = telegram ? 'Telegram' : 'JSONL fallback';
2837
+ console.log(pc.yellow(` Worktree detector: ${detectionResult.emitted} misplaced worktree(s) flagged via ${channel} (` +
2838
+ `enumerated=${detectionResult.enumerated} skipped=${detectionResult.skipped}` +
2839
+ `${detectionResult.deduped ? ` deduped=${detectionResult.deduped}` : ''}` +
2840
+ `${detectionResult.timedOut ? ' [timeout]' : ''})`));
2841
+ }
2842
+ }
2843
+ }
2844
+ catch (err) {
2845
+ console.log(pc.yellow(` Worktree detector: skipped (${err instanceof Error ? err.message : String(err)})`));
2846
+ }
2816
2847
  // Initialize TopicMemory whenever Telegram is configured (any mode).
2817
2848
  // TopicMemory provides session context — needed even when lifeline owns polling.
2818
2849
  if (telegram) {