@finalai/agent-provider 0.1.5 → 0.1.7
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/HOSTING.md +49 -9
- package/dist/modules/conformance/sandbox-kit.d.mts +8 -0
- package/dist/modules/conformance/sandbox-kit.mjs +228 -6
- package/dist/modules/conformance/sandbox-kit.mjs.map +2 -2
- package/dist/modules/harness.mjs +2 -1
- package/dist/modules/harness.mjs.map +2 -2
- package/dist/modules/sandbox/memory-sandbox.d.mts +1 -0
- package/dist/modules/sandbox/memory-sandbox.mjs +37 -10
- package/dist/modules/sandbox/memory-sandbox.mjs.map +2 -2
- package/dist/modules/sandbox/memory-shell.d.mts +1 -0
- package/dist/modules/sandbox/memory-shell.mjs +14 -0
- package/dist/modules/sandbox/memory-shell.mjs.map +2 -2
- package/dist/modules/sandbox/types.d.mts +13 -1
- package/dist/modules/sandbox/types.mjs +47 -2
- package/dist/modules/sandbox/types.mjs.map +2 -2
- package/dist/modules/schemas.mjs +1 -1
- package/dist/modules/schemas.mjs.map +1 -1
- package/package.json +1 -1
package/HOSTING.md
CHANGED
|
@@ -21,6 +21,24 @@ Neither rewrites authored URLs. A GitHub-backed definition uses remote source;
|
|
|
21
21
|
push edits before explicitly publishing a ref. Caller API keys never become agent
|
|
22
22
|
credentials merely because they were used to publish.
|
|
23
23
|
|
|
24
|
+
## Hosted model resolution (SDK 0.2.0)
|
|
25
|
+
|
|
26
|
+
Hosted Final, Pi, Codex and Claude configurations accept string model references.
|
|
27
|
+
`serverless*ConfigSchema.parse(...).model` can be undefined: the host must choose
|
|
28
|
+
its catalog default, resolve aliases and validate availability before dispatch.
|
|
29
|
+
The host owns current candidates, runtime capabilities and dated prices, and
|
|
30
|
+
advertises picker choices through its harness descriptions. Compilation remains
|
|
31
|
+
offline and checks reference syntax.
|
|
32
|
+
|
|
33
|
+
SDK 0.2.0 removes `@finalai/agents/models` and
|
|
34
|
+
`@finalai/final-agent-provider/harnesses/models`, including their model arrays,
|
|
35
|
+
defaults, model-ID unions and pricing helpers. Migrate callers to string model
|
|
36
|
+
references and host-owned discovery, metadata and pricing.
|
|
37
|
+
|
|
38
|
+
Publish the SDK release before upgrading host dependencies. Ship the host's
|
|
39
|
+
catalog/default implementation together with its SDK dependency upgrade; a host
|
|
40
|
+
that only changes the dependency will lose the old default and catalog APIs.
|
|
41
|
+
|
|
24
42
|
## Hosted connections
|
|
25
43
|
|
|
26
44
|
```ts
|
|
@@ -99,15 +117,37 @@ export default defineFinalConnection({
|
|
|
99
117
|
});
|
|
100
118
|
```
|
|
101
119
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
With `load`, the host lists only the loaded tools and must keep every other exposed
|
|
121
|
+
tool reachable: it serves a search over the connection's remaining exposed tools
|
|
122
|
+
(name, description, input schema) and a call that runs a found tool by its real
|
|
123
|
+
name, with the same exposure and approval checks as a direct call. A host may
|
|
124
|
+
instead add a found tool to the list and send `notifications/tools/list_changed`;
|
|
125
|
+
harnesses that ignore that notification still need the call path. `load: []`
|
|
126
|
+
leaves every tool to search. Entries are tool names or `*` patterns.
|
|
127
|
+
`isToolLoaded` from `@finalai/agent-provider` applies the rule after exposure.
|
|
128
|
+
|
|
129
|
+
Without `load`, the harness lists the connection's exposed tools except:
|
|
130
|
+
|
|
131
|
+
- **Connector tools.** A server can label a tool with the connector it belongs to
|
|
132
|
+
in the tool's `_meta`:
|
|
133
|
+
`{ "ai.final/connector": { "namespace": "salesforce", "name": "Salesforce" } }`.
|
|
134
|
+
The namespace identifies the connector (unique within the server's tools); the
|
|
135
|
+
name is for display, and two connectors may share one. Final's server labels
|
|
136
|
+
every connector tool with the namespace and name of the install it comes from.
|
|
137
|
+
The host never lists labelled tools up front. Its search tool names each
|
|
138
|
+
connector and how many tools it has, so the agent knows what is connected
|
|
139
|
+
without any of those definitions in its context, and searches for the tools it
|
|
140
|
+
needs. A `load` entry that names a labelled tool still lists it.
|
|
141
|
+
- **Tools past a size limit.** When a connection exposes more unlabelled tools
|
|
142
|
+
than the host lists directly (100 in Final's host), those are searched too.
|
|
143
|
+
|
|
144
|
+
A harness that declares `supports.deferredToolSearch` defers and searches tools
|
|
145
|
+
itself, so the host lists every exposed tool to it and serves no search.
|
|
146
|
+
|
|
147
|
+
A host's search should name the connectors it covers and accept a connector's
|
|
148
|
+
namespace to narrow to. Once a host has listed its search and call tools, it keeps answering them for
|
|
149
|
+
that harness even if the connection stops hiding tools, unless the connection
|
|
150
|
+
then lists its own tool by one of those names.
|
|
111
151
|
|
|
112
152
|
## Selecting tools by annotation
|
|
113
153
|
|
|
@@ -11,6 +11,14 @@ export interface RunSandboxConformanceArgsIface {
|
|
|
11
11
|
viaWire?: boolean;
|
|
12
12
|
largeFileBytes?: number;
|
|
13
13
|
timeoutMs?: number;
|
|
14
|
+
platform?: SandboxPlatformConformanceIface;
|
|
15
|
+
}
|
|
16
|
+
export interface SandboxPlatformConformanceIface {
|
|
17
|
+
environmentOptions(args: {
|
|
18
|
+
env: Record<string, string>;
|
|
19
|
+
allow?: string[];
|
|
20
|
+
}): JsonValue;
|
|
21
|
+
observedAllowlist?(sandbox: NetworkSandboxSessionIface): Promise<readonly string[] | null>;
|
|
14
22
|
}
|
|
15
23
|
export interface SandboxConformanceReportIface {
|
|
16
24
|
passed: boolean;
|
|
@@ -3,6 +3,7 @@ import { readAllBytes } from "../sandbox/bytes.mjs";
|
|
|
3
3
|
import { streamToString } from "../sandbox/convenience.mjs";
|
|
4
4
|
import { createInMemoryHandleNetwork } from "../sandbox/testing.mjs";
|
|
5
5
|
import {
|
|
6
|
+
NetworkPolicy,
|
|
6
7
|
noSandboxActingUser,
|
|
7
8
|
noSandboxGuides,
|
|
8
9
|
noSandboxRepositories,
|
|
@@ -182,8 +183,10 @@ const sandboxCases = (largeFileBytes) => [
|
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
];
|
|
185
|
-
const startFromProvider = async (args, provider) => {
|
|
186
|
-
const implementation = provider.definition.environment(
|
|
186
|
+
const startFromProvider = async (args, provider, overrides = {}) => {
|
|
187
|
+
const implementation = provider.definition.environment(
|
|
188
|
+
overrides.environmentOptions ?? args.environmentOptions
|
|
189
|
+
);
|
|
187
190
|
const prepareContext = {
|
|
188
191
|
files: {},
|
|
189
192
|
resources: {},
|
|
@@ -209,10 +212,205 @@ const startFromProvider = async (args, provider) => {
|
|
|
209
212
|
variables: noSandboxVariables,
|
|
210
213
|
repositories: noSandboxRepositories,
|
|
211
214
|
actingUser: noSandboxActingUser,
|
|
212
|
-
|
|
215
|
+
platformNetworkPolicy: async () => void 0,
|
|
216
|
+
...args.startContext,
|
|
217
|
+
...overrides.startContext
|
|
213
218
|
};
|
|
214
|
-
|
|
215
|
-
|
|
219
|
+
if (overrides.ownBinding === true) {
|
|
220
|
+
startContext.session = {
|
|
221
|
+
...startContext.session,
|
|
222
|
+
id: crypto.randomUUID(),
|
|
223
|
+
bindingId: crypto.randomUUID(),
|
|
224
|
+
conversationId: null
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
const { handle, state } = await implementation.start(startContext, args.openOptions, artifact);
|
|
228
|
+
return {
|
|
229
|
+
handle,
|
|
230
|
+
awaitRunning: (timeoutMs) => implementation.awaitRunning(startContext, state, { timeoutMs })
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
const PLATFORM_VARIABLE = "FINAL_CONFORMANCE_PLATFORM";
|
|
234
|
+
const SPEC_VARIABLE = "FINAL_CONFORMANCE_SPEC";
|
|
235
|
+
const SHARED_VARIABLE = "FINAL_CONFORMANCE_SHARED";
|
|
236
|
+
const SPEC_ENV = { [SPEC_VARIABLE]: "spec", [SHARED_VARIABLE]: "spec" };
|
|
237
|
+
const SPEC_ALLOW = ["conformance.example.com"];
|
|
238
|
+
const PLATFORM_EGRESS_HOSTS = ["egress.conformance.example.com"];
|
|
239
|
+
const variableIn = async (sandbox, name) => {
|
|
240
|
+
const process = await sandbox.spawn({ command: "printenv", args: [name] });
|
|
241
|
+
const [stdout, { exitCode }] = await Promise.all([
|
|
242
|
+
streamToString(process.stdout),
|
|
243
|
+
process.wait()
|
|
244
|
+
]);
|
|
245
|
+
return exitCode === 0 ? stdout.replace(/\n$/, "") : null;
|
|
246
|
+
};
|
|
247
|
+
const expectVariables = async (sandbox, expected) => {
|
|
248
|
+
for (const [name, value] of Object.entries(expected)) {
|
|
249
|
+
const actual = await variableIn(sandbox, name);
|
|
250
|
+
check(
|
|
251
|
+
actual === value,
|
|
252
|
+
`${name} is ${JSON.stringify(actual)}, expected ${JSON.stringify(value)}`
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const runPlatformCases = async (args) => {
|
|
257
|
+
const { kit, provider, platform, record } = args;
|
|
258
|
+
let platformValues = {
|
|
259
|
+
[PLATFORM_VARIABLE]: "first",
|
|
260
|
+
[SHARED_VARIABLE]: "platform"
|
|
261
|
+
};
|
|
262
|
+
const filePath = `/tmp/final-conformance-${crypto.randomUUID().slice(0, 8)}/platform/ca.pem`;
|
|
263
|
+
const order = [];
|
|
264
|
+
const withPlatform = { handle: null };
|
|
265
|
+
await record("platform environment: provider start", async () => {
|
|
266
|
+
({ handle: withPlatform.handle } = await startFromProvider(kit, provider, {
|
|
267
|
+
environmentOptions: platform.environmentOptions({ env: SPEC_ENV }),
|
|
268
|
+
startContext: {
|
|
269
|
+
platformFiles: async () => {
|
|
270
|
+
order.push("files");
|
|
271
|
+
return { [filePath]: "conformance CA\n" };
|
|
272
|
+
},
|
|
273
|
+
platformEnvironment: async () => {
|
|
274
|
+
order.push("environment");
|
|
275
|
+
return { ...platformValues };
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
ownBinding: true
|
|
279
|
+
}));
|
|
280
|
+
});
|
|
281
|
+
const sandbox = withPlatform.handle?.sandbox;
|
|
282
|
+
if (sandbox != null) {
|
|
283
|
+
try {
|
|
284
|
+
await record("platform files: written before any process", async () => {
|
|
285
|
+
check(
|
|
286
|
+
order.indexOf("files") === 0,
|
|
287
|
+
`platformEnvironment was read before platformFiles: ${order.join(", ")}`
|
|
288
|
+
);
|
|
289
|
+
const content = await sandbox.readTextFile({ path: filePath });
|
|
290
|
+
check(content === "conformance CA\n", `${filePath} holds ${JSON.stringify(content)}`);
|
|
291
|
+
});
|
|
292
|
+
await record("platform environment: reaches spawned processes", async () => {
|
|
293
|
+
await expectVariables(sandbox, { [PLATFORM_VARIABLE]: "first" });
|
|
294
|
+
const run = await sandbox.run({ command: "printenv", args: [PLATFORM_VARIABLE] });
|
|
295
|
+
check(run.stdout === "first\n", `run saw ${JSON.stringify(run.stdout)}`);
|
|
296
|
+
});
|
|
297
|
+
await record("platform environment: read again for every process", async () => {
|
|
298
|
+
platformValues = { ...platformValues, [PLATFORM_VARIABLE]: "second" };
|
|
299
|
+
await expectVariables(sandbox, { [PLATFORM_VARIABLE]: "second" });
|
|
300
|
+
});
|
|
301
|
+
await record("platform environment: overrides the spec env", async () => {
|
|
302
|
+
await expectVariables(sandbox, { [SHARED_VARIABLE]: "platform", [SPEC_VARIABLE]: "spec" });
|
|
303
|
+
});
|
|
304
|
+
await record("platform environment: {} leaves the spec env", async () => {
|
|
305
|
+
platformValues = {};
|
|
306
|
+
await expectVariables(sandbox, {
|
|
307
|
+
[PLATFORM_VARIABLE]: null,
|
|
308
|
+
[SHARED_VARIABLE]: "spec",
|
|
309
|
+
[SPEC_VARIABLE]: "spec"
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
} finally {
|
|
313
|
+
await withPlatform.handle?.onSandboxDelete({ reason: "conformance" }).catch(() => void 0);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const withoutPlatform = { handle: null };
|
|
317
|
+
const reported = [];
|
|
318
|
+
const reportOrder = [];
|
|
319
|
+
const allowlistContext = (platformNetworkPolicy) => ({
|
|
320
|
+
platformEnvironment: void 0,
|
|
321
|
+
platformEgressHosts: PLATFORM_EGRESS_HOSTS,
|
|
322
|
+
platformNetworkPolicy,
|
|
323
|
+
platformFiles: async () => {
|
|
324
|
+
reportOrder.push("files");
|
|
325
|
+
return {};
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
await record("platform environment: provider start without it", async () => {
|
|
329
|
+
({ handle: withoutPlatform.handle } = await startFromProvider(kit, provider, {
|
|
330
|
+
environmentOptions: platform.environmentOptions({ env: SPEC_ENV, allow: SPEC_ALLOW }),
|
|
331
|
+
startContext: allowlistContext(async (policy) => {
|
|
332
|
+
reportOrder.push("policy");
|
|
333
|
+
reported.push(policy);
|
|
334
|
+
}),
|
|
335
|
+
ownBinding: true
|
|
336
|
+
}));
|
|
337
|
+
});
|
|
338
|
+
const plain = withoutPlatform.handle?.sandbox;
|
|
339
|
+
if (plain != null) {
|
|
340
|
+
try {
|
|
341
|
+
await record(
|
|
342
|
+
"platform environment: absent leaves the spec env",
|
|
343
|
+
() => expectVariables(plain, {
|
|
344
|
+
[PLATFORM_VARIABLE]: null,
|
|
345
|
+
[SHARED_VARIABLE]: "spec",
|
|
346
|
+
[SPEC_VARIABLE]: "spec"
|
|
347
|
+
})
|
|
348
|
+
);
|
|
349
|
+
const observe = platform.observedAllowlist;
|
|
350
|
+
if (observe == null) {
|
|
351
|
+
args.skip("platform egress hosts: appended to an allowlist", "no observedAllowlist");
|
|
352
|
+
args.skip("platform network policy: reported as applied", "no observedAllowlist");
|
|
353
|
+
} else {
|
|
354
|
+
await record("platform egress hosts: appended to an allowlist", async () => {
|
|
355
|
+
const allow = await observe(plain) ?? [];
|
|
356
|
+
for (const host of [...SPEC_ALLOW, ...PLATFORM_EGRESS_HOSTS])
|
|
357
|
+
check(allow.includes(host), `allowlist ${JSON.stringify(allow)} lacks ${host}`);
|
|
358
|
+
});
|
|
359
|
+
await record("platform network policy: reported as applied", async () => {
|
|
360
|
+
const last = reported.at(-1);
|
|
361
|
+
check(
|
|
362
|
+
last?.mode === NetworkPolicy.Allowlist,
|
|
363
|
+
`reported ${JSON.stringify(reported)}, expected an allowlist`
|
|
364
|
+
);
|
|
365
|
+
const applied = [...await observe(plain) ?? []].sort();
|
|
366
|
+
const allow = [...last?.allow ?? []].sort();
|
|
367
|
+
check(
|
|
368
|
+
JSON.stringify(allow) === JSON.stringify(applied),
|
|
369
|
+
`reported ${JSON.stringify(allow)}, applied ${JSON.stringify(applied)}`
|
|
370
|
+
);
|
|
371
|
+
check(
|
|
372
|
+
reportOrder.indexOf("policy") < reportOrder.indexOf("files"),
|
|
373
|
+
`platformFiles were written before the policy was reported: ${reportOrder.join(", ")}`
|
|
374
|
+
);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
} finally {
|
|
378
|
+
await withoutPlatform.handle?.onSandboxDelete({ reason: "conformance" }).catch(() => void 0);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (platform.observedAllowlist == null) {
|
|
382
|
+
args.skip("platform network policy: a rejected report fails the start", "no observedAllowlist");
|
|
383
|
+
} else {
|
|
384
|
+
await record("platform network policy: a rejected report fails the start", async () => {
|
|
385
|
+
const started = await startFromProvider(kit, provider, {
|
|
386
|
+
environmentOptions: platform.environmentOptions({ env: SPEC_ENV, allow: SPEC_ALLOW }),
|
|
387
|
+
startContext: allowlistContext(async () => {
|
|
388
|
+
throw new Error("conformance: the policy was not recorded");
|
|
389
|
+
}),
|
|
390
|
+
ownBinding: true
|
|
391
|
+
}).then(
|
|
392
|
+
({ handle }) => handle,
|
|
393
|
+
() => null
|
|
394
|
+
);
|
|
395
|
+
if (started == null) return;
|
|
396
|
+
await started.onSandboxDelete({ reason: "conformance" }).catch(() => void 0);
|
|
397
|
+
throw new Error("a start whose policy report failed returned a sandbox");
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
await record("platform environment: reserved names refused", async () => {
|
|
401
|
+
const started = await startFromProvider(kit, provider, {
|
|
402
|
+
environmentOptions: platform.environmentOptions({
|
|
403
|
+
env: { HTTPS_PROXY: "http://spec.example.com" }
|
|
404
|
+
}),
|
|
405
|
+
ownBinding: true
|
|
406
|
+
}).then(
|
|
407
|
+
({ handle }) => handle,
|
|
408
|
+
() => null
|
|
409
|
+
);
|
|
410
|
+
if (started == null) return;
|
|
411
|
+
await started.onSandboxDelete({ reason: "conformance" }).catch(() => void 0);
|
|
412
|
+
throw new Error("a spec setting HTTPS_PROXY started");
|
|
413
|
+
});
|
|
216
414
|
};
|
|
217
415
|
const runSandboxConformance = async (args) => {
|
|
218
416
|
const timeoutMs = args.timeoutMs ?? 3e4;
|
|
@@ -245,8 +443,17 @@ const runSandboxConformance = async (args) => {
|
|
|
245
443
|
throw new Error("runSandboxConformance needs a handle or a provider");
|
|
246
444
|
const provider = args.provider;
|
|
247
445
|
await record("provider start", async () => {
|
|
248
|
-
started.handle = await startFromProvider(
|
|
446
|
+
({ handle: started.handle, awaitRunning: started.awaitRunning } = await startFromProvider(
|
|
447
|
+
args,
|
|
448
|
+
provider
|
|
449
|
+
));
|
|
249
450
|
});
|
|
451
|
+
const awaitRunning = started.awaitRunning;
|
|
452
|
+
if (awaitRunning != null)
|
|
453
|
+
await record(
|
|
454
|
+
"provider awaitRunning: resolves for a started sandbox",
|
|
455
|
+
() => awaitRunning(timeoutMs)
|
|
456
|
+
);
|
|
250
457
|
sandbox = started.handle?.sandbox ?? null;
|
|
251
458
|
}
|
|
252
459
|
if (sandbox == null) return { passed: false, cases };
|
|
@@ -312,6 +519,21 @@ const runSandboxConformance = async (args) => {
|
|
|
312
519
|
}
|
|
313
520
|
await target.removePath({ path: root, recursive: true, force: true }).catch(() => void 0);
|
|
314
521
|
await started.handle?.onSandboxDelete({ reason: "conformance" }).catch(() => void 0);
|
|
522
|
+
if (args.platform != null && args.provider != null) {
|
|
523
|
+
await runPlatformCases({
|
|
524
|
+
kit: args,
|
|
525
|
+
provider: args.provider,
|
|
526
|
+
platform: args.platform,
|
|
527
|
+
record,
|
|
528
|
+
skip: (name, detail) => cases.push({
|
|
529
|
+
name,
|
|
530
|
+
status: ConformanceCaseStatus.Skipped,
|
|
531
|
+
durationMs: 0,
|
|
532
|
+
error: null,
|
|
533
|
+
detail
|
|
534
|
+
})
|
|
535
|
+
});
|
|
536
|
+
}
|
|
315
537
|
return { passed: cases.every((entry) => entry.status !== ConformanceCaseStatus.Failed), cases };
|
|
316
538
|
};
|
|
317
539
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/conformance/sandbox-kit.ts"],
|
|
4
|
-
"sourcesContent": ["import type { JsonValue } from \"../json.mjs\";\nimport { SandboxAccess } from \"../manifest.mjs\";\nimport { readAllBytes } from \"../sandbox/bytes.mjs\";\nimport { streamToString } from \"../sandbox/convenience.mjs\";\nimport { createInMemoryHandleNetwork } from \"../sandbox/testing.mjs\";\nimport {\n noSandboxActingUser,\n noSandboxGuides,\n noSandboxRepositories,\n noSandboxVariables,\n SandboxEntryType,\n type AnySandboxProviderIface,\n type NetworkSandboxSessionIface,\n type SandboxPrepareContextIface,\n type SandboxProviderHandleIface,\n type SandboxStartContextIface,\n} from \"../sandbox/types.mjs\";\nimport { HandleRpcErrorCode, isHandleRpcError } from \"../sandbox/wire.mjs\";\nimport { ConformanceCaseStatus, type ConformanceCaseResultIface } from \"./harness-kit.mjs\";\n\n// Sandbox conformance: files, streams with\n// multi-megabyte content, ranged reads, process I/O and kill, run directly on\n// the handle and again through the handle RPC (client and server over an\n// in-memory connection), plus the server's read-only access policy. Commands\n// used: echo, cat, sleep and `exit` under `shell: true`.\n\nexport interface RunSandboxConformanceArgsIface {\n // Either a started handle, or a provider the kit prepares and starts.\n handle?: NetworkSandboxSessionIface;\n provider?: AnySandboxProviderIface;\n environmentOptions?: JsonValue;\n openOptions?: JsonValue;\n prepareContext?: Partial<SandboxPrepareContextIface>;\n startContext?: Partial<SandboxStartContextIface>;\n // Also run the cases through the handle RPC (default true).\n viaWire?: boolean;\n largeFileBytes?: number;\n timeoutMs?: number;\n}\n\nexport interface SandboxConformanceReportIface {\n passed: boolean;\n cases: ConformanceCaseResultIface[];\n}\n\ninterface StartedProviderIface {\n handle: SandboxProviderHandleIface<NetworkSandboxSessionIface> | null;\n}\n\nconst check = (condition: boolean, message: string) => {\n if (!condition) throw new Error(message);\n};\n\nconst patternBytes = (size: number, seed: number): Uint8Array => {\n const bytes = new Uint8Array(size);\n let state = seed >>> 0;\n for (let i = 0; i < size; i += 1) {\n state = (Math.imul(state, 1664525) + 1013904223) >>> 0;\n bytes[i] = state >>> 24;\n }\n return bytes;\n};\n\nconst chunked = (bytes: Uint8Array, chunk: number): ReadableStream<Uint8Array> => {\n let offset = 0;\n return new ReadableStream<Uint8Array>({\n pull: (controller) => {\n if (offset >= bytes.byteLength) {\n controller.close();\n return;\n }\n controller.enqueue(bytes.slice(offset, offset + chunk));\n offset += chunk;\n },\n });\n};\n\nconst sameBytes = (a: Uint8Array, b: Uint8Array) =>\n a.byteLength === b.byteLength && a.every((value, i) => value === b[i]);\n\nconst withTimeout = async <T>(promise: Promise<T>, ms: number, what: string): Promise<T> => {\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n return await Promise.race([\n promise,\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error(`${what} timed out after ${ms} ms`)), ms);\n }),\n ]);\n } finally {\n if (timer != null) clearTimeout(timer);\n }\n};\n\ntype SandboxCase = {\n name: string;\n run: (sandbox: NetworkSandboxSessionIface, root: string) => Promise<string | void>;\n};\n\nconst sandboxCases = (largeFileBytes: number): SandboxCase[] => [\n {\n name: 'describe',\n run: async (sandbox) => {\n check(sandbox.id.length > 0, 'empty id');\n check(\n sandbox.defaultWorkingDirectory.startsWith('/'),\n 'defaultWorkingDirectory is not absolute',\n );\n check(\n sandbox.resolvePath('a/b') === `${sandbox.defaultWorkingDirectory.replace(/\\/$/, '')}/a/b`,\n 'resolvePath',\n );\n },\n },\n {\n name: 'text files',\n run: async (sandbox, root) => {\n const path = `${root}/nested/dir/a.txt`;\n await sandbox.writeTextFile({ path, content: 'first' });\n await sandbox.writeTextFile({ path, content: 'h\u00E9llo\\n' });\n check((await sandbox.readTextFile({ path })) === 'h\u00E9llo\\n', 'text round trip');\n check(\n (await sandbox.readTextFile({ path: `${root}/missing.txt` })) == null,\n 'missing text file is not null',\n );\n check(\n (await sandbox.readFile({ path: `${root}/missing.txt` })) == null,\n 'missing file stream is not null',\n );\n },\n },\n {\n name: 'ranged reads',\n run: async (sandbox, root) => {\n const path = `${root}/lines.txt`;\n await sandbox.writeTextFile({ path, content: 'l1\\nl2\\nl3\\nl4\\n' });\n check(\n (await sandbox.readTextFile({ path, startLine: 2, endLine: 3 })) === 'l2\\nl3\\n',\n 'lines 2-3',\n );\n check(\n (await sandbox.readTextFile({ path, startLine: 4, endLine: 99 })) === 'l4\\n',\n 'endLine past EOF',\n );\n },\n },\n {\n name: 'multi-megabyte streams',\n run: async (sandbox, root) => {\n const path = `${root}/large.bin`;\n const content = patternBytes(largeFileBytes, largeFileBytes);\n await sandbox.writeFile({ path, content: chunked(content, 300_000) });\n const stream = await sandbox.readFile({ path });\n check(stream != null, 'large file not found');\n if (stream == null) return;\n check(sameBytes(await readAllBytes(stream), content), 'streamed bytes differ');\n const binary = await sandbox.readBinaryFile({ path });\n check(binary != null && sameBytes(binary, content), 'readBinaryFile differs');\n const small = patternBytes(1000, 7);\n await sandbox.writeBinaryFile({ path: `${root}/small.bin`, content: small });\n const back = await sandbox.readBinaryFile({ path: `${root}/small.bin` });\n check(back != null && sameBytes(back, small), 'binary round trip');\n return `${largeFileBytes} bytes`;\n },\n },\n {\n name: 'stat, readDir, removePath',\n run: async (sandbox, root) => {\n await sandbox.writeTextFile({ path: `${root}/tree/x.txt`, content: 'xyz' });\n await sandbox.writeTextFile({ path: `${root}/tree/sub/y.txt`, content: 'y' });\n const stat = await sandbox.stat({ path: `${root}/tree/x.txt` });\n check(stat?.type === SandboxEntryType.File && stat.size === 3, 'file stat');\n check(\n (await sandbox.stat({ path: `${root}/tree` }))?.type === SandboxEntryType.Directory,\n 'directory stat',\n );\n check(\n (await sandbox.stat({ path: `${root}/tree/none` })) == null,\n 'missing stat is not null',\n );\n const names = (await sandbox.readDir({ path: `${root}/tree` }))\n .map((entry) => entry.name)\n .sort();\n check(\n JSON.stringify(names) === JSON.stringify(['sub', 'x.txt']),\n `readDir returned ${names.join(',')}`,\n );\n await sandbox.removePath({ path: `${root}/tree/none`, force: true });\n await sandbox.removePath({ path: `${root}/tree`, recursive: true });\n check(\n (await sandbox.stat({ path: `${root}/tree/x.txt` })) == null,\n 'recursive remove left files',\n );\n },\n },\n {\n name: 'process output and exit codes',\n run: async (sandbox) => {\n const echo = await sandbox.run({ command: 'echo', args: ['hello', 'world'] });\n check(\n echo.exitCode === 0 && echo.stdout === 'hello world\\n',\n `echo: ${JSON.stringify(echo)}`,\n );\n const shell = await sandbox.run({ command: 'echo out; echo err >&2; exit 3', shell: true });\n check(\n shell.exitCode === 3 && shell.stdout === 'out\\n' && shell.stderr === 'err\\n',\n `shell: ${JSON.stringify(shell)}`,\n );\n },\n },\n {\n name: 'process stdin',\n run: async (sandbox) => {\n const piped = await sandbox.run({ command: 'cat', stdin: 'from stdin' });\n check(piped.stdout === 'from stdin', `run stdin: ${JSON.stringify(piped)}`);\n const cat = await sandbox.spawn({ command: 'cat' });\n const output = streamToString(cat.stdout);\n await cat.write('a');\n await cat.write('b', { end: true });\n check((await output) === 'ab', 'spawned cat echoed wrong data');\n check((await cat.wait()).exitCode === 0, 'cat exit code');\n },\n },\n {\n name: 'process kill',\n run: async (sandbox) => {\n const sleeper = await sandbox.spawn({ command: 'sleep', args: ['30'] });\n await sleeper.kill();\n const result = await withTimeout(sleeper.wait(), 5_000, 'wait after kill');\n check(result.exitCode !== 0, 'killed process exited 0');\n },\n },\n];\n\nconst startFromProvider = async (\n args: RunSandboxConformanceArgsIface,\n provider: AnySandboxProviderIface,\n): Promise<SandboxProviderHandleIface<NetworkSandboxSessionIface>> => {\n const implementation = provider.definition.environment(args.environmentOptions);\n const prepareContext: SandboxPrepareContextIface = {\n files: {},\n resources: {},\n sourceRevision: 'conformance',\n storagePath: '/tmp/final-conformance',\n organizationId: 'conformance',\n guides: noSandboxGuides,\n actingUser: noSandboxActingUser,\n ...args.prepareContext,\n };\n const artifact = await implementation.prepare(prepareContext);\n const startContext: SandboxStartContextIface = {\n session: {\n id: crypto.randomUUID(),\n organizationId: 'conformance',\n conversationId: null,\n definitionId: 'conformance',\n bindingId: crypto.randomUUID(),\n target: 'conformance',\n },\n storagePath: '/tmp/final-conformance',\n guides: noSandboxGuides,\n variables: noSandboxVariables,\n repositories: noSandboxRepositories,\n actingUser: noSandboxActingUser,\n ...args.startContext,\n };\n const { handle } = await implementation.start(startContext, args.openOptions, artifact);\n return handle;\n};\n\nexport const runSandboxConformance = async (\n args: RunSandboxConformanceArgsIface,\n): Promise<SandboxConformanceReportIface> => {\n const timeoutMs = args.timeoutMs ?? 30_000;\n const cases: ConformanceCaseResultIface[] = [];\n const record = async (name: string, run: () => Promise<string | void>) => {\n const started = Date.now();\n try {\n const detail = await withTimeout(run(), timeoutMs, name);\n cases.push({\n name,\n status: ConformanceCaseStatus.Passed,\n durationMs: Date.now() - started,\n error: null,\n detail: detail ?? null,\n });\n } catch (error) {\n cases.push({\n name,\n status: ConformanceCaseStatus.Failed,\n durationMs: Date.now() - started,\n error: error instanceof Error ? error.message : String(error),\n detail: null,\n });\n }\n };\n\n // A holder, so the assignment inside the closure is visible to the narrowing.\n const started: StartedProviderIface = { handle: null };\n let sandbox = args.handle ?? null;\n if (sandbox == null) {\n if (args.provider == null)\n throw new Error('runSandboxConformance needs a handle or a provider');\n const provider = args.provider;\n await record('provider start', async () => {\n started.handle = await startFromProvider(args, provider);\n });\n sandbox = started.handle?.sandbox ?? null;\n }\n if (sandbox == null) return { passed: false, cases };\n const target = sandbox;\n\n const root = target.resolvePath(`conformance-${crypto.randomUUID().slice(0, 8)}`);\n const list = sandboxCases(args.largeFileBytes ?? 5 * 1024 * 1024);\n for (const entry of list) await record(entry.name, () => entry.run(target, root));\n\n if (args.viaWire !== false) {\n const network = createInMemoryHandleNetwork();\n network.serve({ url: 'mem://conformance', sandbox: target });\n network.serve({\n url: 'mem://conformance-read',\n sandbox: target,\n access: { mode: SandboxAccess.Read, lifecycle: false },\n });\n const client = await network.connect({ url: 'mem://conformance', token: 'conformance' });\n try {\n const wireRoot = `${root}-wire`;\n for (const entry of list)\n await record(`handle rpc: ${entry.name}`, () => entry.run(client, wireRoot));\n await record('handle rpc: read-only access policy', async () => {\n const readOnly = await network.connect({\n url: 'mem://conformance-read',\n token: 'conformance',\n });\n try {\n await target.writeTextFile({ path: `${root}/ro.txt`, content: 'visible' });\n check(\n (await readOnly.readTextFile({ path: `${root}/ro.txt` })) === 'visible',\n 'read failed on a read binding',\n );\n const attempts: [string, Promise<unknown>][] = [\n [\n 'writeTextFile',\n readOnly.writeTextFile({ path: `${root}/ro.txt`, content: 'changed' }),\n ],\n ['run', readOnly.run({ command: 'echo' })],\n ['spawn', readOnly.spawn({ command: 'echo' })],\n ['removePath', readOnly.removePath({ path: `${root}/ro.txt` })],\n ];\n for (const [what, attempt] of attempts) {\n const error = await attempt.then(\n () => null,\n (cause: unknown) => cause,\n );\n check(\n isHandleRpcError(error) && error.code === HandleRpcErrorCode.Forbidden,\n `${what} was not rejected`,\n );\n }\n check(\n (await target.readTextFile({ path: `${root}/ro.txt` })) === 'visible',\n 'a read binding changed the file',\n );\n } finally {\n readOnly.close();\n }\n });\n } finally {\n client.close();\n await target\n .removePath({ path: `${root}-wire`, recursive: true, force: true })\n .catch(() => undefined);\n }\n }\n\n await target.removePath({ path: root, recursive: true, force: true }).catch(() => undefined);\n await started.handle?.onSandboxDelete({ reason: 'conformance' }).catch(() => undefined);\n return { passed: cases.every((entry) => entry.status !== ConformanceCaseStatus.Failed), cases };\n};\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,qBAAqB;AAC9B,S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SAAS,OAAO,CAAC,CAAC;AAAA,YAC7C,CAAC,cAAc,SAAS,WAAW,EAAE,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC;AAAA,UAChE;AACA,qBAAW,CAAC,MAAM,OAAO,KAAK,UAAU;AACtC,kBAAM,QAAQ,MAAM,QAAQ;AAAA,cAC1B,MAAM;AAAA,cACN,CAAC,UAAmB;AAAA,YACtB;AACA;AAAA,cACE,iBAAiB,KAAK,KAAK,MAAM,SAAS,mBAAmB;AAAA,cAC7D,GAAG,IAAI;AAAA,YACT;AAAA,UACF;AACA;AAAA,YACG,MAAM,OAAO,aAAa,EAAE,MAAM,GAAG,IAAI,UAAU,CAAC,MAAO;AAAA,YAC5D;AAAA,UACF;AAAA,QACF,UAAE;AACA,mBAAS,MAAM;AAAA,QACjB;AAAA,MACF,CAAC;AAAA,IACH,UAAE;AACA,aAAO,MAAM;AACb,YAAM,OACH,WAAW,EAAE,MAAM,GAAG,IAAI,SAAS,WAAW,MAAM,OAAO,KAAK,CAAC,EACjE,MAAM,MAAM,MAAS;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,OAAO,WAAW,EAAE,MAAM,MAAM,WAAW,MAAM,OAAO,KAAK,CAAC,EAAE,MAAM,MAAM,MAAS;AAC3F,QAAM,QAAQ,QAAQ,gBAAgB,EAAE,QAAQ,cAAc,CAAC,EAAE,MAAM,MAAM,MAAS;AACtF,SAAO,EAAE,QAAQ,MAAM,MAAM,CAAC,UAAU,MAAM,WAAW,sBAAsB,MAAM,GAAG,MAAM;AAChG;",
|
|
4
|
+
"sourcesContent": ["import type { JsonValue } from \"../json.mjs\";\nimport { SandboxAccess } from \"../manifest.mjs\";\nimport { readAllBytes } from \"../sandbox/bytes.mjs\";\nimport { streamToString } from \"../sandbox/convenience.mjs\";\nimport { createInMemoryHandleNetwork } from \"../sandbox/testing.mjs\";\nimport {\n NetworkPolicy,\n noSandboxActingUser,\n noSandboxGuides,\n noSandboxRepositories,\n noSandboxVariables,\n SandboxEntryType,\n type AnySandboxProviderIface,\n type NetworkPolicyIface,\n type NetworkSandboxSessionIface,\n type SandboxPrepareContextIface,\n type SandboxProviderHandleIface,\n type SandboxStartContextIface,\n} from \"../sandbox/types.mjs\";\nimport { HandleRpcErrorCode, isHandleRpcError } from \"../sandbox/wire.mjs\";\nimport { ConformanceCaseStatus, type ConformanceCaseResultIface } from \"./harness-kit.mjs\";\n\n// Sandbox conformance: files, streams with\n// multi-megabyte content, ranged reads, process I/O and kill, run directly on\n// the handle and again through the handle RPC (client and server over an\n// in-memory connection), plus the server's read-only access policy. Commands\n// used: echo, cat, sleep and `exit` under `shell: true`, and printenv for the\n// platform environment cases. A provider start also checks that awaitRunning\n// resolves for the sandbox it started.\n\nexport interface RunSandboxConformanceArgsIface {\n // Either a started handle, or a provider the kit prepares and starts.\n handle?: NetworkSandboxSessionIface;\n provider?: AnySandboxProviderIface;\n environmentOptions?: JsonValue;\n openOptions?: JsonValue;\n prepareContext?: Partial<SandboxPrepareContextIface>;\n startContext?: Partial<SandboxStartContextIface>;\n // Also run the cases through the handle RPC (default true).\n viaWire?: boolean;\n largeFileBytes?: number;\n timeoutMs?: number;\n // Also run the platform environment cases, on sandboxes of their own (needs `provider`).\n platform?: SandboxPlatformConformanceIface;\n}\n\n// How the platform environment cases declare a spec for the provider under test.\nexport interface SandboxPlatformConformanceIface {\n // Environment options whose spec sets `env` as plain variables for every\n // process and, when `allow` is given, an allowlist egress policy of those hosts.\n environmentOptions(args: { env: Record<string, string>; allow?: string[] }): JsonValue;\n // The allowlist the provider gave its backend for this sandbox. Absent: the\n // egress hosts and network policy report cases are skipped.\n observedAllowlist?(sandbox: NetworkSandboxSessionIface): Promise<readonly string[] | null>;\n}\n\nexport interface SandboxConformanceReportIface {\n passed: boolean;\n cases: ConformanceCaseResultIface[];\n}\n\ninterface StartedProviderIface {\n handle: SandboxProviderHandleIface<NetworkSandboxSessionIface> | null;\n // The provider's awaitRunning for the sandbox it started.\n awaitRunning?: (timeoutMs: number) => Promise<void>;\n}\n\ninterface ProviderStartIface {\n handle: SandboxProviderHandleIface<NetworkSandboxSessionIface>;\n awaitRunning: (timeoutMs: number) => Promise<void>;\n}\n\nconst check = (condition: boolean, message: string) => {\n if (!condition) throw new Error(message);\n};\n\nconst patternBytes = (size: number, seed: number): Uint8Array => {\n const bytes = new Uint8Array(size);\n let state = seed >>> 0;\n for (let i = 0; i < size; i += 1) {\n state = (Math.imul(state, 1664525) + 1013904223) >>> 0;\n bytes[i] = state >>> 24;\n }\n return bytes;\n};\n\nconst chunked = (bytes: Uint8Array, chunk: number): ReadableStream<Uint8Array> => {\n let offset = 0;\n return new ReadableStream<Uint8Array>({\n pull: (controller) => {\n if (offset >= bytes.byteLength) {\n controller.close();\n return;\n }\n controller.enqueue(bytes.slice(offset, offset + chunk));\n offset += chunk;\n },\n });\n};\n\nconst sameBytes = (a: Uint8Array, b: Uint8Array) =>\n a.byteLength === b.byteLength && a.every((value, i) => value === b[i]);\n\nconst withTimeout = async <T>(promise: Promise<T>, ms: number, what: string): Promise<T> => {\n let timer: ReturnType<typeof setTimeout> | null = null;\n try {\n return await Promise.race([\n promise,\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error(`${what} timed out after ${ms} ms`)), ms);\n }),\n ]);\n } finally {\n if (timer != null) clearTimeout(timer);\n }\n};\n\ntype SandboxCase = {\n name: string;\n run: (sandbox: NetworkSandboxSessionIface, root: string) => Promise<string | void>;\n};\n\nconst sandboxCases = (largeFileBytes: number): SandboxCase[] => [\n {\n name: 'describe',\n run: async (sandbox) => {\n check(sandbox.id.length > 0, 'empty id');\n check(\n sandbox.defaultWorkingDirectory.startsWith('/'),\n 'defaultWorkingDirectory is not absolute',\n );\n check(\n sandbox.resolvePath('a/b') === `${sandbox.defaultWorkingDirectory.replace(/\\/$/, '')}/a/b`,\n 'resolvePath',\n );\n },\n },\n {\n name: 'text files',\n run: async (sandbox, root) => {\n const path = `${root}/nested/dir/a.txt`;\n await sandbox.writeTextFile({ path, content: 'first' });\n await sandbox.writeTextFile({ path, content: 'h\u00E9llo\\n' });\n check((await sandbox.readTextFile({ path })) === 'h\u00E9llo\\n', 'text round trip');\n check(\n (await sandbox.readTextFile({ path: `${root}/missing.txt` })) == null,\n 'missing text file is not null',\n );\n check(\n (await sandbox.readFile({ path: `${root}/missing.txt` })) == null,\n 'missing file stream is not null',\n );\n },\n },\n {\n name: 'ranged reads',\n run: async (sandbox, root) => {\n const path = `${root}/lines.txt`;\n await sandbox.writeTextFile({ path, content: 'l1\\nl2\\nl3\\nl4\\n' });\n check(\n (await sandbox.readTextFile({ path, startLine: 2, endLine: 3 })) === 'l2\\nl3\\n',\n 'lines 2-3',\n );\n check(\n (await sandbox.readTextFile({ path, startLine: 4, endLine: 99 })) === 'l4\\n',\n 'endLine past EOF',\n );\n },\n },\n {\n name: 'multi-megabyte streams',\n run: async (sandbox, root) => {\n const path = `${root}/large.bin`;\n const content = patternBytes(largeFileBytes, largeFileBytes);\n await sandbox.writeFile({ path, content: chunked(content, 300_000) });\n const stream = await sandbox.readFile({ path });\n check(stream != null, 'large file not found');\n if (stream == null) return;\n check(sameBytes(await readAllBytes(stream), content), 'streamed bytes differ');\n const binary = await sandbox.readBinaryFile({ path });\n check(binary != null && sameBytes(binary, content), 'readBinaryFile differs');\n const small = patternBytes(1000, 7);\n await sandbox.writeBinaryFile({ path: `${root}/small.bin`, content: small });\n const back = await sandbox.readBinaryFile({ path: `${root}/small.bin` });\n check(back != null && sameBytes(back, small), 'binary round trip');\n return `${largeFileBytes} bytes`;\n },\n },\n {\n name: 'stat, readDir, removePath',\n run: async (sandbox, root) => {\n await sandbox.writeTextFile({ path: `${root}/tree/x.txt`, content: 'xyz' });\n await sandbox.writeTextFile({ path: `${root}/tree/sub/y.txt`, content: 'y' });\n const stat = await sandbox.stat({ path: `${root}/tree/x.txt` });\n check(stat?.type === SandboxEntryType.File && stat.size === 3, 'file stat');\n check(\n (await sandbox.stat({ path: `${root}/tree` }))?.type === SandboxEntryType.Directory,\n 'directory stat',\n );\n check(\n (await sandbox.stat({ path: `${root}/tree/none` })) == null,\n 'missing stat is not null',\n );\n const names = (await sandbox.readDir({ path: `${root}/tree` }))\n .map((entry) => entry.name)\n .sort();\n check(\n JSON.stringify(names) === JSON.stringify(['sub', 'x.txt']),\n `readDir returned ${names.join(',')}`,\n );\n await sandbox.removePath({ path: `${root}/tree/none`, force: true });\n await sandbox.removePath({ path: `${root}/tree`, recursive: true });\n check(\n (await sandbox.stat({ path: `${root}/tree/x.txt` })) == null,\n 'recursive remove left files',\n );\n },\n },\n {\n name: 'process output and exit codes',\n run: async (sandbox) => {\n const echo = await sandbox.run({ command: 'echo', args: ['hello', 'world'] });\n check(\n echo.exitCode === 0 && echo.stdout === 'hello world\\n',\n `echo: ${JSON.stringify(echo)}`,\n );\n const shell = await sandbox.run({ command: 'echo out; echo err >&2; exit 3', shell: true });\n check(\n shell.exitCode === 3 && shell.stdout === 'out\\n' && shell.stderr === 'err\\n',\n `shell: ${JSON.stringify(shell)}`,\n );\n },\n },\n {\n name: 'process stdin',\n run: async (sandbox) => {\n const piped = await sandbox.run({ command: 'cat', stdin: 'from stdin' });\n check(piped.stdout === 'from stdin', `run stdin: ${JSON.stringify(piped)}`);\n const cat = await sandbox.spawn({ command: 'cat' });\n const output = streamToString(cat.stdout);\n await cat.write('a');\n await cat.write('b', { end: true });\n check((await output) === 'ab', 'spawned cat echoed wrong data');\n check((await cat.wait()).exitCode === 0, 'cat exit code');\n },\n },\n {\n name: 'process kill',\n run: async (sandbox) => {\n const sleeper = await sandbox.spawn({ command: 'sleep', args: ['30'] });\n await sleeper.kill();\n const result = await withTimeout(sleeper.wait(), 5_000, 'wait after kill');\n check(result.exitCode !== 0, 'killed process exited 0');\n },\n },\n];\n\nconst startFromProvider = async (\n args: RunSandboxConformanceArgsIface,\n provider: AnySandboxProviderIface,\n overrides: {\n environmentOptions?: JsonValue;\n startContext?: Partial<SandboxStartContextIface>;\n // A binding (and so a sandbox) of its own, whatever session the caller's context names.\n ownBinding?: boolean;\n } = {},\n): Promise<ProviderStartIface> => {\n const implementation = provider.definition.environment(\n overrides.environmentOptions ?? args.environmentOptions,\n );\n const prepareContext: SandboxPrepareContextIface = {\n files: {},\n resources: {},\n sourceRevision: 'conformance',\n storagePath: '/tmp/final-conformance',\n organizationId: 'conformance',\n guides: noSandboxGuides,\n actingUser: noSandboxActingUser,\n ...args.prepareContext,\n };\n const artifact = await implementation.prepare(prepareContext);\n const startContext: SandboxStartContextIface = {\n session: {\n id: crypto.randomUUID(),\n organizationId: 'conformance',\n conversationId: null,\n definitionId: 'conformance',\n bindingId: crypto.randomUUID(),\n target: 'conformance',\n },\n storagePath: '/tmp/final-conformance',\n guides: noSandboxGuides,\n variables: noSandboxVariables,\n repositories: noSandboxRepositories,\n actingUser: noSandboxActingUser,\n platformNetworkPolicy: async () => undefined,\n ...args.startContext,\n ...overrides.startContext,\n };\n if (overrides.ownBinding === true) {\n startContext.session = {\n ...startContext.session,\n id: crypto.randomUUID(),\n bindingId: crypto.randomUUID(),\n conversationId: null,\n };\n }\n const { handle, state } = await implementation.start(startContext, args.openOptions, artifact);\n return {\n handle,\n awaitRunning: (timeoutMs) => implementation.awaitRunning(startContext, state, { timeoutMs }),\n };\n};\n\nconst PLATFORM_VARIABLE = 'FINAL_CONFORMANCE_PLATFORM';\nconst SPEC_VARIABLE = 'FINAL_CONFORMANCE_SPEC';\nconst SHARED_VARIABLE = 'FINAL_CONFORMANCE_SHARED';\nconst SPEC_ENV = { [SPEC_VARIABLE]: 'spec', [SHARED_VARIABLE]: 'spec' };\nconst SPEC_ALLOW = ['conformance.example.com'];\nconst PLATFORM_EGRESS_HOSTS = ['egress.conformance.example.com'];\n\n// A variable as a spawned process sees it; null when unset.\nconst variableIn = async (\n sandbox: NetworkSandboxSessionIface,\n name: string,\n): Promise<string | null> => {\n const process = await sandbox.spawn({ command: 'printenv', args: [name] });\n const [stdout, { exitCode }] = await Promise.all([\n streamToString(process.stdout),\n process.wait(),\n ]);\n return exitCode === 0 ? stdout.replace(/\\n$/, '') : null;\n};\n\nconst expectVariables = async (\n sandbox: NetworkSandboxSessionIface,\n expected: Record<string, string | null>,\n) => {\n for (const [name, value] of Object.entries(expected)) {\n const actual = await variableIn(sandbox, name);\n check(\n actual === value,\n `${name} is ${JSON.stringify(actual)}, expected ${JSON.stringify(value)}`,\n );\n }\n};\n\ntype RecordCase = (name: string, run: () => Promise<string | void>) => Promise<void>;\n\n// The start context's platformFiles are written before any process runs;\n// platformEnvironment reaches every process, read again for each one and over\n// the spec's env; platformEgressHosts join an allowlist, and the policy is\n// reported through platformNetworkPolicy before platformFiles are written (a\n// rejected report fails the start); a spec naming a platform variable is refused.\nconst runPlatformCases = async (args: {\n kit: RunSandboxConformanceArgsIface;\n provider: AnySandboxProviderIface;\n platform: SandboxPlatformConformanceIface;\n record: RecordCase;\n skip: (name: string, detail: string) => void;\n}) => {\n const { kit, provider, platform, record } = args;\n let platformValues: Record<string, string> = {\n [PLATFORM_VARIABLE]: 'first',\n [SHARED_VARIABLE]: 'platform',\n };\n const filePath = `/tmp/final-conformance-${crypto.randomUUID().slice(0, 8)}/platform/ca.pem`;\n const order: string[] = [];\n const withPlatform: StartedProviderIface = { handle: null };\n await record('platform environment: provider start', async () => {\n ({ handle: withPlatform.handle } = await startFromProvider(kit, provider, {\n environmentOptions: platform.environmentOptions({ env: SPEC_ENV }),\n startContext: {\n platformFiles: async () => {\n order.push('files');\n return { [filePath]: 'conformance CA\\n' };\n },\n platformEnvironment: async () => {\n order.push('environment');\n return { ...platformValues };\n },\n },\n ownBinding: true,\n }));\n });\n const sandbox = withPlatform.handle?.sandbox;\n if (sandbox != null) {\n try {\n await record('platform files: written before any process', async () => {\n check(\n order.indexOf('files') === 0,\n `platformEnvironment was read before platformFiles: ${order.join(', ')}`,\n );\n const content = await sandbox.readTextFile({ path: filePath });\n check(content === 'conformance CA\\n', `${filePath} holds ${JSON.stringify(content)}`);\n });\n await record('platform environment: reaches spawned processes', async () => {\n await expectVariables(sandbox, { [PLATFORM_VARIABLE]: 'first' });\n const run = await sandbox.run({ command: 'printenv', args: [PLATFORM_VARIABLE] });\n check(run.stdout === 'first\\n', `run saw ${JSON.stringify(run.stdout)}`);\n });\n await record('platform environment: read again for every process', async () => {\n platformValues = { ...platformValues, [PLATFORM_VARIABLE]: 'second' };\n await expectVariables(sandbox, { [PLATFORM_VARIABLE]: 'second' });\n });\n await record('platform environment: overrides the spec env', async () => {\n await expectVariables(sandbox, { [SHARED_VARIABLE]: 'platform', [SPEC_VARIABLE]: 'spec' });\n });\n await record('platform environment: {} leaves the spec env', async () => {\n platformValues = {};\n await expectVariables(sandbox, {\n [PLATFORM_VARIABLE]: null,\n [SHARED_VARIABLE]: 'spec',\n [SPEC_VARIABLE]: 'spec',\n });\n });\n } finally {\n await withPlatform.handle?.onSandboxDelete({ reason: 'conformance' }).catch(() => undefined);\n }\n }\n\n const withoutPlatform: StartedProviderIface = { handle: null };\n const reported: NetworkPolicyIface[] = [];\n const reportOrder: string[] = [];\n const allowlistContext = (\n platformNetworkPolicy: (policy: NetworkPolicyIface) => Promise<void>,\n ): Partial<SandboxStartContextIface> => ({\n platformEnvironment: undefined,\n platformEgressHosts: PLATFORM_EGRESS_HOSTS,\n platformNetworkPolicy,\n platformFiles: async () => {\n reportOrder.push('files');\n return {};\n },\n });\n await record('platform environment: provider start without it', async () => {\n ({ handle: withoutPlatform.handle } = await startFromProvider(kit, provider, {\n environmentOptions: platform.environmentOptions({ env: SPEC_ENV, allow: SPEC_ALLOW }),\n startContext: allowlistContext(async (policy) => {\n reportOrder.push('policy');\n reported.push(policy);\n }),\n ownBinding: true,\n }));\n });\n const plain = withoutPlatform.handle?.sandbox;\n if (plain != null) {\n try {\n await record('platform environment: absent leaves the spec env', () =>\n expectVariables(plain, {\n [PLATFORM_VARIABLE]: null,\n [SHARED_VARIABLE]: 'spec',\n [SPEC_VARIABLE]: 'spec',\n }),\n );\n const observe = platform.observedAllowlist;\n if (observe == null) {\n args.skip('platform egress hosts: appended to an allowlist', 'no observedAllowlist');\n args.skip('platform network policy: reported as applied', 'no observedAllowlist');\n } else {\n await record('platform egress hosts: appended to an allowlist', async () => {\n const allow = (await observe(plain)) ?? [];\n for (const host of [...SPEC_ALLOW, ...PLATFORM_EGRESS_HOSTS])\n check(allow.includes(host), `allowlist ${JSON.stringify(allow)} lacks ${host}`);\n });\n await record('platform network policy: reported as applied', async () => {\n const last = reported.at(-1);\n check(\n last?.mode === NetworkPolicy.Allowlist,\n `reported ${JSON.stringify(reported)}, expected an allowlist`,\n );\n const applied = [...((await observe(plain)) ?? [])].sort();\n const allow = [...(last?.allow ?? [])].sort();\n check(\n JSON.stringify(allow) === JSON.stringify(applied),\n `reported ${JSON.stringify(allow)}, applied ${JSON.stringify(applied)}`,\n );\n check(\n reportOrder.indexOf('policy') < reportOrder.indexOf('files'),\n `platformFiles were written before the policy was reported: ${reportOrder.join(', ')}`,\n );\n });\n }\n } finally {\n await withoutPlatform.handle\n ?.onSandboxDelete({ reason: 'conformance' })\n .catch(() => undefined);\n }\n }\n\n if (platform.observedAllowlist == null) {\n args.skip('platform network policy: a rejected report fails the start', 'no observedAllowlist');\n } else {\n await record('platform network policy: a rejected report fails the start', async () => {\n const started = await startFromProvider(kit, provider, {\n environmentOptions: platform.environmentOptions({ env: SPEC_ENV, allow: SPEC_ALLOW }),\n startContext: allowlistContext(async () => {\n throw new Error('conformance: the policy was not recorded');\n }),\n ownBinding: true,\n }).then(\n ({ handle }) => handle,\n () => null,\n );\n if (started == null) return;\n await started.onSandboxDelete({ reason: 'conformance' }).catch(() => undefined);\n throw new Error('a start whose policy report failed returned a sandbox');\n });\n }\n\n await record('platform environment: reserved names refused', async () => {\n const started = await startFromProvider(kit, provider, {\n environmentOptions: platform.environmentOptions({\n env: { HTTPS_PROXY: 'http://spec.example.com' },\n }),\n ownBinding: true,\n }).then(\n ({ handle }) => handle,\n () => null,\n );\n if (started == null) return;\n await started.onSandboxDelete({ reason: 'conformance' }).catch(() => undefined);\n throw new Error('a spec setting HTTPS_PROXY started');\n });\n};\n\nexport const runSandboxConformance = async (\n args: RunSandboxConformanceArgsIface,\n): Promise<SandboxConformanceReportIface> => {\n const timeoutMs = args.timeoutMs ?? 30_000;\n const cases: ConformanceCaseResultIface[] = [];\n const record: RecordCase = async (name, run) => {\n const started = Date.now();\n try {\n const detail = await withTimeout(run(), timeoutMs, name);\n cases.push({\n name,\n status: ConformanceCaseStatus.Passed,\n durationMs: Date.now() - started,\n error: null,\n detail: detail ?? null,\n });\n } catch (error) {\n cases.push({\n name,\n status: ConformanceCaseStatus.Failed,\n durationMs: Date.now() - started,\n error: error instanceof Error ? error.message : String(error),\n detail: null,\n });\n }\n };\n\n // A holder, so the assignment inside the closure is visible to the narrowing.\n const started: StartedProviderIface = { handle: null };\n let sandbox = args.handle ?? null;\n if (sandbox == null) {\n if (args.provider == null)\n throw new Error('runSandboxConformance needs a handle or a provider');\n const provider = args.provider;\n await record('provider start', async () => {\n ({ handle: started.handle, awaitRunning: started.awaitRunning } = await startFromProvider(\n args,\n provider,\n ));\n });\n const awaitRunning = started.awaitRunning;\n if (awaitRunning != null)\n await record('provider awaitRunning: resolves for a started sandbox', () =>\n awaitRunning(timeoutMs),\n );\n sandbox = started.handle?.sandbox ?? null;\n }\n if (sandbox == null) return { passed: false, cases };\n const target = sandbox;\n\n const root = target.resolvePath(`conformance-${crypto.randomUUID().slice(0, 8)}`);\n const list = sandboxCases(args.largeFileBytes ?? 5 * 1024 * 1024);\n for (const entry of list) await record(entry.name, () => entry.run(target, root));\n\n if (args.viaWire !== false) {\n const network = createInMemoryHandleNetwork();\n network.serve({ url: 'mem://conformance', sandbox: target });\n network.serve({\n url: 'mem://conformance-read',\n sandbox: target,\n access: { mode: SandboxAccess.Read, lifecycle: false },\n });\n const client = await network.connect({ url: 'mem://conformance', token: 'conformance' });\n try {\n const wireRoot = `${root}-wire`;\n for (const entry of list)\n await record(`handle rpc: ${entry.name}`, () => entry.run(client, wireRoot));\n await record('handle rpc: read-only access policy', async () => {\n const readOnly = await network.connect({\n url: 'mem://conformance-read',\n token: 'conformance',\n });\n try {\n await target.writeTextFile({ path: `${root}/ro.txt`, content: 'visible' });\n check(\n (await readOnly.readTextFile({ path: `${root}/ro.txt` })) === 'visible',\n 'read failed on a read binding',\n );\n const attempts: [string, Promise<unknown>][] = [\n [\n 'writeTextFile',\n readOnly.writeTextFile({ path: `${root}/ro.txt`, content: 'changed' }),\n ],\n ['run', readOnly.run({ command: 'echo' })],\n ['spawn', readOnly.spawn({ command: 'echo' })],\n ['removePath', readOnly.removePath({ path: `${root}/ro.txt` })],\n ];\n for (const [what, attempt] of attempts) {\n const error = await attempt.then(\n () => null,\n (cause: unknown) => cause,\n );\n check(\n isHandleRpcError(error) && error.code === HandleRpcErrorCode.Forbidden,\n `${what} was not rejected`,\n );\n }\n check(\n (await target.readTextFile({ path: `${root}/ro.txt` })) === 'visible',\n 'a read binding changed the file',\n );\n } finally {\n readOnly.close();\n }\n });\n } finally {\n client.close();\n await target\n .removePath({ path: `${root}-wire`, recursive: true, force: true })\n .catch(() => undefined);\n }\n }\n\n await target.removePath({ path: root, recursive: true, force: true }).catch(() => undefined);\n await started.handle?.onSandboxDelete({ reason: 'conformance' }).catch(() => undefined);\n\n if (args.platform != null && args.provider != null) {\n await runPlatformCases({\n kit: args,\n provider: args.provider,\n platform: args.platform,\n record,\n skip: (name, detail) =>\n cases.push({\n name,\n status: ConformanceCaseStatus.Skipped,\n durationMs: 0,\n error: null,\n detail,\n }),\n });\n }\n return { passed: cases.every((entry) => entry.status !== ConformanceCaseStatus.Failed), cases };\n};\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,mCAAmC;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AACP,SAAS,oBAAoB,wBAAwB;AACr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AAM,MAAM,CAAC,UAAU,MAAM,WAAW,sBAAsB,MAAM,GAAG,MAAM;AAChG;",
|
|
6
6
|
"names": ["started"]
|
|
7
7
|
}
|
package/dist/modules/harness.mjs
CHANGED
|
@@ -83,7 +83,8 @@ const harnessDescriptionSchema = z.object({
|
|
|
83
83
|
nativeToolPolicy: z.boolean().optional(),
|
|
84
84
|
// Defers and searches MCP tools itself (a harness-native tool search): the
|
|
85
85
|
// host lists every exposed tool, ignoring connections' `tools.load`, and
|
|
86
|
-
// adds no search of its own. Absent: the host
|
|
86
|
+
// adds no search of its own. Absent: the host lists what `load` (or, without
|
|
87
|
+
// it, HOSTING.md's defaults) leaves listed and serves search for the rest.
|
|
87
88
|
deferredToolSearch: z.boolean().optional()
|
|
88
89
|
}),
|
|
89
90
|
promptWhileRunning: z.nativeEnum(PromptWhileRunning).default(DEFAULT_PROMPT_WHILE_RUNNING),
|