@walkeros/cli 4.7.1 → 4.7.2-next-1791213015481

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/index.d.ts CHANGED
@@ -738,7 +738,7 @@ type ValidateOptions = z.infer<typeof ValidateOptionsSchema>;
738
738
  * Every code an error, warning or skip of `validate` can carry. Agents and
739
739
  * tests branch on these, never on message text.
740
740
  */
741
- declare const VALIDATE_CODES: readonly ["INPUT_ERROR", "SERIALIZATION_ERROR", "OPTION_NOT_APPLICABLE", "FLOW_NOT_FOUND", "ENTRY_NOT_FOUND", "AMBIGUOUS_ENTRY", "UNSUPPORTED_SECTION", "INVALID_PATH", "SCHEMA_VALIDATION", "CONFIG_WARNING", "EMPTY_FLOWS", "UNKNOWN_KEY", "CONFLICT", "MISSING_PACKAGE", "OBSOLETE_CODE_STRING", "INVALID_IMPORT", "INVALID_CODE_SHAPE", "PACKAGE_VERSION_MISSING", "DEPRECATED_PACKAGE", "UNKNOWN_ROUTE_TARGET", "ROUTE_DEAD_CODE", "ROUTE_EMPTY_MANY", "ROUTE_SINGLE_MANY", "ROUTE_FIRST_MATCH", "INCOMPATIBLE_EXAMPLES", "EXAMPLES_INCOMPLETE", "CONTRACT_VIOLATION", "MAPPING_DOT_KEY", "FLOW_REF_WARNING", "FLOW_CYCLE", "VAR_CYCLE", "INVALID_COMPONENT_NAME", "INVALID_REFERENCE", "STORE_REFERENCE_NOT_FOUND", "UNRESOLVED_REFERENCE", "MISSING_ENV", "WEB_SECRET_REF", "UNRESOLVED_CONTRACT", "ENTRY_SCHEMA", "NO_CONTRACT_SECTION", "INVALID_CONTRACT", "FLAT_CONTRACT_SHAPE", "INVALID_CONTRACT_ENTRY", "UNKNOWN_CONTRACT_KEY", "INVALID_TAGGING", "INVALID_SCHEMA", "INVALID_EXTENDS", "INVALID_SECTION", "INVALID_EVENTS", "CIRCULAR_EXTENDS", "INVALID_ENTITY_KEY", "INVALID_ENTITY", "INVALID_ACTION_KEY", "INVALID_SCHEMA_ENTRY", "NOT_AN_OBJECT", "MISSING_EVENT_NAME", "EMPTY_EVENT_NAME", "INVALID_EVENT_NAME", "INVALID_MAPPING_TYPE", "INVALID_EVENT_PATTERN", "INVALID_RULE_TYPE", "CATCH_ALL_NOT_LAST", "GATED_BY_ERRORS", "CONTRACT_NOT_STATIC", "NO_PACKAGE", "NO_SETTINGS_SCHEMA", "SCHEMA_UNAVAILABLE"];
741
+ declare const VALIDATE_CODES: readonly ["INPUT_ERROR", "SERIALIZATION_ERROR", "OPTION_NOT_APPLICABLE", "FLOW_NOT_FOUND", "ENTRY_NOT_FOUND", "AMBIGUOUS_ENTRY", "UNSUPPORTED_SECTION", "INVALID_PATH", "SCHEMA_VALIDATION", "CONFIG_WARNING", "EMPTY_FLOWS", "UNKNOWN_KEY", "CONFLICT", "MISSING_PACKAGE", "OBSOLETE_CODE_STRING", "INVALID_IMPORT", "INVALID_CODE_SHAPE", "PACKAGE_VERSION_MISSING", "DEPRECATED_PACKAGE", "UNKNOWN_ROUTE_TARGET", "ROUTE_DEAD_CODE", "ROUTE_EMPTY_MANY", "ROUTE_SINGLE_MANY", "ROUTE_FIRST_MATCH", "INCOMPATIBLE_EXAMPLES", "EXAMPLES_INCOMPLETE", "CONTRACT_VIOLATION", "MAPPING_DOT_KEY", "FLOW_REF_WARNING", "FLOW_CYCLE", "VAR_CYCLE", "INVALID_COMPONENT_NAME", "INVALID_REFERENCE", "STORE_REFERENCE_NOT_FOUND", "STATE_STORE_UNKNOWN", "STATE_STORE_FILE", "TRANSFORMER_MAPPING_NO_OP", "UNRESOLVED_REFERENCE", "MISSING_ENV", "WEB_SECRET_REF", "UNRESOLVED_CONTRACT", "ENTRY_SCHEMA", "NO_CONTRACT_SECTION", "INVALID_CONTRACT", "FLAT_CONTRACT_SHAPE", "INVALID_CONTRACT_ENTRY", "UNKNOWN_CONTRACT_KEY", "INVALID_TAGGING", "INVALID_SCHEMA", "INVALID_EXTENDS", "INVALID_SECTION", "INVALID_EVENTS", "CIRCULAR_EXTENDS", "INVALID_ENTITY_KEY", "INVALID_ENTITY", "INVALID_ACTION_KEY", "INVALID_SCHEMA_ENTRY", "NOT_AN_OBJECT", "MISSING_EVENT_NAME", "EMPTY_EVENT_NAME", "INVALID_EVENT_NAME", "INVALID_MAPPING_TYPE", "INVALID_EVENT_PATTERN", "INVALID_RULE_TYPE", "CATCH_ALL_NOT_LAST", "GATED_BY_ERRORS", "CONTRACT_NOT_STATIC", "NO_PACKAGE", "NO_SETTINGS_SCHEMA", "SCHEMA_UNAVAILABLE"];
742
742
  type ValidateCode = (typeof VALIDATE_CODES)[number];
743
743
  /**
744
744
  * Named checks a run includes (`details.scope.checks`). `file:` checks run
@@ -7104,13 +7104,23 @@ declare function setFeedbackPreference(anonymous: boolean): void;
7104
7104
  declare function getFeedbackPreference(): boolean | undefined;
7105
7105
  /**
7106
7106
  * Set the default project ID in the config.
7107
- * Throws if no config exists (user not authenticated).
7107
+ *
7108
+ * Needs a credential: `WALKEROS_TOKEN`, or a stored login. An env-only setup
7109
+ * gets a config file that holds just the default. Refuses while
7110
+ * `WALKEROS_PROJECT_ID` names another project, because the variable takes
7111
+ * precedence (see `resolveProjectId`) and the write would change nothing.
7108
7112
  */
7109
7113
  declare function setDefaultProject(projectId: string): void;
7110
7114
  /**
7111
7115
  * Get the default project ID from the config, or null if not set.
7112
7116
  */
7113
7117
  declare function getDefaultProject(): string | null;
7118
+ /**
7119
+ * The project a call without a `projectId` works on: `WALKEROS_PROJECT_ID`,
7120
+ * then the config's default, or null when neither names one. The one
7121
+ * resolution `requireProjectId()` and the local MCP door share.
7122
+ */
7123
+ declare function resolveProjectId(): string | null;
7114
7124
  /**
7115
7125
  * Resolve the API token using priority order:
7116
7126
  * 1. WALKEROS_TOKEN env var
@@ -7415,4 +7425,4 @@ declare module '@walkeros/core' {
7415
7425
  }
7416
7426
  }
7417
7427
 
7418
- export { type AddThreadMessageOptions, type ApiAuth, ApiError, type ApiErrorDetail, type ApiRequestInit, type ApiTransport, BUILD_ERROR_CODES, BUILD_MANIFEST_ENV, BUILD_MANIFEST_VERSION, type BuildArtifact, BuildArtifactSchema, BuildBundleArtifactSchema, type BuildErrorCode, type BuildManifest, BuildManifestSchema, type BuildOptions, type BuildResult, BuildResultSchema, BuildWrapArtifactSchema, type BuildWrapOptions, BuildWrapOptionsSchema, type BundleStats, type CLIBuildOptions, type ClientContext, type ClientOperation, type ClientType, type CompareContractInput, type CompleteDeviceLoginOptions, type ContractClient, type ContractComparison, type ContractVerdict, type CreatePreviewOptions, type CreateSecretOptions, type CreateThreadOptions, DEPLOYMENT_STATUSES, DEPLOYMENT_TYPES, type DeletePreviewOptions, type DeleteSecretOptions, type DeployOptions, DeploymentAmbiguityError, type DeploymentStatus, type DeploymentSummaryForFlow, type DeploymentType, type DeviceAuthorization, type DeviceLoginResult, type EndObserveSessionOptions, type FeedbackOptions, type GetFrameOptions, type GetObserveSessionOptions, type GetPreviewOptions, type GetReleaseOptions, type GlobalOptions, type HealthResult, type ListDeploymentsOptions, type ListFlowsOptions, type ListFramesOptions, type ListJourneysOptions, type ListKnowledgeOptions, type ListPageFramesOptions, type ListPreviewsOptions, type ListProjectsOptions, type ListReleasesOptions, type ListSecretsOptions, type ListStepHistoryOptions, type ListThreadsOptions, type LoginOptions, type LoginResult, type MinifyOptions, type MissingOperation, type OpenApiResult, type OperationKey, type PrepareInput, type PreparedFlow, type ProjectFlows, type PushResult, type RegrantPreviewOptions, type ReleaseDetailResponse, type ReleaseDiffResponse, type ReleaseIndexResponse, type ReleaseRationaleSummary, type ReleaseRef, type ResponseJson, type RunBuildManifestResult, type SSEEvent, type SSEParseResult, type SetReleaseRationaleOptions, type SimulateCollectorOptions, type SimulateDataOptions, type SimulateDestinationOptions, type SimulateSourceOptions, type SimulateTransformerOptions, type StartObserveSessionOptions, type ThreadAnchorType, type ThreadStatus, type UpdateSecretOptions, VALIDATE_CODES, VERSION, type ValidateCheck, type ValidateCode, type ValidateDeferred, type ValidateResult, type ValidateScope, type ValidateSkip, type ValidationError, type ValidationWarning, type WalkerOSConfig, type WrapSkeletonOptions, addThreadMessage, apiFetch, apiRequest, bakedClientOperations, bakedContractHash, bakedContractVersion, buildDataPayload, bundle, bundleCommand, canonicalContractHash, classifyStepProperties, clearAuthFields, clientContextHeaders, collectKnownSecrets, compareContract, completeDeviceLogin, containsCodeMarkers, createApiClient, createDeployCommand, createDeployment, createDeploymentCommand, createFlow, createFlowCommand, createPreview, createProject, createProjectCommand, createSecret, createThread, credentialSource, deleteConfig, deleteDeployment, deleteDeploymentByFlowId, deleteDeploymentCommand, deleteFlow, deleteFlowCommand, deletePreview, deleteProject, deleteProjectCommand, deleteSecret, deploy, deployCommand, deployFetch, duplicateFlow, duplicateFlowCommand, endObserveSession, feedback, feedbackCommand, fetchHealth, fetchOpenApi, formatContract, formatPushResult, getAuthHeaders, getClientContext, getDefaultProject, getDeployment, getDeploymentBySlug, getDeploymentBySlugCommand, getDeploymentCommand, getFeedbackPreference, getFlow, getFlowCommand, getFrame, getObserveSession, getPreview, getProject, getProjectCommand, getRelease, isDeploymentStatus, listAllFlows, listDeployments, listDeploymentsCommand, listFlows, listFlowsCommand, listFrames, listJourneys, listKnowledge, listPageFrames, listPreviews, listProjects, listProjectsCommand, listReleases, listSecrets, listStepHistory, listThreads, loadConfig, loadJsonConfig, login, loginCommand, logout, logoutCommand, mergeAuthHeaders, operationUrl, parseSSEEvents, publicFetch, push, pushCommand, readConfig, regrantPreview, requireProjectId, resetClientContext, resolveAccessToken, resolveAppUrl, resolveExportName, resolveManifestSource, resolveToken, runBuildManifest, selectDevExamples, setClientContext, setDefaultProject, setFeedbackPreference, setReleaseRationale, simulateCollector, simulateDestination, simulateSource, simulateTransformer, startDeviceAuthorization, startObserveSession, index as telemetry, telemetryDisableCommand, telemetryEnableCommand, telemetryStatusCommand, throwApiError, updateFlow, updateFlowCommand, updateProject, updateProjectCommand, updateSecret, validate, validateCommand, whoami, whoamiCommand, wrapSkeleton, writeConfig };
7428
+ export { type AddThreadMessageOptions, type ApiAuth, ApiError, type ApiErrorDetail, type ApiRequestInit, type ApiTransport, BUILD_ERROR_CODES, BUILD_MANIFEST_ENV, BUILD_MANIFEST_VERSION, type BuildArtifact, BuildArtifactSchema, BuildBundleArtifactSchema, type BuildErrorCode, type BuildManifest, BuildManifestSchema, type BuildOptions, type BuildResult, BuildResultSchema, BuildWrapArtifactSchema, type BuildWrapOptions, BuildWrapOptionsSchema, type BundleStats, type CLIBuildOptions, type ClientContext, type ClientOperation, type ClientType, type CompareContractInput, type CompleteDeviceLoginOptions, type ContractClient, type ContractComparison, type ContractVerdict, type CreatePreviewOptions, type CreateSecretOptions, type CreateThreadOptions, DEPLOYMENT_STATUSES, DEPLOYMENT_TYPES, type DeletePreviewOptions, type DeleteSecretOptions, type DeployOptions, DeploymentAmbiguityError, type DeploymentStatus, type DeploymentSummaryForFlow, type DeploymentType, type DeviceAuthorization, type DeviceLoginResult, type EndObserveSessionOptions, type FeedbackOptions, type GetFrameOptions, type GetObserveSessionOptions, type GetPreviewOptions, type GetReleaseOptions, type GlobalOptions, type HealthResult, type ListDeploymentsOptions, type ListFlowsOptions, type ListFramesOptions, type ListJourneysOptions, type ListKnowledgeOptions, type ListPageFramesOptions, type ListPreviewsOptions, type ListProjectsOptions, type ListReleasesOptions, type ListSecretsOptions, type ListStepHistoryOptions, type ListThreadsOptions, type LoginOptions, type LoginResult, type MinifyOptions, type MissingOperation, type OpenApiResult, type OperationKey, type PrepareInput, type PreparedFlow, type ProjectFlows, type PushResult, type RegrantPreviewOptions, type ReleaseDetailResponse, type ReleaseDiffResponse, type ReleaseIndexResponse, type ReleaseRationaleSummary, type ReleaseRef, type ResponseJson, type RunBuildManifestResult, type SSEEvent, type SSEParseResult, type SetReleaseRationaleOptions, type SimulateCollectorOptions, type SimulateDataOptions, type SimulateDestinationOptions, type SimulateSourceOptions, type SimulateTransformerOptions, type StartObserveSessionOptions, type ThreadAnchorType, type ThreadStatus, type UpdateSecretOptions, VALIDATE_CODES, VERSION, type ValidateCheck, type ValidateCode, type ValidateDeferred, type ValidateResult, type ValidateScope, type ValidateSkip, type ValidationError, type ValidationWarning, type WalkerOSConfig, type WrapSkeletonOptions, addThreadMessage, apiFetch, apiRequest, bakedClientOperations, bakedContractHash, bakedContractVersion, buildDataPayload, bundle, bundleCommand, canonicalContractHash, classifyStepProperties, clearAuthFields, clientContextHeaders, collectKnownSecrets, compareContract, completeDeviceLogin, containsCodeMarkers, createApiClient, createDeployCommand, createDeployment, createDeploymentCommand, createFlow, createFlowCommand, createPreview, createProject, createProjectCommand, createSecret, createThread, credentialSource, deleteConfig, deleteDeployment, deleteDeploymentByFlowId, deleteDeploymentCommand, deleteFlow, deleteFlowCommand, deletePreview, deleteProject, deleteProjectCommand, deleteSecret, deploy, deployCommand, deployFetch, duplicateFlow, duplicateFlowCommand, endObserveSession, feedback, feedbackCommand, fetchHealth, fetchOpenApi, formatContract, formatPushResult, getAuthHeaders, getClientContext, getDefaultProject, getDeployment, getDeploymentBySlug, getDeploymentBySlugCommand, getDeploymentCommand, getFeedbackPreference, getFlow, getFlowCommand, getFrame, getObserveSession, getPreview, getProject, getProjectCommand, getRelease, isDeploymentStatus, listAllFlows, listDeployments, listDeploymentsCommand, listFlows, listFlowsCommand, listFrames, listJourneys, listKnowledge, listPageFrames, listPreviews, listProjects, listProjectsCommand, listReleases, listSecrets, listStepHistory, listThreads, loadConfig, loadJsonConfig, login, loginCommand, logout, logoutCommand, mergeAuthHeaders, operationUrl, parseSSEEvents, publicFetch, push, pushCommand, readConfig, regrantPreview, requireProjectId, resetClientContext, resolveAccessToken, resolveAppUrl, resolveExportName, resolveManifestSource, resolveProjectId, resolveToken, runBuildManifest, selectDevExamples, setClientContext, setDefaultProject, setFeedbackPreference, setReleaseRationale, simulateCollector, simulateDestination, simulateSource, simulateTransformer, startDeviceAuthorization, startObserveSession, index as telemetry, telemetryDisableCommand, telemetryEnableCommand, telemetryStatusCommand, throwApiError, updateFlow, updateFlowCommand, updateProject, updateProjectCommand, updateSecret, validate, validateCommand, whoami, whoamiCommand, wrapSkeleton, writeConfig };
package/dist/index.js CHANGED
@@ -86,6 +86,116 @@ import {
86
86
  import { randomBytes } from "crypto";
87
87
  import { join } from "path";
88
88
  import { homedir } from "os";
89
+
90
+ // src/core/api-error.ts
91
+ var EXIT_RETRYABLE = 75;
92
+ var ApiError = class extends Error {
93
+ code;
94
+ details;
95
+ status;
96
+ retryable;
97
+ retryAfterSeconds;
98
+ // Populated only for CLIENT_OUTDATED responses (HTTP 426).
99
+ minVersion;
100
+ clientVersion;
101
+ client;
102
+ upgrade;
103
+ docs;
104
+ constructor(message, options) {
105
+ super(message);
106
+ this.name = "ApiError";
107
+ this.code = options?.code;
108
+ this.details = options?.details;
109
+ this.status = options?.status;
110
+ this.retryable = options?.retryable;
111
+ this.retryAfterSeconds = options?.retryAfterSeconds;
112
+ this.minVersion = options?.minVersion;
113
+ this.clientVersion = options?.clientVersion;
114
+ this.client = options?.client;
115
+ this.upgrade = options?.upgrade;
116
+ this.docs = options?.docs;
117
+ }
118
+ };
119
+ function notAuthenticatedError() {
120
+ return new ApiError("Not authenticated. Run `walkeros auth login` first.", {
121
+ code: "UNAUTHORIZED"
122
+ });
123
+ }
124
+ function extractApiErrorOptions(error, fallbackMessage) {
125
+ if (!error || typeof error !== "object" || !("error" in error) || typeof error.error !== "object") {
126
+ return null;
127
+ }
128
+ const inner = error.error;
129
+ const message = inner.message || fallbackMessage;
130
+ const code = inner.code;
131
+ const details = inner.details?.errors;
132
+ const options = { code, details };
133
+ if (code === "CLIENT_OUTDATED") {
134
+ options.minVersion = inner.minVersion;
135
+ options.clientVersion = inner.clientVersion;
136
+ options.client = inner.client;
137
+ options.upgrade = inner.upgrade;
138
+ options.docs = inner.docs;
139
+ }
140
+ return { message, options };
141
+ }
142
+ function throwApiError(error, fallbackMessage) {
143
+ const extracted = extractApiErrorOptions(error, fallbackMessage);
144
+ if (extracted) throw new ApiError(extracted.message, extracted.options);
145
+ throw new ApiError(fallbackMessage);
146
+ }
147
+ function parseRetryAfter(value) {
148
+ if (!value) return void 0;
149
+ const trimmed = value.trim();
150
+ if (/^\d+$/.test(trimmed)) return parseInt(trimmed, 10);
151
+ const when = Date.parse(trimmed);
152
+ if (Number.isNaN(when)) return void 0;
153
+ return Math.max(0, Math.round((when - Date.now()) / 1e3));
154
+ }
155
+ function throwApiResponseError(response, body, fallbackMessage) {
156
+ const status = response.status;
157
+ const retryAfterSeconds = parseRetryAfter(
158
+ response.headers.get("retry-after")
159
+ );
160
+ const retryable = status === 429 || status === 503 && retryAfterSeconds !== void 0;
161
+ const extracted = extractApiErrorOptions(body, fallbackMessage);
162
+ const message = extracted?.message ?? fallbackMessage;
163
+ const options = {
164
+ ...extracted?.options ?? {},
165
+ status,
166
+ retryable,
167
+ retryAfterSeconds
168
+ };
169
+ throw new ApiError(message, options);
170
+ }
171
+ function machineReadableErrorLine(err) {
172
+ const code = err instanceof ApiError ? err.code ?? "UNKNOWN" : "UNKNOWN";
173
+ const retryable = err instanceof ApiError ? err.retryable === true : false;
174
+ const retryAfter = err instanceof ApiError && err.retryAfterSeconds !== void 0 ? ` retryAfter=${err.retryAfterSeconds}` : "";
175
+ const message = err instanceof Error ? err.message : String(err);
176
+ return `error: code=${code} retryable=${retryable}${retryAfter} message=${message}`;
177
+ }
178
+ function handleCliError(err) {
179
+ console.error(machineReadableErrorLine(err));
180
+ if (err instanceof ApiError && err.code === "CLIENT_OUTDATED") {
181
+ console.error(`
182
+ ${err.message}
183
+ `);
184
+ if (err.upgrade) console.error(` Upgrade: ${err.upgrade}`);
185
+ if (err.docs) console.error(` Docs: ${err.docs}
186
+ `);
187
+ process.exit(2);
188
+ }
189
+ if (err instanceof ApiError && err.retryable) {
190
+ const hint = err.retryAfterSeconds !== void 0 ? ` Retry after ${err.retryAfterSeconds}s.` : " This is temporary, retry shortly.";
191
+ console.error(`${err.message}${hint}`);
192
+ process.exit(EXIT_RETRYABLE);
193
+ }
194
+ console.error(err instanceof Error ? err.message : String(err));
195
+ process.exit(1);
196
+ }
197
+
198
+ // src/lib/config-file.ts
89
199
  function getConfigDir() {
90
200
  const xdgConfig = process.env.XDG_CONFIG_HOME;
91
201
  const base = xdgConfig || join(homedir(), ".config");
@@ -156,17 +266,26 @@ function getFeedbackPreference() {
156
266
  const config = readConfig();
157
267
  return config?.anonymousFeedback;
158
268
  }
269
+ function hasStoredCredential(config) {
270
+ return Boolean(config?.token || config?.accessToken);
271
+ }
159
272
  function setDefaultProject(projectId) {
160
- const config = readConfig();
161
- if (!config) {
162
- throw new Error("Not authenticated. Run `walkeros auth login` first.");
163
- }
164
- writeConfig({ ...config, defaultProjectId: projectId });
273
+ if (!process.env.WALKEROS_TOKEN && !hasStoredCredential(readConfig()))
274
+ throw notAuthenticatedError();
275
+ const envProjectId = process.env.WALKEROS_PROJECT_ID;
276
+ if (envProjectId && envProjectId !== projectId)
277
+ throw new Error(
278
+ `WALKEROS_PROJECT_ID is set to ${envProjectId} and takes precedence over the default project, so ${projectId} would not be used. Pass projectId on each call, or unset WALKEROS_PROJECT_ID to change the default.`
279
+ );
280
+ writeConfig({ defaultProjectId: projectId });
165
281
  }
166
282
  function getDefaultProject() {
167
283
  const config = readConfig();
168
284
  return config?.defaultProjectId ?? null;
169
285
  }
286
+ function resolveProjectId() {
287
+ return process.env.WALKEROS_PROJECT_ID || getDefaultProject();
288
+ }
170
289
  function clearDefaultProject() {
171
290
  const config = readConfig();
172
291
  if (!config) return;
@@ -917,12 +1036,11 @@ async function getAuthHeaders() {
917
1036
  }
918
1037
  function credentialSource() {
919
1038
  if (process.env.WALKEROS_TOKEN) return "env";
920
- const config = readConfig();
921
- if (config?.token || config?.accessToken) return "config";
1039
+ if (hasStoredCredential(readConfig())) return "config";
922
1040
  return null;
923
1041
  }
924
1042
  function requireProjectId() {
925
- const projectId = process.env.WALKEROS_PROJECT_ID || getDefaultProject();
1043
+ const projectId = resolveProjectId();
926
1044
  if (!projectId)
927
1045
  throw new Error(
928
1046
  "No project selected. Set WALKEROS_PROJECT_ID or configure a default project."
@@ -7256,7 +7374,7 @@ import {
7256
7374
  REF_STORE,
7257
7375
  SECRET_MARKER_PREFIX as SECRET_MARKER_PREFIX3
7258
7376
  } from "@walkeros/core";
7259
- var CLIENT_HEADER = "walkeros-cli/4.7.1";
7377
+ var CLIENT_HEADER = "walkeros-cli/4.7.2-next-1791213015481";
7260
7378
  function createSettingsContext(configDir) {
7261
7379
  return { configDir, cache: /* @__PURE__ */ new Map(), compiled: /* @__PURE__ */ new Map() };
7262
7380
  }
@@ -7813,6 +7931,7 @@ function runFlowChecks(input, options) {
7813
7931
  flows: { [name]: flow }
7814
7932
  });
7815
7933
  errors.push(...structure.errors);
7934
+ warnings.push(...structure.warnings);
7816
7935
  });
7817
7936
  perFlow(["flow:routes"], (name, flow) => {
7818
7937
  lintFlowRoutes(name, flow, errors, warnings);
@@ -8434,6 +8553,9 @@ var VALIDATE_CODES = [
8434
8553
  "INVALID_COMPONENT_NAME",
8435
8554
  "INVALID_REFERENCE",
8436
8555
  "STORE_REFERENCE_NOT_FOUND",
8556
+ "STATE_STORE_UNKNOWN",
8557
+ "STATE_STORE_FILE",
8558
+ "TRANSFORMER_MAPPING_NO_OP",
8437
8559
  // Resolution (getFlowSettings, as the bundler resolves the flow)
8438
8560
  "UNRESOLVED_REFERENCE",
8439
8561
  "MISSING_ENV",
@@ -8924,8 +9046,7 @@ function createApiClient() {
8924
9046
  // here would go stale and never pick up a refresh.
8925
9047
  async onRequest({ request }) {
8926
9048
  const token = await resolveAccessToken();
8927
- if (!token)
8928
- throw new Error("Not authenticated. Run `walkeros auth login` first.");
9049
+ if (!token) throw notAuthenticatedError();
8929
9050
  requireSecureUrl(request.url);
8930
9051
  request.headers.set("Authorization", `Bearer ${token}`);
8931
9052
  return request;
@@ -8934,109 +9055,6 @@ function createApiClient() {
8934
9055
  return client;
8935
9056
  }
8936
9057
 
8937
- // src/core/api-error.ts
8938
- var EXIT_RETRYABLE = 75;
8939
- var ApiError = class extends Error {
8940
- code;
8941
- details;
8942
- status;
8943
- retryable;
8944
- retryAfterSeconds;
8945
- // Populated only for CLIENT_OUTDATED responses (HTTP 426).
8946
- minVersion;
8947
- clientVersion;
8948
- client;
8949
- upgrade;
8950
- docs;
8951
- constructor(message, options) {
8952
- super(message);
8953
- this.name = "ApiError";
8954
- this.code = options?.code;
8955
- this.details = options?.details;
8956
- this.status = options?.status;
8957
- this.retryable = options?.retryable;
8958
- this.retryAfterSeconds = options?.retryAfterSeconds;
8959
- this.minVersion = options?.minVersion;
8960
- this.clientVersion = options?.clientVersion;
8961
- this.client = options?.client;
8962
- this.upgrade = options?.upgrade;
8963
- this.docs = options?.docs;
8964
- }
8965
- };
8966
- function extractApiErrorOptions(error, fallbackMessage) {
8967
- if (!error || typeof error !== "object" || !("error" in error) || typeof error.error !== "object") {
8968
- return null;
8969
- }
8970
- const inner = error.error;
8971
- const message = inner.message || fallbackMessage;
8972
- const code = inner.code;
8973
- const details = inner.details?.errors;
8974
- const options = { code, details };
8975
- if (code === "CLIENT_OUTDATED") {
8976
- options.minVersion = inner.minVersion;
8977
- options.clientVersion = inner.clientVersion;
8978
- options.client = inner.client;
8979
- options.upgrade = inner.upgrade;
8980
- options.docs = inner.docs;
8981
- }
8982
- return { message, options };
8983
- }
8984
- function throwApiError(error, fallbackMessage) {
8985
- const extracted = extractApiErrorOptions(error, fallbackMessage);
8986
- if (extracted) throw new ApiError(extracted.message, extracted.options);
8987
- throw new ApiError(fallbackMessage);
8988
- }
8989
- function parseRetryAfter(value) {
8990
- if (!value) return void 0;
8991
- const trimmed = value.trim();
8992
- if (/^\d+$/.test(trimmed)) return parseInt(trimmed, 10);
8993
- const when = Date.parse(trimmed);
8994
- if (Number.isNaN(when)) return void 0;
8995
- return Math.max(0, Math.round((when - Date.now()) / 1e3));
8996
- }
8997
- function throwApiResponseError(response, body, fallbackMessage) {
8998
- const status = response.status;
8999
- const retryAfterSeconds = parseRetryAfter(
9000
- response.headers.get("retry-after")
9001
- );
9002
- const retryable = status === 429 || status === 503 && retryAfterSeconds !== void 0;
9003
- const extracted = extractApiErrorOptions(body, fallbackMessage);
9004
- const message = extracted?.message ?? fallbackMessage;
9005
- const options = {
9006
- ...extracted?.options ?? {},
9007
- status,
9008
- retryable,
9009
- retryAfterSeconds
9010
- };
9011
- throw new ApiError(message, options);
9012
- }
9013
- function machineReadableErrorLine(err) {
9014
- const code = err instanceof ApiError ? err.code ?? "UNKNOWN" : "UNKNOWN";
9015
- const retryable = err instanceof ApiError ? err.retryable === true : false;
9016
- const retryAfter = err instanceof ApiError && err.retryAfterSeconds !== void 0 ? ` retryAfter=${err.retryAfterSeconds}` : "";
9017
- const message = err instanceof Error ? err.message : String(err);
9018
- return `error: code=${code} retryable=${retryable}${retryAfter} message=${message}`;
9019
- }
9020
- function handleCliError(err) {
9021
- console.error(machineReadableErrorLine(err));
9022
- if (err instanceof ApiError && err.code === "CLIENT_OUTDATED") {
9023
- console.error(`
9024
- ${err.message}
9025
- `);
9026
- if (err.upgrade) console.error(` Upgrade: ${err.upgrade}`);
9027
- if (err.docs) console.error(` Docs: ${err.docs}
9028
- `);
9029
- process.exit(2);
9030
- }
9031
- if (err instanceof ApiError && err.retryable) {
9032
- const hint = err.retryAfterSeconds !== void 0 ? ` Retry after ${err.retryAfterSeconds}s.` : " This is temporary, retry shortly.";
9033
- console.error(`${err.message}${hint}`);
9034
- process.exit(EXIT_RETRYABLE);
9035
- }
9036
- console.error(err instanceof Error ? err.message : String(err));
9037
- process.exit(1);
9038
- }
9039
-
9040
9058
  // src/commands/auth/index.ts
9041
9059
  async function whoami() {
9042
9060
  const client = createApiClient();
@@ -9067,7 +9085,7 @@ async function listProjects(options = {}) {
9067
9085
  const { data, error } = await client.GET("/api/projects", {
9068
9086
  params: { query: { cursor: options.cursor, limit: options.limit } }
9069
9087
  });
9070
- if (error) throw new Error(error.error?.message || "Failed to list projects");
9088
+ if (error) throwApiError(error, "Failed to list projects");
9071
9089
  return data;
9072
9090
  }
9073
9091
  async function getProject(options = {}) {
@@ -9076,7 +9094,7 @@ async function getProject(options = {}) {
9076
9094
  const { data, error } = await client.GET("/api/projects/{projectId}", {
9077
9095
  params: { path: { projectId: id } }
9078
9096
  });
9079
- if (error) throw new Error(error.error?.message || "Failed to get project");
9097
+ if (error) throwApiError(error, "Failed to get project");
9080
9098
  return data;
9081
9099
  }
9082
9100
  async function createProject(options) {
@@ -9084,8 +9102,7 @@ async function createProject(options) {
9084
9102
  const { data, error } = await client.POST("/api/projects", {
9085
9103
  body: { name: options.name }
9086
9104
  });
9087
- if (error)
9088
- throw new Error(error.error?.message || "Failed to create project");
9105
+ if (error) throwApiError(error, "Failed to create project");
9089
9106
  return data;
9090
9107
  }
9091
9108
  async function updateProject(options) {
@@ -9095,8 +9112,7 @@ async function updateProject(options) {
9095
9112
  params: { path: { projectId: id } },
9096
9113
  body: { name: options.name }
9097
9114
  });
9098
- if (error)
9099
- throw new Error(error.error?.message || "Failed to update project");
9115
+ if (error) throwApiError(error, "Failed to update project");
9100
9116
  return data;
9101
9117
  }
9102
9118
  async function deleteProject(options = {}) {
@@ -9105,8 +9121,7 @@ async function deleteProject(options = {}) {
9105
9121
  const { data, error } = await client.DELETE("/api/projects/{projectId}", {
9106
9122
  params: { path: { projectId: id } }
9107
9123
  });
9108
- if (error)
9109
- throw new Error(error.error?.message || "Failed to delete project");
9124
+ if (error) throwApiError(error, "Failed to delete project");
9110
9125
  if (getDefaultProject() === id) clearDefaultProject();
9111
9126
  return data ?? { success: true };
9112
9127
  }
@@ -11547,6 +11562,7 @@ export {
11547
11562
  resolveAppUrl,
11548
11563
  resolveExportName,
11549
11564
  resolveManifestSource,
11565
+ resolveProjectId,
11550
11566
  resolveToken,
11551
11567
  runBuildManifest,
11552
11568
  selectDevExamples,