@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,385 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { F as schemaToJsonSchema, S as SourceLocationSchema, V as SHA256HashSchema, a as CredentialRequirementsSchema, c as IntegrationScopeSchema, f as TriggerTypeSchema, h as WorkflowStepEntrySchema, l as ResolvedCredentialSetSchema, p as TriggerUploadDataSchema, t as DurationSchema, v as CallKindSchema, x as ImportSourceSchema, y as CallsiteFingerprintSchema, z as JsonSchemaSchema } from "./schedule-BXx3uXwr.mjs";
4
+ import { z } from "zod";
5
+ import { createHash } from "node:crypto";
6
+ //#region ../../packages/workflow-core/src/artifacts/flow-graph-schema.ts
7
+ const DecisionKindSchema = z.enum([
8
+ "if",
9
+ "switch",
10
+ "ternary"
11
+ ]);
12
+ const ParallelKindSchema = z.enum([
13
+ "all",
14
+ "race",
15
+ "allSettled",
16
+ "any"
17
+ ]);
18
+ const LoopKindSchema = z.enum([
19
+ "for",
20
+ "for-of",
21
+ "for-in",
22
+ "while",
23
+ "do-while"
24
+ ]);
25
+ const ExitKindSchema = z.enum(["return", "throw"]);
26
+ const FlowBranchKindSchema = z.enum([
27
+ "then",
28
+ "else",
29
+ "parallel-branch"
30
+ ]);
31
+ const FlowNodeTypeSchema = z.enum([
32
+ "entry",
33
+ "step",
34
+ "code-block",
35
+ "decision",
36
+ "merge",
37
+ "fork",
38
+ "join",
39
+ "parallel-map",
40
+ "loop",
41
+ "exit"
42
+ ]);
43
+ const FlowEdgeTypeSchema = z.enum([
44
+ "default",
45
+ "true-branch",
46
+ "false-branch",
47
+ "merge",
48
+ "loop-entry",
49
+ "loop-back",
50
+ "parallel",
51
+ "return"
52
+ ]);
53
+ const FlowStatementSchema = z.object({
54
+ kind: z.string().min(1),
55
+ label: z.string().min(1),
56
+ sourceText: z.string().min(1)
57
+ });
58
+ const EntryNodeDataSchema = z.object({ kind: z.literal("entry") });
59
+ const StepNodeDataSchema = z.object({
60
+ kind: z.literal("call"),
61
+ callKind: CallKindSchema,
62
+ stepName: z.string().min(1),
63
+ callsiteFingerprint: CallsiteFingerprintSchema.optional(),
64
+ exportName: z.string().min(1).optional(),
65
+ stepId: z.string().min(1).optional(),
66
+ awaited: z.boolean().optional(),
67
+ dynamic: z.boolean().optional(),
68
+ recursive: z.boolean().optional(),
69
+ importSource: ImportSourceSchema.optional(),
70
+ outputBinding: z.string().min(1).optional(),
71
+ description: z.string().optional(),
72
+ inputSchema: JsonSchemaSchema.optional(),
73
+ outputSchema: JsonSchemaSchema.optional(),
74
+ source: SourceLocationSchema.optional(),
75
+ astKind: z.string().min(1).optional(),
76
+ scopeOverride: IntegrationScopeSchema.optional(),
77
+ credentialSets: z.array(ResolvedCredentialSetSchema).optional(),
78
+ requiredOAuthScopes: z.array(z.string()).optional()
79
+ });
80
+ const CodeBlockNodeDataSchema = z.object({
81
+ kind: z.literal("code-block"),
82
+ statements: z.array(FlowStatementSchema)
83
+ });
84
+ const DecisionNodeDataSchema = z.object({
85
+ kind: z.literal("decision"),
86
+ decisionKind: DecisionKindSchema.optional(),
87
+ source: SourceLocationSchema.optional(),
88
+ astKind: z.string().min(1).optional(),
89
+ conditionText: z.string().optional()
90
+ });
91
+ const MergeNodeDataSchema = z.object({
92
+ kind: z.literal("merge"),
93
+ source: SourceLocationSchema.optional()
94
+ });
95
+ const ForkNodeDataSchema = z.object({
96
+ kind: z.literal("fork"),
97
+ parallelKind: ParallelKindSchema.optional(),
98
+ preStatements: z.array(FlowStatementSchema).optional(),
99
+ source: SourceLocationSchema.optional(),
100
+ astKind: z.string().min(1).optional()
101
+ });
102
+ const JoinNodeDataSchema = z.object({
103
+ kind: z.literal("join"),
104
+ outputBinding: z.string().min(1).optional(),
105
+ source: SourceLocationSchema.optional()
106
+ });
107
+ const ParallelMapNodeDataSchema = z.object({
108
+ kind: z.literal("parallel-map"),
109
+ parallelKind: ParallelKindSchema.optional(),
110
+ iterationExpression: z.string().optional(),
111
+ stepNames: z.array(z.string()).optional(),
112
+ outputBinding: z.string().min(1).optional(),
113
+ preStatements: z.array(FlowStatementSchema).optional(),
114
+ source: SourceLocationSchema.optional(),
115
+ astKind: z.string().min(1).optional()
116
+ });
117
+ const LoopNodeDataSchema = z.object({
118
+ kind: z.literal("loop"),
119
+ loopKind: LoopKindSchema.optional(),
120
+ source: SourceLocationSchema.optional(),
121
+ astKind: z.string().min(1).optional(),
122
+ conditionText: z.string().optional()
123
+ });
124
+ const ExitNodeDataSchema = z.object({
125
+ kind: z.literal("exit"),
126
+ exitKind: ExitKindSchema,
127
+ sourceText: z.string().optional(),
128
+ source: SourceLocationSchema.optional(),
129
+ astKind: z.string().min(1).optional()
130
+ });
131
+ const FlowNodeDataSchema = z.discriminatedUnion("kind", [
132
+ EntryNodeDataSchema,
133
+ StepNodeDataSchema,
134
+ CodeBlockNodeDataSchema,
135
+ DecisionNodeDataSchema,
136
+ MergeNodeDataSchema,
137
+ ForkNodeDataSchema,
138
+ JoinNodeDataSchema,
139
+ ParallelMapNodeDataSchema,
140
+ LoopNodeDataSchema,
141
+ ExitNodeDataSchema
142
+ ]);
143
+ const FlowEdgeDataSchema = z.object({ branchKind: FlowBranchKindSchema.optional() }).catchall(z.unknown());
144
+ const FlowPositionSchema = z.object({
145
+ x: z.number().finite(),
146
+ y: z.number().finite()
147
+ });
148
+ const FlowNodeSchema = z.object({
149
+ id: z.string().min(1),
150
+ type: FlowNodeTypeSchema,
151
+ label: z.string(),
152
+ position: FlowPositionSchema,
153
+ data: FlowNodeDataSchema
154
+ });
155
+ const FlowEdgeSchema = z.object({
156
+ id: z.string().min(1),
157
+ source: z.string().min(1),
158
+ target: z.string().min(1),
159
+ type: FlowEdgeTypeSchema,
160
+ label: z.string().optional(),
161
+ data: FlowEdgeDataSchema.optional()
162
+ });
163
+ const FlowGraphSchema = z.object({
164
+ nodes: z.array(FlowNodeSchema),
165
+ edges: z.array(FlowEdgeSchema),
166
+ entryPoint: z.string().min(1),
167
+ exitPoints: z.array(z.string().min(1)),
168
+ generatedAt: z.iso.datetime(),
169
+ diagnostics: z.array(z.string())
170
+ });
171
+ //#endregion
172
+ //#region ../../packages/workflow-core/src/artifacts/schema-fingerprint.ts
173
+ /**
174
+ * schema-fingerprint.ts
175
+ *
176
+ * Computes a deterministic fingerprint (hash) of a credential set's schema.
177
+ * Used as a persistence-layer identity stamp: the workflow-builder stamps each
178
+ * credential requirement with its fingerprint at build time, the server stamps
179
+ * each vault row with the fingerprint at upload time, and the executor's
180
+ * credential resolver compares the two at read time so schema drift surfaces
181
+ * as a `CredentialSchemaMismatchError` rather than a silent decode into a
182
+ * stale shape.
183
+ *
184
+ * The fingerprint is deterministic: identical JSON schemas always produce the
185
+ * same hash regardless of property ordering, timestamps, or other
186
+ * non-structural differences.
187
+ *
188
+ * @remarks
189
+ * This is the *persistence* fingerprint. The construction-time registry in
190
+ * `credential-set/registry.ts` uses a different (Zod-structural) fingerprint
191
+ * purely for in-process identity collision detection; the two fingerprints
192
+ * serve different purposes and do not need to match.
193
+ */
194
+ /**
195
+ * Compute a deterministic fingerprint for a JSON schema object.
196
+ *
197
+ * The schema is the output of `schemaToJsonSchema(zodSchema)` — a plain JSON
198
+ * object describing the shape of the Zod schema.
199
+ *
200
+ * Properties are sorted recursively before hashing to ensure deterministic
201
+ * output regardless of insertion order.
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * const auth = schemaToJsonSchema(credentialSet.auth);
206
+ * const stored = credentialSet.stored ? schemaToJsonSchema(credentialSet.stored) : undefined;
207
+ * const fingerprint = computeSchemaFingerprint(auth, stored);
208
+ * ```
209
+ *
210
+ * @see CredentialSchemaMismatchError
211
+ */
212
+ function computeSchemaFingerprint(authSchema, storedSchema) {
213
+ const normalized = sortDeep({
214
+ auth: authSchema,
215
+ ...storedSchema ? { stored: storedSchema } : {}
216
+ });
217
+ const json = JSON.stringify(normalized);
218
+ return createHash("sha256").update(json).digest("hex").substring(0, 16);
219
+ }
220
+ function sortDeep(value) {
221
+ if (value === null || value === void 0) return value;
222
+ if (Array.isArray(value)) return value.map(sortDeep);
223
+ if (typeof value === "object") {
224
+ const sorted = {};
225
+ for (const key of Object.keys(value).sort()) sorted[key] = sortDeep(value[key]);
226
+ return sorted;
227
+ }
228
+ return value;
229
+ }
230
+ //#endregion
231
+ //#region ../../packages/workflow-core/src/artifacts/workflow-manifest.ts
232
+ const WORKFLOW_MANIFEST_GENERATOR = "local-build";
233
+ const WORKFLOW_MANIFEST_SCHEMA_VERSION = "1.0.0";
234
+ /** Shared identity fields for a workflow. Single source of truth for name/description/tags validation. */
235
+ const WorkflowIdentitySchema = z.object({
236
+ name: z.string().trim().min(1).max(255),
237
+ description: z.string().trim().min(1).optional(),
238
+ tags: z.array(z.string()).optional()
239
+ });
240
+ z.object({
241
+ name: z.string().trim().min(1).max(255),
242
+ description: z.string().trim().min(1).optional(),
243
+ tags: z.array(z.string()).optional()
244
+ });
245
+ const WorkflowIOSchema = z.object({
246
+ input: JsonSchemaSchema.nullable(),
247
+ output: JsonSchemaSchema.nullable()
248
+ });
249
+ const BuildInfoSchema = z.object({
250
+ timestamp: z.iso.datetime(),
251
+ builderVersion: z.string().min(1),
252
+ generatedBy: z.literal(WORKFLOW_MANIFEST_GENERATOR),
253
+ gitCommit: z.string().optional(),
254
+ gitBranch: z.string().optional(),
255
+ gitIsDirty: z.boolean().optional(),
256
+ nodeVersion: z.string().min(1),
257
+ platform: z.string().min(1),
258
+ sourceChecksumAlgorithm: z.enum(["sha256"]),
259
+ sourceChecksum: z.string().length(64),
260
+ generatedFiles: z.array(z.string().min(1))
261
+ });
262
+ /** Trigger binding data included in workflow manifests. */
263
+ const WorkflowTriggerBindingSchema = z.object({
264
+ triggerName: z.string().min(1),
265
+ triggerType: TriggerTypeSchema,
266
+ hasTransform: z.boolean(),
267
+ hasFilter: z.boolean(),
268
+ narrowedFrom: z.string().optional(),
269
+ lineage: z.array(z.string()).optional()
270
+ });
271
+ /** What a Workflow primitive knows about itself at construction time. Every field is real — no placeholders. */
272
+ const WorkflowCoreManifestSchema = WorkflowIdentitySchema.extend({
273
+ schemaVersion: z.literal(WORKFLOW_MANIFEST_SCHEMA_VERSION),
274
+ id: z.string().min(1),
275
+ exportName: z.string().min(1),
276
+ workflowSchemas: WorkflowIOSchema,
277
+ workflowGlobals: JsonSchemaSchema.optional(),
278
+ timeout: DurationSchema.optional(),
279
+ buildInfo: BuildInfoSchema,
280
+ triggers: z.array(WorkflowTriggerBindingSchema).optional()
281
+ });
282
+ /** Categorized dependency tracking for workflow manifests */
283
+ const ManifestDependenciesSchema = z.object({
284
+ /** Local source files: relative path (from project root) -> SHA256 content hash */
285
+ localFiles: z.record(z.string(), z.string()),
286
+ /** npm packages: package name -> declared version from package.json */
287
+ packages: z.record(z.string(), z.string()),
288
+ /** Workspace packages: @keystroke/* name -> version specifier */
289
+ workspacePackages: z.record(z.string(), z.string()),
290
+ /** Node.js built-in module specifiers (e.g., "node:fs") */
291
+ builtins: z.array(z.string())
292
+ });
293
+ /** Complete build-enriched manifest. Extends core with steps, dependencies, and credentials discovered by the build pipeline. */
294
+ const WorkflowManifestSchema = WorkflowCoreManifestSchema.extend({
295
+ workflowSource: SourceLocationSchema.optional(),
296
+ dependencies: ManifestDependenciesSchema,
297
+ hasCycles: z.boolean().optional(),
298
+ credentials: CredentialRequirementsSchema.optional(),
299
+ sandboxes: z.array(z.record(z.string(), z.unknown())).optional(),
300
+ steps: z.record(z.string(), WorkflowStepEntrySchema)
301
+ });
302
+ z.object({
303
+ organizationId: z.string(),
304
+ workflowId: z.string(),
305
+ bundle: z.instanceof(Uint8Array).optional(),
306
+ manifest: WorkflowManifestSchema,
307
+ sourcePath: z.string().optional(),
308
+ triggers: z.array(TriggerUploadDataSchema).optional(),
309
+ bundleSize: z.number().optional(),
310
+ bundleHash: SHA256HashSchema.optional(),
311
+ skipVersionBump: z.boolean().optional(),
312
+ projectRoot: z.string().optional(),
313
+ projectId: z.uuid(),
314
+ flowJson: FlowGraphSchema.optional(),
315
+ deploymentSnapshotOnly: z.boolean().optional()
316
+ });
317
+ //#endregion
318
+ //#region ../../packages/workflow-core/src/shared/declared-credential-requirements.ts
319
+ function readSchemaKeys(schema, propertyKey) {
320
+ if (schema === null || typeof schema !== "object") return [];
321
+ const candidate = schema[propertyKey];
322
+ if (candidate === null || typeof candidate !== "object" || Array.isArray(candidate)) return [];
323
+ return Object.keys(candidate).sort();
324
+ }
325
+ /**
326
+ * Returns sorted keys that are NOT listed in the JSON Schema `required` array.
327
+ */
328
+ function readOptionalJsonSchemaKeys(schema) {
329
+ if (schema === null || typeof schema !== "object") return [];
330
+ const record = schema;
331
+ const properties = record.properties;
332
+ if (properties === null || typeof properties !== "object" || Array.isArray(properties)) return [];
333
+ const requiredSet = new Set(Array.isArray(record.required) ? record.required : []);
334
+ return Object.keys(properties).filter((key) => !requiredSet.has(key)).sort();
335
+ }
336
+ function toDeclaredCredentialRequirement(credentialSet) {
337
+ const optionalAuthKeys = credentialSet.optionalCredentialKeys;
338
+ const optionalStoredKeys = credentialSet.optionalStoredCredentialKeys;
339
+ const schemaFingerprint = computeSchemaFingerprint(schemaToJsonSchema(credentialSet.auth), credentialSet.stored ? schemaToJsonSchema(credentialSet.stored) : void 0);
340
+ const onCredentialRevoked = credentialSet.onCredentialRevoked;
341
+ return {
342
+ credentialSetId: credentialSet.id,
343
+ ...credentialSet.namespace ? { namespace: credentialSet.namespace } : {},
344
+ resolvedCredentialSetId: credentialSet.resolvedCredentialSetId,
345
+ credentialKeys: [...credentialSet.credentialKeys],
346
+ ...optionalAuthKeys.length > 0 ? { optionalCredentialKeys: [...optionalAuthKeys] } : {},
347
+ storedCredentialKeys: [...credentialSet.storedCredentialKeys],
348
+ ...optionalStoredKeys.length > 0 ? { optionalStoredCredentialKeys: [...optionalStoredKeys] } : {},
349
+ schemaFingerprint,
350
+ ...credentialSet.needsResolve ? { needsResolve: true } : {},
351
+ ...credentialSet.resolveCacheMs > 0 ? { resolveCacheMs: credentialSet.resolveCacheMs } : {},
352
+ ...onCredentialRevoked ? { onCredentialRevoked } : {},
353
+ ...credentialSet.proxy ? { proxy: credentialSet.proxy } : {},
354
+ ...credentialSet.needsRawSecret === true ? { needsRawSecret: true } : {}
355
+ };
356
+ }
357
+ function toDeclaredCredentialRequirements(credentialSets) {
358
+ return credentialSets.map(toDeclaredCredentialRequirement);
359
+ }
360
+ function manifestToDeclaredCredentialRequirement(credentialSet) {
361
+ const authKeys = readSchemaKeys(credentialSet.auth, "properties");
362
+ const optionalAuthKeys = readOptionalJsonSchemaKeys(credentialSet.auth);
363
+ const storedSchema = credentialSet.stored ?? credentialSet.auth;
364
+ const storedKeys = readSchemaKeys(storedSchema, "properties");
365
+ const optionalStoredKeys = readOptionalJsonSchemaKeys(storedSchema);
366
+ const schemaFingerprint = credentialSet.auth ? computeSchemaFingerprint(credentialSet.auth, credentialSet.stored) : void 0;
367
+ const onCredentialRevoked = credentialSet.onCredentialRevoked;
368
+ return {
369
+ credentialSetId: credentialSet.id,
370
+ ...credentialSet.namespace ? { namespace: credentialSet.namespace } : {},
371
+ resolvedCredentialSetId: credentialSet.resolvedCredentialSetId,
372
+ credentialKeys: authKeys,
373
+ ...optionalAuthKeys.length > 0 ? { optionalCredentialKeys: optionalAuthKeys } : {},
374
+ storedCredentialKeys: storedKeys,
375
+ ...optionalStoredKeys.length > 0 ? { optionalStoredCredentialKeys: optionalStoredKeys } : {},
376
+ ...schemaFingerprint ? { schemaFingerprint } : {},
377
+ ...credentialSet.needsResolve ? { needsResolve: true } : {},
378
+ ...typeof credentialSet.resolveCacheMs === "number" && credentialSet.resolveCacheMs > 0 ? { resolveCacheMs: credentialSet.resolveCacheMs } : {},
379
+ ...onCredentialRevoked ? { onCredentialRevoked } : {},
380
+ ...credentialSet.proxy ? { proxy: credentialSet.proxy } : {},
381
+ ...credentialSet.needsRawSecret === true ? { needsRawSecret: true } : {}
382
+ };
383
+ }
384
+ //#endregion
385
+ export { WORKFLOW_MANIFEST_SCHEMA_VERSION as a, FlowGraphSchema as c, WORKFLOW_MANIFEST_GENERATOR as i, readOptionalJsonSchemaKeys as n, WorkflowCoreManifestSchema as o, toDeclaredCredentialRequirements as r, WorkflowManifestSchema as s, manifestToDeclaredCredentialRequirement as t };