@opencode/protocol 0.0.0-dev-21458 → 0.0.0-dev-21463

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.
@@ -6,26 +6,28 @@ export declare const PTY_CONNECT_TOKEN_HEADER = "x-opencode-ticket";
6
6
  export declare const PTY_CONNECT_TOKEN_HEADER_VALUE = "1";
7
7
  export declare const PTY_CONNECT_PATH = "/api/pty/:ptyID/connect";
8
8
  export declare function hasPtyConnectTicketURL(url: URL): boolean;
9
- export declare const makePtyGroup: <LocationId extends HttpApiMiddleware.AnyId, LocationService>(locationMiddleware: Context.Key<LocationId, LocationService>) => HttpApiGroup.HttpApiGroup<"server.pty", HttpApiEndpoint.HttpApiEndpoint<"pty.connectToken", "POST", "/api/pty/:ptyID/connect-token", Schema.toCodecStringTree<Schema.Struct<{
10
- ptyID: Schema.brand<Schema.String, "PtyID"> & {
11
- create: () => string & import("effect/Brand").Brand<"PtyID">;
12
- ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
13
- };
14
- }>>, Schema.toCodecStringTree<Schema.Struct<{
9
+ export declare const makePtyGroup: <LocationId extends HttpApiMiddleware.AnyId, LocationService>(locationMiddleware: Context.Key<LocationId, LocationService>) => HttpApiGroup.HttpApiGroup<"server.pty", HttpApiEndpoint.HttpApiEndpoint<"pty.list", "GET", "/api/pty", never, Schema.toCodecStringTree<Schema.Struct<{
15
10
  readonly location: Schema.optional<Schema.Struct<{
16
11
  readonly directory: Schema.optional<Schema.String>;
17
12
  }>>;
18
- }>>, never, Schema.toCodecStringTree<Schema.Struct<{
19
- readonly "x-opencode-ticket": Schema.optional<Schema.String>;
20
- }>>, Schema.toCodecJson<Schema.Struct<{
13
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
21
14
  readonly location: Schema.Struct<{
22
15
  readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
23
16
  }>;
24
- readonly data: Schema.Struct<{
25
- readonly ticket: Schema.String;
26
- readonly expires_in: Schema.Int;
27
- }>;
28
- }>>, Schema.toCodecJson<typeof ForbiddenError | typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.create", "POST", "/api/pty", never, Schema.toCodecStringTree<Schema.Struct<{
17
+ readonly data: Schema.$Array<Schema.Struct<{
18
+ readonly id: Schema.brand<Schema.String, "PtyID"> & {
19
+ create: () => string & import("effect/Brand").Brand<"PtyID">;
20
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
21
+ };
22
+ readonly title: Schema.String;
23
+ readonly command: Schema.String;
24
+ readonly args: Schema.$Array<Schema.String>;
25
+ readonly cwd: Schema.String;
26
+ readonly status: Schema.Literals<readonly ["running", "exited"]>;
27
+ readonly pid: Schema.Int;
28
+ readonly exitCode: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
29
+ }>>;
30
+ }>>, never, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.create", "POST", "/api/pty", never, Schema.toCodecStringTree<Schema.Struct<{
29
31
  readonly location: Schema.optional<Schema.Struct<{
30
32
  readonly directory: Schema.optional<Schema.String>;
31
33
  }>>;
@@ -78,15 +80,29 @@ export declare const makePtyGroup: <LocationId extends HttpApiMiddleware.AnyId,
78
80
  readonly pid: Schema.Int;
79
81
  readonly exitCode: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
80
82
  }>;
81
- }>>, Schema.toCodecJson<typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.list", "GET", "/api/pty", never, Schema.toCodecStringTree<Schema.Struct<{
83
+ }>>, Schema.toCodecJson<typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.update", "PUT", "/api/pty/:ptyID", Schema.toCodecStringTree<Schema.Struct<{
84
+ ptyID: Schema.brand<Schema.String, "PtyID"> & {
85
+ create: () => string & import("effect/Brand").Brand<"PtyID">;
86
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
87
+ };
88
+ }>>, Schema.toCodecStringTree<Schema.Struct<{
82
89
  readonly location: Schema.optional<Schema.Struct<{
83
90
  readonly directory: Schema.optional<Schema.String>;
84
91
  }>>;
85
- }>>, never, never, Schema.toCodecJson<Schema.Struct<{
92
+ }>>, Schema.toCodecJson<Schema.Struct<{
93
+ readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
94
+ readonly size: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
95
+ readonly rows: Schema.Int;
96
+ readonly cols: Schema.Int;
97
+ }>>>, Schema.optionalKey<Schema.Struct<{
98
+ readonly rows: Schema.Int;
99
+ readonly cols: Schema.Int;
100
+ }>>, never, never>;
101
+ }>>, never, Schema.toCodecJson<Schema.Struct<{
86
102
  readonly location: Schema.Struct<{
87
103
  readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
88
104
  }>;
89
- readonly data: Schema.$Array<Schema.Struct<{
105
+ readonly data: Schema.Struct<{
90
106
  readonly id: Schema.brand<Schema.String, "PtyID"> & {
91
107
  create: () => string & import("effect/Brand").Brand<"PtyID">;
92
108
  ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
@@ -98,8 +114,8 @@ export declare const makePtyGroup: <LocationId extends HttpApiMiddleware.AnyId,
98
114
  readonly status: Schema.Literals<readonly ["running", "exited"]>;
99
115
  readonly pid: Schema.Int;
100
116
  readonly exitCode: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
101
- }>>;
102
- }>>, never, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.remove", "DELETE", "/api/pty/:ptyID", Schema.toCodecStringTree<Schema.Struct<{
117
+ }>;
118
+ }>>, Schema.toCodecJson<typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.remove", "DELETE", "/api/pty/:ptyID", Schema.toCodecStringTree<Schema.Struct<{
103
119
  ptyID: Schema.brand<Schema.String, "PtyID"> & {
104
120
  create: () => string & import("effect/Brand").Brand<"PtyID">;
105
121
  ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
@@ -108,7 +124,7 @@ export declare const makePtyGroup: <LocationId extends HttpApiMiddleware.AnyId,
108
124
  readonly location: Schema.optional<Schema.Struct<{
109
125
  readonly directory: Schema.optional<Schema.String>;
110
126
  }>>;
111
- }>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.update", "PUT", "/api/pty/:ptyID", Schema.toCodecStringTree<Schema.Struct<{
127
+ }>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.connectToken", "POST", "/api/pty/:ptyID/connect-token", Schema.toCodecStringTree<Schema.Struct<{
112
128
  ptyID: Schema.brand<Schema.String, "PtyID"> & {
113
129
  create: () => string & import("effect/Brand").Brand<"PtyID">;
114
130
  ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
@@ -117,33 +133,17 @@ export declare const makePtyGroup: <LocationId extends HttpApiMiddleware.AnyId,
117
133
  readonly location: Schema.optional<Schema.Struct<{
118
134
  readonly directory: Schema.optional<Schema.String>;
119
135
  }>>;
136
+ }>>, never, Schema.toCodecStringTree<Schema.Struct<{
137
+ readonly "x-opencode-ticket": Schema.optional<Schema.String>;
120
138
  }>>, Schema.toCodecJson<Schema.Struct<{
121
- readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
122
- readonly size: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
123
- readonly rows: Schema.Int;
124
- readonly cols: Schema.Int;
125
- }>>>, Schema.optionalKey<Schema.Struct<{
126
- readonly rows: Schema.Int;
127
- readonly cols: Schema.Int;
128
- }>>, never, never>;
129
- }>>, never, Schema.toCodecJson<Schema.Struct<{
130
139
  readonly location: Schema.Struct<{
131
140
  readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
132
141
  }>;
133
142
  readonly data: Schema.Struct<{
134
- readonly id: Schema.brand<Schema.String, "PtyID"> & {
135
- create: () => string & import("effect/Brand").Brand<"PtyID">;
136
- ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
137
- };
138
- readonly title: Schema.String;
139
- readonly command: Schema.String;
140
- readonly args: Schema.$Array<Schema.String>;
141
- readonly cwd: Schema.String;
142
- readonly status: Schema.Literals<readonly ["running", "exited"]>;
143
- readonly pid: Schema.Int;
144
- readonly exitCode: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
143
+ readonly ticket: Schema.String;
144
+ readonly expires_in: Schema.Int;
145
145
  }>;
146
- }>>, Schema.toCodecJson<typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.connect", "GET", "/api/pty/:ptyID/connect", Schema.toCodecStringTree<Schema.Struct<{
146
+ }>>, Schema.toCodecJson<typeof ForbiddenError | typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.connect", "GET", "/api/pty/:ptyID/connect", Schema.toCodecStringTree<Schema.Struct<{
147
147
  ptyID: Schema.brand<Schema.String, "PtyID"> & {
148
148
  create: () => string & import("effect/Brand").Brand<"PtyID">;
149
149
  ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
3
3
  import { InvalidRequestError, LocationNotFoundError, ServiceUnavailableError } from "../errors.js";
4
4
  export declare const VoiceTransportType: Schema.Literals<readonly ["webrtc", "websocket"]>;
5
5
  export declare const VoiceModel: Schema.Struct<{
@@ -7,6 +7,10 @@ export declare const VoiceModel: Schema.Struct<{
7
7
  readonly provider: Schema.String;
8
8
  readonly transports: Schema.$Array<Schema.Literals<readonly ["webrtc", "websocket"]>>;
9
9
  readonly available: Schema.Boolean;
10
+ /** The integration whose connection starts its sessions: the provider's stored key, or `opencode` when the connected OpenCode Console hosts it. */
11
+ readonly integration: Schema.optional<Schema.String>;
12
+ /** The OpenCode Console workspace a hosted model's sessions bill to. */
13
+ readonly workspace: Schema.optional<Schema.String>;
10
14
  }>;
11
15
  export declare const VoiceWebRTCTransportInput: Schema.Struct<{
12
16
  readonly type: Schema.Literal<"webrtc">;
@@ -42,13 +46,21 @@ export declare const VoiceTransport: Schema.Union<readonly [Schema.Struct<{
42
46
  readonly token: Schema.String;
43
47
  readonly expiresAt: Schema.Number;
44
48
  }>]>;
45
- export declare const VoiceGroup: HttpApiGroup.HttpApiGroup<"server.voice", HttpApiEndpoint.HttpApiEndpoint<"voice.models", "GET", "/api/experimental/voice/models", never, never, never, never, Schema.toCodecJson<Schema.Struct<{
49
+ export declare const VoiceGroup: HttpApiGroup.HttpApiGroup<"server.voice", HttpApiEndpoint.HttpApiEndpoint<"voice.instructions", "POST", "/api/experimental/voice/session/:sessionID/instructions", Schema.toCodecStringTree<Schema.Struct<{
50
+ sessionID: Schema.String;
51
+ }>>, never, Schema.toCodecJson<Schema.Struct<{
52
+ readonly instructions: Schema.String;
53
+ }>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"voice.models", "GET", "/api/experimental/voice/models", never, never, never, never, Schema.toCodecJson<Schema.Struct<{
46
54
  readonly data: Schema.Struct<{
47
55
  readonly models: Schema.$Array<Schema.Struct<{
48
56
  readonly model: Schema.String;
49
57
  readonly provider: Schema.String;
50
58
  readonly transports: Schema.$Array<Schema.Literals<readonly ["webrtc", "websocket"]>>;
51
59
  readonly available: Schema.Boolean;
60
+ /** The integration whose connection starts its sessions: the provider's stored key, or `opencode` when the connected OpenCode Console hosts it. */
61
+ readonly integration: Schema.optional<Schema.String>;
62
+ /** The OpenCode Console workspace a hosted model's sessions bill to. */
63
+ readonly workspace: Schema.optional<Schema.String>;
52
64
  }>>;
53
65
  readonly default: Schema.optional<Schema.String>;
54
66
  }>;
@@ -73,5 +85,9 @@ export declare const VoiceGroup: HttpApiGroup.HttpApiGroup<"server.voice", HttpA
73
85
  readonly token: Schema.String;
74
86
  readonly expiresAt: Schema.Number;
75
87
  }>]>;
88
+ /** A hosted session's ID, for `voice.instructions`. */
89
+ readonly session: Schema.optional<Schema.Struct<{
90
+ readonly id: Schema.String;
91
+ }>>;
76
92
  }>;
77
93
  }>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api";
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
3
3
  import { InvalidRequestError, LocationNotFoundError, ServiceUnavailableError } from "../errors.js";
4
4
  export const VoiceTransportType = Schema.Literals(["webrtc", "websocket"]).annotate({
5
5
  identifier: "VoiceTransportType",
@@ -9,6 +9,10 @@ export const VoiceModel = Schema.Struct({
9
9
  provider: Schema.String,
10
10
  transports: Schema.Array(VoiceTransportType),
11
11
  available: Schema.Boolean,
12
+ /** The integration whose connection starts its sessions: the provider's stored key, or `opencode` when the connected OpenCode Console hosts it. */
13
+ integration: Schema.optional(Schema.String),
14
+ /** The OpenCode Console workspace a hosted model's sessions bill to. */
15
+ workspace: Schema.optional(Schema.String),
12
16
  }).annotate({ identifier: "VoiceModel" });
13
17
  export const VoiceWebRTCTransportInput = Schema.Struct({
14
18
  type: Schema.Literal("webrtc"),
@@ -48,7 +52,7 @@ export const VoiceGroup = HttpApiGroup.make("server.voice")
48
52
  }).annotateMerge(OpenApi.annotations({
49
53
  identifier: "experimental.voice.models",
50
54
  summary: "List voice models",
51
- description: "List supported voice models, their transports, and whether the server has a usable API key for each provider.",
55
+ description: "List supported voice models, their transports, whether the server has a usable API key for each provider or the connected OpenCode Console hosts the model, and the Console workspace a hosted model bills to.",
52
56
  })))
53
57
  .add(HttpApiEndpoint.post("voice.session", "/api/experimental/voice/session", {
54
58
  payload: Schema.Struct({
@@ -59,13 +63,25 @@ export const VoiceGroup = HttpApiGroup.make("server.voice")
59
63
  success: Schema.Struct({
60
64
  data: Schema.Struct({
61
65
  transport: VoiceTransport,
66
+ /** A hosted session's ID, for `voice.instructions`. */
67
+ session: Schema.optional(Schema.Struct({ id: Schema.String })),
62
68
  }),
63
69
  }).annotate({ identifier: "VoiceSessionResponse" }),
64
70
  error: [InvalidRequestError, ServiceUnavailableError, LocationNotFoundError],
65
71
  }).annotateMerge(OpenApi.annotations({
66
72
  identifier: "experimental.voice.session",
67
73
  summary: "Create voice session",
68
- description: "Create a server-brokered voice session using the server's configured provider credentials and return the WebRTC SDP answer or WebSocket ephemeral token.",
74
+ description: "Create a server-brokered voice session using the server's configured provider credentials, or the connected OpenCode Console when it hosts the model, and return the WebRTC SDP answer or WebSocket ephemeral token.",
75
+ })))
76
+ .add(HttpApiEndpoint.post("voice.instructions", "/api/experimental/voice/session/:sessionID/instructions", {
77
+ params: { sessionID: Schema.String },
78
+ payload: Schema.Struct({ instructions: Schema.String }),
79
+ success: HttpApiSchema.NoContent,
80
+ error: [InvalidRequestError, ServiceUnavailableError, LocationNotFoundError],
81
+ }).annotateMerge(OpenApi.annotations({
82
+ identifier: "experimental.voice.instructions",
83
+ summary: "Replace voice session instructions",
84
+ description: "Replace the backend instructions of a running session the connected OpenCode Console hosts, whose data channel can't change them.",
69
85
  })))
70
86
  .annotateMerge(OpenApi.annotations({
71
87
  title: "voice",
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-21458",
4
+ "version": "0.0.0-dev-21463",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "typecheck": "tsc --noEmit"
34
34
  },
35
35
  "dependencies": {
36
- "@opencode/schema": "0.0.0-dev-21458",
36
+ "@opencode/schema": "0.0.0-dev-21463",
37
37
  "effect": "4.0.1"
38
38
  },
39
39
  "devDependencies": {