@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,125 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
3
+ import { ServiceUnavailableError, ShellNotFoundError } from "../errors.js";
4
+ export declare const ShellGroup: HttpApiGroup.HttpApiGroup<"server.shell", HttpApiEndpoint.HttpApiEndpoint<"shell.create", "POST", "/api/shell", never, Schema.toCodecStringTree<Schema.Struct<{
5
+ readonly location: Schema.optional<Schema.Struct<{
6
+ readonly directory: Schema.optional<Schema.String>;
7
+ }>>;
8
+ }>>, Schema.toCodecJson<Schema.Struct<{
9
+ readonly command: Schema.String;
10
+ readonly cwd: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
11
+ readonly timeout: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
12
+ readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
13
+ }>>, never, Schema.toCodecJson<Schema.Struct<{
14
+ readonly location: Schema.Struct<{
15
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
16
+ }>;
17
+ readonly data: Schema.Struct<{
18
+ readonly id: Schema.brand<Schema.String, "Shell.ID"> & {
19
+ create: () => string & import("effect/Brand").Brand<"Shell.ID">;
20
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Shell.ID">;
21
+ };
22
+ readonly status: Schema.Literals<readonly ["running", "exited", "timeout", "killed"]>;
23
+ readonly command: Schema.String;
24
+ readonly cwd: Schema.String;
25
+ readonly shell: Schema.String;
26
+ readonly file: Schema.String;
27
+ readonly pid: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
28
+ readonly exit: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
29
+ readonly signal: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
30
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
31
+ readonly time: Schema.Struct<{
32
+ readonly started: Schema.Finite;
33
+ readonly completed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
34
+ }>;
35
+ }>;
36
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"shell.get", "GET", "/api/shell/:id", Schema.toCodecStringTree<Schema.Struct<{
37
+ id: Schema.brand<Schema.String, "Shell.ID"> & {
38
+ create: () => string & import("effect/Brand").Brand<"Shell.ID">;
39
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Shell.ID">;
40
+ };
41
+ }>>, Schema.toCodecStringTree<Schema.Struct<{
42
+ readonly location: Schema.optional<Schema.Struct<{
43
+ readonly directory: Schema.optional<Schema.String>;
44
+ }>>;
45
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
46
+ readonly location: Schema.Struct<{
47
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
48
+ }>;
49
+ readonly data: Schema.Struct<{
50
+ readonly id: Schema.brand<Schema.String, "Shell.ID"> & {
51
+ create: () => string & import("effect/Brand").Brand<"Shell.ID">;
52
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Shell.ID">;
53
+ };
54
+ readonly status: Schema.Literals<readonly ["running", "exited", "timeout", "killed"]>;
55
+ readonly command: Schema.String;
56
+ readonly cwd: Schema.String;
57
+ readonly shell: Schema.String;
58
+ readonly file: Schema.String;
59
+ readonly pid: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
60
+ readonly exit: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
61
+ readonly signal: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
62
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
63
+ readonly time: Schema.Struct<{
64
+ readonly started: Schema.Finite;
65
+ readonly completed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
66
+ }>;
67
+ }>;
68
+ }>>, Schema.toCodecJson<typeof ShellNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"shell.list", "GET", "/api/shell", never, Schema.toCodecStringTree<Schema.Struct<{
69
+ readonly location: Schema.optional<Schema.Struct<{
70
+ readonly directory: Schema.optional<Schema.String>;
71
+ }>>;
72
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
73
+ readonly location: Schema.Struct<{
74
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
75
+ }>;
76
+ readonly data: Schema.$Array<Schema.Struct<{
77
+ readonly id: Schema.brand<Schema.String, "Shell.ID"> & {
78
+ create: () => string & import("effect/Brand").Brand<"Shell.ID">;
79
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Shell.ID">;
80
+ };
81
+ readonly status: Schema.Literals<readonly ["running", "exited", "timeout", "killed"]>;
82
+ readonly command: Schema.String;
83
+ readonly cwd: Schema.String;
84
+ readonly shell: Schema.String;
85
+ readonly file: Schema.String;
86
+ readonly pid: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
87
+ readonly exit: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
88
+ readonly signal: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
89
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
90
+ readonly time: Schema.Struct<{
91
+ readonly started: Schema.Finite;
92
+ readonly completed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Finite>>, Schema.optionalKey<Schema.Finite>, never, never>;
93
+ }>;
94
+ }>>;
95
+ }>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"shell.output", "GET", "/api/shell/:id/output", Schema.toCodecStringTree<Schema.Struct<{
96
+ id: Schema.brand<Schema.String, "Shell.ID"> & {
97
+ create: () => string & import("effect/Brand").Brand<"Shell.ID">;
98
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Shell.ID">;
99
+ };
100
+ }>>, Schema.toCodecStringTree<Schema.Struct<{
101
+ readonly cursor: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
102
+ readonly limit: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
103
+ readonly location: Schema.optional<Schema.Struct<{
104
+ readonly directory: Schema.optional<Schema.String>;
105
+ }>>;
106
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
107
+ readonly location: Schema.Struct<{
108
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
109
+ }>;
110
+ readonly data: Schema.Struct<{
111
+ readonly output: Schema.String;
112
+ readonly cursor: Schema.Int;
113
+ readonly size: Schema.Int;
114
+ readonly truncated: Schema.Boolean;
115
+ }>;
116
+ }>>, Schema.toCodecJson<typeof ShellNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"shell.remove", "DELETE", "/api/shell/:id", Schema.toCodecStringTree<Schema.Struct<{
117
+ id: Schema.brand<Schema.String, "Shell.ID"> & {
118
+ create: () => string & import("effect/Brand").Brand<"Shell.ID">;
119
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Shell.ID">;
120
+ };
121
+ }>>, Schema.toCodecStringTree<Schema.Struct<{
122
+ readonly location: Schema.optional<Schema.Struct<{
123
+ readonly directory: Schema.optional<Schema.String>;
124
+ }>>;
125
+ }>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, never, never, never>, false>;
@@ -0,0 +1,65 @@
1
+ import { Shell } from "@radheim/schema/shell";
2
+ import { Location } from "@radheim/schema/location";
3
+ import { Schema } from "effect";
4
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
5
+ import { ServiceUnavailableError, ShellNotFoundError } from "../errors.js";
6
+ import { LocationQuery, locationQueryOpenApi } from "./location.js";
7
+ export const ShellGroup = HttpApiGroup.make("server.shell")
8
+ .add(HttpApiEndpoint.get("shell.list", "/api/shell", {
9
+ query: LocationQuery,
10
+ success: Location.response(Schema.Array(Shell.Info)),
11
+ })
12
+ .annotateMerge(locationQueryOpenApi)
13
+ .annotateMerge(OpenApi.annotations({
14
+ identifier: "shell.list",
15
+ summary: "List running shell commands",
16
+ description: "List currently running shell commands for a location. Exited commands are not included.",
17
+ })))
18
+ .add(HttpApiEndpoint.post("shell.create", "/api/shell", {
19
+ query: LocationQuery,
20
+ payload: Shell.CreateInput,
21
+ success: Location.response(Shell.Info),
22
+ error: ServiceUnavailableError,
23
+ })
24
+ .annotateMerge(locationQueryOpenApi)
25
+ .annotateMerge(OpenApi.annotations({
26
+ identifier: "shell.create",
27
+ summary: "Run shell command",
28
+ description: "Spawn one non-interactive shell command for a location. Combined stdout/stderr is captured to a file pageable via output.",
29
+ })))
30
+ .add(HttpApiEndpoint.get("shell.get", "/api/shell/:id", {
31
+ params: { id: Shell.ID },
32
+ query: LocationQuery,
33
+ success: Location.response(Shell.Info),
34
+ error: ShellNotFoundError,
35
+ })
36
+ .annotateMerge(locationQueryOpenApi)
37
+ .annotateMerge(OpenApi.annotations({
38
+ identifier: "shell.get",
39
+ summary: "Get shell command",
40
+ description: "Get one shell command, including its status and exit code once exited.",
41
+ })))
42
+ .add(HttpApiEndpoint.get("shell.output", "/api/shell/:id/output", {
43
+ params: { id: Shell.ID },
44
+ query: Schema.Struct({ ...LocationQuery.fields, ...Shell.OutputInput.fields }),
45
+ success: Location.response(Shell.Output),
46
+ error: ShellNotFoundError,
47
+ })
48
+ .annotateMerge(locationQueryOpenApi)
49
+ .annotateMerge(OpenApi.annotations({
50
+ identifier: "shell.output",
51
+ summary: "Read shell output",
52
+ description: "Page through captured combined output by absolute byte cursor.",
53
+ })))
54
+ .add(HttpApiEndpoint.delete("shell.remove", "/api/shell/:id", {
55
+ params: { id: Shell.ID },
56
+ query: LocationQuery,
57
+ success: HttpApiSchema.NoContent,
58
+ })
59
+ .annotateMerge(locationQueryOpenApi)
60
+ .annotateMerge(OpenApi.annotations({
61
+ identifier: "shell.remove",
62
+ summary: "Remove shell command",
63
+ description: "Terminate and remove one shell command and its retained output.",
64
+ })))
65
+ .annotateMerge(OpenApi.annotations({ title: "shell", description: "Location-scoped shell command routes." }));
@@ -0,0 +1,26 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
3
+ import { FileNotFoundError, SkillLoadError, SkillNotFoundError } from "../errors.js";
4
+ export declare const SkillGroup: HttpApiGroup.HttpApiGroup<"server.skill", HttpApiEndpoint.HttpApiEndpoint<"skill.file", "GET", "/api/experimental/skill/:skillID/file/*", Schema.toCodecStringTree<Schema.Struct<{
5
+ skillID: Schema.brand<Schema.String, "Skill.ID">;
6
+ }>>, Schema.toCodecStringTree<Schema.Struct<{
7
+ readonly location: Schema.optional<Schema.Struct<{
8
+ readonly directory: Schema.optional<Schema.String>;
9
+ }>>;
10
+ }>>, never, never, Schema.toCodecJson<Schema.Uint8Array>, Schema.toCodecJson<typeof FileNotFoundError | typeof SkillNotFoundError | typeof SkillLoadError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"skill.list", "GET", "/api/skill", never, Schema.toCodecStringTree<Schema.Struct<{
11
+ readonly location: Schema.optional<Schema.Struct<{
12
+ readonly directory: Schema.optional<Schema.String>;
13
+ }>>;
14
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
15
+ readonly location: Schema.Struct<{
16
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
17
+ }>;
18
+ readonly data: Schema.$Array<Schema.Struct<{
19
+ readonly id: Schema.brand<Schema.String, "Skill.ID">;
20
+ readonly name: Schema.brand<Schema.String, "Skill.Name">;
21
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
22
+ readonly autoinvoke: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
23
+ readonly path: Schema.brand<Schema.String, "AbsolutePath">;
24
+ readonly content: Schema.String;
25
+ }>>;
26
+ }>>, never, never, never>, false>;
@@ -0,0 +1,34 @@
1
+ import { Skill } from "@radheim/schema/skill";
2
+ import { Location } from "@radheim/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
+ export const SkillGroup = HttpApiGroup.make("server.skill")
8
+ .add(HttpApiEndpoint.get("skill.list", "/api/skill", {
9
+ query: LocationQuery,
10
+ success: Location.response(Schema.Array(Skill.Info)),
11
+ })
12
+ .annotateMerge(locationQueryOpenApi)
13
+ .annotateMerge(OpenApi.annotations({
14
+ identifier: "skill.list",
15
+ summary: "List skills",
16
+ description: "Retrieve currently registered skills.",
17
+ })))
18
+ .add(HttpApiEndpoint.get("skill.file", "/api/experimental/skill/:skillID/file/*", {
19
+ params: { skillID: Skill.ID },
20
+ query: LocationQuery,
21
+ success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
22
+ error: [SkillNotFoundError, FileNotFoundError, SkillLoadError],
23
+ })
24
+ .annotateMerge(locationQueryOpenApi)
25
+ .annotateMerge(OpenApi.annotations({
26
+ identifier: "experimental.skill.file",
27
+ summary: "Read skill file",
28
+ description: "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.",
29
+ transform: (operation) => ({ ...operation, tags: ["experimental"] }),
30
+ })))
31
+ .annotateMerge(OpenApi.annotations({
32
+ title: "skill",
33
+ description: "Experimental skill routes.",
34
+ }));
@@ -0,0 +1,56 @@
1
+ import { InvalidRequestError } from "../errors.js";
2
+ import { Schema } from "effect";
3
+ import { HttpApiEndpoint, HttpApiSchema } from "effect/http-api";
4
+ /** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
5
+ export declare const SpaceEndpoints: readonly [HttpApiEndpoint.HttpApiEndpoint<"space.write", "POST", "/api/experimental/space/write", never, never, Schema.toCodecJson<Schema.Struct<{
6
+ readonly changes: Schema.$Array<Schema.Struct<{
7
+ readonly space: Schema.String;
8
+ readonly key: Schema.String;
9
+ readonly value: Schema.NullOr<Schema.String>;
10
+ }>>;
11
+ }>>, never, Schema.toCodecJson<Schema.Struct<{
12
+ readonly spaces: Schema.$Array<Schema.Struct<{
13
+ readonly space: Schema.String;
14
+ readonly revision: Schema.Int;
15
+ readonly cursor: Schema.String;
16
+ }>>;
17
+ }>>, Schema.toCodecJson<typeof InvalidRequestError>, never, never>, HttpApiEndpoint.HttpApiEndpoint<"space.sync", "POST", "/api/experimental/space/sync", never, never, Schema.toCodecJson<Schema.Struct<{
18
+ readonly spaces: Schema.$Array<Schema.Struct<{
19
+ readonly space: Schema.String;
20
+ readonly cursor: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
21
+ }>>;
22
+ }>>, never, Schema.toCodecJson<Schema.Struct<{
23
+ readonly pages: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
24
+ readonly space: Schema.String;
25
+ readonly epoch: Schema.String;
26
+ readonly revision: Schema.Int;
27
+ readonly entries: Schema.$Array<Schema.Struct<{
28
+ readonly key: Schema.String;
29
+ readonly value: Schema.String;
30
+ }>>;
31
+ readonly cursor: Schema.String;
32
+ readonly next: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
33
+ readonly type: Schema.tag<"snapshot">;
34
+ }>, Schema.Struct<{
35
+ readonly space: Schema.String;
36
+ readonly epoch: Schema.String;
37
+ readonly revision: Schema.Int;
38
+ readonly entries: Schema.$Array<Schema.Struct<{
39
+ readonly key: Schema.String;
40
+ readonly value: Schema.String;
41
+ }>>;
42
+ readonly cursor: Schema.String;
43
+ readonly next: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
44
+ readonly type: Schema.tag<"delta">;
45
+ readonly deleted: Schema.$Array<Schema.String>;
46
+ }>]>>;
47
+ }>>, Schema.toCodecJson<typeof InvalidRequestError>, never, never>, HttpApiEndpoint.HttpApiEndpoint<"space.subscribe", "POST", "/api/experimental/space/subscribe", never, never, Schema.toCodecJson<Schema.Struct<{
48
+ readonly stream: Schema.String;
49
+ readonly spaces: Schema.$Array<Schema.Struct<{
50
+ readonly space: Schema.String;
51
+ readonly cursor: Schema.String;
52
+ }>>;
53
+ }>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof InvalidRequestError>, never, never>, HttpApiEndpoint.HttpApiEndpoint<"space.unsubscribe", "POST", "/api/experimental/space/unsubscribe", never, never, Schema.toCodecJson<Schema.Struct<{
54
+ readonly stream: Schema.String;
55
+ readonly spaces: Schema.$Array<Schema.String>;
56
+ }>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof InvalidRequestError>, never, never>, HttpApiEndpoint.HttpApiEndpoint<"space.reset", "POST", "/api/experimental/space/reset", never, never, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, never, never, never>];
@@ -0,0 +1,59 @@
1
+ import { Space } from "@radheim/schema/space";
2
+ import { optional } from "@radheim/schema/schema";
3
+ import { InvalidRequestError } from "../errors.js";
4
+ import { Schema } from "effect";
5
+ import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api";
6
+ const annotations = (identifier, summary, description) => OpenApi.annotations({
7
+ identifier: `experimental.space.${identifier}`,
8
+ summary,
9
+ description: `${description} To follow a space, a client opens /api/event and reads its stream ID from server.connected, syncs with experimental.space.sync until no space has a \`next\` or is left without a page, then subscribes the stream with the saved cursor through experimental.space.subscribe and applies the stream's events in order. On experimental.space.resync it syncs and subscribes that space again; after a reconnect it subscribes again with its latest cursor. Experimental: may change without compatibility guarantees.`,
10
+ // The routes share the `server.experimental` group with the persistent PTY prototype; tag them on their own.
11
+ transform: (operation) => ({ ...operation, tags: ["experimental"] }),
12
+ });
13
+ /** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
14
+ export const SpaceEndpoints = [
15
+ HttpApiEndpoint.post("space.write", "/api/experimental/space/write", {
16
+ payload: Schema.Struct({
17
+ changes: Schema.Array(Space.Change).check(Schema.isMinLength(1), Schema.isMaxLength(Space.MaxChanges)),
18
+ }),
19
+ error: InvalidRequestError,
20
+ success: Schema.Struct({
21
+ spaces: Schema.Array(Schema.Struct({
22
+ space: Space.Name,
23
+ revision: Space.Revision,
24
+ cursor: Space.Cursor.annotate({ description: "Covers this write and every change of the space before it." }),
25
+ })),
26
+ }),
27
+ }).annotateMerge(annotations("write", "Write values", "Commit 1 to 1024 changes, across any spaces, in one transaction, their values at most 1 MiB of UTF-8 in total. A string value sets the space's key, replacing any previous value; null deletes it, and deleting an unset key changes nothing. In request order, each change that changes a key takes its space's next revision and goes to that space's subscribers as its own experimental.space.updated or experimental.space.deleted event, so a key that appears twice keeps its last value. Values are client-defined, such as JSON text, and sent back unchanged. Returns each space's revision after the write, in the order the spaces first appear.")),
28
+ HttpApiEndpoint.post("space.sync", "/api/experimental/space/sync", {
29
+ payload: Schema.Struct({
30
+ spaces: Schema.Array(Schema.Struct({
31
+ space: Space.Name,
32
+ cursor: optional(Space.Cursor).annotate({
33
+ description: "A page's `next`, or a saved `cursor`. Without one, or with one this database cannot use, sync starts from a snapshot.",
34
+ }),
35
+ })).check(Schema.isMinLength(1), Schema.isMaxLength(Space.MaxSpaces)),
36
+ }),
37
+ error: InvalidRequestError,
38
+ success: Schema.Struct({ pages: Schema.Array(Space.Page) }),
39
+ }).annotateMerge(annotations("sync", "Sync spaces", "Read one page for each of 1 to 100 distinct spaces, in request order, with at most 500 keys across all pages: a snapshot page, or a delta of the keys changed and deleted since the cursor. A delta whose deletions were purged comes back as a snapshot. Apply a delta page at once; apply a snapshot page's entries at once, and remove the keys none of the snapshot's pages held after its last one, the page without `next` or the one before a delta. Once the 500 keys are used up, the remaining spaces get no page: sync them again with the same cursor, together with the `next` of the pages that have one.")),
40
+ HttpApiEndpoint.post("space.subscribe", "/api/experimental/space/subscribe", {
41
+ payload: Schema.Struct({
42
+ stream: Schema.String.annotate({ description: "The stream ID from the stream's server.connected event." }),
43
+ spaces: Schema.Array(Schema.Struct({ space: Space.Name, cursor: Space.Cursor })).check(Schema.isMinLength(1), Schema.isMaxLength(Space.MaxSpaces)),
44
+ }),
45
+ error: InvalidRequestError,
46
+ success: HttpApiSchema.NoContent,
47
+ }).annotateMerge(annotations("subscribe", "Subscribe stream", "Send 1 to 100 distinct spaces' changes to an open event stream, replacing any earlier subscription of those spaces on it: first the changes since each cursor as experimental.space.updated and experimental.space.deleted events in revision order, then every later change the same way, none missed or repeated. The catch-ups read at most 500 changes together, in request order: a space whose changes do not fit what is left, every space after they are used up, and one whose cursor is unusable get experimental.space.resync instead.")),
48
+ HttpApiEndpoint.post("space.unsubscribe", "/api/experimental/space/unsubscribe", {
49
+ payload: Schema.Struct({
50
+ stream: Schema.String.annotate({ description: "The stream ID from the stream's server.connected event." }),
51
+ spaces: Schema.Array(Space.Name).check(Schema.isMinLength(1), Schema.isMaxLength(Space.MaxSpaces)),
52
+ }),
53
+ error: InvalidRequestError,
54
+ success: HttpApiSchema.NoContent,
55
+ }).annotateMerge(annotations("unsubscribe", "Unsubscribe stream", "Stop sending these 1 to 100 distinct spaces' changes to an open event stream, including a catch-up still going out. Spaces it does not follow are ignored.")),
56
+ HttpApiEndpoint.post("space.reset", "/api/experimental/space/reset", {
57
+ success: HttpApiSchema.NoContent,
58
+ }).annotateMerge(annotations("reset", "Reset revisions", "Replace the epoch, so every client's saved cursor becomes unusable and its next sync starts from a snapshot. A restored backup brings back its old epoch, and cursors issued after the backup would then get wrong deltas: after restoring one, call this before clients reconnect, and do not serve writes or subscribers until it has run.")),
59
+ ];
@@ -0,0 +1,96 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
3
+ import { ServiceUnavailableError } from "../errors.js";
4
+ export declare const UsageGroup: HttpApiGroup.HttpApiGroup<"server.usage", HttpApiEndpoint.HttpApiEndpoint<"usage.limits", "GET", "/api/experimental/usage/limits", never, Schema.toCodecStringTree<Schema.Struct<{
5
+ readonly location: Schema.optional<Schema.Struct<{
6
+ readonly directory: Schema.optional<Schema.String>;
7
+ }>>;
8
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
9
+ readonly location: Schema.Struct<{
10
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
11
+ }>;
12
+ readonly data: Schema.NullOr<Schema.Struct<{
13
+ readonly workspace: Schema.Struct<{
14
+ readonly id: Schema.String;
15
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
16
+ readonly usageURL: Schema.String;
17
+ }>;
18
+ readonly go: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
19
+ readonly rolling: Schema.Struct<{
20
+ readonly percent: Schema.Finite;
21
+ readonly limited: Schema.Boolean;
22
+ readonly resetsAt: Schema.Finite;
23
+ }>;
24
+ readonly weekly: Schema.Struct<{
25
+ readonly percent: Schema.Finite;
26
+ readonly limited: Schema.Boolean;
27
+ readonly resetsAt: Schema.Finite;
28
+ }>;
29
+ readonly monthly: Schema.Struct<{
30
+ readonly percent: Schema.Finite;
31
+ readonly limited: Schema.Boolean;
32
+ readonly resetsAt: Schema.Finite;
33
+ }>;
34
+ }>>>, Schema.optionalKey<Schema.Struct<{
35
+ readonly rolling: Schema.Struct<{
36
+ readonly percent: Schema.Finite;
37
+ readonly limited: Schema.Boolean;
38
+ readonly resetsAt: Schema.Finite;
39
+ }>;
40
+ readonly weekly: Schema.Struct<{
41
+ readonly percent: Schema.Finite;
42
+ readonly limited: Schema.Boolean;
43
+ readonly resetsAt: Schema.Finite;
44
+ }>;
45
+ readonly monthly: Schema.Struct<{
46
+ readonly percent: Schema.Finite;
47
+ readonly limited: Schema.Boolean;
48
+ readonly resetsAt: Schema.Finite;
49
+ }>;
50
+ }>>, never, never>;
51
+ readonly budgets: Schema.$Array<Schema.Struct<{
52
+ readonly id: Schema.String;
53
+ readonly limit: Schema.brand<Schema.Finite, "Money.USD"> & {
54
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
55
+ };
56
+ readonly spent: Schema.brand<Schema.Finite, "Money.USD"> & {
57
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
58
+ };
59
+ readonly scope: Schema.Literals<readonly ["each", "combined"]>;
60
+ readonly per: Schema.Literals<readonly ["set", "model"]>;
61
+ readonly coverage: Schema.Literals<readonly ["all", "models"]>;
62
+ readonly models: Schema.$Array<Schema.Struct<{
63
+ readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
64
+ opencode: string & import("effect/Brand").Brand<"Provider.ID">;
65
+ anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
66
+ openai: string & import("effect/Brand").Brand<"Provider.ID">;
67
+ google: string & import("effect/Brand").Brand<"Provider.ID">;
68
+ googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
69
+ githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
70
+ claudeAgent: string & import("effect/Brand").Brand<"Provider.ID">;
71
+ amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
72
+ azure: string & import("effect/Brand").Brand<"Provider.ID">;
73
+ openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
74
+ mistral: string & import("effect/Brand").Brand<"Provider.ID">;
75
+ gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
76
+ };
77
+ readonly modelID: Schema.brand<Schema.String, "Model.ID">;
78
+ readonly name: Schema.String;
79
+ readonly spent: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USD"> & {
80
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
81
+ }>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USD"> & {
82
+ zero: number & import("effect/Brand").Brand<"Money.USD">;
83
+ }>, never, never>;
84
+ }>>;
85
+ readonly vendors: Schema.$Array<Schema.String>;
86
+ readonly inputPriceAtLeast: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
87
+ zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
88
+ }>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
89
+ zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
90
+ }>, never, never>;
91
+ readonly picked: Schema.Boolean;
92
+ readonly shared: Schema.Boolean;
93
+ readonly resetsAt: Schema.Finite;
94
+ }>>;
95
+ }>>;
96
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never>, false>;
@@ -0,0 +1,22 @@
1
+ import { Location } from "@radheim/schema/location";
2
+ import { UsageLimits } from "@radheim/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
+ export const UsageGroup = HttpApiGroup.make("server.usage")
8
+ .add(HttpApiEndpoint.get("usage.limits", "/api/experimental/usage/limits", {
9
+ query: LocationQuery,
10
+ success: Location.response(Schema.NullOr(UsageLimits.Info)),
11
+ error: ServiceUnavailableError,
12
+ })
13
+ .annotateMerge(locationQueryOpenApi)
14
+ .annotateMerge(OpenApi.annotations({
15
+ identifier: "experimental.usage.limits",
16
+ summary: "Get usage limits",
17
+ description: "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.",
18
+ })))
19
+ .annotateMerge(OpenApi.annotations({
20
+ title: "usage",
21
+ description: "Experimental usage limit routes.",
22
+ }));
@@ -0,0 +1,89 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
3
+ import { ConflictError, InvalidRequestError, ServiceUnavailableError } from "../errors.js";
4
+ declare const VcsInitNotSupportedError_base: Schema.Class<VcsInitNotSupportedError, Schema.TaggedStruct<"VcsInitNotSupportedError", {
5
+ readonly providerID: Schema.String;
6
+ readonly message: Schema.String;
7
+ }>, import("effect/Cause").YieldableError>;
8
+ export declare class VcsInitNotSupportedError extends VcsInitNotSupportedError_base {
9
+ }
10
+ export declare const VcsGroup: HttpApiGroup.HttpApiGroup<"server.vcs", HttpApiEndpoint.HttpApiEndpoint<"vcs.base", "GET", "/api/vcs/base", never, Schema.toCodecStringTree<Schema.Struct<{
11
+ readonly location: Schema.optional<Schema.Struct<{
12
+ readonly directory: Schema.optional<Schema.String>;
13
+ }>>;
14
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
15
+ readonly location: Schema.Struct<{
16
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
17
+ }>;
18
+ readonly data: Schema.NullOr<Schema.Struct<{
19
+ readonly name: Schema.String;
20
+ readonly ref: Schema.String;
21
+ readonly source: Schema.Literals<readonly ["reflog", "default"]>;
22
+ }>>;
23
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"vcs.branch.list", "GET", "/api/vcs/branch", never, Schema.toCodecStringTree<Schema.Struct<{
24
+ readonly location: Schema.optional<Schema.Struct<{
25
+ readonly directory: Schema.optional<Schema.String>;
26
+ }>>;
27
+ readonly search: Schema.optional<Schema.String>;
28
+ readonly limit: Schema.optional<Schema.compose<Schema.Int, Schema.NumberFromString>>;
29
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
30
+ readonly location: Schema.Struct<{
31
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
32
+ }>;
33
+ readonly data: Schema.$Array<Schema.String>;
34
+ }>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"vcs.diff", "GET", "/api/vcs/diff", never, Schema.toCodecStringTree<Schema.Struct<{
35
+ readonly location: Schema.optional<Schema.Struct<{
36
+ readonly directory: Schema.optional<Schema.String>;
37
+ }>>;
38
+ readonly mode: Schema.Literals<readonly ["working", "branch", "committed"]>;
39
+ readonly base: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
40
+ readonly context: Schema.optional<Schema.compose<Schema.Int, Schema.NumberFromString>>;
41
+ readonly untracked: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["files", "folders"]>>>, Schema.optionalKey<Schema.Literals<readonly ["files", "folders"]>>, never, never>;
42
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
43
+ readonly location: Schema.Struct<{
44
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
45
+ }>;
46
+ readonly data: Schema.$Array<Schema.Struct<{
47
+ readonly file: Schema.String;
48
+ readonly patch: Schema.String;
49
+ readonly additions: Schema.Int;
50
+ readonly deletions: Schema.Int;
51
+ readonly status: Schema.Literals<readonly ["added", "deleted", "modified"]>;
52
+ readonly more: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
53
+ }>>;
54
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"vcs.get", "GET", "/api/vcs", never, Schema.toCodecStringTree<Schema.Struct<{
55
+ readonly location: Schema.optional<Schema.Struct<{
56
+ readonly directory: Schema.optional<Schema.String>;
57
+ }>>;
58
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
59
+ readonly location: Schema.Struct<{
60
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
61
+ }>;
62
+ readonly data: Schema.Struct<{
63
+ readonly provider: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
64
+ readonly branch: Schema.Struct<{
65
+ readonly current: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
66
+ readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
67
+ }>;
68
+ }>;
69
+ }>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"vcs.init", "POST", "/api/vcs/init", never, Schema.toCodecStringTree<Schema.Struct<{
70
+ readonly location: Schema.optional<Schema.Struct<{
71
+ readonly directory: Schema.optional<Schema.String>;
72
+ }>>;
73
+ readonly provider: Schema.optional<Schema.String>;
74
+ }>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof InvalidRequestError | typeof ConflictError | typeof ServiceUnavailableError | typeof VcsInitNotSupportedError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"vcs.status", "GET", "/api/vcs/status", never, Schema.toCodecStringTree<Schema.Struct<{
75
+ readonly location: Schema.optional<Schema.Struct<{
76
+ readonly directory: Schema.optional<Schema.String>;
77
+ }>>;
78
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
79
+ readonly location: Schema.Struct<{
80
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
81
+ }>;
82
+ readonly data: Schema.$Array<Schema.Struct<{
83
+ readonly file: Schema.String;
84
+ readonly additions: Schema.Int;
85
+ readonly deletions: Schema.Int;
86
+ readonly status: Schema.Literals<readonly ["added", "deleted", "modified"]>;
87
+ }>>;
88
+ }>>, never, never, never>, false>;
89
+ export {};