@graftland/plugin-remote 0.3.1 → 0.3.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 (184) hide show
  1. package/dist/Auth.d.ts +2 -2
  2. package/dist/Auth.d.ts.map +1 -1
  3. package/dist/Auth.js.map +1 -1
  4. package/dist/{Bootstrap-Dr6sX7el.js → Bootstrap-H9gDsgsC.js} +2 -2
  5. package/dist/{Contract-DL2mHvaT.js → Contract-DsJtisvL.js} +2 -2
  6. package/dist/Contract.js +1 -1
  7. package/dist/{Errors-BMKmu5Y7.js → Errors-DYhsGZcZ.js} +3 -1
  8. package/dist/Errors.d.ts +7 -0
  9. package/dist/Errors.d.ts.map +1 -1
  10. package/dist/Errors.js +3 -1
  11. package/dist/Errors.js.map +1 -1
  12. package/dist/{FailureGroup-BcH0XOBi.js → FailureGroup-BgT73AaR.js} +14 -4
  13. package/dist/{Framing-zaYdOJnT.js → Framing-G9eSaeLb.js} +1 -1
  14. package/dist/{Graft-CVyueNOf.js → Graft-B71CPA2Y.js} +20 -16
  15. package/dist/{Packages-JNL34JpS.js → Packages-AgoCGotL.js} +23 -26
  16. package/dist/{Peer-BT7eAGmh.js → Peer-DXeVrGBh.js} +5 -5
  17. package/dist/{ProcessObservation-DEGrEMfP.js → ProcessObservation-gLgGirYv.js} +1 -1
  18. package/dist/{ServeLifecycle-CJM0gG5B.js → ServeLifecycle-Bd1FPJ6e.js} +1 -1
  19. package/dist/Transport.d.ts +2 -2
  20. package/dist/Transport.d.ts.map +1 -1
  21. package/dist/Transport.js.map +1 -1
  22. package/dist/bin.js +48 -47
  23. package/dist/bin.js.map +1 -1
  24. package/dist/{childRuntime-An0HsIzl.js → childRuntime-Bm3iSg_N.js} +29 -26
  25. package/dist/{connectionEnded-DCpFCjMX.js → connectionEnded-BwcxQ7W8.js} +4 -4
  26. package/dist/{entry-B89sepMU.js → entry-psOpX3Bj.js} +72 -35
  27. package/dist/host/auth/bearer.d.ts +9 -1
  28. package/dist/host/auth/bearer.d.ts.map +1 -1
  29. package/dist/host/auth/bearer.js +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 +1 -1
  33. package/dist/host/auth/mtls.d.ts +8 -1
  34. package/dist/host/auth/mtls.d.ts.map +1 -1
  35. package/dist/host/auth/mtls.js +2 -2
  36. package/dist/host/auth/none.d.ts +3 -1
  37. package/dist/host/auth/none.js +1 -1
  38. package/dist/host/command.d.ts +14 -1
  39. package/dist/host/command.d.ts.map +1 -1
  40. package/dist/host/command.js +4 -4
  41. package/dist/host/local.d.ts +2 -1
  42. package/dist/host/local.d.ts.map +1 -1
  43. package/dist/host/local.js +3 -3
  44. package/dist/host/unix.d.ts +6 -1
  45. package/dist/host/unix.d.ts.map +1 -1
  46. package/dist/host/unix.js +3 -3
  47. package/dist/host/websocket.d.ts +10 -1
  48. package/dist/host/websocket.d.ts.map +1 -1
  49. package/dist/host/websocket.js +3 -3
  50. package/dist/host/worker.d.ts +3 -1
  51. package/dist/host/worker.d.ts.map +1 -1
  52. package/dist/host/worker.js +4 -5
  53. package/dist/{importer-Bk6U_sn4.js → importer-Cvf88eAY.js} +5 -8
  54. package/dist/index.js +9 -9
  55. package/dist/index.js.map +1 -1
  56. package/dist/internal/Certificates.js +4 -4
  57. package/dist/internal/Certificates.js.map +1 -1
  58. package/dist/internal/FailureGroup.js +3 -2
  59. package/dist/internal/FailureGroup.js.map +1 -1
  60. package/dist/internal/assembly.d.ts +2 -1
  61. package/dist/internal/assembly.js +9 -2
  62. package/dist/internal/assembly.js.map +1 -1
  63. package/dist/internal/auth/mtls.js +1 -1
  64. package/dist/internal/auth/mtls.js.map +1 -1
  65. package/dist/internal/auth/tokenCredentials.d.ts +2 -1
  66. package/dist/internal/auth/tokenCredentials.d.ts.map +1 -1
  67. package/dist/internal/child.js +20 -17
  68. package/dist/internal/child.js.map +1 -1
  69. package/dist/internal/childRuntime.js +4 -4
  70. package/dist/internal/childRuntime.js.map +1 -1
  71. package/dist/internal/credentials.d.ts +1 -1
  72. package/dist/internal/directTransport.d.ts +1 -1
  73. package/dist/internal/entry.d.ts +415 -3
  74. package/dist/internal/entry.d.ts.map +1 -1
  75. package/dist/internal/entry.js +1 -1
  76. package/dist/internal/entry.js.map +1 -1
  77. package/dist/internal/execution.js +40 -5
  78. package/dist/internal/execution.js.map +1 -1
  79. package/dist/internal/host/runner.js +7 -6
  80. package/dist/internal/host/runner.js.map +1 -1
  81. package/dist/internal/host.js +5 -5
  82. package/dist/internal/host.js.map +1 -1
  83. package/dist/internal/port.js +5 -5
  84. package/dist/internal/port.js.map +1 -1
  85. package/dist/internal/release.js +1 -1
  86. package/dist/internal/release.js.map +1 -1
  87. package/dist/internal/runner/Connection.d.ts +1 -1
  88. package/dist/internal/runner/Connection.js +4 -4
  89. package/dist/internal/runner/Connection.js.map +1 -1
  90. package/dist/internal/runner/Execution.js +3 -3
  91. package/dist/internal/runner/Execution.js.map +1 -1
  92. package/dist/internal/runner/Framing.js +1 -1
  93. package/dist/internal/runner/Framing.js.map +1 -1
  94. package/dist/internal/runner/Local.js +1 -1
  95. package/dist/internal/runner/Local.js.map +1 -1
  96. package/dist/internal/runner/Lock.js +1 -1
  97. package/dist/internal/runner/Lock.js.map +1 -1
  98. package/dist/internal/runner/Packages.d.ts +1 -1
  99. package/dist/internal/runner/Packages.js +22 -25
  100. package/dist/internal/runner/Packages.js.map +1 -1
  101. package/dist/internal/runner/Processes.js +7 -9
  102. package/dist/internal/runner/Processes.js.map +1 -1
  103. package/dist/internal/runner/Store.js +3 -3
  104. package/dist/internal/runner/Store.js.map +1 -1
  105. package/dist/internal/runner/Supervisor.js +46 -47
  106. package/dist/internal/runner/Supervisor.js.map +1 -1
  107. package/dist/internal/runner/accept.js +3 -3
  108. package/dist/internal/runner/accept.js.map +1 -1
  109. package/dist/internal/runner/model.js +1 -1
  110. package/dist/internal/runner/model.js.map +1 -1
  111. package/dist/internal/serve.js +1 -1
  112. package/dist/internal/serve.js.map +1 -1
  113. package/dist/internal/supervisorPlugin.js +1 -1
  114. package/dist/internal/watchdogMain.js +5 -5
  115. package/dist/internal/watchdogMain.js.map +1 -1
  116. package/dist/internal/websocketServer.js +3 -1
  117. package/dist/internal/websocketServer.js.map +1 -1
  118. package/dist/internal/workerMain.js +3 -3
  119. package/dist/{port-DSVUY8Bq.js → port--3x2zJ4D.js} +8 -8
  120. package/dist/{release-BY4Mlluy.js → release-DfZPuIcK.js} +1 -1
  121. package/dist/runner/auth/bearer.d.ts +6 -1
  122. package/dist/runner/auth/bearer.d.ts.map +1 -1
  123. package/dist/runner/auth/bearer.js +2 -2
  124. package/dist/runner/auth/jwt.d.ts +29 -2
  125. package/dist/runner/auth/jwt.d.ts.map +1 -1
  126. package/dist/runner/auth/jwt.js +4 -4
  127. package/dist/runner/auth/jwt.js.map +1 -1
  128. package/dist/runner/auth/mtls.d.ts +6 -1
  129. package/dist/runner/auth/mtls.d.ts.map +1 -1
  130. package/dist/runner/auth/mtls.js +3 -3
  131. package/dist/runner/auth/none.d.ts +7 -1
  132. package/dist/runner/auth/none.js +1 -1
  133. package/dist/runner/index.d.ts +310 -1
  134. package/dist/runner/index.d.ts.map +1 -1
  135. package/dist/runner/index.js +5 -5
  136. package/dist/runner/stdio.d.ts +6 -1
  137. package/dist/runner/stdio.d.ts.map +1 -1
  138. package/dist/runner/stdio.js +3 -3
  139. package/dist/runner/unix.d.ts +6 -1
  140. package/dist/runner/unix.d.ts.map +1 -1
  141. package/dist/runner/unix.js +3 -3
  142. package/dist/runner/websocket.d.ts +24 -1
  143. package/dist/runner/websocket.d.ts.map +1 -1
  144. package/dist/runner/websocket.js +4 -4
  145. package/dist/{socketChannel-C_ppdSzz.js → socketChannel-CJvL2DiB.js} +2 -2
  146. package/dist/{supervisorPlugin-CivhM7x5.js → supervisorPlugin-t6Z6PrhD.js} +72 -76
  147. package/dist/{token-Cc_1CTbE.js → token-CYBNNlhS.js} +1 -1
  148. package/dist/{tokenCredentials-CI6mMRRd.js → tokenCredentials-CbCuk-Rt.js} +3 -3
  149. package/dist/{websocketServer-D2Hk7wsA.js → websocketServer-NQhODlEt.js} +5 -3
  150. package/dist/{workerChannel-cmLc13vm.js → workerChannel-C8hhBJzA.js} +1 -1
  151. package/package.json +4 -4
  152. package/src/Auth.ts +9 -2
  153. package/src/Errors.ts +8 -0
  154. package/src/Transport.ts +6 -2
  155. package/src/bin.ts +28 -30
  156. package/src/index.ts +5 -3
  157. package/src/internal/Certificates.ts +10 -13
  158. package/src/internal/FailureGroup.ts +128 -121
  159. package/src/internal/assembly.ts +19 -10
  160. package/src/internal/auth/mtls.ts +19 -20
  161. package/src/internal/child.ts +248 -239
  162. package/src/internal/childRuntime.ts +81 -80
  163. package/src/internal/entry.ts +10 -11
  164. package/src/internal/execution.ts +69 -12
  165. package/src/internal/host/runner.ts +153 -153
  166. package/src/internal/host.ts +116 -120
  167. package/src/internal/port.ts +100 -103
  168. package/src/internal/release.ts +3 -2
  169. package/src/internal/runner/Connection.ts +52 -60
  170. package/src/internal/runner/Execution.ts +163 -164
  171. package/src/internal/runner/Framing.ts +9 -10
  172. package/src/internal/runner/Local.ts +26 -27
  173. package/src/internal/runner/Lock.ts +23 -25
  174. package/src/internal/runner/Packages.ts +67 -70
  175. package/src/internal/runner/Processes.ts +89 -92
  176. package/src/internal/runner/Store.ts +110 -114
  177. package/src/internal/runner/Supervisor.ts +392 -405
  178. package/src/internal/runner/accept.ts +76 -84
  179. package/src/internal/runner/model.ts +20 -21
  180. package/src/internal/serve.ts +15 -13
  181. package/src/internal/watchdogMain.ts +16 -11
  182. package/src/internal/websocketServer.ts +18 -3
  183. package/src/runner/auth/jwt.ts +10 -6
  184. package/dist/cleanup-CXLa1Wd9.js +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"childRuntime.js","names":["Multiplex.make","channel","Port.make","Wire.channel","Services.endpoints","telemetry","Child.telemetry","Child.lifecycle"],"sources":["../../src/internal/childRuntime.ts"],"sourcesContent":["import { loadModule } from \"./loadModule\"\nimport { ContractNotFound } from \"./childErrors\"\nimport type { Graft } from \"@graftland/graft\"\nimport { Effect, Logger, Option } from \"effect\"\nimport { RpcServer } from \"effect/rpc\"\nimport { fromModule, type RunnerContract } from \"../Contract\"\nimport * as Port from \"./port\"\nimport { prepare, type RunnerContract as PreparedContract } from \"./contract\"\nimport * as Services from \"./services\"\nimport * as Child from \"./child\"\nimport * as Multiplex from \"./runner/Multiplex\"\nimport * as Wire from \"./runner/Wire\"\nimport type { Bootstrap } from \"./runner/Bootstrap\"\nimport { ExecutionError } from \"./runner/model\"\nimport { closedNormally } from \"./runner/connectionEnded\"\nimport { endpoint } from \"./control\"\n\n/** Import a contract in the runner installation; importing this module performs no I/O. */\nexport const load = (specifier: string) =>\n\tEffect.gen(function* () {\n\t\tconst module = yield* loadModule(specifier)\n\t\tconst contract = fromModule(module)\n\t\tif (Option.isNone(contract))\n\t\t\treturn yield* ContractNotFound.make({ module: specifier })\n\t\treturn contract.value\n\t})\n\nconst connect = (\n\tcontract: PreparedContract,\n\tchannel: Port.Channel,\n\tsession: string,\n\tbootstrap: Bootstrap | undefined,\n) =>\n\tEffect.gen(function* () {\n\t\tconst mux =\n\t\t\tbootstrap === undefined ? undefined : yield* Multiplex.make(channel)\n\t\treturn yield* Port.make(\n\t\t\tmux === undefined ? channel : Wire.channel(mux, 1),\n\t\t\t{\n\t\t\t\tsession,\n\t\t\t\tserve: {\n\t\t\t\t\t...Services.endpoints(contract.provides),\n\t\t\t\t\t[endpoint]: contract.control,\n\t\t\t\t},\n\t\t\t\tcall: Services.endpoints(contract.inject),\n\t\t\t\t...(bootstrap === undefined ? {} : { limits: bootstrap.limits }),\n\t\t\t},\n\t\t)\n\t})\n\n/** One execution unit; the executable supplies the platform and Graft services. */\nexport const run = (\n\tdescriptor: RunnerContract,\n\tchannel: Port.Channel,\n\tsession = \"local\",\n\tbootstrap?: Bootstrap,\n\tstop: Effect.Effect<unknown, ExecutionError> = Effect.never,\n): Effect.Effect<void, ExecutionError, Graft.Graft> =>\n\tEffect.scoped(\n\t\tEffect.gen(function* () {\n\t\t\tconst contract = prepare(descriptor)\n\t\t\tconst telemetry = yield* Child.telemetry(contract)\n\t\t\tconst loggers = yield* Logger.CurrentLoggers\n\t\t\tyield* Effect.gen(function* () {\n\t\t\t\tconst peer = yield* connect(contract, channel, session, bootstrap)\n\t\t\t\tconst instance = yield* Child.lifecycle(\n\t\t\t\t\tcontract,\n\t\t\t\t\tpeer,\n\t\t\t\t\tbootstrap?.identity ?? { id: session, generation: 1 },\n\t\t\t\t\ttelemetry,\n\t\t\t\t)\n\t\t\t\tconst handlers = yield* contract.control.toHandlers({\n\t\t\t\t\tLoad: ({ input }) => instance.load(input),\n\t\t\t\t\tDispose: () => instance.dispose,\n\t\t\t\t\tEvents: () => telemetry.eventStream,\n\t\t\t\t\tLogs: () => telemetry.logStream,\n\t\t\t\t})\n\t\t\t\tyield* RpcServer.make(contract.control, {\n\t\t\t\t\tdisableFatalDefects: true,\n\t\t\t\t}).pipe(\n\t\t\t\t\tEffect.provideContext(handlers),\n\t\t\t\t\tEffect.provideService(\n\t\t\t\t\t\tRpcServer.Protocol,\n\t\t\t\t\t\tpeer.serverProtocol(endpoint),\n\t\t\t\t\t),\n\t\t\t\t\tEffect.forkScoped,\n\t\t\t\t)\n\t\t\t\tyield* Effect.raceFirst(\n\t\t\t\t\tpeer.await.pipe(\n\t\t\t\t\t\tEffect.catchIf(\n\t\t\t\t\t\t\t(error) => closedNormally(error.cause),\n\t\t\t\t\t\t\t() => Effect.void,\n\t\t\t\t\t\t),\n\t\t\t\t\t\tEffect.mapError((error) =>\n\t\t\t\t\t\t\tExecutionError.make({\n\t\t\t\t\t\t\t\tdetail: \"Child transport failed\",\n\t\t\t\t\t\t\t\tcause: error.cause,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t\tstop,\n\t\t\t\t).pipe(\n\t\t\t\t\t// Release exports before closing the instance scope, including on interruption.\n\t\t\t\t\tEffect.ensuring(instance.release),\n\t\t\t\t)\n\t\t\t}).pipe(\n\t\t\t\tEffect.provideService(\n\t\t\t\t\tLogger.CurrentLoggers,\n\t\t\t\t\tnew Set([...loggers, telemetry.logger]),\n\t\t\t\t),\n\t\t\t)\n\t\t}),\n\t)\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAa,QAAQ,cACpB,OAAO,IAAI,aAAa;CACvB,MAAM,SAAS,OAAO,WAAW,SAAS;CAC1C,MAAM,WAAW,WAAW,MAAM;CAClC,IAAI,OAAO,OAAO,QAAQ,GACzB,OAAO,OAAO,iBAAiB,KAAK,EAAE,QAAQ,UAAU,CAAC;CAC1D,OAAO,SAAS;AACjB,CAAC;AAEF,MAAM,WACL,UACA,WACA,SACA,cAEA,OAAO,IAAI,aAAa;CACvB,MAAM,MACL,cAAc,KAAA,IAAY,KAAA,IAAY,OAAOA,OAAeC,SAAO;CACpE,OAAO,OAAOC,KACb,QAAQ,KAAA,IAAYD,YAAUE,QAAa,KAAK,CAAC,GACjD;EACC;EACA,OAAO;GACN,GAAGC,UAAmB,SAAS,QAAQ;IACtC,WAAW,SAAS;EACtB;EACA,MAAMA,UAAmB,SAAS,MAAM;EACxC,GAAI,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,UAAU,OAAO;CAC/D,CACD;AACD,CAAC;;AAGF,MAAa,OACZ,YACA,SACA,UAAU,SACV,WACA,OAA+C,OAAO,UAEtD,OAAO,OACN,OAAO,IAAI,aAAa;CACvB,MAAM,WAAW,QAAQ,UAAU;CACnC,MAAMC,cAAY,OAAOC,UAAgB,QAAQ;CACjD,MAAM,UAAU,OAAO,OAAO;CAC9B,OAAO,OAAO,IAAI,aAAa;EAC9B,MAAM,OAAO,OAAO,QAAQ,UAAU,SAAS,SAAS,SAAS;EACjE,MAAM,WAAW,OAAOC,UACvB,UACA,MACA,WAAW,YAAY;GAAE,IAAI;GAAS,YAAY;EAAE,GACpDF,WACD;EACA,MAAM,WAAW,OAAO,SAAS,QAAQ,WAAW;GACnD,OAAO,EAAE,YAAY,SAAS,KAAK,KAAK;GACxC,eAAe,SAAS;GACxB,cAAcA,YAAU;GACxB,YAAYA,YAAU;EACvB,CAAC;EACD,OAAO,UAAU,KAAK,SAAS,SAAS,EACvC,qBAAqB,KACtB,CAAC,CAAC,CAAC,KACF,OAAO,eAAe,QAAQ,GAC9B,OAAO,eACN,UAAU,UACV,KAAK,eAAe,QAAQ,CAC7B,GACA,OAAO,UACR;EACA,OAAO,OAAO,UACb,KAAK,MAAM,KACV,OAAO,SACL,UAAU,eAAe,MAAM,KAAK,SAC/B,OAAO,IACd,GACA,OAAO,UAAU,UAChB,eAAe,KAAK;GACnB,QAAQ;GACR,OAAO,MAAM;EACd,CAAC,CACF,CACD,GACA,IACD,CAAC,CAAC,KAED,OAAO,SAAS,SAAS,OAAO,CACjC;CACD,CAAC,CAAC,CAAC,KACF,OAAO,eACN,OAAO,gCACP,IAAI,IAAI,CAAC,GAAG,SAASA,YAAU,MAAM,CAAC,CACvC,CACD;AACD,CAAC,CACF"}
1
+ {"version":3,"file":"childRuntime.js","names":["Multiplex.make","channel","Port.make","Wire.channel","Services.endpoints","telemetry","Child.telemetry","Child.lifecycle"],"sources":["../../src/internal/childRuntime.ts"],"sourcesContent":["import { loadModule } from \"./loadModule\"\nimport { ContractNotFound } from \"./childErrors\"\nimport type { Graft } from \"@graftland/graft\"\nimport { Effect, Logger, Option } from \"effect\"\nimport { RpcServer } from \"effect/rpc\"\nimport { fromModule, type RunnerContract } from \"../Contract\"\nimport * as Port from \"./port\"\nimport { prepare, type RunnerContract as PreparedContract } from \"./contract\"\nimport * as Services from \"./services\"\nimport * as Child from \"./child\"\nimport * as Multiplex from \"./runner/Multiplex\"\nimport * as Wire from \"./runner/Wire\"\nimport type { Bootstrap } from \"./runner/Bootstrap\"\nimport { ExecutionError } from \"./runner/model\"\nimport { closedNormally } from \"./runner/connectionEnded\"\nimport { endpoint } from \"./control\"\n\n/** Import a contract in the runner installation; importing this module performs no I/O. */\nexport const load = Effect.fnUntraced(function* (specifier: string) {\n\tconst module = yield* loadModule(specifier)\n\tconst contract = fromModule(module)\n\tif (Option.isNone(contract))\n\t\treturn yield* ContractNotFound.make({ module: specifier })\n\treturn contract.value\n})\n\nconst connect = Effect.fnUntraced(function* (\n\tcontract: PreparedContract,\n\tchannel: Port.Channel,\n\tsession: string,\n\tbootstrap: Bootstrap | undefined,\n) {\n\tconst mux =\n\t\tbootstrap === undefined ? undefined : yield* Multiplex.make(channel)\n\treturn yield* Port.make(mux === undefined ? channel : Wire.channel(mux, 1), {\n\t\tsession,\n\t\tserve: {\n\t\t\t...Services.endpoints(contract.provides),\n\t\t\t[endpoint]: contract.control,\n\t\t},\n\t\tcall: Services.endpoints(contract.inject),\n\t\t...(bootstrap === undefined ? {} : { limits: bootstrap.limits }),\n\t})\n})\n\n/** One execution unit; the executable supplies the platform and Graft services. */\nexport const run: (\n\tdescriptor: RunnerContract,\n\tchannel: Port.Channel,\n\tsession?: string,\n\tbootstrap?: Bootstrap,\n\tstop?: Effect.Effect<unknown, ExecutionError>,\n) => Effect.Effect<void, ExecutionError, Graft.Graft> = Effect.fnUntraced(\n\tfunction* (\n\t\tdescriptor: RunnerContract,\n\t\tchannel: Port.Channel,\n\t\tsession: string = \"local\",\n\t\tbootstrap?: Bootstrap,\n\t\tstop: Effect.Effect<unknown, ExecutionError> = Effect.never,\n\t) {\n\t\tconst contract = prepare(descriptor)\n\t\tconst telemetry = yield* Child.telemetry(contract)\n\t\tconst loggers = yield* Logger.CurrentLoggers\n\t\tyield* Effect.gen(function* () {\n\t\t\tconst peer = yield* connect(contract, channel, session, bootstrap)\n\t\t\tconst instance = yield* Child.lifecycle(\n\t\t\t\tcontract,\n\t\t\t\tpeer,\n\t\t\t\tbootstrap?.identity ?? { id: session, generation: 1 },\n\t\t\t\ttelemetry,\n\t\t\t)\n\t\t\tconst handlers = yield* contract.control.toHandlers({\n\t\t\t\tLoad: ({ input }) => instance.load(input),\n\t\t\t\tDispose: () => instance.dispose,\n\t\t\t\tEvents: () => telemetry.eventStream,\n\t\t\t\tLogs: () => telemetry.logStream,\n\t\t\t})\n\t\t\tyield* RpcServer.make(contract.control, {\n\t\t\t\tdisableFatalDefects: true,\n\t\t\t}).pipe(\n\t\t\t\tEffect.provideContext(handlers),\n\t\t\t\tEffect.provideService(\n\t\t\t\t\tRpcServer.Protocol,\n\t\t\t\t\tpeer.serverProtocol(endpoint),\n\t\t\t\t),\n\t\t\t\tEffect.forkScoped,\n\t\t\t)\n\t\t\tyield* Effect.raceFirst(\n\t\t\t\tpeer.await.pipe(\n\t\t\t\t\tEffect.catchIf(\n\t\t\t\t\t\t(error) => closedNormally(error.cause),\n\t\t\t\t\t\t() => Effect.void,\n\t\t\t\t\t),\n\t\t\t\t\tEffect.mapError((error) =>\n\t\t\t\t\t\tExecutionError.make({\n\t\t\t\t\t\t\tdetail: \"Child transport failed\",\n\t\t\t\t\t\t\tcause: error.cause,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tstop,\n\t\t\t).pipe(\n\t\t\t\t// Release exports before closing the instance scope, including on interruption.\n\t\t\t\tEffect.ensuring(instance.release),\n\t\t\t)\n\t\t}).pipe(\n\t\t\tEffect.provideService(\n\t\t\t\tLogger.CurrentLoggers,\n\t\t\t\tnew Set([...loggers, telemetry.logger]),\n\t\t\t),\n\t\t)\n\t},\n\tEffect.scoped,\n)\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAa,OAAO,OAAO,WAAW,WAAW,WAAmB;CACnE,MAAM,SAAS,OAAO,WAAW,SAAS;CAC1C,MAAM,WAAW,WAAW,MAAM;CAClC,IAAI,OAAO,OAAO,QAAQ,GACzB,OAAO,OAAO,iBAAiB,KAAK,EAAE,QAAQ,UAAU,CAAC;CAC1D,OAAO,SAAS;AACjB,CAAC;AAED,MAAM,U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d,CAAC,CACF,CACD,GACA,IACD,CAAC,CAAC,KAED,OAAO,SAAS,SAAS,OAAO,CACjC;CACD,CAAC,CAAC,CAAC,KACF,OAAO,eACN,OAAO,gCACP,IAAI,IAAI,CAAC,GAAG,SAASA,YAAU,MAAM,CAAC,CACvC,CACD;AACD,GACA,OAAO,MACR"}
@@ -1,6 +1,6 @@
1
1
  import { ClientCertificate } from "../Auth.js";
2
2
  import { Connect as Connect$1 } from "./entryConfig.js";
3
- import { Plugin } from "@graftland/graft";
3
+ import { Graft, Plugin } from "@graftland/graft";
4
4
  import { Effect, Redacted, Scope } from "effect";
5
5
  export type Source<A, D extends ReadonlyArray<Plugin.Dependency>, E = unknown> = Effect.Effect<A, E, Scope.Scope> | {
6
6
  readonly inject: D;
@@ -1,3 +1,3 @@
1
1
  import "../Errors.js";
2
2
  import "../Transport.js";
3
- import { Context, Effect, Option, Scope } from "effect";
3
+ import { Context, Effect, Option, PlatformError, Scope } from "effect";
@@ -1,8 +1,420 @@
1
+ import "./runner/model.js";
1
2
  import "../Contract.js";
2
- import "../Errors.js";
3
+ import { RemoteEntryError } from "../Errors.js";
3
4
  import "./directTransport.js";
4
5
  import "./execution.js";
5
6
  import { Fork, Graft, Plugin } from "@graftland/graft";
6
- import { Cause, Effect, Schema, Scope } from "effect";
7
- export declare const host: any;
7
+ import { ModuleResolver } from "@graftland/loader";
8
+ import { Cause, Effect, Path, Schema, Scope } from "effect";
9
+ import { SecureRandom } from "effect/crypto";
10
+ import { ChildProcessSpawner } from "effect/process";
11
+ export declare const host: Plugin.Definition<{
12
+ readonly contract: string;
13
+ readonly connect: {
14
+ readonly unix?: never;
15
+ readonly command?: never;
16
+ readonly stdio?: never;
17
+ readonly local?: never;
18
+ readonly worker?: never;
19
+ readonly transport?: never;
20
+ readonly instance?: string;
21
+ readonly lease?: import("effect/Duration").Duration;
22
+ readonly margin?: import("effect/Duration").Duration;
23
+ readonly expect?: {
24
+ readonly version?: string;
25
+ readonly digest?: string;
26
+ };
27
+ readonly auth?: {
28
+ readonly mtls?: never;
29
+ readonly bearer?: never;
30
+ readonly jwt?: never;
31
+ readonly none?: never;
32
+ readonly name: string;
33
+ readonly config?: unknown;
34
+ } | {
35
+ readonly name?: never;
36
+ readonly config?: never;
37
+ readonly bearer?: never;
38
+ readonly jwt?: never;
39
+ readonly none?: never;
40
+ readonly mtls: unknown;
41
+ } | {
42
+ readonly name?: never;
43
+ readonly config?: never;
44
+ readonly mtls?: never;
45
+ readonly jwt?: never;
46
+ readonly none?: never;
47
+ readonly bearer: unknown;
48
+ } | {
49
+ readonly name?: never;
50
+ readonly config?: never;
51
+ readonly mtls?: never;
52
+ readonly bearer?: never;
53
+ readonly none?: never;
54
+ readonly jwt: unknown;
55
+ } | {
56
+ readonly name?: never;
57
+ readonly config?: never;
58
+ readonly mtls?: never;
59
+ readonly bearer?: never;
60
+ readonly jwt?: never;
61
+ readonly none: unknown;
62
+ };
63
+ readonly url: string;
64
+ readonly ca?: string;
65
+ readonly servername?: string;
66
+ } | {
67
+ readonly url?: never;
68
+ readonly command?: never;
69
+ readonly stdio?: never;
70
+ readonly local?: never;
71
+ readonly worker?: never;
72
+ readonly transport?: never;
73
+ readonly instance?: string;
74
+ readonly lease?: import("effect/Duration").Duration;
75
+ readonly margin?: import("effect/Duration").Duration;
76
+ readonly expect?: {
77
+ readonly version?: string;
78
+ readonly digest?: string;
79
+ };
80
+ readonly auth?: {
81
+ readonly mtls?: never;
82
+ readonly bearer?: never;
83
+ readonly jwt?: never;
84
+ readonly none?: never;
85
+ readonly name: string;
86
+ readonly config?: unknown;
87
+ } | {
88
+ readonly name?: never;
89
+ readonly config?: never;
90
+ readonly bearer?: never;
91
+ readonly jwt?: never;
92
+ readonly none?: never;
93
+ readonly mtls: unknown;
94
+ } | {
95
+ readonly name?: never;
96
+ readonly config?: never;
97
+ readonly mtls?: never;
98
+ readonly jwt?: never;
99
+ readonly none?: never;
100
+ readonly bearer: unknown;
101
+ } | {
102
+ readonly name?: never;
103
+ readonly config?: never;
104
+ readonly mtls?: never;
105
+ readonly bearer?: never;
106
+ readonly none?: never;
107
+ readonly jwt: unknown;
108
+ } | {
109
+ readonly name?: never;
110
+ readonly config?: never;
111
+ readonly mtls?: never;
112
+ readonly bearer?: never;
113
+ readonly jwt?: never;
114
+ readonly none: unknown;
115
+ };
116
+ readonly unix: string;
117
+ } | {
118
+ readonly url?: never;
119
+ readonly unix?: never;
120
+ readonly stdio?: never;
121
+ readonly local?: never;
122
+ readonly worker?: never;
123
+ readonly transport?: never;
124
+ readonly instance?: string;
125
+ readonly lease?: import("effect/Duration").Duration;
126
+ readonly margin?: import("effect/Duration").Duration;
127
+ readonly expect?: {
128
+ readonly version?: string;
129
+ readonly digest?: string;
130
+ };
131
+ readonly command: readonly [string, ...string[]];
132
+ readonly auth?: never;
133
+ readonly cwd?: string;
134
+ readonly env?: {
135
+ readonly [x: string]: string;
136
+ };
137
+ } | {
138
+ readonly url?: never;
139
+ readonly unix?: never;
140
+ readonly command?: never;
141
+ readonly stdio?: never;
142
+ readonly worker?: never;
143
+ readonly transport?: never;
144
+ readonly auth?: never;
145
+ readonly local: {
146
+ readonly command?: readonly [string, ...string[]];
147
+ };
148
+ } | {
149
+ readonly url?: never;
150
+ readonly unix?: never;
151
+ readonly command?: never;
152
+ readonly stdio?: never;
153
+ readonly local?: never;
154
+ readonly transport?: never;
155
+ readonly auth?: never;
156
+ readonly worker: {
157
+ readonly execArgv?: readonly string[];
158
+ };
159
+ } | {
160
+ readonly url?: never;
161
+ readonly unix?: never;
162
+ readonly command?: never;
163
+ readonly stdio?: never;
164
+ readonly local?: never;
165
+ readonly worker?: never;
166
+ readonly instance?: string;
167
+ readonly lease?: import("effect/Duration").Duration;
168
+ readonly margin?: import("effect/Duration").Duration;
169
+ readonly expect?: {
170
+ readonly version?: string;
171
+ readonly digest?: string;
172
+ };
173
+ readonly auth?: {
174
+ readonly mtls?: never;
175
+ readonly bearer?: never;
176
+ readonly jwt?: never;
177
+ readonly none?: never;
178
+ readonly name: string;
179
+ readonly config?: unknown;
180
+ } | {
181
+ readonly name?: never;
182
+ readonly config?: never;
183
+ readonly bearer?: never;
184
+ readonly jwt?: never;
185
+ readonly none?: never;
186
+ readonly mtls: unknown;
187
+ } | {
188
+ readonly name?: never;
189
+ readonly config?: never;
190
+ readonly mtls?: never;
191
+ readonly jwt?: never;
192
+ readonly none?: never;
193
+ readonly bearer: unknown;
194
+ } | {
195
+ readonly name?: never;
196
+ readonly config?: never;
197
+ readonly mtls?: never;
198
+ readonly bearer?: never;
199
+ readonly none?: never;
200
+ readonly jwt: unknown;
201
+ } | {
202
+ readonly name?: never;
203
+ readonly config?: never;
204
+ readonly mtls?: never;
205
+ readonly bearer?: never;
206
+ readonly jwt?: never;
207
+ readonly none: unknown;
208
+ };
209
+ readonly transport: {
210
+ readonly name: string;
211
+ readonly config?: unknown;
212
+ };
213
+ };
214
+ readonly config: Schema.Json;
215
+ }, {
216
+ readonly contract: string;
217
+ readonly connect: {
218
+ readonly unix?: never;
219
+ readonly command?: never;
220
+ readonly stdio?: never;
221
+ readonly local?: never;
222
+ readonly worker?: never;
223
+ readonly transport?: never;
224
+ readonly instance?: string;
225
+ readonly lease?: string;
226
+ readonly margin?: string;
227
+ readonly expect?: {
228
+ readonly version?: string;
229
+ readonly digest?: string;
230
+ };
231
+ readonly auth?: {
232
+ readonly mtls?: never;
233
+ readonly bearer?: never;
234
+ readonly jwt?: never;
235
+ readonly none?: never;
236
+ readonly name: string;
237
+ readonly config?: unknown;
238
+ } | {
239
+ readonly name?: never;
240
+ readonly config?: never;
241
+ readonly bearer?: never;
242
+ readonly jwt?: never;
243
+ readonly none?: never;
244
+ readonly mtls: unknown;
245
+ } | {
246
+ readonly name?: never;
247
+ readonly config?: never;
248
+ readonly mtls?: never;
249
+ readonly jwt?: never;
250
+ readonly none?: never;
251
+ readonly bearer: unknown;
252
+ } | {
253
+ readonly name?: never;
254
+ readonly config?: never;
255
+ readonly mtls?: never;
256
+ readonly bearer?: never;
257
+ readonly none?: never;
258
+ readonly jwt: unknown;
259
+ } | {
260
+ readonly name?: never;
261
+ readonly config?: never;
262
+ readonly mtls?: never;
263
+ readonly bearer?: never;
264
+ readonly jwt?: never;
265
+ readonly none: unknown;
266
+ };
267
+ readonly url: string;
268
+ readonly ca?: string;
269
+ readonly servername?: string;
270
+ } | {
271
+ readonly url?: never;
272
+ readonly command?: never;
273
+ readonly stdio?: never;
274
+ readonly local?: never;
275
+ readonly worker?: never;
276
+ readonly transport?: never;
277
+ readonly instance?: string;
278
+ readonly lease?: string;
279
+ readonly margin?: string;
280
+ readonly expect?: {
281
+ readonly version?: string;
282
+ readonly digest?: string;
283
+ };
284
+ readonly auth?: {
285
+ readonly mtls?: never;
286
+ readonly bearer?: never;
287
+ readonly jwt?: never;
288
+ readonly none?: never;
289
+ readonly name: string;
290
+ readonly config?: unknown;
291
+ } | {
292
+ readonly name?: never;
293
+ readonly config?: never;
294
+ readonly bearer?: never;
295
+ readonly jwt?: never;
296
+ readonly none?: never;
297
+ readonly mtls: unknown;
298
+ } | {
299
+ readonly name?: never;
300
+ readonly config?: never;
301
+ readonly mtls?: never;
302
+ readonly jwt?: never;
303
+ readonly none?: never;
304
+ readonly bearer: unknown;
305
+ } | {
306
+ readonly name?: never;
307
+ readonly config?: never;
308
+ readonly mtls?: never;
309
+ readonly bearer?: never;
310
+ readonly none?: never;
311
+ readonly jwt: unknown;
312
+ } | {
313
+ readonly name?: never;
314
+ readonly config?: never;
315
+ readonly mtls?: never;
316
+ readonly bearer?: never;
317
+ readonly jwt?: never;
318
+ readonly none: unknown;
319
+ };
320
+ readonly unix: string;
321
+ } | {
322
+ readonly url?: never;
323
+ readonly unix?: never;
324
+ readonly stdio?: never;
325
+ readonly local?: never;
326
+ readonly worker?: never;
327
+ readonly transport?: never;
328
+ readonly instance?: string;
329
+ readonly lease?: string;
330
+ readonly margin?: string;
331
+ readonly expect?: {
332
+ readonly version?: string;
333
+ readonly digest?: string;
334
+ };
335
+ readonly command: readonly [string, ...string[]];
336
+ readonly auth?: never;
337
+ readonly cwd?: string;
338
+ readonly env?: {
339
+ readonly [x: string]: string;
340
+ };
341
+ } | {
342
+ readonly url?: never;
343
+ readonly unix?: never;
344
+ readonly command?: never;
345
+ readonly stdio?: never;
346
+ readonly worker?: never;
347
+ readonly transport?: never;
348
+ readonly auth?: never;
349
+ readonly local: {
350
+ readonly command?: readonly [string, ...string[]];
351
+ };
352
+ } | {
353
+ readonly url?: never;
354
+ readonly unix?: never;
355
+ readonly command?: never;
356
+ readonly stdio?: never;
357
+ readonly local?: never;
358
+ readonly transport?: never;
359
+ readonly auth?: never;
360
+ readonly worker: {
361
+ readonly execArgv?: readonly string[];
362
+ };
363
+ } | {
364
+ readonly url?: never;
365
+ readonly unix?: never;
366
+ readonly command?: never;
367
+ readonly stdio?: never;
368
+ readonly local?: never;
369
+ readonly worker?: never;
370
+ readonly instance?: string;
371
+ readonly lease?: string;
372
+ readonly margin?: string;
373
+ readonly expect?: {
374
+ readonly version?: string;
375
+ readonly digest?: string;
376
+ };
377
+ readonly auth?: {
378
+ readonly mtls?: never;
379
+ readonly bearer?: never;
380
+ readonly jwt?: never;
381
+ readonly none?: never;
382
+ readonly name: string;
383
+ readonly config?: unknown;
384
+ } | {
385
+ readonly name?: never;
386
+ readonly config?: never;
387
+ readonly bearer?: never;
388
+ readonly jwt?: never;
389
+ readonly none?: never;
390
+ readonly mtls: unknown;
391
+ } | {
392
+ readonly name?: never;
393
+ readonly config?: never;
394
+ readonly mtls?: never;
395
+ readonly jwt?: never;
396
+ readonly none?: never;
397
+ readonly bearer: unknown;
398
+ } | {
399
+ readonly name?: never;
400
+ readonly config?: never;
401
+ readonly mtls?: never;
402
+ readonly bearer?: never;
403
+ readonly none?: never;
404
+ readonly jwt: unknown;
405
+ } | {
406
+ readonly name?: never;
407
+ readonly config?: never;
408
+ readonly mtls?: never;
409
+ readonly bearer?: never;
410
+ readonly jwt?: never;
411
+ readonly none: unknown;
412
+ };
413
+ readonly transport: {
414
+ readonly name: string;
415
+ readonly config?: unknown;
416
+ };
417
+ };
418
+ readonly config?: Schema.Json;
419
+ }, RemoteEntryError | Schema.SchemaError>;
8
420
  //# sourceMappingURL=entry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entry.d.ts","names":[],"sources":["../../src/internal/entry.ts"],"mappings":";;;;;;qBAwQa"}
1
+ {"version":3,"file":"entry.d.ts","names":["EntryError"],"sources":["../../src/internal/entry.ts"],"mappings":";;;;;;;;;;qBAuQa,MAAI,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUfA,mBAAA,OAAA"}
@@ -31,7 +31,7 @@ const resolve = Effect.fnUntraced(function* (reference, field) {
31
31
  const directory = path.resolve(Option.getOrElse(source, () => "."));
32
32
  const resolver = yield* Option.match(existing, {
33
33
  onSome: Effect.succeed,
34
- onNone: () => Effect.gen(function* () {
34
+ onNone: Effect.fnUntraced(function* () {
35
35
  const importer = yield* make(directory);
36
36
  return yield* ModuleResolver.make({
37
37
  base: directory,
@@ -1 +1 @@
1
- {"version":3,"file":"entry.js","names":["EntryError","Importer.make","Contract.fromModule","Configuration.hostTransport","Configuration.authentication","Assembly.host","Configuration.Host"],"sources":["../../src/internal/entry.ts"],"sourcesContent":["import { Graft, Plugin, type Fork } from \"@graftland/graft\"\nimport { ConfigDirectory, Entry, ModuleResolver } from \"@graftland/loader\"\nimport {\n\tCause,\n\tEffect,\n\tOption,\n\tPath,\n\tSchema,\n\tReferences,\n\tScope,\n\tString,\n} from \"effect\"\nimport { ChildProcessSpawner } from \"effect/process\"\nimport * as Contract from \"../Contract\"\nimport { MissingInstance, RemoteEntryError as EntryError } from \"../Errors\"\nimport { LocalTransport, WorkerTransport } from \"./directTransport\"\nimport * as Configuration from \"./entryConfig\"\nimport * as Assembly from \"./assembly\"\nimport { executionPlugin } from \"./execution\"\nimport { follow } from \"./follow\"\nimport { children } from \"./cleanup\"\nimport { resolveEntry } from \"./runner/Packages\"\nimport type { LocalTarget, WorkerTarget } from \"./runner/Connection\"\nimport type { ExecutionOptions } from \"./execution\"\nimport * as Importer from \"./importer\"\nimport { SecureRandom } from \"effect/crypto\"\n\nexport const boundary = Effect.fnUntraced(function* (field: string) {\n\tconst entry = yield* Entry.CurrentId\n\tconst directory = yield* ConfigDirectory\n\treturn (cause: Cause.Cause<unknown>) =>\n\t\tEffect.fail(EntryError.make({ entry, directory, field, cause }))\n})\nexport const resolve = Effect.fnUntraced(function* (\n\treference: Configuration.Reference,\n\tfield: string,\n) {\n\tconst existing = yield* Effect.serviceOption(ModuleResolver.ModuleResolver)\n\tconst path = yield* Path.Path\n\tconst source = yield* ConfigDirectory\n\tconst directory = path.resolve(Option.getOrElse(source, () => \".\"))\n\tconst resolver = yield* Option.match(existing, {\n\t\tonSome: Effect.succeed,\n\t\tonNone: () =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst importer = yield* Importer.make(directory)\n\t\t\t\treturn yield* ModuleResolver.make({\n\t\t\t\t\tbase: directory,\n\t\t\t\t\timporter: (specifier) =>\n\t\t\t\t\t\tString.startsWith(\"@graftland/plugin-remote/\")(specifier)\n\t\t\t\t\t\t\t? import(specifier)\n\t\t\t\t\t\t\t: importer(specifier),\n\t\t\t\t})\n\t\t\t}),\n\t})\n\tconst fail = yield* boundary(field)\n\tconst plugin = yield* resolver\n\t\t.resolve(reference.name)\n\t\t.pipe(Effect.catchCause(fail))\n\treturn { plugin, config: reference.config }\n})\nexport const loadContract = Effect.fnUntraced(function* (specifier: string) {\n\tconst resolver = yield* ModuleResolver.ModuleResolver\n\tconst fail = yield* boundary(\"contract\")\n\treturn yield* resolver.importModule(specifier).pipe(\n\t\tEffect.flatMap((module) =>\n\t\t\tEffect.fromOption(Contract.fromModule(module), () =>\n\t\t\t\tModuleResolver.ModuleInvalid.make({\n\t\t\t\t\tspecifier,\n\t\t\t\t\tcause: \"Expected a default or named remote contract\",\n\t\t\t\t}),\n\t\t\t),\n\t\t),\n\t\tEffect.catchCause(fail),\n\t)\n})\n\n/** Direct execution installs only its execution capability in a private realm. */\nexport const direct = (\n\tprovider: Plugin.Plugin,\n\tconsumer: Plugin.Plugin,\n\tinput: Schema.Json,\n\tkey: typeof LocalTransport | typeof WorkerTransport,\n): Effect.Effect<Fork.Fork<never, unknown>, never, Graft.Graft | Scope.Scope> =>\n\tGraft.plugin(\n\t\tPlugin.make({\n\t\t\tname: \"remote-direct\",\n\t\t\tapply: Effect.fnUntraced(function* () {\n\t\t\t\tconst capability = yield* Graft.plugin(provider)\n\t\t\t\tyield* follow(capability, (cause) =>\n\t\t\t\t\tEffect.fail(Assembly.CapabilityFailed.make({ cause })),\n\t\t\t\t)\n\t\t\t\tconst execution = yield* Graft.plugin(consumer, input)\n\t\t\t\tyield* follow(execution, (cause) =>\n\t\t\t\t\tEffect.fail(Assembly.CapabilityFailed.make({ cause })),\n\t\t\t\t)\n\t\t\t}),\n\t\t}),\n\t\tundefined,\n\t\t{ isolate: [key] },\n\t)\n\ntype Annotations = Readonly<Record<string, unknown>>\nconst directTarget = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\tselected: LocalTarget | WorkerTarget,\n\tannotations: Annotations,\n\toptions: ExecutionOptions,\n) {\n\tconst path = yield* Path.Path\n\tconst source = yield* ConfigDirectory\n\tconst directory = path.resolve(Option.getOrElse(source, () => \".\"))\n\tconst module = String.startsWith(\"file:\")(input.contract)\n\t\t? input.contract\n\t\t: yield* resolveEntry(directory, input.contract)\n\tconst capability = yield* resolve(\n\t\t{\n\t\t\tname:\n\t\t\t\tselected._tag === \"Local\"\n\t\t\t\t\t? \"@graftland/plugin-remote/host/local\"\n\t\t\t\t\t: \"@graftland/plugin-remote/host/worker\",\n\t\t},\n\t\t\"connect\",\n\t)\n\treturn yield* direct(\n\t\tcapability.plugin,\n\t\texecutionPlugin(\n\t\t\tcontract,\n\t\t\t{ ...options, contractModule: module },\n\t\t\tselected,\n\t\t\tannotations,\n\t\t),\n\t\tinput.config,\n\t\tselected._tag === \"Local\" ? LocalTransport : WorkerTransport,\n\t)\n})\nconst runnerTarget = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\ttarget: Exclude<\n\t\tConfiguration.Connect,\n\t\t{ readonly local: object } | { readonly worker: object }\n\t>,\n\tannotations: Annotations,\n\toptions: ExecutionOptions,\n\tauthOverride: typeof Assembly.Invocation.Type | undefined,\n) {\n\tconst instance =\n\t\ttarget.instance === undefined\n\t\t\t? yield* Entry.CurrentId\n\t\t\t: Option.some(target.instance)\n\tif (Option.isNone(instance)) return yield* MissingInstance.make({})\n\tconst transport = yield* resolve(\n\t\tConfiguration.hostTransport(target),\n\t\t\"connect.transport\",\n\t)\n\tconst auth =\n\t\tauthOverride ??\n\t\t(yield* resolve(\n\t\t\tConfiguration.authentication(\"host\", target.auth),\n\t\t\t\"connect.auth\",\n\t\t))\n\tconst consumer = executionPlugin(\n\t\tcontract,\n\t\toptions,\n\t\t{\n\t\t\t_tag: \"Connector\",\n\t\t\texplicitAuth: target.auth !== undefined,\n\t\t\tinstance: instance.value,\n\t\t\t...(target.lease === undefined ? {} : { lease: target.lease }),\n\t\t\t...(target.margin === undefined ? {} : { margin: target.margin }),\n\t\t\t...(target.expect === undefined ? {} : { expect: target.expect }),\n\t\t},\n\t\tannotations,\n\t)\n\treturn yield* Assembly.host({\n\t\ttransport,\n\t\tauth,\n\t\tconsumer,\n\t\tinput: input.config,\n\t})\n})\n\nexport const launch = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\toptions: ExecutionOptions,\n\tauthOverride?: typeof Assembly.Invocation.Type,\n) {\n\tconst annotations = yield* References.CurrentLogAnnotations\n\tconst connect = input.connect\n\tconst scope = yield* children\n\treturn yield* Effect.gen(function* () {\n\t\tif (connect.local !== undefined)\n\t\t\treturn yield* directTarget(\n\t\t\t\tcontract,\n\t\t\t\tinput,\n\t\t\t\t{ _tag: \"Local\", ...connect.local },\n\t\t\t\tannotations,\n\t\t\t\toptions,\n\t\t\t)\n\t\tif (connect.worker !== undefined)\n\t\t\treturn yield* directTarget(\n\t\t\t\tcontract,\n\t\t\t\tinput,\n\t\t\t\t{ _tag: \"Worker\", ...connect.worker },\n\t\t\t\tannotations,\n\t\t\t\toptions,\n\t\t\t)\n\t\treturn yield* runnerTarget(\n\t\t\tcontract,\n\t\t\tinput,\n\t\t\tconnect,\n\t\t\tannotations,\n\t\t\toptions,\n\t\t\tauthOverride,\n\t\t)\n\t}).pipe(Scope.provide(scope))\n})\nconst load = Effect.fnUntraced(function* (\n\tinput: typeof Configuration.Host.Type,\n) {\n\tconst contract = yield* loadContract(input.contract)\n\tconst failConfig = yield* boundary(\"config\")\n\tyield* Schema.decodeEffect(contract.config)(input.config).pipe(\n\t\tEffect.catchCause(failConfig),\n\t)\n\tconst failConnect = yield* boundary(\"connect\")\n\tconst fork = yield* launch(contract, input, {\n\t\tcontractModule: input.contract,\n\t}).pipe(Effect.catchCause(failConnect))\n\tyield* follow(fork, failConnect)\n})\nexport const host = Plugin.make({\n\tname: \"remote\",\n\tconfig: Configuration.Host,\n\tinject: [\n\t\tSecureRandom.SecureRandom,\n\t\tModuleResolver.ModuleResolver,\n\t\tPath.Path,\n\t\tChildProcessSpawner.ChildProcessSpawner,\n\t],\n\tapply: load,\n})\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,MAAa,WAAW,OAAO,WAAW,WAAW,OAAe;CACnE,MAAM,QAAQ,OAAO,MAAM;CAC3B,MAAM,YAAY,OAAO;CACzB,QAAQ,UACP,OAAO,KAAKA,iBAAW,KAAK;EAAE;EAAO;EAAW;EAAO;CAAM,CAAC,CAAC;AACjE,CAAC;AACD,MAAa,UAAU,OAAO,WAAW,WACxC,WACA,OACC;CACD,MAAM,WAAW,OAAO,OAAO,cAAc,eAAe,cAAc;CAC1E,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,KAAK,QAAQ,OAAO,UAAU,cAAc,GAAG,CAAC;CAClE,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU;EAC9C,QAAQ,OAAO;EACf,cACC,OAAO,IAAI,aAAa;GACvB,MAAM,WAAW,OAAOC,KAAc,SAAS;GAC/C,OAAO,OAAO,eAAe,KAAK;IACjC,MAAM;IACN,WAAW,cACV,OAAO,WAAW,2BAA2B,CAAC,CAAC,SAAS,IACrD,OA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O,OAAO,aACb,UACA,OACA;GAAE,MAAM;GAAS,GAAG,QAAQ;EAAM,GAClC,aACA,OACD;EACD,IAAI,QAAQ,WAAW,KAAA,GACtB,OAAO,OAAO,aACb,UACA,OACA;GAAE,MAAM;GAAU,GAAG,QAAQ;EAAO,GACpC,aACA,OACD;EACD,OAAO,OAAO,aACb,UACA,OACA,SACA,aACA,SACA,YACD;CACD,CAAC,CAAC,CAAC,KAAK,MAAM,QAAQ,KAAK,CAAC;AAC7B,CAAC;AACD,MAAM,OAAO,OAAO,WAAW,WAC9B,OACC;CACD,MAAM,WAAW,OAAO,aAAa,MAAM,QAAQ;CACnD,MAAM,aAAa,OAAO,SAAS,QAAQ;CAC3C,OAAO,OAAO,aAAa,SAAS,MAAM,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,KACzD,OAAO,WAAW,UAAU,CAC7B;CACA,MAAM,cAAc,OAAO,SAAS,SAAS;CAC7C,MAAM,OAAO,OAAO,OAAO,UAAU,OAAO,EAC3C,gBAAgB,MAAM,SACvB,CAAC,CAAC,CAAC,KAAK,OAAO,WAAW,WAAW,CAAC;CACtC,OAAO,OAAO,MAAM,WAAW;AAChC,CAAC;AACD,MAAa,OAAO,OAAO,KAAK;CAC/B,MAAM;CACN,QAAQC;CACR,QAAQ;EACP,aAAa;EACb,eAAe;EACf,KAAK;EACL,oBAAoB;CACrB;CACA,OAAO;AACR,CAAC"}
1
+ {"version":3,"file":"entry.js","names":["EntryError","Importer.make","Contract.fromModule","Configuration.hostTransport","Configuration.authentication","Assembly.host","Configuration.Host"],"sources":["../../src/internal/entry.ts"],"sourcesContent":["import { Graft, Plugin, type Fork } from \"@graftland/graft\"\nimport { ConfigDirectory, Entry, ModuleResolver } from \"@graftland/loader\"\nimport {\n\tCause,\n\tEffect,\n\tOption,\n\tPath,\n\tSchema,\n\tReferences,\n\tScope,\n\tString,\n} from \"effect\"\nimport { ChildProcessSpawner } from \"effect/process\"\nimport * as Contract from \"../Contract\"\nimport { MissingInstance, RemoteEntryError as EntryError } from \"../Errors\"\nimport { LocalTransport, WorkerTransport } from \"./directTransport\"\nimport * as Configuration from \"./entryConfig\"\nimport * as Assembly from \"./assembly\"\nimport { executionPlugin } from \"./execution\"\nimport { follow } from \"./follow\"\nimport { children } from \"./cleanup\"\nimport { resolveEntry } from \"./runner/Packages\"\nimport type { LocalTarget, WorkerTarget } from \"./runner/Connection\"\nimport type { ExecutionOptions } from \"./execution\"\nimport * as Importer from \"./importer\"\nimport { SecureRandom } from \"effect/crypto\"\n\nexport const boundary = Effect.fnUntraced(function* (field: string) {\n\tconst entry = yield* Entry.CurrentId\n\tconst directory = yield* ConfigDirectory\n\treturn (cause: Cause.Cause<unknown>) =>\n\t\tEffect.fail(EntryError.make({ entry, directory, field, cause }))\n})\nexport const resolve = Effect.fnUntraced(function* (\n\treference: Configuration.Reference,\n\tfield: string,\n) {\n\tconst existing = yield* Effect.serviceOption(ModuleResolver.ModuleResolver)\n\tconst path = yield* Path.Path\n\tconst source = yield* ConfigDirectory\n\tconst directory = path.resolve(Option.getOrElse(source, () => \".\"))\n\tconst resolver = yield* Option.match(existing, {\n\t\tonSome: Effect.succeed,\n\t\tonNone: Effect.fnUntraced(function* () {\n\t\t\tconst importer = yield* Importer.make(directory)\n\t\t\treturn yield* ModuleResolver.make({\n\t\t\t\tbase: directory,\n\t\t\t\timporter: (specifier) =>\n\t\t\t\t\tString.startsWith(\"@graftland/plugin-remote/\")(specifier)\n\t\t\t\t\t\t? import(specifier)\n\t\t\t\t\t\t: importer(specifier),\n\t\t\t})\n\t\t}),\n\t})\n\tconst fail = yield* boundary(field)\n\tconst plugin = yield* resolver\n\t\t.resolve(reference.name)\n\t\t.pipe(Effect.catchCause(fail))\n\treturn { plugin, config: reference.config }\n})\nexport const loadContract = Effect.fnUntraced(function* (specifier: string) {\n\tconst resolver = yield* ModuleResolver.ModuleResolver\n\tconst fail = yield* boundary(\"contract\")\n\treturn yield* resolver.importModule(specifier).pipe(\n\t\tEffect.flatMap((module) =>\n\t\t\tEffect.fromOption(Contract.fromModule(module), () =>\n\t\t\t\tModuleResolver.ModuleInvalid.make({\n\t\t\t\t\tspecifier,\n\t\t\t\t\tcause: \"Expected a default or named remote contract\",\n\t\t\t\t}),\n\t\t\t),\n\t\t),\n\t\tEffect.catchCause(fail),\n\t)\n})\n\n/** Direct execution installs only its execution capability in a private realm. */\nexport const direct = (\n\tprovider: Plugin.Plugin,\n\tconsumer: Plugin.Plugin,\n\tinput: Schema.Json,\n\tkey: typeof LocalTransport | typeof WorkerTransport,\n): Effect.Effect<Fork.Fork<never, unknown>, never, Graft.Graft | Scope.Scope> =>\n\tGraft.plugin(\n\t\tPlugin.make({\n\t\t\tname: \"remote-direct\",\n\t\t\tapply: Effect.fnUntraced(function* () {\n\t\t\t\tconst capability = yield* Graft.plugin(provider)\n\t\t\t\tyield* follow(capability, (cause) =>\n\t\t\t\t\tEffect.fail(Assembly.CapabilityFailed.make({ cause })),\n\t\t\t\t)\n\t\t\t\tconst execution = yield* Graft.plugin(consumer, input)\n\t\t\t\tyield* follow(execution, (cause) =>\n\t\t\t\t\tEffect.fail(Assembly.CapabilityFailed.make({ cause })),\n\t\t\t\t)\n\t\t\t}),\n\t\t}),\n\t\tundefined,\n\t\t{ isolate: [key] },\n\t)\n\ntype Annotations = Readonly<Record<string, unknown>>\nconst directTarget = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\tselected: LocalTarget | WorkerTarget,\n\tannotations: Annotations,\n\toptions: ExecutionOptions,\n) {\n\tconst path = yield* Path.Path\n\tconst source = yield* ConfigDirectory\n\tconst directory = path.resolve(Option.getOrElse(source, () => \".\"))\n\tconst module = String.startsWith(\"file:\")(input.contract)\n\t\t? input.contract\n\t\t: yield* resolveEntry(directory, input.contract)\n\tconst capability = yield* resolve(\n\t\t{\n\t\t\tname:\n\t\t\t\tselected._tag === \"Local\"\n\t\t\t\t\t? \"@graftland/plugin-remote/host/local\"\n\t\t\t\t\t: \"@graftland/plugin-remote/host/worker\",\n\t\t},\n\t\t\"connect\",\n\t)\n\treturn yield* direct(\n\t\tcapability.plugin,\n\t\texecutionPlugin(\n\t\t\tcontract,\n\t\t\t{ ...options, contractModule: module },\n\t\t\tselected,\n\t\t\tannotations,\n\t\t),\n\t\tinput.config,\n\t\tselected._tag === \"Local\" ? LocalTransport : WorkerTransport,\n\t)\n})\nconst runnerTarget = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\ttarget: Exclude<\n\t\tConfiguration.Connect,\n\t\t{ readonly local: object } | { readonly worker: object }\n\t>,\n\tannotations: Annotations,\n\toptions: ExecutionOptions,\n\tauthOverride: typeof Assembly.Invocation.Type | undefined,\n) {\n\tconst instance =\n\t\ttarget.instance === undefined\n\t\t\t? yield* Entry.CurrentId\n\t\t\t: Option.some(target.instance)\n\tif (Option.isNone(instance)) return yield* MissingInstance.make({})\n\tconst transport = yield* resolve(\n\t\tConfiguration.hostTransport(target),\n\t\t\"connect.transport\",\n\t)\n\tconst auth =\n\t\tauthOverride ??\n\t\t(yield* resolve(\n\t\t\tConfiguration.authentication(\"host\", target.auth),\n\t\t\t\"connect.auth\",\n\t\t))\n\tconst consumer = executionPlugin(\n\t\tcontract,\n\t\toptions,\n\t\t{\n\t\t\t_tag: \"Connector\",\n\t\t\texplicitAuth: target.auth !== undefined,\n\t\t\tinstance: instance.value,\n\t\t\t...(target.lease === undefined ? {} : { lease: target.lease }),\n\t\t\t...(target.margin === undefined ? {} : { margin: target.margin }),\n\t\t\t...(target.expect === undefined ? {} : { expect: target.expect }),\n\t\t},\n\t\tannotations,\n\t)\n\treturn yield* Assembly.host({\n\t\ttransport,\n\t\tauth,\n\t\tconsumer,\n\t\tinput: input.config,\n\t})\n})\n\nexport const launch = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\toptions: ExecutionOptions,\n\tauthOverride?: typeof Assembly.Invocation.Type,\n) {\n\tconst annotations = yield* References.CurrentLogAnnotations\n\tconst connect = input.connect\n\tconst scope = yield* children\n\treturn yield* Effect.gen(function* () {\n\t\tif (connect.local !== undefined)\n\t\t\treturn yield* directTarget(\n\t\t\t\tcontract,\n\t\t\t\tinput,\n\t\t\t\t{ _tag: \"Local\", ...connect.local },\n\t\t\t\tannotations,\n\t\t\t\toptions,\n\t\t\t)\n\t\tif (connect.worker !== undefined)\n\t\t\treturn yield* directTarget(\n\t\t\t\tcontract,\n\t\t\t\tinput,\n\t\t\t\t{ _tag: \"Worker\", ...connect.worker },\n\t\t\t\tannotations,\n\t\t\t\toptions,\n\t\t\t)\n\t\treturn yield* runnerTarget(\n\t\t\tcontract,\n\t\t\tinput,\n\t\t\tconnect,\n\t\t\tannotations,\n\t\t\toptions,\n\t\t\tauthOverride,\n\t\t)\n\t}).pipe(Scope.provide(scope))\n})\nconst load = Effect.fnUntraced(function* (\n\tinput: typeof Configuration.Host.Type,\n) {\n\tconst contract = yield* loadContract(input.contract)\n\tconst failConfig = yield* boundary(\"config\")\n\tyield* Schema.decodeEffect(contract.config)(input.config).pipe(\n\t\tEffect.catchCause(failConfig),\n\t)\n\tconst failConnect = yield* boundary(\"connect\")\n\tconst fork = yield* launch(contract, input, {\n\t\tcontractModule: input.contract,\n\t}).pipe(Effect.catchCause(failConnect))\n\tyield* follow(fork, failConnect)\n})\nexport const host = Plugin.make({\n\tname: \"remote\",\n\tconfig: Configuration.Host,\n\tinject: [\n\t\tSecureRandom.SecureRandom,\n\t\tModuleResolver.ModuleResolver,\n\t\tPath.Path,\n\t\tChildProcessSpawner.ChildProcessSpawner,\n\t],\n\tapply: load,\n})\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,MAAa,WAAW,OAAO,WAAW,WAAW,OAAe;CACnE,MAAM,QAAQ,OAAO,MAAM;CAC3B,MAAM,YAAY,OAAO;CACzB,QAAQ,UACP,OAAO,KAAKA,iBAAW,KAAK;EAAE;EAAO;EAAW;EAAO;CAAM,CAAC,CAAC;AACjE,CAAC;AACD,MAAa,UAAU,OAAO,WAAW,WACxC,WACA,OACC;CACD,MAAM,WAAW,OAAO,OAAO,cAAc,eAAe,cAAc;CAC1E,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,KAAK,QAAQ,OAAO,UAAU,cAAc,GAAG,CAAC;CAClE,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU;EAC9C,QAAQ,OAAO;EACf,QAAQ,OAAO,WAAW,aAAa;GACtC,MAAM,WAAW,OAAOC,KAAc,SAAS;GAC/C,OAAO,OAAO,eAAe,KAAK;IACjC,MAAM;IACN,WAAW,cACV,OAAO,WAAW,2BAA2B,CAAC,CAAC,SAAS,IACrD,OAAO,aACP,SAAS,SAAS;GACvB,CAAC;EACF,CAAC;CACF,CAAC;CACD,MAAM,OAAO,OAAO,SAAS,KAAK;CAIlC,OAAO;EAAE,QAAA,OAHa,SACpB,QAAQ,UAAU,IAAI,CAAC,CACvB,KAAK,OAAO,WAAW,IAAI,CAAC;EACb,QAAQ,UAAU;CAAO;AAC3C,CAAC;AACD,MAAa,eAAe,OAAO,WAAW,WAAW,WAA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,KAAK,MAAM,QAAQ,KAAK,CAAC;AAC7B,CAAC;AACD,MAAM,OAAO,OAAO,WAAW,WAC9B,OACC;CACD,MAAM,WAAW,OAAO,aAAa,MAAM,QAAQ;CACnD,MAAM,aAAa,OAAO,SAAS,QAAQ;CAC3C,OAAO,OAAO,aAAa,SAAS,MAAM,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,KACzD,OAAO,WAAW,UAAU,CAC7B;CACA,MAAM,cAAc,OAAO,SAAS,SAAS;CAC7C,MAAM,OAAO,OAAO,OAAO,UAAU,OAAO,EAC3C,gBAAgB,MAAM,SACvB,CAAC,CAAC,CAAC,KAAK,OAAO,WAAW,WAAW,CAAC;CACtC,OAAO,OAAO,MAAM,WAAW;AAChC,CAAC;AACD,MAAa,OAAO,OAAO,KAAK;CAC/B,MAAM;CACN,QAAQC;CACR,QAAQ;EACP,aAAa;EACb,eAAe;EACf,KAAK;EACL,oBAAoB;CACrB;CACA,OAAO;AACR,CAAC"}
@@ -4,13 +4,18 @@ import { Credentials } from "../Auth.js";
4
4
  import { acquire } from "./runner/Connection.js";
5
5
  import { endpoints } from "./services.js";
6
6
  import { dispose, initialize, load } from "./host.js";
7
- import { MissingInstance, RemoteError, RemoteWithdrawn } from "../Errors.js";
7
+ import { AuthenticationFailed, CredentialsError, LocalTerminationTimeout, MissingInstance, ProcessExited, RemoteEntryError, RemoteError, RemoteWithdrawn, TransportError } from "../Errors.js";
8
+ import { ActivationFailed, AlreadyLoaded, ContractNotFound, ModuleImportFailed } from "./childErrors.js";
9
+ import { errors } from "./assembly.js";
10
+ import { ExecutionError, LeaseExpired, PackageError, RemoteTerminationUnconfirmed, RunnerClosing, SessionAccessDenied, SessionConflict, SessionStopped, StaleSession, StateDirectoryLocked, StateStorageError, TerminationUnconfirmed } from "./runner/model.js";
11
+ import { ReleaseInterrupted } from "./release.js";
8
12
  import { UndeclaredFailure } from "../Contract.js";
9
13
  import { endpoint } from "./control.js";
10
14
  import { prepare } from "./contract.js";
11
15
  import { Plugin } from "@graftland/graft";
12
- import { Array, Cause, Effect, Fiber, Schema, Scope } from "effect";
16
+ import { Array, Cause, Effect, Fiber, PlatformError, Schema, Scope } from "effect";
13
17
  import { SecureRandom } from "effect/crypto";
18
+ import { RpcClientError } from "effect/rpc";
14
19
  // src/internal/execution.ts
15
20
  const dependencies = (target) => target._tag === "Connector" ? [Connector, Credentials] : target._tag === "Local" ? [LocalTransport] : [WorkerTransport];
16
21
  /** One owned execution per activation, with explicitly mapped services. */
@@ -22,7 +27,7 @@ const executionPlugin = (contract, options, configured, annotations = {}) => Plu
22
27
  ...Array.map(contract.inject, (service) => service.key)
23
28
  ],
24
29
  config: Schema.toEncoded(contract.config),
25
- apply: (input) => Effect.gen(function* () {
30
+ apply: Effect.fnUntraced(function* (input) {
26
31
  const prepared = prepare(contract);
27
32
  const session = yield* (yield* SecureRandom.SecureRandom).uuidV4();
28
33
  const active = yield* acquire(configured, options.contractModule, {
@@ -37,9 +42,39 @@ const executionPlugin = (contract, options, configured, annotations = {}) => Plu
37
42
  for (const service of contract.provides) yield* service.publish(active.connection.transport).pipe(Scope.provide(active.connection.resources));
38
43
  yield* Plugin.fork(Effect.raceFirst(Fiber.join(active.events), active.remoteFailure.await).pipe(Effect.mapError((error) => publicError(contract.error, error))));
39
44
  return () => Effect.succeed(false);
40
- }).pipe(Effect.annotateLogs(annotations), Effect.mapError((error) => publicError(contract.error, error)))
45
+ }, Effect.annotateLogs(annotations), Effect.mapError((error) => publicError(contract.error, error)))
41
46
  });
42
- const publicError = (declared, error) => Schema.is(declared)(error) ? error : Schema.is(UndeclaredFailure)(error) || Schema.is(RemoteWithdrawn)(error) || Schema.is(RemoteError)(error) || Schema.is(MissingInstance)(error) ? error : RemoteError.make({ cause: Cause.fail(error) });
47
+ /** Failures raised by the host machinery; a permissive declared schema must not claim them. */
48
+ const internalErrors = [
49
+ ProcessExited,
50
+ TransportError,
51
+ LocalTerminationTimeout,
52
+ CredentialsError,
53
+ AuthenticationFailed,
54
+ RemoteEntryError,
55
+ AlreadyLoaded,
56
+ ContractNotFound,
57
+ ModuleImportFailed,
58
+ ActivationFailed,
59
+ PackageError,
60
+ SessionAccessDenied,
61
+ StaleSession,
62
+ LeaseExpired,
63
+ SessionStopped,
64
+ SessionConflict,
65
+ StateStorageError,
66
+ ExecutionError,
67
+ TerminationUnconfirmed,
68
+ RunnerClosing,
69
+ StateDirectoryLocked,
70
+ RemoteTerminationUnconfirmed,
71
+ ReleaseInterrupted,
72
+ RpcClientError.RpcClientError,
73
+ ...errors
74
+ ];
75
+ const isInternal = (error) => Schema.isSchemaError(error) || PlatformError.isPlatformError(error) || Array.some(internalErrors, (Class) => error instanceof Class);
76
+ const isPublic = (error) => Schema.is(UndeclaredFailure)(error) || Schema.is(RemoteWithdrawn)(error) || Schema.is(RemoteError)(error) || Schema.is(MissingInstance)(error);
77
+ const publicError = (declared, error) => isPublic(error) ? error : !isInternal(error) && Schema.is(declared)(error) ? error : RemoteError.make({ cause: Cause.fail(error) });
43
78
  export { executionPlugin, publicError };
44
79
 
45
80
  //# sourceMappingURL=execution.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution.js","names":["Connection.acquire","Services.endpoints","Control.endpoint","Host.initialize","Host.dispose","Host.load","Contract.UndeclaredFailure"],"sources":["../../src/internal/execution.ts"],"sourcesContent":["import { Plugin } from \"@graftland/graft\"\nimport { Array, Cause, Effect, Fiber, Schema, Scope } from \"effect\"\nimport { SecureRandom } from \"effect/crypto\"\nimport type {\n\tLocalTarget as Local,\n\tWorkerTarget as Worker,\n} from \"./runner/Connection\"\nimport { Connector } from \"../Transport\"\nimport { LocalTransport, WorkerTransport } from \"./directTransport\"\nimport { Credentials } from \"../Auth\"\nimport type { Duration } from \"effect\"\nimport * as Connection from \"./runner/Connection\"\nimport * as Services from \"./services\"\nimport * as Host from \"./host\"\nimport { RemoteWithdrawn, RemoteError, MissingInstance } from \"../Errors\"\nimport * as Contract from \"../Contract\"\nimport * as Control from \"./control\"\nimport { prepare } from \"./contract\"\n\nexport interface ExecutionOptions {\n\treadonly contractModule: string\n\treadonly shutdownTimeout?: Duration.Input | undefined\n}\n\nconst dependencies = (\n\ttarget: Local | Worker | Connection.ConfiguredRunner,\n): ReadonlyArray<Plugin.Dependency> =>\n\ttarget._tag === \"Connector\"\n\t\t? [Connector, Credentials]\n\t\t: target._tag === \"Local\"\n\t\t\t? [LocalTransport]\n\t\t\t: [WorkerTransport]\n\n/** One owned execution per activation, with explicitly mapped services. */\nexport const executionPlugin = <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\toptions: ExecutionOptions,\n\tconfigured: Local | Worker | Connection.ConfiguredRunner,\n\tannotations: Readonly<Record<string, unknown>> = {},\n): Plugin.Plugin<\n\tS[\"Encoded\"],\n\tS[\"Encoded\"],\n\t| E[\"Type\"]\n\t| Contract.UndeclaredFailure\n\t| RemoteError\n\t| RemoteWithdrawn\n\t| MissingInstance\n> =>\n\tPlugin.make({\n\t\tname: contract.name,\n\t\tinject: [\n\t\t\tSecureRandom.SecureRandom,\n\t\t\t...dependencies(configured),\n\t\t\t...Array.map(contract.inject, (service) => service.key),\n\t\t],\n\t\tconfig: Schema.toEncoded(contract.config),\n\t\tapply: (input) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst prepared = prepare(contract)\n\t\t\t\tconst random = yield* SecureRandom.SecureRandom\n\t\t\t\tconst session = yield* random.uuidV4()\n\t\t\t\tconst active = yield* Connection.acquire(\n\t\t\t\t\tconfigured,\n\t\t\t\t\toptions.contractModule,\n\t\t\t\t\t{\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tserve: Services.endpoints(contract.inject),\n\t\t\t\t\t\tcall: {\n\t\t\t\t\t\t\t...Services.endpoints(contract.provides),\n\t\t\t\t\t\t\t[Control.endpoint]: prepared.control,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tHost.initialize(prepared),\n\t\t\t\t\tHost.dispose,\n\t\t\t\t\toptions.shutdownTimeout ?? \"5 seconds\",\n\t\t\t\t)\n\t\t\t\tyield* Host.load(active, input)\n\t\t\t\tfor (const service of contract.provides)\n\t\t\t\t\tyield* service\n\t\t\t\t\t\t.publish(active.connection.transport)\n\t\t\t\t\t\t.pipe(Scope.provide(active.connection.resources))\n\t\t\t\tyield* Plugin.fork(\n\t\t\t\t\tEffect.raceFirst(\n\t\t\t\t\t\tFiber.join(active.events),\n\t\t\t\t\t\tactive.remoteFailure.await,\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.mapError((error) => publicError(contract.error, error)),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\treturn () => Effect.succeed(false)\n\t\t\t}).pipe(\n\t\t\t\tEffect.annotateLogs(annotations),\n\t\t\t\tEffect.mapError((error) => publicError(contract.error, error)),\n\t\t\t),\n\t})\n\nexport const publicError = <E extends Schema.Top>(\n\tdeclared: E,\n\terror: unknown,\n):\n\t| E[\"Type\"]\n\t| Contract.UndeclaredFailure\n\t| RemoteWithdrawn\n\t| RemoteError\n\t| MissingInstance =>\n\tSchema.is(declared)(error)\n\t\t? error\n\t\t: Schema.is(Contract.UndeclaredFailure)(error) ||\n\t\t\t Schema.is(RemoteWithdrawn)(error) ||\n\t\t\t Schema.is(RemoteError)(error) ||\n\t\t\t Schema.is(MissingInstance)(error)\n\t\t\t? error\n\t\t\t: RemoteError.make({ cause: Cause.fail(error) })\n"],"mappings":";;;;;;;;;;;;;;AAwBA,MAAM,gBACL,WAEA,OAAO,SAAS,cACb,CAAC,WAAW,WAAW,IACvB,OAAO,SAAS,UACf,CAAC,cAAc,IACf,CAAC,eAAe;;AAGrB,MAAa,mBAWZ,UACA,SACA,YACA,cAAiD,CAAC,MAUlD,OAAO,KAAK;CACX,MAAM,S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,OAAO,MAAM,KAAK,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"execution.js","names":["Connection.acquire","Services.endpoints","Control.endpoint","Host.initialize","Host.dispose","Host.load","Errors.ProcessExited","Errors.TransportError","Errors.LocalTerminationTimeout","Errors.CredentialsError","Errors.AuthenticationFailed","Errors.RemoteEntryError","ChildErrors.AlreadyLoaded","ChildErrors.ContractNotFound","ChildErrors.ModuleImportFailed","ChildErrors.ActivationFailed","Model.PackageError","Model.SessionAccessDenied","Model.StaleSession","Model.LeaseExpired","Model.SessionStopped","Model.SessionConflict","Model.StateStorageError","Model.ExecutionError","Model.TerminationUnconfirmed","Model.RunnerClosing","Model.StateDirectoryLocked","Model.RemoteTerminationUnconfirmed","Assembly.errors","Contract.UndeclaredFailure"],"sources":["../../src/internal/execution.ts"],"sourcesContent":["import { Plugin } from \"@graftland/graft\"\nimport {\n\tArray,\n\tCause,\n\tEffect,\n\tFiber,\n\tPlatformError,\n\tSchema,\n\tScope,\n} from \"effect\"\nimport { SecureRandom } from \"effect/crypto\"\nimport { RpcClientError } from \"effect/rpc\"\nimport type {\n\tLocalTarget as Local,\n\tWorkerTarget as Worker,\n} from \"./runner/Connection\"\nimport { Connector } from \"../Transport\"\nimport { LocalTransport, WorkerTransport } from \"./directTransport\"\nimport { Credentials } from \"../Auth\"\nimport type { Duration } from \"effect\"\nimport * as Connection from \"./runner/Connection\"\nimport * as Services from \"./services\"\nimport * as Host from \"./host\"\nimport * as Errors from \"../Errors\"\nimport { RemoteWithdrawn, RemoteError, MissingInstance } from \"../Errors\"\nimport * as ChildErrors from \"./childErrors\"\nimport * as Assembly from \"./assembly\"\nimport * as Model from \"./runner/model\"\nimport { ReleaseInterrupted } from \"./release\"\nimport * as Contract from \"../Contract\"\nimport * as Control from \"./control\"\nimport { prepare } from \"./contract\"\n\nexport interface ExecutionOptions {\n\treadonly contractModule: string\n\treadonly shutdownTimeout?: Duration.Input | undefined\n}\n\nconst dependencies = (\n\ttarget: Local | Worker | Connection.ConfiguredRunner,\n): ReadonlyArray<Plugin.Dependency> =>\n\ttarget._tag === \"Connector\"\n\t\t? [Connector, Credentials]\n\t\t: target._tag === \"Local\"\n\t\t\t? [LocalTransport]\n\t\t\t: [WorkerTransport]\n\n/** One owned execution per activation, with explicitly mapped services. */\nexport const executionPlugin = <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\toptions: ExecutionOptions,\n\tconfigured: Local | Worker | Connection.ConfiguredRunner,\n\tannotations: Readonly<Record<string, unknown>> = {},\n): Plugin.Plugin<\n\tS[\"Encoded\"],\n\tS[\"Encoded\"],\n\t| E[\"Type\"]\n\t| Contract.UndeclaredFailure\n\t| RemoteError\n\t| RemoteWithdrawn\n\t| MissingInstance\n> =>\n\tPlugin.make({\n\t\tname: contract.name,\n\t\tinject: [\n\t\t\tSecureRandom.SecureRandom,\n\t\t\t...dependencies(configured),\n\t\t\t...Array.map(contract.inject, (service) => service.key),\n\t\t],\n\t\tconfig: Schema.toEncoded(contract.config),\n\t\tapply: Effect.fnUntraced(\n\t\t\tfunction* (input: Schema.Json) {\n\t\t\t\tconst prepared = prepare(contract)\n\t\t\t\tconst random = yield* SecureRandom.SecureRandom\n\t\t\t\tconst session = yield* random.uuidV4()\n\t\t\t\tconst active = yield* Connection.acquire(\n\t\t\t\t\tconfigured,\n\t\t\t\t\toptions.contractModule,\n\t\t\t\t\t{\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tserve: Services.endpoints(contract.inject),\n\t\t\t\t\t\tcall: {\n\t\t\t\t\t\t\t...Services.endpoints(contract.provides),\n\t\t\t\t\t\t\t[Control.endpoint]: prepared.control,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tHost.initialize(prepared),\n\t\t\t\t\tHost.dispose,\n\t\t\t\t\toptions.shutdownTimeout ?? \"5 seconds\",\n\t\t\t\t)\n\t\t\t\tyield* Host.load(active, input)\n\t\t\t\tfor (const service of contract.provides)\n\t\t\t\t\tyield* service\n\t\t\t\t\t\t.publish(active.connection.transport)\n\t\t\t\t\t\t.pipe(Scope.provide(active.connection.resources))\n\t\t\t\tyield* Plugin.fork(\n\t\t\t\t\tEffect.raceFirst(\n\t\t\t\t\t\tFiber.join(active.events),\n\t\t\t\t\t\tactive.remoteFailure.await,\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.mapError((error) => publicError(contract.error, error)),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\treturn () => Effect.succeed(false)\n\t\t\t},\n\t\t\tEffect.annotateLogs(annotations),\n\t\t\tEffect.mapError((error) => publicError(contract.error, error)),\n\t\t),\n\t})\n\n/** Failures raised by the host machinery; a permissive declared schema must not claim them. */\nconst internalErrors: ReadonlyArray<abstract new (...args: never) => unknown> =\n\t[\n\t\tErrors.ProcessExited,\n\t\tErrors.TransportError,\n\t\tErrors.LocalTerminationTimeout,\n\t\tErrors.CredentialsError,\n\t\tErrors.AuthenticationFailed,\n\t\tErrors.RemoteEntryError,\n\t\tChildErrors.AlreadyLoaded,\n\t\tChildErrors.ContractNotFound,\n\t\tChildErrors.ModuleImportFailed,\n\t\tChildErrors.ActivationFailed,\n\t\tModel.PackageError,\n\t\tModel.SessionAccessDenied,\n\t\tModel.StaleSession,\n\t\tModel.LeaseExpired,\n\t\tModel.SessionStopped,\n\t\tModel.SessionConflict,\n\t\tModel.StateStorageError,\n\t\tModel.ExecutionError,\n\t\tModel.TerminationUnconfirmed,\n\t\tModel.RunnerClosing,\n\t\tModel.StateDirectoryLocked,\n\t\tModel.RemoteTerminationUnconfirmed,\n\t\tReleaseInterrupted,\n\t\tRpcClientError.RpcClientError,\n\t\t...Assembly.errors,\n\t]\nconst isInternal = (error: unknown) =>\n\tSchema.isSchemaError(error) ||\n\tPlatformError.isPlatformError(error) ||\n\tArray.some(internalErrors, (Class) => error instanceof Class)\nconst isPublic = (\n\terror: unknown,\n): error is\n\t| Contract.UndeclaredFailure\n\t| RemoteWithdrawn\n\t| RemoteError\n\t| MissingInstance =>\n\tSchema.is(Contract.UndeclaredFailure)(error) ||\n\tSchema.is(RemoteWithdrawn)(error) ||\n\tSchema.is(RemoteError)(error) ||\n\tSchema.is(MissingInstance)(error)\n\nexport const publicError = <E extends Schema.Top>(\n\tdeclared: E,\n\terror: unknown,\n):\n\t| E[\"Type\"]\n\t| Contract.UndeclaredFailure\n\t| RemoteWithdrawn\n\t| RemoteError\n\t| MissingInstance =>\n\tisPublic(error)\n\t\t? error\n\t\t: // Classify host failures before the declared schema, which may be structural.\n\t\t\t!isInternal(error) && Schema.is(declared)(error)\n\t\t\t? error\n\t\t\t: RemoteError.make({ cause: Cause.fail(error) })\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,MAAM,gBACL,WAEA,OAAO,SAAS,cACb,CAAC,WAAW,WAAW,IACvB,OAAO,SAAS,UACf,CAAC,cAAc,IACf,CAAC,eAAe;;AAGrB,MAAa,mBAWZ,UACA,SACA,YACA,cAAiD,CAAC,MAUlD,OAAO,KAAK;CACX,MAAM,SAAS;CACf,QAAQ;EACP,aAAa;EACb,GAAG,aAAa,UAAU;EAC1B,GAAG,MAAM,IAAI,SAAS,SAAS,YAAY,QAAQ,GAAG;CACvD;CACA,QAAQ,OAAO,UAAU,SAAS,MAAM;CACxC,OAAO,OAAO,WACb,WAAW,OAAoB;EAC9B,MAAM,WAAW,QAAQ,QAAQ;EAEjC,MAAM,UAAU,QAAO,OADD,aAAa,aAAA,CACL,OAAO;EACrC,MAAM,SAAS,OAAOA,QACrB,YACA,QAAQ,gBACR;GACC;GACA,OAAOC,UAAmB,SAAS,MAAM;GACzC,MAAM;IACL,GAAGA,UAAmB,SAAS,QAAQ;KACtCC,WAAmB,SAAS;GAC9B;EACD,GACAC,WAAgB,QAAQ,GACxBC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