@opencode/protocol 0.0.0-reserved → 2.0.0

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.
Files changed (78) hide show
  1. package/dist/api.d.ts +56 -0
  2. package/dist/api.js +79 -0
  3. package/dist/client.d.ts +64 -0
  4. package/dist/client.js +50 -0
  5. package/dist/errors.d.ts +153 -0
  6. package/dist/errors.js +122 -0
  7. package/dist/groups/agent.d.ts +194 -0
  8. package/dist/groups/agent.js +30 -0
  9. package/dist/groups/command.d.ts +15 -0
  10. package/dist/groups/command.js +20 -0
  11. package/dist/groups/config.d.ts +9 -0
  12. package/dist/groups/config.js +16 -0
  13. package/dist/groups/credential.d.ts +32 -0
  14. package/dist/groups/credential.js +40 -0
  15. package/dist/groups/debug.d.ts +17 -0
  16. package/dist/groups/debug.js +23 -0
  17. package/dist/groups/event.d.ts +14643 -0
  18. package/dist/groups/event.js +51 -0
  19. package/dist/groups/form.d.ts +781 -0
  20. package/dist/groups/form.js +95 -0
  21. package/dist/groups/fs.d.ts +35 -0
  22. package/dist/groups/fs.js +53 -0
  23. package/dist/groups/generate.d.ts +33 -0
  24. package/dist/groups/generate.js +23 -0
  25. package/dist/groups/health.d.ts +15 -0
  26. package/dist/groups/health.js +20 -0
  27. package/dist/groups/integration.d.ts +1154 -0
  28. package/dist/groups/integration.js +149 -0
  29. package/dist/groups/location.d.ts +16 -0
  30. package/dist/groups/location.js +34 -0
  31. package/dist/groups/mcp.d.ts +82 -0
  32. package/dist/groups/mcp.js +78 -0
  33. package/dist/groups/message.d.ts +734 -0
  34. package/dist/groups/message.js +51 -0
  35. package/dist/groups/migration.d.ts +28 -0
  36. package/dist/groups/migration.js +21 -0
  37. package/dist/groups/model.d.ts +314 -0
  38. package/dist/groups/model.js +33 -0
  39. package/dist/groups/permission.d.ts +167 -0
  40. package/dist/groups/permission.js +109 -0
  41. package/dist/groups/persistent-pty.d.ts +249 -0
  42. package/dist/groups/persistent-pty.js +91 -0
  43. package/dist/groups/plugin.d.ts +91 -0
  44. package/dist/groups/plugin.js +55 -0
  45. package/dist/groups/project.d.ts +90 -0
  46. package/dist/groups/project.js +39 -0
  47. package/dist/groups/provider.d.ts +156 -0
  48. package/dist/groups/provider.js +34 -0
  49. package/dist/groups/pty.d.ts +147 -0
  50. package/dist/groups/pty.js +113 -0
  51. package/dist/groups/reference.d.ts +29 -0
  52. package/dist/groups/reference.js +20 -0
  53. package/dist/groups/rpc.d.ts +22 -0
  54. package/dist/groups/rpc.js +24 -0
  55. package/dist/groups/server.d.ts +5 -0
  56. package/dist/groups/server.js +11 -0
  57. package/dist/groups/session.d.ts +10794 -0
  58. package/dist/groups/session.js +549 -0
  59. package/dist/groups/shell.d.ts +152 -0
  60. package/dist/groups/shell.js +82 -0
  61. package/dist/groups/skill.d.ts +20 -0
  62. package/dist/groups/skill.js +20 -0
  63. package/dist/groups/vcs.d.ts +70 -0
  64. package/dist/groups/vcs.js +76 -0
  65. package/dist/groups/websearch.d.ts +28 -0
  66. package/dist/groups/websearch.js +34 -0
  67. package/dist/groups/workspace.d.ts +22 -0
  68. package/dist/groups/workspace.js +27 -0
  69. package/dist/groups/worktree.d.ts +47 -0
  70. package/dist/groups/worktree.js +61 -0
  71. package/dist/middleware/authorization.d.ts +13 -0
  72. package/dist/middleware/authorization.js +6 -0
  73. package/dist/middleware/schema-error.d.ts +13 -0
  74. package/dist/middleware/schema-error.js +4 -0
  75. package/dist/simulation.d.ts +1801 -0
  76. package/dist/simulation.js +487 -0
  77. package/package.json +36 -6
  78. package/README.md +0 -5
@@ -0,0 +1,487 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { Rpc, RpcGroup } from "effect/unstable/rpc";
3
+ const JsonRpcID = Schema.Union([Schema.String, Schema.Number, Schema.Null]);
4
+ const decodeJson = Schema.decodeUnknownSync(Schema.Json);
5
+ export var JsonRpc;
6
+ (function (JsonRpc) {
7
+ JsonRpc.RequestFields = {
8
+ jsonrpc: Schema.Literal("2.0"),
9
+ id: Schema.optional(JsonRpcID),
10
+ };
11
+ JsonRpc.Request = Schema.Struct({
12
+ ...JsonRpc.RequestFields,
13
+ method: Schema.String,
14
+ params: Schema.optional(Schema.Json),
15
+ });
16
+ JsonRpc.ErrorObject = Schema.Struct({
17
+ code: Schema.Number,
18
+ message: Schema.String,
19
+ data: Schema.optional(Schema.Json),
20
+ });
21
+ JsonRpc.Response = Schema.Union([
22
+ Schema.Struct({
23
+ jsonrpc: Schema.Literal("2.0"),
24
+ id: JsonRpcID,
25
+ result: Schema.Json,
26
+ error: Schema.optionalKey(Schema.Never),
27
+ }),
28
+ Schema.Struct({
29
+ jsonrpc: Schema.Literal("2.0"),
30
+ id: JsonRpcID,
31
+ result: Schema.optionalKey(Schema.Never),
32
+ error: JsonRpc.ErrorObject,
33
+ }),
34
+ ], { mode: "oneOf" });
35
+ JsonRpc.decodeRequest = Schema.decodeUnknownSync(JsonRpc.Request);
36
+ function success(id, result) {
37
+ if (id === undefined)
38
+ return undefined;
39
+ return { jsonrpc: "2.0", id, result: decodeJson(result) };
40
+ }
41
+ JsonRpc.success = success;
42
+ function failure(id, error) {
43
+ return {
44
+ jsonrpc: "2.0",
45
+ id: id ?? null,
46
+ error: {
47
+ code: -32000,
48
+ message: error instanceof Error ? error.message : String(error),
49
+ },
50
+ };
51
+ }
52
+ JsonRpc.failure = failure;
53
+ })(JsonRpc || (JsonRpc = {}));
54
+ export class SimulationRequestError extends Schema.TaggedError()("SimulationRequestError", {
55
+ method: Schema.String,
56
+ code: Schema.Number,
57
+ message: Schema.String,
58
+ data: Schema.optionalKey(Schema.Json),
59
+ }) {
60
+ }
61
+ const request = (tag, options) => Rpc.make(tag, { ...options, error: SimulationRequestError });
62
+ export var Handshake;
63
+ (function (Handshake) {
64
+ Handshake.ProtocolVersion = Schema.Literal(1);
65
+ Handshake.Capability = Schema.NonEmptyString;
66
+ Handshake.EndpointRole = Schema.Literals(["ui", "backend"]);
67
+ Handshake.Identity = Schema.Struct({
68
+ name: Schema.NonEmptyString,
69
+ version: Schema.NonEmptyString,
70
+ });
71
+ Handshake.Params = Schema.Struct({
72
+ client: Handshake.Identity,
73
+ expectedRole: Handshake.EndpointRole,
74
+ offeredVersions: Schema.Array(Schema.Int.check(Schema.isGreaterThan(0))).check(Schema.isMinLength(1), Schema.isUnique()),
75
+ requiredCapabilities: Schema.Array(Handshake.Capability).check(Schema.isUnique()),
76
+ optionalCapabilities: Schema.Array(Handshake.Capability).check(Schema.isUnique()),
77
+ });
78
+ Handshake.Response = Schema.Struct({
79
+ protocolVersion: Handshake.ProtocolVersion,
80
+ role: Handshake.EndpointRole,
81
+ server: Handshake.Identity,
82
+ capabilities: Schema.Array(Handshake.Capability).check(Schema.isUnique()),
83
+ });
84
+ Handshake.Request = Schema.Struct({
85
+ ...JsonRpc.RequestFields,
86
+ method: Schema.Literal("simulation.handshake"),
87
+ params: Handshake.Params,
88
+ });
89
+ class RoleMismatchError extends Schema.TaggedError()("SimulationHandshake.RoleMismatchError", {
90
+ expected: Handshake.EndpointRole,
91
+ actual: Handshake.EndpointRole,
92
+ message: Schema.String,
93
+ }) {
94
+ }
95
+ Handshake.RoleMismatchError = RoleMismatchError;
96
+ class UnsupportedProtocolError extends Schema.TaggedError()("SimulationHandshake.UnsupportedProtocolError", {
97
+ offered: Schema.Array(Schema.Number),
98
+ supported: Schema.Array(Handshake.ProtocolVersion),
99
+ message: Schema.String,
100
+ }) {
101
+ }
102
+ Handshake.UnsupportedProtocolError = UnsupportedProtocolError;
103
+ class MissingCapabilityError extends Schema.TaggedError()("SimulationHandshake.MissingCapabilityError", {
104
+ missing: Schema.Array(Handshake.Capability),
105
+ message: Schema.String,
106
+ }) {
107
+ }
108
+ Handshake.MissingCapabilityError = MissingCapabilityError;
109
+ function dispatch(action, params) {
110
+ return Effect.gen(function* () {
111
+ if (params.expectedRole !== action.role) {
112
+ return yield* Effect.fail(new RoleMismatchError({
113
+ expected: params.expectedRole,
114
+ actual: action.role,
115
+ message: `Expected simulation endpoint role ${params.expectedRole}, received ${action.role}`,
116
+ }));
117
+ }
118
+ if (!params.offeredVersions.includes(1)) {
119
+ return yield* Effect.fail(new UnsupportedProtocolError({
120
+ offered: params.offeredVersions,
121
+ supported: [1],
122
+ message: "No mutually supported simulation protocol version",
123
+ }));
124
+ }
125
+ const installed = new Set(action.capabilities);
126
+ const missing = params.requiredCapabilities.filter((capability) => !installed.has(capability));
127
+ if (missing.length > 0) {
128
+ return yield* Effect.fail(new MissingCapabilityError({
129
+ missing,
130
+ message: `Simulation endpoint is missing required capabilities: ${missing.join(", ")}`,
131
+ }));
132
+ }
133
+ return {
134
+ protocolVersion: 1,
135
+ role: action.role,
136
+ server: action.server,
137
+ capabilities: Array.from(installed),
138
+ };
139
+ });
140
+ }
141
+ Handshake.dispatch = dispatch;
142
+ })(Handshake || (Handshake = {}));
143
+ export var Frontend;
144
+ (function (Frontend) {
145
+ Frontend.Capabilities = [
146
+ "ui.type",
147
+ "ui.press",
148
+ "ui.enter",
149
+ "ui.arrow",
150
+ "ui.focus",
151
+ "ui.click",
152
+ "ui.click.semantic",
153
+ "ui.mouse",
154
+ "ui.recording.pointer",
155
+ "ui.resize",
156
+ "ui.matches",
157
+ "ui.state",
158
+ "ui.snapshot",
159
+ "ui.capture",
160
+ "ui.recording.finish",
161
+ ];
162
+ Frontend.KeyModifiers = Schema.Struct({
163
+ ctrl: Schema.optional(Schema.Boolean),
164
+ shift: Schema.optional(Schema.Boolean),
165
+ meta: Schema.optional(Schema.Boolean),
166
+ super: Schema.optional(Schema.Boolean),
167
+ hyper: Schema.optional(Schema.Boolean),
168
+ });
169
+ Frontend.SemanticClickTarget = Schema.Struct({
170
+ id: Schema.NonEmptyString,
171
+ instance: Schema.optionalKey(Schema.NonEmptyString),
172
+ element: Schema.Number.check(Schema.isInt(), Schema.isGreaterThan(0)),
173
+ });
174
+ const MousePosition = {
175
+ x: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
176
+ y: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
177
+ modifiers: Schema.optionalKey(Schema.Struct({
178
+ shift: Schema.optionalKey(Schema.Boolean),
179
+ alt: Schema.optionalKey(Schema.Boolean),
180
+ ctrl: Schema.optionalKey(Schema.Boolean),
181
+ })),
182
+ };
183
+ Frontend.MouseParams = Schema.Union([
184
+ Schema.Struct({ ...MousePosition, action: Schema.Literal("move") }),
185
+ Schema.Struct({
186
+ ...MousePosition,
187
+ action: Schema.Literals(["down", "up"]),
188
+ button: Schema.optionalKey(Schema.Literals(["left", "middle", "right"])),
189
+ }),
190
+ Schema.Struct({
191
+ ...MousePosition,
192
+ action: Schema.Literal("scroll"),
193
+ direction: Schema.Literals(["up", "down", "left", "right"]),
194
+ }),
195
+ ]);
196
+ Frontend.Action = Schema.Union([
197
+ Schema.Struct({ type: Schema.Literal("ui.type"), text: Schema.String }),
198
+ Schema.Struct({ type: Schema.Literal("ui.press"), key: Schema.String, modifiers: Schema.optional(Frontend.KeyModifiers) }),
199
+ Schema.Struct({ type: Schema.Literal("ui.enter") }),
200
+ Schema.Struct({ type: Schema.Literal("ui.arrow"), direction: Schema.Literals(["up", "down", "left", "right"]) }),
201
+ Schema.Struct({ type: Schema.Literal("ui.focus"), target: Schema.Number }),
202
+ Schema.Struct({ type: Schema.Literal("ui.mouse"), params: Frontend.MouseParams }),
203
+ Schema.Struct({
204
+ type: Schema.Literal("ui.click"),
205
+ target: Schema.Number,
206
+ x: Schema.Number,
207
+ y: Schema.Number,
208
+ semantic: Schema.optionalKey(Frontend.SemanticClickTarget),
209
+ }),
210
+ Schema.Struct({ type: Schema.Literal("ui.resize"), cols: Schema.Number, rows: Schema.Number }),
211
+ ]);
212
+ Frontend.Element = Schema.Struct({
213
+ id: Schema.String,
214
+ num: Schema.Number,
215
+ x: Schema.Number,
216
+ y: Schema.Number,
217
+ width: Schema.Number,
218
+ height: Schema.Number,
219
+ focusable: Schema.Boolean,
220
+ focused: Schema.Boolean,
221
+ clickable: Schema.Boolean,
222
+ editor: Schema.Boolean,
223
+ });
224
+ Frontend.State = Schema.Struct({
225
+ focused: Schema.Struct({
226
+ renderable: Schema.optional(Schema.Number),
227
+ editor: Schema.Boolean,
228
+ }),
229
+ elements: Schema.Array(Frontend.Element),
230
+ });
231
+ Frontend.SemanticNode = Schema.Struct({
232
+ id: Schema.NonEmptyString,
233
+ instance: Schema.optionalKey(Schema.NonEmptyString),
234
+ parent: Schema.optionalKey(Schema.NonEmptyString),
235
+ role: Schema.NonEmptyString,
236
+ label: Schema.optionalKey(Schema.NonEmptyString),
237
+ element: Schema.Number.check(Schema.isInt(), Schema.isGreaterThan(0)),
238
+ focused: Schema.optionalKey(Schema.Boolean),
239
+ selected: Schema.optionalKey(Schema.Boolean),
240
+ expanded: Schema.optionalKey(Schema.Boolean),
241
+ disabled: Schema.optionalKey(Schema.Boolean),
242
+ });
243
+ Frontend.SemanticSnapshot = Schema.Struct({
244
+ format: Schema.Literal("opencode-ui-snapshot-v1"),
245
+ nodes: Schema.Array(Frontend.SemanticNode).check(Schema.makeFilter((nodes) => {
246
+ const ids = new Set(nodes.map((node) => node.id));
247
+ if (ids.size !== nodes.length)
248
+ return "semantic node ids must be unique";
249
+ if (new Set(nodes.map((node) => node.element)).size !== nodes.length)
250
+ return "semantic node elements must be unique";
251
+ if (nodes.some((node) => node.parent !== undefined && !ids.has(node.parent)))
252
+ return "semantic node parents must reference another node";
253
+ const parents = new Map(nodes.map((node) => [node.id, node.parent]));
254
+ for (const node of nodes) {
255
+ const visited = new Set();
256
+ let current = node.id;
257
+ while (current !== undefined) {
258
+ if (visited.has(current))
259
+ return "semantic node hierarchy must be acyclic";
260
+ visited.add(current);
261
+ current = parents.get(current);
262
+ }
263
+ }
264
+ return undefined;
265
+ })),
266
+ });
267
+ Frontend.Color = Schema.Tuple([Schema.Number, Schema.Number, Schema.Number, Schema.Number]);
268
+ Frontend.CapturedFrame = Schema.Struct({
269
+ cols: Schema.Number,
270
+ rows: Schema.Number,
271
+ cursor: Schema.Tuple([Schema.Number, Schema.Number]),
272
+ lines: Schema.Array(Schema.Struct({
273
+ spans: Schema.Array(Schema.Struct({
274
+ text: Schema.String,
275
+ fg: Frontend.Color,
276
+ bg: Frontend.Color,
277
+ attributes: Schema.Number,
278
+ width: Schema.Number,
279
+ })),
280
+ })),
281
+ });
282
+ Frontend.RecordingFinish = Schema.String;
283
+ Frontend.Matches = Schema.Boolean;
284
+ Frontend.TypeParams = Schema.Struct({ text: Schema.String });
285
+ Frontend.MatchesParams = Schema.Struct({ text: Schema.String });
286
+ Frontend.PressParams = Schema.Struct({ key: Schema.String, modifiers: Schema.optional(Frontend.KeyModifiers) });
287
+ Frontend.pressParams = (key, modifiers) => ({
288
+ key,
289
+ ...(modifiers === undefined ? {} : { modifiers }),
290
+ });
291
+ Frontend.ArrowParams = Schema.Struct({ direction: Schema.Literals(["up", "down", "left", "right"]) });
292
+ Frontend.FocusParams = Schema.Struct({ target: Schema.Number });
293
+ Frontend.ClickParams = Schema.Struct({
294
+ target: Schema.Number,
295
+ x: Schema.Number,
296
+ y: Schema.Number,
297
+ semantic: Schema.optionalKey(Frontend.SemanticClickTarget),
298
+ });
299
+ Frontend.ResizeParams = Schema.Struct({ cols: Schema.Number, rows: Schema.Number });
300
+ Frontend.Request = Schema.Union([
301
+ Handshake.Request,
302
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("ui.type"), params: Frontend.TypeParams }),
303
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("ui.press"), params: Frontend.PressParams }),
304
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("ui.arrow"), params: Frontend.ArrowParams }),
305
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("ui.focus"), params: Frontend.FocusParams }),
306
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("ui.click"), params: Frontend.ClickParams }),
307
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("ui.mouse"), params: Frontend.MouseParams }),
308
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("ui.resize"), params: Frontend.ResizeParams }),
309
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("ui.matches"), params: Frontend.MatchesParams }),
310
+ Schema.Struct({
311
+ ...JsonRpc.RequestFields,
312
+ method: Schema.Literals(["ui.enter", "ui.state", "ui.snapshot", "ui.recording.finish"]),
313
+ }),
314
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("ui.capture") }),
315
+ ]);
316
+ Frontend.decodeRequest = Schema.decodeUnknownSync(Frontend.Request);
317
+ Frontend.decodeRequestEffect = Schema.decodeUnknownEffect(Schema.fromJsonString(Frontend.Request));
318
+ })(Frontend || (Frontend = {}));
319
+ export var Backend;
320
+ (function (Backend) {
321
+ Backend.Capabilities = [
322
+ "llm.attach",
323
+ "llm.chunk",
324
+ "llm.finish",
325
+ "llm.disconnect",
326
+ "llm.pending",
327
+ "llm.request",
328
+ "llm.tool-input-delta",
329
+ "tool.attach",
330
+ "tool.update",
331
+ "tool.finish",
332
+ "tool.fail",
333
+ "tool.invocation",
334
+ "tool.cancel",
335
+ ];
336
+ Backend.Item = Schema.Union([
337
+ Schema.Struct({ type: Schema.Literal("textDelta"), text: Schema.String }),
338
+ Schema.Struct({ type: Schema.Literal("reasoningDelta"), text: Schema.String }),
339
+ Schema.Struct({
340
+ type: Schema.Literal("toolInputStart"),
341
+ index: Schema.Number,
342
+ id: Schema.String,
343
+ name: Schema.String,
344
+ }),
345
+ Schema.Struct({
346
+ type: Schema.Literal("toolInputDelta"),
347
+ index: Schema.Number,
348
+ text: Schema.String,
349
+ }),
350
+ Schema.Struct({
351
+ type: Schema.Literal("toolCall"),
352
+ index: Schema.Number,
353
+ id: Schema.String,
354
+ name: Schema.String,
355
+ input: Schema.Json,
356
+ }),
357
+ Schema.Struct({ type: Schema.Literal("raw"), chunk: Schema.Json }),
358
+ ]);
359
+ Backend.FinishReason = Schema.Literals(["stop", "tool-calls", "length", "content-filter"]);
360
+ Backend.ToolContent = Schema.Union([
361
+ Schema.Struct({ type: Schema.Literal("text"), text: Schema.String }),
362
+ Schema.Struct({
363
+ type: Schema.Literal("file"),
364
+ data: Schema.String,
365
+ mime: Schema.NonEmptyString,
366
+ name: Schema.optionalKey(Schema.String),
367
+ }),
368
+ ]);
369
+ const ProviderSafeName = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
370
+ const ToolName = Schema.NonEmptyString.check(Schema.makeFilter((name) => ProviderSafeName.test(name) ? undefined : "simulated tool names must be provider-safe"));
371
+ const ToolNamespace = Schema.NonEmptyString.check(Schema.makeFilter((namespace) => namespace.split(".").every((segment) => ProviderSafeName.test(segment))
372
+ ? undefined
373
+ : "simulated tool namespaces must contain provider-safe segments"));
374
+ Backend.ToolRegistration = Schema.Struct({
375
+ name: ToolName,
376
+ description: Schema.String,
377
+ inputSchema: Schema.Record(Schema.String, Schema.Json),
378
+ outputSchema: Schema.optionalKey(Schema.Record(Schema.String, Schema.Json)),
379
+ permission: Schema.optionalKey(Schema.NonEmptyString),
380
+ options: Schema.optionalKey(Schema.Struct({
381
+ namespace: Schema.optionalKey(ToolNamespace),
382
+ codemode: Schema.optionalKey(Schema.Boolean),
383
+ })),
384
+ });
385
+ Backend.ToolAttachParams = Schema.Struct({
386
+ tools: Schema.Array(Backend.ToolRegistration).check(Schema.makeFilter((tools) => {
387
+ const names = tools.map(exposedToolName);
388
+ if (names.some((name) => !ProviderSafeName.test(name)))
389
+ return "simulated tool names including namespaces must be provider-safe";
390
+ if (new Set(names).size !== names.length)
391
+ return "simulated tool registrations must have unique exposed names";
392
+ if (tools.some((tool) => tool.name === "execute" && tool.options?.namespace === undefined && tool.options?.codemode === false))
393
+ return 'direct simulated tool name "execute" is reserved';
394
+ return undefined;
395
+ })),
396
+ });
397
+ function exposedToolName(registration) {
398
+ return registration.options?.namespace === undefined
399
+ ? registration.name
400
+ : `${registration.options.namespace.replaceAll(".", "_")}_${registration.name}`;
401
+ }
402
+ Backend.exposedToolName = exposedToolName;
403
+ Backend.ToolProgress = Schema.Record(Schema.String, Schema.Json);
404
+ Backend.ToolOutput = Schema.Struct({
405
+ structured: Schema.Json,
406
+ content: Schema.Array(Backend.ToolContent),
407
+ });
408
+ Backend.ToolUpdateParams = Schema.Struct({
409
+ id: Schema.String,
410
+ sequence: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
411
+ update: Backend.ToolProgress,
412
+ });
413
+ Backend.ToolFinishParams = Schema.Struct({ id: Schema.String, output: Backend.ToolOutput });
414
+ Backend.ToolFailParams = Schema.Struct({ id: Schema.String, message: Schema.String });
415
+ Backend.ToolInvocation = Schema.Struct({
416
+ id: Schema.String,
417
+ name: Schema.String,
418
+ input: Schema.Json,
419
+ context: Schema.Struct({
420
+ sessionID: Schema.String,
421
+ agent: Schema.String,
422
+ messageID: Schema.String,
423
+ id: Schema.String,
424
+ }),
425
+ });
426
+ Backend.ToolCancellation = Schema.Struct({
427
+ id: Schema.String,
428
+ reason: Schema.Literal("interrupted"),
429
+ });
430
+ Backend.Attached = Schema.Struct({ attached: Schema.Literal(true) });
431
+ Backend.Ok = Schema.Struct({ ok: Schema.Literal(true) });
432
+ Backend.ChunkParams = Schema.Struct({ id: Schema.String, items: Schema.Array(Backend.Item) });
433
+ Backend.FinishParams = Schema.Struct({
434
+ id: Schema.String,
435
+ reason: Backend.FinishReason.pipe(Schema.withDecodingDefault(Effect.succeed("stop"))),
436
+ });
437
+ Backend.FinishPayload = Schema.Struct({
438
+ id: Schema.String,
439
+ reason: Schema.optionalKey(Backend.FinishReason),
440
+ });
441
+ Backend.DisconnectParams = Schema.Struct({ id: Schema.String });
442
+ Backend.Request = Schema.Union([
443
+ Handshake.Request,
444
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("llm.chunk"), params: Backend.ChunkParams }),
445
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("llm.finish"), params: Backend.FinishParams }),
446
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("llm.disconnect"), params: Backend.DisconnectParams }),
447
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("tool.attach"), params: Backend.ToolAttachParams }),
448
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("tool.update"), params: Backend.ToolUpdateParams }),
449
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("tool.finish"), params: Backend.ToolFinishParams }),
450
+ Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("tool.fail"), params: Backend.ToolFailParams }),
451
+ Schema.Struct({
452
+ ...JsonRpc.RequestFields,
453
+ method: Schema.Literals(["llm.attach", "llm.pending"]),
454
+ }),
455
+ ]);
456
+ Backend.decodeRequest = Schema.decodeUnknownSync(Backend.Request);
457
+ Backend.decodeRequestEffect = Schema.decodeUnknownEffect(Schema.fromJsonString(Backend.Request));
458
+ Backend.ProviderInvocation = Schema.Struct({ id: Schema.String, url: Schema.String, body: Schema.Json });
459
+ Backend.Pending = Schema.Struct({ invocations: Schema.Array(Backend.ProviderInvocation) });
460
+ Backend.NetworkLogEntry = Schema.Struct({
461
+ time: Schema.Number,
462
+ method: Schema.String,
463
+ url: Schema.String,
464
+ matched: Schema.Boolean,
465
+ });
466
+ Backend.Notification = Schema.Union([
467
+ Schema.Struct({
468
+ jsonrpc: Schema.Literal("2.0"),
469
+ method: Schema.Literal("llm.request"),
470
+ params: Backend.ProviderInvocation,
471
+ }),
472
+ Schema.Struct({
473
+ jsonrpc: Schema.Literal("2.0"),
474
+ method: Schema.Literal("tool.invocation"),
475
+ params: Backend.ToolInvocation,
476
+ }),
477
+ Schema.Struct({
478
+ jsonrpc: Schema.Literal("2.0"),
479
+ method: Schema.Literal("tool.cancel"),
480
+ params: Backend.ToolCancellation,
481
+ }),
482
+ ]);
483
+ Backend.decodeNotification = Schema.decodeUnknownSync(Backend.Notification);
484
+ Backend.decodeNotificationEffect = Schema.decodeUnknownEffect(Schema.fromJsonString(Backend.Notification));
485
+ })(Backend || (Backend = {}));
486
+ export const UiRpcs = RpcGroup.make(request("simulation.handshake", { payload: Handshake.Params, success: Handshake.Response }), request("ui.state", { success: Frontend.State }), request("ui.snapshot", { success: Frontend.SemanticSnapshot }), request("ui.capture", { success: Frontend.CapturedFrame }), request("ui.matches", { payload: Frontend.MatchesParams, success: Frontend.Matches }), request("ui.recording.finish", { success: Frontend.RecordingFinish }), request("ui.type", { payload: Frontend.TypeParams, success: Frontend.State }), request("ui.press", { payload: Frontend.PressParams, success: Frontend.State }), request("ui.enter", { success: Frontend.State }), request("ui.arrow", { payload: Frontend.ArrowParams, success: Frontend.State }), request("ui.focus", { payload: Frontend.FocusParams, success: Frontend.State }), request("ui.click", { payload: Frontend.ClickParams, success: Frontend.State }), request("ui.mouse", { payload: Frontend.MouseParams, success: Frontend.State }), request("ui.resize", { payload: Frontend.ResizeParams, success: Frontend.State }));
487
+ export const BackendRpcs = RpcGroup.make(request("simulation.handshake", { payload: Handshake.Params, success: Handshake.Response }), request("llm.attach", { success: Backend.Attached }), request("llm.pending", { success: Backend.Pending }), request("llm.chunk", { payload: Backend.ChunkParams, success: Backend.Ok }), request("llm.finish", { payload: Backend.FinishPayload, success: Backend.Ok }), request("llm.disconnect", { payload: Backend.DisconnectParams, success: Backend.Ok }), request("tool.attach", { payload: Backend.ToolAttachParams, success: Backend.Attached }), request("tool.update", { payload: Backend.ToolUpdateParams, success: Backend.Ok }), request("tool.finish", { payload: Backend.ToolFinishParams, success: Backend.Ok }), request("tool.fail", { payload: Backend.ToolFailParams, success: Backend.Ok }));
package/package.json CHANGED
@@ -1,15 +1,45 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package.json",
2
3
  "name": "@opencode/protocol",
3
- "version": "0.0.0-reserved",
4
- "description": "OpenCode package bootstrap — not a functional release",
4
+ "version": "2.0.0",
5
+ "type": "module",
5
6
  "license": "MIT",
6
7
  "repository": {
7
8
  "type": "git",
8
- "url": "git+https://github.com/anomalyco/opencode.git"
9
+ "url": "git+https://github.com/anomalyco/opencode.git",
10
+ "directory": "packages/protocol"
9
11
  },
10
12
  "publishConfig": {
11
- "registry": "https://registry.npmjs.org",
12
- "access": "public",
13
- "tag": "reserved"
13
+ "access": "public"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "exports": {
19
+ "./simulation": {
20
+ "import": "./dist/simulation.js",
21
+ "types": "./dist/simulation.d.ts"
22
+ },
23
+ "./*": {
24
+ "import": "./dist/*.js",
25
+ "types": "./dist/*.d.ts"
26
+ }
27
+ },
28
+ "scripts": {
29
+ "build": "bun run script/build.ts",
30
+ "generate": "bun run script/generate-openapi.ts",
31
+ "check:generated": "bun run script/generate-openapi.ts --check",
32
+ "typecheck": "tsgo --noEmit"
33
+ },
34
+ "dependencies": {
35
+ "@opencode/schema": "2.0.0",
36
+ "effect": "4.0.0-rc.112"
37
+ },
38
+ "devDependencies": {
39
+ "@tsconfig/bun": "1.0.9",
40
+ "@types/bun": "1.4.0",
41
+ "@typescript/native-preview": "7.0.0-dev.20251207.1",
42
+ "prettier": "3.6.2",
43
+ "typescript": "5.8.2"
14
44
  }
15
45
  }
package/README.md DELETED
@@ -1,5 +0,0 @@
1
- # @opencode/protocol
2
-
3
- Bootstrap placeholder for the official [OpenCode](https://opencode.ai) release pipeline.
4
-
5
- This version contains no implementation or executable. Do not use it as a functional release.