@mingchuno/agent-workflows 0.1.0 → 0.3.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 (76) hide show
  1. package/README.md +37 -6
  2. package/dist/src/adapters/agents.js +6 -3
  3. package/dist/src/adapters/hosting.js +16 -10
  4. package/dist/src/adapters/sdk-protocol.d.ts +3 -3
  5. package/dist/src/adapters/sdk-protocol.js +9 -7
  6. package/dist/src/attribution.d.ts +9 -0
  7. package/dist/src/attribution.js +57 -0
  8. package/dist/src/cli.d.ts +1 -1
  9. package/dist/src/cli.js +80 -25
  10. package/dist/src/config.d.ts +24 -30
  11. package/dist/src/config.js +32 -27
  12. package/dist/src/defaults.d.ts +2 -0
  13. package/dist/src/defaults.js +2 -0
  14. package/dist/src/domain.d.ts +31 -4
  15. package/dist/src/domain.js +10 -3
  16. package/dist/src/evidence.d.ts +54 -0
  17. package/dist/src/evidence.js +214 -0
  18. package/dist/src/index.d.ts +1 -0
  19. package/dist/src/index.js +1 -0
  20. package/dist/src/invocation.d.ts +25 -0
  21. package/dist/src/invocation.js +166 -0
  22. package/dist/src/operations.d.ts +8 -2
  23. package/dist/src/operations.js +100 -136
  24. package/dist/src/prompts.d.ts +28 -0
  25. package/dist/src/prompts.js +63 -0
  26. package/dist/src/recovery.d.ts +19 -0
  27. package/dist/src/recovery.js +99 -0
  28. package/dist/src/runner.d.ts +7 -0
  29. package/dist/src/runner.js +170 -18
  30. package/dist/src/runtime/process.d.ts +2 -0
  31. package/dist/src/runtime/process.js +41 -12
  32. package/dist/src/store.d.ts +21 -2
  33. package/dist/src/store.js +122 -1
  34. package/dist/src/tui/actions.d.ts +16 -0
  35. package/dist/src/tui/actions.js +23 -0
  36. package/dist/src/tui/constants.d.ts +6 -0
  37. package/dist/src/tui/constants.js +3 -0
  38. package/dist/src/{tui-data.d.ts → tui/data.d.ts} +10 -7
  39. package/dist/src/tui/data.js +146 -0
  40. package/dist/src/tui/dialogs.d.ts +17 -0
  41. package/dist/src/tui/dialogs.js +149 -0
  42. package/dist/src/tui/format.d.ts +7 -0
  43. package/dist/src/tui/format.js +62 -0
  44. package/dist/src/tui/index.d.ts +3 -0
  45. package/dist/src/tui/index.js +2 -0
  46. package/dist/src/tui/layout.d.ts +25 -0
  47. package/dist/src/tui/layout.js +36 -0
  48. package/dist/src/tui/log-file.d.ts +26 -0
  49. package/dist/src/tui/log-file.js +156 -0
  50. package/dist/src/tui/log.d.ts +11 -0
  51. package/dist/src/tui/log.js +90 -0
  52. package/dist/src/tui/monitor.d.ts +10 -0
  53. package/dist/src/tui/monitor.js +284 -0
  54. package/dist/src/tui/notifications.d.ts +23 -0
  55. package/dist/src/tui/notifications.js +104 -0
  56. package/dist/src/tui/text.d.ts +3 -0
  57. package/dist/src/tui/text.js +10 -0
  58. package/dist/src/tui/use-log-controller.d.ts +27 -0
  59. package/dist/src/tui/use-log-controller.js +192 -0
  60. package/dist/src/tui/views.d.ts +25 -0
  61. package/dist/src/tui/views.js +327 -0
  62. package/dist/src/workspace.js +21 -8
  63. package/docs/api.md +132 -8
  64. package/docs/architecture.md +21 -4
  65. package/docs/configuration.md +181 -8
  66. package/docs/database.md +7 -0
  67. package/docs/operations.md +160 -5
  68. package/docs/providers.md +58 -2
  69. package/docs/releases.md +34 -79
  70. package/examples/config.ts +6 -6
  71. package/examples/run.ts +4 -1
  72. package/package.json +4 -2
  73. package/dist/src/tui-data.js +0 -89
  74. package/dist/src/tui.d.ts +0 -5
  75. package/dist/src/tui.js +0 -69
  76. package/docs/acceptance.md +0 -35
@@ -1,29 +1,100 @@
1
1
  # Configuration
2
2
 
3
- The CLI reads `agent-workflows.json`, or `--config PATH`. Unknown properties are rejected by Zod. Paths are local filesystem paths; checkout paths are canonicalized before ownership is acquired. Use absolute paths when launching from different working directories.
3
+ The CLI reads `agent-workflows.json`, or `--config PATH`. Both paths resolve from
4
+ the launch directory. Unknown properties are rejected by Zod. Relative
5
+ configuration-owned paths resolve from the directory containing the resolved
6
+ configuration file, independently of where the CLI is launched. Use
7
+ `--config-base-directory DIRECTORY` to select another base; a relative option
8
+ value resolves from the launch directory. The base must be an existing directory
9
+ and is canonicalized before startup.
4
10
 
5
11
  | Runner field | Default / meaning |
6
12
  | ---------------- | --------------------------------------------------------------------------------------------------------- |
7
13
  | `id` | Required stable letters/digits/underscore/hyphen identity; scopes records and queues |
8
14
  | `databaseUrlEnv` | `AGENT_WORKFLOWS_DATABASE_URL`; environment variable containing a PostgreSQL connection URL with username |
9
- | `stateDirectory` | `.agent-workflows`; persistent local artifact directory |
15
+ | `stateDirectory` | `.agent-workflows`; relative to the configuration base and outside every managed checkout |
10
16
  | `projects` | Nonempty array; duplicate IDs or canonical checkout roots are rejected |
11
17
 
12
18
  | Project field | Default / meaning |
13
19
  | ---------------------- | --------------------------------------------------------------------------------------------------- |
14
- | `id`, `checkout` | Required stable identity and existing Git repository root |
20
+ | `id`, `checkout` | Required stable identity and existing Git repository root; relative to the configuration base |
15
21
  | `hosting` | `provider` (`github`/`gitlab`), web `origin`, `repository`, and `tokenEnv`; no serialized tokens |
16
22
  | `labels` | `['ready-for-agent']`; all labels must match |
17
23
  | `baseBranch`, `remote` | `main`, `origin`; Git remote is independent of hosting API origin |
18
24
  | `branchTemplate` | `agent/{issue}-{attempt}`; `{issue}` required; `{attempt}` and `{run}` supported |
19
25
  | `pollIntervalMs` | 30000; minimum 100 |
20
- | `gitIdentity` | Required `name` and `email`; used by application commits |
26
+ | `includeAgentCoAuthors` | `true`; append co-author trailers for providers whose writable invocations produced retained changes |
21
27
  | `validation` | Array of `{command,args,timeoutMs}`; no shell expansion; timeout defaults to 300000 ms |
22
28
  | `agent` | Required default profile |
23
- | `stages` | `implementation`, `writing`, `review`; each has optional `profile`, `prompt`, `skills`, `timeoutMs` |
29
+ | `stages` | `implementation`, `publication`, `review`; each has optional `profile`, `prompt`, `promptFile`, `timeoutMs` |
24
30
 
25
31
  Issues are selected in ascending issue-number order within each intake scan. Deduplication persists across restarts. An explicit retry is a new numbered attempt linked through `retryOf`.
26
32
 
33
+ Absolute configuration paths remain absolute. Effective state and checkout
34
+ paths are normalized once during startup before safety and ownership checks, so
35
+ a later working-directory change cannot redirect a running process. Validation
36
+ commands still execute in the canonical checkout; command names and arguments
37
+ are passed unchanged and are not rebased to the configuration directory.
38
+
39
+ `init` writes relative checkout and external sibling-state paths from the
40
+ effective configuration base. It still refuses to overwrite an existing file.
41
+ When the configuration is in the checkout root, the checkout is `.` and state
42
+ is the relative sibling `<checkout-name>.agent-workflows`.
43
+
44
+ ## CLI environment files
45
+
46
+ Select one file explicitly for any CLI command:
47
+
48
+ ```sh
49
+ agent-workflows --env-file ./runner.env run
50
+ agent-workflows --env-file ./runner.env status --json
51
+ agent-workflows --env-file /absolute/path/runner.env monitor
52
+ ```
53
+
54
+ Example `runner.env` (replace placeholders locally):
55
+
56
+ ```dotenv
57
+ AGENT_WORKFLOWS_DATABASE_URL="postgresql://USER:PASSWORD@localhost/agent_workflows"
58
+ GITHUB_TOKEN="YOUR_GITHUB_TOKEN"
59
+ APP_MODE=development # unquoted comment
60
+ APP_GREETING="hello # literal text"
61
+ APP_REFERENCE='${APP_MODE}'
62
+ ```
63
+
64
+ - Existing process values win, including empty strings. Empty required database
65
+ or hosting values still fail existing validation. Missing keys are filled from
66
+ the file; arbitrary application variable names are supported. `databaseUrlEnv`
67
+ and `hosting.tokenEnv` still select which names the runner uses.
68
+ - Relative paths resolve from the CLI launch directory, independently of
69
+ `--config` and project checkouts. Absolute paths work too. No `.env` discovery
70
+ or multiple-file layering is performed.
71
+ - Parsing uses Node's literal dotenv syntax: quotes and comments are supported;
72
+ `$NAME`, `${NAME}`, backticks and `$(command)` in values are not expanded or
73
+ executed. This is not shell sourcing.
74
+ - The file is read once before the command action, database access, hosting
75
+ adapters or runner creation. Missing or unreadable files stop the command with
76
+ a nonzero exit and a path/error code, without printing file contents. Restart
77
+ the runner to pick up edits. Help only displays usage and does not load files.
78
+ - The merged environment is shared across all projects in the runner. Validation,
79
+ Git and agent worker subprocesses inherit it. Provider runtimes may apply their
80
+ own environment policies to tools they launch; see [providers](providers.md).
81
+ No per-project environment isolation is added.
82
+
83
+ Keep local environment files out of version control. Add their actual names to
84
+ `.gitignore` (or `.git/info/exclude`), especially inside managed checkouts where
85
+ untracked files interfere with cleanliness checks. Do not copy credentials into
86
+ configuration, prompts or issue bodies. Existing database/hosting credential
87
+ redaction remains in effect; arbitrary variable support does not classify every
88
+ application value as a secret. A GitHub API token does not configure Git push
89
+ credentials.
90
+
91
+ The flag belongs to `agent-workflows`, not the separate `pnpm db:migrate` command.
92
+ SDK callers load their own process environment before creating a runner and
93
+ continue passing `databaseUrl` explicitly. Node startup-only settings, such as
94
+ `NODE_EXTRA_CA_CERTS`, must be set before launching Node to affect the CLI process.
95
+ When invoking the script directly through Node, separate Node arguments from
96
+ application arguments: `node -- dist/src/cli.js --env-file ./runner.env status`.
97
+
27
98
  ## Profiles
28
99
 
29
100
  A profile has `provider`, optional `model`, optional `reasoningEffort`, and optional `context`. Each stage merges its profile over project defaults. Switching provider discards the old provider's settings, so incompatible defaults cannot leak between providers. Each invocation starts a fresh session, including repeated custom steps.
@@ -34,8 +105,110 @@ Copilot queries its SDK model catalog for explicit settings. Supported context c
34
105
 
35
106
  See [checked examples](../examples/config.ts). Model IDs in `modelOverrides` are placeholders that must be replaced with available models. No provider silently clamps or substitutes explicit options.
36
107
 
37
- ## Prompts and skills
108
+ ## Stage prompts
109
+
110
+ Omit `prompt` and `promptFile` to use the installed defaults. `init` leaves both
111
+ out so package upgrades update default task instructions. An override replaces
112
+ only task instructions; issue context, captured change evidence, permission rules
113
+ and output contracts remain application-owned.
114
+
115
+ ### Default stage prompts
116
+
117
+ Implementation:
118
+
119
+ ```text
120
+ Implement the supplied issue in the current checkout. Follow repository
121
+ instructions and existing conventions. Keep changes focused on the issue's
122
+ requirements, and add or update tests where needed to verify the behavior.
123
+ ```
124
+
125
+ Publication:
126
+
127
+ ```text
128
+ Prepare a Git commit message and a pull request or merge request title and
129
+ description for the supplied changes. Follow repository conventions. Describe
130
+ what changed and why, summarize the recorded validation accurately, and state
131
+ material limitations. Do not claim checks passed unless the supplied evidence
132
+ shows they ran and passed.
133
+ ```
134
+
135
+ Review:
136
+
137
+ ```text
138
+ Independently review the supplied published changes against the issue's
139
+ requirements and repository conventions. Inspect the change artifacts and
140
+ relevant source for correctness, regressions, and missing validation. Report
141
+ actionable findings with supporting locations where possible. State any gaps
142
+ in inspection explicitly; do not present an incomplete review as a clean review.
143
+ ```
144
+
145
+ These exact defaults are checked against the runtime source.
146
+
147
+ Use either nonblank literal `prompt` text or a `promptFile` path, never both.
148
+ Files must contain nonblank UTF-8 text. Relative paths use the same configuration
149
+ base as state and checkout paths; absolute paths are allowed. Files load once
150
+ when the runner is constructed. Restart to apply edits. No templating,
151
+ interpolation, or includes are supported. SDK callers use `pathBaseDirectory` as
152
+ the general base. `promptBaseDirectory`, when supplied, overrides it for prompt
153
+ files only.
154
+
155
+ ```json
156
+ "stages": {
157
+ "implementation": {},
158
+ "publication": { "promptFile": "prompts/publication.md" },
159
+ "review": { "prompt": "Review correctness and missing regression tests." }
160
+ }
161
+ ```
162
+
163
+ `writing` is now `publication`; `skills` was removed. Both old keys are rejected
164
+ without aliases. Configure skills in the selected agent runtime and request them
165
+ in task text. Old invocation records and skill snapshots remain readable.
166
+
167
+ ## Git identity and agent attribution
168
+
169
+ Commits use Git's native author and committer selection. The application does
170
+ not configure, validate, snapshot, or override identity. Repository, worktree,
171
+ global, system, and identity environment settings therefore behave as they do
172
+ for `git commit`, including distinct author and committer identities. Missing or
173
+ invalid identity fails at the commit operation with Git's error. The removed
174
+ `gitIdentity` property is rejected as unknown input.
175
+
176
+ Agent assistance is represented separately. With `includeAgentCoAuthors: true`,
177
+ the finalized commit message includes each provider once, ordered by its first
178
+ successful writable invocation that produced a retained change:
179
+
180
+ - `Codex <noreply@openai.com>` (OpenAI's published implementation convention)
181
+ - `Copilot <223556219+Copilot@users.noreply.github.com>` (GitHub's current
182
+ first-party convention, not a stable product API guarantee)
183
+
184
+ Read-only publication/review invocations and writable invocations with no
185
+ accepted retained change are not attributed. Existing trailers are preserved,
186
+ matching agent trailers are deduplicated, and exactly one
187
+ `Agent-Workflows-Run` trailer remains. Set `includeAgentCoAuthors: false` per
188
+ project to disable injection; existing publication trailers are not removed.
189
+
190
+ Stage timeout defaults to 30 minutes, including profile validation and at most
191
+ one format-correction attempt. Correction uses a fresh inspection-only session
192
+ and only the remaining deadline. Provider failures, cancellation, timeout and
193
+ workspace mutation never trigger correction. Custom text-only stages do not
194
+ receive format correction. Credentials belong in environment variables or
195
+ runtime authentication stores, not prompts.
196
+
197
+ ## Change evidence
198
+
199
+ Use a `stateDirectory` outside every managed checkout. `init` chooses a sibling
200
+ `<checkout-name>.agent-workflows` directory. Publication and review receive a
201
+ small overview and an absolute index path, then read ordered artifact chunks.
202
+ Publication captures staged, unstaged and untracked changes. Review captures the
203
+ exact base and published head. Hash checks reject missing or modified evidence.
38
204
 
39
- `prompt` is literal stage text. `skills` contains paths to `SKILL.md` files, relative to the checkout or absolute. The runner snapshots their content and SHA-256 revision into invocation records and explicitly tells the agent to apply them. Copilot additionally receives skill directories; Codex receives explicit skill text. Automatic provider discovery is not assumed equivalent.
205
+ Text chunks are at most 64 KiB; total text evidence, including indexes, is at most
206
+ 32 MiB per stage. Capture fails explicitly above the limit. Large indexes have
207
+ bounded pages; binary changes contain metadata instead of encoded content.
208
+ These are internal limits, not configurable model context limits.
40
209
 
41
- Stage timeout defaults to 30 minutes. Custom agent steps use the same `Stage` schema, profile resolution, snapshots, cancellation and session tracking as built-in stages. Credentials stay in environment variables/runtime authentication stores; do not place them in prompts or source files.
210
+ Review output includes `complete` and `limitations`. Incomplete reviews preserve
211
+ partial findings locally and block normal review publication. Prompt content,
212
+ output contract and evidence identities are retained with each response attempt.
213
+ Changed effective prompts, including upgraded defaults, block recovery with
214
+ fresh-retry guidance; file edits do not change an already running instance.
package/docs/database.md CHANGED
@@ -26,3 +26,10 @@ attempts. Runner's checkout/process safety check runs while that lock is held;
26
26
  command replay skips it and does not write new events.
27
27
 
28
28
  `src/db/locks.ts` contains the only application driver SQL: fixed, parameterized PostgreSQL session-lock calls, which have no Drizzle query-builder equivalent. Generated migration SQL and the frozen legacy-schema test fixture are intentional SQL artifacts. No interpolated SQL template strings are used for record access.
29
+
30
+ Execution history is stored in the existing run JSON record. Publication recovery
31
+ adds optional fields without changing SQL tables; no migration or backfill is
32
+ required. Legacy records remain readable, but lack the evidence needed for
33
+ recovery. Recovery admission atomically appends an execution, queues the same
34
+ run and writes an event under the project/task locks used by retry admission.
35
+ The persisted execution ID lets dispatch reconcile a DBOS fork across crashes.
@@ -13,12 +13,129 @@ All commands accept `--config PATH` before the subcommand.
13
13
  | `logs RUN [--invocation ID]` | Local agent and validation artifacts |
14
14
  | `pause PROJECT` / `resume PROJECT` | Queue an intake control command |
15
15
  | `stop RUN` | Queue cancellation; success means active local work has stopped |
16
+ | `recover RUN` | Continue a failed publication step using completed checkpoints |
16
17
  | `retry RUN` | Queue an explicit new attempt after checkout validation |
17
- | `monitor` | Attach an interactive terminal view |
18
+ | `monitor [--notify]` | Attach an interactive terminal view; optionally alert on outcomes |
18
19
 
19
20
  Control commands return a command ID and `pending`; inspect `status --json` or the monitor for success/failure. With no runner, commands stay pending. Run and monitor are separate processes. Closing the monitor never cancels work. Ctrl-C on the runner stops intake, cancels active work, waits for process termination and releases ownership. Queued issues remain durable for the next start.
20
21
 
21
- In the monitor, Left/Right selects a project, Up/Down a run, `[`/`]` a step/attempt event, Tab an agent invocation, `l` displays its log tail, `v` cycles validation logs, `p` pauses/resumes intake, `s` stops the selected run, `r` retries it, and `q` closes the view. Session IDs are displayed in full for terminal selection/copying. Outcomes, validation, profiles and session state use text as well as color. Noninteractive tools use `status --json` and `inspect`.
22
+ The monitor uses a full-screen view and restores the terminal when closed.
23
+ It refreshes persisted workflow state and open logs every 400 ms. Database
24
+ connectivity is shown separately from command acknowledgements; it does not
25
+ prove that a runner is alive. Requires an interactive terminal of at least
26
+ 80 columns by 24 rows. Wide terminals show run list, summary and sessions;
27
+ compact terminals show the focused pane. Titles and identifiers are available
28
+ in full in scrollable details. `NO_COLOR=1` disables semantic colors.
29
+
30
+ `monitor --notify` emits one desktop notification when an Execution first
31
+ reaches `completed`, `failed`, `blocked`, `cancelled`, `no-change` or
32
+ `ineligible` during that monitor session. The initial snapshot is silent;
33
+ later terminal Executions are detected across every visible project, including
34
+ Executions first seen after a database reconnection. Delivery uses OSC 9 and is
35
+ best-effort: notifications are not persisted, retried or acknowledged, and a
36
+ terminal write failure does not affect monitoring or workflow state. Current
37
+ iTerm2, Kitty, WezTerm and Ghostty releases are supported; other OSC 9
38
+ implementations may work, while Windows Terminal is not supported in this
39
+ version. Terminal permissions and settings determine whether an alert appears,
40
+ including whether foreground alerts are suppressed.
41
+
42
+ The notification payload is display-only and contains only
43
+ `agent-workflows: <project> · <issue reference> · <outcome>`. It excludes issue
44
+ titles, diagnostics, paths and internal Run, Execution and session identifiers.
45
+ Under tmux, the monitor emits one layer of DCS passthrough wrapping. tmux 3.3
46
+ and later requires `set -g allow-passthrough on`; the CLI does not change tmux
47
+ configuration.
48
+
49
+ Run details is one responsive, vertically scrollable document. It leads with
50
+ the issue, outcome, phase, attempt, total elapsed time and branch, and adds an
51
+ attention summary only when operator action may be required. At 140 columns
52
+ and above, execution history appears beside validation and agent-session
53
+ evidence; narrower terminals stack those sections in the same reading order.
54
+ The primary design target is 160×48, with 80×24 retained as the functional
55
+ fallback. An overflowing document shows its visible line range in the heading.
56
+
57
+ | Context | Keys |
58
+ | --- | --- |
59
+ | Dashboard | Left/Right project; Tab/Shift+Tab pane; Up/Down selection or scroll |
60
+ | Details | Enter opens; Up/Down or PgUp/PgDn scroll; Esc returns; `l` opens the latest current-execution session, preferring a running session |
61
+ | Progress | `[`/`]` inspect step history; End follows latest event |
62
+ | Sessions | `a` focuses session list; Up/Down selects invocation; `l` opens log |
63
+ | Validation | `v` opens validation logs |
64
+ | Controls | `p` pauses/resumes intake; `s` stops; `r` retries; `c` recovers publication |
65
+ | Monitor | `?` opens the shortcut dialog; `q` or Ctrl-C closes only the monitor |
66
+ | Shortcut dialog | Tab/Shift+Tab or Left/Right changes category; Up/Down scrolls; Esc closes |
67
+ | Logs | Up/Down or `j`/`k` scroll; PgUp/PgDn page; Left/Right pan long lines |
68
+ | Logs | Home/End or `g`/`G` first/last page; `f` resumes live follow |
69
+ | Logs | Tab selects next log; `R` toggles readable/raw presentation |
70
+ | Search | `/` opens; Enter applies; `n`/`N` next/previous matching record |
71
+ | Back | Esc dismisses search/help first, then returns from logs |
72
+
73
+ Stop, retry and publication recovery require confirmation of the selected issue;
74
+ The centered dialog defaults to Cancel. Tab/Shift+Tab or Left/Right switches
75
+ between Cancel and Confirm; Enter activates the highlighted option and Esc
76
+ cancels. Unavailable actions are omitted from the footer.
77
+ A pending command stays pending until the runner acknowledges it, including
78
+ while switching projects. Logs and search cannot send workflow commands.
79
+
80
+ Search is literal and covers the entire selected file, not only the visible page.
81
+ Lowercase queries ignore case; any uppercase character makes the query
82
+ case-sensitive. Search wraps at file boundaries. Scrolling or searching pauses
83
+ follow so arriving output does not move the view. Known agent events render as
84
+ readable messages/tool activity; unknown events remain visible as JSON. Raw
85
+ presentation preserves the stored text except unsafe terminal control codes.
86
+
87
+ Execution duration includes eligibility, preparation and waits within one
88
+ execution. It excludes queue waiting and gaps before publication recovery.
89
+ Details show each execution, its queue wait and the run's total elapsed time.
90
+ Completed execution durations freeze at their first terminal outcome. Records
91
+ without timing evidence use factual labels such as `not started`, `not recorded`
92
+ or `unavailable`. Noninteractive tools use `status --json` and `inspect`. Run
93
+ details keeps complete errors under Diagnostics and exact identifiers, paths,
94
+ profiles and ISO timestamps under Technical details.
95
+
96
+ ## Observability Landscape
97
+
98
+ This section includes only options that run locally without a license key.
99
+ Cloud services and tools requiring a license key are excluded. These boundaries
100
+ apply to observability; agent and hosting providers retain their own requirements.
101
+
102
+ | Option | Available information | Integration path |
103
+ | ------ | --------------------- | ---------------- |
104
+ | Project CLI/TUI | Run outcomes, phases, invocations, sessions and local logs | Built in: `monitor`, `status --json`, `inspect RUN`, `logs RUN` |
105
+ | DBOS SDK CLI | Durable workflow status and step history | Connect directly to the runner's PostgreSQL database |
106
+ | Project `Store` API | Application records and ordered events | Build a local script or dashboard using `runs`, `run`, `invocations`, `events` and `subscribe` |
107
+ | `DBOSClient` | DBOS workflow and step records | Build a local inspector using `getWorkflow`, `listWorkflows` and `listWorkflowSteps`; close it with `destroy()` |
108
+
109
+ For DBOS CLI inspection from this repository:
110
+
111
+ ```sh
112
+ pnpm exec dbos workflow list --sys-db-url "$AGENT_WORKFLOWS_DATABASE_URL"
113
+ pnpm exec dbos workflow get "<run-id>" --sys-db-url "$AGENT_WORKFLOWS_DATABASE_URL"
114
+ pnpm exec dbos workflow steps "<run-id>" --sys-db-url "$AGENT_WORKFLOWS_DATABASE_URL"
115
+ ```
116
+
117
+ Use the database URL selected by `config.databaseUrlEnv` if it differs from the
118
+ default above. These commands use the installed SDK CLI and require no running
119
+ Conductor service or cloud login. See the [DBOS CLI reference](https://docs.dbos.dev/typescript/reference/cli).
120
+
121
+ The initial DBOS workflow ID equals the run ID. Publication recovery keeps the
122
+ run ID and adds a new DBOS execution ID; `inspect RUN` includes execution history
123
+ and a persisted recovery eligibility assessment. Admission performs live checks.
124
+ Inspect both layers: the
125
+ runner catches execution errors and persists application outcomes, so a DBOS
126
+ `SUCCESS` can accompany an application `failed` or `blocked` outcome. DBOS step
127
+ history does not replace the local agent/validation artifacts.
128
+
129
+ A browser dashboard is an extension path, not a bundled feature. A local server
130
+ could combine the [Store query/event API](api.md#query-and-event-interface) with
131
+ `DBOSClient.create({ systemDatabaseUrl: databaseUrl })`, joining records by run ID.
132
+ Neither inspector needs to launch another DBOS runtime. Keep database access on
133
+ the server and bind a local-only dashboard to loopback. See the
134
+ [inspection example](../examples/observe.ts) for Store lifecycle handling.
135
+
136
+ Route dashboard controls through `Store.request` or the runner's public controls.
137
+ Direct DBOS cancellation, resumption or forking bypasses application coordination
138
+ for process termination, checkout safety and retry admission.
22
139
 
23
140
  ## Ownership and recovery
24
141
 
@@ -28,9 +145,41 @@ Git process journals live in `<git-directory>/agent-workflows-processes/`, indep
28
145
 
29
146
  Startup and phase boundaries check ownership assumptions, branch/head and actual changes. Unfinished files are never reset, cleaned, stashed or discarded automatically. Dirty files, unresolved Git operations, branch collisions, unexpected mutations and ambiguous agent recovery become inspectable blocked states. Other eligible projects continue.
30
147
 
31
- Publication effects have independent DBOS checkpoints. A task commit carries `Agent-Workflows-Run`; commit recovery checks parent and marker, push recovery checks the remote ref, request creation checks the source branch, and review publication checks stable markers. Transient publication failures use bounded retries and reconciliation. Interrupted agent stages block rather than starting another writer.
32
-
33
- After a blocked/failed task:
148
+ Publication effects have independent DBOS checkpoints. A task commit preserves
149
+ publication trailers, carries exactly one `Agent-Workflows-Run`, and by default
150
+ adds co-author trailers for providers with retained writable contributions.
151
+ Commit reconciliation checks the expected parent, change set, finalized message,
152
+ and clean checkout. Push recovery checks the remote ref, request creation checks
153
+ the source branch, and review publication checks stable markers. Transient
154
+ publication failures use bounded retries and reconciliation. Interrupted agent
155
+ stages block rather than starting another writer.
156
+
157
+ ## Publication recovery
158
+
159
+ For the default workflow, `recover RUN` continues a run whose latest execution
160
+ failed at `push`, `change-request`, or `review-publication`. It reuses completed
161
+ checkpoints, keeps the branch, commit and publication markers, and gives the
162
+ failed step three new attempts. Later steps execute normally. Each execution
163
+ retains its outcome, error and source execution; a repeated command ID identifies
164
+ the same recovery.
165
+
166
+ Keep the original branch and commit checked out with a clean working tree.
167
+ Recovery verifies process ownership, complete checkpoint history, local artifacts,
168
+ remote revision, workflow version, configuration and skill contents. Environment
169
+ credential rotation is allowed. Changed code or execution inputs require a fresh
170
+ retry. Recovery honors project pause and never removes an existing project block.
171
+ Checks run again inside the first step that executes, including after a crash.
172
+
173
+ Use `inspect RUN` before recovery and check command outcomes afterward. Monitor
174
+ shows execution history and the recovery restriction, if any. Eligibility based
175
+ on persisted records is provisional until the runner finishes live checks.
176
+
177
+ Agent/validation failures, cancelled or blocked runs, custom workflows, and older
178
+ runs without recovery metadata use the existing inspection and fresh-retry path.
179
+ Recovery does not restore checkouts or accept arbitrary restart steps. A newer
180
+ fresh attempt supersedes recovery of the older run.
181
+
182
+ After a blocked/failed task that cannot be recovered:
34
183
 
35
184
  1. Read `inspect RUN`, logs, session IDs and the local Git diff.
36
185
  2. Establish that no worker/process group is still running. If startup reports an old PID or process journal, inspect that exact process and stop it before recovery. Never remove a live owner's lease.
@@ -41,6 +190,12 @@ A failed review after publication remains a failed automation attempt, even if i
41
190
 
42
191
  ## Evidence and limits
43
192
 
193
+ Git hooks are disabled for application-authored task commits; configure required checks as validation commands. Changed symlinks and submodules require manual handling. Checkout checks detect boundary changes but do not sandbox custom adapters or prevent unrelated local tools from writing.
194
+
195
+ Git chooses author and committer through its normal configuration and environment
196
+ rules. Runner startup performs no identity preflight; missing identity fails at
197
+ the commit step before push or hosting publication.
198
+
44
199
  Validation records say exactly which command ran, when, its exit code and artifact path. No-change work skips publication. Generated commit/request text is validated and saved before Git/API writes. Logs, prompts and errors redact configured credentials and recognized secret environment values; this does not sanitize arbitrary repository content or secrets unknown to the runner.
45
200
 
46
201
  Back up both PostgreSQL and the state directory if history/artifacts matter. The checkout and runtime session stores are separate local state. Losing them cannot be repaired from DBOS checkpoints alone. Do not change a custom workflow's step order or rename projects while its runs are pending; use a new workflow version and finish or explicitly resolve existing runs first.
package/docs/providers.md CHANGED
@@ -6,7 +6,7 @@ Authenticate the selected local agent runtime before starting. Codex SDK uses th
6
6
 
7
7
  | Capability | Codex | Copilot |
8
8
  | ------------------------------------------- | -------------------------------------------------------------------- | ----------------------------------------------------------------- |
9
- | Implementation, writing, independent review | SDK fresh thread | SDK fresh session |
9
+ | Implementation, publication, independent review | SDK fresh thread | SDK fresh session |
10
10
  | Explicit model/effort validation | Runtime model cache or injected catalog | SDK model catalog or injected catalog |
11
11
  | Runtime context controls | Rejected | Compaction/exhaustion utilization fractions |
12
12
  | Structured publication/review | Application JSON schema validation | Application JSON schema validation |
@@ -19,9 +19,48 @@ Codex implementation uses its workspace-write sandbox. Copilot implementation ap
19
19
 
20
20
  The runner deliberately does not automatically resume interrupted agent work. Runtime session existence does not establish whether old processes are still writing. Use runtime-specific tools/SDKs to inspect sessions after stopping the runner and establishing ownership; there is no universal session-opening command.
21
21
 
22
+ ## Environment inheritance
23
+
24
+ CLI `--env-file` values reach validation commands, Git subprocesses and agent
25
+ workers through the runner's process environment. SDK callers get the same
26
+ inheritance from their own process environment. The installed Codex SDK forwards
27
+ that environment to its executable; Copilot uses it for its local runtime, with
28
+ SDK-specific adjustments such as removing `NODE_DEBUG`.
29
+
30
+ Commands launched inside a provider remain subject to its runtime configuration.
31
+ For example, Codex's [shell environment policy](https://developers.openai.com/codex/config-advanced/#shell-environment-policy)
32
+ can filter or replace inherited values. The CLI does not override these policies
33
+ or inject environment values into an already-running remote Copilot runtime.
34
+ Controlled executable tests cover the SDK worker boundary; live model-driven
35
+ shell-tool inheritance requires the explicit smoke verification below.
36
+
22
37
  ## GitHub
23
38
 
24
- Set `hosting.origin` to `https://github.com` or the GitHub Enterprise web origin. Repository is `owner/name`; the adapter derives the REST endpoint. `tokenEnv` names the environment variable holding a token authorized to read issues and create change requests/reviews. Git push uses the checkout's configured remote and Git credentials, independently of the API token. Do not embed credentials in remote URLs.
39
+ Set `hosting.origin` to `https://github.com` or the GitHub Enterprise web origin. Repository is `owner/name`; the adapter derives the REST endpoint. `hosting.tokenEnv` names the environment variable holding the API token, for example `GITHUB_TOKEN`.
40
+
41
+ ### Create a fine-grained personal access token
42
+
43
+ In GitHub **Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate new token**:
44
+
45
+ 1. Set an expiration and choose the repository's user or organization as **Resource owner**.
46
+ 2. Under **Repository access**, choose **Only select repositories** and select the configured `owner/name`, including for a public repository.
47
+ 3. Under **Repository permissions**, grant:
48
+
49
+ | Permission | Access | Used for |
50
+ | ---------- | ------ | -------- |
51
+ | Issues | Read-only | List and recheck issues for intake |
52
+ | Pull requests | Read and write | Find/create draft PRs, check their head, and publish reviews with inline comments |
53
+ | Metadata | Read-only (automatically included) | Required baseline repository access |
54
+
55
+ 4. Generate the token and store it through your secret manager in the variable named by `hosting.tokenEnv`. If organization approval is required, wait for approval before starting the runner; pending tokens can only read public resources.
56
+
57
+ **Pull requests must be Read and write.** Reading issues or pushing a branch successfully does not establish permission to create a PR. Missing PR write access can fail the `change-request` step with `Resource not accessible by personal access token` after implementation has completed.
58
+
59
+ Git push uses the checkout's configured remote and Git credentials independently of this API token. The API adapter does not require **Contents** permission. If you also use this PAT for HTTPS Git pushes, grant **Contents: Read and write**; pushing changes to `.github/workflows/` additionally requires **Workflows: Read and write**. Do not embed credentials in remote URLs.
60
+
61
+ If access is denied, check the selected owner/repository, PR write permission, token expiration, organization approval, and the token owner's repository access. If you replace the token value, restart the runner with the updated environment; existing environment variables override `--env-file` values. An already failed run requires explicit [recovery](operations.md#ownership-and-recovery); updating permissions does not restart it.
62
+
63
+ References: GitHub's [PAT creation guide](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), [issue permissions](https://docs.github.com/en/rest/issues/issues#list-repository-issues), [PR creation permissions](https://docs.github.com/en/rest/pulls/pulls#create-a-pull-request), and [review permissions](https://docs.github.com/en/rest/pulls/reviews#create-a-review-for-a-pull-request).
25
64
 
26
65
  Issue intake paginates and excludes PRs. Publications default to draft. Reviews use the exact commit ID and right-side added lines where valid; other findings appear in the summary.
27
66
 
@@ -47,3 +86,20 @@ Draft MRs use the supported `Draft:` title prefix. Revision-bound inline discuss
47
86
  ## Explicit smoke verification
48
87
 
49
88
  Real-provider smoke tests are opt-in manual runs: configure a disposable repository/issue, authenticated agent, hosting token, Git push access and validation; run one project; inspect the draft request, exact-head review and session records. This performs paid agent usage and real remote writes. The automated acceptance evidence is fixture-based, not a claim of live-provider compatibility or account access.
89
+
90
+ ## Structured output and evidence access
91
+
92
+ Codex receives the application output schema through `runStreamed` options.
93
+ Copilot receives generated JSON instructions; common strict validation gates both
94
+ providers. Stage task text cannot remove those checks. Both retain their existing
95
+ inspection permissions: Codex's read-only sandbox and Copilot's read-only
96
+ permission handler (`approve-once` for reads, `reject` for non-read requests).
97
+ Managed human-approval requirements remain denied. No shell permission is added
98
+ for Copilot.
99
+
100
+ Evidence indexes use absolute paths outside the checkout. Controlled tests check
101
+ schema mapping, outside-directory reads and denied write/shell requests. The
102
+ optional `AGENT_WORKFLOWS_LIVE_AGENTS=codex,copilot` test checks actual runtime
103
+ file-reader access using the authenticated local providers; it is separate from
104
+ local fixture acceptance. Missing runtime authentication is a live-test failure,
105
+ not evidence of successful provider access.
package/docs/releases.md CHANGED
@@ -2,88 +2,43 @@
2
2
 
3
3
  One public npm package, `@mingchuno/agent-workflows`, contains the SDK and
4
4
  `agent-workflows` CLI/TUI. Release Please opens a version/changelog PR from
5
- Conventional Commits on `main`. Review and merge that PR to create its GitHub
6
- release and publish to npm when enabled. The first release is `0.1.0`; fixes
7
- bump patch, features bump minor, and breaking changes bump minor before 1.0.
8
-
9
- ## GitHub setup
10
-
11
- - Add this repository to the existing release GitHub App installation. It needs
12
- Contents, Pull requests and Issues read/write. Store `RELEASE_APP_ID` and
13
- `RELEASE_APP_PRIVATE_KEY` as repository Actions secrets. Tokens are scoped to
14
- this repository; no webhook server is needed. App-created release PRs trigger CI.
15
- - Enable squash merging with the PR title and description as the commit message.
16
- Protect `main` with the `check` and `commitlint` checks after their first run.
17
- Preserve `!` or `BREAKING CHANGE:` when squashing breaking changes.
18
- - Create the `npm` environment with deployment branches restricted to `main`.
19
- Required reviewers are optional: merging the release PR is the normal release
20
- decision; environment reviewers would add a second publishing approval.
21
- - Leave the repository variable `NPM_PUBLISH_ENABLED` unset until npm setup is
22
- complete. Setting it to `true` enables subsequent automatic publications.
23
-
24
- ## First publication and npm setup
25
-
26
- The maintainer must control the `@mingchuno` npm scope and have account 2FA.
27
- The package must exist before configuring its trusted publisher.
28
-
29
- 1. Merge the implementation, let Release Please open its first release PR, then
30
- review and merge the proposed `0.1.0` release. Keep automated publishing disabled.
31
- 2. In a clean checkout of tag `v0.1.0`, install the pinned tools and dependencies,
32
- then verify and test the package:
33
-
34
- ```sh
35
- mise trust
36
- mise install
37
- mise exec -- pnpm install --frozen-lockfile
38
- mise exec -- pnpm verify
39
- mise exec -- pnpm pack:smoke
40
- ```
41
-
42
- The smoke test leaves `.artifacts/mingchuno-agent-workflows-0.1.0.tgz`.
43
- Authenticate interactively and publish that tested tarball:
44
-
45
- ```sh
46
- mise exec -- pnpm exec npm login --registry=https://registry.npmjs.org/
47
- mise exec -- pnpm exec npm publish .artifacts/mingchuno-agent-workflows-0.1.0.tgz --access public --ignore-scripts --registry=https://registry.npmjs.org/
48
- ```
49
-
50
- 3. In the npm package settings, add a GitHub Actions trusted publisher:
51
-
52
- | Field | Value |
53
- | --- | --- |
54
- | Owner | `mingchuno` |
55
- | Repository | `agent-workflows` |
56
- | Workflow filename | `release.yml` |
57
- | Environment | `npm` |
58
- | Publication permission | Allow direct `npm publish` |
59
-
60
- 4. Set GitHub repository variable `NPM_PUBLISH_ENABLED=true`. The next releasable
61
- change exercises OIDC; the manual first publication does not verify it.
62
-
63
- The GitHub App manages releases; npm OIDC authenticates publication independently.
64
- No `NPM_TOKEN` is required. The publishing job uses a GitHub-hosted runner,
65
- `id-token: write`, and pinned npm 12. Public repository/package visibility enables
66
- automatic provenance. See [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/).
5
+ Conventional Commits on `main`. Merging that PR creates a GitHub release and,
6
+ when `NPM_PUBLISH_ENABLED=true`, publishes to npm. Fixes bump patch, features
7
+ bump minor, and breaking changes bump minor before 1.0.
8
+
9
+ ## Configuration
10
+
11
+ - The release GitHub App needs Contents, Pull requests and Issues read/write.
12
+ Actions secrets `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY` provide its
13
+ credentials. App-created release PRs trigger CI.
14
+ - Squash commits use the PR title and description. Protect `main` with `check`
15
+ and `commitlint`; preserve `!` or `BREAKING CHANGE:` for breaking changes.
16
+ - The `npm` environment restricts deployment to `main`. Environment reviewers
17
+ are optional; merging the release PR is the normal release decision.
18
+ - npm trusted publishing uses GitHub Actions owner `mingchuno`, repository
19
+ `agent-workflows`, workflow `release.yml`, environment `npm`, and permission
20
+ to publish directly. It authenticates independently of the GitHub App via
21
+ OIDC; no `NPM_TOKEN` is required. See [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/).
22
+ - The repository variable `NPM_PUBLISH_ENABLED=true` enables publication.
23
+ Unset it or set it to `false` to pause future publishing. Inspect active runs
24
+ separately: they may already have evaluated the switch.
67
25
 
68
26
  ## Verification and recovery
69
27
 
70
- `pnpm verify` runs type checking, linting, release guard tests and the existing
71
- PostgreSQL-backed application tests. `pnpm pack:smoke` additionally needs registry
72
- access: it installs the tarball in a temporary consumer, checks SDK imports and
73
- TypeScript resolution, runs the CLI, and applies migrations to an isolated database.
74
- Both commands use disposable local PostgreSQL or `TEST_DATABASE_URL`; its role must
75
- be able to create test databases. Neither invokes paid agents or real hosting writes.
28
+ The publishing job runs `pnpm verify` and `pnpm pack:smoke` at the release commit.
29
+ The smoke test installs the tarball in a temporary consumer, checks SDK imports
30
+ and TypeScript resolution, runs the CLI, and applies migrations to an isolated
31
+ database. It needs registry access and the [development test prerequisites](../README.md#development-and-review).
32
+ Neither command invokes paid agents or writes to real hosting providers.
76
33
 
77
- Publishing checks the tag, release SHA, package version and tested tarball integrity.
78
- It publishes the same tarball that passed the smoke test. Release runs are serialized
79
- and never cancelled by newer pushes.
34
+ Publishing checks the tag, release SHA, package version and tested tarball
35
+ integrity, then publishes that same tarball. Release runs are serialized and
36
+ never cancelled by newer pushes.
80
37
 
81
38
  After a publishing failure, choose **Re-run failed jobs** on that Actions run to
82
- retain the release outputs and commit. An existing npm version is skipped only when
83
- its integrity matches; differing contents require a new version. Re-running the
84
- whole workflow or dispatching a new run may find no new release and skip publishing.
85
- If Release Please failed after creating a tag, inspect the existing release before
86
- recovering; never overwrite a published version or delete a release tag to retry.
87
-
88
- To pause future publishing, unset `NPM_PUBLISH_ENABLED` or set it to `false`.
89
- Inspect active runs separately: they may already have evaluated the switch.
39
+ retain the release outputs and commit. An existing npm version is skipped only
40
+ when its integrity matches; differing contents require a new version. Re-running
41
+ the whole workflow or dispatching a new run may find no new release and skip
42
+ publishing. If Release Please failed after creating a tag, inspect the existing
43
+ release before recovering; never overwrite a published version or delete a
44
+ release tag to retry.