@keystrokehq/hosting 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2299,6 +2299,21 @@ function handleReadonlyResult(payload) {
2299
2299
  payload.value = Object.freeze(payload.value);
2300
2300
  return payload;
2301
2301
  }
2302
+ const $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
2303
+ $ZodType.init(inst, def);
2304
+ defineLazy(inst._zod, "innerType", () => {
2305
+ const d = def;
2306
+ if (!d._cachedInner) d._cachedInner = def.getter();
2307
+ return d._cachedInner;
2308
+ });
2309
+ defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
2310
+ defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
2311
+ defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? void 0);
2312
+ defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? void 0);
2313
+ inst._zod.parse = (payload, ctx) => {
2314
+ return inst._zod.innerType._zod.run(payload, ctx);
2315
+ };
2316
+ });
2302
2317
  const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
2303
2318
  $ZodCheck.init(inst, def);
2304
2319
  $ZodType.init(inst, def);
@@ -3441,6 +3456,12 @@ const optionalProcessor = (schema, ctx, _json, params) => {
3441
3456
  const seen = ctx.seen.get(schema);
3442
3457
  seen.ref = def.innerType;
3443
3458
  };
3459
+ const lazyProcessor = (schema, ctx, _json, params) => {
3460
+ const innerType = schema._zod.innerType;
3461
+ process$1(innerType, ctx, params);
3462
+ const seen = ctx.seen.get(schema);
3463
+ seen.ref = innerType;
3464
+ };
3444
3465
  //#endregion
3445
3466
  //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
3446
3467
  const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
@@ -4304,6 +4325,18 @@ function readonly(innerType) {
4304
4325
  innerType
4305
4326
  });
4306
4327
  }
4328
+ const ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
4329
+ $ZodLazy.init(inst, def);
4330
+ ZodType.init(inst, def);
4331
+ inst._zod.processJSONSchema = (ctx, json, params) => lazyProcessor(inst, ctx, json, params);
4332
+ inst.unwrap = () => inst._zod.def.getter();
4333
+ });
4334
+ function lazy(getter) {
4335
+ return new ZodLazy({
4336
+ type: "lazy",
4337
+ getter
4338
+ });
4339
+ }
4307
4340
  const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
4308
4341
  $ZodCustom.init(inst, def);
4309
4342
  ZodType.init(inst, def);
@@ -4979,10 +5012,244 @@ const AppSlugSchema = ProjectSlugSchema;
4979
5012
  function resolveExplicitPublicPlatformOrigin(env = process.env) {
4980
5013
  return env.PUBLIC_PLATFORM_URL?.replace(/\/$/, "") || void 0;
4981
5014
  }
5015
+ /** How a credential instance is stored (`credential_instances.auth_kind`). */
5016
+ const CredentialAuthKindSchema = _enum([
5017
+ "api_key",
5018
+ "oauth_managed",
5019
+ "keystroke"
5020
+ ]);
5021
+ /**
5022
+ * Where a credential instance is stored (`credential_instances.scope_type`), and the only thing an
5023
+ * action/tool can pin via `.scope(...)`. There is no resolution chain: when no scope is pinned, the
5024
+ * resolver tries the project default, then the org default, then throws.
5025
+ */
5026
+ const CredentialScopeTypeSchema = _enum([
5027
+ "organization",
5028
+ "project",
5029
+ "user"
5030
+ ]);
5031
+ CredentialAuthKindSchema.options;
5032
+ CredentialScopeTypeSchema.options;
5033
+ /** Non-empty human-readable label or description (trimmed). */
5034
+ const requiredDisplayTextSchema = string().trim().min(1);
5035
+ /**
5036
+ * Structural workflow-canvas graph contract.
5037
+ *
5038
+ * This is the deterministic skeleton the deploy-time AST producer emits for a
5039
+ * workflow (nodes + edges), plus the manifest-derived trigger-source nodes. It
5040
+ * is the single source of truth shared by:
5041
+ * - the AST producer (emits it at deploy, stored with the manifest),
5042
+ * - the platform route that serves the canvas, and
5043
+ * - the SDK / web client that renders it (React Flow).
5044
+ *
5045
+ * Only the structural skeleton lives here. The LLM enrichment + run-overlay
5046
+ * envelope types live in `workflow-canvas-envelope.ts`; the SDK re-exports them.
5047
+ * See WORKFLOW.md (§4 grammar, §8 node ids, §9 caching).
5048
+ */
5049
+ /**
5050
+ * Canvas node taxonomy — the single discriminator for every canvas node. The
5051
+ * client derives the React Flow component, icon, and per-node treatment from it
5052
+ * (no parallel `type` / `data.kind` fields), and the producer + fixtures emit it
5053
+ * directly, so the structural contract can never silently diverge across the
5054
+ * deploy → render boundary.
5055
+ * - Boundaries: `entry` (Start, owns input) · `exit` (Output, owns output) ·
5056
+ * `error` (a terminal `throw` — an error output that ends the run on a branch)
5057
+ * - Callable: `step` (action / agent / llm / hook / child-workflow invocation) —
5058
+ * the invocation flavor lives in {@link WorkflowCanvasCallKind}
5059
+ * - Structural control flow: `code-block` · `decision` · `merge` · `loop` ·
5060
+ * `parallel` (group containers) · `loop-start` (the group body's entry marker,
5061
+ * shared by loop + parallel)
5062
+ * - Upstream of entry: `trigger-source` (one per manifest trigger attachment)
5063
+ *
5064
+ * `Promise.all([...])` is modeled as a `parallel` group container: the branches
5065
+ * are stacked inside and the container itself is the single prong leaving the
5066
+ * wrapper (there is no separate fork/join pair).
5067
+ *
5068
+ * `exit` and `error` are both terminals: a `return` flows to the shared `exit`
5069
+ * (the workflow output), while a `throw` gets its own `error` terminal off the
5070
+ * branch so guard clauses (`if (bad) throw …`) read as a visible dead-end.
5071
+ */
5072
+ const WorkflowCanvasNodeTypeSchema = _enum([
5073
+ "entry",
5074
+ "exit",
5075
+ "error",
5076
+ "step",
5077
+ "code-block",
5078
+ "decision",
5079
+ "merge",
5080
+ "loop",
5081
+ "parallel",
5082
+ "loop-start",
5083
+ "trigger-source"
5084
+ ]);
5085
+ _enum([
5086
+ "workflow-step",
5087
+ "agent",
5088
+ "llm",
5089
+ "wait",
5090
+ "hook",
5091
+ "tool",
5092
+ "child-workflow"
5093
+ ]);
5094
+ /** A labeled branch output on a decision-style node. */
5095
+ const WorkflowCanvasNodeOutputSchema = object({
5096
+ id: string(),
5097
+ label: string()
5098
+ });
5099
+ /**
5100
+ * A step input's configured value at its call site, captured deterministically
5101
+ * by the producer from the call's argument object. The platform join turns this
5102
+ * into the inspector's {@link WorkflowNodeInputBinding} (filling display labels).
5103
+ */
5104
+ const WorkflowCanvasRawBindingSchema = object({
5105
+ tokens: array(discriminatedUnion("kind", [
5106
+ object({
5107
+ kind: literal("text"),
5108
+ text: string()
5109
+ }),
5110
+ object({
5111
+ kind: literal("reference"),
5112
+ /** Upstream node id this value flows from; absent only for unresolved refs. */
5113
+ sourceNodeId: string().optional(),
5114
+ /** Output field of the source (dotted path); omitted = the whole output. */
5115
+ field: string().optional()
5116
+ }),
5117
+ object({
5118
+ kind: literal("variable"),
5119
+ text: string()
5120
+ }),
5121
+ object({
5122
+ kind: literal("call"),
5123
+ name: string()
5124
+ })
5125
+ ])),
5126
+ /** Render as a tall multi-line box (object/array/multiline template values). */
5127
+ multiline: boolean().optional()
5128
+ });
5129
+ /**
5130
+ * Statically-captured `promptLlm` options for an `llm` step node. Literal-only:
5131
+ * dynamic/expression values (a computed model, a `system` built by a function) are
5132
+ * not captured; `system`/`outputSchema` record presence so the inspector can note
5133
+ * "a system prompt is configured" / "structured output" without their values.
5134
+ */
5135
+ const WorkflowCanvasLlmOptionsSchema = object({
5136
+ model: string().optional(),
5137
+ maxTokens: number$1().optional(),
5138
+ temperature: number$1().optional(),
5139
+ thinkingLevel: string().optional(),
5140
+ hasSystemPrompt: boolean().optional(),
5141
+ hasOutputSchema: boolean().optional()
5142
+ });
5143
+ const WorkflowCanvasNodeDataSchema = object({
5144
+ label: string(),
5145
+ /** Set on group nodes (loop / parallel section containers). */
5146
+ groupKind: _enum([
5147
+ "loop",
5148
+ "parallel",
5149
+ "conditional"
5150
+ ]).optional(),
5151
+ description: string().optional(),
5152
+ /** {@link WorkflowCanvasCallKind} or a looser raw call-site label. */
5153
+ callKind: string().optional(),
5154
+ /**
5155
+ * App/integration slug for a `step` whose action/agent is imported directly
5156
+ * from a `@keystrokehq/<app>` package (e.g. "slack", "apollo"). Lets the client
5157
+ * badge the node with that app's logo; absent for custom (project-local)
5158
+ * actions, which fall back to the call-kind icon.
5159
+ */
5160
+ appSlug: string().optional(),
5161
+ /** Cron/webhook/poll discriminator on trigger-source nodes. */
5162
+ triggerType: string().optional(),
5163
+ /** Branch outputs (decision nodes). */
5164
+ outputs: array(WorkflowCanvasNodeOutputSchema).optional(),
5165
+ /**
5166
+ * Action/agent/workflow slug resolved at deploy time (via import → definition).
5167
+ * Optional when the deploy build cannot resolve source (dist-only artifacts).
5168
+ */
5169
+ slug: string().optional(),
5170
+ /**
5171
+ * Durable call-site ids nested inside an off-grammar `code-block` (same-file only).
5172
+ * Used by the run overlay to light the block when any contained step executes.
5173
+ */
5174
+ containedCallSiteIds: array(string()).optional(),
5175
+ /**
5176
+ * Per-input call-site value bindings for `step` nodes, keyed by input field name.
5177
+ * Deterministically captured from the call's argument object; reference tokens point
5178
+ * at the upstream node that produced the value. The platform join fills display labels.
5179
+ */
5180
+ inputBindings: record(string(), WorkflowCanvasRawBindingSchema).optional(),
5181
+ /**
5182
+ * Static `promptLlm(prompt, options)` configuration captured at the call site for
5183
+ * `llm` step nodes. Only literal values are captured (model/maxTokens/temperature/
5184
+ * thinkingLevel); `system`/`outputSchema` are usually expressions, so only their
5185
+ * presence is recorded. Absent when no options are statically resolvable.
5186
+ */
5187
+ llmOptions: WorkflowCanvasLlmOptionsSchema.optional()
5188
+ });
5189
+ /**
5190
+ * A single structural node. This is the deploy artifact's shape: identity
5191
+ * (`id`), the canonical discriminator (`nodeType`), display `data`, and group
5192
+ * nesting (`parentId`). All layout/rendering — React Flow component key,
5193
+ * positions, sizes, `extent`, group box dimensions — is derived entirely
5194
+ * client-side from this structure, so it never leaks into the wire contract.
5195
+ */
5196
+ const WorkflowCanvasGraphNodeSchema = object({
5197
+ id: string(),
5198
+ nodeType: WorkflowCanvasNodeTypeSchema,
5199
+ data: WorkflowCanvasNodeDataSchema,
5200
+ /** Set on children nested inside a group (loop / parallel) container. */
5201
+ parentId: string().optional()
5202
+ });
5203
+ const WorkflowCanvasEdgeSchema = object({
5204
+ id: string(),
5205
+ source: string(),
5206
+ target: string(),
5207
+ type: string().optional(),
5208
+ label: string().optional(),
5209
+ sourceHandle: string().optional(),
5210
+ targetHandle: string().optional(),
5211
+ data: object({ branchKind: _enum([
5212
+ "then",
5213
+ "else",
5214
+ "parallel-branch",
5215
+ "error"
5216
+ ]).optional() }).optional()
5217
+ });
5218
+ /** A statically-evaluable top-level `const` value (literal scalars only). */
5219
+ const WorkflowCanvasConstantValueSchema = union([
5220
+ string(),
5221
+ number$1(),
5222
+ boolean()
5223
+ ]);
5224
+ /**
5225
+ * Top-level `const NAME = <literal>` declarations in the workflow source, captured
5226
+ * at deploy. Lets the platform resolve `variable` value tokens (e.g. a `model` set
5227
+ * to a named const) to their concrete value for display. Scalars only — computed,
5228
+ * function-local, or non-literal consts are intentionally omitted.
5229
+ */
5230
+ const WorkflowCanvasConstantsSchema = record(string(), WorkflowCanvasConstantValueSchema);
5231
+ const WorkflowCanvasGraphSchema = object({
5232
+ nodes: array(WorkflowCanvasGraphNodeSchema),
5233
+ edges: array(WorkflowCanvasEdgeSchema),
5234
+ /** Top-level literal constants from the workflow source (for value-token resolution). */
5235
+ constants: WorkflowCanvasConstantsSchema.optional()
5236
+ });
5237
+ /**
5238
+ * Deploy-time summary of one credential a step requires, derived from the
5239
+ * action/agent-tool definition's `.credentials`. The workflow-canvas credential
5240
+ * overlay joins a step node's `slug` to these to resolve the bound instance.
5241
+ * `key` doubles as the app slug (matches `credential_instances.app_slug`).
5242
+ */
5243
+ const CredentialRequirementSummarySchema = object({
5244
+ key: string(),
5245
+ kind: CredentialAuthKindSchema,
5246
+ /** Scope pinned via `.scope(...)`; absent means project-default → org-default. */
5247
+ scope: CredentialScopeTypeSchema.optional()
5248
+ });
4982
5249
  const StoredRouteManifestSkillSchema = object({
4983
5250
  slug: string(),
4984
- name: string().optional(),
4985
- description: string().optional(),
5251
+ name: requiredDisplayTextSchema,
5252
+ description: requiredDisplayTextSchema,
4986
5253
  moduleFile: string()
4987
5254
  });
4988
5255
  const attachmentSchemasSchema = record(string(), object({
@@ -4990,8 +5257,8 @@ const attachmentSchemasSchema = record(string(), object({
4990
5257
  filterSchema: record(string(), unknown()).optional()
4991
5258
  }));
4992
5259
  const attachmentMetaSchema = record(string(), object({
4993
- name: string().optional(),
4994
- description: string().optional()
5260
+ name: requiredDisplayTextSchema,
5261
+ description: requiredDisplayTextSchema
4995
5262
  }));
4996
5263
  const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
4997
5264
  object({ kind: literal("health") }),
@@ -4999,23 +5266,43 @@ const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
4999
5266
  kind: literal("agent"),
5000
5267
  slug: string(),
5001
5268
  moduleFile: string(),
5002
- name: string().optional(),
5003
- description: string().optional(),
5269
+ name: requiredDisplayTextSchema,
5270
+ description: requiredDisplayTextSchema,
5004
5271
  model: string(),
5005
5272
  systemPrompt: string(),
5006
5273
  toolCount: number$1().int().nonnegative(),
5007
5274
  credentialCount: number$1().int().nonnegative(),
5008
5275
  appSlugs: array(string()).default([]),
5009
- toolSlugs: array(string()).default([])
5276
+ toolSlugs: array(string()).default([]),
5277
+ /** Credential requirements per tool slug (the agent's credential consumer key). */
5278
+ toolRequirements: record(string(), array(CredentialRequirementSummarySchema)).optional()
5279
+ }),
5280
+ object({
5281
+ kind: literal("action"),
5282
+ slug: string(),
5283
+ name: requiredDisplayTextSchema,
5284
+ description: requiredDisplayTextSchema,
5285
+ moduleFile: string(),
5286
+ /** App slug for actions imported from an integration package (`@keystrokehq/<app>/actions`). */
5287
+ appSlug: string().optional(),
5288
+ inputSchema: record(string(), unknown()),
5289
+ outputSchema: record(string(), unknown()),
5290
+ /** Credentials this action requires (for the canvas credential overlay). */
5291
+ requirements: array(CredentialRequirementSummarySchema).optional()
5010
5292
  }),
5011
5293
  object({
5012
5294
  kind: literal("workflow"),
5013
5295
  slug: string(),
5014
- name: string().optional(),
5015
- description: string().optional(),
5296
+ name: requiredDisplayTextSchema,
5297
+ description: requiredDisplayTextSchema,
5016
5298
  subscribable: boolean(),
5017
5299
  moduleFile: string(),
5018
- requestSchema: record(string(), unknown())
5300
+ requestSchema: record(string(), unknown()),
5301
+ responseSchema: record(string(), unknown()).optional(),
5302
+ /** Deterministic AST control-flow skeleton (deploy-time producer). */
5303
+ flowGraph: WorkflowCanvasGraphSchema.optional(),
5304
+ /** sha256 of the workflow source the `flowGraph` was produced from (staleness). */
5305
+ flowGraphSourceHash: string().optional()
5019
5306
  }),
5020
5307
  object({
5021
5308
  kind: literal("trigger-webhook"),
@@ -5034,8 +5321,8 @@ const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
5034
5321
  moduleFile: string(),
5035
5322
  sourceHash: string().optional(),
5036
5323
  schedule: string(),
5037
- name: string().optional(),
5038
- description: string().optional()
5324
+ name: requiredDisplayTextSchema,
5325
+ description: requiredDisplayTextSchema
5039
5326
  }),
5040
5327
  object({
5041
5328
  kind: literal("trigger-poll-group"),
@@ -5051,8 +5338,8 @@ const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
5051
5338
  moduleFile: string(),
5052
5339
  sourceHash: string().optional(),
5053
5340
  schedule: string(),
5054
- name: string().optional(),
5055
- description: string().optional()
5341
+ name: requiredDisplayTextSchema,
5342
+ description: requiredDisplayTextSchema
5056
5343
  })
5057
5344
  ]);
5058
5345
  object({
@@ -5290,18 +5577,19 @@ object({
5290
5577
  source: _enum([
5291
5578
  "custom",
5292
5579
  "mcp",
5293
- "openapi"
5580
+ "openapi",
5581
+ "graphql"
5294
5582
  ]).default("custom"),
5295
- mcpUrl: string().url().optional(),
5583
+ url: string().url().optional(),
5296
5584
  authKind: AppAuthKindSchema.optional(),
5297
5585
  fields: optionalCredentialFieldsSchema.optional(),
5298
5586
  credentialScheme: AppCredentialSchemeSchema.optional(),
5299
5587
  oauthScopes: array(OAuthScopeOptionSchema).optional()
5300
5588
  }).superRefine((data, ctx) => {
5301
- if (data.source === "mcp" && !data.mcpUrl) ctx.addIssue({
5589
+ if ((data.source === "mcp" || data.source === "openapi" || data.source === "graphql") && !data.url) ctx.addIssue({
5302
5590
  code: "custom",
5303
- message: "mcpUrl is required for MCP apps",
5304
- path: ["mcpUrl"]
5591
+ message: "url is required for this app source",
5592
+ path: ["url"]
5305
5593
  });
5306
5594
  if (!(data.authKind ?? (data.source === "custom" ? "api_key" : void 0))) {
5307
5595
  ctx.addIssue({
@@ -5327,7 +5615,7 @@ object({
5327
5615
  category: string().min(1),
5328
5616
  authKind: AppAuthKindSchema,
5329
5617
  source: AppSourceSchema,
5330
- mcpUrl: string().url().nullable().optional(),
5618
+ url: string().url().nullable().optional(),
5331
5619
  credentialFields: optionalCredentialFieldsSchema.optional(),
5332
5620
  credentialScheme: AppCredentialSchemeSchema.optional(),
5333
5621
  oauthScopes: array(OAuthScopeOptionSchema).optional(),
@@ -5347,7 +5635,7 @@ object({
5347
5635
  source: AppSourceSchema,
5348
5636
  credentialFields: AppCredentialFieldsSchema.optional(),
5349
5637
  credentialScheme: AppCredentialSchemeSchema.optional(),
5350
- mcpUrl: string().url().nullable().optional(),
5638
+ url: string().url().nullable().optional(),
5351
5639
  createdAt: string().min(1),
5352
5640
  updatedAt: string().min(1)
5353
5641
  });
@@ -5366,8 +5654,8 @@ object({
5366
5654
  credentialFields: AppCredentialFieldsSchema.optional(),
5367
5655
  /** Composio auth scheme when credentialFields are present. */
5368
5656
  credentialScheme: AppCredentialSchemeSchema.optional(),
5369
- /** Direct MCP server URL when source is mcp. */
5370
- mcpUrl: string().url().nullable().optional(),
5657
+ /** Endpoint URL for MCP, OpenAPI, or GraphQL custom apps. */
5658
+ url: string().url().nullable().optional(),
5371
5659
  /** When present, the app supports agent gateway bindings (external channels). */
5372
5660
  gateway: AppGatewaySchema.optional()
5373
5661
  });
@@ -5401,7 +5689,7 @@ object({
5401
5689
  credentialFields: record(string(), AppCredentialFieldSchema).optional(),
5402
5690
  credentialScheme: AppCredentialSchemeSchema.optional(),
5403
5691
  oauthScopes: array(OAuthScopeOptionSchema),
5404
- mcpUrl: string().url(),
5692
+ url: string().url(),
5405
5693
  oauth: McpAuthProbeOAuthSchema.optional(),
5406
5694
  serverName: string().optional(),
5407
5695
  serverDescription: string().optional()
@@ -5425,7 +5713,21 @@ object({
5425
5713
  credentialFields: record(string(), AppCredentialFieldSchema).optional(),
5426
5714
  credentialScheme: AppCredentialSchemeSchema.optional(),
5427
5715
  oauthScopes: array(OAuthScopeOptionSchema),
5428
- openapiUrl: string().url(),
5716
+ url: string().url(),
5717
+ name: string().optional(),
5718
+ description: string().optional(),
5719
+ homepageUrl: string().optional()
5720
+ })
5721
+ });
5722
+ object({ url: string().url() });
5723
+ object({
5724
+ detected: boolean(),
5725
+ template: object({
5726
+ authKind: AppAuthKindSchema,
5727
+ credentialFields: record(string(), AppCredentialFieldSchema).optional(),
5728
+ credentialScheme: AppCredentialSchemeSchema.optional(),
5729
+ oauthScopes: array(OAuthScopeOptionSchema),
5730
+ url: string().url(),
5429
5731
  name: string().optional(),
5430
5732
  description: string().optional(),
5431
5733
  homepageUrl: string().optional()
@@ -5463,24 +5765,6 @@ object({
5463
5765
  outputParameters: record(string(), unknown()).optional(),
5464
5766
  version: string().optional()
5465
5767
  });
5466
- /** How a credential instance is stored (`credential_instances.auth_kind`). */
5467
- const CredentialAuthKindSchema = _enum([
5468
- "api_key",
5469
- "oauth_managed",
5470
- "keystroke"
5471
- ]);
5472
- /**
5473
- * Where a credential instance is stored (`credential_instances.scope_type`), and the only thing an
5474
- * action/tool can pin via `.scope(...)`. There is no resolution chain: when no scope is pinned, the
5475
- * resolver tries the project default, then the org default, then throws.
5476
- */
5477
- const CredentialScopeTypeSchema = _enum([
5478
- "organization",
5479
- "project",
5480
- "user"
5481
- ]);
5482
- CredentialAuthKindSchema.options;
5483
- CredentialScopeTypeSchema.options;
5484
5768
  /** Scope of a platform app credential (maps to `credential_instances.scope_type`). */
5485
5769
  const AppCredentialScopeSchema = _enum([
5486
5770
  "user",
@@ -5687,6 +5971,7 @@ object({
5687
5971
  /** Honeypot — must stay empty; bots that fill it are ignored silently. */
5688
5972
  companyWebsite: string().optional()
5689
5973
  });
5974
+ object({ models: array(string()) });
5690
5975
  const ValidationErrorDetailSchema = object({
5691
5976
  path: string(),
5692
5977
  message: string()
@@ -5700,6 +5985,43 @@ object({
5700
5985
  details: array(ValidationErrorDetailSchema).optional()
5701
5986
  });
5702
5987
  object({ message: string() });
5988
+ const CHAT_ATTACHMENT_MAX_BYTES = 10 * 1024 * 1024;
5989
+ [
5990
+ {
5991
+ mediaType: "image/png",
5992
+ ext: "png"
5993
+ },
5994
+ {
5995
+ mediaType: "image/jpeg",
5996
+ ext: "jpg"
5997
+ },
5998
+ {
5999
+ mediaType: "image/webp",
6000
+ ext: "webp"
6001
+ },
6002
+ {
6003
+ mediaType: "image/gif",
6004
+ ext: "gif"
6005
+ },
6006
+ {
6007
+ mediaType: "application/pdf",
6008
+ ext: "pdf"
6009
+ }
6010
+ ].map((type) => type.mediaType);
6011
+ const ChatAttachmentInputSchema = object({
6012
+ storageKey: string().min(1),
6013
+ mediaType: string().min(1),
6014
+ filename: string().optional()
6015
+ });
6016
+ object({
6017
+ contentType: string().min(1),
6018
+ filename: string().min(1),
6019
+ size: number$1().int().positive().max(CHAT_ATTACHMENT_MAX_BYTES)
6020
+ });
6021
+ object({
6022
+ uploadUrl: string().url(),
6023
+ storageKey: string().min(1)
6024
+ });
5703
6025
  const CredentialRunContextSchema = object({
5704
6026
  orgId: string().min(1).optional(),
5705
6027
  projectId: string().min(1).optional(),
@@ -5708,7 +6030,8 @@ const CredentialRunContextSchema = object({
5708
6030
  selection: record(string(), string()).optional()
5709
6031
  });
5710
6032
  const ThinkingLevelSchema = _enum([
5711
- "off",
6033
+ "provider-default",
6034
+ "none",
5712
6035
  "minimal",
5713
6036
  "low",
5714
6037
  "medium",
@@ -5716,15 +6039,17 @@ const ThinkingLevelSchema = _enum([
5716
6039
  "xhigh"
5717
6040
  ]);
5718
6041
  object({
5719
- message: string().min(1),
6042
+ message: string(),
5720
6043
  sessionId: string().min(1).optional(),
5721
6044
  subscriptionId: string().min(1).optional(),
5722
6045
  context: CredentialRunContextSchema.optional(),
5723
- thinkingLevel: ThinkingLevelSchema.optional()
5724
- });
6046
+ thinkingLevel: ThinkingLevelSchema.optional(),
6047
+ files: array(ChatAttachmentInputSchema).max(5).optional()
6048
+ }).refine((data) => data.message.trim().length > 0 || (data.files?.length ?? 0) > 0, { message: "message or files is required" });
5725
6049
  object({
5726
6050
  sessionId: string(),
5727
6051
  messages: array(record(string(), unknown())),
6052
+ text: string(),
5728
6053
  error: string().nullable()
5729
6054
  });
5730
6055
  const SkipResponseSchema = object({
@@ -5949,6 +6274,14 @@ object({
5949
6274
  steps: array(WorkflowStepRunSchema),
5950
6275
  trace: TraceResponseSchema.nullable()
5951
6276
  });
6277
+ const WorkflowHookStatusSchema = _enum(["waiting", "resumed"]);
6278
+ object({ items: array(object({
6279
+ token: string(),
6280
+ correlationId: string(),
6281
+ status: WorkflowHookStatusSchema,
6282
+ createdAt: string(),
6283
+ resumeUrl: string().nullable()
6284
+ })) });
5952
6285
  const AgentSessionStatusSchema = _enum([
5953
6286
  "running",
5954
6287
  "completed",
@@ -6427,7 +6760,7 @@ object({
6427
6760
  id: string(),
6428
6761
  slug: string(),
6429
6762
  name: string(),
6430
- description: string().nullable(),
6763
+ description: string().min(1),
6431
6764
  type: TriggerTypeSchema,
6432
6765
  status: TriggerStatusSchema,
6433
6766
  projectId: string(),
@@ -6723,9 +7056,13 @@ const AgentSummarySchema = object({
6723
7056
  name: string().min(1),
6724
7057
  projectId: string().min(1),
6725
7058
  updatedAt: string().min(1),
6726
- description: string().optional(),
7059
+ description: string().min(1),
6727
7060
  sourcePath: string().min(1).optional(),
6728
7061
  model: string().optional(),
7062
+ capabilities: object({
7063
+ images: boolean(),
7064
+ files: boolean()
7065
+ }).optional(),
6729
7066
  systemPrompt: string().optional(),
6730
7067
  toolCount: optionalCount,
6731
7068
  credentialCount: optionalCount,
@@ -6741,7 +7078,7 @@ const WorkflowSummarySchema = object({
6741
7078
  name: string().min(1),
6742
7079
  projectId: string().min(1),
6743
7080
  updatedAt: string().min(1),
6744
- description: string().optional(),
7081
+ description: string().min(1),
6745
7082
  sourcePath: string().min(1).optional(),
6746
7083
  lastRunAt: optionalTimestamp
6747
7084
  });
@@ -6751,7 +7088,7 @@ const SkillSummarySchema = object({
6751
7088
  name: string().min(1),
6752
7089
  projectId: string().min(1),
6753
7090
  updatedAt: string().min(1),
6754
- description: string().optional(),
7091
+ description: string().min(1),
6755
7092
  sourcePath: string().min(1).optional()
6756
7093
  });
6757
7094
  AgentSummarySchema.nullable();
@@ -6838,6 +7175,20 @@ object({
6838
7175
  })),
6839
7176
  generatedAt: isoDateTime
6840
7177
  });
7178
+ /** A single source file returned by the bulk active-source download endpoint. */
7179
+ const DownloadActiveProjectSourceFileSchema = object({
7180
+ path: string().min(1),
7181
+ contents: string()
7182
+ });
7183
+ object({
7184
+ artifactId: string(),
7185
+ files: array(DownloadActiveProjectSourceFileSchema)
7186
+ });
7187
+ object({
7188
+ projectId: string(),
7189
+ artifactId: string(),
7190
+ pulledAt: string().datetime()
7191
+ });
6841
7192
  object({ files: array(object({
6842
7193
  id: string(),
6843
7194
  path: string().min(1)
@@ -6846,6 +7197,245 @@ object({ files: array(object({
6846
7197
  id: string(),
6847
7198
  path: string().min(1)
6848
7199
  })) });
7200
+ /** Whether the overview is still being produced or finished. */
7201
+ const WorkflowOverviewStatusSchema = _enum(["generating", "ready"]);
7202
+ /** One phase of the guided-tour overview. */
7203
+ const WorkflowPhaseSchema = object({
7204
+ id: string(),
7205
+ title: string(),
7206
+ copy: string(),
7207
+ nodeIds: array(string())
7208
+ });
7209
+ object({
7210
+ status: WorkflowOverviewStatusSchema,
7211
+ summary: string(),
7212
+ phases: array(WorkflowPhaseSchema),
7213
+ hash: string(),
7214
+ generatedAt: string().nullable(),
7215
+ model: string()
7216
+ });
7217
+ /** Subset of JSON-Schema field types the dashboard form renders inline. */
7218
+ const WorkflowInputFieldTypeSchema = _enum([
7219
+ "string",
7220
+ "number",
7221
+ "boolean",
7222
+ "enum",
7223
+ "object",
7224
+ "array"
7225
+ ]);
7226
+ const WorkflowInputFieldSchema = lazy(() => object({
7227
+ key: string(),
7228
+ label: string(),
7229
+ type: WorkflowInputFieldTypeSchema,
7230
+ required: boolean(),
7231
+ description: string().optional(),
7232
+ placeholder: string().optional(),
7233
+ options: array(string()).optional(),
7234
+ default: union([
7235
+ string(),
7236
+ number$1(),
7237
+ boolean()
7238
+ ]).optional(),
7239
+ children: array(WorkflowInputFieldSchema).optional(),
7240
+ format: string().optional()
7241
+ }));
7242
+ object({
7243
+ schema: object({ fields: array(WorkflowInputFieldSchema) }),
7244
+ values: record(string(), unknown()).nullable()
7245
+ });
7246
+ object({ runId: string() });
7247
+ /** Annotation lifecycle: "generating" while the LLM pass streams in, then "ready". */
7248
+ const WorkflowCanvasStatusSchema = _enum(["generating", "ready"]);
7249
+ /** LLM-produced enrichment for a single skeleton node. */
7250
+ const WorkflowCanvasAnnotationSchema = object({
7251
+ label: string().optional(),
7252
+ description: string().optional()
7253
+ });
7254
+ /** The configured value of one input at this call site. */
7255
+ const WorkflowNodeInputBindingSchema = object({
7256
+ tokens: array(discriminatedUnion("kind", [
7257
+ object({
7258
+ kind: literal("text"),
7259
+ text: string()
7260
+ }),
7261
+ object({
7262
+ kind: literal("reference"),
7263
+ sourceNodeId: string().optional(),
7264
+ sourceLabel: string(),
7265
+ field: string().optional()
7266
+ }),
7267
+ object({
7268
+ kind: literal("variable"),
7269
+ text: string(),
7270
+ /** Concrete value when `text` resolves to a top-level literal constant. */
7271
+ resolvedValue: string().optional()
7272
+ }),
7273
+ object({
7274
+ kind: literal("call"),
7275
+ name: string()
7276
+ })
7277
+ ])),
7278
+ multiline: boolean().optional()
7279
+ });
7280
+ /** An inspector input with optional call-site binding. */
7281
+ const WorkflowCanvasNodeInputSchema = WorkflowInputFieldSchema.and(object({
7282
+ binding: WorkflowNodeInputBindingSchema.optional(),
7283
+ additional: boolean().optional()
7284
+ }));
7285
+ /** Authored, deterministic metadata for a single node. */
7286
+ const WorkflowCanvasNodeMetaSchema = object({
7287
+ kind: _enum([
7288
+ "action",
7289
+ "agent",
7290
+ "workflow",
7291
+ "llm",
7292
+ "trigger",
7293
+ "boundary"
7294
+ ]),
7295
+ slug: string(),
7296
+ name: string(),
7297
+ description: string().optional(),
7298
+ appSlug: string().optional(),
7299
+ inputs: array(WorkflowCanvasNodeInputSchema),
7300
+ outputs: array(WorkflowInputFieldSchema),
7301
+ requiredApps: array(string()).optional(),
7302
+ model: string().optional(),
7303
+ toolCount: number$1().int().nonnegative().optional()
7304
+ });
7305
+ object({
7306
+ graph: WorkflowCanvasGraphSchema,
7307
+ nodeMetadata: record(string(), WorkflowCanvasNodeMetaSchema),
7308
+ annotations: record(string(), WorkflowCanvasAnnotationSchema),
7309
+ status: WorkflowCanvasStatusSchema,
7310
+ hash: string(),
7311
+ generatedAt: string().nullable(),
7312
+ model: string()
7313
+ });
7314
+ const WorkflowCanvasNodeRunStateSchema = object({
7315
+ status: _enum([
7316
+ "pending",
7317
+ "running",
7318
+ "succeeded",
7319
+ "failed",
7320
+ "skipped"
7321
+ ]),
7322
+ iteration: object({
7323
+ index: number$1().int().nonnegative(),
7324
+ total: number$1().int().nonnegative()
7325
+ }).optional()
7326
+ });
7327
+ /** Overall lifecycle of a run as the canvas animates it. */
7328
+ const WorkflowCanvasRunStatusSchema = _enum([
7329
+ "running",
7330
+ "succeeded",
7331
+ "failed",
7332
+ "canceled"
7333
+ ]);
7334
+ object({
7335
+ runId: string(),
7336
+ status: WorkflowCanvasRunStatusSchema,
7337
+ startedAt: string(),
7338
+ finishedAt: string().nullable(),
7339
+ nodeStates: record(string(), WorkflowCanvasNodeRunStateSchema)
7340
+ });
7341
+ /** Scope a credential instance lives in. */
7342
+ const WorkflowCredentialScopeSchema = _enum([
7343
+ "organization",
7344
+ "project",
7345
+ "user"
7346
+ ]);
7347
+ /** The concrete credential instance a binding currently resolves to. */
7348
+ const WorkflowResolvedCredentialSchema = object({
7349
+ id: string(),
7350
+ name: string(),
7351
+ scope: WorkflowCredentialScopeSchema,
7352
+ appSlug: string().optional(),
7353
+ isDefault: boolean().optional(),
7354
+ projectId: string().optional(),
7355
+ projectName: string().optional()
7356
+ });
7357
+ record(string(), WorkflowCanvasAnnotationSchema);
7358
+ /** One opaque code-block the annotation pass should label, keyed by its canvas node id. */
7359
+ const WorkflowCanvasAnnotationCodeBlockSchema = object({
7360
+ nodeId: string(),
7361
+ /** The raw source snippet (the node's label) the LLM turns into human copy. */
7362
+ source: string()
7363
+ });
7364
+ /** Inputs the worker feeds the LLM for the gated code-block annotation pass. */
7365
+ const WorkflowCanvasAnnotationsInputSchema = object({
7366
+ workflowName: string(),
7367
+ workflowDescription: string().nullable(),
7368
+ codeBlocks: array(WorkflowCanvasAnnotationCodeBlockSchema)
7369
+ });
7370
+ object({
7371
+ workflowId: string(),
7372
+ projectId: string(),
7373
+ hash: string(),
7374
+ model: string(),
7375
+ input: WorkflowCanvasAnnotationsInputSchema
7376
+ });
7377
+ /** One node as the overview LLM sees it (derived from the canvas node metadata + graph). */
7378
+ const WorkflowOverviewNodeSchema = object({
7379
+ nodeId: string(),
7380
+ label: string(),
7381
+ kind: string(),
7382
+ description: string().optional(),
7383
+ /** App/integration slug for steps imported from a `@keystrokehq/<app>` package. */
7384
+ appSlug: string().optional(),
7385
+ /** Authored input field keys (from the action/agent/workflow definition). */
7386
+ inputs: array(string()).optional(),
7387
+ /** Authored output field keys. */
7388
+ outputs: array(string()).optional(),
7389
+ /** Agent-only: the model the agent runs on. */
7390
+ model: string().optional(),
7391
+ /** Agent-only: number of tools available to the agent. */
7392
+ toolCount: number$1().int().nonnegative().optional()
7393
+ });
7394
+ /** Inputs the worker feeds the LLM to produce the workflow overview (summary + phases). */
7395
+ const WorkflowOverviewInputSchema = object({
7396
+ workflowName: string(),
7397
+ workflowDescription: string().nullable(),
7398
+ /** Display labels of the trigger sources upstream of the workflow (read-only context). */
7399
+ triggers: array(string()),
7400
+ nodes: array(WorkflowOverviewNodeSchema),
7401
+ /** The workflow's TypeScript source (best-effort; null when the deploy has no source snapshot). */
7402
+ source: string().nullable()
7403
+ });
7404
+ object({
7405
+ workflowId: string(),
7406
+ projectId: string(),
7407
+ hash: string(),
7408
+ model: string(),
7409
+ input: WorkflowOverviewInputSchema
7410
+ });
7411
+ const WorkflowCanvasCredentialBindingBaseSchema = object({
7412
+ credentialKey: string(),
7413
+ label: string(),
7414
+ appSlug: string().optional()
7415
+ });
7416
+ /** How one credential requirement on a step currently resolves. */
7417
+ const WorkflowCanvasCredentialBindingSchema = union([
7418
+ WorkflowCanvasCredentialBindingBaseSchema.extend({
7419
+ policy: _enum([
7420
+ "project-default",
7421
+ "org-default",
7422
+ "assigned"
7423
+ ]),
7424
+ instance: WorkflowResolvedCredentialSchema
7425
+ }),
7426
+ WorkflowCanvasCredentialBindingBaseSchema.extend({
7427
+ policy: literal("scope-pinned"),
7428
+ pinnedScope: WorkflowCredentialScopeSchema,
7429
+ instance: WorkflowResolvedCredentialSchema
7430
+ }),
7431
+ WorkflowCanvasCredentialBindingBaseSchema.extend({
7432
+ policy: literal("unresolved"),
7433
+ reason: _enum(["needs-selection", "missing"]),
7434
+ pinnedScope: WorkflowCredentialScopeSchema.optional()
7435
+ })
7436
+ ]);
7437
+ record(string(), array(WorkflowCanvasCredentialBindingSchema));
7438
+ record(string(), unknown());
6849
7439
  //#endregion
6850
7440
  //#region src/runtime.ts
6851
7441
  /** Builds base64 `KEYSTROKE_ORG_ARTIFACTS` payload for org worker containers. */