@ai-sdk/harness 1.0.133 → 1.0.134
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/CHANGELOG.md +14 -0
- package/dist/agent/index.d.ts +1546 -1509
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +4419 -5044
- package/dist/agent/index.js.map +1 -1
- package/dist/bridge/index.d.ts +141 -139
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +579 -650
- package/dist/bridge/index.js.map +1 -1
- package/dist/index.d.ts +1447 -1422
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +703 -668
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +551 -522
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +1910 -2465
- package/dist/utils/index.js.map +1 -1
- package/package.json +9 -9
- package/src/bridge/index.ts +1 -1
package/dist/bridge/index.d.ts
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
import { ToolResultPart } from
|
|
2
|
-
|
|
1
|
+
import { ToolResultPart } from "@ai-sdk/provider-utils";
|
|
2
|
+
//#region src/bridge/harness-bridge-capability-unsupported-error.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Signals an unsupported capability discovered inside a sandbox bridge.
|
|
5
5
|
* `isInstance` also recognizes the serialized error shape received by the
|
|
6
6
|
* host, where it can be translated to `HarnessCapabilityUnsupportedError`.
|
|
7
7
|
*/
|
|
8
|
-
declare class HarnessBridgeCapabilityUnsupportedError extends Error {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export declare class HarnessBridgeCapabilityUnsupportedError extends Error {
|
|
9
|
+
readonly harnessId?: string;
|
|
10
|
+
readonly cause?: unknown;
|
|
11
|
+
constructor({ message, harnessId, cause }: {
|
|
12
|
+
message: string;
|
|
13
|
+
harnessId?: string;
|
|
14
|
+
cause?: unknown;
|
|
15
|
+
});
|
|
16
|
+
static isInstance(error: unknown): error is HarnessBridgeCapabilityUnsupportedError;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/bridge/index.d.ts
|
|
19
20
|
type BridgeState = 'init' | 'waiting' | 'running' | 'draining' | 'done';
|
|
20
21
|
/** Outbound turn event the adapter emits. `seq` is added by the runtime. */
|
|
21
22
|
type BridgeEvent = Record<string, unknown> & {
|
|
22
|
-
|
|
23
|
+
type: string;
|
|
23
24
|
};
|
|
24
25
|
type BridgeDebugLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
25
26
|
interface Experimental_BridgeUserMessage {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
readonly messageId: string;
|
|
28
|
+
readonly text: string;
|
|
29
|
+
accept(): void;
|
|
30
|
+
reject(error: unknown): void;
|
|
30
31
|
}
|
|
31
32
|
interface Experimental_BridgeUserMessageQueue extends AsyncIterable<Experimental_BridgeUserMessage> {
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
readonly pendingCount: number;
|
|
34
|
+
close(error?: unknown): void;
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Per-session diagnostics config. The host resolves it from settings +
|
|
@@ -39,127 +40,127 @@ interface Experimental_BridgeUserMessageQueue extends AsyncIterable<Experimental
|
|
|
39
40
|
* emitted and no `seq` is consumed.
|
|
40
41
|
*/
|
|
41
42
|
interface BridgeDebugConfig {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
enabled?: boolean;
|
|
44
|
+
level?: BridgeDebugLevel;
|
|
45
|
+
subsystems?: string[];
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* Per-turn surface handed to {@link RunBridgeOptions.onStart}. The adapter
|
|
48
49
|
* drives its runtime against these primitives; the runtime owns the transport.
|
|
49
50
|
*/
|
|
50
51
|
interface BridgeTurn {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Emit a turn event to the host. Stamps a monotonic `seq`, appends to the
|
|
54
|
+
* in-memory replay log, and sends to the live socket (best-effort — if the
|
|
55
|
+
* host is mid-reconnect the event waits in the log and is replayed on
|
|
56
|
+
* resume).
|
|
57
|
+
*/
|
|
58
|
+
emit(event: BridgeEvent): void;
|
|
59
|
+
/**
|
|
60
|
+
* Register interest in a host-executed tool result and resolve when the
|
|
61
|
+
* matching `tool-result` arrives. The adapter emits the `tool-call` event
|
|
62
|
+
* itself (via {@link emit}) using the same `toolCallId`.
|
|
63
|
+
*/
|
|
64
|
+
requestToolResult(input: string | {
|
|
65
|
+
toolCallId: string;
|
|
66
|
+
matches?: (result: {
|
|
67
|
+
output: unknown;
|
|
68
|
+
isError?: boolean;
|
|
69
|
+
toolResult?: ToolResultPart;
|
|
70
|
+
}) => boolean;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
output: unknown;
|
|
73
|
+
isError?: boolean;
|
|
74
|
+
toolResult?: ToolResultPart;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Register interest in a host approval decision and resolve when the matching
|
|
78
|
+
* `tool-approval-response` arrives. The adapter emits the
|
|
79
|
+
* `tool-approval-request` event itself using the same `approvalId`.
|
|
80
|
+
*/
|
|
81
|
+
requestToolApproval(approvalId: string): Promise<{
|
|
82
|
+
approved: boolean;
|
|
83
|
+
reason?: string;
|
|
84
|
+
}>;
|
|
85
|
+
readonly experimental_userMessages: Experimental_BridgeUserMessageQueue;
|
|
86
|
+
/** Aborts when the host sends `abort`. */
|
|
87
|
+
readonly abortSignal: AbortSignal;
|
|
88
|
+
/** True for the first turn since this bridge process started. */
|
|
89
|
+
readonly firstTurn: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Emit a structured diagnostic. Gated by the session's debug level +
|
|
92
|
+
* subsystem filter; a no-op when diagnostics are disabled. Adapters use this
|
|
93
|
+
* for runtime-level instrumentation; raw `console.*` output is captured and
|
|
94
|
+
* forwarded automatically.
|
|
95
|
+
*/
|
|
96
|
+
bridgeLog(input: {
|
|
97
|
+
level?: BridgeDebugLevel;
|
|
98
|
+
subsystem: string;
|
|
99
|
+
message: string;
|
|
100
|
+
attrs?: Record<string, unknown>;
|
|
101
|
+
error?: unknown;
|
|
102
|
+
}): void;
|
|
103
|
+
/**
|
|
104
|
+
* Emit a non-fatal bridge warning to stderr using the runtime's harness
|
|
105
|
+
* prefix. This is diagnostic-only: it does not emit a stream event, does not
|
|
106
|
+
* consume a `seq`, and does not fail the turn.
|
|
107
|
+
*/
|
|
108
|
+
emitWarning(input: {
|
|
109
|
+
message: string;
|
|
110
|
+
}): void;
|
|
111
|
+
emitError(input: {
|
|
112
|
+
error: unknown;
|
|
113
|
+
message?: string;
|
|
114
|
+
}): void;
|
|
114
115
|
}
|
|
115
116
|
interface RunBridgeOptions<TStart extends {
|
|
116
|
-
|
|
117
|
+
type: 'start';
|
|
117
118
|
}> {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
119
|
+
/** Identifier written into `bridge-meta.json` (`'claude-code'` / `'codex'`). */
|
|
120
|
+
bridgeType: string;
|
|
121
|
+
/** Directory for `bridge-meta.json` / `start-config.json`. Created if absent. */
|
|
122
|
+
bridgeStateDir: string;
|
|
123
|
+
/**
|
|
124
|
+
* Drive one prompt turn. Rejections surface to the host as an `error`
|
|
125
|
+
* event.
|
|
126
|
+
*
|
|
127
|
+
* Contract: once `turn.abortSignal` fires, wind down promptly — turns are
|
|
128
|
+
* serialized, and a replacement `start` waits up to
|
|
129
|
+
* {@link turnTeardownGraceMs} for this promise to settle before it
|
|
130
|
+
* proceeds anyway.
|
|
131
|
+
*/
|
|
132
|
+
onStart(start: TStart, turn: BridgeTurn): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* How long a replacement `start` waits for the previous turn's teardown
|
|
135
|
+
* after aborting it, in milliseconds. Turns are serialized so an aborted
|
|
136
|
+
* turn cannot emit into its replacement's event log or overlap its runtime
|
|
137
|
+
* process — but only within this bound: an adapter that does not settle
|
|
138
|
+
* `onStart` after its abort signal fires forfeits the protection for that
|
|
139
|
+
* boundary, and the new turn proceeds anyway rather than blocking forever.
|
|
140
|
+
* The default of ten seconds exceeds the Claude bridge's five-second
|
|
141
|
+
* hard-abort fallback.
|
|
142
|
+
*/
|
|
143
|
+
turnTeardownGraceMs?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Produce the adapter-defined runtime resume data for `stop`. Defaults to
|
|
146
|
+
* `{}`.
|
|
147
|
+
*/
|
|
148
|
+
onStop?(): unknown | Promise<unknown>;
|
|
149
|
+
/**
|
|
150
|
+
* Perform adapter-defined destruction before the bridge exits.
|
|
151
|
+
*/
|
|
152
|
+
onDestroy?(): void | Promise<void>;
|
|
153
|
+
/** WS port. Defaults to `BRIDGE_WS_PORT` env (0 = OS-assigned). */
|
|
154
|
+
port?: number;
|
|
155
|
+
/** Auth token. Defaults to `BRIDGE_CHANNEL_TOKEN` env. */
|
|
156
|
+
token?: string;
|
|
157
|
+
/** Called with the bound port once the server is listening. */
|
|
158
|
+
onListening?(port: number): void;
|
|
159
|
+
/**
|
|
160
|
+
* Tear the process down after `stop` / `destroy`. Defaults to closing
|
|
161
|
+
* the server and calling `process.exit(0)`. Overridable for tests.
|
|
162
|
+
*/
|
|
163
|
+
onExit?(): void;
|
|
163
164
|
}
|
|
164
165
|
/**
|
|
165
166
|
* Boot the bridge: bind the WebSocket server, announce `bridge-ready`, and
|
|
@@ -168,13 +169,14 @@ interface RunBridgeOptions<TStart extends {
|
|
|
168
169
|
* `stop` / `destroy` exits it.
|
|
169
170
|
*/
|
|
170
171
|
interface BridgeHandle {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
/** The port the WebSocket server bound to. */
|
|
173
|
+
readonly port: number;
|
|
174
|
+
/** Close the WebSocket server. Does not call `process.exit`. */
|
|
175
|
+
close(): Promise<void>;
|
|
175
176
|
}
|
|
176
|
-
declare function runBridge<TStart extends {
|
|
177
|
-
|
|
177
|
+
export declare function runBridge<TStart extends {
|
|
178
|
+
type: 'start';
|
|
178
179
|
}>(options: RunBridgeOptions<TStart>): Promise<BridgeHandle>;
|
|
179
|
-
|
|
180
|
-
export {
|
|
180
|
+
//#endregion
|
|
181
|
+
export type { BridgeDebugConfig, BridgeDebugLevel, BridgeEvent, BridgeHandle, BridgeState, BridgeTurn, Experimental_BridgeUserMessage, Experimental_BridgeUserMessageQueue, RunBridgeOptions };
|
|
182
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/bridge/harness-bridge-capability-unsupported-error.ts","../../src/bridge/index.ts"],"mappings":";;;;;;;qBAOa,gDAAgD;WAClD;WACA;EAEG,cACV,SACA,WACA;IAEA;IACA;IACA;;SAQK,WACL,iBACC,SAAS;;;;KCVF;;KAGA,cAAc;EAA4B;;KAE1C;UAEK;WACN;WACA;EACT;EACA,OAAO;;UAGQ,4CAA4C,cAAc;WAChE;EACT,MAAM;;;;;;;;UAoBS;EACf;EACA,QAAQ;EACR;;;;;;UA+Ke;;;;;;;EAOf,KAAK,OAAO;;;;;;EAOZ,kBACE;IAGM;IACA,WAAW;MACT;MACA;MACA,aAAa;;MAGpB;IACD;IACA;IACA,aAAa;;;;;;;EAQf,oBACE,qBACC;IAAU;IAAmB;;WAEvB,2BAA2B;;WAG3B,aAAa;;WAGb;;;;;;;EAQT,UAAU;IACR,QAAQ;IACR;IACA;IACA,QAAQ;IACR;;;;;;;EAQF,YAAY;IAAS;;EAErB,UAAU;IAAS;IAAgB;;;UAGpB,iBAAiB;EAAiB;;;EAEjD;;EAEA;;;;;;;;;;EAUA,QAAQ,OAAO,QAAQ,MAAM,aAAa;;;;;;;;;;;EAW1C;;;;;EAKA,qBAAqB;;;;EAIrB,qBAAqB;;EAErB;;EAEA;;EAEA,aAAa;;;;;EAKb;;;;;;;;UA+Be;;WAEN;;EAET,SAAS;;wBAGW,UAAU;EAAiB;GAC/C,SAAS,iBAAiB,UACzB,QAAQ"}
|