@proteos/sdk 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/LICENSE +40 -0
  2. package/dist/chunk-7RGN4E22.cjs +1185 -0
  3. package/dist/chunk-7RGN4E22.cjs.map +1 -0
  4. package/dist/chunk-XJP5WCRZ.js +1125 -0
  5. package/dist/chunk-XJP5WCRZ.js.map +1 -0
  6. package/dist/index.cjs +2384 -0
  7. package/dist/index.cjs.map +1 -0
  8. package/dist/index.d.cts +5225 -0
  9. package/dist/index.d.ts +5225 -0
  10. package/dist/index.js +2146 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/meta/index.cjs +204 -0
  13. package/dist/meta/index.cjs.map +1 -0
  14. package/dist/meta/index.d.cts +2 -0
  15. package/dist/meta/index.d.ts +2 -0
  16. package/dist/meta/index.js +3 -0
  17. package/dist/meta/index.js.map +1 -0
  18. package/dist/types-BNsjfU8N.d.cts +3299 -0
  19. package/dist/types-BNsjfU8N.d.ts +3299 -0
  20. package/package.json +86 -0
  21. package/src/agent/agents.ts +53 -0
  22. package/src/agent/index.ts +134 -0
  23. package/src/agent/mcp-servers.ts +102 -0
  24. package/src/agent/prompts.ts +80 -0
  25. package/src/agent/session-types.ts +397 -0
  26. package/src/agent/sessions.ts +197 -0
  27. package/src/agent/skills.ts +89 -0
  28. package/src/agent/tools.ts +53 -0
  29. package/src/agent/types.ts +362 -0
  30. package/src/auth/index.ts +111 -0
  31. package/src/auth/me.ts +46 -0
  32. package/src/auth/organizations.ts +128 -0
  33. package/src/auth/platform-entities.ts +78 -0
  34. package/src/auth/roles.ts +213 -0
  35. package/src/auth/types.ts +294 -0
  36. package/src/auth/users.ts +226 -0
  37. package/src/client.ts +441 -0
  38. package/src/connector/index.ts +120 -0
  39. package/src/connector/types.ts +150 -0
  40. package/src/conversation/index.ts +297 -0
  41. package/src/conversation/types.ts +590 -0
  42. package/src/conversation/voice.ts +123 -0
  43. package/src/data/index.ts +53 -0
  44. package/src/data/queries.ts +66 -0
  45. package/src/data/records.ts +122 -0
  46. package/src/data/types.ts +89 -0
  47. package/src/errors.ts +148 -0
  48. package/src/events/index.ts +172 -0
  49. package/src/events/types.ts +77 -0
  50. package/src/functions/actions.ts +95 -0
  51. package/src/functions/index.ts +32 -0
  52. package/src/functions/types.ts +71 -0
  53. package/src/http/index.ts +2 -0
  54. package/src/http/query-params.ts +106 -0
  55. package/src/index.ts +598 -0
  56. package/src/iterator.ts +183 -0
  57. package/src/knowledge/graph.ts +35 -0
  58. package/src/knowledge/index.ts +104 -0
  59. package/src/knowledge/labels.ts +70 -0
  60. package/src/knowledge/links.ts +65 -0
  61. package/src/knowledge/nodes.ts +198 -0
  62. package/src/knowledge/record-links.ts +66 -0
  63. package/src/knowledge/types.ts +569 -0
  64. package/src/meta/apps.ts +107 -0
  65. package/src/meta/components.ts +124 -0
  66. package/src/meta/currency/index.ts +202 -0
  67. package/src/meta/entities.ts +193 -0
  68. package/src/meta/filters.ts +76 -0
  69. package/src/meta/index.ts +227 -0
  70. package/src/meta/layout/common-props.ts +93 -0
  71. package/src/meta/layout/control-registry.json +70 -0
  72. package/src/meta/layout/control-registry.ts +92 -0
  73. package/src/meta/layout/elements.ts +203 -0
  74. package/src/meta/layout/index.ts +41 -0
  75. package/src/meta/layout/page-layout.ts +35 -0
  76. package/src/meta/layout/size-value.ts +27 -0
  77. package/src/meta/list-views.ts +109 -0
  78. package/src/meta/lists.ts +104 -0
  79. package/src/meta/menu-configurations.ts +128 -0
  80. package/src/meta/modules.ts +159 -0
  81. package/src/meta/pages.ts +106 -0
  82. package/src/meta/types.ts +1115 -0
  83. package/src/meta/variables.ts +98 -0
  84. package/src/storage/files.ts +183 -0
  85. package/src/storage/index.ts +33 -0
  86. package/src/storage/types.ts +70 -0
  87. package/src/types/common.ts +143 -0
  88. package/src/types/index.ts +28 -0
  89. package/src/types/options.ts +95 -0
  90. package/src/workflow/executions.ts +99 -0
  91. package/src/workflow/index.ts +109 -0
  92. package/src/workflow/node-types.ts +50 -0
  93. package/src/workflow/types.ts +658 -0
  94. package/src/workflow/workflows.ts +152 -0
@@ -0,0 +1,658 @@
1
+ /**
2
+ * Types for the Proteos Workflow Service API (engine v2).
3
+ *
4
+ * Hand-written mirror of the Go models in `go.proteos.ai/model/workflow`
5
+ * (`workflow.go`, `graph.go`, `node-type.go`, `execution.go`, `item.go` +
6
+ * `api/*-requests.go`). Field names match the snake_case wire format exactly,
7
+ * including enum values.
8
+ *
9
+ * A Workflow is an n8n-shaped automation definition keyed by an immutable
10
+ * kebab-case `key` ((org_id, key) PK). Its graph is catalog-driven: every node
11
+ * references a registered node type (a NodeDescriptor) by an open string type
12
+ * key plus a pinned `type_version`. A WorkflowExecution is one firing of a
13
+ * workflow; per-node results live in append-only NodeExecution rows.
14
+ */
15
+
16
+ import type { AuditFields, ListOptions, UserRef } from '../types/common.js'
17
+
18
+ // ---------------------------------------------------------------------------
19
+ // Graph (v2)
20
+ // ---------------------------------------------------------------------------
21
+
22
+ export type WorkflowStatus = 'active' | 'paused' | 'archived'
23
+
24
+ /**
25
+ * A node's registered type key — open string. Catalog types follow
26
+ * `<package>.<node>` (e.g. `proteos-nodes-core.http-request`); engine-native
27
+ * trigger types keep their legacy `trigger.<kind>` keys.
28
+ */
29
+ export type NodeTypeKey = string
30
+
31
+ export interface NodePosition {
32
+ x: number
33
+ y: number
34
+ }
35
+
36
+ /** How the interpreter routes a failed node run. */
37
+ export type OnErrorPolicy = 'stop' | 'continue' | 'continue_error_output'
38
+
39
+ /**
40
+ * Per-node activity retry policy. `max_attempts: 1` disables retries; zero
41
+ * values fall back to the descriptor's defaults, then the engine defaults.
42
+ */
43
+ export interface NodeRetryPolicy {
44
+ max_attempts?: number
45
+ backoff_seconds?: number
46
+ }
47
+
48
+ /**
49
+ * One node in the graph. `parameters` holds the RAW parameter values for the
50
+ * node's descriptor properties (Liquid expressions unresolved — resolution
51
+ * happens at ExecuteNode time).
52
+ */
53
+ export interface WorkflowNode {
54
+ id: string
55
+ type: NodeTypeKey
56
+ /** Pins one registered descriptor version of `type`. */
57
+ type_version?: number
58
+ name: string
59
+ parameters?: Record<string, unknown>
60
+ /** Credential-type slug → metadata variable key or id. */
61
+ credential_refs?: Record<string, string>
62
+ position?: NodePosition
63
+ is_disabled?: boolean
64
+ notes?: string
65
+ on_error?: OnErrorPolicy
66
+ retry?: NodeRetryPolicy
67
+ }
68
+
69
+ /** The single-port key used when a connection endpoint omits the port. */
70
+ export const DEFAULT_PORT = 'main'
71
+
72
+ /**
73
+ * The reserved output-port key the `on_error: continue_error_output` policy
74
+ * routes failed items to, when the node's descriptor declares it.
75
+ */
76
+ export const ERROR_PORT = 'error'
77
+
78
+ /**
79
+ * One side of a connection: a node by id and one of its ports by key.
80
+ * Connections are id-keyed (renaming a node never breaks the graph) and
81
+ * port-keyed (never index-keyed).
82
+ */
83
+ export interface ConnectionEndpoint {
84
+ node_id: string
85
+ port: string
86
+ }
87
+
88
+ /** A directed edge from one node's output port to another node's input port. */
89
+ export interface WorkflowConnection {
90
+ from: ConnectionEndpoint
91
+ to: ConnectionEndpoint
92
+ }
93
+
94
+ export interface WorkflowGraph {
95
+ nodes: WorkflowNode[]
96
+ connections: WorkflowConnection[]
97
+ /**
98
+ * Editor-only per-node pinned output items (keyed by node id) used for
99
+ * partial executions; the production interpreter ignores it unless a run
100
+ * explicitly opts in.
101
+ */
102
+ pin_data?: Record<string, Item[]>
103
+ }
104
+
105
+ // ---------------------------------------------------------------------------
106
+ // Items
107
+ // ---------------------------------------------------------------------------
108
+
109
+ /** A storage-service file reference carried by an item (never inline bytes). */
110
+ export interface BinaryRef {
111
+ file_id: string
112
+ mime_type?: string
113
+ file_name?: string
114
+ size_bytes?: number
115
+ }
116
+
117
+ /**
118
+ * Item lineage: which input item (and port) produced an output item. The wire
119
+ * shape also allows an int shorthand equivalent to `{ item: n }`.
120
+ */
121
+ export interface PairedItem {
122
+ item: number
123
+ input?: string
124
+ }
125
+
126
+ /**
127
+ * The unit of data flowing between workflow nodes (n8n 1:1). Node input/output
128
+ * is a map of port key → `Item[]`.
129
+ */
130
+ export interface Item {
131
+ json: Record<string, unknown>
132
+ binary?: Record<string, BinaryRef>
133
+ paired_item?: PairedItem | number
134
+ }
135
+
136
+ // ---------------------------------------------------------------------------
137
+ // Node descriptors (catalog)
138
+ // ---------------------------------------------------------------------------
139
+
140
+ /**
141
+ * Which runtime executes a node type. `go` nodes are first-party, compiled
142
+ * into the node host; `wasm` nodes are user-defined sandboxed bundles;
143
+ * `intrinsic` types are executed by the interpreter / workflow-service itself.
144
+ */
145
+ export type NodeRuntime = 'go' | 'wasm' | 'intrinsic'
146
+
147
+ /** Coarse catalog grouping of a node type. */
148
+ export type NodeGroup = 'trigger' | 'action' | 'transform' | 'flow'
149
+
150
+ /** Control type of one descriptor property (n8n INodeProperties paradigm). */
151
+ export type PropertyType =
152
+ | 'string'
153
+ | 'number'
154
+ | 'boolean'
155
+ | 'options'
156
+ | 'multi_options'
157
+ | 'json'
158
+ | 'date_time'
159
+ | 'color'
160
+ | 'notice'
161
+ | 'hidden'
162
+ | 'collection'
163
+ | 'fixed_collection'
164
+ | 'credentials_select'
165
+ | 'button'
166
+ // Wave 2 (editor support lands with Phase 3):
167
+ | 'resource_locator'
168
+ | 'resource_mapper'
169
+ | 'filter'
170
+ | 'assignment_collection'
171
+
172
+ /**
173
+ * One named input or output port. Port keys are stable identifiers referenced
174
+ * by connections (never indexes).
175
+ */
176
+ export interface PortSpec {
177
+ key: string
178
+ display_name?: string
179
+ is_required?: boolean
180
+ max_connections?: number
181
+ }
182
+
183
+ /**
184
+ * Gates a property's visibility on sibling parameter values. The editor
185
+ * re-evaluates reactively; the backend applies the same rule during validation
186
+ * (hidden properties are ignored). `hide` wins over `show`.
187
+ */
188
+ export interface DisplayOptions {
189
+ show?: Record<string, unknown[]>
190
+ hide?: Record<string, unknown[]>
191
+ }
192
+
193
+ /**
194
+ * One entry of an options/multi_options list, one repeatable sub-property
195
+ * group of a collection, or one named group of a fixed_collection (in which
196
+ * case `values` carries the group's fixed sub-fields).
197
+ */
198
+ export interface PropertyOption {
199
+ name: string
200
+ value?: unknown
201
+ display_name?: string
202
+ description?: string
203
+ values?: NodeProperty[]
204
+ }
205
+
206
+ /**
207
+ * One parameter in a descriptor's schema. `name` is the verbatim key under
208
+ * `node.parameters` (never case-converted). Every value-bearing property
209
+ * accepts a Liquid expression unless `no_data_expression` is true.
210
+ */
211
+ export interface NodeProperty {
212
+ display_name: string
213
+ name: string
214
+ type: PropertyType
215
+ default?: unknown
216
+ description?: string
217
+ placeholder?: string
218
+ hint?: string
219
+ is_required?: boolean
220
+ no_data_expression?: boolean
221
+ options?: PropertyOption[]
222
+ display_options?: DisplayOptions
223
+ /**
224
+ * v1 subset: `load_options_method`, `load_options_depends_on`,
225
+ * `multiple_values`, `multiple_value_button_text`, `rows`, `password`,
226
+ * `min_value`, `max_value`, `editor`.
227
+ */
228
+ type_options?: Record<string, unknown>
229
+ }
230
+
231
+ /** Declares that a node type uses a credential of the given type slug. */
232
+ export interface CredentialSpec {
233
+ type: string
234
+ is_required?: boolean
235
+ display_options?: DisplayOptions
236
+ }
237
+
238
+ /**
239
+ * The full, self-describing contract of one node type: drives the editor's
240
+ * picker and parameter form, backend validation, and dispatch.
241
+ */
242
+ export interface NodeDescriptor {
243
+ type: NodeTypeKey
244
+ display_name: string
245
+ description?: string
246
+ /** Lucide icon name, PascalCase. */
247
+ icon?: string
248
+ group: NodeGroup
249
+ version: number
250
+ runtime: NodeRuntime
251
+ task_queue?: string
252
+ inputs: PortSpec[]
253
+ outputs: PortSpec[]
254
+ properties: NodeProperty[]
255
+ credentials?: CredentialSpec[]
256
+ /** Dynamic methods the host answers, as `"<kind>:<method_name>"`. */
257
+ methods?: string[]
258
+ /** Declarative routing spec (Phase 4). */
259
+ routing?: unknown
260
+ documentation_url?: string
261
+ /** Liquid over parameters, shown on the canvas node card. */
262
+ subtitle?: string
263
+ }
264
+
265
+ /** Registry lifecycle of one (type, version) row. */
266
+ export type NodeTypeStatus = 'active' | 'inactive'
267
+
268
+ /**
269
+ * One node-type registry row: a registered (package, name, version) with its
270
+ * full descriptor. `org_id` is empty for platform-global types and set for
271
+ * org-installed (wasm) types.
272
+ */
273
+ export interface WorkflowNodeType {
274
+ package: string
275
+ name: string
276
+ version: number
277
+ runtime: NodeRuntime
278
+ task_queue?: string
279
+ descriptor: NodeDescriptor
280
+ status: NodeTypeStatus
281
+ org_id?: string
282
+ created_at: string
283
+ updated_at: string
284
+ }
285
+
286
+ // ---------------------------------------------------------------------------
287
+ // Node-type API shapes
288
+ // ---------------------------------------------------------------------------
289
+
290
+ export interface GetNodeTypesResponse {
291
+ data: WorkflowNodeType[]
292
+ }
293
+
294
+ /**
295
+ * An editor dynamic-method call (load_options / list_search /
296
+ * resource_mapper_fields / credential_test) proxied to the node host.
297
+ * `parameters` carries the node's current (partial) parameter values.
298
+ */
299
+ export interface InvokeNodeMethodRequest {
300
+ type_version?: number
301
+ parameters?: Record<string, unknown>
302
+ credential_refs?: Record<string, string>
303
+ filter?: string
304
+ pagination_token?: string
305
+ }
306
+
307
+ /** One dynamic dropdown entry returned by a load_options method. */
308
+ export interface NodeMethodOption {
309
+ name: string
310
+ value: unknown
311
+ description?: string
312
+ }
313
+
314
+ export interface InvokeNodeMethodResponse {
315
+ /** load_options */
316
+ options?: NodeMethodOption[]
317
+ /** list_search */
318
+ results?: unknown
319
+ pagination_token?: string
320
+ /** resource_mapper_fields */
321
+ fields?: unknown
322
+ /** credential_test */
323
+ is_valid?: boolean
324
+ message?: string
325
+ }
326
+
327
+ // ---------------------------------------------------------------------------
328
+ // Engine-native trigger / agent parameters
329
+ // ---------------------------------------------------------------------------
330
+ // Trigger nodes are executed by workflow-service itself; their parameters stay
331
+ // typed. Action/transform/flow node parameters are descriptor-driven raw JSON.
332
+
333
+ export interface CronTriggerParams {
334
+ cron_expression: string
335
+ timezone: string
336
+ }
337
+
338
+ export type ManualTriggerParams = Record<string, never>
339
+
340
+ export interface WebhookTriggerParams {
341
+ token: string
342
+ }
343
+
344
+ export type EventVerb = 'created' | 'updated' | 'deleted'
345
+
346
+ export interface EventTriggerParams {
347
+ entity_slug: string
348
+ verbs: EventVerb[]
349
+ }
350
+
351
+ export interface MessageTriggerParams {
352
+ direction?: string
353
+ channels?: string[]
354
+ connection_id?: string
355
+ event_types?: string[]
356
+ }
357
+
358
+ export type KickoffType = 'message' | 'outcome'
359
+
360
+ /**
361
+ * Where a kickoff draws its instruction text from: typed inline (`manual`) or
362
+ * resolved from a reusable agent-service Prompt by key (`prompt`) at run time.
363
+ */
364
+ export type KickoffSource = 'manual' | 'prompt'
365
+
366
+ export interface WorkflowContentBlock {
367
+ type: 'text' | 'file'
368
+ text?: string
369
+ file_id?: string
370
+ }
371
+
372
+ export interface MessageKickoff {
373
+ source?: KickoffSource
374
+ /** Inline content blocks (manual source). */
375
+ content?: WorkflowContentBlock[]
376
+ /** Prompt key whose body becomes the message text (prompt source). */
377
+ prompt_key?: string
378
+ }
379
+
380
+ export interface OutcomeRubric {
381
+ type: 'text' | 'file'
382
+ content?: string
383
+ file_id?: string
384
+ }
385
+
386
+ export interface OutcomeKickoff {
387
+ /** Description and rubric are independently sourced (manual vs prompt). */
388
+ description_source?: KickoffSource
389
+ description?: string
390
+ description_prompt_key?: string
391
+ rubric_source?: KickoffSource
392
+ rubric?: OutcomeRubric
393
+ rubric_prompt_key?: string
394
+ max_iterations?: number
395
+ }
396
+
397
+ export interface AgentKickoff {
398
+ type: KickoffType
399
+ message?: MessageKickoff
400
+ outcome?: OutcomeKickoff
401
+ }
402
+
403
+ export interface AgentActionParams {
404
+ agent_key: string
405
+ kickoff: AgentKickoff
406
+ }
407
+
408
+ // ---------------------------------------------------------------------------
409
+ // Workflow
410
+ // ---------------------------------------------------------------------------
411
+
412
+ export interface Workflow extends AuditFields {
413
+ org_id: string
414
+ key: string
415
+ name: string
416
+ description: string
417
+ status: WorkflowStatus
418
+ graph: WorkflowGraph
419
+ version: number
420
+ }
421
+
422
+ export interface CreateWorkflowRequest {
423
+ key: string
424
+ name: string
425
+ description?: string
426
+ graph: WorkflowGraph
427
+ }
428
+
429
+ export interface UpdateWorkflowRequest {
430
+ name: string
431
+ description?: string
432
+ graph: WorkflowGraph
433
+ }
434
+
435
+ /**
436
+ * Body of a manual "run now" call. `destination_node_id` turns the run into a
437
+ * partial "run until here" execution: only nodes on a path from the trigger to
438
+ * the destination (inclusive) execute.
439
+ */
440
+ export interface RunWorkflowRequest {
441
+ destination_node_id?: string
442
+ }
443
+
444
+ /** Where a standalone node test's input comes from. */
445
+ export type TestNodeInputSource = 'last_execution' | 'pinned'
446
+
447
+ /**
448
+ * The candidate node definition under test — the editor's in-memory (possibly
449
+ * unsaved) state. Parameters stay raw; Liquid resolves on the node host per
450
+ * item, exactly like a real run.
451
+ */
452
+ export interface TestNodeCandidate {
453
+ type: NodeTypeKey
454
+ type_version?: number
455
+ name?: string
456
+ parameters?: Record<string, unknown>
457
+ credential_refs?: Record<string, string>
458
+ }
459
+
460
+ /**
461
+ * Runs ONE node ephemerally — no execution rows, real side effects. Input is
462
+ * seeded from the last execution's mirrored input (default) or from the
463
+ * pinned output of the node's upstream neighbors.
464
+ */
465
+ export interface TestNodeRequest {
466
+ node: TestNodeCandidate
467
+ input_source?: TestNodeInputSource
468
+ }
469
+
470
+ /**
471
+ * The full test round trip: the input that was fed in (shown even when the
472
+ * node fails) and the produced output, items inline per port. Both sides are
473
+ * capped (`is_truncated`).
474
+ */
475
+ export interface TestNodeResponse {
476
+ status: 'succeeded' | 'failed' | 'skipped'
477
+ input_source: TestNodeInputSource
478
+ /** False when the workflow (or this node) never ran — nothing was fed in. */
479
+ has_prior_execution: boolean
480
+ input: Record<string, Item[]>
481
+ output: Record<string, Item[]>
482
+ item_counts: Record<string, number>
483
+ error?: ExecutionError
484
+ metadata?: Record<string, unknown>
485
+ is_truncated: boolean
486
+ }
487
+
488
+ export interface ListWorkflowsOptions extends ListOptions {
489
+ name?: string
490
+ 'name[contains]'?: string
491
+ status?: WorkflowStatus
492
+ }
493
+
494
+ // ---------------------------------------------------------------------------
495
+ // Versions
496
+ // ---------------------------------------------------------------------------
497
+
498
+ /**
499
+ * The author of a workflow version — a common {@link UserRef} that the
500
+ * versions endpoints enrich with a resolved display `name` when available.
501
+ */
502
+ export interface WorkflowVersionAuthor extends UserRef {
503
+ name?: string
504
+ }
505
+
506
+ /**
507
+ * One row of a workflow's version history (newest first). Lightweight — the
508
+ * graph itself is fetched per version via `getVersion`.
509
+ */
510
+ export interface WorkflowVersionSummary {
511
+ version: number
512
+ nodes_total: number
513
+ created_at: string
514
+ created_by: WorkflowVersionAuthor
515
+ }
516
+
517
+ /**
518
+ * One immutable, fully materialized workflow version: the graph exactly as it
519
+ * was saved at that version. Versions are append-only — restoring an old
520
+ * version writes its graph as a NEW bumped version, never rewrites history.
521
+ */
522
+ export interface WorkflowVersion {
523
+ org_id: string
524
+ workflow_key: string
525
+ version: number
526
+ graph: WorkflowGraph
527
+ created_at: string
528
+ created_by: WorkflowVersionAuthor
529
+ }
530
+
531
+ // ---------------------------------------------------------------------------
532
+ // Execution
533
+ // ---------------------------------------------------------------------------
534
+
535
+ /**
536
+ * Coarse status of one workflow firing (and of one node run — `skipped` is
537
+ * node-execution-only: the node never ran because no items reached it).
538
+ */
539
+ export type ExecutionStatus =
540
+ | 'pending'
541
+ | 'running'
542
+ | 'succeeded'
543
+ | 'failed'
544
+ | 'cancelled'
545
+ | 'skipped'
546
+
547
+ export type TriggerKind = 'schedule' | 'manual' | 'webhook' | 'event' | 'message' | 'workflow'
548
+
549
+ /**
550
+ * Why and how an execution fired. Flat, kind-discriminated: `kind` selects
551
+ * which optional fields are meaningful. `payload` carries the trigger's data
552
+ * payload and seeds the workflow's first item.
553
+ */
554
+ export interface ExecutionTriggerContext {
555
+ kind: TriggerKind
556
+ // schedule
557
+ scheduled_at?: string
558
+ // manual
559
+ actor?: UserRef
560
+ // webhook
561
+ received_at?: string
562
+ // event
563
+ topic?: string
564
+ event_type?: string
565
+ record_id?: string
566
+ // message
567
+ conversation_id?: string
568
+ channel?: string
569
+ // workflow (child executions)
570
+ parent_execution_id?: string
571
+ payload?: unknown
572
+ }
573
+
574
+ export interface ExecutionError {
575
+ code: string
576
+ message: string
577
+ /** Marks business failures the user can fix, vs infrastructure faults. */
578
+ is_user_error?: boolean
579
+ }
580
+
581
+ /**
582
+ * One firing of a Workflow. It pins the immutable workflow version it ran
583
+ * against; per-node results live in the append-only NodeExecution rows keyed
584
+ * by (execution_id, node_id, run_index).
585
+ */
586
+ export interface WorkflowExecution {
587
+ org_id: string
588
+ id: string
589
+ workflow_key: string
590
+ workflow_version: number
591
+ status: ExecutionStatus
592
+ trigger_context: ExecutionTriggerContext
593
+ temporal_workflow_id?: string
594
+ temporal_run_id?: string
595
+ error?: ExecutionError
596
+ started_at?: string
597
+ finished_at?: string
598
+ created_at: string
599
+ created_by: UserRef
600
+ }
601
+
602
+ /**
603
+ * One run of one node within an execution — append-only, a new row per
604
+ * (node_id, run_index) so loops and retries never overwrite history.
605
+ * `item_counts` counts output items per port; `metadata` carries node-specific
606
+ * extras (e.g. the agent session id).
607
+ */
608
+ export interface NodeExecution {
609
+ org_id: string
610
+ execution_id: string
611
+ node_id: string
612
+ run_index: number
613
+ node_name: string
614
+ node_type: NodeTypeKey
615
+ status: ExecutionStatus
616
+ input_counts?: Record<string, number>
617
+ item_counts?: Record<string, number>
618
+ error?: ExecutionError
619
+ metadata?: Record<string, unknown>
620
+ started_at?: string
621
+ finished_at?: string
622
+ created_at: string
623
+ }
624
+
625
+ export interface ListExecutionsOptions extends ListOptions {
626
+ workflow_key?: string
627
+ status?: ExecutionStatus
628
+ }
629
+
630
+ // ---------------------------------------------------------------------------
631
+ // Execution API shapes
632
+ // ---------------------------------------------------------------------------
633
+
634
+ /** Execution detail: the header row plus its append-only node executions. */
635
+ export interface GetExecutionDetailResponse {
636
+ execution: WorkflowExecution
637
+ node_executions: NodeExecution[]
638
+ }
639
+
640
+ /** Windows into one node run's stored items on one port. */
641
+ export interface GetNodeExecutionItemsOptions {
642
+ port?: string
643
+ /**
644
+ * Which side of the node run to read: its own output ports (default) or the
645
+ * mirrored copy of what fed it.
646
+ */
647
+ side?: 'input' | 'output'
648
+ offset?: number
649
+ limit?: number
650
+ }
651
+
652
+ /** One window of items plus the true total. */
653
+ export interface GetNodeExecutionItemsResponse {
654
+ items: Item[]
655
+ items_total: number
656
+ offset: number
657
+ limit: number
658
+ }