@opencode/protocol 0.0.0-dev-19654 → 0.0.0-dev-19657

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,95 +1,18 @@
1
1
  import { Form } from "@opencode/schema/form";
2
2
  import { Location } from "@opencode/schema/location";
3
3
  import { Context, Schema } from "effect";
4
- import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
5
- import { ConflictError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidRequestError, SessionNotFoundError, } from "../errors.js";
4
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, OpenApi } from "effect/unstable/httpapi";
6
5
  import { LocationQuery, locationQueryOpenApi } from "./location.js";
7
- const CreatePayload = Schema.Struct({
8
- id: Form.ID.pipe(Schema.optional),
9
- title: Form.Info.fields.title,
10
- metadata: Form.Info.fields.metadata,
11
- fields: Form.Info.fields.fields,
12
- }).annotate({ identifier: "Form.CreatePayload" });
13
- // Form routes intentionally look session-scoped, but use a form-specific middleware instead of
14
- // SessionLocationMiddleware. The middleware treats real session IDs normally and has an
15
- // undocumented `global` sentinel branch for MCP elicitation forms that are still Location-scoped
16
- // but not session-owned. This is temporary and should disappear once elicitations are attributable.
17
- export const makeFormGroup = (locationMiddleware, formLocationMiddleware) => HttpApiGroup.make("server.form")
18
- .add(HttpApiEndpoint.get("form.request.list", "/api/form/request", {
6
+ export const makeFormGroup = (locationMiddleware) => HttpApiGroup.make("server.form")
7
+ .add(HttpApiEndpoint.get("form.list", "/api/form", {
19
8
  query: LocationQuery,
20
9
  success: Location.response(Schema.Array(Form.Info)),
21
10
  })
22
11
  .annotateMerge(locationQueryOpenApi)
23
12
  .annotateMerge(OpenApi.annotations({
24
- identifier: "form.request.list",
25
- summary: "List pending form requests",
13
+ identifier: "form.list",
14
+ summary: "List pending forms",
26
15
  description: "Retrieve pending forms for a location.",
27
16
  })))
28
17
  .middleware(locationMiddleware)
29
- .add(HttpApiEndpoint.get("session.form.list", "/api/session/:sessionID/form", {
30
- params: { sessionID: Schema.String },
31
- success: Schema.Struct({ data: Schema.Array(Form.Info) }),
32
- error: SessionNotFoundError,
33
- }).annotateMerge(OpenApi.annotations({
34
- identifier: "session.form.list",
35
- summary: "List session forms",
36
- description: "Retrieve pending forms for a session.",
37
- })))
38
- .add(HttpApiEndpoint.post("session.form.create", "/api/session/:sessionID/form", {
39
- params: { sessionID: Schema.String },
40
- payload: CreatePayload,
41
- success: Schema.Struct({ data: Form.Info }),
42
- error: [SessionNotFoundError, ConflictError, InvalidRequestError],
43
- })
44
- .middleware(formLocationMiddleware)
45
- .annotateMerge(OpenApi.annotations({
46
- identifier: "session.form.create",
47
- summary: "Create session form",
48
- description: "Create a form for a session.",
49
- })))
50
- .add(HttpApiEndpoint.get("session.form.get", "/api/session/:sessionID/form/:formID", {
51
- params: { sessionID: Schema.String, formID: Form.ID },
52
- success: Schema.Struct({ data: Form.Info }),
53
- error: [SessionNotFoundError, FormNotFoundError],
54
- })
55
- .middleware(formLocationMiddleware)
56
- .annotateMerge(OpenApi.annotations({
57
- identifier: "session.form.get",
58
- summary: "Get session form",
59
- description: "Retrieve a form for a session.",
60
- })))
61
- .add(HttpApiEndpoint.get("session.form.state", "/api/session/:sessionID/form/:formID/state", {
62
- params: { sessionID: Schema.String, formID: Form.ID },
63
- success: Schema.Struct({ data: Form.State }),
64
- error: [SessionNotFoundError, FormNotFoundError],
65
- })
66
- .middleware(formLocationMiddleware)
67
- .annotateMerge(OpenApi.annotations({
68
- identifier: "session.form.state",
69
- summary: "Get form state",
70
- description: "Retrieve the current state for a form.",
71
- })))
72
- .add(HttpApiEndpoint.post("session.form.reply", "/api/session/:sessionID/form/:formID/reply", {
73
- params: { sessionID: Schema.String, formID: Form.ID },
74
- payload: Form.Reply,
75
- success: HttpApiSchema.NoContent,
76
- error: [SessionNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError],
77
- })
78
- .middleware(formLocationMiddleware)
79
- .annotateMerge(OpenApi.annotations({
80
- identifier: "session.form.reply",
81
- summary: "Reply to form",
82
- description: "Submit an answer to a pending form.",
83
- })))
84
- .add(HttpApiEndpoint.post("session.form.cancel", "/api/session/:sessionID/form/:formID/cancel", {
85
- params: { sessionID: Schema.String, formID: Form.ID },
86
- success: HttpApiSchema.NoContent,
87
- error: [SessionNotFoundError, FormAlreadySettledError, FormNotFoundError],
88
- })
89
- .middleware(formLocationMiddleware)
90
- .annotateMerge(OpenApi.annotations({
91
- identifier: "session.form.cancel",
92
- summary: "Cancel form",
93
- description: "Cancel a pending form.",
94
- })))
95
- .annotateMerge(OpenApi.annotations({ title: "form", description: "Session form routes." }));
18
+ .annotateMerge(OpenApi.annotations({ title: "form", description: "Location form routes." }));
@@ -46,6 +46,10 @@ export declare const makePermissionGroup: <LocationId extends HttpApiMiddleware.
46
46
  };
47
47
  readonly action: Schema.String;
48
48
  readonly resource: Schema.String;
49
+ readonly time: Schema.Struct<{
50
+ readonly created: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
51
+ readonly updated: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
52
+ }>;
49
53
  }>>;
50
54
  }>>, never, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"permission.saved.remove", "DELETE", "/api/permission/saved/:id", Schema.toCodecStringTree<Schema.Struct<{
51
55
  id: Schema.brand<Schema.String, "PermissionSaved.ID"> & {
@@ -151,17 +155,6 @@ export declare const makePermissionGroup: <LocationId extends HttpApiMiddleware.
151
155
  create: (id?: string) => string & import("effect/Brand").Brand<"Permission.ID">;
152
156
  };
153
157
  }>>, never, Schema.toCodecJson<Schema.Struct<{
154
- readonly reply: Schema.Literals<readonly ["once", "always", "reject"]>;
158
+ readonly decision: Schema.Literals<readonly ["once", "always", "reject"]>;
155
159
  readonly message: Schema.optional<Schema.String>;
156
- }>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof SessionNotFoundError | typeof PermissionNotFoundError>, SessionLocationId, HttpApiMiddleware.Requires<SessionLocationId>> | HttpApiEndpoint.HttpApiEndpoint<"session.permission.rules", "PUT", "/api/session/:sessionID/permission/rules", Schema.toCodecStringTree<Schema.Struct<{
157
- sessionID: Schema.brand<Schema.String, "SessionID"> & {
158
- create: () => string & import("effect/Brand").Brand<"SessionID">;
159
- descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
160
- };
161
- }>>, never, Schema.toCodecJson<Schema.Struct<{
162
- readonly permissions: Schema.$Array<Schema.Struct<{
163
- readonly action: Schema.String;
164
- readonly resource: Schema.String;
165
- readonly effect: Schema.Literals<readonly ["allow", "deny", "ask"]>;
166
- }>>;
167
- }>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof SessionNotFoundError>, SessionLocationId, HttpApiMiddleware.Requires<SessionLocationId>>, false>;
160
+ }>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof SessionNotFoundError | typeof PermissionNotFoundError>, SessionLocationId, HttpApiMiddleware.Requires<SessionLocationId>>, false>;
@@ -82,7 +82,7 @@ export const makePermissionGroup = (locationMiddleware, sessionLocationMiddlewar
82
82
  .add(HttpApiEndpoint.post("session.permission.reply", "/api/session/:sessionID/permission/:requestID/reply", {
83
83
  params: { sessionID: Session.ID, requestID: Permission.ID },
84
84
  payload: Schema.Struct({
85
- reply: Permission.Reply,
85
+ decision: Permission.Reply,
86
86
  message: Schema.String.pipe(Schema.optional),
87
87
  }),
88
88
  success: HttpApiSchema.NoContent,
@@ -93,17 +93,5 @@ export const makePermissionGroup = (locationMiddleware, sessionLocationMiddlewar
93
93
  identifier: "session.permission.reply",
94
94
  summary: "Reply to pending permission request",
95
95
  description: "Respond to a pending permission request owned by a session.",
96
- })))
97
- .add(HttpApiEndpoint.put("session.permission.rules", "/api/session/:sessionID/permission/rules", {
98
- params: { sessionID: Session.ID },
99
- payload: Schema.Struct({ permissions: Permission.Ruleset }),
100
- success: HttpApiSchema.NoContent,
101
- error: SessionNotFoundError,
102
- })
103
- .middleware(sessionLocationMiddleware)
104
- .annotateMerge(OpenApi.annotations({
105
- identifier: "session.permission.rules",
106
- summary: "Replace session permission rules",
107
- description: "Replace the session-scoped permission rules. Rules are evaluated after the agent's rules, and the last matching rule wins.",
108
96
  })))
109
97
  .annotateMerge(OpenApi.annotations({ title: "permission", description: "Experimental permission routes." }));