@graftland/plugin-remote 0.3.2 → 0.4.0

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 (326) hide show
  1. package/README.md +18 -54
  2. package/README.zh-CN.md +17 -51
  3. package/README.zh-TW.md +17 -51
  4. package/dist/Auth.d.ts.map +1 -1
  5. package/dist/Auth.js.map +1 -1
  6. package/dist/Config.d.ts +1151 -0
  7. package/dist/Config.d.ts.map +1 -0
  8. package/dist/Config.js +183 -0
  9. package/dist/Config.js.map +1 -0
  10. package/dist/Contract.d.ts +1 -1
  11. package/dist/Contract.d.ts.map +1 -1
  12. package/dist/Contract.js +32 -1
  13. package/dist/Contract.js.map +1 -1
  14. package/dist/Instance.d.ts.map +1 -1
  15. package/dist/Instance.js.map +1 -1
  16. package/dist/Testing.d.ts +1 -1
  17. package/dist/Testing.d.ts.map +1 -1
  18. package/dist/Testing.js.map +1 -1
  19. package/dist/Transport.d.ts +1 -1
  20. package/dist/Transport.d.ts.map +1 -1
  21. package/dist/Transport.js.map +1 -1
  22. package/dist/cli.d.ts +4 -0
  23. package/dist/cli.d.ts.map +1 -0
  24. package/dist/cli.js +25 -0
  25. package/dist/cli.js.map +1 -0
  26. package/dist/host/auth/bearer.d.ts +9 -1
  27. package/dist/host/auth/bearer.d.ts.map +1 -1
  28. package/dist/host/auth/bearer.js +4 -2
  29. package/dist/host/auth/bearer.js.map +1 -1
  30. package/dist/host/auth/jwt.d.ts +9 -1
  31. package/dist/host/auth/jwt.d.ts.map +1 -1
  32. package/dist/host/auth/jwt.js +4 -2
  33. package/dist/host/auth/jwt.js.map +1 -1
  34. package/dist/host/auth/mtls.d.ts +10 -7
  35. package/dist/host/auth/mtls.d.ts.map +1 -1
  36. package/dist/host/auth/mtls.js +13 -14
  37. package/dist/host/auth/mtls.js.map +1 -1
  38. package/dist/host/auth/none.d.ts +3 -1
  39. package/dist/host/auth/none.js +7 -5
  40. package/dist/host/auth/none.js.map +1 -1
  41. package/dist/host/command.d.ts +14 -1
  42. package/dist/host/command.d.ts.map +1 -1
  43. package/dist/host/command.js +11 -9
  44. package/dist/host/command.js.map +1 -1
  45. package/dist/host/local.d.ts +2 -1
  46. package/dist/host/local.d.ts.map +1 -1
  47. package/dist/host/local.js +9 -30
  48. package/dist/host/local.js.map +1 -1
  49. package/dist/host/unix.d.ts +6 -1
  50. package/dist/host/unix.d.ts.map +1 -1
  51. package/dist/host/unix.js +13 -9
  52. package/dist/host/unix.js.map +1 -1
  53. package/dist/host/websocket.d.ts +10 -1
  54. package/dist/host/websocket.d.ts.map +1 -1
  55. package/dist/host/websocket.js +11 -8
  56. package/dist/host/websocket.js.map +1 -1
  57. package/dist/host/worker.d.ts +3 -1
  58. package/dist/host/worker.d.ts.map +1 -1
  59. package/dist/host/worker.js +13 -9
  60. package/dist/host/worker.js.map +1 -1
  61. package/dist/index.d.ts +6 -8
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +30 -64
  64. package/dist/index.js.map +1 -1
  65. package/dist/internal/Certificates.js.map +1 -1
  66. package/dist/internal/FailureGroup.js +6 -6
  67. package/dist/internal/FailureGroup.js.map +1 -1
  68. package/dist/internal/Peer.js.map +1 -1
  69. package/dist/internal/{ServeLifecycle.js → RunnerLifecycle.js} +6 -6
  70. package/dist/internal/RunnerLifecycle.js.map +1 -0
  71. package/dist/internal/Supervisor.js.map +1 -1
  72. package/dist/internal/assembly.d.ts +3 -2
  73. package/dist/internal/assembly.js +8 -8
  74. package/dist/internal/assembly.js.map +1 -1
  75. package/dist/internal/auth/config.d.ts +27 -0
  76. package/dist/internal/auth/config.d.ts.map +1 -0
  77. package/dist/internal/auth/config.js +29 -0
  78. package/dist/internal/auth/config.js.map +1 -0
  79. package/dist/internal/auth/mtls.js.map +1 -1
  80. package/dist/internal/auth/token.js.map +1 -1
  81. package/dist/internal/auth/tokenCredentials.d.ts +2 -1
  82. package/dist/internal/auth/tokenCredentials.d.ts.map +1 -1
  83. package/dist/internal/auth/tokenCredentials.js +1 -1
  84. package/dist/internal/auth/tokenCredentials.js.map +1 -1
  85. package/dist/internal/child.js +3 -3
  86. package/dist/internal/child.js.map +1 -1
  87. package/dist/internal/childMain.js +47 -0
  88. package/dist/internal/childMain.js.map +1 -0
  89. package/dist/internal/childRuntime.js +8 -8
  90. package/dist/internal/childRuntime.js.map +1 -1
  91. package/dist/internal/cleanup.js +3 -3
  92. package/dist/internal/cleanup.js.map +1 -1
  93. package/dist/internal/contract.js.map +1 -1
  94. package/dist/internal/credentials.d.ts +3 -2
  95. package/dist/internal/credentials.d.ts.map +1 -1
  96. package/dist/internal/credentials.js +1 -1
  97. package/dist/internal/credentials.js.map +1 -1
  98. package/dist/internal/directTransport.js.map +1 -1
  99. package/dist/internal/entry.d.ts +493 -3
  100. package/dist/internal/entry.d.ts.map +1 -1
  101. package/dist/internal/entry.js +22 -9
  102. package/dist/internal/entry.js.map +1 -1
  103. package/dist/internal/entryConfig.d.ts +2 -202
  104. package/dist/internal/entryConfig.js +2 -136
  105. package/dist/internal/entryConfig.js.map +1 -1
  106. package/dist/internal/execution.d.ts +4 -4
  107. package/dist/internal/execution.js +11 -11
  108. package/dist/internal/execution.js.map +1 -1
  109. package/dist/internal/follow.js +1 -1
  110. package/dist/internal/follow.js.map +1 -1
  111. package/dist/internal/forkTree.js.map +1 -1
  112. package/dist/internal/host/local.js.map +1 -1
  113. package/dist/internal/host/runner.js +4 -4
  114. package/dist/internal/host/runner.js.map +1 -1
  115. package/dist/internal/host.js +2 -2
  116. package/dist/internal/host.js.map +1 -1
  117. package/dist/internal/importer.js +1 -1
  118. package/dist/internal/importer.js.map +1 -1
  119. package/dist/internal/listenerStartup.js +1 -1
  120. package/dist/internal/listenerStartup.js.map +1 -1
  121. package/dist/internal/loadModule.js.map +1 -1
  122. package/dist/internal/platform.js +1 -9
  123. package/dist/internal/port.d.ts +1 -1
  124. package/dist/internal/port.js +2 -2
  125. package/dist/internal/port.js.map +1 -1
  126. package/dist/internal/runner/Bootstrap.js.map +1 -1
  127. package/dist/internal/runner/Connection.d.ts +3 -2
  128. package/dist/internal/runner/Connection.js +6 -6
  129. package/dist/internal/runner/Connection.js.map +1 -1
  130. package/dist/internal/runner/Execution.js +6 -6
  131. package/dist/internal/runner/Execution.js.map +1 -1
  132. package/dist/internal/runner/Local.js +1 -1
  133. package/dist/internal/runner/Local.js.map +1 -1
  134. package/dist/internal/runner/Lock.js.map +1 -1
  135. package/dist/internal/runner/Multiplex.js.map +1 -1
  136. package/dist/internal/runner/Packages.js.map +1 -1
  137. package/dist/internal/runner/ProcessObservation.js.map +1 -1
  138. package/dist/internal/runner/Processes.js.map +1 -1
  139. package/dist/internal/runner/Retention.js.map +1 -1
  140. package/dist/internal/runner/Store.js.map +1 -1
  141. package/dist/internal/runner/Supervisor.js +5 -5
  142. package/dist/internal/runner/Supervisor.js.map +1 -1
  143. package/dist/internal/runner/Watchdog.js.map +1 -1
  144. package/dist/internal/runner/Wire.d.ts +1 -1
  145. package/dist/internal/runner/Wire.js.map +1 -1
  146. package/dist/internal/runner/accept.js +2 -2
  147. package/dist/internal/runner/accept.js.map +1 -1
  148. package/dist/internal/runner/command.js +1 -1
  149. package/dist/internal/runner/command.js.map +1 -1
  150. package/dist/internal/runner/connectionEnded.js +1 -1
  151. package/dist/internal/runner/connectionEnded.js.map +1 -1
  152. package/dist/internal/runner/model.d.ts.map +1 -1
  153. package/dist/internal/runner/model.js.map +1 -1
  154. package/dist/internal/services.d.ts.map +1 -1
  155. package/dist/internal/services.js +1 -1
  156. package/dist/internal/services.js.map +1 -1
  157. package/dist/internal/socketChannel.js.map +1 -1
  158. package/dist/internal/stdioChannel.js.map +1 -1
  159. package/dist/internal/supervisorPlugin.js +48 -1
  160. package/dist/internal/supervisorPlugin.js.map +1 -1
  161. package/dist/internal/transportOptions.d.ts.map +1 -1
  162. package/dist/internal/watchdogMain.js +5 -3
  163. package/dist/internal/watchdogMain.js.map +1 -1
  164. package/dist/internal/websocket.js.map +1 -1
  165. package/dist/internal/websocketServer.js +1 -1
  166. package/dist/internal/websocketServer.js.map +1 -1
  167. package/dist/internal/workerChannel.js.map +1 -1
  168. package/dist/internal/workerMain.js +13 -6
  169. package/dist/internal/workerMain.js.map +1 -1
  170. package/dist/runner/auth/bearer.d.ts +8 -5
  171. package/dist/runner/auth/bearer.d.ts.map +1 -1
  172. package/dist/runner/auth/bearer.js +13 -11
  173. package/dist/runner/auth/bearer.js.map +1 -1
  174. package/dist/runner/auth/jwt.d.ts +30 -17
  175. package/dist/runner/auth/jwt.d.ts.map +1 -1
  176. package/dist/runner/auth/jwt.js +16 -28
  177. package/dist/runner/auth/jwt.js.map +1 -1
  178. package/dist/runner/auth/mtls.d.ts +8 -6
  179. package/dist/runner/auth/mtls.d.ts.map +1 -1
  180. package/dist/runner/auth/mtls.js +13 -29
  181. package/dist/runner/auth/mtls.js.map +1 -1
  182. package/dist/runner/auth/none.d.ts +7 -1
  183. package/dist/runner/auth/none.js +7 -5
  184. package/dist/runner/auth/none.js.map +1 -1
  185. package/dist/runner/index.d.ts +5 -1
  186. package/dist/runner/index.d.ts.map +1 -1
  187. package/dist/runner/index.js +62 -30
  188. package/dist/runner/index.js.map +1 -1
  189. package/dist/runner/stdio.d.ts +6 -1
  190. package/dist/runner/stdio.d.ts.map +1 -1
  191. package/dist/runner/stdio.js +11 -9
  192. package/dist/runner/stdio.js.map +1 -1
  193. package/dist/runner/unix.d.ts +6 -1
  194. package/dist/runner/unix.d.ts.map +1 -1
  195. package/dist/runner/unix.js +10 -8
  196. package/dist/runner/unix.js.map +1 -1
  197. package/dist/runner/websocket.d.ts +24 -1
  198. package/dist/runner/websocket.d.ts.map +1 -1
  199. package/dist/runner/websocket.js +12 -10
  200. package/dist/runner/websocket.js.map +1 -1
  201. package/package.json +14 -12
  202. package/schema.json +2269 -0
  203. package/src/Auth.ts +8 -2
  204. package/src/Config.ts +196 -0
  205. package/src/Contract.ts +12 -3
  206. package/src/Instance.ts +1 -0
  207. package/src/Testing.ts +6 -4
  208. package/src/Transport.ts +12 -3
  209. package/src/cli.ts +60 -0
  210. package/src/host/auth/bearer.ts +1 -0
  211. package/src/host/auth/jwt.ts +1 -0
  212. package/src/host/auth/mtls.ts +7 -12
  213. package/src/host/auth/none.ts +3 -1
  214. package/src/host/command.ts +8 -5
  215. package/src/host/local.ts +4 -2
  216. package/src/host/unix.ts +11 -7
  217. package/src/host/websocket.ts +10 -7
  218. package/src/host/worker.ts +8 -5
  219. package/src/index.ts +36 -23
  220. package/src/internal/Certificates.ts +1 -0
  221. package/src/internal/FailureGroup.ts +5 -3
  222. package/src/internal/Peer.ts +1 -0
  223. package/src/internal/{ServeLifecycle.ts → RunnerLifecycle.ts} +7 -5
  224. package/src/internal/Supervisor.ts +5 -4
  225. package/src/internal/assembly.ts +11 -9
  226. package/src/internal/auth/config.ts +44 -0
  227. package/src/internal/auth/mtls.ts +1 -0
  228. package/src/internal/auth/token.ts +1 -0
  229. package/src/internal/auth/tokenCredentials.ts +4 -2
  230. package/src/internal/child.ts +8 -6
  231. package/src/{bin.ts → internal/childMain.ts} +16 -61
  232. package/src/internal/childRuntime.ts +12 -10
  233. package/src/internal/cleanup.ts +3 -2
  234. package/src/internal/contract.ts +1 -0
  235. package/src/internal/credentials.ts +3 -1
  236. package/src/internal/directTransport.ts +9 -2
  237. package/src/internal/entry.ts +53 -16
  238. package/src/internal/entryConfig.ts +10 -132
  239. package/src/internal/execution.ts +17 -15
  240. package/src/internal/follow.ts +2 -1
  241. package/src/internal/forkTree.ts +2 -1
  242. package/src/internal/host/local.ts +1 -0
  243. package/src/internal/host/runner.ts +7 -5
  244. package/src/internal/host.ts +9 -8
  245. package/src/internal/importer.ts +3 -2
  246. package/src/internal/listenerStartup.ts +4 -2
  247. package/src/internal/loadModule.ts +1 -0
  248. package/src/internal/platform.ts +1 -12
  249. package/src/internal/port.ts +11 -6
  250. package/src/internal/runner/Bootstrap.ts +1 -0
  251. package/src/internal/runner/Connection.ts +13 -11
  252. package/src/internal/runner/Execution.ts +14 -13
  253. package/src/internal/runner/Local.ts +3 -2
  254. package/src/internal/runner/Lock.ts +1 -0
  255. package/src/internal/runner/Multiplex.ts +2 -1
  256. package/src/internal/runner/Packages.ts +7 -5
  257. package/src/internal/runner/ProcessObservation.ts +2 -1
  258. package/src/internal/runner/Processes.ts +3 -1
  259. package/src/internal/runner/Retention.ts +1 -0
  260. package/src/internal/runner/Store.ts +3 -2
  261. package/src/internal/runner/Supervisor.ts +22 -20
  262. package/src/internal/runner/Watchdog.ts +3 -1
  263. package/src/internal/runner/Wire.ts +13 -12
  264. package/src/internal/runner/accept.ts +6 -5
  265. package/src/internal/runner/command.ts +3 -2
  266. package/src/internal/runner/connectionEnded.ts +2 -1
  267. package/src/internal/runner/model.ts +5 -3
  268. package/src/internal/services.ts +9 -2
  269. package/src/internal/socketChannel.ts +2 -1
  270. package/src/internal/stdioChannel.ts +4 -2
  271. package/src/internal/supervisorPlugin.ts +10 -8
  272. package/src/internal/transportOptions.ts +1 -0
  273. package/src/internal/watchdogMain.ts +5 -3
  274. package/src/internal/websocket.ts +5 -2
  275. package/src/internal/websocketServer.ts +6 -4
  276. package/src/internal/workerChannel.ts +1 -0
  277. package/src/internal/workerMain.ts +21 -5
  278. package/src/runner/auth/bearer.ts +10 -6
  279. package/src/runner/auth/jwt.ts +10 -41
  280. package/src/runner/auth/mtls.ts +6 -3
  281. package/src/runner/auth/none.ts +3 -1
  282. package/src/runner/index.ts +102 -11
  283. package/src/runner/stdio.ts +15 -10
  284. package/src/runner/unix.ts +7 -4
  285. package/src/runner/websocket.ts +9 -7
  286. package/dist/Auth-BElTC9_X.js +0 -6
  287. package/dist/Bootstrap-H9gDsgsC.js +0 -9
  288. package/dist/ConfigDirectory-BCC6q2R4.js +0 -5
  289. package/dist/Contract-DsJtisvL.js +0 -83
  290. package/dist/Errors-DYhsGZcZ.js +0 -58
  291. package/dist/FailureGroup-BgT73AaR.js +0 -63
  292. package/dist/Framing-G9eSaeLb.js +0 -61
  293. package/dist/Graft-B71CPA2Y.js +0 -996
  294. package/dist/Packages-AgoCGotL.js +0 -108
  295. package/dist/Peer-DXeVrGBh.js +0 -342
  296. package/dist/ProcessObservation-gLgGirYv.js +0 -38
  297. package/dist/ServeLifecycle-Bd1FPJ6e.js +0 -24
  298. package/dist/Transport-DULzpsgR.js +0 -6
  299. package/dist/WatchdogProtocol-BZmVxrBP.js +0 -17
  300. package/dist/bin.js +0 -28276
  301. package/dist/bin.js.map +0 -1
  302. package/dist/childRuntime-Bm3iSg_N.js +0 -192
  303. package/dist/command-9zrHdbwT.js +0 -7
  304. package/dist/connectionEnded-BwcxQ7W8.js +0 -54
  305. package/dist/directTransport-DrexuPSm.js +0 -5
  306. package/dist/entry-psOpX3Bj.js +0 -736
  307. package/dist/importer-Cvf88eAY.js +0 -344
  308. package/dist/internal/ServeLifecycle.js.map +0 -1
  309. package/dist/internal/entryConfig.d.ts.map +0 -1
  310. package/dist/internal/platform.js.map +0 -1
  311. package/dist/internal/release.js +0 -25
  312. package/dist/internal/release.js.map +0 -1
  313. package/dist/internal/serve.js +0 -60
  314. package/dist/internal/serve.js.map +0 -1
  315. package/dist/port--3x2zJ4D.js +0 -285
  316. package/dist/release-DfZPuIcK.js +0 -23
  317. package/dist/rolldown-runtime-DYf_mQCB.js +0 -34
  318. package/dist/socketChannel-CJvL2DiB.js +0 -3658
  319. package/dist/supervisorPlugin-t6Z6PrhD.js +0 -733
  320. package/dist/token-CYBNNlhS.js +0 -17
  321. package/dist/tokenCredentials-CbCuk-Rt.js +0 -31
  322. package/dist/websocketServer-NQhODlEt.js +0 -60
  323. package/dist/workerChannel-C8hhBJzA.js +0 -27
  324. package/src/internal/release.ts +0 -72
  325. package/src/internal/serve.ts +0 -119
  326. /package/dist/{bin.d.ts → internal/childMain.d.ts} +0 -0
package/src/Auth.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  /** Credentials and authenticated identities shared by transport plugins. */
2
- import { Context } from "effect"
3
- import type { Effect, Redacted, Option, Scope } from "effect"
2
+ import {
3
+ Context,
4
+ type Effect,
5
+ type Option,
6
+ type Redacted,
7
+ type Scope,
8
+ } from "effect"
9
+
4
10
  import type {
5
11
  AuthenticationFailed,
6
12
  AuthenticatorUnavailable,
package/src/Config.ts ADDED
@@ -0,0 +1,196 @@
1
+ /** Configuration schemas for remote entries and their built-in capabilities. */
2
+ import { Effect, JsonSchema, Schema } from "effect"
3
+
4
+ import * as Auth from "./internal/auth/config"
5
+ import { PositiveDuration } from "./internal/config"
6
+
7
+ export const Reference = Schema.Struct({
8
+ name: Schema.String,
9
+ config: Schema.optionalKey(Schema.Unknown),
10
+ })
11
+ export type Reference = typeof Reference.Type
12
+ const absent = Schema.optionalKey(Schema.Never)
13
+ const authFields = {
14
+ name: absent,
15
+ config: absent,
16
+ mtls: absent,
17
+ bearer: absent,
18
+ jwt: absent,
19
+ none: absent,
20
+ }
21
+ const authentication = <
22
+ M extends Schema.Top,
23
+ B extends Schema.Top,
24
+ J extends Schema.Top,
25
+ N extends Schema.Top,
26
+ >(schemas: {
27
+ readonly mtls: M
28
+ readonly bearer: B
29
+ readonly jwt: J
30
+ readonly none: N
31
+ }) =>
32
+ Schema.Union([
33
+ Schema.Struct({
34
+ ...authFields,
35
+ name: Schema.String,
36
+ config: Schema.optionalKey(Schema.Unknown),
37
+ }),
38
+ Schema.Struct({ ...authFields, mtls: schemas.mtls }),
39
+ Schema.Struct({ ...authFields, bearer: schemas.bearer }),
40
+ Schema.Struct({ ...authFields, jwt: schemas.jwt }),
41
+ Schema.Struct({ ...authFields, none: schemas.none }),
42
+ ])
43
+ export const Authentication = authentication({
44
+ mtls: Auth.Certificate,
45
+ bearer: Auth.Token,
46
+ jwt: Auth.Token,
47
+ none: Auth.None,
48
+ })
49
+ export const RunnerAuthentication = authentication({
50
+ mtls: Auth.Mtls,
51
+ bearer: Auth.Bearer,
52
+ jwt: Schema.toEncoded(Auth.Jwt),
53
+ none: Auth.None,
54
+ })
55
+ const transportFields = {
56
+ url: absent,
57
+ unix: absent,
58
+ command: absent,
59
+ stdio: absent,
60
+ local: absent,
61
+ worker: absent,
62
+ transport: absent,
63
+ }
64
+ const auth = Schema.optionalKey(Authentication)
65
+ const common = {
66
+ instance: Schema.optionalKey(Schema.String),
67
+ lease: Schema.optionalKey(PositiveDuration),
68
+ margin: Schema.optionalKey(PositiveDuration),
69
+ expect: Schema.optionalKey(
70
+ Schema.Struct({
71
+ version: Schema.optionalKey(Schema.String),
72
+ digest: Schema.optionalKey(Schema.String),
73
+ }),
74
+ ),
75
+ }
76
+ const network = {
77
+ ...transportFields,
78
+ ...common,
79
+ auth,
80
+ url: Schema.String,
81
+ ca: Schema.optionalKey(Schema.String),
82
+ servername: Schema.optionalKey(Schema.String),
83
+ }
84
+ export const Connect = Schema.Union([
85
+ Schema.Struct(network),
86
+ Schema.Struct({ ...transportFields, ...common, auth, unix: Schema.String }),
87
+ Schema.Struct({
88
+ ...transportFields,
89
+ ...common,
90
+ command: Schema.NonEmptyArray(Schema.String),
91
+ auth: Schema.optionalKey(
92
+ Schema.Never.annotate({
93
+ message: "Direct and stdio transports do not accept auth",
94
+ }),
95
+ ),
96
+ cwd: Schema.optionalKey(Schema.String),
97
+ env: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
98
+ }),
99
+ Schema.Struct({
100
+ ...transportFields,
101
+ auth: Schema.optionalKey(
102
+ Schema.Never.annotate({
103
+ message: "Direct and stdio transports do not accept auth",
104
+ }),
105
+ ),
106
+ local: Schema.Struct({
107
+ command: Schema.optionalKey(Schema.NonEmptyArray(Schema.String)),
108
+ }),
109
+ }),
110
+ Schema.Struct({
111
+ ...transportFields,
112
+ auth: Schema.optionalKey(
113
+ Schema.Never.annotate({
114
+ message: "Direct and stdio transports do not accept auth",
115
+ }),
116
+ ),
117
+ worker: Schema.Struct({
118
+ execArgv: Schema.optionalKey(Schema.Array(Schema.String)),
119
+ }),
120
+ }),
121
+ Schema.Struct({ ...transportFields, ...common, auth, transport: Reference }),
122
+ ])
123
+ export type Connect = typeof Connect.Type
124
+ export const Listen = Schema.Union([
125
+ Schema.Struct({
126
+ ...transportFields,
127
+ auth: Schema.optionalKey(RunnerAuthentication),
128
+ url: Schema.String.check(Schema.isStartingWith("ws://")),
129
+ cert: absent,
130
+ key: absent,
131
+ }),
132
+ Schema.Struct({
133
+ ...transportFields,
134
+ auth: Schema.optionalKey(RunnerAuthentication),
135
+ url: Schema.String.check(Schema.isStartingWith("wss://")),
136
+ cert: Schema.String,
137
+ key: Schema.String,
138
+ }),
139
+ Schema.Struct({
140
+ ...transportFields,
141
+ auth: Schema.optionalKey(RunnerAuthentication),
142
+ unix: Schema.String,
143
+ }),
144
+ Schema.Struct({
145
+ ...transportFields,
146
+ stdio: Schema.Literal(true),
147
+ auth: Schema.optionalKey(
148
+ Schema.Never.annotate({
149
+ message: "Direct and stdio transports do not accept auth",
150
+ }),
151
+ ),
152
+ identity: Schema.optionalKey(Schema.String),
153
+ }),
154
+ Schema.Struct({
155
+ ...transportFields,
156
+ auth: Schema.optionalKey(RunnerAuthentication),
157
+ transport: Reference,
158
+ }),
159
+ ])
160
+ export type Listen = typeof Listen.Type
161
+ export const Host = Schema.Struct({
162
+ contract: Schema.String,
163
+ connect: Connect,
164
+ config: Schema.Json.pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),
165
+ })
166
+ export const Runner = Schema.Struct({
167
+ root: Schema.String,
168
+ state: Schema.String,
169
+ lease: Schema.optionalKey(PositiveDuration),
170
+ grace: Schema.optionalKey(PositiveDuration),
171
+ listen: Schema.Array(Listen),
172
+ })
173
+
174
+ /** The command plugin has no business configuration. */
175
+ export const Cli = Schema.Struct({})
176
+ /** Editor registrations, with inline schemas so consumers can compose them without reference collisions. */
177
+ export const entries = () => [
178
+ {
179
+ names: ["remote", "@graftland/plugin-remote"],
180
+ schema: json(Host),
181
+ required: true,
182
+ },
183
+ {
184
+ names: ["remote/runner", "@graftland/plugin-remote/runner"],
185
+ schema: json(Runner),
186
+ required: true,
187
+ },
188
+ { names: ["remote/cli", "@graftland/plugin-remote/cli"], schema: json(Cli) },
189
+ ]
190
+ const json = (schema: Schema.Top) =>
191
+ JsonSchema.toDocumentDraft07(
192
+ Schema.toJsonSchemaDocument(schema, {
193
+ referencePolicy: () => undefined,
194
+ onExcessProperty: "error",
195
+ }),
196
+ ).schema
package/src/Contract.ts CHANGED
@@ -1,8 +1,17 @@
1
- import { Array, Predicate, Schema } from "effect"
2
- import type { Context, Effect, Scope } from "effect"
3
- import type { Graft } from "@graftland/graft"
1
+ import {
2
+ Array,
3
+ Predicate,
4
+ Schema,
5
+ type Context,
6
+ type Effect,
7
+ type Scope,
8
+ } from "effect"
4
9
  import type { Rpc, RpcClient, RpcGroup, RpcServer } from "effect/rpc"
10
+
11
+ import type { Graft } from "@graftland/graft"
12
+
5
13
  import * as Control from "./internal/control"
14
+
6
15
  export { service } from "./internal/services"
7
16
 
8
17
  const TypeId = "~@graftland/plugin-remote/Contract"
package/src/Instance.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Context, Schema } from "effect"
2
+
2
3
  export const Identity = Schema.Struct({
3
4
  id: Schema.String,
4
5
  generation: Schema.Int,
package/src/Testing.ts CHANGED
@@ -1,18 +1,20 @@
1
- import type { Plugin } from "@graftland/graft"
2
1
  import {
3
2
  Array,
4
3
  Cause,
5
- Equivalence,
6
4
  Deferred,
7
5
  Effect,
6
+ Equivalence,
8
7
  Fiber,
8
+ Schema,
9
9
  Stream,
10
10
  String,
11
- Schema,
12
11
  } from "effect"
12
+
13
+ import type { Plugin } from "@graftland/graft"
14
+
13
15
  import type { TransportError } from "./Errors"
14
- import type { Channel } from "./Transport"
15
16
  import * as Framing from "./internal/runner/Framing"
17
+ import type { Channel } from "./Transport"
16
18
 
17
19
  export class ConformanceError extends Schema.TaggedError<
18
20
  ConformanceError,
package/src/Transport.ts CHANGED
@@ -1,12 +1,21 @@
1
1
  /** Execution and byte-channel capabilities; implementations live in host plugins. */
2
- import { Context } from "effect"
3
- import type { Effect, Option, Scope, Stream, Sink, Redacted } from "effect"
2
+ import {
3
+ Context,
4
+ type Effect,
5
+ type Option,
6
+ type Redacted,
7
+ type Scope,
8
+ type Sink,
9
+ type Stream,
10
+ } from "effect"
11
+
12
+ import type { Prepared, TlsPolicy, VerifiedCertificate } from "./Auth"
4
13
  import type {
5
14
  AuthenticationFailed,
6
15
  AuthenticatorUnavailable,
7
16
  TransportError,
8
17
  } from "./Errors"
9
- import type { Prepared, VerifiedCertificate, TlsPolicy } from "./Auth"
18
+
10
19
  /** Ordered reliable bytes. Chunk boundaries have no meaning; EOF is not exit confirmation. */
11
20
  export interface Channel {
12
21
  readonly input: Stream.Stream<Uint8Array, TransportError>
package/src/cli.ts ADDED
@@ -0,0 +1,60 @@
1
+ import { Console, Effect } from "effect"
2
+ import { CliError, Command, Flag } from "effect/cli"
3
+
4
+ import { platform } from "@graftland/cli/Application"
5
+ import { Commands } from "@graftland/cli/Commands"
6
+ import { Plugin } from "@graftland/graft"
7
+
8
+ const certificates = Command.make(
9
+ "certificates",
10
+ {
11
+ out: Flag.String("out").pipe(
12
+ Flag.withDescription("Directory for the CA and issued certificates"),
13
+ ),
14
+ server: Flag.String("server").pipe(
15
+ Flag.atLeast(0),
16
+ Flag.withDescription(
17
+ "Runner DNS name or IP address; repeat for additional SANs",
18
+ ),
19
+ ),
20
+ identity: Flag.String("identity").pipe(
21
+ Flag.atLeast(0),
22
+ Flag.withDescription(
23
+ "Host identity; repeat to issue multiple client certificates",
24
+ ),
25
+ ),
26
+ days: Flag.Int("days").pipe(
27
+ Flag.withDefault(365),
28
+ Flag.filter(
29
+ (days) => days > 0,
30
+ () => "Days must be a positive integer",
31
+ ),
32
+ ),
33
+ force: Flag.Boolean("force").pipe(
34
+ Flag.withDefault(false),
35
+ Flag.withDescription(
36
+ "Replace requested leaf certificates, keeping the existing CA",
37
+ ),
38
+ ),
39
+ },
40
+ (options) =>
41
+ Effect.promise(() => import("./internal/Certificates")).pipe(
42
+ Effect.uninterruptible,
43
+ Effect.flatMap((Certificates) => Certificates.generate(options)),
44
+ Effect.andThen(Console.log(`Certificates written to ${options.out}`)),
45
+ Effect.mapError((error) =>
46
+ CliError.UserError.make({ cause: error, userMessage: String(error) }),
47
+ ),
48
+ ),
49
+ )
50
+
51
+ const command = Command.make("remote").pipe(
52
+ Command.withSubcommands([certificates]),
53
+ Command.provide(platform),
54
+ )
55
+ export default Plugin.make({
56
+ name: "remote-commands",
57
+ inject: [Commands],
58
+ apply: () =>
59
+ Effect.flatMap(Commands, (commands) => commands.register(command)),
60
+ })
@@ -1,4 +1,5 @@
1
1
  import { Config, plugin } from "../../internal/auth/tokenCredentials"
2
+
2
3
  export { Config }
3
4
 
4
5
  const capability = plugin("remote-bearer-credentials")
@@ -1,4 +1,5 @@
1
1
  import { Config, plugin } from "../../internal/auth/tokenCredentials"
2
+
2
3
  export { Config }
3
4
 
4
5
  const capability = plugin("remote-jwt-credentials")
@@ -1,18 +1,13 @@
1
- import { Plugin, Graft } from "@graftland/graft"
2
- import {
3
- Cause,
4
- Effect,
5
- FileSystem,
6
- Option,
7
- Path,
8
- Redacted,
9
- Schema,
10
- } from "effect"
11
- import { CredentialsError } from "../../Errors"
1
+ import { Cause, Effect, FileSystem, Option, Path, Redacted } from "effect"
2
+
3
+ import { Graft, Plugin } from "@graftland/graft"
12
4
  import { ConfigDirectory } from "@graftland/loader"
5
+
13
6
  import { Credentials, type Prepared } from "../../Auth"
7
+ import { CredentialsError } from "../../Errors"
8
+ import { Certificate as Config } from "../../internal/auth/config"
14
9
 
15
- export const Config = Schema.Struct({ cert: Schema.String, key: Schema.String })
10
+ export { Config }
16
11
  export default Plugin.make({
17
12
  name: "remote-certificate-credentials",
18
13
  config: Config,
@@ -1,5 +1,7 @@
1
- import { Plugin, Graft } from "@graftland/graft"
2
1
  import { Effect, Schema } from "effect"
2
+
3
+ import { Graft, Plugin } from "@graftland/graft"
4
+
3
5
  import { Credentials } from "../../Auth"
4
6
 
5
7
  export default Plugin.make({
@@ -1,7 +1,3 @@
1
- /** Options for the command connector. */
2
- export type { CommandOptions as Options } from "../internal/transportOptions"
3
- import type { CommandOptions } from "../internal/transportOptions"
4
- import { Plugin, Graft } from "@graftland/graft"
5
1
  import {
6
2
  Array,
7
3
  Cause,
@@ -14,11 +10,18 @@ import {
14
10
  Stream,
15
11
  } from "effect"
16
12
  import { ChildProcess, ChildProcessSpawner } from "effect/process"
17
- import { Connector } from "../Transport"
13
+
14
+ import { Graft, Plugin } from "@graftland/graft"
18
15
  import { ConfigDirectory } from "@graftland/loader"
16
+
19
17
  import { TransportError } from "../Errors"
20
18
  import { cleanupCause } from "../internal/cleanup"
21
19
  import * as ProcessObservation from "../internal/runner/ProcessObservation"
20
+ import type { CommandOptions } from "../internal/transportOptions"
21
+ import { Connector } from "../Transport"
22
+
23
+ /** Options for the command connector. */
24
+ export type { CommandOptions as Options } from "../internal/transportOptions"
22
25
 
23
26
  export class CommandExited extends Schema.TaggedError<
24
27
  CommandExited,
package/src/host/local.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { Plugin } from "@graftland/graft"
2
1
  import { Array, Effect, Scope } from "effect"
3
2
  import { ChildProcess, ChildProcessSpawner } from "effect/process"
3
+
4
+ import { Plugin } from "@graftland/graft"
5
+
4
6
  import { LocalTransport } from "../internal/directTransport"
5
- import { command } from "../internal/runner/command"
6
7
  import * as Local from "../internal/host/local"
8
+ import { command } from "../internal/runner/command"
7
9
 
8
10
  const make = Effect.map(ChildProcessSpawner.ChildProcessSpawner, (spawner) =>
9
11
  LocalTransport.of({
package/src/host/unix.ts CHANGED
@@ -1,16 +1,20 @@
1
- /** Options for the unix connector. */
2
- export type { UnixOptions as Options } from "../internal/transportOptions"
3
- import type { UnixOptions } from "../internal/transportOptions"
4
- import { Plugin, Graft } from "@graftland/graft"
5
- import { ConfigDirectory } from "@graftland/loader"
6
1
  import { Cause, Effect, Layer, Option, Path, Redacted, Schema } from "effect"
7
2
  import { Socket } from "effect/socket"
3
+
4
+ import { Graft, Plugin } from "@graftland/graft"
5
+ import { ConfigDirectory } from "@graftland/loader"
6
+
8
7
  import WS from "ws"
8
+
9
9
  import type { Prepared } from "../Auth"
10
- import { Connector, type ConnectorApi } from "../Transport"
11
10
  import { TransportError } from "../Errors"
12
- import { path, protocol, payloadLimit } from "../internal/websocket"
13
11
  import * as Channel from "../internal/socketChannel"
12
+ import type { UnixOptions } from "../internal/transportOptions"
13
+ import { path, payloadLimit, protocol } from "../internal/websocket"
14
+ import { Connector, type ConnectorApi } from "../Transport"
15
+
16
+ /** Options for the unix connector. */
17
+ export type { UnixOptions as Options } from "../internal/transportOptions"
14
18
 
15
19
  export const properties: ConnectorApi["properties"] = {
16
20
  protocol: "unix",
@@ -1,13 +1,16 @@
1
- /** Options for the websocket connector. */
2
- export type { WebsocketOptions as Options } from "../internal/transportOptions"
3
- import type { WebsocketOptions } from "../internal/transportOptions"
4
- import { Plugin, Graft } from "@graftland/graft"
5
1
  import { Cause, Effect, FileSystem, Option, Path, Schema } from "effect"
6
- import { Connector, type ConnectorApi } from "../Transport"
7
- import { TransportError } from "../Errors"
2
+
3
+ import { Graft, Plugin } from "@graftland/graft"
8
4
  import { ConfigDirectory } from "@graftland/loader"
9
- import * as Websocket from "../internal/websocket"
5
+
6
+ import { TransportError } from "../Errors"
10
7
  import * as Channel from "../internal/socketChannel"
8
+ import type { WebsocketOptions } from "../internal/transportOptions"
9
+ import * as Websocket from "../internal/websocket"
10
+ import { Connector, type ConnectorApi } from "../Transport"
11
+
12
+ /** Options for the websocket connector. */
13
+ export type { WebsocketOptions as Options } from "../internal/transportOptions"
11
14
 
12
15
  /** Configured Connector; certificate paths belong to the enclosing configuration. */
13
16
  export const Config = Schema.Struct({
@@ -1,12 +1,15 @@
1
- import { Plugin } from "@graftland/graft"
2
- import { Cause, Deferred, Effect, FiberSet, Option, Schema } from "effect"
3
1
  import { Worker } from "node:worker_threads"
4
- import { WorkerTransport } from "../internal/directTransport"
2
+
3
+ import { Cause, Deferred, Effect, FiberSet, Option, Schema } from "effect"
4
+
5
+ import { Plugin } from "@graftland/graft"
6
+
5
7
  import { ProcessExited, TransportError } from "../Errors"
6
- import * as Channel from "../internal/workerChannel"
8
+ import { cleanupCause } from "../internal/cleanup"
9
+ import { WorkerTransport } from "../internal/directTransport"
7
10
  import * as FailureGroup from "../internal/FailureGroup"
8
11
  import { Bootstrap } from "../internal/workerBootstrap"
9
- import { cleanupCause } from "../internal/cleanup"
12
+ import * as Channel from "../internal/workerChannel"
10
13
 
11
14
  const start: typeof WorkerTransport.Service.start = Effect.fnUntraced(
12
15
  function* (options) {
package/src/index.ts CHANGED
@@ -1,21 +1,31 @@
1
- import { Plugin } from "@graftland/graft"
2
- import { ModuleResolver } from "@graftland/loader"
3
- import { Array, Cause, Effect, Path, Schema } from "effect"
4
- import type { Duration, Schedule } from "effect"
1
+ import {
2
+ Array,
3
+ Cause,
4
+ Effect,
5
+ Path,
6
+ Schema,
7
+ type Duration,
8
+ type Schedule,
9
+ } from "effect"
5
10
  import { SecureRandom } from "effect/crypto"
6
11
  import { ChildProcessSpawner } from "effect/process"
7
- import { launch } from "./internal/entry"
8
- import { follow } from "./internal/follow"
12
+
13
+ import { Plugin } from "@graftland/graft"
14
+ import { ModuleResolver } from "@graftland/loader"
15
+
16
+ import * as Contract from "./Contract"
17
+ import { MissingInstance, RemoteError, RemoteWithdrawn } from "./Errors"
9
18
  import { CapabilityFailed } from "./internal/assembly"
10
- import { publicError } from "./internal/execution"
11
- import * as Configuration from "./internal/entryConfig"
12
19
  import * as Credential from "./internal/credentials"
13
- import { RemoteWithdrawn, RemoteError, MissingInstance } from "./Errors"
14
- import * as Contract from "./Contract"
20
+ import { launch } from "./internal/entry"
21
+ import * as Configuration from "./internal/entryConfig"
22
+ import { publicError } from "./internal/execution"
23
+ import { follow } from "./internal/follow"
24
+
15
25
  export { Contract }
16
26
  export { Instance } from "./Instance"
17
27
  export { RemoteTerminationUnconfirmed } from "./internal/runner/model"
18
- export { RemoteError, RemoteWithdrawn, MissingInstance } from "./Errors"
28
+ export * from "./Errors"
19
29
  export { UndeclaredFailure } from "./Contract"
20
30
  export type {
21
31
  Connect,
@@ -30,7 +40,6 @@ export interface Options<
30
40
  readonly connect: Credential.Connect<D>
31
41
  /** Contract module resolved independently in each execution environment. */
32
42
  readonly contractModule: string
33
- readonly config?: Schema.Json
34
43
  readonly retry?: Schedule.Schedule<unknown, unknown> | undefined
35
44
  readonly shutdownTimeout?: Duration.Input | undefined
36
45
  }
@@ -60,6 +69,7 @@ const publicCause = <E extends Schema.Top>(
60
69
  }),
61
70
  )
62
71
 
72
+ /** Fixes deployment options; business config is plugin input, and updates restart the execution unit. */
63
73
  export const plugin = <
64
74
  S extends Schema.Top & {
65
75
  readonly Encoded: Schema.Json
@@ -73,10 +83,10 @@ export const plugin = <
73
83
  const D extends ReadonlyArray<Plugin.Dependency> = readonly [],
74
84
  >(
75
85
  contract: Contract.Contract<S, E>,
76
- options: Options<D> & { readonly config?: S["Encoded"] },
86
+ options: Options<D>,
77
87
  ): Plugin.Plugin<
78
- void,
79
- void,
88
+ S["Encoded"],
89
+ S["Encoded"],
80
90
  | E["Type"]
81
91
  | Contract.UndeclaredFailure
82
92
  | RemoteError
@@ -92,12 +102,17 @@ export const plugin = <
92
102
  ChildProcessSpawner.ChildProcessSpawner,
93
103
  ],
94
104
  retry: options.retry,
95
- apply: Effect.fnUntraced(
96
- function* () {
105
+ config: Schema.toEncoded(contract.config),
106
+ apply: (config) =>
107
+ Effect.gen(function* () {
108
+ const auth = Credential.invocation(options.connect)
97
109
  const input = yield* Schema.decodeUnknownEffect(Configuration.Host)({
98
110
  contract: options.contractModule,
99
- connect: options.connect,
100
- config: options.config === undefined ? {} : options.config,
111
+ connect:
112
+ auth === undefined
113
+ ? options.connect
114
+ : { ...options.connect, auth: { name: "effect-credentials" } },
115
+ config,
101
116
  })
102
117
  yield* Schema.decodeEffect(contract.config)(input.config)
103
118
  const child = yield* launch(
@@ -107,13 +122,11 @@ export const plugin = <
107
122
  contractModule: options.contractModule,
108
123
  shutdownTimeout: options.shutdownTimeout,
109
124
  },
110
- Credential.invocation(options.connect),
125
+ auth,
111
126
  )
112
127
  yield* follow(child, (cause) =>
113
128
  Effect.failCause(publicCause(contract.error, cause)),
114
129
  )
115
- },
116
- Effect.mapError((error) => publicError(contract.error, error)),
117
- ),
130
+ }).pipe(Effect.mapError((error) => publicError(contract.error, error))),
118
131
  })
119
132
  export { host as default } from "./internal/entry"
@@ -12,6 +12,7 @@ import {
12
12
  import { SecureRandom, WebCrypto } from "effect/crypto"
13
13
  import { Base64 } from "effect/encoding"
14
14
  import { NetAddress } from "effect/net"
15
+
15
16
  import * as asn1js from "asn1js"
16
17
  import * as pki from "pkijs"
17
18
 
@@ -1,18 +1,20 @@
1
1
  import {
2
2
  Array,
3
3
  Cause,
4
- Fiber,
5
4
  Data,
6
5
  Deferred,
7
6
  Effect,
8
7
  Exit,
8
+ Fiber,
9
9
  FiberSet,
10
10
  Ref,
11
- Scope,
12
11
  Schema,
12
+ Scope,
13
13
  TxRef,
14
14
  } from "effect"
15
- import * as Release from "./release"
15
+
16
+ import * as Release from "@graftland/graft/Release"
17
+
16
18
  import { cleanupCause } from "./cleanup"
17
19
 
18
20
  type State<E> = Data.TaggedEnum<{
@@ -1,4 +1,5 @@
1
1
  import { Context } from "effect"
2
+
2
3
  export class Peer extends Context.Service<Peer, string>()(
3
4
  "@graftland/plugin-remote/internal/Peer",
4
5
  ) {}