@opencode-ai/protocol 0.0.0-next-14661

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 (57) hide show
  1. package/dist/api.d.ts +44 -0
  2. package/dist/api.js +61 -0
  3. package/dist/client.d.ts +69 -0
  4. package/dist/client.js +52 -0
  5. package/dist/errors.d.ts +97 -0
  6. package/dist/errors.js +74 -0
  7. package/dist/groups/agent.d.ts +91 -0
  8. package/dist/groups/agent.js +15 -0
  9. package/dist/groups/command.d.ts +51 -0
  10. package/dist/groups/command.js +20 -0
  11. package/dist/groups/credential.d.ts +23 -0
  12. package/dist/groups/credential.js +28 -0
  13. package/dist/groups/event.d.ts +16086 -0
  14. package/dist/groups/event.js +42 -0
  15. package/dist/groups/fs.d.ts +35 -0
  16. package/dist/groups/fs.js +51 -0
  17. package/dist/groups/generate.d.ts +32 -0
  18. package/dist/groups/generate.js +27 -0
  19. package/dist/groups/health.d.ts +5 -0
  20. package/dist/groups/health.js +9 -0
  21. package/dist/groups/integration.d.ts +105 -0
  22. package/dist/groups/integration.js +98 -0
  23. package/dist/groups/location.d.ts +16 -0
  24. package/dist/groups/location.js +32 -0
  25. package/dist/groups/mcp.d.ts +30 -0
  26. package/dist/groups/mcp.js +17 -0
  27. package/dist/groups/message.d.ts +409 -0
  28. package/dist/groups/message.js +37 -0
  29. package/dist/groups/model.d.ts +151 -0
  30. package/dist/groups/model.js +22 -0
  31. package/dist/groups/permission.d.ts +153 -0
  32. package/dist/groups/permission.js +99 -0
  33. package/dist/groups/plugin.d.ts +14 -0
  34. package/dist/groups/plugin.js +20 -0
  35. package/dist/groups/project-copy.d.ts +49 -0
  36. package/dist/groups/project-copy.js +44 -0
  37. package/dist/groups/project.d.ts +24 -0
  38. package/dist/groups/project.js +30 -0
  39. package/dist/groups/provider.d.ts +156 -0
  40. package/dist/groups/provider.js +34 -0
  41. package/dist/groups/pty.d.ts +145 -0
  42. package/dist/groups/pty.js +111 -0
  43. package/dist/groups/question.d.ts +92 -0
  44. package/dist/groups/question.js +56 -0
  45. package/dist/groups/reference.d.ts +13 -0
  46. package/dist/groups/reference.js +20 -0
  47. package/dist/groups/session.d.ts +8020 -0
  48. package/dist/groups/session.js +331 -0
  49. package/dist/groups/shell.d.ts +120 -0
  50. package/dist/groups/shell.js +65 -0
  51. package/dist/groups/skill.d.ts +19 -0
  52. package/dist/groups/skill.js +20 -0
  53. package/dist/middleware/authorization.d.ts +13 -0
  54. package/dist/middleware/authorization.js +6 -0
  55. package/dist/middleware/schema-error.d.ts +13 -0
  56. package/dist/middleware/schema-error.js +4 -0
  57. package/package.json +38 -0
package/dist/api.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ import { Context } from "effect";
2
+ import { HttpApi, HttpApiGroup, HttpApiMiddleware } from "effect/unstable/httpapi";
3
+ import { SchemaErrorMiddleware } from "./middleware/schema-error.js";
4
+ import { GenerateGroup } from "./groups/generate.js";
5
+ import { MessageGroup } from "./groups/message.js";
6
+ import { ModelGroup } from "./groups/model.js";
7
+ import { ProviderGroup } from "./groups/provider.js";
8
+ import { makeSessionGroup } from "./groups/session.js";
9
+ import { makePermissionGroup } from "./groups/permission.js";
10
+ import { FileSystemGroup } from "./groups/fs.js";
11
+ import { CommandGroup } from "./groups/command.js";
12
+ import { SkillGroup } from "./groups/skill.js";
13
+ import { EventGroup, makeEventGroup } from "./groups/event.js";
14
+ import type { Definition } from "@opencode-ai/schema/event";
15
+ import { AgentGroup } from "./groups/agent.js";
16
+ import { PluginGroup } from "./groups/plugin.js";
17
+ import { HealthGroup } from "./groups/health.js";
18
+ import { PtyGroup } from "./groups/pty.js";
19
+ import { ShellGroup } from "./groups/shell.js";
20
+ import { makeQuestionGroup } from "./groups/question.js";
21
+ import { ReferenceGroup } from "./groups/reference.js";
22
+ import { Authorization } from "./middleware/authorization.js";
23
+ import { LocationGroup } from "./groups/location.js";
24
+ import { IntegrationGroup } from "./groups/integration.js";
25
+ import { McpGroup } from "./groups/mcp.js";
26
+ import { CredentialGroup } from "./groups/credential.js";
27
+ import { ProjectGroup } from "./groups/project.js";
28
+ import { ProjectCopyGroup } from "./groups/project-copy.js";
29
+ type LocationGroups<LocationId extends HttpApiMiddleware.AnyId> = HttpApiGroup.AddMiddleware<typeof LocationGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof AgentGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof PluginGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ModelGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof GenerateGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProviderGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof IntegrationGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof McpGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof CredentialGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProjectGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof FileSystemGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof CommandGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof SkillGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof PtyGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ShellGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ReferenceGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProjectCopyGroup, LocationId>;
30
+ type SessionGroups<SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService> = ReturnType<typeof makeSessionGroup<SessionLocationId, SessionLocationService>> | HttpApiGroup.AddMiddleware<typeof MessageGroup, SessionLocationId>;
31
+ type MixedMiddlewareGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService> = ReturnType<typeof makePermissionGroup<LocationId, LocationService, SessionLocationId, SessionLocationService>> | ReturnType<typeof makeQuestionGroup<LocationId, LocationService, SessionLocationId, SessionLocationService>>;
32
+ type ApiGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService, Event extends HttpApiGroup.Any> = typeof HealthGroup | LocationGroups<LocationId> | SessionGroups<SessionLocationId, SessionLocationService> | MixedMiddlewareGroups<LocationId, LocationService, SessionLocationId, SessionLocationService> | Event;
33
+ type EventGroupFor<Definitions extends ReadonlyArray<Definition>> = ReturnType<typeof makeEventGroup<Definitions>>;
34
+ export type Api<LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService, Event extends HttpApiGroup.Any> = HttpApi.HttpApi<"server", HttpApiGroup.AddMiddleware<HttpApiGroup.AddMiddleware<ApiGroups<LocationId, LocationService, SessionLocationId, SessionLocationService, Event>, Authorization>, SchemaErrorMiddleware>>;
35
+ export declare const makeApi: <const Definitions extends ReadonlyArray<Definition>, LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService>(options: {
36
+ readonly definitions: Definitions;
37
+ readonly locationMiddleware: Context.Key<LocationId, LocationService>;
38
+ readonly sessionLocationMiddleware: Context.Key<SessionLocationId, SessionLocationService>;
39
+ }) => Api<LocationId, LocationService, SessionLocationId, SessionLocationService, EventGroupFor<Definitions>>;
40
+ export declare const makeDefaultApi: <LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService>(options: {
41
+ readonly locationMiddleware: Context.Key<LocationId, LocationService>;
42
+ readonly sessionLocationMiddleware: Context.Key<SessionLocationId, SessionLocationService>;
43
+ }) => Api<LocationId, LocationService, SessionLocationId, SessionLocationService, typeof EventGroup>;
44
+ export {};
package/dist/api.js ADDED
@@ -0,0 +1,61 @@
1
+ import { Context } from "effect";
2
+ import { HttpApi, HttpApiGroup, HttpApiMiddleware, OpenApi } from "effect/unstable/httpapi";
3
+ import { SchemaErrorMiddleware } from "./middleware/schema-error.js";
4
+ import { GenerateGroup } from "./groups/generate.js";
5
+ import { MessageGroup } from "./groups/message.js";
6
+ import { ModelGroup } from "./groups/model.js";
7
+ import { ProviderGroup } from "./groups/provider.js";
8
+ import { makeSessionGroup } from "./groups/session.js";
9
+ import { makePermissionGroup } from "./groups/permission.js";
10
+ import { FileSystemGroup } from "./groups/fs.js";
11
+ import { CommandGroup } from "./groups/command.js";
12
+ import { SkillGroup } from "./groups/skill.js";
13
+ import { EventGroup, makeEventGroup } from "./groups/event.js";
14
+ import { AgentGroup } from "./groups/agent.js";
15
+ import { PluginGroup } from "./groups/plugin.js";
16
+ import { HealthGroup } from "./groups/health.js";
17
+ import { PtyGroup } from "./groups/pty.js";
18
+ import { ShellGroup } from "./groups/shell.js";
19
+ import { makeQuestionGroup } from "./groups/question.js";
20
+ import { ReferenceGroup } from "./groups/reference.js";
21
+ import { Authorization } from "./middleware/authorization.js";
22
+ import { LocationGroup } from "./groups/location.js";
23
+ import { IntegrationGroup } from "./groups/integration.js";
24
+ import { McpGroup } from "./groups/mcp.js";
25
+ import { CredentialGroup } from "./groups/credential.js";
26
+ import { ProjectGroup } from "./groups/project.js";
27
+ import { ProjectCopyGroup } from "./groups/project-copy.js";
28
+ // Protocol owns middleware placement, while Server injects concrete keys so Core service identities stay downstream.
29
+ const makeApiFromGroup = (eventGroup, locationMiddleware, sessionLocationMiddleware) => HttpApi.make("server")
30
+ .add(HealthGroup)
31
+ .add(LocationGroup.middleware(locationMiddleware))
32
+ .add(AgentGroup.middleware(locationMiddleware))
33
+ .add(PluginGroup.middleware(locationMiddleware))
34
+ .add(makeSessionGroup(sessionLocationMiddleware))
35
+ .add(MessageGroup.middleware(sessionLocationMiddleware))
36
+ .add(ModelGroup.middleware(locationMiddleware))
37
+ .add(GenerateGroup.middleware(locationMiddleware))
38
+ .add(ProviderGroup.middleware(locationMiddleware))
39
+ .add(IntegrationGroup.middleware(locationMiddleware))
40
+ .add(McpGroup.middleware(locationMiddleware))
41
+ .add(CredentialGroup.middleware(locationMiddleware))
42
+ .add(ProjectGroup.middleware(locationMiddleware))
43
+ .add(makePermissionGroup(locationMiddleware, sessionLocationMiddleware))
44
+ .add(FileSystemGroup.middleware(locationMiddleware))
45
+ .add(CommandGroup.middleware(locationMiddleware))
46
+ .add(SkillGroup.middleware(locationMiddleware))
47
+ .add(eventGroup)
48
+ .add(PtyGroup.middleware(locationMiddleware))
49
+ .add(ShellGroup.middleware(locationMiddleware))
50
+ .add(makeQuestionGroup(locationMiddleware, sessionLocationMiddleware))
51
+ .add(ReferenceGroup.middleware(locationMiddleware))
52
+ .add(ProjectCopyGroup.middleware(locationMiddleware))
53
+ .annotateMerge(OpenApi.annotations({
54
+ title: "opencode HttpApi",
55
+ version: "0.0.1",
56
+ description: "Experimental HttpApi surface for selected instance routes.",
57
+ }))
58
+ .middleware(Authorization)
59
+ .middleware(SchemaErrorMiddleware);
60
+ export const makeApi = (options) => makeApiFromGroup(makeEventGroup(options.definitions), options.locationMiddleware, options.sessionLocationMiddleware);
61
+ export const makeDefaultApi = (options) => makeApiFromGroup(EventGroup, options.locationMiddleware, options.sessionLocationMiddleware);
@@ -0,0 +1,69 @@
1
+ import { InvalidRequestError, SessionNotFoundError } from "./errors.js";
2
+ import type { Api } from "./api.js";
3
+ import type { Context } from "effect";
4
+ import { HttpApiMiddleware } from "effect/unstable/httpapi";
5
+ import type { EventGroup } from "./groups/event.js";
6
+ declare const LocationMiddleware_base: HttpApiMiddleware.ServiceClass<LocationMiddleware, "@opencode-ai/client/LocationMiddleware", {
7
+ requires: never;
8
+ provides: never;
9
+ error: never;
10
+ clientError: never;
11
+ requiredForClient: false;
12
+ security: never;
13
+ }, HttpApiMiddleware.HttpApiMiddleware<never, never, never>>;
14
+ declare class LocationMiddleware extends LocationMiddleware_base {
15
+ }
16
+ declare const SessionLocationMiddleware_base: HttpApiMiddleware.ServiceClass<SessionLocationMiddleware, "@opencode-ai/client/SessionLocationMiddleware", {
17
+ requires: never;
18
+ provides: never;
19
+ error: readonly [typeof InvalidRequestError, typeof SessionNotFoundError];
20
+ clientError: never;
21
+ requiredForClient: false;
22
+ security: never;
23
+ }, HttpApiMiddleware.HttpApiMiddleware<never, readonly [typeof InvalidRequestError, typeof SessionNotFoundError], never>>;
24
+ declare class SessionLocationMiddleware extends SessionLocationMiddleware_base {
25
+ }
26
+ type ClientApiShape = Api<Context.Service.Identifier<typeof LocationMiddleware>, Context.Service.Shape<typeof LocationMiddleware>, Context.Service.Identifier<typeof SessionLocationMiddleware>, Context.Service.Shape<typeof SessionLocationMiddleware>, typeof EventGroup>;
27
+ export declare const ClientApi: ClientApiShape;
28
+ export declare const groupNames: {
29
+ readonly "server.health": "health";
30
+ readonly "server.location": "location";
31
+ readonly "server.agent": "agent";
32
+ readonly "server.plugin": "plugin";
33
+ readonly "server.session": "session";
34
+ readonly "server.message": "message";
35
+ readonly "server.model": "model";
36
+ readonly "server.generate": "generate";
37
+ readonly "server.provider": "provider";
38
+ readonly "server.integration": "integration";
39
+ readonly "server.credential": "credential";
40
+ readonly "server.permission": "permission";
41
+ readonly "server.fs": "file";
42
+ readonly "server.command": "command";
43
+ readonly "server.skill": "skill";
44
+ readonly "server.event": "event";
45
+ readonly "server.pty": "pty";
46
+ readonly "server.shell": "shell";
47
+ readonly "server.question": "question";
48
+ readonly "server.reference": "reference";
49
+ readonly "server.project": "project";
50
+ readonly "server.projectCopy": "projectCopy";
51
+ };
52
+ export declare const endpointNames: {
53
+ readonly "session.messages": "list";
54
+ readonly "integration.connect.key": "connectKey";
55
+ readonly "integration.connect.oauth": "connectOauth";
56
+ readonly "integration.attempt.status": "attemptStatus";
57
+ readonly "integration.attempt.complete": "attemptComplete";
58
+ readonly "integration.attempt.cancel": "attemptCancel";
59
+ readonly "session.revert.stage": "revertStage";
60
+ readonly "session.revert.clear": "revertClear";
61
+ readonly "session.revert.commit": "revertCommit";
62
+ readonly "permission.request.list": "listRequests";
63
+ readonly "permission.saved.list": "listSaved";
64
+ readonly "permission.saved.remove": "removeSaved";
65
+ readonly "question.request.list": "listRequests";
66
+ };
67
+ export declare const promiseOmitEndpoints: Set<string>;
68
+ export declare const effectOmitEndpoints: Set<string>;
69
+ export {};
package/dist/client.js ADDED
@@ -0,0 +1,52 @@
1
+ import { InvalidRequestError, SessionNotFoundError } from "./errors.js";
2
+ import { makeDefaultApi } from "./api.js";
3
+ import { HttpApiMiddleware } from "effect/unstable/httpapi";
4
+ class LocationMiddleware extends HttpApiMiddleware.Service()("@opencode-ai/client/LocationMiddleware") {
5
+ }
6
+ class SessionLocationMiddleware extends HttpApiMiddleware.Service()("@opencode-ai/client/SessionLocationMiddleware", { error: [InvalidRequestError, SessionNotFoundError] }) {
7
+ }
8
+ export const ClientApi = makeDefaultApi({
9
+ locationMiddleware: LocationMiddleware,
10
+ sessionLocationMiddleware: SessionLocationMiddleware,
11
+ });
12
+ export const groupNames = {
13
+ "server.health": "health",
14
+ "server.location": "location",
15
+ "server.agent": "agent",
16
+ "server.plugin": "plugin",
17
+ "server.session": "session",
18
+ "server.message": "message",
19
+ "server.model": "model",
20
+ "server.generate": "generate",
21
+ "server.provider": "provider",
22
+ "server.integration": "integration",
23
+ "server.credential": "credential",
24
+ "server.permission": "permission",
25
+ "server.fs": "file",
26
+ "server.command": "command",
27
+ "server.skill": "skill",
28
+ "server.event": "event",
29
+ "server.pty": "pty",
30
+ "server.shell": "shell",
31
+ "server.question": "question",
32
+ "server.reference": "reference",
33
+ "server.project": "project",
34
+ "server.projectCopy": "projectCopy",
35
+ };
36
+ export const endpointNames = {
37
+ "session.messages": "list",
38
+ "integration.connect.key": "connectKey",
39
+ "integration.connect.oauth": "connectOauth",
40
+ "integration.attempt.status": "attemptStatus",
41
+ "integration.attempt.complete": "attemptComplete",
42
+ "integration.attempt.cancel": "attemptCancel",
43
+ "session.revert.stage": "revertStage",
44
+ "session.revert.clear": "revertClear",
45
+ "session.revert.commit": "revertCommit",
46
+ "permission.request.list": "listRequests",
47
+ "permission.saved.list": "listSaved",
48
+ "permission.saved.remove": "removeSaved",
49
+ "question.request.list": "listRequests",
50
+ };
51
+ export const promiseOmitEndpoints = new Set(["pty.connect", "pty.connectToken"]);
52
+ export const effectOmitEndpoints = new Set(["fs.read", "pty.connect", "pty.connectToken"]);
@@ -0,0 +1,97 @@
1
+ import { Schema } from "effect";
2
+ declare const InvalidRequestError_base: Schema.Class<InvalidRequestError, Schema.TaggedStruct<"InvalidRequestError", {
3
+ readonly message: Schema.String;
4
+ readonly kind: Schema.optional<Schema.String>;
5
+ readonly field: Schema.optional<Schema.String>;
6
+ }>, import("effect/Cause").YieldableError>;
7
+ export declare class InvalidRequestError extends InvalidRequestError_base {
8
+ }
9
+ declare const UnauthorizedError_base: Schema.Class<UnauthorizedError, Schema.TaggedStruct<"UnauthorizedError", {
10
+ readonly message: Schema.String;
11
+ }>, import("effect/Cause").YieldableError>;
12
+ export declare class UnauthorizedError extends UnauthorizedError_base {
13
+ }
14
+ declare const ConflictError_base: Schema.Class<ConflictError, Schema.TaggedStruct<"ConflictError", {
15
+ readonly message: Schema.String;
16
+ readonly resource: Schema.optional<Schema.String>;
17
+ }>, import("effect/Cause").YieldableError>;
18
+ export declare class ConflictError extends ConflictError_base {
19
+ }
20
+ declare const SessionBusyError_base: Schema.Class<SessionBusyError, Schema.TaggedStruct<"SessionBusyError", {
21
+ readonly sessionID: Schema.String;
22
+ readonly message: Schema.String;
23
+ }>, import("effect/Cause").YieldableError>;
24
+ export declare class SessionBusyError extends SessionBusyError_base {
25
+ }
26
+ declare const ServiceUnavailableError_base: Schema.Class<ServiceUnavailableError, Schema.TaggedStruct<"ServiceUnavailableError", {
27
+ readonly message: Schema.String;
28
+ readonly service: Schema.optional<Schema.String>;
29
+ }>, import("effect/Cause").YieldableError>;
30
+ export declare class ServiceUnavailableError extends ServiceUnavailableError_base {
31
+ }
32
+ declare const UnknownError_base: Schema.Class<UnknownError, Schema.TaggedStruct<"UnknownError", {
33
+ readonly message: Schema.String;
34
+ readonly ref: Schema.optional<Schema.String>;
35
+ }>, import("effect/Cause").YieldableError>;
36
+ export declare class UnknownError extends UnknownError_base {
37
+ }
38
+ declare const ProviderNotFoundError_base: Schema.Class<ProviderNotFoundError, Schema.TaggedStruct<"ProviderNotFoundError", {
39
+ readonly providerID: Schema.String;
40
+ readonly message: Schema.String;
41
+ }>, import("effect/Cause").YieldableError>;
42
+ export declare class ProviderNotFoundError extends ProviderNotFoundError_base {
43
+ }
44
+ declare const SessionNotFoundError_base: Schema.Class<SessionNotFoundError, Schema.TaggedStruct<"SessionNotFoundError", {
45
+ readonly sessionID: Schema.String;
46
+ readonly message: Schema.String;
47
+ }>, import("effect/Cause").YieldableError>;
48
+ export declare class SessionNotFoundError extends SessionNotFoundError_base {
49
+ }
50
+ declare const MessageNotFoundError_base: Schema.Class<MessageNotFoundError, Schema.TaggedStruct<"MessageNotFoundError", {
51
+ readonly sessionID: Schema.String;
52
+ readonly messageID: Schema.String;
53
+ readonly message: Schema.String;
54
+ }>, import("effect/Cause").YieldableError>;
55
+ export declare class MessageNotFoundError extends MessageNotFoundError_base {
56
+ }
57
+ declare const SkillNotFoundError_base: Schema.Class<SkillNotFoundError, Schema.TaggedStruct<"SkillNotFoundError", {
58
+ readonly skill: Schema.String;
59
+ readonly message: Schema.String;
60
+ }>, import("effect/Cause").YieldableError>;
61
+ export declare class SkillNotFoundError extends SkillNotFoundError_base {
62
+ }
63
+ declare const InvalidCursorError_base: Schema.Class<InvalidCursorError, Schema.TaggedStruct<"InvalidCursorError", {
64
+ readonly message: Schema.String;
65
+ }>, import("effect/Cause").YieldableError>;
66
+ export declare class InvalidCursorError extends InvalidCursorError_base {
67
+ }
68
+ declare const PermissionNotFoundError_base: Schema.Class<PermissionNotFoundError, Schema.TaggedStruct<"PermissionNotFoundError", {
69
+ readonly requestID: Schema.String;
70
+ readonly message: Schema.String;
71
+ }>, import("effect/Cause").YieldableError>;
72
+ export declare class PermissionNotFoundError extends PermissionNotFoundError_base {
73
+ }
74
+ declare const QuestionNotFoundError_base: Schema.Class<QuestionNotFoundError, Schema.TaggedStruct<"QuestionNotFoundError", {
75
+ readonly requestID: Schema.String;
76
+ readonly message: Schema.String;
77
+ }>, import("effect/Cause").YieldableError>;
78
+ export declare class QuestionNotFoundError extends QuestionNotFoundError_base {
79
+ }
80
+ declare const ForbiddenError_base: Schema.Class<ForbiddenError, Schema.TaggedStruct<"ForbiddenError", {
81
+ readonly message: Schema.String;
82
+ }>, import("effect/Cause").YieldableError>;
83
+ export declare class ForbiddenError extends ForbiddenError_base {
84
+ }
85
+ declare const PtyNotFoundError_base: Schema.Class<PtyNotFoundError, Schema.TaggedStruct<"PtyNotFoundError", {
86
+ readonly ptyID: Schema.String;
87
+ readonly message: Schema.String;
88
+ }>, import("effect/Cause").YieldableError>;
89
+ export declare class PtyNotFoundError extends PtyNotFoundError_base {
90
+ }
91
+ declare const ShellNotFoundError_base: Schema.Class<ShellNotFoundError, Schema.TaggedStruct<"ShellNotFoundError", {
92
+ readonly id: Schema.String;
93
+ readonly message: Schema.String;
94
+ }>, import("effect/Cause").YieldableError>;
95
+ export declare class ShellNotFoundError extends ShellNotFoundError_base {
96
+ }
97
+ export {};
package/dist/errors.js ADDED
@@ -0,0 +1,74 @@
1
+ import { Schema } from "effect";
2
+ export class InvalidRequestError extends Schema.TaggedErrorClass()("InvalidRequestError", {
3
+ message: Schema.String,
4
+ kind: Schema.optional(Schema.String),
5
+ field: Schema.optional(Schema.String),
6
+ }, { httpApiStatus: 400 }) {
7
+ }
8
+ export class UnauthorizedError extends Schema.TaggedErrorClass()("UnauthorizedError", { message: Schema.String }, { httpApiStatus: 401 }) {
9
+ }
10
+ export class ConflictError extends Schema.TaggedErrorClass()("ConflictError", {
11
+ message: Schema.String,
12
+ resource: Schema.optional(Schema.String),
13
+ }, { httpApiStatus: 409 }) {
14
+ }
15
+ export class SessionBusyError extends Schema.TaggedErrorClass()("SessionBusyError", {
16
+ sessionID: Schema.String,
17
+ message: Schema.String,
18
+ }, { httpApiStatus: 409 }) {
19
+ }
20
+ export class ServiceUnavailableError extends Schema.TaggedErrorClass()("ServiceUnavailableError", {
21
+ message: Schema.String,
22
+ service: Schema.optional(Schema.String),
23
+ }, { httpApiStatus: 503 }) {
24
+ }
25
+ export class UnknownError extends Schema.TaggedErrorClass()("UnknownError", {
26
+ message: Schema.String,
27
+ ref: Schema.optional(Schema.String),
28
+ }, { httpApiStatus: 500 }) {
29
+ }
30
+ export class ProviderNotFoundError extends Schema.TaggedErrorClass()("ProviderNotFoundError", {
31
+ providerID: Schema.String,
32
+ message: Schema.String,
33
+ }, { httpApiStatus: 404 }) {
34
+ }
35
+ export class SessionNotFoundError extends Schema.TaggedErrorClass()("SessionNotFoundError", {
36
+ sessionID: Schema.String,
37
+ message: Schema.String,
38
+ }, { httpApiStatus: 404 }) {
39
+ }
40
+ export class MessageNotFoundError extends Schema.TaggedErrorClass()("MessageNotFoundError", {
41
+ sessionID: Schema.String,
42
+ messageID: Schema.String,
43
+ message: Schema.String,
44
+ }, { httpApiStatus: 404 }) {
45
+ }
46
+ export class SkillNotFoundError extends Schema.TaggedErrorClass()("SkillNotFoundError", {
47
+ skill: Schema.String,
48
+ message: Schema.String,
49
+ }, { httpApiStatus: 404 }) {
50
+ }
51
+ export class InvalidCursorError extends Schema.TaggedErrorClass()("InvalidCursorError", { message: Schema.String }, { httpApiStatus: 400 }) {
52
+ }
53
+ export class PermissionNotFoundError extends Schema.TaggedErrorClass()("PermissionNotFoundError", {
54
+ requestID: Schema.String,
55
+ message: Schema.String,
56
+ }, { httpApiStatus: 404 }) {
57
+ }
58
+ export class QuestionNotFoundError extends Schema.TaggedErrorClass()("QuestionNotFoundError", {
59
+ requestID: Schema.String,
60
+ message: Schema.String,
61
+ }, { httpApiStatus: 404 }) {
62
+ }
63
+ export class ForbiddenError extends Schema.TaggedErrorClass()("ForbiddenError", { message: Schema.String }, { httpApiStatus: 403 }) {
64
+ }
65
+ export class PtyNotFoundError extends Schema.TaggedErrorClass()("PtyNotFoundError", {
66
+ ptyID: Schema.String,
67
+ message: Schema.String,
68
+ }, { httpApiStatus: 404 }) {
69
+ }
70
+ export class ShellNotFoundError extends Schema.TaggedErrorClass()("ShellNotFoundError", {
71
+ id: Schema.String,
72
+ message: Schema.String,
73
+ }, { httpApiStatus: 404 }) {
74
+ }
@@ -0,0 +1,91 @@
1
+ import { Agent } from "@opencode-ai/schema/agent";
2
+ import { Location } from "@opencode-ai/schema/location";
3
+ import { Schema } from "effect";
4
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
5
+ export declare const AgentGroup: HttpApiGroup.HttpApiGroup<"server.agent", HttpApiEndpoint.HttpApiEndpoint<"agent.list", "GET", "/api/agent", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<Schema.Struct<{
6
+ readonly location: Schema.optional<Schema.Struct<{
7
+ readonly directory: Schema.optional<Schema.String>;
8
+ readonly workspace: Schema.optional<Schema.String>;
9
+ }>>;
10
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
11
+ readonly location: typeof Location.Info;
12
+ readonly data: Schema.$Array<Schema.Struct<{
13
+ readonly id: Schema.brand<Schema.String, "AgentV2.ID">;
14
+ readonly model: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
15
+ readonly id: Schema.brand<Schema.String, "ModelV2.ID">;
16
+ readonly providerID: Schema.brand<Schema.String, "ProviderV2.ID"> & {
17
+ opencode: string & import("effect/Brand").Brand<"ProviderV2.ID">;
18
+ anthropic: string & import("effect/Brand").Brand<"ProviderV2.ID">;
19
+ openai: string & import("effect/Brand").Brand<"ProviderV2.ID">;
20
+ google: string & import("effect/Brand").Brand<"ProviderV2.ID">;
21
+ googleVertex: string & import("effect/Brand").Brand<"ProviderV2.ID">;
22
+ githubCopilot: string & import("effect/Brand").Brand<"ProviderV2.ID">;
23
+ amazonBedrock: string & import("effect/Brand").Brand<"ProviderV2.ID">;
24
+ azure: string & import("effect/Brand").Brand<"ProviderV2.ID">;
25
+ openrouter: string & import("effect/Brand").Brand<"ProviderV2.ID">;
26
+ mistral: string & import("effect/Brand").Brand<"ProviderV2.ID">;
27
+ gitlab: string & import("effect/Brand").Brand<"ProviderV2.ID">;
28
+ };
29
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "VariantID">>, never, never>;
30
+ }>>>, Schema.optionalKey<Schema.Struct<{
31
+ readonly id: Schema.brand<Schema.String, "ModelV2.ID">;
32
+ readonly providerID: Schema.brand<Schema.String, "ProviderV2.ID"> & {
33
+ opencode: string & import("effect/Brand").Brand<"ProviderV2.ID">;
34
+ anthropic: string & import("effect/Brand").Brand<"ProviderV2.ID">;
35
+ openai: string & import("effect/Brand").Brand<"ProviderV2.ID">;
36
+ google: string & import("effect/Brand").Brand<"ProviderV2.ID">;
37
+ googleVertex: string & import("effect/Brand").Brand<"ProviderV2.ID">;
38
+ githubCopilot: string & import("effect/Brand").Brand<"ProviderV2.ID">;
39
+ amazonBedrock: string & import("effect/Brand").Brand<"ProviderV2.ID">;
40
+ azure: string & import("effect/Brand").Brand<"ProviderV2.ID">;
41
+ openrouter: string & import("effect/Brand").Brand<"ProviderV2.ID">;
42
+ mistral: string & import("effect/Brand").Brand<"ProviderV2.ID">;
43
+ gitlab: string & import("effect/Brand").Brand<"ProviderV2.ID">;
44
+ };
45
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "VariantID">>, never, never>;
46
+ }>>, never, never>;
47
+ readonly request: Schema.Struct<{
48
+ readonly headers: Schema.$Record<Schema.String, Schema.String>;
49
+ readonly body: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
50
+ }>;
51
+ readonly system: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
52
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
53
+ readonly mode: Schema.Literals<readonly ["subagent", "primary", "all"]>;
54
+ readonly hidden: Schema.Boolean;
55
+ readonly color: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.String, Schema.Literals<readonly ["primary", "secondary", "accent", "success", "warning", "error", "info"]>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Literals<readonly ["primary", "secondary", "accent", "success", "warning", "error", "info"]>]>>, never, never>;
56
+ readonly steps: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
57
+ readonly permissions: Schema.$Array<Schema.Struct<{
58
+ readonly action: Schema.String;
59
+ readonly resource: Schema.String;
60
+ readonly effect: Schema.Literals<readonly ["allow", "deny", "ask"]>;
61
+ }>>;
62
+ }> & {
63
+ empty: (id: Agent.ID) => {
64
+ readonly id: string & import("effect/Brand").Brand<"AgentV2.ID">;
65
+ readonly request: {
66
+ readonly headers: {
67
+ readonly [x: string]: string;
68
+ };
69
+ readonly body: {
70
+ readonly [x: string]: Schema.Json;
71
+ };
72
+ };
73
+ readonly mode: "primary" | "subagent" | "all";
74
+ readonly hidden: boolean;
75
+ readonly permissions: readonly {
76
+ readonly action: string;
77
+ readonly resource: string;
78
+ readonly effect: "allow" | "deny" | "ask";
79
+ }[];
80
+ readonly model?: {
81
+ readonly id: string & import("effect/Brand").Brand<"ModelV2.ID">;
82
+ readonly providerID: string & import("effect/Brand").Brand<"ProviderV2.ID">;
83
+ readonly variant?: (string & import("effect/Brand").Brand<"VariantID">) | undefined;
84
+ } | undefined;
85
+ readonly system?: string | undefined;
86
+ readonly description?: string | undefined;
87
+ readonly color?: string | undefined;
88
+ readonly steps?: number | undefined;
89
+ };
90
+ }>;
91
+ }>>, HttpApiEndpoint.Json<never>, never, never>, false>;
@@ -0,0 +1,15 @@
1
+ import { Agent } from "@opencode-ai/schema/agent";
2
+ import { Location } from "@opencode-ai/schema/location";
3
+ import { Schema } from "effect";
4
+ import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
5
+ import { LocationQuery, locationQueryOpenApi } from "./location.js";
6
+ export const AgentGroup = HttpApiGroup.make("server.agent").add(HttpApiEndpoint.get("agent.list", "/api/agent", {
7
+ query: LocationQuery,
8
+ success: Location.response(Schema.Array(Agent.Info)),
9
+ })
10
+ .annotateMerge(locationQueryOpenApi)
11
+ .annotateMerge(OpenApi.annotations({
12
+ identifier: "v2.agent.list",
13
+ summary: "List agents",
14
+ description: "Retrieve currently registered agents.",
15
+ })));
@@ -0,0 +1,51 @@
1
+ import { Location } from "@opencode-ai/schema/location";
2
+ import { Schema } from "effect";
3
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
4
+ export declare const CommandGroup: HttpApiGroup.HttpApiGroup<"server.command", HttpApiEndpoint.HttpApiEndpoint<"command.list", "GET", "/api/command", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<Schema.Struct<{
5
+ readonly location: Schema.optional<Schema.Struct<{
6
+ readonly directory: Schema.optional<Schema.String>;
7
+ readonly workspace: Schema.optional<Schema.String>;
8
+ }>>;
9
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
10
+ readonly location: typeof Location.Info;
11
+ readonly data: Schema.$Array<Schema.Struct<{
12
+ readonly name: Schema.String;
13
+ readonly template: Schema.String;
14
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
15
+ readonly agent: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
16
+ readonly model: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
17
+ readonly id: Schema.brand<Schema.String, "ModelV2.ID">;
18
+ readonly providerID: Schema.brand<Schema.String, "ProviderV2.ID"> & {
19
+ opencode: string & import("effect/Brand").Brand<"ProviderV2.ID">;
20
+ anthropic: string & import("effect/Brand").Brand<"ProviderV2.ID">;
21
+ openai: string & import("effect/Brand").Brand<"ProviderV2.ID">;
22
+ google: string & import("effect/Brand").Brand<"ProviderV2.ID">;
23
+ googleVertex: string & import("effect/Brand").Brand<"ProviderV2.ID">;
24
+ githubCopilot: string & import("effect/Brand").Brand<"ProviderV2.ID">;
25
+ amazonBedrock: string & import("effect/Brand").Brand<"ProviderV2.ID">;
26
+ azure: string & import("effect/Brand").Brand<"ProviderV2.ID">;
27
+ openrouter: string & import("effect/Brand").Brand<"ProviderV2.ID">;
28
+ mistral: string & import("effect/Brand").Brand<"ProviderV2.ID">;
29
+ gitlab: string & import("effect/Brand").Brand<"ProviderV2.ID">;
30
+ };
31
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "VariantID">>, never, never>;
32
+ }>>>, Schema.optionalKey<Schema.Struct<{
33
+ readonly id: Schema.brand<Schema.String, "ModelV2.ID">;
34
+ readonly providerID: Schema.brand<Schema.String, "ProviderV2.ID"> & {
35
+ opencode: string & import("effect/Brand").Brand<"ProviderV2.ID">;
36
+ anthropic: string & import("effect/Brand").Brand<"ProviderV2.ID">;
37
+ openai: string & import("effect/Brand").Brand<"ProviderV2.ID">;
38
+ google: string & import("effect/Brand").Brand<"ProviderV2.ID">;
39
+ googleVertex: string & import("effect/Brand").Brand<"ProviderV2.ID">;
40
+ githubCopilot: string & import("effect/Brand").Brand<"ProviderV2.ID">;
41
+ amazonBedrock: string & import("effect/Brand").Brand<"ProviderV2.ID">;
42
+ azure: string & import("effect/Brand").Brand<"ProviderV2.ID">;
43
+ openrouter: string & import("effect/Brand").Brand<"ProviderV2.ID">;
44
+ mistral: string & import("effect/Brand").Brand<"ProviderV2.ID">;
45
+ gitlab: string & import("effect/Brand").Brand<"ProviderV2.ID">;
46
+ };
47
+ readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "VariantID">>, never, never>;
48
+ }>>, never, never>;
49
+ readonly subtask: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
50
+ }>>;
51
+ }>>, HttpApiEndpoint.Json<never>, never, never>, false>;
@@ -0,0 +1,20 @@
1
+ import { Command } from "@opencode-ai/schema/command";
2
+ import { Location } from "@opencode-ai/schema/location";
3
+ import { Schema } from "effect";
4
+ import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
5
+ import { LocationQuery, locationQueryOpenApi } from "./location.js";
6
+ export const CommandGroup = HttpApiGroup.make("server.command")
7
+ .add(HttpApiEndpoint.get("command.list", "/api/command", {
8
+ query: LocationQuery,
9
+ success: Location.response(Schema.Array(Command.Info)),
10
+ })
11
+ .annotateMerge(locationQueryOpenApi)
12
+ .annotateMerge(OpenApi.annotations({
13
+ identifier: "v2.command.list",
14
+ summary: "List commands",
15
+ description: "Retrieve currently registered commands.",
16
+ })))
17
+ .annotateMerge(OpenApi.annotations({
18
+ title: "commands",
19
+ description: "Experimental command routes.",
20
+ }));
@@ -0,0 +1,23 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
3
+ export declare const CredentialGroup: HttpApiGroup.HttpApiGroup<"server.credential", HttpApiEndpoint.HttpApiEndpoint<"credential.update", "PATCH", "/api/credential/:credentialID", HttpApiEndpoint.StringTree<Schema.Struct<{
4
+ credentialID: Schema.brand<Schema.String, "Credential.ID"> & {
5
+ create: () => string & import("effect/Brand").Brand<"Credential.ID">;
6
+ };
7
+ }>>, HttpApiEndpoint.StringTree<Schema.Struct<{
8
+ readonly location: Schema.optional<Schema.Struct<{
9
+ readonly directory: Schema.optional<Schema.String>;
10
+ readonly workspace: Schema.optional<Schema.String>;
11
+ }>>;
12
+ }>>, HttpApiEndpoint.Json<Schema.Struct<{
13
+ readonly label: Schema.String;
14
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<HttpApiSchema.NoContent>, HttpApiEndpoint.Json<never>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"credential.remove", "DELETE", "/api/credential/:credentialID", HttpApiEndpoint.StringTree<Schema.Struct<{
15
+ credentialID: Schema.brand<Schema.String, "Credential.ID"> & {
16
+ create: () => string & import("effect/Brand").Brand<"Credential.ID">;
17
+ };
18
+ }>>, HttpApiEndpoint.StringTree<Schema.Struct<{
19
+ readonly location: Schema.optional<Schema.Struct<{
20
+ readonly directory: Schema.optional<Schema.String>;
21
+ readonly workspace: Schema.optional<Schema.String>;
22
+ }>>;
23
+ }>>, HttpApiEndpoint.Json<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<HttpApiSchema.NoContent>, HttpApiEndpoint.Json<never>, never, never>, false>;