@opencode/protocol 2.0.32 → 2.1.1

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.
@@ -4,6 +4,20 @@ import { Location } from "@opencode/schema/location";
4
4
  import { Schema, Struct } from "effect";
5
5
  import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api";
6
6
  import { InvalidCursorError, SessionNotFoundError, UnknownError } from "../errors.js";
7
+ // Keyed by message type so a new message type cannot be left out of the filter.
8
+ const MessageTypes = {
9
+ "agent-switched": true,
10
+ "model-switched": true,
11
+ "location-switched": true,
12
+ user: true,
13
+ synthetic: true,
14
+ system: true,
15
+ skill: true,
16
+ shell: true,
17
+ assistant: true,
18
+ compaction: true,
19
+ idle: true,
20
+ };
7
21
  export const SessionMessagesQuery = Schema.Struct({
8
22
  limit: Schema.optional(Schema.NumberFromString.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(200))).annotate({
9
23
  description: "Maximum number of messages to return. When omitted, the endpoint returns its default page size.",
@@ -14,18 +28,7 @@ export const SessionMessagesQuery = Schema.Struct({
14
28
  cursor: Schema.optional(Schema.String.annotate({
15
29
  description: "Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.",
16
30
  })),
17
- type: Schema.optional(Schema.Literals([
18
- "agent-switched",
19
- "model-switched",
20
- "location-switched",
21
- "user",
22
- "synthetic",
23
- "system",
24
- "skill",
25
- "shell",
26
- "assistant",
27
- "compaction",
28
- ])).annotate({
31
+ type: Schema.optional(Schema.Literals(Object.keys(MessageTypes))).annotate({
29
32
  description: "Filter by message type before pagination. When omitted, all message types are returned. Pass the same type when following cursors.",
30
33
  }),
31
34
  }).annotate({ identifier: "SessionMessagesQuery" });
@@ -2,7 +2,7 @@ import { Model } from "@opencode/schema/model";
2
2
  import { Schema } from "effect";
3
3
  import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
4
4
  import { ServiceUnavailableError } from "../errors.js";
5
- export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpApiEndpoint.HttpApiEndpoint<"model.list", "GET", "/api/model", never, Schema.toCodecStringTree<Schema.Struct<{
5
+ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpApiEndpoint.HttpApiEndpoint<"model.default", "GET", "/api/model/default", never, Schema.toCodecStringTree<Schema.Struct<{
6
6
  readonly location: Schema.optional<Schema.Struct<{
7
7
  readonly directory: Schema.optional<Schema.String>;
8
8
  }>>;
@@ -10,80 +10,7 @@ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpA
10
10
  readonly location: Schema.Struct<{
11
11
  readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
12
12
  }>;
13
- readonly data: Schema.$Array<Schema.Struct<{
14
- readonly capabilities: Schema.Struct<{
15
- readonly tools: Schema.Boolean;
16
- readonly input: Schema.$Array<Schema.String>;
17
- readonly output: Schema.$Array<Schema.String>;
18
- readonly temperature: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
19
- }> & {
20
- default: () => {
21
- tools: true;
22
- input: string[];
23
- output: string[];
24
- };
25
- };
26
- readonly variants: Schema.$Array<Schema.Struct<{
27
- readonly settings: Schema.decodeTo<Schema.optional<Schema.toType<Schema.StructWithRest<Schema.Struct<{
28
- readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
29
- readonly type: Schema.Literal<"summary">;
30
- }>, Schema.Struct<{
31
- readonly type: Schema.Literal<"native">;
32
- }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
33
- readonly type: Schema.Literal<"summary">;
34
- }>, Schema.Struct<{
35
- readonly type: Schema.Literal<"native">;
36
- }>]>>, never, never>;
37
- readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
38
- }>, readonly [Schema.$Record<Schema.String, Schema.Any>]>>>, Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
39
- readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
40
- readonly type: Schema.Literal<"summary">;
41
- }>, Schema.Struct<{
42
- readonly type: Schema.Literal<"native">;
43
- }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
44
- readonly type: Schema.Literal<"summary">;
45
- }>, Schema.Struct<{
46
- readonly type: Schema.Literal<"native">;
47
- }>]>>, never, never>;
48
- readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
49
- }>, readonly [Schema.$Record<Schema.String, Schema.Any>]>>, never, never>;
50
- readonly headers: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.String>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>, never, never>;
51
- readonly body: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Any>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Any>>, never, never>;
52
- readonly id: Schema.brand<Schema.String, "Model.VariantID">;
53
- }>>;
54
- readonly time: Schema.Struct<{
55
- readonly released: Schema.Finite;
56
- }>;
57
- readonly cost: Schema.$Array<Schema.Struct<{
58
- readonly tier: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
59
- readonly type: Schema.tag<"context">;
60
- readonly size: Schema.Int;
61
- }>>>, Schema.optionalKey<Schema.Struct<{
62
- readonly type: Schema.tag<"context">;
63
- readonly size: Schema.Int;
64
- }>>, never, never>;
65
- readonly input: Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
66
- zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
67
- };
68
- readonly output: Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
69
- zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
70
- };
71
- readonly cache: Schema.Struct<{
72
- readonly read: Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
73
- zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
74
- };
75
- readonly write: Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
76
- zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
77
- };
78
- }>;
79
- }>>;
80
- readonly status: Schema.Literals<readonly ["alpha", "beta", "deprecated", "active"]>;
81
- readonly enabled: Schema.Boolean;
82
- readonly limit: Schema.Struct<{
83
- readonly context: Schema.Int;
84
- readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
85
- readonly output: Schema.Int;
86
- }>;
13
+ readonly data: Schema.UndefinedOr<Schema.Struct<{
87
14
  readonly settings: Schema.decodeTo<Schema.optional<Schema.toType<Schema.StructWithRest<Schema.Struct<{
88
15
  readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
89
16
  readonly type: Schema.Literal<"summary">;
@@ -158,6 +85,7 @@ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpA
158
85
  readonly requireFinishReason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
159
86
  readonly requireAssistantAfterTool: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
160
87
  readonly supportsPromptCacheKey: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
88
+ readonly streamUsage: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
161
89
  readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
162
90
  readonly supportsThinkingBlockBinding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
163
91
  readonly supportsEffortUpdates: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
@@ -168,44 +96,12 @@ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpA
168
96
  readonly requireFinishReason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
169
97
  readonly requireAssistantAfterTool: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
170
98
  readonly supportsPromptCacheKey: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
99
+ readonly streamUsage: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
171
100
  readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
172
101
  readonly supportsThinkingBlockBinding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
173
102
  readonly supportsEffortUpdates: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
174
103
  }>>, never, never>;
175
104
  readonly package: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
176
- }> & {
177
- default: (providerID: import("@opencode/schema/provider").ID, id: Model.ID) => {
178
- id: string & import("effect/Brand").Brand<"Model.ID">;
179
- modelID: string & import("effect/Brand").Brand<"Model.ID">;
180
- providerID: string & import("effect/Brand").Brand<"Provider.ID">;
181
- name: string & import("effect/Brand").Brand<"Model.ID">;
182
- capabilities: {
183
- tools: true;
184
- input: string[];
185
- output: string[];
186
- };
187
- variants: never[];
188
- time: {
189
- released: number;
190
- };
191
- cost: never[];
192
- status: "active";
193
- enabled: true;
194
- limit: {
195
- context: number;
196
- output: number;
197
- };
198
- };
199
- }>;
200
- }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"model.default", "GET", "/api/model/default", never, Schema.toCodecStringTree<Schema.Struct<{
201
- readonly location: Schema.optional<Schema.Struct<{
202
- readonly directory: Schema.optional<Schema.String>;
203
- }>>;
204
- }>>, never, never, Schema.toCodecJson<Schema.Struct<{
205
- readonly location: Schema.Struct<{
206
- readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
207
- }>;
208
- readonly data: Schema.UndefinedOr<Schema.Struct<{
209
105
  readonly capabilities: Schema.Struct<{
210
106
  readonly tools: Schema.Boolean;
211
107
  readonly input: Schema.$Array<Schema.String>;
@@ -279,6 +175,39 @@ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpA
279
175
  readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
280
176
  readonly output: Schema.Int;
281
177
  }>;
178
+ }> & {
179
+ default: (providerID: import("@opencode/schema/provider").ID, id: Model.ID) => {
180
+ id: string & import("effect/Brand").Brand<"Model.ID">;
181
+ modelID: string & import("effect/Brand").Brand<"Model.ID">;
182
+ providerID: string & import("effect/Brand").Brand<"Provider.ID">;
183
+ name: string & import("effect/Brand").Brand<"Model.ID">;
184
+ capabilities: {
185
+ tools: true;
186
+ input: string[];
187
+ output: string[];
188
+ };
189
+ variants: never[];
190
+ time: {
191
+ released: number;
192
+ };
193
+ cost: never[];
194
+ status: "active";
195
+ enabled: true;
196
+ limit: {
197
+ context: number;
198
+ output: number;
199
+ };
200
+ };
201
+ }>;
202
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"model.list", "GET", "/api/model", never, Schema.toCodecStringTree<Schema.Struct<{
203
+ readonly location: Schema.optional<Schema.Struct<{
204
+ readonly directory: Schema.optional<Schema.String>;
205
+ }>>;
206
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
207
+ readonly location: Schema.Struct<{
208
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
209
+ }>;
210
+ readonly data: Schema.$Array<Schema.Struct<{
282
211
  readonly settings: Schema.decodeTo<Schema.optional<Schema.toType<Schema.StructWithRest<Schema.Struct<{
283
212
  readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
284
213
  readonly type: Schema.Literal<"summary">;
@@ -353,6 +282,7 @@ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpA
353
282
  readonly requireFinishReason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
354
283
  readonly requireAssistantAfterTool: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
355
284
  readonly supportsPromptCacheKey: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
285
+ readonly streamUsage: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
356
286
  readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
357
287
  readonly supportsThinkingBlockBinding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
358
288
  readonly supportsEffortUpdates: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
@@ -363,11 +293,85 @@ export declare const ModelGroup: HttpApiGroup.HttpApiGroup<"server.model", HttpA
363
293
  readonly requireFinishReason: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
364
294
  readonly requireAssistantAfterTool: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
365
295
  readonly supportsPromptCacheKey: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
296
+ readonly streamUsage: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
366
297
  readonly cacheFormat: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["anthropic", "alibaba"]>>>, Schema.optionalKey<Schema.Literals<readonly ["anthropic", "alibaba"]>>, never, never>;
367
298
  readonly supportsThinkingBlockBinding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
368
299
  readonly supportsEffortUpdates: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
369
300
  }>>, never, never>;
370
301
  readonly package: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
302
+ readonly capabilities: Schema.Struct<{
303
+ readonly tools: Schema.Boolean;
304
+ readonly input: Schema.$Array<Schema.String>;
305
+ readonly output: Schema.$Array<Schema.String>;
306
+ readonly temperature: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
307
+ }> & {
308
+ default: () => {
309
+ tools: true;
310
+ input: string[];
311
+ output: string[];
312
+ };
313
+ };
314
+ readonly variants: Schema.$Array<Schema.Struct<{
315
+ readonly settings: Schema.decodeTo<Schema.optional<Schema.toType<Schema.StructWithRest<Schema.Struct<{
316
+ readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
317
+ readonly type: Schema.Literal<"summary">;
318
+ }>, Schema.Struct<{
319
+ readonly type: Schema.Literal<"native">;
320
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
321
+ readonly type: Schema.Literal<"summary">;
322
+ }>, Schema.Struct<{
323
+ readonly type: Schema.Literal<"native">;
324
+ }>]>>, never, never>;
325
+ readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
326
+ }>, readonly [Schema.$Record<Schema.String, Schema.Any>]>>>, Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
327
+ readonly compaction: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
328
+ readonly type: Schema.Literal<"summary">;
329
+ }>, Schema.Struct<{
330
+ readonly type: Schema.Literal<"native">;
331
+ }>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
332
+ readonly type: Schema.Literal<"summary">;
333
+ }>, Schema.Struct<{
334
+ readonly type: Schema.Literal<"native">;
335
+ }>]>>, never, never>;
336
+ readonly encoding: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["zstd", "gzip", "none"]>>>, Schema.optionalKey<Schema.Literals<readonly ["zstd", "gzip", "none"]>>, never, never>;
337
+ }>, readonly [Schema.$Record<Schema.String, Schema.Any>]>>, never, never>;
338
+ readonly headers: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.String>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>, never, never>;
339
+ readonly body: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Any>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Any>>, never, never>;
340
+ readonly id: Schema.brand<Schema.String, "Model.VariantID">;
341
+ }>>;
342
+ readonly time: Schema.Struct<{
343
+ readonly released: Schema.Finite;
344
+ }>;
345
+ readonly cost: Schema.$Array<Schema.Struct<{
346
+ readonly tier: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
347
+ readonly type: Schema.tag<"context">;
348
+ readonly size: Schema.Int;
349
+ }>>>, Schema.optionalKey<Schema.Struct<{
350
+ readonly type: Schema.tag<"context">;
351
+ readonly size: Schema.Int;
352
+ }>>, never, never>;
353
+ readonly input: Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
354
+ zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
355
+ };
356
+ readonly output: Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
357
+ zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
358
+ };
359
+ readonly cache: Schema.Struct<{
360
+ readonly read: Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
361
+ zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
362
+ };
363
+ readonly write: Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
364
+ zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
365
+ };
366
+ }>;
367
+ }>>;
368
+ readonly status: Schema.Literals<readonly ["alpha", "beta", "deprecated", "active"]>;
369
+ readonly enabled: Schema.Boolean;
370
+ readonly limit: Schema.Struct<{
371
+ readonly context: Schema.Int;
372
+ readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
373
+ readonly output: Schema.Int;
374
+ }>;
371
375
  }> & {
372
376
  default: (providerID: import("@opencode/schema/provider").ID, id: Model.ID) => {
373
377
  id: string & import("effect/Brand").Brand<"Model.ID">;
@@ -1,6 +1,6 @@
1
1
  import { Context, Schema } from "effect";
2
2
  import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema } from "effect/http-api";
3
- import { LocationNotFoundError, PermissionNotFoundError, SessionNotFoundError } from "../errors.js";
3
+ import { ConflictError, LocationNotFoundError, PermissionNotFoundError, PermissionSavedNotFoundError, SessionNotFoundError } from "../errors.js";
4
4
  export declare const makePermissionGroup: <LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService>(locationMiddleware: Context.Key<LocationId, LocationService>, sessionLocationMiddleware: Context.Key<SessionLocationId, SessionLocationService>) => HttpApiGroup.HttpApiGroup<"server.permission", HttpApiEndpoint.HttpApiEndpoint<"permission.request.list", "GET", "/api/permission/request", never, Schema.toCodecStringTree<Schema.Struct<{
5
5
  readonly location: Schema.optional<Schema.Struct<{
6
6
  readonly directory: Schema.optional<Schema.String>;
@@ -51,7 +51,29 @@ export declare const makePermissionGroup: <LocationId extends HttpApiMiddleware.
51
51
  readonly updated: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
52
52
  }>;
53
53
  }>>;
54
- }>>, never, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"permission.saved.remove", "DELETE", "/api/permission/saved/:id", Schema.toCodecStringTree<Schema.Struct<{
54
+ }>>, never, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"permission.saved.update", "PATCH", "/api/permission/saved/:id", Schema.toCodecStringTree<Schema.Struct<{
55
+ id: Schema.brand<Schema.String, "PermissionSaved.ID"> & {
56
+ create: () => string & import("effect/Brand").Brand<"PermissionSaved.ID">;
57
+ };
58
+ }>>, never, Schema.toCodecJson<Schema.Struct<{
59
+ readonly action: Schema.optional<Schema.String>;
60
+ readonly resource: Schema.optional<Schema.String>;
61
+ }>>, never, Schema.toCodecJson<Schema.Struct<{
62
+ readonly data: Schema.Struct<{
63
+ readonly id: Schema.brand<Schema.String, "PermissionSaved.ID"> & {
64
+ create: () => string & import("effect/Brand").Brand<"PermissionSaved.ID">;
65
+ };
66
+ readonly projectID: Schema.brand<Schema.String, "Project.ID"> & {
67
+ global: string & import("effect/Brand").Brand<"Project.ID">;
68
+ };
69
+ readonly action: Schema.String;
70
+ readonly resource: Schema.String;
71
+ readonly time: Schema.Struct<{
72
+ readonly created: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
73
+ readonly updated: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
74
+ }>;
75
+ }>;
76
+ }>>, Schema.toCodecJson<typeof ConflictError | typeof PermissionSavedNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"permission.saved.remove", "DELETE", "/api/permission/saved/:id", Schema.toCodecStringTree<Schema.Struct<{
55
77
  id: Schema.brand<Schema.String, "PermissionSaved.ID"> & {
56
78
  create: () => string & import("effect/Brand").Brand<"PermissionSaved.ID">;
57
79
  };
@@ -85,13 +107,16 @@ export declare const makePermissionGroup: <LocationId extends HttpApiMiddleware.
85
107
  };
86
108
  readonly effect: Schema.Literals<readonly ["allow", "deny", "ask"]>;
87
109
  }>;
88
- }>>, Schema.toCodecJson<typeof SessionNotFoundError>, SessionLocationId, HttpApiMiddleware.Requires<SessionLocationId>> | HttpApiEndpoint.HttpApiEndpoint<"session.permission.list", "GET", "/api/session/:sessionID/permission", Schema.toCodecStringTree<Schema.Struct<{
110
+ }>>, Schema.toCodecJson<typeof SessionNotFoundError>, SessionLocationId, HttpApiMiddleware.Requires<SessionLocationId>> | HttpApiEndpoint.HttpApiEndpoint<"session.permission.get", "GET", "/api/session/:sessionID/permission/:requestID", Schema.toCodecStringTree<Schema.Struct<{
89
111
  sessionID: Schema.brand<Schema.String, "SessionID"> & {
90
112
  create: () => string & import("effect/Brand").Brand<"SessionID">;
91
113
  descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
92
114
  };
115
+ requestID: Schema.brand<Schema.String, "Permission.ID"> & {
116
+ create: (id?: string) => string & import("effect/Brand").Brand<"Permission.ID">;
117
+ };
93
118
  }>>, never, never, never, Schema.toCodecJson<Schema.Struct<{
94
- readonly data: Schema.$Array<Schema.Struct<{
119
+ readonly data: Schema.Struct<{
95
120
  readonly sessionID: Schema.brand<Schema.String, "SessionID"> & {
96
121
  create: () => string & import("effect/Brand").Brand<"SessionID">;
97
122
  descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
@@ -113,17 +138,14 @@ export declare const makePermissionGroup: <LocationId extends HttpApiMiddleware.
113
138
  readonly id: Schema.brand<Schema.String, "Permission.ID"> & {
114
139
  create: (id?: string) => string & import("effect/Brand").Brand<"Permission.ID">;
115
140
  };
116
- }>>;
117
- }>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof SessionNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"session.permission.get", "GET", "/api/session/:sessionID/permission/:requestID", Schema.toCodecStringTree<Schema.Struct<{
141
+ }>;
142
+ }>>, Schema.toCodecJson<typeof SessionNotFoundError | typeof PermissionNotFoundError>, SessionLocationId, HttpApiMiddleware.Requires<SessionLocationId>> | HttpApiEndpoint.HttpApiEndpoint<"session.permission.list", "GET", "/api/session/:sessionID/permission", Schema.toCodecStringTree<Schema.Struct<{
118
143
  sessionID: Schema.brand<Schema.String, "SessionID"> & {
119
144
  create: () => string & import("effect/Brand").Brand<"SessionID">;
120
145
  descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
121
146
  };
122
- requestID: Schema.brand<Schema.String, "Permission.ID"> & {
123
- create: (id?: string) => string & import("effect/Brand").Brand<"Permission.ID">;
124
- };
125
147
  }>>, never, never, never, Schema.toCodecJson<Schema.Struct<{
126
- readonly data: Schema.Struct<{
148
+ readonly data: Schema.$Array<Schema.Struct<{
127
149
  readonly sessionID: Schema.brand<Schema.String, "SessionID"> & {
128
150
  create: () => string & import("effect/Brand").Brand<"SessionID">;
129
151
  descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
@@ -145,8 +167,8 @@ export declare const makePermissionGroup: <LocationId extends HttpApiMiddleware.
145
167
  readonly id: Schema.brand<Schema.String, "Permission.ID"> & {
146
168
  create: (id?: string) => string & import("effect/Brand").Brand<"Permission.ID">;
147
169
  };
148
- }>;
149
- }>>, Schema.toCodecJson<typeof SessionNotFoundError | typeof PermissionNotFoundError>, SessionLocationId, HttpApiMiddleware.Requires<SessionLocationId>> | HttpApiEndpoint.HttpApiEndpoint<"session.permission.reply", "POST", "/api/session/:sessionID/permission/:requestID/reply", Schema.toCodecStringTree<Schema.Struct<{
170
+ }>>;
171
+ }>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof SessionNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"session.permission.reply", "POST", "/api/session/:sessionID/permission/:requestID/reply", Schema.toCodecStringTree<Schema.Struct<{
150
172
  sessionID: Schema.brand<Schema.String, "SessionID"> & {
151
173
  create: () => string & import("effect/Brand").Brand<"SessionID">;
152
174
  descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
@@ -6,7 +6,7 @@ import { Project } from "@opencode/schema/project";
6
6
  import { Session } from "@opencode/schema/session";
7
7
  import { Context, Schema } from "effect";
8
8
  import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/http-api";
9
- import { LocationNotFoundError, PermissionNotFoundError, SessionNotFoundError } from "../errors.js";
9
+ import { ConflictError, LocationNotFoundError, PermissionNotFoundError, PermissionSavedNotFoundError, SessionNotFoundError, } from "../errors.js";
10
10
  import { LocationQuery, locationQueryOpenApi } from "./location.js";
11
11
  export const makePermissionGroup = (locationMiddleware, sessionLocationMiddleware) => HttpApiGroup.make("server.permission")
12
12
  .add(HttpApiEndpoint.get("permission.request.list", "/api/permission/request", {
@@ -26,6 +26,19 @@ export const makePermissionGroup = (locationMiddleware, sessionLocationMiddlewar
26
26
  identifier: "permission.saved.list",
27
27
  summary: "List saved permissions",
28
28
  description: "Retrieve saved permissions, optionally filtered by project.",
29
+ })))
30
+ .add(HttpApiEndpoint.patch("permission.saved.update", "/api/permission/saved/:id", {
31
+ params: { id: PermissionSaved.ID },
32
+ payload: Schema.Struct({
33
+ action: Schema.String.pipe(Schema.optional),
34
+ resource: Schema.String.pipe(Schema.optional),
35
+ }),
36
+ success: Schema.Struct({ data: PermissionSaved.Info }),
37
+ error: [PermissionSavedNotFoundError, ConflictError],
38
+ }).annotateMerge(OpenApi.annotations({
39
+ identifier: "permission.saved.update",
40
+ summary: "Update saved permission",
41
+ description: "Change the action or resource of a saved permission. Fails with a conflict when the project already has a saved permission with the same action and resource.",
29
42
  })))
30
43
  .add(HttpApiEndpoint.delete("permission.saved.remove", "/api/permission/saved/:id", {
31
44
  params: { id: PermissionSaved.ID },