@keystrokehq/cli 0.0.1

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.
Files changed (122) hide show
  1. package/AGENTS-blurb.md +123 -0
  2. package/LICENSE +42 -0
  3. package/README.md +177 -0
  4. package/THIRD_PARTY_NOTICES.md +16 -0
  5. package/bin/keystroke.mjs +107 -0
  6. package/dist/_manifest-JSRE3H8k.mjs +385 -0
  7. package/dist/agent-bundle-package-DWV6B_5q-BtV7Xycc.mjs +2344 -0
  8. package/dist/agent-manifest-CDnbkR2f.mjs +245 -0
  9. package/dist/agents-CZJGxVqV.mjs +228 -0
  10. package/dist/api-keys-D2lgguuY.mjs +40 -0
  11. package/dist/auth-DN2VusyU.mjs +59 -0
  12. package/dist/auth.handler-CT1BQUvu.mjs +340 -0
  13. package/dist/browser-qwFrUH82.mjs +24 -0
  14. package/dist/build-agents-BmM_AsSd-BGi9wtzt.mjs +514 -0
  15. package/dist/build-metadata-BWS7uhd_-DR8gJjTX.mjs +1422 -0
  16. package/dist/build-progress-DgYKb4hB.mjs +183 -0
  17. package/dist/build-tasks-CdihpudT-D5r5HUHe.mjs +91 -0
  18. package/dist/build-workflows-CfxBnIWh-CdYPv8w2.mjs +370 -0
  19. package/dist/build.handler-4799CjWH.mjs +36 -0
  20. package/dist/chunk-CH6r78ws.mjs +37 -0
  21. package/dist/clear-cache.handler-B9tqSoSM.mjs +11 -0
  22. package/dist/clear.handler-BTIXXPTJ.mjs +42 -0
  23. package/dist/clear.handler-BydlX-zE.mjs +11 -0
  24. package/dist/commander-DfTVqQ-3.mjs +133 -0
  25. package/dist/concurrency-gXn9Rw8x-DNl2YtrS.mjs +20 -0
  26. package/dist/connect-BUXkeH0F.mjs +43 -0
  27. package/dist/connect.handler-CYel9cy6.mjs +430 -0
  28. package/dist/constants-CPpPdSNg.mjs +8 -0
  29. package/dist/context-T7HZuB97.mjs +138 -0
  30. package/dist/credential-env-map-CI8yWHVy.mjs +28 -0
  31. package/dist/credential-schema-mismatch-BKo5PjcQ.mjs +76 -0
  32. package/dist/credentials-CvmjU0lK.mjs +171 -0
  33. package/dist/credentials-OfVHOtG3.mjs +151216 -0
  34. package/dist/current-deployment-workflow-poHt27i3.mjs +94 -0
  35. package/dist/current.handler-B8zKzfPp.mjs +21 -0
  36. package/dist/delete.handler-bAu1iXVQ.mjs +17 -0
  37. package/dist/deploy-7Jjls436.mjs +26 -0
  38. package/dist/deploy-BOPIpRWm.mjs +74 -0
  39. package/dist/deploy-progress-BmGUNFKg.mjs +70 -0
  40. package/dist/deploy.handler-BAzgiNhd.mjs +370 -0
  41. package/dist/detect-env-access-CwkOYeYM-D_BCZqV6.mjs +209 -0
  42. package/dist/diff-utils-NEfcjqxt.mjs +185 -0
  43. package/dist/diff.handler-Du7SY8K4.mjs +47 -0
  44. package/dist/dist-BkJUoBiG.mjs +1116 -0
  45. package/dist/dist-CUK7yBM0.mjs +308 -0
  46. package/dist/env-91KwMKov.mjs +140 -0
  47. package/dist/env.handler-BAzBuMzQ.mjs +277 -0
  48. package/dist/error-boundary-VL-JLfIa.mjs +34 -0
  49. package/dist/file-metadata-D1vm-XY2.mjs +191 -0
  50. package/dist/get-intrinsic-zLxwtrLK.mjs +658 -0
  51. package/dist/import-module-CV84H5fZ-B_CBCmb4.mjs +1747 -0
  52. package/dist/init-DpMCotSK.mjs +45 -0
  53. package/dist/init.handler-CPRnif52.mjs +585 -0
  54. package/dist/inspect.handler-DT_cD036.mjs +146 -0
  55. package/dist/integration-catalog-Bt-L3GjF.mjs +104 -0
  56. package/dist/integrations-DlatPK4W.mjs +79 -0
  57. package/dist/keystroke.d.mts +3 -0
  58. package/dist/keystroke.mjs +707 -0
  59. package/dist/layout-CbMtQ2tm.mjs +67 -0
  60. package/dist/list-enrichment-y-cwizLr.mjs +189 -0
  61. package/dist/list.handler-BTWvCyjA.mjs +52 -0
  62. package/dist/list.handler-CWF_Dj15.mjs +24 -0
  63. package/dist/list.handler-CZ6G2x_G.mjs +75 -0
  64. package/dist/list.handler-DWaQkJaR.mjs +51 -0
  65. package/dist/list.handler-DqbFcBW7.mjs +180 -0
  66. package/dist/list.handler-lq3ZGAn4.mjs +104 -0
  67. package/dist/logs-BEg9L5l8.mjs +28 -0
  68. package/dist/logs.handler-6hoMBzqw.mjs +35 -0
  69. package/dist/logs.handler-BD_dXiL1.mjs +231 -0
  70. package/dist/metadata-layout-GUYIUo0i-_aG2zjue.mjs +5877 -0
  71. package/dist/normalize-path-CojS-CgQ-DLCOvnD1.mjs +20 -0
  72. package/dist/options-CeaTcFxP.mjs +43 -0
  73. package/dist/org-xLzBtt2_.mjs +41 -0
  74. package/dist/output-DM4b7KgY.mjs +72 -0
  75. package/dist/oxc-B3KI3rf_-n9d1hKNq.mjs +119 -0
  76. package/dist/paused.handler-BMFm9Cff.mjs +94 -0
  77. package/dist/project-config-D1qsQlO7.mjs +107 -0
  78. package/dist/projects-CHkRE9rS.mjs +1574 -0
  79. package/dist/projects-Cjb7sovS.mjs +30 -0
  80. package/dist/read-credential-keys-77a91T8M-KA0Iw0Z1.mjs +9 -0
  81. package/dist/register.handler-BPCdor1_.mjs +86 -0
  82. package/dist/requirements.handler-DPXdSks3.mjs +201 -0
  83. package/dist/resolve-project-DDJ29sCF.mjs +35 -0
  84. package/dist/rolldown-runtime-twds-ZHy-BWWzu8VG.mjs +15 -0
  85. package/dist/run-polling-CAgFRdK3.mjs +20 -0
  86. package/dist/runs-D9hNLb9A.mjs +259 -0
  87. package/dist/schedule-BXx3uXwr.mjs +1142 -0
  88. package/dist/schema-17qMfNyI.mjs +18 -0
  89. package/dist/schema-display-CgmeKigW.mjs +130 -0
  90. package/dist/schemas-CDib1RhE.mjs +125 -0
  91. package/dist/skills-sync.handler-DIy8GR16.mjs +34 -0
  92. package/dist/skills.command-CrjI2dN9.mjs +35 -0
  93. package/dist/skills.handler-Bz8bJKql.mjs +9 -0
  94. package/dist/source-analysis-Cj-ADyu--BJQcFPCG.mjs +144 -0
  95. package/dist/spinner-progress-DMVwgqO9.mjs +173 -0
  96. package/dist/src-C0X6u_Mw.mjs +1340 -0
  97. package/dist/src-eHwu-Gfw.mjs +369 -0
  98. package/dist/status.handler-BO4nwvWn.mjs +101 -0
  99. package/dist/switch.handler-D_9213Vf.mjs +51 -0
  100. package/dist/sync-BL_Mo5st.mjs +39 -0
  101. package/dist/sync-keystroke-agent-skills-Kx_H7UTd.mjs +70 -0
  102. package/dist/sync.handler-BUFPdzWz.mjs +82 -0
  103. package/dist/task-B2sZMaZu.mjs +8 -0
  104. package/dist/task-target-build-CBeCKbu2.mjs +432 -0
  105. package/dist/task-target-deploy-C5X-USeR.mjs +4 -0
  106. package/dist/task-target-deploy-CA6elFpF-BEr4gkol.mjs +271 -0
  107. package/dist/task-target-deploy-runner.d.mts +3 -0
  108. package/dist/task-target-deploy-runner.mjs +202 -0
  109. package/dist/test-BHTgR3UA.mjs +698 -0
  110. package/dist/test.handler-BcPQ8b74.mjs +13 -0
  111. package/dist/trigger-artifacts-DQPbQNqC-B4yeeFBY.mjs +239 -0
  112. package/dist/trigger-manifest-CY7brZeg.mjs +30 -0
  113. package/dist/try-deploy.handler-DqybNhXx.mjs +490 -0
  114. package/dist/upload-CkU--iDC.mjs +207 -0
  115. package/dist/upload.handler-DCtiznQp.mjs +441 -0
  116. package/dist/utils-CywxCDM7.mjs +14 -0
  117. package/dist/validate.handler-DOcTaJL0.mjs +280 -0
  118. package/dist/workflow-build-DBQaBfnn.mjs +1819 -0
  119. package/dist/workflow-bundler-BPiqVscj-X1PFFAuP.mjs +167 -0
  120. package/dist/workflows-g9z87AJJ.mjs +799 -0
  121. package/dist/writer-BG8poUm3-BbXlU2kI.mjs +426 -0
  122. package/package.json +87 -0
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { t as ui } from "./keystroke.mjs";
4
+ import { a as validateApiKey, i as requireClient } from "./context-T7HZuB97.mjs";
5
+ //#region src/commands/auth/test.handler.ts
6
+ async function handleAuthTest(_options, ctx) {
7
+ const result = await validateApiKey(requireClient(ctx));
8
+ ui.success("API key is valid.");
9
+ ui.hint(` Organization: ${result.organizationId}`);
10
+ ui.hint(` Key ID: ${result.apiKeyId}`);
11
+ }
12
+ //#endregion
13
+ export { handleAuthTest };
@@ -0,0 +1,239 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { n as readOptionalJsonSchemaKeys } from "./_manifest-JSRE3H8k.mjs";
4
+ import { t as __exportAll } from "./rolldown-runtime-twds-ZHy-BWWzu8VG.mjs";
5
+ import { t as readCredentialKeysFromSchemaObject } from "./read-credential-keys-77a91T8M-KA0Iw0Z1.mjs";
6
+ import { r as formatEnvAccessError, t as createEnvAccessPlugin } from "./detect-env-access-CwkOYeYM-D_BCZqV6.mjs";
7
+ import { createHash } from "node:crypto";
8
+ import { rolldown } from "rolldown";
9
+ //#region ../../packages/workflow-builder/dist/trigger-artifacts-DQPbQNqC.mjs
10
+ async function bundleTriggerCallbacks(options) {
11
+ return bundleCallbacks(options.filePath, options.projectRoot, options.exportNames, options.triggerExportName, options.workflowExtraction);
12
+ }
13
+ async function bundleAttachmentCallbacks(options) {
14
+ return bundleCallbacks(options.filePath, options.projectRoot, options.exportNames, void 0, options.workflowExtraction);
15
+ }
16
+ async function bundleCallbacks(filePath, projectRoot, exportNames, triggerExportName, workflowExtraction) {
17
+ const entryId = "\0virtual:trigger-callback-entry";
18
+ const accessorExpr = (base, name) => `${base}.${name} ?? ${base}.trigger?.${name} ?? ${base}.source?.${name} ?? ${base}.trigger?.source?.${name}`;
19
+ let reExports;
20
+ if (workflowExtraction) {
21
+ const { workflowExportName, workflowFilePath, triggerIndex } = workflowExtraction;
22
+ const base = `__wf.triggers[${triggerIndex}]`;
23
+ reExports = [`import { ${workflowExportName} as __wf } from ${JSON.stringify(workflowFilePath)};`, ...exportNames.map((name) => `export const ${name} = ${accessorExpr(base, name)};`)].join("\n");
24
+ } else if (triggerExportName) reExports = [`import { ${triggerExportName} as __trigger } from ${JSON.stringify(filePath)};`, ...exportNames.map((name) => `export const ${name} = ${accessorExpr("__trigger", name)};`)].join("\n");
25
+ else reExports = exportNames.map((name) => `export { ${name} } from ${JSON.stringify(filePath)};`).join("\n");
26
+ const envViolations = [];
27
+ const bundle = await rolldown({
28
+ input: entryId,
29
+ platform: "node",
30
+ external: [
31
+ /^node:/,
32
+ "@swc/core",
33
+ /^@swc\/core-/,
34
+ /^@swc\/wasm/
35
+ ],
36
+ plugins: [createEnvAccessPlugin(envViolations, projectRoot), {
37
+ name: "trigger-callback-entry",
38
+ resolveId(source) {
39
+ if (source === entryId) return entryId;
40
+ return null;
41
+ },
42
+ load(id) {
43
+ if (id === entryId) return reExports;
44
+ return null;
45
+ }
46
+ }]
47
+ });
48
+ try {
49
+ const { output } = await bundle.generate({
50
+ codeSplitting: false,
51
+ format: "esm",
52
+ sourcemap: false
53
+ });
54
+ if (envViolations.length > 0) throw new Error(formatEnvAccessError(envViolations));
55
+ const chunks = output.filter((candidate) => candidate.type === "chunk");
56
+ if (chunks.length !== 1) throw new Error(`Trigger callback bundle must produce exactly one chunk for ${filePath}`);
57
+ const [chunk] = chunks;
58
+ if (!chunk) throw new Error(`Expected rolldown to generate a chunk for trigger callbacks in ${filePath}`);
59
+ return {
60
+ code: chunk.code,
61
+ size: Buffer.byteLength(chunk.code),
62
+ hash: createHash("sha256").update(chunk.code).digest("hex")
63
+ };
64
+ } finally {
65
+ await bundle.close();
66
+ }
67
+ }
68
+ var trigger_artifacts_exports = /* @__PURE__ */ __exportAll({
69
+ buildTriggerArtifacts: () => buildTriggerArtifacts,
70
+ generateTriggerId: () => generateTriggerId
71
+ });
72
+ function generateTriggerId(workflowId, triggerName) {
73
+ return createHash("sha256").update(`${workflowId}::${triggerName}`).digest("hex").slice(0, 16);
74
+ }
75
+ async function buildTriggerArtifacts(loadedTriggers, workflowId, workflowName, projectRoot, workflowContext) {
76
+ const artifacts = [];
77
+ const triggerFailures = [];
78
+ for (const loaded of loadedTriggers) {
79
+ const triggerManifest = loaded.triggerManifest;
80
+ const triggerName = triggerManifest.name;
81
+ const triggerType = triggerManifest.triggerType;
82
+ const runtime = triggerManifest.runtime;
83
+ const callbacks = runtime.callbacks;
84
+ const triggerId = generateTriggerId(workflowId, triggerName);
85
+ const webhookSource = "source" in runtime && runtime.source && typeof runtime.source === "object" ? runtime.source : null;
86
+ const projectedConfig = webhookSource ? webhookSource.type === "app" ? { source: {
87
+ type: "app",
88
+ appRef: webhookSource.appRef
89
+ } } : { source: {
90
+ type: "custom",
91
+ method: webhookSource.method,
92
+ path: webhookSource.path,
93
+ ...webhookSource.response ? { response: webhookSource.response } : {}
94
+ } } : void 0;
95
+ const artifact = {
96
+ triggerId,
97
+ triggerType,
98
+ triggerName,
99
+ workflowId,
100
+ workflowName,
101
+ sourceFilePath: loaded.sourceFilePath,
102
+ hasTransform: loaded.hasTransform,
103
+ hasFilter: loaded.hasFilter,
104
+ enabled: triggerManifest.enabled,
105
+ ..."schedule" in runtime && typeof runtime.schedule === "string" ? { schedule: runtime.schedule } : {},
106
+ ..."timezone" in runtime && typeof runtime.timezone === "string" ? { timezone: runtime.timezone } : {},
107
+ ...webhookSource ? { triggerSource: webhookSource.type } : {},
108
+ ...webhookSource?.type === "custom" && webhookSource.path ? { path: webhookSource.path } : {},
109
+ ...webhookSource?.type === "custom" && webhookSource.method ? { method: webhookSource.method } : {},
110
+ ...projectedConfig ? { config: projectedConfig } : {},
111
+ ...triggerManifest.modeDefault ? { modeDefault: triggerManifest.modeDefault } : {},
112
+ ...triggerManifest.credentialSets ? { requiredCredentials: buildTriggerCredentialRequirements(triggerManifest.credentialSets, callbacks) } : {},
113
+ ...loaded.staticPayload !== void 0 ? { staticPayload: loaded.staticPayload } : {},
114
+ trigger: loaded.triggerManifest
115
+ };
116
+ if (callbacks) {
117
+ const callbackEntries = [];
118
+ if (callbacks.verify) callbackEntries.push({
119
+ exportName: "verify",
120
+ manifestKey: "verify"
121
+ });
122
+ if (callbacks.filter) callbackEntries.push({
123
+ exportName: "filter",
124
+ manifestKey: "filter"
125
+ });
126
+ if (callbacks.idempotencyKey) callbackEntries.push({
127
+ exportName: "idempotencyKey",
128
+ manifestKey: "idempotencyKey"
129
+ });
130
+ if (callbacks.poll) callbackEntries.push({
131
+ exportName: "poll",
132
+ manifestKey: "callback"
133
+ });
134
+ if (callbackEntries.length > 0) try {
135
+ artifact.callbackBundle = await bundleTriggerCallbacks({
136
+ filePath: loaded.sourceFilePath,
137
+ projectRoot,
138
+ exportNames: callbackEntries.map((entry) => entry.exportName),
139
+ triggerExportName: loaded.triggerExportName,
140
+ ...workflowContext ? { workflowExtraction: {
141
+ workflowExportName: workflowContext.workflowExportName,
142
+ workflowFilePath: workflowContext.workflowFilePath,
143
+ triggerIndex: loaded.triggerIndex
144
+ } } : {}
145
+ });
146
+ artifact.callbackExports = Object.fromEntries(callbackEntries.map((entry) => [entry.manifestKey, entry.exportName]));
147
+ } catch (error) {
148
+ triggerFailures.push({
149
+ kind: "trigger",
150
+ triggerName,
151
+ triggerExportName: loaded.triggerExportName ?? "unknown",
152
+ workflowId,
153
+ phase: "callback-bundle",
154
+ error: error instanceof Error ? error.message : String(error)
155
+ });
156
+ }
157
+ }
158
+ if (loaded.hasTransform) {
159
+ let transformBundled = false;
160
+ let bundleError;
161
+ if (workflowContext) try {
162
+ artifact.transformCallbackBundle = await bundleAttachmentCallbacks({
163
+ filePath: loaded.sourceFilePath,
164
+ projectRoot,
165
+ exportNames: ["transform"],
166
+ workflowExtraction: {
167
+ workflowExportName: workflowContext.workflowExportName,
168
+ workflowFilePath: workflowContext.workflowFilePath,
169
+ triggerIndex: loaded.triggerIndex
170
+ }
171
+ });
172
+ artifact.transformCallbackExports = { transform: "transform" };
173
+ transformBundled = true;
174
+ } catch (err) {
175
+ bundleError = err;
176
+ }
177
+ if (!transformBundled) try {
178
+ artifact.transformCallbackBundle = await bundleAttachmentCallbacks({
179
+ filePath: loaded.sourceFilePath,
180
+ projectRoot,
181
+ exportNames: ["transform"]
182
+ });
183
+ artifact.transformCallbackExports = { transform: "transform" };
184
+ transformBundled = true;
185
+ } catch (err) {
186
+ bundleError = bundleError ?? err;
187
+ }
188
+ if (!transformBundled) {
189
+ const cause = bundleError instanceof Error ? `: ${bundleError.message}` : "";
190
+ triggerFailures.push({
191
+ kind: "trigger",
192
+ triggerName,
193
+ triggerExportName: loaded.triggerExportName ?? "unknown",
194
+ workflowId,
195
+ phase: "callback-bundle",
196
+ error: `Transform declared on trigger "${triggerName}" but could not be bundled${cause}. Ensure the workflow is exported or the transform is a standalone export.`
197
+ });
198
+ }
199
+ }
200
+ artifacts.push(artifact);
201
+ }
202
+ return {
203
+ artifacts,
204
+ failures: triggerFailures
205
+ };
206
+ }
207
+ function buildTriggerCredentialRequirements(credentialSets, callbacks) {
208
+ if (!credentialSets || credentialSets.length === 0) return {
209
+ required: [],
210
+ byCallback: {}
211
+ };
212
+ const entries = credentialSets.map((credentialSet) => {
213
+ const optionalCredentialKeys = readOptionalJsonSchemaKeys(credentialSet.auth);
214
+ const storedSchema = credentialSet.stored ?? credentialSet.auth;
215
+ const storedCredentialKeys = readCredentialKeysFromSchemaObject(storedSchema);
216
+ const optionalStoredCredentialKeys = readOptionalJsonSchemaKeys(storedSchema);
217
+ const resolveCacheMs = "resolveCacheMs" in credentialSet && typeof credentialSet.resolveCacheMs === "number" ? credentialSet.resolveCacheMs : void 0;
218
+ const topLevelRevoked = "onCredentialRevoked" in credentialSet ? credentialSet.onCredentialRevoked : void 0;
219
+ return {
220
+ credentialSetId: credentialSet.resolvedCredentialSetId,
221
+ credentialKeys: readCredentialKeysFromSchemaObject(credentialSet.auth),
222
+ ...optionalCredentialKeys.length > 0 ? { optionalCredentialKeys } : {},
223
+ ...storedCredentialKeys.length > 0 ? { storedCredentialKeys } : {},
224
+ ...optionalStoredCredentialKeys.length > 0 ? { optionalStoredCredentialKeys } : {},
225
+ ...typeof resolveCacheMs === "number" && resolveCacheMs > 0 ? { resolveCacheMs } : {},
226
+ ...topLevelRevoked ? { onCredentialRevoked: topLevelRevoked } : {}
227
+ };
228
+ });
229
+ const requiredIds = credentialSets.map((credentialSet) => credentialSet.resolvedCredentialSetId);
230
+ const byCallback = {};
231
+ if (callbacks?.poll) byCallback.callback = entries;
232
+ if (callbacks?.verify) byCallback.verify = entries;
233
+ return {
234
+ required: requiredIds,
235
+ byCallback
236
+ };
237
+ }
238
+ //#endregion
239
+ export { trigger_artifacts_exports as n, buildTriggerArtifacts as t };
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { d as TriggerSourceSchema, f as TriggerTypeSchema, m as WebhookMethodSchema, u as TriggerCredentialRequirementsSchema } from "./schedule-BXx3uXwr.mjs";
4
+ import "./_manifest-JSRE3H8k.mjs";
5
+ import { z } from "zod";
6
+ //#region ../../packages/shared-types/src/workflows/build-output/trigger-manifest.ts
7
+ const TriggerBuildFunctionSchema = z.object({
8
+ js: z.string().min(1),
9
+ export: z.string().min(1)
10
+ });
11
+ const TriggerBuildManifestSchema = z.object({
12
+ id: z.string().min(1),
13
+ type: TriggerTypeSchema,
14
+ /**
15
+ * Webhook source discriminator (`'custom' | 'app'`). Undefined for
16
+ * non-webhook triggers.
17
+ */
18
+ triggerSource: TriggerSourceSchema.optional(),
19
+ enabled: z.boolean().default(true),
20
+ path: z.string().optional(),
21
+ method: WebhookMethodSchema.optional(),
22
+ schedule: z.string().optional(),
23
+ timezone: z.string().optional(),
24
+ config: z.record(z.string(), z.unknown()).optional(),
25
+ requiredCredentials: TriggerCredentialRequirementsSchema.optional(),
26
+ functions: z.record(z.string(), TriggerBuildFunctionSchema).optional(),
27
+ attachmentFunctions: z.record(z.string(), TriggerBuildFunctionSchema).optional()
28
+ });
29
+ //#endregion
30
+ export { TriggerBuildManifestSchema as t };