@opencode-ai/protocol 0.0.0-next-14854 → 0.0.0-reserved.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 (63) hide show
  1. package/README.md +3 -0
  2. package/index.js +1 -0
  3. package/package.json +3 -23
  4. package/dist/api.d.ts +0 -49
  5. package/dist/api.js +0 -65
  6. package/dist/client.d.ts +0 -75
  7. package/dist/client.js +0 -61
  8. package/dist/errors.d.ts +0 -127
  9. package/dist/errors.js +0 -99
  10. package/dist/groups/agent.d.ts +0 -95
  11. package/dist/groups/agent.js +0 -15
  12. package/dist/groups/command.d.ts +0 -51
  13. package/dist/groups/command.js +0 -20
  14. package/dist/groups/credential.d.ts +0 -23
  15. package/dist/groups/credential.js +0 -28
  16. package/dist/groups/event.d.ts +0 -17224
  17. package/dist/groups/event.js +0 -49
  18. package/dist/groups/form.d.ts +0 -789
  19. package/dist/groups/form.js +0 -99
  20. package/dist/groups/fs.d.ts +0 -35
  21. package/dist/groups/fs.js +0 -51
  22. package/dist/groups/generate.d.ts +0 -32
  23. package/dist/groups/generate.js +0 -27
  24. package/dist/groups/health.d.ts +0 -5
  25. package/dist/groups/health.js +0 -9
  26. package/dist/groups/integration.d.ts +0 -105
  27. package/dist/groups/integration.js +0 -98
  28. package/dist/groups/location.d.ts +0 -16
  29. package/dist/groups/location.js +0 -32
  30. package/dist/groups/mcp.d.ts +0 -30
  31. package/dist/groups/mcp.js +0 -17
  32. package/dist/groups/message.d.ts +0 -446
  33. package/dist/groups/message.js +0 -42
  34. package/dist/groups/model.d.ts +0 -312
  35. package/dist/groups/model.js +0 -33
  36. package/dist/groups/permission.d.ts +0 -153
  37. package/dist/groups/permission.js +0 -99
  38. package/dist/groups/plugin.d.ts +0 -14
  39. package/dist/groups/plugin.js +0 -20
  40. package/dist/groups/project-copy.d.ts +0 -49
  41. package/dist/groups/project-copy.js +0 -44
  42. package/dist/groups/project.d.ts +0 -24
  43. package/dist/groups/project.js +0 -30
  44. package/dist/groups/provider.d.ts +0 -164
  45. package/dist/groups/provider.js +0 -34
  46. package/dist/groups/pty.d.ts +0 -145
  47. package/dist/groups/pty.js +0 -111
  48. package/dist/groups/question.d.ts +0 -92
  49. package/dist/groups/question.js +0 -56
  50. package/dist/groups/reference.d.ts +0 -13
  51. package/dist/groups/reference.js +0 -20
  52. package/dist/groups/session.d.ts +0 -5457
  53. package/dist/groups/session.js +0 -423
  54. package/dist/groups/shell.d.ts +0 -120
  55. package/dist/groups/shell.js +0 -65
  56. package/dist/groups/skill.d.ts +0 -19
  57. package/dist/groups/skill.js +0 -20
  58. package/dist/groups/vcs.d.ts +0 -33
  59. package/dist/groups/vcs.js +0 -37
  60. package/dist/middleware/authorization.d.ts +0 -13
  61. package/dist/middleware/authorization.js +0 -6
  62. package/dist/middleware/schema-error.d.ts +0 -13
  63. package/dist/middleware/schema-error.js +0 -4
@@ -1,423 +0,0 @@
1
- import { SessionMessage } from "@opencode-ai/schema/session-message";
2
- import { SessionInput } from "@opencode-ai/schema/session-input";
3
- import { PromptInput } from "@opencode-ai/schema/prompt-input";
4
- import { Session } from "@opencode-ai/schema/session";
5
- import { SessionContextEntry } from "@opencode-ai/schema/session-context-entry";
6
- import { Project } from "@opencode-ai/schema/project";
7
- import { AbsolutePath, PositiveInt, RelativePath, statics } from "@opencode-ai/schema/schema";
8
- import { Event } from "@opencode-ai/schema/event";
9
- import { Workspace } from "@opencode-ai/schema/workspace";
10
- import { Context, Effect, Encoding, Result, Schema, SchemaGetter, Struct } from "effect";
11
- import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
12
- import { ConflictError, CommandEvaluationError, CommandNotFoundError, InvalidCursorError, InvalidRequestError, MessageNotFoundError, ServiceUnavailableError, SessionBusyError, SessionNotFoundError, SkillNotFoundError, UnknownError, } from "../errors.js";
13
- import { Agent } from "@opencode-ai/schema/agent";
14
- import { Model } from "@opencode-ai/schema/model";
15
- import { Location } from "@opencode-ai/schema/location";
16
- import { Revert } from "@opencode-ai/schema/revert";
17
- import { SessionEvent } from "@opencode-ai/schema/session-event";
18
- import { EventLog } from "@opencode-ai/schema/event-log";
19
- const ParentIDFilter = Schema.Union([
20
- Session.ID,
21
- Schema.Null.pipe(Schema.encodeTo(Schema.Literal("null"), {
22
- decode: SchemaGetter.transform(() => null),
23
- encode: SchemaGetter.transform(() => "null"),
24
- })),
25
- ]).annotate({
26
- description: "Filter by parent session. Use null to return only root sessions.",
27
- });
28
- const SessionsQueryFields = {
29
- workspace: Workspace.ID.pipe(Schema.optional),
30
- limit: Schema.NumberFromString.pipe(Schema.decodeTo(PositiveInt), Schema.optional).annotate({
31
- description: "Maximum number of sessions to return. Defaults to the newest 50 sessions.",
32
- }),
33
- order: Schema.optional(Schema.Union([Schema.Literal("asc"), Schema.Literal("desc")])).annotate({
34
- description: "Session order for the first page. Use desc for newest first or asc for oldest first.",
35
- }),
36
- search: Schema.optional(Schema.String),
37
- parentID: ParentIDFilter.pipe(Schema.optional),
38
- };
39
- const SessionsDirectoryQuery = Schema.Struct({
40
- ...SessionsQueryFields,
41
- directory: AbsolutePath,
42
- });
43
- const SessionsProjectQuery = Schema.Struct({
44
- ...SessionsQueryFields,
45
- project: Project.ID,
46
- subpath: RelativePath.pipe(Schema.optional),
47
- });
48
- const SessionsAllQuery = Schema.Struct(SessionsQueryFields);
49
- const withCursor = (schema) => schema.mapFields((fields) => ({
50
- ...Struct.omit(fields, ["limit"]),
51
- anchor: Session.ListAnchor,
52
- }));
53
- const SessionsCursorInput = Schema.Union([
54
- withCursor(SessionsDirectoryQuery),
55
- withCursor(SessionsProjectQuery),
56
- withCursor(SessionsAllQuery),
57
- ]);
58
- const SessionsCursorJson = Schema.fromJsonString(SessionsCursorInput);
59
- const encodeSessionsCursor = Schema.encodeSync(SessionsCursorJson);
60
- const decodeSessionsCursor = Schema.decodeUnknownEffect(SessionsCursorJson);
61
- const invalidCursor = "Invalid cursor";
62
- export const SessionsCursor = Schema.String.pipe(Schema.brand("SessionsCursor"), statics((schema) => {
63
- const make = schema.make.bind(schema);
64
- return {
65
- make: (input) => make(Encoding.encodeBase64Url(encodeSessionsCursor(input))),
66
- parse: (input) => Effect.suspend(() => {
67
- const result = Encoding.decodeBase64UrlString(input);
68
- return Result.isFailure(result)
69
- ? Effect.fail(invalidCursor)
70
- : decodeSessionsCursor(result.success).pipe(Effect.mapError(() => invalidCursor));
71
- }),
72
- };
73
- }));
74
- const SessionActive = Schema.Struct({
75
- type: Schema.Literal("running"),
76
- }).annotate({ identifier: "SessionActive" });
77
- const SessionWatermarks = Schema.Record(Session.ID, Event.Seq).annotate({
78
- identifier: "SessionWatermarks",
79
- description: "Durable log seq each session's snapshot was computed at. Attach a live log read after the watermark to compose fetch and stream gap-free; apply a snapshot only where its watermark is at or beyond already-applied events. Sessions without durable events are absent.",
80
- });
81
- const BooleanFromString = Schema.Literals(["true", "false"]).pipe(Schema.decodeTo(Schema.Boolean, {
82
- decode: SchemaGetter.transform((value) => value === "true"),
83
- encode: SchemaGetter.transform((value) => (value ? "true" : "false")),
84
- }));
85
- const SessionsQueryCursor = SessionsCursor.annotate({
86
- description: "Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.",
87
- });
88
- export const SessionsQuery = Schema.Struct({
89
- ...SessionsQueryFields,
90
- directory: AbsolutePath.pipe(Schema.optional),
91
- project: Project.ID.pipe(Schema.optional),
92
- subpath: RelativePath.pipe(Schema.optional),
93
- cursor: SessionsQueryCursor.pipe(Schema.optional),
94
- }).annotate({ identifier: "SessionsQuery" });
95
- export const makeSessionGroup = (sessionLocationMiddleware) => HttpApiGroup.make("server.session")
96
- .add(HttpApiEndpoint.get("session.list", "/api/session", {
97
- query: SessionsQuery,
98
- success: Schema.Struct({
99
- data: Schema.Array(Session.Info),
100
- watermarks: SessionWatermarks,
101
- cursor: Schema.Struct({
102
- previous: SessionsCursor.pipe(Schema.optional),
103
- next: SessionsCursor.pipe(Schema.optional),
104
- }),
105
- }).annotate({ identifier: "SessionsResponse" }),
106
- error: [InvalidCursorError, InvalidRequestError],
107
- }).annotateMerge(OpenApi.annotations({
108
- identifier: "v2.session.list",
109
- summary: "List sessions",
110
- description: "Retrieve sessions in the requested order. Items keep that order across pages; use cursor.next or cursor.previous to move through the ordered list.",
111
- })))
112
- .add(HttpApiEndpoint.post("session.create", "/api/session", {
113
- payload: Schema.Struct({
114
- id: Session.ID.pipe(Schema.optional),
115
- agent: Agent.ID.pipe(Schema.optional),
116
- model: Model.Ref.pipe(Schema.optional),
117
- location: Location.Ref.pipe(Schema.optional),
118
- }),
119
- success: Schema.Struct({ data: Session.Info }),
120
- }).annotateMerge(OpenApi.annotations({
121
- identifier: "v2.session.create",
122
- summary: "Create session",
123
- description: "Create a session at the requested location.",
124
- })))
125
- .add(HttpApiEndpoint.get("session.active", "/api/session/active", {
126
- success: Schema.Struct({ data: Schema.Record(Session.ID, SessionActive), watermarks: SessionWatermarks }),
127
- }).annotateMerge(OpenApi.annotations({
128
- identifier: "v2.session.active",
129
- summary: "List active sessions",
130
- description: "Retrieve foreground Session drains currently owned by this OpenCode process. Sessions absent from the result are inactive. Watermarks are the durable log positions read alongside the activity snapshot; activity itself is process state, so the pairing is advisory rather than transactional.",
131
- })))
132
- .add(HttpApiEndpoint.get("session.get", "/api/session/:sessionID", {
133
- params: { sessionID: Session.ID },
134
- success: Schema.Struct({ data: Session.Info }),
135
- error: SessionNotFoundError,
136
- })
137
- .middleware(sessionLocationMiddleware)
138
- .annotateMerge(OpenApi.annotations({
139
- identifier: "v2.session.get",
140
- summary: "Get session",
141
- description: "Retrieve a session by ID.",
142
- })))
143
- .add(HttpApiEndpoint.post("session.fork", "/api/session/:sessionID/fork", {
144
- params: { sessionID: Session.ID },
145
- payload: Schema.Struct({ messageID: SessionMessage.ID.pipe(Schema.optional) }),
146
- success: Schema.Struct({ data: Session.Info }),
147
- error: [SessionNotFoundError, MessageNotFoundError],
148
- })
149
- .middleware(sessionLocationMiddleware)
150
- .annotateMerge(OpenApi.annotations({
151
- identifier: "v2.session.fork",
152
- summary: "Fork session",
153
- description: "Create a child session by copying projected history from the parent. When messageID is supplied, copy messages before that boundary.",
154
- })))
155
- .add(HttpApiEndpoint.post("session.switchAgent", "/api/session/:sessionID/agent", {
156
- params: { sessionID: Session.ID },
157
- payload: Schema.Struct({ agent: Agent.ID }),
158
- success: HttpApiSchema.NoContent,
159
- error: SessionNotFoundError,
160
- })
161
- .middleware(sessionLocationMiddleware)
162
- .annotateMerge(OpenApi.annotations({
163
- identifier: "v2.session.switchAgent",
164
- summary: "Switch session agent",
165
- description: "Switch the agent used by subsequent provider turns.",
166
- })))
167
- .add(HttpApiEndpoint.post("session.switchModel", "/api/session/:sessionID/model", {
168
- params: { sessionID: Session.ID },
169
- payload: Schema.Struct({ model: Model.Ref }),
170
- success: HttpApiSchema.NoContent,
171
- error: SessionNotFoundError,
172
- })
173
- .middleware(sessionLocationMiddleware)
174
- .annotateMerge(OpenApi.annotations({
175
- identifier: "v2.session.switchModel",
176
- summary: "Switch session model",
177
- description: "Switch the model used by subsequent provider turns.",
178
- })))
179
- .add(HttpApiEndpoint.post("session.rename", "/api/session/:sessionID/rename", {
180
- params: { sessionID: Session.ID },
181
- payload: Schema.Struct({ title: Schema.String }),
182
- success: HttpApiSchema.NoContent,
183
- error: SessionNotFoundError,
184
- })
185
- .middleware(sessionLocationMiddleware)
186
- .annotateMerge(OpenApi.annotations({
187
- identifier: "v2.session.rename",
188
- summary: "Rename session",
189
- description: "Update the session title.",
190
- })))
191
- .add(HttpApiEndpoint.post("session.prompt", "/api/session/:sessionID/prompt", {
192
- params: { sessionID: Session.ID },
193
- payload: Schema.Struct({
194
- id: SessionMessage.ID.pipe(Schema.optional),
195
- prompt: PromptInput.Prompt,
196
- delivery: SessionInput.Delivery.pipe(Schema.optional),
197
- resume: Schema.Boolean.pipe(Schema.optional),
198
- }),
199
- success: Schema.Struct({ data: SessionInput.Admitted }),
200
- error: [ConflictError, SessionNotFoundError],
201
- })
202
- .middleware(sessionLocationMiddleware)
203
- .annotateMerge(OpenApi.annotations({
204
- identifier: "v2.session.prompt",
205
- summary: "Send message",
206
- description: "Durably admit one session input and schedule agent-loop execution unless resume is false.",
207
- })))
208
- .add(HttpApiEndpoint.post("session.command", "/api/session/:sessionID/command", {
209
- params: { sessionID: Session.ID },
210
- payload: Schema.Struct({
211
- id: SessionMessage.ID.pipe(Schema.optional),
212
- command: Schema.String,
213
- arguments: Schema.String.pipe(Schema.optional),
214
- agent: Schema.String.pipe(Schema.optional),
215
- model: Model.Ref.pipe(Schema.optional),
216
- files: PromptInput.Prompt.fields.files,
217
- agents: PromptInput.Prompt.fields.agents,
218
- delivery: SessionInput.Delivery.pipe(Schema.optional),
219
- resume: Schema.Boolean.pipe(Schema.optional),
220
- }),
221
- success: Schema.Struct({ data: SessionInput.Admitted }),
222
- error: [ConflictError, SessionNotFoundError, CommandNotFoundError, CommandEvaluationError],
223
- })
224
- .middleware(sessionLocationMiddleware)
225
- .annotateMerge(OpenApi.annotations({
226
- identifier: "v2.session.command",
227
- summary: "Run command",
228
- description: "Resolve a slash command into prompt input, admit it durably, and schedule execution unless resume is false.",
229
- })))
230
- .add(HttpApiEndpoint.post("session.skill", "/api/session/:sessionID/skill", {
231
- params: { sessionID: Session.ID },
232
- payload: Schema.Struct({
233
- id: SessionMessage.ID.pipe(Schema.optional),
234
- skill: Schema.String,
235
- resume: Schema.Boolean.pipe(Schema.optional),
236
- }),
237
- success: HttpApiSchema.NoContent,
238
- error: [SessionNotFoundError, SkillNotFoundError],
239
- })
240
- .middleware(sessionLocationMiddleware)
241
- .annotateMerge(OpenApi.annotations({
242
- identifier: "v2.session.skill",
243
- summary: "Activate skill",
244
- description: "Activate a skill for a session by appending a skill message and resuming execution.",
245
- })))
246
- .add(HttpApiEndpoint.post("session.synthetic", "/api/session/:sessionID/synthetic", {
247
- params: { sessionID: Session.ID },
248
- payload: Schema.Struct({
249
- text: Schema.String,
250
- description: Schema.String.pipe(Schema.optional),
251
- metadata: SessionMessage.Synthetic.fields.metadata,
252
- }),
253
- success: HttpApiSchema.NoContent,
254
- error: SessionNotFoundError,
255
- })
256
- .middleware(sessionLocationMiddleware)
257
- .annotateMerge(OpenApi.annotations({
258
- identifier: "v2.session.synthetic",
259
- summary: "Add synthetic message",
260
- description: "Append a synthetic message to a session and resume execution.",
261
- })))
262
- .add(HttpApiEndpoint.post("session.shell", "/api/session/:sessionID/shell", {
263
- params: { sessionID: Session.ID },
264
- payload: Schema.Struct({
265
- id: Event.ID.pipe(Schema.optional),
266
- command: Schema.String,
267
- }),
268
- success: HttpApiSchema.NoContent,
269
- error: SessionNotFoundError,
270
- })
271
- .middleware(sessionLocationMiddleware)
272
- .annotateMerge(OpenApi.annotations({
273
- identifier: "v2.session.shell",
274
- summary: "Run shell command",
275
- description: "Execute one shell command in the session's working directory. Emits a shell.started event before execution and a shell.ended event with the merged output after.",
276
- })))
277
- .add(HttpApiEndpoint.post("session.compact", "/api/session/:sessionID/compact", {
278
- params: { sessionID: Session.ID },
279
- success: HttpApiSchema.NoContent,
280
- error: [SessionNotFoundError, SessionBusyError, ServiceUnavailableError, UnknownError],
281
- })
282
- .middleware(sessionLocationMiddleware)
283
- .annotateMerge(OpenApi.annotations({
284
- identifier: "v2.session.compact",
285
- summary: "Compact session",
286
- description: "Compact a session conversation.",
287
- })))
288
- .add(HttpApiEndpoint.post("session.wait", "/api/session/:sessionID/wait", {
289
- params: { sessionID: Session.ID },
290
- success: HttpApiSchema.NoContent,
291
- error: [SessionNotFoundError, ServiceUnavailableError],
292
- })
293
- .middleware(sessionLocationMiddleware)
294
- .annotateMerge(OpenApi.annotations({
295
- identifier: "v2.session.wait",
296
- summary: "Wait for session",
297
- description: "Wait for a session agent loop to become idle.",
298
- })))
299
- .add(HttpApiEndpoint.post("session.revert.stage", "/api/session/:sessionID/revert/stage", {
300
- params: { sessionID: Session.ID },
301
- payload: Schema.Struct({ messageID: SessionMessage.ID, files: Schema.Boolean.pipe(Schema.optional) }),
302
- success: Schema.Struct({ data: Revert.State }),
303
- error: [MessageNotFoundError, SessionNotFoundError, SessionBusyError, UnknownError],
304
- })
305
- .middleware(sessionLocationMiddleware)
306
- .annotateMerge(OpenApi.annotations({
307
- identifier: "v2.session.revert.stage",
308
- summary: "Stage session revert",
309
- description: "Stage or move a reversible session boundary and optionally apply its file changes.",
310
- })))
311
- .add(HttpApiEndpoint.post("session.revert.clear", "/api/session/:sessionID/revert/clear", {
312
- params: { sessionID: Session.ID },
313
- success: HttpApiSchema.NoContent,
314
- error: [SessionNotFoundError, SessionBusyError, UnknownError],
315
- })
316
- .middleware(sessionLocationMiddleware)
317
- .annotateMerge(OpenApi.annotations({ identifier: "v2.session.revert.clear", summary: "Clear staged revert" })))
318
- .add(HttpApiEndpoint.post("session.revert.commit", "/api/session/:sessionID/revert/commit", {
319
- params: { sessionID: Session.ID },
320
- success: HttpApiSchema.NoContent,
321
- error: [SessionNotFoundError, SessionBusyError],
322
- })
323
- .middleware(sessionLocationMiddleware)
324
- .annotateMerge(OpenApi.annotations({ identifier: "v2.session.revert.commit", summary: "Commit staged revert" })))
325
- .add(HttpApiEndpoint.get("session.context", "/api/session/:sessionID/context", {
326
- params: { sessionID: Session.ID },
327
- success: Schema.Struct({ data: Schema.Array(SessionMessage.Message) }),
328
- error: [SessionNotFoundError, UnknownError],
329
- })
330
- .middleware(sessionLocationMiddleware)
331
- .annotateMerge(OpenApi.annotations({
332
- identifier: "v2.session.context",
333
- summary: "Get session context",
334
- description: "Retrieve the active context messages for a session (all messages after the last compaction).",
335
- })))
336
- .add(HttpApiEndpoint.get("session.context.entry.list", "/api/session/:sessionID/context-entry", {
337
- params: { sessionID: Session.ID },
338
- success: Schema.Struct({ data: Schema.Array(SessionContextEntry.Info) }),
339
- error: SessionNotFoundError,
340
- })
341
- .middleware(sessionLocationMiddleware)
342
- .annotateMerge(OpenApi.annotations({
343
- identifier: "v2.session.context.entry.list",
344
- summary: "List context entries",
345
- description: "List API-managed context entries attached to the session's system context.",
346
- })))
347
- .add(HttpApiEndpoint.put("session.context.entry.put", "/api/session/:sessionID/context-entry/:key", {
348
- params: { sessionID: Session.ID, key: SessionContextEntry.Key },
349
- payload: Schema.Struct({ value: Schema.Json }),
350
- success: HttpApiSchema.NoContent,
351
- error: SessionNotFoundError,
352
- })
353
- .middleware(sessionLocationMiddleware)
354
- .annotateMerge(OpenApi.annotations({
355
- identifier: "v2.session.context.entry.put",
356
- summary: "Put context entry",
357
- description: "Attach or replace one durable context entry. The value is rendered into the session's system context; changes announce as updates at the next turn boundary.",
358
- })))
359
- .add(HttpApiEndpoint.delete("session.context.entry.remove", "/api/session/:sessionID/context-entry/:key", {
360
- params: { sessionID: Session.ID, key: SessionContextEntry.Key },
361
- success: HttpApiSchema.NoContent,
362
- error: SessionNotFoundError,
363
- })
364
- .middleware(sessionLocationMiddleware)
365
- .annotateMerge(OpenApi.annotations({
366
- identifier: "v2.session.context.entry.remove",
367
- summary: "Remove context entry",
368
- description: "Remove one context entry; the removal is announced to the model at the next turn boundary.",
369
- })))
370
- .add(HttpApiEndpoint.get("session.log", "/api/session/:sessionID/log", {
371
- params: { sessionID: Session.ID },
372
- query: {
373
- after: Schema.NumberFromString.pipe(Schema.decodeTo(Event.Seq), Schema.optional),
374
- follow: BooleanFromString.pipe(Schema.optional),
375
- },
376
- success: HttpApiSchema.StreamSse({
377
- data: Schema.Union([SessionEvent.Durable, EventLog.Synced]).annotate({ identifier: "SessionLogItem" }),
378
- }),
379
- error: SessionNotFoundError,
380
- })
381
- .middleware(sessionLocationMiddleware)
382
- .annotateMerge(OpenApi.annotations({
383
- identifier: "v2.session.log",
384
- summary: "Read the session log",
385
- description: "Durable, ordered, gap-free read of public session events after an exclusive aggregate sequence. Emits a synced marker once replay reaches the captured watermark, then completes; with follow=true it continues with live events instead. The only event API that promises reliability: attach after a snapshot watermark to compose fetch and stream without a race window.",
386
- })))
387
- .add(HttpApiEndpoint.post("session.interrupt", "/api/session/:sessionID/interrupt", {
388
- params: { sessionID: Session.ID },
389
- success: HttpApiSchema.NoContent,
390
- error: SessionNotFoundError,
391
- })
392
- .middleware(sessionLocationMiddleware)
393
- .annotateMerge(OpenApi.annotations({
394
- identifier: "v2.session.interrupt",
395
- summary: "Interrupt session execution",
396
- description: "Interrupt active execution owned by this OpenCode process. Idle interruption is a no-op.",
397
- })))
398
- .add(HttpApiEndpoint.post("session.background", "/api/session/:sessionID/background", {
399
- params: { sessionID: Session.ID },
400
- success: HttpApiSchema.NoContent,
401
- error: SessionNotFoundError,
402
- })
403
- .middleware(sessionLocationMiddleware)
404
- .annotateMerge(OpenApi.annotations({
405
- identifier: "v2.session.background",
406
- summary: "Background blocking session tools",
407
- description: "Move active foreground backgroundable tools for this session into background observation. Idle requests are a no-op.",
408
- })))
409
- .add(HttpApiEndpoint.get("session.message", "/api/session/:sessionID/message/:messageID", {
410
- params: { sessionID: Session.ID, messageID: SessionMessage.ID },
411
- success: Schema.Struct({ data: SessionMessage.Message }),
412
- error: [SessionNotFoundError, MessageNotFoundError],
413
- })
414
- .middleware(sessionLocationMiddleware)
415
- .annotateMerge(OpenApi.annotations({
416
- identifier: "v2.session.message",
417
- summary: "Get session message",
418
- description: "Retrieve one projected message owned by the Session.",
419
- })))
420
- .annotateMerge(OpenApi.annotations({
421
- title: "sessions",
422
- description: "Experimental session routes.",
423
- }));
@@ -1,120 +0,0 @@
1
- import { Location } from "@opencode-ai/schema/location";
2
- import { Schema } from "effect";
3
- import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
4
- import { ShellNotFoundError } from "../errors.js";
5
- export declare const ShellGroup: HttpApiGroup.HttpApiGroup<"server.shell", HttpApiEndpoint.HttpApiEndpoint<"shell.list", "GET", "/api/shell", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<Schema.Struct<{
6
- readonly location: Schema.optional<Schema.Struct<{
7
- readonly directory: Schema.optional<Schema.String>;
8
- readonly workspace: Schema.optional<Schema.String>;
9
- }>>;
10
- }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
11
- readonly location: typeof Location.Info;
12
- readonly data: Schema.$Array<Schema.Struct<{
13
- readonly id: Schema.brand<Schema.String, "ShellID"> & {
14
- create: () => string & import("effect/Brand").Brand<"ShellID">;
15
- ascending: (id?: string) => string & import("effect/Brand").Brand<"ShellID">;
16
- };
17
- readonly status: Schema.Literals<readonly ["running", "exited", "timeout", "killed"]>;
18
- readonly command: Schema.String;
19
- readonly cwd: Schema.String;
20
- readonly shell: Schema.String;
21
- readonly file: Schema.String;
22
- readonly pid: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
23
- readonly exit: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
24
- readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
25
- readonly time: Schema.Struct<{
26
- readonly started: Schema.Number;
27
- readonly completed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
28
- }>;
29
- }>>;
30
- }>>, HttpApiEndpoint.Json<never>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"shell.create", "POST", "/api/shell", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<Schema.Struct<{
31
- readonly location: Schema.optional<Schema.Struct<{
32
- readonly directory: Schema.optional<Schema.String>;
33
- readonly workspace: Schema.optional<Schema.String>;
34
- }>>;
35
- }>>, HttpApiEndpoint.Json<Schema.Struct<{
36
- readonly command: Schema.String;
37
- readonly cwd: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
38
- readonly timeout: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
39
- readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
40
- }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
41
- readonly location: typeof Location.Info;
42
- readonly data: Schema.Struct<{
43
- readonly id: Schema.brand<Schema.String, "ShellID"> & {
44
- create: () => string & import("effect/Brand").Brand<"ShellID">;
45
- ascending: (id?: string) => string & import("effect/Brand").Brand<"ShellID">;
46
- };
47
- readonly status: Schema.Literals<readonly ["running", "exited", "timeout", "killed"]>;
48
- readonly command: Schema.String;
49
- readonly cwd: Schema.String;
50
- readonly shell: Schema.String;
51
- readonly file: Schema.String;
52
- readonly pid: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
53
- readonly exit: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
54
- readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
55
- readonly time: Schema.Struct<{
56
- readonly started: Schema.Number;
57
- readonly completed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
58
- }>;
59
- }>;
60
- }>>, HttpApiEndpoint.Json<never>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"shell.get", "GET", "/api/shell/:id", HttpApiEndpoint.StringTree<Schema.Struct<{
61
- id: Schema.brand<Schema.String, "ShellID"> & {
62
- create: () => string & import("effect/Brand").Brand<"ShellID">;
63
- ascending: (id?: string) => string & import("effect/Brand").Brand<"ShellID">;
64
- };
65
- }>>, HttpApiEndpoint.StringTree<Schema.Struct<{
66
- readonly location: Schema.optional<Schema.Struct<{
67
- readonly directory: Schema.optional<Schema.String>;
68
- readonly workspace: Schema.optional<Schema.String>;
69
- }>>;
70
- }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
71
- readonly location: typeof Location.Info;
72
- readonly data: Schema.Struct<{
73
- readonly id: Schema.brand<Schema.String, "ShellID"> & {
74
- create: () => string & import("effect/Brand").Brand<"ShellID">;
75
- ascending: (id?: string) => string & import("effect/Brand").Brand<"ShellID">;
76
- };
77
- readonly status: Schema.Literals<readonly ["running", "exited", "timeout", "killed"]>;
78
- readonly command: Schema.String;
79
- readonly cwd: Schema.String;
80
- readonly shell: Schema.String;
81
- readonly file: Schema.String;
82
- readonly pid: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
83
- readonly exit: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
84
- readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
85
- readonly time: Schema.Struct<{
86
- readonly started: Schema.Number;
87
- readonly completed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
88
- }>;
89
- }>;
90
- }>>, HttpApiEndpoint.Json<typeof ShellNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"shell.output", "GET", "/api/shell/:id/output", HttpApiEndpoint.StringTree<Schema.Struct<{
91
- id: Schema.brand<Schema.String, "ShellID"> & {
92
- create: () => string & import("effect/Brand").Brand<"ShellID">;
93
- ascending: (id?: string) => string & import("effect/Brand").Brand<"ShellID">;
94
- };
95
- }>>, HttpApiEndpoint.StringTree<Schema.Struct<{
96
- readonly cursor: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
97
- readonly limit: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
98
- readonly location: Schema.optional<Schema.Struct<{
99
- readonly directory: Schema.optional<Schema.String>;
100
- readonly workspace: Schema.optional<Schema.String>;
101
- }>>;
102
- }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
103
- readonly location: typeof Location.Info;
104
- readonly data: Schema.Struct<{
105
- readonly output: Schema.String;
106
- readonly cursor: Schema.Int;
107
- readonly size: Schema.Int;
108
- readonly truncated: Schema.Boolean;
109
- }>;
110
- }>>, HttpApiEndpoint.Json<typeof ShellNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"shell.remove", "DELETE", "/api/shell/:id", HttpApiEndpoint.StringTree<Schema.Struct<{
111
- id: Schema.brand<Schema.String, "ShellID"> & {
112
- create: () => string & import("effect/Brand").Brand<"ShellID">;
113
- ascending: (id?: string) => string & import("effect/Brand").Brand<"ShellID">;
114
- };
115
- }>>, HttpApiEndpoint.StringTree<Schema.Struct<{
116
- readonly location: Schema.optional<Schema.Struct<{
117
- readonly directory: Schema.optional<Schema.String>;
118
- readonly workspace: Schema.optional<Schema.String>;
119
- }>>;
120
- }>>, HttpApiEndpoint.Json<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<HttpApiSchema.NoContent>, HttpApiEndpoint.Json<typeof ShellNotFoundError>, never, never>, false>;
@@ -1,65 +0,0 @@
1
- import { Shell } from "@opencode-ai/schema/shell";
2
- import { Location } from "@opencode-ai/schema/location";
3
- import { Schema } from "effect";
4
- import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
5
- import { ShellNotFoundError } from "../errors.js";
6
- import { LocationQuery, locationQueryOpenApi } from "./location.js";
7
- export const ShellGroup = HttpApiGroup.make("server.shell")
8
- .add(HttpApiEndpoint.get("shell.list", "/api/shell", {
9
- query: LocationQuery,
10
- success: Location.response(Schema.Array(Shell.Info)),
11
- })
12
- .annotateMerge(locationQueryOpenApi)
13
- .annotateMerge(OpenApi.annotations({
14
- identifier: "v2.shell.list",
15
- summary: "List running shell commands",
16
- description: "List currently running shell commands for a location. Exited commands are not included.",
17
- })))
18
- .add(HttpApiEndpoint.post("shell.create", "/api/shell", {
19
- query: LocationQuery,
20
- payload: Shell.CreateInput,
21
- success: Location.response(Shell.Info),
22
- })
23
- .annotateMerge(locationQueryOpenApi)
24
- .annotateMerge(OpenApi.annotations({
25
- identifier: "v2.shell.create",
26
- summary: "Run shell command",
27
- description: "Spawn one non-interactive shell command for a location. Combined stdout/stderr is captured to a file pageable via output.",
28
- })))
29
- .add(HttpApiEndpoint.get("shell.get", "/api/shell/:id", {
30
- params: { id: Shell.ID },
31
- query: LocationQuery,
32
- success: Location.response(Shell.Info),
33
- error: ShellNotFoundError,
34
- })
35
- .annotateMerge(locationQueryOpenApi)
36
- .annotateMerge(OpenApi.annotations({
37
- identifier: "v2.shell.get",
38
- summary: "Get shell command",
39
- description: "Get one shell command, including its status and exit code once exited.",
40
- })))
41
- .add(HttpApiEndpoint.get("shell.output", "/api/shell/:id/output", {
42
- params: { id: Shell.ID },
43
- query: Schema.Struct({ ...LocationQuery.fields, ...Shell.OutputInput.fields }),
44
- success: Location.response(Shell.Output),
45
- error: ShellNotFoundError,
46
- })
47
- .annotateMerge(locationQueryOpenApi)
48
- .annotateMerge(OpenApi.annotations({
49
- identifier: "v2.shell.output",
50
- summary: "Read shell output",
51
- description: "Page through captured combined output by absolute byte cursor.",
52
- })))
53
- .add(HttpApiEndpoint.delete("shell.remove", "/api/shell/:id", {
54
- params: { id: Shell.ID },
55
- query: LocationQuery,
56
- success: HttpApiSchema.NoContent,
57
- error: ShellNotFoundError,
58
- })
59
- .annotateMerge(locationQueryOpenApi)
60
- .annotateMerge(OpenApi.annotations({
61
- identifier: "v2.shell.remove",
62
- summary: "Remove shell command",
63
- description: "Terminate and remove one shell command and its retained output.",
64
- })))
65
- .annotateMerge(OpenApi.annotations({ title: "shell", description: "Experimental location-scoped shell command routes." }));
@@ -1,19 +0,0 @@
1
- import { Location } from "@opencode-ai/schema/location";
2
- import { Schema } from "effect";
3
- import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
4
- export declare const SkillGroup: HttpApiGroup.HttpApiGroup<"server.skill", HttpApiEndpoint.HttpApiEndpoint<"skill.list", "GET", "/api/skill", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<Schema.Struct<{
5
- readonly location: Schema.optional<Schema.Struct<{
6
- readonly directory: Schema.optional<Schema.String>;
7
- readonly workspace: Schema.optional<Schema.String>;
8
- }>>;
9
- }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
10
- readonly location: typeof Location.Info;
11
- readonly data: Schema.$Array<Schema.Struct<{
12
- readonly name: Schema.String;
13
- readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
14
- readonly slash: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
15
- readonly autoinvoke: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
16
- readonly location: Schema.brand<Schema.String, "AbsolutePath">;
17
- readonly content: Schema.String;
18
- }>>;
19
- }>>, HttpApiEndpoint.Json<never>, never, never>, false>;
@@ -1,20 +0,0 @@
1
- import { Skill } from "@opencode-ai/schema/skill";
2
- import { Location } from "@opencode-ai/schema/location";
3
- import { Schema } from "effect";
4
- import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
5
- import { LocationQuery, locationQueryOpenApi } from "./location.js";
6
- export const SkillGroup = HttpApiGroup.make("server.skill")
7
- .add(HttpApiEndpoint.get("skill.list", "/api/skill", {
8
- query: LocationQuery,
9
- success: Location.response(Schema.Array(Skill.Info)),
10
- })
11
- .annotateMerge(locationQueryOpenApi)
12
- .annotateMerge(OpenApi.annotations({
13
- identifier: "v2.skill.list",
14
- summary: "List skills",
15
- description: "Retrieve currently registered skills.",
16
- })))
17
- .annotateMerge(OpenApi.annotations({
18
- title: "skills",
19
- description: "Experimental skill routes.",
20
- }));