@opencode/protocol 2.1.3 → 2.2.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 (44) hide show
  1. package/dist/api.d.ts +6 -4
  2. package/dist/api.js +7 -5
  3. package/dist/client.d.ts +1 -0
  4. package/dist/client.js +16 -2
  5. package/dist/errors.d.ts +32 -0
  6. package/dist/errors.js +35 -0
  7. package/dist/groups/agent.d.ts +12 -2
  8. package/dist/groups/agent.js +2 -1
  9. package/dist/groups/debug.d.ts +14 -1
  10. package/dist/groups/debug.js +26 -0
  11. package/dist/groups/event.d.ts +1235 -1467
  12. package/dist/groups/event.js +9 -0
  13. package/dist/groups/experimental.d.ts +238 -0
  14. package/dist/groups/experimental.js +4 -0
  15. package/dist/groups/fs.d.ts +15 -3
  16. package/dist/groups/fs.js +27 -1
  17. package/dist/groups/generate.d.ts +194 -3
  18. package/dist/groups/generate.js +41 -5
  19. package/dist/groups/mcp.d.ts +49 -25
  20. package/dist/groups/mcp.js +40 -4
  21. package/dist/groups/media.d.ts +8 -0
  22. package/dist/groups/media.js +18 -0
  23. package/dist/groups/message.d.ts +2266 -27
  24. package/dist/groups/message.js +29 -4
  25. package/dist/groups/model.d.ts +47 -0
  26. package/dist/groups/model.js +8 -2
  27. package/dist/groups/permission.d.ts +6 -13
  28. package/dist/groups/permission.js +4 -3
  29. package/dist/groups/persistent-pty.d.ts +0 -8
  30. package/dist/groups/plugin.d.ts +18 -2
  31. package/dist/groups/plugin.js +15 -1
  32. package/dist/groups/provider.d.ts +24 -0
  33. package/dist/groups/pty.d.ts +33 -33
  34. package/dist/groups/server.d.ts +2 -0
  35. package/dist/groups/server.js +2 -0
  36. package/dist/groups/session.d.ts +609 -551
  37. package/dist/groups/session.js +18 -34
  38. package/dist/groups/usage.d.ts +95 -0
  39. package/dist/groups/usage.js +22 -0
  40. package/dist/groups/vcs.d.ts +2 -0
  41. package/dist/groups/vcs.js +1 -0
  42. package/dist/groups/voice.d.ts +2 -18
  43. package/dist/groups/voice.js +3 -19
  44. package/package.json +6 -4
package/dist/api.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Context } from "effect";
2
2
  import { HttpApi, HttpApiGroup, HttpApiMiddleware } from "effect/http-api";
3
3
  import { SchemaErrorMiddleware } from "./middleware/schema-error.js";
4
4
  import { GenerateGroup } from "./groups/generate.js";
5
+ import { ExperimentalGroup } from "./groups/experimental.js";
5
6
  import { VoiceGroup } from "./groups/voice.js";
6
7
  import { MessageGroup } from "./groups/message.js";
7
8
  import { ModelGroup } from "./groups/model.js";
@@ -20,27 +21,28 @@ import { PluginGroup } from "./groups/plugin.js";
20
21
  import { ServerGroup } from "./groups/server.js";
21
22
  import { DebugGroup } from "./groups/debug.js";
22
23
  import { makePtyGroup } from "./groups/pty.js";
23
- import { PersistentPtyGroup } from "./groups/persistent-pty.js";
24
24
  import { ShellGroup } from "./groups/shell.js";
25
25
  import { ReferenceGroup } from "./groups/reference.js";
26
26
  import { Authorization } from "./middleware/authorization.js";
27
27
  import { makeLocationGroup } from "./groups/location.js";
28
28
  import { IntegrationGroup } from "./groups/integration.js";
29
29
  import { WebSearchGroup } from "./groups/websearch.js";
30
- import { McpGroup } from "./groups/mcp.js";
30
+ import { UsageGroup } from "./groups/usage.js";
31
+ import { makeMcpGroup } from "./groups/mcp.js";
31
32
  import { CredentialGroup } from "./groups/credential.js";
32
33
  import { ProjectGroup } from "./groups/project.js";
33
34
  import { WorktreeGroup } from "./groups/worktree.js";
34
35
  import { VcsGroup } from "./groups/vcs.js";
35
36
  import { MigrationGroup } from "./groups/migration.js";
36
37
  import { ConfigGroup } from "./groups/config.js";
37
- type LocationGroups<LocationId extends HttpApiMiddleware.AnyId> = HttpApiGroup.AddMiddleware<typeof AgentGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof PluginGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ModelGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProviderGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof IntegrationGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof WebSearchGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof McpGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProjectGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof FileSystemGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof CommandGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof SkillGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof RpcGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ShellGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ReferenceGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof VcsGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ConfigGroup, LocationId>;
38
+ type LocationGroups<LocationId extends HttpApiMiddleware.AnyId> = HttpApiGroup.AddMiddleware<typeof AgentGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof PluginGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ModelGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProviderGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof IntegrationGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof WebSearchGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof UsageGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof FileSystemGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof CommandGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof SkillGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof RpcGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ShellGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ReferenceGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof VcsGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ConfigGroup, LocationId>;
38
39
  type PtyGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService> = ReturnType<typeof makePtyGroup<LocationId, LocationService>>;
40
+ type McpGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService> = ReturnType<typeof makeMcpGroup<LocationId, LocationService>>;
39
41
  type SessionGroups<SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService, FormLocationId extends HttpApiMiddleware.AnyId, FormLocationService> = ReturnType<typeof makeSessionGroup<SessionLocationId, SessionLocationService, FormLocationId, FormLocationService>> | typeof MessageGroup;
40
42
  type FormGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService> = ReturnType<typeof makeFormGroup<LocationId, LocationService>>;
41
43
  type LocationGroup<LocationId extends HttpApiMiddleware.AnyId, LocationService> = ReturnType<typeof makeLocationGroup<LocationId, LocationService>>;
42
44
  type MixedMiddlewareGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService> = ReturnType<typeof makePermissionGroup<LocationId, LocationService, SessionLocationId, SessionLocationService>>;
43
- type ApiGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService, FormLocationId extends HttpApiMiddleware.AnyId, FormLocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService, Event extends HttpApiGroup.Constraint> = typeof ServerGroup | typeof DebugGroup | typeof MigrationGroup | typeof WorktreeGroup | typeof GenerateGroup | typeof VoiceGroup | typeof PersistentPtyGroup | typeof CredentialGroup | LocationGroups<LocationId> | LocationGroup<LocationId, LocationService> | PtyGroups<LocationId, LocationService> | FormGroups<LocationId, LocationService> | SessionGroups<SessionLocationId, SessionLocationService, FormLocationId, FormLocationService> | MixedMiddlewareGroups<LocationId, LocationService, SessionLocationId, SessionLocationService> | Event;
45
+ type ApiGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService, FormLocationId extends HttpApiMiddleware.AnyId, FormLocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService, Event extends HttpApiGroup.Constraint> = typeof ServerGroup | typeof DebugGroup | typeof MigrationGroup | typeof WorktreeGroup | typeof GenerateGroup | typeof VoiceGroup | typeof ExperimentalGroup | typeof CredentialGroup | typeof ProjectGroup | LocationGroups<LocationId> | LocationGroup<LocationId, LocationService> | PtyGroups<LocationId, LocationService> | McpGroups<LocationId, LocationService> | FormGroups<LocationId, LocationService> | SessionGroups<SessionLocationId, SessionLocationService, FormLocationId, FormLocationService> | MixedMiddlewareGroups<LocationId, LocationService, SessionLocationId, SessionLocationService> | Event;
44
46
  type EventGroupFor<Definitions extends ReadonlyArray<Definition>> = ReturnType<typeof makeEventGroup<Definitions>>;
45
47
  export type Api<LocationId extends HttpApiMiddleware.AnyId, LocationService, FormLocationId extends HttpApiMiddleware.AnyId, FormLocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService, Event extends HttpApiGroup.Constraint> = HttpApi.HttpApi<"server", HttpApiGroup.AddMiddleware<HttpApiGroup.AddMiddleware<ApiGroups<LocationId, LocationService, FormLocationId, FormLocationService, SessionLocationId, SessionLocationService, Event>, Authorization>, SchemaErrorMiddleware>>;
46
48
  export declare const makeApi: <const Definitions extends ReadonlyArray<Definition>, LocationId extends HttpApiMiddleware.AnyId, LocationService, FormLocationId extends HttpApiMiddleware.AnyId, FormLocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService>(options: {
package/dist/api.js CHANGED
@@ -2,6 +2,7 @@ import { Context } from "effect";
2
2
  import { HttpApi, HttpApiGroup, HttpApiMiddleware, OpenApi } from "effect/http-api";
3
3
  import { SchemaErrorMiddleware } from "./middleware/schema-error.js";
4
4
  import { GenerateGroup } from "./groups/generate.js";
5
+ import { ExperimentalGroup } from "./groups/experimental.js";
5
6
  import { VoiceGroup } from "./groups/voice.js";
6
7
  import { MessageGroup } from "./groups/message.js";
7
8
  import { ModelGroup } from "./groups/model.js";
@@ -19,14 +20,14 @@ import { PluginGroup } from "./groups/plugin.js";
19
20
  import { ServerGroup } from "./groups/server.js";
20
21
  import { DebugGroup } from "./groups/debug.js";
21
22
  import { makePtyGroup } from "./groups/pty.js";
22
- import { PersistentPtyGroup } from "./groups/persistent-pty.js";
23
23
  import { ShellGroup } from "./groups/shell.js";
24
24
  import { ReferenceGroup } from "./groups/reference.js";
25
25
  import { Authorization } from "./middleware/authorization.js";
26
26
  import { makeLocationGroup } from "./groups/location.js";
27
27
  import { IntegrationGroup } from "./groups/integration.js";
28
28
  import { WebSearchGroup } from "./groups/websearch.js";
29
- import { McpGroup } from "./groups/mcp.js";
29
+ import { UsageGroup } from "./groups/usage.js";
30
+ import { makeMcpGroup } from "./groups/mcp.js";
30
31
  import { CredentialGroup } from "./groups/credential.js";
31
32
  import { ProjectGroup } from "./groups/project.js";
32
33
  import { WorktreeGroup } from "./groups/worktree.js";
@@ -46,9 +47,9 @@ const makeApiFromGroup = (eventGroup, locationMiddleware, formLocationMiddleware
46
47
  .add(VoiceGroup)
47
48
  .add(ProviderGroup.middleware(locationMiddleware))
48
49
  .add(IntegrationGroup.middleware(locationMiddleware))
49
- .add(McpGroup.middleware(locationMiddleware))
50
+ .add(makeMcpGroup(locationMiddleware))
50
51
  .add(CredentialGroup)
51
- .add(ProjectGroup.middleware(locationMiddleware))
52
+ .add(ProjectGroup)
52
53
  .add(makeFormGroup(locationMiddleware))
53
54
  .add(makePermissionGroup(locationMiddleware, sessionLocationMiddleware))
54
55
  .add(FileSystemGroup.middleware(locationMiddleware))
@@ -57,7 +58,7 @@ const makeApiFromGroup = (eventGroup, locationMiddleware, formLocationMiddleware
57
58
  .add(RpcGroup.middleware(locationMiddleware))
58
59
  .add(eventGroup)
59
60
  .add(makePtyGroup(locationMiddleware))
60
- .add(PersistentPtyGroup)
61
+ .add(ExperimentalGroup)
61
62
  .add(ShellGroup.middleware(locationMiddleware))
62
63
  .add(ReferenceGroup.middleware(locationMiddleware))
63
64
  .add(WorktreeGroup)
@@ -65,6 +66,7 @@ const makeApiFromGroup = (eventGroup, locationMiddleware, formLocationMiddleware
65
66
  .add(DebugGroup)
66
67
  .add(MigrationGroup)
67
68
  .add(WebSearchGroup.middleware(locationMiddleware))
69
+ .add(UsageGroup.middleware(locationMiddleware))
68
70
  .add(ConfigGroup.middleware(locationMiddleware))
69
71
  .annotateMerge(OpenApi.annotations({
70
72
  title: "opencode HttpApi",
package/dist/client.d.ts CHANGED
@@ -40,6 +40,7 @@ export declare const groupNames: {
40
40
  readonly "server.provider": "provider";
41
41
  readonly "server.integration": "integration";
42
42
  readonly "server.websearch": "websearch";
43
+ readonly "server.usage": "usage";
43
44
  readonly "server.credential": "credential";
44
45
  readonly "server.form": "form";
45
46
  readonly "server.permission": "permission";
package/dist/client.js CHANGED
@@ -27,6 +27,7 @@ export const groupNames = {
27
27
  "server.provider": "provider",
28
28
  "server.integration": "integration",
29
29
  "server.websearch": "websearch",
30
+ "server.usage": "usage",
30
31
  "server.credential": "credential",
31
32
  "server.form": "form",
32
33
  "server.permission": "permission",
@@ -45,5 +46,18 @@ export const groupNames = {
45
46
  "server.vcs": "vcs",
46
47
  "server.config": "config",
47
48
  };
48
- export const promiseOmitEndpoints = new Set(["pty.connect", "persistentPty.connect"]);
49
- export const effectOmitEndpoints = new Set(["fs.read", "fs.write", "pty.connect", "persistentPty.connect"]);
49
+ export const promiseOmitEndpoints = new Set([
50
+ "pty.connect",
51
+ "persistentPty.connect",
52
+ "mcp.client",
53
+ "generate.textLegacy",
54
+ ]);
55
+ export const effectOmitEndpoints = new Set([
56
+ "fs.read",
57
+ "fs.write",
58
+ "media.get",
59
+ "pty.connect",
60
+ "persistentPty.connect",
61
+ "mcp.client",
62
+ "generate.textLegacy",
63
+ ]);
package/dist/errors.d.ts CHANGED
@@ -95,6 +95,12 @@ declare const FileNotFoundError_base: Schema.Class<FileNotFoundError, Schema.Tag
95
95
  }>, import("effect/Cause").YieldableError>;
96
96
  export declare class FileNotFoundError extends FileNotFoundError_base {
97
97
  }
98
+ declare const PluginNotFoundError_base: Schema.Class<PluginNotFoundError, Schema.TaggedStruct<"PluginNotFoundError", {
99
+ readonly pluginID: Schema.String;
100
+ readonly message: Schema.String;
101
+ }>, import("effect/Cause").YieldableError>;
102
+ export declare class PluginNotFoundError extends PluginNotFoundError_base {
103
+ }
98
104
  declare const AgentNotFoundError_base: Schema.Class<AgentNotFoundError, Schema.TaggedStruct<"AgentNotFoundError", {
99
105
  readonly agentID: Schema.String;
100
106
  readonly message: Schema.String;
@@ -190,4 +196,30 @@ declare const ShellNotFoundError_base: Schema.Class<ShellNotFoundError, Schema.T
190
196
  }>, import("effect/Cause").YieldableError>;
191
197
  export declare class ShellNotFoundError extends ShellNotFoundError_base {
192
198
  }
199
+ declare const ModelNotFoundError_base: Schema.Class<ModelNotFoundError, Schema.TaggedStruct<"ModelNotFoundError", {
200
+ readonly providerID: Schema.String;
201
+ readonly modelID: Schema.String;
202
+ readonly message: Schema.String;
203
+ }>, import("effect/Cause").YieldableError>;
204
+ export declare class ModelNotFoundError extends ModelNotFoundError_base {
205
+ }
206
+ declare const UnsupportedModelError_base: Schema.Class<UnsupportedModelError, Schema.TaggedStruct<"UnsupportedModelError", {
207
+ readonly providerID: Schema.String;
208
+ readonly modelID: Schema.String;
209
+ readonly capability: Schema.String;
210
+ readonly message: Schema.String;
211
+ }>, import("effect/Cause").YieldableError>;
212
+ /** The model exists but cannot serve this request, such as a chat model asked for images. */
213
+ export declare class UnsupportedModelError extends UnsupportedModelError_base {
214
+ }
215
+ declare const ProviderRequestError_base: Schema.Class<ProviderRequestError, Schema.TaggedStruct<"ProviderRequestError", {
216
+ readonly providerID: Schema.String;
217
+ readonly reason: Schema.Literals<readonly ["authentication", "rate_limit", "content_filter", "invalid_request", "overloaded", "provider"]>;
218
+ readonly message: Schema.String;
219
+ readonly status: Schema.optional<Schema.Int>;
220
+ readonly retryAfterMs: Schema.optional<Schema.Int>;
221
+ }>, import("effect/Cause").YieldableError>;
222
+ /** The provider rejected or failed the request after the server sent it. */
223
+ export declare class ProviderRequestError extends ProviderRequestError_base {
224
+ }
193
225
  export {};
package/dist/errors.js CHANGED
@@ -75,6 +75,11 @@ export class FileNotFoundError extends Schema.TaggedError()("FileNotFoundError",
75
75
  message: Schema.String,
76
76
  }, { httpApiStatus: 404 }) {
77
77
  }
78
+ export class PluginNotFoundError extends Schema.TaggedError()("PluginNotFoundError", {
79
+ pluginID: Schema.String,
80
+ message: Schema.String,
81
+ }, { httpApiStatus: 404 }) {
82
+ }
78
83
  export class AgentNotFoundError extends Schema.TaggedError()("AgentNotFoundError", {
79
84
  agentID: Schema.String,
80
85
  message: Schema.String,
@@ -150,3 +155,33 @@ export class ShellNotFoundError extends Schema.TaggedError()("ShellNotFoundError
150
155
  message: Schema.String,
151
156
  }, { httpApiStatus: 404 }) {
152
157
  }
158
+ export class ModelNotFoundError extends Schema.TaggedError()("ModelNotFoundError", {
159
+ providerID: Schema.String,
160
+ modelID: Schema.String,
161
+ message: Schema.String,
162
+ }, { httpApiStatus: 404 }) {
163
+ }
164
+ /** The model exists but cannot serve this request, such as a chat model asked for images. */
165
+ export class UnsupportedModelError extends Schema.TaggedError()("UnsupportedModelError", {
166
+ providerID: Schema.String,
167
+ modelID: Schema.String,
168
+ capability: Schema.String,
169
+ message: Schema.String,
170
+ }, { httpApiStatus: 422 }) {
171
+ }
172
+ /** The provider rejected or failed the request after the server sent it. */
173
+ export class ProviderRequestError extends Schema.TaggedError()("ProviderRequestError", {
174
+ providerID: Schema.String,
175
+ reason: Schema.Literals([
176
+ "authentication",
177
+ "rate_limit",
178
+ "content_filter",
179
+ "invalid_request",
180
+ "overloaded",
181
+ "provider",
182
+ ]),
183
+ message: Schema.String,
184
+ status: Schema.optional(Schema.Int),
185
+ retryAfterMs: Schema.optional(Schema.Int),
186
+ }, { httpApiStatus: 502 }) {
187
+ }
@@ -1,7 +1,7 @@
1
1
  import { Agent } from "@opencode/schema/agent";
2
2
  import { Schema } from "effect";
3
3
  import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
4
- import { AgentNotFoundError } from "../errors.js";
4
+ import { AgentNotFoundError, ServiceUnavailableError } from "../errors.js";
5
5
  export declare const AgentGroup: HttpApiGroup.HttpApiGroup<"server.agent", HttpApiEndpoint.HttpApiEndpoint<"agent.get", "GET", "/api/agent/:agentID", Schema.toCodecStringTree<Schema.Struct<{
6
6
  agentID: Schema.brand<Schema.String, "Agent.ID">;
7
7
  }>>, Schema.toCodecStringTree<Schema.Struct<{
@@ -74,6 +74,11 @@ export declare const AgentGroup: HttpApiGroup.HttpApiGroup<"server.agent", HttpA
74
74
  }>, Schema.Struct<{
75
75
  readonly type: Schema.Literal<"native">;
76
76
  }>]>>, never, never>;
77
+ readonly cache: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
78
+ readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
79
+ }>>>, Schema.optionalKey<Schema.Struct<{
80
+ readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
81
+ }>>, never, never>;
77
82
  readonly transport: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["http", "websocket"]>>>, Schema.optionalKey<Schema.Literals<readonly ["http", "websocket"]>>, never, never>;
78
83
  readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
79
84
  }>, readonly [Schema.$Record<Schema.String, Schema.Any>]>>;
@@ -183,6 +188,11 @@ export declare const AgentGroup: HttpApiGroup.HttpApiGroup<"server.agent", HttpA
183
188
  }>, Schema.Struct<{
184
189
  readonly type: Schema.Literal<"native">;
185
190
  }>]>>, never, never>;
191
+ readonly cache: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
192
+ readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
193
+ }>>>, Schema.optionalKey<Schema.Struct<{
194
+ readonly ttl: Schema.decodeTo<Schema.optional<Schema.toType<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>>, Schema.optionalKey<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>, never, never>;
195
+ }>>, never, never>;
186
196
  readonly transport: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["http", "websocket"]>>>, Schema.optionalKey<Schema.Literals<readonly ["http", "websocket"]>>, never, never>;
187
197
  readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
188
198
  }>, readonly [Schema.$Record<Schema.String, Schema.Any>]>>;
@@ -222,4 +232,4 @@ export declare const AgentGroup: HttpApiGroup.HttpApiGroup<"server.agent", HttpA
222
232
  })[];
223
233
  };
224
234
  }>;
225
- }>>, never, never, never>, false>;
235
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never>, false>;
@@ -3,11 +3,12 @@ import { Location } from "@opencode/schema/location";
3
3
  import { Schema } from "effect";
4
4
  import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api";
5
5
  import { LocationQuery, locationQueryOpenApi } from "./location.js";
6
- import { AgentNotFoundError } from "../errors.js";
6
+ import { AgentNotFoundError, ServiceUnavailableError } from "../errors.js";
7
7
  export const AgentGroup = HttpApiGroup.make("server.agent")
8
8
  .add(HttpApiEndpoint.get("agent.list", "/api/agent", {
9
9
  query: LocationQuery,
10
10
  success: Location.response(Schema.Array(Agent.Info)),
11
+ error: ServiceUnavailableError,
11
12
  })
12
13
  .annotateMerge(locationQueryOpenApi)
13
14
  .annotateMerge(OpenApi.annotations({
@@ -1,6 +1,19 @@
1
1
  import { Schema } from "effect";
2
2
  import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
3
- export declare const DebugGroup: HttpApiGroup.HttpApiGroup<"server.debug", HttpApiEndpoint.HttpApiEndpoint<"debug.location", "GET", "/api/debug/location", never, never, never, never, Schema.toCodecJson<Schema.$Array<Schema.Struct<{
3
+ import { InvalidRequestError, UnknownError } from "../errors.js";
4
+ export declare const DebugGroup: HttpApiGroup.HttpApiGroup<"server.debug", HttpApiEndpoint.HttpApiEndpoint<"debug.heapDump", "POST", "/api/debug/heap-dump", never, Schema.toCodecStringTree<Schema.Struct<{
5
+ readonly directory: Schema.optional<Schema.String>;
6
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
7
+ readonly path: Schema.String;
8
+ readonly pid: Schema.Int;
9
+ readonly memory: Schema.Struct<{
10
+ readonly rss: Schema.Number;
11
+ readonly heapTotal: Schema.Number;
12
+ readonly heapUsed: Schema.Number;
13
+ readonly external: Schema.Number;
14
+ readonly arrayBuffers: Schema.Number;
15
+ }>;
16
+ }>>, Schema.toCodecJson<typeof InvalidRequestError | typeof UnknownError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"debug.location", "GET", "/api/debug/location", never, never, never, never, Schema.toCodecJson<Schema.$Array<Schema.Struct<{
4
17
  readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
5
18
  }>>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"debug.location.evict", "DELETE", "/api/debug/location", never, Schema.toCodecStringTree<Schema.Struct<{
6
19
  readonly location: Schema.optional<Schema.Struct<{
@@ -1,8 +1,34 @@
1
1
  import { Location } from "@opencode/schema/location";
2
2
  import { Schema } from "effect";
3
3
  import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
4
+ import { InvalidRequestError, UnknownError } from "../errors.js";
4
5
  import { LocationQuery, locationQueryOpenApi } from "./location.js";
5
6
  export const DebugGroup = HttpApiGroup.make("server.debug")
7
+ .add(HttpApiEndpoint.post("debug.heapDump", "/api/debug/heap-dump", {
8
+ query: Schema.Struct({
9
+ directory: Schema.String.pipe(Schema.optional, Schema.annotate({
10
+ description: "Absolute server-local directory to write the snapshot into, created when missing. Defaults to the server's log directory.",
11
+ })),
12
+ }),
13
+ success: Schema.Struct({
14
+ path: Schema.String,
15
+ pid: Schema.Int,
16
+ memory: Schema.Struct({
17
+ rss: Schema.Number,
18
+ heapTotal: Schema.Number,
19
+ heapUsed: Schema.Number,
20
+ external: Schema.Number,
21
+ arrayBuffers: Schema.Number,
22
+ }).annotate({
23
+ description: "The server process's memory in bytes, read just before the snapshot (Node's process.memoryUsage()). rss covers native memory the snapshot cannot show.",
24
+ }),
25
+ }),
26
+ error: [InvalidRequestError, UnknownError],
27
+ }).annotateMerge(OpenApi.annotations({
28
+ identifier: "debug.heapDump",
29
+ summary: "Write a heap snapshot",
30
+ description: "Write a JavaScript heap snapshot of the server process into its log directory, or the requested directory, and return the server-local path once the file is complete. Pauses the server while the heap serializes and can temporarily increase its memory use. The snapshot can contain credentials, prompts, and file contents.",
31
+ })))
6
32
  .add(HttpApiEndpoint.get("debug.location", "/api/debug/location", {
7
33
  success: Schema.Array(Location.PublicRef),
8
34
  }).annotateMerge(OpenApi.annotations({