Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 94f725c50b | |||
| e14643a50b | |||
| 76830c5e22 | |||
| 90a388f5ab | |||
| 82e40f0c21 | |||
| 8d650326db | |||
| dd3eec7d35 | |||
| 9276689cb6 | |||
| b4584cbaa6 | |||
| 1cf963a1fb | |||
| ce5bc50210 | |||
| 439e203113 |
@@ -2,16 +2,10 @@
|
|||||||
"$schema": "https://unpkg.com/@changesets/config@3.1.4/schema.json",
|
"$schema": "https://unpkg.com/@changesets/config@3.1.4/schema.json",
|
||||||
"changelog": "@changesets/cli/changelog",
|
"changelog": "@changesets/cli/changelog",
|
||||||
"commit": false,
|
"commit": false,
|
||||||
"fixed": [
|
"fixed": [["@uncaged/*"]],
|
||||||
[
|
|
||||||
"@uncaged/*"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"linked": [],
|
"linked": [],
|
||||||
"access": "restricted",
|
"access": "public",
|
||||||
"baseBranch": "main",
|
"baseBranch": "main",
|
||||||
"updateInternalDependencies": "patch",
|
"updateInternalDependencies": "patch",
|
||||||
"ignore": [
|
"ignore": ["@uncaged/workflow-dashboard"]
|
||||||
"@uncaged/workflow-dashboard"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
Executable
+6
@@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# pre-push hook: typecheck + biome + lint-log-tags
|
||||||
|
set -euo pipefail
|
||||||
|
echo "🔍 pre-push: running checks..."
|
||||||
|
bun run check
|
||||||
|
echo "✅ pre-push: all checks passed"
|
||||||
@@ -30,6 +30,7 @@ workflow/
|
|||||||
workflow-agent-cursor/ # @uncaged/workflow-agent-cursor
|
workflow-agent-cursor/ # @uncaged/workflow-agent-cursor
|
||||||
workflow-agent-hermes/ # @uncaged/workflow-agent-hermes
|
workflow-agent-hermes/ # @uncaged/workflow-agent-hermes
|
||||||
workflow-agent-llm/ # @uncaged/workflow-agent-llm
|
workflow-agent-llm/ # @uncaged/workflow-agent-llm
|
||||||
|
workflow-agent-react/ # @uncaged/workflow-agent-react
|
||||||
workflow-util-agent/ # @uncaged/workflow-util-agent — buildAgentPrompt, spawnCli
|
workflow-util-agent/ # @uncaged/workflow-util-agent — buildAgentPrompt, spawnCli
|
||||||
workflow-template-develop/ # @uncaged/workflow-template-develop
|
workflow-template-develop/ # @uncaged/workflow-template-develop
|
||||||
workflow-template-solve-issue/ # @uncaged/workflow-template-solve-issue
|
workflow-template-solve-issue/ # @uncaged/workflow-template-solve-issue
|
||||||
@@ -40,7 +41,7 @@ workflow/
|
|||||||
```
|
```
|
||||||
|
|
||||||
- Execution stack layers: `workflow-protocol` → (`workflow-runtime`, `workflow-util`, `workflow-reactor`) → (`workflow-cas`, `workflow-register`) → `workflow-execute` → `cli-workflow`
|
- Execution stack layers: `workflow-protocol` → (`workflow-runtime`, `workflow-util`, `workflow-reactor`) → (`workflow-cas`, `workflow-register`) → `workflow-execute` → `cli-workflow`
|
||||||
- Packages use `workspace:*` protocol
|
- Packages use `workspace:^` protocol (resolves to `^x.y.z` on publish)
|
||||||
|
|
||||||
## Language & Paradigm
|
## Language & Paradigm
|
||||||
|
|
||||||
@@ -245,61 +246,47 @@ bun run format # biome format --write
|
|||||||
bun test # run tests
|
bun test # run tests
|
||||||
```
|
```
|
||||||
|
|
||||||
### Publishing to Gitea npm Registry
|
### Version Management & Publishing
|
||||||
|
|
||||||
All public `@uncaged/*` packages are published to the Gitea npm registry at `git.shazhou.work`. Workflow workspaces consume packages from this registry via `bunfig.toml`.
|
All public `@uncaged/*` packages are published to **npmjs.org** via `@changesets/cli` with **fixed mode** (all packages share the same version number). `workflow-dashboard` is private and excluded.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Publish all packages (bun pm pack resolves workspace:* → actual versions)
|
# 1. After making changes, add a changeset describing the change
|
||||||
bun run publish:gitea
|
bun changeset
|
||||||
|
|
||||||
# Dry run — see what would be published
|
# 2. Before release, bump all package versions + generate CHANGELOGs
|
||||||
bun run publish:gitea:dry
|
bun version
|
||||||
|
|
||||||
|
# 3. Build, test, and publish to npmjs
|
||||||
|
bun release
|
||||||
```
|
```
|
||||||
|
|
||||||
Prerequisites: `.npmrc` in monorepo root with Gitea auth token (`//git.shazhou.work/api/packages/shazhou/npm/:_authToken=<token>`).
|
- `workspace:^` dependencies resolve to `^x.y.z` on publish
|
||||||
|
- Changesets config: `.changeset/config.json` (fixed mode, public access)
|
||||||
|
- Each package has auto-generated `CHANGELOG.md`
|
||||||
|
|
||||||
### Workflow Workspace Setup
|
### Consuming @uncaged/* Packages
|
||||||
|
|
||||||
External workflow repos (e.g. `xingyue-workflows`) use the Gitea registry for `@uncaged/*` packages. Add a `bunfig.toml`:
|
External workflow repos just `bun install` — packages come from npmjs like any other dependency. No special registry config needed.
|
||||||
|
|
||||||
```toml
|
|
||||||
[install.scopes]
|
|
||||||
"@uncaged" = "https://git.shazhou.work/api/packages/shazhou/npm/"
|
|
||||||
```
|
|
||||||
|
|
||||||
Then `bun install` resolves `@uncaged/*` from Gitea, all other packages from npmjs.
|
|
||||||
|
|
||||||
### Cross-repo Development (bun link)
|
|
||||||
|
|
||||||
Alternative for development against un-published local changes:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bun run link # Register all packages (from monorepo root)
|
|
||||||
bun run link:consume # Link into CWD's project (⚠️ don't bun install after)
|
|
||||||
bun run link:unlink # Restore original deps
|
|
||||||
```
|
|
||||||
|
|
||||||
### End-to-end: Monorepo → Registry → Workspace → Bundle
|
### End-to-end: Monorepo → Registry → Workspace → Bundle
|
||||||
|
|
||||||
The recommended development flow for building workflows:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
workflow/ (monorepo) — engine, runtime, templates, agents
|
workflow/ (monorepo) — engine, runtime, templates, agents
|
||||||
│ bun run publish:gitea — auto topo-sort, bun pm pack → npm publish
|
│ bun release — build + test + changeset publish
|
||||||
▼
|
▼
|
||||||
git.shazhou.work npm registry — @uncaged/* scoped packages
|
npmjs.org — @uncaged/* scoped packages (public)
|
||||||
│ bun install — via bunfig.toml scoped registry
|
│ bun install
|
||||||
▼
|
▼
|
||||||
my-workflows/ (workspace) — bunfig.toml + normal package.json
|
my-workflows/ (workspace) — normal package.json
|
||||||
│ bun run build:develop — bun build → single .esm.js
|
│ bun run build:develop — bun build → single .esm.js
|
||||||
▼
|
▼
|
||||||
uncaged-workflow workflow add — register bundle locally
|
uncaged-workflow workflow add — register bundle locally
|
||||||
uncaged-workflow run — execute workflow
|
uncaged-workflow run — execute workflow
|
||||||
```
|
```
|
||||||
|
|
||||||
1. **Monorepo changes** → `bun run publish:gitea` (packages auto-discovered from `packages/*/`, topologically sorted, `workspace:*` resolved to real versions)
|
1. **Monorepo changes** → `bun changeset` (describe change) → `bun version` (bump) → `bun release` (publish)
|
||||||
2. **Workspace** → `bun install` fetches latest from Gitea, `bun install` is safe to run anytime
|
2. **Workspace** → `bun install` fetches latest from npmjs
|
||||||
3. **Build** → produces single-file ESM bundle with `@uncaged/*` as externals
|
3. **Build** → produces single-file ESM bundle with `@uncaged/*` as externals
|
||||||
4. **Register & Run** → `uncaged-workflow workflow add <name> <bundle>` then `uncaged-workflow run <name>`
|
4. **Register & Run** → `uncaged-workflow workflow add <name> <bundle>` then `uncaged-workflow run <name>`
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
|
"$schema": "https://biomejs.dev/schemas/2.4.15/schema.json",
|
||||||
"files": {
|
"files": {
|
||||||
"includes": ["**", "!**/dist", "!**/node_modules", "!packages/workflow/workflow"]
|
"includes": ["**", "!**/dist", "!**/node_modules", "!packages/workflow/workflow"]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { createCursorAgent } from "./packages/workflow-agent-cursor/src/index.js";
|
||||||
|
import { createWorkflow } from "./packages/workflow-runtime/src/create-workflow.js";
|
||||||
|
import {
|
||||||
|
buildDevelopDescriptor,
|
||||||
|
developWorkflowDefinition,
|
||||||
|
} from "./packages/workflow-template-develop/src/index.js";
|
||||||
|
|
||||||
|
const agent = createCursorAgent({
|
||||||
|
command: "/home/azureuser/.local/bin/cursor-agent",
|
||||||
|
model: "auto",
|
||||||
|
timeout: 300_000,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const descriptor = buildDevelopDescriptor();
|
||||||
|
export const run = createWorkflow(developWorkflowDefinition, { adapter: agent, overrides: null });
|
||||||
+2
-7
@@ -6,18 +6,13 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "bunx tsc --build",
|
"build": "bunx tsc --build",
|
||||||
"check": "bunx tsc --build && biome check .",
|
"check": "bunx tsc --build && biome check . && bash scripts/lint-log-tags.sh",
|
||||||
"typecheck": "bunx tsc --build",
|
"typecheck": "bunx tsc --build",
|
||||||
"format": "biome format --write .",
|
"format": "biome format --write .",
|
||||||
"test": "bun run --filter '*' test",
|
"test": "bun run --filter '*' test",
|
||||||
"link": "./scripts/link-all.sh",
|
|
||||||
"link:consume": "./scripts/link-all.sh --consume",
|
|
||||||
"link:unlink": "./scripts/link-all.sh --unlink",
|
|
||||||
"publish:gitea": "./scripts/publish.sh patch",
|
|
||||||
"publish:gitea:dry": "./scripts/publish.sh --dry-run patch",
|
|
||||||
"changeset": "bunx changeset",
|
"changeset": "bunx changeset",
|
||||||
"version": "bunx changeset version",
|
"version": "bunx changeset version",
|
||||||
"release": "bunx changeset publish --no-git-tag"
|
"release": "bun run build && bun test && npx changeset publish --no-git-tag"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^2.4.14",
|
"@biomejs/biome": "^2.4.14",
|
||||||
|
|||||||
@@ -1,5 +1,59 @@
|
|||||||
# @uncaged/cli-workflow
|
# @uncaged/cli-workflow
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.5
|
||||||
|
- @uncaged/workflow-cas@0.4.5
|
||||||
|
- @uncaged/workflow-execute@0.4.5
|
||||||
|
- @uncaged/workflow-gateway@0.4.5
|
||||||
|
- @uncaged/workflow-register@0.4.5
|
||||||
|
- @uncaged/workflow-runtime@0.4.5
|
||||||
|
- @uncaged/workflow-util@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.4
|
||||||
|
- @uncaged/workflow-cas@0.4.4
|
||||||
|
- @uncaged/workflow-execute@0.4.4
|
||||||
|
- @uncaged/workflow-gateway@0.4.4
|
||||||
|
- @uncaged/workflow-register@0.4.4
|
||||||
|
- @uncaged/workflow-runtime@0.4.4
|
||||||
|
- @uncaged/workflow-util@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-cas@0.4.3
|
||||||
|
- @uncaged/workflow-execute@0.4.3
|
||||||
|
- @uncaged/workflow-gateway@0.4.3
|
||||||
|
- @uncaged/workflow-protocol@0.4.3
|
||||||
|
- @uncaged/workflow-register@0.4.3
|
||||||
|
- @uncaged/workflow-runtime@0.4.3
|
||||||
|
- @uncaged/workflow-util@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-cas@0.4.2
|
||||||
|
- @uncaged/workflow-execute@0.4.2
|
||||||
|
- @uncaged/workflow-gateway@0.4.2
|
||||||
|
- @uncaged/workflow-protocol@0.4.2
|
||||||
|
- @uncaged/workflow-register@0.4.2
|
||||||
|
- @uncaged/workflow-runtime@0.4.2
|
||||||
|
- @uncaged/workflow-util@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/cli-workflow",
|
"name": "@uncaged/cli-workflow",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
@@ -11,17 +11,20 @@
|
|||||||
"uncaged-workflow": "src/cli.ts"
|
"uncaged-workflow": "src/cli.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-gateway": "workspace:*",
|
"@uncaged/workflow-gateway": "workspace:^",
|
||||||
"@uncaged/workflow-protocol": "workspace:*",
|
"@uncaged/workflow-protocol": "workspace:^",
|
||||||
"@uncaged/workflow-util": "workspace:*",
|
"@uncaged/workflow-util": "workspace:^",
|
||||||
"@uncaged/workflow-cas": "workspace:*",
|
"@uncaged/workflow-cas": "workspace:^",
|
||||||
"@uncaged/workflow-execute": "workspace:*",
|
"@uncaged/workflow-execute": "workspace:^",
|
||||||
"@uncaged/workflow-register": "workspace:*",
|
"@uncaged/workflow-register": "workspace:^",
|
||||||
"@uncaged/workflow-runtime": "workspace:*",
|
"@uncaged/workflow-runtime": "workspace:^",
|
||||||
"hono": "^4.12.18",
|
"hono": "^4.12.18",
|
||||||
"yaml": "^2.8.4"
|
"yaml": "^2.8.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-38
@@ -1,43 +1,9 @@
|
|||||||
import { printCliLine } from "../../cli-output.js";
|
import { printCliLine } from "../../cli-output.js";
|
||||||
|
|
||||||
type TunnelHandle = {
|
|
||||||
process: ReturnType<typeof Bun.spawn>;
|
|
||||||
url: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function startTunnel(port: number): Promise<TunnelHandle | null> {
|
|
||||||
const proc = Bun.spawn(["cloudflared", "tunnel", "--url", `http://localhost:${port}`], {
|
|
||||||
stdout: "pipe",
|
|
||||||
stderr: "pipe",
|
|
||||||
});
|
|
||||||
|
|
||||||
// cloudflared prints the URL to stderr
|
|
||||||
const reader = proc.stderr.getReader();
|
|
||||||
const decoder = new TextDecoder();
|
|
||||||
let buffer = "";
|
|
||||||
const deadline = Date.now() + 30_000;
|
|
||||||
|
|
||||||
while (Date.now() < deadline) {
|
|
||||||
const { done, value } = await reader.read();
|
|
||||||
if (done) break;
|
|
||||||
buffer += decoder.decode(value, { stream: true });
|
|
||||||
const match = buffer.match(/https:\/\/[a-z0-9-]+\.trycloudflare\.com/);
|
|
||||||
if (match) {
|
|
||||||
// Release the reader so stderr keeps flowing without backpressure
|
|
||||||
reader.releaseLock();
|
|
||||||
return { process: proc, url: match[0] };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reader.releaseLock();
|
|
||||||
proc.kill();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function registerWithGateway(
|
export async function registerWithGateway(
|
||||||
gatewayUrl: string,
|
gatewayUrl: string,
|
||||||
name: string,
|
name: string,
|
||||||
tunnelUrl: string,
|
localUrl: string,
|
||||||
secret: string,
|
secret: string,
|
||||||
agentToken: string,
|
agentToken: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
@@ -45,7 +11,7 @@ export async function registerWithGateway(
|
|||||||
const resp = await fetch(`${gatewayUrl}/api/gateway/register`, {
|
const resp = await fetch(`${gatewayUrl}/api/gateway/register`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({ name, url: tunnelUrl, secret, agentToken }),
|
body: JSON.stringify({ name, url: localUrl, secret, agentToken }),
|
||||||
});
|
});
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
const body = await resp.text();
|
const body = await resp.text();
|
||||||
@@ -77,12 +43,12 @@ export async function unregisterFromGateway(
|
|||||||
export function startHeartbeat(
|
export function startHeartbeat(
|
||||||
gatewayUrl: string,
|
gatewayUrl: string,
|
||||||
name: string,
|
name: string,
|
||||||
tunnelUrl: string,
|
localUrl: string,
|
||||||
secret: string,
|
secret: string,
|
||||||
agentToken: string,
|
agentToken: string,
|
||||||
intervalMs: number,
|
intervalMs: number,
|
||||||
): ReturnType<typeof setInterval> {
|
): ReturnType<typeof setInterval> {
|
||||||
return setInterval(() => {
|
return setInterval(() => {
|
||||||
registerWithGateway(gatewayUrl, name, tunnelUrl, secret, agentToken).catch(() => {});
|
registerWithGateway(gatewayUrl, name, localUrl, secret, agentToken).catch(() => {});
|
||||||
}, intervalMs);
|
}, intervalMs);
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ import { serve } from "bun";
|
|||||||
|
|
||||||
import { printCliLine } from "../../cli-output.js";
|
import { printCliLine } from "../../cli-output.js";
|
||||||
import { createApp } from "./app.js";
|
import { createApp } from "./app.js";
|
||||||
import { registerWithGateway, startHeartbeat, unregisterFromGateway } from "./tunnel.js";
|
import { registerWithGateway, startHeartbeat, unregisterFromGateway } from "./gateway.js";
|
||||||
import type { ServeOptions } from "./types.js";
|
import type { ServeOptions } from "./types.js";
|
||||||
import { startGatewayWsClient } from "./ws-client.js";
|
import { startGatewayWsClient } from "./ws-client.js";
|
||||||
|
|
||||||
@@ -52,8 +52,6 @@ function parseServeArgv(argv: string[]): Result<ServeOptions, string> {
|
|||||||
let port = 7860;
|
let port = 7860;
|
||||||
let hostname = "127.0.0.1";
|
let hostname = "127.0.0.1";
|
||||||
let name = osHostname().split(".")[0].toLowerCase();
|
let name = osHostname().split(".")[0].toLowerCase();
|
||||||
let noTunnel = false;
|
|
||||||
let tunnelUrl: string | null = null;
|
|
||||||
let gatewayUrl = DEFAULT_GATEWAY_URL;
|
let gatewayUrl = DEFAULT_GATEWAY_URL;
|
||||||
const gatewaySecret = process.env.WORKFLOW_GATEWAY_SECRET ?? "";
|
const gatewaySecret = process.env.WORKFLOW_GATEWAY_SECRET ?? "";
|
||||||
const stringFlags: Record<string, (v: string) => void> = {
|
const stringFlags: Record<string, (v: string) => void> = {
|
||||||
@@ -66,9 +64,6 @@ function parseServeArgv(argv: string[]): Result<ServeOptions, string> {
|
|||||||
"--gateway": (v) => {
|
"--gateway": (v) => {
|
||||||
gatewayUrl = v;
|
gatewayUrl = v;
|
||||||
},
|
},
|
||||||
"--tunnel-url": (v) => {
|
|
||||||
tunnelUrl = v;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let i = 0; i < argv.length; i++) {
|
for (let i = 0; i < argv.length; i++) {
|
||||||
@@ -78,8 +73,6 @@ function parseServeArgv(argv: string[]): Result<ServeOptions, string> {
|
|||||||
if (!portResult.ok) return portResult;
|
if (!portResult.ok) return portResult;
|
||||||
port = portResult.value;
|
port = portResult.value;
|
||||||
i++;
|
i++;
|
||||||
} else if (arg === "--no-tunnel") {
|
|
||||||
noTunnel = true;
|
|
||||||
} else if (arg in stringFlags) {
|
} else if (arg in stringFlags) {
|
||||||
const r = requireNextArg(argv, i, arg);
|
const r = requireNextArg(argv, i, arg);
|
||||||
if (!r.ok) return r;
|
if (!r.ok) return r;
|
||||||
@@ -88,7 +81,7 @@ function parseServeArgv(argv: string[]): Result<ServeOptions, string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok({ port, hostname, name, noTunnel, tunnelUrl, gatewayUrl, gatewaySecret });
|
return ok({ port, hostname, name, gatewayUrl, gatewaySecret });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function dispatchServe(storageRoot: string, argv: string[]): Promise<number> {
|
export async function dispatchServe(storageRoot: string, argv: string[]): Promise<number> {
|
||||||
@@ -99,81 +92,62 @@ export async function dispatchServe(storageRoot: string, argv: string[]): Promis
|
|||||||
}
|
}
|
||||||
|
|
||||||
const options = parsed.value;
|
const options = parsed.value;
|
||||||
const agentToken = options.noTunnel ? null : randomUUID();
|
|
||||||
startServer(storageRoot, options, agentToken);
|
|
||||||
|
|
||||||
if (options.noTunnel) {
|
if (options.gatewaySecret === "") {
|
||||||
printCliLine("tunnel disabled (--no-tunnel)");
|
// No gateway — local-only mode
|
||||||
|
startServer(storageRoot, options, null);
|
||||||
|
printCliLine("no WORKFLOW_GATEWAY_SECRET — running in local-only mode");
|
||||||
await new Promise(() => {});
|
await new Promise(() => {});
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let resolvedTunnelUrl: string;
|
const agentToken = randomUUID();
|
||||||
let stopWsClient: (() => void) | null = null;
|
startServer(storageRoot, options, agentToken);
|
||||||
|
|
||||||
if (options.tunnelUrl !== null) {
|
// Start WebSocket reverse connection to gateway
|
||||||
resolvedTunnelUrl = options.tunnelUrl;
|
const log = createLogger({ sink: { kind: "stderr" } });
|
||||||
printCliLine(`using tunnel URL: ${resolvedTunnelUrl}`);
|
const stopWsClient = startGatewayWsClient({
|
||||||
} else {
|
gatewayUrl: options.gatewayUrl,
|
||||||
if (options.gatewaySecret === "") {
|
name: options.name,
|
||||||
printCliLine(
|
secret: options.gatewaySecret,
|
||||||
"WORKFLOW_GATEWAY_SECRET not set — cannot use WebSocket gateway connection (set env or pass --tunnel-url)",
|
localPort: options.port,
|
||||||
);
|
log,
|
||||||
await new Promise(() => {});
|
});
|
||||||
return 0;
|
|
||||||
}
|
printCliLine("connected to gateway via WebSocket");
|
||||||
resolvedTunnelUrl = `http://127.0.0.1:${options.port}`;
|
|
||||||
const log = createLogger({ sink: { kind: "stderr" } });
|
// Register with gateway for discovery
|
||||||
stopWsClient = startGatewayWsClient({
|
const localUrl = `http://127.0.0.1:${options.port}`;
|
||||||
gatewayUrl: options.gatewayUrl,
|
const registered = await registerWithGateway(
|
||||||
name: options.name,
|
options.gatewayUrl,
|
||||||
secret: options.gatewaySecret,
|
options.name,
|
||||||
localPort: options.port,
|
localUrl,
|
||||||
log,
|
options.gatewaySecret,
|
||||||
});
|
agentToken,
|
||||||
printCliLine("gateway WebSocket reverse connection (no cloudflared)");
|
);
|
||||||
|
if (registered) {
|
||||||
|
printCliLine(`registered with gateway as "${options.name}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.gatewaySecret) {
|
const heartbeatTimer = startHeartbeat(
|
||||||
if (agentToken === null) {
|
options.gatewayUrl,
|
||||||
printCliLine("internal error: agent token missing");
|
options.name,
|
||||||
await new Promise(() => {});
|
localUrl,
|
||||||
return 1;
|
options.gatewaySecret,
|
||||||
}
|
agentToken,
|
||||||
const token = agentToken;
|
HEARTBEAT_INTERVAL_MS,
|
||||||
const registered = await registerWithGateway(
|
);
|
||||||
options.gatewayUrl,
|
|
||||||
options.name,
|
|
||||||
resolvedTunnelUrl,
|
|
||||||
options.gatewaySecret,
|
|
||||||
token,
|
|
||||||
);
|
|
||||||
if (registered) {
|
|
||||||
printCliLine(`registered with gateway as "${options.name}"`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const heartbeatTimer = startHeartbeat(
|
const cleanup = async () => {
|
||||||
options.gatewayUrl,
|
clearInterval(heartbeatTimer);
|
||||||
options.name,
|
stopWsClient();
|
||||||
resolvedTunnelUrl,
|
printCliLine("unregistering from gateway...");
|
||||||
options.gatewaySecret,
|
await unregisterFromGateway(options.gatewayUrl, options.name, options.gatewaySecret);
|
||||||
token,
|
process.exit(0);
|
||||||
HEARTBEAT_INTERVAL_MS,
|
};
|
||||||
);
|
|
||||||
|
|
||||||
const cleanup = async () => {
|
process.on("SIGINT", cleanup);
|
||||||
clearInterval(heartbeatTimer);
|
process.on("SIGTERM", cleanup);
|
||||||
stopWsClient?.();
|
|
||||||
printCliLine("unregistering from gateway...");
|
|
||||||
await unregisterFromGateway(options.gatewayUrl, options.name, options.gatewaySecret);
|
|
||||||
process.exit(0);
|
|
||||||
};
|
|
||||||
|
|
||||||
process.on("SIGINT", cleanup);
|
|
||||||
process.on("SIGTERM", cleanup);
|
|
||||||
} else {
|
|
||||||
printCliLine("WORKFLOW_GATEWAY_SECRET not set — skipping gateway registration");
|
|
||||||
}
|
|
||||||
|
|
||||||
await new Promise(() => {});
|
await new Promise(() => {});
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ export type ServeOptions = {
|
|||||||
port: number;
|
port: number;
|
||||||
hostname: string;
|
hostname: string;
|
||||||
name: string;
|
name: string;
|
||||||
noTunnel: boolean;
|
|
||||||
tunnelUrl: string | null;
|
|
||||||
gatewayUrl: string;
|
gatewayUrl: string;
|
||||||
gatewaySecret: string;
|
gatewaySecret: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ export function startGatewayWsClient(params: GatewayWsClientParams): () => void
|
|||||||
clearReconnectTimer();
|
clearReconnectTimer();
|
||||||
const delayMs = Math.min(INITIAL_BACKOFF_MS * 2 ** attempt, MAX_BACKOFF_MS);
|
const delayMs = Math.min(INITIAL_BACKOFF_MS * 2 ** attempt, MAX_BACKOFF_MS);
|
||||||
attempt++;
|
attempt++;
|
||||||
params.log("6CJX2RLP", `gateway WebSocket reconnect in ${delayMs}ms (attempt ${attempt})`);
|
params.log("6CJX2R8P", `gateway WebSocket reconnect in ${delayMs}ms (attempt ${attempt})`);
|
||||||
reconnectTimer = setTimeout(connect, delayMs);
|
reconnectTimer = setTimeout(connect, delayMs);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ export function startGatewayWsClient(params: GatewayWsClientParams): () => void
|
|||||||
ws.addEventListener("message", (ev) => {
|
ws.addEventListener("message", (ev) => {
|
||||||
const data = ev.data;
|
const data = ev.data;
|
||||||
if (typeof data !== "string") {
|
if (typeof data !== "string") {
|
||||||
params.log("T9W2KL5H", "gateway WebSocket non-text frame ignored");
|
params.log("T9W2K35H", "gateway WebSocket non-text frame ignored");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void handleGatewayMessage(ws, data, params).catch((e: unknown) => {
|
void handleGatewayMessage(ws, data, params).catch((e: unknown) => {
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ ${commandSections.join("\n\n")}
|
|||||||
|
|
||||||
| Command | Args | Description |
|
| Command | Args | Description |
|
||||||
|---------|------|-------------|
|
|---------|------|-------------|
|
||||||
| \`serve\` | \`[--port N] [--host ADDR] [--name NAME]\` | Start HTTP API server with auto-tunnel. \`--name\` registers with the gateway. |
|
| \`serve\` | \`[--port N] [--host ADDR] [--name NAME]\` | Start HTTP API server with WebSocket gateway connection. \`--name\` registers with the gateway. |
|
||||||
|
|
||||||
## Typical Workflow
|
## Typical Workflow
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,51 @@
|
|||||||
# @uncaged/workflow-agent-cursor
|
# @uncaged/workflow-agent-cursor
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.5
|
||||||
|
- @uncaged/workflow-reactor@0.4.5
|
||||||
|
- @uncaged/workflow-runtime@0.4.5
|
||||||
|
- @uncaged/workflow-util@0.4.5
|
||||||
|
- @uncaged/workflow-util-agent@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.4
|
||||||
|
- @uncaged/workflow-reactor@0.4.4
|
||||||
|
- @uncaged/workflow-runtime@0.4.4
|
||||||
|
- @uncaged/workflow-util@0.4.4
|
||||||
|
- @uncaged/workflow-util-agent@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.3
|
||||||
|
- @uncaged/workflow-reactor@0.4.3
|
||||||
|
- @uncaged/workflow-runtime@0.4.3
|
||||||
|
- @uncaged/workflow-util-agent@0.4.3
|
||||||
|
- @uncaged/workflow-util@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.2
|
||||||
|
- @uncaged/workflow-reactor@0.4.2
|
||||||
|
- @uncaged/workflow-runtime@0.4.2
|
||||||
|
- @uncaged/workflow-util-agent@0.4.2
|
||||||
|
- @uncaged/workflow-util@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -2,24 +2,11 @@ import { describe, expect, test } from "bun:test";
|
|||||||
import { createCursorAgent, validateCursorAgentConfig } from "../src/index.js";
|
import { createCursorAgent, validateCursorAgentConfig } from "../src/index.js";
|
||||||
|
|
||||||
describe("validateCursorAgentConfig", () => {
|
describe("validateCursorAgentConfig", () => {
|
||||||
test("accepts valid config with explicit workspace", () => {
|
test("accepts valid config", () => {
|
||||||
const r = validateCursorAgentConfig({
|
const r = validateCursorAgentConfig({
|
||||||
command: "/usr/local/bin/cursor-agent",
|
command: "/usr/local/bin/cursor-agent",
|
||||||
model: null,
|
model: null,
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
workspace: "/tmp/test-project",
|
|
||||||
llmProvider: null,
|
|
||||||
});
|
|
||||||
expect(r.ok).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("accepts valid config with null workspace and llmProvider", () => {
|
|
||||||
const r = validateCursorAgentConfig({
|
|
||||||
command: "/usr/local/bin/cursor-agent",
|
|
||||||
model: null,
|
|
||||||
timeout: 0,
|
|
||||||
workspace: null,
|
|
||||||
llmProvider: { baseUrl: "http://localhost", apiKey: "test", model: "test" },
|
|
||||||
});
|
});
|
||||||
expect(r.ok).toBe(true);
|
expect(r.ok).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -29,8 +16,6 @@ describe("validateCursorAgentConfig", () => {
|
|||||||
command: "cursor-agent",
|
command: "cursor-agent",
|
||||||
model: null,
|
model: null,
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
workspace: "/tmp/test-project",
|
|
||||||
llmProvider: null,
|
|
||||||
});
|
});
|
||||||
expect(r.ok).toBe(false);
|
expect(r.ok).toBe(false);
|
||||||
if (!r.ok) {
|
if (!r.ok) {
|
||||||
@@ -38,65 +23,22 @@ describe("validateCursorAgentConfig", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("rejects empty workspace string", () => {
|
|
||||||
const r = validateCursorAgentConfig({
|
|
||||||
command: "/usr/local/bin/cursor-agent",
|
|
||||||
model: null,
|
|
||||||
timeout: 0,
|
|
||||||
workspace: "",
|
|
||||||
llmProvider: null,
|
|
||||||
});
|
|
||||||
expect(r.ok).toBe(false);
|
|
||||||
if (!r.ok) {
|
|
||||||
expect(r.error).toContain("workspace");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test("rejects null workspace without llmProvider", () => {
|
|
||||||
const r = validateCursorAgentConfig({
|
|
||||||
command: "/usr/local/bin/cursor-agent",
|
|
||||||
model: null,
|
|
||||||
timeout: 0,
|
|
||||||
workspace: null,
|
|
||||||
llmProvider: null,
|
|
||||||
});
|
|
||||||
expect(r.ok).toBe(false);
|
|
||||||
if (!r.ok) {
|
|
||||||
expect(r.error).toContain("llmProvider");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test("rejects negative timeout", () => {
|
test("rejects negative timeout", () => {
|
||||||
const r = validateCursorAgentConfig({
|
const r = validateCursorAgentConfig({
|
||||||
command: "/usr/local/bin/cursor-agent",
|
command: "/usr/local/bin/cursor-agent",
|
||||||
model: null,
|
model: null,
|
||||||
timeout: -1,
|
timeout: -1,
|
||||||
workspace: "/tmp/test-project",
|
|
||||||
llmProvider: null,
|
|
||||||
});
|
});
|
||||||
expect(r.ok).toBe(false);
|
expect(r.ok).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("createCursorAgent", () => {
|
describe("createCursorAgent", () => {
|
||||||
test("returns an AdapterFn with explicit workspace", () => {
|
test("returns an AdapterFn", () => {
|
||||||
const agent = createCursorAgent({
|
const agent = createCursorAgent({
|
||||||
command: "/usr/local/bin/cursor-agent",
|
command: "/usr/local/bin/cursor-agent",
|
||||||
model: null,
|
model: null,
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
workspace: "/tmp/test-project",
|
|
||||||
llmProvider: null,
|
|
||||||
});
|
|
||||||
expect(typeof agent).toBe("function");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("returns an AdapterFn with null workspace and llmProvider", () => {
|
|
||||||
const agent = createCursorAgent({
|
|
||||||
command: "/usr/local/bin/cursor-agent",
|
|
||||||
model: null,
|
|
||||||
timeout: 0,
|
|
||||||
workspace: null,
|
|
||||||
llmProvider: { baseUrl: "http://localhost", apiKey: "test", model: "test" },
|
|
||||||
});
|
});
|
||||||
expect(typeof agent).toBe("function");
|
expect(typeof agent).toBe("function");
|
||||||
});
|
});
|
||||||
@@ -106,19 +48,6 @@ describe("createCursorAgent", () => {
|
|||||||
command: "/usr/local/bin/cursor-agent",
|
command: "/usr/local/bin/cursor-agent",
|
||||||
model: null,
|
model: null,
|
||||||
timeout: -1,
|
timeout: -1,
|
||||||
workspace: "/tmp/test-project",
|
|
||||||
llmProvider: null,
|
|
||||||
});
|
|
||||||
expect(typeof agent).toBe("function");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("defers validation — null workspace without llmProvider does not throw at construction", () => {
|
|
||||||
const agent = createCursorAgent({
|
|
||||||
command: "/usr/local/bin/cursor-agent",
|
|
||||||
model: null,
|
|
||||||
timeout: 0,
|
|
||||||
workspace: null,
|
|
||||||
llmProvider: null,
|
|
||||||
});
|
});
|
||||||
expect(typeof agent).toBe("function");
|
expect(typeof agent).toBe("function");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-agent-cursor",
|
"name": "@uncaged/workflow-agent-cursor",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -11,11 +12,11 @@
|
|||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-protocol": "workspace:*",
|
"@uncaged/workflow-cas": "workspace:^",
|
||||||
"@uncaged/workflow-reactor": "workspace:*",
|
"@uncaged/workflow-protocol": "workspace:^",
|
||||||
"@uncaged/workflow-runtime": "workspace:*",
|
"@uncaged/workflow-runtime": "workspace:^",
|
||||||
"@uncaged/workflow-util": "workspace:*",
|
"@uncaged/workflow-util": "workspace:^",
|
||||||
"@uncaged/workflow-util-agent": "workspace:*",
|
"@uncaged/workflow-util-agent": "workspace:^",
|
||||||
"zod": "^4.0.0"
|
"zod": "^4.0.0"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
@@ -24,5 +25,8 @@
|
|||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { AgentContext, LlmProvider } from "@uncaged/workflow-protocol";
|
import { putContentNodeWithRefs } from "@uncaged/workflow-cas";
|
||||||
import { createLlmFn, createThreadReactor } from "@uncaged/workflow-reactor";
|
import type { ThreadContext, WorkflowRuntime } from "@uncaged/workflow-runtime";
|
||||||
import type { LogFn } from "@uncaged/workflow-util";
|
import type { LogFn } from "@uncaged/workflow-util";
|
||||||
import * as z from "zod/v4";
|
import * as z from "zod/v4";
|
||||||
|
|
||||||
@@ -7,10 +7,7 @@ const workspaceSchema = z.object({
|
|||||||
workspace: z.string().describe("Absolute filesystem path of the project workspace"),
|
workspace: z.string().describe("Absolute filesystem path of the project workspace"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const EXTRACT_SYSTEM_FN = (_toolName: string) =>
|
function buildExtractionInput(ctx: ThreadContext): string {
|
||||||
`You are a workspace-path extractor. Given a workflow agent context (task description and previous step outputs), identify the absolute filesystem path of the project workspace where code changes should be made. Call the tool with the absolute path.`;
|
|
||||||
|
|
||||||
function buildExtractionInput(ctx: AgentContext): string {
|
|
||||||
const lines: string[] = [];
|
const lines: string[] = [];
|
||||||
lines.push("## Task");
|
lines.push("## Task");
|
||||||
lines.push(ctx.start.content);
|
lines.push(ctx.start.content);
|
||||||
@@ -21,48 +18,25 @@ function buildExtractionInput(ctx: AgentContext): string {
|
|||||||
lines.push(`Meta: ${JSON.stringify(step.meta)}`);
|
lines.push(`Meta: ${JSON.stringify(step.meta)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lines.push("");
|
||||||
|
lines.push(
|
||||||
|
"Extract the absolute filesystem path of the project workspace where code changes should be made.",
|
||||||
|
);
|
||||||
|
|
||||||
return lines.join("\n");
|
return lines.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function extractWorkspacePath(
|
export async function extractWorkspacePath(
|
||||||
ctx: AgentContext,
|
ctx: ThreadContext,
|
||||||
provider: LlmProvider,
|
runtime: WorkflowRuntime,
|
||||||
logger: LogFn,
|
logger: LogFn,
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
const reactor = createThreadReactor<null>({
|
const input = buildExtractionInput(ctx);
|
||||||
llm: createLlmFn(provider),
|
const contentHash = await putContentNodeWithRefs(runtime.cas, input, []);
|
||||||
maxRounds: 2,
|
|
||||||
staticTools: [],
|
|
||||||
structuredToolFromSchema: (schema) => {
|
|
||||||
const jsonSchema = z.toJSONSchema(schema);
|
|
||||||
return {
|
|
||||||
name: "set_workspace",
|
|
||||||
tool: {
|
|
||||||
type: "function" as const,
|
|
||||||
function: {
|
|
||||||
name: "set_workspace",
|
|
||||||
description: "Set the extracted workspace path",
|
|
||||||
parameters: jsonSchema as Record<string, unknown>,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
systemPromptForStructuredTool: EXTRACT_SYSTEM_FN,
|
|
||||||
toolHandler: async () => "unknown tool",
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await reactor({
|
const result = await runtime.extract(workspaceSchema, contentHash);
|
||||||
thread: null,
|
const workspace = result.meta.workspace.trim();
|
||||||
input: buildExtractionInput(ctx),
|
|
||||||
schema: workspaceSchema,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!result.ok) {
|
|
||||||
logger("W8KN3QYT", `workspace extraction failed: ${result.error}`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const workspace = result.value.workspace.trim();
|
|
||||||
if (!workspace.startsWith("/")) {
|
if (!workspace.startsWith("/")) {
|
||||||
logger("H4PM7RXV", `workspace extraction returned non-absolute path: ${workspace}`);
|
logger("H4PM7RXV", `workspace extraction returned non-absolute path: ${workspace}`);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { AdapterFn } from "@uncaged/workflow-runtime";
|
import type { WorkflowRuntime } from "@uncaged/workflow-runtime";
|
||||||
import { createLogger } from "@uncaged/workflow-util";
|
import { createLogger } from "@uncaged/workflow-util";
|
||||||
import {
|
import {
|
||||||
buildThreadInput,
|
buildThreadInput,
|
||||||
@@ -33,34 +33,23 @@ function resolveCursorModel(model: string | null): string {
|
|||||||
return model === null ? "auto" : model;
|
return model === null ? "auto" : model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Runs `cursor-agent` with workspace from config or extracted from context via LLM. */
|
/** Runs `cursor-agent` with workspace extracted from thread context via runtime.extract. */
|
||||||
export function createCursorAgent(config: CursorAgentConfig): AdapterFn {
|
export function createCursorAgent(config: CursorAgentConfig) {
|
||||||
const modelFlag = resolveCursorModel(config.model);
|
const modelFlag = resolveCursorModel(config.model);
|
||||||
const timeoutMs = config.timeout > 0 ? config.timeout : null;
|
const timeoutMs = config.timeout > 0 ? config.timeout : null;
|
||||||
const logger = createLogger({ sink: { kind: "stderr" } });
|
const logger = createLogger({ sink: { kind: "stderr" } });
|
||||||
|
|
||||||
return createTextAdapter(async (ctx, prompt) => {
|
return createTextAdapter(async (ctx, prompt, runtime: WorkflowRuntime) => {
|
||||||
const validated = validateCursorAgentConfig(config);
|
const validated = validateCursorAgentConfig(config);
|
||||||
if (!validated.ok) {
|
if (!validated.ok) {
|
||||||
throw new Error(validated.error);
|
throw new Error(validated.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
let workspace: string;
|
const workspace = await extractWorkspacePath(ctx, runtime, logger);
|
||||||
|
if (workspace === null) {
|
||||||
if (config.workspace !== null) {
|
throw new Error(
|
||||||
workspace = config.workspace;
|
"cursor-agent: failed to extract workspace path from context. Ensure the task prompt or previous steps include a project path.",
|
||||||
} else {
|
);
|
||||||
if (config.llmProvider === null) {
|
|
||||||
throw new Error("cursor-agent: llmProvider is required when workspace is null");
|
|
||||||
}
|
|
||||||
const agentCtx = { ...ctx, currentRole: { name: "cursor", systemPrompt: prompt } };
|
|
||||||
const extracted = await extractWorkspacePath(agentCtx, config.llmProvider, logger);
|
|
||||||
if (extracted === null) {
|
|
||||||
throw new Error(
|
|
||||||
"cursor-agent: failed to extract workspace path from context. Provide an explicit workspace or ensure previous steps include a repoPath.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
workspace = extracted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger("R5HN3YKQ", `cursor-agent workspace: ${workspace}`);
|
logger("R5HN3YKQ", `cursor-agent workspace: ${workspace}`);
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
import type { LlmProvider } from "@uncaged/workflow-protocol";
|
|
||||||
|
|
||||||
export type CursorAgentConfig = {
|
export type CursorAgentConfig = {
|
||||||
/** Absolute path to the cursor-agent CLI binary. */
|
/** Absolute path to the cursor-agent CLI binary. */
|
||||||
command: string;
|
command: string;
|
||||||
model: string | null;
|
model: string | null;
|
||||||
timeout: number;
|
timeout: number;
|
||||||
/** Explicit workspace path. When `null`, the agent extracts workspace from AgentContext via a ReAct LLM call. */
|
|
||||||
workspace: string | null;
|
|
||||||
/** Required when `workspace` is `null` — LLM provider used for workspace extraction. */
|
|
||||||
llmProvider: LlmProvider | null;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,12 +8,6 @@ export function validateCursorAgentConfig(config: CursorAgentConfig): Result<voi
|
|||||||
if (!isAbsolute(config.command)) {
|
if (!isAbsolute(config.command)) {
|
||||||
return err("command must be an absolute path to the cursor-agent CLI binary");
|
return err("command must be an absolute path to the cursor-agent CLI binary");
|
||||||
}
|
}
|
||||||
if (config.workspace !== null && config.workspace.length === 0) {
|
|
||||||
return err("workspace must be a non-empty string (absolute path) or null for auto-detection");
|
|
||||||
}
|
|
||||||
if (config.workspace === null && config.llmProvider === null) {
|
|
||||||
return err("llmProvider is required when workspace is null (needed for workspace extraction)");
|
|
||||||
}
|
|
||||||
if (config.timeout < 0) {
|
if (config.timeout < 0) {
|
||||||
return err("timeout must be a non-negative number (milliseconds); use 0 for no limit");
|
return err("timeout must be a non-negative number (milliseconds); use 0 for no limit");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,37 @@
|
|||||||
# @uncaged/workflow-agent-hermes
|
# @uncaged/workflow-agent-hermes
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @uncaged/workflow-runtime@0.4.5
|
||||||
|
- @uncaged/workflow-util-agent@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @uncaged/workflow-runtime@0.4.4
|
||||||
|
- @uncaged/workflow-util-agent@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-runtime@0.4.3
|
||||||
|
- @uncaged/workflow-util-agent@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-runtime@0.4.2
|
||||||
|
- @uncaged/workflow-util-agent@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-agent-hermes",
|
"name": "@uncaged/workflow-agent-hermes",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -11,8 +12,8 @@
|
|||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-runtime": "workspace:*",
|
"@uncaged/workflow-runtime": "workspace:^",
|
||||||
"@uncaged/workflow-util-agent": "workspace:*"
|
"@uncaged/workflow-util-agent": "workspace:^"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
@@ -20,5 +21,8 @@
|
|||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function throwHermesSpawnError(error: SpawnCliError): never {
|
|||||||
export function createHermesAgent(config: HermesAgentConfig): AdapterFn {
|
export function createHermesAgent(config: HermesAgentConfig): AdapterFn {
|
||||||
const timeoutMs = config.timeout;
|
const timeoutMs = config.timeout;
|
||||||
|
|
||||||
return createTextAdapter(async (ctx, prompt) => {
|
return createTextAdapter(async (ctx, prompt, _runtime) => {
|
||||||
const validated = validateHermesAgentConfig(config);
|
const validated = validateHermesAgentConfig(config);
|
||||||
if (!validated.ok) {
|
if (!validated.ok) {
|
||||||
throw new Error(validated.error);
|
throw new Error(validated.error);
|
||||||
|
|||||||
@@ -1,5 +1,37 @@
|
|||||||
# @uncaged/workflow-agent-llm
|
# @uncaged/workflow-agent-llm
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @uncaged/workflow-runtime@0.4.5
|
||||||
|
- @uncaged/workflow-util-agent@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @uncaged/workflow-runtime@0.4.4
|
||||||
|
- @uncaged/workflow-util-agent@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-runtime@0.4.3
|
||||||
|
- @uncaged/workflow-util-agent@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-runtime@0.4.2
|
||||||
|
- @uncaged/workflow-util-agent@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-agent-llm",
|
"name": "@uncaged/workflow-agent-llm",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -11,8 +12,8 @@
|
|||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-runtime": "workspace:*",
|
"@uncaged/workflow-runtime": "workspace:^",
|
||||||
"@uncaged/workflow-util-agent": "workspace:*"
|
"@uncaged/workflow-util-agent": "workspace:^"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"zod": "^4.0.0"
|
"zod": "^4.0.0"
|
||||||
@@ -23,5 +24,8 @@
|
|||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export async function chatCompletionText(options: {
|
|||||||
|
|
||||||
/** Single-turn chat adapter: system prompt is passed by the workflow engine. */
|
/** Single-turn chat adapter: system prompt is passed by the workflow engine. */
|
||||||
export function createLlmAdapter(provider: LlmProvider): AdapterFn {
|
export function createLlmAdapter(provider: LlmProvider): AdapterFn {
|
||||||
return createTextAdapter(async (ctx, prompt) => {
|
return createTextAdapter(async (ctx, prompt, _runtime) => {
|
||||||
const result = await chatCompletionText({
|
const result = await chatCompletionText({
|
||||||
provider,
|
provider,
|
||||||
messages: [
|
messages: [
|
||||||
|
|||||||
@@ -1,5 +1,43 @@
|
|||||||
# @uncaged/workflow-agent-react
|
# @uncaged/workflow-agent-react
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.5
|
||||||
|
- @uncaged/workflow-reactor@0.4.5
|
||||||
|
- @uncaged/workflow-util-agent@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.4
|
||||||
|
- @uncaged/workflow-reactor@0.4.4
|
||||||
|
- @uncaged/workflow-util-agent@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.3
|
||||||
|
- @uncaged/workflow-reactor@0.4.3
|
||||||
|
- @uncaged/workflow-util-agent@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.2
|
||||||
|
- @uncaged/workflow-reactor@0.4.2
|
||||||
|
- @uncaged/workflow-util-agent@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-agent-react",
|
"name": "@uncaged/workflow-agent-react",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -18,14 +19,17 @@
|
|||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-protocol": "workspace:*",
|
"@uncaged/workflow-protocol": "workspace:^",
|
||||||
"@uncaged/workflow-reactor": "workspace:*",
|
"@uncaged/workflow-reactor": "workspace:^",
|
||||||
"@uncaged/workflow-util-agent": "workspace:*"
|
"@uncaged/workflow-util-agent": "workspace:^"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"zod": "^4.0.0"
|
"zod": "^4.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"zod": "^4.0.0"
|
"zod": "^4.0.0"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,39 @@
|
|||||||
# @uncaged/workflow-cas
|
# @uncaged/workflow-cas
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.5
|
||||||
|
- @uncaged/workflow-util@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.4
|
||||||
|
- @uncaged/workflow-util@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.3
|
||||||
|
- @uncaged/workflow-util@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.2
|
||||||
|
- @uncaged/workflow-util@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-cas",
|
"name": "@uncaged/workflow-cas",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -17,12 +18,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-protocol": "workspace:*",
|
"@uncaged/workflow-protocol": "workspace:^",
|
||||||
"@uncaged/workflow-util": "workspace:*",
|
"@uncaged/workflow-util": "workspace:^",
|
||||||
"xxhashjs": "^0.2.2",
|
"xxhashjs": "^0.2.2",
|
||||||
"yaml": "^2.7.1"
|
"yaml": "^2.7.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "latest"
|
"@types/bun": "latest"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { BaseEdge, EdgeLabelRenderer, type EdgeProps, getSmoothStepPath } from "@xyflow/react";
|
||||||
BaseEdge,
|
|
||||||
EdgeLabelRenderer,
|
|
||||||
type EdgeProps,
|
|
||||||
getSmoothStepPath,
|
|
||||||
} from "@xyflow/react";
|
|
||||||
import type { ConditionEdgeData } from "./types.ts";
|
import type { ConditionEdgeData } from "./types.ts";
|
||||||
|
|
||||||
// Must match the FEEDBACK_OFFSET_X in use-layout.ts
|
// Must match the FEEDBACK_OFFSET_X in use-layout.ts
|
||||||
@@ -15,12 +10,7 @@ const FEEDBACK_RADIUS = 16;
|
|||||||
* Build an SVG path for a feedback (back) edge that routes to the right of the nodes.
|
* Build an SVG path for a feedback (back) edge that routes to the right of the nodes.
|
||||||
* The path goes: source right → arc → vertical up → arc → target right
|
* The path goes: source right → arc → vertical up → arc → target right
|
||||||
*/
|
*/
|
||||||
function feedbackPath(
|
function feedbackPath(sourceX: number, sourceY: number, targetX: number, targetY: number): string {
|
||||||
sourceX: number,
|
|
||||||
sourceY: number,
|
|
||||||
targetX: number,
|
|
||||||
targetY: number,
|
|
||||||
): string {
|
|
||||||
const rightX = Math.max(sourceX, targetX) + FEEDBACK_OFFSET_X;
|
const rightX = Math.max(sourceX, targetX) + FEEDBACK_OFFSET_X;
|
||||||
const r = FEEDBACK_RADIUS;
|
const r = FEEDBACK_RADIUS;
|
||||||
|
|
||||||
@@ -42,6 +32,7 @@ function feedbackPath(
|
|||||||
return segments.join(" ");
|
return segments.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: edge routing logic is inherently branchy
|
||||||
export function ConditionEdge(props: EdgeProps) {
|
export function ConditionEdge(props: EdgeProps) {
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { Edge, Node } from "@xyflow/react";
|
import type { Edge, Node } from "@xyflow/react";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import type { WorkflowGraphEdge } from "../../api.ts";
|
import type { WorkflowGraphEdge } from "../../api.ts";
|
||||||
import type { ConditionEdgeData, NodeState, RoleNodeData, TerminalNodeData } from "./types.ts";
|
import type { NodeState, RoleNodeData, TerminalNodeData } from "./types.ts";
|
||||||
|
|
||||||
const START_ID = "__start__";
|
const START_ID = "__start__";
|
||||||
const END_ID = "__end__";
|
const END_ID = "__end__";
|
||||||
@@ -41,6 +41,7 @@ function edgeKey(e: WorkflowGraphEdge): string {
|
|||||||
* Forward edges go from lower rank to higher rank; feedback edges go backwards.
|
* Forward edges go from lower rank to higher rank; feedback edges go backwards.
|
||||||
* Self-loops are neither forward nor feedback — they're handled separately.
|
* Self-loops are neither forward nor feedback — they're handled separately.
|
||||||
*/
|
*/
|
||||||
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: topological sort is inherently branchy
|
||||||
function extractSpine(edges: readonly WorkflowGraphEdge[]): string[] {
|
function extractSpine(edges: readonly WorkflowGraphEdge[]): string[] {
|
||||||
// Collect all node IDs
|
// Collect all node IDs
|
||||||
const ids = new Set<string>();
|
const ids = new Set<string>();
|
||||||
@@ -213,8 +214,8 @@ function computeLayout(input: LayoutInput): LayoutResult {
|
|||||||
isFallback,
|
isFallback,
|
||||||
isFeedback,
|
isFeedback,
|
||||||
isSelfLoop,
|
isSelfLoop,
|
||||||
labelX,
|
labelX,
|
||||||
labelY,
|
labelY,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -223,8 +224,5 @@ function computeLayout(input: LayoutInput): LayoutResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useLayout(input: LayoutInput): LayoutResult {
|
export function useLayout(input: LayoutInput): LayoutResult {
|
||||||
return useMemo(
|
return useMemo(() => computeLayout(input), [input]);
|
||||||
() => computeLayout(input),
|
|
||||||
[input.edges, input.roles, input.nodeStates],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,10 +48,7 @@ function ExpandedWorkflowBody({
|
|||||||
const hasGraph = descriptor !== null && edgeCount > 0;
|
const hasGraph = descriptor !== null && edgeCount > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className="pt-3 border-t flex gap-4" style={{ borderColor: "var(--color-border)" }}>
|
||||||
className="pt-3 border-t flex gap-4"
|
|
||||||
style={{ borderColor: "var(--color-border)" }}
|
|
||||||
>
|
|
||||||
<div className="space-y-3 shrink-0" style={{ minWidth: 200, maxWidth: 280 }}>
|
<div className="space-y-3 shrink-0" style={{ minWidth: 200, maxWidth: 280 }}>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm font-medium" style={{ color: "var(--color-text)" }}>
|
<p className="text-sm font-medium" style={{ color: "var(--color-text)" }}>
|
||||||
@@ -83,7 +80,11 @@ function ExpandedWorkflowBody({
|
|||||||
{hasGraph ? (
|
{hasGraph ? (
|
||||||
<div
|
<div
|
||||||
className="rounded-lg border overflow-hidden flex-1"
|
className="rounded-lg border overflow-hidden flex-1"
|
||||||
style={{ borderColor: "var(--color-border)", background: "var(--color-bg)", minHeight: 500 }}
|
style={{
|
||||||
|
borderColor: "var(--color-border)",
|
||||||
|
background: "var(--color-bg)",
|
||||||
|
minHeight: 500,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="px-3 py-2 text-xs flex justify-between items-center"
|
className="px-3 py-2 text-xs flex justify-between items-center"
|
||||||
|
|||||||
@@ -1,5 +1,55 @@
|
|||||||
# @uncaged/workflow-execute
|
# @uncaged/workflow-execute
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.5
|
||||||
|
- @uncaged/workflow-cas@0.4.5
|
||||||
|
- @uncaged/workflow-reactor@0.4.5
|
||||||
|
- @uncaged/workflow-register@0.4.5
|
||||||
|
- @uncaged/workflow-runtime@0.4.5
|
||||||
|
- @uncaged/workflow-util@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.4
|
||||||
|
- @uncaged/workflow-cas@0.4.4
|
||||||
|
- @uncaged/workflow-reactor@0.4.4
|
||||||
|
- @uncaged/workflow-register@0.4.4
|
||||||
|
- @uncaged/workflow-runtime@0.4.4
|
||||||
|
- @uncaged/workflow-util@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-cas@0.4.3
|
||||||
|
- @uncaged/workflow-protocol@0.4.3
|
||||||
|
- @uncaged/workflow-reactor@0.4.3
|
||||||
|
- @uncaged/workflow-register@0.4.3
|
||||||
|
- @uncaged/workflow-runtime@0.4.3
|
||||||
|
- @uncaged/workflow-util@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-cas@0.4.2
|
||||||
|
- @uncaged/workflow-protocol@0.4.2
|
||||||
|
- @uncaged/workflow-reactor@0.4.2
|
||||||
|
- @uncaged/workflow-register@0.4.2
|
||||||
|
- @uncaged/workflow-runtime@0.4.2
|
||||||
|
- @uncaged/workflow-util@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-execute",
|
"name": "@uncaged/workflow-execute",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -17,12 +18,12 @@
|
|||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-protocol": "workspace:*",
|
"@uncaged/workflow-protocol": "workspace:^",
|
||||||
"@uncaged/workflow-runtime": "workspace:*",
|
"@uncaged/workflow-runtime": "workspace:^",
|
||||||
"@uncaged/workflow-util": "workspace:*",
|
"@uncaged/workflow-util": "workspace:^",
|
||||||
"@uncaged/workflow-cas": "workspace:*",
|
"@uncaged/workflow-cas": "workspace:^",
|
||||||
"@uncaged/workflow-reactor": "workspace:*",
|
"@uncaged/workflow-reactor": "workspace:^",
|
||||||
"@uncaged/workflow-register": "workspace:*",
|
"@uncaged/workflow-register": "workspace:^",
|
||||||
"yaml": "^2.7.1"
|
"yaml": "^2.7.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@@ -30,5 +31,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"zod": "^4.0.0"
|
"zod": "^4.0.0"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
# @uncaged/workflow-gateway
|
# @uncaged/workflow-gateway
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-gateway",
|
"name": "@uncaged/workflow-gateway",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -20,5 +21,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cloudflare/workers-types": "^4.20260425.1",
|
"@cloudflare/workers-types": "^4.20260425.1",
|
||||||
"wrangler": "^4.20.0"
|
"wrangler": "^4.20.0"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,29 @@
|
|||||||
# @uncaged/workflow-protocol
|
# @uncaged/workflow-protocol
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Add publishConfig to all packages for Gitea registry compatibility with changeset publish.
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Test changeset publish with Gitea registry.
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-protocol",
|
"name": "@uncaged/workflow-protocol",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -24,5 +25,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"zod": "^4.0.0",
|
"zod": "^4.0.0",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,35 @@
|
|||||||
# @uncaged/workflow-reactor
|
# @uncaged/workflow-reactor
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-reactor",
|
"name": "@uncaged/workflow-reactor",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-protocol": "workspace:*"
|
"@uncaged/workflow-protocol": "workspace:^"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"zod": "^4.0.0"
|
"zod": "^4.0.0"
|
||||||
@@ -22,5 +23,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"zod": "^4.0.0",
|
"zod": "^4.0.0",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,39 @@
|
|||||||
# @uncaged/workflow-register
|
# @uncaged/workflow-register
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.5
|
||||||
|
- @uncaged/workflow-util@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.4
|
||||||
|
- @uncaged/workflow-util@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.3
|
||||||
|
- @uncaged/workflow-util@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.2
|
||||||
|
- @uncaged/workflow-util@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-register",
|
"name": "@uncaged/workflow-register",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -14,8 +15,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-protocol": "workspace:*",
|
"@uncaged/workflow-protocol": "workspace:^",
|
||||||
"@uncaged/workflow-util": "workspace:*"
|
"@uncaged/workflow-util": "workspace:^"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"acorn": "^8.0.0",
|
"acorn": "^8.0.0",
|
||||||
@@ -27,5 +28,8 @@
|
|||||||
"yaml": "^2.7.1",
|
"yaml": "^2.7.1",
|
||||||
"zod": "^4.0.0",
|
"zod": "^4.0.0",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,39 @@
|
|||||||
# @uncaged/workflow-runtime
|
# @uncaged/workflow-runtime
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.5
|
||||||
|
- @uncaged/workflow-cas@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.4
|
||||||
|
- @uncaged/workflow-cas@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-cas@0.4.3
|
||||||
|
- @uncaged/workflow-protocol@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-cas@0.4.2
|
||||||
|
- @uncaged/workflow-protocol@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-runtime",
|
"name": "@uncaged/workflow-runtime",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -11,8 +12,8 @@
|
|||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-cas": "workspace:*",
|
"@uncaged/workflow-cas": "workspace:^",
|
||||||
"@uncaged/workflow-protocol": "workspace:*"
|
"@uncaged/workflow-protocol": "workspace:^"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"zod": "^4.0.0"
|
"zod": "^4.0.0"
|
||||||
@@ -26,5 +27,8 @@
|
|||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.js"
|
"import": "./dist/index.js"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/**
|
||||||
|
* greet workflow — smoke test entry
|
||||||
|
* Single role: greeter takes a prompt and returns a structured greeting.
|
||||||
|
* 小橘 🍊
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type {
|
||||||
|
AdapterFn,
|
||||||
|
ModeratorTable,
|
||||||
|
RoleFn,
|
||||||
|
RoleResult,
|
||||||
|
ThreadContext,
|
||||||
|
WorkflowDefinition,
|
||||||
|
WorkflowRuntime,
|
||||||
|
} from "@uncaged/workflow-runtime";
|
||||||
|
import { createWorkflow, END, START } from "@uncaged/workflow-runtime";
|
||||||
|
import * as z from "zod/v4";
|
||||||
|
|
||||||
|
type GreetMeta = {
|
||||||
|
greeter: { greeting: string; language: string };
|
||||||
|
};
|
||||||
|
|
||||||
|
const greeterSchema = z.object({
|
||||||
|
greeting: z.string().describe("A friendly greeting message"),
|
||||||
|
language: z.string().describe("The language of the greeting"),
|
||||||
|
});
|
||||||
|
|
||||||
|
const roles: WorkflowDefinition<GreetMeta>["roles"] = {
|
||||||
|
greeter: {
|
||||||
|
description: "Generates a friendly greeting",
|
||||||
|
systemPrompt:
|
||||||
|
"You are a friendly greeter. Given a user prompt, produce a warm greeting. Respond in valid JSON with keys: greeting (string), language (string).",
|
||||||
|
schema: greeterSchema,
|
||||||
|
extractRefs: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const table: ModeratorTable<GreetMeta> = {
|
||||||
|
[START]: [{ condition: "FALLBACK", role: "greeter" }],
|
||||||
|
greeter: [{ condition: "FALLBACK", role: END }],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const descriptor = {
|
||||||
|
name: "greet",
|
||||||
|
description: "A simple greeting workflow for smoke testing",
|
||||||
|
graph: { [START]: ["greeter"], greeter: [END] },
|
||||||
|
roles: { greeter: { description: "Generates a friendly greeting" } },
|
||||||
|
};
|
||||||
|
|
||||||
|
function createLazyAdapter(): AdapterFn {
|
||||||
|
let cached: { baseUrl: string; apiKey: string; model: string } | null = null;
|
||||||
|
function getProvider() {
|
||||||
|
if (cached !== null) return cached;
|
||||||
|
const apiKey = process.env.DASHSCOPE_API_KEY;
|
||||||
|
if (!apiKey) throw new Error("missing env: DASHSCOPE_API_KEY");
|
||||||
|
cached = {
|
||||||
|
baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
||||||
|
apiKey,
|
||||||
|
model: process.env.WORKFLOW_MODEL ?? "qwen-plus",
|
||||||
|
};
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (<T>(prompt: string, schema: z.ZodType<T>): RoleFn<T> => {
|
||||||
|
return async (ctx: ThreadContext, _runtime: WorkflowRuntime): Promise<RoleResult<T>> => {
|
||||||
|
const provider = getProvider();
|
||||||
|
const response = await fetch(`${provider.baseUrl}/chat/completions`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${provider.apiKey}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
model: provider.model,
|
||||||
|
messages: [
|
||||||
|
{ role: "system", content: prompt },
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: `${ctx.start.content}\n\nRespond with JSON: ${JSON.stringify(z.toJSONSchema(schema))}`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
response_format: { type: "json_object" },
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
const body = await response.text();
|
||||||
|
throw new Error(`LLM error ${response.status}: ${body.slice(0, 500)}`);
|
||||||
|
}
|
||||||
|
const data = (await response.json()) as { choices: Array<{ message: { content: string } }> };
|
||||||
|
const text = data.choices[0]?.message?.content;
|
||||||
|
if (!text) throw new Error("Empty LLM response");
|
||||||
|
const parsed = schema.parse(JSON.parse(text));
|
||||||
|
return { meta: parsed, childThread: null };
|
||||||
|
};
|
||||||
|
}) as AdapterFn;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const run = createWorkflow<GreetMeta>(
|
||||||
|
{ roles, table },
|
||||||
|
{ adapter: createLazyAdapter(), overrides: null },
|
||||||
|
);
|
||||||
@@ -1,5 +1,37 @@
|
|||||||
# @uncaged/workflow-template-develop
|
# @uncaged/workflow-template-develop
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @uncaged/workflow-register@0.4.5
|
||||||
|
- @uncaged/workflow-runtime@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @uncaged/workflow-register@0.4.4
|
||||||
|
- @uncaged/workflow-runtime@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-register@0.4.3
|
||||||
|
- @uncaged/workflow-runtime@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-register@0.4.2
|
||||||
|
- @uncaged/workflow-runtime@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import type { DevelopMeta } from "../src/roles.js";
|
|||||||
|
|
||||||
const developModerator = tableToModerator(developTable);
|
const developModerator = tableToModerator(developTable);
|
||||||
|
|
||||||
const DEFAULT_PHASES: PlannerMeta["phases"] = [
|
type PlannedMeta = Extract<PlannerMeta, { status: "planned" }>;
|
||||||
|
|
||||||
|
const DEFAULT_PHASES: PlannedMeta["phases"] = [
|
||||||
{
|
{
|
||||||
hash: "4KNMR2PX",
|
hash: "4KNMR2PX",
|
||||||
title: "Do the work",
|
title: "Do the work",
|
||||||
@@ -36,11 +38,11 @@ function makeCtx(steps: ModeratorContext<DevelopMeta>["steps"]): ModeratorContex
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function plannerStep(phases: PlannerMeta["phases"] = DEFAULT_PHASES): RoleStep<DevelopMeta> {
|
function plannerStep(phases: PlannedMeta["phases"] = DEFAULT_PHASES): RoleStep<DevelopMeta> {
|
||||||
return {
|
return {
|
||||||
role: "planner",
|
role: "planner",
|
||||||
contentHash: "STUBHASHPLANNER001",
|
contentHash: "STUBHASHPLANNER001",
|
||||||
meta: { phases },
|
meta: { status: "planned" as const, phases },
|
||||||
refs: phases.map((p) => p.hash),
|
refs: phases.map((p) => p.hash),
|
||||||
timestamp: 1,
|
timestamp: 1,
|
||||||
};
|
};
|
||||||
@@ -153,7 +155,7 @@ describe("developModerator", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("multiple planner phases → coder until all complete, then reviewer", () => {
|
test("multiple planner phases → coder until all complete, then reviewer", () => {
|
||||||
const phases: PlannerMeta["phases"] = [
|
const phases: PlannedMeta["phases"] = [
|
||||||
{ hash: "AA000001", title: "first phase" },
|
{ hash: "AA000001", title: "first phase" },
|
||||||
{ hash: "AA000002", title: "second phase" },
|
{ hash: "AA000002", title: "second phase" },
|
||||||
];
|
];
|
||||||
@@ -167,7 +169,7 @@ describe("developModerator", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("one-shot coder reports only last phase hash → reviewer (moderator treats as all phases done)", () => {
|
test("one-shot coder reports only last phase hash → reviewer (moderator treats as all phases done)", () => {
|
||||||
const phases: PlannerMeta["phases"] = [
|
const phases: PlannedMeta["phases"] = [
|
||||||
{ hash: "BB000001", title: "setup branch" },
|
{ hash: "BB000001", title: "setup branch" },
|
||||||
{ hash: "BB000002", title: "write tests" },
|
{ hash: "BB000002", title: "write tests" },
|
||||||
{ hash: "BB000003", title: "verify" },
|
{ hash: "BB000003", title: "verify" },
|
||||||
@@ -179,7 +181,7 @@ describe("developModerator", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("unrecognised completedPhase hash → coder retry when budget allows", () => {
|
test("unrecognised completedPhase hash → coder retry when budget allows", () => {
|
||||||
const phases: PlannerMeta["phases"] = [
|
const phases: PlannedMeta["phases"] = [
|
||||||
{ hash: "CC000001", title: "first phase" },
|
{ hash: "CC000001", title: "first phase" },
|
||||||
{ hash: "CC000002", title: "second phase" },
|
{ hash: "CC000002", title: "second phase" },
|
||||||
];
|
];
|
||||||
@@ -187,7 +189,7 @@ describe("developModerator", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("incomplete phases → coder retry (supervisor controls termination)", () => {
|
test("incomplete phases → coder retry (supervisor controls termination)", () => {
|
||||||
const phases: PlannerMeta["phases"] = [
|
const phases: PlannedMeta["phases"] = [
|
||||||
{ hash: "DD000001", title: "first phase" },
|
{ hash: "DD000001", title: "first phase" },
|
||||||
{ hash: "DD000002", title: "second phase" },
|
{ hash: "DD000002", title: "second phase" },
|
||||||
];
|
];
|
||||||
@@ -198,6 +200,17 @@ describe("developModerator", () => {
|
|||||||
expect(developModerator(makeCtx(steps))).toBe("coder");
|
expect(developModerator(makeCtx(steps))).toBe("coder");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("planner aborted → END", () => {
|
||||||
|
const abortedStep: RoleStep<DevelopMeta> = {
|
||||||
|
role: "planner",
|
||||||
|
contentHash: "STUBHASHABORT001",
|
||||||
|
meta: { status: "aborted", reason: "No workspace path provided" },
|
||||||
|
refs: [],
|
||||||
|
timestamp: 1,
|
||||||
|
};
|
||||||
|
expect(developModerator(makeCtx([abortedStep]))).toBe("__end__");
|
||||||
|
});
|
||||||
|
|
||||||
test("committer → END for any committer meta status", () => {
|
test("committer → END for any committer meta status", () => {
|
||||||
const committed = committerStep({ status: "committed", branch: "f", commitSha: "x" });
|
const committed = committerStep({ status: "committed", branch: "f", commitSha: "x" });
|
||||||
const recoverable = committerStep({
|
const recoverable = committerStep({
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-template-develop",
|
"name": "@uncaged/workflow-template-develop",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -17,11 +18,14 @@
|
|||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-register": "workspace:*",
|
"@uncaged/workflow-register": "workspace:^",
|
||||||
"@uncaged/workflow-runtime": "workspace:*",
|
"@uncaged/workflow-runtime": "workspace:^",
|
||||||
"zod": "^4.0.0"
|
"zod": "^4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@uncaged/workflow-protocol": "workspace:*"
|
"@uncaged/workflow-protocol": "workspace:^"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ function coderFinishedAllPlannedPhases(
|
|||||||
|
|
||||||
// ── Conditions ─────────────────────────────────────────────────────
|
// ── Conditions ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
const plannerAborted: ModeratorCondition<DevelopMeta> = {
|
||||||
|
name: "plannerAborted",
|
||||||
|
description: "The planner aborted due to insufficient information",
|
||||||
|
check: (ctx) => {
|
||||||
|
const plannerStep = ctx.steps.find((s) => s.role === "planner");
|
||||||
|
if (plannerStep === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return plannerStep.meta.status === "aborted";
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const allPhasesComplete: ModeratorCondition<DevelopMeta> = {
|
const allPhasesComplete: ModeratorCondition<DevelopMeta> = {
|
||||||
name: "allPhasesComplete",
|
name: "allPhasesComplete",
|
||||||
description: "All planned phases have been completed by the coder",
|
description: "All planned phases have been completed by the coder",
|
||||||
@@ -38,7 +50,7 @@ const allPhasesComplete: ModeratorCondition<DevelopMeta> = {
|
|||||||
if (plannerStep === undefined) {
|
if (plannerStep === undefined) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const phases = plannerStep.meta.phases;
|
const phases = plannerStep.meta.status === "planned" ? plannerStep.meta.phases : [];
|
||||||
if (!Array.isArray(phases)) {
|
if (!Array.isArray(phases)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -71,7 +83,10 @@ const testsPassed: ModeratorCondition<DevelopMeta> = {
|
|||||||
|
|
||||||
const table: ModeratorTable<DevelopMeta> = {
|
const table: ModeratorTable<DevelopMeta> = {
|
||||||
[START]: [{ condition: "FALLBACK", role: "planner" }],
|
[START]: [{ condition: "FALLBACK", role: "planner" }],
|
||||||
planner: [{ condition: "FALLBACK", role: "coder" }],
|
planner: [
|
||||||
|
{ condition: plannerAborted, role: END },
|
||||||
|
{ condition: "FALLBACK", role: "coder" },
|
||||||
|
],
|
||||||
coder: [
|
coder: [
|
||||||
{ condition: allPhasesComplete, role: "reviewer" },
|
{ condition: allPhasesComplete, role: "reviewer" },
|
||||||
{ condition: "FALLBACK", role: "coder" },
|
{ condition: "FALLBACK", role: "coder" },
|
||||||
|
|||||||
@@ -25,7 +25,11 @@ The thread ID (26-char Crockford Base32) appears in the first message. If unsure
|
|||||||
|
|
||||||
## Completing a phase
|
## Completing a phase
|
||||||
|
|
||||||
Report which phase you completed using the phase **hash** (not the title). If you legitimately finish every remaining phase in this single turn, set completedPhase to the **last** phase hash in the plan (the workflow treats that as full completion). List the files you changed and summarize what you did.`;
|
Report which phase you completed using the phase **hash** (not the title). If you legitimately finish every remaining phase in this single turn, set completedPhase to the **last** phase hash in the plan (the workflow treats that as full completion). List the files you changed and summarize what you did.
|
||||||
|
|
||||||
|
## Output rules
|
||||||
|
|
||||||
|
Keep your final response **short** — a brief summary paragraph plus the structured meta output. Do NOT paste diffs, file contents, or code blocks in your response. The actual changes are already on disk; repeating them wastes tokens. Just say what you did and why.`;
|
||||||
|
|
||||||
export const coderRole: RoleDefinition<CoderMeta> = {
|
export const coderRole: RoleDefinition<CoderMeta> = {
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -6,16 +6,27 @@ export const phaseSchema = z.object({
|
|||||||
title: z.string(),
|
title: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const plannerMetaSchema = z.object({
|
export const plannerMetaSchema = z.discriminatedUnion("status", [
|
||||||
phases: z.array(phaseSchema),
|
z.object({
|
||||||
});
|
status: z.literal("planned"),
|
||||||
|
phases: z.array(phaseSchema),
|
||||||
|
}),
|
||||||
|
z.object({
|
||||||
|
status: z.literal("aborted"),
|
||||||
|
reason: z.string().describe("Why the task cannot proceed"),
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
export type PlannerMeta = z.infer<typeof plannerMetaSchema>;
|
export type PlannerMeta = z.infer<typeof plannerMetaSchema>;
|
||||||
|
|
||||||
const PLANNER_SYSTEM = `You are a **planner** for a software task. Break the work into **sequential phases** the coder will execute one at a time.
|
const PLANNER_SYSTEM = `You are a **planner** for a software task. Break the work into **sequential phases** the coder will execute one at a time. **Abort** if the prompt lacks critical information (e.g. no project/workspace path, ambiguous target repo).
|
||||||
|
|
||||||
Run \`uncaged-workflow skill develop\` for thread ID lookup, CAS commands, and meta output guide.
|
Run \`uncaged-workflow skill develop\` for thread ID lookup, CAS commands, and meta output guide.
|
||||||
|
|
||||||
|
## Prerequisites — check FIRST
|
||||||
|
|
||||||
|
The prompt MUST include an **absolute filesystem path** to the project workspace (e.g. \`/home/user/repos/my-project\`). If no workspace path is given and you cannot reliably infer one from context, **abort immediately** with a clear reason explaining what information is missing. Do NOT guess paths.
|
||||||
|
|
||||||
## Storing phase details — MANDATORY
|
## Storing phase details — MANDATORY
|
||||||
|
|
||||||
For each phase, store its full detail text in CAS via \`uncaged-workflow cas put '<content>'\`. The command prints a content-hash — use that as the phase identifier.
|
For each phase, store its full detail text in CAS via \`uncaged-workflow cas put '<content>'\`. The command prints a content-hash — use that as the phase identifier.
|
||||||
@@ -37,13 +48,20 @@ Fewer phases is always better. Each phase must justify its existence — if two
|
|||||||
## Output format
|
## Output format
|
||||||
|
|
||||||
After storing all phases via the CLI, output compact JSON only:
|
After storing all phases via the CLI, output compact JSON only:
|
||||||
{ "phases": [{ "hash": "<hash-from-cas-put>", "title": "<one-line-summary>" }] }
|
{ "status": "planned", "phases": [{ "hash": "<hash-from-cas-put>", "title": "<one-line-summary>" }] }
|
||||||
|
|
||||||
Order phases so earlier steps unblock later ones. Cover root cause, edge cases, and verification across the phases.`;
|
If aborting:
|
||||||
|
{ "status": "aborted", "reason": "<what is missing>" }
|
||||||
|
|
||||||
|
Order phases so earlier steps unblock later ones. Cover root cause, edge cases, and verification across the phases.
|
||||||
|
|
||||||
|
## Output rules
|
||||||
|
|
||||||
|
Keep your final response **short** — just the JSON with phases. Do NOT paste code snippets, diffs, or implementation details in your response. Phase details are already stored in CAS; your response should only contain the compact phases JSON.`;
|
||||||
|
|
||||||
export const plannerRole: RoleDefinition<PlannerMeta> = {
|
export const plannerRole: RoleDefinition<PlannerMeta> = {
|
||||||
description: "Breaks the task into sequential phases for the coder.",
|
description: "Breaks the task into sequential phases for the coder.",
|
||||||
systemPrompt: PLANNER_SYSTEM,
|
systemPrompt: PLANNER_SYSTEM,
|
||||||
schema: plannerMetaSchema,
|
schema: plannerMetaSchema,
|
||||||
extractRefs: (meta) => meta.phases.map((p) => p.hash),
|
extractRefs: (meta) => (meta.status === "planned" ? meta.phases.map((p) => p.hash) : []),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ const REVIEWER_SYSTEM = `You are a code reviewer. Review the git diff for correc
|
|||||||
- **Approve** only if there are zero issues
|
- **Approve** only if there are zero issues
|
||||||
- **Reject** with specific issues that must be fixed — every issue you find is blocking
|
- **Reject** with specific issues that must be fixed — every issue you find is blocking
|
||||||
|
|
||||||
Be thorough. A false approve costs more than a false reject.`;
|
Be thorough. A false approve costs more than a false reject.
|
||||||
|
|
||||||
|
## Output rules
|
||||||
|
|
||||||
|
Keep your final response **short**. Summarize findings in a few bullet points, then output the structured verdict. Do NOT paste the full diff or large code blocks in your response.`;
|
||||||
|
|
||||||
export const reviewerRole: RoleDefinition<ReviewerMeta> = {
|
export const reviewerRole: RoleDefinition<ReviewerMeta> = {
|
||||||
description: "Runs git diff checks and sets approved when the change is ready.",
|
description: "Runs git diff checks and sets approved when the change is ready.",
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ export const testerMetaSchema = z.discriminatedUnion("status", [
|
|||||||
|
|
||||||
export type TesterMeta = z.infer<typeof testerMetaSchema>;
|
export type TesterMeta = z.infer<typeof testerMetaSchema>;
|
||||||
|
|
||||||
const TESTER_SYSTEM = `You are a tester. Run the project's test suite, build, and lint commands. Check what commands are available from the preparer's output in the thread. Report pass/fail with details of what failed.`;
|
const TESTER_SYSTEM = `You are a tester. Run the project's test suite, build, and lint commands. Check what commands are available from the preparer's output in the thread. Report pass/fail with details of what failed.
|
||||||
|
|
||||||
|
## Output rules
|
||||||
|
|
||||||
|
Keep your final response **short**. Report pass/fail with a brief summary of failures (if any). Do NOT paste full test output or build logs — just the key error lines.`;
|
||||||
|
|
||||||
export const testerRole: RoleDefinition<TesterMeta> = {
|
export const testerRole: RoleDefinition<TesterMeta> = {
|
||||||
description: "Runs test, build, and lint commands and reports pass or fail with details.",
|
description: "Runs test, build, and lint commands and reports pass or fail with details.",
|
||||||
|
|||||||
@@ -1,5 +1,37 @@
|
|||||||
# @uncaged/workflow-template-solve-issue
|
# @uncaged/workflow-template-solve-issue
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @uncaged/workflow-register@0.4.5
|
||||||
|
- @uncaged/workflow-runtime@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @uncaged/workflow-register@0.4.4
|
||||||
|
- @uncaged/workflow-runtime@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-register@0.4.3
|
||||||
|
- @uncaged/workflow-runtime@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-register@0.4.2
|
||||||
|
- @uncaged/workflow-runtime@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-template-solve-issue",
|
"name": "@uncaged/workflow-template-solve-issue",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -17,13 +18,16 @@
|
|||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-register": "workspace:*",
|
"@uncaged/workflow-register": "workspace:^",
|
||||||
"@uncaged/workflow-runtime": "workspace:*",
|
"@uncaged/workflow-runtime": "workspace:^",
|
||||||
"zod": "^4.0.0"
|
"zod": "^4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@uncaged/workflow-cas": "workspace:*",
|
"@uncaged/workflow-cas": "workspace:^",
|
||||||
"@uncaged/workflow-execute": "workspace:*",
|
"@uncaged/workflow-execute": "workspace:^",
|
||||||
"@uncaged/workflow-protocol": "workspace:*"
|
"@uncaged/workflow-protocol": "workspace:^"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,37 @@
|
|||||||
# @uncaged/workflow-util-agent
|
# @uncaged/workflow-util-agent
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @uncaged/workflow-cas@0.4.5
|
||||||
|
- @uncaged/workflow-runtime@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @uncaged/workflow-cas@0.4.4
|
||||||
|
- @uncaged/workflow-runtime@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-cas@0.4.3
|
||||||
|
- @uncaged/workflow-runtime@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-cas@0.4.2
|
||||||
|
- @uncaged/workflow-runtime@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-util-agent",
|
"name": "@uncaged/workflow-util-agent",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -18,8 +19,11 @@
|
|||||||
"test": "bun test"
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-runtime": "workspace:*",
|
"@uncaged/workflow-runtime": "workspace:^",
|
||||||
"@uncaged/workflow-cas": "workspace:*",
|
"@uncaged/workflow-cas": "workspace:^",
|
||||||
"zod": "^4.0.0"
|
"zod": "^4.0.0"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import type {
|
|||||||
} from "@uncaged/workflow-runtime";
|
} from "@uncaged/workflow-runtime";
|
||||||
import type * as z from "zod/v4";
|
import type * as z from "zod/v4";
|
||||||
|
|
||||||
|
export type { WorkflowRuntime } from "@uncaged/workflow-runtime";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result from a text-producing agent (CLI spawn, LLM call, etc.).
|
* Result from a text-producing agent (CLI spawn, LLM call, etc.).
|
||||||
* `output` is the raw text; `childThread` links to a spawned sub-workflow.
|
* `output` is the raw text; `childThread` links to a spawned sub-workflow.
|
||||||
@@ -23,6 +25,7 @@ export type TextAdapterResult = {
|
|||||||
export type TextProducerFn = (
|
export type TextProducerFn = (
|
||||||
ctx: ThreadContext,
|
ctx: ThreadContext,
|
||||||
prompt: string,
|
prompt: string,
|
||||||
|
runtime: WorkflowRuntime,
|
||||||
) => Promise<string | TextAdapterResult>;
|
) => Promise<string | TextAdapterResult>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +40,7 @@ export type TextProducerFn = (
|
|||||||
export function createTextAdapter(producer: TextProducerFn): AdapterFn {
|
export function createTextAdapter(producer: TextProducerFn): AdapterFn {
|
||||||
return <T>(prompt: string, schema: z.ZodType<T>) => {
|
return <T>(prompt: string, schema: z.ZodType<T>) => {
|
||||||
return async (ctx: ThreadContext, runtime: WorkflowRuntime): Promise<RoleResult<T>> => {
|
return async (ctx: ThreadContext, runtime: WorkflowRuntime): Promise<RoleResult<T>> => {
|
||||||
const result = await producer(ctx, prompt);
|
const result = await producer(ctx, prompt, runtime);
|
||||||
const output = typeof result === "string" ? result : result.output;
|
const output = typeof result === "string" ? result : result.output;
|
||||||
const childThread = typeof result === "string" ? null : result.childThread;
|
const childThread = typeof result === "string" ? null : result.childThread;
|
||||||
const contentHash = await putContentNodeWithRefs(runtime.cas, output, []);
|
const contentHash = await putContentNodeWithRefs(runtime.cas, output, []);
|
||||||
|
|||||||
@@ -1,5 +1,35 @@
|
|||||||
# @uncaged/workflow-util
|
# @uncaged/workflow-util
|
||||||
|
|
||||||
|
## 0.4.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.5
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.4
|
||||||
|
|
||||||
|
## 0.4.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Include src/ in published packages so bun runtime can resolve the 'bun' exports condition.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.3
|
||||||
|
|
||||||
|
## 0.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix workspace dependency resolution: use workspace:^ so published packages resolve to compatible versions instead of exact (non-existent) versions.
|
||||||
|
- Updated dependencies
|
||||||
|
- @uncaged/workflow-protocol@0.4.2
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@uncaged/workflow-util",
|
"name": "@uncaged/workflow-util",
|
||||||
"version": "0.4.0",
|
"version": "0.4.5",
|
||||||
"files": [
|
"files": [
|
||||||
|
"src",
|
||||||
"dist",
|
"dist",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
@@ -14,9 +15,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uncaged/workflow-protocol": "workspace:*"
|
"@uncaged/workflow-protocol": "workspace:^"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Executable
+24
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Validate Crockford Base32 log tags in .log("TAG", ...) calls.
|
||||||
|
# Crockford Base32 excludes: I, L, O, U
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
BAD=0
|
||||||
|
|
||||||
|
while IFS= read -r match; do
|
||||||
|
file="${match%%:*}"
|
||||||
|
rest="${match#*:}"
|
||||||
|
line="${rest%%:*}"
|
||||||
|
tag=$(echo "$rest" | grep -oP '\.log\(\s*"\K[A-Za-z0-9]+')
|
||||||
|
if echo "$tag" | grep -qiE '[ILOU]'; then
|
||||||
|
echo " ❌ ${file}:${line} tag \"${tag}\" contains invalid Crockford Base32 char (I/L/O/U)"
|
||||||
|
BAD=1
|
||||||
|
fi
|
||||||
|
done < <(grep -rn '\.log("[A-Za-z0-9]\{8\}"' "$ROOT/packages/" --include='*.ts' \
|
||||||
|
| grep -v node_modules | grep -v '/dist/')
|
||||||
|
|
||||||
|
if [ "$BAD" -eq 0 ]; then
|
||||||
|
echo " ✅ All log tags are valid Crockford Base32"
|
||||||
|
fi
|
||||||
|
exit $BAD
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# publish.sh — Bump version, build, test, topologically publish @uncaged/* to Gitea npm
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# ./scripts/publish.sh 0.4.0 # explicit version
|
|
||||||
# ./scripts/publish.sh patch # 0.3.1 → 0.3.2
|
|
||||||
# ./scripts/publish.sh minor # 0.3.1 → 0.4.0
|
|
||||||
# ./scripts/publish.sh major # 0.3.1 → 1.0.0
|
|
||||||
# ./scripts/publish.sh --dry-run patch # dry-run bun publish only (no git commit/push)
|
|
||||||
#
|
|
||||||
# Env (via `cfg` or export):
|
|
||||||
# GITEA_TOKEN — Gitea npm registry auth (see root .npmrc)
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
||||||
cd "$REPO_ROOT"
|
|
||||||
|
|
||||||
GITEA_TOKEN="${GITEA_TOKEN:?GITEA_TOKEN is required}"
|
|
||||||
|
|
||||||
REGISTRY="https://git.shazhou.work/api/packages/uncaged/npm/"
|
|
||||||
DRY_RUN=""
|
|
||||||
|
|
||||||
if [[ "${1:-}" == "--dry-run" ]]; then
|
|
||||||
DRY_RUN="--dry-run"
|
|
||||||
shift
|
|
||||||
echo "🔍 Dry run — bun publish will not upload; git commit/push skipped"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ─── Version ─────────────────────────────────────────────────────────────────
|
|
||||||
current_version() {
|
|
||||||
node -e "console.log(require('./packages/workflow-protocol/package.json').version)"
|
|
||||||
}
|
|
||||||
|
|
||||||
bump_version() {
|
|
||||||
local cur="$1" kind="$2"
|
|
||||||
IFS='.' read -r major minor patch <<< "$cur"
|
|
||||||
case "$kind" in
|
|
||||||
patch) echo "${major}.${minor}.$((patch + 1))" ;;
|
|
||||||
minor) echo "${major}.$((minor + 1)).0" ;;
|
|
||||||
major) echo "$((major + 1)).0.0" ;;
|
|
||||||
*) echo "$kind" ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
CURRENT=$(current_version)
|
|
||||||
VERSION=$(bump_version "$CURRENT" "${1:?Usage: publish.sh [--dry-run] <version|patch|minor|major>}")
|
|
||||||
echo "📦 Publish: $CURRENT → $VERSION"
|
|
||||||
|
|
||||||
# ─── Bump version ─────────────────────────────────────────────────────────────
|
|
||||||
echo "🔢 Bumping versions..."
|
|
||||||
for dir in packages/*/; do
|
|
||||||
pkg="$dir/package.json"
|
|
||||||
[[ -f "$pkg" ]] || continue
|
|
||||||
is_private=$(node -e "console.log(require('./$pkg').private || false)")
|
|
||||||
[[ "$is_private" == "true" ]] && continue
|
|
||||||
node -e "
|
|
||||||
const fs = require('fs');
|
|
||||||
const p = JSON.parse(fs.readFileSync('$pkg','utf8'));
|
|
||||||
p.version = '$VERSION';
|
|
||||||
fs.writeFileSync('$pkg', JSON.stringify(p, null, 2) + '\n');
|
|
||||||
"
|
|
||||||
done
|
|
||||||
|
|
||||||
# ─── Topological publish order (workspace:* deps first) ───────────────────────
|
|
||||||
ORDERED=$(python3 -c "
|
|
||||||
import json, sys
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
pkgs_dir = Path('$REPO_ROOT/packages')
|
|
||||||
name_to_dir = {}
|
|
||||||
for d in sorted(pkgs_dir.iterdir()):
|
|
||||||
pj = d / 'package.json'
|
|
||||||
if not pj.exists():
|
|
||||||
continue
|
|
||||||
data = json.loads(pj.read_text())
|
|
||||||
name = data.get('name', '')
|
|
||||||
if not name.startswith('@uncaged/') or data.get('private'):
|
|
||||||
continue
|
|
||||||
name_to_dir[name] = d.name
|
|
||||||
|
|
||||||
deps_graph = {}
|
|
||||||
for name, dirname in name_to_dir.items():
|
|
||||||
pj = pkgs_dir / dirname / 'package.json'
|
|
||||||
data = json.loads(pj.read_text())
|
|
||||||
local_deps = set()
|
|
||||||
for section in ('dependencies', 'devDependencies', 'peerDependencies'):
|
|
||||||
for dep, ver in data.get(section, {}).items():
|
|
||||||
if dep.startswith('@uncaged/') and dep in name_to_dir and ver.startswith('workspace:'):
|
|
||||||
local_deps.add(dep)
|
|
||||||
deps_graph[name] = local_deps
|
|
||||||
|
|
||||||
in_degree = {n: 0 for n in deps_graph}
|
|
||||||
for n, ds in deps_graph.items():
|
|
||||||
in_degree[n] = len(ds)
|
|
||||||
|
|
||||||
queue = sorted([n for n, deg in in_degree.items() if deg == 0])
|
|
||||||
result = []
|
|
||||||
while queue:
|
|
||||||
node = queue.pop(0)
|
|
||||||
result.append(node)
|
|
||||||
for n, ds in deps_graph.items():
|
|
||||||
if node in ds:
|
|
||||||
in_degree[n] -= 1
|
|
||||||
if in_degree[n] == 0:
|
|
||||||
queue.append(n)
|
|
||||||
queue.sort()
|
|
||||||
|
|
||||||
if len(result) != len(deps_graph):
|
|
||||||
missing = set(deps_graph) - set(result)
|
|
||||||
sys.stderr.write('publish: cyclic @uncaged/ workspace:* dependencies among: ' + ', '.join(sorted(missing)) + '\n')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
for name in result:
|
|
||||||
print(name_to_dir[name])
|
|
||||||
")
|
|
||||||
|
|
||||||
# ─── Build ────────────────────────────────────────────────────────────────────
|
|
||||||
echo "🔨 Building..."
|
|
||||||
bun run build
|
|
||||||
|
|
||||||
# ─── Self-test ────────────────────────────────────────────────────────────────
|
|
||||||
echo "🧪 Running tests..."
|
|
||||||
if ! bun test; then
|
|
||||||
echo "❌ Tests failed — aborting publish"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ─── Publish (bun resolves workspace:* for publish) ──────────────────────────
|
|
||||||
echo "🚀 Publishing to $REGISTRY ..."
|
|
||||||
ok=0
|
|
||||||
fail=0
|
|
||||||
|
|
||||||
while IFS= read -r pkg; do
|
|
||||||
[[ -n "$pkg" ]] || continue
|
|
||||||
dir="$REPO_ROOT/packages/$pkg"
|
|
||||||
name=$(node -e "console.log(require('$dir/package.json').name)")
|
|
||||||
|
|
||||||
if ( cd "$dir" && bun publish --registry="$REGISTRY" ${DRY_RUN:+"$DRY_RUN"} ); then
|
|
||||||
echo "✅ $name"
|
|
||||||
ok=$((ok + 1))
|
|
||||||
else
|
|
||||||
echo "⚠️ $name (publish failed or version may already exist)"
|
|
||||||
fail=$((fail + 1))
|
|
||||||
fi
|
|
||||||
|
|
||||||
done <<< "$ORDERED"
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Published: $ok Skipped/Failed: $fail"
|
|
||||||
|
|
||||||
# ─── Commit ───────────────────────────────────────────────────────────────────
|
|
||||||
if [[ -n "$DRY_RUN" ]]; then
|
|
||||||
echo "⏭️ Skipping git commit/push (dry run). Revert bumps with: git checkout -- packages/*/package.json"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "📝 Committing..."
|
|
||||||
git add -A
|
|
||||||
git commit -m "chore: publish v${VERSION}
|
|
||||||
|
|
||||||
小橘 <xiaoju@shazhou.work>"
|
|
||||||
git push
|
|
||||||
|
|
||||||
echo "✅ v${VERSION} published"
|
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/**
|
||||||
|
* greet workflow — smoke test entry
|
||||||
|
* Single role: greeter takes a prompt and returns a structured greeting.
|
||||||
|
* 小橘 🍊
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type {
|
||||||
|
AdapterFn,
|
||||||
|
ModeratorTable,
|
||||||
|
RoleFn,
|
||||||
|
RoleResult,
|
||||||
|
ThreadContext,
|
||||||
|
WorkflowDefinition,
|
||||||
|
WorkflowRuntime,
|
||||||
|
} from "@uncaged/workflow-runtime";
|
||||||
|
import { createWorkflow, END, START } from "@uncaged/workflow-runtime";
|
||||||
|
import * as z from "zod/v4";
|
||||||
|
|
||||||
|
type GreetMeta = {
|
||||||
|
greeter: { greeting: string; language: string };
|
||||||
|
};
|
||||||
|
|
||||||
|
const greeterSchema = z.object({
|
||||||
|
greeting: z.string().describe("A friendly greeting message"),
|
||||||
|
language: z.string().describe("The language of the greeting"),
|
||||||
|
});
|
||||||
|
|
||||||
|
const roles: WorkflowDefinition<GreetMeta>["roles"] = {
|
||||||
|
greeter: {
|
||||||
|
description: "Generates a friendly greeting",
|
||||||
|
systemPrompt:
|
||||||
|
"You are a friendly greeter. Given a user prompt, produce a warm greeting. Respond in valid JSON with keys: greeting (string), language (string).",
|
||||||
|
schema: greeterSchema,
|
||||||
|
extractRefs: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const table: ModeratorTable<GreetMeta> = {
|
||||||
|
[START]: [{ condition: "FALLBACK", role: "greeter" }],
|
||||||
|
greeter: [{ condition: "FALLBACK", role: END }],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const descriptor = {
|
||||||
|
name: "greet",
|
||||||
|
description: "A simple greeting workflow for smoke testing",
|
||||||
|
graph: { [START]: ["greeter"], greeter: [END] },
|
||||||
|
roles: { greeter: { description: "Generates a friendly greeting" } },
|
||||||
|
};
|
||||||
|
|
||||||
|
function createLazyAdapter(): AdapterFn {
|
||||||
|
let cached: { baseUrl: string; apiKey: string; model: string } | null = null;
|
||||||
|
function getProvider() {
|
||||||
|
if (cached !== null) return cached;
|
||||||
|
const apiKey = process.env.DASHSCOPE_API_KEY;
|
||||||
|
if (!apiKey) throw new Error("missing env: DASHSCOPE_API_KEY");
|
||||||
|
cached = {
|
||||||
|
baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
||||||
|
apiKey,
|
||||||
|
model: process.env.WORKFLOW_MODEL ?? "qwen-plus",
|
||||||
|
};
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (<T>(prompt: string, schema: z.ZodType<T>): RoleFn<T> => {
|
||||||
|
return async (ctx: ThreadContext, _runtime: WorkflowRuntime): Promise<RoleResult<T>> => {
|
||||||
|
const provider = getProvider();
|
||||||
|
const response = await fetch(`${provider.baseUrl}/chat/completions`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${provider.apiKey}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
model: provider.model,
|
||||||
|
messages: [
|
||||||
|
{ role: "system", content: prompt },
|
||||||
|
{
|
||||||
|
role: "user",
|
||||||
|
content: `${ctx.start.content}\n\nRespond with JSON: ${JSON.stringify(z.toJSONSchema(schema))}`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
response_format: { type: "json_object" },
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
const body = await response.text();
|
||||||
|
throw new Error(`LLM error ${response.status}: ${body.slice(0, 500)}`);
|
||||||
|
}
|
||||||
|
const data = (await response.json()) as { choices: Array<{ message: { content: string } }> };
|
||||||
|
const text = data.choices[0]?.message?.content;
|
||||||
|
if (!text) throw new Error("Empty LLM response");
|
||||||
|
const parsed = schema.parse(JSON.parse(text));
|
||||||
|
return { meta: parsed, childThread: null };
|
||||||
|
};
|
||||||
|
}) as AdapterFn;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const run = createWorkflow<GreetMeta>(
|
||||||
|
{ roles, table },
|
||||||
|
{ adapter: createLazyAdapter(), overrides: null },
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user