@arcforge/cognet 2.0.145 → 2.0.147
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.
- package/package.json +3 -3
- package/src/host.ts +22 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcforge/cognet",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.147",
|
|
4
4
|
"description": "A cognitive engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"deploy": "echo \"This package is published ONLY by apps/tui/scripts/release.ts, which pins workspace:* deps to concrete versions first. Publishing it directly ships an unresolvable dependency.\" && exit 1"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@arcforge/err": "2.0.
|
|
21
|
-
"@arcforge/types": "2.0.
|
|
20
|
+
"@arcforge/err": "2.0.147",
|
|
21
|
+
"@arcforge/types": "2.0.147",
|
|
22
22
|
"hookable": "^5.5.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
package/src/host.ts
CHANGED
|
@@ -133,10 +133,30 @@ function run(code: string | string[]) {
|
|
|
133
133
|
return kernelOrThrow().run(code)
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* The `engine` verb, delegating like every other syscall.
|
|
138
|
+
*
|
|
139
|
+
* A FACADE rather than a captured reference, for the same reason the rest of
|
|
140
|
+
* this table delegates: the bound ABI is resolved at the moment a call is
|
|
141
|
+
* made, never at module scope, so nothing here can outlive or precede a
|
|
142
|
+
* load(). Written twice-over as one helper because the two facades below
|
|
143
|
+
* (bound-kernel and ambient) differ only in how they reach the ABI.
|
|
144
|
+
*
|
|
145
|
+
* `has` hangs off the callable so the common case reads as one verb and the
|
|
146
|
+
* degradation check reads as a question — which is the shape the ABI
|
|
147
|
+
* declares, and a shim that flattened it would quietly change the contract.
|
|
148
|
+
*/
|
|
149
|
+
function engineFacade(resolve: () => KernelAbi): KernelAbi["engine"] {
|
|
150
|
+
return Object.assign(
|
|
151
|
+
(role: string) => resolve().engine(role),
|
|
152
|
+
{ has: (role: string) => resolve().engine.has(role) },
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
|
|
136
156
|
// the syscall table, delegating — live from load() onward
|
|
137
157
|
const localKernel = {
|
|
138
158
|
output: (type: keyof AxonOutputEvent, data: never) => kernelOrThrow().output(type, data),
|
|
139
|
-
|
|
159
|
+
engine: engineFacade(() => kernelOrThrow()),
|
|
140
160
|
run,
|
|
141
161
|
scope: () => kernelOrThrow().scope(),
|
|
142
162
|
base: () => kernelOrThrow().base(),
|
|
@@ -164,7 +184,6 @@ const localKernel = {
|
|
|
164
184
|
// A getter, not a captured value: the bound kernel arrives at load(), and
|
|
165
185
|
// capturing this at module scope would freeze an empty map from before
|
|
166
186
|
// the brain was given anything.
|
|
167
|
-
get models() { return kernelOrThrow().models },
|
|
168
187
|
} satisfies KernelAbi
|
|
169
188
|
|
|
170
189
|
/**
|
|
@@ -193,7 +212,7 @@ const localScope: CognetAmbientScope = scopeFor(null)
|
|
|
193
212
|
globals.loop = (body: LoopBody): void => ambientOrThrow().loop(body)
|
|
194
213
|
globals.kernel = {
|
|
195
214
|
output: (type: keyof AxonOutputEvent, data: never) => ambientOrThrow().kernel.output(type, data),
|
|
196
|
-
|
|
215
|
+
engine: engineFacade(() => ambientOrThrow().kernel),
|
|
197
216
|
run: ((code: string | string[]) => ambientOrThrow().kernel.run(code as never)) as KernelAbi["run"],
|
|
198
217
|
scope: () => ambientOrThrow().kernel.scope(),
|
|
199
218
|
base: () => ambientOrThrow().kernel.base(),
|
|
@@ -216,7 +235,6 @@ globals.kernel = {
|
|
|
216
235
|
// that outlives each wake, which is exactly what a driver needs.
|
|
217
236
|
wake: () => kernelOrThrow().wake(),
|
|
218
237
|
clock: () => kernelOrThrow().clock(),
|
|
219
|
-
get models() { return kernelOrThrow().models },
|
|
220
238
|
} satisfies KernelAbi
|
|
221
239
|
|
|
222
240
|
globals.phase = <T>(name: string, fn: () => Promise<T>) => ambientOrThrow().phase(name, fn)
|