@keystrokehq/cli 0.1.106 → 0.1.108

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";
@@ -3540,7 +3539,8 @@ function createCliClient(config, options) {
3540
3539
  return createKeystrokeClient({
3541
3540
  baseUrl: options.baseUrl,
3542
3541
  auth: resolveCliAuth(config),
3543
- 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" } }
3544
3544
  });
3545
3545
  }
3546
3546
  //#endregion
@@ -5114,7 +5114,8 @@ function createCliPlatformClient(config, options = {}) {
5114
5114
  baseUrl: platformUrl,
5115
5115
  auth: toPlatformAuth(resolveCliAuth(config)),
5116
5116
  refreshBearerToken: () => getCliJwt(platformUrl, true),
5117
- 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" })
5118
5119
  });
5119
5120
  }
5120
5121
  //#endregion
@@ -5381,88 +5382,6 @@ async function resolveApiTarget(config, options = {}) {
5381
5382
  return resolvePlatformTarget(config, projectRef);
5382
5383
  }
5383
5384
  //#endregion
5384
- //#region ../../packages/telemetry/dist/index.mjs
5385
- const storage = new AsyncLocalStorage();
5386
- function getTelemetryContext() {
5387
- return storage.getStore();
5388
- }
5389
- /**
5390
- * Returns true when an error is an expected client/control-flow failure that
5391
- * should not become an Error Tracking issue.
5392
- */
5393
- function isExpectedError(error) {
5394
- if (!error || typeof error !== "object") return false;
5395
- const status = readStatus$1(error);
5396
- if (status !== void 0 && (status === 0 || status >= 400 && status < 500)) return true;
5397
- if ("name" in error && typeof error.name === "string") {
5398
- if (error.name === "AbortError" || error.name === "CanceledError" || error.name === "CancelledError" || error.name === "RunTimeoutError") return true;
5399
- }
5400
- return false;
5401
- }
5402
- function readStatus$1(error) {
5403
- if ("status" in error && typeof error.status === "number") return error.status;
5404
- if ("statusCode" in error && typeof error.statusCode === "number") return error.statusCode;
5405
- }
5406
- const EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*(:[a-z][a-z0-9_]*)?$/;
5407
- let sink;
5408
- function configureTelemetry(options) {
5409
- sink = options.sink;
5410
- }
5411
- async function flushTelemetry() {
5412
- await sink?.flush?.();
5413
- }
5414
- async function shutdownTelemetry() {
5415
- const current = sink;
5416
- sink = void 0;
5417
- await current?.shutdown?.();
5418
- }
5419
- async function captureException(input) {
5420
- if (isExpectedError(input.error) || !sink?.captureException) return;
5421
- const context = getTelemetryContext();
5422
- const actorId = input.actorId ?? context?.actorId;
5423
- const analyticsId = input.analyticsId ?? context?.analyticsId;
5424
- const organizationId = input.organizationId ?? context?.organizationId;
5425
- const projectId = input.projectId ?? context?.projectId;
5426
- const sessionId = input.sessionId ?? context?.sessionId;
5427
- const enriched = {
5428
- error: input.error,
5429
- ...actorId ? { actorId } : {},
5430
- ...analyticsId ? { analyticsId } : {},
5431
- ...organizationId ? { organizationId } : {},
5432
- ...projectId ? { projectId } : {},
5433
- ...sessionId ? { sessionId } : {},
5434
- ...input.operation ? { operation: input.operation } : {},
5435
- ...input.properties ? { properties: input.properties } : {}
5436
- };
5437
- try {
5438
- await sink.captureException(enriched);
5439
- } catch (error) {
5440
- console.error("[telemetry] captureException sink failed", error);
5441
- }
5442
- }
5443
- async function event(input) {
5444
- if (!EVENT_NAME_PATTERN.test(input.name)) {
5445
- console.error(`[telemetry] rejected invalid event name: ${input.name}`);
5446
- return;
5447
- }
5448
- const actorId = input.actorId.trim();
5449
- if (!actorId) {
5450
- console.error("[telemetry] rejected event without actorId");
5451
- return;
5452
- }
5453
- if (!sink?.event) return;
5454
- try {
5455
- await sink.event({
5456
- ...input,
5457
- actorId,
5458
- timestamp: input.timestamp ?? /* @__PURE__ */ new Date(),
5459
- uuid: input.uuid ?? globalThis.crypto.randomUUID()
5460
- });
5461
- } catch (error) {
5462
- console.error("[telemetry] event sink failed", error);
5463
- }
5464
- }
5465
- //#endregion
5466
5385
  //#region ../../packages/telemetry/dist/posthog-node.mjs
5467
5386
  const MAX_EVENT_BYTES = 9e5;
5468
5387
  function createPostHogSink(options) {
@@ -5510,6 +5429,21 @@ function createPostHogSink(options) {
5510
5429
  client.capture(body);
5511
5430
  if (immediate) await client.flush();
5512
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
+ },
5513
5447
  async flush() {
5514
5448
  await client.flush();
5515
5449
  },
@@ -5567,25 +5501,56 @@ function shouldReportCliException(error, context) {
5567
5501
  }
5568
5502
  //#endregion
5569
5503
  //#region src/telemetry/identity.ts
5570
- function getCliTelemetryActorId() {
5571
- return getOrCreateAnonymousDistinctId();
5572
- }
5573
- function getOrCreateAnonymousDistinctId(configDir = getCliConfigDir()) {
5574
- 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) {
5575
5507
  try {
5576
- const existing = readFileSync(path, "utf8").trim();
5577
- if (existing) return existing;
5578
- } catch {}
5579
- 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) {
5580
5514
  try {
5581
5515
  mkdirSync(configDir, { recursive: true });
5582
- writeFileSync(path, `${id}\n`, {
5516
+ writeFileSync(path, `${value}\n`, {
5583
5517
  encoding: "utf8",
5584
5518
  mode: 384
5585
5519
  });
5586
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);
5587
5528
  return id;
5588
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
+ }
5589
5554
  //#endregion
5590
5555
  //#region src/telemetry/init.ts
5591
5556
  let enabled = false;
@@ -5637,9 +5602,10 @@ async function shutdownCliTelemetry() {
5637
5602
  }
5638
5603
  async function reportCliException(error, context) {
5639
5604
  if (!enabled || isExpectedCliError(error) || !shouldReportCliException(error, context)) return;
5605
+ const actor = getCliTelemetryActor();
5640
5606
  await captureException({
5641
5607
  error,
5642
- analyticsId: getCliTelemetryActorId(),
5608
+ ...actor.anonymous ? { analyticsId: actor.actorId } : { actorId: actor.actorId },
5643
5609
  organizationId: context.organizationId,
5644
5610
  projectId: context.projectId,
5645
5611
  operation: context.operation ?? context.command ?? "cli.command",
@@ -5648,10 +5614,11 @@ async function reportCliException(error, context) {
5648
5614
  }
5649
5615
  async function trackCliEvent(name, input) {
5650
5616
  if (!enabled) return;
5617
+ const actor = getCliTelemetryActor();
5651
5618
  await event({
5652
5619
  name,
5653
- actorId: getCliTelemetryActorId(),
5654
- anonymous: true,
5620
+ actorId: actor.actorId,
5621
+ ...actor.anonymous ? { anonymous: true } : {},
5655
5622
  organizationId: input?.organizationId,
5656
5623
  projectId: input?.projectId,
5657
5624
  properties: baseProperties({
@@ -5660,6 +5627,21 @@ async function trackCliEvent(name, input) {
5660
5627
  })
5661
5628
  });
5662
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
+ }
5663
5645
  //#endregion
5664
5646
  //#region src/errors/example-input.ts
5665
5647
  function exampleValueFromValidationMessage(message) {
@@ -7174,6 +7156,7 @@ function registerAuthLoginCommand(auth) {
7174
7156
  setAccessToken(platformUrl, result.accessToken);
7175
7157
  const user = await getSessionWithBearer(platformUrl, result.accessToken);
7176
7158
  if (user) {
7159
+ await aliasCliTelemetryUser(user.id);
7177
7160
  await trackCliEvent("cli:auth_login", { userId: user.id });
7178
7161
  process.stdout.write(`Logged in as ${user.name} (${user.email})\n`);
7179
7162
  } else {
@@ -7201,6 +7184,7 @@ function registerAuthLogoutCommand(auth) {
7201
7184
  const webUrl = options.webUrl ?? getWebUrl(config);
7202
7185
  const platformUrl = getPlatformUrl(config);
7203
7186
  clearAccessToken(platformUrl);
7187
+ clearCliTelemetryUserId();
7204
7188
  process.stdout.write(`${JSON.stringify({
7205
7189
  authenticated: false,
7206
7190
  webUrl,
@@ -7352,7 +7336,7 @@ function registerBuildCommand(program) {
7352
7336
  try {
7353
7337
  const root = resolveProjectRoot(options.dir);
7354
7338
  await ensureSdkCurrent(root);
7355
- const { buildApp } = await import("./dist-C8eO3iET.mjs");
7339
+ const { buildApp } = await import("./dist-yDNd8kGO.mjs");
7356
7340
  await buildApp({ root });
7357
7341
  process.stdout.write(`Built ${root}\n`);
7358
7342
  } catch (error) {
@@ -7477,7 +7461,7 @@ async function sleep(ms) {
7477
7461
  }
7478
7462
  async function buildDeployArchive(client, root, projectId, filter) {
7479
7463
  if (filter?.length) {
7480
- const { buildFilteredApp } = await import("./dist-C8eO3iET.mjs");
7464
+ const { buildFilteredApp } = await import("./dist-yDNd8kGO.mjs");
7481
7465
  const filtered = await buildFilteredApp({
7482
7466
  root,
7483
7467
  filter,
@@ -7499,7 +7483,7 @@ async function buildDeployArchive(client, root, projectId, filter) {
7499
7483
  sourceFiles: filtered.sourceFiles
7500
7484
  };
7501
7485
  }
7502
- const { buildApp } = await import("./dist-C8eO3iET.mjs");
7486
+ const { buildApp } = await import("./dist-yDNd8kGO.mjs");
7503
7487
  const { sourceFiles } = await buildApp({
7504
7488
  root,
7505
7489
  collectSources: true,
@@ -7626,7 +7610,7 @@ function runtimeChildEnv(parentEnv, overrides) {
7626
7610
  //#region src/project/bootstrap-run.ts
7627
7611
  /** Node args + env for `@keystrokehq/build` bootstrap (shared by start + dev). */
7628
7612
  async function resolveBootstrapRun(options) {
7629
- const { resolveRuntimeBuildArtifact } = await import("./dist-C8eO3iET.mjs");
7613
+ const { resolveRuntimeBuildArtifact } = await import("./dist-yDNd8kGO.mjs");
7630
7614
  const loader = pathToFileURL(resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/runtime-loader.mjs")).href;
7631
7615
  const bootstrap = resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/standalone-bootstrap.mjs");
7632
7616
  const args = [`--import=${loader}`];
@@ -7736,6 +7720,7 @@ function resolveDevServerUrl(root, portOverride) {
7736
7720
  return url.origin;
7737
7721
  }
7738
7722
  async function runDev(options) {
7723
+ trackCliEvent("cli:dev_started").catch(() => {});
7739
7724
  const root = resolveProjectRoot(options.dir);
7740
7725
  const runtimeNodeModules = resolveCliRuntimeNodeModules(resolveCliRoot(import.meta.url));
7741
7726
  ensureNativeDeps(runtimeNodeModules);
@@ -7775,7 +7760,7 @@ async function runDev(options) {
7775
7760
  process.on("SIGINT", shutdown);
7776
7761
  process.on("SIGTERM", shutdown);
7777
7762
  try {
7778
- const { watchApp } = await import("./dist-C8eO3iET.mjs");
7763
+ const { watchApp } = await import("./dist-yDNd8kGO.mjs");
7779
7764
  await watchApp({
7780
7765
  root,
7781
7766
  clean: false,
@@ -8837,7 +8822,7 @@ async function runStart(options) {
8837
8822
  const apiPort = Number(new URL(serverUrl).port || 80);
8838
8823
  const runtimeNodeModules = resolveCliRuntimeNodeModules(resolveCliRoot(import.meta.url));
8839
8824
  ensureNativeDeps(runtimeNodeModules);
8840
- const { buildApp } = await import("./dist-C8eO3iET.mjs");
8825
+ const { buildApp } = await import("./dist-yDNd8kGO.mjs");
8841
8826
  await buildApp({
8842
8827
  root,
8843
8828
  clean: false
@@ -9575,7 +9560,8 @@ function registerConfigCommand(program) {
9575
9560
  });
9576
9561
  }
9577
9562
  //#endregion
9578
- //#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"]`. */
9579
9565
  function commandPath(command) {
9580
9566
  const names = [];
9581
9567
  for (let current = command; current; current = current.parent) {
@@ -9584,6 +9570,8 @@ function commandPath(command) {
9584
9570
  }
9585
9571
  return names;
9586
9572
  }
9573
+ //#endregion
9574
+ //#region src/skills/sync-agents-guide.ts
9587
9575
  function shouldSkipAutoSync(command) {
9588
9576
  if (process.env.CI === "true" || process.env.CI === "1") return true;
9589
9577
  if (commandPath(command)[0] === "init") return true;
@@ -9614,6 +9602,7 @@ async function syncAgentsGuide(command) {
9614
9602
  }
9615
9603
  //#endregion
9616
9604
  //#region src/program.ts
9605
+ const commandStartTimes = /* @__PURE__ */ new WeakMap();
9617
9606
  function createProgram() {
9618
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) => {
9619
9608
  const opts = thisCommand.opts();
@@ -9622,7 +9611,17 @@ function createProgram() {
9622
9611
  organizationRef: opts.organization,
9623
9612
  local: opts.local
9624
9613
  });
9614
+ commandStartTimes.set(actionCommand, Date.now());
9625
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(() => {});
9626
9625
  });
9627
9626
  registerAuthCommand(program);
9628
9627
  registerConnectCommand(program);
@@ -9655,7 +9654,7 @@ function createProgram() {
9655
9654
  async function runCli(argv) {
9656
9655
  initCliTelemetry();
9657
9656
  try {
9658
- const { maybeAutoUpdate } = await import("./maybe-auto-update-DflBoY7a.mjs");
9657
+ const { maybeAutoUpdate } = await import("./maybe-auto-update-C-HUlgKp.mjs");
9659
9658
  await maybeAutoUpdate(argv);
9660
9659
  await createProgram().parseAsync(argv);
9661
9660
  } finally {