@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,277 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { C as CliExitError, D as throwReportedCliExit, h as toErrorMessage, m as isNetworkError, o as ANSI, p as isAuthError, s as style, t as ui, u as REAUTH_HINT } from "./keystroke.mjs";
4
+ import { d as trackProject } from "./dist-CUK7yBM0.mjs";
5
+ import { i as writeJson } from "./output-DM4b7KgY.mjs";
6
+ import { n as CredentialScopeSchema, t as ConnectionStatusSchema } from "./schema-17qMfNyI.mjs";
7
+ import { a as readManifestsFromOutDir } from "./dist-BkJUoBiG.mjs";
8
+ import { t as requireWorkflowsDir } from "./resolve-project-DDJ29sCF.mjs";
9
+ import { i as requireClient } from "./context-T7HZuB97.mjs";
10
+ import { t as getIntegrationCatalog } from "./integration-catalog-Bt-L3GjF.mjs";
11
+ import { t as groupCredentialRequirements } from "./credentials-OfVHOtG3.mjs";
12
+ import { z } from "zod";
13
+ import Table from "cli-table3";
14
+ //#region ../../packages/shared-types/src/credentials/api/responses.ts
15
+ /**
16
+ * credentials/api/responses.ts
17
+ *
18
+ * Response types for credential management endpoints.
19
+ */
20
+ /** Schema for a credential set in API responses (no values) */
21
+ const CredentialSetResponseSchema = z.object({
22
+ id: z.string(),
23
+ organizationId: z.string(),
24
+ credentialSetId: z.string(),
25
+ name: z.string(),
26
+ scope: CredentialScopeSchema,
27
+ userId: z.string().nullable(),
28
+ /** Set for project-scoped credential sets; null for all other scopes. */
29
+ projectId: z.uuid().nullable(),
30
+ isDefault: z.boolean(),
31
+ /** Whether this connection was established through Keystroke's platform OAuth flow. */
32
+ platformConnected: z.boolean(),
33
+ /** Health status of this connection. */
34
+ connectionStatus: ConnectionStatusSchema,
35
+ /** Token expiry for refreshable platform OAuth connections. Null for long-lived and user-managed. */
36
+ expiresAt: z.string().nullable(),
37
+ createdAt: z.string(),
38
+ updatedAt: z.string(),
39
+ /** Keys present in this credential set (values are never returned) */
40
+ keys: z.array(z.string()).optional()
41
+ });
42
+ z.object({
43
+ /** All credential sets created, one per requested scope. */
44
+ credentialSets: z.array(CredentialSetResponseSchema) });
45
+ z.object({
46
+ credentialSets: z.array(CredentialSetResponseSchema),
47
+ pagination: z.object({
48
+ limit: z.number(),
49
+ offset: z.number(),
50
+ total: z.number()
51
+ })
52
+ });
53
+ z.object({ credentialSet: CredentialSetResponseSchema });
54
+ z.object({ credentialSet: CredentialSetResponseSchema });
55
+ z.object({ success: z.literal(true) });
56
+ z.object({
57
+ success: z.literal(true),
58
+ updatedKeys: z.array(z.string())
59
+ });
60
+ z.object({
61
+ /** Decrypted credential key-value pairs (e.g., { "SLACK_BOT_TOKEN": "xoxb-..." }) */
62
+ credentials: z.record(z.string(), z.string()) });
63
+ const CredentialResolutionRemediationSchema = z.object({
64
+ /** Human-friendly credential or integration label. */
65
+ displayName: z.string(),
66
+ /** High-level auth model for the missing or incomplete requirement. */
67
+ connectionType: z.enum([
68
+ "oauth",
69
+ "manual",
70
+ "internal"
71
+ ]),
72
+ /** Primary action a user should take next. */
73
+ action: z.enum([
74
+ "connect",
75
+ "reconnect",
76
+ "upload",
77
+ "contact_admin"
78
+ ]),
79
+ /** Human-facing fix summary that should avoid internal credential-set IDs. */
80
+ summary: z.string(),
81
+ /** Suggested CLI command when Keystroke can point to one. */
82
+ command: z.string().optional(),
83
+ /** Missing keys when a credential set exists but is incomplete. */
84
+ missingKeys: z.array(z.string()).optional()
85
+ });
86
+ const ResolveCredentialsErrorResponseSchema = z.object({
87
+ error: z.string(),
88
+ message: z.string().optional(),
89
+ detail: z.string().optional(),
90
+ remediation: CredentialResolutionRemediationSchema.optional(),
91
+ requestedKeys: z.array(z.string()).optional()
92
+ });
93
+ z.discriminatedUnion("status", [z.object({
94
+ status: z.literal("exchanged"),
95
+ /** The credential set the server persisted values into. */
96
+ credentialSetId: z.string(),
97
+ /** Keys persisted from the exchange hook's returned `stored` payload. */
98
+ keys: z.array(z.string()),
99
+ /** ISO timestamp when the stored payload expires, if any. */
100
+ expiresAt: z.string().datetime().nullable().optional()
101
+ }), z.object({
102
+ status: z.literal("needs-reinput"),
103
+ /** Optional user-facing message provided by the connection author. */
104
+ message: z.string().optional()
105
+ })]);
106
+ //#endregion
107
+ //#region src/commands/workflows/env/env.handler.ts
108
+ /** 404 = no credential set, 422 = missing keys — these are expected "not configured" responses */
109
+ function isCredentialNotConfiguredError(error) {
110
+ if (typeof error === "object" && error !== null && "response" in error && typeof error.response?.status === "number") {
111
+ const status = error.response.status;
112
+ return status === 404 || status === 422;
113
+ }
114
+ return false;
115
+ }
116
+ async function handleWorkflowsEnv(options, ctx) {
117
+ const client = requireClient(ctx);
118
+ const workflowsDir = await requireWorkflowsDir(options.path);
119
+ trackProject(workflowsDir);
120
+ const manifests = await readManifestsFromOutDir(workflowsDir, options.workflow);
121
+ if (manifests.length === 0) if (options.workflow) {
122
+ ui.error(`Workflow "${options.workflow}" not found.`);
123
+ ui.hint("Run `keystroke workflows build` first, then re-run this command.");
124
+ throwReportedCliExit(`Workflow "${options.workflow}" not found.`);
125
+ } else {
126
+ ui.hint("No built manifests found.");
127
+ ui.hint("Run `keystroke workflows build` first, then re-run this command.");
128
+ return;
129
+ }
130
+ const catalog = await getIntegrationCatalog(ctx);
131
+ const results = [];
132
+ for (const { manifest } of manifests) try {
133
+ const result = await buildWorkflowEnvResult(manifest, client, catalog);
134
+ results.push(result);
135
+ } catch (error) {
136
+ if (isNetworkError(error)) {
137
+ const url = ctx.baseUrl ?? "unknown";
138
+ ui.error(`Cannot reach the server. Tried: ${url}`);
139
+ ui.hint(` ${toErrorMessage(error)}`);
140
+ ui.hint(" Credential status cannot be verified when the server is unreachable.");
141
+ throwReportedCliExit("Cannot verify credential status because the server is unreachable.", { cause: error });
142
+ }
143
+ if (isAuthError(error)) {
144
+ ui.error(`Invalid or expired credentials. ${REAUTH_HINT}`);
145
+ ui.hint(toErrorMessage(error));
146
+ throwReportedCliExit("Invalid or expired credentials.", { cause: error });
147
+ }
148
+ throw error;
149
+ }
150
+ if (ctx.jsonMode) writeJson(results.map((r) => ({
151
+ workflowName: r.workflowName,
152
+ requirements: r.requirements.map((req) => ({
153
+ varName: req.varName,
154
+ credentialSetId: req.credentialSetId,
155
+ sourceLabel: req.sourceLabel,
156
+ scope: req.scope,
157
+ isPresent: req.status === "set"
158
+ }))
159
+ })));
160
+ else renderTable(results);
161
+ if (options.check) {
162
+ if (results.some((r) => r.requirements.some((req) => req.status === "missing"))) throw new CliExitError("Missing workflow environment requirements.", {
163
+ exitCode: 1,
164
+ reported: true
165
+ });
166
+ }
167
+ }
168
+ async function buildWorkflowEnvResult(manifest, client, catalog) {
169
+ const seen = /* @__PURE__ */ new Set();
170
+ const requirements = [];
171
+ const fixes = [];
172
+ const groups = groupCredentialRequirements(manifest);
173
+ for (const group of groups) {
174
+ const defaultSourceLabel = getCredentialSourceLabel(catalog, group.credentialSetId);
175
+ try {
176
+ const scope = group.scope === "organization" || group.scope === "project" ? group.scope : void 0;
177
+ const response = await client.credentials.resolve({
178
+ credentialSetId: group.credentialSetId,
179
+ keys: group.keys,
180
+ ...scope && { scope }
181
+ });
182
+ const configuredKeys = new Set(Object.keys(response.credentials));
183
+ for (const key of group.keys) {
184
+ if (seen.has(key)) continue;
185
+ seen.add(key);
186
+ requirements.push({
187
+ varName: key,
188
+ credentialSetId: group.credentialSetId,
189
+ sourceLabel: defaultSourceLabel,
190
+ scope: group.scope,
191
+ status: configuredKeys.has(key) ? "set" : "missing"
192
+ });
193
+ }
194
+ } catch (err) {
195
+ if (!isCredentialNotConfiguredError(err)) throw err;
196
+ const resolutionError = await readCredentialResolutionError(err);
197
+ if (resolutionError?.remediation?.summary) addWorkflowFix(fixes, {
198
+ displayName: resolutionError.remediation.displayName,
199
+ summary: resolutionError.remediation.summary
200
+ });
201
+ for (const key of group.keys) {
202
+ if (seen.has(key)) continue;
203
+ seen.add(key);
204
+ requirements.push({
205
+ varName: key,
206
+ credentialSetId: group.credentialSetId,
207
+ sourceLabel: resolutionError?.remediation?.displayName ?? defaultSourceLabel,
208
+ scope: group.scope,
209
+ status: "missing"
210
+ });
211
+ }
212
+ }
213
+ }
214
+ return {
215
+ workflowName: manifest.name,
216
+ requirements,
217
+ fixes
218
+ };
219
+ }
220
+ function renderTable(results) {
221
+ for (const result of results) {
222
+ ui.text(style(`◆ Workflow: ${result.workflowName}`, ANSI.bold));
223
+ if (result.requirements.length === 0) {
224
+ ui.hint(" No environment variables required.");
225
+ ui.br();
226
+ continue;
227
+ }
228
+ const table = new Table({
229
+ head: [
230
+ "Variable",
231
+ "Source",
232
+ "Scope",
233
+ "Status"
234
+ ],
235
+ style: { head: [] }
236
+ });
237
+ for (const req of result.requirements) {
238
+ const statusText = req.status === "set" ? style("set", `${ANSI.bold}${ANSI.green}`) : style("missing", `${ANSI.bold}${ANSI.red}`);
239
+ table.push([
240
+ req.varName,
241
+ req.sourceLabel ?? req.credentialSetId ?? style("—", ANSI.dim),
242
+ req.scope ?? style("—", ANSI.dim),
243
+ statusText
244
+ ]);
245
+ }
246
+ ui.text(table.toString());
247
+ const missingCount = result.requirements.filter((r) => r.status === "missing").length;
248
+ const total = result.requirements.length;
249
+ if (missingCount > 0) {
250
+ ui.warn(`${missingCount} of ${total} required credential(s) are missing on the server.`);
251
+ if (result.fixes.length > 0) {
252
+ ui.text("Suggested fixes:");
253
+ for (const fix of result.fixes) ui.hint(` ${fix.summary}`);
254
+ }
255
+ } else if (total > 0) ui.success(`All ${total} required credential(s) are set on the server.`);
256
+ ui.br();
257
+ }
258
+ }
259
+ async function readCredentialResolutionError(error) {
260
+ if (typeof error !== "object" || error === null || !("response" in error) || typeof error.response?.clone !== "function") return;
261
+ try {
262
+ const response = error.response;
263
+ return ResolveCredentialsErrorResponseSchema.parse(await response.clone().json());
264
+ } catch {
265
+ return;
266
+ }
267
+ }
268
+ function getCredentialSourceLabel(catalog, credentialSetId) {
269
+ if (!credentialSetId) return null;
270
+ return catalog.byResolvedCredentialSetId.get(credentialSetId)?.label ?? credentialSetId;
271
+ }
272
+ function addWorkflowFix(fixes, fix) {
273
+ if (fixes.some((existing) => existing.summary === fix.summary)) return;
274
+ fixes.push(fix);
275
+ }
276
+ //#endregion
277
+ export { handleWorkflowsEnv };
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { C as CliExitError, h as toErrorMessage, i as logger, m as isNetworkError, t as ui } from "./keystroke.mjs";
4
+ import { r as isJsonMode } from "./output-DM4b7KgY.mjs";
5
+ import { n as renderCredentialSchemaMismatchText, r as writeCredentialSchemaMismatchJson, t as isCredentialSchemaMismatchErrorLike } from "./credential-schema-mismatch-BKo5PjcQ.mjs";
6
+ //#region src/lib/error-boundary.ts
7
+ async function withErrorBoundary(commandName, fn, options = {}) {
8
+ const jsonMode = options.json ?? isJsonMode({});
9
+ try {
10
+ await fn();
11
+ } catch (error) {
12
+ if (error instanceof CliExitError) throw error.markReported();
13
+ if (isCredentialSchemaMismatchErrorLike(error)) {
14
+ const message = toErrorMessage(error);
15
+ logger.error(`${commandName} error`, { error: message });
16
+ if (jsonMode) writeCredentialSchemaMismatchJson(error);
17
+ else renderCredentialSchemaMismatchText(ui, error);
18
+ throw new CliExitError(message, {
19
+ cause: error,
20
+ reported: true
21
+ });
22
+ }
23
+ const message = toErrorMessage(error);
24
+ logger.error(`${commandName} error`, { error: message });
25
+ ui.error(`${commandName} error: ${message}`);
26
+ if (isNetworkError(error)) ui.hint("Tip: If using a local server, ensure it is running (e.g. turbo dev) and that the database is available.");
27
+ throw new CliExitError(message, {
28
+ cause: error,
29
+ reported: true
30
+ });
31
+ }
32
+ }
33
+ //#endregion
34
+ export { withErrorBoundary as t };
@@ -0,0 +1,191 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { S as SourceLocationSchema, b as CapturedVariableSchema } from "./schedule-BXx3uXwr.mjs";
4
+ import { z } from "zod";
5
+ z.enum([
6
+ "pending",
7
+ "running",
8
+ "completed",
9
+ "failed",
10
+ "cancelled",
11
+ "expired",
12
+ "suspended",
13
+ "suspended_cred_wait"
14
+ ]);
15
+ z.enum([
16
+ "queued",
17
+ "running",
18
+ "completed",
19
+ "failed",
20
+ "suspended",
21
+ "cancelled"
22
+ ]);
23
+ z.enum([
24
+ "queued",
25
+ "running",
26
+ "completed",
27
+ "failed",
28
+ "suspended",
29
+ "cancelled"
30
+ ]);
31
+ z.enum(["workflow", "step"]);
32
+ const TriggerTypeSchema = z.enum([
33
+ "webhook",
34
+ "cron",
35
+ "polling"
36
+ ]);
37
+ z.enum(["custom", "app"]);
38
+ z.enum([
39
+ "cli-test",
40
+ "webhook",
41
+ "cron",
42
+ "polling"
43
+ ]);
44
+ z.enum([
45
+ "GET",
46
+ "POST",
47
+ "PUT",
48
+ "PATCH"
49
+ ]);
50
+ z.enum([
51
+ "filter",
52
+ "idempotencyKey",
53
+ "verify",
54
+ "callback"
55
+ ]);
56
+ //#endregion
57
+ //#region ../../packages/shared-types/src/workflows/build-output/file-metadata.ts
58
+ function isNormalizedRelativePath(value) {
59
+ if (value.length === 0) return false;
60
+ if (value.startsWith("/") || value.startsWith("./") || value.startsWith("../")) return false;
61
+ if (value.split("/").some((segment) => segment.length === 0 || segment === "." || segment === "..")) return false;
62
+ return !value.includes("\\");
63
+ }
64
+ const FILE_METADATA_SCHEMA_VERSION = "1.0.0";
65
+ const RelativeFilePathSchema = z.string().min(1).refine(isNormalizedRelativePath, { error: "Expected a normalized project-relative path" });
66
+ const WorkflowDelegatedAgentRefSchema = z.object({
67
+ exportName: z.string().min(1),
68
+ authoredAgentId: z.string().min(1).optional(),
69
+ agentName: z.string().min(1),
70
+ sourceFilePath: RelativeFilePathSchema.optional()
71
+ });
72
+ const WorkflowDelegatedWorkflowRefSchema = z.object({
73
+ exportName: z.string().min(1),
74
+ authoredWorkflowId: z.string().min(1).optional(),
75
+ workflowName: z.string().min(1),
76
+ sourceFilePath: RelativeFilePathSchema.optional()
77
+ });
78
+ const FileWorkflowDefinitionSchema = z.object({
79
+ name: z.string().min(1),
80
+ exportName: z.string().min(1),
81
+ workflowId: z.string().min(1).optional(),
82
+ description: z.string().optional(),
83
+ delegatedAgents: z.array(WorkflowDelegatedAgentRefSchema).optional(),
84
+ delegatedWorkflows: z.array(WorkflowDelegatedWorkflowRefSchema).optional(),
85
+ source: SourceLocationSchema,
86
+ capturedVariables: z.array(CapturedVariableSchema).optional()
87
+ });
88
+ const FileOperationDefinitionSchema = z.object({
89
+ name: z.string().min(1),
90
+ exportName: z.string().min(1),
91
+ source: SourceLocationSchema,
92
+ capturedVariables: z.array(CapturedVariableSchema).optional(),
93
+ isBundle: z.boolean().optional()
94
+ });
95
+ const FileAgentDefinitionSchema = z.object({
96
+ agentName: z.string().min(1),
97
+ exportName: z.string().min(1),
98
+ factoryName: z.string().min(1).optional(),
99
+ source: SourceLocationSchema,
100
+ capturedVariables: z.array(CapturedVariableSchema).optional()
101
+ });
102
+ const FileTriggerDefinitionSchema = z.object({
103
+ name: z.string().min(1).optional(),
104
+ triggerType: TriggerTypeSchema,
105
+ exportName: z.string().min(1),
106
+ source: SourceLocationSchema
107
+ });
108
+ const FileCredentialSetDefinitionSchema = z.object({
109
+ credentialSetName: z.string().min(1),
110
+ resolvedCredentialSetId: z.string().min(1).optional(),
111
+ exportName: z.string().min(1),
112
+ source: SourceLocationSchema
113
+ });
114
+ const FileSandboxDefinitionSchema = z.object({
115
+ sandboxName: z.string().min(1),
116
+ exportName: z.string().min(1),
117
+ source: SourceLocationSchema
118
+ });
119
+ const FileMcpServerDefinitionSchema = z.object({
120
+ mcpServerName: z.string().min(1),
121
+ exportName: z.string().min(1),
122
+ source: SourceLocationSchema
123
+ });
124
+ const FileDefinitionsSchema = z.object({
125
+ workflows: z.array(FileWorkflowDefinitionSchema).default([]),
126
+ operations: z.array(FileOperationDefinitionSchema).default([]),
127
+ agents: z.array(FileAgentDefinitionSchema).default([]),
128
+ triggers: z.object({ defined: z.array(FileTriggerDefinitionSchema).default([]) }).default({ defined: [] }),
129
+ credentialSets: z.array(FileCredentialSetDefinitionSchema).default([]),
130
+ sandboxes: z.array(FileSandboxDefinitionSchema).default([]),
131
+ mcpServers: z.array(FileMcpServerDefinitionSchema).default([])
132
+ });
133
+ const StepConsumptionEntrySchema = z.object({
134
+ stepName: z.string().min(1),
135
+ consumedInFile: RelativeFilePathSchema,
136
+ workflowName: z.string().min(1),
137
+ nodeId: z.string().min(1)
138
+ });
139
+ const FileConsumptionSchema = z.object({ stepsConsumedBy: z.array(StepConsumptionEntrySchema).default([]) });
140
+ const FileCredentialRefSchema = z.object({
141
+ resolvedId: z.string().min(1),
142
+ scope: z.string().optional(),
143
+ credentialKeys: z.array(z.string()).optional()
144
+ });
145
+ const FileImportEntrySchema = z.object({
146
+ moduleSpecifier: z.string().min(1),
147
+ importNames: z.array(z.string()).default([]),
148
+ isNamespaceImport: z.boolean().optional(),
149
+ namespaceName: z.string().optional(),
150
+ resolvedPath: RelativeFilePathSchema.optional()
151
+ });
152
+ const FileExportEntrySchema = z.object({
153
+ exportName: z.string().min(1),
154
+ kind: z.enum([
155
+ "workflow",
156
+ "operation",
157
+ "agent",
158
+ "trigger",
159
+ "credential-set",
160
+ "sandbox",
161
+ "mcp-server",
162
+ "other"
163
+ ])
164
+ });
165
+ const FileMetadataBuildInfoSchema = z.object({
166
+ generatedAt: z.iso.datetime(),
167
+ sourceChecksum: z.string().length(64).regex(/^[a-f0-9]{64}$/i)
168
+ });
169
+ const FileConventionSchema = z.enum([
170
+ "workflow",
171
+ "operation",
172
+ "trigger",
173
+ "agent",
174
+ "credential-set",
175
+ "sandbox",
176
+ "mcp-server"
177
+ ]).nullable().optional();
178
+ const FileMetadataSchema = z.object({
179
+ schemaVersion: z.literal(FILE_METADATA_SCHEMA_VERSION),
180
+ filePath: RelativeFilePathSchema,
181
+ absoluteFilePath: z.string().min(1).optional(),
182
+ fileConvention: FileConventionSchema,
183
+ definitions: FileDefinitionsSchema,
184
+ consumption: FileConsumptionSchema.default({ stepsConsumedBy: [] }),
185
+ credentials: z.array(FileCredentialRefSchema).default([]),
186
+ imports: z.array(FileImportEntrySchema).default([]),
187
+ exports: z.array(FileExportEntrySchema).default([]),
188
+ buildInfo: FileMetadataBuildInfoSchema
189
+ });
190
+ //#endregion
191
+ export { FileMetadataSchema as n, RelativeFilePathSchema as r, FILE_METADATA_SCHEMA_VERSION as t };