@syntropika/tembra-sdk 0.2.2 → 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 -3332
  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 -3310
  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 -3321
  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 +7 -6
  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 +213 -90
  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 -301
@@ -0,0 +1,92 @@
1
+ /**
2
+ * WIT `u64`/`s64` on the portable executor wire: JavaScript sees `bigint`, the wire carries a
3
+ * canonical decimal JSON string, and only a position that WIT types as `u64`/`s64` is ever read
4
+ * that way (a WIT `string` stays a string). This module holds the parts shared by the hardened
5
+ * host capture, the host lift and the guest conversion:
6
+ * - the strict integer helpers;
7
+ * - `Shape`: where 64-bit values occur in one WIT type, compiled once per prepared function;
8
+ * - `lift`: restoring `bigint` in data parsed from already checked text.
9
+ * It has no imports and no state, so the guest bootstrap bundles it as is. It is not a WIT
10
+ * validator: the Rust contract still checks every value in full.
11
+ */
12
+ export type IntegerKind = "u64" | "s64";
13
+ /** Whether `value` is a bigint primitive within the range of `kind`. */
14
+ export declare function isInteger(kind: IntegerKind, value: unknown): value is bigint;
15
+ /** Canonical wire text of a `bigint`; every other JavaScript kind is refused. */
16
+ export declare function integerText(kind: IntegerKind, value: unknown): string;
17
+ /** The `bigint` of canonical wire text; anything else is refused. */
18
+ export declare function integerValue(kind: IntegerKind, text: unknown): bigint;
19
+ /** Where 64-bit values occur in one WIT type; `undefined` means none below this point. */
20
+ export type Shape = IntegerKind | {
21
+ readonly list: Shape;
22
+ }
23
+ /** Record fields by JavaScript name; every field is present, 64-bit-free ones as `undefined`. */
24
+ | {
25
+ readonly fields: ReadonlyMap<string, Shape | undefined>;
26
+ }
27
+ /** Tuples and argument lists. */
28
+ | {
29
+ readonly items: readonly (Shape | undefined)[];
30
+ } | {
31
+ readonly option: Shape;
32
+ }
33
+ /** Variant and result payloads by case name; every case is present. */
34
+ | {
35
+ readonly cases: ReadonlyMap<string, Shape | undefined>;
36
+ };
37
+ /** Argument list and result shapes of one prepared function. */
38
+ export interface Signature {
39
+ readonly params: Shape | undefined;
40
+ readonly result: Shape | undefined;
41
+ }
42
+ type WitType = string | number | null | undefined;
43
+ interface WitKind {
44
+ type?: WitType;
45
+ list?: WitType;
46
+ option?: WitType;
47
+ record?: {
48
+ fields: {
49
+ name: string;
50
+ type: WitType;
51
+ }[];
52
+ };
53
+ tuple?: {
54
+ types: WitType[];
55
+ };
56
+ variant?: {
57
+ cases: {
58
+ name: string;
59
+ type?: WitType;
60
+ }[];
61
+ };
62
+ result?: {
63
+ ok?: WitType;
64
+ err?: WitType;
65
+ };
66
+ }
67
+ /** The parts of the contract's `describe` answer this module reads. */
68
+ export interface WitTypes {
69
+ readonly javascriptNames: Readonly<Record<string, string>>;
70
+ readonly types: readonly {
71
+ readonly id: number;
72
+ readonly definition: {
73
+ kind: WitKind | string;
74
+ };
75
+ }[];
76
+ }
77
+ export interface WitFunction {
78
+ readonly params: readonly {
79
+ readonly name: string;
80
+ readonly type: WitType;
81
+ }[];
82
+ readonly result?: WitType;
83
+ }
84
+ /** Compile function signatures against one contract graph; compiled types are memoized. */
85
+ export declare function shapes(graph: WitTypes): (fn: WitFunction) => Signature;
86
+ /**
87
+ * Restore `bigint` positions in data parsed from text the Rust contract already checked. Shaped
88
+ * containers are copied, never updated in place, so the caller's parsed data stays wire form;
89
+ * lists of 64-bit values become arrays of `bigint`.
90
+ */
91
+ export declare function lift(shape: Shape | undefined, value: unknown): unknown;
92
+ export {};
package/dist/manager.js CHANGED
@@ -1,334 +1,7 @@
1
- // src/bridge/identifiers.ts
2
- var Code = Object.freeze({
3
- Invalid: "invalid",
4
- Unavailable: "unavailable",
5
- Released: "released",
6
- Gone: "gone",
7
- Expired: "expired",
8
- Cancelled: "cancelled",
9
- Forbidden: "forbidden",
10
- Conflict: "conflict",
11
- Unsupported: "unsupported",
12
- Closed: "closed",
13
- Exhausted: "exhausted"
14
- });
15
- var Reason = Object.freeze({
16
- ActivationBusy: "activation_busy",
17
- Address: "address",
18
- AlreadyCommitted: "already_committed",
19
- AmbiguousScope: "ambiguous_scope",
20
- ApiVersion: "api_version",
21
- Arguments: "arguments",
22
- AsyncFactory: "async_factory",
23
- AsyncState: "async_state",
24
- Bigint: "bigint",
25
- ByteResult: "byte_result",
26
- Call: "call",
27
- Callback: "callback",
28
- CleanupBusy: "cleanup_busy",
29
- Clock: "clock",
30
- Codec: "codec",
31
- Connection: "connection",
32
- Context: "context",
33
- Contribution: "contribution",
34
- CoordinationLimits: "coordination_limits",
35
- Deadline: "deadline",
36
- Dependency: "dependency",
37
- DependencyCycle: "dependency_cycle",
38
- DependencyService: "dependency_service",
39
- Disposing: "disposing",
40
- Driver: "driver",
41
- Duplicate: "duplicate",
42
- DuplicateContribution: "duplicate_contribution",
43
- DuplicateListener: "duplicate_listener",
44
- DuplicateResource: "duplicate_resource",
45
- DuplicateService: "duplicate_service",
46
- EffectResults: "effect_results",
47
- EffectsRunning: "effects_running",
48
- EngineEffect: "engine_effect",
49
- EventSource: "event_source",
50
- ExclusiveDependent: "exclusive_dependent",
51
- Executor: "executor",
52
- Orb: "orb",
53
- OrbGone: "orb_gone",
54
- OrbInstalled: "orb_installed",
55
- OrbScope: "orb_scope",
56
- Factory: "factory",
57
- FactoryExpired: "factory_expired",
58
- FrameSize: "frame_size",
59
- GateBusy: "gate_busy",
60
- GateOrb: "gate_orb",
61
- GateObject: "gate_object",
62
- Hook: "hook",
63
- HookDependency: "hook_dependency",
64
- Hooks: "hooks",
65
- HooksDisabled: "hooks_disabled",
66
- Host: "host",
67
- HostAddress: "host_address",
68
- HostResource: "host_resource",
69
- HostResourceReload: "host_resource_reload",
70
- Identities: "identities",
71
- Implementation: "implementation",
72
- Invocation: "invocation",
73
- Javascript: "javascript",
74
- JsonAccessor: "json_accessor",
75
- JsonCycle: "json_cycle",
76
- JsonNumber: "json_number",
77
- JsonSymbol: "json_symbol",
78
- JsonTag: "json_tag",
79
- JsonType: "json_type",
80
- JsonValue: "json_value",
81
- Lifetime: "lifetime",
82
- Linger: "linger",
83
- ListenerCallback: "listener_callback",
84
- LiveConsumer: "live_consumer",
85
- LiveReference: "live_reference",
86
- LocalValue: "local_value",
87
- Memory: "memory",
88
- Metadata: "metadata",
89
- MetadataSize: "metadata_size",
90
- Method: "method",
91
- MigrationGate: "migration_gate",
92
- MigrationRequired: "migration_required",
93
- MigrationValue: "migration_value",
94
- MissingHook: "missing_hook",
95
- MissingMethod: "missing_method",
96
- NativeEffect: "native_effect",
97
- NativeMethod: "native_method",
98
- NativeObject: "native_object",
99
- NativeService: "native_service",
100
- Next: "next",
101
- NextUsed: "next_used",
102
- NotReady: "not_ready",
103
- Object: "object",
104
- ObjectState: "object_state",
105
- ObservationSource: "observation_source",
106
- ObservationAdmitted: "observation_admitted",
107
- Opaque: "opaque",
108
- Operation: "operation",
109
- OperationOwner: "operation_owner",
110
- Owner: "owner",
111
- Payload: "payload",
112
- PendingRequests: "pending_requests",
113
- PrepareDeadline: "prepare_deadline",
114
- Priority: "priority",
115
- Program: "program",
116
- ProgramPhase: "program_phase",
117
- ProgramRunning: "program_running",
118
- Reference: "reference",
119
- ReloadAborted: "reload_aborted",
120
- ReloadDeadline: "reload_deadline",
121
- ReloadPreparing: "reload_preparing",
122
- ReloadRunning: "reload_running",
123
- ReloadTicket: "reload_ticket",
124
- RemoteOpaque: "remote_opaque",
125
- RemoteReferences: "remote_references",
126
- Request: "request",
127
- RequestIds: "request_ids",
128
- Requires: "requires",
129
- Resource: "resource",
130
- ResourceDependencies: "resource_dependencies",
131
- ResourceDependency: "resource_dependency",
132
- ResourceHost: "resource_host",
133
- ResourceInFactory: "resource_in_factory",
134
- ResourceState: "resource_state",
135
- ResourceVersion: "resource_version",
136
- Result: "result",
137
- RetainedVersions: "retained_versions",
138
- RevisionExhausted: "revision_exhausted",
139
- Root: "root",
140
- Route: "route",
141
- RpcFrame: "rpc_frame",
142
- RpcOperation: "rpc_operation",
143
- RpcRequest: "rpc_request",
144
- RustType: "rust_type",
145
- Scope: "scope",
146
- ScopeClosed: "scope_closed",
147
- ScopeOrb: "scope_orb",
148
- ScopeOwner: "scope_owner",
149
- ScopeResource: "scope_resource",
150
- Serialization: "serialization",
151
- Service: "service",
152
- ServiceGone: "service_gone",
153
- State: "state",
154
- StateCycle: "state_cycle",
155
- StateInitialized: "state_initialized",
156
- StateOwner: "state_owner",
157
- StateRevision: "state_revision",
158
- StateValidation: "state_validation",
159
- StateValue: "state_value",
160
- StateVersion: "state_version",
161
- Subscription: "subscription",
162
- SubscriptionBusy: "subscription_busy",
163
- SubscriptionIdle: "subscription_idle",
164
- SubscriptionQueue: "subscription_queue",
165
- SubscriptionSize: "subscription_size",
166
- SubscriptionsDisabled: "subscriptions_disabled",
167
- Superseded: "superseded",
168
- Task: "task",
169
- Telemetry: "telemetry",
170
- UndeclaredDependency: "undeclared_dependency",
171
- UndeclaredService: "undeclared_service",
172
- UnknownService: "unknown_service",
173
- UpgradeConflict: "upgrade_conflict",
174
- Utf8: "utf8",
175
- Value: "value",
176
- ValueGone: "value_gone",
177
- ValuesExhausted: "values_exhausted",
178
- Views: "views"
179
- });
180
- var Lifetime = Object.freeze({
181
- Referenced: "referenced",
182
- Host: "host"
183
- });
184
- var Status = Object.freeze({
185
- Loading: "loading",
186
- Live: "live",
187
- Released: "released",
188
- Gone: "gone"
189
- });
190
- var ReloadStatus = Object.freeze({
191
- Prepared: "prepared",
192
- Committed: "committed",
193
- Aborted: "aborted"
194
- });
195
- var HookCapability = Object.freeze({
196
- Observe: "observe",
197
- Transform: "transform",
198
- Decide: "decide"
199
- });
200
-
201
- // src/errors.ts
202
- function define(code, reason, message) {
203
- return Object.freeze({ code, reason, message });
204
- }
205
- var Errors = Object.freeze({
206
- Cancelled: Object.freeze({
207
- EngineEffect: define(Code.Cancelled, Reason.EngineEffect, "The engine effect was cancelled"),
208
- Request: define(Code.Cancelled, Reason.Request, "The request was cancelled"),
209
- Resource: define(Code.Cancelled, Reason.Resource, "Resource opening was cancelled"),
210
- Root: define(Code.Cancelled, Reason.Root, "The operation was cancelled"),
211
- Task: define(Code.Cancelled, Reason.Task, "The task was cancelled")
212
- }),
213
- Closed: Object.freeze({
214
- Host: define(Code.Closed, Reason.Host, "The host is closing")
215
- }),
216
- Conflict: Object.freeze({
217
- AlreadyCommitted: define(Code.Conflict, Reason.AlreadyCommitted, "The replacement is already committed"),
218
- Codec: define(Code.Conflict, Reason.Codec, "The Rust and JS host codecs must agree"),
219
- PrepareDeadline: define(Code.Conflict, Reason.PrepareDeadline, "The preparation deadline expired"),
220
- ReloadRunning: define(Code.Conflict, Reason.ReloadRunning, "A replacement is already running"),
221
- ReloadTicket: define(Code.Conflict, Reason.ReloadTicket, "The replacement is no longer prepared")
222
- }),
223
- Exhausted: Object.freeze({
224
- FrameSize: define(Code.Exhausted, Reason.FrameSize, "The frame exceeds the configured size limit"),
225
- PendingRequests: define(Code.Exhausted, Reason.PendingRequests, "The pending request limit was reached"),
226
- RemoteReferences: define(Code.Exhausted, Reason.RemoteReferences, "The remote reference limit was reached"),
227
- RequestIds: define(Code.Exhausted, Reason.RequestIds, "Request identities are exhausted"),
228
- SubscriptionQueue: define(Code.Exhausted, Reason.SubscriptionQueue, "The subscription queue is full")
229
- }),
230
- Expired: Object.freeze({
231
- Next: define(Code.Expired, Reason.Next, "Continuation scope has ended")
232
- }),
233
- Forbidden: Object.freeze({
234
- Context: define(Code.Forbidden, Reason.Context, "An issued context from this host is required"),
235
- HostResource: define(Code.Forbidden, Reason.HostResource, "The host resource was not declared"),
236
- Method: define(Code.Forbidden, Reason.Method, "The method is not allowed by this reference"),
237
- ObservationSource: define(Code.Forbidden, Reason.ObservationSource, "Hook observation requires the original physical invocation"),
238
- Opaque: define(Code.Forbidden, Reason.Opaque, "The resource is not available as an opaque local value"),
239
- Service: define(Code.Forbidden, Reason.Service, "Access to this service is forbidden"),
240
- StateOwner: define(Code.Forbidden, Reason.StateOwner, "Only the owning orb may change this state"),
241
- UndeclaredDependency: define(Code.Forbidden, Reason.UndeclaredDependency, "The dependency was not declared"),
242
- UndeclaredService: define(Code.Forbidden, Reason.UndeclaredService, "The service was not declared as a dependency")
243
- }),
244
- Gone: Object.freeze({
245
- Connection: define(Code.Gone, Reason.Connection, "The connection is closed"),
246
- Contribution: define(Code.Gone, Reason.Contribution, "The contribution is no longer available"),
247
- Implementation: define(Code.Gone, Reason.Implementation, "The implementation is no longer available"),
248
- ListenerCallback: define(Code.Gone, Reason.ListenerCallback, "The listener callback is no longer available"),
249
- Reference: define(Code.Gone, Reason.Reference, "The reference is no longer available"),
250
- Resource: define(Code.Gone, Reason.Resource, "The resource is no longer available"),
251
- Scope: define(Code.Gone, Reason.Scope, "The declaration scope is no longer available"),
252
- State: define(Code.Gone, Reason.State, "State owner is gone")
253
- }),
254
- Invalid: Object.freeze({
255
- Address: define(Code.Invalid, Reason.Address, "Invalid address"),
256
- AsyncFactory: define(Code.Invalid, Reason.AsyncFactory, "Factories must be synchronous"),
257
- AsyncState: define(Code.Invalid, Reason.AsyncState, "State updates and migrations must be synchronous"),
258
- CoordinationLimits: define(Code.Invalid, Reason.CoordinationLimits, "Invalid coordination limits"),
259
- DependencyCycle: define(Code.Invalid, Reason.DependencyCycle, "Orb factories cannot acquire their own services"),
260
- DependencyService: define(Code.Invalid, Reason.DependencyService, "Invalid dependency service"),
261
- DuplicateListener: define(Code.Invalid, Reason.DuplicateListener, "Invalid duplicate listener"),
262
- DuplicateResource: define(Code.Invalid, Reason.DuplicateResource, "Invalid duplicate resource"),
263
- EventSource: define(Code.Invalid, Reason.EventSource, "Invalid event source"),
264
- Orb: define(Code.Invalid, Reason.Orb, "An orb needs a name and positive API version"),
265
- OrbGone: define(Code.Invalid, Reason.OrbGone, "Invalid orb gone"),
266
- OrbInstalled: define(Code.Invalid, Reason.OrbInstalled, "Use reload to replace an installed orb"),
267
- Factory: define(Code.Invalid, Reason.Factory, "Invalid factory"),
268
- FactoryExpired: define(Code.Invalid, Reason.FactoryExpired, "Declarations must be synchronous"),
269
- Hook: define(Code.Invalid, Reason.Hook, "Hooks need a run function"),
270
- HookDependency: define(Code.Invalid, Reason.HookDependency, "Invalid hook dependency"),
271
- HooksDisabled: define(Code.Invalid, Reason.HooksDisabled, "Invalid hooks disabled"),
272
- JsonAccessor: define(Code.Invalid, Reason.JsonAccessor, "Invalid json accessor"),
273
- JsonCycle: define(Code.Invalid, Reason.JsonCycle, "Invalid json cycle"),
274
- JsonNumber: define(Code.Invalid, Reason.JsonNumber, "Use BigInt for integers outside the safe Number range"),
275
- JsonSymbol: define(Code.Invalid, Reason.JsonSymbol, "Invalid json symbol"),
276
- JsonTag: define(Code.Invalid, Reason.JsonTag, "Unknown or malformed portable type tag"),
277
- JsonType: define(Code.Invalid, Reason.JsonType, "Supply a codec for custom object types"),
278
- JsonValue: define(Code.Invalid, Reason.JsonValue, "This JSON codec requires explicit portable values"),
279
- Method: define(Code.Invalid, Reason.Method, "Methods must be functions"),
280
- NextUsed: define(Code.Invalid, Reason.NextUsed, "Invalid next used"),
281
- Priority: define(Code.Invalid, Reason.Priority, "Invalid priority"),
282
- Reference: define(Code.Invalid, Reason.Reference, "An issued local reference is required"),
283
- Resource: define(Code.Invalid, Reason.Resource, "Invalid resource"),
284
- ResourceHost: define(Code.Invalid, Reason.ResourceHost, "Resource dependencies must belong to the same host"),
285
- ResourceInFactory: define(Code.Invalid, Reason.ResourceInFactory, "Resources open after declaration"),
286
- RpcFrame: define(Code.Invalid, Reason.RpcFrame, "Invalid rpc frame"),
287
- RpcOperation: define(Code.Invalid, Reason.RpcOperation, "Invalid rpc operation"),
288
- RpcRequest: define(Code.Invalid, Reason.RpcRequest, "Invalid rpc request"),
289
- Service: define(Code.Invalid, Reason.Service, "Invalid service"),
290
- ServiceGone: define(Code.Invalid, Reason.ServiceGone, "Invalid service gone"),
291
- State: define(Code.Invalid, Reason.State, "Service does not expose state"),
292
- StateCycle: define(Code.Invalid, Reason.StateCycle, "State cannot contain cycles"),
293
- StateValidation: define(Code.Invalid, Reason.StateValidation, "The orb rejected the state candidate"),
294
- StateValue: define(Code.Invalid, Reason.StateValue, "State cannot contain accessors"),
295
- StateVersion: define(Code.Invalid, Reason.StateVersion, "Invalid state version"),
296
- SubscriptionsDisabled: define(Code.Invalid, Reason.SubscriptionsDisabled, "Invalid subscriptions disabled"),
297
- SubscriptionSize: define(Code.Invalid, Reason.SubscriptionSize, "A local byte budget requires an explicit sizeOf function"),
298
- Task: define(Code.Invalid, Reason.Task, "Invalid task"),
299
- Utf8: define(Code.Invalid, Reason.Utf8, "Invalid utf8"),
300
- ValueGone: define(Code.Invalid, Reason.ValueGone, "Invalid value gone"),
301
- ValuesExhausted: define(Code.Invalid, Reason.ValuesExhausted, "Invalid values exhausted")
302
- }),
303
- Released: Object.freeze({
304
- Reference: define(Code.Released, Reason.Reference, "The reference has been released")
305
- }),
306
- Unavailable: Object.freeze({
307
- Callback: define(Code.Unavailable, Reason.Callback, "A callback failed"),
308
- OrbScope: define(Code.Unavailable, Reason.OrbScope, "The orb scope is unavailable"),
309
- NotReady: define(Code.Unavailable, Reason.NotReady, "The object is not ready"),
310
- Route: define(Code.Unavailable, Reason.Route, "The route is unavailable")
311
- }),
312
- Unsupported: Object.freeze({
313
- EngineEffect: define(Code.Unsupported, Reason.EngineEffect, "The engine effect is not supported by this adapter"),
314
- RemoteOpaque: define(Code.Unsupported, Reason.RemoteOpaque, "Opaque resources are local to their language environment"),
315
- Telemetry: define(Code.Unsupported, Reason.Telemetry, "Telemetry is disabled in this kernel"),
316
- Views: define(Code.Unsupported, Reason.Views, "Reference views are disabled in this kernel")
317
- })
318
- });
319
-
320
- // src/error.ts
321
- var codes = new Set(Object.values(Code));
322
- class TembraError extends Error {
323
- code;
324
- reason;
325
- constructor(error, message = error.message, options) {
326
- super(message, options);
327
- this.name = "TembraError";
328
- this.code = error.code;
329
- this.reason = error.reason;
330
- }
331
- }
1
+ import {
2
+ Errors2,
3
+ TembraError2
4
+ } from "./chunks/index-c1w7z9hx.js";
332
5
 
333
6
  // src/infrastructure/manager.ts
334
7
  class HostManager {
@@ -379,7 +52,7 @@ function router(hosts, route) {
379
52
  const name = route(service, typeof key === "string" ? [key] : key);
380
53
  const host = hosts.get(name);
381
54
  if (!host)
382
- throw new TembraError(Errors.Unavailable.Route, name);
55
+ throw new TembraError2(Errors2.Unavailable.Route, name);
383
56
  return host.get(service, key, options);
384
57
  }
385
58
  };