@arcforge/kernel 2.0.181 → 2.0.182
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 +50 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcforge/kernel",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.182",
|
|
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
|
-
"@arcforge/cloud": "2.0.
|
|
24
|
-
"@arcforge/capsule": "2.0.
|
|
18
|
+
"@arcforge/air": "2.0.182",
|
|
19
|
+
"@arcforge/engines": "2.0.182",
|
|
20
|
+
"@arcforge/err": "2.0.182",
|
|
21
|
+
"@arcforge/session": "2.0.182",
|
|
22
|
+
"@arcforge/types": "2.0.182",
|
|
23
|
+
"@arcforge/cloud": "2.0.182",
|
|
24
|
+
"@arcforge/capsule": "2.0.182"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/bun": "latest",
|
package/src/kernel.ts
CHANGED
|
@@ -208,6 +208,40 @@ function interruptedResult(reason: unknown): AxonRunResult {
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* The Codex text channel occasionally leaks a fragment of a different tool
|
|
213
|
+
* protocol into the beginning of an otherwise valid AIR <script> body:
|
|
214
|
+
*
|
|
215
|
+
* tagger to=fs.read …
|
|
216
|
+
* <![CDATA[
|
|
217
|
+
*
|
|
218
|
+
* AIR has correctly parsed the OUTER block by this point, but neither prefix
|
|
219
|
+
* is TypeScript. Sending it to the capsule records it as an ordinary action,
|
|
220
|
+
* then feeds the poisoned source and its parse error back into the next model
|
|
221
|
+
* context. That turns one bad completion into a long-session copying loop.
|
|
222
|
+
*
|
|
223
|
+
* This is deliberately a narrow quarantine, not a second TypeScript parser.
|
|
224
|
+
* Bun remains the authority on whether ordinary source is valid; these are
|
|
225
|
+
* transport/control preambles which cannot be meaningful Axon scripts.
|
|
226
|
+
*/
|
|
227
|
+
function scriptControlPreamble(code: string): "tagger" | "cdata" | undefined {
|
|
228
|
+
const first = code.trimStart()
|
|
229
|
+
if (/^<!\[CDATA\[/i.test(first)) return "cdata"
|
|
230
|
+
if (/^tagger(?:\s|$)/i.test(first)) return "tagger"
|
|
231
|
+
return undefined
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function scriptControlCorrection(kind: "tagger" | "cdata"): string {
|
|
235
|
+
const leaked = kind === "tagger" ? "provider routing text (for example `tagger to=…`)" : "a CDATA wrapper"
|
|
236
|
+
return [
|
|
237
|
+
"## Script not run",
|
|
238
|
+
"",
|
|
239
|
+
`The previous script began with ${leaked}, not TypeScript. It was rejected before execution.`,
|
|
240
|
+
"",
|
|
241
|
+
"Emit only TypeScript inside `<script>`: no provider routing text, CDATA, XML, JSON labels, or other preamble before the first TypeScript token.",
|
|
242
|
+
].join("\n")
|
|
243
|
+
}
|
|
244
|
+
|
|
211
245
|
/**
|
|
212
246
|
* Run one block against the capsule and normalize the outcome — the ABI
|
|
213
247
|
* boundary this seam exists for. Exec() below (capsule's own contract)
|
|
@@ -536,6 +570,22 @@ export async function Kernel(opts: KernelOpts) {
|
|
|
536
570
|
// not appear in the log as one that did.
|
|
537
571
|
if (runOpts?.signal?.aborted) throw interruptedError(runOpts.signal)
|
|
538
572
|
|
|
573
|
+
const preamble = scriptControlPreamble(code)
|
|
574
|
+
if (preamble) {
|
|
575
|
+
// Do not commit an action or a result. It neither ran nor is it a
|
|
576
|
+
// useful assistant example for the next inference. The durable
|
|
577
|
+
// system fact is enough to correct the model without preserving
|
|
578
|
+
// the contaminating bytes in its conversational history.
|
|
579
|
+
const message = scriptControlCorrection(preamble)
|
|
580
|
+
await recordFault({ code: "SCRIPT_CONTROL_PREAMBLE", message }, run)
|
|
581
|
+
return {
|
|
582
|
+
ok: false,
|
|
583
|
+
stdout: [],
|
|
584
|
+
scope: EMPTY_CAPSULE_SCOPE,
|
|
585
|
+
error: { kind: "exception", message: "script rejected: provider control preamble" },
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
539
589
|
const id = Bun.randomUUIDv7()
|
|
540
590
|
await session.commitEntry("cognet:action:typescript", { id, content: code }, run)
|
|
541
591
|
// The entry id IS the capsule command id — one id for one execution,
|