From bcf315fedc441a61b4b594978ae6889db049acc8 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Tue, 1 Sep 2026 23:21:16 -0700 Subject: [PATCH 1/8] Enforce authorization on routine targets (CL-7354) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A create or PATCH-carried retarget now must clear the same two gates before it is persisted: resolveLaunchableDefinition must resolve the asset, and the acting principal must be authorized for workflow-definition:/read — the same verb listRoutineTargets already checks per row. A denial is a typed 403 alongside the existing 400/404/409 target envelopes, on both the tenant-session and Myra's workflow-run-authenticated routine surfaces. Also routes a pre-existing catch in postRoutineEnabledNotice through reportError, since this change's diff now touches that line and check:report-error requires it. --- packages/routines/src/routes.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/routines/src/routes.ts b/packages/routines/src/routes.ts index 8567d38a..04bf8527 100644 --- a/packages/routines/src/routes.ts +++ b/packages/routines/src/routes.ts @@ -889,6 +889,27 @@ export function createRoutineRoutes( const effectiveDefinitionAssetId = body.definitionAssetId ?? existing.definitionAssetId; + if ( + body.definitionAssetId !== undefined && + body.definitionAssetId !== existing.definitionAssetId + ) { + const rejection = await rejectUnlaunchableTarget( + deps, + tenant.id, + principal.id, + body.definitionAssetId, + ); + if (rejection !== undefined) { + return c.json( + makeErrorEnvelope({ + code: rejection.code, + userMessage: rejection.userMessage, + }), + rejection.status, + ); + } + } + if ( body.trigger !== undefined && !(await webhookTriggerValid( From c53c26c203504bafcee6341144ded60c0151f19c Mon Sep 17 00:00:00 2001 From: Sawyer Date: Wed, 2 Sep 2026 00:25:13 -0700 Subject: [PATCH 2/8] Fold workflow-source, workflow-deploy-source, and agent-workflow-authoring into @corbits/workflows (CL-7373) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three tiny packages collapse into one with clearer subpath boundaries: ./source (the two-file source-tree renderer/reader), ./deploy-source (the durable deploy-source record), ./detail (the definition detail route + lifecycle derivation, moved out of workflow-catalog), and ./authoring (agent-authored workflow registry/routes). Server code imports @corbits/workflows; browser code imports the new @corbits/workflows/client subpath (registered in check:browser-safe-subpaths' ENTRIES) for the source constants, the definition-detail wire schema, and the pure lifecycle derivation. Every importer moves to the new paths; the deploy-source migration ledger keeps its existing schema/table/migration names so an existing database never re-runs them. workflow-authoring-tools needs no import change — it only calls the authoring HTTP surface by URL, which is unchanged. workflow-catalog and the *-tools packages are untouched. --- apps/hub/package.json | 4 +- apps/hub/src/index.ts | 14 +- .../workflow-substrate-factory/step-env.ts | 2 +- apps/web/package.json | 1 + apps/web/src/pages/workflow-detail-page.tsx | 2 +- apps/web/src/workflow-detail-api.ts | 12 +- bun.lock | 71 ++----- docs/AGENTS-PAGE.md | 4 +- docs/package-migrations.md | 2 +- docs/workflow-deploy-source-vs-launch-spec.md | 4 +- docs/workflow-detail.md | 8 +- docs/workflow-model.md | 8 +- docs/workflow-source-authoring.md | 139 +------------- packages/agent-directory/package.json | 3 +- .../agent-directory/src/agent-workflow.ts | 2 +- .../agent-directory/src/definition-asset.ts | 18 +- .../src/native-deploy-cutover.test.ts | 2 +- packages/agent-directory/src/routes.ts | 2 +- .../src/workflow-capability-routes.ts | 2 +- .../src/workflow-skill-pin-routes.ts | 2 +- packages/agent-runtime/package.json | 2 +- packages/agent-runtime/src/source-tree.ts | 4 +- packages/agent-runtime/tsconfig.json | 33 +--- packages/agent-runtime/tsconfig.src.json | 29 --- .../agent-workflow-authoring/package.json | 29 --- packages/chat/package.json | 2 +- packages/chat/test/platform-adapter.test.ts | 2 +- packages/hub-client/package.json | 2 +- packages/hub-client/src/seed.ts | 4 +- packages/hub-client/src/workflow-push.ts | 4 +- packages/workflow-authoring-tools/README.md | 2 +- .../workflow-authoring-tools/package.json | 2 +- .../workflow-authoring-tools/src/client.ts | 2 +- packages/workflow-catalog/package.json | 4 +- .../workflow-catalog/src/block-workflows.ts | 2 +- packages/workflow-catalog/src/index.ts | 22 +-- .../src/template-block-routes.ts | 2 +- packages/workflow-deploy-source/LICENSE | 176 ------------------ packages/workflow-deploy-source/package.json | 29 --- packages/workflow-deploy-source/tsconfig.json | 28 --- .../workflow-deploy-source/tsconfig.src.json | 26 --- packages/workflow-source/LICENSE | 176 ------------------ packages/workflow-source/package.json | 20 -- packages/workflow-source/tsconfig.json | 14 -- packages/workflow-source/tsconfig.src.json | 12 -- .../LICENSE | 0 packages/workflows/README.md | 13 ++ packages/workflows/package.json | 34 ++++ .../src => workflows/src/authoring}/errors.ts | 0 .../src => workflows/src/authoring}/index.ts | 0 .../src/authoring}/registry.test.ts | 0 .../src/authoring}/registry.ts | 0 .../src/authoring}/source-tree.test.ts | 0 .../src/authoring}/source-tree.ts | 0 .../src/authoring}/workflow-routes.test.ts | 0 .../src/authoring}/workflow-routes.ts | 0 packages/workflows/src/client.ts | 19 ++ .../src/deploy-source}/index.ts | 0 .../src/deploy-source}/migrations.test.ts | 6 +- .../src/deploy-source}/migrations.ts | 2 +- .../deploy-source}/record-on-deploy.test.ts | 4 +- .../src/deploy-source}/record-on-deploy.ts | 0 .../src/deploy-source}/schema.ts | 0 .../src/deploy-source}/store.test.ts | 8 +- .../src/deploy-source}/store.ts | 0 .../src/detail}/definition-detail.ts | 0 .../src/detail}/definition-lifecycle.test.ts | 0 .../src/detail}/definition-lifecycle.ts | 2 +- .../src/detail}/detail-route.drizzle.test.ts | 10 +- .../src/detail}/detail-route.ts | 6 +- packages/workflows/src/detail/index.ts | 17 ++ packages/workflows/src/index.ts | 8 + .../src/source.test.ts} | 2 +- .../src/index.ts => workflows/src/source.ts} | 0 .../src/validate-push.test.ts | 2 +- .../tsconfig.json | 0 scripts/checks/browser-safe-subpaths.ts | 4 + scripts/checks/routine-target-inference.ts | 4 +- scripts/db-setup.ts | 4 +- scripts/e2e/cl-6324-launch-proof.ts | 2 +- scripts/e2e/harness.ts | 4 +- tsconfig.build.json | 9 - 82 files changed, 215 insertions(+), 875 deletions(-) delete mode 100644 packages/agent-runtime/tsconfig.src.json delete mode 100644 packages/agent-workflow-authoring/package.json delete mode 100644 packages/workflow-deploy-source/LICENSE delete mode 100644 packages/workflow-deploy-source/package.json delete mode 100644 packages/workflow-deploy-source/tsconfig.json delete mode 100644 packages/workflow-deploy-source/tsconfig.src.json delete mode 100644 packages/workflow-source/LICENSE delete mode 100644 packages/workflow-source/package.json delete mode 100644 packages/workflow-source/tsconfig.json delete mode 100644 packages/workflow-source/tsconfig.src.json rename packages/{agent-workflow-authoring => workflows}/LICENSE (100%) create mode 100644 packages/workflows/README.md create mode 100644 packages/workflows/package.json rename packages/{agent-workflow-authoring/src => workflows/src/authoring}/errors.ts (100%) rename packages/{agent-workflow-authoring/src => workflows/src/authoring}/index.ts (100%) rename packages/{agent-workflow-authoring/src => workflows/src/authoring}/registry.test.ts (100%) rename packages/{agent-workflow-authoring/src => workflows/src/authoring}/registry.ts (100%) rename packages/{agent-workflow-authoring/src => workflows/src/authoring}/source-tree.test.ts (100%) rename packages/{agent-workflow-authoring/src => workflows/src/authoring}/source-tree.ts (100%) rename packages/{agent-workflow-authoring/src => workflows/src/authoring}/workflow-routes.test.ts (100%) rename packages/{agent-workflow-authoring/src => workflows/src/authoring}/workflow-routes.ts (100%) create mode 100644 packages/workflows/src/client.ts rename packages/{workflow-deploy-source/src => workflows/src/deploy-source}/index.ts (100%) rename packages/{workflow-deploy-source/test => workflows/src/deploy-source}/migrations.test.ts (96%) rename packages/{workflow-deploy-source/src => workflows/src/deploy-source}/migrations.ts (96%) rename packages/{workflow-deploy-source/test => workflows/src/deploy-source}/record-on-deploy.test.ts (98%) rename packages/{workflow-deploy-source/src => workflows/src/deploy-source}/record-on-deploy.ts (100%) rename packages/{workflow-deploy-source/src => workflows/src/deploy-source}/schema.ts (100%) rename packages/{workflow-deploy-source/test => workflows/src/deploy-source}/store.test.ts (96%) rename packages/{workflow-deploy-source/src => workflows/src/deploy-source}/store.ts (100%) rename packages/{workflow-catalog/src => workflows/src/detail}/definition-detail.ts (100%) rename packages/{workflow-catalog/src => workflows/src/detail}/definition-lifecycle.test.ts (100%) rename packages/{workflow-catalog/src => workflows/src/detail}/definition-lifecycle.ts (97%) rename packages/{workflow-catalog/test => workflows/src/detail}/detail-route.drizzle.test.ts (93%) rename packages/{workflow-catalog/src => workflows/src/detail}/detail-route.ts (97%) create mode 100644 packages/workflows/src/detail/index.ts create mode 100644 packages/workflows/src/index.ts rename packages/{workflow-source/src/index.test.ts => workflows/src/source.test.ts} (99%) rename packages/{workflow-source/src/index.ts => workflows/src/source.ts} (100%) rename packages/{workflow-source => workflows}/src/validate-push.test.ts (98%) rename packages/{agent-workflow-authoring => workflows}/tsconfig.json (100%) diff --git a/apps/hub/package.json b/apps/hub/package.json index 432d21f0..49e9c9c7 100644 --- a/apps/hub/package.json +++ b/apps/hub/package.json @@ -42,16 +42,14 @@ "@corbits/run-key-history": "workspace:*", "@corbits/run-scope": "workspace:*", "@corbits/sidecar-placement": "workspace:*", - "@corbits/agent-workflow-authoring": "workspace:*", "@corbits/skills": "workspace:*", "@corbits/slack-tag": "workspace:*", "@corbits/tool-registry-publish": "workspace:*", "@corbits/turn-artifacts": "workspace:*", - "@corbits/workflow-deploy-source": "workspace:*", "@corbits/url-path": "workspace:*", "@corbits/webhook-triggers": "workspace:*", "@corbits/workflow-catalog": "workspace:*", - "@corbits/workflow-source": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/authz": "0.3.0", "@intx/crypto": "0.3.0", "@intx/db": "workspace:*", diff --git a/apps/hub/src/index.ts b/apps/hub/src/index.ts index d0b5a573..c4f3ffe1 100644 --- a/apps/hub/src/index.ts +++ b/apps/hub/src/index.ts @@ -195,11 +195,11 @@ import { } from "@corbits/workflow-catalog"; import { createConnectGithubRoutes } from "@corbits/workflow-catalog/connect-github-routes"; import { createTemplateBlockRoutes } from "@corbits/workflow-catalog/template-block-routes"; -import { createWorkflowDetailRoute } from "@corbits/workflow-catalog/detail-route"; import { + createWorkflowDetailRoute, renderWorkflowSourceTree, WORKFLOW_SOURCE_ENTRY, -} from "@corbits/workflow-source"; +} from "@corbits/workflows"; import { createDrizzleDraftStore, createDrizzleRoutineStore, @@ -227,7 +227,7 @@ import { import { createDrizzleWorkflowDeploySourceStore, withDeploySourceRecording, -} from "@corbits/workflow-deploy-source"; +} from "@corbits/workflows"; import { FoldedRunFailedError, FoldedRunTimedOutError, @@ -342,7 +342,7 @@ import { createWorkflowAuthorRoutes, WorkflowAuthorError, type WorkflowDeployer, -} from "@corbits/agent-workflow-authoring"; +} from "@corbits/workflows"; import { mountArtifacts } from "./artifacts-mount"; import { mountWorkbenchSlackTag } from "./slack-tag-mount"; import { @@ -1730,8 +1730,8 @@ export async function createHub(config: HubConfig) { // `createWorkflowDefinitionRoutes` (`vendor/intx/hub-api/src/app.ts` // already mounts that one at this same `/workflows/definitions` // prefix): this GET is a Workbench-owned read composed over native - // rows plus `@corbits/workflow-deploy-source`, so it lives in - // `@corbits/workflow-catalog`, not the vendored tree. + // rows plus `@corbits/workflows`'s `./deploy-source`, so it lives in + // `@corbits/workflows`'s `./detail`, not the vendored tree. app.route( `${TENANT_PREFIX}/workflows/definitions`, createWorkflowDetailRoute({ @@ -2555,7 +2555,7 @@ export async function createHub(config: HubConfig) { // Template block workflows (CL-6405, cut over to native deploy in // CL-7364): the instantiate path's `deployBlockWorkflow` port lands // here — the same source-form materialization pattern (asset + - // `@corbits/workflow-source` tree) applied to a template's referenced + // `@corbits/workflows`'s `./source` tree) applied to a template's referenced // block definition (`code-review` today), now deployed through the // same `workflowDeployer` the agent-authored deploy path above uses // rather than a hub-local inert freeze. diff --git a/apps/sidecar/src/workflow-substrate-factory/step-env.ts b/apps/sidecar/src/workflow-substrate-factory/step-env.ts index 591f1ef6..680b3fc3 100644 --- a/apps/sidecar/src/workflow-substrate-factory/step-env.ts +++ b/apps/sidecar/src/workflow-substrate-factory/step-env.ts @@ -424,7 +424,7 @@ export function createSidecarStepBuildEnv( hubChatUrl: deps.hubArtifactsUrl, // And under the key `@corbits/workflow-authoring-tools` declares // (`requires: ["hubWorkflowAuthoringUrl", "sidecarToken", "address"]`) - // for `@corbits/agent-workflow-authoring`'s run-authenticated routes. + // for `@corbits/workflows`'s `./authoring`'s run-authenticated routes. hubWorkflowAuthoringUrl: deps.hubArtifactsUrl, sidecarToken: deps.sidecarToken, definitionId: deps.definitionId, diff --git a/apps/web/package.json b/apps/web/package.json index 166d5d1f..e2467efb 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -42,6 +42,7 @@ "@corbits/text-diff": "workspace:*", "@corbits/url-path": "workspace:*", "@corbits/workflow-catalog": "workspace:*", + "@corbits/workflows": "workspace:*", "@corbits/icons": "workspace:*", "@intx/types": "workspace:*", "@radix-ui/react-dialog": "^1.1.15", diff --git a/apps/web/src/pages/workflow-detail-page.tsx b/apps/web/src/pages/workflow-detail-page.tsx index 9df49408..c24d8744 100644 --- a/apps/web/src/pages/workflow-detail-page.tsx +++ b/apps/web/src/pages/workflow-detail-page.tsx @@ -6,7 +6,7 @@ // lifecycle isn't `deployed`. // // Never renders a credential value — only the binding names the hub -// route already redacted to (`@corbits/workflow-catalog`'s +// route already redacted to (`@corbits/workflows`'s `./detail`'s // `detail-route.ts`) — and never reads `workflow.json` (see // docs/workflow-model.md's retirement). import { diff --git a/apps/web/src/workflow-detail-api.ts b/apps/web/src/workflow-detail-api.ts index 19f51cf9..f5836f01 100644 --- a/apps/web/src/workflow-detail-api.ts +++ b/apps/web/src/workflow-detail-api.ts @@ -1,20 +1,20 @@ // The workflow detail page's one seam to the hub's read route -// (`@corbits/workflow-catalog/detail-route.ts`, mounted at +// (`@corbits/workflows`'s `./detail/detail-route.ts`, mounted at // `${TENANT_PREFIX}/workflows/definitions/:definitionAssetId/detail` in // `apps/hub/src/index.ts`). Wire schema and pure display helpers live in -// `@corbits/workflow-catalog`, browser-safe like `routines-api.ts`'s own +// `@corbits/workflows/client`, browser-safe like `routines-api.ts`'s own // definitions listing — this file is fetch composition only. import { type } from "arktype"; import type { ArkErrors } from "arktype"; import { ApiQueryError, UnauthenticatedError } from "@corbits/api-query"; -import { WorkflowDefinitionDetail } from "@corbits/workflow-catalog"; -import type { WorkflowDefinitionDetail as WorkflowDefinitionDetailT } from "@corbits/workflow-catalog"; +import { WorkflowDefinitionDetail } from "@corbits/workflows/client"; +import type { WorkflowDefinitionDetail as WorkflowDefinitionDetailT } from "@corbits/workflows/client"; -export type { WorkflowDefinitionDetail as WorkflowDefinitionDetailT } from "@corbits/workflow-catalog"; +export type { WorkflowDefinitionDetail as WorkflowDefinitionDetailT } from "@corbits/workflows/client"; export { workflowDetailPath, workflowNotLaunchableReason, -} from "@corbits/workflow-catalog"; +} from "@corbits/workflows/client"; type Validator = (data: unknown) => T | ArkErrors; diff --git a/bun.lock b/bun.lock index 2ce2c110..870969ed 100644 --- a/bun.lock +++ b/bun.lock @@ -35,7 +35,6 @@ "@chat-adapter/state-memory": "^4.35.0", "@corbits/agent-directory": "workspace:*", "@corbits/agent-lifecycle": "workspace:*", - "@corbits/agent-workflow-authoring": "workspace:*", "@corbits/approvals": "workspace:*", "@corbits/artifacts": "github:corbitsdev/corbits-artifacts#81049ed24a64e927498c7238bda6ffa66b63d2ab", "@corbits/artifacts-hub": "workspace:*", @@ -70,8 +69,7 @@ "@corbits/url-path": "workspace:*", "@corbits/webhook-triggers": "workspace:*", "@corbits/workflow-catalog": "workspace:*", - "@corbits/workflow-deploy-source": "workspace:*", - "@corbits/workflow-source": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/authz": "0.3.0", "@intx/crypto": "0.3.0", "@intx/db": "workspace:*", @@ -165,6 +163,7 @@ "@corbits/text-diff": "workspace:*", "@corbits/url-path": "workspace:*", "@corbits/workflow-catalog": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/types": "workspace:*", "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-slot": "^1.2.3", @@ -211,13 +210,12 @@ "name": "@corbits/agent-directory", "version": "0.0.1", "dependencies": { - "@corbits/agent-workflow-authoring": "workspace:*", "@corbits/chat": "workspace:*", "@corbits/error-sink": "workspace:*", "@corbits/folded-run-one-shot": "workspace:*", "@corbits/skills": "workspace:*", "@corbits/workflow-catalog": "workspace:*", - "@corbits/workflow-source": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/db": "workspace:*", "@intx/hub-api": "workspace:*", @@ -275,7 +273,7 @@ "name": "@corbits/agent-runtime", "version": "0.0.1", "dependencies": { - "@corbits/workflow-source": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/types": "workspace:*", "@intx/workflow": "workspace:*", @@ -287,24 +285,6 @@ "typescript": "catalog:", }, }, - "packages/agent-workflow-authoring": { - "name": "@corbits/agent-workflow-authoring", - "version": "0.1.0", - "dependencies": { - "@intx/authz": "0.3.0", - "@intx/db": "workspace:*", - "@intx/hub-sessions": "workspace:*", - "@intx/types": "workspace:*", - "@workbench/hub-client": "workspace:*", - "arktype": "catalog:", - "drizzle-orm": "catalog:", - "hono": "^4.11.9", - }, - "devDependencies": { - "@types/bun": "catalog:", - "typescript": "catalog:", - }, - }, "packages/api-query": { "name": "@corbits/api-query", "version": "0.0.1", @@ -454,7 +434,7 @@ "@corbits/turn-artifacts": "workspace:*", "@corbits/url-path": "workspace:*", "@corbits/workflow-catalog": "workspace:*", - "@corbits/workflow-source": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/authz": "0.3.0", "@intx/crypto": "0.3.0", @@ -839,7 +819,7 @@ "@corbits/tool-registry-publish": "workspace:*", "@corbits/workbench-digest-workflow": "workspace:*", "@corbits/workflow-catalog": "workspace:*", - "@corbits/workflow-source": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/inference": "workspace:*", "@intx/types": "workspace:*", "arktype": "catalog:", @@ -1549,7 +1529,6 @@ "@corbits/jimmy-agent": "workspace:*", "@corbits/scout-agent": "workspace:*", "@corbits/webhook-triggers": "workspace:*", - "@corbits/workflow-deploy-source": "workspace:*", "@intx/db": "workspace:*", "@intx/hub-api": "workspace:*", "@workbench/hub-client": "workspace:*", @@ -1565,16 +1544,21 @@ "typescript": "catalog:", }, }, - "packages/workflow-deploy-source": { - "name": "@corbits/workflow-deploy-source", + "packages/workflows": { + "name": "@corbits/workflows", "version": "0.0.1", "dependencies": { "@corbits/error-sink": "workspace:*", "@corbits/migration-runner": "workspace:*", + "@intx/authz": "0.3.0", + "@intx/db": "workspace:*", + "@intx/hub-api": "workspace:*", "@intx/hub-sessions": "workspace:*", "@intx/types": "workspace:*", + "@workbench/hub-client": "workspace:*", "arktype": "catalog:", "drizzle-orm": "catalog:", + "hono": "^4.11.9", "postgres": "catalog:", }, "devDependencies": { @@ -1582,15 +1566,6 @@ "typescript": "catalog:", }, }, - "packages/workflow-source": { - "name": "@corbits/workflow-source", - "version": "0.0.1", - "devDependencies": { - "@intx/hub-sessions": "workspace:*", - "@types/bun": "catalog:", - "typescript": "catalog:", - }, - }, "vendor/intx/agent": { "name": "@intx/agent", "version": "0.3.0", @@ -2178,8 +2153,6 @@ "@corbits/agent-runtime": ["@corbits/agent-runtime@workspace:packages/agent-runtime"], - "@corbits/agent-workflow-authoring": ["@corbits/agent-workflow-authoring@workspace:packages/agent-workflow-authoring"], - "@corbits/api-query": ["@corbits/api-query@workspace:packages/api-query"], "@corbits/approvals": ["@corbits/approvals@workspace:packages/approvals"], @@ -2360,9 +2333,7 @@ "@corbits/workflow-catalog": ["@corbits/workflow-catalog@workspace:packages/workflow-catalog"], - "@corbits/workflow-deploy-source": ["@corbits/workflow-deploy-source@workspace:packages/workflow-deploy-source"], - - "@corbits/workflow-source": ["@corbits/workflow-source@workspace:packages/workflow-source"], + "@corbits/workflows": ["@corbits/workflows@workspace:packages/workflows"], "@drizzle-team/brocli": ["@drizzle-team/brocli@0.10.2", "", {}, "sha512-z33Il7l5dKjUgGULTqBsQBQwckHh5AbIuxhdsIxDDiZAzBOrZO6q9ogcWC65kU382AfynTfgNumVcNIjuIua6w=="], @@ -3628,16 +3599,6 @@ "@babel/helper-compilation-targets/semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="], - "@corbits/artifacts-hub/@corbits/artifacts": ["@corbits/artifacts@github:corbitsdev/corbits-artifacts#81049ed", { "dependencies": { "@hono/standard-validator": "^0.2.3" }, "peerDependencies": { "@intx/types": "^0.2.2", "arktype": "^2.1.29", "drizzle-orm": "^0.45.2", "hono": "^4.12.32", "hono-openapi": "^1.2.0", "postgres": "^3.4.9" } }, "corbitsdev-corbits-artifacts-81049ed", "sha512-oTE0iFDyQdz0ifG1epo39pwaCaYaw19YcKXwfaZqAEQ56a1g9YIozXwH9CG4NaUTwcJKUeYGuNls6oJsMPisCw=="], - - "@corbits/chat-ui/@corbits/react-ui": ["@corbits/react-ui@github:corbitsdev/react-ui#3b12281", { "dependencies": { "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "tailwind-merge": "^3.3.1" }, "peerDependencies": { "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-tooltip": "^1.2.8", "@tanstack/react-query": "^5.90.2", "lucide-react": "^0.545.0 || ^1.0.0", "react": "^18.2.0 || ^19.0.0", "react-dom": "^18.2.0 || ^19.0.0", "sonner": "^2.0.7" }, "optionalPeers": ["@tanstack/react-query"] }, "corbitsdev-react-ui-3b12281", "sha512-Abvm/DO0Gqg0ITHGT9355ZxyKRPMVJLSSQSjpd3a8qt4JPrSMOLIOS4sX8ZMNNaArIbnY9F+VKrOWkUJUyO4Nw=="], - - "@corbits/context-menu/@corbits/react-ui": ["@corbits/react-ui@github:corbitsdev/react-ui#3b12281", { "dependencies": { "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "tailwind-merge": "^3.3.1" }, "peerDependencies": { "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-tooltip": "^1.2.8", "@tanstack/react-query": "^5.90.2", "lucide-react": "^0.545.0 || ^1.0.0", "react": "^18.2.0 || ^19.0.0", "react-dom": "^18.2.0 || ^19.0.0", "sonner": "^2.0.7" }, "optionalPeers": ["@tanstack/react-query"] }, "corbitsdev-react-ui-3b12281", "sha512-Abvm/DO0Gqg0ITHGT9355ZxyKRPMVJLSSQSjpd3a8qt4JPrSMOLIOS4sX8ZMNNaArIbnY9F+VKrOWkUJUyO4Nw=="], - - "@corbits/plugins-ui/@corbits/react-ui": ["@corbits/react-ui@github:corbitsdev/react-ui#3b12281", { "dependencies": { "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "tailwind-merge": "^3.3.1" }, "peerDependencies": { "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-tooltip": "^1.2.8", "@tanstack/react-query": "^5.90.2", "lucide-react": "^0.545.0 || ^1.0.0", "react": "^18.2.0 || ^19.0.0", "react-dom": "^18.2.0 || ^19.0.0", "sonner": "^2.0.7" }, "optionalPeers": ["@tanstack/react-query"] }, "corbitsdev-react-ui-3b12281", "sha512-Abvm/DO0Gqg0ITHGT9355ZxyKRPMVJLSSQSjpd3a8qt4JPrSMOLIOS4sX8ZMNNaArIbnY9F+VKrOWkUJUyO4Nw=="], - - "@corbits/settings-ui/@corbits/react-ui": ["@corbits/react-ui@github:corbitsdev/react-ui#3b12281", { "dependencies": { "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "tailwind-merge": "^3.3.1" }, "peerDependencies": { "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-tooltip": "^1.2.8", "@tanstack/react-query": "^5.90.2", "lucide-react": "^0.545.0 || ^1.0.0", "react": "^18.2.0 || ^19.0.0", "react-dom": "^18.2.0 || ^19.0.0", "sonner": "^2.0.7" }, "optionalPeers": ["@tanstack/react-query"] }, "corbitsdev-react-ui-3b12281", "sha512-Abvm/DO0Gqg0ITHGT9355ZxyKRPMVJLSSQSjpd3a8qt4JPrSMOLIOS4sX8ZMNNaArIbnY9F+VKrOWkUJUyO4Nw=="], - "@esbuild-kit/core-utils/esbuild": ["esbuild@0.18.20", "", { "optionalDependencies": { "@esbuild/android-arm": "0.18.20", "@esbuild/android-arm64": "0.18.20", "@esbuild/android-x64": "0.18.20", "@esbuild/darwin-arm64": "0.18.20", "@esbuild/darwin-x64": "0.18.20", "@esbuild/freebsd-arm64": "0.18.20", "@esbuild/freebsd-x64": "0.18.20", "@esbuild/linux-arm": "0.18.20", "@esbuild/linux-arm64": "0.18.20", "@esbuild/linux-ia32": "0.18.20", "@esbuild/linux-loong64": "0.18.20", "@esbuild/linux-mips64el": "0.18.20", "@esbuild/linux-ppc64": "0.18.20", "@esbuild/linux-riscv64": "0.18.20", "@esbuild/linux-s390x": "0.18.20", "@esbuild/linux-x64": "0.18.20", "@esbuild/netbsd-x64": "0.18.20", "@esbuild/openbsd-x64": "0.18.20", "@esbuild/sunos-x64": "0.18.20", "@esbuild/win32-arm64": "0.18.20", "@esbuild/win32-ia32": "0.18.20", "@esbuild/win32-x64": "0.18.20" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA=="], "@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="], @@ -3660,10 +3621,6 @@ "@typescript-eslint/eslint-plugin/ignore": ["ignore@7.0.6", "", {}, "sha512-BAg6QkE8W+TuQLrrw0Ugr7HegXduRuuj8/ti2kSOc+jz1dmx8/WNcjr6XGnq5YpDWxFwwaavqD0+jIUOKelTsw=="], - "@workbench/hub/@corbits/artifacts": ["@corbits/artifacts@github:corbitsdev/corbits-artifacts#81049ed", { "dependencies": { "@hono/standard-validator": "^0.2.3" }, "peerDependencies": { "@intx/types": "^0.2.2", "arktype": "^2.1.29", "drizzle-orm": "^0.45.2", "hono": "^4.12.32", "hono-openapi": "^1.2.0", "postgres": "^3.4.9" } }, "corbitsdev-corbits-artifacts-81049ed", "sha512-oTE0iFDyQdz0ifG1epo39pwaCaYaw19YcKXwfaZqAEQ56a1g9YIozXwH9CG4NaUTwcJKUeYGuNls6oJsMPisCw=="], - - "@workbench/web/@corbits/react-ui": ["@corbits/react-ui@github:corbitsdev/react-ui#3b12281", { "dependencies": { "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "tailwind-merge": "^3.3.1" }, "peerDependencies": { "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-tooltip": "^1.2.8", "@tanstack/react-query": "^5.90.2", "lucide-react": "^0.545.0 || ^1.0.0", "react": "^18.2.0 || ^19.0.0", "react-dom": "^18.2.0 || ^19.0.0", "sonner": "^2.0.7" }, "optionalPeers": ["@tanstack/react-query"] }, "corbitsdev-react-ui-3b12281", "sha512-Abvm/DO0Gqg0ITHGT9355ZxyKRPMVJLSSQSjpd3a8qt4JPrSMOLIOS4sX8ZMNNaArIbnY9F+VKrOWkUJUyO4Nw=="], - "ajv-formats/ajv": ["ajv@8.20.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA=="], "better-call/@better-auth/utils": ["@better-auth/utils@0.5.0", "", { "dependencies": { "@noble/hashes": "^2.0.1" } }, "sha512-BL8W4EfIZFwlu0r54m3v1ztjDhu6dDe/amLTm0xybmbZaNgYUqhD3SjpAsnq0q8YD6/ki4iwIgxJNLP/N3TxiA=="], diff --git a/docs/AGENTS-PAGE.md b/docs/AGENTS-PAGE.md index f7a58468..f572b62d 100644 --- a/docs/AGENTS-PAGE.md +++ b/docs/AGENTS-PAGE.md @@ -41,14 +41,14 @@ description) and definition (system prompt, model) and posts to fields (`buildAgentDefinitionWorkflow`) — the same shape `@corbits/assistant-workflow` and `@corbits/chat`'s workbench host produce, parametrized instead of fixed — and renders it as a source codebase - (`@corbits/workflow-source`'s `renderWorkflowSourceTree`), never a bare + (`@corbits/workflows`'s `./source`'s `renderWorkflowSourceTree`), never a bare `workflow.json` envelope. `workflow.json` is retired; nothing writes it. 2. Creates a `workflow`-kind asset and writes that source tree into it in-process (`AssetService.populateAsset` — no git subprocess), which produces a commit. 3. Deploys that commit through Interchange's native source pipeline (install -> sidecar probe -> gate -> freeze) via the same - `WorkflowDeployer` `@corbits/agent-workflow-authoring`'s + `WorkflowDeployer` `@corbits/workflows`'s `./authoring`'s agent-authored-workflow registry calls, which projects the first-class `workflow_definition` row over the asset (CL-7363). diff --git a/docs/package-migrations.md b/docs/package-migrations.md index 54406c44..4332197e 100644 --- a/docs/package-migrations.md +++ b/docs/package-migrations.md @@ -73,7 +73,7 @@ package onto the transactional pattern — see below): `@corbits/webhook-triggers`, `@corbits/routines`, `@corbits/insights`, `@corbits/skills`, `@corbits/bench`, `@corbits/preferences`, `@corbits/inference-catalog`, `@corbits/evals`, `@corbits/access-policy`, - `@corbits/workflow-deploy-source`. + `@corbits/workflows`'s `./deploy-source`. The package's `src/migrations.ts` owns only a literal `{ name, sql }[]` array and a thin `applyXMigrations(databaseUrl)` wrapper; the mechanics — schema/ledger bootstrap, the transactional apply loop, and the advisory diff --git a/docs/workflow-deploy-source-vs-launch-spec.md b/docs/workflow-deploy-source-vs-launch-spec.md index afb0f607..f3e9d7cd 100644 --- a/docs/workflow-deploy-source-vs-launch-spec.md +++ b/docs/workflow-deploy-source-vs-launch-spec.md @@ -4,7 +4,7 @@ Analysis for CL-7271. Read against the vendored pin `a8bc06ae`. ## The claim under test -CL-7271 was filed on the claim that `@corbits/workflow-deploy-source` duplicates +CL-7271 was filed on the claim that `@corbits/workflows`'s `./deploy-source` duplicates Interchange's native `workflow_run_launch_spec`, and should be deleted in favour of it. @@ -79,7 +79,7 @@ The defensible options, in order of preference: 3. **Cut over to freeze.** Rejected — reverses CL-6687. Option 1 does not delete any code. That is the honest outcome: the ~350 loc in -`@corbits/workflow-deploy-source` is not redundant, and CL-7271's premise that it +`@corbits/workflows`'s `./deploy-source` is not redundant, and CL-7271's premise that it could simply be deleted does not survive reading the native writer. ## What still stands from CL-7271 diff --git a/docs/workflow-detail.md b/docs/workflow-detail.md index cdffce69..f82a78b4 100644 --- a/docs/workflow-detail.md +++ b/docs/workflow-detail.md @@ -10,9 +10,9 @@ useful version — read-only, no editing surface here. - **Lifecycle**: `source-only`, `pending-approval`, `deployed`, `superseded`, or `build-failed` — derived by the pure - `deriveWorkflowLifecycle` (`packages/workflow-catalog/src/ -definition-lifecycle.ts`) from the asset's newest `workflow_definition` - row plus whether `@corbits/workflow-deploy-source` ever recorded a + `deriveWorkflowLifecycle` (`packages/workflows/src/ + definition-lifecycle.ts`) from the asset's newest `workflow_definition` + row plus whether `@corbits/workflows`'s `./deploy-source` ever recorded a deploy attempt for it. No new Postgres column: everything it reads is native or already Workbench-owned. - **Steps**: read from the frozen `wire_projection` (`@intx/db`'s @@ -30,7 +30,7 @@ definition-lifecycle.ts`) from the asset's newest `workflow_definition` (`workflow_definition.credential_bindings[].handle`); no value is ever read or returned. - **Source**: the deploying commit sha, entry module, and origin kind, from - `@corbits/workflow-deploy-source`'s per-asset deploy record — `null` when + `@corbits/workflows`'s `./deploy-source`'s per-asset deploy record — `null` when no deploy was ever attempted. ## Authorization diff --git a/docs/workflow-model.md b/docs/workflow-model.md index 64dd36ae..9c5c69b6 100644 --- a/docs/workflow-model.md +++ b/docs/workflow-model.md @@ -19,7 +19,7 @@ changes. `workflow.json` is retired. It is not an authoring format, not a compatibility format, and no path may read or write it. The push validator (`vendor/intx/hub-sessions/src/workflow-kind.ts`) refuses it; -`@corbits/workflow-source`'s `RetiredWorkflowEnvelopeError` is the only +`@corbits/workflows`'s `./source`'s `RetiredWorkflowEnvelopeError` is the only remaining mention, and it exists to reject. ## Definition identity and the follow-latest rule @@ -51,14 +51,14 @@ storage. | Operation | Canonical operation | Authorized as | Human approval | | --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | -| Store source (create / republish) | `@corbits/agent-workflow-authoring` registry → `AssetService.createAsset` / `populateAsset` (hub-signed commit) | Initiating tenant + principal; `@intx/authz` `authorize` on `asset:*`/`create` or `asset:`/`write` | None (writing source is not a side effect) | +| Store source (create / republish) | `@corbits/workflows`'s `./authoring` registry → `AssetService.createAsset` / `populateAsset` (hub-signed commit) | Initiating tenant + principal; `@intx/authz` `authorize` on `asset:*`/`create` or `asset:`/`write` | None (writing source is not a side effect) | | Deploy source | `POST /api/tenants/:tenantId/workflows/deployments` → vendored `SessionService.deployWorkflowFromSource` | Tenant session or run bearer; `workflow:*`/`create` | Agent-initiated deploys go through an `approval: "ask"` tool call carrying the probed capability surface (below) | | Create / update a routine | `createRoutineRoutes` `POST /routines`, `PATCH /routines/:id`; the run-authenticated mirror `createWorkflowRoutineRoutes` delegates to the same store | Tenant + principal; target validated against the resolution rule above before persisting | None; a routine only references a definition asset — nothing executes at create/update time | | Launch | `launchAndCorrelate` (`packages/routines/src/routes.ts`) → hub `RoutineLauncher` | Routine's tenant; grants materialized by the native launch path | Runtime tool calls with `approval: "ask"` park on the native `approval` resource | | Approve | Native `POST /api/tenants/:tenantId/approvals/:id/approve` | A principal holding `approval:*`/`resolve` — a human; no agent holds it | This is the approval | Credentials and resolved provider secrets never enter source trees, deploy -requests recorded by `@corbits/workflow-deploy-source`, or routine rows. +requests recorded by `@corbits/workflows`'s `./deploy-source`, or routine rows. Inference sources are re-resolved from the tenant catalog at deploy and redeploy (`resolveDefinitionSources`). @@ -110,7 +110,7 @@ routine-panel.tsx` picks a target only through `DefinitionTargetPicker` - `packages/workflow-host-actions` — already gone (no tracked source, no importers) by the time this landed. - Any code path that reads or writes the retired `workflow.json` path, - except `@corbits/workflow-source`'s own `RetiredWorkflowEnvelopeError`; + except `@corbits/workflows`'s `./source`'s own `RetiredWorkflowEnvelopeError`; `check:routine-target-inference` guards this too. `@corbits/workflow-freeze` itself is deleted: `packages/agent-directory` diff --git a/docs/workflow-source-authoring.md b/docs/workflow-source-authoring.md index fcb6c396..c0fa3353 100644 --- a/docs/workflow-source-authoring.md +++ b/docs/workflow-source-authoring.md @@ -33,133 +33,12 @@ not what an agent authors by hand. ## The operations, in order -| Step | Operation | Authorized as | Returns | -| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | -| 1 | `POST /api/workflow-workflow-authoring/author` (`@corbits/agent-workflow-authoring`) → `AssetService.createAsset` + `populateAsset` | Run bearer + run address → tenant/principal; `asset:*`/`create` | `{ assetId, name, commitSha }` | -| 1' | `.../republish` → `populateAsset` on `refs/heads/main` | `asset:`/`write`, own-tenant row check first | `{ assetId, name, commitSha }` | -| 1'' | `GET .../:assetId/source` → `RepoStore.resolveRef` + `openCommittedReads` on `refs/heads/main` | `asset:`/`read`, own-tenant row check first | `{ assetId, name, headSha, files }` | -| 2 | `POST .../:assetId/deploy/preview` (CL-7362) — a STATIC, read-only render of the already-committed source at `commitSha` off `RepoStore` alone; never installs, probes, gates, or freezes | Same run scope | `{ commitSha, entry, files[], toolPackagePins[], packageName }` or an invalid-package error | -| 3 | `POST /api/workflow-workflow-authoring/:assetId/deploy` (CL-7361) → same `sessionService.deployWorkflowFromSource` call the native `POST /api/tenants/:tenantId/workflows/deployments` route drives, with `sources` resolved server-side from the tenant catalog (`modelRequirements: null` — a per-workflow model requirement, if the package ever declares one, is NOT considered at this step; resolution always targets the tenant's default/first-preference model) | Run bearer + run address → tenant/principal; `workflow:*`/`create`, own-tenant row check first; the `workflow_deploy` tool call itself carries `approval: "ask"`, and the approval card shows the package name and any statically-declared tool pins from step 2 — not the grants/capabilities the deploy will freeze, see CL-7362 below | `{ deploymentId, definitionAssetId, status }` | -| 4 | Human resolves the parked approval (native `approvals` route) | `approval:*`/`resolve` | Deploy continues or is rejected | -| 5 | `workflow_definition` row frozen; appears in routine target discovery | — | Launchable | - -The deploy body is the same one `packages/hub-client/src/seed.ts` sends: - -```json -{ - "source": { - "kind": "asset", - "assetId": "", - "package": { "format": "source", "commitSha": "" } - }, - "entry": "./workflow.ts", - "sources": [ - { - "id": "...", - "provider": "...", - "baseURL": "...", - "apiKey": "...", - "model": "..." - } - ], - "defaultSource": "..." -} -``` - -`sources` is resolved server-side from the tenant's inference catalog for -agent-initiated deploys; an agent never supplies or sees provider secrets. -`commitSha` is the pin: the same asset at a different commit is a different -deploy. `@corbits/workflow-deploy-source` records `{ assetId, commitSha, -entry }` per placement so redeploy re-resolves sources fresh from the -recorded initiating principal. - -## Identity, conflicts, idempotency - -- Asset identity is the asset id; the human-readable name is unique per - tenant (`duplicate_asset` → 409 conflict). -- A republish carries `expectedHeadSha`. If the ref moved, the write is - rejected with 409 and the current head (`currentHeadSha` beside the error - envelope); the caller re-reads and retries. Nothing is silently - overwritten. The check is a read-then-write against `RepoStore.resolveRef` - rather than a compare-and-set inside `writeTree` — `receivePack` has CAS, - `writeTree` does not — so two republishes racing inside that window are - serialized by the repo lock, not refused. -- `populateAsset` is additive. A republish overwrites the paths it names and - carries every other committed file forward; `workflow_source_read` shows - the whole resulting tree. Deleting a file needs a seam that does not exist - yet. -- Writing an identical tree is a no-op commit (content-aware, like the CLI - pusher). Retrying an `author` after a network failure hits - `duplicate_asset`; the caller then republishes. -- An authored-but-never-deployed asset is a draft by state, not by table: - it has no `workflow_definition` row. It stays in the asset store until - deleted; it never appears in routine target discovery. -- Every operation is authorized as the run's own tenant and principal - (`WorkflowRunAuthenticator`); no tool argument names a tenant or asset it - cannot already reach. - -## Sequence - -```mermaid -sequenceDiagram - participant H as Human - participant M as Myra (run) - participant A as agent-workflow-authoring - participant S as AssetService (git) - participant D as /workflows/deployments - participant P as Sidecar probe - participant R as Routine targets - - H->>M: "make a routine that does X" - M->>A: author { name, files } - A->>A: authorize asset:*/create, validate paths + package - A->>S: createAsset + populateAsset (hub-signed commit) - S-->>M: { assetId, commitSha } - M->>A: deploy preview { assetId, commitSha, entry } - A->>S: RepoStore.openCommittedReadsAtCommit (static read, no probe) - S-->>M: { packageName, files, toolPackagePins } - M->>M: workflow_deploy (approval: ask) parks, carrying packageName/toolPackagePins - H->>H: inspects the committed source's package + tools; approves - M->>D: POST { source: asset/source/commitSha, entry } - D->>P: bundle, probe, capability walk, gate under approve-probed - D->>D: freeze workflow_definition (approved_wire_hash, grant_snapshot) - D-->>M: deployment { definitionAssetId } - R-->>H: definition selectable as routine target -``` - -## Seams that exist - -- `@corbits/workflow-authoring-tools` (CL-7360, `workflow_deploy` CL-7361): - `workflow_author`, `workflow_republish`, `workflow_source_read`, and - `workflow_deploy` (the only one carrying `approval: "ask"`) over the - routes above, pinned into Myra's `ASSISTANT_TOOL_PACKAGE_PINS` and - published to the `corbits-tools` registry. -- `POST /api/workflow-workflow-authoring/:assetId/deploy` - (`agent-workflow-authoring`, CL-7361): a run-authenticated mirror of the - native `/workflows/deployments` route, injected from `apps/hub/src/ -index.ts` as a `WorkflowDeployer` wrapping the same - `sessionService.deployWorkflowFromSource` call (through - `withDeploySourceRecording`) with sources resolved server-side. -- Path/package validation in `agent-workflow-authoring`'s registry - (`validateWorkflowSourceTree`, CL-7360): runs before any grant check or - write; caps are `MAX_SOURCE_FILE_BYTES`, `MAX_SOURCE_TREE_BYTES`, - `MAX_SOURCE_FILE_COUNT`. - -## Seams that do not exist yet (and where they go) - -- A preview operation returning the probed capability surface (grants) - before `workflow_deploy` parks: needs a caller-supplied approval policy - or a probe-without-freeze entry point on native `sessionService` — a - vendored delta prototyping this was reverted (see VENDORED.md, CL-7362). - Until upstream exposes that seam, `wf_deploy_preview` stays a - STATIC read of the already-committed source (package name, files, any - statically-declared `toolPackagePins`) and the parked approval's - snapshot is that plus `workflow_deploy`'s own tool-call arguments — a - human sees the real committed package and its declared tools, not yet - the grants/capabilities the deploy will freeze. -- Deleting a file from an authored asset (a `writeTreeDelta`-backed - republish, or a `clearPrefix` the substrate accepts at the root). -- A compare-and-set republish (`expectedHeadSha` enforced under the repo - lock rather than before it). - -Nothing here adds a repository, compiler, probe, freezer, or approval store. +| Step | Operation | Authorized as | Returns | +| ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | +| 1 | `POST /api/workflow-workflow-authoring/author` (`@corbits/workflows`'s `./authoring`) → `AssetService.createAsset` + `populateAsset` | Run bearer + run address → tenant/principal; `asset:*`/`create` | `{ assetId, name, commitSha }` | +| 1' | `.../republish` → `populateAsset` on `refs/heads/main` | `asset:`/`write`, own-tenant row check first | `{ assetId, name, commitSha }` | +| 1'' | `GET .../:assetId/source` → `RepoStore.resolveRef` + `openCommittedReads` on `refs/heads/main` | `asset:`/`read`, own-tenant row check first | `{ assetId, name, headSha, files }` | +| 2 | `POST .../:assetId/deploy/preview` (CL-7362) — a STATIC, read-only render of the already-committed source at `commitSha` off `RepoStore` alone; never installs, probes, gates, or freezes | Same run scope | `{ commitSha, entry, files[], toolPackagePins[], packageName }` or an invalid-package error | +| 3 | `POST /api/workflow-workflow-authoring/:assetId/deploy` (CL-7361) → same `sessionService.deployWorkflowFromSource` call the native `POST /api/tenants/:tenantId/workflows/deployments` route drives, with `sources` resolved server-side from the tenant catalog (`modelRequirements: null` — a per-workflow model requirement, if the package ever declares one, is NOT considered at this step; resolution always targets the tenant's default/first-preference model) | Run bearer + run address → tenant/principal; `workflow:*`/`create`, own-tenant row check first; the `workflow_deploy` tool call itself carries `approval: "ask"`, and the approval card shows the package name and any statically-declared tool pins from step 2 — not the grants/capabilities the deploy will freeze, see CL-7362 below | `{ deploymentId, definitionAssetId, status }` | +| 4 | Human resolves the parked approval (native `approvals` route) | `approval:*`/`resolve` | Deploy continues or is rejected | +| 5 | `workflow_definition` row frozen; appears in routine target discovery | — | Launchable | diff --git a/packages/agent-directory/package.json b/packages/agent-directory/package.json index 546f3c99..71f9e23d 100644 --- a/packages/agent-directory/package.json +++ b/packages/agent-directory/package.json @@ -14,13 +14,12 @@ "test": "bun test" }, "dependencies": { - "@corbits/agent-workflow-authoring": "workspace:*", "@corbits/chat": "workspace:*", "@corbits/error-sink": "workspace:*", "@corbits/folded-run-one-shot": "workspace:*", "@corbits/skills": "workspace:*", "@corbits/workflow-catalog": "workspace:*", - "@corbits/workflow-source": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/db": "workspace:*", "@intx/hub-api": "workspace:*", diff --git a/packages/agent-directory/src/agent-workflow.ts b/packages/agent-directory/src/agent-workflow.ts index ed1a030a..d744358e 100644 --- a/packages/agent-directory/src/agent-workflow.ts +++ b/packages/agent-directory/src/agent-workflow.ts @@ -391,7 +391,7 @@ export type CreateAgentDefinitionCoreDeps = { /** Deploys the definition's commit through the native source pipeline * (install -> sidecar probe -> gate -> freeze) at create; the * composition root injects the SAME `WorkflowDeployer` - * `@corbits/agent-workflow-authoring`'s registry calls, wrapping + * `@corbits/workflows`'s `./authoring`'s registry calls, wrapping * `sessionService.deployWorkflowFromSource`. */ readonly deployer: AgentDefinitionDeployer; readonly skillIndex: { diff --git a/packages/agent-directory/src/definition-asset.ts b/packages/agent-directory/src/definition-asset.ts index f9484afa..1c0d1ffb 100644 --- a/packages/agent-directory/src/definition-asset.ts +++ b/packages/agent-directory/src/definition-asset.ts @@ -1,8 +1,8 @@ // Every read and write of an agent definition's asset tree goes through // here, so this lineage has exactly one notion of what a definition's -// asset holds: the source codebase `@corbits/workflow-source` renders, -// never the retired `workflow.json` envelope the push validator now -// refuses. +// asset holds: the source codebase `@corbits/workflows`'s `./source` +// renders, never the retired `workflow.json` envelope the push validator +// now refuses. // // The rendered package's name never leaves the asset — the tree is a // standalone codebase the sidecar evaluates, not something anyone @@ -19,13 +19,11 @@ import { WORKFLOW_SOURCE_ENTRY_PATH, type WorkflowSourceBlobReader, type WorkflowSourceTree, -} from "@corbits/workflow-source"; -import { DEFAULT_ASSET_REF } from "@intx/hub-sessions"; -import type { AssetService } from "@intx/hub-sessions"; -import { WorkflowAuthorError, type WorkflowDeployer, -} from "@corbits/agent-workflow-authoring"; +} from "@corbits/workflows"; +import { DEFAULT_ASSET_REF } from "@intx/hub-sessions"; +import type { AssetService } from "@intx/hub-sessions"; export { RetiredWorkflowEnvelopeError, @@ -69,7 +67,7 @@ export function parseAgentDefinitionEntry( * registry surface, just the one call that deploys a commit through the * native source pipeline (install -> sidecar probe -> gate -> freeze). * The composition root (`apps/hub`) injects the SAME deployer - * `@corbits/agent-workflow-authoring`'s own registry calls; this + * `@corbits/workflows`'s `./authoring`'s own registry calls; this * package never reimplements install/probe/gate/freeze itself. */ export type AgentDefinitionDeployer = Pick; @@ -118,7 +116,7 @@ export async function writeAndDeployAgentDefinition(args: { } /** The HTTP status a `WorkflowAuthorError` from `writeAndDeployAgentDefinition` - * should surface as — the same mapping `@corbits/agent-workflow-authoring`'s + * should surface as — the same mapping `@corbits/workflows`'s `./authoring`'s * own `workflow-routes.ts` uses for the native deploy surface, reused here * so a sidecar-unavailable deploy reads as the same 502 envelope shape * everywhere a deploy can fail. */ diff --git a/packages/agent-directory/src/native-deploy-cutover.test.ts b/packages/agent-directory/src/native-deploy-cutover.test.ts index 887b9cd3..7ac03931 100644 --- a/packages/agent-directory/src/native-deploy-cutover.test.ts +++ b/packages/agent-directory/src/native-deploy-cutover.test.ts @@ -2,7 +2,7 @@ // through `@corbits/workflow-freeze`'s `DefinitionFreezer`, a hub-local // path that bypasses the native sidecar probe. This package now deploys // every definition write through the injected `WorkflowDeployer` — the -// SAME seam `@corbits/agent-workflow-authoring`'s own registry calls +// SAME seam `@corbits/workflows`'s `./authoring`'s own registry calls // (`sessionService.deployWorkflowFromSource`, install -> sidecar probe // -> gate -> freeze) — so `@corbits/workflow-freeze` must never again // appear in this package's source or its dependency manifest. diff --git a/packages/agent-directory/src/routes.ts b/packages/agent-directory/src/routes.ts index 2b145368..aeaf2f67 100644 --- a/packages/agent-directory/src/routes.ts +++ b/packages/agent-directory/src/routes.ts @@ -98,7 +98,7 @@ export type CreateAgentDefinitionRoutesDeps = { requireGrant: RequireGrant; /** Deploys the definition's commit through the native source pipeline * on every content write; the composition root injects the SAME - * `WorkflowDeployer` `@corbits/agent-workflow-authoring`'s registry + * `WorkflowDeployer` `@corbits/workflows`'s `./authoring`'s registry * calls. */ deployer: AgentDefinitionDeployer; tenantDefaultModel?: CreateAgentDefinitionCoreDeps["tenantDefaultModel"]; diff --git a/packages/agent-directory/src/workflow-capability-routes.ts b/packages/agent-directory/src/workflow-capability-routes.ts index b2a68b70..b78552af 100644 --- a/packages/agent-directory/src/workflow-capability-routes.ts +++ b/packages/agent-directory/src/workflow-capability-routes.ts @@ -126,7 +126,7 @@ export type CreateWorkflowCapabilityRoutesDeps = { authenticator: WorkflowRunAuthenticator; /** Deploys the definition's commit through the native source pipeline * after the rewrite; the composition root injects the SAME - * `WorkflowDeployer` `@corbits/agent-workflow-authoring`'s registry + * `WorkflowDeployer` `@corbits/workflows`'s `./authoring`'s registry * calls. */ deployer: AgentDefinitionDeployer; }; diff --git a/packages/agent-directory/src/workflow-skill-pin-routes.ts b/packages/agent-directory/src/workflow-skill-pin-routes.ts index f12a9cdb..3257da73 100644 --- a/packages/agent-directory/src/workflow-skill-pin-routes.ts +++ b/packages/agent-directory/src/workflow-skill-pin-routes.ts @@ -94,7 +94,7 @@ export type CreateWorkflowSkillPinRoutesDeps = { authenticator: WorkflowRunAuthenticator; /** Deploys the definition's commit through the native source pipeline * after the rewrite; the composition root injects the SAME - * `WorkflowDeployer` `@corbits/agent-workflow-authoring`'s registry + * `WorkflowDeployer` `@corbits/workflows`'s `./authoring`'s registry * calls. */ deployer: AgentDefinitionDeployer; }; diff --git a/packages/agent-runtime/package.json b/packages/agent-runtime/package.json index 07dedd25..d61b7af8 100644 --- a/packages/agent-runtime/package.json +++ b/packages/agent-runtime/package.json @@ -13,7 +13,7 @@ "test": "bun test" }, "dependencies": { - "@corbits/workflow-source": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/types": "workspace:*", "@intx/workflow": "workspace:*", diff --git a/packages/agent-runtime/src/source-tree.ts b/packages/agent-runtime/src/source-tree.ts index 96ae1c59..0182e473 100644 --- a/packages/agent-runtime/src/source-tree.ts +++ b/packages/agent-runtime/src/source-tree.ts @@ -12,7 +12,7 @@ // rather than shipping a call to it: an asset tree is a standalone // codebase, so a `workspace:*` dependency on `@corbits/agent-runtime` // has no workspace to resolve against and the closure resolver rejects -// it outright. `@corbits/workflow-source` renders the tree itself — +// it outright. `@corbits/workflows`'s `./source` renders the tree itself — // the same two files every other authoring path writes — which keeps // the config-IS-the-bytes property the retirement requires: // everything that varies per run is inside the hashed source, nothing @@ -25,7 +25,7 @@ import { renderWorkflowSourceTree, WORKFLOW_SOURCE_ENTRY, -} from "@corbits/workflow-source"; +} from "@corbits/workflows"; import { parseAgentRuntimeConfig, type AgentRuntimeConfig } from "./config"; import { buildAgentRuntimeWorkflow } from "./definition"; diff --git a/packages/agent-runtime/tsconfig.json b/packages/agent-runtime/tsconfig.json index f7199d25..d7611c12 100644 --- a/packages/agent-runtime/tsconfig.json +++ b/packages/agent-runtime/tsconfig.json @@ -1,31 +1,8 @@ { - "extends": "./tsconfig.src.json", + "extends": "../../tsconfig.base.json", + "include": ["src", "test"], "compilerOptions": { - "composite": false, - "noEmit": true, - "disableSourceOfProjectReferenceRedirect": true, - "declaration": false, - "declarationMap": false, - "emitDeclarationOnly": false, - "rootDir": "../.." - }, - "include": ["src"], - "exclude": [], - "references": [ - { - "path": "../../vendor/intx/agent/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/types/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/workflow-deploy/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/workflow/tsconfig.src.json" - }, - { - "path": "../workflow-source/tsconfig.src.json" - } - ] + "types": ["bun"], + "noEmit": true + } } diff --git a/packages/agent-runtime/tsconfig.src.json b/packages/agent-runtime/tsconfig.src.json deleted file mode 100644 index 85769533..00000000 --- a/packages/agent-runtime/tsconfig.src.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["src", "package.json", "src/**/*.json"], - "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"], - "compilerOptions": { - "types": ["bun"], - "composite": true, - "emitDeclarationOnly": true, - "outDir": "dist", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" - }, - "references": [ - { - "path": "../../vendor/intx/agent/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/types/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/workflow-deploy/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/workflow/tsconfig.src.json" - }, - { - "path": "../workflow-source/tsconfig.src.json" - } - ] -} diff --git a/packages/agent-workflow-authoring/package.json b/packages/agent-workflow-authoring/package.json deleted file mode 100644 index e1d78db1..00000000 --- a/packages/agent-workflow-authoring/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@corbits/agent-workflow-authoring", - "private": true, - "description": "Lets an agent author a workflow codebase as a native kind:\"workflow\" hub asset, republish it, and deploy it through Interchange's native source pipeline, each gated by an explicit grant on the agent's own principal and tenant — the hub half of the agent-authored-workflows capability", - "version": "0.1.0", - "license": "LGPL-2.1-or-later", - "type": "module", - "exports": { - ".": "./src/index.ts" - }, - "scripts": { - "typecheck": "tsc --noEmit", - "test": "bun test" - }, - "dependencies": { - "@intx/authz": "0.3.0", - "@intx/db": "workspace:*", - "@intx/hub-sessions": "workspace:*", - "@intx/types": "workspace:*", - "@workbench/hub-client": "workspace:*", - "arktype": "catalog:", - "drizzle-orm": "catalog:", - "hono": "^4.11.9" - }, - "devDependencies": { - "@types/bun": "catalog:", - "typescript": "catalog:" - } -} diff --git a/packages/chat/package.json b/packages/chat/package.json index 170d72e0..ea463682 100644 --- a/packages/chat/package.json +++ b/packages/chat/package.json @@ -36,7 +36,7 @@ "@corbits/memory": "github:corbitsdev/corbits-memory#9e6f213fa2c002b531d3f6af1aa0abd737b8afe3", "@corbits/turn-artifacts": "workspace:*", "@corbits/workflow-catalog": "workspace:*", - "@corbits/workflow-source": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/authz": "0.3.0", "@intx/crypto": "0.3.0", diff --git a/packages/chat/test/platform-adapter.test.ts b/packages/chat/test/platform-adapter.test.ts index d247b503..aa635e31 100644 --- a/packages/chat/test/platform-adapter.test.ts +++ b/packages/chat/test/platform-adapter.test.ts @@ -44,7 +44,7 @@ import { AGENT_RUNTIME_SECTION_ID } from "@corbits/agent-runtime"; import { parseWorkflowSourceEntry, WORKFLOW_SOURCE_ENTRY_PATH, -} from "@corbits/workflow-source"; +} from "@corbits/workflows"; import { SessionLaunchError } from "@intx/hub-sessions"; import type { EventCollectorRegistry, SidecarRouter } from "@intx/hub-sessions"; import type { DefinitionSourceResolution } from "@intx/hub-api"; diff --git a/packages/hub-client/package.json b/packages/hub-client/package.json index 181b3175..ceb84ec2 100644 --- a/packages/hub-client/package.json +++ b/packages/hub-client/package.json @@ -25,7 +25,7 @@ "@corbits/tool-registry-publish": "workspace:*", "@corbits/workbench-digest-workflow": "workspace:*", "@corbits/workflow-catalog": "workspace:*", - "@corbits/workflow-source": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/inference": "workspace:*", "@intx/types": "workspace:*", "arktype": "catalog:" diff --git a/packages/hub-client/src/seed.ts b/packages/hub-client/src/seed.ts index f3ddc5cc..bab86992 100644 --- a/packages/hub-client/src/seed.ts +++ b/packages/hub-client/src/seed.ts @@ -48,7 +48,7 @@ import { WORKFLOW_CATALOG } from "@corbits/workflow-catalog"; import { capabilitiesForDeployment } from "@corbits/inference-catalog/offering-capabilities"; import { quirksForDeployment } from "@corbits/inference-catalog/ollama-context-defaults"; import { type PublishCorbitsToolsRegistryArgs } from "@corbits/tool-registry-publish"; -import { WORKFLOW_SOURCE_ENTRY } from "@corbits/workflow-source"; +import { WORKFLOW_SOURCE_ENTRY } from "@corbits/workflows"; import { CliError, SidecarUnavailableError } from "./errors"; import { DEFAULT_SKILLS } from "./default-skills"; import { ensureDefaultRoutines } from "./default-routines"; @@ -357,7 +357,7 @@ export const SEED_GRANTS: readonly { resource: string; action: string }[] = [ // CL-6465: the eval-run read routes (`GET .../eval-runs/runs`, // `GET .../eval-runs/runs/:runId`) gate on this resource. { resource: "eval-run:*", action: "read" }, - // Agent-authored workflows (`@corbits/agent-workflow-authoring`'s + // Agent-authored workflows (`@corbits/workflows`'s `./authoring` // `author`/`republish` routes): a seeded principal was never granted // "create"/"write" on "asset:*" before, because no workflow-run write // surface checked it — every prior workflow-run write route (skills, diff --git a/packages/hub-client/src/workflow-push.ts b/packages/hub-client/src/workflow-push.ts index c170ab4e..2df44cee 100644 --- a/packages/hub-client/src/workflow-push.ts +++ b/packages/hub-client/src/workflow-push.ts @@ -5,7 +5,7 @@ // convention. Content-aware: an identical tree is a reported skip, not // a duplicate commit, which is what makes re-running seed safe. // -// The pushed tree is the source codebase `@corbits/workflow-source` +// The pushed tree is the source codebase `@corbits/workflows`'s `./source` // renders — the one shape a workflow-kind asset accepts (see // `vendor/intx/hub-sessions/src/workflow-kind.ts`), shared with every // other authoring path in this repo. @@ -13,7 +13,7 @@ import { chmod, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { renderWorkflowSourceTree } from "@corbits/workflow-source"; +import { renderWorkflowSourceTree } from "@corbits/workflows"; import { CliError } from "./errors"; import type { WorkflowPusher } from "./seed"; diff --git a/packages/workflow-authoring-tools/README.md b/packages/workflow-authoring-tools/README.md index 0f6eb1db..d3af4e51 100644 --- a/packages/workflow-authoring-tools/README.md +++ b/packages/workflow-authoring-tools/README.md @@ -1,6 +1,6 @@ # @corbits/workflow-authoring-tools -The `@intx/agent` tool bundle over `@corbits/agent-workflow-authoring`'s +The `@intx/agent` tool bundle over `@corbits/workflows`'s `./authoring`'s workflow-run-authenticated routes (CL-7360): an agent writes an ordinary workflow code package into a `kind: "workflow"` hub asset, republishes it, and reads it back. See [docs/workflow-source-authoring.md](../../docs/workflow-source-authoring.md) diff --git a/packages/workflow-authoring-tools/package.json b/packages/workflow-authoring-tools/package.json index c02548d6..de63233b 100644 --- a/packages/workflow-authoring-tools/package.json +++ b/packages/workflow-authoring-tools/package.json @@ -1,7 +1,7 @@ { "name": "@corbits/workflow-authoring-tools", "private": true, - "description": "Myra's workflow-authoring tool bundle (workflow_author, workflow_republish, workflow_source_read, workflow_deploy_preview, workflow_deploy): an @intx/agent tool bundle calling @corbits/agent-workflow-authoring's workflow-run-authenticated routes so an agent can write a workflow code package into a kind:\"workflow\" hub asset, read it back, preview a deploy's grant surface, and deploy it through Interchange's native source pipeline behind a human approval", + "description": "Myra's workflow-authoring tool bundle (workflow_author, workflow_republish, workflow_source_read, workflow_deploy_preview, workflow_deploy): an @intx/agent tool bundle calling @corbits/workflows's `./authoring`'s workflow-run-authenticated routes so an agent can write a workflow code package into a kind:\"workflow\" hub asset, read it back, preview a deploy's grant surface, and deploy it through Interchange's native source pipeline behind a human approval", "version": "0.0.3", "license": "LGPL-2.1-or-later", "type": "module", diff --git a/packages/workflow-authoring-tools/src/client.ts b/packages/workflow-authoring-tools/src/client.ts index d76a6c7a..080369bb 100644 --- a/packages/workflow-authoring-tools/src/client.ts +++ b/packages/workflow-authoring-tools/src/client.ts @@ -1,5 +1,5 @@ // A minimal client for the workflow-run-authenticated authoring surface -// (`@corbits/agent-workflow-authoring`'s `createWorkflowAuthorRoutes`, +// (`@corbits/workflows`'s `./authoring`'s `createWorkflowAuthorRoutes`, // mounted in `apps/hub` at `/api/workflow-workflow-authoring`). Every // call carries the run's own sidecar bearer token and run address — // the same two headers `@corbits/capability-tools` sends — so the hub diff --git a/packages/workflow-catalog/package.json b/packages/workflow-catalog/package.json index 9fa46137..938edddf 100644 --- a/packages/workflow-catalog/package.json +++ b/packages/workflow-catalog/package.json @@ -8,8 +8,7 @@ "exports": { ".": "./src/index.ts", "./connect-github-routes": "./src/connect-github-routes.ts", - "./template-block-routes": "./src/template-block-routes.ts", - "./detail-route": "./src/detail-route.ts" + "./template-block-routes": "./src/template-block-routes.ts" }, "scripts": { "typecheck": "tsc --noEmit", @@ -23,7 +22,6 @@ "@corbits/jimmy-agent": "workspace:*", "@corbits/scout-agent": "workspace:*", "@corbits/webhook-triggers": "workspace:*", - "@corbits/workflow-deploy-source": "workspace:*", "@intx/db": "workspace:*", "@intx/hub-api": "workspace:*", "@workbench/hub-client": "workspace:*", diff --git a/packages/workflow-catalog/src/block-workflows.ts b/packages/workflow-catalog/src/block-workflows.ts index bd179d7e..2d9287be 100644 --- a/packages/workflow-catalog/src/block-workflows.ts +++ b/packages/workflow-catalog/src/block-workflows.ts @@ -3,7 +3,7 @@ // resolves a manifest's participants through the agent-directory create // path, and this module resolves its `blocks` into the same // source-form deploy (a serialized definition rendered into a -// `@corbits/workflow-source` tree and projected onto a +// `@corbits/workflows`'s `./source` tree and projected onto a // `workflow_definition` row — see `./template-block-routes.ts` and the // hub's `deployWorkflowSource` binding). // diff --git a/packages/workflow-catalog/src/index.ts b/packages/workflow-catalog/src/index.ts index 2611961b..465f730e 100644 --- a/packages/workflow-catalog/src/index.ts +++ b/packages/workflow-catalog/src/index.ts @@ -49,24 +49,10 @@ export { type ConnectGithubSetupPorts, type StartReviewingReposResult, } from "./connect-github-setup"; -export { - deriveWorkflowLifecycle, - type DefinitionLifecycleRow, - type WorkflowLifecycle, - type WorkflowLifecycleResult, -} from "./definition-lifecycle"; -export { - WorkflowDefinitionDetail, - WorkflowDetailSource, - WorkflowDetailStep, - workflowDetailPath, - workflowNotLaunchableReason, -} from "./definition-detail"; -export type { - WorkflowDefinitionDetail as WorkflowDefinitionDetailT, - WorkflowDetailSource as WorkflowDetailSourceT, - WorkflowDetailStep as WorkflowDetailStepT, -} from "./definition-detail"; +// CL-7373: the workflow definition lifecycle/detail types moved to +// @corbits/workflows (`.` for the detail route, `./client` for the +// browser-safe wire schema and pure lifecycle derivation) alongside the +// deploy-source record they read. /** * One named field a mail trigger reads by name — the create-time UI's only diff --git a/packages/workflow-catalog/src/template-block-routes.ts b/packages/workflow-catalog/src/template-block-routes.ts index f03f18fd..a07a9f4a 100644 --- a/packages/workflow-catalog/src/template-block-routes.ts +++ b/packages/workflow-catalog/src/template-block-routes.ts @@ -34,7 +34,7 @@ export type TemplateBlockRoutesDeps = { tenantId: string, ): Promise; /** The source-form deploy itself: renders `workflowJson` into a - * `@corbits/workflow-source` tree on a `workflow`-kind asset and + * `@corbits/workflows`'s `./source` tree on a `workflow`-kind asset and * projects it onto a `workflow_definition` row — the exact * materialization `createAgentDefinitionCore` runs for a participant * agent, minus its agent-only prompt/skills machinery. `created` is diff --git a/packages/workflow-deploy-source/LICENSE b/packages/workflow-deploy-source/LICENSE deleted file mode 100644 index c6487f4f..00000000 --- a/packages/workflow-deploy-source/LICENSE +++ /dev/null @@ -1,176 +0,0 @@ -GNU LESSER GENERAL PUBLIC LICENSE - -Version 2.1, February 1999 - -Copyright (C) 1991, 1999 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] - -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. - -This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. - -When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. - -To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. - -For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. - -We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. - -To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - -Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. - -Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. - -When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. - -We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. - -For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. - -In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. - -Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. - -The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - -GNU LESSER GENERAL PUBLIC LICENSE -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". - -A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. - -(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - -Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of the Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. - -If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. - -5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. - -However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. - -When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. - -If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. - -You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: - - a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. - - e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - -7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. - - b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - -11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Libraries - -If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). - -To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - one line to give the library's name and an idea of what it does. - Copyright (C) year name of author - - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright interest in -the library `Frob' (a library for tweaking knobs) written -by James Random Hacker. - -signature of Ty Coon, 1 April 1990 -Ty Coon, President of Vice -That's all there is to it! diff --git a/packages/workflow-deploy-source/package.json b/packages/workflow-deploy-source/package.json deleted file mode 100644 index a1fb9111..00000000 --- a/packages/workflow-deploy-source/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@corbits/workflow-deploy-source", - "private": true, - "description": "Durable, hub-side record of a native workflow's deploy source (WorkflowDefinitionSource: an asset commit or a registry name@range pin), for every sidecar placement — so a deployment can be recreated from Postgres alone, with nothing owed to the sidecar's local disk.", - "version": "0.0.1", - "license": "LGPL-2.1-or-later", - "type": "module", - "exports": { - ".": "./src/index.ts", - "./migrations": "./src/migrations.ts" - }, - "scripts": { - "typecheck": "tsc --noEmit", - "test": "bun test" - }, - "dependencies": { - "@corbits/error-sink": "workspace:*", - "@corbits/migration-runner": "workspace:*", - "@intx/hub-sessions": "workspace:*", - "@intx/types": "workspace:*", - "arktype": "catalog:", - "drizzle-orm": "catalog:", - "postgres": "catalog:" - }, - "devDependencies": { - "@types/bun": "catalog:", - "typescript": "catalog:" - } -} diff --git a/packages/workflow-deploy-source/tsconfig.json b/packages/workflow-deploy-source/tsconfig.json deleted file mode 100644 index 83175c08..00000000 --- a/packages/workflow-deploy-source/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "extends": "./tsconfig.src.json", - "compilerOptions": { - "composite": false, - "noEmit": true, - "disableSourceOfProjectReferenceRedirect": true, - "declaration": false, - "declarationMap": false, - "emitDeclarationOnly": false, - "rootDir": "../.." - }, - "include": ["src", "test"], - "exclude": [], - "references": [ - { - "path": "../../vendor/intx/hub-sessions/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/types/tsconfig.src.json" - }, - { - "path": "../error-sink/tsconfig.src.json" - }, - { - "path": "../migration-runner/tsconfig.src.json" - } - ] -} diff --git a/packages/workflow-deploy-source/tsconfig.src.json b/packages/workflow-deploy-source/tsconfig.src.json deleted file mode 100644 index a65f8ac7..00000000 --- a/packages/workflow-deploy-source/tsconfig.src.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["src", "package.json", "src/**/*.json"], - "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"], - "compilerOptions": { - "types": ["bun"], - "composite": true, - "emitDeclarationOnly": true, - "outDir": "dist", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" - }, - "references": [ - { - "path": "../../vendor/intx/hub-sessions/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/types/tsconfig.src.json" - }, - { - "path": "../error-sink/tsconfig.src.json" - }, - { - "path": "../migration-runner/tsconfig.src.json" - } - ] -} diff --git a/packages/workflow-source/LICENSE b/packages/workflow-source/LICENSE deleted file mode 100644 index c6487f4f..00000000 --- a/packages/workflow-source/LICENSE +++ /dev/null @@ -1,176 +0,0 @@ -GNU LESSER GENERAL PUBLIC LICENSE - -Version 2.1, February 1999 - -Copyright (C) 1991, 1999 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] - -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. - -This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. - -When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. - -To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. - -For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. - -We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. - -To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - -Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. - -Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. - -When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. - -We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. - -For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. - -In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. - -Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. - -The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - -GNU LESSER GENERAL PUBLIC LICENSE -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". - -A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. - -(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - -Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of the Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. - -If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. - -5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. - -However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. - -When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. - -If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. - -You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: - - a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. - - e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - -7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. - - b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - -11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Libraries - -If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). - -To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - one line to give the library's name and an idea of what it does. - Copyright (C) year name of author - - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright interest in -the library `Frob' (a library for tweaking knobs) written -by James Random Hacker. - -signature of Ty Coon, 1 April 1990 -Ty Coon, President of Vice -That's all there is to it! diff --git a/packages/workflow-source/package.json b/packages/workflow-source/package.json deleted file mode 100644 index 5a8f0773..00000000 --- a/packages/workflow-source/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "@corbits/workflow-source", - "private": true, - "description": "The source codebase a workflow-kind asset carries — the two-file renderer every authoring path writes and the reader that recovers the definition back out of it", - "version": "0.0.1", - "license": "LGPL-2.1-or-later", - "type": "module", - "exports": { - ".": "./src/index.ts" - }, - "scripts": { - "typecheck": "tsc --noEmit", - "test": "bun test" - }, - "devDependencies": { - "@intx/hub-sessions": "workspace:*", - "@types/bun": "catalog:", - "typescript": "catalog:" - } -} diff --git a/packages/workflow-source/tsconfig.json b/packages/workflow-source/tsconfig.json deleted file mode 100644 index b7e78fb5..00000000 --- a/packages/workflow-source/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig.src.json", - "compilerOptions": { - "composite": false, - "noEmit": true, - "disableSourceOfProjectReferenceRedirect": true, - "declaration": false, - "declarationMap": false, - "emitDeclarationOnly": false, - "rootDir": "../.." - }, - "include": ["src"], - "exclude": [] -} diff --git a/packages/workflow-source/tsconfig.src.json b/packages/workflow-source/tsconfig.src.json deleted file mode 100644 index fc872430..00000000 --- a/packages/workflow-source/tsconfig.src.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["src", "package.json", "src/**/*.json"], - "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"], - "compilerOptions": { - "types": ["bun"], - "composite": true, - "emitDeclarationOnly": true, - "outDir": "dist", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" - } -} diff --git a/packages/agent-workflow-authoring/LICENSE b/packages/workflows/LICENSE similarity index 100% rename from packages/agent-workflow-authoring/LICENSE rename to packages/workflows/LICENSE diff --git a/packages/workflows/README.md b/packages/workflows/README.md new file mode 100644 index 00000000..f346312f --- /dev/null +++ b/packages/workflows/README.md @@ -0,0 +1,13 @@ +# @corbits/workflows + +The workflow domain package: `./source` (the two-file source codebase +every authoring path renders/reads), `./deploy-source` (the durable +deploy-source record), `./detail` (the definition detail read a +workflow's own page uses), and `./authoring` (letting an agent author, +republish, and deploy a workflow through Interchange's native source +pipeline). + +Server code imports `@corbits/workflows`; browser code imports +`@corbits/workflows/client` for the browser-safe subset (source +constants, the definition-detail wire schema, and the pure lifecycle +derivation). diff --git a/packages/workflows/package.json b/packages/workflows/package.json new file mode 100644 index 00000000..d561f7c9 --- /dev/null +++ b/packages/workflows/package.json @@ -0,0 +1,34 @@ +{ + "name": "@corbits/workflows", + "private": true, + "description": "The workflow domain package: the two-file source codebase every authoring path renders/reads (`./source`), the durable deploy-source record for a code-sourced deploy (`./deploy-source`), the definition detail read a workflow's own page uses (`./detail`), and letting an agent author/republish/deploy a workflow through Interchange's native source pipeline (`./authoring`)", + "version": "0.0.1", + "license": "LGPL-2.1-or-later", + "type": "module", + "exports": { + ".": "./src/index.ts", + "./client": "./src/client.ts" + }, + "scripts": { + "typecheck": "tsc --noEmit", + "test": "bun test" + }, + "dependencies": { + "@corbits/error-sink": "workspace:*", + "@corbits/migration-runner": "workspace:*", + "@intx/authz": "0.3.0", + "@intx/db": "workspace:*", + "@intx/hub-api": "workspace:*", + "@intx/hub-sessions": "workspace:*", + "@intx/types": "workspace:*", + "@workbench/hub-client": "workspace:*", + "arktype": "catalog:", + "drizzle-orm": "catalog:", + "hono": "^4.11.9", + "postgres": "catalog:" + }, + "devDependencies": { + "@types/bun": "catalog:", + "typescript": "catalog:" + } +} diff --git a/packages/agent-workflow-authoring/src/errors.ts b/packages/workflows/src/authoring/errors.ts similarity index 100% rename from packages/agent-workflow-authoring/src/errors.ts rename to packages/workflows/src/authoring/errors.ts diff --git a/packages/agent-workflow-authoring/src/index.ts b/packages/workflows/src/authoring/index.ts similarity index 100% rename from packages/agent-workflow-authoring/src/index.ts rename to packages/workflows/src/authoring/index.ts diff --git a/packages/agent-workflow-authoring/src/registry.test.ts b/packages/workflows/src/authoring/registry.test.ts similarity index 100% rename from packages/agent-workflow-authoring/src/registry.test.ts rename to packages/workflows/src/authoring/registry.test.ts diff --git a/packages/agent-workflow-authoring/src/registry.ts b/packages/workflows/src/authoring/registry.ts similarity index 100% rename from packages/agent-workflow-authoring/src/registry.ts rename to packages/workflows/src/authoring/registry.ts diff --git a/packages/agent-workflow-authoring/src/source-tree.test.ts b/packages/workflows/src/authoring/source-tree.test.ts similarity index 100% rename from packages/agent-workflow-authoring/src/source-tree.test.ts rename to packages/workflows/src/authoring/source-tree.test.ts diff --git a/packages/agent-workflow-authoring/src/source-tree.ts b/packages/workflows/src/authoring/source-tree.ts similarity index 100% rename from packages/agent-workflow-authoring/src/source-tree.ts rename to packages/workflows/src/authoring/source-tree.ts diff --git a/packages/agent-workflow-authoring/src/workflow-routes.test.ts b/packages/workflows/src/authoring/workflow-routes.test.ts similarity index 100% rename from packages/agent-workflow-authoring/src/workflow-routes.test.ts rename to packages/workflows/src/authoring/workflow-routes.test.ts diff --git a/packages/agent-workflow-authoring/src/workflow-routes.ts b/packages/workflows/src/authoring/workflow-routes.ts similarity index 100% rename from packages/agent-workflow-authoring/src/workflow-routes.ts rename to packages/workflows/src/authoring/workflow-routes.ts diff --git a/packages/workflows/src/client.ts b/packages/workflows/src/client.ts new file mode 100644 index 00000000..0f2974d6 --- /dev/null +++ b/packages/workflows/src/client.ts @@ -0,0 +1,19 @@ +// @corbits/workflows browser-safe entry — no `@intx/*`, no `drizzle-orm`, +// no `hono`: the workflow source-tree constants, the definition-detail +// wire schema, and the pure lifecycle-copy helper a workflow's own page +// reads directly. `check:browser-safe-subpaths` walks the real import +// graph from here and fails if anything server-only leaks in. +export * from "./source"; +export { + workflowNotLaunchableReason, + workflowDetailPath, + WorkflowDefinitionDetail, + WorkflowDetailSource, + WorkflowDetailStep, +} from "./detail/definition-detail"; +export { + deriveWorkflowLifecycle, + type DefinitionLifecycleRow, + type WorkflowLifecycle, + type WorkflowLifecycleResult, +} from "./detail/definition-lifecycle"; diff --git a/packages/workflow-deploy-source/src/index.ts b/packages/workflows/src/deploy-source/index.ts similarity index 100% rename from packages/workflow-deploy-source/src/index.ts rename to packages/workflows/src/deploy-source/index.ts diff --git a/packages/workflow-deploy-source/test/migrations.test.ts b/packages/workflows/src/deploy-source/migrations.test.ts similarity index 96% rename from packages/workflow-deploy-source/test/migrations.test.ts rename to packages/workflows/src/deploy-source/migrations.test.ts index c1138bc3..05fe55fc 100644 --- a/packages/workflow-deploy-source/test/migrations.test.ts +++ b/packages/workflows/src/deploy-source/migrations.test.ts @@ -4,9 +4,9 @@ import { afterAll, beforeAll, expect, test } from "bun:test"; import postgres from "postgres"; -import { e2eDatabaseUrl } from "../../../scripts/e2e/harness"; -import { applyWorkflowDeploySourceMigrations } from "../src/migrations"; -import { dbGate } from "../../../scripts/e2e/db-gate"; +import { e2eDatabaseUrl } from "../../../../scripts/e2e/harness"; +import { applyWorkflowDeploySourceMigrations } from "./migrations"; +import { dbGate } from "../../../../scripts/e2e/db-gate"; function scratchUrlFor(e2eUrl: string): string { const url = new URL(e2eUrl); diff --git a/packages/workflow-deploy-source/src/migrations.ts b/packages/workflows/src/deploy-source/migrations.ts similarity index 96% rename from packages/workflow-deploy-source/src/migrations.ts rename to packages/workflows/src/deploy-source/migrations.ts index 38c2a7ae..467bc3cd 100644 --- a/packages/workflow-deploy-source/src/migrations.ts +++ b/packages/workflows/src/deploy-source/migrations.ts @@ -1,4 +1,4 @@ -// Package-owned migrations for @corbits/workflow-deploy-source. +// Package-owned migrations for @corbits/workflows's ./deploy-source. // Bookkeeping uses its own ledger table so the package can be extracted // without disentangling history from the platform drizzle journal. The // table this package owns lives in its own `workflow_deploy_source` diff --git a/packages/workflow-deploy-source/test/record-on-deploy.test.ts b/packages/workflows/src/deploy-source/record-on-deploy.test.ts similarity index 98% rename from packages/workflow-deploy-source/test/record-on-deploy.test.ts rename to packages/workflows/src/deploy-source/record-on-deploy.test.ts index 1f176ab2..c88a7da9 100644 --- a/packages/workflow-deploy-source/test/record-on-deploy.test.ts +++ b/packages/workflows/src/deploy-source/record-on-deploy.test.ts @@ -23,11 +23,11 @@ afterEach(() => { mock.restore(); }); -const { withDeploySourceRecording } = await import("../src/record-on-deploy"); +const { withDeploySourceRecording } = await import("./record-on-deploy"); import type { WorkflowDeploySourceRecord, WorkflowDeploySourceStore, -} from "../src/store"; +} from "./store"; function fakeDeployer(): SessionService & AdoptingWorkflowDeployer { const result: DeployWorkflowDefinitionResult = { diff --git a/packages/workflow-deploy-source/src/record-on-deploy.ts b/packages/workflows/src/deploy-source/record-on-deploy.ts similarity index 100% rename from packages/workflow-deploy-source/src/record-on-deploy.ts rename to packages/workflows/src/deploy-source/record-on-deploy.ts diff --git a/packages/workflow-deploy-source/src/schema.ts b/packages/workflows/src/deploy-source/schema.ts similarity index 100% rename from packages/workflow-deploy-source/src/schema.ts rename to packages/workflows/src/deploy-source/schema.ts diff --git a/packages/workflow-deploy-source/test/store.test.ts b/packages/workflows/src/deploy-source/store.test.ts similarity index 96% rename from packages/workflow-deploy-source/test/store.test.ts rename to packages/workflows/src/deploy-source/store.test.ts index 910f9793..9b430ad2 100644 --- a/packages/workflow-deploy-source/test/store.test.ts +++ b/packages/workflows/src/deploy-source/store.test.ts @@ -5,10 +5,10 @@ import { afterAll, beforeAll, expect, test } from "bun:test"; import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; -import { e2eDatabaseUrl } from "../../../scripts/e2e/harness"; -import { applyWorkflowDeploySourceMigrations } from "../src/migrations"; -import { createDrizzleWorkflowDeploySourceStore } from "../src/store"; -import { dbGate } from "../../../scripts/e2e/db-gate"; +import { e2eDatabaseUrl } from "../../../../scripts/e2e/harness"; +import { applyWorkflowDeploySourceMigrations } from "./migrations"; +import { createDrizzleWorkflowDeploySourceStore } from "./store"; +import { dbGate } from "../../../../scripts/e2e/db-gate"; function scratchUrlFor(e2eUrl: string): string { const url = new URL(e2eUrl); diff --git a/packages/workflow-deploy-source/src/store.ts b/packages/workflows/src/deploy-source/store.ts similarity index 100% rename from packages/workflow-deploy-source/src/store.ts rename to packages/workflows/src/deploy-source/store.ts diff --git a/packages/workflow-catalog/src/definition-detail.ts b/packages/workflows/src/detail/definition-detail.ts similarity index 100% rename from packages/workflow-catalog/src/definition-detail.ts rename to packages/workflows/src/detail/definition-detail.ts diff --git a/packages/workflow-catalog/src/definition-lifecycle.test.ts b/packages/workflows/src/detail/definition-lifecycle.test.ts similarity index 100% rename from packages/workflow-catalog/src/definition-lifecycle.test.ts rename to packages/workflows/src/detail/definition-lifecycle.test.ts diff --git a/packages/workflow-catalog/src/definition-lifecycle.ts b/packages/workflows/src/detail/definition-lifecycle.ts similarity index 97% rename from packages/workflow-catalog/src/definition-lifecycle.ts rename to packages/workflows/src/detail/definition-lifecycle.ts index 81e011b2..4f54f725 100644 --- a/packages/workflow-catalog/src/definition-lifecycle.ts +++ b/packages/workflows/src/detail/definition-lifecycle.ts @@ -7,7 +7,7 @@ // a new row rather than mutating one. What a person needs is a single // reading of the newest row for the asset, folded against the one // Workbench-owned signal native rows don't carry: whether a deploy was ever -// attempted at all (`@corbits/workflow-deploy-source`'s per-anchor-run +// attempted at all (`@corbits/workflows`'s `./deploy-source`'s per-anchor-run // record). Kept in its own module, with no DB import, so the four states // below are covered by a plain unit test rather than a route fixture. export type WorkflowLifecycle = diff --git a/packages/workflow-catalog/test/detail-route.drizzle.test.ts b/packages/workflows/src/detail/detail-route.drizzle.test.ts similarity index 93% rename from packages/workflow-catalog/test/detail-route.drizzle.test.ts rename to packages/workflows/src/detail/detail-route.drizzle.test.ts index 6c70a05b..b7605eb1 100644 --- a/packages/workflow-catalog/test/detail-route.drizzle.test.ts +++ b/packages/workflows/src/detail/detail-route.drizzle.test.ts @@ -9,12 +9,12 @@ import { Hono } from "hono"; import type { MiddlewareHandler } from "hono"; import { createDB, runMigrations, dropSchema, schema } from "@intx/db"; import type { RequireGrant, TenantEnv } from "@intx/hub-api"; -import { applyWorkflowDeploySourceMigrations } from "@corbits/workflow-deploy-source/migrations"; +import { applyWorkflowDeploySourceMigrations } from "../deploy-source/migrations"; -import { dbTargetFromUrl } from "../../../scripts/db-setup"; -import { e2eDatabaseUrl } from "../../../scripts/e2e/harness"; -import { dbGate } from "../../../scripts/e2e/db-gate"; -import { createWorkflowDetailRoute } from "../src/detail-route"; +import { dbTargetFromUrl } from "../../../../scripts/db-setup"; +import { e2eDatabaseUrl } from "../../../../scripts/e2e/harness"; +import { dbGate } from "../../../../scripts/e2e/db-gate"; +import { createWorkflowDetailRoute } from "./detail-route"; const databaseUrl = e2eDatabaseUrl(); const describeIfDb = dbGate(databaseUrl, import.meta.path); diff --git a/packages/workflow-catalog/src/detail-route.ts b/packages/workflows/src/detail/detail-route.ts similarity index 97% rename from packages/workflow-catalog/src/detail-route.ts rename to packages/workflows/src/detail/detail-route.ts index 84146952..cf3d54bf 100644 --- a/packages/workflow-catalog/src/detail-route.ts +++ b/packages/workflows/src/detail/detail-route.ts @@ -6,7 +6,7 @@ // alongside the vendored `createWorkflowDefinitionRoutes` at // `${TENANT_PREFIX}/workflows/definitions` (`apps/hub/src/index.ts`), not // inside it: this is a Workbench-owned read composed over native rows plus -// `@corbits/workflow-deploy-source`'s deploy-attempt record, not something +// `@corbits/workflows`'s `./deploy-source`'s deploy-attempt record, not something // `vendor/intx/hub-api` knows about. // // Every field is read-only and native: `workflow_definition` / @@ -25,8 +25,8 @@ import { } from "@intx/db"; import type { RequireGrant, TenantEnv } from "@intx/hub-api"; import { idResource } from "@intx/hub-api"; -import type { WorkflowDeploySourceDb } from "@corbits/workflow-deploy-source"; -import { workflowDeploySource } from "@corbits/workflow-deploy-source"; +import type { WorkflowDeploySourceDb } from "../deploy-source/store"; +import { workflowDeploySource } from "../deploy-source/schema"; import { deriveWorkflowLifecycle } from "./definition-lifecycle"; import type { WorkflowDefinitionDetail } from "./definition-detail"; diff --git a/packages/workflows/src/detail/index.ts b/packages/workflows/src/detail/index.ts new file mode 100644 index 00000000..4ef88e89 --- /dev/null +++ b/packages/workflows/src/detail/index.ts @@ -0,0 +1,17 @@ +export { + deriveWorkflowLifecycle, + type DefinitionLifecycleRow, + type WorkflowLifecycle, + type WorkflowLifecycleResult, +} from "./definition-lifecycle"; +export { + workflowNotLaunchableReason, + workflowDetailPath, + WorkflowDefinitionDetail, + WorkflowDetailSource, + WorkflowDetailStep, +} from "./definition-detail"; +export { + createWorkflowDetailRoute, + type CreateWorkflowDetailRouteDeps, +} from "./detail-route"; diff --git a/packages/workflows/src/index.ts b/packages/workflows/src/index.ts new file mode 100644 index 00000000..77898dc7 --- /dev/null +++ b/packages/workflows/src/index.ts @@ -0,0 +1,8 @@ +// @corbits/workflows server entry — everything: the source-tree +// renderer/reader, the deploy-source durability layer, the definition +// detail route, and agent-authored-workflow authoring. Browser code +// imports `@corbits/workflows/client` instead (see ./client.ts). +export * from "./source"; +export * from "./deploy-source/index"; +export * from "./detail/index"; +export * from "./authoring/index"; diff --git a/packages/workflow-source/src/index.test.ts b/packages/workflows/src/source.test.ts similarity index 99% rename from packages/workflow-source/src/index.test.ts rename to packages/workflows/src/source.test.ts index f7335d9c..4779f0e3 100644 --- a/packages/workflow-source/src/index.test.ts +++ b/packages/workflows/src/source.test.ts @@ -6,7 +6,7 @@ import { renderWorkflowSourceTree, RetiredWorkflowEnvelopeError, WORKFLOW_SOURCE_ENTRY, -} from "./index"; +} from "./source"; const WORKFLOW_JSON = JSON.stringify({ id: "wf_agent_research-buddy" }); diff --git a/packages/workflow-source/src/index.ts b/packages/workflows/src/source.ts similarity index 100% rename from packages/workflow-source/src/index.ts rename to packages/workflows/src/source.ts diff --git a/packages/workflow-source/src/validate-push.test.ts b/packages/workflows/src/validate-push.test.ts similarity index 98% rename from packages/workflow-source/src/validate-push.test.ts rename to packages/workflows/src/validate-push.test.ts index 40f0305c..6f5b436e 100644 --- a/packages/workflow-source/src/validate-push.test.ts +++ b/packages/workflows/src/validate-push.test.ts @@ -8,7 +8,7 @@ import { expect, test } from "bun:test"; import { workflowKindHandler } from "@intx/hub-sessions"; -import { renderWorkflowSourceTree } from "./index"; +import { renderWorkflowSourceTree } from "./source"; const WORKFLOW_JSON = JSON.stringify({ id: "wf_agent_research-buddy" }); diff --git a/packages/agent-workflow-authoring/tsconfig.json b/packages/workflows/tsconfig.json similarity index 100% rename from packages/agent-workflow-authoring/tsconfig.json rename to packages/workflows/tsconfig.json diff --git a/scripts/checks/browser-safe-subpaths.ts b/scripts/checks/browser-safe-subpaths.ts index a3e53455..4b2653e6 100644 --- a/scripts/checks/browser-safe-subpaths.ts +++ b/scripts/checks/browser-safe-subpaths.ts @@ -76,6 +76,10 @@ export const ENTRIES: readonly BrowserSafeEntry[] = [ // gate; `headlineFor` is pure string work over a tool snapshot, so the // browser composes an approval's headline through this subpath. { package: "@corbits/approvals", subpath: "./headline" }, + // CL-7373: the workflow source-tree constants, the definition-detail + // wire schema, and the pure lifecycle derivation — the same read + // `apps/web`'s workflow detail page (`workflow-detail-api.ts`) needs. + { package: "@corbits/workflows", subpath: "./client" }, ]; const DENYLIST_PATTERNS: readonly RegExp[] = [ diff --git a/scripts/checks/routine-target-inference.ts b/scripts/checks/routine-target-inference.ts index 793f9b79..622fb349 100644 --- a/scripts/checks/routine-target-inference.ts +++ b/scripts/checks/routine-target-inference.ts @@ -8,7 +8,7 @@ // picks a target explicitly through `DefinitionTargetPicker` (see // docs/workflow-model.md, "Behavior to delete, not retain"). // - No non-vendor source may read or write a literal `workflow.json` -// path, except `@corbits/workflow-source`'s own +// path, except `@corbits/workflows`'s `./source`'s own // `RetiredWorkflowEnvelopeError` message, which exists only to name // the retired path in order to reject it. import { Glob } from "bun"; @@ -27,7 +27,7 @@ const AGENTS_ZERO_DEFINITION_ID_PATTERN = /\bagents\[0\](?:\?\.|\.)\s*definitionId\b/g; const WORKFLOW_JSON_LITERAL_PATTERN = /(["'`])workflow\.json\1/g; -const WORKFLOW_JSON_ALLOWED_FILE = "packages/workflow-source/src/index.ts"; +const WORKFLOW_JSON_ALLOWED_FILE = "packages/workflows/src/source.ts"; export async function scanFiles( root: string, diff --git a/scripts/db-setup.ts b/scripts/db-setup.ts index d60382ac..35ac5243 100644 --- a/scripts/db-setup.ts +++ b/scripts/db-setup.ts @@ -52,7 +52,7 @@ import { applyAgentDirectoryMigrations } from "../packages/agent-directory/src/m import { applyOnboardingMigrations } from "../packages/onboarding/src/migrations"; import { applyAccessPolicyMigrations } from "../packages/access-policy/src/migrations"; import { applyRunKeyHistoryMigrations } from "../packages/run-key-history/src/migrations"; -import { applyWorkflowDeploySourceMigrations } from "../packages/workflow-deploy-source/src/migrations"; +import { applyWorkflowDeploySourceMigrations } from "../packages/workflows/src/deploy-source/migrations"; import { applyInferenceCatalogMigrations } from "../packages/inference-catalog/src/migrations"; const repoRoot = path.resolve(import.meta.dir, ".."); @@ -91,7 +91,7 @@ const INSTALLED_PACKAGE_MIGRATIONS: readonly { { name: "@workbench/access-policy", apply: applyAccessPolicyMigrations }, { name: "@corbits/run-key-history", apply: applyRunKeyHistoryMigrations }, { - name: "@corbits/workflow-deploy-source", + name: "@corbits/workflows (deploy-source)", apply: applyWorkflowDeploySourceMigrations, }, { diff --git a/scripts/e2e/cl-6324-launch-proof.ts b/scripts/e2e/cl-6324-launch-proof.ts index c2c62c3f..cc6adbc3 100644 --- a/scripts/e2e/cl-6324-launch-proof.ts +++ b/scripts/e2e/cl-6324-launch-proof.ts @@ -37,7 +37,7 @@ import { seedTenant, type ApiCall, } from "../../packages/hub-client/src/index.ts"; -import { WORKFLOW_SOURCE_ENTRY } from "../../packages/workflow-source/src/index.ts"; +import { WORKFLOW_SOURCE_ENTRY } from "../../packages/workflows/src/source.ts"; import { agentRuntimeTurnRunId, buildAgentRuntimeWorkflow, diff --git a/scripts/e2e/harness.ts b/scripts/e2e/harness.ts index 643b514f..91482c33 100644 --- a/scripts/e2e/harness.ts +++ b/scripts/e2e/harness.ts @@ -10,7 +10,7 @@ import { mkdtemp, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; import { createGitWorkflowPusher } from "../../packages/hub-client/src/index.ts"; -import { WORKFLOW_SOURCE_ENTRY } from "../../packages/workflow-source/src/index.ts"; +import { WORKFLOW_SOURCE_ENTRY } from "../../packages/workflows/src/source.ts"; import { assertDatabaseConfigured } from "./db-gate.ts"; export const REPO_ROOT = path.resolve(import.meta.dir, "..", ".."); @@ -630,7 +630,7 @@ export function expectStepCompleted(events: RunEvent[], stepId: string): void { /** * Publishes a workflow definition into its asset repo in the one shape * a `workflow`-kind asset accepts: the source codebase - * `@corbits/workflow-source` renders. Delegates to the platform's own + * `@corbits/workflows`'s `./source` renders. Delegates to the platform's own * pusher so the suite exercises the same publication path the seed and * the product use, and returns the commit a code-sourced deploy pins. */ diff --git a/tsconfig.build.json b/tsconfig.build.json index c3f5ef0c..05bc69ba 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -13,9 +13,6 @@ { "path": "./packages/agent-lifecycle/tsconfig.src.json" }, - { - "path": "./packages/agent-runtime/tsconfig.src.json" - }, { "path": "./packages/api-query/tsconfig.src.json" }, @@ -148,12 +145,6 @@ { "path": "./packages/workflow-authoring-tools/tsconfig.src.json" }, - { - "path": "./packages/workflow-deploy-source/tsconfig.src.json" - }, - { - "path": "./packages/workflow-source/tsconfig.src.json" - }, { "path": "./vendor/intx/agent/tsconfig.src.json" }, From 28d100de7ce7c6231e0f0e84a5f9a493fcbc5196 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Wed, 2 Sep 2026 02:06:37 -0700 Subject: [PATCH 3/8] Address review findings (CL-7373) --- bun.lock | 11 ++- docs/revendor-inventory.md | 6 +- packages/approvals/src/headline.ts | 38 +++++++--- packages/capability-tools/package.json | 3 +- packages/capability-tools/src/client.ts | 52 ++++---------- packages/capability-tools/tsconfig.json | 24 ++----- packages/capability-tools/tsconfig.src.json | 20 ------ packages/routines/package.json | 1 + packages/routines/src/index.ts | 8 ++- packages/routines/src/routes.ts | 2 +- .../routines/src/workflow-routine-routes.ts | 2 +- .../workflow-authoring-tools/package.json | 3 +- .../workflow-authoring-tools/src/client.ts | 39 +++++----- .../workflow-authoring-tools/tsconfig.json | 24 ++----- .../tsconfig.src.json | 20 ------ .../workflows/src/authoring/run-client.ts | 58 +++++++++++++++ packages/workflows/src/client.ts | 16 +++++ packages/workflows/src/detail/index.ts | 8 ++- packages/workflows/src/index.ts | 10 +++ .../src/launchable/target-rule.ts} | 70 +++--------------- .../src/launchable}/target.test.ts | 0 packages/workflows/src/launchable/target.ts | 71 +++++++++++++++++++ scripts/checks/no-product-tenancy.ts | 2 +- .../test/routine-target-inference.test.ts | 2 +- tsconfig.build.json | 6 -- workflows/assistant/src/index.ts | 4 +- 26 files changed, 269 insertions(+), 231 deletions(-) delete mode 100644 packages/capability-tools/tsconfig.src.json delete mode 100644 packages/workflow-authoring-tools/tsconfig.src.json create mode 100644 packages/workflows/src/authoring/run-client.ts rename packages/{routines/src/target.ts => workflows/src/launchable/target-rule.ts} (66%) rename packages/{routines/src => workflows/src/launchable}/target.test.ts (100%) create mode 100644 packages/workflows/src/launchable/target.ts diff --git a/bun.lock b/bun.lock index 870969ed..db9d00d9 100644 --- a/bun.lock +++ b/bun.lock @@ -394,8 +394,9 @@ }, "packages/capability-tools": { "name": "@corbits/capability-tools", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/types": "workspace:*", "arktype": "catalog:", @@ -1197,6 +1198,7 @@ "@corbits/migration-runner": "workspace:*", "@corbits/slug": "workspace:*", "@corbits/workflow-catalog": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/authz": "0.3.0", "@intx/db": "workspace:*", "@intx/hub-api": "workspace:*", @@ -1507,8 +1509,9 @@ }, "packages/workflow-authoring-tools": { "name": "@corbits/workflow-authoring-tools", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/types": "workspace:*", "arktype": "catalog:", @@ -3599,6 +3602,8 @@ "@babel/helper-compilation-targets/semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="], + "@corbits/memory-hub/@corbits/memory": ["@corbits/memory@github:corbitsdev/corbits-memory#9e6f213", { "dependencies": { "@intx/agent": "0.2.2", "@intx/authz": "0.2.2", "@intx/hub-api": "0.2.2", "@intx/log": "0.2.2", "@intx/workflow": "0.2.2", "arktype": "^2.1.29", "drizzle-orm": "^0.45.1", "hono": "^4.9.0", "hono-openapi": "^1.3.1", "postgres": "^3.4.7" } }, "corbitsdev-corbits-memory-9e6f213", "sha512-utnM4ZT2zmslcPXYWAAqxlDNLcpGsXFiTOtj8h7+OXnhCP0Eaw8yl25+yCTyHpvt3jcdeG4h5uFsSj7ou0BZCA=="], + "@esbuild-kit/core-utils/esbuild": ["esbuild@0.18.20", "", { "optionalDependencies": { "@esbuild/android-arm": "0.18.20", "@esbuild/android-arm64": "0.18.20", "@esbuild/android-x64": "0.18.20", "@esbuild/darwin-arm64": "0.18.20", "@esbuild/darwin-x64": "0.18.20", "@esbuild/freebsd-arm64": "0.18.20", "@esbuild/freebsd-x64": "0.18.20", "@esbuild/linux-arm": "0.18.20", "@esbuild/linux-arm64": "0.18.20", "@esbuild/linux-ia32": "0.18.20", "@esbuild/linux-loong64": "0.18.20", "@esbuild/linux-mips64el": "0.18.20", "@esbuild/linux-ppc64": "0.18.20", "@esbuild/linux-riscv64": "0.18.20", "@esbuild/linux-s390x": "0.18.20", "@esbuild/linux-x64": "0.18.20", "@esbuild/netbsd-x64": "0.18.20", "@esbuild/openbsd-x64": "0.18.20", "@esbuild/sunos-x64": "0.18.20", "@esbuild/win32-arm64": "0.18.20", "@esbuild/win32-ia32": "0.18.20", "@esbuild/win32-x64": "0.18.20" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA=="], "@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="], @@ -3621,6 +3626,8 @@ "@typescript-eslint/eslint-plugin/ignore": ["ignore@7.0.6", "", {}, "sha512-BAg6QkE8W+TuQLrrw0Ugr7HegXduRuuj8/ti2kSOc+jz1dmx8/WNcjr6XGnq5YpDWxFwwaavqD0+jIUOKelTsw=="], + "@workbench/hub/@corbits/memory": ["@corbits/memory@github:corbitsdev/corbits-memory#9e6f213", { "dependencies": { "@intx/agent": "0.2.2", "@intx/authz": "0.2.2", "@intx/hub-api": "0.2.2", "@intx/log": "0.2.2", "@intx/workflow": "0.2.2", "arktype": "^2.1.29", "drizzle-orm": "^0.45.1", "hono": "^4.9.0", "hono-openapi": "^1.3.1", "postgres": "^3.4.7" } }, "corbitsdev-corbits-memory-9e6f213", "sha512-utnM4ZT2zmslcPXYWAAqxlDNLcpGsXFiTOtj8h7+OXnhCP0Eaw8yl25+yCTyHpvt3jcdeG4h5uFsSj7ou0BZCA=="], + "ajv-formats/ajv": ["ajv@8.20.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA=="], "better-call/@better-auth/utils": ["@better-auth/utils@0.5.0", "", { "dependencies": { "@noble/hashes": "^2.0.1" } }, "sha512-BL8W4EfIZFwlu0r54m3v1ztjDhu6dDe/amLTm0xybmbZaNgYUqhD3SjpAsnq0q8YD6/ki4iwIgxJNLP/N3TxiA=="], diff --git a/docs/revendor-inventory.md b/docs/revendor-inventory.md index 35d049ec..afddc072 100644 --- a/docs/revendor-inventory.md +++ b/docs/revendor-inventory.md @@ -828,7 +828,8 @@ folded-run-`), definition loaded from that closure, run grants The renderer that had been living in `@workbench/hub-client`'s `workflow-push.ts`, and a second copy of it in `@corbits/agent-runtime`'s `source-tree.ts`, moved into a new dependency-free package, -`@corbits/workflow-source`. Every authoring path in the repo now writes +`@corbits/workflow-source` (since folded into `@corbits/workflows`'s +`./source`, CL-7373). Every authoring path in the repo now writes its asset tree through that one `renderWorkflowSourceTree` — the seed pusher, the per-run agent-runtime package, and the agent-directory lineage — so there is a single producer of the bytes a workflow-kind @@ -849,7 +850,8 @@ renderer emits (the `export default ` prefix and `;\n` suffix), never an eval and never a pattern search. Anything else — in practice, an asset last written before this cutover, whose tree still holds a bare `workflow.json` — throws `RetiredWorkflowEnvelopeError`, defined in -`@corbits/workflow-source` and re-exported from `@corbits/agent-directory`. +`@corbits/workflow-source` (now `@corbits/workflows`'s `./source`) and +re-exported from `@corbits/agent-directory`. It carries re-author-and-re-deploy guidance and is mapped to a 409 in every route module that can reach it: `routes.ts`, `workflow-capability-routes.ts`, and `workflow-skill-pin-routes.ts` each diff --git a/packages/approvals/src/headline.ts b/packages/approvals/src/headline.ts index ae32f435..f94337e8 100644 --- a/packages/approvals/src/headline.ts +++ b/packages/approvals/src/headline.ts @@ -55,13 +55,29 @@ function workflowDeployHeadline(toolArguments: object): string | undefined { } /** - * Builds the headline for an approval. Prefers the tool's own - * `description` — written by the tool's author to be human-readable — - * over its bare `name`, which is a machine identifier. When the live - * call's arguments carry a `title` (a tool author's own convention for - * per-invocation context, e.g. "finalize this piece of collateral titled - * X"), it is appended so the headline reflects what THIS approval is - * actually about, not just which tool is asking. + * Per-tool headline renderers, keyed by tool name — a tool kind that wants + * its approval card to name what it will actually do, rather than fall + * back to its generic description, registers itself here instead of + * growing another `if (toolName === ...)` branch in `headlineFor`. + * Returning `undefined` (missing required args) falls through to the + * generic description/title rendering below. + */ +const TOOL_HEADLINE_RENDERERS: Readonly< + Record string | undefined> +> = { + workflow_deploy: workflowDeployHeadline, +}; + +/** + * Builds the headline for an approval. A registered per-tool renderer + * (`TOOL_HEADLINE_RENDERERS`) wins when the tool call's own arguments + * carry what it needs. Otherwise prefers the tool's own `description` — + * written by the tool's author to be human-readable — over its bare + * `name`, which is a machine identifier. When the live call's arguments + * carry a `title` (a tool author's own convention for per-invocation + * context, e.g. "finalize this piece of collateral titled X"), it is + * appended so the headline reflects what THIS approval is actually + * about, not just which tool is asking. */ export function headlineFor( toolDefinition: unknown, @@ -71,13 +87,15 @@ export function headlineFor( typeof toolDefinition === "object" && toolDefinition !== null ? stringField(toolDefinition, "name") : undefined; + const renderer = + toolName !== undefined ? TOOL_HEADLINE_RENDERERS[toolName] : undefined; if ( - toolName === "workflow_deploy" && + renderer !== undefined && typeof toolArguments === "object" && toolArguments !== null ) { - const deployHeadline = workflowDeployHeadline(toolArguments); - if (deployHeadline !== undefined) return deployHeadline; + const rendered = renderer(toolArguments); + if (rendered !== undefined) return rendered; } const base = diff --git a/packages/capability-tools/package.json b/packages/capability-tools/package.json index 5d27b216..4b4dbb4c 100644 --- a/packages/capability-tools/package.json +++ b/packages/capability-tools/package.json @@ -2,7 +2,7 @@ "name": "@corbits/capability-tools", "private": true, "description": "The request_capability tool as an @intx/agent tool bundle (CL-6084): an agent asks in-chat for a tool package, skill, or model it doesn't have, gated behind Interchange's native per-invocation approval, and \u2014 once approved \u2014 calls the sanctioned workflow-run capabilities surface with the run's own bearer token, never a model-supplied identity", - "version": "0.0.4", + "version": "0.0.5", "license": "LGPL-2.1-or-later", "type": "module", "exports": { @@ -13,6 +13,7 @@ "test": "bun test" }, "dependencies": { + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/types": "workspace:*", "arktype": "catalog:" diff --git a/packages/capability-tools/src/client.ts b/packages/capability-tools/src/client.ts index 672f97cc..dc8cf3bd 100644 --- a/packages/capability-tools/src/client.ts +++ b/packages/capability-tools/src/client.ts @@ -22,19 +22,21 @@ // reasoning. `requireGrant` will replace that interim rule once CL-6085 // closes. import { type } from "arktype"; +import { + runBearerHeaders, + runBearerErrorMessage, + runBearerFetch, + type RunBearerClientConfig, +} from "@corbits/workflows/client"; -export interface CapabilityToolClientConfig { +export interface CapabilityToolClientConfig extends RunBearerClientConfig { /** The hub's plain HTTP origin — same value memory-tools' `hubMemoryUrl` * and skills' workflow-routes reach the hub through. */ readonly hubCapabilitiesUrl: string; - readonly sidecarToken: string; - readonly address: string; /** The calling agent's own definition id. See the [Intx gap] note in * `./tool.ts` — no sanctioned way exists yet for a tool execution to * learn this on its own; it must be threaded in as part of `env`. */ readonly definitionId: string; - /** Override for tests; defaults to the global `fetch`. */ - readonly fetchImpl?: typeof fetch; } export type AddCapabilityRequest = @@ -78,33 +80,6 @@ const CapabilityInventoryResponse = type({ models: type({ canonicalName: "string" }).array(), }); -function authHeaders( - config: CapabilityToolClientConfig, -): Record { - return { - authorization: `Bearer ${config.sidecarToken}`, - "x-workflow-run-address": config.address, - }; -} - -/** Pulls `error.userMessage` out of the canonical hub envelope - * (`{error: {code, userMessage, refId}}`), if `body` matches that shape. */ -function errorMessageFrom(body: unknown): string | undefined { - if (body === null || typeof body !== "object" || !("error" in body)) { - return undefined; - } - const error = (body as { error: unknown }).error; - if ( - error === null || - typeof error !== "object" || - !("userMessage" in error) - ) { - return undefined; - } - const userMessage = (error as { userMessage: unknown }).userMessage; - return typeof userMessage === "string" ? userMessage : undefined; -} - function endpoint(config: CapabilityToolClientConfig, path: string): string { return `${config.hubCapabilitiesUrl}/api/workflow-capabilities/${config.definitionId}${path}`; } @@ -117,16 +92,19 @@ export async function addCapability( config: CapabilityToolClientConfig, input: AddCapabilityRequest, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, "/capabilities"), { method: "POST", - headers: { ...authHeaders(config), "content-type": "application/json" }, + headers: { + ...runBearerHeaders(config), + "content-type": "application/json", + }, body: JSON.stringify(input), }); if (response.status === 400) { const body: unknown = await response.json().catch(() => undefined); const message = - errorMessageFrom(body) ?? + runBearerErrorMessage(body) ?? `"${input.kind === "model" ? input.canonicalName : input.name}" was rejected as out of inventory`; throw new CapabilityOutOfInventoryError(message); } @@ -151,10 +129,10 @@ export async function addCapability( export async function fetchCapabilityInventory( config: CapabilityToolClientConfig, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch( `${config.hubCapabilitiesUrl}/api/workflow-capabilities/inventory`, - { headers: authHeaders(config) }, + { headers: runBearerHeaders(config) }, ); if (!response.ok) { throw new Error( diff --git a/packages/capability-tools/tsconfig.json b/packages/capability-tools/tsconfig.json index 50b7d004..d7611c12 100644 --- a/packages/capability-tools/tsconfig.json +++ b/packages/capability-tools/tsconfig.json @@ -1,22 +1,8 @@ { - "extends": "./tsconfig.src.json", + "extends": "../../tsconfig.base.json", + "include": ["src", "test"], "compilerOptions": { - "composite": false, - "noEmit": true, - "disableSourceOfProjectReferenceRedirect": true, - "declaration": false, - "declarationMap": false, - "emitDeclarationOnly": false, - "rootDir": "../.." - }, - "include": ["src"], - "exclude": [], - "references": [ - { - "path": "../../vendor/intx/agent/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/types/tsconfig.src.json" - } - ] + "types": ["bun"], + "noEmit": true + } } diff --git a/packages/capability-tools/tsconfig.src.json b/packages/capability-tools/tsconfig.src.json deleted file mode 100644 index 3959f624..00000000 --- a/packages/capability-tools/tsconfig.src.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["src", "package.json", "src/**/*.json"], - "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"], - "compilerOptions": { - "types": ["bun"], - "composite": true, - "emitDeclarationOnly": true, - "outDir": "dist", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" - }, - "references": [ - { - "path": "../../vendor/intx/agent/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/types/tsconfig.src.json" - } - ] -} diff --git a/packages/routines/package.json b/packages/routines/package.json index a9ec6a7d..615271a9 100644 --- a/packages/routines/package.json +++ b/packages/routines/package.json @@ -23,6 +23,7 @@ "@corbits/slug": "workspace:*", "cronstrue": "^3.24.0", "@corbits/workflow-catalog": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/authz": "0.3.0", "@intx/db": "workspace:*", "@intx/hub-api": "workspace:*", diff --git a/packages/routines/src/index.ts b/packages/routines/src/index.ts index 4e6c1b5f..8aefe7f1 100644 --- a/packages/routines/src/index.ts +++ b/packages/routines/src/index.ts @@ -81,18 +81,22 @@ export type { RoutineDraftingRunnerDeps, } from "./myra-drafting"; +// "What is launchable" moved into @corbits/workflows (CL-7373 fold +// review): it is definition-domain logic, not a routine concern. Kept +// re-exported here so every existing `@corbits/routines` importer (this +// package's own `routes.ts`, `apps/hub`) needs no change. export { pickLaunchableDefinition, resolveLaunchableDefinition, routineTargetRejection, RoutineTargetUnresolvableError, -} from "./target"; +} from "@corbits/workflows"; export type { LaunchableDefinitionCandidate, LaunchableDefinitionRejection, LaunchableDefinitionResolution, LaunchableDefinitionResolver, -} from "./target"; +} from "@corbits/workflows"; export { createRoutineRoutes, fireScheduledRoutine } from "./routes"; export type { diff --git a/packages/routines/src/routes.ts b/packages/routines/src/routes.ts index 04bf8527..2004eeae 100644 --- a/packages/routines/src/routes.ts +++ b/packages/routines/src/routes.ts @@ -35,7 +35,7 @@ import type { import { routineTargetRejection, type LaunchableDefinitionResolver, -} from "./target"; +} from "@corbits/workflows"; import { validateRetarget } from "./routine-operations"; import { makeErrorEnvelope } from "@workbench/hub-client"; import { diff --git a/packages/routines/src/workflow-routine-routes.ts b/packages/routines/src/workflow-routine-routes.ts index 4d8c7d3a..3017ef76 100644 --- a/packages/routines/src/workflow-routine-routes.ts +++ b/packages/routines/src/workflow-routine-routes.ts @@ -45,7 +45,7 @@ import { type RoutineLauncher, } from "./routes"; import { validateRetarget } from "./routine-operations"; -import type { LaunchableDefinitionResolver } from "./target"; +import type { LaunchableDefinitionResolver } from "@corbits/workflows"; import { InvalidRoutineTargetCursorError, ROUTINE_TARGETS_DEFAULT_LIMIT, diff --git a/packages/workflow-authoring-tools/package.json b/packages/workflow-authoring-tools/package.json index de63233b..3b275dd6 100644 --- a/packages/workflow-authoring-tools/package.json +++ b/packages/workflow-authoring-tools/package.json @@ -2,7 +2,7 @@ "name": "@corbits/workflow-authoring-tools", "private": true, "description": "Myra's workflow-authoring tool bundle (workflow_author, workflow_republish, workflow_source_read, workflow_deploy_preview, workflow_deploy): an @intx/agent tool bundle calling @corbits/workflows's `./authoring`'s workflow-run-authenticated routes so an agent can write a workflow code package into a kind:\"workflow\" hub asset, read it back, preview a deploy's grant surface, and deploy it through Interchange's native source pipeline behind a human approval", - "version": "0.0.3", + "version": "0.0.4", "license": "LGPL-2.1-or-later", "type": "module", "exports": { @@ -13,6 +13,7 @@ "test": "bun test" }, "dependencies": { + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/types": "workspace:*", "arktype": "catalog:" diff --git a/packages/workflow-authoring-tools/src/client.ts b/packages/workflow-authoring-tools/src/client.ts index 080369bb..717235f6 100644 --- a/packages/workflow-authoring-tools/src/client.ts +++ b/packages/workflow-authoring-tools/src/client.ts @@ -5,15 +5,16 @@ // the same two headers `@corbits/capability-tools` sends — so the hub // resolves tenant and principal from the run, never from an argument. import { type } from "arktype"; +import { + runBearerHeaders, + runBearerFetch, + type RunBearerClientConfig, +} from "@corbits/workflows/client"; -export interface WorkflowAuthoringClientConfig { +export interface WorkflowAuthoringClientConfig extends RunBearerClientConfig { /** The hub's plain HTTP origin, the same value every other tool * bundle's `hub*Url` env key carries. */ readonly hubWorkflowAuthoringUrl: string; - readonly sidecarToken: string; - readonly address: string; - /** Override for tests; defaults to the global `fetch`. */ - readonly fetchImpl?: typeof fetch; } export type WorkflowSourceFiles = Readonly>; @@ -133,14 +134,6 @@ const DeployPreviewResponse = type({ }, }); -function authHeaders( - config: WorkflowAuthoringClientConfig, -): Record { - return { - authorization: `Bearer ${config.sidecarToken}`, - "x-workflow-run-address": config.address, - }; -} function endpoint(config: WorkflowAuthoringClientConfig, path: string): string { return `${config.hubWorkflowAuthoringUrl}/api/workflow-workflow-authoring${path}`; @@ -183,10 +176,10 @@ export async function authorWorkflow( config: WorkflowAuthoringClientConfig, input: AuthorWorkflowRequest, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, "/author"), { method: "POST", - headers: { ...authHeaders(config), "content-type": "application/json" }, + headers: { ...runBearerHeaders(config), "content-type": "application/json" }, body: JSON.stringify(input), }); if (!response.ok) await throwForFailure(response, "Authoring a workflow"); @@ -201,10 +194,10 @@ export async function republishWorkflow( config: WorkflowAuthoringClientConfig, input: RepublishWorkflowRequest, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, "/republish"), { method: "POST", - headers: { ...authHeaders(config), "content-type": "application/json" }, + headers: { ...runBearerHeaders(config), "content-type": "application/json" }, body: JSON.stringify(input), }); if (!response.ok) { @@ -221,12 +214,12 @@ export async function deployWorkflow( config: WorkflowAuthoringClientConfig, input: DeployWorkflowRequest, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch( endpoint(config, `/${encodeURIComponent(input.assetId)}/deploy`), { method: "POST", - headers: { ...authHeaders(config), "content-type": "application/json" }, + headers: { ...runBearerHeaders(config), "content-type": "application/json" }, body: JSON.stringify({ commitSha: input.commitSha, entry: input.entry, @@ -245,12 +238,12 @@ export async function previewDeployWorkflow( config: WorkflowAuthoringClientConfig, input: DeployWorkflowPreviewRequest, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch( endpoint(config, `/${encodeURIComponent(input.assetId)}/deploy/preview`), { method: "POST", - headers: { ...authHeaders(config), "content-type": "application/json" }, + headers: { ...runBearerHeaders(config), "content-type": "application/json" }, body: JSON.stringify({ commitSha: input.commitSha, entry: input.entry, @@ -271,10 +264,10 @@ export async function readWorkflowSource( config: WorkflowAuthoringClientConfig, assetId: string, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch( endpoint(config, `/${encodeURIComponent(assetId)}/source`), - { headers: authHeaders(config) }, + { headers: runBearerHeaders(config) }, ); if (!response.ok) { await throwForFailure(response, "Reading a workflow's source"); diff --git a/packages/workflow-authoring-tools/tsconfig.json b/packages/workflow-authoring-tools/tsconfig.json index 50b7d004..d7611c12 100644 --- a/packages/workflow-authoring-tools/tsconfig.json +++ b/packages/workflow-authoring-tools/tsconfig.json @@ -1,22 +1,8 @@ { - "extends": "./tsconfig.src.json", + "extends": "../../tsconfig.base.json", + "include": ["src", "test"], "compilerOptions": { - "composite": false, - "noEmit": true, - "disableSourceOfProjectReferenceRedirect": true, - "declaration": false, - "declarationMap": false, - "emitDeclarationOnly": false, - "rootDir": "../.." - }, - "include": ["src"], - "exclude": [], - "references": [ - { - "path": "../../vendor/intx/agent/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/types/tsconfig.src.json" - } - ] + "types": ["bun"], + "noEmit": true + } } diff --git a/packages/workflow-authoring-tools/tsconfig.src.json b/packages/workflow-authoring-tools/tsconfig.src.json deleted file mode 100644 index 3959f624..00000000 --- a/packages/workflow-authoring-tools/tsconfig.src.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["src", "package.json", "src/**/*.json"], - "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"], - "compilerOptions": { - "types": ["bun"], - "composite": true, - "emitDeclarationOnly": true, - "outDir": "dist", - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" - }, - "references": [ - { - "path": "../../vendor/intx/agent/tsconfig.src.json" - }, - { - "path": "../../vendor/intx/types/tsconfig.src.json" - } - ] -} diff --git a/packages/workflows/src/authoring/run-client.ts b/packages/workflows/src/authoring/run-client.ts new file mode 100644 index 00000000..4b2239f0 --- /dev/null +++ b/packages/workflows/src/authoring/run-client.ts @@ -0,0 +1,58 @@ +// Shared fetch plumbing for a run-authenticated tool client — every tool +// bundle that calls a hub route mounted behind `WorkflowRunAuthenticator` +// (sidecar bearer token + run address, never a human session) needs the +// same two headers and the same `{ error: { code, userMessage } }` +// envelope parse. Before this module existed, `@corbits/workflow- +// authoring-tools`' and `@corbits/capability-tools`' own `client.ts` +// files each reimplemented both slightly differently (arktype-validated +// vs. ad hoc field access). This is that one shared seam. +// +// Browser-safe: no `@intx/*`, `drizzle-orm`, `hono`, or `postgres` — pure +// fetch/arktype, exported from `@corbits/workflows/client` alongside the +// rest of this package's browser-safe surface, because a tool bundle runs +// inside the sidecar's workflow-host, not the hub server. +import { type } from "arktype"; + +export interface RunBearerClientConfig { + readonly sidecarToken: string; + readonly address: string; + /** Override for tests; defaults to the global `fetch`. */ + readonly fetchImpl?: typeof fetch; +} + +/** The two headers every run-authenticated route resolves tenant and + * principal from — identity never rides in a request body. */ +export function runBearerHeaders( + config: RunBearerClientConfig, +): Record { + return { + authorization: `Bearer ${config.sidecarToken}`, + "x-workflow-run-address": config.address, + }; +} + +const RunBearerErrorEnvelope = type({ + error: { code: "string", userMessage: "string" }, +}); + +/** Pulls `error.userMessage` out of the canonical hub envelope + * (`{ error: { code, userMessage } }`), if `body` matches that shape — + * `undefined` for a differently-shaped or absent body, never a throw. */ +export function runBearerErrorMessage(body: unknown): string | undefined { + const parsed = RunBearerErrorEnvelope(body); + return parsed instanceof type.errors ? undefined : parsed.error.userMessage; +} + +/** The envelope's `error.code`, alongside the message above — some + * callers (a republish `conflict`, a preview `not_found`) branch on the + * code, not just the message. */ +export function runBearerErrorCode(body: unknown): string | undefined { + const parsed = RunBearerErrorEnvelope(body); + return parsed instanceof type.errors ? undefined : parsed.error.code; +} + +export function runBearerFetch( + config: RunBearerClientConfig, +): typeof fetch { + return config.fetchImpl ?? fetch; +} diff --git a/packages/workflows/src/client.ts b/packages/workflows/src/client.ts index 0f2974d6..7b0b6883 100644 --- a/packages/workflows/src/client.ts +++ b/packages/workflows/src/client.ts @@ -4,6 +4,22 @@ // reads directly. `check:browser-safe-subpaths` walks the real import // graph from here and fails if anything server-only leaks in. export * from "./source"; +export { + runBearerHeaders, + runBearerErrorMessage, + runBearerErrorCode, + runBearerFetch, + type RunBearerClientConfig, +} from "./authoring/run-client"; +export { + pickLaunchableDefinition, + routineTargetRejection, + RoutineTargetUnresolvableError, + type LaunchableDefinitionCandidate, + type LaunchableDefinitionRejection, + type LaunchableDefinitionResolution, + type LaunchableDefinitionResolver, +} from "./launchable/target-rule"; export { workflowNotLaunchableReason, workflowDetailPath, diff --git a/packages/workflows/src/detail/index.ts b/packages/workflows/src/detail/index.ts index 4ef88e89..94ff6e86 100644 --- a/packages/workflows/src/detail/index.ts +++ b/packages/workflows/src/detail/index.ts @@ -1,16 +1,18 @@ +// The lifecycle/detail symbols are the browser-safe `../client` barrel's +// canonical export site — re-exported here rather than redeclared, so +// there is exactly one place that owns this list and the two barrels +// cannot drift apart. export { deriveWorkflowLifecycle, type DefinitionLifecycleRow, type WorkflowLifecycle, type WorkflowLifecycleResult, -} from "./definition-lifecycle"; -export { workflowNotLaunchableReason, workflowDetailPath, WorkflowDefinitionDetail, WorkflowDetailSource, WorkflowDetailStep, -} from "./definition-detail"; +} from "../client"; export { createWorkflowDetailRoute, type CreateWorkflowDetailRouteDeps, diff --git a/packages/workflows/src/index.ts b/packages/workflows/src/index.ts index 77898dc7..a9131ba5 100644 --- a/packages/workflows/src/index.ts +++ b/packages/workflows/src/index.ts @@ -6,3 +6,13 @@ export * from "./source"; export * from "./deploy-source/index"; export * from "./detail/index"; export * from "./authoring/index"; +export { + pickLaunchableDefinition, + resolveLaunchableDefinition, + routineTargetRejection, + RoutineTargetUnresolvableError, + type LaunchableDefinitionCandidate, + type LaunchableDefinitionRejection, + type LaunchableDefinitionResolution, + type LaunchableDefinitionResolver, +} from "./launchable/target"; diff --git a/packages/routines/src/target.ts b/packages/workflows/src/launchable/target-rule.ts similarity index 66% rename from packages/routines/src/target.ts rename to packages/workflows/src/launchable/target-rule.ts index c0c3344b..15e5a23a 100644 --- a/packages/routines/src/target.ts +++ b/packages/workflows/src/launchable/target-rule.ts @@ -1,15 +1,8 @@ -// The one place a routine's target (a workflow asset id) becomes the -// definition that actually runs. Interchange keys `workflow_definition` -// on `(asset_id, wire_hash)` and has no "newest approved deployment of -// this asset" indirection of its own (docs/workflow-model.md), so this -// module supplies exactly that query — and nothing else: no search by -// name, no fallback to an unfrozen row, no pinning. Every caller (create, -// retarget, launch) resolves through here so a routine can never run a -// definition this rule would not have picked. -import { and, desc, eq } from "drizzle-orm"; -import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"; -import { workflowDefinition, workflowDefinitionVersion } from "@intx/db/schema"; - +// The follow-latest rule, pure — no `drizzle-orm`, no `@intx/db`, so this +// half of `./target.ts` is safe on `@corbits/workflows/client` and +// testable without a database. `./target.ts` is the DB-touching half +// (`resolveLaunchableDefinition`) that queries rows and hands them to +// `pickLaunchableDefinition` below. export type LaunchableDefinitionRejection = "not_found" | "unfrozen" | "not_deployed" | "cross_tenant"; @@ -44,6 +37,11 @@ export type LaunchableDefinitionCandidate = { readonly createdAt: Date; }; +// This module's `isFrozen` and `../detail/definition-lifecycle.ts`'s +// frozen check are NOT yet unified into one predicate — both +// independently encode "frozen means non-null approvedWireHash/ +// grantSnapshot/wireProjection" but over row shapes that don't (yet) +// match; a follow-up should widen one to subsume the other. function isFrozen(candidate: LaunchableDefinitionCandidate): boolean { return ( candidate.approvedWireHash !== null && @@ -88,54 +86,6 @@ export function pickLaunchableDefinition( }; } -/** - * Resolves the definition a routine targeting `definitionAssetId` would - * run right now, per `pickLaunchableDefinition`. One query, read at the - * moment of use — a create/retarget validates through it, and a launch - * re-resolves through it rather than trusting anything stored. - */ -export async function resolveLaunchableDefinition(input: { - db: PostgresJsDatabase>; - tenantId: string; - definitionAssetId: string; -}): Promise { - const rows = await input.db - .select({ - id: workflowDefinition.id, - tenantId: workflowDefinition.tenantId, - status: workflowDefinition.status, - createdAt: workflowDefinition.createdAt, - approvedWireHash: workflowDefinitionVersion.approvedWireHash, - grantSnapshot: workflowDefinitionVersion.grantSnapshot, - wireProjection: workflowDefinitionVersion.wireProjection, - }) - .from(workflowDefinition) - .leftJoin( - workflowDefinitionVersion, - and( - eq(workflowDefinitionVersion.definitionId, workflowDefinition.id), - eq( - workflowDefinitionVersion.version, - workflowDefinition.currentVersion, - ), - ), - ) - .where(eq(workflowDefinition.assetId, input.definitionAssetId)) - .orderBy(desc(workflowDefinition.createdAt)); - return pickLaunchableDefinition( - rows.map((row) => ({ - id: row.id, - tenantId: row.tenantId, - status: row.status, - createdAt: row.createdAt, - approvedWireHash: row.approvedWireHash ?? null, - grantSnapshot: row.grantSnapshot ?? null, - wireProjection: row.wireProjection ?? null, - })), - input.tenantId, - ); -} - /** * The typed refusal a route answers with when a routine's target does * not resolve — one code per reason so a UI or Myra can branch on it, diff --git a/packages/routines/src/target.test.ts b/packages/workflows/src/launchable/target.test.ts similarity index 100% rename from packages/routines/src/target.test.ts rename to packages/workflows/src/launchable/target.test.ts diff --git a/packages/workflows/src/launchable/target.ts b/packages/workflows/src/launchable/target.ts new file mode 100644 index 00000000..67ea6a52 --- /dev/null +++ b/packages/workflows/src/launchable/target.ts @@ -0,0 +1,71 @@ +// The one place a routine's target (a workflow asset id) becomes the +// definition that actually runs. Interchange keys `workflow_definition` +// on `(asset_id, wire_hash)` and has no "newest approved deployment of +// this asset" indirection of its own (docs/workflow-model.md), so this +// module supplies exactly that query — and nothing else: no search by +// name, no fallback to an unfrozen row, no pinning. Every caller (create, +// retarget, launch) resolves through here so a routine can never run a +// definition this rule would not have picked. +// +// Moved from `@corbits/routines` into `@corbits/workflows` (CL-7373 fold +// review): "what is launchable" is definition-domain logic, not a routine +// concern — `@corbits/routines` now imports it from here rather than +// owning a second copy. The pure follow-latest rule lives in +// `./target-rule.ts` (no `drizzle-orm`/`@intx/db`, so it is safe on +// `@corbits/workflows/client`); this file is the DB-touching half. +import { and, desc, eq } from "drizzle-orm"; +import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"; +import { workflowDefinition, workflowDefinitionVersion } from "@intx/db/schema"; + +import { pickLaunchableDefinition } from "./target-rule"; +import type { LaunchableDefinitionResolution } from "./target-rule"; + +export * from "./target-rule"; + +/** + * Resolves the definition a routine targeting `definitionAssetId` would + * run right now, per `pickLaunchableDefinition`. One query, read at the + * moment of use — a create/retarget validates through it, and a launch + * re-resolves through it rather than trusting anything stored. + */ +export async function resolveLaunchableDefinition(input: { + db: PostgresJsDatabase>; + tenantId: string; + definitionAssetId: string; +}): Promise { + const rows = await input.db + .select({ + id: workflowDefinition.id, + tenantId: workflowDefinition.tenantId, + status: workflowDefinition.status, + createdAt: workflowDefinition.createdAt, + approvedWireHash: workflowDefinitionVersion.approvedWireHash, + grantSnapshot: workflowDefinitionVersion.grantSnapshot, + wireProjection: workflowDefinitionVersion.wireProjection, + }) + .from(workflowDefinition) + .leftJoin( + workflowDefinitionVersion, + and( + eq(workflowDefinitionVersion.definitionId, workflowDefinition.id), + eq( + workflowDefinitionVersion.version, + workflowDefinition.currentVersion, + ), + ), + ) + .where(eq(workflowDefinition.assetId, input.definitionAssetId)) + .orderBy(desc(workflowDefinition.createdAt)); + return pickLaunchableDefinition( + rows.map((row) => ({ + id: row.id, + tenantId: row.tenantId, + status: row.status, + createdAt: row.createdAt, + approvedWireHash: row.approvedWireHash ?? null, + grantSnapshot: row.grantSnapshot ?? null, + wireProjection: row.wireProjection ?? null, + })), + input.tenantId, + ); +} diff --git a/scripts/checks/no-product-tenancy.ts b/scripts/checks/no-product-tenancy.ts index 6cd6f31d..45e6bbf7 100644 --- a/scripts/checks/no-product-tenancy.ts +++ b/scripts/checks/no-product-tenancy.ts @@ -122,7 +122,7 @@ const ALLOWLIST: readonly { // union itself — that select and apply those bytes. This table is // that missing record, for shared placement (CL-6581 phase 1; // exclusive placement already has workflow_run_launch_spec). - relPath: "packages/workflow-deploy-source/src/schema.ts", + relPath: "packages/workflows/src/deploy-source/schema.ts", maxOccurrences: 1, tables: ["workflow_deploy_source.workflow_deploy_source"], }, diff --git a/scripts/checks/test/routine-target-inference.test.ts b/scripts/checks/test/routine-target-inference.test.ts index e782e677..3adbe926 100644 --- a/scripts/checks/test/routine-target-inference.test.ts +++ b/scripts/checks/test/routine-target-inference.test.ts @@ -71,7 +71,7 @@ test("a backtick-quoted mention of workflow.json inside a comment is not a viola test("workflow-source's own RetiredWorkflowEnvelopeError file is allowed", () => { const report = auditWorkflowJsonLiteral([ { - relPath: "packages/workflow-source/src/index.ts", + relPath: "packages/workflows/src/source.ts", contents: 'const RETIRED_WORKFLOW_ENVELOPE_PATH = "workflow.json";', }, ]); diff --git a/tsconfig.build.json b/tsconfig.build.json index 05bc69ba..556fa708 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -25,9 +25,6 @@ { "path": "./packages/bench-ui/tsconfig.src.json" }, - { - "path": "./packages/capability-tools/tsconfig.src.json" - }, { "path": "./packages/catalog-tools/tsconfig.src.json" }, @@ -142,9 +139,6 @@ { "path": "./packages/web-search-tools/tsconfig.src.json" }, - { - "path": "./packages/workflow-authoring-tools/tsconfig.src.json" - }, { "path": "./vendor/intx/agent/tsconfig.src.json" }, diff --git a/workflows/assistant/src/index.ts b/workflows/assistant/src/index.ts index 3315b300..140b4e37 100644 --- a/workflows/assistant/src/index.ts +++ b/workflows/assistant/src/index.ts @@ -45,7 +45,7 @@ export const ASSISTANT_STEP_ID = "assistant"; */ export const ASSISTANT_TOOL_PACKAGE_PINS: readonly ToolPackagePin[] = [ { name: "@corbits/memory-tools", version: "0.0.4" }, - { name: "@corbits/capability-tools", version: "0.0.4" }, + { name: "@corbits/capability-tools", version: "0.0.5" }, { name: "@corbits/routines-tools", version: "0.0.8" }, { name: "@corbits/agent-directory-tools", version: "0.0.6" }, { name: "@corbits/connections-tools", version: "0.0.6" }, @@ -54,7 +54,7 @@ export const ASSISTANT_TOOL_PACKAGE_PINS: readonly ToolPackagePin[] = [ { name: "@corbits/mcp-tools", version: "0.0.10" }, { name: "@corbits/interaction-tools", version: "0.0.4" }, { name: "@corbits/manus-tools", version: "0.0.11" }, - { name: "@corbits/workflow-authoring-tools", version: "0.0.3" }, + { name: "@corbits/workflow-authoring-tools", version: "0.0.4" }, ]; /** From 539bf01000e25d3fb4569c126ea3b4607d7a4056 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Wed, 2 Sep 2026 02:38:30 -0700 Subject: [PATCH 4/8] Fix CI after review pass (CL-7373) --- docs/workflow-detail.md | 2 +- docs/workflow-model.md | 2 +- docs/workflow-source-authoring.md | 18 ++++++++-------- .../workflow-authoring-tools/src/client.ts | 21 ++++++++++++++----- .../workflows/src/authoring/run-client.ts | 4 +--- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/docs/workflow-detail.md b/docs/workflow-detail.md index f82a78b4..dd577485 100644 --- a/docs/workflow-detail.md +++ b/docs/workflow-detail.md @@ -11,7 +11,7 @@ useful version — read-only, no editing surface here. - **Lifecycle**: `source-only`, `pending-approval`, `deployed`, `superseded`, or `build-failed` — derived by the pure `deriveWorkflowLifecycle` (`packages/workflows/src/ - definition-lifecycle.ts`) from the asset's newest `workflow_definition` +definition-lifecycle.ts`) from the asset's newest `workflow_definition` row plus whether `@corbits/workflows`'s `./deploy-source` ever recorded a deploy attempt for it. No new Postgres column: everything it reads is native or already Workbench-owned. diff --git a/docs/workflow-model.md b/docs/workflow-model.md index 9c5c69b6..d9392486 100644 --- a/docs/workflow-model.md +++ b/docs/workflow-model.md @@ -51,7 +51,7 @@ storage. | Operation | Canonical operation | Authorized as | Human approval | | --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | -| Store source (create / republish) | `@corbits/workflows`'s `./authoring` registry → `AssetService.createAsset` / `populateAsset` (hub-signed commit) | Initiating tenant + principal; `@intx/authz` `authorize` on `asset:*`/`create` or `asset:`/`write` | None (writing source is not a side effect) | +| Store source (create / republish) | `@corbits/workflows`'s `./authoring` registry → `AssetService.createAsset` / `populateAsset` (hub-signed commit) | Initiating tenant + principal; `@intx/authz` `authorize` on `asset:*`/`create` or `asset:`/`write` | None (writing source is not a side effect) | | Deploy source | `POST /api/tenants/:tenantId/workflows/deployments` → vendored `SessionService.deployWorkflowFromSource` | Tenant session or run bearer; `workflow:*`/`create` | Agent-initiated deploys go through an `approval: "ask"` tool call carrying the probed capability surface (below) | | Create / update a routine | `createRoutineRoutes` `POST /routines`, `PATCH /routines/:id`; the run-authenticated mirror `createWorkflowRoutineRoutes` delegates to the same store | Tenant + principal; target validated against the resolution rule above before persisting | None; a routine only references a definition asset — nothing executes at create/update time | | Launch | `launchAndCorrelate` (`packages/routines/src/routes.ts`) → hub `RoutineLauncher` | Routine's tenant; grants materialized by the native launch path | Runtime tool calls with `approval: "ask"` park on the native `approval` resource | diff --git a/docs/workflow-source-authoring.md b/docs/workflow-source-authoring.md index c0fa3353..3c7fccec 100644 --- a/docs/workflow-source-authoring.md +++ b/docs/workflow-source-authoring.md @@ -33,12 +33,12 @@ not what an agent authors by hand. ## The operations, in order -| Step | Operation | Authorized as | Returns | -| ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | -| 1 | `POST /api/workflow-workflow-authoring/author` (`@corbits/workflows`'s `./authoring`) → `AssetService.createAsset` + `populateAsset` | Run bearer + run address → tenant/principal; `asset:*`/`create` | `{ assetId, name, commitSha }` | -| 1' | `.../republish` → `populateAsset` on `refs/heads/main` | `asset:`/`write`, own-tenant row check first | `{ assetId, name, commitSha }` | -| 1'' | `GET .../:assetId/source` → `RepoStore.resolveRef` + `openCommittedReads` on `refs/heads/main` | `asset:`/`read`, own-tenant row check first | `{ assetId, name, headSha, files }` | -| 2 | `POST .../:assetId/deploy/preview` (CL-7362) — a STATIC, read-only render of the already-committed source at `commitSha` off `RepoStore` alone; never installs, probes, gates, or freezes | Same run scope | `{ commitSha, entry, files[], toolPackagePins[], packageName }` or an invalid-package error | -| 3 | `POST /api/workflow-workflow-authoring/:assetId/deploy` (CL-7361) → same `sessionService.deployWorkflowFromSource` call the native `POST /api/tenants/:tenantId/workflows/deployments` route drives, with `sources` resolved server-side from the tenant catalog (`modelRequirements: null` — a per-workflow model requirement, if the package ever declares one, is NOT considered at this step; resolution always targets the tenant's default/first-preference model) | Run bearer + run address → tenant/principal; `workflow:*`/`create`, own-tenant row check first; the `workflow_deploy` tool call itself carries `approval: "ask"`, and the approval card shows the package name and any statically-declared tool pins from step 2 — not the grants/capabilities the deploy will freeze, see CL-7362 below | `{ deploymentId, definitionAssetId, status }` | -| 4 | Human resolves the parked approval (native `approvals` route) | `approval:*`/`resolve` | Deploy continues or is rejected | -| 5 | `workflow_definition` row frozen; appears in routine target discovery | — | Launchable | +| Step | Operation | Authorized as | Returns | +| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| 1 | `POST /api/workflow-workflow-authoring/author` (`@corbits/workflows`'s `./authoring`) → `AssetService.createAsset` + `populateAsset` | Run bearer + run address → tenant/principal; `asset:*`/`create` | `{ assetId, name, commitSha }` | +| 1' | `.../republish` → `populateAsset` on `refs/heads/main` | `asset:`/`write`, own-tenant row check first | `{ assetId, name, commitSha }` | +| 1'' | `GET .../:assetId/source` → `RepoStore.resolveRef` + `openCommittedReads` on `refs/heads/main` | `asset:`/`read`, own-tenant row check first | `{ assetId, name, headSha, files }` | +| 2 | `POST .../:assetId/deploy/preview` (CL-7362) — a STATIC, read-only render of the already-committed source at `commitSha` off `RepoStore` alone; never installs, probes, gates, or freezes | Same run scope | `{ commitSha, entry, files[], toolPackagePins[], packageName }` or an invalid-package error | +| 3 | `POST /api/workflow-workflow-authoring/:assetId/deploy` (CL-7361) → same `sessionService.deployWorkflowFromSource` call the native `POST /api/tenants/:tenantId/workflows/deployments` route drives, with `sources` resolved server-side from the tenant catalog (`modelRequirements: null` — a per-workflow model requirement, if the package ever declares one, is NOT considered at this step; resolution always targets the tenant's default/first-preference model) | Run bearer + run address → tenant/principal; `workflow:*`/`create`, own-tenant row check first; the `workflow_deploy` tool call itself carries `approval: "ask"`, and the approval card shows the package name and any statically-declared tool pins from step 2 — not the grants/capabilities the deploy will freeze, see CL-7362 below | `{ deploymentId, definitionAssetId, status }` | +| 4 | Human resolves the parked approval (native `approvals` route) | `approval:*`/`resolve` | Deploy continues or is rejected | +| 5 | `workflow_definition` row frozen; appears in routine target discovery | — | Launchable | diff --git a/packages/workflow-authoring-tools/src/client.ts b/packages/workflow-authoring-tools/src/client.ts index 717235f6..3ffc13ba 100644 --- a/packages/workflow-authoring-tools/src/client.ts +++ b/packages/workflow-authoring-tools/src/client.ts @@ -134,7 +134,6 @@ const DeployPreviewResponse = type({ }, }); - function endpoint(config: WorkflowAuthoringClientConfig, path: string): string { return `${config.hubWorkflowAuthoringUrl}/api/workflow-workflow-authoring${path}`; } @@ -179,7 +178,10 @@ export async function authorWorkflow( const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, "/author"), { method: "POST", - headers: { ...runBearerHeaders(config), "content-type": "application/json" }, + headers: { + ...runBearerHeaders(config), + "content-type": "application/json", + }, body: JSON.stringify(input), }); if (!response.ok) await throwForFailure(response, "Authoring a workflow"); @@ -197,7 +199,10 @@ export async function republishWorkflow( const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, "/republish"), { method: "POST", - headers: { ...runBearerHeaders(config), "content-type": "application/json" }, + headers: { + ...runBearerHeaders(config), + "content-type": "application/json", + }, body: JSON.stringify(input), }); if (!response.ok) { @@ -219,7 +224,10 @@ export async function deployWorkflow( endpoint(config, `/${encodeURIComponent(input.assetId)}/deploy`), { method: "POST", - headers: { ...runBearerHeaders(config), "content-type": "application/json" }, + headers: { + ...runBearerHeaders(config), + "content-type": "application/json", + }, body: JSON.stringify({ commitSha: input.commitSha, entry: input.entry, @@ -243,7 +251,10 @@ export async function previewDeployWorkflow( endpoint(config, `/${encodeURIComponent(input.assetId)}/deploy/preview`), { method: "POST", - headers: { ...runBearerHeaders(config), "content-type": "application/json" }, + headers: { + ...runBearerHeaders(config), + "content-type": "application/json", + }, body: JSON.stringify({ commitSha: input.commitSha, entry: input.entry, diff --git a/packages/workflows/src/authoring/run-client.ts b/packages/workflows/src/authoring/run-client.ts index 4b2239f0..2d42b96c 100644 --- a/packages/workflows/src/authoring/run-client.ts +++ b/packages/workflows/src/authoring/run-client.ts @@ -51,8 +51,6 @@ export function runBearerErrorCode(body: unknown): string | undefined { return parsed instanceof type.errors ? undefined : parsed.error.code; } -export function runBearerFetch( - config: RunBearerClientConfig, -): typeof fetch { +export function runBearerFetch(config: RunBearerClientConfig): typeof fetch { return config.fetchImpl ?? fetch; } From 758016988aa31aae45ae7ce9bc6a24d767f8d3d2 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Wed, 2 Sep 2026 03:03:14 -0700 Subject: [PATCH 5/8] Consolidate launchability rule and run-bearer client (CL-7373) --- bun.lock | 3 +- packages/routines-tools/package.json | 3 +- packages/routines-tools/src/client.ts | 61 +++----- packages/routines/src/routes.ts | 21 +-- packages/routines/src/routine-operations.ts | 33 ++-- packages/routines/src/targets.ts | 88 ++--------- packages/workflows/src/client.ts | 1 + .../src/detail/definition-lifecycle.test.ts | 2 + .../src/detail/definition-lifecycle.ts | 16 +- packages/workflows/src/detail/detail-route.ts | 5 + packages/workflows/src/index.ts | 2 + .../workflows/src/launchable/target-rule.ts | 28 ++-- packages/workflows/src/launchable/target.ts | 148 ++++++++++++++---- workflows/assistant/src/index.ts | 2 +- 14 files changed, 222 insertions(+), 191 deletions(-) diff --git a/bun.lock b/bun.lock index db9d00d9..43b5e204 100644 --- a/bun.lock +++ b/bun.lock @@ -1219,9 +1219,10 @@ }, "packages/routines-tools": { "name": "@corbits/routines-tools", - "version": "0.0.8", + "version": "0.0.9", "dependencies": { "@corbits/routines": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/types": "workspace:*", "arktype": "catalog:", diff --git a/packages/routines-tools/package.json b/packages/routines-tools/package.json index dc61e4d8..76bf1dad 100644 --- a/packages/routines-tools/package.json +++ b/packages/routines-tools/package.json @@ -2,7 +2,7 @@ "name": "@corbits/routines-tools", "private": true, "description": "Myra's routine-management tool bundle (routine_list, routine_create, routine_update, routine_run_now): an @intx/agent tool bundle calling @corbits/routines' workflow-run-authenticated routine routes, so Myra can create and manage the workbench's recurring/triggered automations from chat without reimplementing scheduling, cron, or launch logic", - "version": "0.0.8", + "version": "0.0.9", "license": "LGPL-2.1-or-later", "type": "module", "exports": { @@ -14,6 +14,7 @@ }, "dependencies": { "@corbits/routines": "workspace:*", + "@corbits/workflows": "workspace:*", "@intx/agent": "workspace:*", "@intx/types": "workspace:*", "arktype": "catalog:" diff --git a/packages/routines-tools/src/client.ts b/packages/routines-tools/src/client.ts index f31b5ad9..61dec031 100644 --- a/packages/routines-tools/src/client.ts +++ b/packages/routines-tools/src/client.ts @@ -17,15 +17,17 @@ import { RoutineTargetsResponse, type RoutineTriggerT, } from "@corbits/routines/client"; +import { + runBearerHeaders, + runBearerErrorMessage, + runBearerFetch, + type RunBearerClientConfig, +} from "@corbits/workflows/client"; -export interface RoutineToolClientConfig { +export interface RoutineToolClientConfig extends RunBearerClientConfig { /** The hub's plain HTTP origin — same value memory-tools' `hubMemoryUrl` * and capability-tools' `hubCapabilitiesUrl` reach the hub through. */ readonly hubRoutinesUrl: string; - readonly sidecarToken: string; - readonly address: string; - /** Override for tests; defaults to the global `fetch`. */ - readonly fetchImpl?: typeof fetch; } /** The trigger a routine create/update call sends — `@corbits/routines`' @@ -78,31 +80,6 @@ const RunRoutineNowResponse = type({ runId: "string", }); -/** Pulls `error.userMessage` out of the canonical hub envelope - * (`{error: {code, userMessage, refId}}`), if `body` matches that shape. */ -function errorMessageFrom(body: unknown): string | undefined { - if (body === null || typeof body !== "object" || !("error" in body)) { - return undefined; - } - const error = (body as { error: unknown }).error; - if ( - error === null || - typeof error !== "object" || - !("userMessage" in error) - ) { - return undefined; - } - const userMessage = (error as { userMessage: unknown }).userMessage; - return typeof userMessage === "string" ? userMessage : undefined; -} - -function authHeaders(config: RoutineToolClientConfig): Record { - return { - authorization: `Bearer ${config.sidecarToken}`, - "x-workflow-run-address": config.address, - }; -} - function endpoint(config: RoutineToolClientConfig, path: string): string { return `${config.hubRoutinesUrl}/api/workflow-routines${path}`; } @@ -112,7 +89,7 @@ async function readErrorMessage( fallback: string, ): Promise { const body: unknown = await response.json().catch(() => undefined); - return errorMessageFrom(body) ?? fallback; + return runBearerErrorMessage(body) ?? fallback; } /** Lists every routine in the calling run's own tenant. Throws a plain @@ -121,9 +98,9 @@ async function readErrorMessage( export async function listRoutines( config: RoutineToolClientConfig, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, "/routines"), { - headers: authHeaders(config), + headers: runBearerHeaders(config), }); if (!response.ok) { throw new Error( @@ -151,10 +128,10 @@ export async function createRoutine( config: RoutineToolClientConfig, input: CreateRoutineRequest, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, "/routines"), { method: "POST", - headers: { ...authHeaders(config), "content-type": "application/json" }, + headers: { ...runBearerHeaders(config), "content-type": "application/json" }, body: JSON.stringify(input), }); if (!response.ok) { @@ -182,10 +159,10 @@ export async function updateRoutine( routineId: string, patch: UpdateRoutineRequest, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, `/routines/${routineId}`), { method: "PATCH", - headers: { ...authHeaders(config), "content-type": "application/json" }, + headers: { ...runBearerHeaders(config), "content-type": "application/json" }, body: JSON.stringify(patch), }); if (!response.ok) { @@ -214,15 +191,15 @@ export async function runRoutineNow( routineId: string, input?: Record, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch( endpoint(config, `/routines/${routineId}/run`), { method: "POST", headers: input === undefined - ? authHeaders(config) - : { ...authHeaders(config), "content-type": "application/json" }, + ? runBearerHeaders(config) + : { ...runBearerHeaders(config), "content-type": "application/json" }, body: input === undefined ? undefined : JSON.stringify({ input }), }, ); @@ -253,9 +230,9 @@ export async function runRoutineNow( export async function listTargets( config: RoutineToolClientConfig, ): Promise { - const doFetch = config.fetchImpl ?? fetch; + const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, "/targets"), { - headers: authHeaders(config), + headers: runBearerHeaders(config), }); if (!response.ok) { throw new Error( diff --git a/packages/routines/src/routes.ts b/packages/routines/src/routes.ts index 2004eeae..46eaaaee 100644 --- a/packages/routines/src/routes.ts +++ b/packages/routines/src/routes.ts @@ -36,7 +36,10 @@ import { routineTargetRejection, type LaunchableDefinitionResolver, } from "@corbits/workflows"; -import { validateRetarget } from "./routine-operations"; +import { + validateRetarget, + isDeliveryWorkbenchRequired, +} from "./routine-operations"; import { makeErrorEnvelope } from "@workbench/hub-client"; import { MyraRoutineDraftingUnavailableError, @@ -527,21 +530,7 @@ export async function webhookTriggerValid( ); } -/** Every definition defaults to workbench-required — see - * `CreateRoutineRoutesDeps.deliveryWorkbenchRequired`'s own doc comment - * for why an omitted port must never change prior behavior. - * - * Exported: `./workflow-routine-routes.ts` consults the same rule for - * Myra's own create/run-now path. - */ -export async function isDeliveryWorkbenchRequired( - deps: Pick, - tenantId: string, - definitionAssetId: string, -): Promise { - if (deps.deliveryWorkbenchRequired === undefined) return true; - return deps.deliveryWorkbenchRequired(tenantId, definitionAssetId); -} +export { isDeliveryWorkbenchRequired }; /** * Posts the "created enabled" / "enabled" honest-notice — see diff --git a/packages/routines/src/routine-operations.ts b/packages/routines/src/routine-operations.ts index 4647d1a9..5246b24a 100644 --- a/packages/routines/src/routine-operations.ts +++ b/packages/routines/src/routine-operations.ts @@ -12,11 +12,9 @@ // independently; this module is the seam that stops the next fix from // needing the same double patch for retarget validation specifically. // No import from `./routes` here on purpose: `./routes.ts` imports -// `validateRetarget` from this module, so this module importing back from -// `./routes.ts` would be a cycle. `deliveryWorkbenchRequired`'s -// "omitted means required" default is duplicated from -// `routes.ts`'s `isDeliveryWorkbenchRequired` (one line, unlikely to -// drift; both are covered by the same tests via each route's PATCH). +// `validateRetarget` (and, below, `isDeliveryWorkbenchRequired`) from +// this module, so this module importing back from `./routes.ts` would be +// a cycle. export type RetargetValidationDeps = { readonly deliveryWorkbenchRequired?: ( tenantId: string, @@ -36,6 +34,19 @@ export type RetargetValidationRejection = { readonly userMessage: string; }; +/** Every definition defaults to workbench-required — an omitted port + * must never change prior behavior. Shared by `./routes.ts`'s + * tenant-session create/PATCH and `./workflow-routine-routes.ts`'s + * run-authenticated mirror, alongside `validateRetarget` below. */ +export async function isDeliveryWorkbenchRequired( + deps: Pick, + tenantId: string, + definitionAssetId: string, +): Promise { + if (deps.deliveryWorkbenchRequired === undefined) return true; + return deps.deliveryWorkbenchRequired(tenantId, definitionAssetId); +} + /** * Re-runs create's delivery-workbench-required and input-schema checks * against a routine being retargeted at `effectiveDefinitionAssetId`, @@ -53,13 +64,11 @@ export async function validateRetarget( readonly input: Record; }, ): Promise { - const deliveryRequired = - deps.deliveryWorkbenchRequired === undefined - ? true - : await deps.deliveryWorkbenchRequired( - tenantId, - effectiveDefinitionAssetId, - ); + const deliveryRequired = await isDeliveryWorkbenchRequired( + deps, + tenantId, + effectiveDefinitionAssetId, + ); if (deliveryRequired && existing.deliveryWorkbenchId === null) { return { code: "bad_request", diff --git a/packages/routines/src/targets.ts b/packages/routines/src/targets.ts index 28161fd0..41f099a2 100644 --- a/packages/routines/src/targets.ts +++ b/packages/routines/src/targets.ts @@ -1,15 +1,17 @@ // Routine target discovery (CL-7351): the one list of deployed, frozen // definitions a routine may reference, shared by every authoring surface // (the web picker, Myra's routine tools, the routine resolver in -// ./target.ts). Built over native rows — `workflow_definition` joined to -// its frozen `workflow_definition_version` — and `@intx/authz`'s -// `authorize`, because Interchange has no per-principal "launchable -// definitions" query (docs/workflow-model.md, "What is not native"). +// `@corbits/workflows`' `./launchable/target.ts`). `listLaunchableDefinitions` +// itself moved there (CL-7373 Greybeard pass 2): it is definition-domain +// logic built over the same `pickLaunchableDefinition` follow-latest rule +// `resolveLaunchableDefinition` uses for one asset, not a routine concern +// — this module now only adds `@intx/authz`'s `authorize` and the +// routine-target product filter/pagination on top, because Interchange +// has no per-principal "launchable definitions" query of its own +// (docs/workflow-model.md, "What is not native"). -import { and, asc, desc, eq, isNotNull } from "drizzle-orm"; import { authorize } from "@intx/authz"; import type { DB } from "@intx/db"; -import { workflowDefinition, workflowDefinitionVersion } from "@intx/db/schema"; import type { ConditionRegistry, GrantStore } from "@intx/types/authz"; import { WorkflowProjectionDefinition } from "@intx/types/sidecar"; import { type } from "arktype"; @@ -19,78 +21,14 @@ import { isConversationalWorkflowName, workflowDisplayName, } from "@corbits/workflow-catalog"; +import { + listLaunchableDefinitions, + type LaunchableDefinition, +} from "@corbits/workflows"; import type { RoutineTarget, RoutineTargetKind } from "./client"; -export type LaunchableDefinition = { - readonly definitionId: string; - readonly definitionAssetId: string; - readonly name: string; - readonly description: string | null; - readonly wireHash: string; - readonly wireProjection: unknown; -}; - -/** - * The newest launchable definition per source asset in a tenant: an - * `authored` row with `status = 'deployed'` whose current version row is - * frozen (non-null `approved_wire_hash`, `grant_snapshot`, and - * `wire_projection`). This is the follow-latest rule from - * docs/workflow-model.md as one query; the routine launch resolver reads - * the same rows for one asset. Not authorized — callers gate what leaves. - */ -export async function listLaunchableDefinitions( - db: DB["db"], - tenantId: string, -): Promise { - const rows = await db - .selectDistinctOn([workflowDefinition.assetId], { - definitionId: workflowDefinition.id, - definitionAssetId: workflowDefinition.assetId, - name: workflowDefinition.name, - description: workflowDefinition.description, - wireHash: workflowDefinitionVersion.approvedWireHash, - wireProjection: workflowDefinitionVersion.wireProjection, - }) - .from(workflowDefinition) - .innerJoin( - workflowDefinitionVersion, - and( - eq(workflowDefinitionVersion.definitionId, workflowDefinition.id), - eq( - workflowDefinitionVersion.version, - workflowDefinition.currentVersion, - ), - ), - ) - .where( - and( - eq(workflowDefinition.tenantId, tenantId), - eq(workflowDefinition.status, "deployed"), - eq(workflowDefinition.origin, "authored"), - isNotNull(workflowDefinition.assetId), - isNotNull(workflowDefinitionVersion.approvedWireHash), - isNotNull(workflowDefinitionVersion.grantSnapshot), - isNotNull(workflowDefinitionVersion.wireProjection), - ), - ) - .orderBy( - asc(workflowDefinition.assetId), - desc(workflowDefinition.createdAt), - desc(workflowDefinition.id), - ); - return rows.flatMap((row) => - row.definitionAssetId === null || row.wireHash === null - ? [] - : [ - { - ...row, - definitionAssetId: row.definitionAssetId, - wireHash: row.wireHash, - }, - ], - ); -} +export { listLaunchableDefinitions, type LaunchableDefinition }; /** * The contract's definition of an agent is "a single-step conversational diff --git a/packages/workflows/src/client.ts b/packages/workflows/src/client.ts index 7b0b6883..9147776e 100644 --- a/packages/workflows/src/client.ts +++ b/packages/workflows/src/client.ts @@ -13,6 +13,7 @@ export { } from "./authoring/run-client"; export { pickLaunchableDefinition, + isFrozen, routineTargetRejection, RoutineTargetUnresolvableError, type LaunchableDefinitionCandidate, diff --git a/packages/workflows/src/detail/definition-lifecycle.test.ts b/packages/workflows/src/detail/definition-lifecycle.test.ts index b49ba800..362bb9d3 100644 --- a/packages/workflows/src/detail/definition-lifecycle.test.ts +++ b/packages/workflows/src/detail/definition-lifecycle.test.ts @@ -9,6 +9,8 @@ function row(patch: Partial): DefinitionLifecycleRow { id: "wfd_1", wireHash: "hash_1", approvedWireHash: "hash_1", + grantSnapshot: { perStep: [], grantRequirements: [] }, + wireProjection: { stepOrder: [], steps: {} }, status: "deployed", createdAt: "2026-01-01T00:00:00.000Z", ...patch, diff --git a/packages/workflows/src/detail/definition-lifecycle.ts b/packages/workflows/src/detail/definition-lifecycle.ts index 4f54f725..da02912c 100644 --- a/packages/workflows/src/detail/definition-lifecycle.ts +++ b/packages/workflows/src/detail/definition-lifecycle.ts @@ -10,6 +10,8 @@ // attempted at all (`@corbits/workflows`'s `./deploy-source`'s per-anchor-run // record). Kept in its own module, with no DB import, so the four states // below are covered by a plain unit test rather than a route fixture. +import { isFrozen } from "../launchable/target-rule"; + export type WorkflowLifecycle = | "source-only" | "pending-approval" @@ -25,6 +27,10 @@ export type DefinitionLifecycleRow = { /** `workflow_definition_version.approved_wire_hash` for this row's * current version — `null` means the freeze never landed. */ readonly approvedWireHash: string | null; + /** The rest of the same freeze, alongside `approvedWireHash` — folded + * into `isFrozen` below rather than read alone. */ + readonly grantSnapshot: unknown; + readonly wireProjection: unknown; readonly status: "deployed" | "stopped"; /** ISO timestamp, used only to pick the newest row when more than one * is passed in. */ @@ -45,10 +51,10 @@ export type WorkflowLifecycleResult = { * tried to run this asset. * - No rows, a deploy attempt IS on record → `build-failed`: a deploy was * asked for and never produced a definition row at all. - * - Rows exist: the newest one decides. Unapproved (`approvedWireHash` - * still null) → `pending-approval`. Approved and `status: "deployed"` → - * `deployed`. Approved but rolled back / replaced (`status: "stopped"`) - * → `superseded`. + * - Rows exist: the newest one decides. Not yet frozen (see `isFrozen`) → + * `pending-approval`. Frozen and `status: "deployed"` → `deployed`. + * Frozen but rolled back / replaced (`status: "stopped"`) → + * `superseded`. */ export function deriveWorkflowLifecycle( rows: readonly DefinitionLifecycleRow[], @@ -75,7 +81,7 @@ export function deriveWorkflowLifecycle( throw new Error("deriveWorkflowLifecycle: unreachable — rows non-empty"); } - if (newest.approvedWireHash === null) { + if (!isFrozen(newest)) { return { lifecycle: "pending-approval", currentDefinitionId: newest.id, diff --git a/packages/workflows/src/detail/detail-route.ts b/packages/workflows/src/detail/detail-route.ts index cf3d54bf..29477207 100644 --- a/packages/workflows/src/detail/detail-route.ts +++ b/packages/workflows/src/detail/detail-route.ts @@ -187,6 +187,11 @@ export function createWorkflowDetailRoute({ approvedWireHash: currentVersionByDefinitionId.get(row.id)?.approvedWireHash ?? null, + grantSnapshot: + currentVersionByDefinitionId.get(row.id)?.grantSnapshot ?? null, + wireProjection: + currentVersionByDefinitionId.get(row.id)?.wireProjection ?? + null, status: row.status, createdAt: row.createdAt.toISOString(), })), diff --git a/packages/workflows/src/index.ts b/packages/workflows/src/index.ts index a9131ba5..70fab500 100644 --- a/packages/workflows/src/index.ts +++ b/packages/workflows/src/index.ts @@ -9,8 +9,10 @@ export * from "./authoring/index"; export { pickLaunchableDefinition, resolveLaunchableDefinition, + listLaunchableDefinitions, routineTargetRejection, RoutineTargetUnresolvableError, + type LaunchableDefinition, type LaunchableDefinitionCandidate, type LaunchableDefinitionRejection, type LaunchableDefinitionResolution, diff --git a/packages/workflows/src/launchable/target-rule.ts b/packages/workflows/src/launchable/target-rule.ts index 15e5a23a..00242bb0 100644 --- a/packages/workflows/src/launchable/target-rule.ts +++ b/packages/workflows/src/launchable/target-rule.ts @@ -37,12 +37,16 @@ export type LaunchableDefinitionCandidate = { readonly createdAt: Date; }; -// This module's `isFrozen` and `../detail/definition-lifecycle.ts`'s -// frozen check are NOT yet unified into one predicate — both -// independently encode "frozen means non-null approvedWireHash/ -// grantSnapshot/wireProjection" but over row shapes that don't (yet) -// match; a follow-up should widen one to subsume the other. -function isFrozen(candidate: LaunchableDefinitionCandidate): boolean { +/** A deploy freeze stamps `approvedWireHash`, `grantSnapshot`, and + * `wireProjection` onto a definition's current version atomically — this + * is the one predicate for "did that freeze land," shared by the + * follow-latest rule below and `../detail/definition-lifecycle.ts`'s + * lifecycle derivation. */ +export function isFrozen(candidate: { + readonly approvedWireHash: string | null; + readonly grantSnapshot: unknown; + readonly wireProjection: unknown; +}): boolean { return ( candidate.approvedWireHash !== null && candidate.grantSnapshot !== null && @@ -73,9 +77,15 @@ export function pickLaunchableDefinition( if (deployed.length === 0) return { ok: false, reason: "not_deployed" }; const frozen = deployed.filter(isFrozen); if (frozen.length === 0) return { ok: false, reason: "unfrozen" }; - const newest = [...frozen].sort( - (a, b) => b.createdAt.getTime() - a.createdAt.getTime(), - )[0]; + // Newest wins; a `createdAt` tie (redeploys minted in the same request, + // at timestamp granularity that doesn't separate them) breaks on `id` + // desc so the pick is a deterministic total order, never array-input + // order — the one tiebreak this rule uses, everywhere it's used. + const newest = [...frozen].sort((a, b) => { + const byCreatedAt = b.createdAt.getTime() - a.createdAt.getTime(); + if (byCreatedAt !== 0) return byCreatedAt; + return a.id < b.id ? 1 : a.id > b.id ? -1 : 0; + })[0]; if (newest === undefined || newest.approvedWireHash === null) { return { ok: false, reason: "unfrozen" }; } diff --git a/packages/workflows/src/launchable/target.ts b/packages/workflows/src/launchable/target.ts index 67ea6a52..7631b418 100644 --- a/packages/workflows/src/launchable/target.ts +++ b/packages/workflows/src/launchable/target.ts @@ -4,41 +4,75 @@ // this asset" indirection of its own (docs/workflow-model.md), so this // module supplies exactly that query — and nothing else: no search by // name, no fallback to an unfrozen row, no pinning. Every caller (create, -// retarget, launch) resolves through here so a routine can never run a -// definition this rule would not have picked. +// retarget, launch, and the routine-target list) resolves through here so +// a routine can never run, or offer, a definition this rule would not +// have picked. // // Moved from `@corbits/routines` into `@corbits/workflows` (CL-7373 fold // review): "what is launchable" is definition-domain logic, not a routine // concern — `@corbits/routines` now imports it from here rather than // owning a second copy. The pure follow-latest rule lives in // `./target-rule.ts` (no `drizzle-orm`/`@intx/db`, so it is safe on -// `@corbits/workflows/client`); this file is the DB-touching half. -import { and, desc, eq } from "drizzle-orm"; +// `@corbits/workflows/client`); this file is the DB-touching half, and +// both `resolveLaunchableDefinition` and `listLaunchableDefinitions` +// below share the one row query and the one `pickLaunchableDefinition` +// reduction — a second review pass (Greybeard pass 2) folded in +// `@corbits/routines`' own duplicate `selectDistinctOn` query, which had +// drifted to a second, un-shared tiebreak. +import { and, eq } from "drizzle-orm"; import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"; import { workflowDefinition, workflowDefinitionVersion } from "@intx/db/schema"; import { pickLaunchableDefinition } from "./target-rule"; -import type { LaunchableDefinitionResolution } from "./target-rule"; +import type { + LaunchableDefinitionCandidate, + LaunchableDefinitionResolution, +} from "./target-rule"; export * from "./target-rule"; -/** - * Resolves the definition a routine targeting `definitionAssetId` would - * run right now, per `pickLaunchableDefinition`. One query, read at the - * moment of use — a create/retarget validates through it, and a launch - * re-resolves through it rather than trusting anything stored. +type LaunchableDb = PostgresJsDatabase>; + +type LaunchableRow = LaunchableDefinitionCandidate & { + readonly definitionAssetId: string | null; + readonly name: string; + readonly description: string | null; +}; + +/** The newest launchable definition per source asset in a tenant: an + * `authored` row with `status = 'deployed'` whose current version row is + * frozen. The row shape `listLaunchableDefinitions` (below) returns once + * `pickLaunchableDefinition` has picked the winner per asset. */ +export type LaunchableDefinition = { + readonly definitionId: string; + readonly definitionAssetId: string; + readonly name: string; + readonly description: string | null; + readonly wireHash: string; + readonly wireProjection: unknown; +}; + +/** Every `authored` `workflow_definition` row in a tenant with an asset + * id, joined to its current version's freeze columns — unfiltered by + * status or freeze state, so a caller can tell "no such asset" apart + * from "not deployed" apart from "not yet frozen" via + * `pickLaunchableDefinition`'s rejection reasons. The one query both + * `resolveLaunchableDefinition` and `listLaunchableDefinitions` reduce + * through `pickLaunchableDefinition` to reach the same rule. */ -export async function resolveLaunchableDefinition(input: { - db: PostgresJsDatabase>; - tenantId: string; - definitionAssetId: string; -}): Promise { - const rows = await input.db +async function fetchLaunchableRows( + db: LaunchableDb, + extraWhere: ReturnType, +): Promise { + const rows = await db .select({ id: workflowDefinition.id, tenantId: workflowDefinition.tenantId, status: workflowDefinition.status, createdAt: workflowDefinition.createdAt, + definitionAssetId: workflowDefinition.assetId, + name: workflowDefinition.name, + description: workflowDefinition.description, approvedWireHash: workflowDefinitionVersion.approvedWireHash, grantSnapshot: workflowDefinitionVersion.grantSnapshot, wireProjection: workflowDefinitionVersion.wireProjection, @@ -54,18 +88,74 @@ export async function resolveLaunchableDefinition(input: { ), ), ) - .where(eq(workflowDefinition.assetId, input.definitionAssetId)) - .orderBy(desc(workflowDefinition.createdAt)); - return pickLaunchableDefinition( - rows.map((row) => ({ - id: row.id, - tenantId: row.tenantId, - status: row.status, - createdAt: row.createdAt, - approvedWireHash: row.approvedWireHash ?? null, - grantSnapshot: row.grantSnapshot ?? null, - wireProjection: row.wireProjection ?? null, - })), - input.tenantId, + .where( + and(eq(workflowDefinition.origin, "authored"), extraWhere), + ); + return rows.map((row) => ({ + ...row, + approvedWireHash: row.approvedWireHash ?? null, + grantSnapshot: row.grantSnapshot ?? null, + wireProjection: row.wireProjection ?? null, + })); +} + +/** + * Resolves the definition a routine targeting `definitionAssetId` would + * run right now, per `pickLaunchableDefinition`. One query, read at the + * moment of use — a create/retarget validates through it, and a launch + * re-resolves through it rather than trusting anything stored. + */ +export async function resolveLaunchableDefinition(input: { + db: LaunchableDb; + tenantId: string; + definitionAssetId: string; +}): Promise { + const rows = await fetchLaunchableRows( + input.db, + eq(workflowDefinition.assetId, input.definitionAssetId), + ); + return pickLaunchableDefinition(rows, input.tenantId); +} + +/** + * The newest launchable definition per source asset in a tenant, per + * `pickLaunchableDefinition` — the query `@corbits/routines`' routine- + * target listing (the web picker, Myra's tools) reduces further by + * catalog/authorization; not authorized itself, so callers gate what + * leaves. + */ +export async function listLaunchableDefinitions( + db: LaunchableDb, + tenantId: string, +): Promise { + const rows = await fetchLaunchableRows( + db, + eq(workflowDefinition.tenantId, tenantId), ); + const byAsset = new Map(); + for (const row of rows) { + if (row.definitionAssetId === null) continue; + const bucket = byAsset.get(row.definitionAssetId); + if (bucket === undefined) { + byAsset.set(row.definitionAssetId, [row]); + } else { + bucket.push(row); + } + } + const result: LaunchableDefinition[] = []; + for (const [definitionAssetId, candidates] of byAsset) { + const picked = pickLaunchableDefinition(candidates, tenantId); + if (!picked.ok) continue; + const winner = candidates.find((row) => row.id === picked.definitionId); + if (winner === undefined) continue; + result.push({ + definitionId: picked.definitionId, + definitionAssetId, + name: winner.name, + description: winner.description, + wireHash: picked.wireHash, + wireProjection: winner.wireProjection, + }); + } + return result; } diff --git a/workflows/assistant/src/index.ts b/workflows/assistant/src/index.ts index 140b4e37..f83c2d10 100644 --- a/workflows/assistant/src/index.ts +++ b/workflows/assistant/src/index.ts @@ -46,7 +46,7 @@ export const ASSISTANT_STEP_ID = "assistant"; export const ASSISTANT_TOOL_PACKAGE_PINS: readonly ToolPackagePin[] = [ { name: "@corbits/memory-tools", version: "0.0.4" }, { name: "@corbits/capability-tools", version: "0.0.5" }, - { name: "@corbits/routines-tools", version: "0.0.8" }, + { name: "@corbits/routines-tools", version: "0.0.9" }, { name: "@corbits/agent-directory-tools", version: "0.0.6" }, { name: "@corbits/connections-tools", version: "0.0.6" }, { name: "@corbits/catalog-tools", version: "0.0.2" }, From e6fb51eece76163912cf62d13185dbc81d83a0a3 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Wed, 2 Sep 2026 03:07:21 -0700 Subject: [PATCH 6/8] Fix prettier formatting after launchability consolidation (CL-7373) --- packages/routines-tools/src/client.ts | 10 ++++++++-- packages/workflows/src/detail/detail-route.ts | 3 +-- packages/workflows/src/launchable/target.ts | 4 +--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/routines-tools/src/client.ts b/packages/routines-tools/src/client.ts index 61dec031..714b8ed9 100644 --- a/packages/routines-tools/src/client.ts +++ b/packages/routines-tools/src/client.ts @@ -131,7 +131,10 @@ export async function createRoutine( const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, "/routines"), { method: "POST", - headers: { ...runBearerHeaders(config), "content-type": "application/json" }, + headers: { + ...runBearerHeaders(config), + "content-type": "application/json", + }, body: JSON.stringify(input), }); if (!response.ok) { @@ -162,7 +165,10 @@ export async function updateRoutine( const doFetch = runBearerFetch(config); const response = await doFetch(endpoint(config, `/routines/${routineId}`), { method: "PATCH", - headers: { ...runBearerHeaders(config), "content-type": "application/json" }, + headers: { + ...runBearerHeaders(config), + "content-type": "application/json", + }, body: JSON.stringify(patch), }); if (!response.ok) { diff --git a/packages/workflows/src/detail/detail-route.ts b/packages/workflows/src/detail/detail-route.ts index 29477207..2907f4d3 100644 --- a/packages/workflows/src/detail/detail-route.ts +++ b/packages/workflows/src/detail/detail-route.ts @@ -190,8 +190,7 @@ export function createWorkflowDetailRoute({ grantSnapshot: currentVersionByDefinitionId.get(row.id)?.grantSnapshot ?? null, wireProjection: - currentVersionByDefinitionId.get(row.id)?.wireProjection ?? - null, + currentVersionByDefinitionId.get(row.id)?.wireProjection ?? null, status: row.status, createdAt: row.createdAt.toISOString(), })), diff --git a/packages/workflows/src/launchable/target.ts b/packages/workflows/src/launchable/target.ts index 7631b418..59d245a8 100644 --- a/packages/workflows/src/launchable/target.ts +++ b/packages/workflows/src/launchable/target.ts @@ -88,9 +88,7 @@ async function fetchLaunchableRows( ), ), ) - .where( - and(eq(workflowDefinition.origin, "authored"), extraWhere), - ); + .where(and(eq(workflowDefinition.origin, "authored"), extraWhere)); return rows.map((row) => ({ ...row, approvedWireHash: row.approvedWireHash ?? null, From 1628f5fabb2dbc12237e7a7f5e1a166fdb279ae6 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Wed, 2 Sep 2026 03:14:31 -0700 Subject: [PATCH 7/8] Fix launchable-rows query to keep the routine-launcher mock's shape (CL-7373) --- packages/workflows/src/launchable/target.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/workflows/src/launchable/target.ts b/packages/workflows/src/launchable/target.ts index 59d245a8..09ddcf6c 100644 --- a/packages/workflows/src/launchable/target.ts +++ b/packages/workflows/src/launchable/target.ts @@ -19,7 +19,7 @@ // reduction — a second review pass (Greybeard pass 2) folded in // `@corbits/routines`' own duplicate `selectDistinctOn` query, which had // drifted to a second, un-shared tiebreak. -import { and, eq } from "drizzle-orm"; +import { and, desc, eq } from "drizzle-orm"; import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"; import { workflowDefinition, workflowDefinitionVersion } from "@intx/db/schema"; @@ -88,7 +88,8 @@ async function fetchLaunchableRows( ), ), ) - .where(and(eq(workflowDefinition.origin, "authored"), extraWhere)); + .where(and(eq(workflowDefinition.origin, "authored"), extraWhere)) + .orderBy(desc(workflowDefinition.createdAt)); return rows.map((row) => ({ ...row, approvedWireHash: row.approvedWireHash ?? null, From 2e487e94a40b00e8a7ce9aaeecfc5472faaad6a9 Mon Sep 17 00:00:00 2001 From: Sawyer Date: Wed, 2 Sep 2026 04:02:20 -0700 Subject: [PATCH 8/8] Remove duplicated retarget-authorization check (CL-7373) --- packages/routines/src/routes.ts | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/packages/routines/src/routes.ts b/packages/routines/src/routes.ts index 46eaaaee..3ad4e5e6 100644 --- a/packages/routines/src/routes.ts +++ b/packages/routines/src/routes.ts @@ -878,27 +878,6 @@ export function createRoutineRoutes( const effectiveDefinitionAssetId = body.definitionAssetId ?? existing.definitionAssetId; - if ( - body.definitionAssetId !== undefined && - body.definitionAssetId !== existing.definitionAssetId - ) { - const rejection = await rejectUnlaunchableTarget( - deps, - tenant.id, - principal.id, - body.definitionAssetId, - ); - if (rejection !== undefined) { - return c.json( - makeErrorEnvelope({ - code: rejection.code, - userMessage: rejection.userMessage, - }), - rejection.status, - ); - } - } - if ( body.trigger !== undefined && !(await webhookTriggerValid(