@ai-sdk/harness 1.0.71 → 1.0.72
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 +11 -0
- package/dist/agent/index.d.ts +90 -9
- package/dist/agent/index.js +5 -15
- package/dist/agent/index.js.map +1 -1
- package/dist/index.d.ts +88 -10
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +59 -7
- package/dist/utils/index.js +36 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/agent/prepare-sandbox-for-harness.ts +8 -18
- package/src/errors/harness-capability-unsupported-error.ts +2 -2
- package/src/utils/index.ts +5 -0
- package/src/utils/sandbox-credential-brokering.ts +41 -0
- package/src/v1/harness-v1-network-sandbox-session.ts +87 -5
- package/src/v1/harness-v1-session.ts +4 -2
- package/src/v1/index.ts +2 -0
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { Experimental_SandboxSession as SandboxSession } from '@ai-sdk/provider-utils';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Connection details for a sandbox-exposed port. Headers are scoped to the
|
|
5
|
+
* returned URL and must be included when opening the connection.
|
|
6
|
+
*/
|
|
7
|
+
export type HarnessV1PortEndpoint = {
|
|
8
|
+
readonly url: string;
|
|
9
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
10
|
+
};
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* Network sandbox session returned by `HarnessV1SandboxProvider.createSession()`. The
|
|
5
14
|
* harness keeps this for the lifetime of a session. It is itself a
|
|
@@ -8,8 +17,8 @@ import type { Experimental_SandboxSession as SandboxSession } from '@ai-sdk/prov
|
|
|
8
17
|
*
|
|
9
18
|
* Code that should only touch the filesystem and spawn processes receives the
|
|
10
19
|
* reduced view from {@link HarnessV1NetworkSandboxSession.restricted}, never the
|
|
11
|
-
* network sandbox session itself — so it cannot stop the sandbox
|
|
12
|
-
* network
|
|
20
|
+
* network sandbox session itself — so it cannot stop the sandbox, change
|
|
21
|
+
* network access, or transform requests.
|
|
13
22
|
*/
|
|
14
23
|
export interface HarnessV1NetworkSandboxSession extends SandboxSession {
|
|
15
24
|
/**
|
|
@@ -36,13 +45,23 @@ export interface HarnessV1NetworkSandboxSession extends SandboxSession {
|
|
|
36
45
|
*/
|
|
37
46
|
readonly defaultWorkingDirectory: string;
|
|
38
47
|
|
|
39
|
-
/** Ports the sandbox exposes; resolvable
|
|
48
|
+
/** Ports the sandbox exposes; resolvable via `getPortEndpoint`. */
|
|
40
49
|
readonly ports: ReadonlyArray<number>;
|
|
41
50
|
|
|
42
51
|
/**
|
|
43
|
-
* Resolve
|
|
52
|
+
* Resolve the connection details for a sandbox-exposed port. Bridge-backed
|
|
44
53
|
* adapters call this to open their WebSocket to the in-sandbox bridge.
|
|
45
54
|
*/
|
|
55
|
+
readonly getPortEndpoint: (options: {
|
|
56
|
+
port: number;
|
|
57
|
+
protocol?: 'http' | 'https' | 'ws';
|
|
58
|
+
}) => PromiseLike<HarnessV1PortEndpoint>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Resolve a publicly-reachable URL for a sandbox-exposed port.
|
|
62
|
+
*
|
|
63
|
+
* @deprecated Use `getPortEndpoint` instead.
|
|
64
|
+
*/
|
|
46
65
|
readonly getPortUrl: (options: {
|
|
47
66
|
port: number;
|
|
48
67
|
protocol?: 'http' | 'https' | 'ws';
|
|
@@ -68,6 +87,29 @@ export interface HarnessV1NetworkSandboxSession extends SandboxSession {
|
|
|
68
87
|
policy: HarnessV1NetworkPolicy,
|
|
69
88
|
) => PromiseLike<void>;
|
|
70
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Replace the sandbox's outbound request-transformation rules. Optional —
|
|
92
|
+
* implementations expose this only when credentials can be injected outside
|
|
93
|
+
* the sandbox security boundary. Calling this method assumes authority over
|
|
94
|
+
* the complete transformation set; harness adapters should normally use
|
|
95
|
+
* `addRequestTransformations` instead. Adapters may preserve legacy
|
|
96
|
+
* credential-forwarding behavior when additive request transformations are
|
|
97
|
+
* unavailable.
|
|
98
|
+
*/
|
|
99
|
+
readonly setRequestTransformations?: (
|
|
100
|
+
transformations: ReadonlyArray<HarnessV1RequestTransformation>,
|
|
101
|
+
) => PromiseLike<void>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Add outbound request-transformation rules without replacing rules already
|
|
105
|
+
* managed by the sandbox session. Optional for the same reason as
|
|
106
|
+
* `setRequestTransformations`. Harness adapters should use this additive
|
|
107
|
+
* capability unless they explicitly own the complete transformation set.
|
|
108
|
+
*/
|
|
109
|
+
readonly addRequestTransformations?: (
|
|
110
|
+
transformations: ReadonlyArray<HarnessV1RequestTransformation>,
|
|
111
|
+
) => PromiseLike<void>;
|
|
112
|
+
|
|
71
113
|
/**
|
|
72
114
|
* Replace the set of ports exposed by the sandbox. Full-replacement
|
|
73
115
|
* semantics: ports omitted from the array are deregistered. Optional —
|
|
@@ -86,7 +128,8 @@ export interface HarnessV1NetworkSandboxSession extends SandboxSession {
|
|
|
86
128
|
*
|
|
87
129
|
* The returned object points at exactly the same underlying sandbox
|
|
88
130
|
* resource as the network sandbox session it was produced from; it is only a
|
|
89
|
-
* narrower surface over the same resource, not a separate sandbox.
|
|
131
|
+
* narrower surface over the same resource, not a separate sandbox. In
|
|
132
|
+
* particular, it cannot mutate network access or request transformations.
|
|
90
133
|
*/
|
|
91
134
|
readonly restricted: () => SandboxSession;
|
|
92
135
|
}
|
|
@@ -121,3 +164,42 @@ export type HarnessV1NetworkPolicy =
|
|
|
121
164
|
allowedCIDRs: ReadonlyArray<string>;
|
|
122
165
|
deniedCIDRs?: ReadonlyArray<string>;
|
|
123
166
|
};
|
|
167
|
+
|
|
168
|
+
type HarnessV1RequestTransformationPathMatcher =
|
|
169
|
+
| { exact: string }
|
|
170
|
+
| { startsWith: string }
|
|
171
|
+
| { regex: string };
|
|
172
|
+
|
|
173
|
+
type HarnessV1RequestTransformationKeyValuePartMatcher =
|
|
174
|
+
| { exact: string }
|
|
175
|
+
| { startsWith: string }
|
|
176
|
+
| { regex: string };
|
|
177
|
+
|
|
178
|
+
type HarnessV1RequestTransformationKeyValueMatcher = {
|
|
179
|
+
readonly key?: HarnessV1RequestTransformationKeyValuePartMatcher;
|
|
180
|
+
readonly value?: HarnessV1RequestTransformationKeyValuePartMatcher;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Outbound HTTPS request transformation applied outside the sandbox security
|
|
185
|
+
* boundary. The host is part of the match so each rule is self-contained and
|
|
186
|
+
* several rules, including several for the same host, can be installed at
|
|
187
|
+
* once.
|
|
188
|
+
*
|
|
189
|
+
* Credential values belong in `transform.headers`, while the sandbox process
|
|
190
|
+
* receives only a non-secret placeholder. Implementations must overwrite
|
|
191
|
+
* matching request headers after the request leaves the sandbox rather than
|
|
192
|
+
* making transformed values available inside it.
|
|
193
|
+
*/
|
|
194
|
+
export type HarnessV1RequestTransformation = {
|
|
195
|
+
readonly match: {
|
|
196
|
+
readonly host: string;
|
|
197
|
+
readonly path?: HarnessV1RequestTransformationPathMatcher;
|
|
198
|
+
readonly method?: ReadonlyArray<string>;
|
|
199
|
+
readonly queryString?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
|
|
200
|
+
readonly headers?: ReadonlyArray<HarnessV1RequestTransformationKeyValueMatcher>;
|
|
201
|
+
};
|
|
202
|
+
readonly transform: {
|
|
203
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
@@ -78,8 +78,10 @@ export type HarnessV1StartOptions = {
|
|
|
78
78
|
* Network sandbox session the adapter operates against. It is owned and
|
|
79
79
|
* lifecycled by `HarnessAgent`. Adapters call `restricted()` for the
|
|
80
80
|
* tool-safe filesystem/exec/spawn surface, and use the infra methods
|
|
81
|
-
* (`
|
|
82
|
-
*
|
|
81
|
+
* (`getPortEndpoint`, `ports`, `setNetworkPolicy`,
|
|
82
|
+
* `setRequestTransformations`, `addRequestTransformations`) for bridge
|
|
83
|
+
* wiring. Adapters must not call `stop()` themselves; the agent does that
|
|
84
|
+
* during cleanup.
|
|
83
85
|
*/
|
|
84
86
|
readonly sandboxSession: HarnessV1NetworkSandboxSession;
|
|
85
87
|
|
package/src/v1/index.ts
CHANGED
|
@@ -36,6 +36,8 @@ export type {
|
|
|
36
36
|
export type {
|
|
37
37
|
HarnessV1NetworkPolicy,
|
|
38
38
|
HarnessV1NetworkSandboxSession,
|
|
39
|
+
HarnessV1PortEndpoint,
|
|
40
|
+
HarnessV1RequestTransformation,
|
|
39
41
|
} from './harness-v1-network-sandbox-session';
|
|
40
42
|
export type { HarnessV1Skill } from './harness-v1-skill';
|
|
41
43
|
export type { HarnessV1StreamPart } from './harness-v1-stream-part';
|