refactor: organize workflow/src into 6 module folders
Move 34 flat modules into cas/, registry/, bundle/, extract/, engine/, util/. Move gc.ts to engine/ (was in cas/) to avoid cas→engine reverse dependency. Dependency direction: util ← cas ← extract ← engine, util ← registry ← bundle. No logic changes — only file locations and import paths. Refs #102
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
|||||||
decodeCrockfordToUint64,
|
decodeCrockfordToUint64,
|
||||||
encodeCrockfordBase32Bits,
|
encodeCrockfordBase32Bits,
|
||||||
encodeUint64AsCrockford,
|
encodeUint64AsCrockford,
|
||||||
} from "../src/base32.js";
|
} from "../src/util/base32.js";
|
||||||
|
|
||||||
describe("Crockford Base32", () => {
|
describe("Crockford Base32", () => {
|
||||||
test("roundtrip 64-bit hash encoding", () => {
|
test("roundtrip 64-bit hash encoding", () => {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
import * as z from "zod/v4";
|
import * as z from "zod/v4";
|
||||||
|
|
||||||
import { buildDescriptor } from "../src/build-descriptor.js";
|
import { buildDescriptor } from "../src/bundle/build-descriptor.js";
|
||||||
|
import { validateWorkflowDescriptor } from "../src/bundle/workflow-descriptor.js";
|
||||||
import { END } from "../src/types.js";
|
import { END } from "../src/types.js";
|
||||||
import { validateWorkflowDescriptor } from "../src/workflow-descriptor.js";
|
|
||||||
|
|
||||||
describe("buildDescriptor", () => {
|
describe("buildDescriptor", () => {
|
||||||
test("produces a descriptor that validates and includes JSON schemas per role", () => {
|
test("produces a descriptor that validates and includes JSON schemas per role", () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
|
|
||||||
import { validateWorkflowBundle } from "../src/bundle-validator.js";
|
import { validateWorkflowBundle } from "../src/bundle/bundle-validator.js";
|
||||||
|
|
||||||
const minimalDescriptor = `export const descriptor = { description: "x", roles: {} };
|
const minimalDescriptor = `export const descriptor = { description: "x", roles: {} };
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { mkdtemp, rm } from "node:fs/promises";
|
|||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import { createCasStore, createThreadCas } from "../src/cas.js";
|
import { createCasStore, createThreadCas } from "../src/cas/cas.js";
|
||||||
import { hashString } from "../src/hash.js";
|
import { hashString } from "../src/cas/hash.js";
|
||||||
|
|
||||||
describe("cas module exports", () => {
|
describe("cas module exports", () => {
|
||||||
test("createThreadCas is a deprecated alias of createCasStore", () => {
|
test("createThreadCas is a deprecated alias of createCasStore", () => {
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ import { tmpdir } from "node:os";
|
|||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import * as z from "zod/v4";
|
import * as z from "zod/v4";
|
||||||
|
|
||||||
import { createCasStore } from "../src/cas.js";
|
import { createCasStore } from "../src/cas/cas.js";
|
||||||
import { createWorkflow } from "../src/create-workflow.js";
|
|
||||||
import { executeThread } from "../src/engine.js";
|
|
||||||
import { createExtract } from "../src/extract-fn.js";
|
|
||||||
import { createLogger } from "../src/logger.js";
|
|
||||||
import {
|
import {
|
||||||
createContentMerkleNode,
|
createContentMerkleNode,
|
||||||
getContentMerklePayload,
|
getContentMerklePayload,
|
||||||
parseMerkleNode,
|
parseMerkleNode,
|
||||||
serializeMerkleNode,
|
serializeMerkleNode,
|
||||||
} from "../src/merkle.js";
|
} from "../src/cas/merkle.js";
|
||||||
|
import { createWorkflow } from "../src/engine/create-workflow.js";
|
||||||
|
import { executeThread } from "../src/engine/engine.js";
|
||||||
|
import { createExtract } from "../src/extract/extract-fn.js";
|
||||||
import { END, type LlmProvider } from "../src/types.js";
|
import { END, type LlmProvider } from "../src/types.js";
|
||||||
|
import { createLogger } from "../src/util/logger.js";
|
||||||
|
|
||||||
const plannerMetaSchema = z.object({
|
const plannerMetaSchema = z.object({
|
||||||
plan: z.string(),
|
plan: z.string(),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
buildForkPlan,
|
buildForkPlan,
|
||||||
parseThreadDataJsonl,
|
parseThreadDataJsonl,
|
||||||
selectForkHistoricalSteps,
|
selectForkHistoricalSteps,
|
||||||
} from "../src/fork-thread.js";
|
} from "../src/engine/fork-thread.js";
|
||||||
|
|
||||||
const sampleDataJsonl = `{"name":"demo","hash":"C9NMV6V2TQT81","threadId":"01AAA1111111111111111111","parameters":{"prompt":"hi","options":{"maxRounds":5}},"timestamp":100}
|
const sampleDataJsonl = `{"name":"demo","hash":"C9NMV6V2TQT81","threadId":"01AAA1111111111111111111","parameters":{"prompt":"hi","options":{"maxRounds":5}},"timestamp":100}
|
||||||
{"role":"planner","contentHash":"HP0000000000000000000001","meta":{},"refs":[],"timestamp":101}
|
{"role":"planner","contentHash":"HP0000000000000000000001","meta":{},"refs":[],"timestamp":101}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
|
import { hashWorkflowBundleBytes } from "../src/cas/hash.js";
|
||||||
import { decodeCrockfordToUint64 } from "../src/base32.js";
|
import { decodeCrockfordToUint64 } from "../src/util/base32.js";
|
||||||
import { hashWorkflowBundleBytes } from "../src/hash.js";
|
|
||||||
|
|
||||||
describe("hashWorkflowBundleBytes", () => {
|
describe("hashWorkflowBundleBytes", () => {
|
||||||
test("matches XXH64 reference for empty input", () => {
|
test("matches XXH64 reference for empty input", () => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { mkdir, readFile, rm } from "node:fs/promises";
|
|||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import { createLogger } from "../src/logger.js";
|
import { createLogger } from "../src/util/logger.js";
|
||||||
|
|
||||||
describe("createLogger", () => {
|
describe("createLogger", () => {
|
||||||
test("writes JSONL records to a file sink", async () => {
|
test("writes JSONL records to a file sink", async () => {
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
|
|
||||||
import { createContentMerkleNode, parseMerkleNode, serializeMerkleNode } from "../src/merkle.js";
|
import {
|
||||||
|
createContentMerkleNode,
|
||||||
|
parseMerkleNode,
|
||||||
|
serializeMerkleNode,
|
||||||
|
} from "../src/cas/merkle.js";
|
||||||
|
|
||||||
describe("merkle", () => {
|
describe("merkle", () => {
|
||||||
test("content node roundtrips through YAML", () => {
|
test("content node roundtrips through YAML", () => {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import { tmpdir } from "node:os";
|
|||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import * as z from "zod/v4";
|
import * as z from "zod/v4";
|
||||||
|
|
||||||
import { createCasStore } from "../src/cas.js";
|
import { createCasStore } from "../src/cas/cas.js";
|
||||||
import { createContentMerkleNode, serializeMerkleNode } from "../src/merkle.js";
|
import { createContentMerkleNode, serializeMerkleNode } from "../src/cas/merkle.js";
|
||||||
import { reactExtract } from "../src/react-extract.js";
|
import { reactExtract } from "../src/extract/react-extract.js";
|
||||||
import type { LlmProvider } from "../src/types.js";
|
import type { LlmProvider } from "../src/types.js";
|
||||||
|
|
||||||
const metaSchema = z.object({ seen: z.string() });
|
const metaSchema = z.object({ seen: z.string() });
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import { tmpdir } from "node:os";
|
|||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import * as z from "zod/v4";
|
import * as z from "zod/v4";
|
||||||
|
|
||||||
import { createCasStore } from "../src/cas.js";
|
import { createCasStore } from "../src/cas/cas.js";
|
||||||
import { createWorkflow } from "../src/create-workflow.js";
|
import { createWorkflow } from "../src/engine/create-workflow.js";
|
||||||
import { executeThread } from "../src/engine.js";
|
import { executeThread } from "../src/engine/engine.js";
|
||||||
import { createExtract } from "../src/extract-fn.js";
|
import { buildForkPlan, parseThreadDataJsonl } from "../src/engine/fork-thread.js";
|
||||||
import { buildForkPlan, parseThreadDataJsonl } from "../src/fork-thread.js";
|
import { createExtract } from "../src/extract/extract-fn.js";
|
||||||
import { createLogger } from "../src/logger.js";
|
|
||||||
import { END } from "../src/types.js";
|
import { END } from "../src/types.js";
|
||||||
|
import { createLogger } from "../src/util/logger.js";
|
||||||
|
|
||||||
const phaseSchema = z.object({
|
const phaseSchema = z.object({
|
||||||
hash: z.string(),
|
hash: z.string(),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
rollbackWorkflowToHistoryHash,
|
rollbackWorkflowToHistoryHash,
|
||||||
unregisterWorkflow,
|
unregisterWorkflow,
|
||||||
writeWorkflowRegistry,
|
writeWorkflowRegistry,
|
||||||
} from "../src/registry.js";
|
} from "../src/registry/registry.js";
|
||||||
|
|
||||||
describe("workflow registry", () => {
|
describe("workflow registry", () => {
|
||||||
test("roundtrips through workflow.yaml", async () => {
|
test("roundtrips through workflow.yaml", async () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
|
|
||||||
import { err, ok } from "../src/result.js";
|
import { err, ok } from "../src/util/result.js";
|
||||||
|
|
||||||
describe("result helpers", () => {
|
describe("result helpers", () => {
|
||||||
test("ok wraps value", () => {
|
test("ok wraps value", () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import { getDefaultWorkflowStorageRoot, getGlobalCasDir } from "../src/storage-root.js";
|
import { getDefaultWorkflowStorageRoot, getGlobalCasDir } from "../src/util/storage-root.js";
|
||||||
|
|
||||||
describe("getGlobalCasDir", () => {
|
describe("getGlobalCasDir", () => {
|
||||||
test("joins cas segment under explicit storage root", () => {
|
test("joins cas segment under explicit storage root", () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
|
|
||||||
import { createThreadPauseGate } from "../src/thread-pause-gate.js";
|
import { createThreadPauseGate } from "../src/engine/thread-pause-gate.js";
|
||||||
|
|
||||||
describe("createThreadPauseGate", () => {
|
describe("createThreadPauseGate", () => {
|
||||||
test("pause blocks awaitAfterYield until resume", async () => {
|
test("pause blocks awaitAfterYield until resume", async () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
|
|
||||||
import { decodeCrockfordBase32Bits } from "../src/base32.js";
|
import { decodeCrockfordBase32Bits } from "../src/util/base32.js";
|
||||||
import { generateUlid } from "../src/ulid.js";
|
import { generateUlid } from "../src/util/ulid.js";
|
||||||
|
|
||||||
describe("generateUlid", () => {
|
describe("generateUlid", () => {
|
||||||
test("length and decodable Crockford payload", () => {
|
test("length and decodable Crockford payload", () => {
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import { createConnection } from "node:net";
|
|||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import { createCasStore } from "../src/cas.js";
|
import { createCasStore } from "../src/cas/cas.js";
|
||||||
import { createContentMerkleNode, serializeMerkleNode } from "../src/merkle.js";
|
import { createContentMerkleNode, serializeMerkleNode } from "../src/cas/merkle.js";
|
||||||
import { getWorkerHostScriptPath } from "../src/worker-entry-path.js";
|
import { getWorkerHostScriptPath } from "../src/engine/worker-entry-path.js";
|
||||||
|
|
||||||
const bundleSource = `import { putContentMerkleNode } from "@uncaged/workflow";
|
const bundleSource = `import { putContentMerkleNode } from "@uncaged/workflow";
|
||||||
|
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ import { tmpdir } from "node:os";
|
|||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import * as z from "zod/v4";
|
import * as z from "zod/v4";
|
||||||
|
|
||||||
import { createCasStore } from "../src/cas.js";
|
import { createCasStore } from "../src/cas/cas.js";
|
||||||
import { createWorkflow } from "../src/create-workflow.js";
|
import { hashWorkflowBundleBytes } from "../src/cas/hash.js";
|
||||||
import { executeThread } from "../src/engine.js";
|
import { getContentMerklePayload, parseMerkleNode } from "../src/cas/merkle.js";
|
||||||
import { createExtract } from "../src/extract-fn.js";
|
import { createWorkflow } from "../src/engine/create-workflow.js";
|
||||||
import { hashWorkflowBundleBytes } from "../src/hash.js";
|
import { executeThread } from "../src/engine/engine.js";
|
||||||
import { createLogger } from "../src/logger.js";
|
import { createExtract } from "../src/extract/extract-fn.js";
|
||||||
import { getContentMerklePayload, parseMerkleNode } from "../src/merkle.js";
|
|
||||||
import {
|
import {
|
||||||
readWorkflowRegistry,
|
readWorkflowRegistry,
|
||||||
registerWorkflowVersion,
|
registerWorkflowVersion,
|
||||||
writeWorkflowRegistry,
|
writeWorkflowRegistry,
|
||||||
} from "../src/registry.js";
|
} from "../src/registry/registry.js";
|
||||||
import { END } from "../src/types.js";
|
import { END } from "../src/types.js";
|
||||||
|
import { createLogger } from "../src/util/logger.js";
|
||||||
import { workflowAsAgent } from "../src/workflow-as-agent.js";
|
import { workflowAsAgent } from "../src/workflow-as-agent.js";
|
||||||
|
|
||||||
const callerMetaSchema = z.object({ done: z.literal(true) });
|
const callerMetaSchema = z.object({ done: z.literal(true) });
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import { createCasStore } from "../src/cas.js";
|
import { createCasStore } from "../src/cas/cas.js";
|
||||||
import { hashWorkflowBundleBytes } from "../src/hash.js";
|
import { hashWorkflowBundleBytes } from "../src/cas/hash.js";
|
||||||
import { parseMerkleNode } from "../src/merkle.js";
|
import { parseMerkleNode } from "../src/cas/merkle.js";
|
||||||
import {
|
import {
|
||||||
readWorkflowRegistry,
|
readWorkflowRegistry,
|
||||||
registerWorkflowVersion,
|
registerWorkflowVersion,
|
||||||
writeWorkflowRegistry,
|
writeWorkflowRegistry,
|
||||||
} from "../src/registry.js";
|
} from "../src/registry/registry.js";
|
||||||
import { type AgentContext, START } from "../src/types.js";
|
import { type AgentContext, START } from "../src/types.js";
|
||||||
import { workflowAsAgent } from "../src/workflow-as-agent.js";
|
import { workflowAsAgent } from "../src/workflow-as-agent.js";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
import { validateWorkflowDescriptor } from "../src/workflow-descriptor.js";
|
import { validateWorkflowDescriptor } from "../src/bundle/workflow-descriptor.js";
|
||||||
|
|
||||||
describe("validateWorkflowDescriptor", () => {
|
describe("validateWorkflowDescriptor", () => {
|
||||||
// 1. Valid minimal descriptor
|
// 1. Valid minimal descriptor
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import * as z from "zod/v4";
|
import * as z from "zod/v4";
|
||||||
|
|
||||||
import type { RoleMeta, WorkflowDefinition } from "./types.js";
|
import type { RoleMeta, WorkflowDefinition } from "../types.js";
|
||||||
import type { WorkflowDescriptor, WorkflowRoleSchema } from "./workflow-descriptor.js";
|
import type { WorkflowDescriptor, WorkflowRoleSchema } from "./workflow-descriptor.js";
|
||||||
|
|
||||||
function stripJsonSchemaMeta(json: Record<string, unknown>): WorkflowRoleSchema {
|
function stripJsonSchemaMeta(json: Record<string, unknown>): WorkflowRoleSchema {
|
||||||
+1
-1
@@ -24,7 +24,7 @@ function narrowNode<T extends Node>(node: Node): T {
|
|||||||
|
|
||||||
import * as acorn from "acorn";
|
import * as acorn from "acorn";
|
||||||
|
|
||||||
import { err, ok, type Result } from "./result.js";
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
|
|
||||||
export type WorkflowBundleValidationInput = {
|
export type WorkflowBundleValidationInput = {
|
||||||
/** Absolute or relative path (used for `.esm.js` suffix checks). */
|
/** Absolute or relative path (used for `.esm.js` suffix checks). */
|
||||||
+2
-2
@@ -2,9 +2,9 @@ import { mkdir, readlink, symlink, unlink } from "node:fs/promises";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
/** This module lives in `@uncaged/workflow/src`; parent dir is the package root. */
|
/** This module lives in `@uncaged/workflow/src/bundle`; grandparent dir is the package root. */
|
||||||
function installedWorkflowPackageDir(): string {
|
function installedWorkflowPackageDir(): string {
|
||||||
return fileURLToPath(new URL("..", import.meta.url));
|
return fileURLToPath(new URL("../..", import.meta.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
|
import type { WorkflowFn } from "../types.js";
|
||||||
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
import { importWorkflowBundleModule } from "./bundle-import-env.js";
|
import { importWorkflowBundleModule } from "./bundle-import-env.js";
|
||||||
import { ensureUncagedWorkflowSymlink } from "./ensure-uncaged-workflow-symlink.js";
|
import { ensureUncagedWorkflowSymlink } from "./ensure-uncaged-workflow-symlink.js";
|
||||||
import { err, ok, type Result } from "./result.js";
|
|
||||||
import type { WorkflowFn } from "./types.js";
|
|
||||||
import type { WorkflowDescriptor } from "./workflow-descriptor.js";
|
import type { WorkflowDescriptor } from "./workflow-descriptor.js";
|
||||||
import { validateWorkflowDescriptor } from "./workflow-descriptor.js";
|
import { validateWorkflowDescriptor } from "./workflow-descriptor.js";
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { err, ok, type Result } from "./result.js";
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
|
|
||||||
/** JSON Schema fragment describing one role's `meta` shape (subset supported by code generation). */
|
/** JSON Schema fragment describing one role's `meta` shape (subset supported by code generation). */
|
||||||
export type WorkflowRoleSchema = Record<string, unknown>;
|
export type WorkflowRoleSchema = Record<string, unknown>;
|
||||||
@@ -2,7 +2,7 @@ import { Buffer } from "node:buffer";
|
|||||||
|
|
||||||
import XXH from "xxhashjs";
|
import XXH from "xxhashjs";
|
||||||
|
|
||||||
import { encodeUint64AsCrockford } from "./base32.js";
|
import { encodeUint64AsCrockford } from "../util/base32.js";
|
||||||
|
|
||||||
function digestToUint64(digest: { toString(radix?: number): string }): bigint {
|
function digestToUint64(digest: { toString(radix?: number): string }): bigint {
|
||||||
const hex = digest.toString(16).padStart(16, "0");
|
const hex = digest.toString(16).padStart(16, "0");
|
||||||
+6
-6
@@ -1,8 +1,7 @@
|
|||||||
import type { CasStore } from "./cas.js";
|
import type { CasStore } from "../cas/cas.js";
|
||||||
import { buildExtractUserContent, type ExtractFn } from "./extract-fn.js";
|
import { putContentMerkleNode } from "../cas/merkle.js";
|
||||||
import { putContentMerkleNode } from "./merkle.js";
|
import { buildExtractUserContent, type ExtractFn } from "../extract/extract-fn.js";
|
||||||
import { reactExtract } from "./react-extract.js";
|
import { reactExtract } from "../extract/react-extract.js";
|
||||||
import { mergeRefsWithContentHash } from "./refs-field.js";
|
|
||||||
import {
|
import {
|
||||||
type AgentBinding,
|
type AgentBinding,
|
||||||
type AgentContext,
|
type AgentContext,
|
||||||
@@ -20,7 +19,8 @@ import {
|
|||||||
type WorkflowDefinition,
|
type WorkflowDefinition,
|
||||||
type WorkflowFn,
|
type WorkflowFn,
|
||||||
type WorkflowFnOptions,
|
type WorkflowFnOptions,
|
||||||
} from "./types.js";
|
} from "../types.js";
|
||||||
|
import { mergeRefsWithContentHash } from "../util/refs-field.js";
|
||||||
|
|
||||||
function isRoleNext<M extends RoleMeta>(
|
function isRoleNext<M extends RoleMeta>(
|
||||||
next: (keyof M & string) | typeof END,
|
next: (keyof M & string) | typeof END,
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
import { appendFile, mkdir } from "node:fs/promises";
|
import { appendFile, mkdir } from "node:fs/promises";
|
||||||
import { dirname } from "node:path";
|
import { dirname } from "node:path";
|
||||||
|
|
||||||
import type { CasStore } from "./cas.js";
|
import type { CasStore } from "../cas/cas.js";
|
||||||
import type { LogFn } from "./logger.js";
|
import { getContentMerklePayload, putStepMerkleNode, putThreadMerkleNode } from "../cas/merkle.js";
|
||||||
import { getContentMerklePayload, putStepMerkleNode, putThreadMerkleNode } from "./merkle.js";
|
|
||||||
import { normalizeRefsField } from "./refs-field.js";
|
|
||||||
import type {
|
import type {
|
||||||
ThreadInput,
|
ThreadInput,
|
||||||
WorkflowCompletion,
|
WorkflowCompletion,
|
||||||
WorkflowFn,
|
WorkflowFn,
|
||||||
WorkflowFnOptions,
|
WorkflowFnOptions,
|
||||||
WorkflowResult,
|
WorkflowResult,
|
||||||
} from "./types.js";
|
} from "../types.js";
|
||||||
|
import type { LogFn } from "../util/logger.js";
|
||||||
|
import { normalizeRefsField } from "../util/refs-field.js";
|
||||||
|
|
||||||
export type ExecuteThreadIo = {
|
export type ExecuteThreadIo = {
|
||||||
threadId: string;
|
threadId: string;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { normalizeRefsField } from "./refs-field.js";
|
import type { RoleOutput, WorkflowCompletion } from "../types.js";
|
||||||
import { err, ok, type Result } from "./result.js";
|
import { normalizeRefsField } from "../util/refs-field.js";
|
||||||
import type { RoleOutput, WorkflowCompletion } from "./types.js";
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
|
|
||||||
/** Role steps replayed from `.data.jsonl`, including persisted timestamps. */
|
/** Role steps replayed from `.data.jsonl`, including persisted timestamps. */
|
||||||
export type ForkHistoricalStep = RoleOutput & { timestamp: number };
|
export type ForkHistoricalStep = RoleOutput & { timestamp: number };
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
import { readdir, readFile } from "node:fs/promises";
|
import { readdir, readFile } from "node:fs/promises";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
import { type CasStore, createCasStore } from "../cas/cas.js";
|
||||||
import { type CasStore, createCasStore } from "./cas.js";
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
|
import { getGlobalCasDir } from "../util/storage-root.js";
|
||||||
import { parseThreadDataJsonl } from "./fork-thread.js";
|
import { parseThreadDataJsonl } from "./fork-thread.js";
|
||||||
import { err, ok, type Result } from "./result.js";
|
|
||||||
import { getGlobalCasDir } from "./storage-root.js";
|
|
||||||
|
|
||||||
export type GcResult = {
|
export type GcResult = {
|
||||||
scannedThreads: number;
|
scannedThreads: number;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { err, ok, type Result } from "./result.js";
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
|
|
||||||
export type ThreadPauseGate = {
|
export type ThreadPauseGate = {
|
||||||
awaitAfterYield: () => Promise<void>;
|
awaitAfterYield: () => Promise<void>;
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
import { appendFile, mkdir, unlink, writeFile } from "node:fs/promises";
|
import { appendFile, mkdir, unlink, writeFile } from "node:fs/promises";
|
||||||
import { createServer, type Socket } from "node:net";
|
import { createServer, type Socket } from "node:net";
|
||||||
import { dirname, join } from "node:path";
|
import { dirname, join } from "node:path";
|
||||||
import { importWorkflowBundleModule } from "./bundle-import-env.js";
|
import { importWorkflowBundleModule } from "../bundle/bundle-import-env.js";
|
||||||
import { createCasStore } from "./cas.js";
|
import { ensureUncagedWorkflowSymlink } from "../bundle/ensure-uncaged-workflow-symlink.js";
|
||||||
|
import { createCasStore } from "../cas/cas.js";
|
||||||
|
import type { RoleOutput, WorkflowFn, WorkflowResult } from "../types.js";
|
||||||
|
import { createLogger } from "../util/logger.js";
|
||||||
|
import { normalizeRefsField } from "../util/refs-field.js";
|
||||||
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
|
import { getGlobalCasDir } from "../util/storage-root.js";
|
||||||
import type { PrefilledDiskStep } from "./engine.js";
|
import type { PrefilledDiskStep } from "./engine.js";
|
||||||
import { type ExecuteThreadIo, executeThread } from "./engine.js";
|
import { type ExecuteThreadIo, executeThread } from "./engine.js";
|
||||||
import { ensureUncagedWorkflowSymlink } from "./ensure-uncaged-workflow-symlink.js";
|
|
||||||
import { createLogger } from "./logger.js";
|
|
||||||
import { normalizeRefsField } from "./refs-field.js";
|
|
||||||
import { err, ok, type Result } from "./result.js";
|
|
||||||
import { getGlobalCasDir } from "./storage-root.js";
|
|
||||||
import { createThreadPauseGate, type ThreadPauseGate } from "./thread-pause-gate.js";
|
import { createThreadPauseGate, type ThreadPauseGate } from "./thread-pause-gate.js";
|
||||||
import type { RoleOutput, WorkflowFn, WorkflowResult } from "./types.js";
|
|
||||||
|
|
||||||
const bootLog = createLogger({ sink: { kind: "stderr" } });
|
const bootLog = createLogger({ sink: { kind: "stderr" } });
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { readWorkflowRegistry } from "./registry.js";
|
import { readWorkflowRegistry } from "./registry/registry.js";
|
||||||
import type { WorkflowConfig } from "./registry-types.js";
|
import type { WorkflowConfig } from "./registry/registry-types.js";
|
||||||
import { err, ok, type Result } from "./result.js";
|
|
||||||
import { getDefaultWorkflowStorageRoot } from "./storage-root.js";
|
|
||||||
import type { LlmProvider } from "./types.js";
|
import type { LlmProvider } from "./types.js";
|
||||||
|
import { err, ok, type Result } from "./util/result.js";
|
||||||
|
import { getDefaultWorkflowStorageRoot } from "./util/storage-root.js";
|
||||||
|
|
||||||
const DEFAULT_WORKFLOW_AS_AGENT_MAX_DEPTH = 3;
|
const DEFAULT_WORKFLOW_AS_AGENT_MAX_DEPTH = 3;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import type * as z from "zod/v4";
|
import type * as z from "zod/v4";
|
||||||
|
import { getContentMerklePayload } from "../cas/merkle.js";
|
||||||
|
import type { ExtractContext, LlmProvider } from "../types.js";
|
||||||
import { llmExtractWithRetry } from "./llm-extract.js";
|
import { llmExtractWithRetry } from "./llm-extract.js";
|
||||||
import { getContentMerklePayload } from "./merkle.js";
|
|
||||||
import type { ExtractContext, LlmProvider } from "./types.js";
|
|
||||||
|
|
||||||
export type ExtractFn = <T extends Record<string, unknown>>(
|
export type ExtractFn = <T extends Record<string, unknown>>(
|
||||||
schema: z.ZodType<T>,
|
schema: z.ZodType<T>,
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import * as z from "zod/v4";
|
import * as z from "zod/v4";
|
||||||
|
import type { LlmProvider } from "../types.js";
|
||||||
import { err, ok, type Result } from "./result.js";
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
import type { LlmProvider } from "./types.js";
|
|
||||||
|
|
||||||
export type LlmExtractArgs<T> = {
|
export type LlmExtractArgs<T> = {
|
||||||
text: string;
|
text: string;
|
||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
import type * as z from "zod/v4";
|
import type * as z from "zod/v4";
|
||||||
|
|
||||||
import type { CasStore } from "./cas.js";
|
import type { CasStore } from "../cas/cas.js";
|
||||||
|
import type { LlmProvider } from "../types.js";
|
||||||
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
import { extractFunctionToolFromZodSchema } from "./llm-extract.js";
|
import { extractFunctionToolFromZodSchema } from "./llm-extract.js";
|
||||||
import { err, ok, type Result } from "./result.js";
|
|
||||||
import type { LlmProvider } from "./types.js";
|
|
||||||
|
|
||||||
export type ReactExtractArgs<T extends Record<string, unknown>> = {
|
export type ReactExtractArgs<T extends Record<string, unknown>> = {
|
||||||
text: string;
|
text: string;
|
||||||
@@ -1,48 +1,21 @@
|
|||||||
|
export { buildDescriptor } from "./bundle/build-descriptor.js";
|
||||||
export {
|
export {
|
||||||
CROCKFORD_BASE32_ALPHABET,
|
validateWorkflowBundle,
|
||||||
decodeCrockfordBase32Bits,
|
type WorkflowBundleValidationInput,
|
||||||
decodeCrockfordToUint64,
|
} from "./bundle/bundle-validator.js";
|
||||||
encodeCrockfordBase32Bits,
|
|
||||||
encodeUint64AsCrockford,
|
|
||||||
} from "./base32.js";
|
|
||||||
export { buildDescriptor } from "./build-descriptor.js";
|
|
||||||
export { validateWorkflowBundle, type WorkflowBundleValidationInput } from "./bundle-validator.js";
|
|
||||||
export { type CasStore, createCasStore, createThreadCas } from "./cas.js";
|
|
||||||
export { createWorkflow } from "./create-workflow.js";
|
|
||||||
export {
|
export {
|
||||||
type ExecuteThreadIo,
|
type ExtractedBundleExports,
|
||||||
type ExecuteThreadOptions,
|
extractBundleExports,
|
||||||
executeThread,
|
} from "./bundle/extract-bundle-exports.js";
|
||||||
type PrefilledDiskStep,
|
export { stringifyWorkflowDescriptor } from "./bundle/generate-descriptor.js";
|
||||||
} from "./engine.js";
|
|
||||||
export { type ExtractedBundleExports, extractBundleExports } from "./extract-bundle-exports.js";
|
|
||||||
export { createExtract, type ExtractFn } from "./extract-fn.js";
|
|
||||||
export { getExtractProvider } from "./extract-provider.js";
|
|
||||||
export {
|
export {
|
||||||
buildForkPlan,
|
validateWorkflowDescriptor,
|
||||||
type ForkHistoricalStep,
|
type WorkflowDescriptor,
|
||||||
type ForkPlan,
|
type WorkflowRoleDescriptor,
|
||||||
type ParsedThreadStartRecord,
|
type WorkflowRoleSchema,
|
||||||
parseThreadDataJsonl,
|
} from "./bundle/workflow-descriptor.js";
|
||||||
selectForkHistoricalSteps,
|
export { type CasStore, createCasStore, createThreadCas } from "./cas/cas.js";
|
||||||
tryParseRoleStepRecord,
|
export { hashString, hashWorkflowBundleBytes } from "./cas/hash.js";
|
||||||
tryParseWorkflowResultRecord,
|
|
||||||
} from "./fork-thread.js";
|
|
||||||
export { type GcResult, garbageCollectCas } from "./gc.js";
|
|
||||||
export { stringifyWorkflowDescriptor } from "./generate-descriptor.js";
|
|
||||||
export { hashString, hashWorkflowBundleBytes } from "./hash.js";
|
|
||||||
export {
|
|
||||||
type LlmError,
|
|
||||||
llmErrorToCause,
|
|
||||||
llmExtract,
|
|
||||||
llmExtractWithRetry,
|
|
||||||
} from "./llm-extract.js";
|
|
||||||
export {
|
|
||||||
type CreateLoggerOptions,
|
|
||||||
createLogger,
|
|
||||||
type LogFn,
|
|
||||||
type LoggerSink,
|
|
||||||
} from "./logger.js";
|
|
||||||
export {
|
export {
|
||||||
createContentMerkleNode,
|
createContentMerkleNode,
|
||||||
getContentMerklePayload,
|
getContentMerklePayload,
|
||||||
@@ -55,8 +28,36 @@ export {
|
|||||||
type StepMerklePayload,
|
type StepMerklePayload,
|
||||||
serializeMerkleNode,
|
serializeMerkleNode,
|
||||||
type ThreadMerklePayload,
|
type ThreadMerklePayload,
|
||||||
} from "./merkle.js";
|
} from "./cas/merkle.js";
|
||||||
export { type ReactExtractArgs, reactExtract } from "./react-extract.js";
|
export { createWorkflow } from "./engine/create-workflow.js";
|
||||||
|
export {
|
||||||
|
type ExecuteThreadIo,
|
||||||
|
type ExecuteThreadOptions,
|
||||||
|
executeThread,
|
||||||
|
type PrefilledDiskStep,
|
||||||
|
} from "./engine/engine.js";
|
||||||
|
export {
|
||||||
|
buildForkPlan,
|
||||||
|
type ForkHistoricalStep,
|
||||||
|
type ForkPlan,
|
||||||
|
type ParsedThreadStartRecord,
|
||||||
|
parseThreadDataJsonl,
|
||||||
|
selectForkHistoricalSteps,
|
||||||
|
tryParseRoleStepRecord,
|
||||||
|
tryParseWorkflowResultRecord,
|
||||||
|
} from "./engine/fork-thread.js";
|
||||||
|
export { type GcResult, garbageCollectCas } from "./engine/gc.js";
|
||||||
|
export { createThreadPauseGate, type ThreadPauseGate } from "./engine/thread-pause-gate.js";
|
||||||
|
export { getWorkerHostScriptPath } from "./engine/worker-entry-path.js";
|
||||||
|
export { createExtract, type ExtractFn } from "./extract/extract-fn.js";
|
||||||
|
export {
|
||||||
|
type LlmError,
|
||||||
|
llmErrorToCause,
|
||||||
|
llmExtract,
|
||||||
|
llmExtractWithRetry,
|
||||||
|
} from "./extract/llm-extract.js";
|
||||||
|
export { type ReactExtractArgs, reactExtract } from "./extract/react-extract.js";
|
||||||
|
export { getExtractProvider } from "./extract-provider.js";
|
||||||
export {
|
export {
|
||||||
type ExtractProviderConfig,
|
type ExtractProviderConfig,
|
||||||
getRegisteredWorkflow,
|
getRegisteredWorkflow,
|
||||||
@@ -73,10 +74,7 @@ export {
|
|||||||
type WorkflowRegistryFile,
|
type WorkflowRegistryFile,
|
||||||
workflowRegistryPath,
|
workflowRegistryPath,
|
||||||
writeWorkflowRegistry,
|
writeWorkflowRegistry,
|
||||||
} from "./registry.js";
|
} from "./registry/registry.js";
|
||||||
export { err, ok, type Result } from "./result.js";
|
|
||||||
export { getDefaultWorkflowStorageRoot, getGlobalCasDir } from "./storage-root.js";
|
|
||||||
export { createThreadPauseGate, type ThreadPauseGate } from "./thread-pause-gate.js";
|
|
||||||
export {
|
export {
|
||||||
type AgentBinding,
|
type AgentBinding,
|
||||||
type AgentContext,
|
type AgentContext,
|
||||||
@@ -101,12 +99,20 @@ export {
|
|||||||
type WorkflowFnOptions,
|
type WorkflowFnOptions,
|
||||||
type WorkflowResult,
|
type WorkflowResult,
|
||||||
} from "./types.js";
|
} from "./types.js";
|
||||||
export { generateUlid } from "./ulid.js";
|
|
||||||
export { getWorkerHostScriptPath } from "./worker-entry-path.js";
|
|
||||||
export { type WorkflowAsAgentOptions, workflowAsAgent } from "./workflow-as-agent.js";
|
|
||||||
export {
|
export {
|
||||||
validateWorkflowDescriptor,
|
CROCKFORD_BASE32_ALPHABET,
|
||||||
type WorkflowDescriptor,
|
decodeCrockfordBase32Bits,
|
||||||
type WorkflowRoleDescriptor,
|
decodeCrockfordToUint64,
|
||||||
type WorkflowRoleSchema,
|
encodeCrockfordBase32Bits,
|
||||||
} from "./workflow-descriptor.js";
|
encodeUint64AsCrockford,
|
||||||
|
} from "./util/base32.js";
|
||||||
|
export {
|
||||||
|
type CreateLoggerOptions,
|
||||||
|
createLogger,
|
||||||
|
type LogFn,
|
||||||
|
type LoggerSink,
|
||||||
|
} from "./util/logger.js";
|
||||||
|
export { err, ok, type Result } from "./util/result.js";
|
||||||
|
export { getDefaultWorkflowStorageRoot, getGlobalCasDir } from "./util/storage-root.js";
|
||||||
|
export { generateUlid } from "./util/ulid.js";
|
||||||
|
export { type WorkflowAsAgentOptions, workflowAsAgent } from "./workflow-as-agent.js";
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,4 @@
|
|||||||
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
import type {
|
import type {
|
||||||
ExtractProviderConfig,
|
ExtractProviderConfig,
|
||||||
WorkflowConfig,
|
WorkflowConfig,
|
||||||
@@ -5,7 +6,6 @@ import type {
|
|||||||
WorkflowRegistryEntry,
|
WorkflowRegistryEntry,
|
||||||
WorkflowRegistryFile,
|
WorkflowRegistryFile,
|
||||||
} from "./registry-types.js";
|
} from "./registry-types.js";
|
||||||
import { err, ok, type Result } from "./result.js";
|
|
||||||
|
|
||||||
function resolveRegistryApiKey(raw: string): Result<string, Error> {
|
function resolveRegistryApiKey(raw: string): Result<string, Error> {
|
||||||
if (raw.startsWith("env:")) {
|
if (raw.startsWith("env:")) {
|
||||||
@@ -2,14 +2,13 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|||||||
import { dirname, join } from "node:path";
|
import { dirname, join } from "node:path";
|
||||||
|
|
||||||
import { parseDocument, stringify } from "yaml";
|
import { parseDocument, stringify } from "yaml";
|
||||||
|
import { err, ok, type Result } from "../util/result.js";
|
||||||
import { normalizeWorkflowRegistryRoot } from "./registry-normalize.js";
|
import { normalizeWorkflowRegistryRoot } from "./registry-normalize.js";
|
||||||
import type {
|
import type {
|
||||||
WorkflowHistoryEntry,
|
WorkflowHistoryEntry,
|
||||||
WorkflowRegistryEntry,
|
WorkflowRegistryEntry,
|
||||||
WorkflowRegistryFile,
|
WorkflowRegistryFile,
|
||||||
} from "./registry-types.js";
|
} from "./registry-types.js";
|
||||||
import { err, ok, type Result } from "./result.js";
|
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
ExtractProviderConfig,
|
ExtractProviderConfig,
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import type * as z from "zod/v4";
|
import type * as z from "zod/v4";
|
||||||
|
|
||||||
import type { CasStore } from "./cas.js";
|
import type { CasStore } from "./cas/cas.js";
|
||||||
|
|
||||||
/** Sentinel values for automaton control flow. */
|
/** Sentinel values for automaton control flow. */
|
||||||
export const START = "__start__" as const;
|
export const START = "__start__" as const;
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
|
||||||
import { createCasStore } from "./cas.js";
|
import { extractBundleExports } from "./bundle/extract-bundle-exports.js";
|
||||||
import { type ExecuteThreadIo, executeThread } from "./engine.js";
|
import { createCasStore } from "./cas/cas.js";
|
||||||
import { extractBundleExports } from "./extract-bundle-exports.js";
|
import { type ExecuteThreadIo, executeThread } from "./engine/engine.js";
|
||||||
import { getWorkflowAsAgentMaxDepth } from "./extract-provider.js";
|
import { getWorkflowAsAgentMaxDepth } from "./extract-provider.js";
|
||||||
import { createLogger } from "./logger.js";
|
import { getRegisteredWorkflow, readWorkflowRegistry } from "./registry/registry.js";
|
||||||
import { getRegisteredWorkflow, readWorkflowRegistry } from "./registry.js";
|
|
||||||
import { getDefaultWorkflowStorageRoot, getGlobalCasDir } from "./storage-root.js";
|
|
||||||
import type { AgentContext, AgentFn, ThreadInput } from "./types.js";
|
import type { AgentContext, AgentFn, ThreadInput } from "./types.js";
|
||||||
import { generateUlid } from "./ulid.js";
|
import { createLogger } from "./util/logger.js";
|
||||||
|
import { getDefaultWorkflowStorageRoot, getGlobalCasDir } from "./util/storage-root.js";
|
||||||
|
import { generateUlid } from "./util/ulid.js";
|
||||||
|
|
||||||
export type WorkflowAsAgentOptions = {
|
export type WorkflowAsAgentOptions = {
|
||||||
/** When `null`, uses `getDefaultWorkflowStorageRoot()`. */
|
/** When `null`, uses `getDefaultWorkflowStorageRoot()`. */
|
||||||
|
|||||||
Reference in New Issue
Block a user