@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,12 @@
1
+ import { ArtifactEndpoints } from "./artifact.js";
2
+ import { BlobEndpoints } from "./blob.js";
3
+ import { BrowserTunnelEndpoint } from "./experimental/browser-tunnel.js";
4
+ import { AutomationEndpoints } from "./automation.js";
5
+ import { JobEndpoints } from "./job.js";
6
+ import { MachineEndpoints } from "./machine.js";
7
+ import { SpaceEndpoints } from "./space.js";
8
+ import { MediaGetEndpoint } from "./media.js";
9
+ import { PersistentPtyGroup } from "./persistent-pty.js";
10
+ import { PushEndpoints } from "./push.js";
11
+ /** `server.experimental`: routes under /api/experimental, without compatibility guarantees. */
12
+ export const ExperimentalGroup = PersistentPtyGroup.add(MediaGetEndpoint, ...BlobEndpoints, BrowserTunnelEndpoint, ...AutomationEndpoints, ...ArtifactEndpoints, ...JobEndpoints, ...MachineEndpoints, ...PushEndpoints, ...SpaceEndpoints);
@@ -0,0 +1,12 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
3
+ export declare const FlagGroup: HttpApiGroup.HttpApiGroup<"server.flag", HttpApiEndpoint.HttpApiEndpoint<"experimental.flag.get", "GET", "/api/experimental/flag", never, Schema.toCodecStringTree<Schema.Struct<{
4
+ readonly location: Schema.optional<Schema.Struct<{
5
+ readonly directory: Schema.optional<Schema.String>;
6
+ }>>;
7
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
8
+ readonly location: Schema.Struct<{
9
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
10
+ }>;
11
+ readonly data: Schema.$Record<Schema.String, Schema.Boolean>;
12
+ }>>, never, never, never>, false>;
@@ -0,0 +1,19 @@
1
+ import { Location } from "@radheim/schema/location";
2
+ import { Schema } from "effect";
3
+ import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api";
4
+ import { LocationQuery, locationQueryOpenApi } from "./location.js";
5
+ export const FlagGroup = HttpApiGroup.make("server.flag")
6
+ .add(HttpApiEndpoint.get("experimental.flag.get", "/api/experimental/flag", {
7
+ query: LocationQuery,
8
+ success: Location.response(Schema.Record(Schema.String, Schema.Boolean)),
9
+ })
10
+ .annotateMerge(locationQueryOpenApi)
11
+ .annotateMerge(OpenApi.annotations({
12
+ identifier: "experimental.flag.get",
13
+ summary: "Get feature flags",
14
+ description: "Experimental. Return the resolved feature flags the location's clients may act on, keyed by flag name. Flags not listed are off.",
15
+ })))
16
+ .annotateMerge(OpenApi.annotations({
17
+ title: "flag",
18
+ description: "Experimental feature flag routes.",
19
+ }));
@@ -0,0 +1,138 @@
1
+ import { Context, Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware } from "effect/http-api";
3
+ export declare const makeFormGroup: <LocationId extends HttpApiMiddleware.AnyId, LocationService>(locationMiddleware: Context.Key<LocationId, LocationService>) => HttpApiGroup.HttpApiGroup<"server.form", HttpApiEndpoint.HttpApiEndpoint<"form.list", "GET", "/api/form", never, Schema.toCodecStringTree<Schema.Struct<{
4
+ readonly location: Schema.optional<Schema.Struct<{
5
+ readonly directory: Schema.optional<Schema.String>;
6
+ }>>;
7
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
8
+ readonly location: Schema.Struct<{
9
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
10
+ }>;
11
+ readonly data: Schema.$Array<Schema.Struct<{
12
+ readonly id: Schema.brand<Schema.String, "Form.ID"> & {
13
+ create: (id?: string) => string & import("effect/Brand").Brand<"Form.ID">;
14
+ };
15
+ readonly sessionID: Schema.String;
16
+ readonly title: Schema.String;
17
+ readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
18
+ readonly fields: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
19
+ readonly key: Schema.String;
20
+ readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
21
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
22
+ readonly required: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
23
+ readonly hidden: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
24
+ readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
25
+ readonly key: Schema.String;
26
+ readonly op: Schema.Literals<readonly ["eq", "neq"]>;
27
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
28
+ }>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
29
+ readonly key: Schema.String;
30
+ readonly op: Schema.Literals<readonly ["eq", "neq"]>;
31
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
32
+ }>>>, never, never>;
33
+ readonly type: Schema.Literal<"string">;
34
+ readonly format: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["email", "uri", "date", "date-time"]>>>, Schema.optionalKey<Schema.Literals<readonly ["email", "uri", "date", "date-time"]>>, never, never>;
35
+ readonly minLength: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
36
+ readonly maxLength: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
37
+ readonly pattern: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
38
+ readonly placeholder: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
39
+ readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
40
+ readonly options: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
41
+ readonly value: Schema.String;
42
+ readonly label: Schema.String;
43
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
44
+ }>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
45
+ readonly value: Schema.String;
46
+ readonly label: Schema.String;
47
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
48
+ }>>>, never, never>;
49
+ readonly custom: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
50
+ }>, Schema.Struct<{
51
+ readonly key: Schema.String;
52
+ readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
53
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
54
+ readonly required: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
55
+ readonly hidden: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
56
+ readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
57
+ readonly key: Schema.String;
58
+ readonly op: Schema.Literals<readonly ["eq", "neq"]>;
59
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
60
+ }>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
61
+ readonly key: Schema.String;
62
+ readonly op: Schema.Literals<readonly ["eq", "neq"]>;
63
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
64
+ }>>>, never, never>;
65
+ readonly type: Schema.Literal<"number">;
66
+ readonly minimum: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
67
+ readonly maximum: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
68
+ readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
69
+ }>, Schema.Struct<{
70
+ readonly key: Schema.String;
71
+ readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
72
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
73
+ readonly required: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
74
+ readonly hidden: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
75
+ readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
76
+ readonly key: Schema.String;
77
+ readonly op: Schema.Literals<readonly ["eq", "neq"]>;
78
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
79
+ }>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
80
+ readonly key: Schema.String;
81
+ readonly op: Schema.Literals<readonly ["eq", "neq"]>;
82
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
83
+ }>>>, never, never>;
84
+ readonly type: Schema.Literal<"integer">;
85
+ readonly minimum: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
86
+ readonly maximum: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
87
+ readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
88
+ }>, Schema.Struct<{
89
+ readonly key: Schema.String;
90
+ readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
91
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
92
+ readonly required: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
93
+ readonly hidden: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
94
+ readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
95
+ readonly key: Schema.String;
96
+ readonly op: Schema.Literals<readonly ["eq", "neq"]>;
97
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
98
+ }>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
99
+ readonly key: Schema.String;
100
+ readonly op: Schema.Literals<readonly ["eq", "neq"]>;
101
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
102
+ }>>>, never, never>;
103
+ readonly type: Schema.Literal<"boolean">;
104
+ readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
105
+ }>, Schema.Struct<{
106
+ readonly key: Schema.String;
107
+ readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
108
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
109
+ readonly required: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
110
+ readonly hidden: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
111
+ readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
112
+ readonly key: Schema.String;
113
+ readonly op: Schema.Literals<readonly ["eq", "neq"]>;
114
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
115
+ }>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
116
+ readonly key: Schema.String;
117
+ readonly op: Schema.Literals<readonly ["eq", "neq"]>;
118
+ readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
119
+ }>>>, never, never>;
120
+ readonly type: Schema.Literal<"multiselect">;
121
+ readonly options: Schema.$Array<Schema.Struct<{
122
+ readonly value: Schema.String;
123
+ readonly label: Schema.String;
124
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
125
+ }>>;
126
+ readonly minItems: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
127
+ readonly maxItems: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
128
+ readonly custom: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
129
+ readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.String>>>, Schema.optionalKey<Schema.$Array<Schema.String>>, never, never>;
130
+ }>, Schema.Struct<{
131
+ readonly key: Schema.String;
132
+ readonly type: Schema.Literal<"external">;
133
+ readonly url: Schema.String;
134
+ readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
135
+ readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
136
+ }>]>>;
137
+ }>>;
138
+ }>>, never, LocationId, HttpApiMiddleware.Requires<LocationId>>, false>;
@@ -0,0 +1,18 @@
1
+ import { Form } from "@radheim/schema/form";
2
+ import { Location } from "@radheim/schema/location";
3
+ import { Context, Schema } from "effect";
4
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, OpenApi } from "effect/http-api";
5
+ import { LocationQuery, locationQueryOpenApi } from "./location.js";
6
+ export const makeFormGroup = (locationMiddleware) => HttpApiGroup.make("server.form")
7
+ .add(HttpApiEndpoint.get("form.list", "/api/form", {
8
+ query: LocationQuery,
9
+ success: Location.response(Schema.Array(Form.Info)),
10
+ })
11
+ .annotateMerge(locationQueryOpenApi)
12
+ .annotateMerge(OpenApi.annotations({
13
+ identifier: "form.list",
14
+ summary: "List pending forms",
15
+ description: "Retrieve pending forms for a location.",
16
+ })))
17
+ .middleware(locationMiddleware)
18
+ .annotateMerge(OpenApi.annotations({ title: "form", description: "Location form routes." }));
@@ -0,0 +1,60 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
3
+ import { FileNotFoundError, ServiceUnavailableError } from "../errors.js";
4
+ export declare const FileSystemGroup: HttpApiGroup.HttpApiGroup<"server.fs", HttpApiEndpoint.HttpApiEndpoint<"fs.find", "GET", "/api/fs/find", never, Schema.toCodecStringTree<Schema.Struct<{
5
+ readonly location: Schema.optional<Schema.Struct<{
6
+ readonly directory: Schema.optional<Schema.String>;
7
+ }>>;
8
+ readonly query: Schema.String;
9
+ readonly type: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["file", "directory"]>>>, Schema.optionalKey<Schema.Literals<readonly ["file", "directory"]>>, never, never>;
10
+ readonly limit: Schema.optional<Schema.compose<Schema.Int, Schema.NumberFromString>>;
11
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
12
+ readonly location: Schema.Struct<{
13
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
14
+ }>;
15
+ readonly data: Schema.$Array<Schema.Struct<{
16
+ readonly path: Schema.brand<Schema.String, "RelativePath">;
17
+ readonly type: Schema.Literals<readonly ["file", "directory"]>;
18
+ }>>;
19
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.list", "GET", "/api/fs/list", never, Schema.toCodecStringTree<Schema.Struct<{
20
+ readonly location: Schema.optional<Schema.Struct<{
21
+ readonly directory: Schema.optional<Schema.String>;
22
+ }>>;
23
+ readonly path: Schema.optional<Schema.String>;
24
+ }>>, never, never, Schema.toCodecJson<Schema.Struct<{
25
+ readonly location: Schema.Struct<{
26
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
27
+ }>;
28
+ readonly data: Schema.$Array<Schema.Struct<{
29
+ readonly path: Schema.brand<Schema.String, "RelativePath">;
30
+ readonly type: Schema.Literals<readonly ["file", "directory"]>;
31
+ }>>;
32
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError | typeof FileNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.read", "GET", "/api/fs/read/*", never, Schema.toCodecStringTree<Schema.Struct<{
33
+ readonly location: Schema.optional<Schema.Struct<{
34
+ readonly directory: Schema.optional<Schema.String>;
35
+ }>>;
36
+ }>>, never, never, Schema.toCodecJson<Schema.Uint8Array>, Schema.toCodecJson<typeof ServiceUnavailableError | typeof FileNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.unwatch", "DELETE", "/api/experimental/fs/watch", never, Schema.toCodecStringTree<Schema.Struct<{
37
+ readonly location: Schema.optional<Schema.Struct<{
38
+ readonly directory: Schema.optional<Schema.String>;
39
+ }>>;
40
+ }>>, Schema.toCodecJson<Schema.Struct<{
41
+ readonly path: Schema.String;
42
+ }>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.watch", "POST", "/api/experimental/fs/watch", never, Schema.toCodecStringTree<Schema.Struct<{
43
+ readonly location: Schema.optional<Schema.Struct<{
44
+ readonly directory: Schema.optional<Schema.String>;
45
+ }>>;
46
+ }>>, Schema.toCodecJson<Schema.Struct<{
47
+ readonly path: Schema.String;
48
+ }>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof ServiceUnavailableError | typeof FileNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.write", "POST", "/api/experimental/fs/write", never, Schema.toCodecStringTree<Schema.Struct<{
49
+ readonly location: Schema.optional<Schema.Struct<{
50
+ readonly directory: Schema.optional<Schema.String>;
51
+ }>>;
52
+ readonly path: Schema.String;
53
+ }>>, Schema.toCodecJson<Schema.Uint8Array>, never, Schema.toCodecJson<Schema.Struct<{
54
+ readonly location: Schema.Struct<{
55
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
56
+ }>;
57
+ readonly data: Schema.Struct<{
58
+ readonly path: Schema.brand<Schema.String, "AbsolutePath">;
59
+ }>;
60
+ }>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never>, false>;
@@ -0,0 +1,101 @@
1
+ import { FileSystem } from "@radheim/schema/filesystem";
2
+ import { Location } from "@radheim/schema/location";
3
+ import { PositiveInt } from "@radheim/schema/schema";
4
+ import { Schema } from "effect";
5
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
6
+ import { FileNotFoundError, ServiceUnavailableError } from "../errors.js";
7
+ import { LocationQuery, locationQueryOpenApi } from "./location.js";
8
+ const ListQuery = Schema.Struct({
9
+ ...LocationQuery.fields,
10
+ path: Schema.String.pipe(Schema.optional).annotate({
11
+ description: "An absolute path or a path relative to the requested location. Defaults to the location directory.",
12
+ }),
13
+ });
14
+ const WriteQuery = Schema.Struct({
15
+ ...LocationQuery.fields,
16
+ path: Schema.String.annotate({
17
+ description: "An absolute path or a path relative to the requested location. Missing parent directories are created.",
18
+ }),
19
+ });
20
+ const WatchPayload = Schema.Struct({
21
+ path: Schema.String.annotate({ description: "A file path relative to the requested location." }),
22
+ });
23
+ const FindQuery = Schema.Struct({
24
+ ...LocationQuery.fields,
25
+ query: FileSystem.FindInput.fields.query,
26
+ type: FileSystem.FindInput.fields.type,
27
+ limit: Schema.NumberFromString.pipe(Schema.decodeTo(PositiveInt), Schema.optional),
28
+ });
29
+ export const FileSystemGroup = HttpApiGroup.make("server.fs")
30
+ .add(HttpApiEndpoint.get("fs.read", "/api/fs/read/*", {
31
+ query: LocationQuery,
32
+ success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
33
+ error: [FileNotFoundError, ServiceUnavailableError],
34
+ })
35
+ .annotateMerge(locationQueryOpenApi)
36
+ .annotateMerge(OpenApi.annotations({
37
+ identifier: "fs.read",
38
+ summary: "Read file",
39
+ description: "Stream one file relative to the requested location with ETag, Last-Modified, and single-range HTTP Range support (206 Partial Content, 416 Range Not Satisfiable, and 304 Not Modified; multi-range and malformed Range headers fall back to 200).",
40
+ })))
41
+ .add(HttpApiEndpoint.get("fs.list", "/api/fs/list", {
42
+ query: ListQuery,
43
+ success: Location.response(Schema.Array(FileSystem.Entry)),
44
+ error: [FileNotFoundError, ServiceUnavailableError],
45
+ })
46
+ .annotateMerge(locationQueryOpenApi)
47
+ .annotateMerge(OpenApi.annotations({
48
+ identifier: "fs.list",
49
+ summary: "List directory",
50
+ description: "List direct children using an absolute path or a path relative to the requested location, including parents and siblings outside its directory. Entry paths remain relative to the requested location; listing does not switch locations.",
51
+ })))
52
+ .add(HttpApiEndpoint.get("fs.find", "/api/fs/find", {
53
+ query: FindQuery,
54
+ success: Location.response(Schema.Array(FileSystem.Entry)),
55
+ error: ServiceUnavailableError,
56
+ })
57
+ .annotateMerge(locationQueryOpenApi)
58
+ .annotateMerge(OpenApi.annotations({
59
+ identifier: "fs.find",
60
+ summary: "Find files",
61
+ description: "Find recursively ranked filesystem entries relative to the requested location.",
62
+ })))
63
+ .add(HttpApiEndpoint.post("fs.write", "/api/experimental/fs/write", {
64
+ query: WriteQuery,
65
+ payload: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
66
+ success: Location.response(FileSystem.Write),
67
+ error: ServiceUnavailableError,
68
+ })
69
+ .annotateMerge(locationQueryOpenApi)
70
+ .annotateMerge(OpenApi.annotations({
71
+ identifier: "experimental.fs.write",
72
+ summary: "Write file",
73
+ description: "Write the raw request body to an absolute path or a path relative to the requested location, creating parent directories, and return the resolved absolute path. Unlike read, the target is not confined to the location. Experimental: may change without compatibility guarantees.",
74
+ })))
75
+ .add(HttpApiEndpoint.post("fs.watch", "/api/experimental/fs/watch", {
76
+ query: LocationQuery,
77
+ payload: WatchPayload,
78
+ success: HttpApiSchema.NoContent,
79
+ error: [FileNotFoundError, ServiceUnavailableError],
80
+ })
81
+ .annotateMerge(locationQueryOpenApi)
82
+ .annotateMerge(OpenApi.annotations({
83
+ identifier: "experimental.fs.watch",
84
+ summary: "Watch file",
85
+ description: "Watch one file relative to the requested location for 24 hours, publishing filesystem.changed on that location when it changes. Watching an already watched file resets its expiry. Paths follow read confinement. Experimental: may change without compatibility guarantees.",
86
+ })))
87
+ .add(HttpApiEndpoint.delete("fs.unwatch", "/api/experimental/fs/watch", {
88
+ query: LocationQuery,
89
+ payload: WatchPayload,
90
+ success: HttpApiSchema.NoContent,
91
+ })
92
+ .annotateMerge(locationQueryOpenApi)
93
+ .annotateMerge(OpenApi.annotations({
94
+ identifier: "experimental.fs.unwatch",
95
+ summary: "Unwatch file",
96
+ description: "Stop watching one file relative to the requested location. Experimental: may change without compatibility guarantees.",
97
+ })))
98
+ .annotateMerge(OpenApi.annotations({
99
+ title: "filesystem",
100
+ description: "Experimental location-scoped filesystem routes.",
101
+ }));