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
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
* Registered on every gateway whose creator doesn't list its own: a gateway that doesn't know an
|
|
4
|
-
* upstream passes its tokens through to the dimension untouched.
|
|
5
|
-
*/
|
|
6
|
-
export declare const BUILTIN_UPSTREAMS: UpstreamDefinition[];
|
|
1
|
+
import type { Upstream } from "../portal-gateway/api.ts";
|
|
2
|
+
export declare const BUILTIN_UPSTREAMS: Upstream[];
|
package/dist/upstreams/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import anthropic from "./anthropic.js";
|
|
2
2
|
import openai from "./openai.js";
|
|
3
|
-
/**
|
|
4
|
-
* Registered on every gateway whose creator doesn't list its own: a gateway that doesn't know an
|
|
5
|
-
* upstream passes its tokens through to the dimension untouched.
|
|
6
|
-
*/
|
|
7
3
|
export const BUILTIN_UPSTREAMS = [anthropic, openai];
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex: a ChatGPT plan through `codex login --device-auth`, or an OpenAI API key. Once the gateway
|
|
3
|
-
* holds a sign-in, `codex login --device-auth` in any dimension completes without a browser: the
|
|
4
|
-
* gateway approves the device login and answers the exchange itself.
|
|
5
|
-
*/
|
|
6
1
|
declare const _default: import("../portal-gateway/upstream.ts").UpstreamDefinition;
|
|
7
2
|
export default _default;
|
package/dist/upstreams/openai.js
CHANGED
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import { defineUpstream } from "../portal-gateway/
|
|
2
|
-
/**
|
|
3
|
-
* Codex: a ChatGPT plan through `codex login --device-auth`, or an OpenAI API key. Once the gateway
|
|
4
|
-
* holds a sign-in, `codex login --device-auth` in any dimension completes without a browser: the
|
|
5
|
-
* gateway approves the device login and answers the exchange itself.
|
|
6
|
-
*/
|
|
1
|
+
import { defineUpstream } from "../portal-gateway/api.js";
|
|
7
2
|
export default defineUpstream({
|
|
8
3
|
name: "openai",
|
|
9
4
|
modes: {
|
|
10
5
|
oauth: {
|
|
11
|
-
// The API (HTTP and websocket) is on chatgpt.com; auth.openai.com is the token endpoint.
|
|
12
6
|
hosts: ["chatgpt.com", "auth.openai.com"],
|
|
13
7
|
present: { header: "authorization", scheme: "Bearer" },
|
|
14
|
-
// The sign-in exchange is form-encoded, the refresh JSON.
|
|
15
8
|
tokenUrl: "https://auth.openai.com/oauth/token",
|
|
16
|
-
// codex decodes both JWTs: the access token's exp decides when it refreshes, and the id
|
|
17
|
-
// token's claims give it the account and plan.
|
|
18
9
|
fakes: {
|
|
19
10
|
access: { jwt: true },
|
|
20
11
|
id: { jwt: true },
|
|
21
12
|
refresh: { prefix: "rt.1." },
|
|
22
13
|
},
|
|
23
|
-
// Another session token, in the body and again in a header; codex doesn't keep it.
|
|
24
14
|
strip: { fields: ["oai_is"], headers: ["x-oai-is-update"] },
|
|
25
|
-
// codex polls this until the device login is approved, then exchanges the code it returns
|
|
26
|
-
// (with the returned verifier, which it doesn't check) at tokenUrl, answered by the gateway.
|
|
27
15
|
answers: [
|
|
28
16
|
{
|
|
29
17
|
url: "https://auth.openai.com/api/accounts/deviceauth/token",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperbrane",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Dimensions, gateways and agents on a machine reached locally, over SSH or on Boat: SDK and CLI.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"node": ">=20.11"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"typecheck": "bun x tsc --noEmit -p tsconfig.json",
|
|
48
|
-
"test": "bun test",
|
|
47
|
+
"typecheck": "bun x tsc --noEmit -p tsconfig.json && bun run scripts/lint-shell.ts && bun run scripts/lint-modules.ts",
|
|
48
|
+
"test": "bun run scripts/test.ts",
|
|
49
49
|
"generate:docker-api": "bun run scripts/generate-docker-api.ts",
|
|
50
50
|
"pull:vendor-types": "bun run scripts/pull-vendor-types.ts",
|
|
51
51
|
"hyperbrane": "bun run cli/main.ts",
|
|
@@ -55,10 +55,17 @@
|
|
|
55
55
|
"build:vendor": "test -d agent/vendor-types/claude && test -d agent/vendor-types/codex || bun run scripts/pull-vendor-types.ts claude codex",
|
|
56
56
|
"prepack": "bun run build",
|
|
57
57
|
"check:package": "bun run scripts/check-package.ts",
|
|
58
|
-
"api:diff": "bun run scripts/api-diff.ts"
|
|
58
|
+
"api:diff": "bun run scripts/api-diff.ts",
|
|
59
|
+
"loc": "bun run scripts/loc.ts",
|
|
60
|
+
"loc:diff": "bun run scripts/loc-diff.ts",
|
|
61
|
+
"lint:modules": "bun run scripts/lint-modules.ts"
|
|
59
62
|
},
|
|
60
63
|
"dependencies": {
|
|
64
|
+
"@anthropic-ai/sdk": "0.133.0",
|
|
61
65
|
"@boatdev/sdk": "1.5.0",
|
|
66
|
+
"eventsource-parser": "4.1.2",
|
|
67
|
+
"jose": "6.2.13",
|
|
68
|
+
"msgpackr": "2.1.2",
|
|
62
69
|
"openapi-fetch": "^0.17.0",
|
|
63
70
|
"ssh2": "^1.17.0"
|
|
64
71
|
},
|
|
@@ -66,6 +73,7 @@
|
|
|
66
73
|
"@types/bun": "latest",
|
|
67
74
|
"@types/ssh2": "^1.15.6",
|
|
68
75
|
"openapi-typescript": "^7.13.0",
|
|
76
|
+
"p-retry": "8.0.1",
|
|
69
77
|
"swagger2openapi": "^7.0.8",
|
|
70
78
|
"typescript": "^5.9.0"
|
|
71
79
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { GatewayService } from "../portal-gateway/gatewayService.ts";
|
|
2
|
-
import type { PortalService } from "../portal-gateway/portalService.ts";
|
|
3
|
-
/** Whether a gateway behind the dimension's portals holds an OAuth sign-in for the upstream. */
|
|
4
|
-
export type GatewaySignIns = (dimensionName: string, upstreamName: string) => Promise<boolean>;
|
|
5
|
-
export declare function createGatewaySignIns(portals: PortalService, gateways: GatewayService): GatewaySignIns;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function createGatewaySignIns(portals, gateways) {
|
|
2
|
-
return async (dimensionName, upstreamName) => {
|
|
3
|
-
const gatewayNames = new Set((await portals.listPortals()).filter((portal) => portal.dimensionName === dimensionName).map((portal) => portal.gatewayName));
|
|
4
|
-
for (const gatewayName of gatewayNames) {
|
|
5
|
-
const credentials = await gateways.listCredentials(gatewayName);
|
|
6
|
-
if (credentials.some((credential) => credential.name === `${upstreamName}.oauth`))
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
return false;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ThreadItem } from "../../vendor-types/codex/app-server/v2/ThreadItem.ts";
|
|
2
|
-
import type { AgentTranscriptMessage as TranscriptMessage } from "../../api.ts";
|
|
3
|
-
import { type AssistantContentBlock } from "../sdkMessages.ts";
|
|
4
|
-
/** The uuid of the result message of tool item `itemId`; the call's is the item id itself. */
|
|
5
|
-
export declare function toolResultId(itemId: string): string;
|
|
6
|
-
export declare function assistantMessage(uuid: string, content: AssistantContentBlock[], threadId: string, model: string): TranscriptMessage;
|
|
7
|
-
export declare function toolResultMessage(itemId: string, content: string, isError: boolean, threadId: string): TranscriptMessage;
|
|
8
|
-
/**
|
|
9
|
-
* The messages a finished item stands for, as the transcript shows them. A user message keeps the
|
|
10
|
-
* id it was sent with (codex records it as the item's clientId).
|
|
11
|
-
*/
|
|
12
|
-
export declare function itemMessages(item: ThreadItem, threadId: string, model: string): TranscriptMessage[];
|
|
13
|
-
/**
|
|
14
|
-
* The messages a rollout item stands for, the same (ids included) as the stream carried live. Items
|
|
15
|
-
* other than messages and commands (file changes, MCP calls, ...) aren't mapped from the rollout yet.
|
|
16
|
-
*/
|
|
17
|
-
export declare function rolloutItemMessages(stored: unknown, threadId: string): TranscriptMessage[];
|
|
18
|
-
/** The claude-style tool call a codex item stands for, if it is one. */
|
|
19
|
-
export declare function toolUseOf(item: ThreadItem): {
|
|
20
|
-
type: "tool_use";
|
|
21
|
-
id: string;
|
|
22
|
-
name: string;
|
|
23
|
-
input: unknown;
|
|
24
|
-
} | null;
|
|
25
|
-
export declare function toolResultOf(item: ThreadItem): {
|
|
26
|
-
type: "tool_result";
|
|
27
|
-
tool_use_id: string;
|
|
28
|
-
content: string;
|
|
29
|
-
is_error: boolean;
|
|
30
|
-
} | null;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { resultUsage } from "../sdkMessages.js";
|
|
2
|
-
// codex's thread items as the stream's SDK messages, the same live (stream.ts) and read back from
|
|
3
|
-
// codex's storage (transcript.ts), ids included: a message's uuid is its item's id, which is what
|
|
4
|
-
// after_id finds again. One tool item is two messages, the call and its result.
|
|
5
|
-
/** An id codex chose, in the SDK's uuid slot. type-bypass: codex's ids ("msg_…") aren't UUID-shaped; the SDK types the slot as one, but only ever compares it. */
|
|
6
|
-
function backendId(id) {
|
|
7
|
-
return id;
|
|
8
|
-
}
|
|
9
|
-
/** The uuid of the result message of tool item `itemId`; the call's is the item id itself. */
|
|
10
|
-
export function toolResultId(itemId) {
|
|
11
|
-
return `${itemId}:result`;
|
|
12
|
-
}
|
|
13
|
-
export function assistantMessage(uuid, content, threadId, model) {
|
|
14
|
-
const usage = { ...resultUsage(), cache_creation: null, server_tool_use: null, service_tier: null };
|
|
15
|
-
return {
|
|
16
|
-
type: "assistant",
|
|
17
|
-
message: {
|
|
18
|
-
id: uuid,
|
|
19
|
-
type: "message",
|
|
20
|
-
role: "assistant",
|
|
21
|
-
model,
|
|
22
|
-
content,
|
|
23
|
-
container: null,
|
|
24
|
-
context_management: null,
|
|
25
|
-
stop_reason: null,
|
|
26
|
-
stop_sequence: null,
|
|
27
|
-
usage,
|
|
28
|
-
},
|
|
29
|
-
parent_tool_use_id: null,
|
|
30
|
-
uuid: backendId(uuid),
|
|
31
|
-
session_id: threadId,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export function toolResultMessage(itemId, content, isError, threadId) {
|
|
35
|
-
return {
|
|
36
|
-
type: "user",
|
|
37
|
-
message: { role: "user", content: [{ type: "tool_result", tool_use_id: itemId, content, is_error: isError }] },
|
|
38
|
-
parent_tool_use_id: null,
|
|
39
|
-
uuid: backendId(toolResultId(itemId)),
|
|
40
|
-
session_id: threadId,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The messages a finished item stands for, as the transcript shows them. A user message keeps the
|
|
45
|
-
* id it was sent with (codex records it as the item's clientId).
|
|
46
|
-
*/
|
|
47
|
-
export function itemMessages(item, threadId, model) {
|
|
48
|
-
if (item.type === "userMessage") {
|
|
49
|
-
const text = item.content.map((input) => (input.type === "text" ? input.text : "")).join("");
|
|
50
|
-
return [{ type: "user", message: { role: "user", content: text }, parent_tool_use_id: null, uuid: backendId(item.clientId ?? item.id), session_id: threadId }];
|
|
51
|
-
}
|
|
52
|
-
if (item.type === "agentMessage")
|
|
53
|
-
return [assistantMessage(item.id, [{ type: "text", text: item.text, citations: null }], threadId, model)];
|
|
54
|
-
const toolUse = toolUseOf(item);
|
|
55
|
-
const toolResult = toolResultOf(item);
|
|
56
|
-
if (!toolUse)
|
|
57
|
-
return [];
|
|
58
|
-
const messages = [assistantMessage(item.id, [toolUse], threadId, model)];
|
|
59
|
-
if (toolResult)
|
|
60
|
-
messages.push(toolResultMessage(item.id, toolResult.content, toolResult.is_error, threadId));
|
|
61
|
-
return messages;
|
|
62
|
-
}
|
|
63
|
-
/** How codex shows a command it ran through a shell: `/bin/bash -lc '<script>'`. */
|
|
64
|
-
function shownCommand(argv) {
|
|
65
|
-
return argv.map((arg) => (/^[\w@%+=:,./-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`)).join(" ");
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* The messages a rollout item stands for, the same (ids included) as the stream carried live. Items
|
|
69
|
-
* other than messages and commands (file changes, MCP calls, ...) aren't mapped from the rollout yet.
|
|
70
|
-
*/
|
|
71
|
-
export function rolloutItemMessages(stored, threadId) {
|
|
72
|
-
const item = stored;
|
|
73
|
-
const text = (content) => (content ?? []).map((part) => part.text ?? "").join("");
|
|
74
|
-
if (item.type === "UserMessage" && "content" in item) {
|
|
75
|
-
const user = item;
|
|
76
|
-
return [{ type: "user", message: { role: "user", content: text(user.content) }, parent_tool_use_id: null, uuid: backendId(user.client_id ?? user.id), session_id: threadId }];
|
|
77
|
-
}
|
|
78
|
-
if (item.type === "AgentMessage" && item.id) {
|
|
79
|
-
const agent = item;
|
|
80
|
-
return [assistantMessage(agent.id, [{ type: "text", text: text(agent.content), citations: null }], threadId, "")];
|
|
81
|
-
}
|
|
82
|
-
if (item.type === "CommandExecution" && item.id) {
|
|
83
|
-
const command = item;
|
|
84
|
-
const input = { command: shownCommand(command.command ?? []), cwd: (command.cwd ?? "").replace(/^file:\/\//, "") };
|
|
85
|
-
return [
|
|
86
|
-
assistantMessage(command.id, [{ type: "tool_use", id: command.id, name: "Bash", input }], threadId, ""),
|
|
87
|
-
toolResultMessage(command.id, command.aggregated_output ?? "", command.status !== "completed" || (command.exit_code ?? 0) !== 0, threadId),
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
return [];
|
|
91
|
-
}
|
|
92
|
-
/** The claude-style tool call a codex item stands for, if it is one. */
|
|
93
|
-
export function toolUseOf(item) {
|
|
94
|
-
switch (item.type) {
|
|
95
|
-
case "commandExecution":
|
|
96
|
-
return { type: "tool_use", id: item.id, name: "Bash", input: { command: item.command, cwd: item.cwd } };
|
|
97
|
-
case "fileChange":
|
|
98
|
-
return { type: "tool_use", id: item.id, name: "ApplyPatch", input: { changes: item.changes } };
|
|
99
|
-
case "mcpToolCall":
|
|
100
|
-
return { type: "tool_use", id: item.id, name: `mcp__${item.server}__${item.tool}`, input: item.arguments };
|
|
101
|
-
case "dynamicToolCall":
|
|
102
|
-
return { type: "tool_use", id: item.id, name: item.tool, input: item.arguments };
|
|
103
|
-
default:
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
export function toolResultOf(item) {
|
|
108
|
-
switch (item.type) {
|
|
109
|
-
case "commandExecution":
|
|
110
|
-
return {
|
|
111
|
-
type: "tool_result",
|
|
112
|
-
tool_use_id: item.id,
|
|
113
|
-
content: item.aggregatedOutput ?? "",
|
|
114
|
-
is_error: item.status !== "completed" || (item.exitCode ?? 0) !== 0,
|
|
115
|
-
};
|
|
116
|
-
case "fileChange":
|
|
117
|
-
return { type: "tool_result", tool_use_id: item.id, content: item.status, is_error: item.status !== "completed" };
|
|
118
|
-
case "mcpToolCall":
|
|
119
|
-
return {
|
|
120
|
-
type: "tool_result",
|
|
121
|
-
tool_use_id: item.id,
|
|
122
|
-
content: JSON.stringify(item.error ?? item.result?.content ?? null),
|
|
123
|
-
is_error: item.status !== "completed",
|
|
124
|
-
};
|
|
125
|
-
case "dynamicToolCall":
|
|
126
|
-
return {
|
|
127
|
-
type: "tool_result",
|
|
128
|
-
tool_use_id: item.id,
|
|
129
|
-
content: JSON.stringify(item.contentItems ?? null),
|
|
130
|
-
is_error: item.success === false,
|
|
131
|
-
};
|
|
132
|
-
default:
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { TranscriptSource } from "../backend.ts";
|
|
2
|
-
import { type FileTranscript, type LineMessages, type TranscriptLayout } from "../fileTranscript.ts";
|
|
3
|
-
/**
|
|
4
|
-
* The conversation from codex's own rollout, <codex home>/sessions/<date>/rollout-<time>-<thread>.jsonl:
|
|
5
|
-
* each finished item is an item_completed event there, as the messages the stream carried for it.
|
|
6
|
-
* Read directly: the app-server's thread/read loads the whole thread, and its paged
|
|
7
|
-
* thread/turns/list isn't implemented in codex 0.157.
|
|
8
|
-
*/
|
|
9
|
-
export declare function codexTranscript({ nativeId, env, files }: TranscriptSource): FileTranscript;
|
|
10
|
-
/** sessions/YYYY/MM/DD/rollout-<time>-<thread>.jsonl in codex's home. */
|
|
11
|
-
export declare const CODEX_TRANSCRIPT_LAYOUT: TranscriptLayout;
|
|
12
|
-
export declare function codexLineMessages(threadId: string): LineMessages;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createFileTranscript, locateTranscript } from "../fileTranscript.js";
|
|
2
|
-
import { rolloutItemMessages } from "./messages.js";
|
|
3
|
-
/**
|
|
4
|
-
* The conversation from codex's own rollout, <codex home>/sessions/<date>/rollout-<time>-<thread>.jsonl:
|
|
5
|
-
* each finished item is an item_completed event there, as the messages the stream carried for it.
|
|
6
|
-
* Read directly: the app-server's thread/read loads the whole thread, and its paged
|
|
7
|
-
* thread/turns/list isn't implemented in codex 0.157.
|
|
8
|
-
*/
|
|
9
|
-
export function codexTranscript({ nativeId, env, files }) {
|
|
10
|
-
const home = env.CODEX_HOME ?? `${env.HOME}/.codex`;
|
|
11
|
-
return createFileTranscript(files, () => locateTranscript(files, home, CODEX_TRANSCRIPT_LAYOUT, nativeId), codexLineMessages(nativeId), CODEX_TRANSCRIPT_LAYOUT);
|
|
12
|
-
}
|
|
13
|
-
/** sessions/YYYY/MM/DD/rollout-<time>-<thread>.jsonl in codex's home. */
|
|
14
|
-
export const CODEX_TRANSCRIPT_LAYOUT = { dir: "sessions", depth: 4, name: "rollout-*-{id}.jsonl", time: "timestamp" };
|
|
15
|
-
export function codexLineMessages(threadId) {
|
|
16
|
-
return (line) => {
|
|
17
|
-
const { type, payload } = line;
|
|
18
|
-
if (type !== "event_msg" || payload?.type !== "item_completed" || !payload.item)
|
|
19
|
-
return [];
|
|
20
|
-
return rolloutItemMessages(payload.item, threadId);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { SDKAssistantMessage, SDKResultMessage } from "../../vendor-types/claude/agent-sdk/sdk.js";
|
|
2
|
-
import type { UserMessage } from "../api.ts";
|
|
3
|
-
/** claude's tool for asking the user; other backends' questions appear in the stream under its name. */
|
|
4
|
-
export declare const ASK_USER_QUESTION = "AskUserQuestion";
|
|
5
|
-
export type AssistantContentBlock = SDKAssistantMessage["message"]["content"][number];
|
|
6
|
-
export type AssistantUsage = SDKAssistantMessage["message"]["usage"];
|
|
7
|
-
/** Token counts in the SDK's shape. */
|
|
8
|
-
export declare function resultUsage({ input, output, cacheRead, cacheWrite }?: {
|
|
9
|
-
input?: number | undefined;
|
|
10
|
-
output?: number | undefined;
|
|
11
|
-
cacheRead?: number | undefined;
|
|
12
|
-
cacheWrite?: number | undefined;
|
|
13
|
-
}): SDKResultMessage["usage"];
|
|
14
|
-
/** The text of a user message, whichever shape its content has. */
|
|
15
|
-
export declare function userMessageText(message: UserMessage): string;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// The stream speaks the Claude Agent SDK's messages (api.ts), so a backend that isn't claude makes
|
|
2
|
-
// them up: these are the pieces it needs.
|
|
3
|
-
/** claude's tool for asking the user; other backends' questions appear in the stream under its name. */
|
|
4
|
-
export const ASK_USER_QUESTION = "AskUserQuestion";
|
|
5
|
-
/** Token counts in the SDK's shape. */
|
|
6
|
-
export function resultUsage({ input = 0, output = 0, cacheRead = 0, cacheWrite = 0 } = {}) {
|
|
7
|
-
return {
|
|
8
|
-
input_tokens: input,
|
|
9
|
-
output_tokens: output,
|
|
10
|
-
cache_read_input_tokens: cacheRead,
|
|
11
|
-
cache_creation_input_tokens: cacheWrite,
|
|
12
|
-
cache_creation: { ephemeral_1h_input_tokens: 0, ephemeral_5m_input_tokens: 0 },
|
|
13
|
-
server_tool_use: { web_fetch_requests: 0, web_search_requests: 0 },
|
|
14
|
-
service_tier: "standard",
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
/** The text of a user message, whichever shape its content has. */
|
|
18
|
-
export function userMessageText(message) {
|
|
19
|
-
const content = message.message.content;
|
|
20
|
-
if (typeof content === "string")
|
|
21
|
-
return content;
|
|
22
|
-
if (!Array.isArray(content))
|
|
23
|
-
return "";
|
|
24
|
-
return content
|
|
25
|
-
.map((block) => (block.type === "text" && typeof block.text === "string" ? block.text : ""))
|
|
26
|
-
.filter(Boolean)
|
|
27
|
-
.join("\n");
|
|
28
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
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. Runs in a browser as well as on a
|
|
9
|
-
* server. Aborting `signal` closes every connection it opened (a stream waiting for the next message
|
|
10
|
-
* included).
|
|
11
|
-
*
|
|
12
|
-
* Given a function (one that calls exposeAgent, through the page's server), it asks it once and
|
|
13
|
-
* keeps the endpoint; when a connection fails to open it asks again, which starts a proxy that
|
|
14
|
-
* stopped (an archived and resumed Boat sandbox, a reboot) at the same URL, and retries once. If that
|
|
15
|
-
* fails too it throws EndpointUnreachableError (or EndpointLoginRequiredError, for an exe.dev
|
|
16
|
-
* endpoint). Given an endpoint, it uses it as it is: one that stopped being served just fails.
|
|
17
|
-
*/
|
|
18
|
-
export declare function workerSseConnector(endpoint: WorkerEndpoint | (() => Promise<WorkerEndpoint>), { signal }?: {
|
|
19
|
-
signal?: AbortSignal;
|
|
20
|
-
}): ConnectWorker;
|
|
21
|
-
/**
|
|
22
|
-
* The worker's endpoint didn't answer, even once exposed again. A browser reports that as a CORS
|
|
23
|
-
* error whatever the cause: the page's origin isn't among the endpoint's allowedOrigins (give it to
|
|
24
|
-
* exposeAgent), or nothing answers at the endpoint's URL (the machine is unreachable, or the
|
|
25
|
-
* endpoint was closed).
|
|
26
|
-
*/
|
|
27
|
-
export declare class EndpointUnreachableError extends Error {
|
|
28
|
-
readonly url: string;
|
|
29
|
-
name: string;
|
|
30
|
-
constructor(url: string, cause?: unknown);
|
|
31
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { EndpointLoginRequiredError, 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. Runs in a browser as well as on a
|
|
7
|
-
* server. Aborting `signal` closes every connection it opened (a stream waiting for the next message
|
|
8
|
-
* included).
|
|
9
|
-
*
|
|
10
|
-
* Given a function (one that calls exposeAgent, through the page's server), it asks it once and
|
|
11
|
-
* keeps the endpoint; when a connection fails to open it asks again, which starts a proxy that
|
|
12
|
-
* stopped (an archived and resumed Boat sandbox, a reboot) at the same URL, and retries once. If that
|
|
13
|
-
* fails too it throws EndpointUnreachableError (or EndpointLoginRequiredError, for an exe.dev
|
|
14
|
-
* endpoint). Given an endpoint, it uses it as it is: one that stopped being served just fails.
|
|
15
|
-
*/
|
|
16
|
-
export function workerSseConnector(endpoint, { signal } = {}) {
|
|
17
|
-
let kept = null;
|
|
18
|
-
const current = (fresh) => {
|
|
19
|
-
if (typeof endpoint !== "function")
|
|
20
|
-
return Promise.resolve(endpoint);
|
|
21
|
-
if (fresh || !kept) {
|
|
22
|
-
const asked = endpoint();
|
|
23
|
-
kept = asked;
|
|
24
|
-
asked.catch(() => kept === asked && (kept = null));
|
|
25
|
-
}
|
|
26
|
-
return kept;
|
|
27
|
-
};
|
|
28
|
-
async function open() {
|
|
29
|
-
const first = await current(false);
|
|
30
|
-
try {
|
|
31
|
-
return [first, await openSseConnection(first, { signal })];
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
if (typeof endpoint !== "function" || signal?.aborted)
|
|
35
|
-
throw error;
|
|
36
|
-
}
|
|
37
|
-
// Asked again unless another connection already did since.
|
|
38
|
-
const access = kept && (await kept) !== first ? await kept : await current(true);
|
|
39
|
-
try {
|
|
40
|
-
return [access, await openSseConnection(access, { signal })];
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
if (signal?.aborted || error instanceof EndpointLoginRequiredError)
|
|
44
|
-
throw error;
|
|
45
|
-
throw new EndpointUnreachableError(access.url, error);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return async (onNotification) => {
|
|
49
|
-
signal?.throwIfAborted();
|
|
50
|
-
const [access, connection] = await open();
|
|
51
|
-
const decoder = new TextDecoder();
|
|
52
|
-
const encoder = new TextEncoder();
|
|
53
|
-
const transport = {
|
|
54
|
-
write: (text) => connection.write(encoder.encode(text)),
|
|
55
|
-
onText: (listener) => connection.onData((data) => listener(decoder.decode(data, { stream: true }))),
|
|
56
|
-
closed: connection.closed,
|
|
57
|
-
close: () => connection.close(),
|
|
58
|
-
};
|
|
59
|
-
return workerConnectionOver(transport, access.url.replace(/\/+$/, ""), onNotification);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The worker's endpoint didn't answer, even once exposed again. A browser reports that as a CORS
|
|
64
|
-
* error whatever the cause: the page's origin isn't among the endpoint's allowedOrigins (give it to
|
|
65
|
-
* exposeAgent), or nothing answers at the endpoint's URL (the machine is unreachable, or the
|
|
66
|
-
* endpoint was closed).
|
|
67
|
-
*/
|
|
68
|
-
export class EndpointUnreachableError extends Error {
|
|
69
|
-
url;
|
|
70
|
-
name = "EndpointUnreachableError";
|
|
71
|
-
constructor(url, cause) {
|
|
72
|
-
super(`the agent's endpoint ${url} didn't answer, even once exposed again (a browser reports this as a CORS error): ` +
|
|
73
|
-
"is the page's origin among its allowedOrigins, and is the machine reachable?", { cause });
|
|
74
|
-
this.url = url;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A path that is guaranteed to be absolute and normalized (though it is not
|
|
3
|
-
* guaranteed to be canonicalized or exist on the filesystem).
|
|
4
|
-
*
|
|
5
|
-
* IMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set
|
|
6
|
-
* using [AbsolutePathBufGuard::new]. If no base path is set, the
|
|
7
|
-
* deserialization will fail unless the path being deserialized is already
|
|
8
|
-
* absolute.
|
|
9
|
-
*/
|
|
10
|
-
export type AbsolutePathBuf = string;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ImageDetail } from "./ImageDetail";
|
|
2
|
-
/**
|
|
3
|
-
* Responses API compatible content items that can be returned by a tool call.
|
|
4
|
-
* This is a subset of ContentItem with the types we support as function call outputs.
|
|
5
|
-
*/
|
|
6
|
-
export type FunctionCallOutputContentItem = {
|
|
7
|
-
"type": "input_text";
|
|
8
|
-
text: string;
|
|
9
|
-
} | {
|
|
10
|
-
"type": "input_image";
|
|
11
|
-
detail?: ImageDetail;
|
|
12
|
-
} & ({
|
|
13
|
-
image_url: string;
|
|
14
|
-
} | {
|
|
15
|
-
file_id: string;
|
|
16
|
-
}) | {
|
|
17
|
-
"type": "input_audio";
|
|
18
|
-
audio_url: string;
|
|
19
|
-
} | {
|
|
20
|
-
"type": "encrypted_content";
|
|
21
|
-
encrypted_content: string;
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type ImageDetail = "auto" | "low" | "high" | "original";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AbsolutePathBuf } from "./AbsolutePathBuf";
|
|
2
|
-
import type { ImageGenerationFailure } from "./ImageGenerationFailure";
|
|
3
|
-
export type ImageGenerationItem = {
|
|
4
|
-
id: string;
|
|
5
|
-
status: string;
|
|
6
|
-
revisedPrompt: string | null;
|
|
7
|
-
result: string;
|
|
8
|
-
transparentBackground?: boolean;
|
|
9
|
-
failure: ImageGenerationFailure | null;
|
|
10
|
-
savedPath?: AbsolutePathBuf;
|
|
11
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A UTF-8 path for preserving raw path compatibility at the app-server API
|
|
3
|
-
* boundary while Codex migrates to [`PathUri`].
|
|
4
|
-
*
|
|
5
|
-
* Supports storing arbitrary strings read from the API and converting to and
|
|
6
|
-
* from [`PathUri`] using an explicitly selected native path convention.
|
|
7
|
-
*
|
|
8
|
-
* When converting from [`PathUri`], "native" refers to the supplied
|
|
9
|
-
* [`PathConvention`], which may be foreign to the operating system running
|
|
10
|
-
* this process. The inner string is private so path-producing code must use a
|
|
11
|
-
* path conversion method instead of bypassing the intended conversion
|
|
12
|
-
* boundary. Non-UTF-8 paths are converted to UTF-8 lossily because this API
|
|
13
|
-
* value is serialized as a JSON string.
|
|
14
|
-
*
|
|
15
|
-
* Deserialization and [`Self::from_string`] accept any UTF-8 string without
|
|
16
|
-
* interpreting or validating it. Use [`Self::from_string`] when a caller
|
|
17
|
-
* already owns legacy app-server path text and needs to preserve its wire
|
|
18
|
-
* spelling; use [`Self::from_path`], [`Self::from_abs_path`], or
|
|
19
|
-
* [`Self::from_path_uri`] when converting an actual path value. Relative
|
|
20
|
-
* path text remains valid until an operation such as [`Self::to_path_uri`]
|
|
21
|
-
* requires an absolute path.
|
|
22
|
-
*/
|
|
23
|
-
export type LegacyAppPathString = string;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Classifies an assistant message as interim commentary or final answer text.
|
|
3
|
-
*
|
|
4
|
-
* Providers do not emit this consistently, so callers must treat `None` as
|
|
5
|
-
* "phase unknown" and keep compatibility behavior for legacy models.
|
|
6
|
-
*/
|
|
7
|
-
export type MessagePhase = "commentary" | "final_answer";
|