@arcforge/kernel 2.0.120 → 2.0.122
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 +8 -8
- package/src/kernel.ts +23 -7
- package/src/scheduler/wake.ts +12 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcforge/kernel",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.122",
|
|
4
4
|
"description": "The Axon kernel — ring 0. Owns resources and execution, enforces policy, and is the only constructor of the unprivileged capsule.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"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"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@arcforge/air": "2.0.
|
|
19
|
-
"@arcforge/engines": "2.0.
|
|
20
|
-
"@arcforge/err": "2.0.
|
|
21
|
-
"@arcforge/session": "2.0.
|
|
22
|
-
"@arcforge/types": "2.0.
|
|
23
|
-
"@arclabs/cloud": "2.0.
|
|
24
|
-
"@axon/capsule": "2.0.
|
|
18
|
+
"@arcforge/air": "2.0.122",
|
|
19
|
+
"@arcforge/engines": "2.0.122",
|
|
20
|
+
"@arcforge/err": "2.0.122",
|
|
21
|
+
"@arcforge/session": "2.0.122",
|
|
22
|
+
"@arcforge/types": "2.0.122",
|
|
23
|
+
"@arclabs/cloud": "2.0.122",
|
|
24
|
+
"@axon/capsule": "2.0.122"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/bun": "latest",
|
package/src/kernel.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { err } from "@arcforge/err"
|
|
2
|
-
import type { AxonBlueprint, AxonEngineCall, AxonEngineEvent, AxonEntry, AxonEntryEvent, AxonEventMap, AxonRunResult, KernelAbi } from "@arcforge/types"
|
|
2
|
+
import type { AxonBlueprint, AxonEngineCall, AxonEngineEvent, AxonEntry, AxonEntryEvent, AxonEventMap, AxonRunResult, CapsuleCommandOrigin, KernelAbi } from "@arcforge/types"
|
|
3
3
|
import { EMPTY_CAPSULE_SCOPE } from "@arcforge/types"
|
|
4
4
|
import type { AxonCloudClient } from "@arclabs/cloud"
|
|
5
5
|
import type { KernelBus } from "./contracts"
|
|
@@ -75,6 +75,15 @@ function formatValue(value: unknown): string {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* What a caller may say about a capsule execution.
|
|
80
|
+
*
|
|
81
|
+
* `origin` is provenance, never privilege — see CapsuleCommandOrigin. The
|
|
82
|
+
* cognet path never sets it (absent means "cognet"); only a developer
|
|
83
|
+
* surface executing code against a live agent does.
|
|
84
|
+
*/
|
|
85
|
+
export type RunOptions = { signal?: AbortSignal; origin?: CapsuleCommandOrigin }
|
|
86
|
+
|
|
78
87
|
/**
|
|
79
88
|
* Run one block against the capsule and normalize the outcome — the ABI
|
|
80
89
|
* boundary this seam exists for. Exec() below (capsule's own contract)
|
|
@@ -88,7 +97,7 @@ function formatValue(value: unknown): string {
|
|
|
88
97
|
* output back as part of the result reads `stdout` here, no callback wired
|
|
89
98
|
* by hand.
|
|
90
99
|
*/
|
|
91
|
-
async function runOne(capsule: AxonCapsuleT, code: string, opts?: { signal?: AbortSignal; id?: string }): Promise<AxonRunResult> {
|
|
100
|
+
async function runOne(capsule: AxonCapsuleT, code: string, opts?: { signal?: AbortSignal; id?: string; origin?: CapsuleCommandOrigin }): Promise<AxonRunResult> {
|
|
92
101
|
const stdout: string[] = []
|
|
93
102
|
const onConsole = (level: string, args: unknown[]) => {
|
|
94
103
|
const line = args.map(a => (typeof a === "string" ? a : JSON.stringify(a))).join(" ")
|
|
@@ -99,7 +108,7 @@ async function runOne(capsule: AxonCapsuleT, code: string, opts?: { signal?: Abo
|
|
|
99
108
|
// exec() rather than run(): the bindings come back alongside the
|
|
100
109
|
// value, so a cognet rendering a template from the same turn has
|
|
101
110
|
// something to interpolate against.
|
|
102
|
-
const { value, scope } = await capsule.current.exec(code, { onConsole, signal: opts?.signal, id: opts?.id })
|
|
111
|
+
const { value, scope } = await capsule.current.exec(code, { onConsole, signal: opts?.signal, id: opts?.id, origin: opts?.origin })
|
|
103
112
|
return { ok: true, value, stdout, scope }
|
|
104
113
|
} catch (cause) {
|
|
105
114
|
const interrupted = opts?.signal?.aborted || (cause instanceof Error && cause.name === "AbortError")
|
|
@@ -186,10 +195,17 @@ export async function Kernel(opts: KernelOpts) {
|
|
|
186
195
|
session: session,
|
|
187
196
|
})
|
|
188
197
|
|
|
189
|
-
/**
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
198
|
+
/**
|
|
199
|
+
* One block or many (concurrent, Promise.all-shaped) — always resolves.
|
|
200
|
+
*
|
|
201
|
+
* `origin` marks who asked. It defaults to the agent's own reasoning and
|
|
202
|
+
* is only ever set by a developer-facing caller (Fleet's capsule input),
|
|
203
|
+
* which changes nothing about how the code executes — same path, same
|
|
204
|
+
* policy gate — and everything about how the session log reads it back.
|
|
205
|
+
*/
|
|
206
|
+
function run(code: string, runOpts?: RunOptions): Promise<AxonRunResult>
|
|
207
|
+
function run(code: string[], runOpts?: RunOptions): Promise<AxonRunResult[]>
|
|
208
|
+
function run(code: string | string[], runOpts?: RunOptions): Promise<AxonRunResult> | Promise<AxonRunResult[]> {
|
|
193
209
|
if (Array.isArray(code)) return Promise.all(code.map(c => runOne(capsule, c, runOpts)))
|
|
194
210
|
return runOne(capsule, code, runOpts)
|
|
195
211
|
}
|
package/src/scheduler/wake.ts
CHANGED
|
@@ -13,11 +13,20 @@ type WakeOpts = {
|
|
|
13
13
|
abort: AbortController
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Entry vocabulary — the families are defined WITH AxonEntryEvent, never
|
|
18
|
+
* duplicated here.
|
|
19
|
+
*
|
|
20
|
+
* Shape-checked on `type` and `time.seq`, which is every enveloped event's
|
|
21
|
+
* identity (see AxonEvent). This used to require a string `id`; when that
|
|
22
|
+
* field was removed from the envelope the predicate rejected every entry
|
|
23
|
+
* ever emitted, and a wake produced no output at all — a reminder that a
|
|
24
|
+
* structural guard is only as correct as the shape it was written against.
|
|
25
|
+
*/
|
|
17
26
|
function isEntry(event: unknown): event is AxonEntry {
|
|
18
27
|
if (typeof event !== "object" || event === null) return false
|
|
19
|
-
const e = event as { type?: string;
|
|
20
|
-
if (typeof e.type !== "string" || typeof e.
|
|
28
|
+
const e = event as { type?: string; time?: { seq?: number } }
|
|
29
|
+
if (typeof e.type !== "string" || typeof e.time?.seq !== "number") return false
|
|
21
30
|
return ENTRY_EVENT_PREFIXES.some(prefix => (e.type as string).startsWith(prefix))
|
|
22
31
|
}
|
|
23
32
|
|