@radheim/protocol 0.0.0-stage → 2.4.3

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 (104) hide show
  1. package/dist/api.d.ts +60 -0
  2. package/dist/api.js +81 -0
  3. package/dist/client.d.ts +69 -0
  4. package/dist/client.js +102 -0
  5. package/dist/errors.d.ts +273 -0
  6. package/dist/errors.js +227 -0
  7. package/dist/groups/agent.d.ts +299 -0
  8. package/dist/groups/agent.js +30 -0
  9. package/dist/groups/artifact.d.ts +173 -0
  10. package/dist/groups/artifact.js +80 -0
  11. package/dist/groups/automation.d.ts +480 -0
  12. package/dist/groups/automation.js +55 -0
  13. package/dist/groups/blob.d.ts +415 -0
  14. package/dist/groups/blob.js +79 -0
  15. package/dist/groups/command.d.ts +15 -0
  16. package/dist/groups/command.js +20 -0
  17. package/dist/groups/config.d.ts +27 -0
  18. package/dist/groups/config.js +32 -0
  19. package/dist/groups/credential.d.ts +93 -0
  20. package/dist/groups/credential.js +50 -0
  21. package/dist/groups/debug.d.ts +22 -0
  22. package/dist/groups/debug.js +49 -0
  23. package/dist/groups/event.d.ts +16442 -0
  24. package/dist/groups/event.js +68 -0
  25. package/dist/groups/experimental/browser-tunnel.d.ts +20 -0
  26. package/dist/groups/experimental/browser-tunnel.js +29 -0
  27. package/dist/groups/experimental.d.ts +1519 -0
  28. package/dist/groups/experimental.js +12 -0
  29. package/dist/groups/flag.d.ts +12 -0
  30. package/dist/groups/flag.js +19 -0
  31. package/dist/groups/form.d.ts +138 -0
  32. package/dist/groups/form.js +18 -0
  33. package/dist/groups/fs.d.ts +60 -0
  34. package/dist/groups/fs.js +101 -0
  35. package/dist/groups/generate.d.ts +397 -0
  36. package/dist/groups/generate.js +77 -0
  37. package/dist/groups/integration.d.ts +1724 -0
  38. package/dist/groups/integration.js +169 -0
  39. package/dist/groups/job.d.ts +95 -0
  40. package/dist/groups/job.js +45 -0
  41. package/dist/groups/location.d.ts +23 -0
  42. package/dist/groups/location.js +47 -0
  43. package/dist/groups/machine.d.ts +91 -0
  44. package/dist/groups/machine.js +61 -0
  45. package/dist/groups/mcp.d.ts +104 -0
  46. package/dist/groups/mcp.js +125 -0
  47. package/dist/groups/media.d.ts +8 -0
  48. package/dist/groups/media.js +18 -0
  49. package/dist/groups/message.d.ts +3696 -0
  50. package/dist/groups/message.js +102 -0
  51. package/dist/groups/migration.d.ts +28 -0
  52. package/dist/groups/migration.js +21 -0
  53. package/dist/groups/model.d.ts +536 -0
  54. package/dist/groups/model.js +39 -0
  55. package/dist/groups/permission.d.ts +175 -0
  56. package/dist/groups/permission.js +115 -0
  57. package/dist/groups/persistent-pty.d.ts +251 -0
  58. package/dist/groups/persistent-pty.js +109 -0
  59. package/dist/groups/plugin.d.ts +102 -0
  60. package/dist/groups/plugin.js +59 -0
  61. package/dist/groups/project.d.ts +83 -0
  62. package/dist/groups/project.js +37 -0
  63. package/dist/groups/provider.d.ts +354 -0
  64. package/dist/groups/provider.js +34 -0
  65. package/dist/groups/pty.d.ts +151 -0
  66. package/dist/groups/pty.js +117 -0
  67. package/dist/groups/push.d.ts +123 -0
  68. package/dist/groups/push.js +60 -0
  69. package/dist/groups/reference.d.ts +25 -0
  70. package/dist/groups/reference.js +33 -0
  71. package/dist/groups/rpc.d.ts +21 -0
  72. package/dist/groups/rpc.js +24 -0
  73. package/dist/groups/server.d.ts +46 -0
  74. package/dist/groups/server.js +55 -0
  75. package/dist/groups/session.d.ts +11874 -0
  76. package/dist/groups/session.js +663 -0
  77. package/dist/groups/shell.d.ts +125 -0
  78. package/dist/groups/shell.js +65 -0
  79. package/dist/groups/skill.d.ts +26 -0
  80. package/dist/groups/skill.js +34 -0
  81. package/dist/groups/space.d.ts +56 -0
  82. package/dist/groups/space.js +59 -0
  83. package/dist/groups/usage.d.ts +96 -0
  84. package/dist/groups/usage.js +22 -0
  85. package/dist/groups/vcs.d.ts +89 -0
  86. package/dist/groups/vcs.js +94 -0
  87. package/dist/groups/voice.d.ts +81 -0
  88. package/dist/groups/voice.js +75 -0
  89. package/dist/groups/websearch.d.ts +29 -0
  90. package/dist/groups/websearch.js +34 -0
  91. package/dist/groups/worktree.d.ts +41 -0
  92. package/dist/groups/worktree.js +52 -0
  93. package/dist/middleware/authorization.d.ts +13 -0
  94. package/dist/middleware/authorization.js +6 -0
  95. package/dist/middleware/schema-error.d.ts +13 -0
  96. package/dist/middleware/schema-error.js +4 -0
  97. package/dist/simulation/image.d.ts +35 -0
  98. package/dist/simulation/image.js +21 -0
  99. package/dist/simulation/terminal.d.ts +81 -0
  100. package/dist/simulation/terminal.js +49 -0
  101. package/dist/simulation.d.ts +1784 -0
  102. package/dist/simulation.js +485 -0
  103. package/package.json +46 -4
  104. package/README.md +0 -3
@@ -0,0 +1,94 @@
1
+ import { FileDiff } from "@radheim/schema/file-diff";
2
+ import { Location } from "@radheim/schema/location";
3
+ import { NonNegativeInt, PositiveInt, optional } from "@radheim/schema/schema";
4
+ import { Vcs } from "@radheim/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
+ const InitQuery = Schema.Struct({
10
+ ...LocationQuery.fields,
11
+ provider: Schema.optional(Schema.String).annotateKey({ description: "VCS provider to initialize. Defaults to git." }),
12
+ });
13
+ export class VcsInitNotSupportedError extends Schema.TaggedError()("VcsInitNotSupportedError", { providerID: Schema.String, message: Schema.String }, { httpApiStatus: 501 }) {
14
+ }
15
+ const BranchesQuery = Schema.Struct({
16
+ ...LocationQuery.fields,
17
+ search: Schema.optional(Schema.String),
18
+ limit: Schema.NumberFromString.pipe(Schema.decodeTo(PositiveInt), Schema.optional),
19
+ });
20
+ const DiffQuery = Schema.Struct({
21
+ ...LocationQuery.fields,
22
+ mode: Vcs.Mode,
23
+ base: optional(Schema.String),
24
+ context: Schema.NumberFromString.pipe(Schema.decodeTo(NonNegativeInt), Schema.optional),
25
+ untracked: optional(Vcs.Untracked),
26
+ });
27
+ export const VcsGroup = HttpApiGroup.make("server.vcs")
28
+ .add(HttpApiEndpoint.post("vcs.init", "/api/vcs/init", {
29
+ query: InitQuery,
30
+ success: HttpApiSchema.NoContent,
31
+ error: [ConflictError, InvalidRequestError, VcsInitNotSupportedError, ServiceUnavailableError],
32
+ })
33
+ .annotateMerge(locationQueryOpenApi)
34
+ .annotateMerge(OpenApi.annotations({
35
+ identifier: "vcs.init",
36
+ summary: "Initialize VCS repository",
37
+ 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.",
38
+ })))
39
+ .add(HttpApiEndpoint.get("vcs.get", "/api/vcs", {
40
+ query: LocationQuery,
41
+ success: Location.response(Vcs.Info),
42
+ })
43
+ .annotateMerge(locationQueryOpenApi)
44
+ .annotateMerge(OpenApi.annotations({
45
+ identifier: "vcs.get",
46
+ summary: "VCS info",
47
+ description: "Get current and default branch information for the requested location.",
48
+ })))
49
+ .add(HttpApiEndpoint.get("vcs.base", "/api/vcs/base", {
50
+ query: LocationQuery,
51
+ success: Location.response(Schema.NullOr(Vcs.Base)),
52
+ error: ServiceUnavailableError,
53
+ })
54
+ .annotateMerge(locationQueryOpenApi)
55
+ .annotateMerge(OpenApi.annotations({
56
+ identifier: "vcs.base",
57
+ summary: "VCS review base",
58
+ description: "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.",
59
+ })))
60
+ .add(HttpApiEndpoint.get("vcs.status", "/api/vcs/status", {
61
+ query: LocationQuery,
62
+ success: Location.response(Schema.Array(Vcs.FileStatus)),
63
+ })
64
+ .annotateMerge(locationQueryOpenApi)
65
+ .annotateMerge(OpenApi.annotations({
66
+ identifier: "vcs.status",
67
+ summary: "VCS status",
68
+ description: "List uncommitted working-copy changes relative to the requested location.",
69
+ })))
70
+ .add(HttpApiEndpoint.get("vcs.branch.list", "/api/vcs/branch", {
71
+ query: BranchesQuery,
72
+ success: Location.response(Vcs.BranchList),
73
+ })
74
+ .annotateMerge(locationQueryOpenApi)
75
+ .annotateMerge(OpenApi.annotations({
76
+ identifier: "vcs.branch.list",
77
+ summary: "VCS branches",
78
+ description: "List local and remote branches available at the requested location.",
79
+ })))
80
+ .add(HttpApiEndpoint.get("vcs.diff", "/api/vcs/diff", {
81
+ query: DiffQuery,
82
+ success: Location.response(Schema.Array(FileDiff.Info)),
83
+ error: ServiceUnavailableError,
84
+ })
85
+ .annotateMerge(locationQueryOpenApi)
86
+ .annotateMerge(OpenApi.annotations({
87
+ identifier: "vcs.diff",
88
+ summary: "VCS diff",
89
+ description: "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.",
90
+ })))
91
+ .annotateMerge(OpenApi.annotations({
92
+ title: "vcs",
93
+ description: "Location-scoped version control routes.",
94
+ }));
@@ -0,0 +1,81 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
3
+ import { InvalidRequestError, LocationNotFoundError, ServiceUnavailableError } from "../errors.js";
4
+ export declare const VoiceTransportType: Schema.Literals<readonly ["webrtc", "websocket"]>;
5
+ export declare const VoiceModel: Schema.Struct<{
6
+ readonly model: Schema.String;
7
+ readonly name: Schema.String;
8
+ readonly engine: Schema.String;
9
+ readonly provider: Schema.String;
10
+ readonly transports: Schema.$Array<Schema.Literals<readonly ["webrtc", "websocket"]>>;
11
+ readonly available: Schema.Boolean;
12
+ }>;
13
+ export declare const VoiceWebRTCTransportInput: Schema.Struct<{
14
+ readonly type: Schema.Literal<"webrtc">;
15
+ readonly sdp: Schema.String;
16
+ readonly dcid: Schema.optional<Schema.Number>;
17
+ }>;
18
+ export declare const VoiceWebSocketTransportInput: Schema.Struct<{
19
+ readonly type: Schema.Literal<"websocket">;
20
+ }>;
21
+ export declare const VoiceTransportInput: Schema.Union<readonly [Schema.Struct<{
22
+ readonly type: Schema.Literal<"webrtc">;
23
+ readonly sdp: Schema.String;
24
+ readonly dcid: Schema.optional<Schema.Number>;
25
+ }>, Schema.Struct<{
26
+ readonly type: Schema.Literal<"websocket">;
27
+ }>]>;
28
+ export declare const VoiceWebRTCTransport: Schema.Struct<{
29
+ readonly type: Schema.Literal<"webrtc">;
30
+ readonly sdp: Schema.String;
31
+ }>;
32
+ export declare const VoiceWebSocketTransport: Schema.Struct<{
33
+ readonly type: Schema.Literal<"websocket">;
34
+ readonly url: Schema.String;
35
+ readonly token: Schema.String;
36
+ readonly expiresAt: Schema.Number;
37
+ }>;
38
+ export declare const VoiceTransport: Schema.Union<readonly [Schema.Struct<{
39
+ readonly type: Schema.Literal<"webrtc">;
40
+ readonly sdp: Schema.String;
41
+ }>, Schema.Struct<{
42
+ readonly type: Schema.Literal<"websocket">;
43
+ readonly url: Schema.String;
44
+ readonly token: Schema.String;
45
+ readonly expiresAt: Schema.Number;
46
+ }>]>;
47
+ export declare const VoiceGroup: HttpApiGroup.HttpApiGroup<"server.voice", HttpApiEndpoint.HttpApiEndpoint<"voice.models", "GET", "/api/experimental/voice/models", never, never, never, never, Schema.toCodecJson<Schema.Struct<{
48
+ readonly data: Schema.Struct<{
49
+ readonly models: Schema.$Array<Schema.Struct<{
50
+ readonly model: Schema.String;
51
+ readonly name: Schema.String;
52
+ readonly engine: Schema.String;
53
+ readonly provider: Schema.String;
54
+ readonly transports: Schema.$Array<Schema.Literals<readonly ["webrtc", "websocket"]>>;
55
+ readonly available: Schema.Boolean;
56
+ }>>;
57
+ readonly default: Schema.optional<Schema.String>;
58
+ }>;
59
+ }>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"voice.session", "POST", "/api/experimental/voice/session", never, never, Schema.toCodecJson<Schema.Struct<{
60
+ readonly model: Schema.String;
61
+ readonly session: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
62
+ readonly transport: Schema.Union<readonly [Schema.Struct<{
63
+ readonly type: Schema.Literal<"webrtc">;
64
+ readonly sdp: Schema.String;
65
+ readonly dcid: Schema.optional<Schema.Number>;
66
+ }>, Schema.Struct<{
67
+ readonly type: Schema.Literal<"websocket">;
68
+ }>]>;
69
+ }>>, never, Schema.toCodecJson<Schema.Struct<{
70
+ readonly data: Schema.Struct<{
71
+ readonly transport: Schema.Union<readonly [Schema.Struct<{
72
+ readonly type: Schema.Literal<"webrtc">;
73
+ readonly sdp: Schema.String;
74
+ }>, Schema.Struct<{
75
+ readonly type: Schema.Literal<"websocket">;
76
+ readonly url: Schema.String;
77
+ readonly token: Schema.String;
78
+ readonly expiresAt: Schema.Number;
79
+ }>]>;
80
+ }>;
81
+ }>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
@@ -0,0 +1,75 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api";
3
+ import { InvalidRequestError, LocationNotFoundError, ServiceUnavailableError } from "../errors.js";
4
+ export const VoiceTransportType = Schema.Literals(["webrtc", "websocket"]).annotate({
5
+ identifier: "VoiceTransportType",
6
+ });
7
+ export const VoiceModel = Schema.Struct({
8
+ model: Schema.String,
9
+ name: Schema.String,
10
+ engine: Schema.String,
11
+ provider: Schema.String,
12
+ transports: Schema.Array(VoiceTransportType),
13
+ available: Schema.Boolean,
14
+ }).annotate({ identifier: "VoiceModel" });
15
+ export const VoiceWebRTCTransportInput = Schema.Struct({
16
+ type: Schema.Literal("webrtc"),
17
+ sdp: Schema.String,
18
+ dcid: Schema.optional(Schema.Number),
19
+ }).annotate({ identifier: "VoiceWebRTCTransportInput" });
20
+ export const VoiceWebSocketTransportInput = Schema.Struct({
21
+ type: Schema.Literal("websocket"),
22
+ }).annotate({ identifier: "VoiceWebSocketTransportInput" });
23
+ export const VoiceTransportInput = Schema.Union([
24
+ VoiceWebRTCTransportInput,
25
+ VoiceWebSocketTransportInput,
26
+ ]).annotate({ identifier: "VoiceTransportInput" });
27
+ export const VoiceWebRTCTransport = Schema.Struct({
28
+ type: Schema.Literal("webrtc"),
29
+ sdp: Schema.String,
30
+ }).annotate({ identifier: "VoiceWebRTCTransport" });
31
+ export const VoiceWebSocketTransport = Schema.Struct({
32
+ type: Schema.Literal("websocket"),
33
+ url: Schema.String,
34
+ token: Schema.String,
35
+ expiresAt: Schema.Number,
36
+ }).annotate({ identifier: "VoiceWebSocketTransport" });
37
+ export const VoiceTransport = Schema.Union([
38
+ VoiceWebRTCTransport,
39
+ VoiceWebSocketTransport,
40
+ ]).annotate({ identifier: "VoiceTransport" });
41
+ export const VoiceGroup = HttpApiGroup.make("server.voice")
42
+ .add(HttpApiEndpoint.get("voice.models", "/api/experimental/voice/models", {
43
+ success: Schema.Struct({
44
+ data: Schema.Struct({
45
+ models: Schema.Array(VoiceModel),
46
+ default: Schema.optional(Schema.String),
47
+ }),
48
+ }).annotate({ identifier: "VoiceModelsResponse" }),
49
+ error: [ServiceUnavailableError, LocationNotFoundError],
50
+ }).annotateMerge(OpenApi.annotations({
51
+ identifier: "experimental.voice.models",
52
+ summary: "List voice models",
53
+ description: "List supported voice models, their transports, and whether the server has a usable API key for each provider.",
54
+ })))
55
+ .add(HttpApiEndpoint.post("voice.session", "/api/experimental/voice/session", {
56
+ payload: Schema.Struct({
57
+ model: Schema.String,
58
+ session: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
59
+ transport: VoiceTransportInput,
60
+ }),
61
+ success: Schema.Struct({
62
+ data: Schema.Struct({
63
+ transport: VoiceTransport,
64
+ }),
65
+ }).annotate({ identifier: "VoiceSessionResponse" }),
66
+ error: [InvalidRequestError, ServiceUnavailableError, LocationNotFoundError],
67
+ }).annotateMerge(OpenApi.annotations({
68
+ identifier: "experimental.voice.session",
69
+ summary: "Create voice session",
70
+ description: "Create a server-brokered voice session using the server's configured provider credentials and return the WebRTC SDP answer or WebSocket ephemeral token.",
71
+ })))
72
+ .annotateMerge(OpenApi.annotations({
73
+ title: "voice",
74
+ description: "Experimental server-brokered voice session routes.",
75
+ }));
@@ -0,0 +1,29 @@
1
+ import { WebSearch } from "@radheim/schema/websearch";
2
+ import { Schema } from "effect";
3
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
4
+ import { InvalidRequestError, ServiceUnavailableError } from "../errors.js";
5
+ export declare const WebSearchGroup: HttpApiGroup.HttpApiGroup<"server.websearch", HttpApiEndpoint.HttpApiEndpoint<"websearch.providers", "GET", "/api/websearch/provider", never, Schema.toCodecStringTree<Schema.Struct<{
6
+ readonly location: Schema.optional<Schema.Struct<{
7
+ readonly directory: Schema.optional<Schema.String>;
8
+ }>>;
9
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
10
+ readonly location: Schema.Struct<{
11
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
12
+ }>;
13
+ readonly data: Schema.$Array<Schema.Struct<{
14
+ readonly id: Schema.brand<Schema.String, "WebSearch.ID">;
15
+ readonly name: Schema.String;
16
+ }>>;
17
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"websearch.query", "POST", "/api/websearch", never, Schema.toCodecStringTree<Schema.Struct<{
18
+ readonly location: Schema.optional<Schema.Struct<{
19
+ readonly directory: Schema.optional<Schema.String>;
20
+ }>>;
21
+ }>>, Schema.toCodecJson<Schema.Struct<{
22
+ readonly query: Schema.String;
23
+ readonly providerID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "WebSearch.ID">>>, Schema.optionalKey<Schema.brand<Schema.String, "WebSearch.ID">>, never, never>;
24
+ }>>, never, Schema.toCodecJson<Schema.Struct<{
25
+ readonly location: Schema.Struct<{
26
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
27
+ }>;
28
+ readonly data: typeof WebSearch.Response;
29
+ }>>, Schema.toCodecJson<typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
@@ -0,0 +1,34 @@
1
+ import { Location } from "@radheim/schema/location";
2
+ import { WebSearch } from "@radheim/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
+ export const WebSearchGroup = HttpApiGroup.make("server.websearch")
8
+ .add(HttpApiEndpoint.get("websearch.providers", "/api/websearch/provider", {
9
+ query: LocationQuery,
10
+ success: Location.response(Schema.Array(WebSearch.Provider)),
11
+ error: ServiceUnavailableError,
12
+ })
13
+ .annotateMerge(locationQueryOpenApi)
14
+ .annotateMerge(OpenApi.annotations({
15
+ identifier: "websearch.providers",
16
+ summary: "List web search providers",
17
+ description: "Return the registered web search providers.",
18
+ })))
19
+ .add(HttpApiEndpoint.post("websearch.query", "/api/websearch", {
20
+ query: LocationQuery,
21
+ payload: Schema.Struct(WebSearch.Input.fields),
22
+ success: Location.response(WebSearch.Response),
23
+ error: [InvalidRequestError, ServiceUnavailableError],
24
+ })
25
+ .annotateMerge(locationQueryOpenApi)
26
+ .annotateMerge(OpenApi.annotations({
27
+ identifier: "websearch.query",
28
+ summary: "Search the web",
29
+ description: "Run one web search through the selected provider. Specify a provider to override the configured default.",
30
+ })))
31
+ .annotateMerge(OpenApi.annotations({
32
+ title: "websearch",
33
+ description: "Location-scoped web search routes.",
34
+ }));
@@ -0,0 +1,41 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
3
+ import { ProjectNotFoundError } from "../errors.js";
4
+ declare const WorktreeError_base: Schema.Class<WorktreeError, Schema.TaggedStruct<"WorktreeError", {
5
+ readonly name: Schema.Literal<"WorktreeError">;
6
+ readonly data: Schema.Struct<{
7
+ readonly message: Schema.String;
8
+ readonly forceRequired: Schema.optional<Schema.Boolean>;
9
+ }>;
10
+ }>, import("effect/Cause").YieldableError>;
11
+ export declare class WorktreeError extends WorktreeError_base {
12
+ }
13
+ export declare const WorktreeGroup: HttpApiGroup.HttpApiGroup<"server.worktree", HttpApiEndpoint.HttpApiEndpoint<"worktree.create", "POST", "/api/worktree", never, never, Schema.toCodecJson<Schema.Struct<{
14
+ readonly projectID: Schema.brand<Schema.String, "Project.ID"> & {
15
+ global: string & import("effect/Brand").Brand<"Project.ID">;
16
+ };
17
+ readonly from: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "AbsolutePath">>>, Schema.optionalKey<Schema.brand<Schema.String, "AbsolutePath">>, never, never>;
18
+ readonly branch: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Trim>>, Schema.optionalKey<Schema.Trim>, never, never>;
19
+ readonly directory: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "AbsolutePath">>>, Schema.optionalKey<Schema.brand<Schema.String, "AbsolutePath">>, never, never>;
20
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
21
+ }>>, never, Schema.toCodecJson<Schema.Struct<{
22
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
23
+ }>>, Schema.toCodecJson<typeof ProjectNotFoundError | typeof WorktreeError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"worktree.list", "GET", "/api/worktree", never, Schema.toCodecStringTree<Schema.Struct<{
24
+ readonly projectID: Schema.brand<Schema.String, "Project.ID"> & {
25
+ global: string & import("effect/Brand").Brand<"Project.ID">;
26
+ };
27
+ }>>, never, never, Schema.toCodecJson<Schema.$Array<Schema.Struct<{
28
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
29
+ readonly strategy: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
30
+ }>>>, Schema.toCodecJson<typeof ProjectNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"worktree.refresh", "POST", "/api/worktree/refresh", never, never, Schema.toCodecJson<Schema.Struct<{
31
+ readonly projectID: Schema.brand<Schema.String, "Project.ID"> & {
32
+ global: string & import("effect/Brand").Brand<"Project.ID">;
33
+ };
34
+ }>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof ProjectNotFoundError | typeof WorktreeError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"worktree.remove", "DELETE", "/api/worktree", never, never, Schema.toCodecJson<Schema.Struct<{
35
+ readonly projectID: Schema.brand<Schema.String, "Project.ID"> & {
36
+ global: string & import("effect/Brand").Brand<"Project.ID">;
37
+ };
38
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
39
+ readonly force: Schema.Boolean;
40
+ }>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof ProjectNotFoundError | typeof WorktreeError>, never, never>, false>;
41
+ export {};
@@ -0,0 +1,52 @@
1
+ import { Worktree } from "@radheim/schema/worktree";
2
+ import { Schema } from "effect";
3
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
4
+ import { Project } from "@radheim/schema/project";
5
+ import { ProjectNotFoundError } from "../errors.js";
6
+ const root = "/api/worktree";
7
+ export class WorktreeError extends Schema.TaggedError()("WorktreeError", {
8
+ name: Schema.Literal("WorktreeError"),
9
+ data: Schema.Struct({
10
+ message: Schema.String,
11
+ forceRequired: Schema.optional(Schema.Boolean),
12
+ }),
13
+ }, { httpApiStatus: 400 }) {
14
+ }
15
+ export const WorktreeGroup = HttpApiGroup.make("server.worktree")
16
+ .add(HttpApiEndpoint.get("worktree.list", root, {
17
+ query: Schema.Struct({ projectID: Project.ID }),
18
+ success: Worktree.List,
19
+ error: ProjectNotFoundError,
20
+ }).annotateMerge(OpenApi.annotations({
21
+ identifier: "worktree.list",
22
+ summary: "List worktrees",
23
+ description: "Return the project's saved worktree inventory without loading configuration or running discovery.",
24
+ })))
25
+ .add(HttpApiEndpoint.post("worktree.create", root, {
26
+ payload: Worktree.CreateInput,
27
+ success: Worktree.Info,
28
+ error: [WorktreeError, ProjectNotFoundError],
29
+ }).annotateMerge(OpenApi.annotations({
30
+ identifier: "worktree.create",
31
+ summary: "Create worktree",
32
+ description: "Load the project's canonical configuration, create a local worktree using its selected strategy, then run the project's setup script.",
33
+ })))
34
+ .add(HttpApiEndpoint.delete("worktree.remove", root, {
35
+ payload: Worktree.RemoveInput,
36
+ success: HttpApiSchema.NoContent,
37
+ error: [WorktreeError, ProjectNotFoundError],
38
+ }).annotateMerge(OpenApi.annotations({
39
+ identifier: "worktree.remove",
40
+ summary: "Remove worktree",
41
+ description: "Load the project's canonical configuration and remove a saved worktree using its recorded strategy.",
42
+ })))
43
+ .add(HttpApiEndpoint.post("worktree.refresh", `${root}/refresh`, {
44
+ payload: Schema.Struct({ projectID: Project.ID }),
45
+ success: HttpApiSchema.NoContent,
46
+ error: [WorktreeError, ProjectNotFoundError],
47
+ }).annotateMerge(OpenApi.annotations({
48
+ identifier: "worktree.refresh",
49
+ summary: "Refresh worktrees",
50
+ description: "Load the project's canonical configuration, discover worktrees across known checkout roots using all available strategies, and reconcile saved state.",
51
+ })))
52
+ .annotateMerge(OpenApi.annotations({ title: "worktree", description: "Project-based worktree management routes." }));
@@ -0,0 +1,13 @@
1
+ import { HttpApiMiddleware } from "effect/http-api";
2
+ import { UnauthorizedError } from "../errors.js";
3
+ declare const Authorization_base: HttpApiMiddleware.ServiceClass<Authorization, "@radheim/HttpApiAuthorization", {
4
+ requires: never;
5
+ provides: never;
6
+ error: typeof UnauthorizedError;
7
+ clientError: never;
8
+ requiredForClient: false;
9
+ security: never;
10
+ }, HttpApiMiddleware.HttpApiMiddleware<never, typeof UnauthorizedError, never>>;
11
+ export declare class Authorization extends Authorization_base {
12
+ }
13
+ export {};
@@ -0,0 +1,6 @@
1
+ import { HttpApiMiddleware } from "effect/http-api";
2
+ import { UnauthorizedError } from "../errors.js";
3
+ export class Authorization extends HttpApiMiddleware.Service()("@radheim/HttpApiAuthorization", {
4
+ error: UnauthorizedError,
5
+ }) {
6
+ }
@@ -0,0 +1,13 @@
1
+ import { HttpApiMiddleware } from "effect/http-api";
2
+ import { InvalidRequestError } from "../errors.js";
3
+ declare const SchemaErrorMiddleware_base: HttpApiMiddleware.ServiceClass<SchemaErrorMiddleware, "@radheim/HttpApiSchemaError", {
4
+ requires: never;
5
+ provides: never;
6
+ error: typeof InvalidRequestError;
7
+ clientError: never;
8
+ requiredForClient: false;
9
+ security: never;
10
+ }, HttpApiMiddleware.HttpApiMiddleware<never, typeof InvalidRequestError, never>>;
11
+ export declare class SchemaErrorMiddleware extends SchemaErrorMiddleware_base {
12
+ }
13
+ export {};
@@ -0,0 +1,4 @@
1
+ import { HttpApiMiddleware } from "effect/http-api";
2
+ import { InvalidRequestError } from "../errors.js";
3
+ export class SchemaErrorMiddleware extends HttpApiMiddleware.Service()("@radheim/HttpApiSchemaError", { error: InvalidRequestError }) {
4
+ }
@@ -0,0 +1,35 @@
1
+ import { Schema } from "effect";
2
+ import { RpcGroup } from "effect/rpc";
3
+ /**
4
+ * The image surface: a frontend that draws pixels (OpenCode in Rune). Coordinates and sizes in the core
5
+ * protocol are logical points.
6
+ */
7
+ export declare const Surface = "image";
8
+ export declare const Capabilities: readonly ["ui.captureImage"];
9
+ export type Capability = (typeof Capabilities)[number];
10
+ /** `ui.captureImage`: the frontend's frame as it drew it, `width` by `height` device pixels. */
11
+ export declare const CapturedFrame: Schema.Struct<{
12
+ readonly format: Schema.Literal<"png">;
13
+ readonly width: Schema.Int;
14
+ readonly height: Schema.Int;
15
+ /** Device pixels per logical point. */
16
+ readonly scale: Schema.Number;
17
+ readonly data: Schema.String;
18
+ }>;
19
+ export interface CapturedFrame extends Schema.Schema.Type<typeof CapturedFrame> {
20
+ }
21
+ export declare const Request: Schema.Struct<{
22
+ readonly jsonrpc: Schema.Literal<"2.0">;
23
+ readonly id: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number, Schema.Null]>>;
24
+ readonly method: Schema.Literal<"ui.captureImage">;
25
+ }>;
26
+ export type Request = Schema.Schema.Type<typeof Request>;
27
+ export declare const Rpcs: RpcGroup.RpcGroup<import("effect/rpc/Rpc").Rpc<"ui.captureImage", Schema.Void, Schema.Struct<{
28
+ readonly format: Schema.Literal<"png">;
29
+ readonly width: Schema.Int;
30
+ readonly height: Schema.Int;
31
+ /** Device pixels per logical point. */
32
+ readonly scale: Schema.Number;
33
+ readonly data: Schema.String;
34
+ }>, typeof import("../simulation.js").SimulationRequestError, never, never>>;
35
+ export * as Image from "./image.js";
@@ -0,0 +1,21 @@
1
+ import { Schema } from "effect";
2
+ import { RpcGroup } from "effect/rpc";
3
+ import { JsonRpc, request } from "../simulation.js";
4
+ /**
5
+ * The image surface: a frontend that draws pixels (OpenCode in Rune). Coordinates and sizes in the core
6
+ * protocol are logical points.
7
+ */
8
+ export const Surface = "image";
9
+ export const Capabilities = ["ui.captureImage"];
10
+ /** `ui.captureImage`: the frontend's frame as it drew it, `width` by `height` device pixels. */
11
+ export const CapturedFrame = Schema.Struct({
12
+ format: Schema.Literal("png"),
13
+ width: Schema.Int.check(Schema.isGreaterThan(0)),
14
+ height: Schema.Int.check(Schema.isGreaterThan(0)),
15
+ /** Device pixels per logical point. */
16
+ scale: Schema.Number.check(Schema.isGreaterThan(0)),
17
+ data: Schema.String.check(Schema.isBase64()),
18
+ });
19
+ export const Request = Schema.Struct({ ...JsonRpc.RequestFields, method: Schema.Literal("ui.captureImage") });
20
+ export const Rpcs = RpcGroup.make(request("ui.captureImage", { success: CapturedFrame }));
21
+ export * as Image from "./image.js";
@@ -0,0 +1,81 @@
1
+ import { Schema } from "effect";
2
+ import { RpcGroup } from "effect/rpc";
3
+ /**
4
+ * The terminal surface: a frontend that draws cells (the OpenCode TUI). Coordinates and sizes in the core
5
+ * protocol are cells. A `ui` endpoint whose handshake declares no surface is a terminal.
6
+ */
7
+ export declare const Surface = "terminal";
8
+ export declare const Capabilities: readonly ["ui.capture", "ui.recording.finish", "ui.recording.pointer"];
9
+ export type Capability = (typeof Capabilities)[number];
10
+ export declare const Color: Schema.Tuple<readonly [Schema.Number, Schema.Number, Schema.Number, Schema.Number]>;
11
+ export type Color = Schema.Schema.Type<typeof Color>;
12
+ export declare const CapturedImage: Schema.Struct<{
13
+ readonly x: Schema.Number;
14
+ readonly y: Schema.Number;
15
+ readonly width: Schema.Number;
16
+ readonly height: Schema.Number;
17
+ readonly pixelWidth: Schema.Number;
18
+ readonly pixelHeight: Schema.Number;
19
+ readonly rgba: Schema.String;
20
+ }>;
21
+ export interface CapturedImage extends Schema.Schema.Type<typeof CapturedImage> {
22
+ }
23
+ /** `ui.capture`: the frontend's cells, with any images drawn over them. */
24
+ export declare const CapturedFrame: Schema.Struct<{
25
+ readonly cols: Schema.Number;
26
+ readonly rows: Schema.Number;
27
+ readonly cursor: Schema.Tuple<readonly [Schema.Number, Schema.Number]>;
28
+ readonly lines: Schema.$Array<Schema.Struct<{
29
+ readonly spans: Schema.$Array<Schema.Struct<{
30
+ readonly text: Schema.String;
31
+ readonly fg: Schema.Tuple<readonly [Schema.Number, Schema.Number, Schema.Number, Schema.Number]>;
32
+ readonly bg: Schema.Tuple<readonly [Schema.Number, Schema.Number, Schema.Number, Schema.Number]>;
33
+ readonly attributes: Schema.Number;
34
+ readonly width: Schema.Number;
35
+ }>>;
36
+ }>>;
37
+ readonly images: Schema.optionalKey<Schema.$Array<Schema.Struct<{
38
+ readonly x: Schema.Number;
39
+ readonly y: Schema.Number;
40
+ readonly width: Schema.Number;
41
+ readonly height: Schema.Number;
42
+ readonly pixelWidth: Schema.Number;
43
+ readonly pixelHeight: Schema.Number;
44
+ readonly rgba: Schema.String;
45
+ }>>>;
46
+ }>;
47
+ export interface CapturedFrame extends Schema.Schema.Type<typeof CapturedFrame> {
48
+ }
49
+ /** `ui.recording.finish`: the path of the finished terminal output timeline. */
50
+ export declare const RecordingFinish: Schema.String;
51
+ export type RecordingFinish = Schema.Schema.Type<typeof RecordingFinish>;
52
+ export declare const Request: Schema.Struct<{
53
+ readonly jsonrpc: Schema.Literal<"2.0">;
54
+ readonly id: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number, Schema.Null]>>;
55
+ readonly method: Schema.Literals<readonly ["ui.capture", "ui.recording.finish"]>;
56
+ }>;
57
+ export type Request = Schema.Schema.Type<typeof Request>;
58
+ export declare const Rpcs: RpcGroup.RpcGroup<import("effect/rpc/Rpc").Rpc<"ui.capture", Schema.Void, Schema.Struct<{
59
+ readonly cols: Schema.Number;
60
+ readonly rows: Schema.Number;
61
+ readonly cursor: Schema.Tuple<readonly [Schema.Number, Schema.Number]>;
62
+ readonly lines: Schema.$Array<Schema.Struct<{
63
+ readonly spans: Schema.$Array<Schema.Struct<{
64
+ readonly text: Schema.String;
65
+ readonly fg: Schema.Tuple<readonly [Schema.Number, Schema.Number, Schema.Number, Schema.Number]>;
66
+ readonly bg: Schema.Tuple<readonly [Schema.Number, Schema.Number, Schema.Number, Schema.Number]>;
67
+ readonly attributes: Schema.Number;
68
+ readonly width: Schema.Number;
69
+ }>>;
70
+ }>>;
71
+ readonly images: Schema.optionalKey<Schema.$Array<Schema.Struct<{
72
+ readonly x: Schema.Number;
73
+ readonly y: Schema.Number;
74
+ readonly width: Schema.Number;
75
+ readonly height: Schema.Number;
76
+ readonly pixelWidth: Schema.Number;
77
+ readonly pixelHeight: Schema.Number;
78
+ readonly rgba: Schema.String;
79
+ }>>>;
80
+ }>, typeof import("../simulation.js").SimulationRequestError, never, never> | import("effect/rpc/Rpc").Rpc<"ui.recording.finish", Schema.Void, Schema.String, typeof import("../simulation.js").SimulationRequestError, never, never>>;
81
+ export * as Terminal from "./terminal.js";
@@ -0,0 +1,49 @@
1
+ import { Schema } from "effect";
2
+ import { RpcGroup } from "effect/rpc";
3
+ import { JsonRpc, request } from "../simulation.js";
4
+ /**
5
+ * The terminal surface: a frontend that draws cells (the OpenCode TUI). Coordinates and sizes in the core
6
+ * protocol are cells. A `ui` endpoint whose handshake declares no surface is a terminal.
7
+ */
8
+ export const Surface = "terminal";
9
+ export const Capabilities = [
10
+ "ui.capture",
11
+ /** The frontend records its terminal output; `ui.recording.finish` returns the timeline. */
12
+ "ui.recording.finish",
13
+ /** The recording timeline includes pointer events, in cells. */
14
+ "ui.recording.pointer",
15
+ ];
16
+ export const Color = Schema.Tuple([Schema.Number, Schema.Number, Schema.Number, Schema.Number]);
17
+ export const CapturedImage = Schema.Struct({
18
+ x: Schema.Number,
19
+ y: Schema.Number,
20
+ width: Schema.Number,
21
+ height: Schema.Number,
22
+ pixelWidth: Schema.Number,
23
+ pixelHeight: Schema.Number,
24
+ rgba: Schema.String.check(Schema.isBase64()),
25
+ });
26
+ /** `ui.capture`: the frontend's cells, with any images drawn over them. */
27
+ export const CapturedFrame = Schema.Struct({
28
+ cols: Schema.Number,
29
+ rows: Schema.Number,
30
+ cursor: Schema.Tuple([Schema.Number, Schema.Number]),
31
+ lines: Schema.Array(Schema.Struct({
32
+ spans: Schema.Array(Schema.Struct({
33
+ text: Schema.String,
34
+ fg: Color,
35
+ bg: Color,
36
+ attributes: Schema.Number,
37
+ width: Schema.Number,
38
+ })),
39
+ })),
40
+ images: Schema.optionalKey(Schema.Array(CapturedImage)),
41
+ });
42
+ /** `ui.recording.finish`: the path of the finished terminal output timeline. */
43
+ export const RecordingFinish = Schema.String;
44
+ export const Request = Schema.Struct({
45
+ ...JsonRpc.RequestFields,
46
+ method: Schema.Literals(["ui.capture", "ui.recording.finish"]),
47
+ });
48
+ export const Rpcs = RpcGroup.make(request("ui.capture", { success: CapturedFrame }), request("ui.recording.finish", { success: RecordingFinish }));
49
+ export * as Terminal from "./terminal.js";