@keystrokehq/cli 0.1.96 → 0.1.99
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/{dist-BbKeSmsJ.mjs → dist-CBmwZ3uz.mjs} +4 -3
- package/dist/dist-CBmwZ3uz.mjs.map +1 -0
- package/dist/dist-CoyYRTnP.mjs +3 -0
- package/dist/{dist-CRQZ6dUM.mjs → dist-DBkNXfrt.mjs} +2 -2
- package/dist/{dist-CRQZ6dUM.mjs.map → dist-DBkNXfrt.mjs.map} +1 -1
- package/dist/{dist-BChg8kdu.mjs → dist-DNmfPa2T.mjs} +9 -7
- package/dist/dist-DNmfPa2T.mjs.map +1 -0
- package/dist/{dist-yxSyWJLs.mjs → dist-ZZlE2vk6.mjs} +3 -1
- package/dist/dist-ZZlE2vk6.mjs.map +1 -0
- package/dist/index.mjs +307 -16
- package/dist/index.mjs.map +1 -1
- package/dist/{js-exec-N5KEZBH7-CgtG-I6s.mjs → js-exec-N5KEZBH7-CoRL1IOd.mjs} +2 -2
- package/dist/{js-exec-N5KEZBH7-CgtG-I6s.mjs.map → js-exec-N5KEZBH7-CoRL1IOd.mjs.map} +1 -1
- package/dist/{maybe-auto-update-CRIaoRBQ.mjs → maybe-auto-update-DflBoY7a.mjs} +2 -2
- package/dist/{maybe-auto-update-CRIaoRBQ.mjs.map → maybe-auto-update-DflBoY7a.mjs.map} +1 -1
- package/dist/{run-package-manager-update-CEE3gsWX.mjs → run-package-manager-update-BVuBh1a2.mjs} +25 -25
- package/dist/{run-package-manager-update-CEE3gsWX.mjs.map → run-package-manager-update-BVuBh1a2.mjs.map} +1 -1
- package/dist/templates/hello-world/src/agents/hello.int.test.ts +7 -4
- package/dist/templates/hello-world/src/agents/hello.ts +1 -1
- package/package.json +2 -1
- package/dist/dist-BChg8kdu.mjs.map +0 -1
- package/dist/dist-BbKeSmsJ.mjs.map +0 -1
- package/dist/dist-CyFwRToz.mjs +0 -3
- package/dist/dist-yxSyWJLs.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
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-
|
|
3
|
-
import { i as packProjectArtifact, n as withMcpReadClient, r as mergeFilteredArtifact, t as mapInParallelBatches } from "./dist-
|
|
4
|
-
import { C as getWebUrl, E as resolvePlatformUrlForWebUrl, S as getPlatformUrl, _ as
|
|
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-DBkNXfrt.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";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { Command } from "commander";
|
|
7
|
+
import { platform, release } from "node:os";
|
|
7
8
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
8
9
|
import { Entry } from "@napi-rs/keyring";
|
|
9
10
|
import { existsSync, lstatSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
12
|
+
import { PostHog } from "posthog-node";
|
|
13
|
+
import { pathToFileURL } from "node:url";
|
|
10
14
|
import { access, lstat, mkdir, readFile, readdir, rm, stat, symlink, writeFile } from "node:fs/promises";
|
|
11
15
|
import { spawn, spawnSync } from "node:child_process";
|
|
12
|
-
import { pathToFileURL } from "node:url";
|
|
13
16
|
import { confirm, input } from "@inquirer/prompts";
|
|
14
17
|
//#region ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/errors/KyError.js
|
|
15
18
|
/**
|
|
@@ -3396,7 +3399,7 @@ async function toPlatformError(error) {
|
|
|
3396
3399
|
const status = error.response.status;
|
|
3397
3400
|
const body = error.data ?? null;
|
|
3398
3401
|
const parsed = ErrorResponseSchema.safeParse(body);
|
|
3399
|
-
return new PlatformError(parsed.success ? parsed.data.error : `Request failed with status ${status}`, status, body, parsed.success ? parsed.data.code : void 0);
|
|
3402
|
+
return new PlatformError(parsed.success ? parsed.data.message ?? parsed.data.error : `Request failed with status ${status}`, status, body, parsed.success ? parsed.data.code : void 0);
|
|
3400
3403
|
}
|
|
3401
3404
|
function createArtifactsResource(http) {
|
|
3402
3405
|
return {
|
|
@@ -4858,6 +4861,10 @@ function createPlatformClient(options) {
|
|
|
4858
4861
|
hooks: {
|
|
4859
4862
|
beforeRequest: [({ request }) => {
|
|
4860
4863
|
applyActiveOrganizationHeader(request, resolveActiveOrganizationId());
|
|
4864
|
+
const extra = options.getExtraHeaders?.();
|
|
4865
|
+
if (extra) {
|
|
4866
|
+
for (const [key, value] of Object.entries(extra)) if (value) request.headers.set(key, value);
|
|
4867
|
+
}
|
|
4861
4868
|
return applyAuthHeaders(request, auth);
|
|
4862
4869
|
}],
|
|
4863
4870
|
afterResponse: [async ({ request, response, retryCount }) => {
|
|
@@ -5180,6 +5187,253 @@ async function resolveApiTarget(config, options = {}) {
|
|
|
5180
5187
|
return resolvePlatformTarget(config, projectRef);
|
|
5181
5188
|
}
|
|
5182
5189
|
//#endregion
|
|
5190
|
+
//#region ../../packages/telemetry/dist/index.mjs
|
|
5191
|
+
const storage = new AsyncLocalStorage();
|
|
5192
|
+
function getTelemetryContext() {
|
|
5193
|
+
return storage.getStore();
|
|
5194
|
+
}
|
|
5195
|
+
/**
|
|
5196
|
+
* Returns true when an error is an expected client/control-flow failure that
|
|
5197
|
+
* should not become an Error Tracking issue.
|
|
5198
|
+
*/
|
|
5199
|
+
function isExpectedError(error) {
|
|
5200
|
+
if (!error || typeof error !== "object") return false;
|
|
5201
|
+
const status = readStatus(error);
|
|
5202
|
+
if (status !== void 0 && status >= 400 && status < 500) return true;
|
|
5203
|
+
if ("name" in error && typeof error.name === "string") {
|
|
5204
|
+
if (error.name === "AbortError" || error.name === "CanceledError" || error.name === "CancelledError" || error.name === "RunTimeoutError") return true;
|
|
5205
|
+
}
|
|
5206
|
+
return false;
|
|
5207
|
+
}
|
|
5208
|
+
function readStatus(error) {
|
|
5209
|
+
if ("status" in error && typeof error.status === "number") return error.status;
|
|
5210
|
+
if ("statusCode" in error && typeof error.statusCode === "number") return error.statusCode;
|
|
5211
|
+
}
|
|
5212
|
+
const EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*(:[a-z][a-z0-9_]*)?$/;
|
|
5213
|
+
let sink;
|
|
5214
|
+
function configureTelemetry(options) {
|
|
5215
|
+
sink = options.sink;
|
|
5216
|
+
}
|
|
5217
|
+
async function flushTelemetry() {
|
|
5218
|
+
await sink?.flush?.();
|
|
5219
|
+
}
|
|
5220
|
+
async function shutdownTelemetry() {
|
|
5221
|
+
const current = sink;
|
|
5222
|
+
sink = void 0;
|
|
5223
|
+
await current?.shutdown?.();
|
|
5224
|
+
}
|
|
5225
|
+
async function captureException(input) {
|
|
5226
|
+
if (isExpectedError(input.error) || !sink?.captureException) return;
|
|
5227
|
+
const context = getTelemetryContext();
|
|
5228
|
+
const actorId = input.actorId ?? context?.actorId;
|
|
5229
|
+
const analyticsId = input.analyticsId ?? context?.analyticsId;
|
|
5230
|
+
const organizationId = input.organizationId ?? context?.organizationId;
|
|
5231
|
+
const projectId = input.projectId ?? context?.projectId;
|
|
5232
|
+
const sessionId = input.sessionId ?? context?.sessionId;
|
|
5233
|
+
const enriched = {
|
|
5234
|
+
error: input.error,
|
|
5235
|
+
...actorId ? { actorId } : {},
|
|
5236
|
+
...analyticsId ? { analyticsId } : {},
|
|
5237
|
+
...organizationId ? { organizationId } : {},
|
|
5238
|
+
...projectId ? { projectId } : {},
|
|
5239
|
+
...sessionId ? { sessionId } : {},
|
|
5240
|
+
...input.operation ? { operation: input.operation } : {},
|
|
5241
|
+
...input.properties ? { properties: input.properties } : {}
|
|
5242
|
+
};
|
|
5243
|
+
try {
|
|
5244
|
+
await sink.captureException(enriched);
|
|
5245
|
+
} catch (error) {
|
|
5246
|
+
console.error("[telemetry] captureException sink failed", error);
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
async function event(input) {
|
|
5250
|
+
if (!EVENT_NAME_PATTERN.test(input.name)) {
|
|
5251
|
+
console.error(`[telemetry] rejected invalid event name: ${input.name}`);
|
|
5252
|
+
return;
|
|
5253
|
+
}
|
|
5254
|
+
const actorId = input.actorId.trim();
|
|
5255
|
+
if (!actorId) {
|
|
5256
|
+
console.error("[telemetry] rejected event without actorId");
|
|
5257
|
+
return;
|
|
5258
|
+
}
|
|
5259
|
+
if (!sink?.event) return;
|
|
5260
|
+
try {
|
|
5261
|
+
await sink.event({
|
|
5262
|
+
...input,
|
|
5263
|
+
actorId,
|
|
5264
|
+
timestamp: input.timestamp ?? /* @__PURE__ */ new Date(),
|
|
5265
|
+
uuid: input.uuid ?? globalThis.crypto.randomUUID()
|
|
5266
|
+
});
|
|
5267
|
+
} catch (error) {
|
|
5268
|
+
console.error("[telemetry] event sink failed", error);
|
|
5269
|
+
}
|
|
5270
|
+
}
|
|
5271
|
+
//#endregion
|
|
5272
|
+
//#region ../../packages/telemetry/dist/posthog-node.mjs
|
|
5273
|
+
const MAX_EVENT_BYTES = 9e5;
|
|
5274
|
+
function createPostHogSink(options) {
|
|
5275
|
+
const immediate = options.mode === "immediate";
|
|
5276
|
+
const client = new PostHog(options.token, {
|
|
5277
|
+
host: options.host,
|
|
5278
|
+
...immediate ? {
|
|
5279
|
+
flushAt: 1,
|
|
5280
|
+
flushInterval: 0
|
|
5281
|
+
} : {}
|
|
5282
|
+
});
|
|
5283
|
+
client.on("error", options.onError ?? (() => {}));
|
|
5284
|
+
return {
|
|
5285
|
+
async captureException(input) {
|
|
5286
|
+
const error = input.error instanceof Error ? input.error : new Error(String(input.error));
|
|
5287
|
+
const distinctId = input.actorId?.trim() || input.analyticsId?.trim() || `${options.serviceName ?? "keystroke"}:anonymous`;
|
|
5288
|
+
const properties = {
|
|
5289
|
+
...sanitizeProperties(input.properties),
|
|
5290
|
+
...commonProperties(options, input),
|
|
5291
|
+
...input.sessionId ? { $session_id: input.sessionId } : {},
|
|
5292
|
+
...input.actorId ? {} : { $process_person_profile: false }
|
|
5293
|
+
};
|
|
5294
|
+
client.captureException(error, distinctId, properties);
|
|
5295
|
+
if (immediate) await client.flush();
|
|
5296
|
+
},
|
|
5297
|
+
async event(input) {
|
|
5298
|
+
const properties = {
|
|
5299
|
+
...sanitizeProperties(input.properties),
|
|
5300
|
+
...commonProperties(options, input),
|
|
5301
|
+
...input.anonymous ? { $process_person_profile: false } : {}
|
|
5302
|
+
};
|
|
5303
|
+
const body = {
|
|
5304
|
+
distinctId: input.actorId,
|
|
5305
|
+
event: input.name,
|
|
5306
|
+
properties,
|
|
5307
|
+
groups: input.organizationId ? { organization: input.organizationId } : void 0,
|
|
5308
|
+
timestamp: input.timestamp,
|
|
5309
|
+
uuid: input.uuid
|
|
5310
|
+
};
|
|
5311
|
+
const encoded = Buffer.byteLength(JSON.stringify(body), "utf8");
|
|
5312
|
+
if (encoded > MAX_EVENT_BYTES) {
|
|
5313
|
+
options.onError?.(/* @__PURE__ */ new Error(`Dropped oversized event ${input.name} (${encoded} bytes)`));
|
|
5314
|
+
return;
|
|
5315
|
+
}
|
|
5316
|
+
client.capture(body);
|
|
5317
|
+
if (immediate) await client.flush();
|
|
5318
|
+
},
|
|
5319
|
+
async flush() {
|
|
5320
|
+
await client.flush();
|
|
5321
|
+
},
|
|
5322
|
+
async shutdown() {
|
|
5323
|
+
await client.shutdown();
|
|
5324
|
+
}
|
|
5325
|
+
};
|
|
5326
|
+
}
|
|
5327
|
+
function commonProperties(options, input) {
|
|
5328
|
+
return sanitizeProperties({
|
|
5329
|
+
organization_id: input.organizationId,
|
|
5330
|
+
project_id: input.projectId,
|
|
5331
|
+
operation: input.operation,
|
|
5332
|
+
service: options.serviceName,
|
|
5333
|
+
release: options.release,
|
|
5334
|
+
environment: options.environment
|
|
5335
|
+
});
|
|
5336
|
+
}
|
|
5337
|
+
function sanitizeProperties(properties) {
|
|
5338
|
+
if (!properties) return {};
|
|
5339
|
+
return Object.fromEntries(Object.entries(properties).filter((entry) => entry[1] !== void 0));
|
|
5340
|
+
}
|
|
5341
|
+
//#endregion
|
|
5342
|
+
//#region src/telemetry/identity.ts
|
|
5343
|
+
function getCliTelemetryActorId() {
|
|
5344
|
+
return getOrCreateAnonymousDistinctId();
|
|
5345
|
+
}
|
|
5346
|
+
function getOrCreateAnonymousDistinctId(configDir = getCliConfigDir()) {
|
|
5347
|
+
const path = join(configDir, "telemetry-distinct-id");
|
|
5348
|
+
try {
|
|
5349
|
+
const existing = readFileSync(path, "utf8").trim();
|
|
5350
|
+
if (existing) return existing;
|
|
5351
|
+
} catch {}
|
|
5352
|
+
const id = globalThis.crypto.randomUUID();
|
|
5353
|
+
try {
|
|
5354
|
+
mkdirSync(configDir, { recursive: true });
|
|
5355
|
+
writeFileSync(path, `${id}\n`, {
|
|
5356
|
+
encoding: "utf8",
|
|
5357
|
+
mode: 384
|
|
5358
|
+
});
|
|
5359
|
+
} catch {}
|
|
5360
|
+
return id;
|
|
5361
|
+
}
|
|
5362
|
+
//#endregion
|
|
5363
|
+
//#region src/telemetry/init.ts
|
|
5364
|
+
let enabled = false;
|
|
5365
|
+
/** Opt out of CLI analytics/error reporting (no OTEL is shipped for the CLI). */
|
|
5366
|
+
function isCliTelemetryDisabled(env = process.env) {
|
|
5367
|
+
const flag = env.KEYSTROKE_DISABLE_TELEMETRY?.trim().toLowerCase();
|
|
5368
|
+
if (flag === "1" || flag === "true" || flag === "yes") return true;
|
|
5369
|
+
if (env.KEYSTROKE_DEV) return true;
|
|
5370
|
+
if (env.CI === "true" || env.CI === "1") return true;
|
|
5371
|
+
return false;
|
|
5372
|
+
}
|
|
5373
|
+
function readPostHogToken(env = process.env) {
|
|
5374
|
+
return env.KEYSTROKE_POSTHOG_TOKEN?.trim() || env.PUBLIC_POSTHOG_TOKEN?.trim() || "phc_CVZPXvV78726vW2hLKSrFBjzgcKS4oBQU2Nq8z2kxGxm";
|
|
5375
|
+
}
|
|
5376
|
+
function readPostHogHost(env = process.env) {
|
|
5377
|
+
return env.KEYSTROKE_POSTHOG_HOST?.trim() || env.PUBLIC_POSTHOG_HOST?.trim() || "https://t.keystroke.ai";
|
|
5378
|
+
}
|
|
5379
|
+
function baseProperties(extra) {
|
|
5380
|
+
return {
|
|
5381
|
+
cli_version: readCliVersion(),
|
|
5382
|
+
os: platform(),
|
|
5383
|
+
os_release: release(),
|
|
5384
|
+
...extra
|
|
5385
|
+
};
|
|
5386
|
+
}
|
|
5387
|
+
function initCliTelemetry(env = process.env) {
|
|
5388
|
+
if (enabled) return true;
|
|
5389
|
+
if (isCliTelemetryDisabled(env)) return false;
|
|
5390
|
+
const token = readPostHogToken(env);
|
|
5391
|
+
if (!token) return false;
|
|
5392
|
+
configureTelemetry({ sink: createPostHogSink({
|
|
5393
|
+
token,
|
|
5394
|
+
host: readPostHogHost(env),
|
|
5395
|
+
mode: "immediate",
|
|
5396
|
+
serviceName: "keystroke-cli",
|
|
5397
|
+
release: readCliVersion(),
|
|
5398
|
+
environment: env.KEYSTROKE_ENVIRONMENT?.trim() || void 0
|
|
5399
|
+
}) });
|
|
5400
|
+
enabled = true;
|
|
5401
|
+
return true;
|
|
5402
|
+
}
|
|
5403
|
+
async function shutdownCliTelemetry() {
|
|
5404
|
+
if (!enabled) return;
|
|
5405
|
+
try {
|
|
5406
|
+
await flushTelemetry();
|
|
5407
|
+
await shutdownTelemetry();
|
|
5408
|
+
} catch {}
|
|
5409
|
+
enabled = false;
|
|
5410
|
+
}
|
|
5411
|
+
async function reportCliException(error, context) {
|
|
5412
|
+
if (!enabled) return;
|
|
5413
|
+
await captureException({
|
|
5414
|
+
error,
|
|
5415
|
+
analyticsId: getCliTelemetryActorId(),
|
|
5416
|
+
organizationId: context.organizationId,
|
|
5417
|
+
projectId: context.projectId,
|
|
5418
|
+
operation: context.operation ?? context.command ?? "cli.command",
|
|
5419
|
+
properties: baseProperties({ ...context.command ? { command: context.command } : {} })
|
|
5420
|
+
});
|
|
5421
|
+
}
|
|
5422
|
+
async function trackCliEvent(name, input) {
|
|
5423
|
+
if (!enabled) return;
|
|
5424
|
+
await event({
|
|
5425
|
+
name,
|
|
5426
|
+
actorId: getCliTelemetryActorId(),
|
|
5427
|
+
anonymous: true,
|
|
5428
|
+
organizationId: input?.organizationId,
|
|
5429
|
+
projectId: input?.projectId,
|
|
5430
|
+
properties: baseProperties({
|
|
5431
|
+
...input?.userId ? { user_id: input.userId } : {},
|
|
5432
|
+
...input?.properties
|
|
5433
|
+
})
|
|
5434
|
+
});
|
|
5435
|
+
}
|
|
5436
|
+
//#endregion
|
|
5183
5437
|
//#region src/errors/example-input.ts
|
|
5184
5438
|
function exampleValueFromValidationMessage(message) {
|
|
5185
5439
|
if (/expected number/i.test(message)) return 0;
|
|
@@ -5282,6 +5536,10 @@ async function runStandaloneCliCommand(fallback, fn, errorContext) {
|
|
|
5282
5536
|
try {
|
|
5283
5537
|
await fn({ config });
|
|
5284
5538
|
} catch (error) {
|
|
5539
|
+
await reportCliException(error, {
|
|
5540
|
+
command: fallback,
|
|
5541
|
+
operation: "cli.command"
|
|
5542
|
+
});
|
|
5285
5543
|
process.stderr.write(`${formatCliError(error, fallback, {
|
|
5286
5544
|
...errorContext,
|
|
5287
5545
|
webUrl: getWebUrl(config)
|
|
@@ -5317,6 +5575,12 @@ async function runCliCommand(fallback, fn, errorContext, targetOptions = {}) {
|
|
|
5317
5575
|
try {
|
|
5318
5576
|
await fn(ctx);
|
|
5319
5577
|
} catch (error) {
|
|
5578
|
+
await reportCliException(error, {
|
|
5579
|
+
command: fallback,
|
|
5580
|
+
operation: "cli.command",
|
|
5581
|
+
organizationId,
|
|
5582
|
+
projectId: target.projectId
|
|
5583
|
+
});
|
|
5320
5584
|
process.stderr.write(`${formatCliError(error, fallback, {
|
|
5321
5585
|
...errorContext,
|
|
5322
5586
|
serverUrl: ctx.serverUrl,
|
|
@@ -6682,9 +6946,18 @@ function registerAuthLoginCommand(auth) {
|
|
|
6682
6946
|
});
|
|
6683
6947
|
setAccessToken(platformUrl, result.accessToken);
|
|
6684
6948
|
const user = await getSessionWithBearer(platformUrl, result.accessToken);
|
|
6685
|
-
if (user)
|
|
6686
|
-
|
|
6949
|
+
if (user) {
|
|
6950
|
+
await trackCliEvent("cli:auth_login", { userId: user.id });
|
|
6951
|
+
process.stdout.write(`Logged in as ${user.name} (${user.email})\n`);
|
|
6952
|
+
} else {
|
|
6953
|
+
await trackCliEvent("cli:auth_login");
|
|
6954
|
+
process.stdout.write(`Logged in to ${webUrl}\n`);
|
|
6955
|
+
}
|
|
6687
6956
|
} catch (error) {
|
|
6957
|
+
await reportCliException(error, {
|
|
6958
|
+
command: "auth login",
|
|
6959
|
+
operation: "cli.auth_login"
|
|
6960
|
+
});
|
|
6688
6961
|
process.stderr.write(`${formatCliError(error, "Login failed", {
|
|
6689
6962
|
webUrl,
|
|
6690
6963
|
platformUrl
|
|
@@ -6853,7 +7126,7 @@ function registerBuildCommand(program) {
|
|
|
6853
7126
|
try {
|
|
6854
7127
|
const root = resolveProjectRoot(options.dir);
|
|
6855
7128
|
await ensureSdkCurrent(root);
|
|
6856
|
-
const { buildApp } = await import("./dist-
|
|
7129
|
+
const { buildApp } = await import("./dist-CBmwZ3uz.mjs");
|
|
6857
7130
|
await buildApp({ root });
|
|
6858
7131
|
process.stdout.write(`Built ${root}\n`);
|
|
6859
7132
|
} catch (error) {
|
|
@@ -6978,7 +7251,7 @@ async function sleep(ms) {
|
|
|
6978
7251
|
}
|
|
6979
7252
|
async function buildDeployArchive(client, root, projectId, filter) {
|
|
6980
7253
|
if (filter?.length) {
|
|
6981
|
-
const { buildFilteredApp } = await import("./dist-
|
|
7254
|
+
const { buildFilteredApp } = await import("./dist-CBmwZ3uz.mjs");
|
|
6982
7255
|
const filtered = await buildFilteredApp({
|
|
6983
7256
|
root,
|
|
6984
7257
|
filter,
|
|
@@ -7000,7 +7273,7 @@ async function buildDeployArchive(client, root, projectId, filter) {
|
|
|
7000
7273
|
sourceFiles: filtered.sourceFiles
|
|
7001
7274
|
};
|
|
7002
7275
|
}
|
|
7003
|
-
const { buildApp } = await import("./dist-
|
|
7276
|
+
const { buildApp } = await import("./dist-CBmwZ3uz.mjs");
|
|
7004
7277
|
const { sourceFiles } = await buildApp({
|
|
7005
7278
|
root,
|
|
7006
7279
|
collectSources: true,
|
|
@@ -7063,7 +7336,12 @@ function registerDeployCommand(program) {
|
|
|
7063
7336
|
projectId,
|
|
7064
7337
|
filter: options.filter.length > 0 ? options.filter : void 0
|
|
7065
7338
|
});
|
|
7339
|
+
await trackCliEvent("cli:deploy", { projectId });
|
|
7066
7340
|
} catch (error) {
|
|
7341
|
+
await reportCliException(error, {
|
|
7342
|
+
command: "deploy",
|
|
7343
|
+
operation: "cli.deploy"
|
|
7344
|
+
});
|
|
7067
7345
|
const message = formatCliError(error, "unknown error", { webUrl: config ? getWebUrl(config) : void 0 });
|
|
7068
7346
|
process.stderr.write(`Deploy failed: ${message}\n`);
|
|
7069
7347
|
process.exitCode = 1;
|
|
@@ -7122,7 +7400,7 @@ function runtimeChildEnv(parentEnv, overrides) {
|
|
|
7122
7400
|
//#region src/project/bootstrap-run.ts
|
|
7123
7401
|
/** Node args + env for `@keystrokehq/build` bootstrap (shared by start + dev). */
|
|
7124
7402
|
async function resolveBootstrapRun(options) {
|
|
7125
|
-
const { resolveRuntimeBuildArtifact } = await import("./dist-
|
|
7403
|
+
const { resolveRuntimeBuildArtifact } = await import("./dist-CBmwZ3uz.mjs");
|
|
7126
7404
|
const loader = pathToFileURL(resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/runtime-loader.mjs")).href;
|
|
7127
7405
|
const bootstrap = resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/standalone-bootstrap.mjs");
|
|
7128
7406
|
const args = [`--import=${loader}`];
|
|
@@ -7271,7 +7549,7 @@ async function runDev(options) {
|
|
|
7271
7549
|
process.on("SIGINT", shutdown);
|
|
7272
7550
|
process.on("SIGTERM", shutdown);
|
|
7273
7551
|
try {
|
|
7274
|
-
const { watchApp } = await import("./dist-
|
|
7552
|
+
const { watchApp } = await import("./dist-CBmwZ3uz.mjs");
|
|
7275
7553
|
await watchApp({
|
|
7276
7554
|
root,
|
|
7277
7555
|
clean: false,
|
|
@@ -7758,6 +8036,10 @@ function registerInitCommand(program) {
|
|
|
7758
8036
|
project,
|
|
7759
8037
|
organization: options.organization
|
|
7760
8038
|
});
|
|
8039
|
+
await trackCliEvent("cli:init", { properties: {
|
|
8040
|
+
template: options.template,
|
|
8041
|
+
skip_install: Boolean(options.skipInstall)
|
|
8042
|
+
} });
|
|
7761
8043
|
process.stdout.write(`Created keystroke project "${result.projectName}" at ${result.targetDir}\n`);
|
|
7762
8044
|
process.stdout.write("\nNext steps:\n");
|
|
7763
8045
|
process.stdout.write(` cd ${result.targetDir}\n`);
|
|
@@ -7765,6 +8047,10 @@ function registerInitCommand(program) {
|
|
|
7765
8047
|
if (!project) process.stdout.write(" keystroke projects link --project <slug> # link this directory to a platform project\n");
|
|
7766
8048
|
process.stdout.write(" keystroke deploy # lint + typecheck + build + ship dist/\n");
|
|
7767
8049
|
} catch (error) {
|
|
8050
|
+
await reportCliException(error, {
|
|
8051
|
+
command: "init",
|
|
8052
|
+
operation: "cli.init"
|
|
8053
|
+
});
|
|
7768
8054
|
const message = error instanceof Error ? error.message : "Init failed";
|
|
7769
8055
|
process.stderr.write(`${message}\n`);
|
|
7770
8056
|
process.exitCode = 1;
|
|
@@ -8313,7 +8599,7 @@ async function runStart(options) {
|
|
|
8313
8599
|
const apiPort = Number(new URL(serverUrl).port || 80);
|
|
8314
8600
|
const runtimeNodeModules = resolveCliRuntimeNodeModules(resolveCliRoot(import.meta.url));
|
|
8315
8601
|
ensureNativeDeps(runtimeNodeModules);
|
|
8316
|
-
const { buildApp } = await import("./dist-
|
|
8602
|
+
const { buildApp } = await import("./dist-CBmwZ3uz.mjs");
|
|
8317
8603
|
await buildApp({
|
|
8318
8604
|
root,
|
|
8319
8605
|
clean: false
|
|
@@ -9124,9 +9410,14 @@ function createProgram() {
|
|
|
9124
9410
|
return program;
|
|
9125
9411
|
}
|
|
9126
9412
|
async function runCli(argv) {
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9413
|
+
initCliTelemetry();
|
|
9414
|
+
try {
|
|
9415
|
+
const { maybeAutoUpdate } = await import("./maybe-auto-update-DflBoY7a.mjs");
|
|
9416
|
+
await maybeAutoUpdate(argv);
|
|
9417
|
+
await createProgram().parseAsync(argv);
|
|
9418
|
+
} finally {
|
|
9419
|
+
await shutdownCliTelemetry();
|
|
9420
|
+
}
|
|
9130
9421
|
}
|
|
9131
9422
|
//#endregion
|
|
9132
9423
|
//#region src/index.ts
|