@zyro-sec/protocol 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/openapi.json +33222 -0
  2. package/package.json +7 -14
  3. package/script/build.ts +9 -0
  4. package/script/generate-openapi.ts +25 -0
  5. package/script/openapi-parameters.ts +30 -0
  6. package/script/openapi-stabilize.ts +102 -0
  7. package/script/pack.ts +5 -0
  8. package/src/api.ts +264 -0
  9. package/src/client.ts +127 -0
  10. package/src/errors.ts +398 -0
  11. package/src/groups/agent.ts +39 -0
  12. package/src/groups/artifact.ts +103 -0
  13. package/src/groups/automation.ts +75 -0
  14. package/src/groups/blob.ts +20 -0
  15. package/src/groups/command.ts +27 -0
  16. package/src/groups/config.ts +46 -0
  17. package/src/groups/credential.ts +72 -0
  18. package/src/groups/debug.ts +68 -0
  19. package/src/groups/event.ts +86 -0
  20. package/src/groups/experimental.ts +19 -0
  21. package/src/groups/form.ts +26 -0
  22. package/src/groups/fs.ts +136 -0
  23. package/src/groups/generate.ts +120 -0
  24. package/src/groups/integration.ts +230 -0
  25. package/src/groups/job.ts +57 -0
  26. package/src/groups/location.ts +66 -0
  27. package/src/groups/machine.ts +120 -0
  28. package/src/groups/mcp.ts +167 -0
  29. package/src/groups/media.ts +23 -0
  30. package/src/groups/message.ts +124 -0
  31. package/src/groups/migration.ts +28 -0
  32. package/src/groups/model.ts +52 -0
  33. package/src/groups/permission.ts +164 -0
  34. package/src/groups/persistent-pty.ts +153 -0
  35. package/src/groups/plugin.ts +80 -0
  36. package/src/groups/project.ts +51 -0
  37. package/src/groups/provider.ts +45 -0
  38. package/src/groups/pty.ts +153 -0
  39. package/src/groups/push.ts +94 -0
  40. package/src/groups/reference.ts +42 -0
  41. package/src/groups/rpc.ts +30 -0
  42. package/src/groups/server.ts +80 -0
  43. package/src/groups/session.ts +918 -0
  44. package/src/groups/shell.ts +88 -0
  45. package/src/groups/skill.ts +46 -0
  46. package/src/groups/usage.ts +30 -0
  47. package/src/groups/vcs.ts +131 -0
  48. package/src/groups/voice.ts +96 -0
  49. package/src/groups/websearch.ts +46 -0
  50. package/src/groups/worktree.ts +78 -0
  51. package/src/middleware/authorization.ts +6 -0
  52. package/src/middleware/schema-error.ts +7 -0
  53. package/src/simulation.ts +691 -0
  54. package/test/event.test.ts +34 -0
  55. package/test/experimental-identifiers.test.ts +24 -0
  56. package/test/openapi-parameters.test.ts +43 -0
  57. package/test/openapi-patterns.test.ts +28 -0
  58. package/test/openapi-stabilize.test.ts +161 -0
  59. package/test/session-cursor.test.ts +7 -0
  60. package/tsconfig.build.json +11 -0
  61. package/tsconfig.json +14 -0
@@ -0,0 +1,88 @@
1
+ import { Shell } from "@zyro-sec/schema/shell"
2
+ import { Location } from "@zyro-sec/schema/location"
3
+ import { Schema } from "effect"
4
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
5
+ import { ShellNotFoundError } from "../errors.js"
6
+ import { LocationQuery, locationQueryOpenApi } from "./location.js"
7
+
8
+ export const ShellGroup = HttpApiGroup.make("server.shell")
9
+ .add(
10
+ HttpApiEndpoint.get("shell.list", "/api/shell", {
11
+ query: LocationQuery,
12
+ success: Location.response(Schema.Array(Shell.Info)),
13
+ })
14
+ .annotateMerge(locationQueryOpenApi)
15
+ .annotateMerge(
16
+ OpenApi.annotations({
17
+ identifier: "shell.list",
18
+ summary: "List running shell commands",
19
+ description: "List currently running shell commands for a location. Exited commands are not included.",
20
+ }),
21
+ ),
22
+ )
23
+ .add(
24
+ HttpApiEndpoint.post("shell.create", "/api/shell", {
25
+ query: LocationQuery,
26
+ payload: Shell.CreateInput,
27
+ success: Location.response(Shell.Info),
28
+ })
29
+ .annotateMerge(locationQueryOpenApi)
30
+ .annotateMerge(
31
+ OpenApi.annotations({
32
+ identifier: "shell.create",
33
+ summary: "Run shell command",
34
+ description:
35
+ "Spawn one non-interactive shell command for a location. Combined stdout/stderr is captured to a file pageable via output.",
36
+ }),
37
+ ),
38
+ )
39
+ .add(
40
+ HttpApiEndpoint.get("shell.get", "/api/shell/:id", {
41
+ params: { id: Shell.ID },
42
+ query: LocationQuery,
43
+ success: Location.response(Shell.Info),
44
+ error: ShellNotFoundError,
45
+ })
46
+ .annotateMerge(locationQueryOpenApi)
47
+ .annotateMerge(
48
+ OpenApi.annotations({
49
+ identifier: "shell.get",
50
+ summary: "Get shell command",
51
+ description: "Get one shell command, including its status and exit code once exited.",
52
+ }),
53
+ ),
54
+ )
55
+ .add(
56
+ HttpApiEndpoint.get("shell.output", "/api/shell/:id/output", {
57
+ params: { id: Shell.ID },
58
+ query: Schema.Struct({ ...LocationQuery.fields, ...Shell.OutputInput.fields }),
59
+ success: Location.response(Shell.Output),
60
+ error: ShellNotFoundError,
61
+ })
62
+ .annotateMerge(locationQueryOpenApi)
63
+ .annotateMerge(
64
+ OpenApi.annotations({
65
+ identifier: "shell.output",
66
+ summary: "Read shell output",
67
+ description: "Page through captured combined output by absolute byte cursor.",
68
+ }),
69
+ ),
70
+ )
71
+ .add(
72
+ HttpApiEndpoint.delete("shell.remove", "/api/shell/:id", {
73
+ params: { id: Shell.ID },
74
+ query: LocationQuery,
75
+ success: HttpApiSchema.NoContent,
76
+ })
77
+ .annotateMerge(locationQueryOpenApi)
78
+ .annotateMerge(
79
+ OpenApi.annotations({
80
+ identifier: "shell.remove",
81
+ summary: "Remove shell command",
82
+ description: "Terminate and remove one shell command and its retained output.",
83
+ }),
84
+ ),
85
+ )
86
+ .annotateMerge(
87
+ OpenApi.annotations({ title: "shell", description: "Location-scoped shell command routes." }),
88
+ )
@@ -0,0 +1,46 @@
1
+ import { Skill } from "@zyro-sec/schema/skill"
2
+ import { Location } from "@zyro-sec/schema/location"
3
+ import { Schema } from "effect"
4
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
5
+ import { FileNotFoundError, SkillLoadError, SkillNotFoundError } from "../errors.js"
6
+ import { LocationQuery, locationQueryOpenApi } from "./location.js"
7
+
8
+ export const SkillGroup = HttpApiGroup.make("server.skill")
9
+ .add(
10
+ HttpApiEndpoint.get("skill.list", "/api/skill", {
11
+ query: LocationQuery,
12
+ success: Location.response(Schema.Array(Skill.Info)),
13
+ })
14
+ .annotateMerge(locationQueryOpenApi)
15
+ .annotateMerge(
16
+ OpenApi.annotations({
17
+ identifier: "skill.list",
18
+ summary: "List skills",
19
+ description: "Retrieve currently registered skills.",
20
+ }),
21
+ ),
22
+ )
23
+ .add(
24
+ HttpApiEndpoint.get("skill.file", "/api/experimental/skill/:skillID/file/*", {
25
+ params: { skillID: Skill.ID },
26
+ query: LocationQuery,
27
+ success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
28
+ error: [SkillNotFoundError, FileNotFoundError, SkillLoadError],
29
+ })
30
+ .annotateMerge(locationQueryOpenApi)
31
+ .annotateMerge(
32
+ OpenApi.annotations({
33
+ identifier: "experimental.skill.file",
34
+ summary: "Read skill file",
35
+ description:
36
+ "Read one file of a skill, loading it when the skill serves it on demand. SKILL.md returns the body without frontmatter. Experimental: may change without compatibility guarantees.",
37
+ transform: (operation) => ({ ...operation, tags: ["experimental"] }),
38
+ }),
39
+ ),
40
+ )
41
+ .annotateMerge(
42
+ OpenApi.annotations({
43
+ title: "skill",
44
+ description: "Experimental skill routes.",
45
+ }),
46
+ )
@@ -0,0 +1,30 @@
1
+ import { Location } from "@zyro-sec/schema/location"
2
+ import { UsageLimits } from "@zyro-sec/schema/usage-limits"
3
+ import { Schema } from "effect"
4
+ import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
5
+ import { ServiceUnavailableError } from "../errors.js"
6
+ import { LocationQuery, locationQueryOpenApi } from "./location.js"
7
+
8
+ export const UsageGroup = HttpApiGroup.make("server.usage")
9
+ .add(
10
+ HttpApiEndpoint.get("usage.limits", "/api/experimental/usage/limits", {
11
+ query: LocationQuery,
12
+ success: Location.response(Schema.NullOr(UsageLimits.Info)),
13
+ error: ServiceUnavailableError,
14
+ })
15
+ .annotateMerge(locationQueryOpenApi)
16
+ .annotateMerge(
17
+ OpenApi.annotations({
18
+ identifier: "experimental.usage.limits",
19
+ summary: "Get usage limits",
20
+ description:
21
+ "Return the OpenCode Go allowance and Console budgets of the OpenCode Console workspace the location is signed in to, or null when it isn't signed in.",
22
+ }),
23
+ ),
24
+ )
25
+ .annotateMerge(
26
+ OpenApi.annotations({
27
+ title: "usage",
28
+ description: "Experimental usage limit routes.",
29
+ }),
30
+ )
@@ -0,0 +1,131 @@
1
+ import { FileDiff } from "@zyro-sec/schema/file-diff"
2
+ import { Location } from "@zyro-sec/schema/location"
3
+ import { NonNegativeInt, PositiveInt, optional } from "@zyro-sec/schema/schema"
4
+ import { Vcs } from "@zyro-sec/schema/vcs"
5
+ import { Schema } from "effect"
6
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
7
+ import { LocationQuery, locationQueryOpenApi } from "./location.js"
8
+ import { ConflictError, InvalidRequestError, ServiceUnavailableError } from "../errors.js"
9
+
10
+ const InitQuery = Schema.Struct({
11
+ ...LocationQuery.fields,
12
+ provider: Schema.optional(Schema.String).annotateKey({ description: "VCS provider to initialize. Defaults to git." }),
13
+ })
14
+
15
+ export class VcsInitNotSupportedError extends Schema.TaggedError<VcsInitNotSupportedError>()(
16
+ "VcsInitNotSupportedError",
17
+ { providerID: Schema.String, message: Schema.String },
18
+ { httpApiStatus: 501 },
19
+ ) {}
20
+
21
+ const BranchesQuery = Schema.Struct({
22
+ ...LocationQuery.fields,
23
+ search: Schema.optional(Schema.String),
24
+ limit: Schema.NumberFromString.pipe(Schema.decodeTo(PositiveInt), Schema.optional),
25
+ })
26
+
27
+ const DiffQuery = Schema.Struct({
28
+ ...LocationQuery.fields,
29
+ mode: Vcs.Mode,
30
+ base: optional(Schema.String),
31
+ context: Schema.NumberFromString.pipe(Schema.decodeTo(NonNegativeInt), Schema.optional),
32
+ untracked: optional(Vcs.Untracked),
33
+ })
34
+
35
+ export const VcsGroup = HttpApiGroup.make("server.vcs")
36
+ .add(
37
+ HttpApiEndpoint.post("vcs.init", "/api/vcs/init", {
38
+ query: InitQuery,
39
+ success: HttpApiSchema.NoContent,
40
+ error: [ConflictError, InvalidRequestError, VcsInitNotSupportedError, ServiceUnavailableError],
41
+ })
42
+ .annotateMerge(locationQueryOpenApi)
43
+ .annotateMerge(
44
+ OpenApi.annotations({
45
+ identifier: "vcs.init",
46
+ summary: "Initialize VCS repository",
47
+ description:
48
+ "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.",
49
+ }),
50
+ ),
51
+ )
52
+ .add(
53
+ HttpApiEndpoint.get("vcs.get", "/api/vcs", {
54
+ query: LocationQuery,
55
+ success: Location.response(Vcs.Info),
56
+ })
57
+ .annotateMerge(locationQueryOpenApi)
58
+ .annotateMerge(
59
+ OpenApi.annotations({
60
+ identifier: "vcs.get",
61
+ summary: "VCS info",
62
+ description: "Get current and default branch information for the requested location.",
63
+ }),
64
+ ),
65
+ )
66
+ .add(
67
+ HttpApiEndpoint.get("vcs.base", "/api/vcs/base", {
68
+ query: LocationQuery,
69
+ success: Location.response(Schema.NullOr(Vcs.Base)),
70
+ error: ServiceUnavailableError,
71
+ })
72
+ .annotateMerge(locationQueryOpenApi)
73
+ .annotateMerge(
74
+ OpenApi.annotations({
75
+ identifier: "vcs.base",
76
+ summary: "VCS review base",
77
+ description:
78
+ "Infer a local review base from named branch creation history, or the repository default only when currently on that branch. Returns null before the first commit or when the provider lacks base metadata; ambiguous Git history requires an explicit base on diff requests.",
79
+ }),
80
+ ),
81
+ )
82
+ .add(
83
+ HttpApiEndpoint.get("vcs.status", "/api/vcs/status", {
84
+ query: LocationQuery,
85
+ success: Location.response(Schema.Array(Vcs.FileStatus)),
86
+ })
87
+ .annotateMerge(locationQueryOpenApi)
88
+ .annotateMerge(
89
+ OpenApi.annotations({
90
+ identifier: "vcs.status",
91
+ summary: "VCS status",
92
+ description: "List uncommitted working-copy changes relative to the requested location.",
93
+ }),
94
+ ),
95
+ )
96
+ .add(
97
+ HttpApiEndpoint.get("vcs.branch.list", "/api/vcs/branch", {
98
+ query: BranchesQuery,
99
+ success: Location.response(Vcs.BranchList),
100
+ })
101
+ .annotateMerge(locationQueryOpenApi)
102
+ .annotateMerge(
103
+ OpenApi.annotations({
104
+ identifier: "vcs.branch.list",
105
+ summary: "VCS branches",
106
+ description: "List local and remote branches available at the requested location.",
107
+ }),
108
+ ),
109
+ )
110
+ .add(
111
+ HttpApiEndpoint.get("vcs.diff", "/api/vcs/diff", {
112
+ query: DiffQuery,
113
+ success: Location.response(Schema.Array(FileDiff.Info)),
114
+ error: ServiceUnavailableError,
115
+ })
116
+ .annotateMerge(locationQueryOpenApi)
117
+ .annotateMerge(
118
+ OpenApi.annotations({
119
+ identifier: "vcs.diff",
120
+ summary: "VCS diff",
121
+ description:
122
+ "Diff HEAD to the working copy (working), the base merge-base to the working copy (branch), or the base merge-base to HEAD (committed). Omitting base preserves repository-default comparison; supplying it overrides the comparison without saving it.",
123
+ }),
124
+ ),
125
+ )
126
+ .annotateMerge(
127
+ OpenApi.annotations({
128
+ title: "vcs",
129
+ description: "Location-scoped version control routes.",
130
+ }),
131
+ )
@@ -0,0 +1,96 @@
1
+ import { Schema } from "effect"
2
+ import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
3
+ import { InvalidRequestError, LocationNotFoundError, ServiceUnavailableError } from "../errors.js"
4
+
5
+ export const VoiceTransportType = Schema.Literals(["webrtc", "websocket"]).annotate({
6
+ identifier: "VoiceTransportType",
7
+ })
8
+
9
+ export const VoiceModel = Schema.Struct({
10
+ model: Schema.String,
11
+ name: Schema.String,
12
+ engine: Schema.String,
13
+ provider: Schema.String,
14
+ transports: Schema.Array(VoiceTransportType),
15
+ available: Schema.Boolean,
16
+ }).annotate({ identifier: "VoiceModel" })
17
+
18
+ export const VoiceWebRTCTransportInput = Schema.Struct({
19
+ type: Schema.Literal("webrtc"),
20
+ sdp: Schema.String,
21
+ dcid: Schema.optional(Schema.Number),
22
+ }).annotate({ identifier: "VoiceWebRTCTransportInput" })
23
+
24
+ export const VoiceWebSocketTransportInput = Schema.Struct({
25
+ type: Schema.Literal("websocket"),
26
+ }).annotate({ identifier: "VoiceWebSocketTransportInput" })
27
+
28
+ export const VoiceTransportInput = Schema.Union([
29
+ VoiceWebRTCTransportInput,
30
+ VoiceWebSocketTransportInput,
31
+ ]).annotate({ identifier: "VoiceTransportInput" })
32
+
33
+ export const VoiceWebRTCTransport = Schema.Struct({
34
+ type: Schema.Literal("webrtc"),
35
+ sdp: Schema.String,
36
+ }).annotate({ identifier: "VoiceWebRTCTransport" })
37
+
38
+ export const VoiceWebSocketTransport = Schema.Struct({
39
+ type: Schema.Literal("websocket"),
40
+ url: Schema.String,
41
+ token: Schema.String,
42
+ expiresAt: Schema.Number,
43
+ }).annotate({ identifier: "VoiceWebSocketTransport" })
44
+
45
+ export const VoiceTransport = Schema.Union([
46
+ VoiceWebRTCTransport,
47
+ VoiceWebSocketTransport,
48
+ ]).annotate({ identifier: "VoiceTransport" })
49
+
50
+ export const VoiceGroup = HttpApiGroup.make("server.voice")
51
+ .add(
52
+ HttpApiEndpoint.get("voice.models", "/api/experimental/voice/models", {
53
+ success: Schema.Struct({
54
+ data: Schema.Struct({
55
+ models: Schema.Array(VoiceModel),
56
+ default: Schema.optional(Schema.String),
57
+ }),
58
+ }).annotate({ identifier: "VoiceModelsResponse" }),
59
+ error: [ServiceUnavailableError, LocationNotFoundError],
60
+ }).annotateMerge(
61
+ OpenApi.annotations({
62
+ identifier: "experimental.voice.models",
63
+ summary: "List voice models",
64
+ description:
65
+ "List supported voice models, their transports, and whether the server has a usable API key for each provider.",
66
+ }),
67
+ ),
68
+ )
69
+ .add(
70
+ HttpApiEndpoint.post("voice.session", "/api/experimental/voice/session", {
71
+ payload: Schema.Struct({
72
+ model: Schema.String,
73
+ session: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
74
+ transport: VoiceTransportInput,
75
+ }),
76
+ success: Schema.Struct({
77
+ data: Schema.Struct({
78
+ transport: VoiceTransport,
79
+ }),
80
+ }).annotate({ identifier: "VoiceSessionResponse" }),
81
+ error: [InvalidRequestError, ServiceUnavailableError, LocationNotFoundError],
82
+ }).annotateMerge(
83
+ OpenApi.annotations({
84
+ identifier: "experimental.voice.session",
85
+ summary: "Create voice session",
86
+ description:
87
+ "Create a server-brokered voice session using the server's configured provider credentials and return the WebRTC SDP answer or WebSocket ephemeral token.",
88
+ }),
89
+ ),
90
+ )
91
+ .annotateMerge(
92
+ OpenApi.annotations({
93
+ title: "voice",
94
+ description: "Experimental server-brokered voice session routes.",
95
+ }),
96
+ )
@@ -0,0 +1,46 @@
1
+ import { Location } from "@zyro-sec/schema/location"
2
+ import { WebSearch } from "@zyro-sec/schema/websearch"
3
+ import { Schema } from "effect"
4
+ import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
5
+ import { InvalidRequestError, ServiceUnavailableError } from "../errors.js"
6
+ import { LocationQuery, locationQueryOpenApi } from "./location.js"
7
+
8
+ export const WebSearchGroup = HttpApiGroup.make("server.websearch")
9
+ .add(
10
+ HttpApiEndpoint.get("websearch.providers", "/api/websearch/provider", {
11
+ query: LocationQuery,
12
+ success: Location.response(Schema.Array(WebSearch.Provider)),
13
+ error: ServiceUnavailableError,
14
+ })
15
+ .annotateMerge(locationQueryOpenApi)
16
+ .annotateMerge(
17
+ OpenApi.annotations({
18
+ identifier: "websearch.providers",
19
+ summary: "List web search providers",
20
+ description: "Return the registered web search providers.",
21
+ }),
22
+ ),
23
+ )
24
+ .add(
25
+ HttpApiEndpoint.post("websearch.query", "/api/websearch", {
26
+ query: LocationQuery,
27
+ payload: Schema.Struct(WebSearch.Input.fields),
28
+ success: Location.response(WebSearch.Response),
29
+ error: [InvalidRequestError, ServiceUnavailableError],
30
+ })
31
+ .annotateMerge(locationQueryOpenApi)
32
+ .annotateMerge(
33
+ OpenApi.annotations({
34
+ identifier: "websearch.query",
35
+ summary: "Search the web",
36
+ description:
37
+ "Run one web search through the selected provider. Specify a provider to override the configured default.",
38
+ }),
39
+ ),
40
+ )
41
+ .annotateMerge(
42
+ OpenApi.annotations({
43
+ title: "websearch",
44
+ description: "Location-scoped web search routes.",
45
+ }),
46
+ )
@@ -0,0 +1,78 @@
1
+ import { Worktree } from "@zyro-sec/schema/worktree"
2
+ import { Schema } from "effect"
3
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
4
+ import { Project } from "@zyro-sec/schema/project"
5
+ import { ProjectNotFoundError } from "../errors.js"
6
+
7
+ const root = "/api/worktree"
8
+
9
+ export class WorktreeError extends Schema.TaggedError<WorktreeError>()(
10
+ "WorktreeError",
11
+ {
12
+ name: Schema.Literal("WorktreeError"),
13
+ data: Schema.Struct({
14
+ message: Schema.String,
15
+ forceRequired: Schema.optional(Schema.Boolean),
16
+ }),
17
+ },
18
+ { httpApiStatus: 400 },
19
+ ) {}
20
+
21
+ export const WorktreeGroup = HttpApiGroup.make("server.worktree")
22
+ .add(
23
+ HttpApiEndpoint.get("worktree.list", root, {
24
+ query: Schema.Struct({ projectID: Project.ID }),
25
+ success: Worktree.List,
26
+ error: ProjectNotFoundError,
27
+ }).annotateMerge(
28
+ OpenApi.annotations({
29
+ identifier: "worktree.list",
30
+ summary: "List worktrees",
31
+ description:
32
+ "Return the project's saved worktree inventory without loading configuration or running discovery.",
33
+ }),
34
+ ),
35
+ )
36
+ .add(
37
+ HttpApiEndpoint.post("worktree.create", root, {
38
+ payload: Worktree.CreateInput,
39
+ success: Worktree.Info,
40
+ error: [WorktreeError, ProjectNotFoundError],
41
+ }).annotateMerge(
42
+ OpenApi.annotations({
43
+ identifier: "worktree.create",
44
+ summary: "Create worktree",
45
+ description:
46
+ "Load the project's canonical configuration, create a local worktree using its selected strategy, then run the project's setup script.",
47
+ }),
48
+ ),
49
+ )
50
+ .add(
51
+ HttpApiEndpoint.delete("worktree.remove", root, {
52
+ payload: Worktree.RemoveInput,
53
+ success: HttpApiSchema.NoContent,
54
+ error: [WorktreeError, ProjectNotFoundError],
55
+ }).annotateMerge(
56
+ OpenApi.annotations({
57
+ identifier: "worktree.remove",
58
+ summary: "Remove worktree",
59
+ description:
60
+ "Load the project's canonical configuration and remove a saved worktree using its recorded strategy.",
61
+ }),
62
+ ),
63
+ )
64
+ .add(
65
+ HttpApiEndpoint.post("worktree.refresh", `${root}/refresh`, {
66
+ payload: Schema.Struct({ projectID: Project.ID }),
67
+ success: HttpApiSchema.NoContent,
68
+ error: [WorktreeError, ProjectNotFoundError],
69
+ }).annotateMerge(
70
+ OpenApi.annotations({
71
+ identifier: "worktree.refresh",
72
+ summary: "Refresh worktrees",
73
+ description:
74
+ "Load the project's canonical configuration, discover worktrees across known checkout roots using all available strategies, and reconcile saved state.",
75
+ }),
76
+ ),
77
+ )
78
+ .annotateMerge(OpenApi.annotations({ title: "worktree", description: "Project-based worktree management routes." }))
@@ -0,0 +1,6 @@
1
+ import { HttpApiMiddleware } from "effect/http-api"
2
+ import { UnauthorizedError } from "../errors.js"
3
+
4
+ export class Authorization extends HttpApiMiddleware.Service<Authorization>()("@zyro-sec/HttpApiAuthorization", {
5
+ error: UnauthorizedError,
6
+ }) {}
@@ -0,0 +1,7 @@
1
+ import { HttpApiMiddleware } from "effect/http-api"
2
+ import { InvalidRequestError } from "../errors.js"
3
+
4
+ export class SchemaErrorMiddleware extends HttpApiMiddleware.Service<SchemaErrorMiddleware>()(
5
+ "@zyro-sec/HttpApiSchemaError",
6
+ { error: InvalidRequestError },
7
+ ) {}