@mingchuno/agent-workflows 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENCE +21 -0
  2. package/README.md +74 -0
  3. package/dist/drizzle/0000_initial.sql +45 -0
  4. package/dist/drizzle/meta/0000_snapshot.json +264 -0
  5. package/dist/drizzle/meta/_journal.json +13 -0
  6. package/dist/src/adapters/agent-worker.d.ts +1 -0
  7. package/dist/src/adapters/agent-worker.js +16 -0
  8. package/dist/src/adapters/agents.d.ts +24 -0
  9. package/dist/src/adapters/agents.js +142 -0
  10. package/dist/src/adapters/hosting.d.ts +33 -0
  11. package/dist/src/adapters/hosting.js +275 -0
  12. package/dist/src/adapters/sdk-protocol.d.ts +43 -0
  13. package/dist/src/adapters/sdk-protocol.js +64 -0
  14. package/dist/src/cli.d.ts +2 -0
  15. package/dist/src/cli.js +175 -0
  16. package/dist/src/config.d.ts +224 -0
  17. package/dist/src/config.js +82 -0
  18. package/dist/src/db/locks.d.ts +4 -0
  19. package/dist/src/db/locks.js +14 -0
  20. package/dist/src/db/migrate.d.ts +1 -0
  21. package/dist/src/db/migrate.js +12 -0
  22. package/dist/src/db/migrations.d.ts +2 -0
  23. package/dist/src/db/migrations.js +22 -0
  24. package/dist/src/db/schema.d.ts +486 -0
  25. package/dist/src/db/schema.js +46 -0
  26. package/dist/src/domain.d.ts +133 -0
  27. package/dist/src/domain.js +24 -0
  28. package/dist/src/index.d.ts +8 -0
  29. package/dist/src/index.js +8 -0
  30. package/dist/src/operations.d.ts +35 -0
  31. package/dist/src/operations.js +378 -0
  32. package/dist/src/run-record.d.ts +7 -0
  33. package/dist/src/run-record.js +19 -0
  34. package/dist/src/runner.d.ts +47 -0
  35. package/dist/src/runner.js +370 -0
  36. package/dist/src/runtime/ownership.d.ts +8 -0
  37. package/dist/src/runtime/ownership.js +84 -0
  38. package/dist/src/runtime/process.d.ts +18 -0
  39. package/dist/src/runtime/process.js +98 -0
  40. package/dist/src/runtime/redaction.d.ts +8 -0
  41. package/dist/src/runtime/redaction.js +33 -0
  42. package/dist/src/store.d.ts +87 -0
  43. package/dist/src/store.js +355 -0
  44. package/dist/src/tui-data.d.ts +25 -0
  45. package/dist/src/tui-data.js +89 -0
  46. package/dist/src/tui.d.ts +5 -0
  47. package/dist/src/tui.js +69 -0
  48. package/dist/src/workspace.d.ts +16 -0
  49. package/dist/src/workspace.js +186 -0
  50. package/docs/acceptance.md +35 -0
  51. package/docs/api.md +64 -0
  52. package/docs/architecture.md +24 -0
  53. package/docs/configuration.md +41 -0
  54. package/docs/database.md +28 -0
  55. package/docs/operations.md +46 -0
  56. package/docs/providers.md +49 -0
  57. package/docs/releases.md +89 -0
  58. package/examples/config.ts +57 -0
  59. package/examples/custom-workflow.ts +32 -0
  60. package/examples/observe.ts +18 -0
  61. package/examples/run.ts +31 -0
  62. package/package.json +78 -0
@@ -0,0 +1,57 @@
1
+ import { configSchema } from "@mingchuno/agent-workflows";
2
+
3
+ /** Replace paths, repository, identity and model IDs with locally available values. */
4
+ export const configuration = configSchema.parse({
5
+ id: "local",
6
+ stateDirectory: "/absolute/path/outside-the-checkout/agent-workflows-state",
7
+ projects: [
8
+ {
9
+ id: "application",
10
+ checkout: "/absolute/path/to/existing-checkout",
11
+ hosting: {
12
+ provider: "gitlab",
13
+ origin: "https://git.example.com/gitlab",
14
+ repository: "group/application",
15
+ tokenEnv: "GITLAB_TOKEN",
16
+ },
17
+ labels: ["ready-for-agent"],
18
+ baseBranch: "main",
19
+ branchTemplate: "agent/{issue}-{attempt}",
20
+ gitIdentity: { name: "Workflow Agent", email: "agent@example.com" },
21
+ agent: { provider: "codex" },
22
+ stages: {
23
+ implementation: {
24
+ prompt: "Implement the issue and follow repository guidance.",
25
+ },
26
+ writing: {
27
+ profile: { provider: "copilot" },
28
+ prompt:
29
+ "Write concise publication text from the diff and validation evidence.",
30
+ },
31
+ review: {
32
+ profile: { provider: "codex" },
33
+ prompt: "Review correctness and requirements independently.",
34
+ },
35
+ },
36
+ validation: [{ command: "pnpm", args: ["test"], timeoutMs: 300_000 }],
37
+ },
38
+ ],
39
+ });
40
+
41
+ // Explicit model selection is checked against provider capabilities before invocation.
42
+ export const modelOverrides = {
43
+ implementation: {
44
+ provider: "codex" as const,
45
+ model: "YOUR_CODEX_MODEL",
46
+ reasoningEffort: "high",
47
+ },
48
+ writing: {
49
+ provider: "copilot" as const,
50
+ model: "YOUR_COPILOT_MODEL",
51
+ reasoningEffort: "low",
52
+ context: {
53
+ backgroundCompactionThreshold: 0.8,
54
+ bufferExhaustionThreshold: 0.95,
55
+ },
56
+ },
57
+ };
@@ -0,0 +1,32 @@
1
+ import type { Operations } from "@mingchuno/agent-workflows";
2
+
3
+ /** Ordinary TypeScript composition; provider adapters remain unchanged. */
4
+ export async function reportingWorkflow(operations: Operations): Promise<void> {
5
+ if (!(await operations.eligible())) {
6
+ await operations.step("ineligible", async (run) => {
7
+ await operations.dependencies.store.patchRun(run.id, {
8
+ outcome: "ineligible",
9
+ });
10
+ });
11
+ return;
12
+ }
13
+ await operations.prepare();
14
+ await operations.implement();
15
+ if (!(await operations.validate())) {
16
+ await operations.complete("no-change");
17
+ return;
18
+ }
19
+ await operations.step("validation-report", async (run) => {
20
+ await operations.dependencies.store.emit(run.id, "validation-report", {
21
+ checks: run.validation ?? [],
22
+ changedPaths: run.snapshot?.paths ?? [],
23
+ });
24
+ });
25
+ await operations.writePublication();
26
+ await operations.commit();
27
+ await operations.push();
28
+ await operations.publish();
29
+ await operations.review();
30
+ await operations.publishReview();
31
+ await operations.complete();
32
+ }
@@ -0,0 +1,18 @@
1
+ import { Store } from "@mingchuno/agent-workflows";
2
+
3
+ export async function inspectRun(
4
+ databaseUrl: string,
5
+ runnerId: string,
6
+ runId: string,
7
+ ) {
8
+ const store = new Store(databaseUrl, runnerId);
9
+ try {
10
+ return {
11
+ run: await store.run(runId),
12
+ invocations: await store.invocations(runId),
13
+ events: (await store.events()).filter((event) => event.runId === runId),
14
+ };
15
+ } finally {
16
+ await store.close();
17
+ }
18
+ }
@@ -0,0 +1,31 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import {
3
+ configSchema,
4
+ createAgents,
5
+ createHosting,
6
+ Runner,
7
+ } from "@mingchuno/agent-workflows";
8
+ import { reportingWorkflow } from "./custom-workflow.js";
9
+
10
+ const config = configSchema.parse(
11
+ JSON.parse(await readFile(process.argv[2] ?? "agent-workflows.json", "utf8")),
12
+ );
13
+ const databaseUrl = process.env[config.databaseUrlEnv];
14
+ if (!databaseUrl) throw new Error(`Set ${config.databaseUrlEnv}`);
15
+ const runner = new Runner({
16
+ config,
17
+ databaseUrl,
18
+ hosting: createHosting,
19
+ agents: createAgents(),
20
+ workflow: reportingWorkflow,
21
+ workflowVersion: "reporting-v1",
22
+ });
23
+ try {
24
+ await runner.start();
25
+ await new Promise<void>((resolve) => {
26
+ process.once("SIGINT", resolve);
27
+ process.once("SIGTERM", resolve);
28
+ });
29
+ } finally {
30
+ await runner.shutdown();
31
+ }
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@mingchuno/agent-workflows",
3
+ "version": "0.1.0",
4
+ "description": "Local durable coding workflows on DBOS",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mingchuno/agent-workflows.git"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "files": [
16
+ "dist/src",
17
+ "dist/drizzle",
18
+ "README.md",
19
+ "LICENCE",
20
+ "docs/*.md",
21
+ "examples"
22
+ ],
23
+ "engines": {
24
+ "node": ">=22.12"
25
+ },
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/src/index.d.ts",
29
+ "import": "./dist/src/index.js"
30
+ }
31
+ },
32
+ "bin": {
33
+ "agent-workflows": "./dist/src/cli.js"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc -p tsconfig.build.json && node scripts/copy-migrations.mjs",
37
+ "check": "tsc --noEmit",
38
+ "test": "pnpm build && node --test scripts/*.test.mjs && node scripts/test.mjs",
39
+ "verify": "pnpm check && pnpm lint && pnpm test",
40
+ "pack:smoke": "pnpm build && node scripts/test.mjs --pack-smoke",
41
+ "release:publish": "node scripts/publish.mjs",
42
+ "lint:pr": "node scripts/lint-pr-title.mjs",
43
+ "start": "tsx src/cli.ts",
44
+ "format": "biome format --write .",
45
+ "format:check": "biome format .",
46
+ "lint": "biome check .",
47
+ "db:generate": "drizzle-kit generate",
48
+ "db:migrate": "tsx src/db/migrate.ts"
49
+ },
50
+ "dependencies": {
51
+ "@dbos-inc/dbos-sdk": "^5.0.2",
52
+ "@gitbeaker/rest": "^43.8.0",
53
+ "@github/copilot-sdk": "^1.0.14",
54
+ "@octokit/rest": "^22.0.1",
55
+ "@openai/codex-sdk": "^0.155.1",
56
+ "@types/pg": "^8.23.1",
57
+ "commander": "^15.0.0",
58
+ "drizzle-orm": "0.45.2",
59
+ "ink": "^7.1.1",
60
+ "pg": "^8.23.0",
61
+ "pino": "^10.3.1",
62
+ "react": "^19.3.0",
63
+ "zod": "^4.6.5"
64
+ },
65
+ "devDependencies": {
66
+ "@biomejs/biome": "2.5.14",
67
+ "@commitlint/cli": "21.2.2",
68
+ "@commitlint/config-conventional": "21.2.2",
69
+ "@types/node": "^26.6.2",
70
+ "@types/react": "^19.3.0",
71
+ "drizzle-kit": "0.31.10",
72
+ "ink-testing-library": "^4.0.0",
73
+ "npm": "12.0.2",
74
+ "tsx": "^4.23.13",
75
+ "typescript": "^7.0.2"
76
+ },
77
+ "packageManager": "pnpm@12.4.2"
78
+ }