@steve31415/baselib 3.8.2 → 3.9.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.
- package/dist/deploy/config.js +8 -0
- package/dist/deploy/deploy.js +4 -1
- package/dist/deploy/types.d.ts +4 -0
- package/dist/llm/complete.js +7 -1
- package/dist/llm/types.d.ts +3 -2
- package/dist/llm/types.js +1 -1
- package/package.json +1 -1
package/dist/deploy/config.js
CHANGED
|
@@ -53,6 +53,14 @@ export function validateConfig(raw) {
|
|
|
53
53
|
fail(`updateSecrets.${key} (want <secret-name>:<numeric version>)`);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
if (c.updateEnv) {
|
|
57
|
+
for (const [key, value] of Object.entries(c.updateEnv)) {
|
|
58
|
+
if (!/^[A-Z][A-Z0-9_]*$/.test(key) || key === 'BUILD_ID')
|
|
59
|
+
fail(`updateEnv.${key} (key)`);
|
|
60
|
+
if (typeof value !== 'string' || /[|\n]/.test(value))
|
|
61
|
+
fail(`updateEnv.${key} (want a string without '|' or newlines)`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
56
64
|
return c;
|
|
57
65
|
}
|
|
58
66
|
export async function loadConfig(repoRoot) {
|
package/dist/deploy/deploy.js
CHANGED
|
@@ -241,11 +241,14 @@ export async function runDeploy(options) {
|
|
|
241
241
|
});
|
|
242
242
|
continue;
|
|
243
243
|
}
|
|
244
|
+
// One --update-env-vars with gcloud's alternate-delimiter form (^|^ …)
|
|
245
|
+
// so declared values may contain commas; '|' is rejected by validateConfig.
|
|
246
|
+
const envPairs = [`BUILD_ID=${sha}`, ...Object.entries(config.updateEnv ?? {}).map(([k, v]) => `${k}=${v}`)];
|
|
244
247
|
const updateArgs = [
|
|
245
248
|
'run', 'services', 'update', service.name,
|
|
246
249
|
...gcloudBase, '--region', config.region, '--quiet', '--format=json',
|
|
247
250
|
'--image', imageDigest,
|
|
248
|
-
'--update-env-vars',
|
|
251
|
+
'--update-env-vars', `^|^${envPairs.join('|')}`,
|
|
249
252
|
'--update-labels', `pw-build-sha=${sha.slice(0, 40)}`,
|
|
250
253
|
];
|
|
251
254
|
if (config.updateSecrets) {
|
package/dist/deploy/types.d.ts
CHANGED
|
@@ -47,6 +47,10 @@ export interface DeployConfig {
|
|
|
47
47
|
releasePrefix: string;
|
|
48
48
|
/** Secrets re-pinned on every routine deploy (name -> secret:version). */
|
|
49
49
|
updateSecrets?: Record<string, string>;
|
|
50
|
+
/** Non-secret env vars asserted on every routine deploy (name -> value), so a
|
|
51
|
+
* runtime-config change is a commit the deploy carries rather than a hand-run
|
|
52
|
+
* `gcloud run services update`. Undeclared vars are left as they are. */
|
|
53
|
+
updateEnv?: Record<string, string>;
|
|
50
54
|
/** Refuse to deploy across a migrations/ diff (notes2 semantics). */
|
|
51
55
|
refuseMigrationDiffOnDeploy?: boolean;
|
|
52
56
|
/** Repo-relative path of an optional ES module exporting hooks. */
|
package/dist/llm/complete.js
CHANGED
|
@@ -126,7 +126,13 @@ export async function llmComplete(request) {
|
|
|
126
126
|
request.logger?.warn('llm.failover_attempt', {
|
|
127
127
|
failedModel: modelName,
|
|
128
128
|
failedProvider: modelEntry.provider,
|
|
129
|
-
|
|
129
|
+
// Provider/network/parse errors can echo prompts, credentials or private
|
|
130
|
+
// response bodies. Keep their text in the returned API only, never logs.
|
|
131
|
+
errorClass: err instanceof LLMError ? 'LLMError' : err instanceof Error ? 'Error' : 'NonError',
|
|
132
|
+
...(err instanceof LLMError && typeof err.statusCode === 'number' && Number.isFinite(err.statusCode)
|
|
133
|
+
? { statusCode: err.statusCode } : {}),
|
|
134
|
+
isRetryable: err instanceof LLMError && err.isRetryable === true,
|
|
135
|
+
declined: err instanceof LLMError && err.declined === true,
|
|
130
136
|
attemptNumber: failedAttempts.length,
|
|
131
137
|
nextModel: modelsToTry[failedAttempts.length] ?? 'none',
|
|
132
138
|
});
|
package/dist/llm/types.d.ts
CHANGED
|
@@ -116,18 +116,19 @@ export interface LLMResponse {
|
|
|
116
116
|
latencyMs: number;
|
|
117
117
|
/** True if the primary model failed and a fallback was used. */
|
|
118
118
|
failedOver: boolean;
|
|
119
|
-
/** Details of each failed attempt before
|
|
119
|
+
/** Details of each failed attempt before success; error text can contain private input. Do not log verbatim. */
|
|
120
120
|
failedAttempts: FailedAttempt[];
|
|
121
121
|
}
|
|
122
122
|
/** Details of a failed provider attempt. */
|
|
123
123
|
export interface FailedAttempt {
|
|
124
124
|
provider: ProviderName;
|
|
125
125
|
model: string;
|
|
126
|
+
/** Provider detail may echo private input or credentials. Do not log verbatim. */
|
|
126
127
|
error: string;
|
|
127
128
|
/** True when this attempt failed because the model declined (vs. an infra error). */
|
|
128
129
|
declined?: boolean;
|
|
129
130
|
}
|
|
130
|
-
/** Error thrown when an LLM provider call fails. */
|
|
131
|
+
/** Error thrown when an LLM provider call fails. Its message may contain private input; do not log verbatim. */
|
|
131
132
|
export declare class LLMError extends Error {
|
|
132
133
|
provider: ProviderName;
|
|
133
134
|
model: string;
|
package/dist/llm/types.js
CHANGED
package/package.json
CHANGED