@tangle-network/hub-sdk 1.0.8 → 1.0.9

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.
@@ -1053,12 +1053,7 @@ var HubWorkflowsClient = class extends WorkflowKvResource {
1053
1053
  async list() {
1054
1054
  return this.request("/v1/workflows", { method: "GET" });
1055
1055
  }
1056
- /**
1057
- * Owner-wide fleet overview: one row per workflow with its run tallies over
1058
- * a trailing window (default 7d), sorted failing-first. Answers "how are ALL
1059
- * my workflows doing" in one call — the per-workflow insights endpoint is
1060
- * the drill-down, not a way to build this row set client-side.
1061
- */
1056
+ /** Owner-wide fleet overview: one row per workflow with its run tallies over a trailing window (default 7d), sorted failing-first. */
1062
1057
  async fleetInsights(opts = {}) {
1063
1058
  const query = opts.window ? `?window=${encodeURIComponent(opts.window)}` : "";
1064
1059
  return this.request(`/v1/workflows/insights/fleet${query}`, { method: "GET" });
@@ -1066,21 +1061,17 @@ var HubWorkflowsClient = class extends WorkflowKvResource {
1066
1061
  async get(id) {
1067
1062
  return this.request(`/v1/workflows/${encodeURIComponent(id)}`, { method: "GET" });
1068
1063
  }
1069
- async create(yaml) {
1070
- return this.request("/v1/workflows", jsonInit("POST", { yaml }));
1064
+ async create(yaml, opts = {}) {
1065
+ return this.request("/v1/workflows", jsonInit("POST", {
1066
+ yaml,
1067
+ ...opts
1068
+ }));
1071
1069
  }
1072
- /**
1073
- * Replace the workflow's definition from YAML (recompiled server-side,
1074
- * triggers reconciled). Every landed update appends a revision;
1075
- * `opts.note` rides onto that revision row (e.g. "why this change"), visible
1076
- * in {@link listRevisions}. Throws `HubSdkError`: `WORKFLOW_INVALID` when the
1077
- * YAML doesn't compile or its connections aren't met, `CONFLICT` on a
1078
- * concurrent modification, `NOT_FOUND` for an unknown/foreign id.
1079
- */
1070
+ /** Replace the workflow's definition from YAML (recompiled server-side, triggers reconciled). */
1080
1071
  async update(id, yaml, opts = {}) {
1081
1072
  return this.request(`/v1/workflows/${encodeURIComponent(id)}`, jsonInit("PUT", {
1082
1073
  yaml,
1083
- ...opts.note !== void 0 ? { note: opts.note } : {}
1074
+ ...opts
1084
1075
  }));
1085
1076
  }
1086
1077
  async delete(id) {
@@ -1105,91 +1096,46 @@ var HubWorkflowsClient = class extends WorkflowKvResource {
1105
1096
  const query = params.toString();
1106
1097
  return this.request(`/v1/workflows/${encodeURIComponent(id)}/runs${query ? `?${query}` : ""}`, { method: "GET" });
1107
1098
  }
1108
- /**
1109
- * Enqueue an immediate ("Run now") run and return its `runId`. The run goes
1110
- * through the identical execution path a trigger delivery uses.
1111
- *
1112
- * `inputs` supplies the trigger fields the workflow reads (its
1113
- * {@link HubWorkflow.manualRunInputs}), as a flat `{ path: value }` map — e.g.
1114
- * `{ "pull_request.number": "123" }`. Omit it for a one-click run of a
1115
- * workflow that reads no trigger fields. Throws `HubSdkError`:
1116
- * `MISSING_RUN_INPUTS` when a required field is absent (`details.missing`
1117
- * names them), `NOT_FOUND` for an unknown/foreign id. A paused workflow
1118
- * still runs once; pausing only stops its triggers. Pass `opts.signal` to
1119
- * abort a slow request.
1120
- */
1099
+ /** Enqueue an immediate ("Run now") run and return its `runId`. */
1121
1100
  async run(id, inputs, opts = {}) {
1122
1101
  const hasInputs = inputs !== void 0 && Object.keys(inputs).length > 0;
1123
1102
  return this.request(`/v1/workflows/${encodeURIComponent(id)}/run`, {
1124
- ...jsonInit("POST", hasInputs ? { inputs } : {}),
1103
+ ...jsonInit("POST", {
1104
+ ...hasInputs ? { inputs } : {},
1105
+ ...opts.resumeRunId ? { resumeRunId: opts.resumeRunId } : {},
1106
+ ...opts.sourceSha ? { sourceSha: opts.sourceSha } : {},
1107
+ ...opts.expectedRev !== void 0 ? { expectedRev: opts.expectedRev } : {}
1108
+ }),
1125
1109
  ...opts.signal ? { signal: opts.signal } : {}
1126
1110
  });
1127
1111
  }
1128
- /**
1129
- * A single run's full detail: per-action `output` + `agentRun` execution
1130
- * detail (size-capped server-side) and the trigger context — the deep "why
1131
- * did this run do what it did" view. `NOT_FOUND` when the run is unknown or
1132
- * does not belong to both the caller and this workflow.
1133
- */
1134
- async getRun(id, runId, opts = {}) {
1135
- return this.request(`/v1/workflows/${encodeURIComponent(id)}/runs/${encodeURIComponent(runId)}`, {
1112
+ async getRun(id, runIdOrOptions, options = {}) {
1113
+ const runId = typeof runIdOrOptions === "string" ? runIdOrOptions : id;
1114
+ const opts = typeof runIdOrOptions === "string" ? options : runIdOrOptions ?? {};
1115
+ const path = typeof runIdOrOptions === "string" ? `${encodeURIComponent(id)}/runs/${encodeURIComponent(runId)}` : `runs/${encodeURIComponent(runId)}`;
1116
+ const query = new URLSearchParams();
1117
+ for (const ref of opts.blobRefs ?? []) query.append("blobRef", ref);
1118
+ if (opts.trace) query.set("trace", "1");
1119
+ return this.request(`/v1/workflows/${path}${query.size ? `?${query}` : ""}`, {
1136
1120
  method: "GET",
1137
1121
  ...opts.signal ? { signal: opts.signal } : {}
1138
1122
  });
1139
1123
  }
1140
- /**
1141
- * Stop a queued or in-flight run. A `queued` run is cancelled synchronously
1142
- * and comes back `{ status: "cancelled" }` (already terminal); a `running` run
1143
- * is signalled to abort and comes back `{ status: "cancelling", signalled }` —
1144
- * it settles `cancelled` a moment later as its current action tears down, which
1145
- * a {@link watchRun}/{@link getRun} observes. Throws `HubSdkError`:
1146
- * `RUN_NOT_CANCELLABLE` when the run already finished, `NOT_FOUND` for an
1147
- * unknown/foreign run id. Pass `opts.signal` to abort a slow request.
1148
- */
1124
+ /** Stop a queued or in-flight run. */
1149
1125
  async cancel(id, runId, opts = {}) {
1150
1126
  return this.request(`/v1/workflows/${encodeURIComponent(id)}/runs/${encodeURIComponent(runId)}/cancel`, {
1151
1127
  method: "POST",
1152
1128
  ...opts.signal ? { signal: opts.signal } : {}
1153
1129
  });
1154
1130
  }
1155
- /**
1156
- * Re-run a terminal failed/cancelled run: enqueues a FRESH run of the same
1157
- * workflow with the SAME trigger context the original ran against, linked
1158
- * back to it via `retriedFromRunId`. The original row is never mutated —
1159
- * execution is at-most-once, so a retry is always a new run, never a
1160
- * requeue. The response carries the NEW run id (and the run it retried);
1161
- * follow it with {@link getRun}/{@link watchRun}/{@link waitForRun} like any
1162
- * other run. Throws `HubSdkError`: `RUN_NOT_RETRYABLE` when the run is not
1163
- * terminal-failed/cancelled (queued/running/waiting, or succeeded),
1164
- * `NOT_FOUND` for an unknown/foreign run id; a workflow paused since the
1165
- * failure still retries. Pass `opts.signal` to abort a slow request.
1166
- */
1131
+ /** Re-run a terminal failed/cancelled run: enqueues a FRESH run of the same workflow with the SAME trigger context the original ran against, linked back to it via `retriedFromRunId`. */
1167
1132
  async retryRun(id, runId, opts = {}) {
1168
1133
  return this.request(`/v1/workflows/${encodeURIComponent(id)}/runs/${encodeURIComponent(runId)}/retry`, {
1169
1134
  method: "POST",
1170
1135
  ...opts.signal ? { signal: opts.signal } : {}
1171
1136
  });
1172
1137
  }
1173
- /**
1174
- * Stream a run's live progress as an async iterable of typed events. The
1175
- * first event is always a `snapshot` of the current persisted state; then
1176
- * `action.*` / `iteration.*` / `token` ticks arrive as the run executes;
1177
- * `ping` is a keepalive; a terminal `run.done` ends the iteration. If the run
1178
- * is already finished when the stream opens, it yields the snapshot then
1179
- * `run.done` and completes.
1180
- *
1181
- * Live ticks require the worker executing the run to share the API process;
1182
- * across instances only `snapshot` + `run.done` (from the server's terminal
1183
- * poll) arrive — the persisted record, read via {@link getRun}, stays the
1184
- * source of truth. Pass `signal` to cancel; iterating to `run.done` (or
1185
- * breaking early) releases the connection.
1186
- *
1187
- * A stream that ends before `run.done` or `run.waiting` (the Platform is
1188
- * restarting or handing over) is reopened after a second, as is one refused
1189
- * with `SERVICE_DRAINING`; the reopened stream starts with a fresh
1190
- * `snapshot`. After 30 reopens in a row that deliver nothing it throws
1191
- * `HubSdkError(WORKFLOW_STREAM_INTERRUPTED)`.
1192
- */
1138
+ /** Stream a run's live progress as an async iterable of typed events. */
1193
1139
  async *watchRun(id, runId, opts = {}) {
1194
1140
  const openStream = this.stream;
1195
1141
  if (!openStream) throw new HubSdkError({
@@ -1256,21 +1202,7 @@ var HubWorkflowsClient = class extends WorkflowKvResource {
1256
1202
  await reader.cancel().catch(() => {});
1257
1203
  }
1258
1204
  }
1259
- /**
1260
- * Poll {@link getRun} until the run reaches a terminal state (`succeeded` or
1261
- * `failed`) and return its detail. The scripting primitive behind "run and
1262
- * print the result": pairs with {@link run} for a one-call trigger-and-wait.
1263
- *
1264
- * Returns as soon as the run leaves the active set (`queued` / `running`) —
1265
- * i.e. on `succeeded`, `failed`, or any future non-active status — so a new
1266
- * terminal state can never hang the wait. Polls every `pollIntervalMs`
1267
- * (default 2000). With `timeoutMs` set, throws
1268
- * `HubSdkError(WORKFLOW_RUN_TIMEOUT)` — carrying the last observed status on
1269
- * `details.status` — only once the deadline has actually passed; the last
1270
- * wait is clamped to the remaining time so a `timeoutMs` shorter than the
1271
- * poll interval still waits the full requested window rather than giving up a
1272
- * poll early. Pass `signal` to cancel the wait between polls.
1273
- */
1205
+ /** Poll {@link getRun} until the run reaches a terminal state (`succeeded` or `failed`) and return its detail. */
1274
1206
  async waitForRun(id, runId, opts = {}) {
1275
1207
  const pollIntervalMs = opts.pollIntervalMs ?? 2e3;
1276
1208
  if (!Number.isFinite(pollIntervalMs) || pollIntervalMs <= 0) throw new HubSdkError({
@@ -1328,34 +1260,16 @@ var HubWorkflowsClient = class extends WorkflowKvResource {
1328
1260
  async getRevision(id, rev) {
1329
1261
  return this.request(`/v1/workflows/${encodeURIComponent(id)}/revisions/${encodeURIComponent(String(rev))}`, { method: "GET" });
1330
1262
  }
1331
- /**
1332
- * Restore a prior rev's YAML as a NEW head revision (history is append-only)
1333
- * through the same compile path as {@link update}, so the restored definition
1334
- * is re-validated against today's connections/models. Throws `HubSdkError`:
1335
- * `REVISION_NOT_FOUND` for an unknown rev, `WORKFLOW_INVALID` when the old
1336
- * YAML no longer compiles, `CONFLICT` on a concurrent modification.
1337
- */
1263
+ /** Restore a prior rev's YAML as a NEW head revision (history is append-only) through the same compile path as {@link update}, so the restored definition is re-validated against today's connections/models. */
1338
1264
  async rollback(id, rev) {
1339
1265
  return this.request(`/v1/workflows/${encodeURIComponent(id)}/rollback`, jsonInit("POST", { rev }));
1340
1266
  }
1341
- /**
1342
- * Deterministic health stats over the workflow's last N terminal runs
1343
- * (default 20, max 100): per-node visits/failures/cost/duration, failure
1344
- * clusters by normalized error signature, and distillation CANDIDATES
1345
- * (agent.run nodes with near-static outputs — labeled with their
1346
- * measurements, never as verdicts). No model in this path.
1347
- */
1267
+ /** Deterministic health stats over the workflow's last N terminal runs (default 20, max 100): per-node visits/failures/cost/duration, failure clusters by normalized error signature, and distillation CANDIDATES (agent.run nodes with near-static outputs — labeled with their measurements, never as verdicts). */
1348
1268
  async health(id, opts = {}) {
1349
1269
  const query = opts.runs !== void 0 ? `?runs=${opts.runs}` : "";
1350
1270
  return this.request(`/v1/workflows/${encodeURIComponent(id)}/health${query}`, { method: "GET" });
1351
1271
  }
1352
- /**
1353
- * One agent round's execution timeline, paged. `action` is the action's
1354
- * `${steps[N]}` position and `iteration` the round's position in that
1355
- * action's `iterations` — both exactly as the run detail serializes them.
1356
- * Pass the previous page's `nextCursor` as `after` for the next page; a null
1357
- * `nextCursor` means the round is fully read.
1358
- */
1272
+ /** One agent round's execution timeline, paged. */
1359
1273
  async listRunSteps(id, runId, input) {
1360
1274
  const params = new URLSearchParams({
1361
1275
  action: String(input.action),
@@ -1365,13 +1279,7 @@ var HubWorkflowsClient = class extends WorkflowKvResource {
1365
1279
  if (input.limit !== void 0) params.set("limit", String(input.limit));
1366
1280
  return this.request(`/v1/workflows/${encodeURIComponent(id)}/runs/${encodeURIComponent(runId)}/steps?${params.toString()}`, { method: "GET" });
1367
1281
  }
1368
- /**
1369
- * Store one artifact for a run (raw bytes) and return the opaque ref — the
1370
- * value a script.run node returns as its step output. `contentType` defaults
1371
- * to `application/octet-stream`; `nodeId` attributes the write to a graph
1372
- * node (owner credential only — a run-scoped token binds its own node).
1373
- * Throws `HubSdkError(ARTIFACT_TOO_LARGE)` past the server cap.
1374
- */
1282
+ /** Store one artifact for a run (raw bytes) and return the opaque ref — the value a script.run node returns as its step output. */
1375
1283
  async uploadArtifact(id, runId, input) {
1376
1284
  const headers = {
1377
1285
  "Content-Type": input.contentType ?? "application/octet-stream",
@@ -1405,14 +1313,7 @@ var HubWorkflowsClient = class extends WorkflowKvResource {
1405
1313
  async listTemplates() {
1406
1314
  return this.request("/v1/workflows/templates", { method: "GET" });
1407
1315
  }
1408
- /**
1409
- * One-click create from a gallery template: substitutes `parameters` into
1410
- * the template server-side, then runs the SAME create path as
1411
- * {@link create}. A `{ created: false }` result is NOT an error — an
1412
- * actionable continuation listing the connections to satisfy before
1413
- * retrying. Invalid parameters or a compile failure throw `HubSdkError`
1414
- * (400); an unknown template id throws `NOT_FOUND`.
1415
- */
1316
+ /** One-click create from a gallery template: substitutes `parameters` into the template server-side, then runs the SAME create path as {@link create}. */
1416
1317
  async instantiateTemplate(templateId, parameters) {
1417
1318
  return this.request(`/v1/workflows/templates/${encodeURIComponent(templateId)}/instantiate`, jsonInit("POST", parameters ? { parameters } : {}));
1418
1319
  }
@@ -1431,32 +1332,15 @@ var HubWorkflowsClient = class extends WorkflowKvResource {
1431
1332
  async getRunDecision(id, runId) {
1432
1333
  return this.request(`/v1/workflows/${encodeURIComponent(id)}/runs/${encodeURIComponent(runId)}/decision`, { method: "GET" });
1433
1334
  }
1434
- /**
1435
- * Answer the decision a run is parked on and resume it from the next action.
1436
- * `decisionId` is REQUIRED: a run can resolve one decision and re-park on the
1437
- * next, so an answer addressed only by run could silently land on a question
1438
- * the caller never saw — a mismatch throws `HubSdkError(DECISION_SUPERSEDED)`.
1439
- * Other typed failures: `INVALID_CHOICE` (400), `DECISION_ALREADY_RESOLVED` /
1440
- * `DECISION_EXPIRED` (409), `DECISION_NOT_FOUND` (404), `RUN_NOT_WAITING`
1441
- * (409 — answered, timed out, or cancelled first).
1442
- */
1335
+ /** Answer the decision a run is parked on and resume it from the next action. */
1443
1336
  async resolveRunDecision(id, runId, input) {
1444
1337
  return this.request(`/v1/workflows/${encodeURIComponent(id)}/runs/${encodeURIComponent(runId)}/decision/resolve`, jsonInit("POST", input));
1445
1338
  }
1446
- /**
1447
- * Dry-run a YAML definition against the platform compiler without saving it.
1448
- *
1449
- * `opts.structural` selects the CI mode: the platform skips its owner-scoped
1450
- * connection/skill/profile resolution, so the verdict depends only on the
1451
- * definition and the deployment's capabilities — identical no matter which
1452
- * providers the calling account has connected. Use it in pipelines that
1453
- * assert "this YAML is well-formed"; leave it off in an editor, where naming
1454
- * the unconnected providers is the point.
1455
- */
1339
+ /** Dry-run a YAML definition against the platform compiler without saving it. */
1456
1340
  async validate(yaml, opts = {}) {
1457
1341
  return this.request("/v1/workflows/validate", jsonInit("POST", {
1458
1342
  yaml,
1459
- ...opts.structural ? { structural: true } : {}
1343
+ ...opts
1460
1344
  }));
1461
1345
  }
1462
1346
  async schema() {
@@ -1576,4 +1460,4 @@ var HubClient = class HubClient extends HubTransport {
1576
1460
  //#endregion
1577
1461
  export { HubLinesClient as C, HubAllowancesClient as D, HubAppsClient as E, jsonInit as O, HubManagedNumbersClient as S, HubKnowledgeManagementClient as T, resolveHubBaseUrl as _, HubChannelsClient as a, isHubUnauthenticated as b, HubInboundWebhooksClient as c, HubPermissionsClient as d, HubTokensClient as f, resolveHubAuth as g, HUB_URL_ENV_VAR as h, HubGithubAppClient as i, HubToolsClient as l, HUB_CAPABILITY_TOKEN_ENV_VAR as m, HubWorkflowsClient as n, HubEventSubscriptionsClient as o, HUB_API_KEY_ENV_VAR as p, HubAuditClient as r, HubConnectionsClient as s, HubClient as t, HubApprovalsClient as u, HubSdkError as v, HubKnowledgeClient as w, redactHubValue as x, HubTransport as y };
1578
1462
 
1579
- //# sourceMappingURL=client-gF4iRjd3.js.map
1463
+ //# sourceMappingURL=client-cT9lHMpc.js.map