@opencode/protocol 2.1.2 → 2.1.4

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.
@@ -1,6 +1,17 @@
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
+ export declare const VoiceTransportType: Schema.Literals<readonly ["webrtc", "websocket"]>;
5
+ export declare const VoiceModel: Schema.Struct<{
6
+ readonly model: Schema.String;
7
+ readonly provider: Schema.String;
8
+ readonly transports: Schema.$Array<Schema.Literals<readonly ["webrtc", "websocket"]>>;
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>;
14
+ }>;
4
15
  export declare const VoiceWebRTCTransportInput: Schema.Struct<{
5
16
  readonly type: Schema.Literal<"webrtc">;
6
17
  readonly sdp: Schema.String;
@@ -35,7 +46,25 @@ export declare const VoiceTransport: Schema.Union<readonly [Schema.Struct<{
35
46
  readonly token: Schema.String;
36
47
  readonly expiresAt: Schema.Number;
37
48
  }>]>;
38
- export declare const VoiceGroup: HttpApiGroup.HttpApiGroup<"server.voice", HttpApiEndpoint.HttpApiEndpoint<"voice.session", "POST", "/api/experimental/voice/session", 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<{
54
+ readonly data: Schema.Struct<{
55
+ readonly models: Schema.$Array<Schema.Struct<{
56
+ readonly model: Schema.String;
57
+ readonly provider: Schema.String;
58
+ readonly transports: Schema.$Array<Schema.Literals<readonly ["webrtc", "websocket"]>>;
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>;
64
+ }>>;
65
+ readonly default: Schema.optional<Schema.String>;
66
+ }>;
67
+ }>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"voice.session", "POST", "/api/experimental/voice/session", never, never, Schema.toCodecJson<Schema.Struct<{
39
68
  readonly model: Schema.String;
40
69
  readonly session: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
41
70
  readonly transport: Schema.Union<readonly [Schema.Struct<{
@@ -56,5 +85,9 @@ export declare const VoiceGroup: HttpApiGroup.HttpApiGroup<"server.voice", HttpA
56
85
  readonly token: Schema.String;
57
86
  readonly expiresAt: Schema.Number;
58
87
  }>]>;
88
+ /** A hosted session's ID, for `voice.instructions`. */
89
+ readonly session: Schema.optional<Schema.Struct<{
90
+ readonly id: Schema.String;
91
+ }>>;
59
92
  }>;
60
93
  }>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
@@ -1,6 +1,19 @@
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
+ export const VoiceTransportType = Schema.Literals(["webrtc", "websocket"]).annotate({
5
+ identifier: "VoiceTransportType",
6
+ });
7
+ export const VoiceModel = Schema.Struct({
8
+ model: Schema.String,
9
+ provider: Schema.String,
10
+ transports: Schema.Array(VoiceTransportType),
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),
16
+ }).annotate({ identifier: "VoiceModel" });
4
17
  export const VoiceWebRTCTransportInput = Schema.Struct({
5
18
  type: Schema.Literal("webrtc"),
6
19
  sdp: Schema.String,
@@ -28,6 +41,19 @@ export const VoiceTransport = Schema.Union([
28
41
  VoiceWebSocketTransport,
29
42
  ]).annotate({ identifier: "VoiceTransport" });
30
43
  export const VoiceGroup = HttpApiGroup.make("server.voice")
44
+ .add(HttpApiEndpoint.get("voice.models", "/api/experimental/voice/models", {
45
+ success: Schema.Struct({
46
+ data: Schema.Struct({
47
+ models: Schema.Array(VoiceModel),
48
+ default: Schema.optional(Schema.String),
49
+ }),
50
+ }).annotate({ identifier: "VoiceModelsResponse" }),
51
+ error: [ServiceUnavailableError, LocationNotFoundError],
52
+ }).annotateMerge(OpenApi.annotations({
53
+ identifier: "experimental.voice.models",
54
+ summary: "List voice models",
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.",
56
+ })))
31
57
  .add(HttpApiEndpoint.post("voice.session", "/api/experimental/voice/session", {
32
58
  payload: Schema.Struct({
33
59
  model: Schema.String,
@@ -37,13 +63,25 @@ export const VoiceGroup = HttpApiGroup.make("server.voice")
37
63
  success: Schema.Struct({
38
64
  data: Schema.Struct({
39
65
  transport: VoiceTransport,
66
+ /** A hosted session's ID, for `voice.instructions`. */
67
+ session: Schema.optional(Schema.Struct({ id: Schema.String })),
40
68
  }),
41
69
  }).annotate({ identifier: "VoiceSessionResponse" }),
42
70
  error: [InvalidRequestError, ServiceUnavailableError, LocationNotFoundError],
43
71
  }).annotateMerge(OpenApi.annotations({
44
72
  identifier: "experimental.voice.session",
45
73
  summary: "Create voice session",
46
- 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.",
47
85
  })))
48
86
  .annotateMerge(OpenApi.annotations({
49
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": "2.1.2",
4
+ "version": "2.1.4",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -30,16 +30,17 @@
30
30
  "generate": "bun run script/generate-openapi.ts",
31
31
  "check:generated": "bun run script/generate-openapi.ts --check",
32
32
  "test": "bun test --only-failures",
33
- "typecheck": "tsc --noEmit"
33
+ "typecheck": "bun check --no-script",
34
+ "typecheck:tsc": "tsc --noEmit"
34
35
  },
35
36
  "dependencies": {
36
- "@opencode/schema": "2.1.2",
37
+ "@opencode/schema": "2.1.4",
37
38
  "effect": "4.0.1"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@tsconfig/bun": "1.0.9",
41
- "@types/bun": "1.4.0",
42
- "@typescript/native": "npm:typescript@7.0.2",
42
+ "@types/bun": "1.4.3",
43
+ "@typescript/native": "npm:typescript@7.1.0-beta",
43
44
  "prettier": "3.6.2",
44
45
  "typescript": "npm:@typescript/typescript6@6.0.2"
45
46
  }