@keystrokehq/cli 0.1.104 → 0.1.107

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.mjs CHANGED
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import { $ as CredentialInstanceRecordSchema, $n as WorkflowCanvasSchema, $t as PresignProjectSourceRequestSchema, A as ConnectManagedServiceCredentialRequestSchema, An as TriggerRunDetailResponseSchema, At as ListCredentialsPageResponseSchema, B as CreateCustomAppResponseSchema, Bn as UpdateProjectMemberRequestSchema, Bt as ListProjectsResponseSchema, C as ChannelConnectionListResponseSchema, Cn as StartOAuthConnectionResultSchema, Cr as parseErrorResponse, D as ConfirmCheckoutRequestSchema, Dn as TriggerInvokeInputsSchema, Dr as resolveDocsMcpUrl, Dt as ListAppsResponseSchema, E as CompleteProjectArtifactResponseSchema, En as TriggerDetailResponseSchema, Er as resolveConnectAppSlug, Et as ListApiKeysResponseSchema, F as CreateCredentialInstanceBodySchema, Fn as UpdateCredentialRequestSchema, Ft as ListOrganizationsResponseSchema, G as CreateProjectResponseSchema, Gn as UploadProjectSourceResponseSchema, Gt as OrganizationSidebarBrandingPatchSchema, H as CreateOrganizationResponseSchema, Hn as UpdateProjectRequestSchema, Ht as ManagedServiceKindSchema, I as CreateCredentialsRequestSchema, In as UpdateManagedServiceCredentialRequestSchema, It as ListProjectDeploymentsResponseSchema, J as CredentialAssignmentListResponseSchema, Jn as UserAvatarSchema, Jt as PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS, K as CreateSubscriptionCheckoutRequestSchema, Kn as UpsertGatewayAttachmentBodySchema, Kt as OrganizationSidebarBrandingSchema, L as CreateCredentialsResponseSchema, Ln as UpdateOrganizationMemberRequestSchema, Lt as ListProjectFilesResponseSchema, M as CreateApiKeyRequestSchema, Mn as UpdateAutoTopupRequestSchema, Mt as ListOrganizationInvitationsResponseSchema, N as CreateApiKeyResponseSchema, Nn as UpdateChannelBindingBodySchema, Nt as ListOrganizationMembersPageQuerySchema, O as ConfirmCheckoutResponseSchema, On as TriggerInvokeResponseSchema, Or as resolvePublicPlatformOrigin, Ot as ListChannelPlatformsResponseSchema, P as CreateBillingPortalRequestSchema, Pn as UpdateCredentialInstanceBodySchema, Pt as ListOrganizationMembersPageResponseSchema, Q as CredentialInstanceListResponseSchema, Qn as WorkflowCanvasRunSchema, Qt as PresignOrgLogoResponseSchema, R as CreateCreditsCheckoutRequestSchema, Rn as UpdateOrganizationMemberResponseSchema, Rt as ListProjectMembersResponseSchema, S as ChannelAccountListResponseSchema, Sn as StartOAuthConnectionInputSchema, Sr as parseAppSlug, St as InviteProjectMembersResponseSchema, T as ChannelDirectoryListResponseSchema, Tn as SubmitTeamRequestRequestSchema, Tt as ListAgentWorkspaceFilesResponseSchema, U as CreateProjectArtifactResponseSchema, Un as UpdateProjectSettingsRequestSchema, Ut as McpDiscoverResponseSchema, V as CreateOrganizationRequestSchema, Vn as UpdateProjectMemberResponseSchema, Vt as ManagedServiceCredentialSchema, W as CreateProjectRequestSchema, Wn as UploadProjectSourceManifestRequestSchema, Wt as OpenApiDiscoverResponseSchema, X as CredentialConsumerListQuerySchema, Xn as UserPreferencesSchema, Xt as PresignChatAttachmentResponseSchema, Y as CredentialAssignmentRecordSchema, Yn as UserPreferencesPatchSchema, Yt as PresignChatAttachmentRequestSchema, Z as CredentialConsumerListResponseSchema, Zn as WorkflowCanvasCredentialBindingsSchema, Zt as PresignOrgLogoRequestSchema, _ as BindChannelBodySchema, _n as SlugAvailabilityResponseSchema, _r as detectProjectPackageManagerFromSnapshot, _t as HistoryRunListQuerySchema, a as AgentSessionListResponseSchema, an as ProjectResponseSchema, ar as WorkflowRunResponseSchema, at as DownloadActiveProjectSourceResponseSchema, b as CatalogAppDetailResponseSchema, bn as StartMcpOAuthConnectionInputSchema, bt as InviteOrganizationMembersResponseSchema, c as AgentTriggerSummaryListResponseSchema, cn as PromptInputSchema, cr as WorkspaceTriggerDetailSchema, d as AutoTopupSummarySchema, dn as QueuedAgentPromptResponseSchema, dr as WorkspaceTriggerOverviewSchema, dt as GetCredentialResponseSchema, en as PresignProjectSourceResponseSchema, er as WorkflowRunDetailResponseSchema, f as BillingActivityResponseSchema, fn as QueuedRunResponseSchema, fr as WorkspaceTriggerRunListResponseSchema, ft as GetCustomAppResponseSchema, g as BillingUsageResponseSchema, gn as SkillSummaryListResponseSchema, gr as deriveCustomAppDisplay, gt as HistoryRunDetailResponseSchema, h as BillingSummaryResponseSchema, hn as SkillSummaryDetailResponseSchema, ht as HistoryRunCancelResponseSchema, i as AgentSessionDetailResponseSchema, in as ProjectReachabilityResponseSchema, ir as WorkflowRunListResponseSchema, it as DownloadActiveProjectArtifactResponseSchema, j as ConnectProvidersResponseSchema, jn as TriggerRunListResponseSchema, jt as ListManagedServiceCredentialsResponseSchema, k as ConnectAuthorizeUrlResponseSchema, kn as TriggerListResponseSchema, kr as slugifyAppName, kt as ListCredentialsPageQuerySchema, l as AppSlugAvailabilityResponseSchema, ln as PromptResponseSchema, lr as WorkspaceTriggerFileSchema, lt as GatewayAttachmentRecordSchema, m as BillingRedirectResponseSchema, mn as RecentResourceListResponseSchema, mr as buildConnectDeeplink, mt as HealthResponseSchema, n as AcceptOrganizationInvitationResponseSchema, nn as PresignUserAvatarResponseSchema, nr as WorkflowRunInputsPutBodySchema, nt as DOCS_SEARCH_TOOL, o as AgentSummaryDetailResponseSchema, on as ProjectSettingsResponseSchema, or as WorkflowSummaryDetailResponseSchema, ot as ErrorResponseSchema, p as BillingInvoiceUrlResponseSchema, pr as WorkspaceWorkflowOverviewSchema, pt as GraphqlDiscoverResponseSchema, q as CredentialAssignmentListQuerySchema, qn as UserAvatarPatchSchema, qt as PROJECT_PULL_STATE_RELATIVE_PATH, r as ActiveOrganizationResponseSchema, rn as ProjectPullStateSchema, rr as WorkflowRunInputsSchema, rt as DeclineOrganizationInvitationResponseSchema, s as AgentSummaryListResponseSchema, sn as ProjectSlugAvailabilityResponseSchema, sr as WorkflowSummaryListResponseSchema, st as ExecuteKeystrokeToolRequestSchema, t as ACTIVE_ORG_HEADER, tn as PresignUserAvatarRequestSchema, tr as WorkflowRunHooksResponseSchema, tt as DOCS_QUERY_TOOL, u as AssignCredentialBodySchema, ur as WorkspaceTriggerListResponseSchema, ut as GetAppCatalogEntryResponseSchema, v as CatalogActionDetailResponseSchema, vn as StartKeystrokeConnectionInputSchema, vr as isAcceptableInstallExit, vt as HistoryRunListResponseSchema, w as ChannelConnectionSchema, wn as SubmitMarketingContactRequestSchema, wt as ListAgentMemoryFilesResponseSchema, x as CatalogAppsPageResponseSchema, xn as StartMcpOAuthConnectionResultSchema, xt as InviteProjectMembersRequestSchema, y as CatalogActionsPageResponseSchema, yn as StartKeystrokeConnectionResultSchema, yr as listenPortFromPublicUrl, yt as InviteOrganizationMembersRequestSchema, z as CreateCustomAppRequestSchema, zn as UpdateOrganizationRequestSchema, zt as ListProjectMetricsResponseSchema } from "./dist-ZZlE2vk6.mjs";
3
- import { i as packProjectArtifact, n as withMcpReadClient, r as mergeFilteredArtifact, t as mapInParallelBatches } from "./dist-odLBD6p1.mjs";
4
- import { C as getWebUrl, E as resolvePlatformUrlForWebUrl, S as getPlatformUrl, _ as resolveCliRoot, a as formatReleaseAgeBlockMessage, b as getConfigDir, c as detectManagerFromLockfile, d as installDependencies$1, f as installPlaygroundDependencies, g as readCliVersion, h as isNewerVersion, i as fetchLatestCliRelease, l as buildPlaygroundWorkspace, m as resolvePackageManager, n as computeReleaseAgeRetryAfter, o as isReleaseAgeBlock, p as resolveGithubPackagesToken, r as readPnpmMinimumReleaseAgeMinutes, s as detectCliInstall, t as runPackageManagerUpdate, u as detectPackageManager, v as createCliConfig, w as DEFAULT_PLATFORM_URL, x as getEffectiveApiTarget, y as getCliConfigDir } from "./run-package-manager-update-BVuBh1a2.mjs";
2
+ import { $ as CredentialInstanceListResponseSchema, $n as WorkflowCanvasRunSchema, $t as PresignOrgLogoResponseSchema, A as ConnectAuthorizeUrlResponseSchema, An as TriggerListResponseSchema, Ar as slugifyAppName, At as ListCredentialsPageQuerySchema, B as CreateCustomAppRequestSchema, Bn as UpdateOrganizationRequestSchema, Bt as ListProjectMetricsResponseSchema, C as ChannelAccountListResponseSchema, Cn as StartOAuthConnectionInputSchema, Cr as parseAppSlug, Ct as InviteProjectMembersResponseSchema, D as CompleteProjectArtifactResponseSchema, Dn as TriggerDetailResponseSchema, Dr as resolveConnectAppSlug, Dt as ListApiKeysResponseSchema, E as ChannelDirectoryListResponseSchema, En as SubmitTeamRequestRequestSchema, Et as ListAgentWorkspaceFilesResponseSchema, F as CreateBillingPortalRequestSchema, Fn as UpdateCredentialInstanceBodySchema, Ft as ListOrganizationMembersPageResponseSchema, G as CreateProjectRequestSchema, Gn as UploadProjectSourceManifestRequestSchema, Gt as OpenApiDiscoverResponseSchema, H as CreateOrganizationRequestSchema, Hn as UpdateProjectMemberResponseSchema, Ht as ManagedServiceCredentialSchema, I as CreateCredentialInstanceBodySchema, In as UpdateCredentialRequestSchema, It as ListOrganizationsResponseSchema, J as CredentialAssignmentListQuerySchema, Jn as UserAvatarPatchSchema, Jt as PROJECT_PULL_STATE_RELATIVE_PATH, K as CreateProjectResponseSchema, Kn as UploadProjectSourceResponseSchema, Kt as OrganizationSidebarBrandingPatchSchema, L as CreateCredentialsRequestSchema, Ln as UpdateManagedServiceCredentialRequestSchema, Lt as ListProjectDeploymentsResponseSchema, M as ConnectProvidersResponseSchema, Mn as TriggerRunListResponseSchema, Mt as ListManagedServiceCredentialsResponseSchema, N as CreateApiKeyRequestSchema, Nn as UpdateAutoTopupRequestSchema, Nt as ListOrganizationInvitationsResponseSchema, O as ConfirmCheckoutRequestSchema, On as TriggerInvokeInputsSchema, Or as resolveDocsMcpUrl, Ot as ListAppsResponseSchema, P as CreateApiKeyResponseSchema, Pn as UpdateChannelBindingBodySchema, Pt as ListOrganizationMembersPageQuerySchema, Q as CredentialConsumerListResponseSchema, Qn as WorkflowCanvasCredentialBindingsSchema, Qt as PresignOrgLogoRequestSchema, R as CreateCredentialsResponseSchema, Rn as UpdateOrganizationMemberRequestSchema, Rt as ListProjectFilesResponseSchema, S as CatalogAppsPageResponseSchema, Sn as StartMcpOAuthConnectionResultSchema, St as InviteProjectMembersRequestSchema, T as ChannelConnectionSchema, Tn as SubmitMarketingContactRequestSchema, Tt as ListAgentMemoryFilesResponseSchema, U as CreateOrganizationResponseSchema, Un as UpdateProjectRequestSchema, Ut as ManagedServiceKindSchema, V as CreateCustomAppResponseSchema, Vn as UpdateProjectMemberRequestSchema, Vt as ListProjectsResponseSchema, W as CreateProjectArtifactResponseSchema, Wn as UpdateProjectSettingsRequestSchema, Wt as McpDiscoverResponseSchema, X as CredentialAssignmentRecordSchema, Xn as UserPreferencesPatchSchema, Xt as PresignChatAttachmentRequestSchema, Y as CredentialAssignmentListResponseSchema, Yn as UserAvatarSchema, Yt as PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS, Z as CredentialConsumerListQuerySchema, Zn as UserPreferencesSchema, Zt as PresignChatAttachmentResponseSchema, _ as BindChannelBodySchema, _n as SkillSummaryListResponseSchema, _r as deriveCustomAppDisplay, _t as HistoryRunDetailResponseSchema, a as AgentSessionListResponseSchema, an as ProjectReachabilityResponseSchema, ar as WorkflowRunListResponseSchema, at as DownloadActiveProjectArtifactResponseSchema, b as CatalogActionsPageResponseSchema, bn as StartKeystrokeConnectionResultSchema, br as listenPortFromPublicUrl, bt as InviteOrganizationMembersRequestSchema, c as AgentTriggerSummaryListResponseSchema, cn as ProjectSlugAvailabilityResponseSchema, cr as WorkflowSummaryListResponseSchema, ct as ExecuteKeystrokeToolRequestSchema, d as AutoTopupSummarySchema, dr as WorkspaceTriggerListResponseSchema, dt as GetAppCatalogEntryResponseSchema, en as PresignProjectSourceRequestSchema, er as WorkflowCanvasSchema, et as CredentialInstanceRecordSchema, f as BillingActivityResponseSchema, fn as QueuedAgentPromptResponseSchema, fr as WorkspaceTriggerOverviewSchema, ft as GetCredentialResponseSchema, g as BillingUsageResponseSchema, gn as SkillSummaryDetailResponseSchema, gt as HistoryRunCancelResponseSchema, h as BillingSummaryResponseSchema, hn as RecentResourceListResponseSchema, hr as buildConnectDeeplink, ht as HealthResponseSchema, i as AgentSessionDetailResponseSchema, in as ProjectPullStateSchema, ir as WorkflowRunInputsSchema, it as DeclineOrganizationInvitationResponseSchema, j as ConnectManagedServiceCredentialRequestSchema, jn as TriggerRunDetailResponseSchema, jt as ListCredentialsPageResponseSchema, k as ConfirmCheckoutResponseSchema, kn as TriggerInvokeResponseSchema, kr as resolvePublicPlatformOrigin, kt as ListChannelPlatformsResponseSchema, l as AppSlugAvailabilityResponseSchema, ln as PromptInputSchema, lr as WorkspaceTriggerDetailSchema, m as BillingRedirectResponseSchema, mr as WorkspaceWorkflowOverviewSchema, mt as GraphqlDiscoverResponseSchema, n as AcceptOrganizationInvitationResponseSchema, nn as PresignUserAvatarRequestSchema, nr as WorkflowRunHooksResponseSchema, nt as DOCS_QUERY_TOOL, o as AgentSummaryDetailResponseSchema, on as ProjectResponseSchema, or as WorkflowRunResponseSchema, ot as DownloadActiveProjectSourceResponseSchema, p as BillingInvoiceUrlResponseSchema, pn as QueuedRunResponseSchema, pr as WorkspaceTriggerRunListResponseSchema, pt as GetCustomAppResponseSchema, q as CreateSubscriptionCheckoutRequestSchema, qn as UpsertGatewayAttachmentBodySchema, qt as OrganizationSidebarBrandingSchema, r as ActiveOrganizationResponseSchema, rn as PresignUserAvatarResponseSchema, rr as WorkflowRunInputsPutBodySchema, rt as DOCS_SEARCH_TOOL, s as AgentSummaryListResponseSchema, sn as ProjectSettingsResponseSchema, sr as WorkflowSummaryDetailResponseSchema, st as ErrorResponseSchema, t as ACTIVE_ORG_HEADER, tn as PresignProjectSourceResponseSchema, tr as WorkflowRunDetailResponseSchema, u as AssignCredentialBodySchema, un as PromptResponseSchema, ur as WorkspaceTriggerFileSchema, ut as GatewayAttachmentRecordSchema, v as CLIENT_CHANNEL_HEADER, vn as SlugAvailabilityResponseSchema, vr as detectProjectPackageManagerFromSnapshot, vt as HistoryRunListQuerySchema, w as ChannelConnectionListResponseSchema, wn as StartOAuthConnectionResultSchema, wr as parseErrorResponse, x as CatalogAppDetailResponseSchema, xn as StartMcpOAuthConnectionInputSchema, xt as InviteOrganizationMembersResponseSchema, y as CatalogActionDetailResponseSchema, yn as StartKeystrokeConnectionInputSchema, yr as isAcceptableInstallExit, yt as HistoryRunListResponseSchema, z as CreateCreditsCheckoutRequestSchema, zn as UpdateOrganizationMemberResponseSchema, zt as ListProjectMembersResponseSchema } from "./dist-BoZPZ9Sz.mjs";
3
+ import { a as alias, c as event, i as packProjectArtifact, l as flushTelemetry, n as withMcpReadClient, o as captureException, r as mergeFilteredArtifact, s as configureTelemetry, t as mapInParallelBatches, u as shutdownTelemetry } from "./dist-De18Uq1U.mjs";
4
+ import { C as getWebUrl, E as resolvePlatformUrlForWebUrl, S as getPlatformUrl, _ as resolveCliRoot, a as formatReleaseAgeBlockMessage, b as getConfigDir, c as detectManagerFromLockfile, d as installDependencies$1, f as installPlaygroundDependencies, g as readCliVersion, h as isNewerVersion, i as fetchLatestCliRelease, l as buildPlaygroundWorkspace, m as resolvePackageManager, n as computeReleaseAgeRetryAfter, o as isReleaseAgeBlock, p as resolveGithubPackagesToken, r as readPnpmMinimumReleaseAgeMinutes, s as detectCliInstall, t as runPackageManagerUpdate, u as detectPackageManager, v as createCliConfig, w as DEFAULT_PLATFORM_URL, x as getEffectiveApiTarget, y as getCliConfigDir } from "./run-package-manager-update-D_jU5wZe.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import { Command } from "commander";
7
7
  import { platform, release } from "node:os";
8
8
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
9
9
  import { Entry } from "@napi-rs/keyring";
10
10
  import { existsSync, lstatSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
11
- import { AsyncLocalStorage } from "node:async_hooks";
12
11
  import { PostHog } from "posthog-node";
13
12
  import { pathToFileURL } from "node:url";
14
13
  import { access, lstat, mkdir, readFile, readdir, rm, stat, symlink, writeFile } from "node:fs/promises";
@@ -415,7 +414,7 @@ const validateAndMerge = (...sources) => {
415
414
  for (const source of sources) if ((!isObject(source) || Array.isArray(source)) && source !== void 0) throw new TypeError("The `options` argument must be an object");
416
415
  return deepMerge({}, ...sources);
417
416
  };
418
- const mergeHeaders = (source1 = {}, source2 = {}) => {
417
+ const mergeHeaders$1 = (source1 = {}, source2 = {}) => {
419
418
  const result = new globalThis.Headers(source1);
420
419
  const isHeadersInstance = source2 instanceof globalThis.Headers;
421
420
  const source = new globalThis.Headers(source2);
@@ -423,7 +422,7 @@ const mergeHeaders = (source1 = {}, source2 = {}) => {
423
422
  else result.set(key, value);
424
423
  return result;
425
424
  };
426
- const isPlainObject$1 = (value) => {
425
+ const isPlainObject$2 = (value) => {
427
426
  if (!isObject(value) || Array.isArray(value)) return false;
428
427
  const prototype = Object.getPrototypeOf(value);
429
428
  return prototype === Object.prototype || prototype === null;
@@ -437,16 +436,16 @@ const cloneShallow = (value) => {
437
436
  }
438
437
  if (value instanceof globalThis.Headers) return new globalThis.Headers(value);
439
438
  if (Array.isArray(value)) return [...value];
440
- if (isPlainObject$1(value)) return { ...value };
439
+ if (isPlainObject$2(value)) return { ...value };
441
440
  return value;
442
441
  };
443
442
  const normalizeHeaderObject = (headers) => Object.fromEntries(Object.entries(headers).filter((entry) => entry[1] !== void 0));
444
443
  const mergeHeaderContainers = (source1, source2) => {
445
- if (isPlainObject$1(source1) && isPlainObject$1(source2)) return normalizeHeaderObject({
444
+ if (isPlainObject$2(source1) && isPlainObject$2(source2)) return normalizeHeaderObject({
446
445
  ...source1,
447
446
  ...source2
448
447
  });
449
- return mergeHeaders(source1, source2);
448
+ return mergeHeaders$1(source1, source2);
450
449
  };
451
450
  function newHookValue(original, incoming, property) {
452
451
  return Object.hasOwn(incoming, property) && incoming[property] === void 0 ? [] : deepMerge(original[property] ?? [], incoming[property] ?? []);
@@ -904,7 +903,7 @@ var Ky = class Ky {
904
903
  if (Object.hasOwn(options, "prefixUrl")) throw new Error(prefixUrlRenamedErrorMessage);
905
904
  this.#options = {
906
905
  ...options,
907
- headers: mergeHeaders(this.#input.headers, options.headers),
906
+ headers: mergeHeaders$1(this.#input.headers, options.headers),
908
907
  hooks: mergeHooks({}, options.hooks),
909
908
  method: normalizeRequestMethod(options.method ?? this.#input.method ?? "GET"),
910
909
  prefix: String(options.prefix || ""),
@@ -1721,10 +1720,10 @@ function createJwtTokenCache(mint) {
1721
1720
  };
1722
1721
  }
1723
1722
  //#endregion
1724
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/version.mjs
1725
- const PACKAGE_VERSION = "1.6.11";
1723
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/version.mjs
1724
+ const PACKAGE_VERSION = "1.6.23";
1726
1725
  //#endregion
1727
- //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.4.3/node_modules/better-call/dist/error.mjs
1726
+ //#region ../../node_modules/.pnpm/better-call@1.3.7_zod@4.4.3/node_modules/better-call/dist/error.mjs
1728
1727
  function isErrorStackTraceLimitWritable() {
1729
1728
  const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
1730
1729
  if (desc === void 0) return Object.isExtensible(Error);
@@ -1836,7 +1835,7 @@ var InternalAPIError = class extends Error {
1836
1835
  };
1837
1836
  makeErrorForHideStackFrame(InternalAPIError, Error);
1838
1837
  //#endregion
1839
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.11_@better-auth+utils@0.4.0_@better-fetch+fetch@1.1.21_@opentelem_3f357e8652888625f393bee0c48e5205/node_modules/@better-auth/core/dist/error/index.mjs
1838
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.6.23_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_398718bcf9b56a2240f5e645ad2d451e/node_modules/@better-auth/core/dist/error/index.mjs
1840
1839
  var BetterAuthError = class extends Error {
1841
1840
  constructor(message, options) {
1842
1841
  super(message, options);
@@ -1846,7 +1845,7 @@ var BetterAuthError = class extends Error {
1846
1845
  }
1847
1846
  };
1848
1847
  //#endregion
1849
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/plugins/device-authorization/client.mjs
1848
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/plugins/device-authorization/client.mjs
1850
1849
  const deviceAuthorizationClient = () => {
1851
1850
  return {
1852
1851
  id: "device-authorization",
@@ -1862,6 +1861,175 @@ const deviceAuthorizationClient = () => {
1862
1861
  };
1863
1862
  };
1864
1863
  //#endregion
1864
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.6.23_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_398718bcf9b56a2240f5e645ad2d451e/node_modules/@better-auth/core/dist/env/env-impl.mjs
1865
+ const _envShim = Object.create(null);
1866
+ const _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis);
1867
+ const env = new Proxy(_envShim, {
1868
+ get(_, prop) {
1869
+ return _getEnv()[prop] ?? _envShim[prop];
1870
+ },
1871
+ has(_, prop) {
1872
+ return prop in _getEnv() || prop in _envShim;
1873
+ },
1874
+ set(_, prop, value) {
1875
+ const env = _getEnv(true);
1876
+ env[prop] = value;
1877
+ return true;
1878
+ },
1879
+ deleteProperty(_, prop) {
1880
+ if (!prop) return false;
1881
+ const env = _getEnv(true);
1882
+ delete env[prop];
1883
+ return true;
1884
+ },
1885
+ ownKeys() {
1886
+ const env = _getEnv(true);
1887
+ return Object.keys(env);
1888
+ }
1889
+ });
1890
+ env.NODE_ENV;
1891
+ /**
1892
+ * Get environment variable with fallback
1893
+ */
1894
+ function getEnvVar(key, fallback) {
1895
+ if (typeof process !== "undefined" && process.env) return process.env[key] ?? fallback;
1896
+ if (typeof Deno !== "undefined") return Deno.env.get(key) ?? fallback;
1897
+ if (typeof Bun !== "undefined") return Bun.env[key] ?? fallback;
1898
+ return fallback;
1899
+ }
1900
+ Object.freeze({
1901
+ get BETTER_AUTH_SECRET() {
1902
+ return getEnvVar("BETTER_AUTH_SECRET");
1903
+ },
1904
+ get AUTH_SECRET() {
1905
+ return getEnvVar("AUTH_SECRET");
1906
+ },
1907
+ get BETTER_AUTH_TELEMETRY() {
1908
+ return getEnvVar("BETTER_AUTH_TELEMETRY");
1909
+ },
1910
+ get BETTER_AUTH_TELEMETRY_ID() {
1911
+ return getEnvVar("BETTER_AUTH_TELEMETRY_ID");
1912
+ },
1913
+ get NODE_ENV() {
1914
+ return getEnvVar("NODE_ENV", "development");
1915
+ },
1916
+ get PACKAGE_VERSION() {
1917
+ return getEnvVar("PACKAGE_VERSION", "0.0.0");
1918
+ },
1919
+ get BETTER_AUTH_TELEMETRY_ENDPOINT() {
1920
+ return getEnvVar("BETTER_AUTH_TELEMETRY_ENDPOINT", "");
1921
+ }
1922
+ });
1923
+ //#endregion
1924
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/utils/url.mjs
1925
+ const SLASH_CHAR_CODE = "/".charCodeAt(0);
1926
+ function trimTrailingSlashes(value) {
1927
+ let end = value.length;
1928
+ while (end > 0 && value.charCodeAt(end - 1) === SLASH_CHAR_CODE) end--;
1929
+ return end === value.length ? value : value.slice(0, end);
1930
+ }
1931
+ function checkHasPath(url) {
1932
+ try {
1933
+ return (trimTrailingSlashes(new URL(url).pathname) || "/") !== "/";
1934
+ } catch {
1935
+ throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
1936
+ }
1937
+ }
1938
+ function assertHasProtocol(url) {
1939
+ try {
1940
+ const parsedUrl = new URL(url);
1941
+ if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new BetterAuthError(`Invalid base URL: ${url}. URL must include 'http://' or 'https://'`);
1942
+ } catch (error) {
1943
+ if (error instanceof BetterAuthError) throw error;
1944
+ throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`, { cause: error });
1945
+ }
1946
+ }
1947
+ function withPath(url, path = "/api/auth") {
1948
+ assertHasProtocol(url);
1949
+ if (checkHasPath(url)) return url;
1950
+ const trimmedUrl = trimTrailingSlashes(url);
1951
+ if (!path || path === "/") return trimmedUrl;
1952
+ path = path.startsWith("/") ? path : `/${path}`;
1953
+ return `${trimmedUrl}${path}`;
1954
+ }
1955
+ function validateProxyHeader(header, type) {
1956
+ if (!header || header.trim() === "") return false;
1957
+ if (type === "proto") return header === "http" || header === "https";
1958
+ if (type === "host") {
1959
+ if ([
1960
+ /\.\./,
1961
+ /\0/,
1962
+ /[\s]/,
1963
+ /^[.]/,
1964
+ /[<>'"]/,
1965
+ /javascript:/i,
1966
+ /file:/i,
1967
+ /data:/i
1968
+ ].some((pattern) => pattern.test(header))) return false;
1969
+ return /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(header) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(header) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(header) || /^localhost(:[0-9]{1,5})?$/i.test(header);
1970
+ }
1971
+ return false;
1972
+ }
1973
+ function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
1974
+ if (url) return withPath(url, path);
1975
+ if (loadEnv !== false) {
1976
+ const fromEnv = env.BETTER_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL || (env.BASE_URL !== "/" ? env.BASE_URL : void 0);
1977
+ if (fromEnv) return withPath(fromEnv, path);
1978
+ }
1979
+ const fromRequest = request?.headers.get("x-forwarded-host");
1980
+ const fromRequestProto = request?.headers.get("x-forwarded-proto");
1981
+ if (fromRequest && fromRequestProto && trustedProxyHeaders) {
1982
+ if (validateProxyHeader(fromRequestProto, "proto") && validateProxyHeader(fromRequest, "host")) try {
1983
+ return withPath(`${fromRequestProto}://${fromRequest}`, path);
1984
+ } catch (_error) {}
1985
+ }
1986
+ if (request) {
1987
+ const url = getOrigin(request.url);
1988
+ if (!url) throw new BetterAuthError("Could not get origin from request. Please provide a valid base URL.");
1989
+ return withPath(url, path);
1990
+ }
1991
+ if (typeof window !== "undefined" && window.location) return withPath(window.location.origin, path);
1992
+ }
1993
+ function getOrigin(url) {
1994
+ try {
1995
+ const parsedUrl = new URL(url);
1996
+ return parsedUrl.origin === "null" ? null : parsedUrl.origin;
1997
+ } catch {
1998
+ return null;
1999
+ }
2000
+ }
2001
+ //#endregion
2002
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.6.23_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_398718bcf9b56a2240f5e645ad2d451e/node_modules/@better-auth/core/dist/utils/url.mjs
2003
+ /**
2004
+ * Schemes that execute or embed code when navigated to or accepted as a
2005
+ * redirect target. These are never safe as an OAuth `redirect_uri` or as a
2006
+ * client-side navigation target (`window.location.href`, `location.assign`, ...).
2007
+ */
2008
+ const DANGEROUS_URL_SCHEMES = [
2009
+ "javascript:",
2010
+ "data:",
2011
+ "vbscript:"
2012
+ ];
2013
+ /**
2014
+ * Returns `false` only when `value` is an absolute URL using a dangerous scheme
2015
+ * (`javascript:`, `data:`, `vbscript:`). Relative URLs (e.g. `/dashboard`) and
2016
+ * safe absolute schemes (`http`, `https`, custom app schemes such as
2017
+ * `myapp://`) return `true`.
2018
+ *
2019
+ * Use this to guard browser navigation sinks and any redirect target that may
2020
+ * originate from untrusted input. It is intentionally narrow: it blocks code
2021
+ * execution schemes without rejecting relative paths or mobile deep links.
2022
+ */
2023
+ function isSafeUrlScheme(value) {
2024
+ let parsed;
2025
+ try {
2026
+ parsed = new URL(value);
2027
+ } catch {
2028
+ return true;
2029
+ }
2030
+ return !DANGEROUS_URL_SCHEMES.includes(parsed.protocol);
2031
+ }
2032
+ //#endregion
1865
2033
  //#region ../../node_modules/.pnpm/nanostores@1.3.0/node_modules/nanostores/clean-stores/index.js
1866
2034
  const clean = Symbol("clean");
1867
2035
  //#endregion
@@ -1924,6 +2092,7 @@ const atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
1924
2092
  };
1925
2093
  //#endregion
1926
2094
  //#region ../../node_modules/.pnpm/nanostores@1.3.0/node_modules/nanostores/lifecycle/index.js
2095
+ const SET = 2;
1927
2096
  const MOUNT = 5;
1928
2097
  const UNMOUNT = 6;
1929
2098
  const REVERT_MUTATION = 10;
@@ -1948,6 +2117,40 @@ let on = (object, listener, eventKey, mutateStore) => {
1948
2117
  }
1949
2118
  };
1950
2119
  };
2120
+ let onSet = ($store, listener) => on($store, listener, SET, (runListeners) => {
2121
+ let originSet = $store.set;
2122
+ let originSetKey = $store.setKey;
2123
+ if ($store.setKey) $store.setKey = (changed, changedValue) => {
2124
+ let isAborted;
2125
+ let abort = () => {
2126
+ isAborted = true;
2127
+ };
2128
+ runListeners({
2129
+ abort,
2130
+ changed,
2131
+ newValue: {
2132
+ ...$store.value,
2133
+ [changed]: changedValue
2134
+ }
2135
+ });
2136
+ if (!isAborted) return originSetKey(changed, changedValue);
2137
+ };
2138
+ $store.set = (newValue) => {
2139
+ let isAborted;
2140
+ let abort = () => {
2141
+ isAborted = true;
2142
+ };
2143
+ runListeners({
2144
+ abort,
2145
+ newValue
2146
+ });
2147
+ if (!isAborted) return originSet(newValue);
2148
+ };
2149
+ return () => {
2150
+ $store.set = originSet;
2151
+ $store.setKey = originSetKey;
2152
+ };
2153
+ });
1951
2154
  const STORE_UNMOUNT_DELAY = 1e3;
1952
2155
  let onMount = ($store, initialize) => {
1953
2156
  let listener = (payload) => {
@@ -1991,101 +2194,47 @@ let onMount = ($store, initialize) => {
1991
2194
  });
1992
2195
  };
1993
2196
  //#endregion
1994
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/query.mjs
1995
- const isServer = () => typeof window === "undefined";
1996
- const useAuthQuery = (initializedAtom, path, $fetch, options) => {
1997
- const value = /* @__PURE__ */ atom({
1998
- data: null,
1999
- error: null,
2000
- isPending: true,
2001
- isRefetching: false,
2002
- refetch: (queryParams) => fn(queryParams)
2003
- });
2004
- const fn = async (queryParams) => {
2005
- return new Promise((resolve) => {
2006
- const opts = typeof options === "function" ? options({
2007
- data: value.get().data,
2008
- error: value.get().error,
2009
- isPending: value.get().isPending
2010
- }) : options;
2011
- $fetch(path, {
2012
- ...opts,
2013
- query: {
2014
- ...opts?.query,
2015
- ...queryParams?.query
2016
- },
2017
- async onSuccess(context) {
2018
- value.set({
2019
- data: context.data,
2020
- error: null,
2021
- isPending: false,
2022
- isRefetching: false,
2023
- refetch: value.value.refetch
2024
- });
2025
- await opts?.onSuccess?.(context);
2026
- },
2027
- async onError(context) {
2028
- const { request } = context;
2029
- const retryAttempts = typeof request.retry === "number" ? request.retry : request.retry?.attempts;
2030
- const retryAttempt = request.retryAttempt || 0;
2031
- if (retryAttempts && retryAttempt < retryAttempts) return;
2032
- const isUnauthorized = context.error.status === 401;
2033
- value.set({
2034
- error: context.error,
2035
- data: isUnauthorized ? null : value.get().data,
2036
- isPending: false,
2037
- isRefetching: false,
2038
- refetch: value.value.refetch
2039
- });
2040
- await opts?.onError?.(context);
2041
- },
2042
- async onRequest(context) {
2043
- const currentValue = value.get();
2044
- value.set({
2045
- isPending: currentValue.data === null,
2046
- data: currentValue.data,
2047
- error: null,
2048
- isRefetching: true,
2049
- refetch: value.value.refetch
2050
- });
2051
- await opts?.onRequest?.(context);
2052
- }
2053
- }).catch((error) => {
2054
- value.set({
2055
- error,
2056
- data: value.get().data,
2057
- isPending: false,
2058
- isRefetching: false,
2059
- refetch: value.value.refetch
2060
- });
2061
- }).finally(() => {
2062
- resolve(void 0);
2063
- });
2064
- });
2065
- };
2066
- initializedAtom = Array.isArray(initializedAtom) ? initializedAtom : [initializedAtom];
2067
- let isInitialized = false;
2068
- for (const initAtom of initializedAtom) initAtom.subscribe(async () => {
2069
- if (isServer()) return;
2070
- if (isInitialized) await fn();
2071
- else onMount(value, () => {
2072
- const timeoutId = setTimeout(async () => {
2073
- if (!isInitialized) {
2074
- isInitialized = true;
2075
- await fn();
2076
- }
2077
- }, 0);
2078
- return () => {
2079
- value.off();
2080
- initAtom.off();
2081
- clearTimeout(timeoutId);
2082
- };
2083
- });
2197
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/equality.mjs
2198
+ function isPlainObject$1(value) {
2199
+ if (typeof value !== "object" || value === null) return false;
2200
+ const prototype = Object.getPrototypeOf(value);
2201
+ return prototype === Object.prototype || prototype === null;
2202
+ }
2203
+ /**
2204
+ * Deep structural equality for JSON-serializable values.
2205
+ * Handles: primitives, null, arrays, and plain objects.
2206
+ * Short-circuits on referential equality at every recursion level.
2207
+ */
2208
+ function isJsonEqual(a, b) {
2209
+ if (a === b) return true;
2210
+ if (Array.isArray(a) && Array.isArray(b)) {
2211
+ if (a.length !== b.length) return false;
2212
+ for (let i = 0; i < a.length; i++) if (!isJsonEqual(a[i], b[i])) return false;
2213
+ return true;
2214
+ }
2215
+ if (isPlainObject$1(a) && isPlainObject$1(b)) {
2216
+ const keysA = Object.keys(a);
2217
+ const keysB = Object.keys(b);
2218
+ if (keysA.length !== keysB.length) return false;
2219
+ for (const key of keysA) if (!(key in b) || !isJsonEqual(a[key], b[key])) return false;
2220
+ return true;
2221
+ }
2222
+ return false;
2223
+ }
2224
+ /**
2225
+ * Attach an equality gate to a nanostores atom via `onSet`.
2226
+ * When `isEqual(currentValue, newValue)` returns true, the `set()` call
2227
+ * is aborted: no listeners fire, no framework re-renders occur.
2228
+ *
2229
+ * Returns the unsubscribe function from `onSet`.
2230
+ */
2231
+ function withEquality(store, isEqual) {
2232
+ return onSet(store, ({ newValue, abort }) => {
2233
+ if (isEqual(store.value, newValue)) abort();
2084
2234
  });
2085
- return value;
2086
- };
2235
+ }
2087
2236
  //#endregion
2088
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/broadcast-channel.mjs
2237
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/broadcast-channel.mjs
2089
2238
  const kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
2090
2239
  const now$1 = () => Math.floor(Date.now() / 1e3);
2091
2240
  var WindowBroadcastChannel = class {
@@ -2128,7 +2277,7 @@ function getGlobalBroadcastChannel(name = "better-auth.message") {
2128
2277
  return globalThis[kBroadcastChannel];
2129
2278
  }
2130
2279
  //#endregion
2131
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/focus-manager.mjs
2280
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/focus-manager.mjs
2132
2281
  const kFocusManager = Symbol.for("better-auth:focus-manager");
2133
2282
  var WindowFocusManager = class {
2134
2283
  listeners = /* @__PURE__ */ new Set();
@@ -2157,7 +2306,7 @@ function getGlobalFocusManager() {
2157
2306
  return globalThis[kFocusManager];
2158
2307
  }
2159
2308
  //#endregion
2160
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/online-manager.mjs
2309
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/online-manager.mjs
2161
2310
  const kOnlineManager = Symbol.for("better-auth:online-manager");
2162
2311
  var WindowOnlineManager = class {
2163
2312
  listeners = /* @__PURE__ */ new Set();
@@ -2189,7 +2338,7 @@ function getGlobalOnlineManager() {
2189
2338
  return globalThis[kOnlineManager];
2190
2339
  }
2191
2340
  //#endregion
2192
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/parser.mjs
2341
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/parser.mjs
2193
2342
  const PROTO_POLLUTION_PATTERNS = {
2194
2343
  proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
2195
2344
  constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
@@ -2225,7 +2374,6 @@ function betterJSONParse(value, options = {}) {
2225
2374
  const { strict = false, warnings = false, reviver, parseDates = true } = options;
2226
2375
  if (typeof value !== "string") return value;
2227
2376
  const trimmed = value.trim();
2228
- if (trimmed.length > 0 && trimmed[0] === "\"" && trimmed.endsWith("\"") && !trimmed.slice(1, -1).includes("\"")) return trimmed.slice(1, -1);
2229
2377
  const lowerValue = trimmed.toLowerCase();
2230
2378
  if (lowerValue.length <= 9 && lowerValue in SPECIAL_VALUES) return SPECIAL_VALUES[lowerValue];
2231
2379
  if (!JSON_SIGNATURE.test(trimmed)) {
@@ -2259,31 +2407,20 @@ function parseJSON(value, options = { strict: true }) {
2259
2407
  return betterJSONParse(value, options);
2260
2408
  }
2261
2409
  //#endregion
2262
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/session-refresh.mjs
2410
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/session-refresh.mjs
2263
2411
  const now = () => Math.floor(Date.now() / 1e3);
2264
2412
  /**
2265
- * Normalize $fetch response: `throw: true` returns data directly, otherwise `{ data, error }`.
2266
- */
2267
- function normalizeSessionResponse(res) {
2268
- if (typeof res === "object" && res !== null && "data" in res && "error" in res) return res;
2269
- return {
2270
- data: res,
2271
- error: null
2272
- };
2273
- }
2274
- /**
2275
2413
  * Rate limit: don't refetch on focus if a session request was made within this many seconds
2276
2414
  */
2277
2415
  const FOCUS_REFETCH_RATE_LIMIT_SECONDS = 5;
2278
2416
  function createSessionRefreshManager(opts) {
2279
- const { sessionAtom, sessionSignal, $fetch, options = {} } = opts;
2417
+ const { fetchSession, shouldPollSession = () => true, sessionSignal, options = {} } = opts;
2280
2418
  const refetchInterval = options.sessionOptions?.refetchInterval ?? 0;
2281
2419
  const refetchOnWindowFocus = options.sessionOptions?.refetchOnWindowFocus ?? true;
2282
2420
  const refetchWhenOffline = options.sessionOptions?.refetchWhenOffline ?? false;
2283
2421
  const state = {
2284
- lastSync: 0,
2285
- lastSessionRequest: 0,
2286
- cachedSession: void 0
2422
+ isInitialized: false,
2423
+ lastSessionRequest: 0
2287
2424
  };
2288
2425
  const shouldRefetch = () => {
2289
2426
  return refetchWhenOffline || getGlobalOnlineManager().isOnline;
@@ -2291,45 +2428,21 @@ function createSessionRefreshManager(opts) {
2291
2428
  const triggerRefetch = (event) => {
2292
2429
  if (!shouldRefetch()) return;
2293
2430
  if (event?.event === "storage") {
2294
- state.lastSync = now();
2295
- sessionSignal.set(!sessionSignal.get());
2431
+ fetchSession();
2296
2432
  return;
2297
2433
  }
2298
- const currentSession = sessionAtom.get();
2299
- const fetchSessionWithRefresh = () => {
2300
- state.lastSessionRequest = now();
2301
- $fetch("/get-session").then(async (res) => {
2302
- let { data, error } = normalizeSessionResponse(res);
2303
- if (data?.needsRefresh) try {
2304
- const refreshRes = await $fetch("/get-session", { method: "POST" });
2305
- ({data, error} = normalizeSessionResponse(refreshRes));
2306
- } catch {}
2307
- const sessionData = data?.session && data?.user ? data : null;
2308
- sessionAtom.set({
2309
- ...currentSession,
2310
- data: sessionData,
2311
- error
2312
- });
2313
- state.lastSync = now();
2314
- sessionSignal.set(!sessionSignal.get());
2315
- }).catch(() => {});
2316
- };
2317
2434
  if (event?.event === "poll") {
2318
- fetchSessionWithRefresh();
2435
+ state.lastSessionRequest = now();
2436
+ fetchSession();
2319
2437
  return;
2320
2438
  }
2321
2439
  if (event?.event === "visibilitychange") {
2322
2440
  if (now() - state.lastSessionRequest < FOCUS_REFETCH_RATE_LIMIT_SECONDS) return;
2323
2441
  state.lastSessionRequest = now();
2324
- }
2325
- if (event?.event === "visibilitychange") {
2326
- fetchSessionWithRefresh();
2442
+ fetchSession();
2327
2443
  return;
2328
2444
  }
2329
- if (currentSession?.data === null || currentSession?.data === void 0) {
2330
- state.lastSync = now();
2331
- sessionSignal.set(!sessionSignal.get());
2332
- }
2445
+ fetchSession();
2333
2446
  };
2334
2447
  const broadcastSessionUpdate = (trigger) => {
2335
2448
  getGlobalBroadcastChannel().post({
@@ -2340,7 +2453,7 @@ function createSessionRefreshManager(opts) {
2340
2453
  };
2341
2454
  const setupPolling = () => {
2342
2455
  if (refetchInterval && refetchInterval > 0) state.pollInterval = setInterval(() => {
2343
- if (sessionAtom.get()?.data) triggerRefetch({ event: "poll" });
2456
+ if (shouldPollSession()) triggerRefetch({ event: "poll" });
2344
2457
  }, refetchInterval * 1e3);
2345
2458
  };
2346
2459
  const setupBroadcast = () => {
@@ -2359,16 +2472,25 @@ function createSessionRefreshManager(opts) {
2359
2472
  if (online) triggerRefetch({ event: "visibilitychange" });
2360
2473
  });
2361
2474
  };
2475
+ const setupSignalSubscription = () => {
2476
+ state.unsubscribeSignal = sessionSignal.listen(() => {
2477
+ fetchSession();
2478
+ });
2479
+ };
2362
2480
  const init = () => {
2481
+ if (state.isInitialized) return;
2482
+ state.isInitialized = true;
2363
2483
  setupPolling();
2364
2484
  setupBroadcast();
2365
2485
  setupFocusRefetch();
2366
2486
  setupOnlineRefetch();
2367
- getGlobalBroadcastChannel().setup();
2368
- getGlobalFocusManager().setup();
2369
- getGlobalOnlineManager().setup();
2487
+ setupSignalSubscription();
2488
+ state.cleanupBroadcastSetup = getGlobalBroadcastChannel().setup();
2489
+ state.cleanupFocusSetup = getGlobalFocusManager().setup();
2490
+ state.cleanupOnlineSetup = getGlobalOnlineManager().setup();
2370
2491
  };
2371
2492
  const cleanup = () => {
2493
+ if (!state.isInitialized) return;
2372
2494
  if (state.pollInterval) {
2373
2495
  clearInterval(state.pollInterval);
2374
2496
  state.pollInterval = void 0;
@@ -2385,9 +2507,24 @@ function createSessionRefreshManager(opts) {
2385
2507
  state.unsubscribeOnline();
2386
2508
  state.unsubscribeOnline = void 0;
2387
2509
  }
2388
- state.lastSync = 0;
2510
+ if (state.unsubscribeSignal) {
2511
+ state.unsubscribeSignal();
2512
+ state.unsubscribeSignal = void 0;
2513
+ }
2514
+ if (state.cleanupBroadcastSetup) {
2515
+ state.cleanupBroadcastSetup();
2516
+ state.cleanupBroadcastSetup = void 0;
2517
+ }
2518
+ if (state.cleanupFocusSetup) {
2519
+ state.cleanupFocusSetup();
2520
+ state.cleanupFocusSetup = void 0;
2521
+ }
2522
+ if (state.cleanupOnlineSetup) {
2523
+ state.cleanupOnlineSetup();
2524
+ state.cleanupOnlineSetup = void 0;
2525
+ }
2526
+ state.isInitialized = false;
2389
2527
  state.lastSessionRequest = 0;
2390
- state.cachedSession = void 0;
2391
2528
  };
2392
2529
  return {
2393
2530
  init,
@@ -2397,144 +2534,12 @@ function createSessionRefreshManager(opts) {
2397
2534
  };
2398
2535
  }
2399
2536
  //#endregion
2400
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.11_@better-auth+utils@0.4.0_@better-fetch+fetch@1.1.21_@opentelem_3f357e8652888625f393bee0c48e5205/node_modules/@better-auth/core/dist/env/env-impl.mjs
2401
- const _envShim = Object.create(null);
2402
- const _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis);
2403
- const env = new Proxy(_envShim, {
2404
- get(_, prop) {
2405
- return _getEnv()[prop] ?? _envShim[prop];
2406
- },
2407
- has(_, prop) {
2408
- return prop in _getEnv() || prop in _envShim;
2409
- },
2410
- set(_, prop, value) {
2411
- const env = _getEnv(true);
2412
- env[prop] = value;
2413
- return true;
2414
- },
2415
- deleteProperty(_, prop) {
2416
- if (!prop) return false;
2417
- const env = _getEnv(true);
2418
- delete env[prop];
2419
- return true;
2420
- },
2421
- ownKeys() {
2422
- const env = _getEnv(true);
2423
- return Object.keys(env);
2424
- }
2425
- });
2426
- typeof process !== "undefined" && process.env && process.env.NODE_ENV;
2427
- /**
2428
- * Get environment variable with fallback
2429
- */
2430
- function getEnvVar(key, fallback) {
2431
- if (typeof process !== "undefined" && process.env) return process.env[key] ?? fallback;
2432
- if (typeof Deno !== "undefined") return Deno.env.get(key) ?? fallback;
2433
- if (typeof Bun !== "undefined") return Bun.env[key] ?? fallback;
2434
- return fallback;
2435
- }
2436
- Object.freeze({
2437
- get BETTER_AUTH_SECRET() {
2438
- return getEnvVar("BETTER_AUTH_SECRET");
2439
- },
2440
- get AUTH_SECRET() {
2441
- return getEnvVar("AUTH_SECRET");
2442
- },
2443
- get BETTER_AUTH_TELEMETRY() {
2444
- return getEnvVar("BETTER_AUTH_TELEMETRY");
2445
- },
2446
- get BETTER_AUTH_TELEMETRY_ID() {
2447
- return getEnvVar("BETTER_AUTH_TELEMETRY_ID");
2448
- },
2449
- get NODE_ENV() {
2450
- return getEnvVar("NODE_ENV", "development");
2451
- },
2452
- get PACKAGE_VERSION() {
2453
- return getEnvVar("PACKAGE_VERSION", "0.0.0");
2454
- },
2455
- get BETTER_AUTH_TELEMETRY_ENDPOINT() {
2456
- return getEnvVar("BETTER_AUTH_TELEMETRY_ENDPOINT", "");
2457
- }
2458
- });
2459
- //#endregion
2460
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/utils/url.mjs
2461
- function checkHasPath(url) {
2462
- try {
2463
- return (new URL(url).pathname.replace(/\/+$/, "") || "/") !== "/";
2464
- } catch {
2465
- throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
2466
- }
2467
- }
2468
- function assertHasProtocol(url) {
2469
- try {
2470
- const parsedUrl = new URL(url);
2471
- if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new BetterAuthError(`Invalid base URL: ${url}. URL must include 'http://' or 'https://'`);
2472
- } catch (error) {
2473
- if (error instanceof BetterAuthError) throw error;
2474
- throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`, { cause: error });
2475
- }
2476
- }
2477
- function withPath(url, path = "/api/auth") {
2478
- assertHasProtocol(url);
2479
- if (checkHasPath(url)) return url;
2480
- const trimmedUrl = url.replace(/\/+$/, "");
2481
- if (!path || path === "/") return trimmedUrl;
2482
- path = path.startsWith("/") ? path : `/${path}`;
2483
- return `${trimmedUrl}${path}`;
2484
- }
2485
- function validateProxyHeader(header, type) {
2486
- if (!header || header.trim() === "") return false;
2487
- if (type === "proto") return header === "http" || header === "https";
2488
- if (type === "host") {
2489
- if ([
2490
- /\.\./,
2491
- /\0/,
2492
- /[\s]/,
2493
- /^[.]/,
2494
- /[<>'"]/,
2495
- /javascript:/i,
2496
- /file:/i,
2497
- /data:/i
2498
- ].some((pattern) => pattern.test(header))) return false;
2499
- return /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(header) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(header) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(header) || /^localhost(:[0-9]{1,5})?$/i.test(header);
2500
- }
2501
- return false;
2502
- }
2503
- function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
2504
- if (url) return withPath(url, path);
2505
- if (loadEnv !== false) {
2506
- const fromEnv = env.BETTER_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL || (env.BASE_URL !== "/" ? env.BASE_URL : void 0);
2507
- if (fromEnv) return withPath(fromEnv, path);
2508
- }
2509
- const fromRequest = request?.headers.get("x-forwarded-host");
2510
- const fromRequestProto = request?.headers.get("x-forwarded-proto");
2511
- if (fromRequest && fromRequestProto && trustedProxyHeaders) {
2512
- if (validateProxyHeader(fromRequestProto, "proto") && validateProxyHeader(fromRequest, "host")) try {
2513
- return withPath(`${fromRequestProto}://${fromRequest}`, path);
2514
- } catch (_error) {}
2515
- }
2516
- if (request) {
2517
- const url = getOrigin(request.url);
2518
- if (!url) throw new BetterAuthError("Could not get origin from request. Please provide a valid base URL.");
2519
- return withPath(url, path);
2520
- }
2521
- if (typeof window !== "undefined" && window.location) return withPath(window.location.origin, path);
2522
- }
2523
- function getOrigin(url) {
2524
- try {
2525
- const parsedUrl = new URL(url);
2526
- return parsedUrl.origin === "null" ? null : parsedUrl.origin;
2527
- } catch {
2528
- return null;
2529
- }
2530
- }
2531
- //#endregion
2532
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/fetch-plugins.mjs
2537
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/fetch-plugins.mjs
2533
2538
  const redirectPlugin = {
2534
2539
  id: "redirect",
2535
2540
  name: "Redirect",
2536
2541
  hooks: { onSuccess(context) {
2537
- if (context.data?.url && context.data?.redirect) {
2542
+ if (context.data?.url && context.data?.redirect && isSafeUrlScheme(context.data.url)) {
2538
2543
  if (typeof window !== "undefined" && window.location) {
2539
2544
  if (window.location) try {
2540
2545
  window.location.href = context.data.url;
@@ -2544,21 +2549,146 @@ const redirectPlugin = {
2544
2549
  } }
2545
2550
  };
2546
2551
  //#endregion
2547
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/session-atom.mjs
2552
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/session-atom.mjs
2553
+ const isServer = () => typeof window === "undefined";
2554
+ /**
2555
+ * Normalize $fetch response: `throw: true` returns data directly,
2556
+ * otherwise `{ data, error }`.
2557
+ */
2558
+ function normalizeSessionResponse(res) {
2559
+ if (typeof res === "object" && res !== null && "data" in res && "error" in res) return res;
2560
+ return {
2561
+ data: res,
2562
+ error: null
2563
+ };
2564
+ }
2565
+ function normalizeSessionData(data) {
2566
+ if (!data) return null;
2567
+ if (data.session === null && data.user === null) return null;
2568
+ return data;
2569
+ }
2570
+ function isSessionAtomEqual(a, b) {
2571
+ return isJsonEqual(a.data, b.data) && a.error === b.error && a.isPending === b.isPending && a.isRefetching === b.isRefetching && a.refetch === b.refetch;
2572
+ }
2548
2573
  function getSessionAtom($fetch, options) {
2549
2574
  const $signal = /* @__PURE__ */ atom(false);
2550
- const session = useAuthQuery($signal, "/get-session", $fetch, { method: "GET" });
2575
+ let abortController;
2576
+ const refetch = (queryParams) => fetchSession(queryParams);
2577
+ const session = /* @__PURE__ */ atom({
2578
+ data: null,
2579
+ error: null,
2580
+ isPending: true,
2581
+ isRefetching: false,
2582
+ refetch
2583
+ });
2584
+ withEquality(session, isSessionAtomEqual);
2585
+ const settleAbortedFetch = (controller) => {
2586
+ if (abortController !== controller) return;
2587
+ const current = session.get();
2588
+ abortController = void 0;
2589
+ if (!current.isPending && !current.isRefetching) return;
2590
+ session.set({
2591
+ ...current,
2592
+ isPending: false,
2593
+ isRefetching: false,
2594
+ refetch
2595
+ });
2596
+ };
2597
+ const fetchSession = async (queryParams) => {
2598
+ abortController?.abort();
2599
+ const controller = new AbortController();
2600
+ abortController = controller;
2601
+ const current = session.get();
2602
+ session.set({
2603
+ ...current,
2604
+ isPending: current.data === null,
2605
+ isRefetching: true,
2606
+ error: null,
2607
+ refetch
2608
+ });
2609
+ try {
2610
+ const res = await $fetch("/get-session", {
2611
+ method: "GET",
2612
+ query: queryParams?.query,
2613
+ signal: controller.signal
2614
+ });
2615
+ if (controller.signal.aborted) {
2616
+ settleAbortedFetch(controller);
2617
+ return;
2618
+ }
2619
+ let { data, error } = normalizeSessionResponse(res);
2620
+ if (data?.needsRefresh) try {
2621
+ const refreshRes = await $fetch("/get-session", {
2622
+ method: "POST",
2623
+ signal: controller.signal
2624
+ });
2625
+ if (controller.signal.aborted) {
2626
+ settleAbortedFetch(controller);
2627
+ return;
2628
+ }
2629
+ ({data, error} = normalizeSessionResponse(refreshRes));
2630
+ } catch {
2631
+ if (controller.signal.aborted) {
2632
+ settleAbortedFetch(controller);
2633
+ return;
2634
+ }
2635
+ }
2636
+ if (error) {
2637
+ const latest = session.get();
2638
+ const isUnauthorized = error?.status === 401;
2639
+ session.set({
2640
+ data: isUnauthorized ? null : latest.data,
2641
+ error,
2642
+ isPending: false,
2643
+ isRefetching: false,
2644
+ refetch
2645
+ });
2646
+ return;
2647
+ }
2648
+ const sessionData = normalizeSessionData(data);
2649
+ const current = session.get();
2650
+ const stableData = current.data != null && sessionData != null && isJsonEqual(current.data, sessionData) ? current.data : sessionData;
2651
+ session.set({
2652
+ data: stableData,
2653
+ error: null,
2654
+ isPending: false,
2655
+ isRefetching: false,
2656
+ refetch
2657
+ });
2658
+ } catch (fetchError) {
2659
+ if (controller.signal.aborted) {
2660
+ settleAbortedFetch(controller);
2661
+ return;
2662
+ }
2663
+ const latest = session.get();
2664
+ session.set({
2665
+ data: latest.data,
2666
+ error: fetchError,
2667
+ isPending: false,
2668
+ isRefetching: false,
2669
+ refetch
2670
+ });
2671
+ }
2672
+ };
2551
2673
  let broadcastSessionUpdate = () => {};
2552
2674
  onMount(session, () => {
2675
+ let timeoutId;
2676
+ if (!isServer()) timeoutId = setTimeout(() => {
2677
+ fetchSession();
2678
+ }, 0);
2553
2679
  const refreshManager = createSessionRefreshManager({
2554
- sessionAtom: session,
2680
+ fetchSession,
2681
+ shouldPollSession: () => session.get().data != null,
2555
2682
  sessionSignal: $signal,
2556
- $fetch,
2557
2683
  options
2558
2684
  });
2559
2685
  refreshManager.init();
2560
2686
  broadcastSessionUpdate = refreshManager.broadcastSessionUpdate;
2561
2687
  return () => {
2688
+ if (timeoutId) clearTimeout(timeoutId);
2689
+ const controller = abortController;
2690
+ controller?.abort();
2691
+ if (controller) settleAbortedFetch(controller);
2562
2692
  refreshManager.cleanup();
2563
2693
  };
2564
2694
  });
@@ -2597,7 +2727,7 @@ function createDefu(merger) {
2597
2727
  }
2598
2728
  const defu = createDefu();
2599
2729
  //#endregion
2600
- //#region ../../node_modules/.pnpm/@better-fetch+fetch@1.1.21/node_modules/@better-fetch/fetch/dist/index.js
2730
+ //#region ../../node_modules/.pnpm/@better-fetch+fetch@1.3.1/node_modules/@better-fetch/fetch/dist/index.js
2601
2731
  var __defProp = Object.defineProperty;
2602
2732
  var __defProps = Object.defineProperties;
2603
2733
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -2764,13 +2894,25 @@ function getFetch(options) {
2764
2894
  if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch;
2765
2895
  throw new Error("No fetch implementation found");
2766
2896
  }
2897
+ function mergeHeaders(...sources) {
2898
+ const merged = {};
2899
+ for (const source of sources) {
2900
+ if (!source) continue;
2901
+ if (source instanceof Headers) source.forEach((value, key) => {
2902
+ merged[key] = value;
2903
+ });
2904
+ else {
2905
+ const entries = Array.isArray(source) ? source : Object.entries(source);
2906
+ for (const [key, value] of entries) if (value !== null && value !== void 0) merged[key] = value;
2907
+ }
2908
+ }
2909
+ return merged;
2910
+ }
2767
2911
  async function getHeaders(opts) {
2768
- const headers = new Headers(opts == null ? void 0 : opts.headers);
2769
- const authHeader = await getAuthHeader(opts);
2770
- for (const [key, value] of Object.entries(authHeader || {})) headers.set(key, value);
2912
+ const headers = new Headers(mergeHeaders(opts == null ? void 0 : opts.headers, await getAuthHeader(opts)));
2771
2913
  if (!headers.has("content-type")) {
2772
- const t = detectContentType(opts == null ? void 0 : opts.body);
2773
- if (t) headers.set("content-type", t);
2914
+ const contentType = detectContentType(opts == null ? void 0 : opts.body);
2915
+ if (contentType) headers.set("content-type", contentType);
2774
2916
  }
2775
2917
  return headers;
2776
2918
  }
@@ -2778,18 +2920,17 @@ function detectContentType(body) {
2778
2920
  if (isJSONSerializable(body)) return "application/json";
2779
2921
  return null;
2780
2922
  }
2781
- function getBody(options) {
2782
- if (!(options == null ? void 0 : options.body)) return null;
2783
- const headers = new Headers(options == null ? void 0 : options.headers);
2784
- if (isJSONSerializable(options.body) && !headers.has("content-type")) {
2785
- for (const [key, value] of Object.entries(options == null ? void 0 : options.body)) if (value instanceof Date) options.body[key] = value.toISOString();
2786
- return JSON.stringify(options.body);
2787
- }
2788
- if (headers.has("content-type") && headers.get("content-type") === "application/x-www-form-urlencoded") {
2789
- if (isJSONSerializable(options.body)) return new URLSearchParams(options.body).toString();
2790
- return options.body;
2791
- }
2792
- return options.body;
2923
+ function getMediaType(headers) {
2924
+ const contentType = headers.get("content-type");
2925
+ return contentType ? contentType.split(";")[0].trim().toLowerCase() : null;
2926
+ }
2927
+ function getBody(options, headers) {
2928
+ const { body } = options;
2929
+ if (!body) return null;
2930
+ if (!isJSONSerializable(body)) return body;
2931
+ if (typeof body === "string") return body;
2932
+ if (getMediaType(headers) === "application/x-www-form-urlencoded") return new URLSearchParams(body).toString();
2933
+ return JSON.stringify(body);
2793
2934
  }
2794
2935
  function getMethod$1(url, options) {
2795
2936
  var _a;
@@ -2851,11 +2992,29 @@ var applySchemaPlugin = (config) => ({
2851
2992
  if ((_d = schema.config) == null ? void 0 : _d.baseURL) {
2852
2993
  if (urlKey.startsWith(schema.config.baseURL)) urlKey = urlKey.replace(schema.config.baseURL, "");
2853
2994
  }
2995
+ if (urlKey.startsWith("/") && urlKey.charAt(1) === "@") urlKey = urlKey.substring(1);
2854
2996
  const keySchema = schema.schema[urlKey];
2855
2997
  if (keySchema) {
2998
+ let validatedHeaders = options == null ? void 0 : options.headers;
2999
+ if (keySchema.headers && !(options == null ? void 0 : options.disableValidation)) {
3000
+ const normalizedHeaders = {};
3001
+ if (options == null ? void 0 : options.headers) {
3002
+ if (options.headers instanceof Headers) options.headers.forEach((value, key) => {
3003
+ normalizedHeaders[key.toLowerCase()] = value;
3004
+ });
3005
+ else if (typeof options.headers === "object") {
3006
+ for (const [key, value] of Object.entries(options.headers)) if (value !== null && value !== void 0) normalizedHeaders[key.toLowerCase()] = value;
3007
+ }
3008
+ }
3009
+ const validated = await parseStandardSchema(keySchema.headers, normalizedHeaders);
3010
+ const finalHeaders = {};
3011
+ for (const [key, value] of Object.entries(validated)) finalHeaders[key.toLowerCase()] = value;
3012
+ validatedHeaders = finalHeaders;
3013
+ }
2856
3014
  let opts = __spreadProps(__spreadValues({}, options), {
2857
3015
  method: keySchema.method,
2858
- output: keySchema.output
3016
+ output: keySchema.output,
3017
+ headers: validatedHeaders
2859
3018
  });
2860
3019
  if (!(options == null ? void 0 : options.disableValidation)) opts = __spreadProps(__spreadValues({}, opts), {
2861
3020
  body: keySchema.input ? await parseStandardSchema(keySchema.input, options == null ? void 0 : options.body) : options == null ? void 0 : options.body,
@@ -2876,11 +3035,14 @@ var applySchemaPlugin = (config) => ({
2876
3035
  });
2877
3036
  var createFetch = (config) => {
2878
3037
  async function $fetch(url, options) {
2879
- const opts = __spreadProps(__spreadValues(__spreadValues({}, config), options), { plugins: [
2880
- ...(config == null ? void 0 : config.plugins) || [],
2881
- applySchemaPlugin(config || {}),
2882
- ...(options == null ? void 0 : options.plugins) || []
2883
- ] });
3038
+ const opts = __spreadProps(__spreadValues(__spreadValues({}, config), options), {
3039
+ headers: mergeHeaders(config == null ? void 0 : config.headers, options == null ? void 0 : options.headers),
3040
+ plugins: [
3041
+ ...(config == null ? void 0 : config.plugins) || [],
3042
+ applySchemaPlugin(config || {}),
3043
+ ...(options == null ? void 0 : options.plugins) || []
3044
+ ]
3045
+ });
2884
3046
  if (config == null ? void 0 : config.catchAllError) try {
2885
3047
  return await betterFetch(url, opts);
2886
3048
  } catch (error) {
@@ -2898,6 +3060,13 @@ var createFetch = (config) => {
2898
3060
  }
2899
3061
  return $fetch;
2900
3062
  };
3063
+ var isReservedPathSegment = (value) => value === "." || value === "..";
3064
+ function encodePathSegment(segment, pathParams) {
3065
+ let pathSegment = segment;
3066
+ for (const [key, value] of pathParams) pathSegment = pathSegment.replace(key, value);
3067
+ if (isReservedPathSegment(pathSegment)) throw new TypeError("Path parameters cannot be reserved path segments");
3068
+ return encodeURIComponent(pathSegment);
3069
+ }
2901
3070
  function getURL2(url, option) {
2902
3071
  const { baseURL, params, query } = option || {
2903
3072
  query: {},
@@ -2922,15 +3091,16 @@ function getURL2(url, option) {
2922
3091
  } else serializedValue = JSON.stringify(value);
2923
3092
  queryParams.set(key, serializedValue);
2924
3093
  }
3094
+ const pathParams = /* @__PURE__ */ new Map();
2925
3095
  if (params) if (Array.isArray(params)) {
2926
3096
  const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
2927
3097
  for (const [index, key] of paramPaths.entries()) {
2928
3098
  const value = params[index];
2929
- path = path.replace(key, value);
3099
+ pathParams.set(key, String(value));
2930
3100
  }
2931
- } else for (const [key, value] of Object.entries(params)) path = path.replace(`:${key}`, String(value));
2932
- path = path.split("/").map(encodeURIComponent).join("/");
2933
- if (path.startsWith("/")) path = path.slice(1);
3101
+ } else for (const [key, value] of Object.entries(params)) pathParams.set(`:${key}`, String(value));
3102
+ path = path.split("/").map((segment) => encodePathSegment(segment, pathParams)).join("/");
3103
+ path = path.replace(/^\/+/, "");
2934
3104
  let queryParamString = queryParams.toString();
2935
3105
  queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
2936
3106
  if (!basePath.startsWith("http")) return `${basePath}${path}${queryParamString}`;
@@ -2943,10 +3113,10 @@ var betterFetch = async (url, options) => {
2943
3113
  const controller = new AbortController();
2944
3114
  const signal = (_a = opts.signal) != null ? _a : controller.signal;
2945
3115
  const _url = getURL2(__url, opts);
2946
- const body = getBody(opts);
2947
3116
  const headers = await getHeaders(opts);
3117
+ const body = getBody(opts, headers);
2948
3118
  const method = getMethod$1(__url, opts);
2949
- let context = __spreadProps(__spreadValues({}, opts), {
3119
+ const context = __spreadProps(__spreadValues({}, opts), {
2950
3120
  url: _url,
2951
3121
  headers,
2952
3122
  body,
@@ -2955,7 +3125,7 @@ var betterFetch = async (url, options) => {
2955
3125
  });
2956
3126
  for (const onRequest of hooks.onRequest) if (onRequest) {
2957
3127
  const res = await onRequest(context);
2958
- if (typeof res === "object" && res !== null) context = res;
3128
+ if (typeof res === "object" && res !== null) Object.assign(context, res);
2959
3129
  }
2960
3130
  if ("pipeTo" in context && typeof context.pipeTo === "function" || typeof ((_b = options == null ? void 0 : options.body) == null ? void 0 : _b.pipe) === "function") {
2961
3131
  if (!("duplex" in context)) context.duplex = "half";
@@ -3031,7 +3201,7 @@ var betterFetch = async (url, options) => {
3031
3201
  };
3032
3202
  };
3033
3203
  //#endregion
3034
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/config.mjs
3204
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/config.mjs
3035
3205
  const resolvePublicAuthUrl = (basePath) => {
3036
3206
  if (typeof process === "undefined") return void 0;
3037
3207
  const path = basePath ?? "/api/auth";
@@ -3129,12 +3299,25 @@ const getClientConfig = (options, loadEnv) => {
3129
3299
  };
3130
3300
  };
3131
3301
  //#endregion
3132
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/utils/is-atom.mjs
3302
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/utils/is-atom.mjs
3133
3303
  function isAtom(value) {
3134
3304
  return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
3135
3305
  }
3136
3306
  //#endregion
3137
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/proxy.mjs
3307
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.6.23_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@openteleme_398718bcf9b56a2240f5e645ad2d451e/node_modules/@better-auth/core/dist/utils/string.mjs
3308
+ function capitalizeFirstLetter(str) {
3309
+ return str.charAt(0).toUpperCase() + str.slice(1);
3310
+ }
3311
+ const WORD_PATTERN = /[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu;
3312
+ const APOSTROPHE_PATTERN = /['\u2019]/g;
3313
+ function splitWords(input) {
3314
+ return input.replace(APOSTROPHE_PATTERN, "").match(WORD_PATTERN) ?? [];
3315
+ }
3316
+ function toKebabCase(input) {
3317
+ return splitWords(input).map((word) => word.toLowerCase()).join("-");
3318
+ }
3319
+ //#endregion
3320
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/proxy.mjs
3138
3321
  function getMethod(path, knownPathMethods, args) {
3139
3322
  const method = knownPathMethods[path];
3140
3323
  const { fetchOptions, query: _query, ...body } = args || {};
@@ -3161,7 +3344,7 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
3161
3344
  return createProxy(fullPath);
3162
3345
  },
3163
3346
  apply: async (_, __, args) => {
3164
- const routePath = "/" + path.map((segment) => segment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)).join("/");
3347
+ const routePath = "/" + path.map(toKebabCase).join("/");
3165
3348
  const arg = args[0] || {};
3166
3349
  const fetchOptions = args[1] || {};
3167
3350
  const { query, fetchOptions: argFetchOptions, ...body } = arg;
@@ -3209,12 +3392,7 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
3209
3392
  return createProxy();
3210
3393
  }
3211
3394
  //#endregion
3212
- //#region ../../node_modules/.pnpm/@better-auth+core@1.6.11_@better-auth+utils@0.4.0_@better-fetch+fetch@1.1.21_@opentelem_3f357e8652888625f393bee0c48e5205/node_modules/@better-auth/core/dist/utils/string.mjs
3213
- function capitalizeFirstLetter(str) {
3214
- return str.charAt(0).toUpperCase() + str.slice(1);
3215
- }
3216
- //#endregion
3217
- //#region ../../node_modules/.pnpm/better-auth@1.6.11_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._122a35b1d4615e80ac3ce156f3d09434/node_modules/better-auth/dist/client/vanilla.mjs
3395
+ //#region ../../node_modules/.pnpm/better-auth@1.6.23_@opentelemetry+api@1.9.1_@tanstack+react-start@1.168.26_crossws@0.4._c472a772c8203e3e5cd8f6066a81eb33/node_modules/better-auth/dist/client/vanilla.mjs
3218
3396
  function createAuthClient(options) {
3219
3397
  const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
3220
3398
  const resolvedHooks = {};
@@ -3361,7 +3539,8 @@ function createCliClient(config, options) {
3361
3539
  return createKeystrokeClient({
3362
3540
  baseUrl: options.baseUrl,
3363
3541
  auth: resolveCliAuth(config),
3364
- getActiveOrganizationId: options.platform ? () => options.organizationId ?? getResolvedOrganizationId() ?? null : void 0
3542
+ getActiveOrganizationId: options.platform ? () => options.organizationId ?? getResolvedOrganizationId() ?? null : void 0,
3543
+ ky: { headers: { [CLIENT_CHANNEL_HEADER]: "cli" } }
3365
3544
  });
3366
3545
  }
3367
3546
  //#endregion
@@ -4935,7 +5114,8 @@ function createCliPlatformClient(config, options = {}) {
4935
5114
  baseUrl: platformUrl,
4936
5115
  auth: toPlatformAuth(resolveCliAuth(config)),
4937
5116
  refreshBearerToken: () => getCliJwt(platformUrl, true),
4938
- getActiveOrganizationId: () => options.organizationId === void 0 ? getResolvedOrganizationId() ?? null : options.organizationId
5117
+ getActiveOrganizationId: () => options.organizationId === void 0 ? getResolvedOrganizationId() ?? null : options.organizationId,
5118
+ getExtraHeaders: () => ({ [CLIENT_CHANNEL_HEADER]: "cli" })
4939
5119
  });
4940
5120
  }
4941
5121
  //#endregion
@@ -5202,88 +5382,6 @@ async function resolveApiTarget(config, options = {}) {
5202
5382
  return resolvePlatformTarget(config, projectRef);
5203
5383
  }
5204
5384
  //#endregion
5205
- //#region ../../packages/telemetry/dist/index.mjs
5206
- const storage = new AsyncLocalStorage();
5207
- function getTelemetryContext() {
5208
- return storage.getStore();
5209
- }
5210
- /**
5211
- * Returns true when an error is an expected client/control-flow failure that
5212
- * should not become an Error Tracking issue.
5213
- */
5214
- function isExpectedError(error) {
5215
- if (!error || typeof error !== "object") return false;
5216
- const status = readStatus$1(error);
5217
- if (status !== void 0 && (status === 0 || status >= 400 && status < 500)) return true;
5218
- if ("name" in error && typeof error.name === "string") {
5219
- if (error.name === "AbortError" || error.name === "CanceledError" || error.name === "CancelledError" || error.name === "RunTimeoutError") return true;
5220
- }
5221
- return false;
5222
- }
5223
- function readStatus$1(error) {
5224
- if ("status" in error && typeof error.status === "number") return error.status;
5225
- if ("statusCode" in error && typeof error.statusCode === "number") return error.statusCode;
5226
- }
5227
- const EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*(:[a-z][a-z0-9_]*)?$/;
5228
- let sink;
5229
- function configureTelemetry(options) {
5230
- sink = options.sink;
5231
- }
5232
- async function flushTelemetry() {
5233
- await sink?.flush?.();
5234
- }
5235
- async function shutdownTelemetry() {
5236
- const current = sink;
5237
- sink = void 0;
5238
- await current?.shutdown?.();
5239
- }
5240
- async function captureException(input) {
5241
- if (isExpectedError(input.error) || !sink?.captureException) return;
5242
- const context = getTelemetryContext();
5243
- const actorId = input.actorId ?? context?.actorId;
5244
- const analyticsId = input.analyticsId ?? context?.analyticsId;
5245
- const organizationId = input.organizationId ?? context?.organizationId;
5246
- const projectId = input.projectId ?? context?.projectId;
5247
- const sessionId = input.sessionId ?? context?.sessionId;
5248
- const enriched = {
5249
- error: input.error,
5250
- ...actorId ? { actorId } : {},
5251
- ...analyticsId ? { analyticsId } : {},
5252
- ...organizationId ? { organizationId } : {},
5253
- ...projectId ? { projectId } : {},
5254
- ...sessionId ? { sessionId } : {},
5255
- ...input.operation ? { operation: input.operation } : {},
5256
- ...input.properties ? { properties: input.properties } : {}
5257
- };
5258
- try {
5259
- await sink.captureException(enriched);
5260
- } catch (error) {
5261
- console.error("[telemetry] captureException sink failed", error);
5262
- }
5263
- }
5264
- async function event(input) {
5265
- if (!EVENT_NAME_PATTERN.test(input.name)) {
5266
- console.error(`[telemetry] rejected invalid event name: ${input.name}`);
5267
- return;
5268
- }
5269
- const actorId = input.actorId.trim();
5270
- if (!actorId) {
5271
- console.error("[telemetry] rejected event without actorId");
5272
- return;
5273
- }
5274
- if (!sink?.event) return;
5275
- try {
5276
- await sink.event({
5277
- ...input,
5278
- actorId,
5279
- timestamp: input.timestamp ?? /* @__PURE__ */ new Date(),
5280
- uuid: input.uuid ?? globalThis.crypto.randomUUID()
5281
- });
5282
- } catch (error) {
5283
- console.error("[telemetry] event sink failed", error);
5284
- }
5285
- }
5286
- //#endregion
5287
5385
  //#region ../../packages/telemetry/dist/posthog-node.mjs
5288
5386
  const MAX_EVENT_BYTES = 9e5;
5289
5387
  function createPostHogSink(options) {
@@ -5331,6 +5429,21 @@ function createPostHogSink(options) {
5331
5429
  client.capture(body);
5332
5430
  if (immediate) await client.flush();
5333
5431
  },
5432
+ async groupIdentify(input) {
5433
+ client.groupIdentify({
5434
+ groupType: input.groupType,
5435
+ groupKey: input.groupKey,
5436
+ properties: sanitizeProperties(input.properties)
5437
+ });
5438
+ if (immediate) await client.flush();
5439
+ },
5440
+ async alias(input) {
5441
+ client.alias({
5442
+ distinctId: input.distinctId,
5443
+ alias: input.alias
5444
+ });
5445
+ if (immediate) await client.flush();
5446
+ },
5334
5447
  async flush() {
5335
5448
  await client.flush();
5336
5449
  },
@@ -5388,25 +5501,56 @@ function shouldReportCliException(error, context) {
5388
5501
  }
5389
5502
  //#endregion
5390
5503
  //#region src/telemetry/identity.ts
5391
- function getCliTelemetryActorId() {
5392
- return getOrCreateAnonymousDistinctId();
5393
- }
5394
- function getOrCreateAnonymousDistinctId(configDir = getCliConfigDir()) {
5395
- const path = join(configDir, "telemetry-distinct-id");
5504
+ const ANON_DISTINCT_ID_FILE = "telemetry-distinct-id";
5505
+ const USER_ID_FILE = "telemetry-user-id";
5506
+ function readTrimmedFile(path) {
5396
5507
  try {
5397
- const existing = readFileSync(path, "utf8").trim();
5398
- if (existing) return existing;
5399
- } catch {}
5400
- const id = globalThis.crypto.randomUUID();
5508
+ return readFileSync(path, "utf8").trim() || void 0;
5509
+ } catch {
5510
+ return;
5511
+ }
5512
+ }
5513
+ function writeSecretFile(path, value, configDir) {
5401
5514
  try {
5402
5515
  mkdirSync(configDir, { recursive: true });
5403
- writeFileSync(path, `${id}\n`, {
5516
+ writeFileSync(path, `${value}\n`, {
5404
5517
  encoding: "utf8",
5405
5518
  mode: 384
5406
5519
  });
5407
5520
  } catch {}
5521
+ }
5522
+ function getOrCreateAnonymousDistinctId(configDir = getCliConfigDir()) {
5523
+ const path = join(configDir, ANON_DISTINCT_ID_FILE);
5524
+ const existing = readTrimmedFile(path);
5525
+ if (existing) return existing;
5526
+ const id = globalThis.crypto.randomUUID();
5527
+ writeSecretFile(path, id, configDir);
5408
5528
  return id;
5409
5529
  }
5530
+ /** Persisted authenticated user id when present; otherwise the anonymous distinct id. */
5531
+ function getCliTelemetryActor(configDir = getCliConfigDir()) {
5532
+ const userId = readTrimmedFile(join(configDir, USER_ID_FILE));
5533
+ if (userId) return {
5534
+ actorId: userId,
5535
+ anonymous: false
5536
+ };
5537
+ return {
5538
+ actorId: getOrCreateAnonymousDistinctId(configDir),
5539
+ anonymous: true
5540
+ };
5541
+ }
5542
+ /** Persist the authenticated user id next to the anonymous distinct id. */
5543
+ function persistCliTelemetryUserId(userId, configDir = getCliConfigDir()) {
5544
+ const trimmed = userId.trim();
5545
+ if (!trimmed) return;
5546
+ writeSecretFile(join(configDir, USER_ID_FILE), trimmed, configDir);
5547
+ }
5548
+ /** Clear the authenticated user id on logout (keeps anonymous distinct id). */
5549
+ function clearCliTelemetryUserId(configDir = getCliConfigDir()) {
5550
+ try {
5551
+ unlinkSync(join(configDir, USER_ID_FILE));
5552
+ } catch {}
5553
+ }
5410
5554
  //#endregion
5411
5555
  //#region src/telemetry/init.ts
5412
5556
  let enabled = false;
@@ -5458,9 +5602,10 @@ async function shutdownCliTelemetry() {
5458
5602
  }
5459
5603
  async function reportCliException(error, context) {
5460
5604
  if (!enabled || isExpectedCliError(error) || !shouldReportCliException(error, context)) return;
5605
+ const actor = getCliTelemetryActor();
5461
5606
  await captureException({
5462
5607
  error,
5463
- analyticsId: getCliTelemetryActorId(),
5608
+ ...actor.anonymous ? { analyticsId: actor.actorId } : { actorId: actor.actorId },
5464
5609
  organizationId: context.organizationId,
5465
5610
  projectId: context.projectId,
5466
5611
  operation: context.operation ?? context.command ?? "cli.command",
@@ -5469,10 +5614,11 @@ async function reportCliException(error, context) {
5469
5614
  }
5470
5615
  async function trackCliEvent(name, input) {
5471
5616
  if (!enabled) return;
5617
+ const actor = getCliTelemetryActor();
5472
5618
  await event({
5473
5619
  name,
5474
- actorId: getCliTelemetryActorId(),
5475
- anonymous: true,
5620
+ actorId: actor.actorId,
5621
+ ...actor.anonymous ? { anonymous: true } : {},
5476
5622
  organizationId: input?.organizationId,
5477
5623
  projectId: input?.projectId,
5478
5624
  properties: baseProperties({
@@ -5481,6 +5627,21 @@ async function trackCliEvent(name, input) {
5481
5627
  })
5482
5628
  });
5483
5629
  }
5630
+ /**
5631
+ * Stitch anonymous CLI identity to an authenticated user id (fail-open).
5632
+ * Persists the user id so later events use it as actorId.
5633
+ */
5634
+ async function aliasCliTelemetryUser(userId, configDir) {
5635
+ const trimmed = userId.trim();
5636
+ if (!trimmed) return;
5637
+ const anonymousId = getOrCreateAnonymousDistinctId(configDir);
5638
+ persistCliTelemetryUserId(trimmed, configDir);
5639
+ if (!enabled || anonymousId === trimmed) return;
5640
+ await alias({
5641
+ distinctId: trimmed,
5642
+ alias: anonymousId
5643
+ }).catch(() => {});
5644
+ }
5484
5645
  //#endregion
5485
5646
  //#region src/errors/example-input.ts
5486
5647
  function exampleValueFromValidationMessage(message) {
@@ -6995,6 +7156,7 @@ function registerAuthLoginCommand(auth) {
6995
7156
  setAccessToken(platformUrl, result.accessToken);
6996
7157
  const user = await getSessionWithBearer(platformUrl, result.accessToken);
6997
7158
  if (user) {
7159
+ await aliasCliTelemetryUser(user.id);
6998
7160
  await trackCliEvent("cli:auth_login", { userId: user.id });
6999
7161
  process.stdout.write(`Logged in as ${user.name} (${user.email})\n`);
7000
7162
  } else {
@@ -7022,6 +7184,7 @@ function registerAuthLogoutCommand(auth) {
7022
7184
  const webUrl = options.webUrl ?? getWebUrl(config);
7023
7185
  const platformUrl = getPlatformUrl(config);
7024
7186
  clearAccessToken(platformUrl);
7187
+ clearCliTelemetryUserId();
7025
7188
  process.stdout.write(`${JSON.stringify({
7026
7189
  authenticated: false,
7027
7190
  webUrl,
@@ -7173,7 +7336,7 @@ function registerBuildCommand(program) {
7173
7336
  try {
7174
7337
  const root = resolveProjectRoot(options.dir);
7175
7338
  await ensureSdkCurrent(root);
7176
- const { buildApp } = await import("./dist-C8eO3iET.mjs");
7339
+ const { buildApp } = await import("./dist-yDNd8kGO.mjs");
7177
7340
  await buildApp({ root });
7178
7341
  process.stdout.write(`Built ${root}\n`);
7179
7342
  } catch (error) {
@@ -7298,7 +7461,7 @@ async function sleep(ms) {
7298
7461
  }
7299
7462
  async function buildDeployArchive(client, root, projectId, filter) {
7300
7463
  if (filter?.length) {
7301
- const { buildFilteredApp } = await import("./dist-C8eO3iET.mjs");
7464
+ const { buildFilteredApp } = await import("./dist-yDNd8kGO.mjs");
7302
7465
  const filtered = await buildFilteredApp({
7303
7466
  root,
7304
7467
  filter,
@@ -7320,7 +7483,7 @@ async function buildDeployArchive(client, root, projectId, filter) {
7320
7483
  sourceFiles: filtered.sourceFiles
7321
7484
  };
7322
7485
  }
7323
- const { buildApp } = await import("./dist-C8eO3iET.mjs");
7486
+ const { buildApp } = await import("./dist-yDNd8kGO.mjs");
7324
7487
  const { sourceFiles } = await buildApp({
7325
7488
  root,
7326
7489
  collectSources: true,
@@ -7447,7 +7610,7 @@ function runtimeChildEnv(parentEnv, overrides) {
7447
7610
  //#region src/project/bootstrap-run.ts
7448
7611
  /** Node args + env for `@keystrokehq/build` bootstrap (shared by start + dev). */
7449
7612
  async function resolveBootstrapRun(options) {
7450
- const { resolveRuntimeBuildArtifact } = await import("./dist-C8eO3iET.mjs");
7613
+ const { resolveRuntimeBuildArtifact } = await import("./dist-yDNd8kGO.mjs");
7451
7614
  const loader = pathToFileURL(resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/runtime-loader.mjs")).href;
7452
7615
  const bootstrap = resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/standalone-bootstrap.mjs");
7453
7616
  const args = [`--import=${loader}`];
@@ -7557,6 +7720,7 @@ function resolveDevServerUrl(root, portOverride) {
7557
7720
  return url.origin;
7558
7721
  }
7559
7722
  async function runDev(options) {
7723
+ trackCliEvent("cli:dev_started").catch(() => {});
7560
7724
  const root = resolveProjectRoot(options.dir);
7561
7725
  const runtimeNodeModules = resolveCliRuntimeNodeModules(resolveCliRoot(import.meta.url));
7562
7726
  ensureNativeDeps(runtimeNodeModules);
@@ -7596,7 +7760,7 @@ async function runDev(options) {
7596
7760
  process.on("SIGINT", shutdown);
7597
7761
  process.on("SIGTERM", shutdown);
7598
7762
  try {
7599
- const { watchApp } = await import("./dist-C8eO3iET.mjs");
7763
+ const { watchApp } = await import("./dist-yDNd8kGO.mjs");
7600
7764
  await watchApp({
7601
7765
  root,
7602
7766
  clean: false,
@@ -8658,7 +8822,7 @@ async function runStart(options) {
8658
8822
  const apiPort = Number(new URL(serverUrl).port || 80);
8659
8823
  const runtimeNodeModules = resolveCliRuntimeNodeModules(resolveCliRoot(import.meta.url));
8660
8824
  ensureNativeDeps(runtimeNodeModules);
8661
- const { buildApp } = await import("./dist-C8eO3iET.mjs");
8825
+ const { buildApp } = await import("./dist-yDNd8kGO.mjs");
8662
8826
  await buildApp({
8663
8827
  root,
8664
8828
  clean: false
@@ -9396,7 +9560,8 @@ function registerConfigCommand(program) {
9396
9560
  });
9397
9561
  }
9398
9562
  //#endregion
9399
- //#region src/skills/sync-agents-guide.ts
9563
+ //#region src/command-path.ts
9564
+ /** Leaf-to-root command names under `keystroke`, e.g. `["auth", "login"]`. */
9400
9565
  function commandPath(command) {
9401
9566
  const names = [];
9402
9567
  for (let current = command; current; current = current.parent) {
@@ -9405,6 +9570,8 @@ function commandPath(command) {
9405
9570
  }
9406
9571
  return names;
9407
9572
  }
9573
+ //#endregion
9574
+ //#region src/skills/sync-agents-guide.ts
9408
9575
  function shouldSkipAutoSync(command) {
9409
9576
  if (process.env.CI === "true" || process.env.CI === "1") return true;
9410
9577
  if (commandPath(command)[0] === "init") return true;
@@ -9435,6 +9602,7 @@ async function syncAgentsGuide(command) {
9435
9602
  }
9436
9603
  //#endregion
9437
9604
  //#region src/program.ts
9605
+ const commandStartTimes = /* @__PURE__ */ new WeakMap();
9438
9606
  function createProgram() {
9439
9607
  const program = new Command().name("keystroke").description("Build, run, and manage keystroke projects").version(readCliVersion()).option("--project <slug>", "Platform project slug (deploy target or one-off API target)").option("--organization <slug>", "Platform organization slug (org-scoped API target)").option("--local", "Force local keystroke server URL").hook("preAction", async (thisCommand, actionCommand) => {
9440
9608
  const opts = thisCommand.opts();
@@ -9443,7 +9611,17 @@ function createProgram() {
9443
9611
  organizationRef: opts.organization,
9444
9612
  local: opts.local
9445
9613
  });
9614
+ commandStartTimes.set(actionCommand, Date.now());
9446
9615
  await syncAgentsGuide(actionCommand);
9616
+ }).hook("postAction", async (_thisCommand, actionCommand) => {
9617
+ const startedAt = commandStartTimes.get(actionCommand);
9618
+ const path = commandPath(actionCommand);
9619
+ if (path.length === 0) return;
9620
+ trackCliEvent("cli:command_ran", { properties: {
9621
+ command_path: path.join(" "),
9622
+ success: !process.exitCode,
9623
+ duration_ms: startedAt !== void 0 ? Date.now() - startedAt : 0
9624
+ } }).catch(() => {});
9447
9625
  });
9448
9626
  registerAuthCommand(program);
9449
9627
  registerConnectCommand(program);
@@ -9476,7 +9654,7 @@ function createProgram() {
9476
9654
  async function runCli(argv) {
9477
9655
  initCliTelemetry();
9478
9656
  try {
9479
- const { maybeAutoUpdate } = await import("./maybe-auto-update-DflBoY7a.mjs");
9657
+ const { maybeAutoUpdate } = await import("./maybe-auto-update-C-HUlgKp.mjs");
9480
9658
  await maybeAutoUpdate(argv);
9481
9659
  await createProgram().parseAsync(argv);
9482
9660
  } finally {