You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The client defaults to a 30-minute task timeout and a 2-minute timeout per HTTP request. Override them with `taskTimeoutMs` and `requestTimeoutMs` when creating the client, or use `timeoutMs` for one task.
160
+
133
161
Use key-pool helpers with a Redis-like runtime:
134
162
135
163
```ts
@@ -141,6 +169,7 @@ import {
141
169
const acquired =awaitacquireRunningHubKey({
142
170
providerId: "runninghub",
143
171
defaultConcurrency: 2,
172
+
leaseSeconds: 60*60,
144
173
runtime: redisLikeRuntime,
145
174
keys: [
146
175
{
@@ -169,6 +198,8 @@ try {
169
198
}
170
199
```
171
200
201
+
Choose a lease long enough for the longest expected task. Each successful acquisition refreshes the lease, and the default is one hour.
202
+
172
203
## What You Can Build With It
173
204
174
205
- A multi-provider AIGC backend.
@@ -232,6 +263,7 @@ npm run harness:verify:project
232
263
npm run type-check
233
264
npm run build
234
265
npm test
266
+
npm run test:package
235
267
```
236
268
237
269
Use the full release gate before publishing or tagging:
Copy file name to clipboardExpand all lines: docs/api-reference.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,12 @@ Normalizes a source catalog record into a complete RunningHub catalog item.
57
57
58
58
Creates a minimal RunningHub submit/poll client. Host applications should wrap this client with their own permission, quota, credential, and audit layers.
59
59
60
+
Client options include `requestTimeoutMs` for individual HTTP requests and `taskTimeoutMs` for the complete polling lifecycle. Both have bounded defaults. `runTask` also accepts a per-task `timeoutMs` and an `AbortSignal` through `signal`.
61
+
62
+
### `RunningHubError` and `isRunningHubError(value)`
63
+
64
+
RunningHub failures use a typed error with `code`, `stage`, optional HTTP `status`, and a `retryable` hint. Codes distinguish invalid configuration/input, cancellation, request or response failures, upstream rejection, task failure/timeout, unknown status, and missing output.
65
+
60
66
### `extractRunningHubOutputUrls(value)`
61
67
62
68
Extracts image, video, and audio URLs from nested RunningHub result payloads.
@@ -65,6 +71,8 @@ Extracts image, video, and audio URLs from nested RunningHub result payloads.
65
71
66
72
Provide key-pool concurrency helpers against a Redis-like runtime interface.
67
73
74
+
`acquireRunningHubKey` accepts an optional `leaseSeconds` value between 30 seconds and 24 hours. Successful acquisitions refresh the counter lease.
75
+
68
76
### `orderRunningHubKeys(keys, preferredKeyId?)`
69
77
70
78
Orders enabled keys by preferred key, default key, then other enabled keys.
The client applies bounded request and task timeouts, accepts an `AbortSignal`, and reports typed `RunningHubError` failures. The key pool uses a configurable concurrency lease so stale counters can recover.
23
+
22
24
## Interfaces
23
25
24
26
| Interface | Direction | Contract |
@@ -33,6 +35,8 @@ The RunningHub system provides reusable contracts and helpers for RunningHub AI
33
35
- App/workflow IDs are mixed.
34
36
- Fields do not match upstream RunningHub node info.
35
37
- Poll returns success with no usable output URL.
38
+
- Poll returns an unknown status or exceeds its timeout.
if(!apiKey)thrownewRunningHubError("INVALID_CONFIGURATION","RunningHub apiKey is required",{stage: "configuration"});
46
+
if(!/^https?:\/\//i.test(baseUrl))thrownewRunningHubError("INVALID_CONFIGURATION","RunningHub baseUrl must be an HTTP(S) URL",{stage: "configuration"});
thrownewError(safeText(submitData.msg||submitRaw.message||submitRaw.msg,"RunningHub did not return a valid task id"));
81
+
thrownewRunningHubError("UPSTREAM_REJECTED",safeText(submitData.msg||submitRaw.message||submitRaw.msg,"RunningHub did not return a valid task id"),{stage: "submit"});
73
82
}
74
83
75
84
awaitinput.onHeartbeat?.({
@@ -81,13 +90,19 @@ export function createRunningHubClient(options: RunningHubClientOptions) {
0 commit comments