@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.mjs CHANGED
@@ -2275,6 +2275,21 @@ function handleReadonlyResult(payload) {
2275
2275
  payload.value = Object.freeze(payload.value);
2276
2276
  return payload;
2277
2277
  }
2278
+ const $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
2279
+ $ZodType.init(inst, def);
2280
+ defineLazy(inst._zod, "innerType", () => {
2281
+ const d = def;
2282
+ if (!d._cachedInner) d._cachedInner = def.getter();
2283
+ return d._cachedInner;
2284
+ });
2285
+ defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
2286
+ defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
2287
+ defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? void 0);
2288
+ defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? void 0);
2289
+ inst._zod.parse = (payload, ctx) => {
2290
+ return inst._zod.innerType._zod.run(payload, ctx);
2291
+ };
2292
+ });
2278
2293
  const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
2279
2294
  $ZodCheck.init(inst, def);
2280
2295
  $ZodType.init(inst, def);
@@ -3417,6 +3432,12 @@ const optionalProcessor = (schema, ctx, _json, params) => {
3417
3432
  const seen = ctx.seen.get(schema);
3418
3433
  seen.ref = def.innerType;
3419
3434
  };
3435
+ const lazyProcessor = (schema, ctx, _json, params) => {
3436
+ const innerType = schema._zod.innerType;
3437
+ process$1(innerType, ctx, params);
3438
+ const seen = ctx.seen.get(schema);
3439
+ seen.ref = innerType;
3440
+ };
3420
3441
  //#endregion
3421
3442
  //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
3422
3443
  const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
@@ -4280,6 +4301,18 @@ function readonly(innerType) {
4280
4301
  innerType
4281
4302
  });
4282
4303
  }
4304
+ const ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
4305
+ $ZodLazy.init(inst, def);
4306
+ ZodType.init(inst, def);
4307
+ inst._zod.processJSONSchema = (ctx, json, params) => lazyProcessor(inst, ctx, json, params);
4308
+ inst.unwrap = () => inst._zod.def.getter();
4309
+ });
4310
+ function lazy(getter) {
4311
+ return new ZodLazy({
4312
+ type: "lazy",
4313
+ getter
4314
+ });
4315
+ }
4283
4316
  const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
4284
4317
  $ZodCustom.init(inst, def);
4285
4318
  ZodType.init(inst, def);
@@ -4955,10 +4988,244 @@ const AppSlugSchema = ProjectSlugSchema;
4955
4988
  function resolveExplicitPublicPlatformOrigin(env = process.env) {
4956
4989
  return env.PUBLIC_PLATFORM_URL?.replace(/\/$/, "") || void 0;
4957
4990
  }
4991
+ /** How a credential instance is stored (`credential_instances.auth_kind`). */
4992
+ const CredentialAuthKindSchema = _enum([
4993
+ "api_key",
4994
+ "oauth_managed",
4995
+ "keystroke"
4996
+ ]);
4997
+ /**
4998
+ * Where a credential instance is stored (`credential_instances.scope_type`), and the only thing an
4999
+ * action/tool can pin via `.scope(...)`. There is no resolution chain: when no scope is pinned, the
5000
+ * resolver tries the project default, then the org default, then throws.
5001
+ */
5002
+ const CredentialScopeTypeSchema = _enum([
5003
+ "organization",
5004
+ "project",
5005
+ "user"
5006
+ ]);
5007
+ CredentialAuthKindSchema.options;
5008
+ CredentialScopeTypeSchema.options;
5009
+ /** Non-empty human-readable label or description (trimmed). */
5010
+ const requiredDisplayTextSchema = string().trim().min(1);
5011
+ /**
5012
+ * Structural workflow-canvas graph contract.
5013
+ *
5014
+ * This is the deterministic skeleton the deploy-time AST producer emits for a
5015
+ * workflow (nodes + edges), plus the manifest-derived trigger-source nodes. It
5016
+ * is the single source of truth shared by:
5017
+ * - the AST producer (emits it at deploy, stored with the manifest),
5018
+ * - the platform route that serves the canvas, and
5019
+ * - the SDK / web client that renders it (React Flow).
5020
+ *
5021
+ * Only the structural skeleton lives here. The LLM enrichment + run-overlay
5022
+ * envelope types live in `workflow-canvas-envelope.ts`; the SDK re-exports them.
5023
+ * See WORKFLOW.md (§4 grammar, §8 node ids, §9 caching).
5024
+ */
5025
+ /**
5026
+ * Canvas node taxonomy — the single discriminator for every canvas node. The
5027
+ * client derives the React Flow component, icon, and per-node treatment from it
5028
+ * (no parallel `type` / `data.kind` fields), and the producer + fixtures emit it
5029
+ * directly, so the structural contract can never silently diverge across the
5030
+ * deploy → render boundary.
5031
+ * - Boundaries: `entry` (Start, owns input) · `exit` (Output, owns output) ·
5032
+ * `error` (a terminal `throw` — an error output that ends the run on a branch)
5033
+ * - Callable: `step` (action / agent / llm / hook / child-workflow invocation) —
5034
+ * the invocation flavor lives in {@link WorkflowCanvasCallKind}
5035
+ * - Structural control flow: `code-block` · `decision` · `merge` · `loop` ·
5036
+ * `parallel` (group containers) · `loop-start` (the group body's entry marker,
5037
+ * shared by loop + parallel)
5038
+ * - Upstream of entry: `trigger-source` (one per manifest trigger attachment)
5039
+ *
5040
+ * `Promise.all([...])` is modeled as a `parallel` group container: the branches
5041
+ * are stacked inside and the container itself is the single prong leaving the
5042
+ * wrapper (there is no separate fork/join pair).
5043
+ *
5044
+ * `exit` and `error` are both terminals: a `return` flows to the shared `exit`
5045
+ * (the workflow output), while a `throw` gets its own `error` terminal off the
5046
+ * branch so guard clauses (`if (bad) throw …`) read as a visible dead-end.
5047
+ */
5048
+ const WorkflowCanvasNodeTypeSchema = _enum([
5049
+ "entry",
5050
+ "exit",
5051
+ "error",
5052
+ "step",
5053
+ "code-block",
5054
+ "decision",
5055
+ "merge",
5056
+ "loop",
5057
+ "parallel",
5058
+ "loop-start",
5059
+ "trigger-source"
5060
+ ]);
5061
+ _enum([
5062
+ "workflow-step",
5063
+ "agent",
5064
+ "llm",
5065
+ "wait",
5066
+ "hook",
5067
+ "tool",
5068
+ "child-workflow"
5069
+ ]);
5070
+ /** A labeled branch output on a decision-style node. */
5071
+ const WorkflowCanvasNodeOutputSchema = object({
5072
+ id: string(),
5073
+ label: string()
5074
+ });
5075
+ /**
5076
+ * A step input's configured value at its call site, captured deterministically
5077
+ * by the producer from the call's argument object. The platform join turns this
5078
+ * into the inspector's {@link WorkflowNodeInputBinding} (filling display labels).
5079
+ */
5080
+ const WorkflowCanvasRawBindingSchema = object({
5081
+ tokens: array(discriminatedUnion("kind", [
5082
+ object({
5083
+ kind: literal("text"),
5084
+ text: string()
5085
+ }),
5086
+ object({
5087
+ kind: literal("reference"),
5088
+ /** Upstream node id this value flows from; absent only for unresolved refs. */
5089
+ sourceNodeId: string().optional(),
5090
+ /** Output field of the source (dotted path); omitted = the whole output. */
5091
+ field: string().optional()
5092
+ }),
5093
+ object({
5094
+ kind: literal("variable"),
5095
+ text: string()
5096
+ }),
5097
+ object({
5098
+ kind: literal("call"),
5099
+ name: string()
5100
+ })
5101
+ ])),
5102
+ /** Render as a tall multi-line box (object/array/multiline template values). */
5103
+ multiline: boolean().optional()
5104
+ });
5105
+ /**
5106
+ * Statically-captured `promptLlm` options for an `llm` step node. Literal-only:
5107
+ * dynamic/expression values (a computed model, a `system` built by a function) are
5108
+ * not captured; `system`/`outputSchema` record presence so the inspector can note
5109
+ * "a system prompt is configured" / "structured output" without their values.
5110
+ */
5111
+ const WorkflowCanvasLlmOptionsSchema = object({
5112
+ model: string().optional(),
5113
+ maxTokens: number$1().optional(),
5114
+ temperature: number$1().optional(),
5115
+ thinkingLevel: string().optional(),
5116
+ hasSystemPrompt: boolean().optional(),
5117
+ hasOutputSchema: boolean().optional()
5118
+ });
5119
+ const WorkflowCanvasNodeDataSchema = object({
5120
+ label: string(),
5121
+ /** Set on group nodes (loop / parallel section containers). */
5122
+ groupKind: _enum([
5123
+ "loop",
5124
+ "parallel",
5125
+ "conditional"
5126
+ ]).optional(),
5127
+ description: string().optional(),
5128
+ /** {@link WorkflowCanvasCallKind} or a looser raw call-site label. */
5129
+ callKind: string().optional(),
5130
+ /**
5131
+ * App/integration slug for a `step` whose action/agent is imported directly
5132
+ * from a `@keystrokehq/<app>` package (e.g. "slack", "apollo"). Lets the client
5133
+ * badge the node with that app's logo; absent for custom (project-local)
5134
+ * actions, which fall back to the call-kind icon.
5135
+ */
5136
+ appSlug: string().optional(),
5137
+ /** Cron/webhook/poll discriminator on trigger-source nodes. */
5138
+ triggerType: string().optional(),
5139
+ /** Branch outputs (decision nodes). */
5140
+ outputs: array(WorkflowCanvasNodeOutputSchema).optional(),
5141
+ /**
5142
+ * Action/agent/workflow slug resolved at deploy time (via import → definition).
5143
+ * Optional when the deploy build cannot resolve source (dist-only artifacts).
5144
+ */
5145
+ slug: string().optional(),
5146
+ /**
5147
+ * Durable call-site ids nested inside an off-grammar `code-block` (same-file only).
5148
+ * Used by the run overlay to light the block when any contained step executes.
5149
+ */
5150
+ containedCallSiteIds: array(string()).optional(),
5151
+ /**
5152
+ * Per-input call-site value bindings for `step` nodes, keyed by input field name.
5153
+ * Deterministically captured from the call's argument object; reference tokens point
5154
+ * at the upstream node that produced the value. The platform join fills display labels.
5155
+ */
5156
+ inputBindings: record(string(), WorkflowCanvasRawBindingSchema).optional(),
5157
+ /**
5158
+ * Static `promptLlm(prompt, options)` configuration captured at the call site for
5159
+ * `llm` step nodes. Only literal values are captured (model/maxTokens/temperature/
5160
+ * thinkingLevel); `system`/`outputSchema` are usually expressions, so only their
5161
+ * presence is recorded. Absent when no options are statically resolvable.
5162
+ */
5163
+ llmOptions: WorkflowCanvasLlmOptionsSchema.optional()
5164
+ });
5165
+ /**
5166
+ * A single structural node. This is the deploy artifact's shape: identity
5167
+ * (`id`), the canonical discriminator (`nodeType`), display `data`, and group
5168
+ * nesting (`parentId`). All layout/rendering — React Flow component key,
5169
+ * positions, sizes, `extent`, group box dimensions — is derived entirely
5170
+ * client-side from this structure, so it never leaks into the wire contract.
5171
+ */
5172
+ const WorkflowCanvasGraphNodeSchema = object({
5173
+ id: string(),
5174
+ nodeType: WorkflowCanvasNodeTypeSchema,
5175
+ data: WorkflowCanvasNodeDataSchema,
5176
+ /** Set on children nested inside a group (loop / parallel) container. */
5177
+ parentId: string().optional()
5178
+ });
5179
+ const WorkflowCanvasEdgeSchema = object({
5180
+ id: string(),
5181
+ source: string(),
5182
+ target: string(),
5183
+ type: string().optional(),
5184
+ label: string().optional(),
5185
+ sourceHandle: string().optional(),
5186
+ targetHandle: string().optional(),
5187
+ data: object({ branchKind: _enum([
5188
+ "then",
5189
+ "else",
5190
+ "parallel-branch",
5191
+ "error"
5192
+ ]).optional() }).optional()
5193
+ });
5194
+ /** A statically-evaluable top-level `const` value (literal scalars only). */
5195
+ const WorkflowCanvasConstantValueSchema = union([
5196
+ string(),
5197
+ number$1(),
5198
+ boolean()
5199
+ ]);
5200
+ /**
5201
+ * Top-level `const NAME = <literal>` declarations in the workflow source, captured
5202
+ * at deploy. Lets the platform resolve `variable` value tokens (e.g. a `model` set
5203
+ * to a named const) to their concrete value for display. Scalars only — computed,
5204
+ * function-local, or non-literal consts are intentionally omitted.
5205
+ */
5206
+ const WorkflowCanvasConstantsSchema = record(string(), WorkflowCanvasConstantValueSchema);
5207
+ const WorkflowCanvasGraphSchema = object({
5208
+ nodes: array(WorkflowCanvasGraphNodeSchema),
5209
+ edges: array(WorkflowCanvasEdgeSchema),
5210
+ /** Top-level literal constants from the workflow source (for value-token resolution). */
5211
+ constants: WorkflowCanvasConstantsSchema.optional()
5212
+ });
5213
+ /**
5214
+ * Deploy-time summary of one credential a step requires, derived from the
5215
+ * action/agent-tool definition's `.credentials`. The workflow-canvas credential
5216
+ * overlay joins a step node's `slug` to these to resolve the bound instance.
5217
+ * `key` doubles as the app slug (matches `credential_instances.app_slug`).
5218
+ */
5219
+ const CredentialRequirementSummarySchema = object({
5220
+ key: string(),
5221
+ kind: CredentialAuthKindSchema,
5222
+ /** Scope pinned via `.scope(...)`; absent means project-default → org-default. */
5223
+ scope: CredentialScopeTypeSchema.optional()
5224
+ });
4958
5225
  const StoredRouteManifestSkillSchema = object({
4959
5226
  slug: string(),
4960
- name: string().optional(),
4961
- description: string().optional(),
5227
+ name: requiredDisplayTextSchema,
5228
+ description: requiredDisplayTextSchema,
4962
5229
  moduleFile: string()
4963
5230
  });
4964
5231
  const attachmentSchemasSchema = record(string(), object({
@@ -4966,8 +5233,8 @@ const attachmentSchemasSchema = record(string(), object({
4966
5233
  filterSchema: record(string(), unknown()).optional()
4967
5234
  }));
4968
5235
  const attachmentMetaSchema = record(string(), object({
4969
- name: string().optional(),
4970
- description: string().optional()
5236
+ name: requiredDisplayTextSchema,
5237
+ description: requiredDisplayTextSchema
4971
5238
  }));
4972
5239
  const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
4973
5240
  object({ kind: literal("health") }),
@@ -4975,23 +5242,43 @@ const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
4975
5242
  kind: literal("agent"),
4976
5243
  slug: string(),
4977
5244
  moduleFile: string(),
4978
- name: string().optional(),
4979
- description: string().optional(),
5245
+ name: requiredDisplayTextSchema,
5246
+ description: requiredDisplayTextSchema,
4980
5247
  model: string(),
4981
5248
  systemPrompt: string(),
4982
5249
  toolCount: number$1().int().nonnegative(),
4983
5250
  credentialCount: number$1().int().nonnegative(),
4984
5251
  appSlugs: array(string()).default([]),
4985
- toolSlugs: array(string()).default([])
5252
+ toolSlugs: array(string()).default([]),
5253
+ /** Credential requirements per tool slug (the agent's credential consumer key). */
5254
+ toolRequirements: record(string(), array(CredentialRequirementSummarySchema)).optional()
5255
+ }),
5256
+ object({
5257
+ kind: literal("action"),
5258
+ slug: string(),
5259
+ name: requiredDisplayTextSchema,
5260
+ description: requiredDisplayTextSchema,
5261
+ moduleFile: string(),
5262
+ /** App slug for actions imported from an integration package (`@keystrokehq/<app>/actions`). */
5263
+ appSlug: string().optional(),
5264
+ inputSchema: record(string(), unknown()),
5265
+ outputSchema: record(string(), unknown()),
5266
+ /** Credentials this action requires (for the canvas credential overlay). */
5267
+ requirements: array(CredentialRequirementSummarySchema).optional()
4986
5268
  }),
4987
5269
  object({
4988
5270
  kind: literal("workflow"),
4989
5271
  slug: string(),
4990
- name: string().optional(),
4991
- description: string().optional(),
5272
+ name: requiredDisplayTextSchema,
5273
+ description: requiredDisplayTextSchema,
4992
5274
  subscribable: boolean(),
4993
5275
  moduleFile: string(),
4994
- requestSchema: record(string(), unknown())
5276
+ requestSchema: record(string(), unknown()),
5277
+ responseSchema: record(string(), unknown()).optional(),
5278
+ /** Deterministic AST control-flow skeleton (deploy-time producer). */
5279
+ flowGraph: WorkflowCanvasGraphSchema.optional(),
5280
+ /** sha256 of the workflow source the `flowGraph` was produced from (staleness). */
5281
+ flowGraphSourceHash: string().optional()
4995
5282
  }),
4996
5283
  object({
4997
5284
  kind: literal("trigger-webhook"),
@@ -5010,8 +5297,8 @@ const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
5010
5297
  moduleFile: string(),
5011
5298
  sourceHash: string().optional(),
5012
5299
  schedule: string(),
5013
- name: string().optional(),
5014
- description: string().optional()
5300
+ name: requiredDisplayTextSchema,
5301
+ description: requiredDisplayTextSchema
5015
5302
  }),
5016
5303
  object({
5017
5304
  kind: literal("trigger-poll-group"),
@@ -5027,8 +5314,8 @@ const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
5027
5314
  moduleFile: string(),
5028
5315
  sourceHash: string().optional(),
5029
5316
  schedule: string(),
5030
- name: string().optional(),
5031
- description: string().optional()
5317
+ name: requiredDisplayTextSchema,
5318
+ description: requiredDisplayTextSchema
5032
5319
  })
5033
5320
  ]);
5034
5321
  object({
@@ -5266,18 +5553,19 @@ object({
5266
5553
  source: _enum([
5267
5554
  "custom",
5268
5555
  "mcp",
5269
- "openapi"
5556
+ "openapi",
5557
+ "graphql"
5270
5558
  ]).default("custom"),
5271
- mcpUrl: string().url().optional(),
5559
+ url: string().url().optional(),
5272
5560
  authKind: AppAuthKindSchema.optional(),
5273
5561
  fields: optionalCredentialFieldsSchema.optional(),
5274
5562
  credentialScheme: AppCredentialSchemeSchema.optional(),
5275
5563
  oauthScopes: array(OAuthScopeOptionSchema).optional()
5276
5564
  }).superRefine((data, ctx) => {
5277
- if (data.source === "mcp" && !data.mcpUrl) ctx.addIssue({
5565
+ if ((data.source === "mcp" || data.source === "openapi" || data.source === "graphql") && !data.url) ctx.addIssue({
5278
5566
  code: "custom",
5279
- message: "mcpUrl is required for MCP apps",
5280
- path: ["mcpUrl"]
5567
+ message: "url is required for this app source",
5568
+ path: ["url"]
5281
5569
  });
5282
5570
  if (!(data.authKind ?? (data.source === "custom" ? "api_key" : void 0))) {
5283
5571
  ctx.addIssue({
@@ -5303,7 +5591,7 @@ object({
5303
5591
  category: string().min(1),
5304
5592
  authKind: AppAuthKindSchema,
5305
5593
  source: AppSourceSchema,
5306
- mcpUrl: string().url().nullable().optional(),
5594
+ url: string().url().nullable().optional(),
5307
5595
  credentialFields: optionalCredentialFieldsSchema.optional(),
5308
5596
  credentialScheme: AppCredentialSchemeSchema.optional(),
5309
5597
  oauthScopes: array(OAuthScopeOptionSchema).optional(),
@@ -5323,7 +5611,7 @@ object({
5323
5611
  source: AppSourceSchema,
5324
5612
  credentialFields: AppCredentialFieldsSchema.optional(),
5325
5613
  credentialScheme: AppCredentialSchemeSchema.optional(),
5326
- mcpUrl: string().url().nullable().optional(),
5614
+ url: string().url().nullable().optional(),
5327
5615
  createdAt: string().min(1),
5328
5616
  updatedAt: string().min(1)
5329
5617
  });
@@ -5342,8 +5630,8 @@ object({
5342
5630
  credentialFields: AppCredentialFieldsSchema.optional(),
5343
5631
  /** Composio auth scheme when credentialFields are present. */
5344
5632
  credentialScheme: AppCredentialSchemeSchema.optional(),
5345
- /** Direct MCP server URL when source is mcp. */
5346
- mcpUrl: string().url().nullable().optional(),
5633
+ /** Endpoint URL for MCP, OpenAPI, or GraphQL custom apps. */
5634
+ url: string().url().nullable().optional(),
5347
5635
  /** When present, the app supports agent gateway bindings (external channels). */
5348
5636
  gateway: AppGatewaySchema.optional()
5349
5637
  });
@@ -5377,7 +5665,7 @@ object({
5377
5665
  credentialFields: record(string(), AppCredentialFieldSchema).optional(),
5378
5666
  credentialScheme: AppCredentialSchemeSchema.optional(),
5379
5667
  oauthScopes: array(OAuthScopeOptionSchema),
5380
- mcpUrl: string().url(),
5668
+ url: string().url(),
5381
5669
  oauth: McpAuthProbeOAuthSchema.optional(),
5382
5670
  serverName: string().optional(),
5383
5671
  serverDescription: string().optional()
@@ -5401,7 +5689,21 @@ object({
5401
5689
  credentialFields: record(string(), AppCredentialFieldSchema).optional(),
5402
5690
  credentialScheme: AppCredentialSchemeSchema.optional(),
5403
5691
  oauthScopes: array(OAuthScopeOptionSchema),
5404
- openapiUrl: string().url(),
5692
+ url: string().url(),
5693
+ name: string().optional(),
5694
+ description: string().optional(),
5695
+ homepageUrl: string().optional()
5696
+ })
5697
+ });
5698
+ object({ url: string().url() });
5699
+ object({
5700
+ detected: boolean(),
5701
+ template: object({
5702
+ authKind: AppAuthKindSchema,
5703
+ credentialFields: record(string(), AppCredentialFieldSchema).optional(),
5704
+ credentialScheme: AppCredentialSchemeSchema.optional(),
5705
+ oauthScopes: array(OAuthScopeOptionSchema),
5706
+ url: string().url(),
5405
5707
  name: string().optional(),
5406
5708
  description: string().optional(),
5407
5709
  homepageUrl: string().optional()
@@ -5439,24 +5741,6 @@ object({
5439
5741
  outputParameters: record(string(), unknown()).optional(),
5440
5742
  version: string().optional()
5441
5743
  });
5442
- /** How a credential instance is stored (`credential_instances.auth_kind`). */
5443
- const CredentialAuthKindSchema = _enum([
5444
- "api_key",
5445
- "oauth_managed",
5446
- "keystroke"
5447
- ]);
5448
- /**
5449
- * Where a credential instance is stored (`credential_instances.scope_type`), and the only thing an
5450
- * action/tool can pin via `.scope(...)`. There is no resolution chain: when no scope is pinned, the
5451
- * resolver tries the project default, then the org default, then throws.
5452
- */
5453
- const CredentialScopeTypeSchema = _enum([
5454
- "organization",
5455
- "project",
5456
- "user"
5457
- ]);
5458
- CredentialAuthKindSchema.options;
5459
- CredentialScopeTypeSchema.options;
5460
5744
  /** Scope of a platform app credential (maps to `credential_instances.scope_type`). */
5461
5745
  const AppCredentialScopeSchema = _enum([
5462
5746
  "user",
@@ -5663,6 +5947,7 @@ object({
5663
5947
  /** Honeypot — must stay empty; bots that fill it are ignored silently. */
5664
5948
  companyWebsite: string().optional()
5665
5949
  });
5950
+ object({ models: array(string()) });
5666
5951
  const ValidationErrorDetailSchema = object({
5667
5952
  path: string(),
5668
5953
  message: string()
@@ -5676,6 +5961,43 @@ object({
5676
5961
  details: array(ValidationErrorDetailSchema).optional()
5677
5962
  });
5678
5963
  object({ message: string() });
5964
+ const CHAT_ATTACHMENT_MAX_BYTES = 10 * 1024 * 1024;
5965
+ [
5966
+ {
5967
+ mediaType: "image/png",
5968
+ ext: "png"
5969
+ },
5970
+ {
5971
+ mediaType: "image/jpeg",
5972
+ ext: "jpg"
5973
+ },
5974
+ {
5975
+ mediaType: "image/webp",
5976
+ ext: "webp"
5977
+ },
5978
+ {
5979
+ mediaType: "image/gif",
5980
+ ext: "gif"
5981
+ },
5982
+ {
5983
+ mediaType: "application/pdf",
5984
+ ext: "pdf"
5985
+ }
5986
+ ].map((type) => type.mediaType);
5987
+ const ChatAttachmentInputSchema = object({
5988
+ storageKey: string().min(1),
5989
+ mediaType: string().min(1),
5990
+ filename: string().optional()
5991
+ });
5992
+ object({
5993
+ contentType: string().min(1),
5994
+ filename: string().min(1),
5995
+ size: number$1().int().positive().max(CHAT_ATTACHMENT_MAX_BYTES)
5996
+ });
5997
+ object({
5998
+ uploadUrl: string().url(),
5999
+ storageKey: string().min(1)
6000
+ });
5679
6001
  const CredentialRunContextSchema = object({
5680
6002
  orgId: string().min(1).optional(),
5681
6003
  projectId: string().min(1).optional(),
@@ -5684,7 +6006,8 @@ const CredentialRunContextSchema = object({
5684
6006
  selection: record(string(), string()).optional()
5685
6007
  });
5686
6008
  const ThinkingLevelSchema = _enum([
5687
- "off",
6009
+ "provider-default",
6010
+ "none",
5688
6011
  "minimal",
5689
6012
  "low",
5690
6013
  "medium",
@@ -5692,15 +6015,17 @@ const ThinkingLevelSchema = _enum([
5692
6015
  "xhigh"
5693
6016
  ]);
5694
6017
  object({
5695
- message: string().min(1),
6018
+ message: string(),
5696
6019
  sessionId: string().min(1).optional(),
5697
6020
  subscriptionId: string().min(1).optional(),
5698
6021
  context: CredentialRunContextSchema.optional(),
5699
- thinkingLevel: ThinkingLevelSchema.optional()
5700
- });
6022
+ thinkingLevel: ThinkingLevelSchema.optional(),
6023
+ files: array(ChatAttachmentInputSchema).max(5).optional()
6024
+ }).refine((data) => data.message.trim().length > 0 || (data.files?.length ?? 0) > 0, { message: "message or files is required" });
5701
6025
  object({
5702
6026
  sessionId: string(),
5703
6027
  messages: array(record(string(), unknown())),
6028
+ text: string(),
5704
6029
  error: string().nullable()
5705
6030
  });
5706
6031
  const SkipResponseSchema = object({
@@ -5925,6 +6250,14 @@ object({
5925
6250
  steps: array(WorkflowStepRunSchema),
5926
6251
  trace: TraceResponseSchema.nullable()
5927
6252
  });
6253
+ const WorkflowHookStatusSchema = _enum(["waiting", "resumed"]);
6254
+ object({ items: array(object({
6255
+ token: string(),
6256
+ correlationId: string(),
6257
+ status: WorkflowHookStatusSchema,
6258
+ createdAt: string(),
6259
+ resumeUrl: string().nullable()
6260
+ })) });
5928
6261
  const AgentSessionStatusSchema = _enum([
5929
6262
  "running",
5930
6263
  "completed",
@@ -6403,7 +6736,7 @@ object({
6403
6736
  id: string(),
6404
6737
  slug: string(),
6405
6738
  name: string(),
6406
- description: string().nullable(),
6739
+ description: string().min(1),
6407
6740
  type: TriggerTypeSchema,
6408
6741
  status: TriggerStatusSchema,
6409
6742
  projectId: string(),
@@ -6699,9 +7032,13 @@ const AgentSummarySchema = object({
6699
7032
  name: string().min(1),
6700
7033
  projectId: string().min(1),
6701
7034
  updatedAt: string().min(1),
6702
- description: string().optional(),
7035
+ description: string().min(1),
6703
7036
  sourcePath: string().min(1).optional(),
6704
7037
  model: string().optional(),
7038
+ capabilities: object({
7039
+ images: boolean(),
7040
+ files: boolean()
7041
+ }).optional(),
6705
7042
  systemPrompt: string().optional(),
6706
7043
  toolCount: optionalCount,
6707
7044
  credentialCount: optionalCount,
@@ -6717,7 +7054,7 @@ const WorkflowSummarySchema = object({
6717
7054
  name: string().min(1),
6718
7055
  projectId: string().min(1),
6719
7056
  updatedAt: string().min(1),
6720
- description: string().optional(),
7057
+ description: string().min(1),
6721
7058
  sourcePath: string().min(1).optional(),
6722
7059
  lastRunAt: optionalTimestamp
6723
7060
  });
@@ -6727,7 +7064,7 @@ const SkillSummarySchema = object({
6727
7064
  name: string().min(1),
6728
7065
  projectId: string().min(1),
6729
7066
  updatedAt: string().min(1),
6730
- description: string().optional(),
7067
+ description: string().min(1),
6731
7068
  sourcePath: string().min(1).optional()
6732
7069
  });
6733
7070
  AgentSummarySchema.nullable();
@@ -6814,6 +7151,20 @@ object({
6814
7151
  })),
6815
7152
  generatedAt: isoDateTime
6816
7153
  });
7154
+ /** A single source file returned by the bulk active-source download endpoint. */
7155
+ const DownloadActiveProjectSourceFileSchema = object({
7156
+ path: string().min(1),
7157
+ contents: string()
7158
+ });
7159
+ object({
7160
+ artifactId: string(),
7161
+ files: array(DownloadActiveProjectSourceFileSchema)
7162
+ });
7163
+ object({
7164
+ projectId: string(),
7165
+ artifactId: string(),
7166
+ pulledAt: string().datetime()
7167
+ });
6817
7168
  object({ files: array(object({
6818
7169
  id: string(),
6819
7170
  path: string().min(1)
@@ -6822,6 +7173,245 @@ object({ files: array(object({
6822
7173
  id: string(),
6823
7174
  path: string().min(1)
6824
7175
  })) });
7176
+ /** Whether the overview is still being produced or finished. */
7177
+ const WorkflowOverviewStatusSchema = _enum(["generating", "ready"]);
7178
+ /** One phase of the guided-tour overview. */
7179
+ const WorkflowPhaseSchema = object({
7180
+ id: string(),
7181
+ title: string(),
7182
+ copy: string(),
7183
+ nodeIds: array(string())
7184
+ });
7185
+ object({
7186
+ status: WorkflowOverviewStatusSchema,
7187
+ summary: string(),
7188
+ phases: array(WorkflowPhaseSchema),
7189
+ hash: string(),
7190
+ generatedAt: string().nullable(),
7191
+ model: string()
7192
+ });
7193
+ /** Subset of JSON-Schema field types the dashboard form renders inline. */
7194
+ const WorkflowInputFieldTypeSchema = _enum([
7195
+ "string",
7196
+ "number",
7197
+ "boolean",
7198
+ "enum",
7199
+ "object",
7200
+ "array"
7201
+ ]);
7202
+ const WorkflowInputFieldSchema = lazy(() => object({
7203
+ key: string(),
7204
+ label: string(),
7205
+ type: WorkflowInputFieldTypeSchema,
7206
+ required: boolean(),
7207
+ description: string().optional(),
7208
+ placeholder: string().optional(),
7209
+ options: array(string()).optional(),
7210
+ default: union([
7211
+ string(),
7212
+ number$1(),
7213
+ boolean()
7214
+ ]).optional(),
7215
+ children: array(WorkflowInputFieldSchema).optional(),
7216
+ format: string().optional()
7217
+ }));
7218
+ object({
7219
+ schema: object({ fields: array(WorkflowInputFieldSchema) }),
7220
+ values: record(string(), unknown()).nullable()
7221
+ });
7222
+ object({ runId: string() });
7223
+ /** Annotation lifecycle: "generating" while the LLM pass streams in, then "ready". */
7224
+ const WorkflowCanvasStatusSchema = _enum(["generating", "ready"]);
7225
+ /** LLM-produced enrichment for a single skeleton node. */
7226
+ const WorkflowCanvasAnnotationSchema = object({
7227
+ label: string().optional(),
7228
+ description: string().optional()
7229
+ });
7230
+ /** The configured value of one input at this call site. */
7231
+ const WorkflowNodeInputBindingSchema = object({
7232
+ tokens: array(discriminatedUnion("kind", [
7233
+ object({
7234
+ kind: literal("text"),
7235
+ text: string()
7236
+ }),
7237
+ object({
7238
+ kind: literal("reference"),
7239
+ sourceNodeId: string().optional(),
7240
+ sourceLabel: string(),
7241
+ field: string().optional()
7242
+ }),
7243
+ object({
7244
+ kind: literal("variable"),
7245
+ text: string(),
7246
+ /** Concrete value when `text` resolves to a top-level literal constant. */
7247
+ resolvedValue: string().optional()
7248
+ }),
7249
+ object({
7250
+ kind: literal("call"),
7251
+ name: string()
7252
+ })
7253
+ ])),
7254
+ multiline: boolean().optional()
7255
+ });
7256
+ /** An inspector input with optional call-site binding. */
7257
+ const WorkflowCanvasNodeInputSchema = WorkflowInputFieldSchema.and(object({
7258
+ binding: WorkflowNodeInputBindingSchema.optional(),
7259
+ additional: boolean().optional()
7260
+ }));
7261
+ /** Authored, deterministic metadata for a single node. */
7262
+ const WorkflowCanvasNodeMetaSchema = object({
7263
+ kind: _enum([
7264
+ "action",
7265
+ "agent",
7266
+ "workflow",
7267
+ "llm",
7268
+ "trigger",
7269
+ "boundary"
7270
+ ]),
7271
+ slug: string(),
7272
+ name: string(),
7273
+ description: string().optional(),
7274
+ appSlug: string().optional(),
7275
+ inputs: array(WorkflowCanvasNodeInputSchema),
7276
+ outputs: array(WorkflowInputFieldSchema),
7277
+ requiredApps: array(string()).optional(),
7278
+ model: string().optional(),
7279
+ toolCount: number$1().int().nonnegative().optional()
7280
+ });
7281
+ object({
7282
+ graph: WorkflowCanvasGraphSchema,
7283
+ nodeMetadata: record(string(), WorkflowCanvasNodeMetaSchema),
7284
+ annotations: record(string(), WorkflowCanvasAnnotationSchema),
7285
+ status: WorkflowCanvasStatusSchema,
7286
+ hash: string(),
7287
+ generatedAt: string().nullable(),
7288
+ model: string()
7289
+ });
7290
+ const WorkflowCanvasNodeRunStateSchema = object({
7291
+ status: _enum([
7292
+ "pending",
7293
+ "running",
7294
+ "succeeded",
7295
+ "failed",
7296
+ "skipped"
7297
+ ]),
7298
+ iteration: object({
7299
+ index: number$1().int().nonnegative(),
7300
+ total: number$1().int().nonnegative()
7301
+ }).optional()
7302
+ });
7303
+ /** Overall lifecycle of a run as the canvas animates it. */
7304
+ const WorkflowCanvasRunStatusSchema = _enum([
7305
+ "running",
7306
+ "succeeded",
7307
+ "failed",
7308
+ "canceled"
7309
+ ]);
7310
+ object({
7311
+ runId: string(),
7312
+ status: WorkflowCanvasRunStatusSchema,
7313
+ startedAt: string(),
7314
+ finishedAt: string().nullable(),
7315
+ nodeStates: record(string(), WorkflowCanvasNodeRunStateSchema)
7316
+ });
7317
+ /** Scope a credential instance lives in. */
7318
+ const WorkflowCredentialScopeSchema = _enum([
7319
+ "organization",
7320
+ "project",
7321
+ "user"
7322
+ ]);
7323
+ /** The concrete credential instance a binding currently resolves to. */
7324
+ const WorkflowResolvedCredentialSchema = object({
7325
+ id: string(),
7326
+ name: string(),
7327
+ scope: WorkflowCredentialScopeSchema,
7328
+ appSlug: string().optional(),
7329
+ isDefault: boolean().optional(),
7330
+ projectId: string().optional(),
7331
+ projectName: string().optional()
7332
+ });
7333
+ record(string(), WorkflowCanvasAnnotationSchema);
7334
+ /** One opaque code-block the annotation pass should label, keyed by its canvas node id. */
7335
+ const WorkflowCanvasAnnotationCodeBlockSchema = object({
7336
+ nodeId: string(),
7337
+ /** The raw source snippet (the node's label) the LLM turns into human copy. */
7338
+ source: string()
7339
+ });
7340
+ /** Inputs the worker feeds the LLM for the gated code-block annotation pass. */
7341
+ const WorkflowCanvasAnnotationsInputSchema = object({
7342
+ workflowName: string(),
7343
+ workflowDescription: string().nullable(),
7344
+ codeBlocks: array(WorkflowCanvasAnnotationCodeBlockSchema)
7345
+ });
7346
+ object({
7347
+ workflowId: string(),
7348
+ projectId: string(),
7349
+ hash: string(),
7350
+ model: string(),
7351
+ input: WorkflowCanvasAnnotationsInputSchema
7352
+ });
7353
+ /** One node as the overview LLM sees it (derived from the canvas node metadata + graph). */
7354
+ const WorkflowOverviewNodeSchema = object({
7355
+ nodeId: string(),
7356
+ label: string(),
7357
+ kind: string(),
7358
+ description: string().optional(),
7359
+ /** App/integration slug for steps imported from a `@keystrokehq/<app>` package. */
7360
+ appSlug: string().optional(),
7361
+ /** Authored input field keys (from the action/agent/workflow definition). */
7362
+ inputs: array(string()).optional(),
7363
+ /** Authored output field keys. */
7364
+ outputs: array(string()).optional(),
7365
+ /** Agent-only: the model the agent runs on. */
7366
+ model: string().optional(),
7367
+ /** Agent-only: number of tools available to the agent. */
7368
+ toolCount: number$1().int().nonnegative().optional()
7369
+ });
7370
+ /** Inputs the worker feeds the LLM to produce the workflow overview (summary + phases). */
7371
+ const WorkflowOverviewInputSchema = object({
7372
+ workflowName: string(),
7373
+ workflowDescription: string().nullable(),
7374
+ /** Display labels of the trigger sources upstream of the workflow (read-only context). */
7375
+ triggers: array(string()),
7376
+ nodes: array(WorkflowOverviewNodeSchema),
7377
+ /** The workflow's TypeScript source (best-effort; null when the deploy has no source snapshot). */
7378
+ source: string().nullable()
7379
+ });
7380
+ object({
7381
+ workflowId: string(),
7382
+ projectId: string(),
7383
+ hash: string(),
7384
+ model: string(),
7385
+ input: WorkflowOverviewInputSchema
7386
+ });
7387
+ const WorkflowCanvasCredentialBindingBaseSchema = object({
7388
+ credentialKey: string(),
7389
+ label: string(),
7390
+ appSlug: string().optional()
7391
+ });
7392
+ /** How one credential requirement on a step currently resolves. */
7393
+ const WorkflowCanvasCredentialBindingSchema = union([
7394
+ WorkflowCanvasCredentialBindingBaseSchema.extend({
7395
+ policy: _enum([
7396
+ "project-default",
7397
+ "org-default",
7398
+ "assigned"
7399
+ ]),
7400
+ instance: WorkflowResolvedCredentialSchema
7401
+ }),
7402
+ WorkflowCanvasCredentialBindingBaseSchema.extend({
7403
+ policy: literal("scope-pinned"),
7404
+ pinnedScope: WorkflowCredentialScopeSchema,
7405
+ instance: WorkflowResolvedCredentialSchema
7406
+ }),
7407
+ WorkflowCanvasCredentialBindingBaseSchema.extend({
7408
+ policy: literal("unresolved"),
7409
+ reason: _enum(["needs-selection", "missing"]),
7410
+ pinnedScope: WorkflowCredentialScopeSchema.optional()
7411
+ })
7412
+ ]);
7413
+ record(string(), array(WorkflowCanvasCredentialBindingSchema));
7414
+ record(string(), unknown());
6825
7415
  //#endregion
6826
7416
  //#region src/runtime.ts
6827
7417
  /** Builds base64 `KEYSTROKE_ORG_ARTIFACTS` payload for org worker containers. */