@opencode/protocol 0.0.0-dev-20691 → 0.0.0-dev-20696

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.
package/dist/api.d.ts CHANGED
@@ -18,7 +18,7 @@ import { AgentGroup } from "./groups/agent.js";
18
18
  import { PluginGroup } from "./groups/plugin.js";
19
19
  import { ServerGroup } from "./groups/server.js";
20
20
  import { DebugGroup } from "./groups/debug.js";
21
- import { PtyGroup } from "./groups/pty.js";
21
+ import { makePtyGroup } from "./groups/pty.js";
22
22
  import { PersistentPtyGroup } from "./groups/persistent-pty.js";
23
23
  import { ShellGroup } from "./groups/shell.js";
24
24
  import { ReferenceGroup } from "./groups/reference.js";
@@ -33,12 +33,13 @@ import { WorktreeGroup } from "./groups/worktree.js";
33
33
  import { VcsGroup } from "./groups/vcs.js";
34
34
  import { MigrationGroup } from "./groups/migration.js";
35
35
  import { ConfigGroup } from "./groups/config.js";
36
- 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 PtyGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ShellGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ReferenceGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof VcsGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ConfigGroup, LocationId>;
36
+ 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>;
37
+ type PtyGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService> = ReturnType<typeof makePtyGroup<LocationId, LocationService>>;
37
38
  type SessionGroups<SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService, FormLocationId extends HttpApiMiddleware.AnyId, FormLocationService> = ReturnType<typeof makeSessionGroup<SessionLocationId, SessionLocationService, FormLocationId, FormLocationService>> | typeof MessageGroup;
38
39
  type FormGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService> = ReturnType<typeof makeFormGroup<LocationId, LocationService>>;
39
40
  type LocationGroup<LocationId extends HttpApiMiddleware.AnyId, LocationService> = ReturnType<typeof makeLocationGroup<LocationId, LocationService>>;
40
41
  type MixedMiddlewareGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService> = ReturnType<typeof makePermissionGroup<LocationId, LocationService, SessionLocationId, SessionLocationService>>;
41
- 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 PersistentPtyGroup | typeof CredentialGroup | LocationGroups<LocationId> | LocationGroup<LocationId, LocationService> | FormGroups<LocationId, LocationService> | SessionGroups<SessionLocationId, SessionLocationService, FormLocationId, FormLocationService> | MixedMiddlewareGroups<LocationId, LocationService, SessionLocationId, SessionLocationService> | Event;
42
+ 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 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;
42
43
  type EventGroupFor<Definitions extends ReadonlyArray<Definition>> = ReturnType<typeof makeEventGroup<Definitions>>;
43
44
  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>>;
44
45
  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
@@ -17,7 +17,7 @@ import { AgentGroup } from "./groups/agent.js";
17
17
  import { PluginGroup } from "./groups/plugin.js";
18
18
  import { ServerGroup } from "./groups/server.js";
19
19
  import { DebugGroup } from "./groups/debug.js";
20
- import { PtyGroup } from "./groups/pty.js";
20
+ import { makePtyGroup } from "./groups/pty.js";
21
21
  import { PersistentPtyGroup } from "./groups/persistent-pty.js";
22
22
  import { ShellGroup } from "./groups/shell.js";
23
23
  import { ReferenceGroup } from "./groups/reference.js";
@@ -54,7 +54,7 @@ const makeApiFromGroup = (eventGroup, locationMiddleware, formLocationMiddleware
54
54
  .add(SkillGroup.middleware(locationMiddleware))
55
55
  .add(RpcGroup.middleware(locationMiddleware))
56
56
  .add(eventGroup)
57
- .add(PtyGroup.middleware(locationMiddleware))
57
+ .add(makePtyGroup(locationMiddleware))
58
58
  .add(PersistentPtyGroup)
59
59
  .add(ShellGroup.middleware(locationMiddleware))
60
60
  .add(ReferenceGroup.middleware(locationMiddleware))
@@ -1,11 +1,11 @@
1
- import { Schema } from "effect";
2
- import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
3
- import { ForbiddenError, PtyNotFoundError } from "../errors.js";
1
+ import { Context, Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema } from "effect/unstable/httpapi";
3
+ import { ForbiddenError, LocationNotFoundError, PtyNotFoundError } from "../errors.js";
4
4
  export declare const PTY_CONNECT_TICKET_QUERY = "ticket";
5
5
  export declare const PTY_CONNECT_TOKEN_HEADER = "x-opencode-ticket";
6
6
  export declare const PTY_CONNECT_TOKEN_HEADER_VALUE = "1";
7
7
  export declare function hasPtyConnectTicketURL(url: URL): boolean;
8
- export declare const PtyGroup: HttpApiGroup.HttpApiGroup<"server.pty", HttpApiEndpoint.HttpApiEndpoint<"pty.list", "GET", "/api/pty", never, Schema.toCodecStringTree<Schema.Struct<{
8
+ export declare const makePtyGroup: <LocationId extends HttpApiMiddleware.AnyId, LocationService>(locationMiddleware: Context.Key<LocationId, LocationService>) => HttpApiGroup.HttpApiGroup<"server.pty", HttpApiEndpoint.HttpApiEndpoint<"pty.list", "GET", "/api/pty", never, Schema.toCodecStringTree<Schema.Struct<{
9
9
  readonly location: Schema.optional<Schema.Struct<{
10
10
  readonly directory: Schema.optional<Schema.String>;
11
11
  }>>;
@@ -26,7 +26,7 @@ export declare const PtyGroup: HttpApiGroup.HttpApiGroup<"server.pty", HttpApiEn
26
26
  readonly pid: Schema.Int;
27
27
  readonly exitCode: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
28
28
  }>>;
29
- }>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"pty.create", "POST", "/api/pty", never, Schema.toCodecStringTree<Schema.Struct<{
29
+ }>>, never, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.create", "POST", "/api/pty", never, Schema.toCodecStringTree<Schema.Struct<{
30
30
  readonly location: Schema.optional<Schema.Struct<{
31
31
  readonly directory: Schema.optional<Schema.String>;
32
32
  }>>;
@@ -53,7 +53,7 @@ export declare const PtyGroup: HttpApiGroup.HttpApiGroup<"server.pty", HttpApiEn
53
53
  readonly pid: Schema.Int;
54
54
  readonly exitCode: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
55
55
  }>;
56
- }>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"pty.get", "GET", "/api/pty/:ptyID", Schema.toCodecStringTree<Schema.Struct<{
56
+ }>>, never, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.get", "GET", "/api/pty/:ptyID", Schema.toCodecStringTree<Schema.Struct<{
57
57
  ptyID: Schema.brand<Schema.String, "PtyID"> & {
58
58
  create: () => string & import("effect/Brand").Brand<"PtyID">;
59
59
  ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
@@ -79,7 +79,7 @@ export declare const PtyGroup: HttpApiGroup.HttpApiGroup<"server.pty", HttpApiEn
79
79
  readonly pid: Schema.Int;
80
80
  readonly exitCode: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
81
81
  }>;
82
- }>>, Schema.toCodecJson<typeof PtyNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"pty.update", "PUT", "/api/pty/:ptyID", Schema.toCodecStringTree<Schema.Struct<{
82
+ }>>, Schema.toCodecJson<typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.update", "PUT", "/api/pty/:ptyID", Schema.toCodecStringTree<Schema.Struct<{
83
83
  ptyID: Schema.brand<Schema.String, "PtyID"> & {
84
84
  create: () => string & import("effect/Brand").Brand<"PtyID">;
85
85
  ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
@@ -114,7 +114,7 @@ export declare const PtyGroup: HttpApiGroup.HttpApiGroup<"server.pty", HttpApiEn
114
114
  readonly pid: Schema.Int;
115
115
  readonly exitCode: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
116
116
  }>;
117
- }>>, Schema.toCodecJson<typeof PtyNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"pty.remove", "DELETE", "/api/pty/:ptyID", Schema.toCodecStringTree<Schema.Struct<{
117
+ }>>, Schema.toCodecJson<typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.remove", "DELETE", "/api/pty/:ptyID", Schema.toCodecStringTree<Schema.Struct<{
118
118
  ptyID: Schema.brand<Schema.String, "PtyID"> & {
119
119
  create: () => string & import("effect/Brand").Brand<"PtyID">;
120
120
  ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
@@ -123,7 +123,7 @@ export declare const PtyGroup: HttpApiGroup.HttpApiGroup<"server.pty", HttpApiEn
123
123
  readonly location: Schema.optional<Schema.Struct<{
124
124
  readonly directory: Schema.optional<Schema.String>;
125
125
  }>>;
126
- }>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof PtyNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"pty.connectToken", "POST", "/api/pty/:ptyID/connect-token", Schema.toCodecStringTree<Schema.Struct<{
126
+ }>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.connectToken", "POST", "/api/pty/:ptyID/connect-token", Schema.toCodecStringTree<Schema.Struct<{
127
127
  ptyID: Schema.brand<Schema.String, "PtyID"> & {
128
128
  create: () => string & import("effect/Brand").Brand<"PtyID">;
129
129
  ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
@@ -142,9 +142,9 @@ export declare const PtyGroup: HttpApiGroup.HttpApiGroup<"server.pty", HttpApiEn
142
142
  readonly ticket: Schema.String;
143
143
  readonly expires_in: Schema.Int;
144
144
  }>;
145
- }>>, Schema.toCodecJson<typeof ForbiddenError | typeof PtyNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"pty.connect", "GET", "/api/pty/:ptyID/connect", Schema.toCodecStringTree<Schema.Struct<{
145
+ }>>, Schema.toCodecJson<typeof ForbiddenError | typeof PtyNotFoundError>, LocationId, HttpApiMiddleware.Requires<LocationId>> | HttpApiEndpoint.HttpApiEndpoint<"pty.connect", "GET", "/api/pty/:ptyID/connect", Schema.toCodecStringTree<Schema.Struct<{
146
146
  ptyID: Schema.brand<Schema.String, "PtyID"> & {
147
147
  create: () => string & import("effect/Brand").Brand<"PtyID">;
148
148
  ascending: (id?: string) => string & import("effect/Brand").Brand<"PtyID">;
149
149
  };
150
- }>>, never, never, never, Schema.toCodecJson<Schema.Boolean>, Schema.toCodecJson<typeof ForbiddenError | typeof PtyNotFoundError>, never, never>, false>;
150
+ }>>, never, never, never, Schema.toCodecJson<Schema.Boolean>, Schema.toCodecJson<typeof LocationNotFoundError | typeof ForbiddenError | typeof PtyNotFoundError>, never, never>, false>;
@@ -1,9 +1,9 @@
1
1
  import { Pty } from "@opencode/schema/pty";
2
2
  import { PtyTicket } from "@opencode/schema/pty-ticket";
3
3
  import { Location } from "@opencode/schema/location";
4
- import { Schema } from "effect";
5
- import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
6
- import { ForbiddenError, PtyNotFoundError } from "../errors.js";
4
+ import { Context, Schema } from "effect";
5
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
6
+ import { ForbiddenError, LocationNotFoundError, PtyNotFoundError } from "../errors.js";
7
7
  import { LocationQuery, locationQueryOpenApi } from "./location.js";
8
8
  export const PTY_CONNECT_TICKET_QUERY = "ticket";
9
9
  export const PTY_CONNECT_TOKEN_HEADER = "x-opencode-ticket";
@@ -14,7 +14,7 @@ const PTY_CONNECT_PATH = /^\/api\/pty\/[^/]+\/connect$/;
14
14
  export function hasPtyConnectTicketURL(url) {
15
15
  return PTY_CONNECT_PATH.test(url.pathname) && !!url.searchParams.get(PTY_CONNECT_TICKET_QUERY);
16
16
  }
17
- export const PtyGroup = HttpApiGroup.make("server.pty")
17
+ export const makePtyGroup = (locationMiddleware) => HttpApiGroup.make("server.pty")
18
18
  .add(HttpApiEndpoint.get("pty.list", "/api/pty", {
19
19
  query: LocationQuery,
20
20
  success: Location.response(Schema.Array(Pty.Info)),
@@ -86,13 +86,13 @@ export const PtyGroup = HttpApiGroup.make("server.pty")
86
86
  summary: "Create PTY WebSocket token",
87
87
  description: "Create a short-lived single-use ticket for opening a PTY WebSocket connection.",
88
88
  })))
89
+ .middleware(locationMiddleware)
89
90
  .add(
90
- // Query fields are decoded in the raw handler after the existence check so a missing
91
- // session responds with an empty 404 before any upgrade work.
91
+ // Query fields are decoded in the raw handler before upgrade work.
92
92
  HttpApiEndpoint.get("pty.connect", "/api/pty/:ptyID/connect", {
93
93
  params: { ptyID: Pty.ID },
94
94
  success: Schema.Boolean,
95
- error: [ForbiddenError, PtyNotFoundError],
95
+ error: [ForbiddenError, PtyNotFoundError, LocationNotFoundError],
96
96
  }).annotateMerge(OpenApi.annotations({
97
97
  identifier: "pty.connect",
98
98
  summary: "Connect to PTY session",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/protocol",
4
- "version": "0.0.0-dev-20691",
4
+ "version": "0.0.0-dev-20696",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -32,7 +32,7 @@
32
32
  "typecheck": "tsgo --noEmit"
33
33
  },
34
34
  "dependencies": {
35
- "@opencode/schema": "0.0.0-dev-20691",
35
+ "@opencode/schema": "0.0.0-dev-20696",
36
36
  "effect": "4.0.0-rc.112"
37
37
  },
38
38
  "devDependencies": {