@hachej/boring-agent 0.1.89 → 0.1.91
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/{chunk-GOM3VJOJ.js → chunk-2GBHYJVC.js} +31 -1
- package/dist/{chunk-I7UEASPG.js → chunk-BHH5NH7P.js} +5534 -8253
- package/dist/{chunk-M32FXCIN.js → chunk-CJ2BW2W2.js} +23 -8
- package/dist/{chunk-WZCTVT57.js → chunk-IWBC6SF7.js} +94 -112
- package/dist/chunk-NITBKFG6.js +1246 -0
- package/dist/{chunk-BDYXKHWY.js → chunk-PZC76CIA.js} +7 -1
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +2 -2
- package/dist/{createHarness-CCQLHKUF.js → createHarness-PMYRKDE4.js} +2 -2
- package/dist/errors-BEmw9HMp.d.ts +200 -0
- package/dist/front/index.d.ts +30 -5
- package/dist/front/index.js +230 -44
- package/dist/{harness-VvP0l5Mj.d.ts → harness-Bt_GMNYR.d.ts} +2 -2
- package/dist/{workspaceAgentDispatcher-CKEeNPjW.d.ts → lease-2aXepSBL.d.ts} +254 -59
- package/dist/{protocol-B_OQKfbI.d.ts → middleware-CzW8n7B7.d.ts} +20 -18
- package/dist/piChatEvent-DBO3M5lu.d.ts +367 -0
- package/dist/{piChatSessionService-DPjJ0g71.d.ts → piChatSessionService-BaaVWke7.d.ts} +5 -1
- package/dist/{sandbox-DthfJaOB.d.ts → sandbox-DAD8cWQR.d.ts} +14 -1
- package/dist/server/agent-host/testing/gatewayConformance.d.ts +41 -0
- package/dist/server/agent-host/testing/gatewayConformance.js +465 -0
- package/dist/server/index.d.ts +507 -708
- package/dist/server/index.js +53 -50
- package/dist/server/worker/index.d.ts +9 -7
- package/dist/server/worker/index.js +19 -28
- package/dist/shared/index.d.ts +119 -27
- package/dist/shared/index.js +65 -282
- package/dist/types-jcMapYr9.d.ts +759 -0
- package/docs/ACCESSIBILITY.md +4 -5
- package/docs/API.md +3 -0
- package/docs/AUTHORING.md +68 -0
- package/docs/ERROR_CODES.md +29 -0
- package/docs/README.md +1 -0
- package/docs/RISKS-MULTI-TAB.md +1 -1
- package/docs/runtime-provisioning.md +1 -1
- package/docs/runtime.md +9 -6
- package/package.json +18 -9
- package/dist/chunk-DGRKMMXO.js +0 -8
- package/dist/chunk-XPQEF32D.js +0 -385
- package/dist/piChatEvent-nmOBSNU9.d.ts +0 -367
package/dist/server/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentDirectoryCompilerError,
|
|
3
|
-
|
|
3
|
+
AgentFleetCompilationError,
|
|
4
|
+
AgentFleetCompilationErrorCode,
|
|
5
|
+
AuthoredAgentMaterializationError,
|
|
6
|
+
EmbeddedAgentGateway,
|
|
7
|
+
InMemoryAgentRequestLedger,
|
|
4
8
|
MANAGED_AGENT_MCP_DELIVERY_RULE,
|
|
5
9
|
MANAGED_AGENT_MCP_ORIGIN_SURFACE,
|
|
6
10
|
ManagedAgentMcpDelegateController,
|
|
@@ -10,73 +14,75 @@ import {
|
|
|
10
14
|
RemoteWorkerClient,
|
|
11
15
|
RemoteWorkerClientError,
|
|
12
16
|
UV_SETUP_COMMANDS,
|
|
13
|
-
VERCEL_PROVISIONING_CACHE_ROOT,
|
|
14
|
-
VERCEL_SANDBOX_WORKSPACE_ROOT,
|
|
15
17
|
WORKER_INTERNAL_TOKEN_HEADER,
|
|
16
18
|
WORKER_REQUEST_ID_HEADER,
|
|
17
19
|
WORKER_WORKSPACE_ID_HEADER,
|
|
18
20
|
applyCspHeaders,
|
|
19
|
-
assertRealPathWithinWorkspace,
|
|
20
21
|
autoDetectMode,
|
|
21
|
-
bakeSnapshotIfNeeded,
|
|
22
22
|
buildDeploymentSnapshotRecipe,
|
|
23
|
-
buildPackageHash,
|
|
24
|
-
buildSnapshotRecipeHash,
|
|
25
23
|
compileAgentDirectory,
|
|
26
24
|
constantTimeTokenEqual,
|
|
27
25
|
createAgent,
|
|
28
26
|
createAgentApp,
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
createAgentHost,
|
|
28
|
+
createAgentHostLegacyRoutePolicy,
|
|
29
|
+
createAuthMiddleware,
|
|
30
|
+
createDirectModeAdapter,
|
|
31
|
+
createEnvironmentProvisioningFingerprint,
|
|
32
|
+
createFakeAuthorityVerifierV1,
|
|
33
|
+
createHostSideCredentialResolverV1,
|
|
34
|
+
createInMemoryCredentialBackendV1,
|
|
35
|
+
createLocalModeAdapter,
|
|
31
36
|
createManagedAgentMcpDelegateController,
|
|
32
37
|
createManagedAgentMcpHttpHandler,
|
|
33
38
|
createManagedAgentMcpServer,
|
|
34
|
-
|
|
39
|
+
createProviderRuntimeModeAdapter,
|
|
35
40
|
createRemoteWorkerModeAdapter,
|
|
36
41
|
createRemoteWorkerSandbox,
|
|
37
42
|
createRemoteWorkerWorkspace,
|
|
38
43
|
createResolvedAgentDigest,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
createResolvedRuntimeScopeIdentity,
|
|
45
|
+
createSandboxRuntimeModeAdapter,
|
|
46
|
+
createValidatingAgentFleetCompiler,
|
|
47
|
+
createVercelSandboxModeAdapter,
|
|
42
48
|
decodeBytesFromWorker,
|
|
43
49
|
encodeBytesForWorker,
|
|
44
|
-
fileRoutes,
|
|
45
|
-
getBoringAgentPathEntries,
|
|
46
|
-
getBoringAgentRuntimeEnv,
|
|
47
|
-
getBoringAgentRuntimePaths,
|
|
48
50
|
hasBwrap,
|
|
51
|
+
materializeAgentDirectory,
|
|
49
52
|
normalizeMeteringUsage,
|
|
50
53
|
prepareDeploymentSnapshot,
|
|
51
|
-
prepareVercelDeploymentSnapshot,
|
|
52
54
|
provisionRuntimeWorkspace,
|
|
53
55
|
provisionWorkspaceRuntime,
|
|
54
56
|
registerAgentRoutes,
|
|
55
57
|
registerShareEntryResources,
|
|
56
58
|
resolveAgentDeployment,
|
|
59
|
+
resolveBuiltinRuntimeLayoutRoot,
|
|
57
60
|
resolveMode,
|
|
58
|
-
resolveSandboxHandle,
|
|
59
61
|
resolveWorkspaceRoot,
|
|
62
|
+
sandboxRuntimeHostOperations,
|
|
60
63
|
shareResourceUri,
|
|
61
|
-
|
|
62
|
-
} from "../chunk-
|
|
63
|
-
import "../chunk-XPQEF32D.js";
|
|
64
|
-
import "../chunk-M32FXCIN.js";
|
|
65
|
-
import "../chunk-WSQ5QNIY.js";
|
|
66
|
-
import "../chunk-BDYXKHWY.js";
|
|
64
|
+
withResolvedCredential
|
|
65
|
+
} from "../chunk-BHH5NH7P.js";
|
|
67
66
|
import {
|
|
68
67
|
PI_PACKAGE_RESOURCE_FILTERS,
|
|
69
68
|
compactPiPackages,
|
|
70
|
-
createLogger,
|
|
71
69
|
createResourceSettingsManager,
|
|
72
70
|
mergePiPackageSources,
|
|
73
71
|
piPackageSourceKey
|
|
74
|
-
} from "../chunk-
|
|
72
|
+
} from "../chunk-IWBC6SF7.js";
|
|
73
|
+
import "../chunk-CJ2BW2W2.js";
|
|
74
|
+
import "../chunk-NITBKFG6.js";
|
|
75
75
|
import "../chunk-AQBXNPMD.js";
|
|
76
|
-
import "../chunk-
|
|
76
|
+
import "../chunk-WSQ5QNIY.js";
|
|
77
|
+
import "../chunk-PZC76CIA.js";
|
|
78
|
+
import "../chunk-2GBHYJVC.js";
|
|
77
79
|
export {
|
|
78
80
|
AgentDirectoryCompilerError,
|
|
79
|
-
|
|
81
|
+
AgentFleetCompilationError,
|
|
82
|
+
AgentFleetCompilationErrorCode,
|
|
83
|
+
AuthoredAgentMaterializationError,
|
|
84
|
+
EmbeddedAgentGateway,
|
|
85
|
+
InMemoryAgentRequestLedger,
|
|
80
86
|
MANAGED_AGENT_MCP_DELIVERY_RULE,
|
|
81
87
|
MANAGED_AGENT_MCP_ORIGIN_SURFACE,
|
|
82
88
|
ManagedAgentMcpDelegateController,
|
|
@@ -87,59 +93,56 @@ export {
|
|
|
87
93
|
RemoteWorkerClient,
|
|
88
94
|
RemoteWorkerClientError,
|
|
89
95
|
UV_SETUP_COMMANDS,
|
|
90
|
-
VERCEL_PROVISIONING_CACHE_ROOT,
|
|
91
|
-
VERCEL_SANDBOX_WORKSPACE_ROOT,
|
|
92
|
-
UV_SETUP_COMMANDS as VERCEL_UV_SETUP_COMMANDS,
|
|
93
96
|
WORKER_INTERNAL_TOKEN_HEADER,
|
|
94
97
|
WORKER_REQUEST_ID_HEADER,
|
|
95
98
|
WORKER_WORKSPACE_ID_HEADER,
|
|
96
99
|
applyCspHeaders,
|
|
97
|
-
assertRealPathWithinWorkspace,
|
|
98
100
|
autoDetectMode,
|
|
99
|
-
bakeSnapshotIfNeeded,
|
|
100
101
|
buildDeploymentSnapshotRecipe,
|
|
101
|
-
buildPackageHash,
|
|
102
|
-
buildSnapshotRecipeHash,
|
|
103
102
|
compactPiPackages,
|
|
104
103
|
compileAgentDirectory,
|
|
105
104
|
constantTimeTokenEqual,
|
|
106
105
|
createAgent,
|
|
107
106
|
createAgentApp,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
createAuthMiddleware as createAgentAuthMiddleware,
|
|
108
|
+
createAgentHost,
|
|
109
|
+
createAgentHostLegacyRoutePolicy,
|
|
110
|
+
createDirectModeAdapter,
|
|
111
|
+
createEnvironmentProvisioningFingerprint,
|
|
112
|
+
createFakeAuthorityVerifierV1,
|
|
113
|
+
createHostSideCredentialResolverV1,
|
|
114
|
+
createInMemoryCredentialBackendV1,
|
|
115
|
+
createLocalModeAdapter,
|
|
111
116
|
createManagedAgentMcpDelegateController,
|
|
112
117
|
createManagedAgentMcpHttpHandler,
|
|
113
118
|
createManagedAgentMcpServer,
|
|
114
|
-
|
|
119
|
+
createProviderRuntimeModeAdapter,
|
|
115
120
|
createRemoteWorkerModeAdapter,
|
|
116
121
|
createRemoteWorkerSandbox,
|
|
117
122
|
createRemoteWorkerWorkspace,
|
|
118
123
|
createResolvedAgentDigest,
|
|
124
|
+
createResolvedRuntimeScopeIdentity,
|
|
119
125
|
createResourceSettingsManager,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
126
|
+
createSandboxRuntimeModeAdapter,
|
|
127
|
+
createValidatingAgentFleetCompiler,
|
|
128
|
+
createVercelSandboxModeAdapter,
|
|
123
129
|
decodeBytesFromWorker,
|
|
124
130
|
encodeBytesForWorker,
|
|
125
|
-
fileRoutes,
|
|
126
|
-
getBoringAgentPathEntries,
|
|
127
|
-
getBoringAgentRuntimeEnv,
|
|
128
|
-
getBoringAgentRuntimePaths,
|
|
129
131
|
hasBwrap,
|
|
132
|
+
materializeAgentDirectory,
|
|
130
133
|
mergePiPackageSources,
|
|
131
134
|
normalizeMeteringUsage,
|
|
132
135
|
piPackageSourceKey,
|
|
133
136
|
prepareDeploymentSnapshot,
|
|
134
|
-
prepareVercelDeploymentSnapshot,
|
|
135
137
|
provisionRuntimeWorkspace,
|
|
136
138
|
provisionWorkspaceRuntime,
|
|
137
139
|
registerAgentRoutes,
|
|
138
140
|
registerShareEntryResources,
|
|
139
141
|
resolveAgentDeployment,
|
|
142
|
+
resolveBuiltinRuntimeLayoutRoot,
|
|
140
143
|
resolveMode,
|
|
141
|
-
resolveSandboxHandle,
|
|
142
144
|
resolveWorkspaceRoot,
|
|
145
|
+
sandboxRuntimeHostOperations,
|
|
143
146
|
shareResourceUri,
|
|
144
|
-
|
|
147
|
+
withResolvedCredential
|
|
145
148
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FastifyInstance, FastifyRequest, FastifyReply, FastifyServerOptions } from 'fastify';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { BwrapResourceLimits } from '@hachej/boring-sandbox/providers/bwrap';
|
|
3
|
+
import { SandboxProviderV1 } from '@hachej/boring-sandbox/shared';
|
|
4
|
+
import { b as Workspace, S as Sandbox } from '../../sandbox-DAD8cWQR.js';
|
|
5
|
+
import { R as RemoteWorkerWorkspaceOp, a as RemoteWorkerWorkspaceResult } from '../../middleware-CzW8n7B7.js';
|
|
4
6
|
|
|
5
7
|
interface WorkerConfig {
|
|
6
8
|
workspaceRoot: string;
|
|
@@ -13,7 +15,7 @@ interface WorkerConfig {
|
|
|
13
15
|
}
|
|
14
16
|
declare function loadWorkerConfig(): WorkerConfig;
|
|
15
17
|
|
|
16
|
-
declare function registerWorkerRoutes(app: FastifyInstance, config: WorkerConfig): Promise<void>;
|
|
18
|
+
declare function registerWorkerRoutes(app: FastifyInstance, config: WorkerConfig, runtimeProvider?: SandboxProviderV1): Promise<void>;
|
|
17
19
|
|
|
18
20
|
declare const WORKER_ERROR_CODES: {
|
|
19
21
|
readonly AUTH_INVALID: "auth_invalid";
|
|
@@ -28,12 +30,10 @@ type WorkerErrorCode = (typeof WORKER_ERROR_CODES)[keyof typeof WORKER_ERROR_COD
|
|
|
28
30
|
interface WorkerRuntime {
|
|
29
31
|
workspace: Workspace;
|
|
30
32
|
sandbox: Sandbox;
|
|
33
|
+
dispose(): Promise<void>;
|
|
31
34
|
}
|
|
32
35
|
declare function assertSafeWorkspaceId(workspaceId: string): string;
|
|
33
|
-
declare function createWorkerRuntime(root: string, workspaceId: string,
|
|
34
|
-
bwrapNetwork: 'isolated' | 'shared';
|
|
35
|
-
resourceLimits?: BwrapResourceLimits;
|
|
36
|
-
}): Promise<WorkerRuntime>;
|
|
36
|
+
declare function createWorkerRuntime(root: string, workspaceId: string, provider: SandboxProviderV1): Promise<WorkerRuntime>;
|
|
37
37
|
declare function runWorkspaceOp(workspace: Workspace, op: RemoteWorkerWorkspaceOp): Promise<RemoteWorkerWorkspaceResult>;
|
|
38
38
|
|
|
39
39
|
declare class ExecSemaphore {
|
|
@@ -51,6 +51,8 @@ interface CreateWorkerServerOptions {
|
|
|
51
51
|
config?: WorkerConfig;
|
|
52
52
|
/** Extra Fastify server options merged over the worker defaults. */
|
|
53
53
|
fastify?: FastifyServerOptions;
|
|
54
|
+
/** Host-owned worker provider (normally bwrap). */
|
|
55
|
+
runtimeProvider?: SandboxProviderV1;
|
|
54
56
|
}
|
|
55
57
|
interface WorkerServer {
|
|
56
58
|
app: FastifyInstance;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
REMOTE_WORKER_RUNTIME_CWD,
|
|
3
2
|
WORKER_INTERNAL_TOKEN_HEADER,
|
|
4
|
-
constantTimeTokenEqual
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import "../../chunk-
|
|
9
|
-
import "../../chunk-M32FXCIN.js";
|
|
10
|
-
import "../../chunk-WSQ5QNIY.js";
|
|
11
|
-
import "../../chunk-BDYXKHWY.js";
|
|
12
|
-
import "../../chunk-WZCTVT57.js";
|
|
3
|
+
constantTimeTokenEqual
|
|
4
|
+
} from "../../chunk-BHH5NH7P.js";
|
|
5
|
+
import "../../chunk-IWBC6SF7.js";
|
|
6
|
+
import "../../chunk-CJ2BW2W2.js";
|
|
7
|
+
import "../../chunk-NITBKFG6.js";
|
|
13
8
|
import "../../chunk-AQBXNPMD.js";
|
|
14
|
-
import "../../chunk-
|
|
9
|
+
import "../../chunk-WSQ5QNIY.js";
|
|
10
|
+
import "../../chunk-PZC76CIA.js";
|
|
11
|
+
import "../../chunk-2GBHYJVC.js";
|
|
15
12
|
|
|
16
13
|
// src/server/worker/index.ts
|
|
17
14
|
import Fastify from "fastify";
|
|
@@ -132,20 +129,16 @@ function assertSafeWorkspaceId(workspaceId) {
|
|
|
132
129
|
}
|
|
133
130
|
return normalized;
|
|
134
131
|
}
|
|
135
|
-
async function createWorkerRuntime(root, workspaceId,
|
|
132
|
+
async function createWorkerRuntime(root, workspaceId, provider) {
|
|
136
133
|
const safeId = assertSafeWorkspaceId(workspaceId);
|
|
137
134
|
const hostRoot = join(root, safeId);
|
|
138
135
|
await mkdir(hostRoot, { recursive: true });
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
network: options.bwrapNetwork,
|
|
144
|
-
dropAllCapabilities: true,
|
|
145
|
-
resourceLimits: options.resourceLimits
|
|
136
|
+
const pair = await provider.create({
|
|
137
|
+
workspaceRoot: hostRoot,
|
|
138
|
+
workspaceId: safeId,
|
|
139
|
+
sessionId: safeId
|
|
146
140
|
});
|
|
147
|
-
|
|
148
|
-
return { workspace, sandbox };
|
|
141
|
+
return { workspace: pair.workspace, sandbox: pair.sandbox, dispose: () => pair.dispose() };
|
|
149
142
|
}
|
|
150
143
|
async function runWorkspaceOp(workspace, op) {
|
|
151
144
|
switch (op.op) {
|
|
@@ -231,17 +224,15 @@ function resultToResponse(result) {
|
|
|
231
224
|
stderrEncoding: result.stderrEncoding
|
|
232
225
|
};
|
|
233
226
|
}
|
|
234
|
-
async function registerWorkerRoutes(app, config) {
|
|
227
|
+
async function registerWorkerRoutes(app, config, runtimeProvider) {
|
|
235
228
|
const semaphore = new ExecSemaphore(config.execConcurrency);
|
|
236
229
|
const runtimes = /* @__PURE__ */ new Map();
|
|
237
230
|
const getRuntime = (workspaceId) => {
|
|
238
231
|
const safeId = assertSafeWorkspaceId(workspaceId);
|
|
239
232
|
let runtime = runtimes.get(safeId);
|
|
240
233
|
if (!runtime) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
resourceLimits: config.resourceLimits
|
|
244
|
-
});
|
|
234
|
+
if (!runtimeProvider) throw new Error("worker runtime provider must be injected by the host");
|
|
235
|
+
runtime = createWorkerRuntime(config.workspaceRoot, safeId, runtimeProvider);
|
|
245
236
|
runtimes.set(safeId, runtime);
|
|
246
237
|
}
|
|
247
238
|
return runtime;
|
|
@@ -250,7 +241,7 @@ async function registerWorkerRoutes(app, config) {
|
|
|
250
241
|
for (const runtimePromise of runtimes.values()) {
|
|
251
242
|
try {
|
|
252
243
|
const runtime = await runtimePromise;
|
|
253
|
-
runtime.
|
|
244
|
+
await runtime.dispose();
|
|
254
245
|
} catch {
|
|
255
246
|
}
|
|
256
247
|
}
|
|
@@ -350,7 +341,7 @@ var DEFAULT_BODY_LIMIT = 20 * 1024 * 1024;
|
|
|
350
341
|
async function createWorkerServer(options = {}) {
|
|
351
342
|
const config = options.config ?? loadWorkerConfig();
|
|
352
343
|
const app = Fastify({ logger: true, bodyLimit: DEFAULT_BODY_LIMIT, ...options.fastify });
|
|
353
|
-
await registerWorkerRoutes(app, config);
|
|
344
|
+
await registerWorkerRoutes(app, config, options.runtimeProvider);
|
|
354
345
|
return { app, config };
|
|
355
346
|
}
|
|
356
347
|
export {
|