hyperbrane 0.1.2 → 0.2.0
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/README.md +67 -25
- package/dist/agent/agentClient.d.ts +5 -0
- package/dist/agent/agentClient.js +4 -0
- package/dist/agent/agentService.d.ts +9 -37
- package/dist/agent/agentService.js +62 -322
- package/dist/agent/agentStorage.d.ts +1 -20
- package/dist/agent/agentStorage.js +0 -30
- package/dist/agent/api.d.ts +80 -151
- package/dist/agent/api.js +1 -8
- package/dist/agent/client.d.ts +3 -1
- package/dist/agent/client.js +2 -3
- package/dist/agent/control.d.ts +23 -0
- package/dist/agent/control.js +479 -0
- package/dist/agent/hostTranscript.d.ts +0 -6
- package/dist/agent/hostTranscript.js +3 -14
- package/dist/agent/session/backend.d.ts +17 -32
- package/dist/agent/session/claude/home.d.ts +0 -1
- package/dist/agent/session/claude/home.js +0 -1
- package/dist/agent/session/claude/provision.d.ts +10 -0
- package/dist/agent/session/claude/provision.js +17 -0
- package/dist/agent/session/claude/transcript.d.ts +2 -7
- package/dist/agent/session/claude/transcript.js +68 -14
- package/dist/agent/session/client.d.ts +1 -10
- package/dist/agent/session/client.js +0 -3
- package/dist/agent/session/codex/provision.d.ts +14 -0
- package/dist/agent/session/codex/provision.js +25 -0
- package/dist/agent/session/fileTranscript.d.ts +6 -49
- package/dist/agent/session/fileTranscript.js +26 -82
- package/dist/agent/session/install.d.ts +5 -0
- package/dist/agent/session/install.js +35 -0
- package/dist/agent/session/sessionStorage.d.ts +4 -35
- package/dist/agent/session/sessionStorage.js +10 -16
- package/dist/agent/session/sharedConnection.d.ts +0 -8
- package/dist/agent/session/sharedConnection.js +0 -7
- package/dist/agent/session/storedTranscripts.d.ts +1 -6
- package/dist/agent/session/storedTranscripts.js +0 -3
- package/dist/agent/session/worker/jsonRpc.d.ts +2 -13
- package/dist/agent/session/worker/jsonRpc.js +2 -11
- package/dist/agent/session/worker/protocol.d.ts +26 -20
- package/dist/agent/session/worker/protocol.js +29 -18
- package/dist/agent/session/worker/workerParams.d.ts +0 -5
- package/dist/agent/session/worker/workerParams.js +14 -14
- package/dist/agent/session/workerConnection.d.ts +2 -13
- package/dist/agent/session/workerConnection.js +7 -12
- package/dist/agent/session/workerGatewayConnection.d.ts +18 -0
- package/dist/agent/session/workerGatewayConnection.js +86 -0
- package/dist/agent/vendor-types/manifest.json +87 -0
- package/dist/agent/workerBundle.d.ts +4 -19
- package/dist/agent/workerBundle.generated.js +1 -1
- package/dist/agent/workerBundle.js +3 -30
- package/dist/agent/workerReplacement.d.ts +3 -0
- package/dist/agent/workerReplacement.js +49 -0
- package/dist/cli/agent.js +31 -16
- package/dist/cli/command.d.ts +10 -11
- package/dist/cli/command.js +0 -4
- package/dist/cli/dimension.js +6 -6
- package/dist/cli/gateway.js +3 -6
- package/dist/cli/main.js +14 -31
- package/dist/cli/streamPrinter.d.ts +2 -10
- package/dist/cli/streamPrinter.js +16 -46
- package/dist/cli/table.d.ts +0 -3
- package/dist/cli/table.js +0 -4
- package/dist/dimension/api.d.ts +39 -27
- package/dist/dimension/api.js +28 -47
- package/dist/dimension/client.d.ts +5 -0
- package/dist/dimension/client.js +4 -0
- package/dist/dimension/control.d.ts +21 -0
- package/dist/dimension/control.js +328 -0
- package/dist/dimension/image.d.ts +0 -5
- package/dist/dimension/image.js +0 -8
- package/dist/dimension/imageFiles.generated.js +1 -1
- package/dist/dimension/paths.d.ts +5 -4
- package/dist/dimension/paths.js +15 -6
- package/dist/dimension/service.d.ts +8 -24
- package/dist/dimension/service.js +60 -228
- package/dist/dimension/transport-worker.d.ts +1 -0
- package/dist/dimension/transport-worker.js +151 -0
- package/dist/dimension/transportBundle.d.ts +2 -0
- package/dist/dimension/transportBundle.generated.d.ts +1 -0
- package/dist/dimension/transportBundle.generated.js +2 -0
- package/dist/dimension/transportBundle.js +4 -0
- package/dist/dimension/transportClient.d.ts +10 -0
- package/dist/dimension/transportClient.js +115 -0
- package/dist/dimension/transportProtocol.d.ts +53 -0
- package/dist/dimension/transportProtocol.js +8 -0
- package/dist/index.d.ts +5 -9
- package/dist/index.js +5 -19
- package/dist/lib/control.d.ts +8 -0
- package/dist/lib/control.js +62 -0
- package/dist/lib/docker.d.ts +0 -22
- package/dist/lib/docker.js +0 -10
- package/dist/lib/image.d.ts +0 -3
- package/dist/lib/image.js +0 -2
- package/dist/lib/jsonDirectory.d.ts +0 -13
- package/dist/lib/jsonDirectory.js +10 -15
- package/dist/lib/scriptBundle.d.ts +6 -0
- package/dist/lib/scriptBundle.js +28 -0
- package/dist/lib/sh.d.ts +2 -0
- package/dist/lib/sh.js +8 -0
- package/dist/lib/sleep.d.ts +0 -1
- package/dist/lib/sleep.js +0 -1
- package/dist/lib/streamFetch.d.ts +15 -0
- package/dist/lib/streamFetch.js +150 -0
- package/dist/lib/tar.d.ts +0 -1
- package/dist/lib/tar.js +5 -11
- package/dist/portal-gateway/api.d.ts +13 -44
- package/dist/portal-gateway/api.js +1 -3
- package/dist/portal-gateway/control.d.ts +42 -0
- package/dist/portal-gateway/control.js +657 -0
- package/dist/portal-gateway/gatewayClient.d.ts +5 -0
- package/dist/portal-gateway/gatewayClient.js +4 -0
- package/dist/portal-gateway/gatewayService.d.ts +8 -38
- package/dist/portal-gateway/gatewayService.js +68 -254
- package/dist/portal-gateway/image.d.ts +0 -1
- package/dist/portal-gateway/image.js +0 -2
- package/dist/portal-gateway/imageFiles.generated.js +2 -2
- package/dist/portal-gateway/portalClient.d.ts +5 -0
- package/dist/portal-gateway/portalClient.js +4 -0
- package/dist/portal-gateway/portalService.d.ts +5 -47
- package/dist/portal-gateway/portalService.js +19 -349
- package/dist/portal-gateway/transport-worker.d.ts +1 -0
- package/dist/portal-gateway/transport-worker.js +205 -0
- package/dist/portal-gateway/transportBundle.d.ts +2 -0
- package/dist/portal-gateway/transportBundle.generated.d.ts +1 -0
- package/dist/portal-gateway/transportBundle.generated.js +2 -0
- package/dist/portal-gateway/transportBundle.js +4 -0
- package/dist/portal-gateway/upstream.d.ts +0 -81
- package/dist/portal-gateway/upstream.js +0 -1
- package/dist/sandbox/api.d.ts +121 -187
- package/dist/sandbox/api.js +5 -7
- package/dist/sandbox/client.d.ts +2 -0
- package/dist/sandbox/client.js +4 -0
- package/dist/sandbox/data-endpoints/dataEndpoints.d.ts +13 -0
- package/dist/sandbox/data-endpoints/dataEndpoints.js +100 -0
- package/dist/sandbox/data-endpoints/firewalledPorts.d.ts +4 -0
- package/dist/sandbox/data-endpoints/firewalledPorts.js +28 -0
- package/dist/sandbox/lib/httpOverStream.d.ts +3 -0
- package/dist/sandbox/lib/httpOverStream.js +21 -0
- package/dist/sandbox/lib/remoteFileOperations.d.ts +10 -0
- package/dist/sandbox/lib/remoteFileOperations.js +70 -0
- package/dist/sandbox/lib/shellCommand.d.ts +3 -0
- package/dist/sandbox/lib/shellCommand.js +7 -0
- package/dist/sandbox/providers/boat/boatService.d.ts +2 -0
- package/dist/sandbox/providers/boat/boatService.js +321 -0
- package/dist/sandbox/providers/exedev/exeDevService.d.ts +2 -0
- package/dist/sandbox/providers/exedev/exeDevService.js +127 -0
- package/dist/sandbox/providers/exedev/exeDevToken.d.ts +1 -0
- package/dist/sandbox/providers/exedev/exeDevToken.js +54 -0
- package/dist/sandbox/providers/local/localService.d.ts +2 -0
- package/dist/sandbox/providers/local/localService.js +219 -0
- package/dist/sandbox/providers/ssh/sshService.d.ts +2 -0
- package/dist/sandbox/providers/ssh/sshService.js +82 -0
- package/dist/sandbox/providers/ssh/sshTransport.d.ts +12 -0
- package/dist/sandbox/providers/ssh/sshTransport.js +216 -0
- package/dist/sandbox/service.d.ts +2 -0
- package/dist/sandbox/service.js +18 -0
- package/dist/sandbox/storage/descriptors.d.ts +6 -0
- package/dist/sandbox/storage/descriptors.js +25 -0
- package/dist/sandbox/storage/sandboxStorage.d.ts +11 -0
- package/dist/sandbox/storage/sandboxStorage.js +42 -0
- package/dist/upstreams/anthropic.d.ts +0 -5
- package/dist/upstreams/anthropic.js +1 -8
- package/dist/upstreams/index.d.ts +2 -6
- package/dist/upstreams/index.js +0 -4
- package/dist/upstreams/openai.d.ts +0 -5
- package/dist/upstreams/openai.js +1 -13
- package/package.json +12 -4
- package/dist/agent/gatewaySignIns.d.ts +0 -5
- package/dist/agent/gatewaySignIns.js +0 -11
- package/dist/agent/session/codex/home.d.ts +0 -2
- package/dist/agent/session/codex/home.js +0 -4
- package/dist/agent/session/codex/messages.d.ts +0 -30
- package/dist/agent/session/codex/messages.js +0 -135
- package/dist/agent/session/codex/transcript.d.ts +0 -12
- package/dist/agent/session/codex/transcript.js +0 -22
- package/dist/agent/session/sdkMessages.d.ts +0 -15
- package/dist/agent/session/sdkMessages.js +0 -28
- package/dist/agent/session/workerSseConnection.d.ts +0 -31
- package/dist/agent/session/workerSseConnection.js +0 -76
- package/dist/agent/vendor-types/codex/app-server/AbsolutePathBuf.d.ts +0 -10
- package/dist/agent/vendor-types/codex/app-server/AbsolutePathBuf.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/FunctionCallOutputBody.d.ts +0 -2
- package/dist/agent/vendor-types/codex/app-server/FunctionCallOutputBody.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/FunctionCallOutputContentItem.d.ts +0 -22
- package/dist/agent/vendor-types/codex/app-server/FunctionCallOutputContentItem.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/ImageDetail.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/ImageDetail.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/ImageGenerationFailure.d.ts +0 -5
- package/dist/agent/vendor-types/codex/app-server/ImageGenerationFailure.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/ImageGenerationItem.d.ts +0 -11
- package/dist/agent/vendor-types/codex/app-server/ImageGenerationItem.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/LegacyAppPathString.d.ts +0 -23
- package/dist/agent/vendor-types/codex/app-server/LegacyAppPathString.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/MessagePhase.d.ts +0 -7
- package/dist/agent/vendor-types/codex/app-server/MessagePhase.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/ReasoningEffort.d.ts +0 -4
- package/dist/agent/vendor-types/codex/app-server/ReasoningEffort.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/SleepItem.d.ts +0 -7
- package/dist/agent/vendor-types/codex/app-server/SleepItem.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/WebSearchItem.d.ts +0 -14
- package/dist/agent/vendor-types/codex/app-server/WebSearchItem.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/serde_json/JsonValue.d.ts +0 -3
- package/dist/agent/vendor-types/codex/app-server/serde_json/JsonValue.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/AgentMessageDelivery.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/AgentMessageDelivery.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/AsyncUserInputQuestion.d.ts +0 -4
- package/dist/agent/vendor-types/codex/app-server/v2/AsyncUserInputQuestion.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/ByteRange.d.ts +0 -4
- package/dist/agent/vendor-types/codex/app-server/v2/ByteRange.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentState.d.ts +0 -5
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentState.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentStatus.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentStatus.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentTool.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentTool.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentToolCallStatus.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentToolCallStatus.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/CommandAction.d.ts +0 -19
- package/dist/agent/vendor-types/codex/app-server/v2/CommandAction.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/CommandExecutionSource.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/CommandExecutionSource.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/CommandExecutionStatus.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/CommandExecutionStatus.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/DynamicToolCallOutputContentItem.d.ts +0 -10
- package/dist/agent/vendor-types/codex/app-server/v2/DynamicToolCallOutputContentItem.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/DynamicToolCallStatus.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/DynamicToolCallStatus.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/FileUpdateChange.d.ts +0 -6
- package/dist/agent/vendor-types/codex/app-server/v2/FileUpdateChange.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/HookPromptFragment.d.ts +0 -4
- package/dist/agent/vendor-types/codex/app-server/v2/HookPromptFragment.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/McpAppDisplayMode.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/McpAppDisplayMode.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/McpAppUi.d.ts +0 -8
- package/dist/agent/vendor-types/codex/app-server/v2/McpAppUi.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallAppContext.d.ts +0 -7
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallAppContext.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallError.d.ts +0 -3
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallError.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallResult.d.ts +0 -6
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallResult.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallStatus.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallStatus.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/MemoryCitation.d.ts +0 -5
- package/dist/agent/vendor-types/codex/app-server/v2/MemoryCitation.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/MemoryCitationEntry.d.ts +0 -6
- package/dist/agent/vendor-types/codex/app-server/v2/MemoryCitationEntry.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/PatchApplyStatus.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/PatchApplyStatus.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/PatchChangeKind.d.ts +0 -8
- package/dist/agent/vendor-types/codex/app-server/v2/PatchChangeKind.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/SubAgentActivityKind.d.ts +0 -1
- package/dist/agent/vendor-types/codex/app-server/v2/SubAgentActivityKind.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/TextElement.d.ts +0 -11
- package/dist/agent/vendor-types/codex/app-server/v2/TextElement.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/ThreadItem.d.ts +0 -215
- package/dist/agent/vendor-types/codex/app-server/v2/ThreadItem.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/UserInput.d.ts +0 -35
- package/dist/agent/vendor-types/codex/app-server/v2/UserInput.js +0 -2
- package/dist/agent/vendor-types/codex/app-server/v2/WebSearchAction.d.ts +0 -14
- package/dist/agent/vendor-types/codex/app-server/v2/WebSearchAction.js +0 -2
- package/dist/cli/services.d.ts +0 -19
- package/dist/cli/services.js +0 -34
- package/dist/dimension/http.d.ts +0 -7
- package/dist/dimension/http.js +0 -77
- package/dist/dimension/storage.d.ts +0 -39
- package/dist/dimension/storage.js +0 -79
- package/dist/portal-gateway/fakes.d.ts +0 -3
- package/dist/portal-gateway/fakes.js +0 -11
- package/dist/portal-gateway/gatewayStorage.d.ts +0 -66
- package/dist/portal-gateway/gatewayStorage.js +0 -125
- package/dist/portal-gateway/portalStorage.d.ts +0 -34
- package/dist/portal-gateway/portalStorage.js +0 -44
- package/dist/sandbox/boatService.d.ts +0 -52
- package/dist/sandbox/boatService.js +0 -343
- package/dist/sandbox/containerService.d.ts +0 -15
- package/dist/sandbox/containerService.js +0 -184
- package/dist/sandbox/endpointProxy.d.ts +0 -90
- package/dist/sandbox/endpointProxy.js +0 -716
- package/dist/sandbox/exeDevAuth.d.ts +0 -16
- package/dist/sandbox/exeDevAuth.js +0 -49
- package/dist/sandbox/localService.d.ts +0 -19
- package/dist/sandbox/localService.js +0 -200
- package/dist/sandbox/sseConnection.d.ts +0 -41
- package/dist/sandbox/sseConnection.js +0 -166
- package/dist/sandbox/sshService.d.ts +0 -30
- package/dist/sandbox/sshService.js +0 -680
package/README.md
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# hyperbrane
|
|
2
2
|
|
|
3
3
|
Dimensions (containers bound to a host directory), the portal gateways they reach the outside
|
|
4
|
-
through, and agents (Claude Code, Codex) running in them, on a machine reached locally, over SSH,
|
|
5
|
-
as a Boat sandbox.
|
|
4
|
+
through, and agents (Claude Code, Codex) running in them, on a machine reached locally, over SSH, as
|
|
5
|
+
an exe.dev VM or as a Boat sandbox.
|
|
6
6
|
|
|
7
7
|
## Requirements
|
|
8
8
|
|
|
9
9
|
- The library: Node ≥ 20.11 or Bun.
|
|
10
10
|
- The CLI: Bun.
|
|
11
|
-
- On the machine driven: docker, and
|
|
11
|
+
- On the machine driven: docker, python3, and curl (or wget) to fetch bun once for gateways' transport
|
|
12
|
+
workers, unless the machine has bun 1.4.3 already.
|
|
12
13
|
|
|
13
14
|
## CLI
|
|
14
15
|
|
|
@@ -21,10 +22,14 @@ hyperbrane dimension create --dir ~/work -m 4G --cpus 2 work
|
|
|
21
22
|
## Library
|
|
22
23
|
|
|
23
24
|
```ts
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
const host =
|
|
27
|
-
|
|
25
|
+
import { createAgentClient, createDimensionClient, createGatewayClient, createPortalClient, createSandboxClient, MemoryLimit, CPULimit } from "hyperbrane";
|
|
26
|
+
|
|
27
|
+
const host = createSandboxClient({ kind: "ssh", sshHost: "server.example.com", sshUser: "me", sshKey: privateKey });
|
|
28
|
+
// A client per part, over the sandbox: making one does nothing.
|
|
29
|
+
const gateways = createGatewayClient(host);
|
|
30
|
+
const dimensions = createDimensionClient(host);
|
|
31
|
+
const portals = createPortalClient(host);
|
|
32
|
+
const agents = createAgentClient(host);
|
|
28
33
|
// The gateway keeps the sign-ins, under its name: a gateway by another name starts with none.
|
|
29
34
|
await gateways.createGateway({ name: "main" });
|
|
30
35
|
await dimensions.createDimension({ name: "work", directory: "work", memoryLimit: MemoryLimit("4G"), cpuLimit: CPULimit("2") });
|
|
@@ -37,14 +42,42 @@ await agents.install("dev", "claude");
|
|
|
37
42
|
Each call resolves once what it made is usable: a gateway once it intercepts, a portal once traffic
|
|
38
43
|
flows through it, an install once the backend runs. Re-running any of them converges.
|
|
39
44
|
|
|
40
|
-
hyperbrane runs where the application does and drives the machine from there
|
|
41
|
-
|
|
42
|
-
browser reaches
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
hyperbrane runs where the application does and drives the machine from there, each call over a
|
|
46
|
+
connection of its own (SSH, Boat's API): nothing is kept between calls, so it runs in serverless
|
|
47
|
+
functions too. A browser reaches the machine through data endpoints instead: ports the sandbox makes
|
|
48
|
+
reachable, one per gateway, each served by its gateway's transport worker. Where they're reached is
|
|
49
|
+
given when the sandbox is created:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// Data endpoints at server.example.com, on ports 8443-8542, each opened in ufw.
|
|
53
|
+
await host.create({ name: "server", dataEndpointOptions: { url: "https://server.example.com", ports: { from: 8443, to: 8542 }, needsFirewall: true } });
|
|
54
|
+
// An exe.dev VM, over exe.dev's SSH with a key added to the account; its endpoints behind exe.dev's proxy.
|
|
55
|
+
const vm = createSandboxClient({ kind: "exe.dev", id: "bloggy", sshKey });
|
|
56
|
+
// Boat's machine is the SDK's, created with its state saved in it.
|
|
57
|
+
const boat = createSandboxClient({ kind: "boat", sshKey }); // BOAT_API_KEY; reaches nothing yet
|
|
58
|
+
const [ctx] = await boat.create({ name: "box" }); // ctx, now with the sandbox's id, is what's kept
|
|
59
|
+
// Elsewhere, with ctx alone: its operations read its state; open() resumes it first.
|
|
60
|
+
const again = createSandboxClient(ctx);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Under a `url` with a root path, every endpoint is at `<url>/<name>` (with
|
|
64
|
+
`dataEndpointOptions: { url: "https://server.example.com/hyb" }`, the gateway `main`'s is at
|
|
65
|
+
`https://server.example.com/hyb/gateway-main`): whatever serves that path routes it to the endpoint's
|
|
66
|
+
port, which `listEndpoints()` gives.
|
|
67
|
+
|
|
68
|
+
A browser streams an agent through the gateway its dimension is wired to: hand the page
|
|
69
|
+
`await gateways.endpoint("main")` (the gateway's URL and credentials, which expire in 12 hours) and
|
|
70
|
+
the dimension's name, and it connects with
|
|
71
|
+
`createWorkerClient(workerGatewayConnector(access, { dimensionName, agentName }))` from
|
|
72
|
+
`hyperbrane/agent/client`. The agent's worker must be running (any call through `agents` starts it).
|
|
73
|
+
On exe.dev the credentials carry a VM token, sent in `X-Exedev-Authorization` as exe.dev documents
|
|
74
|
+
([HTTPS tokens for VMs](https://exe.dev/docs/https-tokens-for-vms.md)). A browser on another site
|
|
75
|
+
can't get through to a private port: exe.dev answers the header's CORS preflight with a redirect to
|
|
76
|
+
its login. There, give the endpoints a `url` with a root path on the VM's public port (the
|
|
77
|
+
`https://<vm>.exe.xyz/hyb` of a server routing `/hyb/<name>` to each endpoint's port). A page
|
|
78
|
+
can be told `EndpointUnreachableError` or `EndpointCredentialsError` (get new ones). Clients of one
|
|
79
|
+
agent can share one connection: `sharedConnector(workerGatewayConnector(...))` opens it on first use
|
|
80
|
+
and keeps it until `close()`.
|
|
48
81
|
|
|
49
82
|
What lasts:
|
|
50
83
|
|
|
@@ -52,20 +85,28 @@ What lasts:
|
|
|
52
85
|
|---|---|---|---|
|
|
53
86
|
| Workspace, sessions, sign-ins, installed backends | kept | kept | kept |
|
|
54
87
|
| Agent workers | started again by the next call (or `agents.restoreAgents()`) | same | same |
|
|
55
|
-
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
88
|
+
| A gateway's transport worker (on the machine) | kept | kept | started again by `restartGateway` |
|
|
89
|
+
| A dimension's transport worker (in it) | started again by `restartDimension` | started by `createDimension` | started again by `restartDimension` |
|
|
90
|
+
| Portals | re-wired by `restartDimension` and `restartGateway`; otherwise as on the right | re-wired by the next agent call, or `portals.restorePortals()` | same |
|
|
91
|
+
|
|
92
|
+
A Boat sandbox stops itself after a while; `sandbox.hasExpiration()` tells a sandbox that does, and
|
|
93
|
+
`setExpiration` moves it.
|
|
94
|
+
|
|
95
|
+
The root module exports the clients (`createDimensionClient`, `createGatewayClient`,
|
|
96
|
+
`createPortalClient`, `createAgentClient`), the sandbox of any kind (`createSandboxClient`) and the
|
|
97
|
+
agent's worker client. An upstream of your own is a `defineUpstream({ name, modes })`, given to a
|
|
98
|
+
gateway with `registerUpstream` (the built-in ones are `BUILTIN_UPSTREAMS`). `dimensionLayout` says
|
|
99
|
+
where a dimension keeps things: its workspace, run and state paths and CA bundle in the container,
|
|
100
|
+
its directories and transport worker's socket on the machine, and its container's name.
|
|
101
|
+
A client is an interface (`DimensionClient`, ...); these drive the machine from this process, through
|
|
102
|
+
the services behind them, and another transport may implement the same interfaces. For a
|
|
62
103
|
browser, which can't take the server side along, the package also exports each part's API
|
|
63
104
|
(`hyperbrane/sandbox/api`, `hyperbrane/dimension/api`, `hyperbrane/portal-gateway/api`,
|
|
64
105
|
`hyperbrane/agent/api`) and the agent's worker client (`hyperbrane/agent/client`). Nothing else is
|
|
65
106
|
importable.
|
|
66
107
|
|
|
67
108
|
What a client may rely on, as the types say: a `readonly` field is set by the package, for the client
|
|
68
|
-
to read; a type marked `@sealed` (the
|
|
109
|
+
to read; a type marked `@sealed` (the clients, sandboxes, services) is made by the package, for the
|
|
69
110
|
client to use, not implement. Both may gain members in any release; anything else gains only optional
|
|
70
111
|
ones, until a breaking release (`bun run api:diff --breaking` shows what would break).
|
|
71
112
|
|
|
@@ -74,6 +115,7 @@ ones, until a breaking release (`bun run api:diff --breaking` shows what would b
|
|
|
74
115
|
```sh
|
|
75
116
|
bun run build # dist/
|
|
76
117
|
bun run check:package # packs it, installs the tarball elsewhere and uses it under Node and Bun
|
|
77
|
-
bun run api:diff [
|
|
78
|
-
bun run api:diff
|
|
118
|
+
bun run api:diff [FROM [TO]] # how the public interface changed from FROM (HEAD) to TO (the working tree): git diff of just that
|
|
119
|
+
bun run api:diff FROM..TO # the same over a range of commits, e.g. v0.1.2..HEAD
|
|
120
|
+
bun run api:diff --breaking [FROM [TO] | FROM..TO] # only its breaking changes: removed, renamed, newly required, retyped
|
|
79
121
|
```
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Sandbox } from "../sandbox/api.ts";
|
|
2
|
+
import type { AgentClient, AgentProvision, AgentSessionCapabilities } from "./api.ts";
|
|
3
|
+
export declare function createAgentClient(sandbox: Sandbox, options?: {
|
|
4
|
+
dataDirectory?: string;
|
|
5
|
+
}): AgentClient & AgentProvision & AgentSessionCapabilities;
|
|
@@ -1,39 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
3
|
-
import type { AgentStorage } from "./agentStorage.ts";
|
|
4
|
-
import type { GatewaySignIns } from "./gatewaySignIns.ts";
|
|
5
|
-
import { type AgentClient, type AgentEndpoint, type AgentProvision, type AgentSessionCapabilities } from "./api.ts";
|
|
6
|
-
import type { PortalService } from "../portal-gateway/portalService.ts";
|
|
1
|
+
import type { Sandbox } from "../sandbox/api.ts";
|
|
2
|
+
import { type AgentClient, type AgentProvision, type AgentSessionCapabilities } from "./api.ts";
|
|
7
3
|
/** @sealed */
|
|
8
|
-
export interface AgentService extends AgentClient, AgentProvision, AgentSessionCapabilities
|
|
9
|
-
/** Starts the workers that a restart took down (their dimension runs again); returns their agents' names. */
|
|
10
|
-
restoreAgents(): Promise<string[]>;
|
|
4
|
+
export interface AgentService extends AgentClient, AgentProvision, AgentSessionCapabilities {
|
|
11
5
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* In the dimension: the worker's script. Outside WORKER_DIR on purpose: bun caches the listing of the
|
|
20
|
-
* directory a script is loaded from, and packages installed there afterwards didn't resolve.
|
|
21
|
-
*/
|
|
22
|
-
export declare const WORKER_SCRIPT = "/opt/hyperbrane/worker.js";
|
|
23
|
-
/**
|
|
24
|
-
* Runs each agent as a session worker inside its dimension (agent/session/main.ts) and talks
|
|
25
|
-
* JSON-RPC to it over the worker's unix socket, which the host reaches through the dimension's
|
|
26
|
-
* mounted run directory (through `host`). Keeps no state between calls beyond the agent records: every call finds
|
|
27
|
-
* the worker again.
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* `gatewaySignIns` tells whether a dimension's gateway already holds a backend's sign-in, so a
|
|
31
|
-
* session's login can complete without anyone; without it every login waits for the user.
|
|
32
|
-
*/
|
|
33
|
-
/**
|
|
34
|
-
* `host` is the machine docker runs on: workers' sockets and logs are reached through it, and agents
|
|
35
|
-
* are exposed through its endpoints when it declares them.
|
|
36
|
-
*/
|
|
37
|
-
export declare function createAgentService(storage: AgentStorage, docker: DockerClient, host: Sandbox | (Sandbox & SandboxAccessibleEndpoint), gatewaySignIns?: GatewaySignIns,
|
|
38
|
-
/** Re-wires a dimension's portals: what a restart (its container's, the machine's) took. */
|
|
39
|
-
restoring?: Pick<PortalService, "restorePortals">): AgentService;
|
|
6
|
+
export type AgentServiceWithSockets = AgentService & {
|
|
7
|
+
workerSocket(agentName: string): Promise<string>;
|
|
8
|
+
};
|
|
9
|
+
export declare function createAgentService(host: Sandbox, { dataDirectory }?: {
|
|
10
|
+
dataDirectory?: string;
|
|
11
|
+
}): AgentServiceWithSockets;
|