@opencode/protocol 0.0.0-dev-1325 → 0.0.0-dev-1326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js
CHANGED
|
@@ -84,6 +84,7 @@ export const promiseOmitEndpoints = new Set([
|
|
|
84
84
|
"pty.connect",
|
|
85
85
|
"persistentPty.connect",
|
|
86
86
|
"mcp.client",
|
|
87
|
+
"machine.link",
|
|
87
88
|
"generate.textLegacy",
|
|
88
89
|
]);
|
|
89
90
|
export const effectOmitEndpoints = new Set([
|
|
@@ -95,5 +96,6 @@ export const effectOmitEndpoints = new Set([
|
|
|
95
96
|
"pty.connect",
|
|
96
97
|
"persistentPty.connect",
|
|
97
98
|
"mcp.client",
|
|
99
|
+
"machine.link",
|
|
98
100
|
"generate.textLegacy",
|
|
99
101
|
]);
|
|
@@ -663,7 +663,7 @@ export declare const ExperimentalGroup: import("effect/http-api/HttpApiGroup").H
|
|
|
663
663
|
}>;
|
|
664
664
|
readonly kind: import("effect/Schema").tag<"codemode">;
|
|
665
665
|
}>]>>;
|
|
666
|
-
}>>, import("effect/Schema").toCodecJson<typeof import("../errors.js").InvalidRequestError | typeof import("../errors.js").SessionNotFoundError>, never, never> | import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"media.get", "GET", "/api/experimental/media/:hash", import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
666
|
+
}>>, import("effect/Schema").toCodecJson<typeof import("../errors.js").InvalidRequestError | typeof import("../errors.js").SessionNotFoundError>, never, never> | import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"machine.link", "GET", "/api/experimental/machine/link", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Boolean>, never, never, never> | import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"media.get", "GET", "/api/experimental/media/:hash", import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
667
667
|
hash: import("effect/Schema").String;
|
|
668
668
|
}>>, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Uint8Array>, import("effect/Schema").toCodecJson<typeof import("../errors.js").InvalidRequestError | typeof import("../errors.js").FileNotFoundError>, never, never> | import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"persistentPty.connect", "GET", "/api/experimental/persistent-pty/:ptyID/connect", import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
669
669
|
ptyID: import("effect/Schema").brand<import("effect/Schema").String, "PtyID"> & {
|
|
@@ -2,7 +2,8 @@ import { ArtifactEndpoints } from "./artifact.js";
|
|
|
2
2
|
import { BlobGetEndpoint } from "./blob.js";
|
|
3
3
|
import { AutomationEndpoints } from "./automation.js";
|
|
4
4
|
import { JobEndpoints } from "./job.js";
|
|
5
|
+
import { MachineLinkEndpoint } from "./machine.js";
|
|
5
6
|
import { MediaGetEndpoint } from "./media.js";
|
|
6
7
|
import { PersistentPtyGroup } from "./persistent-pty.js";
|
|
7
8
|
/** `server.experimental`: routes under /api/experimental, without compatibility guarantees. */
|
|
8
|
-
export const ExperimentalGroup = PersistentPtyGroup.add(MediaGetEndpoint, BlobGetEndpoint, ...AutomationEndpoints, ...ArtifactEndpoints, ...JobEndpoints);
|
|
9
|
+
export const ExperimentalGroup = PersistentPtyGroup.add(MediaGetEndpoint, BlobGetEndpoint, ...AutomationEndpoints, ...ArtifactEndpoints, ...JobEndpoints, MachineLinkEndpoint);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint } from "effect/http-api";
|
|
3
|
+
export declare const MACHINE_LINK_PATH = "/api/experimental/machine/link";
|
|
4
|
+
/**
|
|
5
|
+
* Whether a request asks to become a WebSocket, the one request the machine link serves and the one the server lets in
|
|
6
|
+
* without its password: a GET with `Upgrade: websocket` and `upgrade` among its `Connection` tokens.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isWebSocketUpgrade(request: {
|
|
9
|
+
readonly method: string;
|
|
10
|
+
readonly headers: Readonly<Record<string, string | undefined>>;
|
|
11
|
+
}): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The same, for code that runs before the router has matched a route: the path is the request's own, up to its query,
|
|
14
|
+
* compared as it was sent. A URL parser would resolve `..` and a leading `//host` to this path, and the router would not.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isMachineLinkUpgrade(request: {
|
|
17
|
+
readonly method: string;
|
|
18
|
+
readonly url: string;
|
|
19
|
+
readonly headers: Readonly<Record<string, string | undefined>>;
|
|
20
|
+
}): boolean;
|
|
21
|
+
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
22
|
+
export declare const MachineLinkEndpoint: HttpApiEndpoint.HttpApiEndpoint<"machine.link", "GET", "/api/experimental/machine/link", never, never, never, never, Schema.toCodecJson<Schema.Boolean>, never, never, never>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, OpenApi } from "effect/http-api";
|
|
3
|
+
export const MACHINE_LINK_PATH = "/api/experimental/machine/link";
|
|
4
|
+
/**
|
|
5
|
+
* Whether a request asks to become a WebSocket, the one request the machine link serves and the one the server lets in
|
|
6
|
+
* without its password: a GET with `Upgrade: websocket` and `upgrade` among its `Connection` tokens.
|
|
7
|
+
*/
|
|
8
|
+
export function isWebSocketUpgrade(request) {
|
|
9
|
+
return (request.method === "GET" &&
|
|
10
|
+
request.headers.upgrade?.toLowerCase() === "websocket" &&
|
|
11
|
+
(request.headers.connection ?? "").split(",").some((token) => token.trim().toLowerCase() === "upgrade"));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The same, for code that runs before the router has matched a route: the path is the request's own, up to its query,
|
|
15
|
+
* compared as it was sent. A URL parser would resolve `..` and a leading `//host` to this path, and the router would not.
|
|
16
|
+
*/
|
|
17
|
+
export function isMachineLinkUpgrade(request) {
|
|
18
|
+
return request.url.split("?", 1)[0] === MACHINE_LINK_PATH && isWebSocketUpgrade(request);
|
|
19
|
+
}
|
|
20
|
+
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
21
|
+
export const MachineLinkEndpoint = HttpApiEndpoint.get("machine.link", MACHINE_LINK_PATH, {
|
|
22
|
+
success: Schema.Boolean,
|
|
23
|
+
}).annotateMerge(OpenApi.annotations({
|
|
24
|
+
identifier: "experimental.machine.link",
|
|
25
|
+
summary: "Connect a machine",
|
|
26
|
+
description: "Upgrade to a WebSocket that carries a machine's link to this server: binary messages only, each at most 65,535 bytes. It takes no server password. The link's own handshake, which starts with the machine's first message, is the only way in: it admits a key this server has paired or a valid join string, and closes the socket on anything else without saying why. Behind the machines flag; without it the route does not exist. Experimental: may change without compatibility guarantees.",
|
|
27
|
+
transform: (operation) => ({ ...operation, "x-websocket": true, tags: ["experimental"] }),
|
|
28
|
+
}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode/protocol",
|
|
4
|
-
"version": "0.0.0-dev-
|
|
4
|
+
"version": "0.0.0-dev-1326",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"typecheck:tsc": "tsc --noEmit"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@opencode/schema": "0.0.0-dev-
|
|
38
|
+
"@opencode/schema": "0.0.0-dev-1326",
|
|
39
39
|
"effect": "4.1.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|