@dougbots/avenor-core 0.15.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 +493 -68
- package/dist/index.js +6613 -403
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -144,6 +144,105 @@ 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;
|
|
@@ -225,17 +324,23 @@ declare class Client {
|
|
|
225
324
|
workflowControllerCreate(params: WorkflowControllerCreateParams): Promise<Record<string, unknown>>;
|
|
226
325
|
workflowControllerEnable(controllerId: string): Promise<Record<string, unknown>>;
|
|
227
326
|
workflowControllerDisable(controllerId: string, reason: string): Promise<Record<string, unknown>>;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
brokerReceive(): Promise<Array<{
|
|
233
|
-
from_run_id: string;
|
|
327
|
+
messageSend(params: MessageSendParams): Promise<MessageSendResult>;
|
|
328
|
+
messageWait(params: MessageWaitParams): Promise<MessageWaitResult>;
|
|
329
|
+
messageReply(params: {
|
|
330
|
+
to_run_id: string;
|
|
234
331
|
message_id: string;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
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>>;
|
|
239
344
|
isClosed(): boolean;
|
|
240
345
|
close(): void;
|
|
241
346
|
}
|
|
@@ -488,6 +593,20 @@ declare class Supervisor {
|
|
|
488
593
|
* Public run IDs are canonical; labels are lookup-only aliases.
|
|
489
594
|
*/
|
|
490
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;
|
|
491
610
|
/** Match a stored run by its broker runtime ID. */
|
|
492
611
|
getRunByRuntimeId(runtimeId: string): RunInfo | undefined;
|
|
493
612
|
/**
|
|
@@ -689,20 +808,6 @@ declare function answerPermissionTool(args: {
|
|
|
689
808
|
ok: boolean;
|
|
690
809
|
}>;
|
|
691
810
|
//#endregion
|
|
692
|
-
//#region src/tools/follow-up.d.ts
|
|
693
|
-
interface FollowUpToolArgs {
|
|
694
|
-
runId: string;
|
|
695
|
-
message: string;
|
|
696
|
-
label?: string;
|
|
697
|
-
supervisorId?: string;
|
|
698
|
-
}
|
|
699
|
-
interface FollowUpToolResult {
|
|
700
|
-
run_id: string;
|
|
701
|
-
label: string;
|
|
702
|
-
runtime_id?: string;
|
|
703
|
-
}
|
|
704
|
-
declare const followUpTool: (args: FollowUpToolArgs) => Promise<FollowUpToolResult>;
|
|
705
|
-
//#endregion
|
|
706
811
|
//#region src/tools/shutdown.d.ts
|
|
707
812
|
declare function shutdownTool(args: {
|
|
708
813
|
supervisorId?: string;
|
|
@@ -712,57 +817,368 @@ declare function shutdownTool(args: {
|
|
|
712
817
|
cleaned_up: string[];
|
|
713
818
|
}>;
|
|
714
819
|
//#endregion
|
|
715
|
-
//#region src/
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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. */
|
|
726
872
|
declare function extractReplyMessage(result: Record<string, unknown>): string;
|
|
727
873
|
/**
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
* already gone.
|
|
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.
|
|
731
876
|
*/
|
|
732
|
-
declare function
|
|
877
|
+
declare function renderAskFailure(messageId: string, target: string, outcome?: MessageOutcome): string;
|
|
733
878
|
/**
|
|
734
879
|
* Reduce a caller-supplied ask timeout to what the broker accepts: a positive
|
|
735
880
|
* finite number of milliseconds, or undefined to keep the broker's own wait.
|
|
736
881
|
*/
|
|
737
882
|
declare function normalizeAskTimeoutMs(timeoutMs: number | undefined): number | undefined;
|
|
738
|
-
declare const askTool: (args: AskToolArgs) => Promise<AskResult>;
|
|
739
883
|
//#endregion
|
|
740
|
-
//#region src/
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
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 {
|
|
745
889
|
run_id: string;
|
|
746
890
|
label?: string;
|
|
891
|
+
kind?: string;
|
|
747
892
|
status?: string;
|
|
748
893
|
backend?: string;
|
|
749
894
|
model?: string;
|
|
750
895
|
dir?: string;
|
|
751
896
|
}
|
|
752
|
-
|
|
753
|
-
|
|
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;
|
|
754
934
|
}
|
|
755
|
-
|
|
935
|
+
interface PeersProviderResult {
|
|
936
|
+
peers: PeerRecord[];
|
|
937
|
+
/** Set when the transport returned peers together with an error. */
|
|
938
|
+
detail?: string;
|
|
939
|
+
}
|
|
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>;
|
|
756
1059
|
//#endregion
|
|
757
|
-
//#region src/tools/
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
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>>;
|
|
761
1115
|
}
|
|
762
|
-
|
|
763
|
-
|
|
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;
|
|
1132
|
+
}
|
|
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;
|
|
764
1167
|
}
|
|
765
|
-
|
|
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>;
|
|
766
1182
|
//#endregion
|
|
767
1183
|
//#region src/tools/kill.d.ts
|
|
768
1184
|
interface KillToolArgs {
|
|
@@ -779,6 +1195,10 @@ declare const killTool: (args: KillToolArgs) => Promise<KillResult>;
|
|
|
779
1195
|
//#region src/tools/broker-receive.d.ts
|
|
780
1196
|
interface BrokerReceiveArgs {
|
|
781
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;
|
|
782
1202
|
}
|
|
783
1203
|
interface InboundAsk {
|
|
784
1204
|
from_run_id: string;
|
|
@@ -788,21 +1208,11 @@ interface InboundAsk {
|
|
|
788
1208
|
}
|
|
789
1209
|
interface BrokerReceiveResult {
|
|
790
1210
|
asks: InboundAsk[];
|
|
1211
|
+
/** The generation the receive ran under, so the caller can bind its next poll. */
|
|
1212
|
+
generation?: string;
|
|
791
1213
|
}
|
|
792
1214
|
declare const brokerReceiveTool: (args: BrokerReceiveArgs) => Promise<BrokerReceiveResult>;
|
|
793
1215
|
//#endregion
|
|
794
|
-
//#region src/tools/broker-reply.d.ts
|
|
795
|
-
interface BrokerReplyArgs {
|
|
796
|
-
toRunId: string;
|
|
797
|
-
replyTo: string;
|
|
798
|
-
message: string;
|
|
799
|
-
supervisorId?: string;
|
|
800
|
-
}
|
|
801
|
-
interface BrokerReplyResult {
|
|
802
|
-
ok: true;
|
|
803
|
-
}
|
|
804
|
-
declare const brokerReplyTool: (args: BrokerReplyArgs) => Promise<BrokerReplyResult>;
|
|
805
|
-
//#endregion
|
|
806
1216
|
//#region src/tools/workflow-client.d.ts
|
|
807
1217
|
type GetSupervisorClient = typeof getSupervisorClient;
|
|
808
1218
|
//#endregion
|
|
@@ -880,4 +1290,19 @@ type WorkflowReadyResult = Record<string, unknown>;
|
|
|
880
1290
|
declare function createWorkflowReadyTool(getSupervisorClient: GetSupervisorClient): (args: WorkflowReadyToolArgs) => Promise<WorkflowReadyResult>;
|
|
881
1291
|
declare const workflowReadyTool: (args: WorkflowReadyToolArgs) => Promise<WorkflowReadyResult>;
|
|
882
1292
|
//#endregion
|
|
883
|
-
|
|
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 };
|