@opencode/protocol 0.0.0-dev-1324 → 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 +2 -0
- package/dist/groups/automation.d.ts +21 -0
- package/dist/groups/automation.js +1 -1
- package/dist/groups/experimental.d.ts +19 -1
- package/dist/groups/experimental.js +2 -1
- package/dist/groups/machine.d.ts +22 -0
- package/dist/groups/machine.js +28 -0
- package/package.json +2 -2
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
|
]);
|
|
@@ -45,6 +45,9 @@ export declare const CreatePayload: Schema.Struct<{
|
|
|
45
45
|
readonly type: Schema.tag<"code">;
|
|
46
46
|
readonly code: Schema.String;
|
|
47
47
|
readonly args: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<Schema.Json, Schema.Json, never, never>>>, Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>, never, never>;
|
|
48
|
+
}>, Schema.Struct<{
|
|
49
|
+
readonly type: Schema.tag<"shell">;
|
|
50
|
+
readonly command: Schema.NonEmptyString;
|
|
48
51
|
}>]>;
|
|
49
52
|
readonly expires: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
50
53
|
readonly sessionID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "SessionID"> & {
|
|
@@ -107,6 +110,9 @@ export declare const AutomationEndpoints: readonly [HttpApiEndpoint.HttpApiEndpo
|
|
|
107
110
|
readonly type: Schema.tag<"code">;
|
|
108
111
|
readonly code: Schema.String;
|
|
109
112
|
readonly args: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<Schema.Json, Schema.Json, never, never>>>, Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>, never, never>;
|
|
113
|
+
}>, Schema.Struct<{
|
|
114
|
+
readonly type: Schema.tag<"shell">;
|
|
115
|
+
readonly command: Schema.NonEmptyString;
|
|
110
116
|
}>]>;
|
|
111
117
|
readonly expires: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
112
118
|
readonly sessionID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "SessionID"> & {
|
|
@@ -165,6 +171,9 @@ export declare const AutomationEndpoints: readonly [HttpApiEndpoint.HttpApiEndpo
|
|
|
165
171
|
readonly type: Schema.tag<"code">;
|
|
166
172
|
readonly code: Schema.String;
|
|
167
173
|
readonly args: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<Schema.Json, Schema.Json, never, never>>>, Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>, never, never>;
|
|
174
|
+
}>, Schema.Struct<{
|
|
175
|
+
type: Schema.tag<"shell">;
|
|
176
|
+
command: Schema.NonEmptyString;
|
|
168
177
|
}>]>;
|
|
169
178
|
readonly expires: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
|
|
170
179
|
readonly status: Schema.Literals<readonly ["active", "paused", "done"]>;
|
|
@@ -234,6 +243,9 @@ export declare const AutomationEndpoints: readonly [HttpApiEndpoint.HttpApiEndpo
|
|
|
234
243
|
readonly type: Schema.tag<"code">;
|
|
235
244
|
readonly code: Schema.String;
|
|
236
245
|
readonly args: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<Schema.Json, Schema.Json, never, never>>>, Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>, never, never>;
|
|
246
|
+
}>, Schema.Struct<{
|
|
247
|
+
type: Schema.tag<"shell">;
|
|
248
|
+
command: Schema.NonEmptyString;
|
|
237
249
|
}>]>;
|
|
238
250
|
readonly expires: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
|
|
239
251
|
readonly status: Schema.Literals<readonly ["active", "paused", "done"]>;
|
|
@@ -302,6 +314,9 @@ export declare const AutomationEndpoints: readonly [HttpApiEndpoint.HttpApiEndpo
|
|
|
302
314
|
readonly type: Schema.tag<"code">;
|
|
303
315
|
readonly code: Schema.String;
|
|
304
316
|
readonly args: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<Schema.Json, Schema.Json, never, never>>>, Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>, never, never>;
|
|
317
|
+
}>, Schema.Struct<{
|
|
318
|
+
type: Schema.tag<"shell">;
|
|
319
|
+
command: Schema.NonEmptyString;
|
|
305
320
|
}>]>;
|
|
306
321
|
readonly expires: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
|
|
307
322
|
readonly status: Schema.Literals<readonly ["active", "paused", "done"]>;
|
|
@@ -370,6 +385,9 @@ export declare const AutomationEndpoints: readonly [HttpApiEndpoint.HttpApiEndpo
|
|
|
370
385
|
readonly type: Schema.tag<"code">;
|
|
371
386
|
readonly code: Schema.String;
|
|
372
387
|
readonly args: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<Schema.Json, Schema.Json, never, never>>>, Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>, never, never>;
|
|
388
|
+
}>, Schema.Struct<{
|
|
389
|
+
type: Schema.tag<"shell">;
|
|
390
|
+
command: Schema.NonEmptyString;
|
|
373
391
|
}>]>;
|
|
374
392
|
readonly expires: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
|
|
375
393
|
readonly status: Schema.Literals<readonly ["active", "paused", "done"]>;
|
|
@@ -438,6 +456,9 @@ export declare const AutomationEndpoints: readonly [HttpApiEndpoint.HttpApiEndpo
|
|
|
438
456
|
readonly type: Schema.tag<"code">;
|
|
439
457
|
readonly code: Schema.String;
|
|
440
458
|
readonly args: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Codec<Schema.Json, Schema.Json, never, never>>>, Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>, never, never>;
|
|
459
|
+
}>, Schema.Struct<{
|
|
460
|
+
type: Schema.tag<"shell">;
|
|
461
|
+
command: Schema.NonEmptyString;
|
|
441
462
|
}>]>;
|
|
442
463
|
readonly expires: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
|
|
443
464
|
readonly status: Schema.Literals<readonly ["active", "paused", "done"]>;
|
|
@@ -26,7 +26,7 @@ export const AutomationEndpoints = [
|
|
|
26
26
|
payload: CreatePayload,
|
|
27
27
|
success: Schema.Struct({ data: Automation.Info }),
|
|
28
28
|
error: [InvalidRequestError, SessionNotFoundError, ForbiddenError],
|
|
29
|
-
}).annotateMerge(annotations("create", "Create automation", "Create an automation that sends a prompt
|
|
29
|
+
}).annotateMerge(annotations("create", "Create automation", "Create an automation that sends a prompt, runs a Code Mode program, or runs a shell command at a time, every interval, or on a cron. Creating an MCP event watch requires the automation_create tool in a local session; a session ID over HTTP is not a watch authorization.")),
|
|
30
30
|
HttpApiEndpoint.get("automation.list", "/api/experimental/automation", {
|
|
31
31
|
query: ListQuery,
|
|
32
32
|
success: Schema.Struct({ data: Schema.Array(Automation.Info) }),
|
|
@@ -211,6 +211,9 @@ export declare const ExperimentalGroup: import("effect/http-api/HttpApiGroup").H
|
|
|
211
211
|
readonly type: import("effect/Schema").tag<"code">;
|
|
212
212
|
readonly code: import("effect/Schema").String;
|
|
213
213
|
readonly args: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>, never, never>;
|
|
214
|
+
}>, import("effect/Schema").Struct<{
|
|
215
|
+
readonly type: import("effect/Schema").tag<"shell">;
|
|
216
|
+
readonly command: import("effect/Schema").NonEmptyString;
|
|
214
217
|
}>]>;
|
|
215
218
|
readonly expires: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").String>>, import("effect/Schema").optionalKey<import("effect/Schema").String>, never, never>;
|
|
216
219
|
readonly sessionID: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").brand<import("effect/Schema").String, "SessionID"> & {
|
|
@@ -269,6 +272,9 @@ export declare const ExperimentalGroup: import("effect/http-api/HttpApiGroup").H
|
|
|
269
272
|
readonly type: import("effect/Schema").tag<"code">;
|
|
270
273
|
readonly code: import("effect/Schema").String;
|
|
271
274
|
readonly args: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>, never, never>;
|
|
275
|
+
}>, import("effect/Schema").Struct<{
|
|
276
|
+
type: import("effect/Schema").tag<"shell">;
|
|
277
|
+
command: import("effect/Schema").NonEmptyString;
|
|
272
278
|
}>]>;
|
|
273
279
|
readonly expires: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").decodeTo<import("effect/Schema").DateTimeUtc, import("effect/Schema").Finite, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").decodeTo<import("effect/Schema").DateTimeUtc, import("effect/Schema").Finite, never, never>>, never, never>;
|
|
274
280
|
readonly status: import("effect/Schema").Literals<readonly ["active", "paused", "done"]>;
|
|
@@ -341,6 +347,9 @@ export declare const ExperimentalGroup: import("effect/http-api/HttpApiGroup").H
|
|
|
341
347
|
readonly type: import("effect/Schema").tag<"code">;
|
|
342
348
|
readonly code: import("effect/Schema").String;
|
|
343
349
|
readonly args: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>, never, never>;
|
|
350
|
+
}>, import("effect/Schema").Struct<{
|
|
351
|
+
type: import("effect/Schema").tag<"shell">;
|
|
352
|
+
command: import("effect/Schema").NonEmptyString;
|
|
344
353
|
}>]>;
|
|
345
354
|
readonly expires: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").decodeTo<import("effect/Schema").DateTimeUtc, import("effect/Schema").Finite, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").decodeTo<import("effect/Schema").DateTimeUtc, import("effect/Schema").Finite, never, never>>, never, never>;
|
|
346
355
|
readonly status: import("effect/Schema").Literals<readonly ["active", "paused", "done"]>;
|
|
@@ -410,6 +419,9 @@ export declare const ExperimentalGroup: import("effect/http-api/HttpApiGroup").H
|
|
|
410
419
|
readonly type: import("effect/Schema").tag<"code">;
|
|
411
420
|
readonly code: import("effect/Schema").String;
|
|
412
421
|
readonly args: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>, never, never>;
|
|
422
|
+
}>, import("effect/Schema").Struct<{
|
|
423
|
+
type: import("effect/Schema").tag<"shell">;
|
|
424
|
+
command: import("effect/Schema").NonEmptyString;
|
|
413
425
|
}>]>;
|
|
414
426
|
readonly expires: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").decodeTo<import("effect/Schema").DateTimeUtc, import("effect/Schema").Finite, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").decodeTo<import("effect/Schema").DateTimeUtc, import("effect/Schema").Finite, never, never>>, never, never>;
|
|
415
427
|
readonly status: import("effect/Schema").Literals<readonly ["active", "paused", "done"]>;
|
|
@@ -478,6 +490,9 @@ export declare const ExperimentalGroup: import("effect/http-api/HttpApiGroup").H
|
|
|
478
490
|
readonly type: import("effect/Schema").tag<"code">;
|
|
479
491
|
readonly code: import("effect/Schema").String;
|
|
480
492
|
readonly args: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>, never, never>;
|
|
493
|
+
}>, import("effect/Schema").Struct<{
|
|
494
|
+
type: import("effect/Schema").tag<"shell">;
|
|
495
|
+
command: import("effect/Schema").NonEmptyString;
|
|
481
496
|
}>]>;
|
|
482
497
|
readonly expires: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").decodeTo<import("effect/Schema").DateTimeUtc, import("effect/Schema").Finite, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").decodeTo<import("effect/Schema").DateTimeUtc, import("effect/Schema").Finite, never, never>>, never, never>;
|
|
483
498
|
readonly status: import("effect/Schema").Literals<readonly ["active", "paused", "done"]>;
|
|
@@ -546,6 +561,9 @@ export declare const ExperimentalGroup: import("effect/http-api/HttpApiGroup").H
|
|
|
546
561
|
readonly type: import("effect/Schema").tag<"code">;
|
|
547
562
|
readonly code: import("effect/Schema").String;
|
|
548
563
|
readonly args: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>, never, never>;
|
|
564
|
+
}>, import("effect/Schema").Struct<{
|
|
565
|
+
type: import("effect/Schema").tag<"shell">;
|
|
566
|
+
command: import("effect/Schema").NonEmptyString;
|
|
549
567
|
}>]>;
|
|
550
568
|
readonly expires: import("effect/Schema").decodeTo<import("effect/Schema").optional<import("effect/Schema").toType<import("effect/Schema").decodeTo<import("effect/Schema").DateTimeUtc, import("effect/Schema").Finite, never, never>>>, import("effect/Schema").optionalKey<import("effect/Schema").decodeTo<import("effect/Schema").DateTimeUtc, import("effect/Schema").Finite, never, never>>, never, never>;
|
|
551
569
|
readonly status: import("effect/Schema").Literals<readonly ["active", "paused", "done"]>;
|
|
@@ -645,7 +663,7 @@ export declare const ExperimentalGroup: import("effect/http-api/HttpApiGroup").H
|
|
|
645
663
|
}>;
|
|
646
664
|
readonly kind: import("effect/Schema").tag<"codemode">;
|
|
647
665
|
}>]>>;
|
|
648
|
-
}>>, 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<{
|
|
649
667
|
hash: import("effect/Schema").String;
|
|
650
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<{
|
|
651
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": {
|