hyperbrane 0.1.0 → 0.1.2
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 +41 -3
- package/dist/agent/agentService.d.ts +11 -3
- package/dist/agent/agentService.js +63 -19
- package/dist/agent/agentStorage.d.ts +2 -0
- package/dist/agent/agentStorage.js +4 -2
- package/dist/agent/api.d.ts +83 -32
- package/dist/agent/api.js +7 -0
- package/dist/agent/client.d.ts +3 -0
- package/dist/agent/client.js +5 -0
- package/dist/agent/hostTranscript.d.ts +13 -0
- package/dist/agent/hostTranscript.js +190 -0
- package/dist/agent/session/backend.d.ts +82 -0
- package/dist/agent/session/backend.js +1 -0
- package/dist/agent/session/claude/home.d.ts +2 -0
- package/dist/agent/session/claude/home.js +4 -0
- package/dist/agent/session/claude/transcript.d.ts +13 -0
- package/dist/agent/session/claude/transcript.js +29 -0
- package/dist/agent/session/client.d.ts +5 -1
- package/dist/agent/session/codex/home.d.ts +2 -0
- package/dist/agent/session/codex/home.js +4 -0
- package/dist/agent/session/codex/messages.d.ts +30 -0
- package/dist/agent/session/codex/messages.js +135 -0
- package/dist/agent/session/codex/transcript.d.ts +12 -0
- package/dist/agent/session/codex/transcript.js +22 -0
- package/dist/agent/session/fileTranscript.d.ts +92 -0
- package/dist/agent/session/fileTranscript.js +454 -0
- package/dist/agent/session/sdkMessages.d.ts +15 -0
- package/dist/agent/session/sdkMessages.js +28 -0
- package/dist/agent/session/sessionStorage.d.ts +4 -0
- package/dist/agent/session/sessionStorage.js +13 -2
- package/dist/agent/session/sharedConnection.d.ts +1 -0
- package/dist/agent/session/storedTranscripts.d.ts +13 -0
- package/dist/agent/session/storedTranscripts.js +8 -0
- package/dist/agent/session/worker/protocol.d.ts +5 -1
- package/dist/agent/session/worker/protocol.js +6 -1
- package/dist/agent/session/worker/workerParams.d.ts +11 -0
- package/dist/agent/session/worker/workerParams.js +163 -0
- package/dist/agent/session/workerSseConnection.d.ts +20 -4
- package/dist/agent/session/workerSseConnection.js +57 -7
- package/dist/agent/vendor-types/codex/app-server/AbsolutePathBuf.d.ts +10 -0
- package/dist/agent/vendor-types/codex/app-server/AbsolutePathBuf.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/FunctionCallOutputBody.d.ts +2 -0
- package/dist/agent/vendor-types/codex/app-server/FunctionCallOutputBody.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/FunctionCallOutputContentItem.d.ts +22 -0
- package/dist/agent/vendor-types/codex/app-server/FunctionCallOutputContentItem.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/ImageDetail.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/ImageDetail.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/ImageGenerationFailure.d.ts +5 -0
- package/dist/agent/vendor-types/codex/app-server/ImageGenerationFailure.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/ImageGenerationItem.d.ts +11 -0
- package/dist/agent/vendor-types/codex/app-server/ImageGenerationItem.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/LegacyAppPathString.d.ts +23 -0
- package/dist/agent/vendor-types/codex/app-server/LegacyAppPathString.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/MessagePhase.d.ts +7 -0
- package/dist/agent/vendor-types/codex/app-server/MessagePhase.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/ReasoningEffort.d.ts +4 -0
- package/dist/agent/vendor-types/codex/app-server/ReasoningEffort.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/SleepItem.d.ts +7 -0
- package/dist/agent/vendor-types/codex/app-server/SleepItem.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/WebSearchItem.d.ts +14 -0
- package/dist/agent/vendor-types/codex/app-server/WebSearchItem.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/serde_json/JsonValue.d.ts +3 -0
- package/dist/agent/vendor-types/codex/app-server/serde_json/JsonValue.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/AgentMessageDelivery.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/AgentMessageDelivery.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/AsyncUserInputQuestion.d.ts +4 -0
- package/dist/agent/vendor-types/codex/app-server/v2/AsyncUserInputQuestion.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/ByteRange.d.ts +4 -0
- package/dist/agent/vendor-types/codex/app-server/v2/ByteRange.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentState.d.ts +5 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentState.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentStatus.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentStatus.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentTool.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentTool.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentToolCallStatus.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CollabAgentToolCallStatus.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CommandAction.d.ts +19 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CommandAction.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CommandExecutionSource.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CommandExecutionSource.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CommandExecutionStatus.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/CommandExecutionStatus.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/DynamicToolCallOutputContentItem.d.ts +10 -0
- package/dist/agent/vendor-types/codex/app-server/v2/DynamicToolCallOutputContentItem.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/DynamicToolCallStatus.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/DynamicToolCallStatus.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/FileUpdateChange.d.ts +6 -0
- package/dist/agent/vendor-types/codex/app-server/v2/FileUpdateChange.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/HookPromptFragment.d.ts +4 -0
- package/dist/agent/vendor-types/codex/app-server/v2/HookPromptFragment.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpAppDisplayMode.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpAppDisplayMode.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpAppUi.d.ts +8 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpAppUi.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallAppContext.d.ts +7 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallAppContext.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallError.d.ts +3 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallError.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallResult.d.ts +6 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallResult.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallStatus.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/McpToolCallStatus.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/MemoryCitation.d.ts +5 -0
- package/dist/agent/vendor-types/codex/app-server/v2/MemoryCitation.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/MemoryCitationEntry.d.ts +6 -0
- package/dist/agent/vendor-types/codex/app-server/v2/MemoryCitationEntry.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/PatchApplyStatus.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/PatchApplyStatus.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/PatchChangeKind.d.ts +8 -0
- package/dist/agent/vendor-types/codex/app-server/v2/PatchChangeKind.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/SubAgentActivityKind.d.ts +1 -0
- package/dist/agent/vendor-types/codex/app-server/v2/SubAgentActivityKind.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/TextElement.d.ts +11 -0
- package/dist/agent/vendor-types/codex/app-server/v2/TextElement.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/ThreadItem.d.ts +215 -0
- package/dist/agent/vendor-types/codex/app-server/v2/ThreadItem.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/UserInput.d.ts +35 -0
- package/dist/agent/vendor-types/codex/app-server/v2/UserInput.js +2 -0
- package/dist/agent/vendor-types/codex/app-server/v2/WebSearchAction.d.ts +14 -0
- package/dist/agent/vendor-types/codex/app-server/v2/WebSearchAction.js +2 -0
- package/dist/agent/workerBundle.generated.js +1 -1
- package/dist/cli/agent.js +30 -4
- package/dist/cli/services.d.ts +6 -5
- package/dist/cli/services.js +4 -3
- package/dist/dimension/api.d.ts +5 -4
- package/dist/dimension/paths.d.ts +4 -0
- package/dist/dimension/paths.js +10 -2
- package/dist/dimension/service.d.ts +5 -1
- package/dist/dimension/service.js +5 -1
- package/dist/dimension/storage.js +3 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.js +7 -5
- package/dist/lib/docker.d.ts +1 -0
- package/dist/portal-gateway/api.d.ts +6 -5
- package/dist/portal-gateway/gatewayService.d.ts +5 -1
- package/dist/portal-gateway/gatewayService.js +25 -13
- package/dist/portal-gateway/image.d.ts +1 -1
- package/dist/portal-gateway/image.js +1 -1
- package/dist/portal-gateway/imageFiles.generated.js +1 -1
- package/dist/portal-gateway/portalService.d.ts +2 -0
- package/dist/portal-gateway/portalService.js +61 -29
- package/dist/portal-gateway/upstream.d.ts +22 -11
- package/dist/sandbox/api.d.ts +60 -23
- package/dist/sandbox/boatService.js +11 -3
- package/dist/sandbox/containerService.js +10 -3
- package/dist/sandbox/endpointProxy.js +16 -1
- package/dist/sandbox/localService.js +20 -2
- package/dist/sandbox/sshService.js +37 -4
- package/package.json +25 -8
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { AGENT_BACKENDS, AgentInvalidError, } from "../../api.js";
|
|
2
|
+
/**
|
|
3
|
+
* Turns each method's params, as they arrived (JSON), into the protocol's types, or throws an
|
|
4
|
+
* AgentInvalidError saying what's wrong. Keeps only the fields the types have, so nothing unknown
|
|
5
|
+
* reaches the service (or its storage).
|
|
6
|
+
*/
|
|
7
|
+
export const WORKER_PARAMS = {
|
|
8
|
+
"worker/health": () => ({}),
|
|
9
|
+
"worker/shutdown": () => ({}),
|
|
10
|
+
"backend/install": (params) => ({ backend: backend(params.backend) }),
|
|
11
|
+
"backend/list": () => ({}),
|
|
12
|
+
"session/create": (params) => ({ session: session(object(params.session, "session")) }),
|
|
13
|
+
"session/list": () => ({}),
|
|
14
|
+
"session/update": (params) => ({ session: name(params), limits: limits(object(params.limits, "limits")) }),
|
|
15
|
+
"session/stop": (params) => ({ session: name(params) }),
|
|
16
|
+
"session/send": (params) => ({ session: name(params), message: userMessage(params.message) }),
|
|
17
|
+
"session/interrupt": (params) => ({ session: name(params) }),
|
|
18
|
+
"session/status": (params) => ({ session: name(params) }),
|
|
19
|
+
"session/lastUserMessages": (params) => ({ session: name(params) }),
|
|
20
|
+
"session/subscribe": (params) => ({
|
|
21
|
+
session: name(params),
|
|
22
|
+
subscription: text(params.subscription, "subscription"),
|
|
23
|
+
after_id: optional(params.after_id, (value) => text(value, "after_id")),
|
|
24
|
+
}),
|
|
25
|
+
"session/unsubscribe": (params) => ({ subscription: text(params.subscription, "subscription") }),
|
|
26
|
+
"session/transcript": (params) => ({
|
|
27
|
+
session: name(params),
|
|
28
|
+
limit: optional(params.limit, (value) => number(value, "limit")),
|
|
29
|
+
// `cursor`: `before`'s old name.
|
|
30
|
+
before: params.before === undefined ? optional(params.cursor, (value) => text(value, "cursor")) : text(params.before, "before"),
|
|
31
|
+
}),
|
|
32
|
+
"permission/list": (params) => ({ session: name(params) }),
|
|
33
|
+
"permission/respond": (params) => ({
|
|
34
|
+
session: name(params),
|
|
35
|
+
request: text(params.request, "request"),
|
|
36
|
+
result: permissionResult(params.result),
|
|
37
|
+
}),
|
|
38
|
+
"question/list": (params) => ({ session: name(params) }),
|
|
39
|
+
"question/respond": (params) => ({
|
|
40
|
+
session: name(params),
|
|
41
|
+
request: text(params.request, "request"),
|
|
42
|
+
response: questionResponse(params.response),
|
|
43
|
+
}),
|
|
44
|
+
"model/list": (params) => ({ session: name(params) }),
|
|
45
|
+
"model/set": (params) => ({
|
|
46
|
+
session: name(params),
|
|
47
|
+
model: params.model === null ? null : text(params.model, "the model (a model name, or null for the backend's default)"),
|
|
48
|
+
}),
|
|
49
|
+
"task/list": (params) => ({ session: name(params) }),
|
|
50
|
+
"task/stop": (params) => ({ session: name(params), task: text(params.task, "task") }),
|
|
51
|
+
"auth/status": (params) => ({ session: name(params) }),
|
|
52
|
+
"auth/login": (params) => ({
|
|
53
|
+
session: name(params),
|
|
54
|
+
gatewaySignedIn: optional(params.gatewaySignedIn, (value) => boolean(value, "gatewaySignedIn")) ?? false,
|
|
55
|
+
}),
|
|
56
|
+
"auth/code": (params) => ({ session: name(params), code: text(params.code, "the code (the one the sign-in page showed)").trim() }),
|
|
57
|
+
};
|
|
58
|
+
function invalid(message) {
|
|
59
|
+
throw new AgentInvalidError(message);
|
|
60
|
+
}
|
|
61
|
+
function name(params) {
|
|
62
|
+
return text(params.session, "session");
|
|
63
|
+
}
|
|
64
|
+
function object(value, what) {
|
|
65
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
66
|
+
invalid(`${what} must be an object`);
|
|
67
|
+
// type-bypass: a non-null, non-array object is a record of its fields.
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
/** A non-empty string. */
|
|
71
|
+
function text(value, what) {
|
|
72
|
+
if (typeof value !== "string" || value.trim() === "")
|
|
73
|
+
invalid(`${what} must be a non-empty string`);
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
function number(value, what) {
|
|
77
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
78
|
+
invalid(`${what} must be a number`);
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
function boolean(value, what) {
|
|
82
|
+
if (typeof value !== "boolean")
|
|
83
|
+
invalid(`${what} must be true or false`);
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
function optional(value, parse) {
|
|
87
|
+
return value === undefined ? undefined : parse(value);
|
|
88
|
+
}
|
|
89
|
+
function backend(value) {
|
|
90
|
+
const known = AGENT_BACKENDS.find((name) => name === value);
|
|
91
|
+
if (!known)
|
|
92
|
+
invalid(`unknown backend "${String(value)}"; known: ${AGENT_BACKENDS.join(", ")}`);
|
|
93
|
+
return known;
|
|
94
|
+
}
|
|
95
|
+
function memoryLimit(value) {
|
|
96
|
+
const bytes = number(value, "memoryLimit");
|
|
97
|
+
if (!(bytes > 0))
|
|
98
|
+
invalid("memoryLimit must be positive");
|
|
99
|
+
// type-bypass: a positive byte count is what a MemoryLimit is (MemoryLimit() parses the CLI's strings).
|
|
100
|
+
return bytes;
|
|
101
|
+
}
|
|
102
|
+
function cpuLimit(value) {
|
|
103
|
+
const cores = number(value, "cpuLimit");
|
|
104
|
+
if (!(cores > 0))
|
|
105
|
+
invalid("cpuLimit must be positive");
|
|
106
|
+
// type-bypass: a positive core count is what a CPULimit is (CPULimit() parses the CLI's strings).
|
|
107
|
+
return cores;
|
|
108
|
+
}
|
|
109
|
+
function environment(value) {
|
|
110
|
+
const fields = object(value, "env");
|
|
111
|
+
for (const [key, entry] of Object.entries(fields))
|
|
112
|
+
if (typeof entry !== "string")
|
|
113
|
+
invalid(`env.${key} must be a string`);
|
|
114
|
+
// type-bypass: every value was just checked to be a string.
|
|
115
|
+
return fields;
|
|
116
|
+
}
|
|
117
|
+
function session(fields) {
|
|
118
|
+
return {
|
|
119
|
+
name: text(fields.name, "the session's name"),
|
|
120
|
+
backend: backend(fields.backend),
|
|
121
|
+
memoryLimit: memoryLimit(fields.memoryLimit),
|
|
122
|
+
cpuLimit: cpuLimit(fields.cpuLimit),
|
|
123
|
+
cwd: optional(fields.cwd, (value) => text(value, "cwd")),
|
|
124
|
+
env: optional(fields.env, environment),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function limits(fields) {
|
|
128
|
+
return { memoryLimit: optional(fields.memoryLimit, memoryLimit), cpuLimit: optional(fields.cpuLimit, cpuLimit) };
|
|
129
|
+
}
|
|
130
|
+
function userMessage(value) {
|
|
131
|
+
const fields = object(value, "a message (an SDK user message: {type: \"user\", message})");
|
|
132
|
+
if (fields.type !== "user")
|
|
133
|
+
invalid('a message is an SDK user message: {type: "user", message}');
|
|
134
|
+
const message = object(fields.message, "message.message");
|
|
135
|
+
if (message.role !== "user")
|
|
136
|
+
invalid('message.message.role must be "user"');
|
|
137
|
+
if (typeof message.content !== "string" && !Array.isArray(message.content))
|
|
138
|
+
invalid("message.message.content must be a string or an array of content blocks");
|
|
139
|
+
// type-bypass: the envelope is checked; the content blocks are the CLI's to judge.
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
function permissionResult(value) {
|
|
143
|
+
const fields = object(value, "result");
|
|
144
|
+
if (fields.behavior === "allow") {
|
|
145
|
+
return { behavior: "allow", updatedInput: optional(fields.updatedInput, (input) => object(input, "updatedInput")) };
|
|
146
|
+
}
|
|
147
|
+
if (fields.behavior === "deny") {
|
|
148
|
+
return {
|
|
149
|
+
behavior: "deny",
|
|
150
|
+
message: typeof fields.message === "string" ? fields.message : invalid("a denial needs a message"),
|
|
151
|
+
interrupt: optional(fields.interrupt, (interrupt) => boolean(interrupt, "interrupt")),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return invalid('a permission result is {behavior: "allow"} or {behavior: "deny", message}');
|
|
155
|
+
}
|
|
156
|
+
function questionResponse(value) {
|
|
157
|
+
const answers = object(object(value, "response").answers, "a question response's answers ({<question>: <answer>})");
|
|
158
|
+
for (const [question, answer] of Object.entries(answers))
|
|
159
|
+
if (typeof answer !== "string")
|
|
160
|
+
invalid(`the answer to "${question}" must be a string`);
|
|
161
|
+
// type-bypass: every answer was just checked to be a string.
|
|
162
|
+
return { answers: answers };
|
|
163
|
+
}
|
|
@@ -5,11 +5,27 @@ export { EndpointLoginRequiredError, exeDevLoginUrl, sseEvents } from "../../san
|
|
|
5
5
|
export type WorkerEndpoint = Pick<SandboxEndpoint, "url" | "credentials">;
|
|
6
6
|
/**
|
|
7
7
|
* Connects to a worker through its accessible endpoint (AgentService.exposeAgent: the endpoint
|
|
8
|
-
* proxy's "sse" transport), each connection an openSseConnection.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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.
|
|
12
17
|
*/
|
|
13
18
|
export declare function workerSseConnector(endpoint: WorkerEndpoint | (() => Promise<WorkerEndpoint>), { signal }?: {
|
|
14
19
|
signal?: AbortSignal;
|
|
15
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,18 +1,53 @@
|
|
|
1
|
-
import { openSseConnection } from "../../sandbox/sseConnection.js";
|
|
1
|
+
import { EndpointLoginRequiredError, openSseConnection } from "../../sandbox/sseConnection.js";
|
|
2
2
|
import { workerConnectionOver } from "./workerConnection.js";
|
|
3
3
|
export { EndpointLoginRequiredError, exeDevLoginUrl, sseEvents } from "../../sandbox/sseConnection.js";
|
|
4
4
|
/**
|
|
5
5
|
* Connects to a worker through its accessible endpoint (AgentService.exposeAgent: the endpoint
|
|
6
|
-
* proxy's "sse" transport), each connection an openSseConnection.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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.
|
|
10
15
|
*/
|
|
11
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
|
+
}
|
|
12
48
|
return async (onNotification) => {
|
|
13
49
|
signal?.throwIfAborted();
|
|
14
|
-
const access =
|
|
15
|
-
const connection = await openSseConnection(access, { signal });
|
|
50
|
+
const [access, connection] = await open();
|
|
16
51
|
const decoder = new TextDecoder();
|
|
17
52
|
const encoder = new TextEncoder();
|
|
18
53
|
const transport = {
|
|
@@ -24,3 +59,18 @@ export function workerSseConnector(endpoint, { signal } = {}) {
|
|
|
24
59
|
return workerConnectionOver(transport, access.url.replace(/\/+$/, ""), onNotification);
|
|
25
60
|
};
|
|
26
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ImageDetail = "auto" | "low" | "high" | "original";
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
import type { WebSearchAction } from "./v2/WebSearchAction";
|
|
3
|
+
export type WebSearchItem = {
|
|
4
|
+
id: string;
|
|
5
|
+
query: string;
|
|
6
|
+
action: WebSearchAction | null;
|
|
7
|
+
/**
|
|
8
|
+
* Structured search results returned out-of-band by standalone web search.
|
|
9
|
+
*
|
|
10
|
+
* These stay as opaque JSON at the extension/app-server boundary so new
|
|
11
|
+
* result fields and result types can pass through without a Codex release.
|
|
12
|
+
*/
|
|
13
|
+
results: Array<JsonValue> | null;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type AgentMessageDelivery = "async";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CollabAgentStatus = "pendingInit" | "running" | "interrupted" | "completed" | "errored" | "shutdown" | "notFound";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CollabAgentTool = "spawnAgent" | "sendInput" | "resumeAgent" | "wait" | "closeAgent" | "sendMessage" | "followupTask" | "interruptAgent" | "listAgents";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CollabAgentToolCallStatus = "inProgress" | "completed" | "failed" | "interrupted";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LegacyAppPathString } from "../LegacyAppPathString";
|
|
2
|
+
export type CommandAction = {
|
|
3
|
+
"type": "read";
|
|
4
|
+
command: string;
|
|
5
|
+
name: string;
|
|
6
|
+
path: LegacyAppPathString;
|
|
7
|
+
} | {
|
|
8
|
+
"type": "listFiles";
|
|
9
|
+
command: string;
|
|
10
|
+
path: string | null;
|
|
11
|
+
} | {
|
|
12
|
+
"type": "search";
|
|
13
|
+
command: string;
|
|
14
|
+
query: string | null;
|
|
15
|
+
path: string | null;
|
|
16
|
+
} | {
|
|
17
|
+
"type": "unknown";
|
|
18
|
+
command: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CommandExecutionSource = "agent" | "userShell" | "unifiedExecStartup" | "unifiedExecInteraction";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CommandExecutionStatus = "inProgress" | "completed" | "failed" | "declined";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DynamicToolCallStatus = "inProgress" | "completed" | "failed";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type McpAppDisplayMode = "inline" | "fullscreen";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { McpAppDisplayMode } from "./McpAppDisplayMode";
|
|
2
|
+
/**
|
|
3
|
+
* UI resource and display preference for model invocations, captured from the tool descriptor.
|
|
4
|
+
*/
|
|
5
|
+
export type McpAppUi = {
|
|
6
|
+
resourceUri: string;
|
|
7
|
+
preferredModelDisplayMode: McpAppDisplayMode;
|
|
8
|
+
};
|