@defrex/autobuild 1.1.0 → 1.2.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 (114) hide show
  1. package/README.md +5 -13
  2. package/SPEC.md +140 -10
  3. package/bin/ab-dispatch-generation.ts +11 -2
  4. package/docs/accounts.md +119 -0
  5. package/docs/agent-runtimes.md +4 -4
  6. package/docs/architecture.md +107 -8
  7. package/docs/build-store.md +3 -41
  8. package/docs/cli.md +14 -0
  9. package/docs/configuration-overview.md +111 -0
  10. package/docs/configuration.md +260 -141
  11. package/docs/dispatcher-hosting.md +18 -33
  12. package/docs/intake.md +2 -0
  13. package/docs/merge-policy.md +1 -3
  14. package/docs/operating.md +1 -2
  15. package/docs/operator-api.md +100 -47
  16. package/docs/operator-surfaces.md +3 -20
  17. package/docs/overview.md +1 -1
  18. package/docs/plugin-authoring.md +21 -0
  19. package/docs/remote-store-protocol.md +198 -89
  20. package/docs/remote-ticket-protocol.md +29 -49
  21. package/docs/seams.md +8 -8
  22. package/docs/setup.md +34 -129
  23. package/docs/ticket-sources.md +18 -0
  24. package/docs/troubleshooting.md +7 -11
  25. package/docs/upgrading.md +1 -1
  26. package/docs/workspaces.md +4 -4
  27. package/package.json +14 -5
  28. package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
  29. package/packages/core/src/accounts/chatgpt-state.ts +41 -0
  30. package/packages/core/src/accounts/local-credentials.ts +194 -0
  31. package/packages/core/src/accounts/local-inference.ts +106 -0
  32. package/packages/core/src/accounts/local-owner.ts +123 -0
  33. package/packages/core/src/accounts/sensitive.ts +2 -0
  34. package/packages/core/src/cli/accounts.ts +147 -0
  35. package/packages/core/src/cli/binary.ts +3 -1
  36. package/packages/core/src/cli/connect.ts +3 -3
  37. package/packages/core/src/cli/dispatch-handoff.ts +125 -44
  38. package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
  39. package/packages/core/src/cli/dispatch-launcher.ts +54 -21
  40. package/packages/core/src/cli/dispatch-preflight.ts +6 -1
  41. package/packages/core/src/cli/dispatch.ts +71 -2
  42. package/packages/core/src/cli/help.ts +16 -0
  43. package/packages/core/src/cli/init-readiness-remote.ts +22 -1
  44. package/packages/core/src/cli/init-readiness-shared.ts +5 -1
  45. package/packages/core/src/cli/init-validation.ts +160 -18
  46. package/packages/core/src/cli/main.ts +44 -0
  47. package/packages/core/src/cli/publication-settlement.ts +4 -1
  48. package/packages/core/src/cli/secrets.ts +173 -0
  49. package/packages/core/src/cli/store-opening.ts +11 -1
  50. package/packages/core/src/cli/upgrade-agent.ts +9 -1
  51. package/packages/core/src/cli/watch.ts +3 -1
  52. package/packages/core/src/config/accounts.ts +101 -0
  53. package/packages/core/src/config/live.ts +14 -1
  54. package/packages/core/src/config/roles.ts +54 -3
  55. package/packages/core/src/config/schema.ts +60 -0
  56. package/packages/core/src/events/compatibility.ts +2 -1
  57. package/packages/core/src/events/payloads.ts +3 -0
  58. package/packages/core/src/events/repository.ts +2 -0
  59. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +3 -0
  60. package/packages/core/src/kernel/reducer.ts +4 -1
  61. package/packages/core/src/operator/index.ts +2 -0
  62. package/packages/core/src/operator/protocol.ts +6 -0
  63. package/packages/core/src/operator/registry.ts +22 -1
  64. package/packages/core/src/operator/tickets.ts +25 -4
  65. package/packages/core/src/plugins/manifest.ts +2 -1
  66. package/packages/core/src/ports/runner/account-env.ts +88 -0
  67. package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
  68. package/packages/core/src/ports/runner/claude.ts +26 -2
  69. package/packages/core/src/ports/runner/codex.ts +63 -31
  70. package/packages/core/src/ports/runner/one-shot.ts +2 -0
  71. package/packages/core/src/ports/runner/provider-error.ts +5 -0
  72. package/packages/core/src/ports/runner/routing.ts +35 -4
  73. package/packages/core/src/ports/tickets/contract.ts +58 -0
  74. package/packages/core/src/ports/tickets/tree.ts +1 -1
  75. package/packages/core/src/ports/types.ts +28 -7
  76. package/packages/core/src/ports/workspace/account-policy.ts +72 -0
  77. package/packages/core/src/ports/workspace/build-execution.ts +6 -1
  78. package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
  79. package/packages/core/src/ports/workspace/create.ts +2 -0
  80. package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
  81. package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
  82. package/packages/core/src/ports/workspace/vercel-sandbox.ts +125 -35
  83. package/packages/core/src/processes/build-runner.ts +32 -1
  84. package/packages/core/src/processes/dispatcher.ts +23 -0
  85. package/packages/core/src/processes/execution-settlement.ts +21 -3
  86. package/packages/core/src/processes/harvest-runner.ts +68 -8
  87. package/packages/core/src/project-secrets.ts +105 -0
  88. package/packages/core/src/secret-name.ts +41 -0
  89. package/packages/core/src/store/account-redaction.ts +156 -0
  90. package/packages/core/src/store/contract.ts +3 -1
  91. package/packages/core/src/store/reducer-value-shapes.json +2889 -2781
  92. package/packages/core/src/store/remote/client.ts +42 -47
  93. package/packages/core/src/store/remote/compatibility.ts +18 -0
  94. package/packages/core/src/testing/dispatch-read-budget.ts +122 -0
  95. package/packages/core/src/testing/index.ts +1 -0
  96. package/packages/core/src/testing/reduced-read-budget.ts +47 -0
  97. package/skills/guide/SKILL.md +120 -30
  98. package/skills/guide/references/accounts.md +119 -0
  99. package/skills/guide/references/merge-policy.md +1 -3
  100. package/skills/guide/references/operator-api.md +100 -47
  101. package/skills/guide/references/plugin-authoring.md +21 -0
  102. package/skills/guide/references/remote-store-protocol.md +198 -89
  103. package/skills/guide/references/remote-ticket-protocol.md +29 -49
  104. package/skills/guide/references/setup.md +34 -129
  105. package/skills/harvest/SKILL.md +3 -1
  106. package/skills/harvest-review/SKILL.md +3 -1
  107. package/skills/operate/SKILL.md +5 -6
  108. package/skills/spec/SKILL.md +1 -1
  109. package/skills/tickets/SKILL.md +3 -2
  110. package/templates/hosted-service/package.json +2 -2
  111. package/docs/hosted-dispatcher-cutover-validation.md +0 -178
  112. package/docs/hosted-dispatcher.md +0 -278
  113. package/docs/hosted-service.md +0 -304
  114. package/docs/mcp.md +0 -150
@@ -39,9 +39,10 @@ bun ab builds --store /srv/autobuild/project-store
39
39
 
40
40
  Keep the database and blob directory together, durable and writable by the dispatcher identity.
41
41
 
42
- ### Postgres with object storage
42
+ ### Remote HTTP client and protocol
43
43
 
44
- The server-side `@defrex/autobuild-postgres-store` package persists to PostgreSQL plus S3-compatible storage or Vercel Blob. The CLI never connects to PostgreSQL directly (no `[store] provider`); a repository selects the HTTP service:
44
+ A hosted instance must implement the remote BuildStore protocol.
45
+ The CLI connects over HTTP, never directly to a database.
45
46
 
46
47
  <!-- seam-config:start -->
47
48
  ```toml
@@ -54,45 +55,6 @@ readyState = "ready"
54
55
  ```
55
56
  <!-- seam-config:end -->
56
57
 
57
- In the service project:
58
-
59
- ```sh
60
- bun add @defrex/autobuild-postgres-store
61
- export DATABASE_URL='<postgres connection URL>'
62
- # AB_POSTGRES_URL overrides DATABASE_URL when nonblank.
63
- ```
64
-
65
- ```ts
66
- import { openPostgresBuildStoreFromEnv } from '@defrex/autobuild-postgres-store'
67
-
68
- const store = await openPostgresBuildStoreFromEnv(process.env)
69
- ```
70
-
71
- - **Migrate first** with the matching release's idempotent migration. Migration needs schema-creation permission; runtime needs access to the resulting tables.
72
- - **One blob backend.** S3 needs a bucket, prefix and GetObject/PutObject credentials; Vercel Blob needs a read-write token, or an OIDC identity plus store ID.
73
- - **Database and blob secrets** never leave the service.
74
-
75
- ```sh
76
- # S3-compatible storage
77
- export AB_BLOB_BACKEND='s3'
78
- export AB_S3_BUCKET='autobuild-artifacts'
79
- export AB_S3_REGION='us-east-1'
80
- export AB_S3_ACCESS_KEY_ID='<object-store identity>'
81
- export AB_S3_SECRET_ACCESS_KEY='<object-store secret>'
82
- # Optional: AB_S3_ENDPOINT, AB_S3_FORCE_PATH_STYLE, AB_S3_SESSION_TOKEN, AB_BLOB_PREFIX
83
- ```
84
-
85
- ```sh
86
- # Alternatively, Vercel Blob
87
- export AB_BLOB_BACKEND='vercel'
88
- export AB_VERCEL_BLOB_ACCESS='private'
89
- export BLOB_READ_WRITE_TOKEN='<blob read-write token>'
90
- # Or supply VERCEL_OIDC_TOKEN and BLOB_STORE_ID together instead of the token.
91
- ```
92
-
93
-
94
- ### Remote HTTP client and service
95
-
96
58
  `[store] url` selects the shipped HTTP client. Connect once per host and user, from a checkout with the intended origin:
97
59
 
98
60
  ```sh
package/docs/cli.md CHANGED
@@ -11,11 +11,14 @@ Run `bun ab <command>`; `bun ab help <command>` lists flags and subcommands. See
11
11
 
12
12
  ## For you
13
13
 
14
+ - `accounts` — Authorize a ChatGPT subscription for a local dispatcher or connected project.
15
+
14
16
  - `dispatch` — Run the dispatcher and dashboard.
15
17
  - `init` — Install skills and hand setup to a coding agent.
16
18
  - `upgrade` — Update Autobuild and merge default skills.
17
19
  - `connect` — Connect to a hosted service with browser approval.
18
20
  - `disconnect` — Revoke and remove the saved credential.
21
+ - `secrets` — List metadata, set or remove write-only project secrets. Project members and super users can also use the web Settings tab; renewing refreshing ChatGPT credentials stays in `ab accounts login <account> --project`.
19
22
 
20
23
  ## For your operator agent
21
24
 
@@ -46,3 +49,14 @@ Run `bun ab <command>`; `bun ab help <command>` lists flags and subcommands. See
46
49
  - `harvest` — Inspect or drive observation harvesting.
47
50
 
48
51
  Phase commands (`context`, `done`, `verdict`) use runner-scoped session authority: the runner starts phase agents, never your operator agent. See [Skills](skills.md).
52
+
53
+
54
+ Permanent hosted data removal is available on the web app's Projects page to
55
+ super users and owners of the project's organization. `ab disconnect` only
56
+ revokes a credential; admin `projects remove` only unregisters access and retains
57
+ data. Project deletion removes hosted builds, tickets, blobs, secrets and accounts,
58
+ revokes every credential and retains only a minimal deletion audit. It does not
59
+ change local files or configuration. Failed cleanup is retryable with access
60
+ already refused. Reconnecting requires fresh browser approval and starts empty,
61
+ with hosted ticket numbering reset to 1. See
62
+ [permanent project deletion](operator-api.md#permanent-project-deletion).
@@ -64,6 +64,117 @@ sessionBudgetSeconds = 3600
64
64
  - **Policy limits** bound review rounds, retries and session budgets, and decide when automation stops for attention.
65
65
 
66
66
 
67
+ ## Accounts
68
+
69
+ Named accounts select billing for Claude Code or Codex, using the user's own
70
+ subscription within ordinary individual usage. Claude and Kimi credentials are
71
+ provisioned manually; Autobuild never runs `claude setup-token`. ChatGPT
72
+ accounts use OpenAI's browser authorization through the CLI.
73
+
74
+ ```toml
75
+ [accounts.personal]
76
+ kind = "claude-subscription"
77
+ credentialEnv = "CLAUDE_CODE_OAUTH_TOKEN"
78
+
79
+ [accounts.kimi]
80
+ kind = "kimi-code"
81
+ credentialEnv = "KIMI_CODE_KEY"
82
+ region = "overseas"
83
+
84
+ [accounts.kimi-china]
85
+ kind = "kimi-code"
86
+ credentialEnv = "KIMI_CHINA_KEY"
87
+ region = "china"
88
+
89
+ [roles.implement]
90
+ runtime = "claude"
91
+ account = "kimi"
92
+ model = "kimi-for-coding"
93
+ ```
94
+
95
+ `account` inherits independently on roles and alternates. Without an explicit
96
+ selection, a Claude route chooses the sole Claude subscription account; multiple
97
+ subscription accounts require an explicit selection. ChatGPT accounts require explicit selection on Codex; Claude and Kimi accounts
98
+ require Claude Code. Incompatible runtime selections are rejected. Repositories with no accounts retain legacy authentication.
99
+ Locally a Claude subscription can use its named token or the host login; Kimi
100
+ requires its membership key. Invalid credentials need renewal (`claude setup-token`
101
+ for Claude, replacement membership key for Kimi); quota and overload failures
102
+ retain alternate fallback.
103
+
104
+ Choose the region of your Kimi membership. The default `overseas` selects
105
+ `https://api.kimi.ai/coding/`; `china` selects `https://api.kimi.com/coding/`.
106
+ The base URL and egress hostname are fixed together and cannot be overridden
107
+ independently. There is no cross-region retry or assertion that keys work across
108
+ regions. Claude Code keeps its native User-Agent.
109
+
110
+ In Vercel Sandbox the guest holds stable nonsecret placeholders, including when
111
+ credential variables are explicitly allowlisted. The host egress policy replaces
112
+ an exact account placeholder header only on its provider's exact hostname.
113
+ The next dispatcher observation tick refreshes credentials for subsequent
114
+ requests without reprovisioning. Changing a local dispatcher's `.env` still needs
115
+ a restart. Accounts are deployment-owned descriptors; configuration artifacts
116
+ contain variable names, never values. Validation reports host credential presence
117
+ and makes one minimal request using each account's actual runtime, including
118
+ unused accounts, in the disposable sandbox. Hosted ChatGPT credentials use the
119
+ metadata readiness boundary described below.
120
+
121
+
122
+ ## ChatGPT subscriptions
123
+
124
+ ChatGPT Plus and Pro are eligible for [Sign in with ChatGPT](https://developers.openai.com/siwc/quickstart).
125
+ Authorization grants plan usage for eligible Responses requests; it does not
126
+ grant access to ChatGPT conversations. Included usage is shared with the plan
127
+ and other authorized apps. Plan exhaustion retains configured alternate fallback.
128
+
129
+ ```toml
130
+ [accounts.chatgpt]
131
+ kind = "chatgpt-subscription"
132
+ credentialEnv = "CHATGPT_ACCESS_TOKEN"
133
+
134
+ [roles.implement]
135
+ runtime = "codex"
136
+ account = "chatgpt"
137
+ ```
138
+
139
+ Run `bun ab accounts login chatgpt --local` on your own machine for a local
140
+ dispatcher, or `bun ab accounts login chatgpt --project` for a connected
141
+ project. Without a destination flag, connected projects choose project storage;
142
+ others choose local storage. The destination is shown before the browser opens.
143
+ OpenAI handles consent and authorization. No token is printed.
144
+
145
+ Local credentials live in protected, ignored main-checkout
146
+ `.autobuild/accounts/` state shared by worktrees. Project sign-in transfers
147
+ credentials directly to the encrypted refreshing project secret named by
148
+ `credentialEnv`; it retains no renewable credential locally. This name
149
+ identifies a host access-token slot, not a refresh token supplied in TOML.
150
+ ChatGPT accounts must use slots distinct from every other account. Existing
151
+ ChatGPT descriptors cannot change during live configuration reload; stop dispatch
152
+ before replacing a descriptor, or introduce a new account name.
153
+
154
+ The stable opaque host identifier belongs to the destination; the issued
155
+ client identifier belongs to the authorized ChatGPT registration. Reauthorization
156
+ keeps identity and registration associated. Never copy the ambient Codex login.
157
+
158
+ Exactly one owner refreshes each connection: the local dispatcher or the
159
+ hosted refreshing secret. Credentials rotate atomically before delivery.
160
+ Sandboxes hold stable placeholders; only an exact bearer match on
161
+ `api.openai.com` receives the current access token at egress. Local Codex uses
162
+ an isolated CODEX_HOME and a capability-protected loopback Responses forwarder which
163
+ reads current durable state and never refreshes.
164
+
165
+ A failed or uncertain refresh is terminal for that credential generation.
166
+ Sign in again with `bun ab accounts login chatgpt` for the same destination;
167
+ do not retry the old refresh token. Token rejection raises account-specific
168
+ attention rather than an alternate or retry loop.
169
+
170
+ For local credentials, `bun ab init --validate` checks the owner and current
171
+ credential and makes a minimal Codex request. Validation uses a temporary
172
+ exclusive ownership claim only when no dispatcher owns the record. For hosted
173
+ project credentials it uses write-only metadata: presence, owner, set time,
174
+ refresh status and any refresh-window warning. It never downloads tokens.
175
+ **The first hosted build is the live check.** A short refresh-window warning is
176
+ advisory and does not revoke a still-valid credential.
177
+
67
178
  ## Admission and merge
68
179
 
69
180
  - **Tickets.** `[tickets]` sets the source and readiness criteria for admitting work.