@dougbots/avenor-core 0.3.7 → 0.4.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +205 -5
  2. package/dist/index.js +1209 -146
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -8,6 +8,22 @@ interface Event {
8
8
  runtime_id?: string;
9
9
  [key: string]: unknown;
10
10
  }
11
+ interface SubscribeOptions {
12
+ runtime_id?: string;
13
+ replay?: boolean;
14
+ limit?: number;
15
+ after_seq?: number;
16
+ }
17
+ interface HistoryOptions {
18
+ runtime_id: string;
19
+ limit?: number;
20
+ after_seq?: number;
21
+ }
22
+ interface HistoryResult<TEvent = Event> {
23
+ runtime_id?: string;
24
+ events: TEvent[];
25
+ latest_seq?: number;
26
+ }
11
27
  interface SpawnParams {
12
28
  agent: string;
13
29
  prompt_file?: string;
@@ -35,14 +51,16 @@ declare class Client {
35
51
  private eventDone;
36
52
  private dropped;
37
53
  private subscribed;
54
+ private subscriptionKey;
38
55
  constructor(socket: net.Socket, opts?: {
39
56
  callTimeoutMs?: number;
40
57
  });
41
58
  private startReadLoop;
42
59
  private pushEvent;
43
60
  call(method: string, params?: unknown): Promise<unknown>;
44
- private subscribe;
45
- events(): AsyncIterable<Event>;
61
+ subscribe(options?: SubscribeOptions): Promise<void>;
62
+ events(options?: SubscribeOptions): AsyncIterableIterator<Event>;
63
+ history(options: HistoryOptions): Promise<HistoryResult>;
46
64
  status(runtimeId?: string): Promise<Record<string, unknown>>;
47
65
  list(): Promise<Array<Record<string, unknown>>>;
48
66
  spawn(params: SpawnParams): Promise<Record<string, unknown>>;
@@ -56,6 +74,156 @@ declare function dial(socketPath: string, opts?: {
56
74
  callTimeoutMs?: number;
57
75
  }): Promise<Client>;
58
76
  //#endregion
77
+ //#region src/run-events.d.ts
78
+ type RunChunkRole = 'assistant' | 'thought' | 'user';
79
+ interface RunPermissionOption {
80
+ option_id: string;
81
+ label: string;
82
+ kind: string;
83
+ }
84
+ interface RunPermissionSummary {
85
+ request_id?: string;
86
+ description?: string;
87
+ question?: string;
88
+ tool?: string;
89
+ options: RunPermissionOption[];
90
+ kind?: string;
91
+ }
92
+ interface RunToolSummary {
93
+ key: string;
94
+ id?: string;
95
+ title?: string;
96
+ kind?: string;
97
+ status?: string;
98
+ preview?: string;
99
+ }
100
+ interface NormalizedRunEvent {
101
+ event: string;
102
+ source_event: string;
103
+ raw: Record<string, unknown>;
104
+ runtime_id?: string;
105
+ session_id?: string;
106
+ run_id?: string;
107
+ run_label?: string;
108
+ seq?: number;
109
+ ts?: number;
110
+ phase?: string;
111
+ phase_label?: string;
112
+ stop_reason?: string;
113
+ final_output?: string;
114
+ usage?: Record<string, unknown>;
115
+ backend?: string;
116
+ agent?: string;
117
+ model?: string;
118
+ dir?: string;
119
+ parent_id?: string;
120
+ children?: string[];
121
+ event_path?: string;
122
+ delta?: string;
123
+ chunk_role?: RunChunkRole;
124
+ tool?: RunToolSummary;
125
+ permission?: RunPermissionSummary;
126
+ alias?: boolean;
127
+ semantic_fingerprint?: string;
128
+ }
129
+ declare function extractEventText(value: unknown, depth?: number): string | undefined;
130
+ declare function normalizeRunEvent(input: unknown): NormalizedRunEvent | null;
131
+ //#endregion
132
+ //#region src/run-reducer.d.ts
133
+ interface RunReducerLimits {
134
+ transcript_entries: number;
135
+ text_chars: number;
136
+ tool_preview_chars: number;
137
+ tools: number;
138
+ permissions: number;
139
+ legacy_keys: number;
140
+ }
141
+ declare const DEFAULT_RUN_REDUCER_LIMITS: RunReducerLimits;
142
+ interface RunTranscriptEntry {
143
+ kind: 'assistant' | 'thought' | 'user' | 'tool' | 'permission' | 'session' | 'status';
144
+ event: string;
145
+ source_event: string;
146
+ text?: string;
147
+ title?: string;
148
+ status?: string;
149
+ request_id?: string;
150
+ seq?: number;
151
+ ts?: number;
152
+ }
153
+ interface RunToolState extends RunToolSummary {
154
+ started_at?: number;
155
+ updated_at?: number;
156
+ ended_at?: number;
157
+ live: boolean;
158
+ }
159
+ interface RunIdentity {
160
+ runtime_id?: string;
161
+ session_id?: string;
162
+ run_id?: string;
163
+ run_label?: string;
164
+ backend?: string;
165
+ agent?: string;
166
+ model?: string;
167
+ dir?: string;
168
+ parent_id?: string;
169
+ children?: string[];
170
+ event_path?: string;
171
+ }
172
+ interface RunSnapshot {
173
+ identity: RunIdentity;
174
+ limits: RunReducerLimits;
175
+ latest_seq?: number;
176
+ last_event?: string;
177
+ last_ts?: number;
178
+ phase?: string;
179
+ phase_label?: string;
180
+ ended: boolean;
181
+ stop_reason?: string;
182
+ usage?: Record<string, unknown>;
183
+ final_output?: string;
184
+ assistant_text: string;
185
+ thought_text: string;
186
+ user_text: string;
187
+ transcript: RunTranscriptEntry[];
188
+ tools: RunToolState[];
189
+ live_tools: RunToolState[];
190
+ pending_permission?: RunPermissionSummary;
191
+ permissions: RunPermissionSummary[];
192
+ _seen_seq_by_scope: Record<string, number>;
193
+ _recent_legacy_keys: string[];
194
+ _last_semantic_fingerprint?: string;
195
+ _last_source_event?: string;
196
+ }
197
+ declare function createRunSnapshot(limits?: Partial<RunReducerLimits>): RunSnapshot;
198
+ declare function reduceRunSnapshot(current: RunSnapshot, input: unknown, limits?: Partial<RunReducerLimits>): RunSnapshot;
199
+ type RunSnapshotSeed = Partial<Omit<RunSnapshot, '_seen_seq_by_scope' | '_recent_legacy_keys' | '_last_semantic_fingerprint' | '_last_source_event'>>;
200
+ declare class RunReducer {
201
+ private state;
202
+ constructor(limits?: Partial<RunReducerLimits>, initial?: RunSnapshotSeed);
203
+ apply(input: unknown): RunSnapshot;
204
+ snapshot(): RunSnapshot;
205
+ }
206
+ //#endregion
207
+ //#region src/run-observer.d.ts
208
+ interface RunObserverClient {
209
+ events(options?: SubscribeOptions): AsyncIterable<Event>;
210
+ close?(): void;
211
+ }
212
+ interface ObserveRunOptions extends SubscribeOptions {
213
+ reducer_limits?: Partial<RunReducerLimits>;
214
+ initial_snapshot?: RunSnapshotSeed;
215
+ close_client?: boolean;
216
+ }
217
+ type SnapshotListener = (snapshot: RunSnapshot, event: Event) => void;
218
+ interface RunObserver {
219
+ snapshot(): RunSnapshot;
220
+ subscribe(listener: SnapshotListener): () => void;
221
+ next(predicate?: (snapshot: RunSnapshot) => boolean): Promise<RunSnapshot | null>;
222
+ close(): Promise<void>;
223
+ readonly closed: boolean;
224
+ }
225
+ declare function observeRun(client: RunObserverClient, options?: ObserveRunOptions): RunObserver;
226
+ //#endregion
59
227
  //#region src/supervisor.d.ts
60
228
  interface RunInfo {
61
229
  runId: string;
@@ -139,6 +307,16 @@ interface StatusResult {
139
307
  };
140
308
  session_id?: string;
141
309
  stop_reason?: string;
310
+ backend?: string;
311
+ agent?: string;
312
+ model?: string;
313
+ dir?: string;
314
+ parent_id?: string;
315
+ children?: string[];
316
+ event_path?: string;
317
+ usage?: Record<string, unknown>;
318
+ latest_seq?: number;
319
+ final_output?: string;
142
320
  }
143
321
  declare function statusTool(args: {
144
322
  runId?: string;
@@ -172,14 +350,36 @@ declare function eventsTool(args: {
172
350
  types?: string[];
173
351
  limit?: number;
174
352
  supervisorId?: string;
353
+ after_seq?: number;
175
354
  }): Promise<{
176
355
  events: Array<{
177
- type: string;
178
- ts: number;
356
+ event?: string;
357
+ type?: string;
358
+ ts?: number;
179
359
  [key: string]: unknown;
180
360
  }>;
181
361
  }>;
182
362
  //#endregion
363
+ //#region src/tools/inspect.d.ts
364
+ interface InspectResult {
365
+ run_id: string;
366
+ label: string;
367
+ status: StatusResult;
368
+ snapshot: Omit<RunSnapshot, '_seen_seq_by_scope' | '_recent_legacy_keys' | '_last_semantic_fingerprint' | '_last_source_event'>;
369
+ transcript: RunSnapshot['transcript'];
370
+ tools: RunSnapshot['tools'];
371
+ live_tools: RunSnapshot['live_tools'];
372
+ permissions: RunSnapshot['permissions'];
373
+ pending_permission?: RunSnapshot['pending_permission'];
374
+ final_output?: string;
375
+ }
376
+ declare function inspectTool(args: {
377
+ runId: string;
378
+ supervisorId?: string;
379
+ limit?: number;
380
+ after_seq?: number;
381
+ }): Promise<InspectResult>;
382
+ //#endregion
183
383
  //#region src/tools/shutdown.d.ts
184
384
  declare function shutdownTool(args: {
185
385
  supervisorId?: string;
@@ -189,4 +389,4 @@ declare function shutdownTool(args: {
189
389
  cleaned_up: string[];
190
390
  }>;
191
391
  //#endregion
192
- export { type Client, type Event, type RunInfo, type SpawnParams, type StatusResult, Supervisor, type SupervisorOptions, answerPermissionTool, dial, eventsTool, findAvenorBinary, followUpTool, getInstallDir, getVersion, installerBinaryPath, shutdownTool, spawnTool, statusTool };
392
+ export { type Client, DEFAULT_RUN_REDUCER_LIMITS, type Event, type HistoryOptions, type HistoryResult, type InspectResult, type NormalizedRunEvent, type ObserveRunOptions, type RunChunkRole, type RunIdentity, type RunInfo, type RunObserver, type RunObserverClient, type RunPermissionOption, type RunPermissionSummary, RunReducer, type RunReducerLimits, type RunSnapshot, type RunSnapshotSeed, type RunToolState, type RunToolSummary, type RunTranscriptEntry, type SpawnParams, type StatusResult, type SubscribeOptions, Supervisor, type SupervisorOptions, answerPermissionTool, createRunSnapshot, dial, eventsTool, extractEventText, findAvenorBinary, followUpTool, getInstallDir, getVersion, inspectTool, installerBinaryPath, normalizeRunEvent, observeRun, reduceRunSnapshot, shutdownTool, spawnTool, statusTool };