hyperbrane 0.1.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.
Files changed (123) hide show
  1. package/README.md +41 -0
  2. package/dist/agent/agentService.d.ts +31 -0
  3. package/dist/agent/agentService.js +388 -0
  4. package/dist/agent/agentStorage.d.ts +27 -0
  5. package/dist/agent/agentStorage.js +52 -0
  6. package/dist/agent/api.d.ts +264 -0
  7. package/dist/agent/api.js +14 -0
  8. package/dist/agent/gatewaySignIns.d.ts +5 -0
  9. package/dist/agent/gatewaySignIns.js +11 -0
  10. package/dist/agent/session/client.d.ts +14 -0
  11. package/dist/agent/session/client.js +47 -0
  12. package/dist/agent/session/sessionStorage.d.ts +66 -0
  13. package/dist/agent/session/sessionStorage.js +89 -0
  14. package/dist/agent/session/sharedConnection.d.ts +13 -0
  15. package/dist/agent/session/sharedConnection.js +55 -0
  16. package/dist/agent/session/worker/jsonRpc.d.ts +39 -0
  17. package/dist/agent/session/worker/jsonRpc.js +102 -0
  18. package/dist/agent/session/worker/protocol.d.ts +120 -0
  19. package/dist/agent/session/worker/protocol.js +32 -0
  20. package/dist/agent/session/workerConnection.d.ts +29 -0
  21. package/dist/agent/session/workerConnection.js +44 -0
  22. package/dist/agent/session/workerSseConnection.d.ts +15 -0
  23. package/dist/agent/session/workerSseConnection.js +26 -0
  24. package/dist/agent/workerBundle.d.ts +19 -0
  25. package/dist/agent/workerBundle.generated.d.ts +1 -0
  26. package/dist/agent/workerBundle.generated.js +2 -0
  27. package/dist/agent/workerBundle.js +31 -0
  28. package/dist/cli/agent.d.ts +3 -0
  29. package/dist/cli/agent.js +423 -0
  30. package/dist/cli/command.d.ts +46 -0
  31. package/dist/cli/command.js +98 -0
  32. package/dist/cli/dimension.d.ts +2 -0
  33. package/dist/cli/dimension.js +85 -0
  34. package/dist/cli/gateway.d.ts +6 -0
  35. package/dist/cli/gateway.js +245 -0
  36. package/dist/cli/main.d.ts +2 -0
  37. package/dist/cli/main.js +125 -0
  38. package/dist/cli/portal.d.ts +2 -0
  39. package/dist/cli/portal.js +39 -0
  40. package/dist/cli/services.d.ts +18 -0
  41. package/dist/cli/services.js +33 -0
  42. package/dist/cli/streamPrinter.d.ts +23 -0
  43. package/dist/cli/streamPrinter.js +251 -0
  44. package/dist/cli/table.d.ts +7 -0
  45. package/dist/cli/table.js +54 -0
  46. package/dist/dimension/api.d.ts +67 -0
  47. package/dist/dimension/api.js +81 -0
  48. package/dist/dimension/http.d.ts +7 -0
  49. package/dist/dimension/http.js +77 -0
  50. package/dist/dimension/image.d.ts +13 -0
  51. package/dist/dimension/image.js +43 -0
  52. package/dist/dimension/imageFiles.generated.d.ts +1 -0
  53. package/dist/dimension/imageFiles.generated.js +5 -0
  54. package/dist/dimension/paths.d.ts +5 -0
  55. package/dist/dimension/paths.js +7 -0
  56. package/dist/dimension/service.d.ts +22 -0
  57. package/dist/dimension/service.js +242 -0
  58. package/dist/dimension/storage.d.ts +39 -0
  59. package/dist/dimension/storage.js +78 -0
  60. package/dist/index.d.ts +18 -0
  61. package/dist/index.js +25 -0
  62. package/dist/lib/docker-api.d.ts +13787 -0
  63. package/dist/lib/docker-api.js +5 -0
  64. package/dist/lib/docker.d.ts +77 -0
  65. package/dist/lib/docker.js +214 -0
  66. package/dist/lib/image.d.ts +14 -0
  67. package/dist/lib/image.js +29 -0
  68. package/dist/lib/jsonDirectory.d.ts +28 -0
  69. package/dist/lib/jsonDirectory.js +102 -0
  70. package/dist/lib/sleep.d.ts +2 -0
  71. package/dist/lib/sleep.js +4 -0
  72. package/dist/lib/tar.d.ts +2 -0
  73. package/dist/lib/tar.js +65 -0
  74. package/dist/lib/version.d.ts +1 -0
  75. package/dist/lib/version.js +1 -0
  76. package/dist/portal-gateway/api.d.ts +98 -0
  77. package/dist/portal-gateway/api.js +12 -0
  78. package/dist/portal-gateway/fakes.d.ts +3 -0
  79. package/dist/portal-gateway/fakes.js +11 -0
  80. package/dist/portal-gateway/gatewayService.d.ts +37 -0
  81. package/dist/portal-gateway/gatewayService.js +380 -0
  82. package/dist/portal-gateway/gatewayStorage.d.ts +66 -0
  83. package/dist/portal-gateway/gatewayStorage.js +125 -0
  84. package/dist/portal-gateway/image.d.ts +6 -0
  85. package/dist/portal-gateway/image.js +13 -0
  86. package/dist/portal-gateway/imageFiles.generated.d.ts +1 -0
  87. package/dist/portal-gateway/imageFiles.generated.js +8 -0
  88. package/dist/portal-gateway/portalService.d.ts +48 -0
  89. package/dist/portal-gateway/portalService.js +327 -0
  90. package/dist/portal-gateway/portalStorage.d.ts +34 -0
  91. package/dist/portal-gateway/portalStorage.js +44 -0
  92. package/dist/portal-gateway/upstream.d.ts +157 -0
  93. package/dist/portal-gateway/upstream.js +4 -0
  94. package/dist/sandbox/api.d.ts +184 -0
  95. package/dist/sandbox/api.js +14 -0
  96. package/dist/sandbox/boatService.d.ts +52 -0
  97. package/dist/sandbox/boatService.js +335 -0
  98. package/dist/sandbox/containerService.d.ts +15 -0
  99. package/dist/sandbox/containerService.js +177 -0
  100. package/dist/sandbox/endpointProxy.d.ts +90 -0
  101. package/dist/sandbox/endpointProxy.js +701 -0
  102. package/dist/sandbox/exeDevAuth.d.ts +16 -0
  103. package/dist/sandbox/exeDevAuth.js +49 -0
  104. package/dist/sandbox/localService.d.ts +19 -0
  105. package/dist/sandbox/localService.js +182 -0
  106. package/dist/sandbox/sseConnection.d.ts +41 -0
  107. package/dist/sandbox/sseConnection.js +166 -0
  108. package/dist/sandbox/sshService.d.ts +30 -0
  109. package/dist/sandbox/sshService.js +647 -0
  110. package/dist/upstreams/anthropic.d.ts +7 -0
  111. package/dist/upstreams/anthropic.js +27 -0
  112. package/dist/upstreams/index.d.ts +6 -0
  113. package/dist/upstreams/index.js +7 -0
  114. package/dist/upstreams/openai.d.ts +7 -0
  115. package/dist/upstreams/openai.js +40 -0
  116. package/dist/vendor-types/claude/agent-sdk/agentSdkTypes.d.ts +1 -0
  117. package/dist/vendor-types/claude/agent-sdk/bridge.d.ts +388 -0
  118. package/dist/vendor-types/claude/agent-sdk/browser-sdk.d.ts +184 -0
  119. package/dist/vendor-types/claude/agent-sdk/core.d.ts +20 -0
  120. package/dist/vendor-types/claude/agent-sdk/extractFromBunfs.d.ts +1 -0
  121. package/dist/vendor-types/claude/agent-sdk/sdk-tools.d.ts +4153 -0
  122. package/dist/vendor-types/claude/agent-sdk/sdk.d.ts +9833 -0
  123. package/package.json +55 -0
@@ -0,0 +1,102 @@
1
+ /**
2
+ * JSON-RPC 2.0 over a byte stream, one JSON object per line (the framing codex's app-server uses).
3
+ * Either end can send requests and notifications; the worker protocol (protocol.ts) is built on it.
4
+ */
5
+ /** Answer for a line that isn't JSON-RPC at all. */
6
+ const PARSE_ERROR = -32700;
7
+ export function createJsonRpcPeer(write, options) {
8
+ const pending = new Map();
9
+ let nextId = 1;
10
+ let buffered = "";
11
+ let closedWith;
12
+ function send(message) {
13
+ if (closedWith)
14
+ return;
15
+ write(JSON.stringify({ jsonrpc: "2.0", ...message }) + "\n");
16
+ }
17
+ function handle(message) {
18
+ if (message.method === undefined) {
19
+ if (message.id === undefined || message.id === null)
20
+ return;
21
+ const waiting = pending.get(message.id);
22
+ pending.delete(message.id);
23
+ if (message.error)
24
+ waiting?.reject(options.decodeError(message.error));
25
+ else
26
+ waiting?.resolve(message.result);
27
+ return;
28
+ }
29
+ if (message.id === undefined || message.id === null) {
30
+ options.onNotification?.(message.method, message.params);
31
+ return;
32
+ }
33
+ const id = message.id;
34
+ options.onRequest(message.method, message.params).then((result) => send({ id, result: result ?? null }), (error) => send({ id, error: options.encodeError(error) }));
35
+ }
36
+ function receive(text) {
37
+ buffered += text;
38
+ let newline;
39
+ while ((newline = buffered.indexOf("\n")) >= 0) {
40
+ const line = buffered.slice(0, newline).trim();
41
+ buffered = buffered.slice(newline + 1);
42
+ if (!line)
43
+ continue;
44
+ let message;
45
+ try {
46
+ message = JSON.parse(line);
47
+ }
48
+ catch {
49
+ send({ id: null, error: { code: PARSE_ERROR, message: "not JSON" } });
50
+ continue;
51
+ }
52
+ handle(message);
53
+ }
54
+ }
55
+ function request(method, params) {
56
+ if (closedWith)
57
+ return Promise.reject(closedWith);
58
+ const id = nextId++;
59
+ return new Promise((resolve, reject) => {
60
+ pending.set(id, { resolve, reject });
61
+ send({ id, method, params });
62
+ });
63
+ }
64
+ function notify(method, params) {
65
+ send({ method, params });
66
+ }
67
+ function close(error) {
68
+ closedWith ??= error;
69
+ for (const waiting of pending.values())
70
+ waiting.reject(error);
71
+ pending.clear();
72
+ }
73
+ return { receive, request, notify, close };
74
+ }
75
+ /**
76
+ * Writes to a Bun socket without losing what it can't take yet: the rest is kept and written on
77
+ * `drain`, which the socket's drain handler must call.
78
+ */
79
+ export function createSocketWriter(socket) {
80
+ const encoder = new TextEncoder();
81
+ let backlog = null;
82
+ function write(text) {
83
+ const bytes = encoder.encode(text);
84
+ if (backlog) {
85
+ const joined = new Uint8Array(backlog.length + bytes.length);
86
+ joined.set(backlog);
87
+ joined.set(bytes, backlog.length);
88
+ backlog = joined;
89
+ return;
90
+ }
91
+ const written = Math.max(socket.write(bytes), 0);
92
+ if (written < bytes.length)
93
+ backlog = bytes.subarray(written);
94
+ }
95
+ function drain() {
96
+ if (!backlog)
97
+ return;
98
+ const written = Math.max(socket.write(backlog), 0);
99
+ backlog = written < backlog.length ? backlog.subarray(written) : null;
100
+ }
101
+ return { write, drain };
102
+ }
@@ -0,0 +1,120 @@
1
+ import { type AgentAuthStatus, type AgentBackend, type AgentBackgroundTask, type AgentLastUserMessage, type AgentModelInfo, type AgentPermissionRequest, type AgentPermissionResult, type AgentQuestionRequest, type AgentQuestionResponse, type AgentSession, type AgentSessionInfo, type AgentSessionLimits, type AgentSessionState, type AgentStreamingMessage, type AgentTranscriptPage, type UserMessage } from "../../api.ts";
2
+ import type { JsonRpcErrorObject } from "./jsonRpc.ts";
3
+ /**
4
+ * The worker's JSON-RPC protocol, spoken over its unix socket (see createWorkerServer): method ->
5
+ * [params, result]. Sessions are named by `session`; everything answers `null` unless it says.
6
+ * worker/health and worker/shutdown are how the host tells a worker's build and replaces it: they
7
+ * never change.
8
+ */
9
+ export type WorkerRequests = {
10
+ "worker/health": [Record<string, never>, WorkerHealth];
11
+ /** Answers, then stops the sessions' CLIs and exits. */
12
+ "worker/shutdown": [Record<string, never>, null];
13
+ "backend/install": [{
14
+ backend: AgentBackend;
15
+ }, null];
16
+ "session/create": [{
17
+ session: AgentSession;
18
+ }, AgentSessionInfo];
19
+ "session/list": [Record<string, never>, AgentSessionInfo[]];
20
+ "session/update": [{
21
+ session: string;
22
+ limits: AgentSessionLimits;
23
+ }, AgentSessionInfo];
24
+ "session/stop": [{
25
+ session: string;
26
+ }, null];
27
+ "session/send": [{
28
+ session: string;
29
+ message: UserMessage;
30
+ }, null];
31
+ "session/interrupt": [{
32
+ session: string;
33
+ }, null];
34
+ "session/status": [{
35
+ session: string;
36
+ }, AgentSessionState];
37
+ "session/lastUserMessages": [{
38
+ session: string;
39
+ }, AgentLastUserMessage[]];
40
+ /**
41
+ * Streams the session's messages as `session/message` notifications carrying `subscription` (the
42
+ * client's own id for the stream): first the complete messages after `after_id` (all of them when
43
+ * omitted) from the backend's transcript, then each message as it comes, until session/unsubscribe
44
+ * or the connection closes.
45
+ */
46
+ "session/subscribe": [{
47
+ session: string;
48
+ subscription: string;
49
+ after_id?: string;
50
+ }, null];
51
+ "session/unsubscribe": [{
52
+ subscription: string;
53
+ }, null];
54
+ "session/transcript": [{
55
+ session: string;
56
+ limit?: number;
57
+ cursor?: string;
58
+ }, AgentTranscriptPage];
59
+ "permission/list": [{
60
+ session: string;
61
+ }, AgentPermissionRequest[]];
62
+ "permission/respond": [{
63
+ session: string;
64
+ request: string;
65
+ result: AgentPermissionResult;
66
+ }, null];
67
+ "question/list": [{
68
+ session: string;
69
+ }, AgentQuestionRequest[]];
70
+ "question/respond": [{
71
+ session: string;
72
+ request: string;
73
+ response: AgentQuestionResponse;
74
+ }, null];
75
+ /** Starts the session's CLI if it isn't running. */
76
+ "model/list": [{
77
+ session: string;
78
+ }, AgentModelInfo[]];
79
+ "model/set": [{
80
+ session: string;
81
+ model: string | null;
82
+ }, null];
83
+ /** Doesn't start the CLI: a session whose CLI isn't running has no tasks. */
84
+ "task/list": [{
85
+ session: string;
86
+ }, AgentBackgroundTask[]];
87
+ "task/stop": [{
88
+ session: string;
89
+ task: string;
90
+ }, null];
91
+ "auth/status": [{
92
+ session: string;
93
+ }, AgentAuthStatus];
94
+ /** `gatewaySignedIn`: the dimension's gateway holds the backend's upstream credential (the host knows; the worker can't). */
95
+ "auth/login": [{
96
+ session: string;
97
+ gatewaySignedIn: boolean;
98
+ }, AgentAuthStatus];
99
+ "auth/code": [{
100
+ session: string;
101
+ code: string;
102
+ }, AgentAuthStatus];
103
+ };
104
+ export type WorkerMethod = keyof WorkerRequests;
105
+ export type WorkerNotifications = {
106
+ "session/message": {
107
+ subscription: string;
108
+ message: AgentStreamingMessage;
109
+ };
110
+ };
111
+ export type WorkerHealth = {
112
+ agentName: string;
113
+ build: string;
114
+ };
115
+ export declare class WorkerMethodNotFoundError extends Error {
116
+ name: string;
117
+ }
118
+ /** The Agent*Errors travel as their own codes, so the client can raise the same class again. */
119
+ export declare function encodeWorkerError(error: unknown): JsonRpcErrorObject;
120
+ export declare function decodeWorkerError({ code, message }: JsonRpcErrorObject): Error;
@@ -0,0 +1,32 @@
1
+ import { AgentConflictError, AgentInvalidError, AgentNotFoundError, } from "../../api.js";
2
+ const METHOD_NOT_FOUND = -32601;
3
+ const INVALID_PARAMS = -32602;
4
+ const INTERNAL_ERROR = -32603;
5
+ // Server-defined codes, for the Agent*Errors that aren't bad params.
6
+ const NOT_FOUND = -32004;
7
+ const CONFLICT = -32009;
8
+ export class WorkerMethodNotFoundError extends Error {
9
+ name = "WorkerMethodNotFoundError";
10
+ }
11
+ /** The Agent*Errors travel as their own codes, so the client can raise the same class again. */
12
+ export function encodeWorkerError(error) {
13
+ const message = error instanceof Error ? error.message : String(error);
14
+ if (error instanceof AgentInvalidError)
15
+ return { code: INVALID_PARAMS, message };
16
+ if (error instanceof AgentNotFoundError)
17
+ return { code: NOT_FOUND, message };
18
+ if (error instanceof AgentConflictError)
19
+ return { code: CONFLICT, message };
20
+ if (error instanceof WorkerMethodNotFoundError)
21
+ return { code: METHOD_NOT_FOUND, message };
22
+ return { code: INTERNAL_ERROR, message };
23
+ }
24
+ export function decodeWorkerError({ code, message }) {
25
+ if (code === INVALID_PARAMS)
26
+ return new AgentInvalidError(message);
27
+ if (code === NOT_FOUND)
28
+ return new AgentNotFoundError(message);
29
+ if (code === CONFLICT)
30
+ return new AgentConflictError(message);
31
+ return new Error(`worker: ${message}`);
32
+ }
@@ -0,0 +1,29 @@
1
+ import type { Sandbox } from "../../sandbox/api.ts";
2
+ import { type WorkerMethod, type WorkerNotifications, type WorkerRequests } from "./worker/protocol.ts";
3
+ /** One connection to a worker: typed requests, and the notifications it pushes. */
4
+ export type WorkerConnection = {
5
+ request<M extends WorkerMethod>(method: M, params: WorkerRequests[M][0]): Promise<WorkerRequests[M][1]>;
6
+ /** Resolves when the worker closes the connection (or it fails). */
7
+ closed: Promise<void>;
8
+ close(): void;
9
+ };
10
+ export type WorkerNotificationHandler = <N extends keyof WorkerNotifications>(method: N, params: WorkerNotifications[N]) => void;
11
+ /** Opens a connection; notifications go to `onNotification`. */
12
+ export type ConnectWorker = (onNotification?: WorkerNotificationHandler) => Promise<WorkerConnection>;
13
+ /** A text stream to a worker that its JSON-RPC lines go out and come in on. */
14
+ export type WorkerTransport = {
15
+ write(text: string): void;
16
+ /** Receives the text read from the worker, in order. Registered before anything arrives. */
17
+ onText(listener: (text: string) => void): void;
18
+ /** Resolves once the transport is closed, by either side or by an error. */
19
+ closed: Promise<void>;
20
+ close(): void;
21
+ };
22
+ /** A connection speaking JSON-RPC over `transport` (`label` says where to, in errors). */
23
+ export declare function workerConnectionOver(transport: WorkerTransport, label: string, onNotification?: WorkerNotificationHandler): WorkerConnection;
24
+ /**
25
+ * Connects over the worker's unix socket at `socketPath` in `host` (the dimension's run directory is
26
+ * mounted on the host, wherever that is: this machine, or a server reached over SSH), speaking
27
+ * JSON-RPC.
28
+ */
29
+ export declare function workerSocketConnector(host: Sandbox, socketPath: string): ConnectWorker;
@@ -0,0 +1,44 @@
1
+ import { createJsonRpcPeer } from "./worker/jsonRpc.js";
2
+ import { WorkerMethodNotFoundError, decodeWorkerError, encodeWorkerError, } from "./worker/protocol.js";
3
+ /** A connection speaking JSON-RPC over `transport` (`label` says where to, in errors). */
4
+ export function workerConnectionOver(transport, label, onNotification) {
5
+ let peer;
6
+ transport.onText((text) => peer?.receive(text));
7
+ const closed = transport.closed.then(() => peer?.close(new Error(`the worker at ${label} closed the connection`)));
8
+ peer = createJsonRpcPeer((text) => transport.write(text), {
9
+ // The worker makes no requests of its clients.
10
+ onRequest: async (method) => {
11
+ throw new WorkerMethodNotFoundError(`no method ${method}`);
12
+ },
13
+ // type-bypass: notifications arrive as JSON; the worker only sends those in WorkerNotifications.
14
+ onNotification: (method, params) => onNotification?.(method, params),
15
+ encodeError: encodeWorkerError,
16
+ decodeError: decodeWorkerError,
17
+ });
18
+ const connected = peer;
19
+ return {
20
+ // type-bypass: the result is the one WorkerRequests pairs with this method.
21
+ request: (method, params) => connected.request(method, params),
22
+ closed,
23
+ close: () => transport.close(),
24
+ };
25
+ }
26
+ /**
27
+ * Connects over the worker's unix socket at `socketPath` in `host` (the dimension's run directory is
28
+ * mounted on the host, wherever that is: this machine, or a server reached over SSH), speaking
29
+ * JSON-RPC.
30
+ */
31
+ export function workerSocketConnector(host, socketPath) {
32
+ return async (onNotification) => {
33
+ const decoder = new TextDecoder();
34
+ const encoder = new TextEncoder();
35
+ const socket = await host.connect(socketPath);
36
+ const transport = {
37
+ write: (text) => socket.write(encoder.encode(text)),
38
+ onText: (listener) => socket.onData((data) => listener(decoder.decode(data, { stream: true }))),
39
+ closed: socket.closed,
40
+ close: () => socket.close(),
41
+ };
42
+ return workerConnectionOver(transport, socketPath, onNotification);
43
+ };
44
+ }
@@ -0,0 +1,15 @@
1
+ import type { SandboxEndpoint } from "../../sandbox/api.ts";
2
+ import { type ConnectWorker } from "./workerConnection.ts";
3
+ export { EndpointLoginRequiredError, exeDevLoginUrl, sseEvents } from "../../sandbox/sseConnection.ts";
4
+ /** Where a worker is reached, and how (AgentService.exposeAgent's answer). */
5
+ export type WorkerEndpoint = Pick<SandboxEndpoint, "url" | "credentials">;
6
+ /**
7
+ * Connects to a worker through its accessible endpoint (AgentService.exposeAgent: the endpoint
8
+ * proxy's "sse" transport), each connection an openSseConnection. Given a function, it asks it for
9
+ * the endpoint before every connection, so a proxy that stopped is started again (exposeAgent does
10
+ * that) before the client needs it. Runs in a browser as well as on a server. Aborting `signal`
11
+ * closes every connection it opened (a stream waiting for the next message included).
12
+ */
13
+ export declare function workerSseConnector(endpoint: WorkerEndpoint | (() => Promise<WorkerEndpoint>), { signal }?: {
14
+ signal?: AbortSignal;
15
+ }): ConnectWorker;
@@ -0,0 +1,26 @@
1
+ import { openSseConnection } from "../../sandbox/sseConnection.js";
2
+ import { workerConnectionOver } from "./workerConnection.js";
3
+ export { EndpointLoginRequiredError, exeDevLoginUrl, sseEvents } from "../../sandbox/sseConnection.js";
4
+ /**
5
+ * Connects to a worker through its accessible endpoint (AgentService.exposeAgent: the endpoint
6
+ * proxy's "sse" transport), each connection an openSseConnection. Given a function, it asks it for
7
+ * the endpoint before every connection, so a proxy that stopped is started again (exposeAgent does
8
+ * that) before the client needs it. Runs in a browser as well as on a server. Aborting `signal`
9
+ * closes every connection it opened (a stream waiting for the next message included).
10
+ */
11
+ export function workerSseConnector(endpoint, { signal } = {}) {
12
+ return async (onNotification) => {
13
+ signal?.throwIfAborted();
14
+ const access = typeof endpoint === "function" ? await endpoint() : endpoint;
15
+ const connection = await openSseConnection(access, { signal });
16
+ const decoder = new TextDecoder();
17
+ const encoder = new TextEncoder();
18
+ const transport = {
19
+ write: (text) => connection.write(encoder.encode(text)),
20
+ onText: (listener) => connection.onData((data) => listener(decoder.decode(data, { stream: true }))),
21
+ closed: connection.closed,
22
+ close: () => connection.close(),
23
+ };
24
+ return workerConnectionOver(transport, access.url.replace(/\/+$/, ""), onNotification);
25
+ };
26
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The session worker (agent/session/main.ts and all it imports) as the one script AgentService
3
+ * uploads into a dimension and runs with bun. The backends' own packages aren't part of it: the
4
+ * worker installs them into the dimension and loads them from there.
5
+ */
6
+ export type WorkerBundle = {
7
+ /** The worker as one script for bun. */
8
+ source: string;
9
+ /** Identifies the source: a running worker with another build is replaced. */
10
+ build: string;
11
+ };
12
+ /**
13
+ * The worker, once per process. Under Bun with the sources at hand (a checkout) it is bundled from
14
+ * them; otherwise (Node, or the built package, which ships no sources) it comes from
15
+ * agent/workerBundle.generated.ts (scripts/bundle-worker.ts).
16
+ */
17
+ export declare function workerBundle(): Promise<WorkerBundle>;
18
+ /** Bundles the worker with Bun.build. */
19
+ export declare function buildWorkerSource(): Promise<string>;
@@ -0,0 +1 @@
1
+ export declare const WORKER_SOURCE: string;