refactor(workflow): scaffold @uncaged/workflow, move types from core

- Create packages/workflow/ with types.ts (from core/workflow.ts) and config.ts
- Core re-exports workflow types from @uncaged/workflow
- Delete packages/core/src/workflow.ts

Phase 1+2 of #320, Testing: #321
This commit is contained in:
2026-05-05 10:27:08 +00:00
parent 7d0200fa15
commit 591be21bb0
10 changed files with 107 additions and 16 deletions
+1
View File
@@ -20,6 +20,7 @@
"test": "vitest run" "test": "vitest run"
}, },
"dependencies": { "dependencies": {
"@uncaged/workflow": "workspace:*",
"yaml": "^2.8.3" "yaml": "^2.8.3"
}, },
"devDependencies": { "devDependencies": {
+8 -14
View File
@@ -1,7 +1,14 @@
import { parse } from "yaml"; import { parse } from "yaml";
import {
DEFAULT_ENGINE_MAX_ROUNDS,
type DropOverflowConfig,
type QueueOverflowConfig,
type WorkflowConfig,
} from "@uncaged/workflow";
import { type Result, err, isPlainRecord, ok, parseDurationStringToMs } from "./util.js"; import { type Result, err, isPlainRecord, ok, parseDurationStringToMs } from "./util.js";
import { DEFAULT_ENGINE_MAX_ROUNDS } from "./workflow.js";
export type { DropOverflowConfig, QueueOverflowConfig, WorkflowConfig };
export type SenseConfig = { export type SenseConfig = {
group: string; group: string;
@@ -14,19 +21,6 @@ export type SenseConfig = {
on: string[]; on: string[];
}; };
export type DropOverflowConfig = {
concurrency: number;
overflow: "drop";
};
export type QueueOverflowConfig = {
concurrency: number;
overflow: "queue";
maxQueue: number;
};
export type WorkflowConfig = DropOverflowConfig | QueueOverflowConfig;
/** Optional HTTP control plane. When `port` is null, the HTTP server is not started. */ /** Optional HTTP control plane. When `port` is null, the HTTP server is not started. */
export type NerveApiConfig = { export type NerveApiConfig = {
port: number | null; port: number | null;
+2 -2
View File
@@ -25,8 +25,8 @@ export type {
ModeratorContext, ModeratorContext,
Moderator, Moderator,
WorkflowDefinition, WorkflowDefinition,
} from "./workflow.js"; } from "@uncaged/workflow";
export { START, END, DEFAULT_ENGINE_MAX_ROUNDS } from "./workflow.js"; export { START, END, DEFAULT_ENGINE_MAX_ROUNDS } from "@uncaged/workflow";
export type { Schema, ExtractFn } from "./agent.js"; export type { Schema, ExtractFn } from "./agent.js";
export { ExtractError } from "./agent.js"; export { ExtractError } from "./agent.js";
export type { Result } from "./util.js"; export type { Result } from "./util.js";
+25
View File
@@ -0,0 +1,25 @@
{
"name": "@uncaged/workflow",
"version": "0.5.0",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": ["dist"],
"publishConfig": {
"access": "public"
},
"scripts": {
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
"build": "rslib build"
},
"devDependencies": {
"@rslib/core": "^0.21.3",
"@types/node": "^22.0.0"
}
}
+19
View File
@@ -0,0 +1,19 @@
import { defineConfig } from "@rslib/core";
export default defineConfig({
lib: [
{
format: "esm",
dts: true,
},
],
source: {
entry: {
index: "src/index.ts",
},
},
output: {
target: "node",
cleanDistPath: true,
},
});
+12
View File
@@ -0,0 +1,12 @@
export type DropOverflowConfig = {
concurrency: number;
overflow: "drop";
};
export type QueueOverflowConfig = {
concurrency: number;
overflow: "queue";
maxQueue: number;
};
export type WorkflowConfig = DropOverflowConfig | QueueOverflowConfig;
+19
View File
@@ -0,0 +1,19 @@
// @uncaged/workflow — standalone workflow orchestration engine
export { START, END, DEFAULT_ENGINE_MAX_ROUNDS } from "./types.js";
export type {
WorkflowMessage,
RoleResult,
Role,
RoleMeta,
StartStep,
ThreadContext,
WorkflowContext,
AgentFn,
RoleStep,
ModeratorContext,
Moderator,
WorkflowDefinition,
} from "./types.js";
export type { DropOverflowConfig, QueueOverflowConfig, WorkflowConfig } from "./config.js";
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"composite": false
},
"include": ["src"]
}
+12
View File
@@ -86,6 +86,9 @@ importers:
packages/core: packages/core:
dependencies: dependencies:
'@uncaged/workflow':
specifier: workspace:*
version: link:../workflow
yaml: yaml:
specifier: ^2.8.3 specifier: ^2.8.3
version: 2.8.3 version: 2.8.3
@@ -215,6 +218,15 @@ importers:
specifier: ^4.1.5 specifier: ^4.1.5
version: 4.1.5(@types/node@22.19.17)(vite@8.0.9(@types/node@22.19.17)(esbuild@0.27.7)(yaml@2.8.3)) version: 4.1.5(@types/node@22.19.17)(vite@8.0.9(@types/node@22.19.17)(esbuild@0.27.7)(yaml@2.8.3))
packages/workflow:
devDependencies:
'@rslib/core':
specifier: ^0.21.3
version: 0.21.3(typescript@5.9.3)
'@types/node':
specifier: ^22.0.0
version: 22.19.17
packages/workflow-meta: packages/workflow-meta:
dependencies: dependencies:
'@uncaged/nerve-core': '@uncaged/nerve-core':