@opencode/protocol 2.0.22 → 2.0.23

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/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { InvalidRequestError, SessionNotFoundError } from "./errors.js";
1
+ import { LocationNotFoundError, InvalidRequestError, SessionNotFoundError } from "./errors.js";
2
2
  import type { Api } from "./api.js";
3
3
  import type { Context } from "effect";
4
4
  import { HttpApiMiddleware } from "effect/unstable/httpapi";
@@ -6,21 +6,21 @@ import type { EventGroup } from "./groups/event.js";
6
6
  declare const LocationMiddleware_base: HttpApiMiddleware.ServiceClass<LocationMiddleware, "@opencode/client/LocationMiddleware", {
7
7
  requires: never;
8
8
  provides: never;
9
- error: never;
9
+ error: readonly [typeof LocationNotFoundError];
10
10
  clientError: never;
11
11
  requiredForClient: false;
12
12
  security: never;
13
- }, HttpApiMiddleware.HttpApiMiddleware<never, never, never>>;
13
+ }, HttpApiMiddleware.HttpApiMiddleware<never, readonly [typeof LocationNotFoundError], never>>;
14
14
  declare class LocationMiddleware extends LocationMiddleware_base {
15
15
  }
16
16
  declare const SessionLocationMiddleware_base: HttpApiMiddleware.ServiceClass<SessionLocationMiddleware, "@opencode/client/SessionLocationMiddleware", {
17
17
  requires: never;
18
18
  provides: never;
19
- error: readonly [typeof InvalidRequestError, typeof SessionNotFoundError];
19
+ error: readonly [typeof InvalidRequestError, typeof SessionNotFoundError, typeof LocationNotFoundError];
20
20
  clientError: never;
21
21
  requiredForClient: false;
22
22
  security: never;
23
- }, HttpApiMiddleware.HttpApiMiddleware<never, readonly [typeof InvalidRequestError, typeof SessionNotFoundError], never>>;
23
+ }, HttpApiMiddleware.HttpApiMiddleware<never, readonly [typeof InvalidRequestError, typeof SessionNotFoundError, typeof LocationNotFoundError], never>>;
24
24
  declare class SessionLocationMiddleware extends SessionLocationMiddleware_base {
25
25
  }
26
26
  type ClientApiShape = Api<Context.Service.Identifier<typeof LocationMiddleware>, Context.Service.Shape<typeof LocationMiddleware>, Context.Service.Identifier<typeof SessionLocationMiddleware>, Context.Service.Shape<typeof SessionLocationMiddleware>, Context.Service.Identifier<typeof SessionLocationMiddleware>, Context.Service.Shape<typeof SessionLocationMiddleware>, typeof EventGroup>;
package/dist/client.js CHANGED
@@ -1,9 +1,9 @@
1
- import { InvalidRequestError, SessionNotFoundError } from "./errors.js";
1
+ import { LocationNotFoundError, InvalidRequestError, SessionNotFoundError } from "./errors.js";
2
2
  import { makeDefaultApi } from "./api.js";
3
3
  import { HttpApiMiddleware } from "effect/unstable/httpapi";
4
- class LocationMiddleware extends HttpApiMiddleware.Service()("@opencode/client/LocationMiddleware") {
4
+ class LocationMiddleware extends HttpApiMiddleware.Service()("@opencode/client/LocationMiddleware", { error: [LocationNotFoundError] }) {
5
5
  }
6
- class SessionLocationMiddleware extends HttpApiMiddleware.Service()("@opencode/client/SessionLocationMiddleware", { error: [InvalidRequestError, SessionNotFoundError] }) {
6
+ class SessionLocationMiddleware extends HttpApiMiddleware.Service()("@opencode/client/SessionLocationMiddleware", { error: [InvalidRequestError, SessionNotFoundError, LocationNotFoundError] }) {
7
7
  }
8
8
  export const ClientApi = makeDefaultApi({
9
9
  locationMiddleware: LocationMiddleware,
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,12 @@
1
1
  import { Schema } from "effect";
2
+ declare const LocationNotFoundError_base: Schema.Class<LocationNotFoundError, Schema.TaggedStruct<"LocationNotFoundError", {
3
+ readonly location: Schema.Struct<{
4
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
5
+ }>;
6
+ readonly message: Schema.String;
7
+ }>, import("effect/Cause").YieldableError>;
8
+ export declare class LocationNotFoundError extends LocationNotFoundError_base {
9
+ }
2
10
  declare const InvalidRequestError_base: Schema.Class<InvalidRequestError, Schema.TaggedStruct<"InvalidRequestError", {
3
11
  readonly message: Schema.String;
4
12
  readonly kind: Schema.optional<Schema.String>;
package/dist/errors.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import { Schema } from "effect";
2
2
  import { Skill } from "@opencode/schema/skill";
3
+ import { Location } from "@opencode/schema/location";
4
+ export class LocationNotFoundError extends Schema.TaggedError()("LocationNotFoundError", { location: Location.PublicRef, message: Schema.String }, { httpApiStatus: 404 }) {
5
+ }
3
6
  export class InvalidRequestError extends Schema.TaggedError()("InvalidRequestError", {
4
7
  message: Schema.String,
5
8
  kind: Schema.optional(Schema.String),
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
3
- import { InvalidRequestError, ServiceUnavailableError } from "../errors.js";
3
+ import { LocationNotFoundError, InvalidRequestError, ServiceUnavailableError } from "../errors.js";
4
4
  export declare const GenerateGroup: HttpApiGroup.HttpApiGroup<"server.generate", HttpApiEndpoint.HttpApiEndpoint<"generate.text", "POST", "/api/experimental/generate", never, never, Schema.toCodecJson<Schema.Struct<{
5
5
  readonly prompt: Schema.String;
6
6
  readonly model: Schema.optional<Schema.Struct<{
@@ -30,4 +30,4 @@ export declare const GenerateGroup: HttpApiGroup.HttpApiGroup<"server.generate",
30
30
  readonly data: Schema.Struct<{
31
31
  readonly text: Schema.String;
32
32
  }>;
33
- }>>, Schema.toCodecJson<typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
33
+ }>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
@@ -1,7 +1,7 @@
1
1
  import { Model } from "@opencode/schema/model";
2
2
  import { Schema } from "effect";
3
3
  import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
4
- import { InvalidRequestError, ServiceUnavailableError } from "../errors.js";
4
+ import { LocationNotFoundError, InvalidRequestError, ServiceUnavailableError } from "../errors.js";
5
5
  export const GenerateGroup = HttpApiGroup.make("server.generate")
6
6
  .add(HttpApiEndpoint.post("generate.text", "/api/experimental/generate", {
7
7
  payload: Schema.Struct({
@@ -11,7 +11,7 @@ export const GenerateGroup = HttpApiGroup.make("server.generate")
11
11
  success: Schema.Struct({
12
12
  data: Schema.Struct({ text: Schema.String }),
13
13
  }).annotate({ identifier: "GenerateTextResponse" }),
14
- error: [InvalidRequestError, ServiceUnavailableError],
14
+ error: [InvalidRequestError, ServiceUnavailableError, LocationNotFoundError],
15
15
  }).annotateMerge(OpenApi.annotations({
16
16
  identifier: "experimental.generate.text",
17
17
  summary: "Generate text",
@@ -1,6 +1,6 @@
1
1
  import { Context, Schema } from "effect";
2
2
  import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema } from "effect/unstable/httpapi";
3
- import { PermissionNotFoundError, SessionNotFoundError } from "../errors.js";
3
+ import { LocationNotFoundError, PermissionNotFoundError, 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>;
@@ -114,7 +114,7 @@ export declare const makePermissionGroup: <LocationId extends HttpApiMiddleware.
114
114
  create: (id?: string) => string & import("effect/Brand").Brand<"Permission.ID">;
115
115
  };
116
116
  }>>;
117
- }>>, Schema.toCodecJson<typeof SessionNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"session.permission.get", "GET", "/api/session/:sessionID/permission/:requestID", Schema.toCodecStringTree<Schema.Struct<{
117
+ }>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof SessionNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"session.permission.get", "GET", "/api/session/:sessionID/permission/:requestID", Schema.toCodecStringTree<Schema.Struct<{
118
118
  sessionID: Schema.brand<Schema.String, "SessionID"> & {
119
119
  create: () => string & import("effect/Brand").Brand<"SessionID">;
120
120
  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/unstable/httpapi";
9
- import { PermissionNotFoundError, SessionNotFoundError } from "../errors.js";
9
+ import { LocationNotFoundError, PermissionNotFoundError, 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", {
@@ -62,7 +62,7 @@ export const makePermissionGroup = (locationMiddleware, sessionLocationMiddlewar
62
62
  .add(HttpApiEndpoint.get("session.permission.list", "/api/session/:sessionID/permission", {
63
63
  params: { sessionID: Session.ID },
64
64
  success: Schema.Struct({ data: Schema.Array(Permission.Request) }),
65
- error: SessionNotFoundError,
65
+ error: [SessionNotFoundError, LocationNotFoundError],
66
66
  }).annotateMerge(OpenApi.annotations({
67
67
  identifier: "session.permission.list",
68
68
  summary: "List session permission requests",
@@ -8,6 +8,9 @@ export declare const ServerInfo: Schema.Struct<{
8
8
  readonly paths: Schema.Struct<{
9
9
  readonly tmp: Schema.String;
10
10
  }>;
11
+ readonly capabilities: Schema.optional<Schema.Struct<{
12
+ readonly persistentPty: Schema.optional<Schema.Boolean>;
13
+ }>>;
11
14
  }>;
12
15
  export type ServerInfo = typeof ServerInfo.Type;
13
16
  export declare const PairingCode: Schema.Struct<{
@@ -27,6 +30,9 @@ export declare const ServerGroup: HttpApiGroup.HttpApiGroup<"server.server", Htt
27
30
  readonly paths: Schema.Struct<{
28
31
  readonly tmp: Schema.String;
29
32
  }>;
33
+ readonly capabilities: Schema.optional<Schema.Struct<{
34
+ readonly persistentPty: Schema.optional<Schema.Boolean>;
35
+ }>>;
30
36
  }>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"server.pair", "POST", "/api/pair", never, never, never, never, Schema.toCodecJson<Schema.Struct<{
31
37
  readonly code: Schema.String;
32
38
  readonly expires_in: Schema.Int;
@@ -9,6 +9,10 @@ export const ServerInfo = Schema.Struct({
9
9
  paths: Schema.Struct({
10
10
  tmp: Schema.String,
11
11
  }),
12
+ // Optional at every level so clients still decode servers that predate a capability.
13
+ capabilities: Schema.optional(Schema.Struct({
14
+ persistentPty: Schema.optional(Schema.Boolean),
15
+ })),
12
16
  }).annotate({ identifier: "ServerInfo" });
13
17
  export const PairingCode = Schema.Struct({
14
18
  code: Schema.String,
@@ -3,8 +3,7 @@ import { InstructionEntry } from "@opencode/schema/instruction-entry";
3
3
  import { Event } from "@opencode/schema/event";
4
4
  import { Context, Effect, Schema } from "effect";
5
5
  import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema } from "effect/unstable/httpapi";
6
- import { ConflictError, CommandExecutionError, CommandNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidCursorError, InvalidRequestError, MessageNotFoundError, ServiceUnavailableError, SessionBusyError, SessionNotFoundError, SkillNotFoundError, UnknownError } from "../errors.js";
7
- import { SessionEvent } from "@opencode/schema/session-event";
6
+ import { ConflictError, LocationNotFoundError, CommandExecutionError, CommandNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidCursorError, InvalidRequestError, MessageNotFoundError, ServiceUnavailableError, SessionBusyError, SessionNotFoundError, SkillNotFoundError, UnknownError } from "../errors.js";
8
7
  declare const SessionsCursorInput: Schema.Union<readonly [Schema.Struct<{
9
8
  readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
10
9
  readonly parentID: Schema.optional<Schema.Union<readonly [Schema.brand<Schema.String, "SessionID"> & {
@@ -1009,7 +1008,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
1009
1008
  readonly text: Schema.String;
1010
1009
  }>>, never, never>;
1011
1010
  }> & {
1012
- create: (input: SessionEvent.FileAttachment) => {
1011
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
1013
1012
  readonly data: string;
1014
1013
  readonly source: {
1015
1014
  readonly type: "inline";
@@ -1047,7 +1046,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
1047
1046
  readonly text: Schema.String;
1048
1047
  }>>, never, never>;
1049
1048
  }> & {
1050
- create: (input: SessionEvent.FileAttachment) => {
1049
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
1051
1050
  readonly data: string;
1052
1051
  readonly source: {
1053
1052
  readonly type: "inline";
@@ -2088,7 +2087,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
2088
2087
  readonly text: Schema.String;
2089
2088
  }>>, never, never>;
2090
2089
  }> & {
2091
- create: (input: SessionEvent.FileAttachment) => {
2090
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
2092
2091
  readonly data: string;
2093
2092
  readonly source: {
2094
2093
  readonly type: "inline";
@@ -2126,7 +2125,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
2126
2125
  readonly text: Schema.String;
2127
2126
  }>>, never, never>;
2128
2127
  }> & {
2129
- create: (input: SessionEvent.FileAttachment) => {
2128
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
2130
2129
  readonly data: string;
2131
2130
  readonly source: {
2132
2131
  readonly type: "inline";
@@ -3237,7 +3236,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
3237
3236
  readonly text: Schema.String;
3238
3237
  }>>, never, never>;
3239
3238
  }> & {
3240
- create: (input: SessionEvent.FileAttachment) => {
3239
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
3241
3240
  readonly data: string;
3242
3241
  readonly source: {
3243
3242
  readonly type: "inline";
@@ -3275,7 +3274,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
3275
3274
  readonly text: Schema.String;
3276
3275
  }>>, never, never>;
3277
3276
  }> & {
3278
- create: (input: SessionEvent.FileAttachment) => {
3277
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
3279
3278
  readonly data: string;
3280
3279
  readonly source: {
3281
3280
  readonly type: "inline";
@@ -3741,7 +3740,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
3741
3740
  readonly text: Schema.String;
3742
3741
  }>>, never, never>;
3743
3742
  }> & {
3744
- create: (input: SessionEvent.FileAttachment) => {
3743
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
3745
3744
  readonly data: string;
3746
3745
  readonly source: {
3747
3746
  readonly type: "inline";
@@ -3779,7 +3778,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
3779
3778
  readonly text: Schema.String;
3780
3779
  }>>, never, never>;
3781
3780
  }> & {
3782
- create: (input: SessionEvent.FileAttachment) => {
3781
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
3783
3782
  readonly data: string;
3784
3783
  readonly source: {
3785
3784
  readonly type: "inline";
@@ -4340,7 +4339,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
4340
4339
  readonly deletions: Schema.Int;
4341
4340
  readonly status: Schema.Literals<readonly ["added", "deleted", "modified"]>;
4342
4341
  }>>;
4343
- }>>, Schema.toCodecJson<typeof InvalidRequestError | typeof UnknownError | typeof SessionNotFoundError | typeof MessageNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"session.inbox.list", "GET", "/api/session/:sessionID/inbox", Schema.toCodecStringTree<Schema.Struct<{
4342
+ }>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof UnknownError | typeof SessionNotFoundError | typeof MessageNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"session.inbox.list", "GET", "/api/session/:sessionID/inbox", Schema.toCodecStringTree<Schema.Struct<{
4344
4343
  sessionID: Schema.brand<Schema.String, "SessionID"> & {
4345
4344
  create: () => string & import("effect/Brand").Brand<"SessionID">;
4346
4345
  descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
@@ -4372,7 +4371,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
4372
4371
  readonly text: Schema.String;
4373
4372
  }>>, never, never>;
4374
4373
  }> & {
4375
- create: (input: SessionEvent.FileAttachment) => {
4374
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
4376
4375
  readonly data: string;
4377
4376
  readonly source: {
4378
4377
  readonly type: "inline";
@@ -4410,7 +4409,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
4410
4409
  readonly text: Schema.String;
4411
4410
  }>>, never, never>;
4412
4411
  }> & {
4413
- create: (input: SessionEvent.FileAttachment) => {
4412
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
4414
4413
  readonly data: string;
4415
4414
  readonly source: {
4416
4415
  readonly type: "inline";
@@ -5626,7 +5625,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
5626
5625
  readonly text: Schema.String;
5627
5626
  }>>, never, never>;
5628
5627
  }> & {
5629
- create: (input: SessionEvent.FileAttachment) => {
5628
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
5630
5629
  readonly data: string;
5631
5630
  readonly source: {
5632
5631
  readonly type: "inline";
@@ -5664,7 +5663,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
5664
5663
  readonly text: Schema.String;
5665
5664
  }>>, never, never>;
5666
5665
  }> & {
5667
- create: (input: SessionEvent.FileAttachment) => {
5666
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
5668
5667
  readonly data: string;
5669
5668
  readonly source: {
5670
5669
  readonly type: "inline";
@@ -5809,7 +5808,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
5809
5808
  readonly text: Schema.String;
5810
5809
  }>>, never, never>;
5811
5810
  }> & {
5812
- create: (input: SessionEvent.FileAttachment) => {
5811
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
5813
5812
  readonly data: string;
5814
5813
  readonly source: {
5815
5814
  readonly type: "inline";
@@ -5847,7 +5846,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
5847
5846
  readonly text: Schema.String;
5848
5847
  }>>, never, never>;
5849
5848
  }> & {
5850
- create: (input: SessionEvent.FileAttachment) => {
5849
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
5851
5850
  readonly data: string;
5852
5851
  readonly source: {
5853
5852
  readonly type: "inline";
@@ -10327,7 +10326,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
10327
10326
  readonly text: Schema.String;
10328
10327
  }>>, never, never>;
10329
10328
  }> & {
10330
- create: (input: SessionEvent.FileAttachment) => {
10329
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
10331
10330
  readonly data: string;
10332
10331
  readonly source: {
10333
10332
  readonly type: "inline";
@@ -10365,7 +10364,7 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
10365
10364
  readonly text: Schema.String;
10366
10365
  }>>, never, never>;
10367
10366
  }> & {
10368
- create: (input: SessionEvent.FileAttachment) => {
10367
+ create: (input: import("@opencode/schema/prompt").FileAttachment) => {
10369
10368
  readonly data: string;
10370
10369
  readonly source: {
10371
10370
  readonly type: "inline";
@@ -9,7 +9,7 @@ import { AbsolutePath, DateTimeUtcFromMillis, NonNegativeInt, PositiveInt, Relat
9
9
  import { Event } from "@opencode/schema/event";
10
10
  import { Context, Effect, Encoding, Result, Schema, SchemaGetter, Struct } from "effect";
11
11
  import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
12
- import { ConflictError, CommandExecutionError, CommandNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidCursorError, InvalidRequestError, MessageNotFoundError, ServiceUnavailableError, SessionBusyError, SessionNotFoundError, SkillNotFoundError, UnknownError, } from "../errors.js";
12
+ import { ConflictError, LocationNotFoundError, CommandExecutionError, CommandNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidCursorError, InvalidRequestError, MessageNotFoundError, ServiceUnavailableError, SessionBusyError, SessionNotFoundError, SkillNotFoundError, UnknownError, } from "../errors.js";
13
13
  import { Agent } from "@opencode/schema/agent";
14
14
  import { Skill } from "@opencode/schema/skill";
15
15
  import { Model } from "@opencode/schema/model";
@@ -435,7 +435,7 @@ export const makeSessionGroup = (sessionLocationMiddleware, formLocationMiddlewa
435
435
  }),
436
436
  }),
437
437
  success: Schema.Struct({ data: Schema.Array(FileDiff.Info) }),
438
- error: [InvalidRequestError, MessageNotFoundError, SessionNotFoundError, UnknownError],
438
+ error: [InvalidRequestError, MessageNotFoundError, SessionNotFoundError, UnknownError, LocationNotFoundError],
439
439
  }).annotateMerge(OpenApi.annotations({
440
440
  identifier: "session.diff",
441
441
  summary: "Diff session turns",
@@ -1,7 +1,18 @@
1
1
  import { Schema } from "effect";
2
- import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
3
- import { ServiceUnavailableError } from "../errors.js";
4
- export declare const VcsGroup: HttpApiGroup.HttpApiGroup<"server.vcs", HttpApiEndpoint.HttpApiEndpoint<"vcs.get", "GET", "/api/vcs", never, Schema.toCodecStringTree<Schema.Struct<{
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
3
+ import { ConflictError, InvalidRequestError, ServiceUnavailableError } from "../errors.js";
4
+ declare const VcsInitNotSupportedError_base: Schema.Class<VcsInitNotSupportedError, Schema.TaggedStruct<"VcsInitNotSupportedError", {
5
+ readonly providerID: Schema.String;
6
+ readonly message: Schema.String;
7
+ }>, import("effect/Cause").YieldableError>;
8
+ export declare class VcsInitNotSupportedError extends VcsInitNotSupportedError_base {
9
+ }
10
+ export declare const VcsGroup: HttpApiGroup.HttpApiGroup<"server.vcs", HttpApiEndpoint.HttpApiEndpoint<"vcs.init", "POST", "/api/vcs/init", never, Schema.toCodecStringTree<Schema.Struct<{
11
+ readonly provider: Schema.optional<Schema.String>;
12
+ readonly location: Schema.optional<Schema.Struct<{
13
+ readonly directory: Schema.optional<Schema.String>;
14
+ }>>;
15
+ }>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof InvalidRequestError | typeof ConflictError | typeof ServiceUnavailableError | typeof VcsInitNotSupportedError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"vcs.get", "GET", "/api/vcs", never, Schema.toCodecStringTree<Schema.Struct<{
5
16
  readonly location: Schema.optional<Schema.Struct<{
6
17
  readonly directory: Schema.optional<Schema.String>;
7
18
  }>>;
@@ -73,3 +84,4 @@ export declare const VcsGroup: HttpApiGroup.HttpApiGroup<"server.vcs", HttpApiEn
73
84
  readonly status: Schema.Literals<readonly ["added", "deleted", "modified"]>;
74
85
  }>>;
75
86
  }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never>, false>;
87
+ export {};
@@ -3,9 +3,15 @@ import { Location } from "@opencode/schema/location";
3
3
  import { NonNegativeInt, PositiveInt, optional } from "@opencode/schema/schema";
4
4
  import { Vcs } from "@opencode/schema/vcs";
5
5
  import { Schema } from "effect";
6
- import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
6
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
7
7
  import { LocationQuery, locationQueryOpenApi } from "./location.js";
8
- import { ServiceUnavailableError } from "../errors.js";
8
+ import { ConflictError, InvalidRequestError, ServiceUnavailableError } from "../errors.js";
9
+ const InitQuery = Schema.Struct({
10
+ ...LocationQuery.fields,
11
+ provider: Schema.optional(Schema.String),
12
+ });
13
+ export class VcsInitNotSupportedError extends Schema.TaggedError()("VcsInitNotSupportedError", { providerID: Schema.String, message: Schema.String }, { httpApiStatus: 501 }) {
14
+ }
9
15
  const BranchesQuery = Schema.Struct({
10
16
  ...LocationQuery.fields,
11
17
  search: Schema.optional(Schema.String),
@@ -18,6 +24,17 @@ const DiffQuery = Schema.Struct({
18
24
  context: Schema.NumberFromString.pipe(Schema.decodeTo(NonNegativeInt), Schema.optional),
19
25
  });
20
26
  export const VcsGroup = HttpApiGroup.make("server.vcs")
27
+ .add(HttpApiEndpoint.post("vcs.init", "/api/vcs/init", {
28
+ query: InitQuery,
29
+ success: HttpApiSchema.NoContent,
30
+ error: [ConflictError, InvalidRequestError, VcsInitNotSupportedError, ServiceUnavailableError],
31
+ })
32
+ .annotateMerge(locationQueryOpenApi)
33
+ .annotateMerge(OpenApi.annotations({
34
+ identifier: "vcs.init",
35
+ summary: "Initialize VCS repository",
36
+ description: "Initialize a repository using the selected VCS provider in a markerless project's directory and refresh its location services. Omitting provider defaults to git; built-in git and hg providers support initialization. An unknown provider returns 400; a registered provider without init returns 501.",
37
+ })))
21
38
  .add(HttpApiEndpoint.get("vcs.get", "/api/vcs", {
22
39
  query: LocationQuery,
23
40
  success: Location.response(Vcs.Info),
@@ -1,7 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
3
3
  import { ProjectNotFoundError } from "../errors.js";
4
- declare const WorktreeError_base: Schema.Class<WorktreeError, Schema.Struct<{
4
+ declare const WorktreeError_base: Schema.Class<WorktreeError, Schema.TaggedStruct<"WorktreeError", {
5
5
  readonly name: Schema.Literal<"WorktreeError">;
6
6
  readonly data: Schema.Struct<{
7
7
  readonly message: Schema.String;
@@ -4,7 +4,7 @@ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/un
4
4
  import { Project } from "@opencode/schema/project";
5
5
  import { ProjectNotFoundError } from "../errors.js";
6
6
  const root = "/api/worktree";
7
- export class WorktreeError extends Schema.Error("WorktreeError")({
7
+ export class WorktreeError extends Schema.TaggedError()("WorktreeError", {
8
8
  name: Schema.Literal("WorktreeError"),
9
9
  data: Schema.Struct({
10
10
  message: Schema.String,
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": "2.0.22",
4
+ "version": "2.0.23",
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": "2.0.22",
35
+ "@opencode/schema": "2.0.23",
36
36
  "effect": "4.0.0-rc.112"
37
37
  },
38
38
  "devDependencies": {