@tangle-network/hub-sdk 0.4.0 → 0.5.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.
package/dist/index.d.ts CHANGED
@@ -537,7 +537,7 @@ interface HubWorkflowEventFilter {
537
537
  }
538
538
  interface HubWorkflowTrigger {
539
539
  id: string;
540
- kind: "provider_event" | "schedule";
540
+ kind: "provider_event" | "schedule" | "webhook";
541
541
  enabled: boolean;
542
542
  provider: string | null;
543
543
  connectionId: string | null;
@@ -598,6 +598,21 @@ interface HubWorkflowActionResult {
598
598
  output?: unknown;
599
599
  error?: string;
600
600
  costUsd?: number;
601
+ /** Graph-run identity: the topology node this action row belongs to. Present
602
+ * when the id says something the row's position does not — an author's DAG
603
+ * node id, and every cycle re-entry row (a node visited more than once
604
+ * produces one row per visit). Absent on a linear run's rows, whose node id
605
+ * IS their position: read it as `step-${index + 1}`. */
606
+ nodeId?: string;
607
+ /** Which visit of `nodeId` this row is (1-based). Present on cycle re-entry
608
+ * rows only; a single-visit row omits it. */
609
+ visit?: number;
610
+ /** `script.run` only (single-run detail): the script's captured stdout
611
+ * (size-capped), or an artifact ref carrying the full log by reference. */
612
+ logs?: unknown;
613
+ /** How an `onError` policy handled this action's failure so the run
614
+ * continued (the action still reads `failed`). */
615
+ onError?: HubWorkflowOnErrorOutcome;
601
616
  /** `agent.run` only (single-run detail): the agent's execution detail —
602
617
  * per-iteration spans (each with text), aggregate usage, partial text. */
603
618
  agentRun?: HubAgentRunDetail;
@@ -633,6 +648,16 @@ interface HubWorkflowRunDetail extends HubWorkflowRun {
633
648
  * `getRun` / a `snapshot` event reads them without re-checking presence. */
634
649
  triggerContext: unknown;
635
650
  definitionSnapshot: string | null;
651
+ /** The terminal failed/cancelled run this one retries (enqueued via
652
+ * {@link HubWorkflowsClient.retryRun}); null on runs that are not retries. */
653
+ retriedFromRunId: string | null;
654
+ /** The compiled graph topology the run executed (resolved from the run's
655
+ * definition snapshot, so a post-run edit can't mislabel it) — null for a
656
+ * linear run. Present on the HTTP run-detail response. */
657
+ graph?: HubWorkflowGraphSpec | null;
658
+ /** Per-completion guard verdicts (keyed `"from->to"`), present only when the
659
+ * run carries a graph journal — i.e. a parked (`waiting`) graph run. */
660
+ edgeVerdicts?: HubWorkflowEdgeVerdicts[];
636
661
  }
637
662
  /**
638
663
  * The trigger fields a manual "Run now" supplies, as a flat `{ path: value }`
@@ -664,6 +689,17 @@ interface HubWorkflowRunCancelResult {
664
689
  * watch/poll the run to confirm it settled `cancelled`. */
665
690
  signalled?: boolean;
666
691
  }
692
+ /**
693
+ * Response of a run retry (`POST /v1/workflows/:id/runs/:runId/retry`): the
694
+ * NEWLY enqueued run's id — a fresh run of the same workflow with the same
695
+ * trigger context — plus the terminal run it was retried from. A finished
696
+ * run in any other state throws `HubSdkError` with code `RUN_NOT_RETRYABLE`;
697
+ * an unknown/foreign run throws `NOT_FOUND`.
698
+ */
699
+ interface HubWorkflowRunRetried {
700
+ runId: string;
701
+ retriedFromRunId: string;
702
+ }
667
703
  /**
668
704
  * A live event from a run's SSE stream (`GET /v1/workflows/:id/runs/:runId/events`),
669
705
  * as surfaced by {@link HubWorkflowsClient.watchRun}. `snapshot` is the current
@@ -734,6 +770,35 @@ interface HubWorkflowRunsPage {
734
770
  runs: HubWorkflowRun[];
735
771
  nextCursor: string | null;
736
772
  }
773
+ /** Trailing windows the fleet-insights endpoint accepts. */
774
+ type HubWorkflowFleetWindow = "24h" | "7d" | "30d";
775
+ /**
776
+ * One workflow's row in the fleet overview: its run tallies over the window.
777
+ * `lastRunStatus`/`lastRunAt` describe the newest run INSIDE the window (null
778
+ * when the workflow didn't run in it), and `successRate` is
779
+ * `succeeded / runsInWindow` — null, never a fabricated 0 or 1, when there is
780
+ * no denominator.
781
+ */
782
+ interface HubWorkflowFleetEntry {
783
+ id: string;
784
+ name: string;
785
+ enabled: boolean;
786
+ runsInWindow: number;
787
+ succeeded: number;
788
+ failed: number;
789
+ /** Runs parked on a human `decision` step (status `waiting`). */
790
+ waiting: number;
791
+ successRate: number | null;
792
+ lastRunStatus: HubWorkflowRunStatus | null;
793
+ lastRunAt: string | null;
794
+ }
795
+ /** `GET /v1/workflows/insights/fleet` — the whole fleet, sorted failing-first. */
796
+ interface HubWorkflowFleetInsights {
797
+ window: HubWorkflowFleetWindow;
798
+ /** ISO instant the window starts at (now minus the window length). */
799
+ windowStart: string;
800
+ workflows: HubWorkflowFleetEntry[];
801
+ }
737
802
  interface HubWorkflow {
738
803
  id: string;
739
804
  name: string;
@@ -744,11 +809,22 @@ interface HubWorkflow {
744
809
  /** The durable YAML this workflow compiled from. */
745
810
  definitionYaml: string | null;
746
811
  validationErrors: HubWorkflowValidationError[];
812
+ /** Current head revision; null on pre-versioning rows until their next
813
+ * update (they have no revision history to point at yet). */
814
+ headRev?: number | null;
747
815
  /** Present on get/create/update detail responses; omitted on list. */
748
816
  triggers?: HubWorkflowTrigger[];
749
817
  /** Present on the detail response: the trigger fields a manual run must supply,
750
818
  * derived from the definition's `${trigger.*}` references (empty when none). */
751
819
  manualRunInputs?: HubManualRunInput[];
820
+ /** Present on the get-detail response: the compiled graph topology (null
821
+ * when the definition has no graph topology, or is chain-equivalent —
822
+ * the legacy linear semantics). Omitted on the list projection. */
823
+ graph?: HubWorkflowGraphSpec | null;
824
+ /** Create response only, when the definition has a webhook trigger: the
825
+ * hook delivery URL, plus the plaintext bearer token exactly once at mint
826
+ * (absent when an active token already exists — rotate to re-reveal). */
827
+ hook?: HubWorkflowHookEndpoint;
752
828
  /** Present on the list response (latest run, or null if never run); omitted on detail. */
753
829
  lastRun?: HubWorkflowRunSummary | null;
754
830
  createdAt: string;
@@ -772,6 +848,305 @@ type HubWorkflowValidateResponse = {
772
848
  };
773
849
  /** JSON Schema for the YAML workflow definition. */
774
850
  type HubWorkflowSchemaResponse = Record<string, unknown>;
851
+ /** How a node's incoming edges release it (default `"all"` — omitted on the
852
+ * wire for it, so specs compiled before join rules existed round-trip). */
853
+ type HubWorkflowGraphJoinRule = "all" | "any" | "any_failed" | "all_done";
854
+ type HubWorkflowConditionOp = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "contains" | "exists" | "truthy";
855
+ type HubWorkflowConditionScalar = string | number | boolean | null;
856
+ /** The predicate on a guarded edge (`needs: [{ id, when }]`), evaluated by the
857
+ * runner against the steps context on the source node's completion. */
858
+ type HubWorkflowCondition = {
859
+ path: string;
860
+ op: HubWorkflowConditionOp;
861
+ value?: HubWorkflowConditionScalar | HubWorkflowConditionScalar[];
862
+ } | {
863
+ all: HubWorkflowCondition[];
864
+ } | {
865
+ any: HubWorkflowCondition[];
866
+ } | {
867
+ not: HubWorkflowCondition;
868
+ };
869
+ interface HubWorkflowGraphNode {
870
+ id: string;
871
+ index: number;
872
+ join?: HubWorkflowGraphJoinRule;
873
+ }
874
+ interface HubWorkflowGraphEdge {
875
+ from: string;
876
+ to: string;
877
+ /** Guard the runner evaluates on the source's completion; unguarded edges
878
+ * carry no `when`. */
879
+ when?: HubWorkflowCondition;
880
+ }
881
+ /** JSON-serializable form of a validated graph (as stored on run/workflow rows). */
882
+ interface HubWorkflowGraphSpec {
883
+ nodes: HubWorkflowGraphNode[];
884
+ edges: HubWorkflowGraphEdge[];
885
+ maxNodeVisits: number;
886
+ }
887
+ /** One journal completion on the wire: the node that completed and the guard
888
+ * verdict evaluated for each of its guarded outgoing edges, keyed by edgeKey
889
+ * (`"from->to"`). Only GUARDED edges ever appear. */
890
+ interface HubWorkflowEdgeVerdicts {
891
+ nodeId: string;
892
+ verdicts: Record<string, boolean>;
893
+ }
894
+ /** How an action's `onError` policy handled a failure so the run continued
895
+ * (the action itself still reads `failed`). */
896
+ interface HubWorkflowOnErrorOutcome {
897
+ policy: "continue" | "fallback";
898
+ /** The recovery leaf's result when the policy ran a `{ do }` fallback. */
899
+ fallback?: {
900
+ kind: string;
901
+ status: "succeeded" | "failed";
902
+ output?: unknown;
903
+ error?: string;
904
+ costUsd?: number;
905
+ };
906
+ }
907
+ type HubWorkflowRevisionSource = "user" | "copilot" | "intelligence";
908
+ /** Lifecycle state of a revision. The head rev only ever points at an
909
+ * `applied` revision; `proposed` is a service-token-authored suggestion
910
+ * awaiting an owner decision; `rejected` is a declined proposal (kept for
911
+ * audit). */
912
+ type HubWorkflowRevisionStatus = "applied" | "proposed" | "rejected";
913
+ /** Revision list projection — attribution + note + status, WITHOUT the YAML body. */
914
+ interface HubWorkflowRevisionMeta {
915
+ rev: number;
916
+ createdAt: string;
917
+ createdBy: string;
918
+ source: HubWorkflowRevisionSource;
919
+ note: string | null;
920
+ status: HubWorkflowRevisionStatus;
921
+ }
922
+ /** One revision WITH its YAML (and the actions compiled alongside it). */
923
+ interface HubWorkflowRevision extends HubWorkflowRevisionMeta {
924
+ yaml: string;
925
+ actions: HubWorkflowAction[];
926
+ }
927
+ /** A proposal (proposed or rejected revision) WITH its evidence — what the
928
+ * proposer derived the suggestion from (e.g. health stats), plus
929
+ * `rejectionReason` once declined. */
930
+ interface HubWorkflowProposal extends HubWorkflowRevisionMeta {
931
+ evidence: unknown;
932
+ }
933
+ /** Input to {@link HubWorkflowsClient.propose}. Service-token callers only. */
934
+ interface HubWorkflowProposalInput {
935
+ yaml: string;
936
+ note?: string;
937
+ /** Proposer-supplied justification (any JSON value) — carried verbatim onto
938
+ * the revision and shown on the approval surface. */
939
+ evidence?: unknown;
940
+ }
941
+ /** One node's aggregate across the analyzed runs. */
942
+ interface HubWorkflowNodeHealth {
943
+ /** The author's graph node id, or `step-N` for a linear run's nodes (and for
944
+ * a node whose run cannot be mapped back to a definition). */
945
+ nodeId: string;
946
+ visits: number;
947
+ failures: number;
948
+ /** Null when no visit carried a cost row (never a fabricated 0). */
949
+ totalCostUsd: number | null;
950
+ /** Null when no visit recorded duration spans. */
951
+ avgDurationMs: number | null;
952
+ }
953
+ /** Failures grouped by a normalized error signature (ids/numbers/whitespace
954
+ * stripped), most frequent first (top 5). */
955
+ interface HubWorkflowFailureCluster {
956
+ signature: string;
957
+ count: number;
958
+ sampleRunIds: string[];
959
+ }
960
+ /** An agent.run node whose outputs are near-static across runs — a
961
+ * CANDIDATE for distillation, reported with its measurements, never a
962
+ * verdict. */
963
+ interface HubWorkflowDistillationCandidate {
964
+ nodeId: string;
965
+ matchRatio: number;
966
+ samples: number;
967
+ avgCostUsd: number | null;
968
+ }
969
+ interface HubWorkflowHealth {
970
+ /** The requested window (the `runs` parameter). */
971
+ runsWindow: number;
972
+ /** Terminal runs that actually went into the stats. */
973
+ runsAnalyzed: number;
974
+ nodes: HubWorkflowNodeHealth[];
975
+ failureClusters: HubWorkflowFailureCluster[];
976
+ distillationCandidates: HubWorkflowDistillationCandidate[];
977
+ }
978
+ /** One KV entry with its metadata — the get/put/cas response shape. */
979
+ interface HubWorkflowKvEntry {
980
+ key: string;
981
+ value: unknown;
982
+ version: number;
983
+ updatedAt: string;
984
+ }
985
+ /** Keyspace metadata row (never the value) — the list response's entry. */
986
+ interface HubWorkflowKvEntryMeta {
987
+ key: string;
988
+ version: number;
989
+ updatedAt: string;
990
+ }
991
+ interface HubWorkflowKvListResponse {
992
+ entries: HubWorkflowKvEntryMeta[];
993
+ }
994
+ interface HubWorkflowKvDeleteResponse {
995
+ deleted: boolean;
996
+ }
997
+ /** The opaque ref a stored artifact is referred to by — the value a
998
+ * script.run node returns as its step output. */
999
+ interface HubWorkflowArtifactRef {
1000
+ $artifact: string;
1001
+ name: string;
1002
+ contentType: string;
1003
+ byteSize: number;
1004
+ preview: string | null;
1005
+ }
1006
+ /** Artifact metadata (never the bytes), oldest first on the list response. */
1007
+ interface HubWorkflowArtifact {
1008
+ id: string;
1009
+ runId: string;
1010
+ workflowId: string;
1011
+ /** The graph node (or `step-N` positional id on linear runs) whose action
1012
+ * emitted the artifact. */
1013
+ nodeId: string;
1014
+ name: string;
1015
+ contentType: string;
1016
+ byteSize: number;
1017
+ /** First 2KiB of textual content; null for binary content types. */
1018
+ preview: string | null;
1019
+ createdAt: string;
1020
+ }
1021
+ interface HubWorkflowArtifactsResponse {
1022
+ artifacts: HubWorkflowArtifact[];
1023
+ }
1024
+ /** Raw artifact bytes from the download route, with their stored content type. */
1025
+ interface HubWorkflowArtifactDownload {
1026
+ bytes: Uint8Array;
1027
+ contentType: string;
1028
+ }
1029
+ type HubWorkflowTemplateCategory = "Code Review" | "Triage" | "Reports" | "Multi-agent";
1030
+ /** One author-time literal a gallery starter needs the user to supply. Every
1031
+ * declared parameter is required; `example` is a valid value that seeds the
1032
+ * form placeholder. */
1033
+ interface HubWorkflowTemplateParameter {
1034
+ key: string;
1035
+ label: string;
1036
+ type: "string" | "integer";
1037
+ help?: string;
1038
+ example: string;
1039
+ }
1040
+ interface HubWorkflowTemplate {
1041
+ id: string;
1042
+ name: string;
1043
+ summary: string;
1044
+ category: HubWorkflowTemplateCategory;
1045
+ icon: string;
1046
+ requiresSandbox: boolean;
1047
+ /** Providers the template references (a "uses GitHub" hint), sorted. */
1048
+ providers: string[];
1049
+ parameters: HubWorkflowTemplateParameter[];
1050
+ /** The template with parameter tokens rendered to their example values. */
1051
+ previewYaml: string;
1052
+ }
1053
+ /** A connection a definition needs, with where to connect it. */
1054
+ interface HubWorkflowConnectionRequirement {
1055
+ provider: string;
1056
+ connected: boolean;
1057
+ kind: "integration" | "github_app";
1058
+ /** Where to satisfy the requirement (App install flow for `github_app`,
1059
+ * integrations page otherwise); null when no target exists. */
1060
+ connectUrl: string | null;
1061
+ }
1062
+ /**
1063
+ * Result of instantiating a template. `created: false` is NOT an error — an
1064
+ * actionable continuation listing the connections to satisfy before retrying
1065
+ * the same call. Invalid parameters or a compile failure throw `HubSdkError`
1066
+ * (400) instead, matching the create route's contract.
1067
+ */
1068
+ type HubWorkflowTemplateInstantiateResult = {
1069
+ created: true;
1070
+ workflow: HubWorkflow;
1071
+ } | {
1072
+ created: false;
1073
+ connectionRequirements: HubWorkflowConnectionRequirement[];
1074
+ };
1075
+ type HubWorkflowDecisionStatus = "pending" | "resolved" | "expired" | "cancelled";
1076
+ type HubWorkflowDecisionOnTimeout = "wait" | "fail" | "default";
1077
+ /** How the answer arrived: a UI click, a provider-channel event (e.g. a Slack
1078
+ * reaction), or the timeout policy. */
1079
+ type HubWorkflowDecisionResolvedVia = "in_app" | "channel" | "system";
1080
+ interface HubWorkflowDecision {
1081
+ id: string;
1082
+ runId: string;
1083
+ workflowId: string;
1084
+ actionIndex: number;
1085
+ title: string;
1086
+ prompt: string | null;
1087
+ options: string[];
1088
+ status: HubWorkflowDecisionStatus;
1089
+ onTimeout: HubWorkflowDecisionOnTimeout;
1090
+ defaultChoice: string | null;
1091
+ choice: string | null;
1092
+ note: string | null;
1093
+ timedOut: boolean;
1094
+ requestedAt: string;
1095
+ expiresAt: string | null;
1096
+ resolvedAt: string | null;
1097
+ /** Null while pending, and on a row settled without an answer (expired /
1098
+ * cancelled). */
1099
+ resolvedVia: HubWorkflowDecisionResolvedVia | null;
1100
+ /** `channel` answers only: the provider whose event carried the answer and
1101
+ * the raw external actor id it came from. */
1102
+ resolvedViaProvider: string | null;
1103
+ resolvedByExternalActor: string | null;
1104
+ }
1105
+ /** A pending decision on the cross-workflow list, named by its workflow
1106
+ * (null when the workflow was deleted while the run was parked). */
1107
+ interface HubWorkflowPendingDecision extends HubWorkflowDecision {
1108
+ workflowName: string | null;
1109
+ }
1110
+ interface HubWorkflowPendingDecisionsResponse {
1111
+ decisions: HubWorkflowPendingDecision[];
1112
+ }
1113
+ /** Result of resolving a decision. `resumed` is false when the resolution
1114
+ * stuck but the run could not be resumed (already terminal/cancelled). */
1115
+ interface HubWorkflowDecisionResolveResult {
1116
+ runId: string;
1117
+ decisionId: string;
1118
+ choice: string;
1119
+ resumed: boolean;
1120
+ }
1121
+ /** A workflow's webhook delivery endpoint. `token` is the plaintext bearer —
1122
+ * revealed only at mint/rotate time (only the hash is stored). */
1123
+ interface HubWorkflowHookEndpoint {
1124
+ url: string;
1125
+ token?: string;
1126
+ }
1127
+ interface HubWorkflowHookToken {
1128
+ url: string;
1129
+ token: string;
1130
+ }
1131
+ /** One step of an agent round's execution timeline (reasoning, or a tool call
1132
+ * with args + result), as the step-page endpoint serves it. */
1133
+ type HubWorkflowAgentStep = {
1134
+ kind: "reasoning";
1135
+ text: string;
1136
+ } | {
1137
+ kind: "tool"; /** Tool name, e.g. "read", "bash". */
1138
+ tool: string;
1139
+ status: "pending" | "running" | "completed" | "error"; /** Arguments the tool was called with (pretty JSON). */
1140
+ input?: string; /** Result the tool returned on success (pretty JSON / text). */
1141
+ output?: string; /** Error message when the tool failed. */
1142
+ error?: string;
1143
+ };
1144
+ /** One page of a round's step archive. `nextCursor` is the last `stepIndex`
1145
+ * held — pass it as `after` for the next page; null on the last page. */
1146
+ interface HubWorkflowRunStepsPage {
1147
+ steps: HubWorkflowAgentStep[];
1148
+ nextCursor: number | null;
1149
+ }
775
1150
  //#endregion
776
1151
  //#region src/client.d.ts
777
1152
  type HubAuthHeaders = () => HeadersInit | Promise<HeadersInit>;
@@ -832,6 +1207,14 @@ declare class HubClient {
832
1207
  * `HUB_HTTP_<status>` transport error — rather than handed back as bogus SSE.
833
1208
  */
834
1209
  private stream;
1210
+ /**
1211
+ * Fetch raw (non-envelope) bytes — the artifact download route, whose 200 is
1212
+ * the artifact's own content type, not JSON. Error responses on such routes
1213
+ * are still the standard envelope, so a failure surfaces exactly like
1214
+ * {@link request}: a typed `HubSdkError` from a `{success:false}` body,
1215
+ * otherwise an `HUB_HTTP_<status>` transport error.
1216
+ */
1217
+ private requestBytes;
835
1218
  private buildHeaders;
836
1219
  }
837
1220
  interface HubTokenListOptions {
@@ -950,11 +1333,31 @@ declare class HubAuditClient {
950
1333
  declare class HubWorkflowsClient {
951
1334
  private readonly request;
952
1335
  private readonly stream?;
953
- constructor(request: <TData>(path: string, init: RequestInit) => Promise<TData>, stream?: ((path: string, init: RequestInit) => Promise<ReadableStream<Uint8Array>>) | undefined);
1336
+ private readonly download?;
1337
+ constructor(request: <TData>(path: string, init: RequestInit) => Promise<TData>, stream?: ((path: string, init: RequestInit) => Promise<ReadableStream<Uint8Array>>) | undefined, download?: ((path: string, init: RequestInit) => Promise<HubWorkflowArtifactDownload>) | undefined);
954
1338
  list(): Promise<HubWorkflow[]>;
1339
+ /**
1340
+ * Owner-wide fleet overview: one row per workflow with its run tallies over
1341
+ * a trailing window (default 7d), sorted failing-first. Answers "how are ALL
1342
+ * my workflows doing" in one call — the per-workflow insights endpoint is
1343
+ * the drill-down, not a way to build this row set client-side.
1344
+ */
1345
+ fleetInsights(opts?: {
1346
+ window?: HubWorkflowFleetWindow;
1347
+ }): Promise<HubWorkflowFleetInsights>;
955
1348
  get(id: string): Promise<HubWorkflow>;
956
1349
  create(yaml: string): Promise<HubWorkflow>;
957
- update(id: string, yaml: string): Promise<HubWorkflow>;
1350
+ /**
1351
+ * Replace the workflow's definition from YAML (recompiled server-side,
1352
+ * triggers reconciled). Every landed update appends a revision;
1353
+ * `opts.note` rides onto that revision row (e.g. "why this change"), visible
1354
+ * in {@link listRevisions}. Throws `HubSdkError`: `WORKFLOW_INVALID` when the
1355
+ * YAML doesn't compile or its connections aren't met, `CONFLICT` on a
1356
+ * concurrent modification, `NOT_FOUND` for an unknown/foreign id.
1357
+ */
1358
+ update(id: string, yaml: string, opts?: {
1359
+ note?: string;
1360
+ }): Promise<HubWorkflow>;
958
1361
  delete(id: string): Promise<void>;
959
1362
  /**
960
1363
  * Enable or disable a workflow without editing its YAML. Works even when the
@@ -1006,6 +1409,21 @@ declare class HubWorkflowsClient {
1006
1409
  cancel(id: string, runId: string, opts?: {
1007
1410
  signal?: AbortSignal;
1008
1411
  }): Promise<HubWorkflowRunCancelResult>;
1412
+ /**
1413
+ * Re-run a terminal failed/cancelled run: enqueues a FRESH run of the same
1414
+ * workflow with the SAME trigger context the original ran against, linked
1415
+ * back to it via `retriedFromRunId`. The original row is never mutated —
1416
+ * execution is at-most-once, so a retry is always a new run, never a
1417
+ * requeue. The response carries the NEW run id (and the run it retried);
1418
+ * follow it with {@link getRun}/{@link watchRun}/{@link waitForRun} like any
1419
+ * other run. Throws `HubSdkError`: `RUN_NOT_RETRYABLE` when the run is not
1420
+ * terminal-failed/cancelled (queued/running/waiting, or succeeded),
1421
+ * `WORKFLOW_DISABLED` when the workflow has since been disabled, `NOT_FOUND`
1422
+ * for an unknown/foreign run id. Pass `opts.signal` to abort a slow request.
1423
+ */
1424
+ retryRun(id: string, runId: string, opts?: {
1425
+ signal?: AbortSignal;
1426
+ }): Promise<HubWorkflowRunRetried>;
1009
1427
  /**
1010
1428
  * Stream a run's live progress as an async iterable of typed events. The
1011
1429
  * first event is always a `snapshot` of the current persisted state; then
@@ -1043,7 +1461,178 @@ declare class HubWorkflowsClient {
1043
1461
  timeoutMs?: number;
1044
1462
  signal?: AbortSignal;
1045
1463
  }): Promise<HubWorkflowRunDetail>;
1046
- validate(yaml: string): Promise<HubWorkflowValidateResponse>;
1464
+ /**
1465
+ * The workflow's definition history, newest rev first — metadata only (rev,
1466
+ * attribution, note); fetch the YAML per-rev with {@link getRevision}. Empty
1467
+ * for a pre-versioning workflow until its next update.
1468
+ */
1469
+ listRevisions(id: string): Promise<HubWorkflowRevisionMeta[]>;
1470
+ /**
1471
+ * One revision WITH its YAML (and the actions compiled alongside it), for
1472
+ * diff/inspect views. Throws `HubSdkError(REVISION_NOT_FOUND)` for an
1473
+ * unknown rev, `NOT_FOUND` for an unknown/foreign workflow.
1474
+ */
1475
+ getRevision(id: string, rev: number): Promise<HubWorkflowRevision>;
1476
+ /**
1477
+ * Restore a prior rev's YAML as a NEW head revision (history is append-only)
1478
+ * through the same compile path as {@link update}, so the restored definition
1479
+ * is re-validated against today's connections/models. Throws `HubSdkError`:
1480
+ * `REVISION_NOT_FOUND` for an unknown rev, `WORKFLOW_INVALID` when the old
1481
+ * YAML no longer compiles, `CONFLICT` on a concurrent modification.
1482
+ */
1483
+ rollback(id: string, rev: number): Promise<HubWorkflow>;
1484
+ /**
1485
+ * Deterministic health stats over the workflow's last N terminal runs
1486
+ * (default 20, max 100): per-node visits/failures/cost/duration, failure
1487
+ * clusters by normalized error signature, and distillation CANDIDATES
1488
+ * (agent.run nodes with near-static outputs — labeled with their
1489
+ * measurements, never as verdicts). No model in this path.
1490
+ */
1491
+ health(id: string, opts?: {
1492
+ runs?: number;
1493
+ }): Promise<HubWorkflowHealth>;
1494
+ /**
1495
+ * Propose a definition change — the intelligence path. SERVICE-TOKEN
1496
+ * callers only (user principals get `HubSdkError(SERVICE_TOKEN_REQUIRED)`,
1497
+ * 403). The YAML is compile-validated server-side (`WORKFLOW_INVALID` on
1498
+ * failure) and appended as a `proposed` revision; the head NEVER advances
1499
+ * until an owner approves.
1500
+ */
1501
+ propose(id: string, input: HubWorkflowProposalInput): Promise<HubWorkflowProposal>;
1502
+ /**
1503
+ * Pending (proposed) and declined (rejected) revisions, newest first, with
1504
+ * their evidence — the approval surface's input.
1505
+ */
1506
+ listProposals(id: string): Promise<HubWorkflowProposal[]>;
1507
+ /**
1508
+ * Accept a proposal: its YAML lands as a NEW applied head revision through
1509
+ * the same compile + advance path as {@link rollback} (re-validated against
1510
+ * today's connections/models), and the proposal settles to `applied`.
1511
+ * Throws `HubSdkError`: `PROPOSAL_NOT_PENDING` (409) when the rev is not a
1512
+ * pending proposal, `WORKFLOW_INVALID` when it no longer compiles,
1513
+ * `CONFLICT` on a concurrent modification.
1514
+ */
1515
+ approveProposal(id: string, rev: number): Promise<HubWorkflow>;
1516
+ /**
1517
+ * Decline a proposal: the revision settles to `rejected` (head untouched);
1518
+ * an optional reason is merged into its evidence as `rejectionReason`.
1519
+ * Throws `HubSdkError(PROPOSAL_NOT_PENDING)` (409) when the rev is not a
1520
+ * pending proposal.
1521
+ */
1522
+ rejectProposal(id: string, rev: number, opts?: {
1523
+ reason?: string;
1524
+ }): Promise<HubWorkflowProposal>;
1525
+ /**
1526
+ * Mint a fresh webhook hook token, retiring the current one immediately.
1527
+ * The plaintext token is returned exactly once (only the hash is stored).
1528
+ * Requires an active webhook trigger — otherwise `HubSdkError` with
1529
+ * `NO_WEBHOOK_TRIGGER` (409).
1530
+ */
1531
+ rotateHookToken(id: string): Promise<HubWorkflowHookToken>;
1532
+ /**
1533
+ * One agent round's execution timeline, paged. `action` is the action's
1534
+ * `${steps[N]}` position and `iteration` the round's position in that
1535
+ * action's `iterations` — both exactly as the run detail serializes them.
1536
+ * Pass the previous page's `nextCursor` as `after` for the next page; a null
1537
+ * `nextCursor` means the round is fully read.
1538
+ */
1539
+ listRunSteps(id: string, runId: string, input: {
1540
+ action: number;
1541
+ iteration: number;
1542
+ after?: number;
1543
+ limit?: number;
1544
+ }): Promise<HubWorkflowRunStepsPage>;
1545
+ /**
1546
+ * Store one artifact for a run (raw bytes) and return the opaque ref — the
1547
+ * value a script.run node returns as its step output. `contentType` defaults
1548
+ * to `application/octet-stream`; `nodeId` attributes the write to a graph
1549
+ * node (owner credential only — a run-scoped token binds its own node).
1550
+ * Throws `HubSdkError(ARTIFACT_TOO_LARGE)` past the server cap.
1551
+ */
1552
+ uploadArtifact(id: string, runId: string, input: {
1553
+ name: string;
1554
+ bytes: Uint8Array;
1555
+ contentType?: string;
1556
+ nodeId?: string;
1557
+ }): Promise<HubWorkflowArtifactRef>;
1558
+ /** Metadata for every artifact of the run (never the bytes), oldest first. */
1559
+ listArtifacts(id: string, runId: string): Promise<HubWorkflowArtifactsResponse>;
1560
+ /**
1561
+ * The artifact's raw bytes with their stored content type — the route every
1562
+ * `downloadUrl` attached to an `$artifact` ref in a run detail points at.
1563
+ */
1564
+ downloadArtifact(id: string, runId: string, artifactId: string): Promise<HubWorkflowArtifactDownload>;
1565
+ /**
1566
+ * The workflow's whole keyspace as metadata (key, version, updatedAt — never
1567
+ * values), key-ordered. Bounded by the server's per-workflow key cap.
1568
+ */
1569
+ listKv(id: string): Promise<HubWorkflowKvListResponse>;
1570
+ /** One KV entry (value + version); `HubSdkError(NOT_FOUND)` when absent. */
1571
+ getKv(id: string, key: string): Promise<HubWorkflowKvEntry>;
1572
+ /**
1573
+ * Upsert a key; returns the entry with its NEW version (increments on every
1574
+ * write). Throws `HubSdkError(KV_VALUE_TOO_LARGE)` past the 64KiB value cap
1575
+ * or `KV_KEY_LIMIT` past the per-workflow key cap.
1576
+ */
1577
+ putKv(id: string, key: string, value: unknown): Promise<HubWorkflowKvEntry>;
1578
+ /**
1579
+ * Compare-and-swap: the write lands only when the stored version still
1580
+ * equals `expectedVersion`; otherwise `HubSdkError(KV_VERSION_CONFLICT)`
1581
+ * (409) — re-read and retry. Creation is {@link putKv}'s job.
1582
+ */
1583
+ casKv(id: string, key: string, expectedVersion: number, value: unknown): Promise<HubWorkflowKvEntry>;
1584
+ /** Delete a key; idempotent — `deleted` reports whether a row was removed. */
1585
+ deleteKv(id: string, key: string): Promise<HubWorkflowKvDeleteResponse>;
1586
+ /** The curated starter gallery runnable on THIS deployment: metadata,
1587
+ * parameters, referenced providers, and a concrete `previewYaml` per card. */
1588
+ listTemplates(): Promise<HubWorkflowTemplate[]>;
1589
+ /**
1590
+ * One-click create from a gallery template: substitutes `parameters` into
1591
+ * the template server-side, then runs the SAME create path as
1592
+ * {@link create}. A `{ created: false }` result is NOT an error — an
1593
+ * actionable continuation listing the connections to satisfy before
1594
+ * retrying. Invalid parameters or a compile failure throw `HubSdkError`
1595
+ * (400); an unknown template id throws `NOT_FOUND`.
1596
+ */
1597
+ instantiateTemplate(templateId: string, parameters?: Record<string, string>): Promise<HubWorkflowTemplateInstantiateResult>;
1598
+ /**
1599
+ * The caller's open decisions across all workflows — the always-available
1600
+ * "pending approvals" surface. Each entry carries its workflow's name (null
1601
+ * when the workflow was deleted while the run was parked).
1602
+ */
1603
+ listPendingDecisions(): Promise<HubWorkflowPendingDecisionsResponse>;
1604
+ /**
1605
+ * The pending decision a run is parked on. Throws `HubSdkError(NOT_FOUND)`
1606
+ * when the run is unknown/foreign or holds no pending decision.
1607
+ */
1608
+ getRunDecision(id: string, runId: string): Promise<HubWorkflowDecision>;
1609
+ /**
1610
+ * Answer the decision a run is parked on and resume it from the next action.
1611
+ * `decisionId` is REQUIRED: a run can resolve one decision and re-park on the
1612
+ * next, so an answer addressed only by run could silently land on a question
1613
+ * the caller never saw — a mismatch throws `HubSdkError(DECISION_SUPERSEDED)`.
1614
+ * Other typed failures: `INVALID_CHOICE` (400), `DECISION_ALREADY_RESOLVED` /
1615
+ * `DECISION_EXPIRED` (409), `DECISION_NOT_FOUND` (404), `RUN_NOT_WAITING`
1616
+ * (409 — answered, timed out, or cancelled first).
1617
+ */
1618
+ resolveRunDecision(id: string, runId: string, input: {
1619
+ decisionId: string;
1620
+ choice: string;
1621
+ note?: string;
1622
+ }): Promise<HubWorkflowDecisionResolveResult>;
1623
+ /**
1624
+ * Dry-run a YAML definition against the platform compiler without saving it.
1625
+ *
1626
+ * `opts.structural` selects the CI mode: the platform skips its owner-scoped
1627
+ * connection/skill/profile resolution, so the verdict depends only on the
1628
+ * definition and the deployment's capabilities — identical no matter which
1629
+ * providers the calling account has connected. Use it in pipelines that
1630
+ * assert "this YAML is well-formed"; leave it off in an editor, where naming
1631
+ * the unconnected providers is the point.
1632
+ */
1633
+ validate(yaml: string, opts?: {
1634
+ structural?: boolean;
1635
+ }): Promise<HubWorkflowValidateResponse>;
1047
1636
  schema(): Promise<HubWorkflowSchemaResponse>;
1048
1637
  }
1049
1638
  //#endregion
@@ -1120,5 +1709,5 @@ declare function parseHubEventDelivery(input: string | unknown): HubEventDeliver
1120
1709
  //#region src/redaction.d.ts
1121
1710
  declare function redactHubValue(value: unknown): unknown;
1122
1711
  //#endregion
1123
- export { type AuthenticateHubEventRequestInput, type DeriveHubEventCallbackSecretInput, HUB_API_KEY_ENV_VAR, HUB_CAPABILITY_TOKEN_ENV_VAR, HUB_URL_ENV_VAR, type HubAgentIterationSpan, type HubAgentRunDetail, type HubApiKeyConnectRequest, type HubApiKeyConnectResponse, type HubApproval, type HubApprovalCapabilityToken, type HubApprovalDecisionResponse, type HubApprovalStatus, HubApprovalsClient, HubAuditClient, type HubAuditEvent, type HubAuditListRequest, type HubAuditResponse, type HubAuthHeaders, type HubCapabilityToken, type HubChannel, type HubChannelCreateResponse, type HubChannelDeleteResponse, HubChannelsClient, type HubChannelsResponse, HubClient, type HubClientFromEnvOptions, type HubClientOptions, type HubConnection, type HubConnectionDeleteRequest, type HubConnectionDeleteResponse, type HubConnectionHealthError, type HubConnectionHealthInfo, type HubConnectionHealthRequest, type HubConnectionHealthResponse, type HubConnectionHealthStatus, type HubConnectionStartOptions, HubConnectionsClient, type HubConnectionsResponse, type HubEmailChannel, type HubEmailChannelCreateRequest, type HubEnv, type HubEnvelope, type HubErrorBody, type HubErrorCode, type HubErrorEnvelope, type HubEventCondition, type HubEventConditionScalar, type HubEventDelivery, HubEventDeliveryError, type HubEventRequestFailureCode, type HubEventRequestResult, type HubEventSignatureFailure, type HubEventSignatureResult, type HubEventSubscription, type HubEventSubscriptionCallback, type HubEventSubscriptionCreateRequest, type HubEventSubscriptionCreateResponse, type HubEventSubscriptionDeleteResponse, type HubEventSubscriptionFilter, type HubEventSubscriptionSource, HubEventSubscriptionsClient, type HubEventSubscriptionsResponse, type HubExecRequest, type HubExecResponse, HubGithubAppClient, type HubGithubAppInstallation, type HubGithubAppInstallationResponse, type HubGithubAppIsRepoInstalledRequest, type HubGithubAppIsRepoInstalledResponse, type HubGithubAppListReposResponse, type HubGithubAppMintInstallationTokenRequest, type HubGithubAppMintInstallationTokenResponse, type HubManualRunInput, type HubOAuthCallbackErrorQuery, type HubOAuthCallbackQuery, type HubOAuthCallbackResponse, type HubOAuthCallbackSuccessQuery, type HubOAuthStartRequest, type HubOAuthStartResponse, HubPermissionsClient, type HubPolicy, type HubPolicyDecision, type HubPolicyDeleteRequest, type HubPolicyDeleteResponse, type HubPolicyListRequest, type HubPolicyListResponse, type HubPolicyResponse, type HubPolicyUpdateRequest, type HubPrincipal, type HubPrincipalKind, type HubProvider, type HubProviderAuthKind, type HubProviderEvent, type HubProvidersResponse, HubSdkError, type HubStatusConnections, type HubStatusResponse, type HubSuccessEnvelope, type HubTokenListOptions, type HubTokenMintRequest, type HubTokenMintResponse, type HubTokenRevokeResponse, HubTokensClient, type HubTokensListResponse, type HubTool, type HubToolInvokeOptions, type HubToolRisk, type HubToolSearchOptions, type HubToolSource, type HubToolSourcesResponse, HubToolsClient, type HubToolsDescribeRequest, type HubToolsDescribeResponse, type HubToolsSearchRequest, type HubToolsSearchResponse, type HubUnimplementedErrorEnvelope, type HubWhatsappEmbeddedSignupCompleteRequest, type HubWhatsappEmbeddedSignupCompleteResponse, type HubWhatsappEmbeddedSignupStartRequest, type HubWhatsappEmbeddedSignupStartResponse, type HubWorkflow, type HubWorkflowAction, type HubWorkflowActionResult, type HubWorkflowEventFilter, type HubWorkflowRun, type HubWorkflowRunCancelResult, type HubWorkflowRunDetail, type HubWorkflowRunEnqueued, type HubWorkflowRunInputs, type HubWorkflowRunStatus, type HubWorkflowRunStreamEvent, type HubWorkflowRunSummary, type HubWorkflowRunsPage, type HubWorkflowSchemaResponse, type HubWorkflowTrigger, type HubWorkflowValidateResponse, type HubWorkflowValidationError, HubWorkflowsClient, type VerifyHubEventSignatureInput, authenticateHubEventRequest, deriveHubEventCallbackSecret, parseHubEventDelivery, redactHubValue, resolveHubAuth, resolveHubBaseUrl, verifyHubEventSignature };
1712
+ export { type AuthenticateHubEventRequestInput, type DeriveHubEventCallbackSecretInput, HUB_API_KEY_ENV_VAR, HUB_CAPABILITY_TOKEN_ENV_VAR, HUB_URL_ENV_VAR, type HubAgentIterationSpan, type HubAgentRunDetail, type HubApiKeyConnectRequest, type HubApiKeyConnectResponse, type HubApproval, type HubApprovalCapabilityToken, type HubApprovalDecisionResponse, type HubApprovalStatus, HubApprovalsClient, HubAuditClient, type HubAuditEvent, type HubAuditListRequest, type HubAuditResponse, type HubAuthHeaders, type HubCapabilityToken, type HubChannel, type HubChannelCreateResponse, type HubChannelDeleteResponse, HubChannelsClient, type HubChannelsResponse, HubClient, type HubClientFromEnvOptions, type HubClientOptions, type HubConnection, type HubConnectionDeleteRequest, type HubConnectionDeleteResponse, type HubConnectionHealthError, type HubConnectionHealthInfo, type HubConnectionHealthRequest, type HubConnectionHealthResponse, type HubConnectionHealthStatus, type HubConnectionStartOptions, HubConnectionsClient, type HubConnectionsResponse, type HubEmailChannel, type HubEmailChannelCreateRequest, type HubEnv, type HubEnvelope, type HubErrorBody, type HubErrorCode, type HubErrorEnvelope, type HubEventCondition, type HubEventConditionScalar, type HubEventDelivery, HubEventDeliveryError, type HubEventRequestFailureCode, type HubEventRequestResult, type HubEventSignatureFailure, type HubEventSignatureResult, type HubEventSubscription, type HubEventSubscriptionCallback, type HubEventSubscriptionCreateRequest, type HubEventSubscriptionCreateResponse, type HubEventSubscriptionDeleteResponse, type HubEventSubscriptionFilter, type HubEventSubscriptionSource, HubEventSubscriptionsClient, type HubEventSubscriptionsResponse, type HubExecRequest, type HubExecResponse, HubGithubAppClient, type HubGithubAppInstallation, type HubGithubAppInstallationResponse, type HubGithubAppIsRepoInstalledRequest, type HubGithubAppIsRepoInstalledResponse, type HubGithubAppListReposResponse, type HubGithubAppMintInstallationTokenRequest, type HubGithubAppMintInstallationTokenResponse, type HubManualRunInput, type HubOAuthCallbackErrorQuery, type HubOAuthCallbackQuery, type HubOAuthCallbackResponse, type HubOAuthCallbackSuccessQuery, type HubOAuthStartRequest, type HubOAuthStartResponse, HubPermissionsClient, type HubPolicy, type HubPolicyDecision, type HubPolicyDeleteRequest, type HubPolicyDeleteResponse, type HubPolicyListRequest, type HubPolicyListResponse, type HubPolicyResponse, type HubPolicyUpdateRequest, type HubPrincipal, type HubPrincipalKind, type HubProvider, type HubProviderAuthKind, type HubProviderEvent, type HubProvidersResponse, HubSdkError, type HubStatusConnections, type HubStatusResponse, type HubSuccessEnvelope, type HubTokenListOptions, type HubTokenMintRequest, type HubTokenMintResponse, type HubTokenRevokeResponse, HubTokensClient, type HubTokensListResponse, type HubTool, type HubToolInvokeOptions, type HubToolRisk, type HubToolSearchOptions, type HubToolSource, type HubToolSourcesResponse, HubToolsClient, type HubToolsDescribeRequest, type HubToolsDescribeResponse, type HubToolsSearchRequest, type HubToolsSearchResponse, type HubUnimplementedErrorEnvelope, type HubWhatsappEmbeddedSignupCompleteRequest, type HubWhatsappEmbeddedSignupCompleteResponse, type HubWhatsappEmbeddedSignupStartRequest, type HubWhatsappEmbeddedSignupStartResponse, type HubWorkflow, type HubWorkflowAction, type HubWorkflowActionResult, type HubWorkflowAgentStep, type HubWorkflowArtifact, type HubWorkflowArtifactDownload, type HubWorkflowArtifactRef, type HubWorkflowArtifactsResponse, type HubWorkflowCondition, type HubWorkflowConditionOp, type HubWorkflowConditionScalar, type HubWorkflowConnectionRequirement, type HubWorkflowDecision, type HubWorkflowDecisionOnTimeout, type HubWorkflowDecisionResolveResult, type HubWorkflowDecisionResolvedVia, type HubWorkflowDecisionStatus, type HubWorkflowDistillationCandidate, type HubWorkflowEdgeVerdicts, type HubWorkflowEventFilter, type HubWorkflowFailureCluster, type HubWorkflowFleetEntry, type HubWorkflowFleetInsights, type HubWorkflowFleetWindow, type HubWorkflowGraphEdge, type HubWorkflowGraphJoinRule, type HubWorkflowGraphNode, type HubWorkflowGraphSpec, type HubWorkflowHealth, type HubWorkflowHookEndpoint, type HubWorkflowHookToken, type HubWorkflowKvDeleteResponse, type HubWorkflowKvEntry, type HubWorkflowKvEntryMeta, type HubWorkflowKvListResponse, type HubWorkflowNodeHealth, type HubWorkflowOnErrorOutcome, type HubWorkflowPendingDecision, type HubWorkflowPendingDecisionsResponse, type HubWorkflowProposal, type HubWorkflowProposalInput, type HubWorkflowRevision, type HubWorkflowRevisionMeta, type HubWorkflowRevisionSource, type HubWorkflowRevisionStatus, type HubWorkflowRun, type HubWorkflowRunCancelResult, type HubWorkflowRunDetail, type HubWorkflowRunEnqueued, type HubWorkflowRunInputs, type HubWorkflowRunRetried, type HubWorkflowRunStatus, type HubWorkflowRunStepsPage, type HubWorkflowRunStreamEvent, type HubWorkflowRunSummary, type HubWorkflowRunsPage, type HubWorkflowSchemaResponse, type HubWorkflowTemplate, type HubWorkflowTemplateCategory, type HubWorkflowTemplateInstantiateResult, type HubWorkflowTemplateParameter, type HubWorkflowTrigger, type HubWorkflowValidateResponse, type HubWorkflowValidationError, HubWorkflowsClient, type VerifyHubEventSignatureInput, authenticateHubEventRequest, deriveHubEventCallbackSecret, parseHubEventDelivery, redactHubValue, resolveHubAuth, resolveHubBaseUrl, verifyHubEventSignature };
1124
1713
  //# sourceMappingURL=index.d.ts.map