@arcforge/cognet 2.0.160 → 2.0.162
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 +29 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcforge/cognet",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.162",
|
|
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.162",
|
|
21
|
+
"@arcforge/types": "2.0.162",
|
|
22
22
|
"hookable": "^5.5.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
package/src/host.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hookable } from "hookable"
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks"
|
|
3
3
|
import { err } from "@arcforge/err"
|
|
4
|
-
import type { AxonRunResult, CognetConfig, CognetDefinition, CognetHooks, CognetPlugin, CognetWake, KernelAbi } from "@arcforge/types"
|
|
4
|
+
import type { AxonRunResult, CognetConfig, CognetIdentity, CognetDefinition, CognetHooks, CognetPlugin, CognetWake, KernelAbi } from "@arcforge/types"
|
|
5
5
|
import type { AxonOutputEvent } from "@arcforge/types"
|
|
6
6
|
import { Clock } from "./clock"
|
|
7
7
|
|
|
@@ -246,8 +246,23 @@ globals.system = <T>(name: string, fn: () => Promise<T>) => ambientOrThrow().sys
|
|
|
246
246
|
* config + wrapped main → the definition the kernel loads. main() runs once
|
|
247
247
|
* at load(), with kernel already bound — its module/closure scope is the
|
|
248
248
|
* brain's resident RAM. It must declare exactly one loop().
|
|
249
|
+
*
|
|
250
|
+
* `config` here is NOT the author's cognet.config.ts. The compile step builds
|
|
251
|
+
* it: the author's declarations (mode, wakeOn, engines) merged with identity
|
|
252
|
+
* it resolved itself — name and version from the cognet's package.json, the
|
|
253
|
+
* ABI from the kernel it compiled against unless the config pinned one. The
|
|
254
|
+
* author writes none of those three, which is why CognetConfig no longer has
|
|
255
|
+
* a place to put them.
|
|
256
|
+
*
|
|
257
|
+
* Deliberately still TWO arguments. This is a published package's public
|
|
258
|
+
* surface, and a compiled bundle inlines whichever copy of it the agent has
|
|
259
|
+
* installed. Widening the signature would mean a new CLI emitting a call an
|
|
260
|
+
* older installed host cannot answer — the arguments shift by one, `main`
|
|
261
|
+
* lands in `config`, and the brain dies at load() calling an object. Passing
|
|
262
|
+
* identity through the object keeps old and new hosts compatible with both
|
|
263
|
+
* old and new entries.
|
|
249
264
|
*/
|
|
250
|
-
export function CognetHost(config:
|
|
265
|
+
export function CognetHost(config: CognetIdentity, main: () => Promise<void>): CognetDefinition {
|
|
251
266
|
return {
|
|
252
267
|
...config,
|
|
253
268
|
|
|
@@ -261,7 +276,18 @@ export function CognetHost(config: CognetConfig, main: () => Promise<void>): Cog
|
|
|
261
276
|
}
|
|
262
277
|
boundKernel = abi
|
|
263
278
|
try {
|
|
264
|
-
|
|
279
|
+
// The brain's own code, running for the first time. Anything
|
|
280
|
+
// it throws is classified HERE rather than escaping raw: a
|
|
281
|
+
// cognet is authored source, so an uncoded throw from it is
|
|
282
|
+
// the ORDINARY case, and letting it surface as an
|
|
283
|
+
// unclassified error told the author only that something
|
|
284
|
+
// failed somewhere. The cause is preserved — this names the
|
|
285
|
+
// boundary the failure crossed, it does not replace it.
|
|
286
|
+
try {
|
|
287
|
+
await ambientStorage.run(localScope, main) // declares loop(); plugins already registered at import time
|
|
288
|
+
} catch (cause) {
|
|
289
|
+
throw err("COGNET_LOAD_FAILED", { cause, context: { name: config.name, version: config.version } })
|
|
290
|
+
}
|
|
265
291
|
if (!registered) {
|
|
266
292
|
throw err("COGNET_NO_LOOP", { detail: `${config.name} ran main() without declaring loop()`, context: { name: config.name } })
|
|
267
293
|
}
|