@tangle-network/hub-sdk 0.15.2-develop.20260728203818.782046b → 0.15.2-develop.20260729013934.7f247ec

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