@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,245 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { z } from "zod";
4
+ //#region ../../packages/shared-types/src/deployments/api/agent-manifest.ts
5
+ /**
6
+ * Sandbox bootstrap artifact schema - describes an immutable artifact
7
+ * that will be placed in the sandbox environment.
8
+ */
9
+ const SandboxBootstrapArtifactSchema = z.object({
10
+ storagePath: z.string(),
11
+ sha256: z.string(),
12
+ target: z.string(),
13
+ kind: z.enum([
14
+ "file",
15
+ "directory",
16
+ "archive"
17
+ ])
18
+ });
19
+ //#endregion
20
+ //#region ../../packages/shared-types/src/workflows/domain/agent-manifest.ts
21
+ const IntegrationScopeSchema = z.enum([
22
+ "organization",
23
+ "project",
24
+ "user_provided_credential"
25
+ ]);
26
+ const JsonSchemaSchema = z.record(z.string(), z.unknown());
27
+ const CredentialSetProxyInjectionSchema = z.object({
28
+ headers: z.boolean().optional(),
29
+ basicAuth: z.boolean().optional(),
30
+ queryParams: z.boolean().optional(),
31
+ body: z.boolean().optional()
32
+ });
33
+ const CredentialSetProxyConfigSchema = z.object({
34
+ hosts: z.array(z.string().min(1)).optional(),
35
+ hostPatterns: z.array(z.string().min(1)).optional(),
36
+ injection: CredentialSetProxyInjectionSchema.optional()
37
+ });
38
+ const ResolvedCredentialSetIdSchema = z.string().trim().min(1).max(255).refine((value) => /^[a-zA-Z0-9_-]+(:[a-zA-Z0-9_-]+)?$/.test(value), { error: "resolvedId must be a valid credential set ID, optionally namespaced (e.g. \"slack\" or \"keystroke:slack\")" });
39
+ const McpTransportSchema = z.discriminatedUnion("type", [
40
+ z.object({
41
+ type: z.literal("stdio"),
42
+ command: z.string().trim().min(1),
43
+ args: z.array(z.string()).optional(),
44
+ env: z.record(z.string(), z.string()).optional()
45
+ }),
46
+ z.object({
47
+ type: z.literal("http"),
48
+ url: z.string().trim().min(1),
49
+ headers: z.record(z.string(), z.string()).optional()
50
+ }),
51
+ z.object({
52
+ type: z.literal("sse"),
53
+ url: z.string().trim().min(1),
54
+ headers: z.record(z.string(), z.string()).optional()
55
+ })
56
+ ]);
57
+ const McpCredentialReferenceSchema = z.object({
58
+ credentialSetId: z.string().trim().min(1),
59
+ key: z.string().trim().min(1)
60
+ });
61
+ const McpCredentialBindingsSchema = z.object({
62
+ env: z.record(z.string(), McpCredentialReferenceSchema).optional(),
63
+ headers: z.record(z.string(), McpCredentialReferenceSchema).optional()
64
+ });
65
+ const AgentMcpCredentialSetSchema = z.object({
66
+ id: z.string().trim().min(1),
67
+ resolvedId: ResolvedCredentialSetIdSchema,
68
+ credentialKeys: z.array(z.string()),
69
+ /** Persistence-layer schema fingerprint (same contract as workflow manifests). */
70
+ schemaFingerprint: z.string().min(1).optional()
71
+ });
72
+ const AgentMcpServerSchema = z.object({
73
+ id: z.string().trim().min(1),
74
+ name: z.string().trim().min(1),
75
+ description: z.string().optional(),
76
+ transport: McpTransportSchema,
77
+ credentialSets: z.array(AgentMcpCredentialSetSchema).default([]),
78
+ credentialInjection: McpCredentialBindingsSchema.optional()
79
+ });
80
+ const AgentToolSuspensionReasonSchema = z.object({
81
+ kind: z.enum([
82
+ "wait",
83
+ "hook",
84
+ "child-workflow-suspending",
85
+ "agent",
86
+ "long-step"
87
+ ]),
88
+ location: z.unknown().optional(),
89
+ detail: z.string(),
90
+ stepId: z.string().optional(),
91
+ hookName: z.string().optional(),
92
+ authoredWorkflowId: z.string().optional()
93
+ });
94
+ const AgentRuntimeModeSchema = z.enum(["pi_session"]);
95
+ const AgentRuntimePlacementSchema = z.object({
96
+ cwd: z.literal("/home/user"),
97
+ piRoot: z.literal("/home/user/.pi")
98
+ });
99
+ const AgentRuntimeSchema = z.object({
100
+ mode: AgentRuntimeModeSchema,
101
+ placement: AgentRuntimePlacementSchema
102
+ });
103
+ /**
104
+ * Mirrors `SandboxFileSourceSchema` from `@keystroke/workflow-core` so this
105
+ * package stays free of a runtime dependency on workflow-core. Keep in sync
106
+ * with `packages/workflow-core/src/sandbox/schemas.ts`.
107
+ */
108
+ const AgentSandboxFileSourceSchema = z.discriminatedUnion("type", [z.object({
109
+ type: z.literal("git"),
110
+ url: z.string().trim().min(1),
111
+ branch: z.string().optional(),
112
+ /** Workdir-relative or absolute (under `/workspace`) clone destination. */
113
+ target: z.string().optional()
114
+ }), z.object({
115
+ type: z.literal("local"),
116
+ /** Host source path (resolved against project root at deploy time). */
117
+ path: z.string().trim().min(1),
118
+ /** Workdir-relative or absolute (under `/workspace`) destination in the VM. */
119
+ target: z.string().optional()
120
+ })]);
121
+ /**
122
+ * `workdir` here mirrors the workflow-core constraint: must be `/workspace`
123
+ * or a subdirectory so it lands inside the persistent bind mount.
124
+ */
125
+ const AgentSandboxWorkdirSchema = z.string().trim().min(1).refine((value) => value === "/workspace" || value.startsWith("/workspace/"), { error: "workdir must be \"/workspace\" or a subdirectory of \"/workspace\"" });
126
+ const AgentSandboxSchema = z.object({
127
+ snapshotId: z.string().optional(),
128
+ runtime: z.object({
129
+ /**
130
+ * Runs every boot (after `setupCommands`, after a snapshot warm-boot
131
+ * where setupCommands are skipped). Use for `git pull`, `pnpm build`,
132
+ * etc. Each command runs with `cwd = workdir`.
133
+ */
134
+ runCommands: z.array(z.string()).default([]),
135
+ env: z.record(z.string(), z.string()).default({}),
136
+ workdir: AgentSandboxWorkdirSchema.optional()
137
+ }).optional(),
138
+ /**
139
+ * Bootstrap-phase commands. Marker-gated; future snapshot warm-boots skip
140
+ * these entirely. Use for one-time, cacheable setup (e.g. `npm install -g`).
141
+ */
142
+ setupCommands: z.array(z.string()).optional(),
143
+ /** File sources resolved at runtime. `git` clones happen in-VM during bootstrap. */
144
+ fileSources: z.array(AgentSandboxFileSourceSchema).optional(),
145
+ bootstrapArtifacts: z.array(SandboxBootstrapArtifactSchema).optional(),
146
+ sandboxBundleStoragePath: z.string().optional()
147
+ });
148
+ /**
149
+ * Canonical agent version manifest schema - describes runtime metadata
150
+ * for a versioned agent bundle and its session-based execution contract.
151
+ */
152
+ const AgentVersionManifestSchema = z.object({
153
+ /** Database-generated or manifest-level agent identifier */
154
+ agentId: z.string(),
155
+ /** User-authored slug identifier. Primary key for all lookups. */
156
+ authoredAgentId: z.string(),
157
+ /** Human-readable display name. Do not use for lookups. */
158
+ agentName: z.string(),
159
+ displayName: z.string().optional(),
160
+ runtimeKind: z.enum(["declarative", "runnable"]).optional(),
161
+ exportName: z.string(),
162
+ mode: z.literal("sandbox"),
163
+ bundleHash: z.string(),
164
+ bundleSize: z.number(),
165
+ runtime: AgentRuntimeSchema.optional(),
166
+ systemPrompt: z.string().optional(),
167
+ model: z.string().optional(),
168
+ thinkingLevel: z.enum([
169
+ "off",
170
+ "minimal",
171
+ "low",
172
+ "medium",
173
+ "high",
174
+ "xhigh"
175
+ ]).optional(),
176
+ maxSteps: z.number().optional(),
177
+ enableMemory: z.boolean().default(true),
178
+ enableDatabase: z.boolean().default(true),
179
+ inputSchema: JsonSchemaSchema.optional(),
180
+ outputSchema: JsonSchemaSchema.optional(),
181
+ tools: z.array(z.object({
182
+ toolName: z.string(),
183
+ description: z.string().optional(),
184
+ sourceKind: z.enum([
185
+ "operation",
186
+ "workflow",
187
+ "auto-injected-toolkit"
188
+ ]).optional(),
189
+ authoredOperationId: z.string().optional(),
190
+ authoredWorkflowId: z.string().optional(),
191
+ deploymentId: z.string().optional(),
192
+ /**
193
+ * Dispatch placement for operation tools; computed by the builder from
194
+ * official integration metadata. `host` for hosted integrations, otherwise
195
+ * `sandbox`. Not set for workflow tools (their dispatch is derived from
196
+ * suspension classification + child workflow placement).
197
+ */
198
+ dispatch: z.enum(["sandbox", "host"]).optional(),
199
+ invocation: z.enum(["sync", "yield"]).optional(),
200
+ largeResultMode: z.enum(["reject", "ref"]).optional(),
201
+ midSessionSnapshot: z.boolean().optional(),
202
+ suspensions: z.array(AgentToolSuspensionReasonSchema).optional(),
203
+ credentialSets: z.array(z.object({
204
+ id: ResolvedCredentialSetIdSchema,
205
+ required: z.boolean().default(true)
206
+ })).optional(),
207
+ /**
208
+ * Whether the tool's output schema is a non-empty array of objects.
209
+ * Computed by the builder via `isTabularSchema(tool.output)`. Lets
210
+ * runtime UIs render tabular tool results without re-introspecting
211
+ * the schema.
212
+ */
213
+ outputSchemaIsTabular: z.boolean().optional()
214
+ })).optional(),
215
+ credentialSets: z.array(z.object({
216
+ resolvedId: ResolvedCredentialSetIdSchema,
217
+ scope: IntegrationScopeSchema.optional(),
218
+ credentialKeys: z.array(z.string()),
219
+ /** Subset of `credentialKeys` that may be absent from the vault
220
+ * without failing resolution. Derived at build time from the
221
+ * credential set's `auth` schema. */
222
+ optionalCredentialKeys: z.array(z.string()).optional(),
223
+ proxy: CredentialSetProxyConfigSchema.optional(),
224
+ needsRawSecret: z.boolean().optional(),
225
+ /** Persistence-layer schema fingerprint (same contract as workflow manifests). */
226
+ schemaFingerprint: z.string().min(1).optional()
227
+ })).optional(),
228
+ mcpServers: z.array(AgentMcpServerSchema).optional(),
229
+ messaging: z.array(z.object({
230
+ id: z.string(),
231
+ name: z.string(),
232
+ provider: z.string(),
233
+ mode: z.enum(["platform", "custom"]),
234
+ credentialSet: z.object({
235
+ resolvedId: ResolvedCredentialSetIdSchema,
236
+ credentialKeys: z.array(z.string()),
237
+ /** Persistence-layer schema fingerprint (same contract as workflow manifests). */
238
+ schemaFingerprint: z.string().min(1).optional()
239
+ }),
240
+ appRef: z.string().optional()
241
+ })).optional(),
242
+ sandbox: AgentSandboxSchema.optional()
243
+ });
244
+ //#endregion
245
+ export { AgentVersionManifestSchema as t };
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { D as throwReportedCliExit, h as toErrorMessage, o as ANSI, s as style, t as ui } from "./keystroke.mjs";
4
+ import { d as trackProject } from "./dist-CUK7yBM0.mjs";
5
+ import { i as writeJson, n as JsonOptionSchema, t as JSON_OPTION_CONFIG } from "./output-DM4b7KgY.mjs";
6
+ import { t as createTypedCommand } from "./commander-DfTVqQ-3.mjs";
7
+ import { i as readAgentManifestsFromOutDir } from "./dist-BkJUoBiG.mjs";
8
+ import { t as requireWorkflowsDir } from "./resolve-project-DDJ29sCF.mjs";
9
+ import { t as createSpinnerProgress } from "./spinner-progress-DMVwgqO9.mjs";
10
+ import { a as runWorkflowBuild, n as renderBuildFailure } from "./workflow-build-DBQaBfnn.mjs";
11
+ import { i as resolveTypeHint } from "./schema-display-CgmeKigW.mjs";
12
+ import { z } from "zod";
13
+ //#region src/commands/agents/inspect-display.ts
14
+ function renderAgentManifestInspect(manifest, options = {}) {
15
+ const displayName = manifest.displayName ?? manifest.agentName;
16
+ ui.text(style(` Agent: ${manifest.authoredAgentId} (${displayName})`, `${ANSI.bold}${ANSI.cyan}`));
17
+ ui.text(style(` Manifest agent id: ${manifest.agentId}`, ANSI.dim));
18
+ if (manifest.model) ui.text(` Model: ${manifest.model}`);
19
+ if (manifest.runtimeKind) ui.text(` Runtime kind: ${manifest.runtimeKind}`);
20
+ if (manifest.systemPrompt) ui.text(` System prompt: ${formatPromptPreview(manifest.systemPrompt)}`);
21
+ ui.br();
22
+ ui.text(style(" Input", ANSI.bold));
23
+ const inputFields = formatSchemaFields(manifest.inputSchema);
24
+ ui.text(inputFields || style(" (none)", ANSI.dim));
25
+ ui.br();
26
+ ui.text(style(" Output", ANSI.bold));
27
+ const outputFields = formatSchemaFields(manifest.outputSchema);
28
+ ui.text(outputFields || style(" (none)", ANSI.dim));
29
+ ui.br();
30
+ ui.text(style(" Tools", ANSI.bold));
31
+ const tools = formatTools(manifest.tools ?? []);
32
+ ui.text(tools || style(" (none)", ANSI.dim));
33
+ ui.br();
34
+ const credentialSets = formatCredentialSets(manifest.credentialSets ?? []);
35
+ if (credentialSets) {
36
+ ui.text(style(" Credential Sets", ANSI.bold));
37
+ ui.text(credentialSets);
38
+ ui.br();
39
+ }
40
+ if (manifest.mcpServers?.length) {
41
+ ui.text(style(" MCP Servers", ANSI.bold));
42
+ ui.text(manifest.mcpServers.map((server) => ` ${server.id} (${server.name})`).join("\n"));
43
+ ui.br();
44
+ }
45
+ if (manifest.messaging?.length) {
46
+ ui.text(style(" Messaging Gateways", ANSI.bold));
47
+ ui.text(manifest.messaging.map((gateway) => ` ${gateway.id} (${gateway.provider}/${gateway.mode})`).join("\n"));
48
+ ui.br();
49
+ }
50
+ if (options.manifestPath) ui.text(style(` Manifest: ${options.manifestPath}`, ANSI.dim));
51
+ }
52
+ function formatTools(tools) {
53
+ if (tools.length === 0) return "";
54
+ return tools.map(formatTool).join("\n");
55
+ }
56
+ function formatCredentialSets(credentialSets) {
57
+ if (credentialSets.length === 0) return "";
58
+ return credentialSets.map((credentialSet) => {
59
+ const scope = credentialSet.scope ? ` (${credentialSet.scope})` : "";
60
+ const keys = credentialSet.credentialKeys.length > 0 ? ` keys: ${credentialSet.credentialKeys.join(", ")}` : "";
61
+ return ` ${credentialSet.resolvedId}${scope}${keys}`;
62
+ }).join("\n");
63
+ }
64
+ function formatSchemaFields(schema) {
65
+ if (!schema || typeof schema !== "object") return "";
66
+ const props = schema.properties;
67
+ if (!props || Object.keys(props).length === 0) return "";
68
+ const required = schema.required ?? [];
69
+ const requiredSet = new Set(required);
70
+ const lines = [];
71
+ for (const [name, fieldSchema] of Object.entries(props)) {
72
+ const typeHint = resolveTypeHint(fieldSchema);
73
+ const req = requiredSet.has(name) ? style(" required", ANSI.dim) : "";
74
+ lines.push(` ${name} ${style(typeHint, ANSI.dim)}${req}`);
75
+ }
76
+ return lines.join("\n");
77
+ }
78
+ function formatTool(tool) {
79
+ const lines = [` ${tool.toolName}`];
80
+ if (tool.description) lines.push(` ${style(tool.description, ANSI.dim)}`);
81
+ const fields = [
82
+ ["sourceKind", tool.sourceKind],
83
+ ["authoredOperationId", tool.authoredOperationId],
84
+ ["authoredWorkflowId", tool.authoredWorkflowId],
85
+ ["deploymentId", tool.deploymentId],
86
+ ["invocation", tool.invocation],
87
+ ["largeResultMode", tool.largeResultMode],
88
+ ["midSessionSnapshot", formatOptionalBoolean(tool.midSessionSnapshot)]
89
+ ].filter((entry) => typeof entry[1] === "string");
90
+ for (const [label, value] of fields) lines.push(` ${label}: ${value}`);
91
+ if (tool.credentialSets?.length) {
92
+ const credentials = tool.credentialSets.map((credentialSet) => {
93
+ const required = credentialSet.required ? "required" : "conditional";
94
+ return `${credentialSet.id} (${required})`;
95
+ });
96
+ lines.push(` credentialSets: [${credentials.join(", ")}]`);
97
+ }
98
+ return lines.join("\n");
99
+ }
100
+ function formatOptionalBoolean(value) {
101
+ if (value === void 0) return;
102
+ return value ? "true" : "false";
103
+ }
104
+ function formatPromptPreview(prompt) {
105
+ const compact = prompt.replace(/\s+/g, " ").trim();
106
+ if (compact.length <= 120) return compact;
107
+ return `${compact.slice(0, 117)}...`;
108
+ }
109
+ //#endregion
110
+ //#region src/commands/agents/inspect.handler.ts
111
+ const agentInspectDependencies = {
112
+ readAgentManifestsFromOutDir,
113
+ runWorkflowBuild
114
+ };
115
+ async function handleAgentsInspect(options, ctx) {
116
+ const resolved = await resolveAgentManifest(options.agent, options.path, { jsonMode: ctx.jsonMode });
117
+ trackProject(resolved.workflowsDir);
118
+ if (ctx.jsonMode) {
119
+ writeJson({
120
+ manifest: resolved.manifest,
121
+ manifestPath: resolved.manifestPath
122
+ });
123
+ return;
124
+ }
125
+ renderAgentManifestInspect(resolved.manifest, { manifestPath: resolved.manifestPath });
126
+ }
127
+ async function resolveAgentManifest(agentRef, explicitPath, options) {
128
+ const workflowsDir = await requireWorkflowsDir(explicitPath);
129
+ let matches = await findAgentManifest(workflowsDir, agentRef);
130
+ if (matches.length === 0) {
131
+ const spinner = options.jsonMode ? void 0 : createSpinnerProgress("[resolve]");
132
+ spinner?.start(`Building agents to resolve "${agentRef}"...`);
133
+ try {
134
+ await agentInspectDependencies.runWorkflowBuild({
135
+ workflowsDir,
136
+ verbose: false,
137
+ force: false
138
+ });
139
+ spinner?.stop();
140
+ } catch (error) {
141
+ spinner?.stop();
142
+ renderBuildFailure(error);
143
+ throwReportedCliExit(`Build failed while resolving agent "${agentRef}".`, { cause: error });
144
+ }
145
+ matches = await findAgentManifest(workflowsDir, agentRef);
146
+ }
147
+ if (matches.length === 0) {
148
+ const available = await listAvailableAgentRefs(workflowsDir);
149
+ ui.error(`Agent "${agentRef}" not found.`);
150
+ if (available.length > 0) ui.hint(`Available agents: ${available.join(", ")}`);
151
+ else ui.hint("No built agent manifests were found. Run `keystroke workflows build` and try again.");
152
+ throwReportedCliExit(`Agent "${agentRef}" not found.`);
153
+ }
154
+ if (matches.length > 1) {
155
+ ui.error(`Agent reference "${agentRef}" matched multiple agent manifests.`);
156
+ for (const match of matches) ui.hint(`- ${match.manifest.authoredAgentId} (${match.manifest.agentName}) at ${match.manifestPath}`);
157
+ ui.hint("Use the authored agent id to inspect one manifest.");
158
+ throwReportedCliExit(`Agent reference "${agentRef}" matched multiple agent manifests.`);
159
+ }
160
+ const match = matches[0];
161
+ if (!match) throwReportedCliExit(`Agent "${agentRef}" not found.`);
162
+ return {
163
+ workflowsDir,
164
+ manifest: match.manifest,
165
+ manifestPath: match.manifestPath
166
+ };
167
+ }
168
+ async function findAgentManifest(workflowsDir, agentRef) {
169
+ try {
170
+ return (await agentInspectDependencies.readAgentManifestsFromOutDir(workflowsDir)).filter(({ manifest }) => manifestMatchesRef(manifest, agentRef));
171
+ } catch (error) {
172
+ ui.error(`Failed to read built agent manifests: ${toErrorMessage(error)}`);
173
+ throwReportedCliExit(`Failed to read built agent manifests: ${toErrorMessage(error)}`, { cause: error });
174
+ }
175
+ }
176
+ async function listAvailableAgentRefs(workflowsDir) {
177
+ return (await agentInspectDependencies.readAgentManifestsFromOutDir(workflowsDir)).map(({ manifest }) => manifest.authoredAgentId || manifest.agentName || manifest.agentId).filter((value) => Boolean(value)).sort((left, right) => left.localeCompare(right));
178
+ }
179
+ function manifestMatchesRef(manifest, agentRef) {
180
+ return [
181
+ manifest.authoredAgentId,
182
+ manifest.agentId,
183
+ manifest.agentName,
184
+ manifest.displayName,
185
+ manifest.exportName
186
+ ].some((value) => value === agentRef);
187
+ }
188
+ //#endregion
189
+ //#region src/commands/agents/agents.command.ts
190
+ const AgentsOptionsSchema = JsonOptionSchema.extend({ path: z.string().optional() });
191
+ const AgentsInspectOptionsSchema = AgentsOptionsSchema.extend({ agent: z.string().min(1) });
192
+ const AGENTS_OPTIONS_CONFIG = {
193
+ ...JSON_OPTION_CONFIG,
194
+ path: {
195
+ flag: "--path <dir>",
196
+ description: "Path to project root (directory containing keystroke.config.ts); auto-discovered from CWD if omitted"
197
+ }
198
+ };
199
+ const AGENTS_INSPECT_OPTIONS_CONFIG = { ...AGENTS_OPTIONS_CONFIG };
200
+ function handleAgentsHelp() {
201
+ ui.hint("Use `keystroke agents inspect <agentId>` to inspect a built agent manifest.");
202
+ }
203
+ function createAgentsCommand() {
204
+ const cmd = createTypedCommand({
205
+ name: "agents",
206
+ description: "Inspect and debug agents",
207
+ schema: AgentsOptionsSchema,
208
+ optionsConfig: AGENTS_OPTIONS_CONFIG,
209
+ handler: handleAgentsHelp,
210
+ subcommands: [createTypedCommand({
211
+ name: "inspect",
212
+ description: "Show the built manifest for an agent",
213
+ schema: AgentsInspectOptionsSchema,
214
+ optionsConfig: AGENTS_INSPECT_OPTIONS_CONFIG,
215
+ argument: {
216
+ name: "agent",
217
+ description: "Authored agent id (preferred), agent id, or agent name",
218
+ key: "agent"
219
+ },
220
+ handler: handleAgentsInspect
221
+ })]
222
+ });
223
+ cmd.enablePositionalOptions();
224
+ cmd.passThroughOptions();
225
+ return cmd;
226
+ }
227
+ //#endregion
228
+ export { createAgentsCommand };
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { n as JsonOptionSchema, t as JSON_OPTION_CONFIG } from "./output-DM4b7KgY.mjs";
4
+ import { t as createTypedCommand } from "./commander-DfTVqQ-3.mjs";
5
+ import { z } from "zod";
6
+ //#region src/commands/api-keys/api-keys.command.ts
7
+ const ApiKeysDeleteOptionsSchema = z.object({ apiKeyId: z.string() });
8
+ const DELETE_OPTIONS_CONFIG = { apiKeyId: {
9
+ flag: "",
10
+ description: ""
11
+ } };
12
+ function createApiKeysCommand() {
13
+ return createTypedCommand({
14
+ name: "api-keys",
15
+ description: "Manage API keys for your organization",
16
+ schema: JsonOptionSchema,
17
+ optionsConfig: { ...JSON_OPTION_CONFIG },
18
+ loadHandler: async () => (await import("./list.handler-DWaQkJaR.mjs")).handleApiKeysList,
19
+ subcommands: [createTypedCommand({
20
+ name: "list",
21
+ description: "List all API keys for your organization",
22
+ schema: JsonOptionSchema,
23
+ optionsConfig: { ...JSON_OPTION_CONFIG },
24
+ loadHandler: async () => (await import("./list.handler-DWaQkJaR.mjs")).handleApiKeysList
25
+ }), createTypedCommand({
26
+ name: "delete",
27
+ description: "Delete an API key by ID",
28
+ schema: ApiKeysDeleteOptionsSchema,
29
+ optionsConfig: DELETE_OPTIONS_CONFIG,
30
+ argument: {
31
+ name: "api-key-id",
32
+ description: "API key ID to delete",
33
+ key: "apiKeyId"
34
+ },
35
+ loadHandler: async () => (await import("./delete.handler-bAu1iXVQ.mjs")).handleApiKeysDelete
36
+ })]
37
+ });
38
+ }
39
+ //#endregion
40
+ export { createApiKeysCommand };
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { g as AUTH_TIMEOUT_SECONDS } from "./keystroke.mjs";
4
+ import { t as createTypedCommand } from "./commander-DfTVqQ-3.mjs";
5
+ import { z } from "zod";
6
+ //#region src/commands/auth/auth.command.ts
7
+ const AuthOptionsSchema = z.object({
8
+ webUrl: z.url().optional().describe("Keystroke web URL"),
9
+ serverUrl: z.url().optional().describe("Keystroke API URL"),
10
+ timeout: z.coerce.number().int().min(AUTH_TIMEOUT_SECONDS.min).max(AUTH_TIMEOUT_SECONDS.max).default(AUTH_TIMEOUT_SECONDS.default).describe("Timeout in seconds")
11
+ });
12
+ const AUTH_OPTIONS_CONFIG = {
13
+ webUrl: {
14
+ flag: "--web-url <url>",
15
+ description: "Keystroke web URL (default: WEB_URL env)"
16
+ },
17
+ serverUrl: {
18
+ flag: "--server-url <url>",
19
+ description: "Keystroke API URL (default: SERVER_URL env)"
20
+ },
21
+ timeout: {
22
+ flag: "--timeout <seconds>",
23
+ description: `Authentication timeout in seconds (default: ${AUTH_TIMEOUT_SECONDS.default})`
24
+ }
25
+ };
26
+ function createAuthCommand() {
27
+ return createTypedCommand({
28
+ name: "auth",
29
+ description: "Authenticate Keystroke CLI via device flow",
30
+ schema: AuthOptionsSchema,
31
+ optionsConfig: AUTH_OPTIONS_CONFIG,
32
+ loadHandler: async () => (await import("./auth.handler-CT1BQUvu.mjs")).handleAuth,
33
+ subcommands: [
34
+ createTypedCommand({
35
+ name: "clear",
36
+ description: "Revoke the saved API key and remove local credentials",
37
+ schema: z.object({}),
38
+ optionsConfig: {},
39
+ loadHandler: async () => (await import("./clear.handler-BTIXXPTJ.mjs")).handleAuthClear
40
+ }),
41
+ createTypedCommand({
42
+ name: "test",
43
+ description: "Verify that the saved API key is valid",
44
+ schema: z.object({}),
45
+ optionsConfig: {},
46
+ loadHandler: async () => (await import("./test.handler-BcPQ8b74.mjs")).handleAuthTest
47
+ }),
48
+ createTypedCommand({
49
+ name: "status",
50
+ description: "Show the current signed-in identity and organization context",
51
+ schema: z.object({}),
52
+ optionsConfig: {},
53
+ loadHandler: async () => (await import("./status.handler-BO4nwvWn.mjs")).handleAuthStatus
54
+ })
55
+ ]
56
+ });
57
+ }
58
+ //#endregion
59
+ export { createAuthCommand };