@vibedev-si/dsh-vibedev 0.3.4 → 0.3.6
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/README.md +42 -3
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/client/client.js +1328 -75
- package/lib/account/index.d.ts +40 -6
- package/lib/account/latency.d.ts +81 -0
- package/lib/{anthropic-messages-KOS0z8Fy.js → anthropic-messages-BgIfgjNt.js} +11 -11
- package/lib/audio/request.d.ts +5 -0
- package/lib/feedback/client-info.d.ts +51 -0
- package/lib/feedback/index.d.ts +46 -0
- package/lib/feedback/observe.d.ts +43 -0
- package/lib/feedback/queue.d.ts +110 -0
- package/lib/feedback/recent-errors.d.ts +59 -0
- package/lib/feedback/routes.d.ts +31 -0
- package/lib/feedback/uploader.d.ts +131 -0
- package/lib/feedback/wire.d.ts +128 -0
- package/lib/gateway/assets.d.ts +38 -5
- package/lib/gateway/catalog.d.ts +11 -0
- package/lib/gateway/errors.d.ts +10 -3
- package/lib/gateway/http.d.ts +12 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +2008 -373
- package/lib/{node-vkDR3GtK.js → node-Br-0fshF.js} +2 -2
- package/lib/{node-Cujw_a4_.js → node-D58f7Ea6.js} +5 -5
- package/lib/video/plan.d.ts +17 -2
- package/package.json +4 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sends queued feedback to the gateway, one upload at a time, oldest first,
|
|
3
|
+
* each only under the VibeDev account it belongs to (queue.ts, `FeedbackOwner`):
|
|
4
|
+
* the account signed in when it was given; feedback given while signed out
|
|
5
|
+
* goes with the next account that signs in. Feedback of another account waits
|
|
6
|
+
* — within the queue's caps — until that account is back; it is never sent
|
|
7
|
+
* under a different user. The credential is pinned for each request: a renewal
|
|
8
|
+
* after a 401 is used only when it is still the same account.
|
|
9
|
+
*
|
|
10
|
+
* Every answer of the contract is handled:
|
|
11
|
+
*
|
|
12
|
+
* - 201 created, 200 the same id and content already received: done;
|
|
13
|
+
* - 400 invalid, 403 not allowed, 409 id reused with other content, 415 not
|
|
14
|
+
* JSON: dropped (sending it again cannot help);
|
|
15
|
+
* - 401: the credential's owner renews it and the same body goes once more; a
|
|
16
|
+
* second refusal waits for a sign-in or the next try;
|
|
17
|
+
* - 413 too large: the attachment is halved, as a new body with a new id;
|
|
18
|
+
* - 429 and 503: after `Retry-After` (else a back-off), the same body;
|
|
19
|
+
* - 404 (an older gateway, or the feature not on yet): kept, tried again in hours;
|
|
20
|
+
* - no answer, 5xx: a back-off with jitter, from 30 s up to an hour;
|
|
21
|
+
* - any other answer: the back-off, and dropped after the fifth.
|
|
22
|
+
*
|
|
23
|
+
* A retry always resends the stored body byte for byte. Bodies are never logged.
|
|
24
|
+
* @module dsh-vibedev/feedback/uploader
|
|
25
|
+
*/
|
|
26
|
+
import type { AccountIdentity } from '../account/index.js';
|
|
27
|
+
import { type GatewayCredential } from '../gateway/http.js';
|
|
28
|
+
import type { FeedbackQueue } from './queue.js';
|
|
29
|
+
import { type FeedbackClient, type FeedbackDraft } from './wire.js';
|
|
30
|
+
/** What became of feedback given through the menu, as far as the dialog needs to know. */
|
|
31
|
+
export type SubmitOutcome = {
|
|
32
|
+
readonly status: 'sent';
|
|
33
|
+
}
|
|
34
|
+
/** Kept to send later: `offline` (no connection), `later` (the gateway asked to wait or does not take it yet). */
|
|
35
|
+
| {
|
|
36
|
+
readonly status: 'queued';
|
|
37
|
+
readonly reason: 'offline' | 'later' | 'signed-out';
|
|
38
|
+
} | {
|
|
39
|
+
readonly status: 'rejected';
|
|
40
|
+
readonly code: string;
|
|
41
|
+
};
|
|
42
|
+
/** Construction options; clocks, timers, randomness, ids and fetch are test seams. */
|
|
43
|
+
export interface FeedbackUploaderOptions {
|
|
44
|
+
/** The gateway, and the plugin's user agent. */
|
|
45
|
+
readonly gateway: {
|
|
46
|
+
readonly origin: string;
|
|
47
|
+
readonly userAgent: string;
|
|
48
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
49
|
+
};
|
|
50
|
+
readonly queue: FeedbackQueue;
|
|
51
|
+
/** The client block (app, versions, os, locale). */
|
|
52
|
+
readonly client: () => FeedbackClient;
|
|
53
|
+
/** Who is signed in now, and the VibeDev user id (the account service). */
|
|
54
|
+
readonly identity: () => Promise<AccountIdentity>;
|
|
55
|
+
/** Let a credential's owner renew it after the gateway refused it. */
|
|
56
|
+
readonly rejectCredential: (credential: GatewayCredential) => Promise<void>;
|
|
57
|
+
readonly log?: (message: string) => void;
|
|
58
|
+
readonly now?: () => number;
|
|
59
|
+
/** Uniform in [0, 1), for the jitter. */
|
|
60
|
+
readonly random?: () => number;
|
|
61
|
+
readonly setTimeout?: (callback: () => void, ms: number) => unknown;
|
|
62
|
+
readonly clearTimeout?: (handle: unknown) => void;
|
|
63
|
+
readonly newId?: () => string;
|
|
64
|
+
}
|
|
65
|
+
/** The feedback uploader. */
|
|
66
|
+
export declare class FeedbackUploader {
|
|
67
|
+
private readonly options;
|
|
68
|
+
private flushing;
|
|
69
|
+
private again;
|
|
70
|
+
private timer;
|
|
71
|
+
private disposed;
|
|
72
|
+
private recording;
|
|
73
|
+
private readonly waiters;
|
|
74
|
+
/** Feedback of an account not identified when it was given: the credential that gave it, in this run only. */
|
|
75
|
+
private readonly bindings;
|
|
76
|
+
private readonly now;
|
|
77
|
+
/**
|
|
78
|
+
* @param options - the gateway, the queue, the client block, and who is signed in.
|
|
79
|
+
*/
|
|
80
|
+
constructor(options: FeedbackUploaderOptions);
|
|
81
|
+
/**
|
|
82
|
+
* Queue one piece of feedback for the account signed in now, and try to send it.
|
|
83
|
+
* @param draft - what it says.
|
|
84
|
+
* @param locale - the locale the user chose it in, when known (the menu's dialog).
|
|
85
|
+
* @returns the body id, or undefined when the draft says nothing the gateway takes.
|
|
86
|
+
*/
|
|
87
|
+
enqueue(draft: FeedbackDraft, locale?: string): Promise<string | undefined>;
|
|
88
|
+
/**
|
|
89
|
+
* Note who gave it and keep it. One at a time, so the queue keeps the order feedback was given in.
|
|
90
|
+
*/
|
|
91
|
+
private record;
|
|
92
|
+
/**
|
|
93
|
+
* Queue feedback from the dialog (for the account signed in now) and say what became of it: sent, kept for later,
|
|
94
|
+
* or refused.
|
|
95
|
+
* @param draft - what it says.
|
|
96
|
+
* @param locale - the dialog's locale.
|
|
97
|
+
* @param waitMs - how long to wait for the first answer before calling it kept.
|
|
98
|
+
* @returns the outcome.
|
|
99
|
+
*/
|
|
100
|
+
submit(draft: FeedbackDraft, locale?: string, waitMs?: number): Promise<SubmitOutcome>;
|
|
101
|
+
/** The account changed (a sign-in, a sign-out, a renewal): its feedback, and what waited on a refused renewal, goes now. */
|
|
102
|
+
credentialChanged(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Send what is due for the account signed in now, one at a time; a call while sending makes the loop look once
|
|
105
|
+
* more when it ends.
|
|
106
|
+
* @returns once nothing more can be sent now.
|
|
107
|
+
*/
|
|
108
|
+
flush(): Promise<void>;
|
|
109
|
+
/** Stop: no new attempt starts and the timer is cleared (the queue stays on disk). */
|
|
110
|
+
dispose(): void;
|
|
111
|
+
/** Whether an item may go out under this account. */
|
|
112
|
+
private sendable;
|
|
113
|
+
private identity;
|
|
114
|
+
private drain;
|
|
115
|
+
/**
|
|
116
|
+
* Feedback given signed out (or by an account not identified then) belongs, from its first attempt under a known
|
|
117
|
+
* account on, to that account, so a retry never changes hands.
|
|
118
|
+
*/
|
|
119
|
+
private claim;
|
|
120
|
+
/** One POST of the stored body with the account's credential, its answer mapped onto the contract. */
|
|
121
|
+
private attempt;
|
|
122
|
+
/** 30 s doubling per attempt up to an hour, times a jitter of 0.5–1.5. */
|
|
123
|
+
private backoff;
|
|
124
|
+
private jitter;
|
|
125
|
+
/** What this account can send waits `ms` (its first item's turn); whoever waits on an answer hears it is kept. */
|
|
126
|
+
private park;
|
|
127
|
+
private release;
|
|
128
|
+
private settle;
|
|
129
|
+
private schedule;
|
|
130
|
+
private cancel;
|
|
131
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The feedback upload contract: `POST {origin}/v1/account/feedback` with the
|
|
3
|
+
* account's credential (the one `GET /v1/account/auth/me` carries) and a
|
|
4
|
+
* strict JSON body — the gateway refuses unknown fields, so a body holds
|
|
5
|
+
* nothing else. Limits: text at most 4,000 code points, an attachment at most
|
|
6
|
+
* 256 KiB of UTF-8, the whole body at most 300 KiB; short fields carry no
|
|
7
|
+
* control characters. Text and attachments are measured as the gateway stores
|
|
8
|
+
* them, with U+0000 as U+FFFD.
|
|
9
|
+
* @module dsh-vibedev/feedback/wire
|
|
10
|
+
*/
|
|
11
|
+
/** Gateway path of the upload. */
|
|
12
|
+
export declare const FEEDBACK_PATH = "/v1/account/feedback";
|
|
13
|
+
/** The categories DeepSeek Harness files feedback under (`FEEDBACK_CATEGORIES` in @deepseek-ai/dsh-command-feedback). */
|
|
14
|
+
export declare const FEEDBACK_CATEGORIES: readonly ["task-result", "instruction-following", "product-interaction", "service-stability", "resource-cost", "security-privacy-permission", "other"];
|
|
15
|
+
export type FeedbackCategory = typeof FEEDBACK_CATEGORIES[number];
|
|
16
|
+
/** Where the feedback came from: a rated assistant message, `/feedback`, or the account menu's dialog. */
|
|
17
|
+
export type FeedbackSource = 'message' | 'command' | 'menu';
|
|
18
|
+
export type FeedbackRating = 'up' | 'down';
|
|
19
|
+
export declare const MAX_TEXT_CODE_POINTS = 4000;
|
|
20
|
+
export declare const MAX_ATTACHMENT_BYTES = 262144;
|
|
21
|
+
export declare const MAX_BODY_BYTES = 307200;
|
|
22
|
+
/** Which app and environment sent it. */
|
|
23
|
+
export interface FeedbackClient {
|
|
24
|
+
/** `vibedev-desktop`, `vibedev-web`, or another client's own name (1..64). */
|
|
25
|
+
readonly app: string;
|
|
26
|
+
readonly appVersion?: string;
|
|
27
|
+
readonly dshVersion?: string;
|
|
28
|
+
readonly pluginVersion?: string;
|
|
29
|
+
readonly os?: {
|
|
30
|
+
readonly platform: string;
|
|
31
|
+
readonly version: string;
|
|
32
|
+
readonly arch: string;
|
|
33
|
+
};
|
|
34
|
+
readonly locale?: string;
|
|
35
|
+
}
|
|
36
|
+
/** What the feedback is about, by reference only. */
|
|
37
|
+
export interface FeedbackContext {
|
|
38
|
+
readonly sessionRef?: string;
|
|
39
|
+
readonly messageRef?: string;
|
|
40
|
+
}
|
|
41
|
+
/** Something the user chose to send along. */
|
|
42
|
+
export interface FeedbackAttachment {
|
|
43
|
+
readonly kind: 'turn-excerpt' | 'error-log';
|
|
44
|
+
/** Only ever sent after the user ticked the box that sends it. */
|
|
45
|
+
readonly consent: true;
|
|
46
|
+
readonly content: string;
|
|
47
|
+
}
|
|
48
|
+
/** One upload. `id` is the idempotency key: a retry resends the same id with the identical body. */
|
|
49
|
+
export interface FeedbackBody {
|
|
50
|
+
readonly id: string;
|
|
51
|
+
readonly source: FeedbackSource;
|
|
52
|
+
readonly rating?: FeedbackRating | null;
|
|
53
|
+
readonly category?: FeedbackCategory | null;
|
|
54
|
+
readonly text?: string;
|
|
55
|
+
readonly client: FeedbackClient;
|
|
56
|
+
readonly context?: FeedbackContext;
|
|
57
|
+
readonly attachment?: FeedbackAttachment;
|
|
58
|
+
}
|
|
59
|
+
/** What one piece of feedback says, before it gets an id and the client facts. */
|
|
60
|
+
export interface FeedbackDraft {
|
|
61
|
+
readonly source: FeedbackSource;
|
|
62
|
+
readonly rating?: FeedbackRating;
|
|
63
|
+
readonly category?: FeedbackCategory;
|
|
64
|
+
readonly text?: string;
|
|
65
|
+
readonly context?: FeedbackContext;
|
|
66
|
+
readonly attachment?: FeedbackAttachment;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Free text as the gateway stores and measures it: U+0000 becomes U+FFFD (PostgreSQL text cannot hold it), three bytes
|
|
70
|
+
* instead of one, before any limit is checked (submission.go sanitizeFreeText, then the size checks). Measuring the
|
|
71
|
+
* text as stored keeps an attachment near 256 KiB with NULs in it from being refused as too large.
|
|
72
|
+
* @param value - the text.
|
|
73
|
+
* @returns the text as it will be stored.
|
|
74
|
+
*/
|
|
75
|
+
export declare function asStored(value: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* A short field as the gateway accepts it: no control characters, trimmed, at most `max` code points.
|
|
78
|
+
* @param value - anything.
|
|
79
|
+
* @param max - the longest value, in code points.
|
|
80
|
+
* @returns the field, or undefined when nothing is left.
|
|
81
|
+
*/
|
|
82
|
+
export declare function shortField(value: unknown, max: number): string | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Free text as the gateway accepts it: line breaks and tabs kept, U+0000 as the U+FFFD the gateway stores, other
|
|
85
|
+
* control characters dropped, trimmed, at most 4,000 code points.
|
|
86
|
+
* @param value - anything.
|
|
87
|
+
* @returns the text, or undefined when blank.
|
|
88
|
+
*/
|
|
89
|
+
export declare function feedbackText(value: unknown): string | undefined;
|
|
90
|
+
/** The number of code points, the unit the gateway counts text in. */
|
|
91
|
+
export declare function codePoints(text: string): number;
|
|
92
|
+
/**
|
|
93
|
+
* Whether a value is one of the feedback categories.
|
|
94
|
+
* @param value - anything.
|
|
95
|
+
* @returns true for a category.
|
|
96
|
+
*/
|
|
97
|
+
export declare function isCategory(value: unknown): value is FeedbackCategory;
|
|
98
|
+
/**
|
|
99
|
+
* Text cut to at most `maxBytes` of UTF-8 on a code-point boundary, with a marker when anything was cut.
|
|
100
|
+
* @param content - the text.
|
|
101
|
+
* @param maxBytes - the budget.
|
|
102
|
+
* @returns the text, unchanged when it fits.
|
|
103
|
+
*/
|
|
104
|
+
export declare function fitUtf8(content: string, maxBytes: number): string;
|
|
105
|
+
/**
|
|
106
|
+
* Whether a draft says anything the gateway accepts: text, a rating or a category.
|
|
107
|
+
* @param draft - the draft.
|
|
108
|
+
* @returns true when it can be sent.
|
|
109
|
+
*/
|
|
110
|
+
export declare function isSendable(draft: FeedbackDraft): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* The body for a draft: only the fields the contract names, none of them empty; the attachment cut to its limit and
|
|
113
|
+
* then, if need be, to what the whole body allows.
|
|
114
|
+
* @param id - the idempotency key.
|
|
115
|
+
* @param draft - what the feedback says.
|
|
116
|
+
* @param client - which app sent it.
|
|
117
|
+
* @returns the body.
|
|
118
|
+
*/
|
|
119
|
+
export declare function feedbackBody(id: string, draft: FeedbackDraft, client: FeedbackClient): FeedbackBody;
|
|
120
|
+
/**
|
|
121
|
+
* The same draft with its attachment cut to half (after the gateway refused the body as too large).
|
|
122
|
+
* @param body - the refused body.
|
|
123
|
+
* @param id - the new body's id (a changed body is a new upload).
|
|
124
|
+
* @returns the smaller body, or undefined when there is no attachment left to cut.
|
|
125
|
+
*/
|
|
126
|
+
export declare function halveAttachment(body: FeedbackBody, id: string): FeedbackBody | undefined;
|
|
127
|
+
/** The size of a body on the wire. */
|
|
128
|
+
export declare function bodyBytes(body: FeedbackBody): number;
|
package/lib/gateway/assets.d.ts
CHANGED
|
@@ -8,6 +8,21 @@
|
|
|
8
8
|
* the returned upload headers when an upload is needed, `POST /{id}/complete`.
|
|
9
9
|
* An asset the library already holds is read back through `/refresh`, which
|
|
10
10
|
* also carries its measured duration.
|
|
11
|
+
*
|
|
12
|
+
* The gateway keeps one asset per account, purpose and digest
|
|
13
|
+
* (media/service.go CreateUpload): every upload of the same bytes is handed the
|
|
14
|
+
* same pending asset, the first PUT claims it, and the others are answered
|
|
15
|
+
* 409 `MEDIA_ASSET_NOT_READY` ("media upload is unavailable" on the PUT,
|
|
16
|
+
* "media upload is already in progress" on a later `uploads`). So inside the
|
|
17
|
+
* Host one upload of a file serves every caller that wants it at the same time
|
|
18
|
+
* (by purpose and digest), and a 409 from another process — or the coming
|
|
19
|
+
* `MEDIA_ASSET_UPLOAD_IN_PROGRESS` — means another upload of the same bytes is
|
|
20
|
+
* under way: the library waits for it (Retry-After, else 1 s doubling to 10 s,
|
|
21
|
+
* two minutes at most) by asking `uploads` again, which hands back the asset
|
|
22
|
+
* once it is ready, still answers 409 while it is not, and hands out a fresh
|
|
23
|
+
* upload when the other one ended without the file (failed or expired) — the
|
|
24
|
+
* library then uploads once more itself. `/refresh` cannot tell those apart (it
|
|
25
|
+
* answers 409 for a failed asset too).
|
|
11
26
|
* @module dsh-vibedev/gateway/assets
|
|
12
27
|
*/
|
|
13
28
|
import type { GatewayHttp } from './http.js';
|
|
@@ -34,28 +49,46 @@ export type AssetPurpose = 'video_reference' | 'audio_reference' | (string & {})
|
|
|
34
49
|
* @returns the asset facts, or undefined when the answer names no usable URL.
|
|
35
50
|
*/
|
|
36
51
|
export declare function parseAsset(body: unknown, fallbackType: string): Omit<UploadedAsset, 'sha256' | 'bytes'> | undefined;
|
|
52
|
+
/** Construction options; the sleep is a test seam. */
|
|
53
|
+
export interface MediaLibraryOptions {
|
|
54
|
+
/** Wait, ending early when the signal aborts. */
|
|
55
|
+
readonly sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
56
|
+
}
|
|
37
57
|
/** Uploads references and remembers them for the life of the plugin. */
|
|
38
58
|
export declare class MediaLibrary {
|
|
39
59
|
private readonly http;
|
|
40
60
|
private readonly now;
|
|
61
|
+
private readonly options;
|
|
41
62
|
private readonly cache;
|
|
63
|
+
private readonly flights;
|
|
64
|
+
/** Bumped by {@link clear}: an upload of the previous account does not land in the cache. */
|
|
65
|
+
private generation;
|
|
42
66
|
/**
|
|
43
67
|
* @param http - the gateway client.
|
|
44
|
-
* @param now - clock, for expiry checks.
|
|
68
|
+
* @param now - clock, for expiry checks and the wait for another upload.
|
|
69
|
+
* @param options - the sleep (a test seam).
|
|
45
70
|
*/
|
|
46
|
-
constructor(http: GatewayHttp, now?: () => number);
|
|
71
|
+
constructor(http: GatewayHttp, now?: () => number, options?: MediaLibraryOptions);
|
|
47
72
|
/** Forget every remembered asset, as after an account change: assets belong to the account that uploaded them. */
|
|
48
73
|
clear(): void;
|
|
49
74
|
/**
|
|
50
|
-
* Upload one loaded input, or reuse the asset the library already holds.
|
|
75
|
+
* Upload one loaded input, or reuse the asset the library already holds. Callers that ask for the same file
|
|
76
|
+
* (purpose and digest) at the same time share one upload; one that gives up leaves it running for the others.
|
|
51
77
|
* @param media - the loaded input.
|
|
52
78
|
* @param purpose - the asset purpose.
|
|
53
|
-
* @param signal - cancels the upload.
|
|
79
|
+
* @param signal - cancels this caller's wait (and the upload, once no caller waits on it).
|
|
54
80
|
* @returns the asset.
|
|
55
81
|
*/
|
|
56
82
|
upload(media: LoadedMedia, purpose: AssetPurpose, signal?: AbortSignal): Promise<UploadedAsset>;
|
|
83
|
+
/** Wait on a shared upload; giving up answers this caller at once and stops the upload when nobody else waits. */
|
|
84
|
+
private join;
|
|
85
|
+
/** Refresh a remembered asset about to expire, else upload the file — waiting for another upload of it when one is under way. */
|
|
86
|
+
private resolve;
|
|
87
|
+
/** `POST /uploads`: the asset when the library already holds the file, else the upload it hands out. */
|
|
88
|
+
private declare;
|
|
89
|
+
/** PUT the bytes where `uploads` said, then `complete`. */
|
|
90
|
+
private put;
|
|
57
91
|
private expiring;
|
|
58
|
-
private remember;
|
|
59
92
|
private refresh;
|
|
60
93
|
private read;
|
|
61
94
|
}
|
package/lib/gateway/catalog.d.ts
CHANGED
|
@@ -158,6 +158,12 @@ export interface AudioReferenceLimits {
|
|
|
158
158
|
readonly exclusiveWith?: readonly string[];
|
|
159
159
|
/** The media-library purpose references are uploaded under, when the catalog names one. */
|
|
160
160
|
readonly purpose?: string;
|
|
161
|
+
/**
|
|
162
|
+
* How each reference goes in `references`: `object` names its input, `{"audio_url": "<url>"}` — Seed's union of
|
|
163
|
+
* speaker, audio and image inputs, which a model declaring those inputs (`reference_audio_input`,
|
|
164
|
+
* `reference_image_input`, `speaker_input`) takes; `url` is the plain link, for a declaration without them.
|
|
165
|
+
*/
|
|
166
|
+
readonly form: 'url' | 'object';
|
|
161
167
|
}
|
|
162
168
|
/** One output format a speech model can write, with the sample rates it takes in that format. */
|
|
163
169
|
export interface AudioOutputFormat {
|
|
@@ -183,6 +189,11 @@ export interface AudioCapabilities {
|
|
|
183
189
|
/** Declared choices for enumerated fields (`gender`, `genre`, …), under their wire names. */
|
|
184
190
|
readonly choices?: Readonly<Record<string, readonly string[]>>;
|
|
185
191
|
readonly maxPromptChars?: number;
|
|
192
|
+
/**
|
|
193
|
+
* The fields of an object watermark (`watermark: {"aigc_watermark": true}`), when the model declares the watermark
|
|
194
|
+
* that way (Seed's `watermark_fields`); absent, the watermark is a boolean.
|
|
195
|
+
*/
|
|
196
|
+
readonly watermarkFields?: readonly string[];
|
|
186
197
|
/** Transcription input limits. */
|
|
187
198
|
readonly maxInputBytes?: number;
|
|
188
199
|
readonly maxInputSeconds?: number;
|
package/lib/gateway/errors.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface MediaErrorDetails {
|
|
|
13
13
|
readonly retryable?: boolean;
|
|
14
14
|
/** The request field the failure names, when the gateway says which. */
|
|
15
15
|
readonly field?: string;
|
|
16
|
+
/** The rule that field broke (`unknown_field`, `too_long`, …), when the gateway says which. */
|
|
17
|
+
readonly rule?: string;
|
|
16
18
|
/** Where the user tops up, on a balance refusal. */
|
|
17
19
|
readonly rechargeUrl?: string;
|
|
18
20
|
/** How long the gateway asked the client to wait. */
|
|
@@ -39,6 +41,8 @@ export interface MediaErrorDetails {
|
|
|
39
41
|
readonly estimatedCny?: string;
|
|
40
42
|
readonly availableCny?: string;
|
|
41
43
|
readonly pendingCny?: string;
|
|
44
|
+
/** The media library asset a media-asset answer is about (`error.asset_id`). */
|
|
45
|
+
readonly assetId?: string;
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* One failure, with a stable `code` to route on and a message to show. It is a
|
|
@@ -60,6 +64,7 @@ export interface GatewayFailure {
|
|
|
60
64
|
readonly code?: string;
|
|
61
65
|
readonly message?: string;
|
|
62
66
|
readonly field?: string;
|
|
67
|
+
readonly rule?: string;
|
|
63
68
|
readonly retryable?: boolean;
|
|
64
69
|
readonly submissionState?: string;
|
|
65
70
|
readonly retryAction?: string;
|
|
@@ -69,13 +74,15 @@ export interface GatewayFailure {
|
|
|
69
74
|
readonly estimatedCny?: string;
|
|
70
75
|
readonly availableCny?: string;
|
|
71
76
|
readonly pendingCny?: string;
|
|
77
|
+
readonly assetId?: string;
|
|
72
78
|
}
|
|
73
79
|
/**
|
|
74
80
|
* Read a gateway error body. The gateway answers in several shapes: OpenAI's
|
|
75
81
|
* `{error:{code,message,type}}`, its own `{error:{code,message,retryable,field}}`,
|
|
76
|
-
* the account API's `{code,message,reason}
|
|
77
|
-
*
|
|
78
|
-
*
|
|
82
|
+
* the account API's `{code,message,reason,metadata}` (a validation refusal names
|
|
83
|
+
* the field and the rule there: `metadata: {field, rule}`), and a top-level
|
|
84
|
+
* `recharge_url` on balance refusals. Media admission refusals add
|
|
85
|
+
* `active`/`limit` (task limit) or `estimated_cny`/`available_cny`/`pending_cny` (balance).
|
|
79
86
|
* @param body - the parsed JSON body, or undefined when it was not JSON.
|
|
80
87
|
* @returns the fields found.
|
|
81
88
|
*/
|
package/lib/gateway/http.d.ts
CHANGED
|
@@ -59,6 +59,18 @@ export interface GatewayRequest {
|
|
|
59
59
|
}
|
|
60
60
|
/** The message for a call made while nobody is signed in. */
|
|
61
61
|
export declare const SIGN_IN_MESSAGE: string;
|
|
62
|
+
/**
|
|
63
|
+
* Wait, ending early (with {@link abortError}) when the signal aborts.
|
|
64
|
+
* @param ms - how long.
|
|
65
|
+
* @param signal - cancels the wait.
|
|
66
|
+
*/
|
|
67
|
+
export declare function delay(ms: number, signal?: AbortSignal): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* The error a cancelled media request ends with.
|
|
70
|
+
* @param signal - the signal that aborted; its reason is the cause.
|
|
71
|
+
* @returns the error (`ABORTED`).
|
|
72
|
+
*/
|
|
73
|
+
export declare function abortError(signal?: AbortSignal): MediaError;
|
|
62
74
|
/** Gateway HTTP client. */
|
|
63
75
|
export declare class GatewayHttp {
|
|
64
76
|
private readonly options;
|
package/lib/index.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ export { parseMediaCatalog } from './gateway/catalog.js';
|
|
|
33
33
|
export type { AudioCapabilities, AudioGenerationKind, MediaModel, PriceUnit, VideoCapabilities, VideoMode, VideoPricingIssue, VideoTokenPricing, VideoTokenRule, } from './gateway/catalog.js';
|
|
34
34
|
export { ACCOUNT_ROUTE_PREFIX, AccountService } from './account/index.js';
|
|
35
35
|
export type { AccountSource, AccountView } from './account/index.js';
|
|
36
|
+
export { LATENCY_ROUTE } from './account/latency.js';
|
|
37
|
+
export type { LatencyErrorKind, LatencyResult } from './account/latency.js';
|
|
38
|
+
export { FEEDBACK_ATTACHMENT_ROUTE, FEEDBACK_ROUTE } from './feedback/index.js';
|
|
36
39
|
export { GATEWAY_SEARCH_PROVIDER_ID as SEARCH_PROVIDER_ID } from './search/provider.js';
|
|
37
40
|
export { INSUFFICIENT_BALANCE_CODE, SIGN_IN_REQUIRED_CODE, VIBEDEV_ROUTE } from './llm/index.js';
|
|
38
41
|
/** The package version, sent in the `User-Agent` the gateway attributes plugin traffic by. */
|