refactor(workflow): cleanup engine re-exports, final verification (Phase 4)

- Remove all re-exports from @uncaged/workflow -> @uncaged/workflow-runtime
- Fix cli-workflow imports to use @uncaged/workflow-runtime for types
- Update bundle-validator to allow @uncaged/workflow-runtime imports
- Update init templates to reference @uncaged/workflow-runtime
- 378 tests passing, build + check clean

Refs #121, relates #125
This commit is contained in:
2026-05-08 06:37:56 +00:00
parent e9e4960714
commit 587518ac09
9 changed files with 20 additions and 30 deletions
+1
View File
@@ -5,6 +5,7 @@
"packages/*" "packages/*"
], ],
"scripts": { "scripts": {
"build": "bunx tsc --build",
"check": "bunx tsc --build && biome check .", "check": "bunx tsc --build && biome check .",
"typecheck": "bunx tsc --build", "typecheck": "bunx tsc --build",
"format": "biome format --write .", "format": "biome format --write .",
@@ -51,6 +51,7 @@ describe("init template", () => {
}; };
expect(pkg.type).toBe("module"); expect(pkg.type).toBe("module");
expect(pkg.dependencies["@uncaged/workflow"]).toBeDefined(); expect(pkg.dependencies["@uncaged/workflow"]).toBeDefined();
expect(pkg.dependencies["@uncaged/workflow-runtime"]).toBeDefined();
expect(pkg.dependencies.zod).toBeDefined(); expect(pkg.dependencies.zod).toBeDefined();
expect(pkg.name).toContain("review-pr"); expect(pkg.name).toContain("review-pr");
+1
View File
@@ -6,6 +6,7 @@
"uncaged-workflow": "src/cli.ts" "uncaged-workflow": "src/cli.ts"
}, },
"dependencies": { "dependencies": {
"@uncaged/workflow-runtime": "workspace:*",
"@uncaged/workflow": "workspace:*", "@uncaged/workflow": "workspace:*",
"hono": "^4.12.18", "hono": "^4.12.18",
"yaml": "^2.8.4" "yaml": "^2.8.4"
@@ -7,6 +7,7 @@ export function templatePackageJson(templateName: string): string {
type: "module", type: "module",
dependencies: { dependencies: {
"@uncaged/workflow": "^0.1.0", "@uncaged/workflow": "^0.1.0",
"@uncaged/workflow-runtime": "^0.1.0",
zod: "^4.0.0", zod: "^4.0.0",
}, },
}, },
@@ -31,7 +32,7 @@ export function templateTsconfigJson(): string {
} }
export function templateRolesTs(): string { export function templateRolesTs(): string {
return `import type { RoleDefinition } from "@uncaged/workflow"; return `import type { RoleDefinition } from "@uncaged/workflow-runtime";
import * as z from "zod/v4"; import * as z from "zod/v4";
export const HELLO_TEMPLATE_DESCRIPTION = export const HELLO_TEMPLATE_DESCRIPTION =
@@ -58,7 +59,7 @@ export const greeterRole: RoleDefinition<HelloTemplateMeta["greeter"]> = {
} }
export function templateModeratorTs(): string { export function templateModeratorTs(): string {
return `import { END, type Moderator, type ModeratorContext } from "@uncaged/workflow"; return `import { END, type Moderator, type ModeratorContext } from "@uncaged/workflow-runtime";
import type { HelloTemplateMeta } from "./roles.js"; import type { HelloTemplateMeta } from "./roles.js";
@@ -74,7 +75,7 @@ export const helloTemplateModerator: Moderator<HelloTemplateMeta> = (
} }
export function templateIndexTs(): string { export function templateIndexTs(): string {
return `import type { WorkflowDefinition } from "@uncaged/workflow"; return `import type { WorkflowDefinition } from "@uncaged/workflow-runtime";
import { helloTemplateModerator } from "./moderator.js"; import { helloTemplateModerator } from "./moderator.js";
import { import {
@@ -9,8 +9,8 @@ import {
getGlobalCasDir, getGlobalCasDir,
tryParseRoleStepRecord, tryParseRoleStepRecord,
tryParseWorkflowResultRecord, tryParseWorkflowResultRecord,
type WorkflowCompletion,
} from "@uncaged/workflow"; } from "@uncaged/workflow";
import type { WorkflowCompletion } from "@uncaged/workflow-runtime";
import { dimGreyLine, highlightLiveRole } from "../../cli-color.js"; import { dimGreyLine, highlightLiveRole } from "../../cli-color.js";
import { printCliError, printCliLine } from "../../cli-output.js"; import { printCliError, printCliLine } from "../../cli-output.js";
+1 -1
View File
@@ -17,6 +17,6 @@
"rootDir": "src", "rootDir": "src",
"types": ["bun-types"] "types": ["bun-types"]
}, },
"references": [{ "path": "../workflow" }], "references": [{ "path": "../workflow-runtime" }, { "path": "../workflow" }],
"include": ["src/**/*.ts"] "include": ["src/**/*.ts"]
} }
@@ -39,6 +39,16 @@ export const run = async function* (_input, options) {
expect(r.ok).toBe(true); expect(r.ok).toBe(true);
}); });
test("allows static import of @uncaged/workflow-runtime", () => {
const source = `${minimalDescriptor}import { createWorkflow } from "@uncaged/workflow-runtime";
import { putContentMerkleNode } from "@uncaged/workflow";
export const run = createWorkflow({ description: "x", roles: {}, moderator: () => "END" }, {});
`;
const r = validateWorkflowBundle({ filePath: "/tmp/w.esm.js", source });
expect(r.ok).toBe(true);
});
test("rejects wrong filename suffix", () => { test("rejects wrong filename suffix", () => {
const r = validateWorkflowBundle({ const r = validateWorkflowBundle({
filePath: "/tmp/w.js", filePath: "/tmp/w.js",
@@ -38,7 +38,7 @@ function isAllowedImportSpecifier(spec: string): boolean {
if (spec.startsWith(".") || spec.startsWith("/") || spec.startsWith("file:")) { if (spec.startsWith(".") || spec.startsWith("/") || spec.startsWith("file:")) {
return false; return false;
} }
if (spec === "@uncaged/workflow") { if (spec === "@uncaged/workflow" || spec === "@uncaged/workflow-runtime") {
return true; return true;
} }
return isBuiltin(spec); return isBuiltin(spec);
-24
View File
@@ -1,27 +1,3 @@
export {
type AgentBinding,
type AgentContext,
type AgentFn,
END,
type ExtractContext,
type ExtractMode,
type LlmProvider,
type Moderator,
type ModeratorContext,
type RoleDefinition,
type RoleMeta,
type RoleOutput,
type RoleStep,
START,
type StartStep,
type ThreadContext,
type ThreadInput,
type WorkflowCompletion,
type WorkflowDefinition,
type WorkflowFn,
type WorkflowFnOptions,
type WorkflowResult,
} from "@uncaged/workflow-runtime";
export { export {
buildDescriptor, buildDescriptor,
type ExtractedBundleExports, type ExtractedBundleExports,