@dougbots/avenor-core 0.9.0 → 0.10.1

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/README.md CHANGED
@@ -50,7 +50,33 @@ const result = await spawnTool({
50
50
  // { run_id: '...', label: 'reverse-string', supervisor_id: '/path/to/socket' }
51
51
  ```
52
52
 
53
- Accepts `agent`, `prompt`, `promptFile`, `label`, `dir`, `timeout`, `model`, `backend`, `serverUrl`, `sessionId`, and `supervisorId` (to target a specific socket).
53
+ Accepts `agent`, `prompt`, `promptFile`, `label`, `dir`, `timeout`, `model`, `thinking`, `backend`, `rosterFile`, `rosterEntry`, `serverUrl`, `sessionId`, and `supervisorId` (to target a specific socket).
54
+
55
+ ### Roster selection
56
+
57
+ `rosterFile` is the path to a top-level JSON roster map and `rosterEntry` is the key selected from it. Each entry must contain `backend` and at least one of `agent` or `model`:
58
+
59
+ ```json
60
+ {
61
+ "planner": {
62
+ "backend": "opencode-acp",
63
+ "model": "provider/planner"
64
+ }
65
+ }
66
+ ```
67
+
68
+ A direct roster spawn forwards both selectors and must not also provide `agent`, `model`, or `backend`. Direct mode without a roster allows each of those identity fields to be omitted independently, including a backend-only request; the selected runtime supplies defaults for omitted values. `thinking` is run-level, not a roster field, and is checked against the effective backend. The shared selector validation rejects missing selector pairs, mixed direct/roster fields, and unknown selector keys. Roster-file loading rejects deferred entry fields such as `system`; `thinking` remains a valid run-level option but is never read from a roster entry.
69
+
70
+ ```ts
71
+ await spawnTool({
72
+ prompt: 'Analyze the repository',
73
+ dir: '/repo',
74
+ rosterFile: '/repo/roster.json',
75
+ rosterEntry: 'planner',
76
+ })
77
+ ```
78
+
79
+ Roster phase selection is resolved by Avenor's Go workflow runners. A roster entry may override backend/agent/model per phase. CLI workflow fallback and nested roster inheritance are CLI-only; stable nesting keeps its existing behavior. A resumed session must use the same effective backend as the original session.
54
80
 
55
81
  ### `statusTool`
56
82
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,34 @@
1
1
  import { n as getVersion, r as installerBinaryPath, t as getInstallDir } from "./install-path-DagQIDKB.js";
2
2
  import * as net from "node:net";
3
3
 
4
+ //#region src/thinking-policy.d.ts
5
+ /**
6
+ * Portable thinking-policy contract.
7
+ *
8
+ * THINKING_LEVELS is the single TypeScript source for the canonical tuple and
9
+ * is exported for hosts (MCP, OpenCode, Pi) to derive their enums from. It is
10
+ * verified against schemas/thinking_policy.umpire.json and the Go tuple by
11
+ * introspection and conformance tests so all languages agree.
12
+ *
13
+ * The backend policy (which canonical values each backend supports, on start
14
+ * vs. explicit resume) is modelled directly in the Umpire schema's eitherOf
15
+ * branches with fairWhen rules and conditions (backend, resume). Both Go and
16
+ * TypeScript derive the policy from the schema, eliminating hand-written
17
+ * policy tables that could drift apart.
18
+ */
19
+ declare const THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
20
+ type ThinkingLevel = (typeof THINKING_LEVELS)[number];
21
+ declare function isThinkingLevel(value: string): boolean;
22
+ /** Accepts an empty value (backend default) or a canonical thinking level. */
23
+ declare function validateThinking(value: unknown): void;
24
+ type ThinkingOutcome = 'ok' | 'unsupportedCapability' | 'unsupportedValue' | 'startOnly';
25
+ /** Evaluates the schema-derived backend policy for a (backend, value, resume) combination. */
26
+ declare function evaluateThinkingPolicy(backend: string, value: string, resume?: boolean): ThinkingOutcome;
27
+ /** Accepts a value iff it is valid under the static backend policy (start). */
28
+ declare function validateThinkingForBackend(backend: string, value: unknown): void;
29
+ /** Accepts a value iff it is valid on an explicit resume for the backend. */
30
+ declare function validateThinkingForBackendResume(backend: string, value: unknown): void;
31
+ //#endregion
4
32
  //#region src/client.d.ts
5
33
  interface Event {
6
34
  event: string;
@@ -24,7 +52,6 @@ interface HistoryResult<TEvent = Event> {
24
52
  events: TEvent[];
25
53
  latest_seq?: number;
26
54
  }
27
- type ThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
28
55
  interface SpawnParams {
29
56
  agent?: string;
30
57
  prompt_file?: string;
@@ -36,13 +63,83 @@ interface SpawnParams {
36
63
  thinking?: ThinkingLevel;
37
64
  agent_profile?: string;
38
65
  backend?: string;
66
+ roster_file?: string;
67
+ roster_entry?: string;
39
68
  server_url?: string;
40
69
  session_id?: string;
41
70
  sentinel_file?: string;
71
+ workflow_id?: string;
72
+ node_id?: string;
73
+ activation_id?: string;
74
+ attempt_id?: string;
42
75
  on_event?: string;
43
76
  auto_approve?: boolean;
44
77
  [key: string]: unknown;
45
78
  }
79
+ interface SpawnResult {
80
+ runtime_id?: string;
81
+ session_id?: string;
82
+ on_event?: string;
83
+ sentinel_file?: string;
84
+ broker_url?: string;
85
+ parent_token?: string;
86
+ agent?: string;
87
+ agent_profile?: string;
88
+ model?: string;
89
+ backend?: string;
90
+ roster_file?: string;
91
+ roster_entry?: string;
92
+ effective_agent?: string;
93
+ effective_model?: string;
94
+ effective_backend?: string;
95
+ [key: string]: unknown;
96
+ }
97
+ interface ExecutionIdentity {
98
+ supervisor_id?: string;
99
+ workflow_id?: string;
100
+ node_id?: string;
101
+ activation_id?: string;
102
+ attempt_id?: string;
103
+ run_id?: string;
104
+ runtime_id?: string;
105
+ session_id?: string;
106
+ }
107
+ type WorkflowGateOperation = 'satisfy' | 'reject' | 'waive' | 'external_result';
108
+ interface WorkflowCompleteParams {
109
+ workflow_id: string;
110
+ node_id: string;
111
+ activation_id: string;
112
+ attempt_id: string;
113
+ lease_id: string;
114
+ owner_token: string;
115
+ outcome: string;
116
+ outputs?: unknown;
117
+ artifacts?: unknown;
118
+ }
119
+ interface WorkflowGateParams {
120
+ workflow_id: string;
121
+ node_id: string;
122
+ gate_id: string;
123
+ activation_id: string;
124
+ operation: WorkflowGateOperation;
125
+ actor?: string;
126
+ reason?: string;
127
+ outcome?: string;
128
+ subject?: unknown;
129
+ poll_id?: string;
130
+ source?: string;
131
+ result?: string;
132
+ response_hash?: string;
133
+ observed_at?: string;
134
+ evidence_ids?: string[];
135
+ }
136
+ interface WorkflowHeartbeatParams {
137
+ workflow_id: string;
138
+ node_id: string;
139
+ activation_id?: string;
140
+ lease_id: string;
141
+ owner_token: string;
142
+ }
46
143
  declare class Client {
47
144
  private socket;
48
145
  private rl;
@@ -69,12 +166,34 @@ declare class Client {
69
166
  status(runtimeId?: string): Promise<Record<string, unknown>>;
70
167
  result(runtimeId?: string): Promise<Record<string, unknown>>;
71
168
  list(): Promise<Array<Record<string, unknown>>>;
72
- spawn(params: SpawnParams): Promise<Record<string, unknown>>;
169
+ spawn(params: SpawnParams): Promise<SpawnResult>;
73
170
  shutdown(mode: string): Promise<void>;
74
171
  answerPermission(runtimeId: string, requestId: string, optionId: string, message?: string): Promise<void>;
75
172
  prompt(runtimeId: string, text: string): Promise<void>;
76
173
  interruptAndPrompt(runtimeId: string, text: string, keepQueue?: boolean): Promise<void>;
77
174
  cancel(runtimeId?: string): Promise<void>;
175
+ workflowStatus(workflowId: string): Promise<Record<string, unknown>>;
176
+ workflowWait(workflowId: string, timeoutMs?: number): Promise<Record<string, unknown>>;
177
+ workflowInspect(workflowId: string): Promise<Record<string, unknown>>;
178
+ workflowEvents(workflowId: string, opts?: {
179
+ afterSeq?: number;
180
+ limit?: number;
181
+ }): Promise<Record<string, unknown>>;
182
+ workflowCommand(workflowId: string, command: unknown): Promise<Record<string, unknown>>;
183
+ workflowComplete(params: WorkflowCompleteParams): Promise<Record<string, unknown>>;
184
+ workflowGate(params: WorkflowGateParams): Promise<Record<string, unknown>>;
185
+ workflowHeartbeat(params: WorkflowHeartbeatParams): Promise<Record<string, unknown>>;
186
+ brokerSend(fromRunId: string, toRunId: string, message: string, role?: string): Promise<void>;
187
+ brokerAsk(toRunId: string, message: string, role?: string): Promise<Record<string, unknown>>;
188
+ brokerPeers(): Promise<Array<Record<string, unknown>>>;
189
+ brokerCancel(messageId: string): Promise<void>;
190
+ brokerReceive(): Promise<Array<{
191
+ from_run_id: string;
192
+ message_id: string;
193
+ message: string;
194
+ role?: string;
195
+ }>>;
196
+ brokerReply(toRunId: string, replyTo: string, message: string): Promise<void>;
78
197
  isClosed(): boolean;
79
198
  close(): void;
80
199
  }
@@ -245,6 +364,11 @@ interface RunInfo {
245
364
  agentProfile?: string;
246
365
  backend?: string;
247
366
  model?: string;
367
+ effectiveAgent?: string;
368
+ effectiveModel?: string;
369
+ effectiveBackend?: string;
370
+ rosterFile?: string;
371
+ rosterEntry?: string;
248
372
  thinking?: ThinkingLevel;
249
373
  dir?: string;
250
374
  brokerUrl?: string;
@@ -255,6 +379,14 @@ interface SupervisorOptions {
255
379
  binaryPath?: string;
256
380
  callTimeoutMs?: number;
257
381
  }
382
+ /** Metadata retained locally when a follow-up uses a resolved direct identity. */
383
+ interface SpawnMetadata {
384
+ rosterFile?: string;
385
+ rosterEntry?: string;
386
+ effectiveAgent?: string;
387
+ effectiveModel?: string;
388
+ effectiveBackend?: string;
389
+ }
258
390
  declare function findAvenorBinary(): string;
259
391
  declare class Supervisor {
260
392
  private static instance;
@@ -267,6 +399,7 @@ declare class Supervisor {
267
399
  private crashed;
268
400
  private crashCode;
269
401
  private runs;
402
+ private aliases;
270
403
  private binaryPath;
271
404
  private callTimeoutMs;
272
405
  private constructor();
@@ -277,7 +410,7 @@ declare class Supervisor {
277
410
  static isCurrentInstance(supervisorId: string): boolean;
278
411
  static currentInstance(): Supervisor | null;
279
412
  getClient(): Client;
280
- spawn(params: SpawnParams, runId?: `${string}-${string}-${string}-${string}-${string}`): Promise<RunInfo>;
413
+ spawn(params: SpawnParams, runId?: `${string}-${string}-${string}-${string}-${string}`, metadata?: SpawnMetadata): Promise<RunInfo>;
281
414
  close(options?: {
282
415
  skipShutdown?: boolean;
283
416
  }): Promise<void>;
@@ -286,8 +419,16 @@ declare class Supervisor {
286
419
  //#region src/paths.d.ts
287
420
  declare function socketsRoot(): string;
288
421
  //#endregion
422
+ //#region src/tools/get-supervisor-client.d.ts
423
+ declare function getSupervisorClient(supervisorId: string): Promise<{
424
+ client: Client;
425
+ isSingleton: boolean;
426
+ sup: Supervisor | null;
427
+ supervisorId: string;
428
+ }>;
429
+ //#endregion
289
430
  //#region src/tools/spawn.d.ts
290
- declare function spawnTool(args: {
431
+ interface SpawnToolArgs {
291
432
  agent?: string;
292
433
  prompt?: string;
293
434
  promptFile?: string;
@@ -298,18 +439,33 @@ declare function spawnTool(args: {
298
439
  thinking?: ThinkingLevel;
299
440
  agentProfile?: string;
300
441
  backend?: string;
442
+ rosterFile?: string;
443
+ rosterEntry?: string;
301
444
  serverUrl?: string;
302
445
  sessionId?: string;
303
446
  supervisorId?: string;
304
447
  parent_run_id?: string;
305
- }): Promise<{
448
+ }
449
+ interface SpawnToolResult {
306
450
  run_id: string;
307
451
  label: string;
308
452
  supervisor_id: string;
309
453
  runtime_id?: string;
310
454
  broker_url?: string;
311
455
  parent_token?: string;
312
- }>;
456
+ }
457
+ declare const spawnTool: (args: SpawnToolArgs) => Promise<SpawnToolResult>;
458
+ //#endregion
459
+ //#region src/spawn-selection.d.ts
460
+ interface SpawnSelectionInput {
461
+ agent?: string;
462
+ model?: string;
463
+ backend?: string;
464
+ roster_file?: string;
465
+ roster_entry?: string;
466
+ }
467
+ /** Validate the direct-versus-roster selector contract. */
468
+ declare function validateSpawnSelection(input: unknown, rosterConfigured?: boolean): void;
313
469
  //#endregion
314
470
  //#region src/tools/status.d.ts
315
471
  type StatusView = 'lifecycle' | 'full';
@@ -337,9 +493,15 @@ interface StatusResult {
337
493
  };
338
494
  session_id?: string;
339
495
  stop_reason?: string;
496
+ roster_file?: string;
497
+ roster_entry?: string;
340
498
  backend?: string;
341
499
  agent?: string;
342
500
  model?: string;
501
+ agent_profile?: string;
502
+ effective_backend?: string;
503
+ effective_agent?: string;
504
+ effective_model?: string;
343
505
  dir?: string;
344
506
  parent_id?: string;
345
507
  children?: string[];
@@ -436,6 +598,7 @@ interface FollowUpToolArgs {
436
598
  interface FollowUpToolResult {
437
599
  run_id: string;
438
600
  label: string;
601
+ runtime_id?: string;
439
602
  }
440
603
  declare const followUpTool: (args: FollowUpToolArgs) => Promise<FollowUpToolResult>;
441
604
  //#endregion
@@ -448,4 +611,128 @@ declare function shutdownTool(args: {
448
611
  cleaned_up: string[];
449
612
  }>;
450
613
  //#endregion
451
- export { type Client, DEFAULT_RUN_REDUCER_LIMITS, type Event, type HistoryOptions, type HistoryResult, type InspectResult, type NormalizedRunEvent, type ObserveRunOptions, type ResultResult, type ResultToolArgs, 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 StatusView, type SubscribeOptions, Supervisor, type SupervisorOptions, type ThinkingLevel, answerPermissionTool, createRunSnapshot, dial, eventsTool, extractEventText, findAvenorBinary, followUpTool, getInstallDir, getVersion, inspectTool, installerBinaryPath, normalizeRunEvent, observeRun, reduceRunSnapshot, resultTool, shutdownTool, socketsRoot, spawnTool, statusTool };
614
+ //#region src/tools/ask.d.ts
615
+ interface AskToolArgs {
616
+ toRunId: string;
617
+ message: string;
618
+ supervisorId?: string;
619
+ }
620
+ interface AskResult {
621
+ reply: string;
622
+ from_run_id: string;
623
+ }
624
+ declare const askTool: (args: AskToolArgs) => Promise<AskResult>;
625
+ //#endregion
626
+ //#region src/tools/peers.d.ts
627
+ interface PeersToolArgs {
628
+ supervisorId?: string;
629
+ }
630
+ interface PeerEntry {
631
+ run_id: string;
632
+ label?: string;
633
+ status?: string;
634
+ backend?: string;
635
+ model?: string;
636
+ dir?: string;
637
+ }
638
+ interface PeersResult {
639
+ peers: PeerEntry[];
640
+ }
641
+ declare const peersTool: (args: PeersToolArgs) => Promise<PeersResult>;
642
+ //#endregion
643
+ //#region src/tools/cancel.d.ts
644
+ interface CancelToolArgs {
645
+ messageId: string;
646
+ supervisorId?: string;
647
+ }
648
+ interface CancelResult {
649
+ cancelled: boolean;
650
+ }
651
+ declare const cancelTool: (args: CancelToolArgs) => Promise<CancelResult>;
652
+ //#endregion
653
+ //#region src/tools/broker-receive.d.ts
654
+ interface BrokerReceiveArgs {
655
+ supervisorId?: string;
656
+ }
657
+ interface InboundAsk {
658
+ from_run_id: string;
659
+ message_id: string;
660
+ message: string;
661
+ role?: string;
662
+ }
663
+ interface BrokerReceiveResult {
664
+ asks: InboundAsk[];
665
+ }
666
+ declare const brokerReceiveTool: (args: BrokerReceiveArgs) => Promise<BrokerReceiveResult>;
667
+ //#endregion
668
+ //#region src/tools/broker-reply.d.ts
669
+ interface BrokerReplyArgs {
670
+ toRunId: string;
671
+ replyTo: string;
672
+ message: string;
673
+ supervisorId?: string;
674
+ }
675
+ interface BrokerReplyResult {
676
+ ok: true;
677
+ }
678
+ declare const brokerReplyTool: (args: BrokerReplyArgs) => Promise<BrokerReplyResult>;
679
+ //#endregion
680
+ //#region src/tools/workflow-client.d.ts
681
+ type GetSupervisorClient = typeof getSupervisorClient;
682
+ //#endregion
683
+ //#region src/tools/workflow-status.d.ts
684
+ interface WorkflowStatusToolArgs {
685
+ workflowId: string;
686
+ supervisorId?: string;
687
+ }
688
+ type WorkflowStatusResult = Record<string, unknown>;
689
+ declare function createWorkflowStatusTool(getSupervisorClient: GetSupervisorClient): (args: WorkflowStatusToolArgs) => Promise<WorkflowStatusResult>;
690
+ declare const workflowStatusTool: (args: WorkflowStatusToolArgs) => Promise<WorkflowStatusResult>;
691
+ //#endregion
692
+ //#region src/tools/workflow-wait.d.ts
693
+ interface WorkflowWaitToolArgs {
694
+ workflowId: string;
695
+ timeout?: string;
696
+ supervisorId?: string;
697
+ }
698
+ type WorkflowWaitResult = Record<string, unknown>;
699
+ declare function createWorkflowWaitTool(getSupervisorClient: GetSupervisorClient): (args: WorkflowWaitToolArgs) => Promise<WorkflowWaitResult>;
700
+ declare const workflowWaitTool: (args: WorkflowWaitToolArgs) => Promise<WorkflowWaitResult>;
701
+ //#endregion
702
+ //#region src/tools/workflow-inspect.d.ts
703
+ interface WorkflowInspectToolArgs {
704
+ workflowId: string;
705
+ supervisorId?: string;
706
+ }
707
+ type WorkflowInspectResult = Record<string, unknown>;
708
+ declare function createWorkflowInspectTool(getSupervisorClient: GetSupervisorClient): (args: WorkflowInspectToolArgs) => Promise<WorkflowInspectResult>;
709
+ declare const workflowInspectTool: (args: WorkflowInspectToolArgs) => Promise<WorkflowInspectResult>;
710
+ //#endregion
711
+ //#region src/tools/workflow-events.d.ts
712
+ interface WorkflowEventsToolArgs {
713
+ workflowId: string;
714
+ afterSeq?: number;
715
+ limit?: number;
716
+ supervisorId?: string;
717
+ }
718
+ type WorkflowEventsResult = Record<string, unknown>;
719
+ declare function createWorkflowEventsTool(getSupervisorClient: GetSupervisorClient): (args: WorkflowEventsToolArgs) => Promise<WorkflowEventsResult>;
720
+ declare const workflowEventsTool: (args: WorkflowEventsToolArgs) => Promise<WorkflowEventsResult>;
721
+ //#endregion
722
+ //#region src/tools/workflow-complete.d.ts
723
+ interface WorkflowCompleteToolArgs extends WorkflowCompleteParams {
724
+ supervisorId?: string;
725
+ }
726
+ type WorkflowCompleteResult = Record<string, unknown>;
727
+ declare function createWorkflowCompleteTool(getSupervisorClient: GetSupervisorClient): (args: WorkflowCompleteToolArgs) => Promise<WorkflowCompleteResult>;
728
+ declare const workflowCompleteTool: (args: WorkflowCompleteToolArgs) => Promise<WorkflowCompleteResult>;
729
+ //#endregion
730
+ //#region src/tools/workflow-gate.d.ts
731
+ interface WorkflowGateToolArgs extends WorkflowGateParams {
732
+ supervisorId?: string;
733
+ }
734
+ type WorkflowGateResult = Record<string, unknown>;
735
+ declare function createWorkflowGateTool(getSupervisorClient: GetSupervisorClient): (args: WorkflowGateToolArgs) => Promise<WorkflowGateResult>;
736
+ declare const workflowGateTool: (args: WorkflowGateToolArgs) => Promise<WorkflowGateResult>;
737
+ //#endregion
738
+ export { type AskResult, type AskToolArgs, type BrokerReceiveArgs, type BrokerReceiveResult, type BrokerReplyArgs, type BrokerReplyResult, type CancelResult, type CancelToolArgs, type Client, DEFAULT_RUN_REDUCER_LIMITS, type Event, type ExecutionIdentity, type FollowUpToolArgs, type FollowUpToolResult, type HistoryOptions, type HistoryResult, type InboundAsk, type InspectResult, type NormalizedRunEvent, type ObserveRunOptions, type PeerEntry, type PeersResult, type ResultResult, type ResultToolArgs, 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 SpawnMetadata, type SpawnParams, type SpawnResult, type SpawnSelectionInput, type SpawnToolArgs, type SpawnToolResult, type StatusResult, type StatusToolArgs, type StatusView, type SubscribeOptions, Supervisor, type SupervisorOptions, THINKING_LEVELS, type ThinkingLevel, type ThinkingOutcome, type WorkflowCompleteParams, type WorkflowCompleteResult, type WorkflowCompleteToolArgs, type WorkflowEventsResult, type WorkflowEventsToolArgs, type WorkflowGateOperation, type WorkflowGateParams, type WorkflowGateResult, type WorkflowGateToolArgs, type WorkflowHeartbeatParams, type WorkflowInspectResult, type WorkflowInspectToolArgs, type WorkflowStatusResult, type WorkflowStatusToolArgs, type WorkflowWaitResult, type WorkflowWaitToolArgs, answerPermissionTool, askTool, brokerReceiveTool, brokerReplyTool, cancelTool, createRunSnapshot, createWorkflowCompleteTool, createWorkflowEventsTool, createWorkflowGateTool, createWorkflowInspectTool, createWorkflowStatusTool, createWorkflowWaitTool, dial, evaluateThinkingPolicy, eventsTool, extractEventText, findAvenorBinary, followUpTool, getInstallDir, getVersion, inspectTool, installerBinaryPath, isThinkingLevel, normalizeRunEvent, observeRun, peersTool, reduceRunSnapshot, resultTool, shutdownTool, socketsRoot, spawnTool, statusTool, validateSpawnSelection, validateThinking, validateThinkingForBackend, validateThinkingForBackendResume, workflowCompleteTool, workflowEventsTool, workflowGateTool, workflowInspectTool, workflowStatusTool, workflowWaitTool };