diff --git a/src/permission/reactor-authorize.ts b/src/permission/reactor-authorize.ts index f1e5666e6..3f44afdd8 100644 --- a/src/permission/reactor-authorize.ts +++ b/src/permission/reactor-authorize.ts @@ -14,7 +14,10 @@ import { getLogger } from "@intx/log"; import { LOG_NAMESPACE_ROOT } from "../branding.js"; -import { ToolCall, type ToolCall as ToolCallType } from "@intx/types/runtime"; +import { + ToolCall, + type ToolCall as ToolCallType, +} from "@intx/types/runtime-core"; import { type } from "arktype"; import type { AuthzCallResult } from "@intx/inference"; diff --git a/src/session/optimized-context-store.ts b/src/session/optimized-context-store.ts index 265dca56a..13af98b76 100644 --- a/src/session/optimized-context-store.ts +++ b/src/session/optimized-context-store.ts @@ -13,7 +13,7 @@ import { TokenUsage, type ConversationTurn, type PendingOperation, -} from "@intx/types/runtime"; +} from "@intx/types/runtime-core"; import { getLogger } from "@intx/log"; import { createSegmentedJSONLWriter, diff --git a/src/session/pending-approval-record.ts b/src/session/pending-approval-record.ts index 021b6ea8b..4a90632c0 100644 --- a/src/session/pending-approval-record.ts +++ b/src/session/pending-approval-record.ts @@ -3,7 +3,7 @@ import { ApprovalSnapshot, type PendingOperation, ToolCall, -} from "@intx/types/runtime"; +} from "@intx/types/runtime-core"; /** * A pending operation as it rests in session state (metadata.json, or a turn diff --git a/src/session/runtime-core-import.test.ts b/src/session/runtime-core-import.test.ts new file mode 100644 index 000000000..c6d195782 --- /dev/null +++ b/src/session/runtime-core-import.test.ts @@ -0,0 +1,64 @@ +// Loading the @intx/types/runtime barrel evaluates inference-events.ts and +// builds the InferenceEvent union. Session modules that need runtime values +// import @intx/types/runtime-core so that boot does not pay for the union. + +import { expect, test } from "bun:test"; +import { spawnSync } from "node:child_process"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const repoRoot = path.resolve( + path.dirname(fileURLToPath(import.meta.url)), + "../..", +); + +const probe = ` +import { mock } from "bun:test"; +mock.module("@intx/types/inference-events", () => { + throw new Error("evaluated-inference-events"); +}); +const specifier = process.env.PROBE_SPECIFIER; +if (specifier === undefined || specifier.length === 0) { + throw new Error("missing PROBE_SPECIFIER"); +} +for (const target of specifier.split(",")) { + await import(target); +} +`; + +function importUnderProbe(specifier: string): { + status: number | null; + stderr: string; +} { + const result = spawnSync("bun", ["-e", probe], { + cwd: repoRoot, + encoding: "utf8", + env: { ...process.env, PROBE_SPECIFIER: specifier }, + }); + return { + status: result.status, + stderr: result.stderr, + }; +} + +const sessionBootModules = [ + "./src/session/optimized-context-store.ts", + "./src/session/pending-approval-record.ts", + "./src/session/summarizer.ts", +].join(","); + +test("the runtime barrel evaluates the inference event union", () => { + const result = importUnderProbe("@intx/types/runtime"); + expect(result.status).not.toBe(0); + expect(result.stderr).toContain("evaluated-inference-events"); +}); + +test( + "session value imports do not evaluate the inference event union", + () => { + const result = importUnderProbe(sessionBootModules); + expect(result.stderr).not.toContain("evaluated-inference-events"); + expect(result.status).toBe(0); + }, + { timeout: 60_000 }, +); diff --git a/src/session/summarizer.ts b/src/session/summarizer.ts index af0d35df1..a9f1c7a29 100644 --- a/src/session/summarizer.ts +++ b/src/session/summarizer.ts @@ -14,7 +14,7 @@ import { type ConversationTurn, type InferenceSource, type RetryPolicy, -} from "@intx/types/runtime"; +} from "@intx/types/runtime-core"; import { LOG_NAMESPACE_ROOT } from "../branding.js"; import { NOOP_TELEMETRY, type Telemetry } from "../telemetry/index.js"; import {