gencow 0.1.282 → 0.1.283
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/bin/gencow.mjs
CHANGED
|
@@ -466,8 +466,7 @@ ${BOLD}App management:${RESET}
|
|
|
466
466
|
${GREEN}app list${RESET} List your apps
|
|
467
467
|
${GREEN}app create${RESET} Create a new app
|
|
468
468
|
${GREEN}app delete${RESET} Delete an app ${DIM}(confirmation required)${RESET}
|
|
469
|
-
${GREEN}app status${RESET}
|
|
470
|
-
${GREEN}app stop|resume|wake${RESET} Control the app runtime ${DIM}(stop asks to confirm on prod)${RESET}
|
|
469
|
+
${GREEN}app status|stop|resume|wake${RESET} Show status / control runtime ${DIM}(stop asks to confirm on prod)${RESET}
|
|
471
470
|
|
|
472
471
|
${BOLD}Ops (Observability):${RESET}
|
|
473
472
|
${GREEN}logs${RESET} Show local dev server logs ${DIM}(--lines N, --follow)${RESET}
|
|
@@ -6,6 +6,7 @@ import { prodRetryCommandLine, reconcileProductionAppTarget } from "./deploy-app
|
|
|
6
6
|
import { readJsonObjectResponse } from "./http-response-json.mjs";
|
|
7
7
|
import { BOLD, DIM, GREEN, RED, RESET, error, info, log, success } from "./output.mjs";
|
|
8
8
|
import { prodCreateFailureMessage } from "./prod-create-failure.mjs";
|
|
9
|
+
import { credentialEnvNameOf } from "./prod-create-auth-diagnostic.mjs";
|
|
9
10
|
|
|
10
11
|
export async function ensureProductionDeployTarget({
|
|
11
12
|
appId,
|
|
@@ -110,7 +111,12 @@ export async function ensureProductionDeployTarget({
|
|
|
110
111
|
logImpl(` ${GREEN}gencow upgrade${RESET} ${DIM}← Upgrade to Startup${RESET}`);
|
|
111
112
|
logImpl("");
|
|
112
113
|
} else {
|
|
113
|
-
errorImpl(
|
|
114
|
+
errorImpl(
|
|
115
|
+
prodCreateFailureMessage(errData, createProdRes, {
|
|
116
|
+
requestedRegion: region,
|
|
117
|
+
credentialEnvName: credentialEnvNameOf(creds),
|
|
118
|
+
}),
|
|
119
|
+
);
|
|
114
120
|
}
|
|
115
121
|
exitImpl(1);
|
|
116
122
|
return null;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { authCauseNextAction, safeAuthCauseCode } from "./release-auth-cause.mjs";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Renders the typed auth rejection from a create-prod response: 503 AUTH_LOOKUP_UNAVAILABLE
|
|
5
|
+
* (temporary lookup failure) or 401 with a credential code or an account lifecycle code.
|
|
6
|
+
* Every field is allow-listed. The message text comes from this file, never from the server body.
|
|
7
|
+
*/
|
|
8
|
+
const CREDENTIAL_REJECTED_CODE = "APP_CREATE_AUTH_REQUIRED";
|
|
9
|
+
const LOOKUP_UNAVAILABLE_CODE = "AUTH_LOOKUP_UNAVAILABLE";
|
|
10
|
+
const ACCOUNT_MESSAGES = new Map([
|
|
11
|
+
["ACCOUNT_DELETED", "This account has been deleted."],
|
|
12
|
+
["ACCOUNT_DELETION_PENDING", "This account is pending deletion."],
|
|
13
|
+
["ACCOUNT_SUSPENDED", "This account is suspended."],
|
|
14
|
+
]);
|
|
15
|
+
const CORRELATION_ID_PATTERN = /^[A-Za-z0-9_-]{8,128}$/u;
|
|
16
|
+
const ACCOUNT_NEXT_ACTION =
|
|
17
|
+
"running `gencow login` or `gencow whoami` does not change the account state. Check the account status in the Gencow dashboard, then run the command again.";
|
|
18
|
+
|
|
19
|
+
export function readCreateProdAuthDiagnostic(body, response) {
|
|
20
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return null;
|
|
21
|
+
if (body.stage !== "auth") return null;
|
|
22
|
+
const correlationId =
|
|
23
|
+
typeof body.correlationId === "string" && CORRELATION_ID_PATTERN.test(body.correlationId)
|
|
24
|
+
? body.correlationId
|
|
25
|
+
: null;
|
|
26
|
+
|
|
27
|
+
if (response?.status === 503 && body.code === LOOKUP_UNAVAILABLE_CODE) {
|
|
28
|
+
return { kind: "unavailable", code: LOOKUP_UNAVAILABLE_CODE, correlationId };
|
|
29
|
+
}
|
|
30
|
+
if (response?.status !== 401) return null;
|
|
31
|
+
if (body.code === CREDENTIAL_REJECTED_CODE) {
|
|
32
|
+
return {
|
|
33
|
+
kind: "credential",
|
|
34
|
+
code: CREDENTIAL_REJECTED_CODE,
|
|
35
|
+
causeCode: safeAuthCauseCode(body.causeCode),
|
|
36
|
+
correlationId,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (ACCOUNT_MESSAGES.has(body.code)) {
|
|
40
|
+
return { kind: "account", code: body.code, correlationId };
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// The env credential that overrides `gencow login`, or null. Same rule as the deploy target helpers.
|
|
46
|
+
export function credentialEnvNameOf(creds) {
|
|
47
|
+
return creds?.credentialSource === "environment" &&
|
|
48
|
+
(creds.credentialEnvName === "GENCOW_TOKEN" || creds.credentialEnvName === "GENCOW_DEPLOY_TOKEN")
|
|
49
|
+
? creds.credentialEnvName
|
|
50
|
+
: null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function formatCreateProdAuthMessage(diagnostic, credentialEnvName = null) {
|
|
54
|
+
const correlation = diagnostic.correlationId ?? "none returned";
|
|
55
|
+
if (diagnostic.kind === "unavailable") {
|
|
56
|
+
return [
|
|
57
|
+
"Prod app creation failed: Authentication lookup temporarily unavailable",
|
|
58
|
+
`Code: ${diagnostic.code}`,
|
|
59
|
+
"Stage: auth",
|
|
60
|
+
"Changed: nothing (no prod app was created)",
|
|
61
|
+
"Retryable: yes",
|
|
62
|
+
"Next: wait a short while, then run the same command again. If it keeps failing, send the Correlation ID.",
|
|
63
|
+
`Correlation ID: ${correlation}`,
|
|
64
|
+
].join("\n");
|
|
65
|
+
}
|
|
66
|
+
if (diagnostic.kind === "account") {
|
|
67
|
+
return [
|
|
68
|
+
`Prod app creation failed: ${ACCOUNT_MESSAGES.get(diagnostic.code)}`,
|
|
69
|
+
`Code: ${diagnostic.code}`,
|
|
70
|
+
"Stage: auth",
|
|
71
|
+
"Changed: nothing (no prod app was created)",
|
|
72
|
+
"Retryable: no",
|
|
73
|
+
`Next: ${ACCOUNT_NEXT_ACTION}`,
|
|
74
|
+
`Correlation ID: ${correlation}`,
|
|
75
|
+
].join("\n");
|
|
76
|
+
}
|
|
77
|
+
const lines = [
|
|
78
|
+
"Prod app creation failed: CLI authentication is required",
|
|
79
|
+
`Code: ${diagnostic.code}`,
|
|
80
|
+
"Stage: auth",
|
|
81
|
+
];
|
|
82
|
+
if (diagnostic.causeCode) lines.push(`Cause: ${diagnostic.causeCode}`);
|
|
83
|
+
lines.push("Changed: nothing (no prod app was created)", "Retryable: no");
|
|
84
|
+
lines.push(`Next: ${authCauseNextAction(credentialEnvName)}`);
|
|
85
|
+
lines.push(`Correlation ID: ${correlation}`);
|
|
86
|
+
return lines.join("\n");
|
|
87
|
+
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
formatRegionUnavailableMessage,
|
|
4
4
|
readRegionUnavailableDiagnostic,
|
|
5
5
|
} from "./prod-create-region-diagnostic.mjs";
|
|
6
|
+
import { formatCreateProdAuthMessage, readCreateProdAuthDiagnostic } from "./prod-create-auth-diagnostic.mjs";
|
|
6
7
|
|
|
7
8
|
/** One rendering of a failed `create-prod` response for every CLI deploy path. */
|
|
8
9
|
export function prodCreateFailureMessage(errData, response, options = {}) {
|
|
@@ -10,6 +11,8 @@ export function prodCreateFailureMessage(errData, response, options = {}) {
|
|
|
10
11
|
response.status === 503
|
|
11
12
|
? "Prod app creation is temporarily unavailable."
|
|
12
13
|
: errData?.error || response.statusText || `HTTP ${response.status}`;
|
|
14
|
+
const authDiagnostic = readCreateProdAuthDiagnostic(errData, response);
|
|
15
|
+
if (authDiagnostic) return formatCreateProdAuthMessage(authDiagnostic, options.credentialEnvName ?? null);
|
|
13
16
|
const regionDiagnostic = readRegionUnavailableDiagnostic(errData, response);
|
|
14
17
|
if (regionDiagnostic) {
|
|
15
18
|
return formatRegionUnavailableMessage(regionDiagnostic, fallback, options.requestedRegion ?? null);
|
package/lib/static-command.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import { BOLD, CYAN, DIM, RESET, error, info, log, success } from "./output.mjs";
|
|
19
19
|
import { platformFetch } from "./platform-client.mjs";
|
|
20
20
|
import { prodCreateFailureMessage } from "./prod-create-failure.mjs";
|
|
21
|
+
import { credentialEnvNameOf } from "./prod-create-auth-diagnostic.mjs";
|
|
21
22
|
import { readJsonObjectResponse } from "./http-response-json.mjs";
|
|
22
23
|
import { detectStaticDeployBackend, preflightStaticDeployArtifact } from "./static-deploy-command.mjs";
|
|
23
24
|
|
|
@@ -138,7 +139,12 @@ async function ensureStaticProductionTarget({
|
|
|
138
139
|
|
|
139
140
|
if (!createProdRes.ok) {
|
|
140
141
|
const errData = await readJsonObjectResponse(createProdRes);
|
|
141
|
-
errorImpl(
|
|
142
|
+
errorImpl(
|
|
143
|
+
prodCreateFailureMessage(errData, createProdRes, {
|
|
144
|
+
requestedRegion: region,
|
|
145
|
+
credentialEnvName: credentialEnvNameOf(creds),
|
|
146
|
+
}),
|
|
147
|
+
);
|
|
142
148
|
exitImpl(1);
|
|
143
149
|
return null;
|
|
144
150
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gencow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.283",
|
|
4
4
|
"description": "Gencow — AI Backend Engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"ai": "^6.0.314",
|
|
41
41
|
"better-auth": "1.7.11",
|
|
42
42
|
"postgres": "^3.4.9",
|
|
43
|
+
"@gencow/client": "0.2.8",
|
|
43
44
|
"@gencow/core": "0.1.47",
|
|
44
45
|
"@gencow/react": "0.2.8",
|
|
45
46
|
"@gencow/server": "0.1.3",
|
|
46
|
-
"@gencow/client": "0.2.8",
|
|
47
47
|
"@gencow/shared": "0.0.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|