sidekick-shared 0.29.1 → 0.30.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/CHANGELOG.md +26 -0
- package/README.md +171 -60
- package/dist/aggregation/EventAggregator.d.ts +79 -4
- package/dist/aggregation/EventAggregator.js +391 -37
- package/dist/aggregation/types.d.ts +27 -3
- package/dist/browser.d.ts +7 -3
- package/dist/browser.js +23 -3
- package/dist/context/sessionContext.js +5 -1
- package/dist/esm/aggregation/EventAggregator.js +392 -38
- package/dist/esm/browser.js +3 -1
- package/dist/esm/context/sessionContext.js +6 -2
- package/dist/esm/fileContinuity.js +149 -0
- package/dist/esm/index.js +5 -2
- package/dist/esm/node.js +2 -0
- package/dist/esm/parsers/codexParser.js +192 -3
- package/dist/esm/parsers/subagentEndState.js +61 -0
- package/dist/esm/parsers/subagentScanner.js +4 -0
- package/dist/esm/parsers/subagentTraceParser.js +6 -0
- package/dist/esm/promptHistory.js +22 -11
- package/dist/esm/providers/claudeCode.js +50 -27
- package/dist/esm/providers/codex.js +153 -163
- package/dist/esm/providers/codexCompressedReader.js +184 -0
- package/dist/esm/providers/codexDatabase.js +47 -2
- package/dist/esm/providers/codexRollouts.js +20 -2
- package/dist/esm/providers/codexSubagents.js +456 -0
- package/dist/esm/providers/compressedRollouts.js +330 -0
- package/dist/esm/providers/factory.js +4 -1
- package/dist/esm/providers/rolloutWalker.js +32 -4
- package/dist/esm/schemas/sessionEvent.js +32 -4
- package/dist/esm/sessionMonitor.js +7 -1
- package/dist/esm/sessionPreviews.js +9 -0
- package/dist/esm/sessionPromptHistory.js +5 -3
- package/dist/esm/subagentActivity.js +125 -0
- package/dist/esm/subagentDisplayState.js +81 -0
- package/dist/esm/subagentSpawn.js +206 -6
- package/dist/esm/testing/codexSubagentFixtures.js +336 -0
- package/dist/esm/toolCallOrigins.js +17 -10
- package/dist/esm/toolCategory.js +6 -2
- package/dist/esm/transcript.js +6 -2
- package/dist/esm/turns/assistantTurn.js +6 -3
- package/dist/esm/usage/usageEvents.js +4 -1
- package/dist/esm/watchers/eventBridge.js +31 -1
- package/dist/esm/watchers/jsonlTail.js +11 -42
- package/dist/esm/watchers/jsonlWatcher.js +19 -9
- package/dist/esm/watchers/providerReaderWatcher.js +5 -4
- package/dist/fileContinuity.d.ts +95 -0
- package/dist/fileContinuity.js +187 -0
- package/dist/index.d.ts +14 -7
- package/dist/index.js +39 -10
- package/dist/node.d.ts +4 -0
- package/dist/node.js +16 -2
- package/dist/parsers/codexParser.d.ts +44 -0
- package/dist/parsers/codexParser.js +192 -3
- package/dist/parsers/subagentEndState.d.ts +20 -0
- package/dist/parsers/subagentEndState.js +65 -0
- package/dist/parsers/subagentScanner.js +4 -0
- package/dist/parsers/subagentTraceParser.d.ts +8 -0
- package/dist/parsers/subagentTraceParser.js +6 -0
- package/dist/promptHistory.d.ts +13 -3
- package/dist/promptHistory.js +22 -11
- package/dist/providers/claudeCode.js +50 -27
- package/dist/providers/codex.d.ts +35 -5
- package/dist/providers/codex.js +150 -160
- package/dist/providers/codexCompressedReader.d.ts +58 -0
- package/dist/providers/codexCompressedReader.js +221 -0
- package/dist/providers/codexDatabase.d.ts +25 -0
- package/dist/providers/codexDatabase.js +48 -2
- package/dist/providers/codexRollouts.d.ts +16 -2
- package/dist/providers/codexRollouts.js +20 -2
- package/dist/providers/codexSubagents.d.ts +66 -0
- package/dist/providers/codexSubagents.js +495 -0
- package/dist/providers/compressedRollouts.d.ts +114 -0
- package/dist/providers/compressedRollouts.js +380 -0
- package/dist/providers/factory.d.ts +5 -0
- package/dist/providers/factory.js +4 -1
- package/dist/providers/rolloutWalker.d.ts +15 -2
- package/dist/providers/rolloutWalker.js +33 -4
- package/dist/providers/types.d.ts +22 -1
- package/dist/schemas/sessionEvent.d.ts +26 -2
- package/dist/schemas/sessionEvent.js +31 -3
- package/dist/sessionMonitor.d.ts +6 -0
- package/dist/sessionMonitor.js +7 -1
- package/dist/sessionPreviews.js +9 -0
- package/dist/sessionPromptHistory.d.ts +5 -0
- package/dist/sessionPromptHistory.js +5 -36
- package/dist/subagentActivity.d.ts +91 -0
- package/dist/subagentActivity.js +132 -0
- package/dist/subagentDisplayState.d.ts +81 -0
- package/dist/subagentDisplayState.js +86 -0
- package/dist/subagentSpawn.d.ts +100 -5
- package/dist/subagentSpawn.js +218 -7
- package/dist/testing/codexSubagentFixtures.d.ts +48 -0
- package/dist/testing/codexSubagentFixtures.js +344 -0
- package/dist/toolCallOrigins.d.ts +5 -0
- package/dist/toolCallOrigins.js +17 -10
- package/dist/toolCategory.js +6 -2
- package/dist/transcript.js +5 -1
- package/dist/turns/assistantTurn.d.ts +4 -1
- package/dist/turns/assistantTurn.js +5 -2
- package/dist/types/codex.d.ts +71 -2
- package/dist/types/sessionEvent.d.ts +38 -3
- package/dist/usage/usageEvents.d.ts +4 -1
- package/dist/usage/usageEvents.js +4 -1
- package/dist/watchers/eventBridge.js +30 -0
- package/dist/watchers/jsonlTail.js +11 -42
- package/dist/watchers/jsonlWatcher.d.ts +5 -1
- package/dist/watchers/jsonlWatcher.js +18 -8
- package/dist/watchers/providerReaderWatcher.js +5 -4
- package/package.json +1 -1
|
@@ -13,8 +13,12 @@ import type { EventAggregatorOptions, AggregatedTokens, ModelUsageStats, BurnRat
|
|
|
13
13
|
import type { SerializedFrequencyState } from './FrequencyTracker';
|
|
14
14
|
import type { SerializedHeatmapState } from './HeatmapTracker';
|
|
15
15
|
import type { SerializedPatternState } from './PatternExtractor';
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Schema version for serialized snapshots. v6: token totals count each Claude
|
|
18
|
+
* response and Codex call once. v7: subagent lifecycles track Codex spawns and
|
|
19
|
+
* record what settled a background agent (`settledBy`).
|
|
20
|
+
*/
|
|
21
|
+
export declare const SNAPSHOT_SCHEMA_VERSION = 7;
|
|
18
22
|
/**
|
|
19
23
|
* JSON-serializable snapshot of EventAggregator state.
|
|
20
24
|
* Used by session snapshot sidecar files for fast resume.
|
|
@@ -83,6 +87,21 @@ export interface SerializedAggregatorState {
|
|
|
83
87
|
patternState?: SerializedPatternState;
|
|
84
88
|
heatmapState?: SerializedHeatmapState;
|
|
85
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Host-supplied evidence about how a subagent ended, for
|
|
92
|
+
* {@link EventAggregator.applySubagentEvidence}: Claude Code's
|
|
93
|
+
* `agent-<id>.meta.json` flags, matched by agent id or spawning tool_use id.
|
|
94
|
+
*/
|
|
95
|
+
export interface SubagentEvidence {
|
|
96
|
+
/** The agent id (Claude Code's `agent-<id>` name, or a Codex child thread id). */
|
|
97
|
+
agentId?: string;
|
|
98
|
+
/** The spawning tool_use id (meta `toolUseId`). */
|
|
99
|
+
toolUseId?: string;
|
|
100
|
+
/** Meta `finished`: the background agent is done. `false` reopens an agent `meta` settled. */
|
|
101
|
+
finished?: boolean;
|
|
102
|
+
/** Meta `stoppedByUser`: the user stopped the agent. */
|
|
103
|
+
stoppedByUser?: boolean;
|
|
104
|
+
}
|
|
86
105
|
/**
|
|
87
106
|
* Parses dependency references from a todo item's content text.
|
|
88
107
|
*
|
|
@@ -139,6 +158,8 @@ export declare class EventAggregator {
|
|
|
139
158
|
private activeTaskId;
|
|
140
159
|
private subagents;
|
|
141
160
|
private pendingSubagents;
|
|
161
|
+
/** Codex `spawn_agent` calls still waiting for their result (always a background launch). */
|
|
162
|
+
private pendingCodexSpawns;
|
|
142
163
|
private planExtractor;
|
|
143
164
|
private planState;
|
|
144
165
|
private planEnteredAt;
|
|
@@ -173,6 +194,8 @@ export declare class EventAggregator {
|
|
|
173
194
|
getBurnRate(): BurnRateInfo;
|
|
174
195
|
getTaskState(): TaskState;
|
|
175
196
|
getSubagents(): SubagentLifecycle[];
|
|
197
|
+
/** Timestamp of the last counted event (`getMetrics().lastEventTime`), without building the metrics. */
|
|
198
|
+
getLastEventTime(): string | null;
|
|
176
199
|
getPlan(): PlanState | null;
|
|
177
200
|
getContextAttribution(): ContextAttribution;
|
|
178
201
|
getTimeline(): TimelineEvent[];
|
|
@@ -229,13 +252,27 @@ export declare class EventAggregator {
|
|
|
229
252
|
private trackSubagentSpawn;
|
|
230
253
|
/**
|
|
231
254
|
* The spawning tool call's result. A foreground agent ends here; a
|
|
232
|
-
* background launch only reports the agent id
|
|
233
|
-
* until
|
|
255
|
+
* background launch only reports the agent id (a Codex spawn, its agent
|
|
256
|
+
* path), and the agent keeps running until a notification or another
|
|
257
|
+
* record says it ended.
|
|
234
258
|
*/
|
|
235
259
|
private resolveSubagentResult;
|
|
236
260
|
private markBackgroundLaunch;
|
|
237
261
|
private completeSubagent;
|
|
238
262
|
private finishSubagent;
|
|
263
|
+
/** Puts a settled agent back to running (it resumed). */
|
|
264
|
+
private reopenSubagent;
|
|
265
|
+
/**
|
|
266
|
+
* Settles a lifecycle that is still running (and its task card). Agents
|
|
267
|
+
* already settled are left alone: a stop notice or status can name agents
|
|
268
|
+
* that finished earlier.
|
|
269
|
+
*/
|
|
270
|
+
private settleRunningSubagent;
|
|
271
|
+
/**
|
|
272
|
+
* Moves an agent's task card with its lifecycle: `null` back to in
|
|
273
|
+
* progress, a failure to deleted, any other outcome to completed.
|
|
274
|
+
*/
|
|
275
|
+
private settleAgentTask;
|
|
239
276
|
/**
|
|
240
277
|
* Applies a background task's notification to the subagent it reports on,
|
|
241
278
|
* matched by the spawning tool_use id (or by agent id when the notification
|
|
@@ -245,6 +282,44 @@ export declare class EventAggregator {
|
|
|
245
282
|
*/
|
|
246
283
|
private applyTaskNotification;
|
|
247
284
|
private findNotifiedSubagent;
|
|
285
|
+
/**
|
|
286
|
+
* Applies host evidence about a subagent (Claude Code's meta flags):
|
|
287
|
+
* `stoppedByUser` settles a running agent as `stopped`, `finished` as
|
|
288
|
+
* `completed` (`settledBy: 'meta'`). Agents already settled some other way
|
|
289
|
+
* keep their outcome; `finished: false` reopens an agent that only meta
|
|
290
|
+
* settled. Matches by `toolUseId`, then `agentId` (the newest such agent),
|
|
291
|
+
* and records the agent id when matched by tool_use id.
|
|
292
|
+
*
|
|
293
|
+
* @param timestamp ISO time to record as the completion (the agent's last
|
|
294
|
+
* activity, when the host knows it)
|
|
295
|
+
* @returns Whether a lifecycle changed
|
|
296
|
+
*/
|
|
297
|
+
applySubagentEvidence(evidence: SubagentEvidence, timestamp: string): boolean;
|
|
298
|
+
/** The newest lifecycle with this spawning tool_use id, else with this agent id. */
|
|
299
|
+
private findSubagent;
|
|
300
|
+
/** `agents_killed`: the user killed every running background agent. */
|
|
301
|
+
private applyAgentsKilled;
|
|
302
|
+
/**
|
|
303
|
+
* "N background agents were stopped by the user: "A", "B"": settles the
|
|
304
|
+
* running agents with those descriptions, the newest first for repeats.
|
|
305
|
+
*/
|
|
306
|
+
private applyAgentsStopped;
|
|
307
|
+
/** A background agent's final `task_status` attachment, matched by agent id. */
|
|
308
|
+
private applyTaskStatus;
|
|
309
|
+
/**
|
|
310
|
+
* A Codex subagent lifecycle record: `started` links the spawn to its child
|
|
311
|
+
* thread; `completed` (a child turn finished) and `final-answer` (the
|
|
312
|
+
* child's report, matched by its agent path) complete it; `interacted`
|
|
313
|
+
* after `followup_task` puts it back to running (a `send_message` does
|
|
314
|
+
* not: it does not start a turn); `interrupted` (`interrupt_agent`) settles
|
|
315
|
+
* it as `stopped`, since the child keeps its thread and a follow-up can
|
|
316
|
+
* run it again, like a user stop rather than a kill.
|
|
317
|
+
*/
|
|
318
|
+
private applySubagentActivity;
|
|
319
|
+
/** The newest lifecycle with this Codex agent path (with `runningFirst`, a running one first). */
|
|
320
|
+
private findSubagentByPath;
|
|
321
|
+
private applySubagentFollowRecord;
|
|
322
|
+
private addSubagentTimeline;
|
|
248
323
|
private addTaskNotificationTimeline;
|
|
249
324
|
private extractPlanFromSessionEvent;
|
|
250
325
|
private processPlanFollowEvent;
|