@dougbots/avenor-core 0.14.0 → 0.16.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/README.md +18 -6
- package/dist/index.d.ts +565 -65
- package/dist/index.js +7151 -386
- package/dist/postinstall.js +2 -2
- package/package.json +1 -1
- package/dist/{install-path-C7QXqbJO.js → install-path-DKsk-86J.js} +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -144,11 +144,119 @@ interface WorkflowControllerCreateParams {
|
|
|
144
144
|
controller_id: string;
|
|
145
145
|
max_inflight: number;
|
|
146
146
|
}
|
|
147
|
+
interface MessageSendParams {
|
|
148
|
+
to_run_id: string;
|
|
149
|
+
message_id: string;
|
|
150
|
+
generation: string;
|
|
151
|
+
body: string;
|
|
152
|
+
no_reply?: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface MessageSendResult {
|
|
155
|
+
outcome: string;
|
|
156
|
+
message_id?: string;
|
|
157
|
+
generation?: string;
|
|
158
|
+
}
|
|
159
|
+
interface MessageWaitParams {
|
|
160
|
+
message_id: string;
|
|
161
|
+
generation: string;
|
|
162
|
+
timeout_ms?: number;
|
|
163
|
+
}
|
|
164
|
+
interface MessageInbound {
|
|
165
|
+
message_id: string;
|
|
166
|
+
from_run_id: string;
|
|
167
|
+
sender?: string;
|
|
168
|
+
kind?: string;
|
|
169
|
+
payload?: unknown;
|
|
170
|
+
}
|
|
171
|
+
interface MessageWaitResult {
|
|
172
|
+
outcome: string;
|
|
173
|
+
message_id?: string;
|
|
174
|
+
reply?: MessageInbound;
|
|
175
|
+
}
|
|
176
|
+
interface MessageWithdrawParams {
|
|
177
|
+
message_id: string;
|
|
178
|
+
generation: string;
|
|
179
|
+
}
|
|
180
|
+
interface MessageFence {
|
|
181
|
+
sender: string;
|
|
182
|
+
message_id: string;
|
|
183
|
+
generation: string;
|
|
184
|
+
deadline: number;
|
|
185
|
+
terminal: boolean;
|
|
186
|
+
}
|
|
187
|
+
interface MessageWithdrawResult {
|
|
188
|
+
outcome: string;
|
|
189
|
+
fence?: MessageFence;
|
|
190
|
+
}
|
|
191
|
+
interface MessageReceiveParams {
|
|
192
|
+
generation: string;
|
|
193
|
+
timeout_ms?: number;
|
|
194
|
+
limit?: number;
|
|
195
|
+
}
|
|
196
|
+
interface MessageReceiveResult {
|
|
197
|
+
messages: MessageInbound[];
|
|
198
|
+
generation?: string;
|
|
199
|
+
}
|
|
200
|
+
interface MessagePeersParams {
|
|
201
|
+
generation: string;
|
|
202
|
+
}
|
|
203
|
+
interface MessagePeer {
|
|
204
|
+
run_id: string;
|
|
205
|
+
session?: unknown;
|
|
206
|
+
}
|
|
207
|
+
interface MessagePeersResult {
|
|
208
|
+
peers: MessagePeer[];
|
|
209
|
+
generation?: string;
|
|
210
|
+
}
|
|
211
|
+
interface MessagePreflightResult {
|
|
212
|
+
protocol: number;
|
|
213
|
+
generation: string;
|
|
214
|
+
}
|
|
215
|
+
interface ResumeParams {
|
|
216
|
+
run_id: string;
|
|
217
|
+
target: string;
|
|
218
|
+
message: string;
|
|
219
|
+
label?: string;
|
|
220
|
+
idempotency_key?: string;
|
|
221
|
+
sentinel_file?: string;
|
|
222
|
+
on_event?: string;
|
|
223
|
+
}
|
|
224
|
+
interface ResumeResult {
|
|
225
|
+
run_id: string;
|
|
226
|
+
label: string;
|
|
227
|
+
runtime_id: string;
|
|
228
|
+
session_id: string;
|
|
229
|
+
sentinel_file: string;
|
|
230
|
+
on_event: string;
|
|
231
|
+
}
|
|
232
|
+
interface SessionRenameResult {
|
|
233
|
+
run_id: string;
|
|
234
|
+
label: string;
|
|
235
|
+
previous_label: string;
|
|
236
|
+
}
|
|
237
|
+
interface SessionLastResult {
|
|
238
|
+
run_id: string;
|
|
239
|
+
label?: string;
|
|
240
|
+
has_record: boolean;
|
|
241
|
+
final_output: string;
|
|
242
|
+
stop_reason?: string;
|
|
243
|
+
final_output_truncated?: boolean;
|
|
244
|
+
at?: number;
|
|
245
|
+
}
|
|
147
246
|
declare class RpcError extends Error {
|
|
148
247
|
readonly code: number;
|
|
149
248
|
readonly data?: unknown;
|
|
150
249
|
constructor(code: number, message: string, data?: unknown);
|
|
151
250
|
}
|
|
251
|
+
type OwnerAuthFailureKind = 'unauthenticated' | 'unsupported' | 'timeout';
|
|
252
|
+
/** A classified owner-authentication rejection, not generic transport failure. */
|
|
253
|
+
declare class OwnerAuthError extends Error {
|
|
254
|
+
readonly kind: OwnerAuthFailureKind;
|
|
255
|
+
constructor(kind: OwnerAuthFailureKind, options?: {
|
|
256
|
+
code?: number;
|
|
257
|
+
reason?: string;
|
|
258
|
+
});
|
|
259
|
+
}
|
|
152
260
|
declare class Client {
|
|
153
261
|
private socket;
|
|
154
262
|
private rl;
|
|
@@ -171,6 +279,22 @@ declare class Client {
|
|
|
171
279
|
call(method: string, params?: unknown, opts?: {
|
|
172
280
|
timeoutMs?: number;
|
|
173
281
|
}): Promise<unknown>;
|
|
282
|
+
/**
|
|
283
|
+
* Send a credential-free identity probe. The control server returns the
|
|
284
|
+
* startup token only after it has published its own owner record.
|
|
285
|
+
*/
|
|
286
|
+
identity(timeoutMs?: number): Promise<string>;
|
|
287
|
+
/**
|
|
288
|
+
* Present the owner capability on this connection. The caller must already
|
|
289
|
+
* have bound the connection to a trusted peer: an owner attach checks the
|
|
290
|
+
* socket's ownership and identity, and an owned start proves the child with
|
|
291
|
+
* its attempt token.
|
|
292
|
+
*/
|
|
293
|
+
authenticateOwner(capability: {
|
|
294
|
+
id: string;
|
|
295
|
+
secret: string;
|
|
296
|
+
}, timeoutMs?: number): Promise<void>;
|
|
297
|
+
private sendCall;
|
|
174
298
|
subscribe(options?: SubscribeOptions): Promise<void>;
|
|
175
299
|
events(options?: SubscribeOptions): AsyncIterableIterator<Event>;
|
|
176
300
|
history(options: HistoryOptions): Promise<HistoryResult>;
|
|
@@ -200,24 +324,64 @@ declare class Client {
|
|
|
200
324
|
workflowControllerCreate(params: WorkflowControllerCreateParams): Promise<Record<string, unknown>>;
|
|
201
325
|
workflowControllerEnable(controllerId: string): Promise<Record<string, unknown>>;
|
|
202
326
|
workflowControllerDisable(controllerId: string, reason: string): Promise<Record<string, unknown>>;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
brokerReceive(): Promise<Array<{
|
|
208
|
-
from_run_id: string;
|
|
327
|
+
messageSend(params: MessageSendParams): Promise<MessageSendResult>;
|
|
328
|
+
messageWait(params: MessageWaitParams): Promise<MessageWaitResult>;
|
|
329
|
+
messageReply(params: {
|
|
330
|
+
to_run_id: string;
|
|
209
331
|
message_id: string;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
332
|
+
correlation_id?: string;
|
|
333
|
+
body: string;
|
|
334
|
+
}): Promise<MessageSendResult>;
|
|
335
|
+
messageWithdraw(params: MessageWithdrawParams): Promise<MessageWithdrawResult>;
|
|
336
|
+
messageReceive(params: MessageReceiveParams): Promise<MessageReceiveResult>;
|
|
337
|
+
messagePeers(params: MessagePeersParams): Promise<MessagePeersResult>;
|
|
338
|
+
messagePreflight(): Promise<MessagePreflightResult>;
|
|
339
|
+
resume(params: ResumeParams): Promise<ResumeResult>;
|
|
340
|
+
sessionRename(sessionId: string, name: string): Promise<SessionRenameResult>;
|
|
341
|
+
sessionLast(runtimeId: string): Promise<SessionLastResult>;
|
|
342
|
+
sessionLastSet(runtimeId: string, finalOutput: string, stopReason: string, truncated: boolean): Promise<void>;
|
|
343
|
+
workflowCancel(workflowId: string, actor: string, reason: string): Promise<Record<string, unknown>>;
|
|
214
344
|
isClosed(): boolean;
|
|
215
345
|
close(): void;
|
|
216
346
|
}
|
|
217
347
|
declare function dial(socketPath: string, opts?: {
|
|
218
348
|
callTimeoutMs?: number;
|
|
349
|
+
connectTimeoutMs?: number;
|
|
219
350
|
}): Promise<Client>;
|
|
220
351
|
//#endregion
|
|
352
|
+
//#region src/owner-attach.d.ts
|
|
353
|
+
/** The owner record published beside a control socket is absent. */
|
|
354
|
+
declare class OwnerRecordMissingError extends Error {
|
|
355
|
+
readonly socketPath: string;
|
|
356
|
+
constructor(socketPath: string);
|
|
357
|
+
}
|
|
358
|
+
/** The record or the socket it names no longer describes the live path. */
|
|
359
|
+
declare class StaleOwnerRecordError extends Error {
|
|
360
|
+
readonly socketPath: string;
|
|
361
|
+
readonly reason: string;
|
|
362
|
+
constructor(socketPath: string, reason: string);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* The control socket path is not bound to this euid, or its directory is
|
|
366
|
+
* writable by another user. No credential byte may be sent to that peer.
|
|
367
|
+
*/
|
|
368
|
+
declare class ForeignPeerError extends Error {
|
|
369
|
+
readonly socketPath: string;
|
|
370
|
+
readonly euid: number;
|
|
371
|
+
readonly reason: string;
|
|
372
|
+
readonly peerUID?: number | undefined;
|
|
373
|
+
constructor(socketPath: string, euid: number, reason: string, peerUID?: number | undefined);
|
|
374
|
+
}
|
|
375
|
+
interface OwnerAttachOptions {
|
|
376
|
+
timeoutMs?: number;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Load the owner record, bind the socket path to this euid and require it to be
|
|
380
|
+
* the record's socket, dial, re-check the socket identity and authenticate. The
|
|
381
|
+
* whole attach is bounded by the timeout.
|
|
382
|
+
*/
|
|
383
|
+
declare function attachOwner(socketPath: string, options?: OwnerAttachOptions): Promise<Client>;
|
|
384
|
+
//#endregion
|
|
221
385
|
//#region src/run-events.d.ts
|
|
222
386
|
type RunChunkRole = 'assistant' | 'thought' | 'user';
|
|
223
387
|
interface RunPermissionOption {
|
|
@@ -429,6 +593,20 @@ declare class Supervisor {
|
|
|
429
593
|
* Public run IDs are canonical; labels are lookup-only aliases.
|
|
430
594
|
*/
|
|
431
595
|
getRunByReference(reference: string): RunInfo | undefined;
|
|
596
|
+
/**
|
|
597
|
+
* Look up a run by its public run ID only, never by a label alias. The
|
|
598
|
+
* messaging router resolves public IDs and labels on separate planes, so a
|
|
599
|
+
* label that happens to equal another run's old ID must not match here.
|
|
600
|
+
*/
|
|
601
|
+
getRunById(runId: string): RunInfo | undefined;
|
|
602
|
+
/**
|
|
603
|
+
* Register a run this supervisor resumed, so its ID and label stay resolvable.
|
|
604
|
+
* Last write wins: an existing entry with the same run ID, or a label held by
|
|
605
|
+
* another run, is replaced. Duplicate rejection is the resume provider's job.
|
|
606
|
+
*/
|
|
607
|
+
registerResumed(run: RunInfo): void;
|
|
608
|
+
/** The one place a run's ID and label are registered, for spawn and for resume. */
|
|
609
|
+
private register;
|
|
432
610
|
/** Match a stored run by its broker runtime ID. */
|
|
433
611
|
getRunByRuntimeId(runtimeId: string): RunInfo | undefined;
|
|
434
612
|
/**
|
|
@@ -452,7 +630,11 @@ declare class Supervisor {
|
|
|
452
630
|
declare function socketsRoot(): string;
|
|
453
631
|
//#endregion
|
|
454
632
|
//#region src/tools/get-supervisor-client.d.ts
|
|
455
|
-
|
|
633
|
+
interface SupervisorClientOptions {
|
|
634
|
+
/** Attach with the socket's published owner capability instead of a bare dial. */
|
|
635
|
+
owner?: boolean;
|
|
636
|
+
}
|
|
637
|
+
declare function getSupervisorClient(supervisorId: string | undefined, options?: SupervisorClientOptions): Promise<{
|
|
456
638
|
client: Client;
|
|
457
639
|
isSingleton: boolean;
|
|
458
640
|
sup: Supervisor | null;
|
|
@@ -626,20 +808,6 @@ declare function answerPermissionTool(args: {
|
|
|
626
808
|
ok: boolean;
|
|
627
809
|
}>;
|
|
628
810
|
//#endregion
|
|
629
|
-
//#region src/tools/follow-up.d.ts
|
|
630
|
-
interface FollowUpToolArgs {
|
|
631
|
-
runId: string;
|
|
632
|
-
message: string;
|
|
633
|
-
label?: string;
|
|
634
|
-
supervisorId?: string;
|
|
635
|
-
}
|
|
636
|
-
interface FollowUpToolResult {
|
|
637
|
-
run_id: string;
|
|
638
|
-
label: string;
|
|
639
|
-
runtime_id?: string;
|
|
640
|
-
}
|
|
641
|
-
declare const followUpTool: (args: FollowUpToolArgs) => Promise<FollowUpToolResult>;
|
|
642
|
-
//#endregion
|
|
643
811
|
//#region src/tools/shutdown.d.ts
|
|
644
812
|
declare function shutdownTool(args: {
|
|
645
813
|
supervisorId?: string;
|
|
@@ -649,45 +817,368 @@ declare function shutdownTool(args: {
|
|
|
649
817
|
cleaned_up: string[];
|
|
650
818
|
}>;
|
|
651
819
|
//#endregion
|
|
652
|
-
//#region src/
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
declare
|
|
820
|
+
//#region src/messaging-text.d.ts
|
|
821
|
+
/** Every outcome the contract declares: the nine messaging rows and the two tool rows. */
|
|
822
|
+
declare const MESSAGE_OUTCOMES: [string, ...string[]];
|
|
823
|
+
type MessageOutcome = (typeof MESSAGE_OUTCOMES)[number];
|
|
824
|
+
/** The ask acceptance window the message ids encode, in milliseconds. */
|
|
825
|
+
declare const MAX_WAIT_MS = 600000;
|
|
826
|
+
/** The bound `session_last_set` carries from the producer, in code points. */
|
|
827
|
+
declare const MAX_FINAL_OUTPUT_RUNES = 4096;
|
|
828
|
+
/** Render the (action, outcome) template; an unlisted pair renders as "". */
|
|
829
|
+
declare function renderOutcome(action: string, outcome: string, facts?: Record<string, string>): string;
|
|
830
|
+
/** Render a repair sentence; the templates are the conformance fixture's `repairs`. */
|
|
831
|
+
declare function repair(code: string, facts?: Record<string, string>): string;
|
|
832
|
+
/** Render one of the peers `last` templates. */
|
|
833
|
+
declare function renderLast(key: string, facts?: Record<string, string>): string;
|
|
834
|
+
/**
|
|
835
|
+
* Render a value for a template fact as one JSON string literal. Control,
|
|
836
|
+
* format, line- and paragraph-separator characters are escaped, so a label a
|
|
837
|
+
* producer controls cannot carry a bidi override or a zero-width character into
|
|
838
|
+
* tool text. The rule is byte-identical to internal/messaging.Quote.
|
|
839
|
+
*/
|
|
840
|
+
declare function quote(value: string): string;
|
|
841
|
+
/** Escape the same characters as quote without adding the surrounding quotes. */
|
|
842
|
+
declare function sanitize(value: string): string;
|
|
843
|
+
/** Render every value with quote and join them with ", ". */
|
|
844
|
+
declare function quoteList(values: string[]): string;
|
|
845
|
+
/**
|
|
846
|
+
* Mint a versioned message id whose acceptance deadline is encoded inside it.
|
|
847
|
+
* The zero-deadline form spans the shared wait window, exactly like
|
|
848
|
+
* messaging.NewMsgID(now, time.Time{}).
|
|
849
|
+
*/
|
|
850
|
+
declare function newMsgID(now?: number): string;
|
|
851
|
+
/**
|
|
852
|
+
* Map pi's raw stop reasons onto avenor's canonical words, so a Pi host's
|
|
853
|
+
* published reason and a Pi child's session.end reason agree. The table is
|
|
854
|
+
* exactly internal/runtime/pi/events.go:normalizePiStopReason's; a spelling it
|
|
855
|
+
* does not know passes through and stays unknown here too.
|
|
856
|
+
*/
|
|
857
|
+
declare function normalizeTurnStopReason(stopReason: string): string;
|
|
858
|
+
/**
|
|
859
|
+
* Read the last assistant message's text and raw stop reason from an agent_end
|
|
860
|
+
* payload's `messages`, the TS twin of internal/runtime/pi's extractPiText plus
|
|
861
|
+
* the per-message `stopReason` read that translateAgentEnd does. Go also falls
|
|
862
|
+
* back to payload-level stopReason/errorMessage and normalises the stop reason;
|
|
863
|
+
* this helper sees only the messages array and does neither.
|
|
864
|
+
*/
|
|
865
|
+
declare function extractTurnText(messages: unknown[]): {
|
|
866
|
+
text: string;
|
|
867
|
+
stopReason: string;
|
|
868
|
+
};
|
|
869
|
+
/** Bound a published turn at the same rune count the Go recorder uses. */
|
|
870
|
+
declare function boundFinalOutput(text: string): string;
|
|
871
|
+
/** Extract the reply body from a wait result payload, as askclient.RenderReply does. */
|
|
872
|
+
declare function extractReplyMessage(result: Record<string, unknown>): string;
|
|
873
|
+
/**
|
|
874
|
+
* Render the shared ask failure sentence for an ask that failed. The outcome
|
|
875
|
+
* and the sentence both come from the contract, so TS and Go text agree.
|
|
876
|
+
*/
|
|
877
|
+
declare function renderAskFailure(messageId: string, target: string, outcome?: MessageOutcome): string;
|
|
878
|
+
/**
|
|
879
|
+
* Reduce a caller-supplied ask timeout to what the broker accepts: a positive
|
|
880
|
+
* finite number of milliseconds, or undefined to keep the broker's own wait.
|
|
881
|
+
*/
|
|
882
|
+
declare function normalizeAskTimeoutMs(timeoutMs: number | undefined): number | undefined;
|
|
664
883
|
//#endregion
|
|
665
|
-
//#region src/
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
interface
|
|
884
|
+
//#region src/message.d.ts
|
|
885
|
+
type MessageCallerKind = 'owner' | 'broker';
|
|
886
|
+
type MessageSurface = 'pi-host' | 'pi-child' | 'opencode' | 'mcp-ts' | 'mcp' | 'channeltools' | 'sidecar';
|
|
887
|
+
/** One peers `list` entry: the tool's projection of the broker's SessionInfo. */
|
|
888
|
+
interface PeerRecord {
|
|
670
889
|
run_id: string;
|
|
671
890
|
label?: string;
|
|
891
|
+
kind?: string;
|
|
672
892
|
status?: string;
|
|
673
893
|
backend?: string;
|
|
674
894
|
model?: string;
|
|
675
895
|
dir?: string;
|
|
676
896
|
}
|
|
677
|
-
|
|
678
|
-
|
|
897
|
+
/**
|
|
898
|
+
* One routed call's outcome and the facts a surface reports. `text` is the
|
|
899
|
+
* (action, outcome) render template and is set on every result, so no surface
|
|
900
|
+
* composes a sentence and every failure says whether an ask can still be
|
|
901
|
+
* withdrawn.
|
|
902
|
+
*/
|
|
903
|
+
interface ProviderResult {
|
|
904
|
+
action?: string;
|
|
905
|
+
outcome: MessageOutcome;
|
|
906
|
+
messageId?: string;
|
|
907
|
+
reply?: string;
|
|
908
|
+
text?: string;
|
|
909
|
+
runId?: string;
|
|
910
|
+
runtimeId?: string;
|
|
911
|
+
sessionId?: string;
|
|
912
|
+
label?: string;
|
|
913
|
+
previousLabel?: string;
|
|
914
|
+
sentinelFile?: string;
|
|
915
|
+
onEvent?: string;
|
|
916
|
+
finalOutput?: string;
|
|
917
|
+
stopReason?: string;
|
|
918
|
+
truncated?: boolean;
|
|
919
|
+
hasRecord?: boolean;
|
|
920
|
+
/** A peers `list` transport's error text; set only on an incomplete listing. */
|
|
921
|
+
detail?: string;
|
|
922
|
+
}
|
|
923
|
+
interface Resolution {
|
|
924
|
+
runId: string;
|
|
925
|
+
publicRunId?: string;
|
|
926
|
+
match: 'unique' | 'ambiguous' | 'none';
|
|
927
|
+
label?: string;
|
|
928
|
+
candidates?: string[];
|
|
929
|
+
}
|
|
930
|
+
interface RunFacts {
|
|
931
|
+
live: boolean;
|
|
932
|
+
resumable: boolean;
|
|
933
|
+
status: string;
|
|
934
|
+
}
|
|
935
|
+
interface PeersProviderResult {
|
|
936
|
+
peers: PeerRecord[];
|
|
937
|
+
/** Set when the transport returned peers together with an error. */
|
|
938
|
+
detail?: string;
|
|
679
939
|
}
|
|
680
|
-
|
|
940
|
+
/**
|
|
941
|
+
* What one bound surface supplies to the router: who it speaks as, how it
|
|
942
|
+
* resolves and reads state, and the action methods only it can perform.
|
|
943
|
+
*/
|
|
944
|
+
interface MessageProvider {
|
|
945
|
+
caller(): {
|
|
946
|
+
kind: MessageCallerKind;
|
|
947
|
+
runId: string;
|
|
948
|
+
};
|
|
949
|
+
surface(): MessageSurface;
|
|
950
|
+
role(): string;
|
|
951
|
+
resolve(ref: string): Promise<Resolution>;
|
|
952
|
+
state(runId: string): Promise<RunFacts>;
|
|
953
|
+
tell(targetRunId: string, message: string): Promise<ProviderResult>;
|
|
954
|
+
ask(targetRunId: string, message: string, timeoutMs?: number, signal?: AbortSignal): Promise<ProviderResult>;
|
|
955
|
+
reply(inboundAskId: string, message: string, askerRunId: string): Promise<ProviderResult>;
|
|
956
|
+
withdraw(messageId: string): Promise<ProviderResult>;
|
|
957
|
+
controlReply?(target: string, payload: unknown): Promise<ProviderResult>;
|
|
958
|
+
/** `target` is the RESOLVED runtime id; the provider mints runId and paths. */
|
|
959
|
+
resume(req: {
|
|
960
|
+
target: string;
|
|
961
|
+
message: string;
|
|
962
|
+
label?: string;
|
|
963
|
+
idempotencyKey?: string;
|
|
964
|
+
}): Promise<ProviderResult>;
|
|
965
|
+
rename(req: {
|
|
966
|
+
sessionId?: string;
|
|
967
|
+
name: string;
|
|
968
|
+
}): Promise<ProviderResult>;
|
|
969
|
+
last(runId: string): Promise<ProviderResult>;
|
|
970
|
+
peers(): Promise<PeersProviderResult>;
|
|
971
|
+
/** Host surfaces that own a turn loop publish their own finished turn. */
|
|
972
|
+
recordLastTurn?(text: string, stopReason: string, truncated: boolean): Promise<void>;
|
|
973
|
+
claimAsk?(messageId: string): string | undefined;
|
|
974
|
+
restoreAsk?(messageId: string, askerRunId: string): void;
|
|
975
|
+
/** Drop a claim once the asker has the answer; the claim map may belong to the surface. */
|
|
976
|
+
releaseAsk?(messageId: string): void;
|
|
977
|
+
onResumed?(result: ProviderResult): void | Promise<void>;
|
|
978
|
+
registerResumed?(result: ProviderResult): void | Promise<void>;
|
|
979
|
+
}
|
|
980
|
+
/** A typed tool denial: one fixed code and the rendered sentence. */
|
|
981
|
+
declare class ToolError extends Error {
|
|
982
|
+
readonly code: string;
|
|
983
|
+
readonly facts: Record<string, string>;
|
|
984
|
+
constructor(code: string, message: string, facts?: Record<string, string>);
|
|
985
|
+
}
|
|
986
|
+
interface MessageInput {
|
|
987
|
+
action: 'tell' | 'ask' | 'reply' | 'resume' | 'withdraw' | 'control_reply';
|
|
988
|
+
target?: string;
|
|
989
|
+
message?: string;
|
|
990
|
+
reply_to?: string;
|
|
991
|
+
message_id?: string;
|
|
992
|
+
timeout_ms?: number;
|
|
993
|
+
label?: string;
|
|
994
|
+
idempotency_key?: string;
|
|
995
|
+
payload?: Record<string, unknown>;
|
|
996
|
+
}
|
|
997
|
+
interface PeersInput {
|
|
998
|
+
action?: 'list' | 'rename' | 'last';
|
|
999
|
+
name?: string;
|
|
1000
|
+
session_id?: string;
|
|
1001
|
+
target?: string;
|
|
1002
|
+
}
|
|
1003
|
+
interface PeersRouterResult {
|
|
1004
|
+
action: 'list' | 'rename' | 'last';
|
|
1005
|
+
outcome?: MessageOutcome;
|
|
1006
|
+
text: string;
|
|
1007
|
+
peers: PeerRecord[];
|
|
1008
|
+
renamed?: {
|
|
1009
|
+
run_id: string;
|
|
1010
|
+
label: string;
|
|
1011
|
+
previous_label: string;
|
|
1012
|
+
};
|
|
1013
|
+
last?: {
|
|
1014
|
+
run_id: string;
|
|
1015
|
+
runtime_id: string;
|
|
1016
|
+
label: string;
|
|
1017
|
+
final_output: string;
|
|
1018
|
+
stop_reason: string;
|
|
1019
|
+
final_output_truncated: boolean;
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Phase 1 for avenor_message: the action enum, the action's permitted and
|
|
1024
|
+
* required field sets, and each field's declared wire type and limits. The
|
|
1025
|
+
* table is the one the Go router validates against.
|
|
1026
|
+
*/
|
|
1027
|
+
declare function assertMessageInput(input: unknown): asserts input is MessageInput;
|
|
1028
|
+
/**
|
|
1029
|
+
* Phase 1 for avenor_peers. An omitted action means `list`; a present but
|
|
1030
|
+
* non-string or unknown action is one invalid action, like the Go router.
|
|
1031
|
+
*/
|
|
1032
|
+
declare function assertPeersInput(input: unknown): asserts input is PeersInput;
|
|
1033
|
+
/** Route one avenor_message call through one provider. */
|
|
1034
|
+
declare function executeMessage(provider: MessageProvider, input: unknown, options?: {
|
|
1035
|
+
signal?: AbortSignal;
|
|
1036
|
+
}): Promise<ProviderResult>;
|
|
1037
|
+
/** Route one avenor_peers call through one provider. */
|
|
1038
|
+
declare function executePeers(provider: MessageProvider, input: unknown): Promise<PeersRouterResult>;
|
|
1039
|
+
/**
|
|
1040
|
+
* Render the peers list block the surfaces show: the one list text for the
|
|
1041
|
+
* shared records, so every surface that routes through the router renders a
|
|
1042
|
+
* peer identically.
|
|
1043
|
+
*/
|
|
1044
|
+
declare function renderPeerList(records: PeerRecord[]): string;
|
|
1045
|
+
/**
|
|
1046
|
+
* The one result object every surface returns for a routed message call.
|
|
1047
|
+
* Snake_case and the contract field set, exactly like the Go router's
|
|
1048
|
+
* `Result.Output()`: a fact that is absent is a key that is absent, `text` is
|
|
1049
|
+
* always present, and the resume paths travel with the result that minted them.
|
|
1050
|
+
*/
|
|
1051
|
+
declare function resultOutput(result: ProviderResult): Record<string, unknown>;
|
|
1052
|
+
/**
|
|
1053
|
+
* The one structured result every surface returns for a peers call, matching
|
|
1054
|
+
* `router.PeersDetails` field for field: `list` carries the peer records,
|
|
1055
|
+
* `rename` the new and previous label, `last` the recorded turn. An optional
|
|
1056
|
+
* peer field that is absent is a key that is absent.
|
|
1057
|
+
*/
|
|
1058
|
+
declare function peersDetails(result: PeersRouterResult): Record<string, unknown>;
|
|
681
1059
|
//#endregion
|
|
682
|
-
//#region src/tools/
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
1060
|
+
//#region src/tools/message.d.ts
|
|
1061
|
+
/**
|
|
1062
|
+
* The one avenor_message handler: every surface routes through it, so the six
|
|
1063
|
+
* actions and their failure text exist once. A router tool error is thrown as a
|
|
1064
|
+
* typed Error, which each surface reports as its own error result.
|
|
1065
|
+
*/
|
|
1066
|
+
declare function messageTool(args: unknown, provider: MessageProvider, options?: {
|
|
1067
|
+
signal?: AbortSignal;
|
|
1068
|
+
}): Promise<ProviderResult>;
|
|
1069
|
+
/** Bind the handler to one provider. */
|
|
1070
|
+
declare function createMessageTool(provider: MessageProvider): (args: unknown, options?: {
|
|
1071
|
+
signal?: AbortSignal;
|
|
1072
|
+
}) => Promise<ProviderResult>;
|
|
1073
|
+
//#endregion
|
|
1074
|
+
//#region src/tools/message-provider.d.ts
|
|
1075
|
+
/** The control-client surface a host provider needs, narrowed for testability. */
|
|
1076
|
+
interface MessageClient {
|
|
1077
|
+
messageSend(params: {
|
|
1078
|
+
to_run_id: string;
|
|
1079
|
+
message_id: string;
|
|
1080
|
+
generation: string;
|
|
1081
|
+
body: string;
|
|
1082
|
+
no_reply?: boolean;
|
|
1083
|
+
}): Promise<MessageSendResult>;
|
|
1084
|
+
messageWait(params: {
|
|
1085
|
+
message_id: string;
|
|
1086
|
+
generation: string;
|
|
1087
|
+
timeout_ms?: number;
|
|
1088
|
+
}): Promise<MessageWaitResult>;
|
|
1089
|
+
messageReply(params: {
|
|
1090
|
+
to_run_id: string;
|
|
1091
|
+
message_id: string;
|
|
1092
|
+
correlation_id?: string;
|
|
1093
|
+
body: string;
|
|
1094
|
+
}): Promise<MessageSendResult>;
|
|
1095
|
+
messageWithdraw(params: {
|
|
1096
|
+
message_id: string;
|
|
1097
|
+
generation: string;
|
|
1098
|
+
}): Promise<MessageWithdrawResult>;
|
|
1099
|
+
messagePeers(params: {
|
|
1100
|
+
generation: string;
|
|
1101
|
+
}): Promise<MessagePeersResult>;
|
|
1102
|
+
resume(params: {
|
|
1103
|
+
run_id: string;
|
|
1104
|
+
target: string;
|
|
1105
|
+
message: string;
|
|
1106
|
+
label?: string;
|
|
1107
|
+
idempotency_key?: string;
|
|
1108
|
+
sentinel_file?: string;
|
|
1109
|
+
on_event?: string;
|
|
1110
|
+
}): Promise<ResumeResult>;
|
|
1111
|
+
sessionRename(sessionId: string, name: string): Promise<SessionRenameResult>;
|
|
1112
|
+
sessionLast(runtimeId: string): Promise<SessionLastResult>;
|
|
1113
|
+
sessionLastSet(runtimeId: string, finalOutput: string, stopReason: string, truncated: boolean): Promise<void>;
|
|
1114
|
+
status(runtimeId?: string): Promise<Record<string, unknown>>;
|
|
686
1115
|
}
|
|
687
|
-
|
|
688
|
-
|
|
1116
|
+
/** One route's answer from a child surface's inherited broker. */
|
|
1117
|
+
interface ChildBroker {
|
|
1118
|
+
tell(targetRunId: string, message: string, messageId: string): Promise<ProviderResult>;
|
|
1119
|
+
ask(targetRunId: string, message: string, messageId: string, timeoutMs?: number, signal?: AbortSignal): Promise<ProviderResult>;
|
|
1120
|
+
reply(askerRunId: string, inboundAskId: string, message: string): Promise<ProviderResult>;
|
|
1121
|
+
withdraw(messageId: string): Promise<ProviderResult>;
|
|
1122
|
+
peers(): Promise<PeersProviderResult>;
|
|
1123
|
+
rename(req: {
|
|
1124
|
+
sessionId?: string;
|
|
1125
|
+
name: string;
|
|
1126
|
+
}): Promise<ProviderResult>;
|
|
1127
|
+
last(runId: string): Promise<ProviderResult>;
|
|
1128
|
+
}
|
|
1129
|
+
interface PendingAsk {
|
|
1130
|
+
from_run_id: string;
|
|
1131
|
+
message_id: string;
|
|
689
1132
|
}
|
|
690
|
-
|
|
1133
|
+
/** The broker rejected a receive because the caller's generation is stale. */
|
|
1134
|
+
declare function isGenerationMismatchError(error: unknown): boolean;
|
|
1135
|
+
interface HostProviderOptions {
|
|
1136
|
+
surface: MessageSurface;
|
|
1137
|
+
supervisorId: string;
|
|
1138
|
+
generation: string;
|
|
1139
|
+
client: MessageClient;
|
|
1140
|
+
/** The pending inbound asks the surface's poll fills; absent = no inbound. */
|
|
1141
|
+
pendingAsks?: Map<string, PendingAsk>;
|
|
1142
|
+
/** The poll generation a restore is scoped to, so a restart cannot resurrect an ask. */
|
|
1143
|
+
pollGeneration?: () => number;
|
|
1144
|
+
/** Runs after a successful resume registration; the surface's own tracking. */
|
|
1145
|
+
onResumed?: (result: ProviderResult) => void | Promise<void>;
|
|
1146
|
+
}
|
|
1147
|
+
type AskClaims = Map<string, {
|
|
1148
|
+
asker: string;
|
|
1149
|
+
generation: number;
|
|
1150
|
+
}>;
|
|
1151
|
+
/** Install the claim/restore pair both factories share, so a restart cannot resurrect a stale ask. */
|
|
1152
|
+
declare function installAskClaims(provider: MessageProvider, claims: AskClaims, pendingAsks: Map<string, PendingAsk>, pollGeneration: (() => number) | undefined): void;
|
|
1153
|
+
/**
|
|
1154
|
+
* Build the bound host provider: one supervisor, one generation, one control
|
|
1155
|
+
* client. It never reads an ambient singleton or retargets, and it never
|
|
1156
|
+
* preflights per call.
|
|
1157
|
+
*/
|
|
1158
|
+
declare function createHostMessageProvider(options: HostProviderOptions): MessageProvider;
|
|
1159
|
+
interface ChildProviderOptions {
|
|
1160
|
+
surface: MessageSurface;
|
|
1161
|
+
runId: string;
|
|
1162
|
+
broker: ChildBroker;
|
|
1163
|
+
/** The pending inbound asks the child's poll fills. */
|
|
1164
|
+
pendingAsks?: Map<string, PendingAsk>;
|
|
1165
|
+
/** The poll generation a restore is scoped to, so a restart cannot resurrect an ask. */
|
|
1166
|
+
pollGeneration?: () => number;
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Build a child provider over the surface's inherited broker. A child never
|
|
1170
|
+
* learns a public run id, and it cannot read a sentinel, so it is never
|
|
1171
|
+
* resumable from here: the supervisor owns a resume.
|
|
1172
|
+
*/
|
|
1173
|
+
declare function createChildMessageProvider(options: ChildProviderOptions): MessageProvider;
|
|
1174
|
+
//#endregion
|
|
1175
|
+
//#region src/tools/peers.d.ts
|
|
1176
|
+
interface PeersToolArgs extends PeersInput {}
|
|
1177
|
+
type PeersResult = PeersRouterResult;
|
|
1178
|
+
/** The one avenor_peers handler; it resolves and reads through the bound provider. */
|
|
1179
|
+
declare function peersTool(args: PeersToolArgs, provider: MessageProvider): Promise<PeersResult>;
|
|
1180
|
+
/** Bind the peers handler to one provider. */
|
|
1181
|
+
declare function createPeersTool(provider: MessageProvider): (args: PeersToolArgs) => Promise<PeersResult>;
|
|
691
1182
|
//#endregion
|
|
692
1183
|
//#region src/tools/kill.d.ts
|
|
693
1184
|
interface KillToolArgs {
|
|
@@ -704,6 +1195,10 @@ declare const killTool: (args: KillToolArgs) => Promise<KillResult>;
|
|
|
704
1195
|
//#region src/tools/broker-receive.d.ts
|
|
705
1196
|
interface BrokerReceiveArgs {
|
|
706
1197
|
supervisorId?: string;
|
|
1198
|
+
/** The generation this poll is bound to; absent asks the tool to preflight once. */
|
|
1199
|
+
generation?: string;
|
|
1200
|
+
/** Bound on the receive wait; the caller owns it, so the tool adds no default. */
|
|
1201
|
+
timeout_ms?: number;
|
|
707
1202
|
}
|
|
708
1203
|
interface InboundAsk {
|
|
709
1204
|
from_run_id: string;
|
|
@@ -713,21 +1208,11 @@ interface InboundAsk {
|
|
|
713
1208
|
}
|
|
714
1209
|
interface BrokerReceiveResult {
|
|
715
1210
|
asks: InboundAsk[];
|
|
1211
|
+
/** The generation the receive ran under, so the caller can bind its next poll. */
|
|
1212
|
+
generation?: string;
|
|
716
1213
|
}
|
|
717
1214
|
declare const brokerReceiveTool: (args: BrokerReceiveArgs) => Promise<BrokerReceiveResult>;
|
|
718
1215
|
//#endregion
|
|
719
|
-
//#region src/tools/broker-reply.d.ts
|
|
720
|
-
interface BrokerReplyArgs {
|
|
721
|
-
toRunId: string;
|
|
722
|
-
replyTo: string;
|
|
723
|
-
message: string;
|
|
724
|
-
supervisorId?: string;
|
|
725
|
-
}
|
|
726
|
-
interface BrokerReplyResult {
|
|
727
|
-
ok: true;
|
|
728
|
-
}
|
|
729
|
-
declare const brokerReplyTool: (args: BrokerReplyArgs) => Promise<BrokerReplyResult>;
|
|
730
|
-
//#endregion
|
|
731
1216
|
//#region src/tools/workflow-client.d.ts
|
|
732
1217
|
type GetSupervisorClient = typeof getSupervisorClient;
|
|
733
1218
|
//#endregion
|
|
@@ -805,4 +1290,19 @@ type WorkflowReadyResult = Record<string, unknown>;
|
|
|
805
1290
|
declare function createWorkflowReadyTool(getSupervisorClient: GetSupervisorClient): (args: WorkflowReadyToolArgs) => Promise<WorkflowReadyResult>;
|
|
806
1291
|
declare const workflowReadyTool: (args: WorkflowReadyToolArgs) => Promise<WorkflowReadyResult>;
|
|
807
1292
|
//#endregion
|
|
808
|
-
|
|
1293
|
+
//#region src/tools/workflow-cancel.d.ts
|
|
1294
|
+
interface WorkflowCancelArgs {
|
|
1295
|
+
workflow_id: string;
|
|
1296
|
+
actor: string;
|
|
1297
|
+
reason: string;
|
|
1298
|
+
supervisorId?: string;
|
|
1299
|
+
}
|
|
1300
|
+
type WorkflowCancelResult = Record<string, unknown>;
|
|
1301
|
+
/**
|
|
1302
|
+
* Cancel a workflow. The manager validates the actor before the reason, so the
|
|
1303
|
+
* handler checks them in the same order and forwards all three unchanged.
|
|
1304
|
+
*/
|
|
1305
|
+
declare function createWorkflowCancelTool(getSupervisorClient: GetSupervisorClient): (args: WorkflowCancelArgs) => Promise<WorkflowCancelResult>;
|
|
1306
|
+
declare const workflowCancelTool: (args: WorkflowCancelArgs) => Promise<WorkflowCancelResult>;
|
|
1307
|
+
//#endregion
|
|
1308
|
+
export { type AskClaims, type BrokerReceiveArgs, type BrokerReceiveResult, type ChildBroker, type Client, DEFAULT_RUN_REDUCER_LIMITS, type Event, type ExecutionIdentity, ForeignPeerError, type HistoryOptions, type HistoryResult, type InboundAsk, type InspectResult, type KillResult, type KillToolArgs, MAX_FINAL_OUTPUT_RUNES, MAX_WAIT_MS, MESSAGE_OUTCOMES, type MessageCallerKind, type MessageClient, type MessageInput, type MessageOutcome, type MessageProvider, type MessageSurface, type NormalizedRunEvent, type ObserveRunOptions, type OwnerAttachOptions, OwnerAuthError, OwnerRecordMissingError, type PeerRecord, type PeersInput, type PeersProviderResult, type PeersResult, type PeersRouterResult, type PeersToolArgs, type PendingAsk, type ProviderResult, type Resolution, type ResultResult, type ResultToolArgs, RpcError, type RunChunkRole, type RunFacts, 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, StaleOwnerRecordError, type StatusListResult, type StatusResult, type StatusToolArgs, type StatusView, type SubscribeOptions, Supervisor, type SupervisorClientOptions, type SupervisorOptions, THINKING_LEVELS, type ThinkingLevel, type ThinkingOutcome, ToolError, type WorkflowCancelArgs, type WorkflowCancelResult, type WorkflowCompleteParams, type WorkflowCompleteResult, type WorkflowCompleteToolArgs, type WorkflowControllerCreateParams, type WorkflowControllerStatusResult, type WorkflowControllerStatusToolArgs, type WorkflowEventsResult, type WorkflowEventsToolArgs, type WorkflowGateOperation, type WorkflowGateParams, type WorkflowGateResult, type WorkflowGateToolArgs, type WorkflowHeartbeatParams, type WorkflowInspectResult, type WorkflowInspectToolArgs, type WorkflowReadyResult, type WorkflowReadyToolArgs, type WorkflowStatusResult, type WorkflowStatusToolArgs, type WorkflowWaitResult, type WorkflowWaitToolArgs, answerPermissionTool, assertMessageInput, assertPeersInput, attachOwner, boundFinalOutput, brokerReceiveTool, createChildMessageProvider, createHostMessageProvider, createMessageTool, createPeersTool, createRunSnapshot, createWorkflowCancelTool, createWorkflowCompleteTool, createWorkflowControllerStatusTool, createWorkflowEventsTool, createWorkflowGateTool, createWorkflowInspectTool, createWorkflowReadyTool, createWorkflowStatusTool, createWorkflowWaitTool, dial, evaluateThinkingPolicy, eventsTool, executeMessage, executePeers, extractEventText, extractReplyMessage, extractTurnText, findAvenorBinary, getInstallDir, getSupervisorClient, getVersion, inspectTool, installAskClaims, installerBinaryPath, isGenerationMismatchError, isThinkingLevel, killTool, messageTool, newMsgID, normalizeAskTimeoutMs, normalizeRunEvent, normalizeTurnStopReason, observeRun, peersDetails, peersTool, quote, quoteList, reduceRunSnapshot, renderAskFailure, renderLast, renderOutcome, renderPeerList, repair, resultOutput, resultTool, sanitize, shutdownTool, socketsRoot, spawnTool, statusTool, validateSpawnSelection, validateThinking, validateThinkingForBackend, validateThinkingForBackendResume, workflowCancelTool, workflowCompleteTool, workflowControllerStatusTool, workflowEventsTool, workflowGateTool, workflowInspectTool, workflowReadyTool, workflowStatusTool, workflowWaitTool };
|