@syntropika/tembra-sdk 0.2.1 → 0.3.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 (241) hide show
  1. package/README.md +43 -17
  2. package/dist/authoring/types.d.ts +64 -3
  3. package/dist/authoring/wit.d.ts +6 -0
  4. package/dist/bridge/commands.d.ts +1190 -0
  5. package/dist/bridge/identifiers.d.ts +2 -0
  6. package/dist/bridge/kernel.d.ts +18 -107
  7. package/dist/bridge/protocol.d.ts +3 -138
  8. package/dist/browser.d.ts +14 -1
  9. package/dist/browser.js +141 -3298
  10. package/dist/chunks/browser-b8jamxw2.js +3399 -0
  11. package/dist/chunks/execution-nsqc6nrt.js +1419 -0
  12. package/dist/chunks/index-01zk0xqx.js +160 -0
  13. package/dist/chunks/index-3fjdfdfd.js +152 -0
  14. package/dist/chunks/index-aaymjn7v.js +787 -0
  15. package/dist/chunks/index-c1w7z9hx.js +356 -0
  16. package/dist/chunks/index-h8t0n42q.js +738 -0
  17. package/dist/chunks/index-hfds9mzp.js +308 -0
  18. package/dist/chunks/index-kr4x67wt.js +177 -0
  19. package/dist/chunks/index-kr6bnh34.js +117 -0
  20. package/dist/chunks/index-kyt9dj0a.js +1421 -0
  21. package/dist/chunks/index-n1wxzc9w.js +830 -0
  22. package/dist/chunks/index-pvac426d.js +74 -0
  23. package/dist/chunks/index-smyds5ce.js +3234 -0
  24. package/dist/chunks/index-sse8aapb.js +121 -0
  25. package/dist/chunks/index-v6heph77.js +643 -0
  26. package/dist/chunks/index-xrdvnv37.js +3448 -0
  27. package/dist/chunks/index-za4mg94e.js +26 -0
  28. package/dist/chunks/index-zkqmnjj8.js +167 -0
  29. package/dist/coordinator.js +9 -500
  30. package/dist/error.d.ts +2 -0
  31. package/dist/errors.d.ts +3 -0
  32. package/dist/guest.d.ts +173 -0
  33. package/dist/guest.js +26 -0
  34. package/dist/host.d.ts +36 -30
  35. package/dist/host.js +37 -3276
  36. package/dist/http/bytes.d.ts +8 -0
  37. package/dist/http/events.d.ts +7 -0
  38. package/dist/http.d.ts +45 -0
  39. package/dist/http.js +291 -0
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +49 -862
  42. package/dist/infrastructure/rpc/client.d.ts +2 -1
  43. package/dist/infrastructure/rpc/resources.d.ts +28 -0
  44. package/dist/interpreter/abi.d.ts +54 -0
  45. package/dist/interpreter/acquire.d.ts +18 -0
  46. package/dist/interpreter/browser-network.d.ts +52 -0
  47. package/dist/interpreter/browser-port.d.ts +55 -0
  48. package/dist/interpreter/browser.d.ts +79 -0
  49. package/dist/interpreter/cli.d.ts +5 -0
  50. package/dist/interpreter/codec.d.ts +42 -0
  51. package/dist/interpreter/component/execution.d.ts +42 -0
  52. package/dist/interpreter/component/host.d.ts +69 -0
  53. package/dist/interpreter/component/instance.d.ts +40 -0
  54. package/dist/interpreter/component/kernel.d.ts +120 -0
  55. package/dist/interpreter/component/names.d.ts +5 -0
  56. package/dist/interpreter/component/port.d.ts +85 -0
  57. package/dist/interpreter/component/prepared.d.ts +97 -0
  58. package/dist/interpreter/component/resources.d.ts +45 -0
  59. package/dist/interpreter/component/revision.d.ts +87 -0
  60. package/dist/interpreter/component/scope.d.ts +116 -0
  61. package/dist/interpreter/component/streams.d.ts +28 -0
  62. package/dist/interpreter/component/values.d.ts +79 -0
  63. package/dist/interpreter/component/wasi-filesystem.d.ts +21 -0
  64. package/dist/interpreter/component/wasi-host.d.ts +64 -0
  65. package/dist/interpreter/component/wasi-http.d.ts +33 -0
  66. package/dist/interpreter/component/wasi-sockets.d.ts +183 -0
  67. package/dist/interpreter/component/wasi.d.ts +41 -0
  68. package/dist/interpreter/core.d.ts +64 -0
  69. package/dist/interpreter/fetch-http-provider.d.ts +17 -0
  70. package/dist/interpreter/filesystem/contract.d.ts +85 -0
  71. package/dist/interpreter/filesystem/memory.d.ts +3 -0
  72. package/dist/interpreter/filesystem/opfs.d.ts +3 -0
  73. package/dist/interpreter/filesystem/scope.d.ts +35 -0
  74. package/dist/interpreter/filesystem.d.ts +8 -0
  75. package/dist/interpreter/gate.d.ts +6 -0
  76. package/dist/interpreter/host-protocol.d.ts +100 -0
  77. package/dist/interpreter/http-ingress-fetch.d.ts +7 -0
  78. package/dist/interpreter/http-ingress.d.ts +96 -0
  79. package/dist/interpreter/http-provider.d.ts +85 -0
  80. package/dist/interpreter/io.d.ts +20 -0
  81. package/dist/interpreter/mobile.d.ts +149 -0
  82. package/dist/interpreter/native-ingress.d.ts +95 -0
  83. package/dist/interpreter/node-port.d.ts +25 -0
  84. package/dist/interpreter/node.d.ts +36 -0
  85. package/dist/interpreter/revision.d.ts +64 -0
  86. package/dist/interpreter/scope.d.ts +89 -0
  87. package/dist/interpreter/socket-addresses.d.ts +50 -0
  88. package/dist/interpreter/socket-provider.d.ts +110 -0
  89. package/dist/interpreter/standard-cli.d.ts +34 -0
  90. package/dist/interpreter/standard-codec.d.ts +96 -0
  91. package/dist/interpreter/standard-filesystem.d.ts +47 -0
  92. package/dist/interpreter/standard-host.d.ts +71 -0
  93. package/dist/interpreter/standard-http-values.d.ts +159 -0
  94. package/dist/interpreter/standard-http.d.ts +9 -0
  95. package/dist/interpreter/standard-ingress.d.ts +63 -0
  96. package/dist/interpreter/standard-sockets.d.ts +177 -0
  97. package/dist/interpreter/standard-streams.d.ts +218 -0
  98. package/dist/interpreter/standard-system.d.ts +35 -0
  99. package/dist/interpreter/standard-utf8.d.ts +4 -0
  100. package/dist/interpreter/standard.d.ts +18 -0
  101. package/dist/interpreter/types.d.ts +152 -0
  102. package/dist/interpreter/wit-shape.d.ts +92 -0
  103. package/dist/manager.js +5 -332
  104. package/dist/msgpack.js +9 -615
  105. package/dist/node.d.ts +8 -1
  106. package/dist/node.js +248 -3287
  107. package/dist/rpc.js +196 -699
  108. package/dist/runtime/adapters.d.ts +120 -0
  109. package/dist/runtime/adapters.js +38 -0
  110. package/dist/runtime/calls.d.ts +9 -3
  111. package/dist/runtime/lifecycle.d.ts +3 -1
  112. package/dist/runtime/orbs.d.ts +5 -4
  113. package/dist/runtime/references.d.ts +27 -1
  114. package/dist/runtime/reload.d.ts +5 -3
  115. package/dist/runtime/scopes.d.ts +1 -1
  116. package/dist/runtime/signals.d.ts +4 -0
  117. package/dist/runtime/wit-client.d.ts +38 -0
  118. package/dist/telemetry.js +4 -25
  119. package/dist/tooling/build.d.ts +2 -2
  120. package/dist/tooling/client-resources.d.ts +23 -0
  121. package/dist/tooling/client.d.ts +10 -0
  122. package/dist/tooling/component-glue.d.ts +17 -0
  123. package/dist/tooling/component.d.ts +11 -0
  124. package/dist/tooling/index.d.ts +3 -1
  125. package/dist/tooling/index.js +1155 -102
  126. package/dist/tooling/resolver.d.ts +4 -4
  127. package/dist/tooling/typecheck.d.ts +2 -1
  128. package/dist/tooling/types.d.ts +27 -12
  129. package/dist/tooling/wit.d.ts +9 -0
  130. package/dist/wasi/wasi-clocks-types.d.ts +2 -0
  131. package/dist/wasi/wasi-http-client.d.ts +5 -0
  132. package/dist/wasi/wasi-http-types.d.ts +285 -0
  133. package/dist/wasi/wasi-sockets-ip-name-lookup.d.ts +23 -0
  134. package/dist/wasi/wasi-sockets-types.d.ts +146 -0
  135. package/package.json +62 -35
  136. package/src/authoring/declaration.ts +1 -1
  137. package/src/authoring/types.ts +53 -3
  138. package/src/authoring/wit.ts +15 -0
  139. package/src/bridge/commands.ts +1105 -0
  140. package/src/bridge/identifiers.ts +2 -0
  141. package/src/bridge/kernel.ts +56 -98
  142. package/src/bridge/protocol.ts +3 -142
  143. package/src/browser.ts +90 -6
  144. package/src/context-key.ts +4 -7
  145. package/src/error.ts +1 -1
  146. package/src/errors.ts +7 -0
  147. package/src/guest.ts +327 -0
  148. package/src/host.ts +128 -23
  149. package/src/http/bytes.ts +87 -0
  150. package/src/http/events.ts +34 -0
  151. package/src/http.ts +272 -0
  152. package/src/index.ts +3 -0
  153. package/src/infrastructure/rpc/client.ts +136 -17
  154. package/src/infrastructure/rpc/resources.ts +123 -0
  155. package/src/interpreter/abi.ts +69 -0
  156. package/src/interpreter/acquire.ts +58 -0
  157. package/src/interpreter/browser-network.ts +170 -0
  158. package/src/interpreter/browser-port.ts +425 -0
  159. package/src/interpreter/browser.ts +340 -0
  160. package/src/interpreter/cli.ts +30 -0
  161. package/src/interpreter/codec.ts +298 -0
  162. package/src/interpreter/component/execution.ts +264 -0
  163. package/src/interpreter/component/host.ts +409 -0
  164. package/src/interpreter/component/instance.ts +138 -0
  165. package/src/interpreter/component/kernel.ts +611 -0
  166. package/src/interpreter/component/names.ts +13 -0
  167. package/src/interpreter/component/port.ts +598 -0
  168. package/src/interpreter/component/prepared.ts +194 -0
  169. package/src/interpreter/component/resources.ts +345 -0
  170. package/src/interpreter/component/revision.ts +702 -0
  171. package/src/interpreter/component/scope.ts +447 -0
  172. package/src/interpreter/component/streams.ts +180 -0
  173. package/src/interpreter/component/values.ts +254 -0
  174. package/src/interpreter/component/wasi-filesystem.ts +472 -0
  175. package/src/interpreter/component/wasi-host.ts +197 -0
  176. package/src/interpreter/component/wasi-http.ts +939 -0
  177. package/src/interpreter/component/wasi-sockets.ts +958 -0
  178. package/src/interpreter/component/wasi.ts +238 -0
  179. package/src/interpreter/core.ts +386 -0
  180. package/src/interpreter/fetch-http-provider.ts +98 -0
  181. package/src/interpreter/filesystem/contract.ts +138 -0
  182. package/src/interpreter/filesystem/memory.ts +180 -0
  183. package/src/interpreter/filesystem/opfs.ts +294 -0
  184. package/src/interpreter/filesystem/scope.ts +390 -0
  185. package/src/interpreter/filesystem.ts +20 -0
  186. package/src/interpreter/gate.ts +55 -0
  187. package/src/interpreter/host-protocol.ts +242 -0
  188. package/src/interpreter/http-ingress-fetch.ts +133 -0
  189. package/src/interpreter/http-ingress.ts +203 -0
  190. package/src/interpreter/http-provider.ts +105 -0
  191. package/src/interpreter/io.ts +66 -0
  192. package/src/interpreter/mobile.ts +385 -0
  193. package/src/interpreter/native-ingress.ts +550 -0
  194. package/src/interpreter/node-port.ts +218 -0
  195. package/src/interpreter/node.ts +114 -0
  196. package/src/interpreter/revision.ts +450 -0
  197. package/src/interpreter/scope.ts +453 -0
  198. package/src/interpreter/socket-addresses.ts +246 -0
  199. package/src/interpreter/socket-provider.ts +126 -0
  200. package/src/interpreter/standard-cli.ts +184 -0
  201. package/src/interpreter/standard-codec.ts +403 -0
  202. package/src/interpreter/standard-filesystem.ts +545 -0
  203. package/src/interpreter/standard-host.ts +840 -0
  204. package/src/interpreter/standard-http-values.ts +624 -0
  205. package/src/interpreter/standard-http.ts +622 -0
  206. package/src/interpreter/standard-ingress.ts +344 -0
  207. package/src/interpreter/standard-sockets.ts +847 -0
  208. package/src/interpreter/standard-streams.ts +710 -0
  209. package/src/interpreter/standard-system.ts +182 -0
  210. package/src/interpreter/standard-utf8.ts +72 -0
  211. package/src/interpreter/standard.ts +283 -0
  212. package/src/interpreter/types.ts +163 -0
  213. package/src/interpreter/wit-shape.ts +175 -0
  214. package/src/node.ts +43 -14
  215. package/src/runtime/activities.ts +6 -6
  216. package/src/runtime/adapters.ts +314 -0
  217. package/src/runtime/calls.ts +218 -56
  218. package/src/runtime/context.ts +7 -7
  219. package/src/runtime/lifecycle.ts +36 -17
  220. package/src/runtime/orbs.ts +81 -39
  221. package/src/runtime/programs.ts +16 -8
  222. package/src/runtime/references.ts +128 -11
  223. package/src/runtime/reload.ts +71 -30
  224. package/src/runtime/resources.ts +2 -2
  225. package/src/runtime/scopes.ts +17 -17
  226. package/src/runtime/session.ts +3 -1
  227. package/src/runtime/signals.ts +31 -0
  228. package/src/runtime/wit-client.ts +228 -0
  229. package/src/tooling/build.ts +152 -54
  230. package/src/tooling/client-resources.ts +74 -0
  231. package/src/tooling/client.ts +531 -0
  232. package/src/tooling/component-glue.ts +288 -0
  233. package/src/tooling/component.ts +225 -0
  234. package/src/tooling/index.ts +3 -7
  235. package/src/tooling/resolver.ts +42 -25
  236. package/src/tooling/typecheck.ts +59 -4
  237. package/src/tooling/types.ts +27 -12
  238. package/src/tooling/wit.ts +188 -0
  239. package/dist/embedded.d.ts +0 -1
  240. package/dist/embedded.js +0 -1
  241. package/src/embedded.ts +0 -293
package/dist/msgpack.js CHANGED
@@ -1,620 +1,14 @@
1
- // src/codecs/msgpack.ts
2
- import { decode, encode, ExtensionCodec } from "@msgpack/msgpack";
3
-
4
- // src/bridge/protocol.ts
5
- var KernelOp = Object.freeze({
6
- ContextDerive: "context-derive",
7
- ContextValue: "context-value",
8
- ContextStats: "context-stats",
9
- Allocate: "allocate",
10
- ScopeRegister: "scope-register",
11
- ScopeExists: "scope-exists",
12
- ScopesForOwner: "scopes-for-owner",
13
- ScopesForOrb: "scopes-for-orb",
14
- ScopeAddResource: "scope-add-resource",
15
- ScopeActivate: "scope-activate",
16
- ScopesCleanup: "scopes-cleanup",
17
- ScopesReloadRegistered: "scopes-reload-registered",
18
- ScopesReload: "scopes-reload",
19
- ProgramRun: "program-run",
20
- ProgramNext: "program-next",
21
- ProgramCompleteStep: "program-complete-step",
22
- ProgramCommit: "program-commit",
23
- ProgramAbort: "program-abort",
24
- ProgramForget: "program-forget",
25
- Features: "features",
26
- Prepare: "prepare",
27
- Gate: "gate",
28
- GateOrbs: "gate-orbs",
29
- Commit: "commit",
30
- Abort: "abort",
31
- Orbs: "orbs",
32
- Orb: "orb",
33
- OrbNamed: "orb-named",
34
- NextDeadline: "next-deadline",
35
- Address: "address",
36
- Acquire: "acquire",
37
- Ready: "ready",
38
- Dependency: "dependency",
39
- Undepend: "undepend",
40
- Fail: "fail",
41
- Status: "status",
42
- Release: "release",
43
- Forget: "forget",
44
- Root: "root",
45
- CleanupRoot: "cleanup-root",
46
- RootPrincipal: "root-principal",
47
- CheckContext: "check-context",
48
- CheckRoot: "check-root",
49
- EndRoot: "end-root",
50
- CancelRoot: "cancel-root",
51
- BeginCall: "begin-call",
52
- BeginOperation: "begin-operation",
53
- BeginHookObservation: "begin-hook-observation",
54
- FinishCall: "finish-call",
55
- Invocation: "invocation",
56
- StateInit: "state-init",
57
- Snapshot: "snapshot",
58
- StateAdopt: "state-adopt",
59
- Task: "task",
60
- TaskRoot: "task-root",
61
- StopTask: "stop-task",
62
- FinishTask: "finish-task",
63
- Resource: "resource",
64
- ResourceOpened: "resource-opened",
65
- ResourceValue: "resource-value",
66
- CloseResource: "close-resource",
67
- ResourceClosed: "resource-closed",
68
- Disposed: "disposed",
69
- Tick: "tick",
70
- NextWake: "next-wake",
71
- NextIdle: "next-idle",
72
- Close: "close",
73
- FinishClose: "finish-close",
74
- Diagnostics: "diagnostics",
75
- Drain: "drain",
76
- Restrict: "restrict",
77
- Contribute: "contribute",
78
- ContributionOrdinal: "contribution-ordinal",
79
- HookPlan: "hook-plan",
80
- Listen: "listen",
81
- Subscribe: "subscribe",
82
- Enqueue: "enqueue",
83
- NextDelivery: "next-delivery",
84
- FinishDelivery: "finish-delivery",
85
- Unsubscribe: "unsubscribe"
86
- });
87
- var ActionType = Object.freeze({
88
- Execute: "execute",
89
- CancelEffects: "cancel-effects",
90
- ProgramPrepared: "program-prepared",
91
- ProgramComplete: "program-complete",
92
- Dispose: "dispose",
93
- CloseResource: "close-resource",
94
- DropValue: "drop-value",
95
- CancelRoot: "cancel-root",
96
- CancelTask: "cancel-task",
97
- RetireOrb: "retire-orb",
98
- State: "state",
99
- SubscriptionFailed: "subscription-failed",
100
- DetachSubscription: "detach-subscription",
101
- Deliver: "deliver"
102
- });
103
- var EffectType = Object.freeze({
104
- Stop: "stop",
105
- Open: "open",
106
- Close: "close",
107
- Restore: "restore",
108
- Prepare: "prepare",
109
- Validate: "validate",
110
- Initialize: "initialize",
111
- Migrate: "migrate",
112
- Adopt: "adopt",
113
- Start: "start",
114
- Drop: "drop"
115
- });
116
- var StepType = Object.freeze({
117
- Execute: "execute",
118
- Wait: "wait",
119
- Prepared: "prepared",
120
- Complete: "complete",
121
- Failed: "failed"
122
- });
123
- var NativeOp = Object.freeze({
124
- Activate: "activate",
125
- Dispose: "dispose",
126
- CancelEffect: "cancel-effect",
127
- Effect: "effect",
128
- Invoke: "invoke",
129
- Contribute: "contribute"
130
- });
131
- var RpcOp = Object.freeze({
132
- Describe: "describe",
133
- Get: "get",
134
- Release: "release",
135
- Call: "call",
136
- Cancel: "cancel"
137
- });
138
- var RpcEvent = Object.freeze({
139
- State: "state"
140
- });
141
- var OwnerKind = Object.freeze({
142
- Host: "host",
143
- Orb: "orb",
144
- Object: "object"
145
- });
146
- var EnvironmentPhase = Object.freeze({
147
- Declaring: "declaring",
148
- Prepared: "prepared",
149
- Live: "live",
150
- Closed: "closed"
151
- });
152
- var CoordinationDecision = Object.freeze({
153
- Preparing: "preparing",
154
- Commit: "commit",
155
- Abort: "abort"
156
- });
157
- var Outcome = Object.freeze({
158
- Ok: "ok",
159
- Error: "error"
160
- });
161
- var CodecTag = Object.freeze({
162
- Bigint: "bigint",
163
- Bytes: "bytes",
164
- Object: "object"
165
- });
166
- var CodecId = Object.freeze({
167
- Json: "tembra-json/1",
168
- MessagePack: "tembra-msgpack/1"
169
- });
170
-
171
- // src/bridge/identifiers.ts
172
- var Code = Object.freeze({
173
- Invalid: "invalid",
174
- Unavailable: "unavailable",
175
- Released: "released",
176
- Gone: "gone",
177
- Expired: "expired",
178
- Cancelled: "cancelled",
179
- Forbidden: "forbidden",
180
- Conflict: "conflict",
181
- Unsupported: "unsupported",
182
- Closed: "closed",
183
- Exhausted: "exhausted"
184
- });
185
- var Reason = Object.freeze({
186
- ActivationBusy: "activation_busy",
187
- Address: "address",
188
- AlreadyCommitted: "already_committed",
189
- AmbiguousScope: "ambiguous_scope",
190
- ApiVersion: "api_version",
191
- Arguments: "arguments",
192
- AsyncFactory: "async_factory",
193
- AsyncState: "async_state",
194
- Bigint: "bigint",
195
- ByteResult: "byte_result",
196
- Call: "call",
197
- Callback: "callback",
198
- CleanupBusy: "cleanup_busy",
199
- Clock: "clock",
200
- Codec: "codec",
201
- Connection: "connection",
202
- Context: "context",
203
- Contribution: "contribution",
204
- CoordinationLimits: "coordination_limits",
205
- Deadline: "deadline",
206
- Dependency: "dependency",
207
- DependencyCycle: "dependency_cycle",
208
- DependencyService: "dependency_service",
209
- Disposing: "disposing",
210
- Driver: "driver",
211
- Duplicate: "duplicate",
212
- DuplicateContribution: "duplicate_contribution",
213
- DuplicateListener: "duplicate_listener",
214
- DuplicateResource: "duplicate_resource",
215
- DuplicateService: "duplicate_service",
216
- EffectResults: "effect_results",
217
- EffectsRunning: "effects_running",
218
- EngineEffect: "engine_effect",
219
- EventSource: "event_source",
220
- ExclusiveDependent: "exclusive_dependent",
221
- Executor: "executor",
222
- Orb: "orb",
223
- OrbGone: "orb_gone",
224
- OrbInstalled: "orb_installed",
225
- OrbScope: "orb_scope",
226
- Factory: "factory",
227
- FactoryExpired: "factory_expired",
228
- FrameSize: "frame_size",
229
- GateBusy: "gate_busy",
230
- GateOrb: "gate_orb",
231
- GateObject: "gate_object",
232
- Hook: "hook",
233
- HookDependency: "hook_dependency",
234
- Hooks: "hooks",
235
- HooksDisabled: "hooks_disabled",
236
- Host: "host",
237
- HostAddress: "host_address",
238
- HostResource: "host_resource",
239
- HostResourceReload: "host_resource_reload",
240
- Identities: "identities",
241
- Implementation: "implementation",
242
- Invocation: "invocation",
243
- Javascript: "javascript",
244
- JsonAccessor: "json_accessor",
245
- JsonCycle: "json_cycle",
246
- JsonNumber: "json_number",
247
- JsonSymbol: "json_symbol",
248
- JsonTag: "json_tag",
249
- JsonType: "json_type",
250
- JsonValue: "json_value",
251
- Lifetime: "lifetime",
252
- Linger: "linger",
253
- ListenerCallback: "listener_callback",
254
- LiveConsumer: "live_consumer",
255
- LiveReference: "live_reference",
256
- LocalValue: "local_value",
257
- Memory: "memory",
258
- Metadata: "metadata",
259
- MetadataSize: "metadata_size",
260
- Method: "method",
261
- MigrationGate: "migration_gate",
262
- MigrationRequired: "migration_required",
263
- MigrationValue: "migration_value",
264
- MissingHook: "missing_hook",
265
- MissingMethod: "missing_method",
266
- NativeEffect: "native_effect",
267
- NativeMethod: "native_method",
268
- NativeObject: "native_object",
269
- NativeService: "native_service",
270
- Next: "next",
271
- NextUsed: "next_used",
272
- NotReady: "not_ready",
273
- Object: "object",
274
- ObjectState: "object_state",
275
- ObservationSource: "observation_source",
276
- ObservationAdmitted: "observation_admitted",
277
- Opaque: "opaque",
278
- Operation: "operation",
279
- OperationOwner: "operation_owner",
280
- Owner: "owner",
281
- Payload: "payload",
282
- PendingRequests: "pending_requests",
283
- PrepareDeadline: "prepare_deadline",
284
- Priority: "priority",
285
- Program: "program",
286
- ProgramPhase: "program_phase",
287
- ProgramRunning: "program_running",
288
- Reference: "reference",
289
- ReloadAborted: "reload_aborted",
290
- ReloadDeadline: "reload_deadline",
291
- ReloadPreparing: "reload_preparing",
292
- ReloadRunning: "reload_running",
293
- ReloadTicket: "reload_ticket",
294
- RemoteOpaque: "remote_opaque",
295
- RemoteReferences: "remote_references",
296
- Request: "request",
297
- RequestIds: "request_ids",
298
- Requires: "requires",
299
- Resource: "resource",
300
- ResourceDependencies: "resource_dependencies",
301
- ResourceDependency: "resource_dependency",
302
- ResourceHost: "resource_host",
303
- ResourceInFactory: "resource_in_factory",
304
- ResourceState: "resource_state",
305
- ResourceVersion: "resource_version",
306
- Result: "result",
307
- RetainedVersions: "retained_versions",
308
- RevisionExhausted: "revision_exhausted",
309
- Root: "root",
310
- Route: "route",
311
- RpcFrame: "rpc_frame",
312
- RpcOperation: "rpc_operation",
313
- RpcRequest: "rpc_request",
314
- RustType: "rust_type",
315
- Scope: "scope",
316
- ScopeClosed: "scope_closed",
317
- ScopeOrb: "scope_orb",
318
- ScopeOwner: "scope_owner",
319
- ScopeResource: "scope_resource",
320
- Serialization: "serialization",
321
- Service: "service",
322
- ServiceGone: "service_gone",
323
- State: "state",
324
- StateCycle: "state_cycle",
325
- StateInitialized: "state_initialized",
326
- StateOwner: "state_owner",
327
- StateRevision: "state_revision",
328
- StateValidation: "state_validation",
329
- StateValue: "state_value",
330
- StateVersion: "state_version",
331
- Subscription: "subscription",
332
- SubscriptionBusy: "subscription_busy",
333
- SubscriptionIdle: "subscription_idle",
334
- SubscriptionQueue: "subscription_queue",
335
- SubscriptionSize: "subscription_size",
336
- SubscriptionsDisabled: "subscriptions_disabled",
337
- Superseded: "superseded",
338
- Task: "task",
339
- Telemetry: "telemetry",
340
- UndeclaredDependency: "undeclared_dependency",
341
- UndeclaredService: "undeclared_service",
342
- UnknownService: "unknown_service",
343
- UpgradeConflict: "upgrade_conflict",
344
- Utf8: "utf8",
345
- Value: "value",
346
- ValueGone: "value_gone",
347
- ValuesExhausted: "values_exhausted",
348
- Views: "views"
349
- });
350
- var Lifetime = Object.freeze({
351
- Referenced: "referenced",
352
- Host: "host"
353
- });
354
- var Status = Object.freeze({
355
- Loading: "loading",
356
- Live: "live",
357
- Released: "released",
358
- Gone: "gone"
359
- });
360
- var ReloadStatus = Object.freeze({
361
- Prepared: "prepared",
362
- Committed: "committed",
363
- Aborted: "aborted"
364
- });
365
- var HookCapability = Object.freeze({
366
- Observe: "observe",
367
- Transform: "transform",
368
- Decide: "decide"
369
- });
370
-
371
- // src/errors.ts
372
- function define(code, reason, message) {
373
- return Object.freeze({ code, reason, message });
374
- }
375
- var Errors = Object.freeze({
376
- Cancelled: Object.freeze({
377
- EngineEffect: define(Code.Cancelled, Reason.EngineEffect, "The engine effect was cancelled"),
378
- Request: define(Code.Cancelled, Reason.Request, "The request was cancelled"),
379
- Resource: define(Code.Cancelled, Reason.Resource, "Resource opening was cancelled"),
380
- Root: define(Code.Cancelled, Reason.Root, "The operation was cancelled"),
381
- Task: define(Code.Cancelled, Reason.Task, "The task was cancelled")
382
- }),
383
- Closed: Object.freeze({
384
- Host: define(Code.Closed, Reason.Host, "The host is closing")
385
- }),
386
- Conflict: Object.freeze({
387
- AlreadyCommitted: define(Code.Conflict, Reason.AlreadyCommitted, "The replacement is already committed"),
388
- Codec: define(Code.Conflict, Reason.Codec, "The Rust and JS host codecs must agree"),
389
- PrepareDeadline: define(Code.Conflict, Reason.PrepareDeadline, "The preparation deadline expired"),
390
- ReloadRunning: define(Code.Conflict, Reason.ReloadRunning, "A replacement is already running"),
391
- ReloadTicket: define(Code.Conflict, Reason.ReloadTicket, "The replacement is no longer prepared")
392
- }),
393
- Exhausted: Object.freeze({
394
- FrameSize: define(Code.Exhausted, Reason.FrameSize, "The frame exceeds the configured size limit"),
395
- PendingRequests: define(Code.Exhausted, Reason.PendingRequests, "The pending request limit was reached"),
396
- RemoteReferences: define(Code.Exhausted, Reason.RemoteReferences, "The remote reference limit was reached"),
397
- RequestIds: define(Code.Exhausted, Reason.RequestIds, "Request identities are exhausted"),
398
- SubscriptionQueue: define(Code.Exhausted, Reason.SubscriptionQueue, "The subscription queue is full")
399
- }),
400
- Expired: Object.freeze({
401
- Next: define(Code.Expired, Reason.Next, "Continuation scope has ended")
402
- }),
403
- Forbidden: Object.freeze({
404
- Context: define(Code.Forbidden, Reason.Context, "An issued context from this host is required"),
405
- HostResource: define(Code.Forbidden, Reason.HostResource, "The host resource was not declared"),
406
- Method: define(Code.Forbidden, Reason.Method, "The method is not allowed by this reference"),
407
- ObservationSource: define(Code.Forbidden, Reason.ObservationSource, "Hook observation requires the original physical invocation"),
408
- Opaque: define(Code.Forbidden, Reason.Opaque, "The resource is not available as an opaque local value"),
409
- Service: define(Code.Forbidden, Reason.Service, "Access to this service is forbidden"),
410
- StateOwner: define(Code.Forbidden, Reason.StateOwner, "Only the owning orb may change this state"),
411
- UndeclaredDependency: define(Code.Forbidden, Reason.UndeclaredDependency, "The dependency was not declared"),
412
- UndeclaredService: define(Code.Forbidden, Reason.UndeclaredService, "The service was not declared as a dependency")
413
- }),
414
- Gone: Object.freeze({
415
- Connection: define(Code.Gone, Reason.Connection, "The connection is closed"),
416
- Contribution: define(Code.Gone, Reason.Contribution, "The contribution is no longer available"),
417
- Implementation: define(Code.Gone, Reason.Implementation, "The implementation is no longer available"),
418
- ListenerCallback: define(Code.Gone, Reason.ListenerCallback, "The listener callback is no longer available"),
419
- Reference: define(Code.Gone, Reason.Reference, "The reference is no longer available"),
420
- Resource: define(Code.Gone, Reason.Resource, "The resource is no longer available"),
421
- Scope: define(Code.Gone, Reason.Scope, "The declaration scope is no longer available"),
422
- State: define(Code.Gone, Reason.State, "State owner is gone")
423
- }),
424
- Invalid: Object.freeze({
425
- Address: define(Code.Invalid, Reason.Address, "Invalid address"),
426
- AsyncFactory: define(Code.Invalid, Reason.AsyncFactory, "Factories must be synchronous"),
427
- AsyncState: define(Code.Invalid, Reason.AsyncState, "State updates and migrations must be synchronous"),
428
- CoordinationLimits: define(Code.Invalid, Reason.CoordinationLimits, "Invalid coordination limits"),
429
- DependencyCycle: define(Code.Invalid, Reason.DependencyCycle, "Orb factories cannot acquire their own services"),
430
- DependencyService: define(Code.Invalid, Reason.DependencyService, "Invalid dependency service"),
431
- DuplicateListener: define(Code.Invalid, Reason.DuplicateListener, "Invalid duplicate listener"),
432
- DuplicateResource: define(Code.Invalid, Reason.DuplicateResource, "Invalid duplicate resource"),
433
- EventSource: define(Code.Invalid, Reason.EventSource, "Invalid event source"),
434
- Orb: define(Code.Invalid, Reason.Orb, "An orb needs a name and positive API version"),
435
- OrbGone: define(Code.Invalid, Reason.OrbGone, "Invalid orb gone"),
436
- OrbInstalled: define(Code.Invalid, Reason.OrbInstalled, "Use reload to replace an installed orb"),
437
- Factory: define(Code.Invalid, Reason.Factory, "Invalid factory"),
438
- FactoryExpired: define(Code.Invalid, Reason.FactoryExpired, "Declarations must be synchronous"),
439
- Hook: define(Code.Invalid, Reason.Hook, "Hooks need a run function"),
440
- HookDependency: define(Code.Invalid, Reason.HookDependency, "Invalid hook dependency"),
441
- HooksDisabled: define(Code.Invalid, Reason.HooksDisabled, "Invalid hooks disabled"),
442
- JsonAccessor: define(Code.Invalid, Reason.JsonAccessor, "Invalid json accessor"),
443
- JsonCycle: define(Code.Invalid, Reason.JsonCycle, "Invalid json cycle"),
444
- JsonNumber: define(Code.Invalid, Reason.JsonNumber, "Use BigInt for integers outside the safe Number range"),
445
- JsonSymbol: define(Code.Invalid, Reason.JsonSymbol, "Invalid json symbol"),
446
- JsonTag: define(Code.Invalid, Reason.JsonTag, "Unknown or malformed portable type tag"),
447
- JsonType: define(Code.Invalid, Reason.JsonType, "Supply a codec for custom object types"),
448
- JsonValue: define(Code.Invalid, Reason.JsonValue, "This JSON codec requires explicit portable values"),
449
- Method: define(Code.Invalid, Reason.Method, "Methods must be functions"),
450
- NextUsed: define(Code.Invalid, Reason.NextUsed, "Invalid next used"),
451
- Priority: define(Code.Invalid, Reason.Priority, "Invalid priority"),
452
- Reference: define(Code.Invalid, Reason.Reference, "An issued local reference is required"),
453
- Resource: define(Code.Invalid, Reason.Resource, "Invalid resource"),
454
- ResourceHost: define(Code.Invalid, Reason.ResourceHost, "Resource dependencies must belong to the same host"),
455
- ResourceInFactory: define(Code.Invalid, Reason.ResourceInFactory, "Resources open after declaration"),
456
- RpcFrame: define(Code.Invalid, Reason.RpcFrame, "Invalid rpc frame"),
457
- RpcOperation: define(Code.Invalid, Reason.RpcOperation, "Invalid rpc operation"),
458
- RpcRequest: define(Code.Invalid, Reason.RpcRequest, "Invalid rpc request"),
459
- Service: define(Code.Invalid, Reason.Service, "Invalid service"),
460
- ServiceGone: define(Code.Invalid, Reason.ServiceGone, "Invalid service gone"),
461
- State: define(Code.Invalid, Reason.State, "Service does not expose state"),
462
- StateCycle: define(Code.Invalid, Reason.StateCycle, "State cannot contain cycles"),
463
- StateValidation: define(Code.Invalid, Reason.StateValidation, "The orb rejected the state candidate"),
464
- StateValue: define(Code.Invalid, Reason.StateValue, "State cannot contain accessors"),
465
- StateVersion: define(Code.Invalid, Reason.StateVersion, "Invalid state version"),
466
- SubscriptionsDisabled: define(Code.Invalid, Reason.SubscriptionsDisabled, "Invalid subscriptions disabled"),
467
- SubscriptionSize: define(Code.Invalid, Reason.SubscriptionSize, "A local byte budget requires an explicit sizeOf function"),
468
- Task: define(Code.Invalid, Reason.Task, "Invalid task"),
469
- Utf8: define(Code.Invalid, Reason.Utf8, "Invalid utf8"),
470
- ValueGone: define(Code.Invalid, Reason.ValueGone, "Invalid value gone"),
471
- ValuesExhausted: define(Code.Invalid, Reason.ValuesExhausted, "Invalid values exhausted")
472
- }),
473
- Released: Object.freeze({
474
- Reference: define(Code.Released, Reason.Reference, "The reference has been released")
475
- }),
476
- Unavailable: Object.freeze({
477
- Callback: define(Code.Unavailable, Reason.Callback, "A callback failed"),
478
- OrbScope: define(Code.Unavailable, Reason.OrbScope, "The orb scope is unavailable"),
479
- NotReady: define(Code.Unavailable, Reason.NotReady, "The object is not ready"),
480
- Route: define(Code.Unavailable, Reason.Route, "The route is unavailable")
481
- }),
482
- Unsupported: Object.freeze({
483
- EngineEffect: define(Code.Unsupported, Reason.EngineEffect, "The engine effect is not supported by this adapter"),
484
- RemoteOpaque: define(Code.Unsupported, Reason.RemoteOpaque, "Opaque resources are local to their language environment"),
485
- Telemetry: define(Code.Unsupported, Reason.Telemetry, "Telemetry is disabled in this kernel"),
486
- Views: define(Code.Unsupported, Reason.Views, "Reference views are disabled in this kernel")
487
- })
488
- });
489
-
490
- // src/error.ts
491
- var codes = new Set(Object.values(Code));
492
- class TembraError extends Error {
493
- code;
494
- reason;
495
- constructor(error, message = error.message, options) {
496
- super(message, options);
497
- this.name = "TembraError";
498
- this.code = error.code;
499
- this.reason = error.reason;
500
- }
501
- }
502
- function refuse(error, message = error.message) {
503
- throw new TembraError(error, message);
504
- }
505
-
506
- // src/codecs/json.ts
507
- var marker = "$tembra";
508
- function pack(value, visiting) {
509
- if (typeof value === "bigint")
510
- return { [marker]: [CodecTag.Bigint, value.toString()] };
511
- if (value instanceof Uint8Array)
512
- return { [marker]: [CodecTag.Bytes, [...value]] };
513
- if (value === null || typeof value === "string" || typeof value === "boolean")
514
- return value;
515
- if (typeof value === "number") {
516
- if (!Number.isFinite(value) || Number.isInteger(value) && !Number.isSafeInteger(value))
517
- refuse(Errors.Invalid.JsonNumber, "Use BigInt for integers outside the safe Number range");
518
- return value;
519
- }
520
- if (typeof value !== "object")
521
- refuse(Errors.Invalid.JsonValue, "This JSON codec requires explicit portable values");
522
- if (visiting.has(value))
523
- refuse(Errors.Invalid.JsonCycle);
524
- const prototype = Object.getPrototypeOf(value);
525
- if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null)
526
- refuse(Errors.Invalid.JsonType, "Supply a codec for custom object types");
527
- visiting.add(value);
528
- try {
529
- if (Array.isArray(value))
530
- return Array.from(value, (child) => pack(child, visiting));
531
- const entries = Reflect.ownKeys(value).map((key) => {
532
- if (typeof key !== "string")
533
- refuse(Errors.Invalid.JsonSymbol);
534
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
535
- if (!Object.hasOwn(descriptor, "value"))
536
- refuse(Errors.Invalid.JsonAccessor);
537
- return [key, pack(descriptor.value, visiting)];
538
- });
539
- return Object.hasOwn(value, marker) ? { [marker]: [CodecTag.Object, entries] } : Object.fromEntries(entries);
540
- } finally {
541
- visiting.delete(value);
542
- }
543
- }
544
- function unpack(value) {
545
- if (value === null || typeof value !== "object") {
546
- if (typeof value === "number" && Number.isInteger(value) && !Number.isSafeInteger(value))
547
- refuse(Errors.Invalid.JsonNumber);
548
- return value;
549
- }
550
- if (Array.isArray(value))
551
- return value.map(unpack);
552
- if (Object.hasOwn(value, marker)) {
553
- const tag = value[marker];
554
- if (Object.keys(value).length !== 1 || !Array.isArray(tag) || tag.length !== 2)
555
- refuse(Errors.Invalid.JsonTag);
556
- const [type, data] = tag;
557
- if (type === CodecTag.Bigint && typeof data === "string" && /^-?(0|[1-9]\d*)$/.test(data))
558
- return BigInt(data);
559
- if (type === CodecTag.Bytes && Array.isArray(data) && data.every((v) => Number.isInteger(v) && v >= 0 && v <= 255))
560
- return Uint8Array.from(data);
561
- if (type === CodecTag.Object && Array.isArray(data)) {
562
- if (!data.every((entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string"))
563
- refuse(Errors.Invalid.JsonTag);
564
- return Object.fromEntries(data.map(([key, child]) => [key, unpack(child)]));
565
- }
566
- refuse(Errors.Invalid.JsonTag, "Unknown or malformed portable type tag");
567
- }
568
- return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, unpack(child)]));
569
- }
570
- function utf8(text) {
571
- const output = [];
572
- for (const character of text) {
573
- let point = character.codePointAt(0);
574
- if (point >= 55296 && point <= 57343)
575
- point = 65533;
576
- if (point < 128)
577
- output.push(point);
578
- else if (point < 2048)
579
- output.push(192 | point >> 6, 128 | point & 63);
580
- else if (point < 65536)
581
- output.push(224 | point >> 12, 128 | point >> 6 & 63, 128 | point & 63);
582
- else
583
- output.push(240 | point >> 18, 128 | point >> 12 & 63, 128 | point >> 6 & 63, 128 | point & 63);
584
- }
585
- return Uint8Array.from(output);
586
- }
587
- function text(bytes) {
588
- const output = [];
589
- for (let index = 0;index < bytes.length; ) {
590
- const first = bytes[index++];
591
- if (first < 128) {
592
- output.push(String.fromCharCode(first));
593
- continue;
594
- }
595
- const count = first >= 194 && first <= 223 ? 1 : first >= 224 && first <= 239 ? 2 : first >= 240 && first <= 244 ? 3 : -1;
596
- if (count < 0 || index + count > bytes.length)
597
- refuse(Errors.Invalid.Utf8);
598
- let point = first & 127 >> count + 1;
599
- for (let offset = 0;offset < count; offset++) {
600
- const next = bytes[index++];
601
- if ((next & 192) !== 128)
602
- refuse(Errors.Invalid.Utf8);
603
- point = point << 6 | next & 63;
604
- }
605
- if (point < [0, 128, 2048, 65536][count] || point > 1114111 || point >= 55296 && point <= 57343)
606
- refuse(Errors.Invalid.Utf8);
607
- output.push(String.fromCodePoint(point));
608
- }
609
- return output.join("");
610
- }
611
- var jsonCodec = Object.freeze({
612
- id: CodecId.Json,
613
- serialize: (value) => utf8(JSON.stringify(pack(value, new WeakSet))),
614
- deserialize: (bytes) => unpack(JSON.parse(text(bytes)))
615
- });
1
+ import {
2
+ CodecId
3
+ } from "./chunks/index-kr4x67wt.js";
4
+ import"./chunks/index-c1w7z9hx.js";
5
+ import {
6
+ utf8,
7
+ text
8
+ } from "./chunks/index-sse8aapb.js";
616
9
 
617
10
  // src/codecs/msgpack.ts
11
+ import { decode, encode, ExtensionCodec } from "@msgpack/msgpack";
618
12
  var extensions = new ExtensionCodec;
619
13
  extensions.register({
620
14
  type: 1,
package/dist/node.d.ts CHANGED
@@ -1,14 +1,21 @@
1
1
  import { orb } from "./authoring/orb.ts";
2
+ import { type InterpreterOptions } from "./interpreter/node.ts";
2
3
  import type { HostOptions } from "./authoring/types.ts";
3
4
  import type { KernelPort } from "./bridge/kernel.ts";
4
5
  import { Host } from "./host.ts";
5
6
  export type NodeHostOptions = Omit<HostOptions, "kernel"> & {
6
7
  kernel?: KernelPort;
8
+ isolated?: InterpreterOptions;
7
9
  };
8
- /** Uses the existing Node runtime; it never embeds a second JavaScript engine. */
10
+ /** Configure the ordinary host and lazily create isolated execution for Wasm Orbs. */
9
11
  export declare function createHost(options?: NodeHostOptions): Host;
10
12
  export { orb };
11
13
  export type { Host };
12
14
  export { Code, HookCapability, Lifetime, Reason, ReloadStatus, Status, } from "./bridge/identifiers.ts";
13
15
  export { Errors, type ErrorDescriptor } from "./errors.ts";
16
+ export { HttpHandlerError, type HandleHttpOptions, type HttpHandlerResponse, type IncomingHttpRequest, } from "./interpreter/http-ingress.ts";
17
+ export type { HttpField } from "./interpreter/http-provider.ts";
14
18
  export { ContextKey, ContextKind, opaqueFrom, type OpaqueContextValue } from "./context-key.ts";
19
+ export { directoryFilesystem, type DirectoryFilesystem } from "./interpreter/node.ts";
20
+ export type { InterpreterOptions as IsolatedOptions } from "./interpreter/node.ts";
21
+ export type { Grants, CliOptions } from "./authoring/types.ts";