@percher/core 0.3.0 → 0.4.1
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.
- package/dist/commands/account.d.ts +24 -14
- package/dist/commands/account.d.ts.map +1 -1
- package/dist/commands/account.js +17 -4
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/admin-reconcile-routes.d.ts +18 -0
- package/dist/commands/admin-reconcile-routes.d.ts.map +1 -0
- package/dist/commands/admin-reconcile-routes.js +22 -0
- package/dist/commands/admin-reconcile-routes.js.map +1 -0
- package/dist/commands/ai-files.d.ts +5 -17
- package/dist/commands/ai-files.d.ts.map +1 -1
- package/dist/commands/ai-files.js +3 -4
- package/dist/commands/ai-files.js.map +1 -1
- package/dist/commands/alerts.d.ts +69 -0
- package/dist/commands/alerts.d.ts.map +1 -0
- package/dist/commands/alerts.js +80 -0
- package/dist/commands/alerts.js.map +1 -0
- package/dist/commands/app-resources.d.ts +30 -0
- package/dist/commands/app-resources.d.ts.map +1 -0
- package/dist/commands/app-resources.js +34 -0
- package/dist/commands/app-resources.js.map +1 -0
- package/dist/commands/app-topology.d.ts +18 -0
- package/dist/commands/app-topology.d.ts.map +1 -0
- package/dist/commands/app-topology.js +25 -0
- package/dist/commands/app-topology.js.map +1 -0
- package/dist/commands/billing.d.ts +8 -8
- package/dist/commands/billing.d.ts.map +1 -1
- package/dist/commands/billing.js +1 -1
- package/dist/commands/billing.js.map +1 -1
- package/dist/commands/continue.d.ts +1 -1
- package/dist/commands/create.d.ts +2 -12
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +1 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dashboard.d.ts +2 -8
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/data-export.d.ts +2 -8
- package/dist/commands/data-export.d.ts.map +1 -1
- package/dist/commands/data-export.js +1 -1
- package/dist/commands/data-export.js.map +1 -1
- package/dist/commands/data.d.ts +2 -8
- package/dist/commands/data.d.ts.map +1 -1
- package/dist/commands/data.js +1 -1
- package/dist/commands/data.js.map +1 -1
- package/dist/commands/delete.d.ts +2 -8
- package/dist/commands/delete.d.ts.map +1 -1
- package/dist/commands/delete.js +1 -1
- package/dist/commands/delete.js.map +1 -1
- package/dist/commands/deploys.d.ts +4 -28
- package/dist/commands/deploys.d.ts.map +1 -1
- package/dist/commands/deploys.js +1 -1
- package/dist/commands/deploys.js.map +1 -1
- package/dist/commands/dev.d.ts +2 -6
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +3 -2
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/diagnose.d.ts +2 -22
- package/dist/commands/diagnose.d.ts.map +1 -1
- package/dist/commands/diagnose.js +1 -1
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/doctor.d.ts +20 -35
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +42 -4
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/domains.d.ts +5 -27
- package/dist/commands/domains.d.ts.map +1 -1
- package/dist/commands/domains.js +1 -1
- package/dist/commands/domains.js.map +1 -1
- package/dist/commands/env-scan.js +1 -1
- package/dist/commands/env-scan.js.map +1 -1
- package/dist/commands/env.d.ts +4 -20
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +1 -1
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/export.d.ts +1 -1
- package/dist/commands/forgejo.d.ts +45 -0
- package/dist/commands/forgejo.d.ts.map +1 -0
- package/dist/commands/forgejo.js +125 -0
- package/dist/commands/forgejo.js.map +1 -0
- package/dist/commands/generate.d.ts +2 -6
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +1 -1
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/github.d.ts +4 -15
- package/dist/commands/github.d.ts.map +1 -1
- package/dist/commands/github.js +17 -1
- package/dist/commands/github.js.map +1 -1
- package/dist/commands/import-project.d.ts +13 -9
- package/dist/commands/import-project.d.ts.map +1 -1
- package/dist/commands/import-project.js +73 -22
- package/dist/commands/import-project.js.map +1 -1
- package/dist/commands/init.d.ts +26 -11
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +103 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/insights.d.ts +2 -6
- package/dist/commands/insights.d.ts.map +1 -1
- package/dist/commands/insights.js +1 -1
- package/dist/commands/insights.js.map +1 -1
- package/dist/commands/login.d.ts +2 -8
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +22 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logs.d.ts +25 -10
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +65 -5
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/mcp.d.ts +2 -2
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/migrate-supabase-map.d.ts +171 -0
- package/dist/commands/migrate-supabase-map.d.ts.map +1 -0
- package/dist/commands/migrate-supabase-map.js +452 -0
- package/dist/commands/migrate-supabase-map.js.map +1 -0
- package/dist/commands/migrate-supabase-schema.d.ts +67 -0
- package/dist/commands/migrate-supabase-schema.d.ts.map +1 -0
- package/dist/commands/migrate-supabase-schema.js +321 -0
- package/dist/commands/migrate-supabase-schema.js.map +1 -0
- package/dist/commands/migrate-supabase-scripts.d.ts +64 -0
- package/dist/commands/migrate-supabase-scripts.d.ts.map +1 -0
- package/dist/commands/migrate-supabase-scripts.js +564 -0
- package/dist/commands/migrate-supabase-scripts.js.map +1 -0
- package/dist/commands/migrate-supabase-sdk.d.ts +133 -0
- package/dist/commands/migrate-supabase-sdk.d.ts.map +1 -0
- package/dist/commands/migrate-supabase-sdk.js +1119 -0
- package/dist/commands/migrate-supabase-sdk.js.map +1 -0
- package/dist/commands/migrate-supabase-walker.d.ts +93 -0
- package/dist/commands/migrate-supabase-walker.d.ts.map +1 -0
- package/dist/commands/migrate-supabase-walker.js +413 -0
- package/dist/commands/migrate-supabase-walker.js.map +1 -0
- package/dist/commands/migrate-supabase.d.ts +81 -0
- package/dist/commands/migrate-supabase.d.ts.map +1 -0
- package/dist/commands/migrate-supabase.js +579 -0
- package/dist/commands/migrate-supabase.js.map +1 -0
- package/dist/commands/open.d.ts +2 -6
- package/dist/commands/open.d.ts.map +1 -1
- package/dist/commands/open.js +1 -1
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/publish-api-error.d.ts +46 -0
- package/dist/commands/publish-api-error.d.ts.map +1 -0
- package/dist/commands/publish-api-error.js +307 -0
- package/dist/commands/publish-api-error.js.map +1 -0
- package/dist/commands/publish-failure.d.ts.map +1 -1
- package/dist/commands/publish-failure.js +11 -3
- package/dist/commands/publish-failure.js.map +1 -1
- package/dist/commands/publish-node.d.ts +5 -2
- package/dist/commands/publish-node.d.ts.map +1 -1
- package/dist/commands/publish-node.js +7 -3
- package/dist/commands/publish-node.js.map +1 -1
- package/dist/commands/publish.d.ts +58 -17
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +407 -145
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/push.d.ts +2 -12
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +25 -7
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/redeploy.d.ts +2 -8
- package/dist/commands/redeploy.d.ts.map +1 -1
- package/dist/commands/redeploy.js +20 -16
- package/dist/commands/redeploy.js.map +1 -1
- package/dist/commands/rename.d.ts +2 -8
- package/dist/commands/rename.d.ts.map +1 -1
- package/dist/commands/rename.js +1 -1
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/reproduce.d.ts +2 -8
- package/dist/commands/reproduce.d.ts.map +1 -1
- package/dist/commands/reproduce.js +1 -1
- package/dist/commands/reproduce.js.map +1 -1
- package/dist/commands/reset-superuser.d.ts +2 -16
- package/dist/commands/reset-superuser.d.ts.map +1 -1
- package/dist/commands/reset-superuser.js +1 -1
- package/dist/commands/reset-superuser.js.map +1 -1
- package/dist/commands/restore.d.ts +7 -22
- package/dist/commands/restore.d.ts.map +1 -1
- package/dist/commands/restore.js +1 -1
- package/dist/commands/restore.js.map +1 -1
- package/dist/commands/resume.d.ts +2 -6
- package/dist/commands/resume.d.ts.map +1 -1
- package/dist/commands/resume.js +1 -1
- package/dist/commands/resume.js.map +1 -1
- package/dist/commands/rollback.d.ts +4 -9
- package/dist/commands/rollback.d.ts.map +1 -1
- package/dist/commands/rollback.js +3 -2
- package/dist/commands/rollback.js.map +1 -1
- package/dist/commands/sharing.d.ts +48 -0
- package/dist/commands/sharing.d.ts.map +1 -0
- package/dist/commands/sharing.js +85 -0
- package/dist/commands/sharing.js.map +1 -0
- package/dist/commands/status.d.ts +29 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +48 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/transfers.d.ts +34 -0
- package/dist/commands/transfers.d.ts.map +1 -0
- package/dist/commands/transfers.js +62 -0
- package/dist/commands/transfers.js.map +1 -0
- package/dist/commands/unsuspend.d.ts +2 -6
- package/dist/commands/unsuspend.d.ts.map +1 -1
- package/dist/commands/unsuspend.js +1 -1
- package/dist/commands/unsuspend.js.map +1 -1
- package/dist/commands/versions.d.ts +2 -6
- package/dist/commands/versions.d.ts.map +1 -1
- package/dist/commands/versions.js +1 -1
- package/dist/commands/versions.js.map +1 -1
- package/dist/commands/wait-deploy.d.ts +2 -12
- package/dist/commands/wait-deploy.d.ts.map +1 -1
- package/dist/commands/wait-deploy.js +5 -4
- package/dist/commands/wait-deploy.js.map +1 -1
- package/dist/context.d.ts +15 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/detect.d.ts +11 -0
- package/dist/detect.d.ts.map +1 -1
- package/dist/detect.js +31 -8
- package/dist/detect.js.map +1 -1
- package/dist/env-scan-source.js +1 -1
- package/dist/env-scan-source.js.map +1 -1
- package/dist/error-classifier.d.ts +17 -0
- package/dist/error-classifier.d.ts.map +1 -1
- package/dist/error-classifier.js +95 -9
- package/dist/error-classifier.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/event-renderer.d.ts +17 -0
- package/dist/event-renderer.d.ts.map +1 -0
- package/dist/event-renderer.js +130 -0
- package/dist/event-renderer.js.map +1 -0
- package/dist/index.d.ts +63 -47
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -40
- package/dist/index.js.map +1 -1
- package/dist/plans.d.ts +70 -5
- package/dist/plans.d.ts.map +1 -1
- package/dist/plans.js +83 -18
- package/dist/plans.js.map +1 -1
- package/dist/poll-deployment.d.ts +13 -1
- package/dist/poll-deployment.d.ts.map +1 -1
- package/dist/poll-deployment.js +37 -1
- package/dist/poll-deployment.js.map +1 -1
- package/dist/publish-retry.d.ts +29 -0
- package/dist/publish-retry.d.ts.map +1 -0
- package/dist/publish-retry.js +224 -0
- package/dist/publish-retry.js.map +1 -0
- package/dist/recovery.d.ts +60 -3
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +24 -1
- package/dist/recovery.js.map +1 -1
- package/dist/static-docker.d.ts +77 -0
- package/dist/static-docker.d.ts.map +1 -0
- package/dist/static-docker.js +105 -0
- package/dist/static-docker.js.map +1 -0
- package/dist/structured-error-codes.d.ts +30 -0
- package/dist/structured-error-codes.d.ts.map +1 -0
- package/dist/structured-error-codes.js +86 -0
- package/dist/structured-error-codes.js.map +1 -0
- package/dist/tarball.d.ts +11 -0
- package/dist/tarball.d.ts.map +1 -1
- package/dist/tarball.js +31 -10
- package/dist/tarball.js.map +1 -1
- package/dist/templates/ai-files/cursor-percher-mdc.d.ts.map +1 -1
- package/dist/templates/ai-files/cursor-percher-mdc.js +12 -9
- package/dist/templates/ai-files/cursor-percher-mdc.js.map +1 -1
- package/dist/templates.js +11 -11
- package/dist/templates.js.map +1 -1
- package/dist/watcher.js +1 -1
- package/dist/watcher.js.map +1 -1
- package/package.json +7 -2
package/dist/recovery.d.ts
CHANGED
|
@@ -52,6 +52,17 @@ export type RecoveryAction =
|
|
|
52
52
|
| "fix_config"
|
|
53
53
|
/** Plan limits exceeded or otherwise needs human input; agent should ask the user. */
|
|
54
54
|
| "ask_user"
|
|
55
|
+
/**
|
|
56
|
+
* FUTURE16 Fas 3 — pre-fetched device-code is in-flight. Agent should
|
|
57
|
+
* call `percher_wait_for_auth` to short-poll the device-code exchange,
|
|
58
|
+
* then resume the original publish call. Pairs 1:1 with the
|
|
59
|
+
* `auth_pending` PublishStatus. Distinct from `open_login` (which
|
|
60
|
+
* tells the agent to *start* a login flow via `percher_login`) — by
|
|
61
|
+
* the time `wait_auth` is emitted the device-code already exists and
|
|
62
|
+
* the user has been pointed at the verification URL; only the wait
|
|
63
|
+
* step remains.
|
|
64
|
+
*/
|
|
65
|
+
| "wait_auth"
|
|
55
66
|
/** Success path — no further action required. */
|
|
56
67
|
| "none";
|
|
57
68
|
/** MCP tool the agent should invoke for `nextAction`, when applicable. */
|
|
@@ -70,7 +81,14 @@ export type SuggestedTool = "percher_login" | "percher_env_set" | "percher_deplo
|
|
|
70
81
|
| "percher_redeploy"
|
|
71
82
|
/** FUTURE1 Phase 4.2 — percher_reproduce tool, surfaced via
|
|
72
83
|
* alternativeActions on build-failure recovery. */
|
|
73
|
-
| "percher_reproduce"
|
|
84
|
+
| "percher_reproduce"
|
|
85
|
+
/**
|
|
86
|
+
* FUTURE16 Fas 3 — short-polls a pre-fetched device-code and resumes
|
|
87
|
+
* the original publish input once a token lands. Pairs with the
|
|
88
|
+
* `wait_auth` recovery action and the `auth_pending` publish status.
|
|
89
|
+
* MCP-only tool — CLI's `percher login` already polls in-process.
|
|
90
|
+
*/
|
|
91
|
+
| "percher_wait_for_auth";
|
|
74
92
|
/**
|
|
75
93
|
* FUTURE12 Phase 1a — stable, enumerated reason an agent or human can
|
|
76
94
|
* branch on. Intentionally orthogonal to `RecoveryAction`: action says
|
|
@@ -135,6 +153,13 @@ export type ReasonCode =
|
|
|
135
153
|
| "log_fetch_failed"
|
|
136
154
|
/** Deploy died before the build phase started (e.g. tarball validation). */
|
|
137
155
|
| "failed_before_build"
|
|
156
|
+
/** FUTURE_account-deletion-guards Fas 4. percher_account_delete
|
|
157
|
+
* pre-flighted percher_account_deletion_preview and got back a
|
|
158
|
+
* non-empty blocker list (apps_owned, apps_with_collaborators,
|
|
159
|
+
* pending_outgoing_transfers, deploys_in_progress, etc.). The agent
|
|
160
|
+
* must surface `recovery.prompt` verbatim and let the user resolve
|
|
161
|
+
* the blockers via the existing routes before retrying. */
|
|
162
|
+
| "account_deletion_blocked"
|
|
138
163
|
/** Catch-all for unclassified state — agents should route to doctor. */
|
|
139
164
|
| "unknown";
|
|
140
165
|
/**
|
|
@@ -152,7 +177,18 @@ export type DoctorMode = "auto" | "deploy" | "runtime" | "config" | "env" | "acc
|
|
|
152
177
|
* deploy. Pinning the value here so the CLI/MCP can declare exhaustive
|
|
153
178
|
* switches before the server path lands.
|
|
154
179
|
*/
|
|
155
|
-
export type PublishStatus = "live" | "failed" | "needs_login"
|
|
180
|
+
export type PublishStatus = "live" | "failed" | "needs_login"
|
|
181
|
+
/**
|
|
182
|
+
* FUTURE16 Fas 3 — MCP `percher_publish` returns this when the
|
|
183
|
+
* caller's session has no token AND a device-code has already been
|
|
184
|
+
* pre-fetched. The agent's next step is `percher_wait_for_auth`
|
|
185
|
+
* (carried in `recovery`); the tarball has NOT been packed yet, so
|
|
186
|
+
* the resume call is the first and only packaging operation in the
|
|
187
|
+
* entire auth flow. CLI uses the existing `needs_login` path —
|
|
188
|
+
* `auth_pending` is MCP-specific because only a long-lived agent
|
|
189
|
+
* session benefits from the pre-fetch + in-process poll split.
|
|
190
|
+
*/
|
|
191
|
+
| "auth_pending" | "dry_run" | "queued" | "replaced" | "already_in_progress";
|
|
156
192
|
/**
|
|
157
193
|
* Structured problem entry used by `fix_config` and `fix_problems`
|
|
158
194
|
* recoveries. Agents apply file edits directly using these.
|
|
@@ -199,7 +235,14 @@ interface BaseRecovery {
|
|
|
199
235
|
* Phase 4 migrates it to `run_doctor`.
|
|
200
236
|
*/
|
|
201
237
|
export interface ToolRecovery extends BaseRecovery {
|
|
202
|
-
nextAction: "open_login" | "wait_deploy" | "run_doctor" | "set_env_vars" | "retry" | "inspect_build_log"
|
|
238
|
+
nextAction: "open_login" | "wait_deploy" | "run_doctor" | "set_env_vars" | "retry" | "inspect_build_log"
|
|
239
|
+
/**
|
|
240
|
+
* FUTURE16 Fas 3 — short-poll a pre-fetched device-code via
|
|
241
|
+
* `percher_wait_for_auth`. `args` carries `{ deviceCode,
|
|
242
|
+
* publishArgs }` so the agent can resume the original publish
|
|
243
|
+
* call without re-deriving inputs.
|
|
244
|
+
*/
|
|
245
|
+
| "wait_auth";
|
|
203
246
|
suggestedTool: SuggestedTool;
|
|
204
247
|
args: Record<string, unknown>;
|
|
205
248
|
}
|
|
@@ -241,6 +284,20 @@ export declare function recoveryNone(opts?: {
|
|
|
241
284
|
export declare function recoveryLogin(opts?: {
|
|
242
285
|
reasonCode?: ReasonCode;
|
|
243
286
|
}): ToolRecovery;
|
|
287
|
+
/**
|
|
288
|
+
* FUTURE16 Fas 3 — pre-fetched device-code is in-flight; agent should
|
|
289
|
+
* call `percher_wait_for_auth` to short-poll the exchange and resume
|
|
290
|
+
* publish once a token lands. `publishArgs` carries the *raw user
|
|
291
|
+
* input flags* (cwd is implicit on ctx; preview/live/message/dryRun/
|
|
292
|
+
* etc. ride here) so the resume call is a first-time publish — no
|
|
293
|
+
* tarball state is preserved across the wait, no upload state to
|
|
294
|
+
* invalidate. That's the entire point of pre-fetch + in-process poll
|
|
295
|
+
* over the alternative anonymous-staged-tarball design (see plan).
|
|
296
|
+
*/
|
|
297
|
+
export declare function recoveryAuthPending(opts: {
|
|
298
|
+
deviceCode: string;
|
|
299
|
+
publishArgs: Record<string, unknown>;
|
|
300
|
+
}): ToolRecovery;
|
|
244
301
|
/** Wait on an in-flight deploy — agent should call `percher_wait_for_deploy`. */
|
|
245
302
|
export declare function recoveryWait(opts: {
|
|
246
303
|
app: string;
|
package/dist/recovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc;AACxB,kEAAkE;AAChE,YAAY;AACd,iEAAiE;GAC/D,cAAc;AAChB;;;;GAIG;GACD,aAAa;AACf,qEAAqE;GACnE,OAAO;AACT;;;;;;;GAOG;GACD,YAAY;AACd,mFAAmF;GACjF,mBAAmB;AACrB;;;;;GAKG;GACD,cAAc;AAChB;;;;;;;;GAQG;GACD,mBAAmB;AACrB,+EAA+E;GAC7E,YAAY;AACd,sFAAsF;GACpF,UAAU;AACZ;;;;;;;;;GASG;GACD,WAAW;AACb,iDAAiD;GAC/C,MAAM,CAAC;AAEX,0EAA0E;AAC1E,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,iBAAiB,GACjB,yBAAyB,GACzB,iBAAiB;AACnB,kFAAkF;GAChF,yBAAyB;AAC3B;;;;GAIG;GACD,gBAAgB;AAClB;;qDAEqD;GACnD,kBAAkB;AACpB;oDACoD;GAClD,mBAAmB;AACrB;;;;;GAKG;GACD,uBAAuB,CAAC;AAE5B;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU;AACpB,0DAA0D;AACxD,MAAM;AACR,0EAA0E;GACxE,eAAe;AACjB,+DAA+D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CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,YAAY,GAAG,eAAe,CAW9E;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,cAAmB,GAC3B,eAAe,CAoHjB"}
|
package/dist/recovery.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TIMEOUTS } from "@percher/shared/timeouts";
|
|
1
2
|
// ── Builders ─────────────────────────────────────────────────────────
|
|
2
3
|
//
|
|
3
4
|
// All recovery construction goes through these. Each builder enforces
|
|
@@ -23,6 +24,28 @@ export function recoveryLogin(opts = {}) {
|
|
|
23
24
|
reasonCode: opts.reasonCode ?? "auth_required",
|
|
24
25
|
};
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* FUTURE16 Fas 3 — pre-fetched device-code is in-flight; agent should
|
|
29
|
+
* call `percher_wait_for_auth` to short-poll the exchange and resume
|
|
30
|
+
* publish once a token lands. `publishArgs` carries the *raw user
|
|
31
|
+
* input flags* (cwd is implicit on ctx; preview/live/message/dryRun/
|
|
32
|
+
* etc. ride here) so the resume call is a first-time publish — no
|
|
33
|
+
* tarball state is preserved across the wait, no upload state to
|
|
34
|
+
* invalidate. That's the entire point of pre-fetch + in-process poll
|
|
35
|
+
* over the alternative anonymous-staged-tarball design (see plan).
|
|
36
|
+
*/
|
|
37
|
+
export function recoveryAuthPending(opts) {
|
|
38
|
+
return {
|
|
39
|
+
retryable: false,
|
|
40
|
+
nextAction: "wait_auth",
|
|
41
|
+
suggestedTool: "percher_wait_for_auth",
|
|
42
|
+
args: {
|
|
43
|
+
deviceCode: opts.deviceCode,
|
|
44
|
+
publishArgs: opts.publishArgs,
|
|
45
|
+
},
|
|
46
|
+
reasonCode: "auth_required",
|
|
47
|
+
};
|
|
48
|
+
}
|
|
26
49
|
/** Wait on an in-flight deploy — agent should call `percher_wait_for_deploy`. */
|
|
27
50
|
export function recoveryWait(opts) {
|
|
28
51
|
return {
|
|
@@ -32,7 +55,7 @@ export function recoveryWait(opts) {
|
|
|
32
55
|
args: {
|
|
33
56
|
app: opts.app,
|
|
34
57
|
deployId: opts.deployId,
|
|
35
|
-
timeoutSeconds: opts.timeoutSeconds ??
|
|
58
|
+
timeoutSeconds: opts.timeoutSeconds ?? TIMEOUTS.mcpWaitDeployDefault / 1000,
|
|
36
59
|
},
|
|
37
60
|
reasonCode: opts.reasonCode,
|
|
38
61
|
};
|
package/dist/recovery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.js","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"recovery.js","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAoTpD,wEAAwE;AACxE,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,sEAAsE;AACtE,iEAAiE;AAEjE,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAAC,OAAkD,EAAE;IAC/E,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,MAAM;QAClB,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,MAAM;QACrC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrD,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,aAAa,CAAC,OAAoC,EAAE;IAClE,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,YAAY;QACxB,aAAa,EAAE,eAAe;QAC9B,IAAI,EAAE,EAAE;QACR,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,eAAe;KAC/C,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG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CAAC;gBACjB,MAAM,EACJ,oIAAoI;gBACtI,UAAU,EAAE,SAAS;aACtB,CAAC,CAAC;IACP,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-stage Dockerfile + Caddyfile generator for static-framework
|
|
3
|
+
* projects — Vite, Astro (static), Eleventy and friends.
|
|
4
|
+
*
|
|
5
|
+
* These frameworks need a build step. Percher's `runtime = "static"`
|
|
6
|
+
* Caddy path only *serves* pre-built files — it rejects a
|
|
7
|
+
* `[build].command` outright (STATIC_BUILD_COMMAND_UNSUPPORTED). So a
|
|
8
|
+
* scaffolded Vite/Astro project can't ride that path as-is. Instead
|
|
9
|
+
* they ship as `runtime = "docker"`: a Bun stage runs the build, then
|
|
10
|
+
* the output is served by the same minimal Caddy image the native
|
|
11
|
+
* static runtime uses — slim image, fast cold start, no server to
|
|
12
|
+
* configure.
|
|
13
|
+
*
|
|
14
|
+
* This is the documented follow-up to FUTURE11 Fas 1 (a builder stage
|
|
15
|
+
* for the static path) done the only way that works on what Percher
|
|
16
|
+
* supports today: the user-owned `runtime = "docker"` lane.
|
|
17
|
+
*
|
|
18
|
+
* Used by both `bunx percher init` (scaffolds these files when it
|
|
19
|
+
* detects a static framework) and the bundled `bunx percher init`
|
|
20
|
+
* templates (astro, vite-react, …), so the CLI and the templates can
|
|
21
|
+
* never drift — `packages/core/test/static-docker.test.ts` pins the
|
|
22
|
+
* committed template files to this renderer's output.
|
|
23
|
+
*
|
|
24
|
+
* The serve stage mirrors `packages/api/src/pipeline/static-build.ts`
|
|
25
|
+
* (`buildStaticDockerfile` / `buildStaticCaddyfile`) — same cap-strip
|
|
26
|
+
* and same `bind 0.0.0.0` IPv4 fix — but lives here independently
|
|
27
|
+
* because `@percher/core` must not depend on `@percher/api`.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Port the Caddy serve stage binds to. 8080 (>= 1024) so Caddy never
|
|
31
|
+
* needs `cap_net_bind_service` — which matters because the cap-strip
|
|
32
|
+
* below removes it. Matches the bundled `hugo` template and the
|
|
33
|
+
* `[web].port` these templates declare.
|
|
34
|
+
*/
|
|
35
|
+
export declare const STATIC_DOCKER_PORT = 8080;
|
|
36
|
+
export interface StaticDockerfileInput {
|
|
37
|
+
/**
|
|
38
|
+
* Directory the framework's build command produces, relative to the
|
|
39
|
+
* project root (e.g. `dist` for Vite/Astro, `_site` for Eleventy).
|
|
40
|
+
*/
|
|
41
|
+
outputDir: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Render the multi-stage Dockerfile. The build stage runs
|
|
45
|
+
* `bun install && bun run build`; the serve stage is a minimal Caddy
|
|
46
|
+
* image with the upstream binary's file capabilities stripped.
|
|
47
|
+
*
|
|
48
|
+
* Why the cap-strip: `caddy:2-alpine` ships `/usr/bin/caddy` with
|
|
49
|
+
* `cap_net_bind_service=+ep`. Percher starts every app container with
|
|
50
|
+
* `--security-opt no-new-privileges`, which makes `execve` refuse a
|
|
51
|
+
* binary whose file caps would grant more privilege than the parent —
|
|
52
|
+
* the result is an `operation not permitted` crash-loop. Copying the
|
|
53
|
+
* binary onto a plain `alpine` base and running `setcap -r` removes
|
|
54
|
+
* the caps; Caddy doesn't need them here (it binds :8080).
|
|
55
|
+
*/
|
|
56
|
+
export declare function renderStaticFrameworkDockerfile(input: StaticDockerfileInput): string;
|
|
57
|
+
export interface StaticCaddyfileInput {
|
|
58
|
+
/**
|
|
59
|
+
* When true, deep links fall back to `/index.html` so client-side
|
|
60
|
+
* routers (React Router, Vue Router, …) handle the route instead of
|
|
61
|
+
* Caddy returning 404. True for SPA frameworks; false for static
|
|
62
|
+
* site generators that emit a real HTML file per route.
|
|
63
|
+
*/
|
|
64
|
+
spa: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Render the Caddyfile served by the container.
|
|
68
|
+
*
|
|
69
|
+
* `bind 0.0.0.0` is load-bearing: Caddy's `:8080` shorthand binds only
|
|
70
|
+
* to the IPv6 wildcard inside Percher's app-container network
|
|
71
|
+
* namespace (`bindv6only` is set), but the deployer's health probe
|
|
72
|
+
* hits `http://127.0.0.1:8080` over IPv4. Without an explicit IPv4
|
|
73
|
+
* bind the probe gets "connection refused" while Caddy is up — every
|
|
74
|
+
* deploy then fails health check. Same fix as `static-build.ts`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function renderStaticFrameworkCaddyfile(input: StaticCaddyfileInput): string;
|
|
77
|
+
//# sourceMappingURL=static-docker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-docker.d.ts","sourceRoot":"","sources":["../src/static-docker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAoCpF;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAQlF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-stage Dockerfile + Caddyfile generator for static-framework
|
|
3
|
+
* projects — Vite, Astro (static), Eleventy and friends.
|
|
4
|
+
*
|
|
5
|
+
* These frameworks need a build step. Percher's `runtime = "static"`
|
|
6
|
+
* Caddy path only *serves* pre-built files — it rejects a
|
|
7
|
+
* `[build].command` outright (STATIC_BUILD_COMMAND_UNSUPPORTED). So a
|
|
8
|
+
* scaffolded Vite/Astro project can't ride that path as-is. Instead
|
|
9
|
+
* they ship as `runtime = "docker"`: a Bun stage runs the build, then
|
|
10
|
+
* the output is served by the same minimal Caddy image the native
|
|
11
|
+
* static runtime uses — slim image, fast cold start, no server to
|
|
12
|
+
* configure.
|
|
13
|
+
*
|
|
14
|
+
* This is the documented follow-up to FUTURE11 Fas 1 (a builder stage
|
|
15
|
+
* for the static path) done the only way that works on what Percher
|
|
16
|
+
* supports today: the user-owned `runtime = "docker"` lane.
|
|
17
|
+
*
|
|
18
|
+
* Used by both `bunx percher init` (scaffolds these files when it
|
|
19
|
+
* detects a static framework) and the bundled `bunx percher init`
|
|
20
|
+
* templates (astro, vite-react, …), so the CLI and the templates can
|
|
21
|
+
* never drift — `packages/core/test/static-docker.test.ts` pins the
|
|
22
|
+
* committed template files to this renderer's output.
|
|
23
|
+
*
|
|
24
|
+
* The serve stage mirrors `packages/api/src/pipeline/static-build.ts`
|
|
25
|
+
* (`buildStaticDockerfile` / `buildStaticCaddyfile`) — same cap-strip
|
|
26
|
+
* and same `bind 0.0.0.0` IPv4 fix — but lives here independently
|
|
27
|
+
* because `@percher/core` must not depend on `@percher/api`.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Port the Caddy serve stage binds to. 8080 (>= 1024) so Caddy never
|
|
31
|
+
* needs `cap_net_bind_service` — which matters because the cap-strip
|
|
32
|
+
* below removes it. Matches the bundled `hugo` template and the
|
|
33
|
+
* `[web].port` these templates declare.
|
|
34
|
+
*/
|
|
35
|
+
export const STATIC_DOCKER_PORT = 8080;
|
|
36
|
+
/**
|
|
37
|
+
* Render the multi-stage Dockerfile. The build stage runs
|
|
38
|
+
* `bun install && bun run build`; the serve stage is a minimal Caddy
|
|
39
|
+
* image with the upstream binary's file capabilities stripped.
|
|
40
|
+
*
|
|
41
|
+
* Why the cap-strip: `caddy:2-alpine` ships `/usr/bin/caddy` with
|
|
42
|
+
* `cap_net_bind_service=+ep`. Percher starts every app container with
|
|
43
|
+
* `--security-opt no-new-privileges`, which makes `execve` refuse a
|
|
44
|
+
* binary whose file caps would grant more privilege than the parent —
|
|
45
|
+
* the result is an `operation not permitted` crash-loop. Copying the
|
|
46
|
+
* binary onto a plain `alpine` base and running `setcap -r` removes
|
|
47
|
+
* the caps; Caddy doesn't need them here (it binds :8080).
|
|
48
|
+
*/
|
|
49
|
+
export function renderStaticFrameworkDockerfile(input) {
|
|
50
|
+
return `# Multi-stage build: a Bun stage compiles the static bundle, then a
|
|
51
|
+
# minimal Caddy image serves it. This project uses runtime = "docker"
|
|
52
|
+
# (not "static") because Percher's static runtime serves pre-built
|
|
53
|
+
# files only — it does not run a build command. Generated by Percher;
|
|
54
|
+
# safe to edit and own.
|
|
55
|
+
|
|
56
|
+
# --- Build stage: install deps and build the static bundle -----------
|
|
57
|
+
FROM oven/bun:1-alpine AS build
|
|
58
|
+
WORKDIR /app
|
|
59
|
+
COPY . .
|
|
60
|
+
RUN bun install && bun run build
|
|
61
|
+
|
|
62
|
+
# --- Serve stage: minimal Caddy image --------------------------------
|
|
63
|
+
# caddy:2-alpine ships /usr/bin/caddy with cap_net_bind_service file
|
|
64
|
+
# caps. Percher runs every container with --security-opt
|
|
65
|
+
# no-new-privileges, which makes execve refuse a cap-bearing binary
|
|
66
|
+
# (an "operation not permitted" crash-loop). Copy Caddy onto a plain
|
|
67
|
+
# alpine base and strip the caps with setcap -r — Caddy never needs
|
|
68
|
+
# the cap here, it listens on :${STATIC_DOCKER_PORT} (>= 1024).
|
|
69
|
+
FROM caddy:2-alpine AS caddy-source
|
|
70
|
+
FROM alpine:3.21
|
|
71
|
+
COPY --from=caddy-source /usr/bin/caddy /usr/bin/caddy
|
|
72
|
+
RUN apk add --no-cache libcap \\
|
|
73
|
+
&& setcap -r /usr/bin/caddy \\
|
|
74
|
+
&& apk del libcap \\
|
|
75
|
+
&& rm -rf /var/cache/apk/*
|
|
76
|
+
COPY Caddyfile /etc/caddy/Caddyfile
|
|
77
|
+
COPY --from=build /app/${input.outputDir} /srv
|
|
78
|
+
# HOME points at the writable tmpfs so non-root Caddy can persist its
|
|
79
|
+
# XDG state (storage-clean lock, config autosave) under Percher's
|
|
80
|
+
# read-only root filesystem.
|
|
81
|
+
ENV HOME=/tmp
|
|
82
|
+
EXPOSE ${STATIC_DOCKER_PORT}
|
|
83
|
+
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Render the Caddyfile served by the container.
|
|
88
|
+
*
|
|
89
|
+
* `bind 0.0.0.0` is load-bearing: Caddy's `:8080` shorthand binds only
|
|
90
|
+
* to the IPv6 wildcard inside Percher's app-container network
|
|
91
|
+
* namespace (`bindv6only` is set), but the deployer's health probe
|
|
92
|
+
* hits `http://127.0.0.1:8080` over IPv4. Without an explicit IPv4
|
|
93
|
+
* bind the probe gets "connection refused" while Caddy is up — every
|
|
94
|
+
* deploy then fails health check. Same fix as `static-build.ts`.
|
|
95
|
+
*/
|
|
96
|
+
export function renderStaticFrameworkCaddyfile(input) {
|
|
97
|
+
const directives = ["bind 0.0.0.0", "root * /srv", "encode gzip zstd"];
|
|
98
|
+
if (input.spa) {
|
|
99
|
+
directives.push("try_files {path} /index.html");
|
|
100
|
+
}
|
|
101
|
+
directives.push("file_server");
|
|
102
|
+
const body = directives.map((d) => `\t${d}`).join("\n");
|
|
103
|
+
return `:${STATIC_DOCKER_PORT} {\n${body}\n}\n`;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=static-docker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-docker.js","sourceRoot":"","sources":["../src/static-docker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAUvC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,+BAA+B,CAAC,KAA4B;IAC1E,OAAO;;;;;;;;;;;;;;;;;;iCAkBwB,kBAAkB;;;;;;;;;yBAS1B,KAAK,CAAC,SAAS;;;;;SAK/B,kBAAkB;;CAE1B,CAAC;AACF,CAAC;AAYD;;;;;;;;;GASG;AACH,MAAM,UAAU,8BAA8B,CAAC,KAA2B;IACxE,MAAM,UAAU,GAAG,CAAC,cAAc,EAAE,aAAa,EAAE,kBAAkB,CAAC,CAAC;IACvE,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;QACd,UAAU,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IACD,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO,IAAI,kBAAkB,OAAO,IAAI,OAAO,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ClassifiedError } from "./error-classifier";
|
|
2
|
+
/**
|
|
3
|
+
* Phase 4 of the publish-resilience plan — CLI-side mapping from
|
|
4
|
+
* the canonical `DeployErrorCode` strings (defined server-side in
|
|
5
|
+
* `@percher/api/src/worker/error-codes.ts`) to the
|
|
6
|
+
* `ClassifiedError` shape the CLI's publish-failure renderer
|
|
7
|
+
* already consumes.
|
|
8
|
+
*
|
|
9
|
+
* Why this lives in @percher/core instead of @percher/client: the
|
|
10
|
+
* client surfaces the raw `errorCode` string on `Deployment` and
|
|
11
|
+
* stays unopinionated; the core package owns the rendering of
|
|
12
|
+
* publish failures and is the right place to decide "given this
|
|
13
|
+
* canonical code, what title/explanation/suggestion does the user
|
|
14
|
+
* see". The CLI's `publish-failure.ts` calls into this module
|
|
15
|
+
* BEFORE the regex-based `classifyError` so the structured code
|
|
16
|
+
* always wins when present.
|
|
17
|
+
*
|
|
18
|
+
* Set parity: the strings here MUST match the ones in the API's
|
|
19
|
+
* `DEPLOY_ERROR_CODES` const. Adding a new code requires updating
|
|
20
|
+
* both files. Forward-compat: an unknown code returns null, the
|
|
21
|
+
* CLI falls back to the regex classifier, no breakage.
|
|
22
|
+
*/
|
|
23
|
+
export type DeployErrorCode = "WORKER_UNAVAILABLE" | "WORKER_UNAVAILABLE_PERSISTENT" | "BUILD_TIMEOUT" | "BUILD_FAILED" | "WORKER_ERROR" | "DEPLOY_STALLED";
|
|
24
|
+
/**
|
|
25
|
+
* Map a canonical Phase 4 error code to a {@link ClassifiedError}.
|
|
26
|
+
* Returns null for NULL / unknown codes so the caller can fall back
|
|
27
|
+
* to the regex-based `classifyError`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function classifyByErrorCode(code: string | null | undefined, rawMessage: string): ClassifiedError | null;
|
|
30
|
+
//# sourceMappingURL=structured-error-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured-error-codes.d.ts","sourceRoot":"","sources":["../src/structured-error-codes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,oBAAoB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,MAAM,eAAe,GACvB,oBAAoB,GACpB,+BAA+B,GAC/B,eAAe,GACf,cAAc,GACd,cAAc,GACd,gBAAgB,CAAC;AAoFrB;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,UAAU,EAAE,MAAM,GACjB,eAAe,GAAG,IAAI,CAcxB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const MAPPINGS = {
|
|
2
|
+
WORKER_UNAVAILABLE: {
|
|
3
|
+
errorClass: "infra_unavailable",
|
|
4
|
+
phase: "infra",
|
|
5
|
+
cause: "worker_fetch_failed",
|
|
6
|
+
title: "Build worker is unreachable",
|
|
7
|
+
explanation: (raw) => raw
|
|
8
|
+
? `The Percher build worker did not respond in time: ${trimMessage(raw)}. This is a platform-side issue, not your code.`
|
|
9
|
+
: "The Percher build worker did not respond in time. This is a platform-side issue, not your code.",
|
|
10
|
+
suggestion: "Wait 30 seconds and run `percher publish` again. If retry #2 also fails, pause 5 minutes before the next attempt — back-to-back retries during a partial outage just waste your time. After 3 spaced-out retries, check status.percher.app or contact support. Your build never started.",
|
|
11
|
+
},
|
|
12
|
+
WORKER_UNAVAILABLE_PERSISTENT: {
|
|
13
|
+
errorClass: "infra_unavailable",
|
|
14
|
+
phase: "infra",
|
|
15
|
+
cause: "worker_circuit_breaker_open",
|
|
16
|
+
title: "Build worker is in a crash loop",
|
|
17
|
+
explanation: () => "The Percher build worker has failed repeatedly in the last minute and the platform's circuit breaker has flipped open. Retrying immediately would just queue more failures.",
|
|
18
|
+
suggestion: "Wait 2-3 minutes for the platform to recover, then retry. If it persists past 5 minutes check status.percher.app or contact support — this is a platform incident, not your code.",
|
|
19
|
+
},
|
|
20
|
+
BUILD_TIMEOUT: {
|
|
21
|
+
errorClass: "build_failed",
|
|
22
|
+
phase: "build",
|
|
23
|
+
cause: "build_timeout",
|
|
24
|
+
title: "Build timed out",
|
|
25
|
+
explanation: () => "The build ran longer than the 10-minute platform limit and was aborted.",
|
|
26
|
+
suggestion: "Common causes: a slow `postinstall` hook, very large dependency tree, or a Dockerfile that pulls a huge base image. Try `bun install` locally and check what's slow. If it's legitimately a heavy build, contact support to discuss raising the limit for your account.",
|
|
27
|
+
},
|
|
28
|
+
BUILD_FAILED: {
|
|
29
|
+
errorClass: "build_failed",
|
|
30
|
+
phase: "build",
|
|
31
|
+
cause: "build_nonzero_exit",
|
|
32
|
+
title: "Build failed",
|
|
33
|
+
explanation: (raw) => raw
|
|
34
|
+
? `The build process returned a non-zero exit code: ${trimMessage(raw)}. Read the build log below for the exact error.`
|
|
35
|
+
: "The build process returned a non-zero exit code. Read the build log below for the exact error.",
|
|
36
|
+
suggestion: "Run your build locally to reproduce: `bun install && bun run build`. The error in the build log usually points to a missing dependency, a TypeScript/syntax error, or a misconfigured framework setting.",
|
|
37
|
+
},
|
|
38
|
+
WORKER_ERROR: {
|
|
39
|
+
errorClass: "infra_unavailable",
|
|
40
|
+
phase: "infra",
|
|
41
|
+
cause: "worker_internal_error",
|
|
42
|
+
title: "Platform error inside the build worker",
|
|
43
|
+
explanation: (raw) => raw
|
|
44
|
+
? `The build worker hit an internal error: ${trimMessage(raw)}. This is a Percher bug, not your code.`
|
|
45
|
+
: "The build worker hit an internal error. This is a Percher bug, not your code.",
|
|
46
|
+
suggestion: "Retry once — transient platform errors usually clear within a minute. If it repeats, please report it: include the deploy ID and we'll investigate. Your account is not at fault.",
|
|
47
|
+
},
|
|
48
|
+
DEPLOY_STALLED: {
|
|
49
|
+
errorClass: "infra_unavailable",
|
|
50
|
+
phase: "infra",
|
|
51
|
+
cause: "deploy_stalled",
|
|
52
|
+
title: "Deploy stalled",
|
|
53
|
+
explanation: () => "The platform abandoned this deploy — likely because the API or build worker restarted mid-build. Your code is fine; the build never finished.",
|
|
54
|
+
suggestion: "Run `percher publish` again. The new deploy will start fresh. If you see this repeatedly across multiple publishes, check status.percher.app — it implies a recurring platform issue.",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Map a canonical Phase 4 error code to a {@link ClassifiedError}.
|
|
59
|
+
* Returns null for NULL / unknown codes so the caller can fall back
|
|
60
|
+
* to the regex-based `classifyError`.
|
|
61
|
+
*/
|
|
62
|
+
export function classifyByErrorCode(code, rawMessage) {
|
|
63
|
+
if (!code)
|
|
64
|
+
return null;
|
|
65
|
+
const mapping = MAPPINGS[code];
|
|
66
|
+
if (!mapping)
|
|
67
|
+
return null;
|
|
68
|
+
return {
|
|
69
|
+
title: mapping.title,
|
|
70
|
+
explanation: mapping.explanation(rawMessage),
|
|
71
|
+
suggestion: mapping.suggestion,
|
|
72
|
+
errorClass: mapping.errorClass,
|
|
73
|
+
phase: mapping.phase,
|
|
74
|
+
cause: mapping.cause,
|
|
75
|
+
relevantFiles: [],
|
|
76
|
+
missingEnvVars: [],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function trimMessage(raw) {
|
|
80
|
+
// Keep the first line + truncate. The CLI already shows the
|
|
81
|
+
// full build-log tail below; this is just enough context to
|
|
82
|
+
// explain WHY the platform-side classifier picked this code.
|
|
83
|
+
const firstLine = raw.split("\n")[0] ?? "";
|
|
84
|
+
return firstLine.length > 200 ? `${firstLine.slice(0, 200)}…` : firstLine;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=structured-error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured-error-codes.js","sourceRoot":"","sources":["../src/structured-error-codes.ts"],"names":[],"mappings":"AA8CA,MAAM,QAAQ,GAAyC;IACrD,kBAAkB,EAAE;QAClB,UAAU,EAAE,mBAAmB;QAC/B,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,qBAAqB;QAC5B,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CACnB,GAAG;YACD,CAAC,CAAC,qDAAqD,WAAW,CAAC,GAAG,CAAC,iDAAiD;YACxH,CAAC,CAAC,iGAAiG;QACvG,UAAU,EACR,0RAA0R;KAC7R;IACD,6BAA6B,EAAE;QAC7B,UAAU,EAAE,mBAAmB;QAC/B,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,6BAA6B;QACpC,KAAK,EAAE,iCAAiC;QACxC,WAAW,EAAE,GAAG,EAAE,CAChB,6KAA6K;QAC/K,UAAU,EACR,mLAAmL;KACtL;IACD,aAAa,EAAE;QACb,UAAU,EAAE,cAAc;QAC1B,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,eAAe;QACtB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,GAAG,EAAE,CAAC,yEAAyE;QAC5F,UAAU,EACR,yQAAyQ;KAC5Q;IACD,YAAY,EAAE;QACZ,UAAU,EAAE,cAAc;QAC1B,KAAK,EA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,cAAc,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,4DAA4D;IAC5D,4DAA4D;IAC5D,6DAA6D;IAC7D,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,OAAO,SAAS,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC"}
|
package/dist/tarball.d.ts
CHANGED
|
@@ -12,6 +12,17 @@ export interface TarballResult {
|
|
|
12
12
|
path: string;
|
|
13
13
|
size: number;
|
|
14
14
|
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Phase 7.8 follow-up — deterministic content-hash of the bundle.
|
|
17
|
+
* Used by the CLI's cache-probe call so identical sources hash to
|
|
18
|
+
* the same value across runs. Distinct from the gzipped-bytes hash
|
|
19
|
+
* the API computes on upload (which carries embedded mtimes from
|
|
20
|
+
* tar/gzip headers and therefore *cannot* be deterministic). The
|
|
21
|
+
* CLI sends this value as the `X-Tarball-Hash` header on the
|
|
22
|
+
* upload; the API stores it on `deployments.tarball_hash` so a
|
|
23
|
+
* subsequent probe matches.
|
|
24
|
+
*/
|
|
25
|
+
contentHash: string;
|
|
15
26
|
}
|
|
16
27
|
export declare function createTarball(options: TarballOptions): Promise<TarballResult>;
|
|
17
28
|
//# sourceMappingURL=tarball.d.ts.map
|
package/dist/tarball.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tarball.d.ts","sourceRoot":"","sources":["../src/tarball.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tarball.d.ts","sourceRoot":"","sources":["../src/tarball.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD;;;;;;;;;OASG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAiCD,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAgEnF"}
|
package/dist/tarball.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
3
|
import { join, relative, sep } from "node:path";
|
|
3
4
|
import { Readable } from "node:stream";
|
|
4
5
|
import { createGzip } from "node:zlib";
|
|
@@ -45,18 +46,34 @@ export async function createTarball(options) {
|
|
|
45
46
|
}
|
|
46
47
|
if (options.extraIgnore)
|
|
47
48
|
ig.add(options.extraIgnore);
|
|
48
|
-
|
|
49
|
+
// Sorted entries — required for the deterministic content-hash
|
|
50
|
+
// below. Without this, readdirSync's platform-dependent order
|
|
51
|
+
// produces a different hash on every run even for unchanged
|
|
52
|
+
// sources, and cache-probe never matches. Codex P2, 2026-05-08.
|
|
53
|
+
const fileBuffers = [];
|
|
49
54
|
for (const rel of walk(options.cwd, options.cwd, ig)) {
|
|
50
|
-
const
|
|
51
|
-
|
|
55
|
+
const data = readFileSync(join(options.cwd, rel));
|
|
56
|
+
fileBuffers.push({ path: rel, size: data.length, data });
|
|
52
57
|
}
|
|
53
|
-
|
|
58
|
+
fileBuffers.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
59
|
+
const totalBytes = fileBuffers.reduce((sum, f) => sum + f.size, 0);
|
|
60
|
+
// Deterministic content-hash: SHA-256 over a canonical encoding of
|
|
61
|
+
// every file's path + bytes, in sorted order. The encoding uses
|
|
62
|
+
// length-prefixed sections so a path containing a delimiter can't
|
|
63
|
+
// collide with a longer/shorter path of the same prefix.
|
|
64
|
+
const contentHasher = createHash("sha256");
|
|
65
|
+
for (const f of fileBuffers) {
|
|
66
|
+
contentHasher.update(`PATH:${f.path.length}:${f.path}\n`);
|
|
67
|
+
contentHasher.update(`SIZE:${f.size}\n`);
|
|
68
|
+
contentHasher.update(f.data);
|
|
69
|
+
contentHasher.update("\n");
|
|
70
|
+
}
|
|
71
|
+
const contentHash = contentHasher.digest("hex");
|
|
54
72
|
const pack = tarPack();
|
|
55
73
|
(async () => {
|
|
56
|
-
for (const file of
|
|
57
|
-
const data = readFileSync(join(options.cwd, file.path));
|
|
74
|
+
for (const file of fileBuffers) {
|
|
58
75
|
await new Promise((resolve, reject) => {
|
|
59
|
-
pack.entry({ name: file.path, size: data.length }, data, (err) => err ? reject(err) : resolve());
|
|
76
|
+
pack.entry({ name: file.path, size: file.data.length }, file.data, (err) => err ? reject(err) : resolve());
|
|
60
77
|
});
|
|
61
78
|
}
|
|
62
79
|
pack.finalize();
|
|
@@ -64,12 +81,16 @@ export async function createTarball(options) {
|
|
|
64
81
|
const gzip = createGzip();
|
|
65
82
|
const nodeStream = pack.pipe(gzip);
|
|
66
83
|
const webStream = Readable.toWeb(nodeStream);
|
|
67
|
-
const topFiles = [...
|
|
84
|
+
const topFiles = [...fileBuffers]
|
|
85
|
+
.sort((a, b) => b.size - a.size)
|
|
86
|
+
.slice(0, 5)
|
|
87
|
+
.map((f) => ({ path: f.path, size: f.size }));
|
|
68
88
|
return {
|
|
69
89
|
stream: webStream,
|
|
70
90
|
bytes: totalBytes,
|
|
71
|
-
fileCount:
|
|
91
|
+
fileCount: fileBuffers.length,
|
|
72
92
|
topFiles,
|
|
93
|
+
contentHash,
|
|
73
94
|
};
|
|
74
95
|
}
|
|
75
96
|
//# sourceMappingURL=tarball.js.map
|