@agentfield/sdk 0.1.101 → 0.1.102-rc.2
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/dist/index.d.ts +328 -1
- package/dist/index.js +917 -226
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,112 @@ import { WriteStream } from 'node:tty';
|
|
|
7
7
|
import { ToolSet } from 'ai';
|
|
8
8
|
import { JWK } from 'jose';
|
|
9
9
|
|
|
10
|
+
type PauseLogger = {
|
|
11
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
12
|
+
};
|
|
13
|
+
/** Canonical human-decision values carried on an {@link ApprovalResult}. */
|
|
14
|
+
type ApprovalDecision = 'approved' | 'rejected' | 'request_changes' | 'expired' | 'error' | 'cancelled' | (string & {});
|
|
15
|
+
/**
|
|
16
|
+
* The outcome of a paused execution once a human (or upstream service)
|
|
17
|
+
* resolves it. Mirrors the Python SDK's `ApprovalResult` dataclass so a
|
|
18
|
+
* reasoner authored against either SDK reads the same fields.
|
|
19
|
+
*/
|
|
20
|
+
declare class ApprovalResult {
|
|
21
|
+
readonly decision: ApprovalDecision;
|
|
22
|
+
readonly feedback: string;
|
|
23
|
+
readonly executionId: string;
|
|
24
|
+
readonly approvalRequestId: string;
|
|
25
|
+
readonly rawResponse?: Record<string, any>;
|
|
26
|
+
constructor(params: {
|
|
27
|
+
decision: ApprovalDecision;
|
|
28
|
+
feedback?: string;
|
|
29
|
+
executionId?: string;
|
|
30
|
+
approvalRequestId?: string;
|
|
31
|
+
rawResponse?: Record<string, any>;
|
|
32
|
+
});
|
|
33
|
+
/** True when the human approved the request. */
|
|
34
|
+
get approved(): boolean;
|
|
35
|
+
/** True when the human asked for changes rather than approving/rejecting. */
|
|
36
|
+
get changesRequested(): boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Tracks how long a single execution has spent inside `ctx.pause()`.
|
|
40
|
+
*
|
|
41
|
+
* The async-execution watchdog (see Agent.runReasonerAsync) must not count
|
|
42
|
+
* time spent waiting for an external approval against the reasoner's active
|
|
43
|
+
* wall-clock budget — otherwise `expiresInHours` on a pause would be silently
|
|
44
|
+
* capped at the reasoner timeout. The watchdog reads `totalPaused()` and
|
|
45
|
+
* subtracts it from elapsed wall-clock. On the awaiter side, the same clock
|
|
46
|
+
* is used so a parent that is blocked waiting on a paused descendant does not
|
|
47
|
+
* burn its own budget.
|
|
48
|
+
*
|
|
49
|
+
* A reasoner runs as a single async chain, so pause intervals cannot overlap
|
|
50
|
+
* on one clock; no locking is needed. All values are milliseconds.
|
|
51
|
+
*/
|
|
52
|
+
declare class PauseClock {
|
|
53
|
+
private totalPausedMs;
|
|
54
|
+
private pauseStartedAt;
|
|
55
|
+
/**
|
|
56
|
+
* Set by the watchdog when it aborts the reasoner for exceeding the active
|
|
57
|
+
* budget. Distinguishes a budget-timeout abort from an external cooperative
|
|
58
|
+
* cancel arriving via the cancel dispatcher.
|
|
59
|
+
*/
|
|
60
|
+
timedOut: boolean;
|
|
61
|
+
startPause(): void;
|
|
62
|
+
endPause(): void;
|
|
63
|
+
/** Cumulative paused milliseconds, including any in-progress pause. */
|
|
64
|
+
totalPaused(): number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Registry of pending execution-pause promises resolved via webhook callback.
|
|
68
|
+
*
|
|
69
|
+
* Each `ctx.pause()` call registers a promise keyed by `approvalRequestId`.
|
|
70
|
+
* When the control plane POSTs a resolution to the agent's
|
|
71
|
+
* `/webhooks/approval` route, the matching promise is resolved and the paused
|
|
72
|
+
* reasoner unblocks. Mirrors the Python SDK's `_PauseManager`.
|
|
73
|
+
*/
|
|
74
|
+
declare class PauseManager {
|
|
75
|
+
private readonly pending;
|
|
76
|
+
/** execution_id -> approval_request_id, for fallback resolution. */
|
|
77
|
+
private readonly execToRequest;
|
|
78
|
+
/**
|
|
79
|
+
* Register a new pending pause and return the promise to await. Idempotent:
|
|
80
|
+
* a second register() for the same `approvalRequestId` returns the existing
|
|
81
|
+
* promise rather than replacing it.
|
|
82
|
+
*/
|
|
83
|
+
register(approvalRequestId: string, executionId?: string): Promise<ApprovalResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Resolve a pending pause by `approvalRequestId`. Returns true if a waiter
|
|
86
|
+
* was found and resolved, false otherwise.
|
|
87
|
+
*/
|
|
88
|
+
resolve(approvalRequestId: string, result: ApprovalResult): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Fallback: resolve by `executionId` when the callback omits the
|
|
91
|
+
* `approvalRequestId`. Returns true if a waiter was found.
|
|
92
|
+
*/
|
|
93
|
+
resolveByExecutionId(executionId: string, result: ApprovalResult): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Resolve every pending pause with a `cancelled` result. Used on shutdown so
|
|
96
|
+
* a reasoner blocked in `ctx.pause()` doesn't hang the process forever.
|
|
97
|
+
*/
|
|
98
|
+
cancelAll(): void;
|
|
99
|
+
/** Number of currently-pending pauses. Useful for tests. */
|
|
100
|
+
pendingCount(): number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Install the `POST /webhooks/approval` route on the agent's Express app.
|
|
104
|
+
*
|
|
105
|
+
* The control plane POSTs here (via the `callback_url` registered when the
|
|
106
|
+
* execution paused) once a human resolves the approval. The body carries
|
|
107
|
+
* `{ execution_id, decision, feedback, approval_request_id, response }`. We
|
|
108
|
+
* resolve the matching pending pause — first by `approval_request_id`, then by
|
|
109
|
+
* `execution_id` as a fallback — and reply `{ status, resolved }`.
|
|
110
|
+
*
|
|
111
|
+
* Always installed so the control plane reaches the worker regardless of which
|
|
112
|
+
* routes the user registered first (same rationale as installCancelRoute).
|
|
113
|
+
*/
|
|
114
|
+
declare function installApprovalWebhookRoute(app: express.Express, manager: PauseManager, logger?: PauseLogger): void;
|
|
115
|
+
|
|
10
116
|
type ZodSchema<T> = z.Schema<T, z.ZodTypeDef, any>;
|
|
11
117
|
interface AIRequestOptions {
|
|
12
118
|
system?: string;
|
|
@@ -274,6 +380,51 @@ interface ExecutionStatusUpdate {
|
|
|
274
380
|
progress?: number;
|
|
275
381
|
statusReason?: string;
|
|
276
382
|
}
|
|
383
|
+
/** Metadata forwarded as `X-*` headers on execute / executeAsync dispatch. */
|
|
384
|
+
interface ExecuteMetadata {
|
|
385
|
+
runId?: string;
|
|
386
|
+
workflowId?: string;
|
|
387
|
+
rootWorkflowId?: string;
|
|
388
|
+
parentExecutionId?: string;
|
|
389
|
+
reasonerId?: string;
|
|
390
|
+
sessionId?: string;
|
|
391
|
+
actorId?: string;
|
|
392
|
+
callerDid?: string;
|
|
393
|
+
targetDid?: string;
|
|
394
|
+
agentNodeDid?: string;
|
|
395
|
+
agentNodeId?: string;
|
|
396
|
+
replaySourceRunId?: string;
|
|
397
|
+
replayBeforeExecutionId?: string;
|
|
398
|
+
replayMode?: string;
|
|
399
|
+
}
|
|
400
|
+
/** Terminal (or in-flight) status snapshot from `GET /executions/{id}`. */
|
|
401
|
+
interface ExecutionStatusSnapshot {
|
|
402
|
+
executionId: string;
|
|
403
|
+
status: string;
|
|
404
|
+
statusReason?: string;
|
|
405
|
+
result?: any;
|
|
406
|
+
error?: string;
|
|
407
|
+
errorDetails?: unknown;
|
|
408
|
+
durationMs?: number;
|
|
409
|
+
}
|
|
410
|
+
/** Options for {@link AgentFieldClient.waitForExecutionResult}. */
|
|
411
|
+
interface WaitForExecutionOptions {
|
|
412
|
+
/** Total timeout in milliseconds. Omit for no wall-clock cap. */
|
|
413
|
+
timeoutMs?: number;
|
|
414
|
+
/** Initial poll interval in milliseconds (default: 1000). */
|
|
415
|
+
pollIntervalMs?: number;
|
|
416
|
+
/** Maximum poll interval in milliseconds (default: 5000). */
|
|
417
|
+
maxIntervalMs?: number;
|
|
418
|
+
/**
|
|
419
|
+
* Pause-clock whose paused time is excluded from the wall-clock timeout, so
|
|
420
|
+
* a parent awaiting a paused descendant does not spuriously time out.
|
|
421
|
+
*/
|
|
422
|
+
pauseClock?: PauseClock;
|
|
423
|
+
/** Fired once when the awaited child transitions into `waiting`. */
|
|
424
|
+
onChildWaiting?: () => void | Promise<void>;
|
|
425
|
+
/** Fired once when the awaited child leaves `waiting` (back to running). */
|
|
426
|
+
onChildRunning?: () => void | Promise<void>;
|
|
427
|
+
}
|
|
277
428
|
interface RestartExecutionOptions {
|
|
278
429
|
scope?: 'workflow' | 'execution';
|
|
279
430
|
reuse?: 'succeeded-before' | 'all-succeeded' | 'none';
|
|
@@ -326,6 +477,61 @@ declare class AgentFieldClient {
|
|
|
326
477
|
}): Promise<void>;
|
|
327
478
|
publishExecutionLogs(payload: ExecutionLogTransportPayload): void;
|
|
328
479
|
updateExecutionStatus(executionId: string, update: ExecutionStatusUpdate): Promise<void>;
|
|
480
|
+
/** Build the `X-*` dispatch headers shared by execute / executeAsync. */
|
|
481
|
+
private buildExecuteHeaders;
|
|
482
|
+
/**
|
|
483
|
+
* Submit an async execution and return its `execution_id`.
|
|
484
|
+
*
|
|
485
|
+
* POSTs to `/api/v1/execute/async/{target}`, which enqueues the execution
|
|
486
|
+
* and responds `202 Accepted` immediately (the control plane runs it and
|
|
487
|
+
* tracks status out-of-band). Use with {@link waitForExecutionResult} to
|
|
488
|
+
* poll for the terminal result without holding a synchronous connection —
|
|
489
|
+
* this is what lets a parent await a descendant that legitimately pauses
|
|
490
|
+
* (WAITING) for a long time without hitting the dispatch ceiling.
|
|
491
|
+
*/
|
|
492
|
+
executeAsync(target: string, input: any, metadata?: ExecuteMetadata): Promise<string>;
|
|
493
|
+
/** Fetch the current status snapshot for an execution. */
|
|
494
|
+
getExecutionStatus(executionId: string): Promise<ExecutionStatusSnapshot>;
|
|
495
|
+
/**
|
|
496
|
+
* Poll an async execution until it reaches a terminal status, returning its
|
|
497
|
+
* result (or throwing on failure/cancellation/timeout).
|
|
498
|
+
*
|
|
499
|
+
* While polling, this observes the child's status transitions: when the
|
|
500
|
+
* child enters `waiting` it starts the supplied pause-clock and fires
|
|
501
|
+
* `onChildWaiting`; when the child leaves `waiting` it stops the clock and
|
|
502
|
+
* fires `onChildRunning`. Paused time is excluded from `timeoutMs`, so a
|
|
503
|
+
* parent awaiting a paused descendant does not time out while the descendant
|
|
504
|
+
* legitimately waits. Mirrors the Python SDK's `wait_for_execution_result`.
|
|
505
|
+
*/
|
|
506
|
+
waitForExecutionResult<T = any>(executionId: string, opts?: WaitForExecutionOptions): Promise<T>;
|
|
507
|
+
/**
|
|
508
|
+
* Notify the control plane that THIS execution is now `waiting` or `running`
|
|
509
|
+
* because of its awaited child's state — the multi-hop pause propagation
|
|
510
|
+
* hook. Distinct from request-approval: no approval id, no webhook, no human.
|
|
511
|
+
* It exists purely so ancestors watching this execution see WAITING
|
|
512
|
+
* transitively while a descendant is paused, and stop counting wall-clock.
|
|
513
|
+
*
|
|
514
|
+
* POSTs to `/api/v1/agents/{node}/executions/{id}/awaiter-status`.
|
|
515
|
+
*/
|
|
516
|
+
notifyAwaiterStatus(executionId: string, status: 'waiting' | 'running', reason?: string): Promise<void>;
|
|
517
|
+
/**
|
|
518
|
+
* Deliver a terminal execution result to the control plane, with retries.
|
|
519
|
+
*
|
|
520
|
+
* This is the out-of-band completion callback used by async-execution
|
|
521
|
+
* dispatch: after a reasoner has been 202-acked and run detached, its final
|
|
522
|
+
* status (`succeeded` / `failed` / `cancelled`) is POSTed to
|
|
523
|
+
* `/api/v1/executions/{id}/status`. Retries with exponential backoff because
|
|
524
|
+
* a dropped terminal callback would leave the execution stuck forever.
|
|
525
|
+
*/
|
|
526
|
+
reportExecutionResult(executionId: string, payload: {
|
|
527
|
+
status: string;
|
|
528
|
+
result?: any;
|
|
529
|
+
error?: string;
|
|
530
|
+
errorDetails?: unknown;
|
|
531
|
+
durationMs?: number;
|
|
532
|
+
completedAt?: string;
|
|
533
|
+
reasoner?: string;
|
|
534
|
+
}, maxRetries?: number): Promise<boolean>;
|
|
329
535
|
discoverCapabilities(options?: DiscoveryOptions): Promise<DiscoveryResult>;
|
|
330
536
|
private mapDiscoveryResponse;
|
|
331
537
|
private mapCompactDiscovery;
|
|
@@ -708,6 +914,22 @@ declare class ReasonerContext<TInput = any> {
|
|
|
708
914
|
}>;
|
|
709
915
|
aiStream(prompt: string, options?: AIRequestOptions): Promise<AIStream>;
|
|
710
916
|
call(target: string, input: any): Promise<any>;
|
|
917
|
+
/**
|
|
918
|
+
* Pause this execution for external approval / resumption.
|
|
919
|
+
*
|
|
920
|
+
* Transitions the execution to `waiting` on the control plane and blocks
|
|
921
|
+
* until a decision arrives via the agent's approval webhook, or the timeout
|
|
922
|
+
* elapses (returning `{ decision: 'expired' }`). The caller creates the
|
|
923
|
+
* approval request on an external service first and passes its
|
|
924
|
+
* `approvalRequestId`. Delegates to {@link Agent.pause}. See its docs for the
|
|
925
|
+
* async-execution requirement that lets a pause outlive the dispatch ceiling.
|
|
926
|
+
*/
|
|
927
|
+
pause(opts: {
|
|
928
|
+
approvalRequestId: string;
|
|
929
|
+
approvalRequestUrl?: string;
|
|
930
|
+
expiresInHours?: number;
|
|
931
|
+
timeoutMs?: number;
|
|
932
|
+
}): Promise<ApprovalResult>;
|
|
711
933
|
discover(options?: DiscoveryOptions): Promise<DiscoveryResult>;
|
|
712
934
|
note(message: string, tags?: string[]): void;
|
|
713
935
|
}
|
|
@@ -879,6 +1101,25 @@ interface AgentConfig {
|
|
|
879
1101
|
verificationRefreshInterval?: number;
|
|
880
1102
|
/** Agent-level tags for tag-based authorization policies. */
|
|
881
1103
|
tags?: string[];
|
|
1104
|
+
/**
|
|
1105
|
+
* Enable async-execution dispatch (default: true). When enabled, a reasoner
|
|
1106
|
+
* invoked by the control plane (i.e. carrying an `X-Execution-ID` header) is
|
|
1107
|
+
* acknowledged immediately with `202 Accepted` and run detached; its terminal
|
|
1108
|
+
* result is delivered out-of-band via `POST /executions/{id}/status`. This is
|
|
1109
|
+
* what lets a reasoner call `ctx.pause()` and wait far longer than the
|
|
1110
|
+
* control plane's synchronous dispatch ceiling. Set to `false` to keep the
|
|
1111
|
+
* legacy behaviour of holding the HTTP connection open until the reasoner
|
|
1112
|
+
* returns (in which case `ctx.pause()` is bounded by that ceiling).
|
|
1113
|
+
*/
|
|
1114
|
+
asyncExecution?: boolean;
|
|
1115
|
+
/**
|
|
1116
|
+
* Active-time wall-clock budget for a detached reasoner, in milliseconds
|
|
1117
|
+
* (default: 7_200_000 = 2h). Time spent inside `ctx.pause()` (and waiting on
|
|
1118
|
+
* a paused descendant) is excluded from this budget. When active time exceeds
|
|
1119
|
+
* it, the reasoner is aborted and reported as failed with reason
|
|
1120
|
+
* `reasoner_timeout`. Only applies when `asyncExecution` is enabled.
|
|
1121
|
+
*/
|
|
1122
|
+
executionBudgetMs?: number;
|
|
882
1123
|
}
|
|
883
1124
|
interface AIConfig {
|
|
884
1125
|
provider?: 'openai' | 'anthropic' | 'google' | 'mistral' | 'groq' | 'xai' | 'deepseek' | 'cohere' | 'openrouter' | 'ollama';
|
|
@@ -1164,7 +1405,26 @@ declare class Agent {
|
|
|
1164
1405
|
* code that respects `signal.aborted` (fetch, anthropic SDK, openai
|
|
1165
1406
|
* SDK, etc.). See ./cancel.ts. */
|
|
1166
1407
|
private readonly cancelRegistry;
|
|
1408
|
+
/** Registry of pending `ctx.pause()` promises, resolved by the
|
|
1409
|
+
* `/webhooks/approval` route when the control plane delivers a decision.
|
|
1410
|
+
* See ./pause.ts. */
|
|
1411
|
+
private readonly pauseManager;
|
|
1412
|
+
/** Per-execution pause clocks, keyed by execution_id. Present only for
|
|
1413
|
+
* detached (async-execution) reasoners; used to exclude pause/await time
|
|
1414
|
+
* from the reasoner's active wall-clock budget and from an awaiter's wait
|
|
1415
|
+
* timeout. See ./pause.ts. */
|
|
1416
|
+
private readonly pauseClocks;
|
|
1417
|
+
/** Execution-scoped approval client used by `Agent.pause()`. */
|
|
1418
|
+
private readonly approvalClient;
|
|
1167
1419
|
constructor(config: AgentConfig);
|
|
1420
|
+
/** Coerce the loosely-typed `defaultHeaders` config into string headers. */
|
|
1421
|
+
private sanitizeDefaultHeaders;
|
|
1422
|
+
/**
|
|
1423
|
+
* Resolve the externally-reachable base URL for this agent — the URL the
|
|
1424
|
+
* control plane uses to call back (approval webhook, cancel). Mirrors the
|
|
1425
|
+
* value published at registration time.
|
|
1426
|
+
*/
|
|
1427
|
+
private resolvePublicUrl;
|
|
1168
1428
|
reasoner<TInput = any, TOutput = any>(name: string, handler: ReasonerHandler<TInput, TOutput>, options?: ReasonerOptions): this;
|
|
1169
1429
|
skill<TInput = any, TOutput = any>(name: string, handler: SkillHandler<TInput, TOutput>, options?: SkillOptions): this;
|
|
1170
1430
|
includeRouter(router: AgentRouter): void;
|
|
@@ -1184,10 +1444,48 @@ declare class Agent {
|
|
|
1184
1444
|
getWorkflowReporter(metadata: ExecutionMetadata): WorkflowReporter;
|
|
1185
1445
|
getDidInterface(metadata: ExecutionMetadata, defaultInput?: any, targetName?: string): DidInterface;
|
|
1186
1446
|
note(message: string, tags?: string[], metadata?: ExecutionMetadata): void;
|
|
1447
|
+
/**
|
|
1448
|
+
* Pause the current execution for external approval / resumption.
|
|
1449
|
+
*
|
|
1450
|
+
* Transitions the execution to `waiting` on the control plane, then blocks
|
|
1451
|
+
* until the approval webhook callback resolves it or the timeout elapses.
|
|
1452
|
+
* The caller is responsible for creating the approval request on an external
|
|
1453
|
+
* service (e.g. hax-sdk) *before* calling this and passing the resulting
|
|
1454
|
+
* `approvalRequestId`.
|
|
1455
|
+
*
|
|
1456
|
+
* Requires the agent to be serving (a reachable callback URL) and, to survive
|
|
1457
|
+
* past the control plane's synchronous dispatch ceiling, requires
|
|
1458
|
+
* async-execution dispatch to be enabled (the default). When async dispatch
|
|
1459
|
+
* is disabled the pause still works but is bounded by that ceiling.
|
|
1460
|
+
*
|
|
1461
|
+
* Returns an {@link ApprovalResult}. On timeout it returns
|
|
1462
|
+
* `{ decision: 'expired' }` rather than throwing. Mirrors the Python SDK's
|
|
1463
|
+
* `Agent.pause()`.
|
|
1464
|
+
*/
|
|
1465
|
+
pause(opts: {
|
|
1466
|
+
approvalRequestId: string;
|
|
1467
|
+
approvalRequestUrl?: string;
|
|
1468
|
+
expiresInHours?: number;
|
|
1469
|
+
timeoutMs?: number;
|
|
1470
|
+
executionId?: string;
|
|
1471
|
+
}): Promise<ApprovalResult>;
|
|
1187
1472
|
private buildExecutionLogContext;
|
|
1188
1473
|
serve(): Promise<void>;
|
|
1189
1474
|
shutdown(): Promise<void>;
|
|
1190
1475
|
call(target: string, input: any): Promise<any>;
|
|
1476
|
+
/**
|
|
1477
|
+
* Remote call variant that submits the execution asynchronously and polls for
|
|
1478
|
+
* its result, instead of holding a synchronous connection open. This lets a
|
|
1479
|
+
* caller await a descendant that legitimately pauses (WAITING) for a long
|
|
1480
|
+
* time without tripping the control plane's synchronous dispatch ceiling.
|
|
1481
|
+
*
|
|
1482
|
+
* Multi-hop pause propagation: if the caller itself is a detached reasoner
|
|
1483
|
+
* (has a registered pause-clock), then when the awaited child enters WAITING
|
|
1484
|
+
* we push the caller's own execution to WAITING via awaiter-status — so any
|
|
1485
|
+
* ancestor awaiting the caller transitively sees WAITING too and doesn't time
|
|
1486
|
+
* out. Mirrors the propagation wiring in the Python SDK's `Agent.call`.
|
|
1487
|
+
*/
|
|
1488
|
+
private callRemoteAsync;
|
|
1191
1489
|
private registerDefaultRoutes;
|
|
1192
1490
|
private executeReasoner;
|
|
1193
1491
|
private executeSkill;
|
|
@@ -1207,6 +1505,35 @@ declare class Agent {
|
|
|
1207
1505
|
private skillDefinitions;
|
|
1208
1506
|
private discoveryPayload;
|
|
1209
1507
|
private executeInvocation;
|
|
1508
|
+
/**
|
|
1509
|
+
* True when an incoming reasoner dispatch should run detached (202-ack).
|
|
1510
|
+
*
|
|
1511
|
+
* Requires async execution to be enabled AND the request to carry BOTH
|
|
1512
|
+
* `X-Execution-ID` and `X-Run-ID`. The `X-Run-ID` header is the marker that
|
|
1513
|
+
* the control plane dispatched this via an async-aware path — the workflow
|
|
1514
|
+
* execute paths (`/execute`, `/execute/async`, agent-to-agent calls, triggers)
|
|
1515
|
+
* always set it (see control-plane callAgent), and those paths wait for the
|
|
1516
|
+
* out-of-band `/status` result. The legacy synchronous invoke endpoint
|
|
1517
|
+
* (`POST /api/v1/reasoners/{node}.{reasoner}`) omits `X-Run-ID` for
|
|
1518
|
+
* long-running agents and forwards the agent's HTTP response verbatim; it
|
|
1519
|
+
* cannot handle a 202, so we must run synchronously there and return the
|
|
1520
|
+
* result inline. Direct HTTP callers / tests without these headers likewise
|
|
1521
|
+
* keep the synchronous request/response contract.
|
|
1522
|
+
*/
|
|
1523
|
+
private shouldRunAsync;
|
|
1524
|
+
/** True when the request carries a non-empty value for the given header. */
|
|
1525
|
+
private hasHeader;
|
|
1526
|
+
/**
|
|
1527
|
+
* Run a reasoner detached after its dispatch was 202-acked, delivering the
|
|
1528
|
+
* terminal status out-of-band via `POST /executions/{id}/status`.
|
|
1529
|
+
*
|
|
1530
|
+
* A pause-clock is registered for the execution so `ctx.pause()` (and any
|
|
1531
|
+
* awaited paused descendant) can exclude its wait from the active wall-clock
|
|
1532
|
+
* budget. A watchdog aborts the reasoner if active time exceeds the budget,
|
|
1533
|
+
* guaranteeing the control plane always sees a terminal status even if the
|
|
1534
|
+
* reasoner hangs. Mirrors the Python SDK's `_execute_async_with_callback`.
|
|
1535
|
+
*/
|
|
1536
|
+
private runReasonerAsync;
|
|
1210
1537
|
private runReasoner;
|
|
1211
1538
|
private runSkill;
|
|
1212
1539
|
private registerWithControlPlane;
|
|
@@ -2067,4 +2394,4 @@ declare class SessionTransportError extends Error {
|
|
|
2067
2394
|
declare function normalizeSessionTransportValue(value: string): string;
|
|
2068
2395
|
declare function validateSessionTransport(provider: string, transport: string): SessionTransportCapability;
|
|
2069
2396
|
|
|
2070
|
-
export { ACTIVE_STATUSES, AIClient, type AIConfig, type AIEmbeddingOptions, type AIRequestOptions, type AIStream, type AIToolRequestOptions, Agent, type AgentCapability, type AgentConfig, type AgentHandler, AgentRouter, type AgentRouterOptions, type AgentState, ApprovalClient, type ApprovalRequestResponse, type ApprovalStatusResponse, Audio, type AudioOutput, type AudioRequest, type AuditTrailExport, type AuditTrailFilters, type Awaitable, CANONICAL_STATUSES, type CompactCapability, type CompactDiscoveryResponse, DIDAuthenticator, type DIDIdentity, type DIDIdentityPackage, type DIDRegistrationRequest, type DIDRegistrationResponse, type DeploymentType, DidClient, DidInterface, DidManager, type DidResolver, type DiscoveryFormat, type DiscoveryOptions, type DiscoveryPagination, type DiscoveryResponse, type DiscoveryResult, ExecutionContext, type ExecutionCredential, type ExecutionLogAttributes, type ExecutionLogBatchPayload, type ExecutionLogContext, type ExecutionLogEmitOptions, type ExecutionLogEntry, type ExecutionLogLevel, type ExecutionLogTransport, type ExecutionLogTransportPayload, type ExecutionLogWireEntry, ExecutionLogger, type ExecutionLoggerOptions, type ExecutionMetadata, ExecutionStatus, type ExecutionStatusValue, File, type FileOutput, type GenerateCredentialOptions, type GenerateCredentialParams, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, type HarnessConfig, type HarnessOptions, type HarnessProvider, type HarnessResult, HarnessRunner, type HealthStatus, Image, type ImageOutput, type ImageRequest, JWE_ALG, JWE_ENC, KEY_AGREEMENT_TYPE, type MediaProvider, MediaProviderError, type MediaResponse, MediaRouter, type MemoryChangeEvent, MemoryClient, MemoryClientBase, type MemoryConfig, MemoryEventClient, type MemoryEventHandler, type MemoryEventHistoryOptions, MemoryInterface, type MemoryRequestMetadata, type MemoryRequestOptions, type MemoryScope, type MemoryWatchHandler, type Metrics, type MultimodalContent, MultimodalResponse, OpenRouterMediaProvider, type OpenRouterMediaProviderOptions, type Payload, PayloadEncryptionError, RateLimitError, type RateLimiterOptions, type RawExecutionContext, type RawResult, RealtimeSession, type ReasonerCapability, ReasonerContext, type ReasonerDefinition, type ReasonerHandler, type ReasonerOptions, type RequestApprovalPayload, SUPPORTED_PROVIDERS, SUPPORTED_SESSION_TRANSPORTS, type ServerlessAdapter, type ServerlessEvent, type ServerlessResponse, type SessionDefinition, type SessionOptions, type SessionProvider, type SessionTransport, type SessionTransportCapability, SessionTransportError, type SessionTurn, type SkillCapability, SkillContext, type SkillDefinition, type SkillHandler, type SkillOptions, StatelessRateLimiter, TERMINAL_STATUSES, Text, type ToolCallConfig, type ToolCallRecord, type ToolCallTrace, type ToolsOption, type VectorSearchOptions, type VectorSearchResult, Video, type VideoFrameImage, type VideoInputReference, type VideoRequest, type WaitForApprovalOptions, type WorkflowCredential, type WorkflowMetadata, type WorkflowProgressOptions, WorkflowReporter, type ZodSchema, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, buildProvider, buildSessionDefinition, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, decrypt, decryptToString, encryptForDid, encryptToJwk, executeToolCallLoop, extractKeyAgreementJwk, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, generateX25519KeyPair, getCurrentContext, getCurrentSkillContext, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, isActive, isExecutionLogBatchPayload, isTerminal, normalizeExecutionLogEntry, normalizeSessionTransportValue, normalizeStatus, serializeExecutionLogEntry, text, validateSessionTransport, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };
|
|
2397
|
+
export { ACTIVE_STATUSES, AIClient, type AIConfig, type AIEmbeddingOptions, type AIRequestOptions, type AIStream, type AIToolRequestOptions, Agent, type AgentCapability, type AgentConfig, type AgentHandler, AgentRouter, type AgentRouterOptions, type AgentState, ApprovalClient, type ApprovalDecision, type ApprovalRequestResponse, ApprovalResult, type ApprovalStatusResponse, Audio, type AudioOutput, type AudioRequest, type AuditTrailExport, type AuditTrailFilters, type Awaitable, CANONICAL_STATUSES, type CompactCapability, type CompactDiscoveryResponse, DIDAuthenticator, type DIDIdentity, type DIDIdentityPackage, type DIDRegistrationRequest, type DIDRegistrationResponse, type DeploymentType, DidClient, DidInterface, DidManager, type DidResolver, type DiscoveryFormat, type DiscoveryOptions, type DiscoveryPagination, type DiscoveryResponse, type DiscoveryResult, ExecutionContext, type ExecutionCredential, type ExecutionLogAttributes, type ExecutionLogBatchPayload, type ExecutionLogContext, type ExecutionLogEmitOptions, type ExecutionLogEntry, type ExecutionLogLevel, type ExecutionLogTransport, type ExecutionLogTransportPayload, type ExecutionLogWireEntry, ExecutionLogger, type ExecutionLoggerOptions, type ExecutionMetadata, ExecutionStatus, type ExecutionStatusValue, File, type FileOutput, type GenerateCredentialOptions, type GenerateCredentialParams, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, type HarnessConfig, type HarnessOptions, type HarnessProvider, type HarnessResult, HarnessRunner, type HealthStatus, Image, type ImageOutput, type ImageRequest, JWE_ALG, JWE_ENC, KEY_AGREEMENT_TYPE, type MediaProvider, MediaProviderError, type MediaResponse, MediaRouter, type MemoryChangeEvent, MemoryClient, MemoryClientBase, type MemoryConfig, MemoryEventClient, type MemoryEventHandler, type MemoryEventHistoryOptions, MemoryInterface, type MemoryRequestMetadata, type MemoryRequestOptions, type MemoryScope, type MemoryWatchHandler, type Metrics, type MultimodalContent, MultimodalResponse, OpenRouterMediaProvider, type OpenRouterMediaProviderOptions, PauseClock, PauseManager, type Payload, PayloadEncryptionError, RateLimitError, type RateLimiterOptions, type RawExecutionContext, type RawResult, RealtimeSession, type ReasonerCapability, ReasonerContext, type ReasonerDefinition, type ReasonerHandler, type ReasonerOptions, type RequestApprovalPayload, SUPPORTED_PROVIDERS, SUPPORTED_SESSION_TRANSPORTS, type ServerlessAdapter, type ServerlessEvent, type ServerlessResponse, type SessionDefinition, type SessionOptions, type SessionProvider, type SessionTransport, type SessionTransportCapability, SessionTransportError, type SessionTurn, type SkillCapability, SkillContext, type SkillDefinition, type SkillHandler, type SkillOptions, StatelessRateLimiter, TERMINAL_STATUSES, Text, type ToolCallConfig, type ToolCallRecord, type ToolCallTrace, type ToolsOption, type VectorSearchOptions, type VectorSearchResult, Video, type VideoFrameImage, type VideoInputReference, type VideoRequest, type WaitForApprovalOptions, type WorkflowCredential, type WorkflowMetadata, type WorkflowProgressOptions, WorkflowReporter, type ZodSchema, audioFromBase64, audioFromBuffer, audioFromFile, audioFromUrl, buildProvider, buildSessionDefinition, buildToolConfig, capabilitiesToTools, capabilityToMetadataTool, capabilityToTool, createExecutionLogger, createHarnessResult, createMetrics, createMultimodalResponse, createRawResult, decrypt, decryptToString, encryptForDid, encryptToJwk, executeToolCallLoop, extractKeyAgreementJwk, fileFromBase64, fileFromBuffer, fileFromPath, fileFromUrl, generateX25519KeyPair, getCurrentContext, getCurrentSkillContext, imageFromBase64, imageFromBuffer, imageFromFile, imageFromUrl, installApprovalWebhookRoute, isActive, isExecutionLogBatchPayload, isTerminal, normalizeExecutionLogEntry, normalizeSessionTransportValue, normalizeStatus, serializeExecutionLogEntry, text, validateSessionTransport, videoFromBase64, videoFromBuffer, videoFromFile, videoFromUrl };
|