@arcforge/core 2.0.191 → 2.0.192

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 (2) hide show
  1. package/package.json +12 -12
  2. package/src/runtime/handle.ts +29 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcforge/core",
3
- "version": "2.0.191",
3
+ "version": "2.0.192",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "exports": {
@@ -14,17 +14,17 @@
14
14
  "test:coverage": "bun test --coverage"
15
15
  },
16
16
  "dependencies": {
17
- "@arcforge/air": "2.0.191",
18
- "@arcforge/capsule": "2.0.191",
19
- "@arcforge/cloud": "2.0.191",
20
- "@arcforge/cognet": "2.0.191",
21
- "@arcforge/engines": "2.0.191",
22
- "@arcforge/err": "2.0.191",
23
- "@arcforge/kernel": "2.0.191",
24
- "@arcforge/link": "2.0.191",
25
- "@arcforge/session": "2.0.191",
26
- "@arcforge/types": "2.0.191",
27
- "@arcforge/vstr": "2.0.191",
17
+ "@arcforge/air": "2.0.192",
18
+ "@arcforge/capsule": "2.0.192",
19
+ "@arcforge/cloud": "2.0.192",
20
+ "@arcforge/cognet": "2.0.192",
21
+ "@arcforge/engines": "2.0.192",
22
+ "@arcforge/err": "2.0.192",
23
+ "@arcforge/kernel": "2.0.192",
24
+ "@arcforge/link": "2.0.192",
25
+ "@arcforge/session": "2.0.192",
26
+ "@arcforge/types": "2.0.192",
27
+ "@arcforge/vstr": "2.0.192",
28
28
  "crossws": "^0.3.5",
29
29
  "h3": "^1.13.0",
30
30
  "hookable": "^5.5.3",
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module"
1
2
  import { err } from "@arcforge/err"
2
3
  import type { AxonCloudClient } from "@arcforge/cloud"
3
4
  import { foldChunks, type AxonBlueprint, type AxonRequestInput, type AxonResult, type AxonToolNamespaces } from "@arcforge/types"
@@ -7,7 +8,7 @@ import type { AxonOutputEvent } from "@arcforge/types"
7
8
  import { Prompt } from "./source/render"
8
9
  import { Scripts } from "./source/scripts"
9
10
  import { AxonKernelT } from "@arcforge/kernel"
10
- import { Output } from "@arcforge/air/output"
11
+ import type { Output as OutputFactory } from "@arcforge/air/output"
11
12
  import type { AxonSessionT } from "@arcforge/session"
12
13
 
13
14
  type AxonHandleOpts = {
@@ -58,11 +59,32 @@ type AxonHandleOpts = {
58
59
  function Invoke(opts: { kernel: AxonKernelT }) {
59
60
  const { kernel } = opts
60
61
 
61
- // The typechecker behind `output`. Built once and reused: it holds a
62
- // warm TypeScript program, so the per-request cost is an incremental
63
- // check rather than a compiler spin-up. Construction is wiring only —
64
- // no program is created until the first output type is compiled.
65
- const output = Output({ scope: () => kernel.scope() })
62
+ /*
63
+ * The typechecker behind `output`. Built once and reused: it holds a warm
64
+ * TypeScript program, so the per-request cost is an incremental check
65
+ * rather than a compiler spin-up.
66
+ *
67
+ * Reached through a lazy `require` rather than a static import, because
68
+ * `@arcforge/air/output` pulls the 17MB TypeScript compiler and this
69
+ * module is on the boot path of every CLI command and the TUI. A static
70
+ * import here meant `axon --version` loaded a typechecker.
71
+ *
72
+ * Synchronous by necessity: `toKernelInput` compiles an output type inline
73
+ * so an invalid one throws at the caller's own line. `typescript` and this
74
+ * package are both CJS-resolvable, so `require` defers the cost without
75
+ * making the surface async.
76
+ */
77
+ let output: ReturnType<typeof OutputFactory> | null = null
78
+
79
+ function typechecker(): ReturnType<typeof OutputFactory> {
80
+ if (!output) {
81
+ const { Output } = createRequire(import.meta.url)("@arcforge/air/output") as {
82
+ Output: typeof OutputFactory
83
+ }
84
+ output = Output({ scope: () => kernel.scope() })
85
+ }
86
+ return output
87
+ }
66
88
 
67
89
  /**
68
90
  * The public surface takes a prompt; the kernel takes content.
@@ -79,7 +101,7 @@ function Invoke(opts: { kernel: AxonKernelT }) {
79
101
  const channel = normalized.channel === undefined ? {} : { channel: normalized.channel }
80
102
  if (!normalized.output) return { content: normalized.prompt, ...channel }
81
103
 
82
- const compiled = output.compile(normalized.output)
104
+ const compiled = typechecker().compile(normalized.output)
83
105
  return {
84
106
  content: normalized.prompt,
85
107
  ...channel,