instar 1.2.74 → 1.2.76

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 (45) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +43 -1
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/config/ConfigDefaults.d.ts.map +1 -1
  5. package/dist/config/ConfigDefaults.js +6 -0
  6. package/dist/config/ConfigDefaults.js.map +1 -1
  7. package/dist/core/Usher.d.ts +57 -0
  8. package/dist/core/Usher.d.ts.map +1 -0
  9. package/dist/core/Usher.js +179 -0
  10. package/dist/core/Usher.js.map +1 -0
  11. package/dist/core/UsherSignalStore.d.ts +58 -0
  12. package/dist/core/UsherSignalStore.d.ts.map +1 -0
  13. package/dist/core/UsherSignalStore.js +113 -0
  14. package/dist/core/UsherSignalStore.js.map +1 -0
  15. package/dist/core/types.d.ts +8 -0
  16. package/dist/core/types.d.ts.map +1 -1
  17. package/dist/core/types.js.map +1 -1
  18. package/dist/server/AgentServer.d.ts +2 -0
  19. package/dist/server/AgentServer.d.ts.map +1 -1
  20. package/dist/server/AgentServer.js +5 -0
  21. package/dist/server/AgentServer.js.map +1 -1
  22. package/dist/server/CapabilityIndex.d.ts.map +1 -1
  23. package/dist/server/CapabilityIndex.js +1 -0
  24. package/dist/server/CapabilityIndex.js.map +1 -1
  25. package/dist/server/usherRoutes.d.ts +16 -0
  26. package/dist/server/usherRoutes.d.ts.map +1 -0
  27. package/dist/server/usherRoutes.js +40 -0
  28. package/dist/server/usherRoutes.js.map +1 -0
  29. package/dist/threadline/ConversationStore.d.ts +53 -25
  30. package/dist/threadline/ConversationStore.d.ts.map +1 -1
  31. package/dist/threadline/ConversationStore.js +149 -68
  32. package/dist/threadline/ConversationStore.js.map +1 -1
  33. package/dist/threadline/ThreadResumeMap.d.ts +49 -116
  34. package/dist/threadline/ThreadResumeMap.d.ts.map +1 -1
  35. package/dist/threadline/ThreadResumeMap.js +194 -252
  36. package/dist/threadline/ThreadResumeMap.js.map +1 -1
  37. package/dist/threadline/ThreadlineObservability.d.ts +6 -1
  38. package/dist/threadline/ThreadlineObservability.d.ts.map +1 -1
  39. package/dist/threadline/ThreadlineObservability.js +17 -8
  40. package/dist/threadline/ThreadlineObservability.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/data/builtin-manifest.json +3 -3
  43. package/upgrades/1.2.75.md +69 -0
  44. package/upgrades/1.2.76.md +64 -0
  45. package/upgrades/side-effects/cwa-usher.md +82 -0
@@ -1,164 +1,97 @@
1
1
  /**
2
- * ThreadResumeMap — Persistent mapping from thread IDs to Claude session UUIDs.
2
+ * ThreadResumeMap — persistent mapping from thread IDs to Claude/Codex session
3
+ * UUIDs, for `--resume`.
3
4
  *
4
- * Analogous to TopicResumeMap but for inter-agent conversation threads.
5
- * When a thread's session is killed idle, the Claude session UUID is persisted
6
- * so it can be resumed (--resume UUID) when the next message arrives on that thread.
5
+ * Phase 2a (THREADLINE-SINGLE-STORE-SPEC.md / CMT-497): this is now a **view over
6
+ * `ConversationStore`** the single source of truth. Every method maps the legacy
7
+ * `ThreadResumeEntry` shape onto a `Conversation` record via the field bridge
8
+ * below. `save` MERGES (it never clobbers the loop gate's `turnCount`/
9
+ * `lastInboundHash`/`lastOutboundHash`). The on-disk `thread-resume-map.json` is no
10
+ * longer written; a one-release dual-read window falls back to it on a miss and
11
+ * writes through, so threads written by a pre-2a version are not lost.
7
12
  *
8
- * Key differences from TopicResumeMap:
9
- * - Maps threadId (string UUID) → extended session info
10
- * - 7-day TTL (vs. 24 hours)
11
- * - Max 1,000 entries with LRU eviction of non-pinned entries
12
- * - Resolved threads get a 7-day grace period before removal
13
- * - Pinned threads are never evicted
14
- *
15
- * Storage: {stateDir}/threadline/thread-resume-map.json
13
+ * Field bridge (ThreadResumeEntry ↔ Conversation):
14
+ * uuid↔sessionUuid · sessionName↔boundSessionName · lastAccessedAt↔lastActivityAt
15
+ * originTopicId↔boundTopicId · originSessionName↔originSessionName · the rest 1:1.
16
16
  */
17
- /** Thread lifecycle state */
17
+ import { ConversationStore } from './ConversationStore.js';
18
+ /** Thread lifecycle state (legacy subset of ConversationState). */
18
19
  export type ThreadState = 'active' | 'idle' | 'resolved' | 'failed' | 'archived';
19
- /** A single thread resume mapping entry */
20
+ /** A single thread resume mapping entry. */
20
21
  export interface ThreadResumeEntry {
21
- /** Claude session UUID */
22
22
  uuid: string;
23
- /** tmux session name */
24
23
  sessionName: string;
25
- /** When thread was created */
26
24
  createdAt: string;
27
- /** When this mapping was last saved */
28
25
  savedAt: string;
29
- /** When thread was last accessed */
30
26
  lastAccessedAt: string;
31
- /** The other agent in this conversation */
32
27
  remoteAgent: string;
33
- /** Thread subject */
34
28
  subject: string;
35
- /** Thread lifecycle state */
36
29
  state: ThreadState;
37
- /** When thread was resolved (only set if state === 'resolved') */
38
30
  resolvedAt?: string;
39
- /** Pinned threads are never evicted */
40
31
  pinned: boolean;
41
- /** Total messages in thread */
42
32
  messageCount: number;
43
- /** Machine that owns this thread (for cross-machine sync) */
44
33
  machineOrigin?: string;
45
- /** If migrated to another machine, which one */
46
34
  migratedTo?: string;
47
- /** Spawn mode: interactive (default) or pipe */
48
35
  spawnMode?: 'interactive' | 'pipe';
49
- /**
50
- * Thread↔Topic linkage (THREAD-TOPIC-LINKAGE-SPEC.md).
51
- * If this thread was initiated by a topic-bound session, the Telegram topic
52
- * that owns it. Set on outbound send; used by inbound dispatch to route the
53
- * reply back to the originating topic session instead of a sibling worker.
54
- */
55
36
  originTopicId?: number;
56
- /**
57
- * Session name of the originating topic at send time. Fast-path cache so the
58
- * inbound dispatcher doesn't have to query CommitmentTracker on every reply.
59
- * The source of truth for "what topic owns this thread" is the commitment
60
- * record with `verificationMethod: 'threadline-reply'`.
61
- */
62
37
  originSessionName?: string;
63
38
  }
64
39
  export declare class ThreadResumeMap {
65
- private filePath;
40
+ private store;
41
+ private legacyPath;
66
42
  private projectDir;
67
43
  private tmuxPath;
68
- constructor(stateDir: string, projectDir: string, tmuxPath?: string);
69
- /**
70
- * Save or update a thread resume mapping.
71
- * Triggers pruning if the map exceeds MAX_ENTRIES.
72
- */
73
- save(threadId: string, entry: ThreadResumeEntry): void;
44
+ constructor(stateDir: string, projectDir: string, tmuxPath?: string, store?: ConversationStore);
74
45
  /**
75
- * Look up a thread resume entry. Returns null if not found,
76
- * expired, or the JSONL file no longer exists.
46
+ * Look up a thread resume entry. Returns null if not found, expired, or the
47
+ * session JSONL no longer exists. Dual-read: on a ConversationStore miss, fall
48
+ * back to the legacy file and write through (one-release transition window).
77
49
  */
78
50
  get(threadId: string): ThreadResumeEntry | null;
79
- /**
80
- * Remove a thread entry.
81
- */
51
+ /** Save or update a thread resume mapping (MERGES — preserves gate turn state). */
52
+ save(threadId: string, entry: ThreadResumeEntry): void;
53
+ /** Remove a thread entry (cross-process safe via ConversationStore). */
82
54
  remove(threadId: string): void;
83
- /**
84
- * Mark a thread as resolved — sets state to 'resolved' and records resolvedAt.
85
- * Resolved threads get a grace period before being removed by prune().
86
- */
55
+ /** Mark a thread resolved (grace period before removal). */
87
56
  resolve(threadId: string): void;
88
- /**
89
- * Mark entries from a specific machine as migrated (Phase 4: cross-machine sync).
90
- * Called during failover when this machine takes over from another.
91
- * The migrated entries can be used to resume threads with --resume UUID.
92
- */
93
- migrateFrom(sourceMachine: string, targetMachine: string): {
94
- migrated: number;
95
- skipped: number;
96
- };
97
- /**
98
- * Get entries that were migrated to this machine (for resume capability).
99
- */
100
- getMigratedEntries(targetMachine: string): Array<{
101
- threadId: string;
102
- entry: ThreadResumeEntry;
103
- }>;
104
- /**
105
- * Pin a thread — pinned threads are never evicted by LRU or TTL.
106
- */
57
+ /** Pin — never evicted. */
107
58
  pin(threadId: string): void;
108
- /**
109
- * Unpin a thread — allows normal TTL and LRU eviction.
110
- */
59
+ /** Unpin — allow normal TTL/LRU eviction. */
111
60
  unpin(threadId: string): void;
112
- /**
113
- * Find all threads with a specific remote agent.
114
- * Returns entries that are not expired.
115
- */
61
+ /** Find all (non-expired) threads with a specific remote agent. */
116
62
  getByRemoteAgent(agentName: string): Array<{
117
63
  threadId: string;
118
64
  entry: ThreadResumeEntry;
119
65
  }>;
120
- /**
121
- * List all active or idle threads (not resolved, failed, or archived).
122
- */
66
+ /** List all active or idle threads. */
123
67
  listActive(): Array<{
124
68
  threadId: string;
125
69
  entry: ThreadResumeEntry;
126
70
  }>;
127
- /**
128
- * Prune expired entries, resolved entries past grace period,
129
- * and LRU overflow entries. Called automatically on save, but
130
- * can be called manually for maintenance.
131
- */
71
+ /** Cross-machine failover: demote a source machine's active threads to idle. */
72
+ migrateFrom(sourceMachine: string, targetMachine: string): {
73
+ migrated: number;
74
+ skipped: number;
75
+ };
76
+ /** Get entries migrated to this machine (for resume capability). */
77
+ getMigratedEntries(targetMachine: string): Array<{
78
+ threadId: string;
79
+ entry: ThreadResumeEntry;
80
+ }>;
81
+ /** Total stored entries (for monitoring). */
82
+ size(): number;
83
+ /** Prune expired / resolved-past-grace / LRU overflow. */
132
84
  prune(): void;
133
85
  /**
134
- * Proactive resume heartbeat: scan all active thread-linked tmux sessions
135
- * and update the thread→UUID mapping. Should be called periodically.
136
- *
137
- * This ensures that even if a session crashes unexpectedly, we already have
138
- * its UUID on file for --resume.
86
+ * Proactive resume heartbeat: scan active thread-linked tmux sessions and
87
+ * update the thread→UUID mapping so a crash leaves the UUID on file.
139
88
  */
140
89
  refreshResumeMappings(threadSessions: Map<string, string>): void;
141
- /**
142
- * Get the total number of entries in the map (for monitoring).
143
- */
144
- size(): number;
145
- private load;
146
- private persist;
147
- /**
148
- * Check if an entry is expired based on its state and age.
149
- * - Active/idle: expire after MAX_AGE_MS from lastAccessedAt
150
- * - Resolved: expire after RESOLVED_GRACE_MS from resolvedAt
151
- * - Failed/archived: expire after MAX_AGE_MS from savedAt
152
- */
90
+ /** Dual-read: read a single entry from the frozen legacy file, if present + fresh. */
91
+ private readLegacyEntry;
153
92
  private isExpired;
154
- /**
155
- * Prune a map in-place: remove expired entries, resolved-past-grace entries,
156
- * and LRU overflow (non-pinned) entries.
157
- */
158
- private pruneMap;
159
- /**
160
- * Check if a JSONL file exists for the given UUID.
161
- */
162
- private jsonlExists;
93
+ /** Check if a JSONL file exists for the given session UUID. (protected so
94
+ * tests can bypass the filesystem check via a subclass.) */
95
+ protected jsonlExists(uuid: string): boolean;
163
96
  }
164
97
  //# sourceMappingURL=ThreadResumeMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadResumeMap.d.ts","sourceRoot":"","sources":["../../src/threadline/ThreadResumeMap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,6BAA6B;AAC7B,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEjF,2CAA2C;AAC3C,MAAM,WAAW,iBAAiB;IAChC,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,KAAK,EAAE,WAAW,CAAC;IACnB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,SAAS,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IACnC;;;;;OAK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