@keystrokehq/hosting 0.1.7 → 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({
@@ -5454,24 +5741,6 @@ object({
5454
5741
  outputParameters: record(string(), unknown()).optional(),
5455
5742
  version: string().optional()
5456
5743
  });
5457
- /** How a credential instance is stored (`credential_instances.auth_kind`). */
5458
- const CredentialAuthKindSchema = _enum([
5459
- "api_key",
5460
- "oauth_managed",
5461
- "keystroke"
5462
- ]);
5463
- /**
5464
- * Where a credential instance is stored (`credential_instances.scope_type`), and the only thing an
5465
- * action/tool can pin via `.scope(...)`. There is no resolution chain: when no scope is pinned, the
5466
- * resolver tries the project default, then the org default, then throws.
5467
- */
5468
- const CredentialScopeTypeSchema = _enum([
5469
- "organization",
5470
- "project",
5471
- "user"
5472
- ]);
5473
- CredentialAuthKindSchema.options;
5474
- CredentialScopeTypeSchema.options;
5475
5744
  /** Scope of a platform app credential (maps to `credential_instances.scope_type`). */
5476
5745
  const AppCredentialScopeSchema = _enum([
5477
5746
  "user",
@@ -6467,7 +6736,7 @@ object({
6467
6736
  id: string(),
6468
6737
  slug: string(),
6469
6738
  name: string(),
6470
- description: string().nullable(),
6739
+ description: string().min(1),
6471
6740
  type: TriggerTypeSchema,
6472
6741
  status: TriggerStatusSchema,
6473
6742
  projectId: string(),
@@ -6763,7 +7032,7 @@ const AgentSummarySchema = object({
6763
7032
  name: string().min(1),
6764
7033
  projectId: string().min(1),
6765
7034
  updatedAt: string().min(1),
6766
- description: string().optional(),
7035
+ description: string().min(1),
6767
7036
  sourcePath: string().min(1).optional(),
6768
7037
  model: string().optional(),
6769
7038
  capabilities: object({
@@ -6785,7 +7054,7 @@ const WorkflowSummarySchema = object({
6785
7054
  name: string().min(1),
6786
7055
  projectId: string().min(1),
6787
7056
  updatedAt: string().min(1),
6788
- description: string().optional(),
7057
+ description: string().min(1),
6789
7058
  sourcePath: string().min(1).optional(),
6790
7059
  lastRunAt: optionalTimestamp
6791
7060
  });
@@ -6795,7 +7064,7 @@ const SkillSummarySchema = object({
6795
7064
  name: string().min(1),
6796
7065
  projectId: string().min(1),
6797
7066
  updatedAt: string().min(1),
6798
- description: string().optional(),
7067
+ description: string().min(1),
6799
7068
  sourcePath: string().min(1).optional()
6800
7069
  });
6801
7070
  AgentSummarySchema.nullable();
@@ -6904,6 +7173,245 @@ object({ files: array(object({
6904
7173
  id: string(),
6905
7174
  path: string().min(1)
6906
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());
6907
7415
  //#endregion
6908
7416
  //#region src/runtime.ts
6909
7417
  /** Builds base64 `KEYSTROKE_ORG_ARTIFACTS` payload for org worker containers. */