@vibedev-si/dsh-vibedev 0.2.7 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -12
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/client/client.js +130 -22
- package/lib/account/index.d.ts +3 -1
- package/lib/audio/request.d.ts +141 -0
- package/lib/auth/credentials.d.ts +5 -3
- package/lib/auth/login.d.ts +12 -2
- package/lib/auth/sign-in-state.d.ts +21 -0
- package/lib/gateway/assets.d.ts +2 -2
- package/lib/gateway/catalog.d.ts +75 -4
- package/lib/gateway/http.d.ts +1 -1
- package/lib/gateway/origin.d.ts +10 -0
- package/lib/index.d.ts +7 -2
- package/lib/index.js +1451 -279
- package/lib/pricing.d.ts +45 -9
- package/lib/runtime.d.ts +24 -1
- package/lib/service.d.ts +81 -7
- package/lib/tasks/remote.d.ts +13 -0
- package/lib/tasks/store.d.ts +17 -0
- package/lib/tasks/tracker.d.ts +14 -1
- package/lib/tools/account.d.ts +0 -2
- package/lib/tools/audio.d.ts +3 -2
- package/lib/tools/models.d.ts +7 -0
- package/package.json +1 -1
package/lib/auth/login.d.ts
CHANGED
|
@@ -12,8 +12,12 @@
|
|
|
12
12
|
* - `POST /api/v1/vibedev/app-token/revoke` (bearer or `{refresh_token}`): always 204
|
|
13
13
|
* @module dsh-vibedev/auth/login
|
|
14
14
|
*/
|
|
15
|
+
import type { SignInAttempt } from './sign-in-state.js';
|
|
16
|
+
export type { SignInAttempt } from './sign-in-state.js';
|
|
15
17
|
/** A stored plugin session. */
|
|
16
18
|
export interface PluginGrant {
|
|
19
|
+
/** Origin that issued this stored app grant; legacy unmarked grants belong to the domestic gateway only. */
|
|
20
|
+
readonly gatewayOrigin?: string;
|
|
17
21
|
readonly accessToken: string;
|
|
18
22
|
readonly refreshToken: string;
|
|
19
23
|
/** Epoch ms. */
|
|
@@ -57,7 +61,7 @@ export interface PluginLoginOptions {
|
|
|
57
61
|
readonly now?: () => number;
|
|
58
62
|
/** Open a URL in the system browser; resolves whether that was attempted successfully. */
|
|
59
63
|
readonly openBrowser?: (url: string) => Promise<boolean>;
|
|
60
|
-
/**
|
|
64
|
+
/** Sign-in deadline through credential exchange, before the atomic write starts. Defaults to 5 minutes. */
|
|
61
65
|
readonly signInTimeoutMs?: number;
|
|
62
66
|
/** The client name the gateway records for the sign-in (it picks the key the usage is billed to). Defaults to `vibedev-plugin`. */
|
|
63
67
|
readonly client?: string;
|
|
@@ -93,6 +97,7 @@ export declare class PluginLogin {
|
|
|
93
97
|
private readFailureReported;
|
|
94
98
|
private refreshing;
|
|
95
99
|
private pending;
|
|
100
|
+
private attempt;
|
|
96
101
|
private readonly listeners;
|
|
97
102
|
private readonly now;
|
|
98
103
|
private readonly origin;
|
|
@@ -106,6 +111,11 @@ export declare class PluginLogin {
|
|
|
106
111
|
restore(): Promise<void>;
|
|
107
112
|
/** Take a grant as current and tell listeners when it changed. */
|
|
108
113
|
private adopt;
|
|
114
|
+
private notify;
|
|
115
|
+
/** A copied safe snapshot, retained after completion until the next sign-in. */
|
|
116
|
+
signInAttempt(): SignInAttempt | undefined;
|
|
117
|
+
private logAttempt;
|
|
118
|
+
private transition;
|
|
109
119
|
private save;
|
|
110
120
|
/**
|
|
111
121
|
* Hear about sign-in and sign-out.
|
|
@@ -151,7 +161,7 @@ export declare class PluginLogin {
|
|
|
151
161
|
}): Promise<PendingSignIn & {
|
|
152
162
|
opened: boolean;
|
|
153
163
|
}>;
|
|
154
|
-
private
|
|
164
|
+
private beginSignIn;
|
|
155
165
|
/** Sign out: revoke the session at the gateway (best effort) and forget it. */
|
|
156
166
|
signOut(): Promise<void>;
|
|
157
167
|
/** Stop a waiting sign-in. */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Safe host diagnostics: deliberately separate from authorization URLs and grants. */
|
|
2
|
+
export interface SignInAttempt {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly phase: 'preparing' | 'waiting-browser' | 'exchanging' | 'committing' | 'succeeded' | 'failed' | 'cancelled' | 'expired';
|
|
5
|
+
readonly expiresAt: number;
|
|
6
|
+
readonly gatewayOrigin: string;
|
|
7
|
+
readonly stage?: 'listen' | 'device' | 'redeem' | 'persist';
|
|
8
|
+
readonly errorCode?: 'network' | 'timeout' | 'gateway-refused' | 'gateway-unavailable' | 'protocol' | 'storage' | 'callback';
|
|
9
|
+
readonly httpStatus?: number;
|
|
10
|
+
readonly networkCode?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const REDEEM_PATH = "/api/v1/vibedev/link/redeem";
|
|
13
|
+
export type SignInFailure = Pick<SignInAttempt, 'errorCode' | 'httpStatus' | 'networkCode'>;
|
|
14
|
+
/** Read only fixed transport codes, never error text, stack, body or arbitrary fields. */
|
|
15
|
+
export declare function transportFailure(error: unknown): SignInFailure;
|
|
16
|
+
/** A fixed bilingual explanation suitable for exposed rejection messages. */
|
|
17
|
+
export declare function failureMessage(attempt: Pick<SignInAttempt, 'errorCode' | 'stage' | 'httpStatus'>): string;
|
|
18
|
+
/** Only our fixed explanation and escaped safe enum/status fields reach the browser. */
|
|
19
|
+
export declare function failurePage(attempt: SignInAttempt): string;
|
|
20
|
+
/** Explicit log allowlist; adding fields to the public attempt never expands log output. */
|
|
21
|
+
export declare function attemptLog(event: 'request' | 'phase' | 'response' | 'terminal', attempt: SignInAttempt): string;
|
package/lib/gateway/assets.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ export interface UploadedAsset {
|
|
|
25
25
|
readonly sha256: string;
|
|
26
26
|
readonly bytes: number;
|
|
27
27
|
}
|
|
28
|
-
/** Purposes the plugin uploads under. */
|
|
29
|
-
export type AssetPurpose = 'video_reference';
|
|
28
|
+
/** Purposes the plugin uploads under: references of a video request, and the reference audio of a speech request. */
|
|
29
|
+
export type AssetPurpose = 'video_reference' | 'audio_reference' | (string & {});
|
|
30
30
|
/**
|
|
31
31
|
* Read an asset answer from `uploads`, `complete` or `refresh`.
|
|
32
32
|
* @param body - the parsed answer.
|
package/lib/gateway/catalog.d.ts
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
* the versioned per-mode declarations (`modes_schema_version: 1`). A mode the
|
|
9
9
|
* model does not list is unsupported; an unknown schema version makes the model
|
|
10
10
|
* unusable rather than guessed at.
|
|
11
|
+
*
|
|
12
|
+
* Audio capabilities follow the `audio` block: `generation_kind` (music,
|
|
13
|
+
* podcast, speech or transcription), `prompt_field`, `request_fields`,
|
|
14
|
+
* `billing_unit` and the declared limits (references, output formats and their
|
|
15
|
+
* sample rates). An audio model that declares no kind is listed but cannot be
|
|
16
|
+
* chosen for generation: neither its name nor its id decides what it makes.
|
|
11
17
|
* @module dsh-vibedev/gateway/catalog
|
|
12
18
|
*/
|
|
13
19
|
/** What a media model produces. */
|
|
@@ -81,10 +87,16 @@ export interface VideoCapabilities {
|
|
|
81
87
|
/** References must be relayed through the gateway media library. */
|
|
82
88
|
readonly gatewayRelayRequired?: boolean;
|
|
83
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* What a price is charged per: one generation, one second of output, one
|
|
92
|
+
* second of ORIGINAL audio (speech is billed on the provider's original length,
|
|
93
|
+
* not on what plays back after processing), or one minute of input audio.
|
|
94
|
+
*/
|
|
95
|
+
export type PriceUnit = 'generation' | 'second' | 'original_second' | 'minute';
|
|
84
96
|
/** One price tier: video tiers are resolutions (`720p`), image tiers size buckets (`1K`). */
|
|
85
97
|
export interface MediaPriceTier {
|
|
86
98
|
readonly tier: string;
|
|
87
|
-
readonly unit:
|
|
99
|
+
readonly unit: PriceUnit;
|
|
88
100
|
readonly amount: number;
|
|
89
101
|
}
|
|
90
102
|
/** A model's selling price, account multiplier included. */
|
|
@@ -92,23 +104,76 @@ export interface MediaPricing {
|
|
|
92
104
|
readonly currency: string;
|
|
93
105
|
readonly tiers: readonly MediaPriceTier[];
|
|
94
106
|
readonly default?: {
|
|
95
|
-
readonly unit:
|
|
107
|
+
readonly unit: PriceUnit;
|
|
96
108
|
readonly amount: number;
|
|
97
109
|
};
|
|
98
110
|
}
|
|
111
|
+
/** What an audio model does, as the catalog declares it (`audio.generation_kind`). */
|
|
112
|
+
export declare const AUDIO_GENERATION_KINDS: readonly ["music", "podcast", "speech", "transcription"];
|
|
113
|
+
export type AudioGenerationKind = typeof AUDIO_GENERATION_KINDS[number];
|
|
114
|
+
/** How an audio model is billed (`audio.billing_unit`). */
|
|
115
|
+
export type AudioBillingUnit = 'generation' | 'original_second' | 'minute';
|
|
116
|
+
/** The reference audio a speech model takes (a voice to imitate), as the catalog declares it. */
|
|
117
|
+
export interface AudioReferenceLimits {
|
|
118
|
+
readonly min: number;
|
|
119
|
+
readonly max: number;
|
|
120
|
+
readonly maxBytes?: number;
|
|
121
|
+
readonly minSeconds?: number;
|
|
122
|
+
readonly maxSeconds?: number;
|
|
123
|
+
readonly maxTotalSeconds?: number;
|
|
124
|
+
/** Accepted MIME types; absent states no restriction. */
|
|
125
|
+
readonly mimes?: readonly string[];
|
|
126
|
+
/** Request fields that may not be sent together with references. */
|
|
127
|
+
readonly exclusiveWith?: readonly string[];
|
|
128
|
+
/** The media-library purpose references are uploaded under, when the catalog names one. */
|
|
129
|
+
readonly purpose?: string;
|
|
130
|
+
}
|
|
131
|
+
/** One output format a speech model can write, with the sample rates it takes in that format. */
|
|
132
|
+
export interface AudioOutputFormat {
|
|
133
|
+
readonly format: string;
|
|
134
|
+
readonly sampleRates: readonly number[];
|
|
135
|
+
readonly defaultSampleRate?: number;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* An audio model's declared capabilities. Nothing here is assumed: a field the
|
|
139
|
+
* catalog does not declare is absent, and a model without `generationKind`
|
|
140
|
+
* cannot be chosen for any kind of generation.
|
|
141
|
+
*/
|
|
142
|
+
export interface AudioCapabilities {
|
|
143
|
+
readonly generationKind?: AudioGenerationKind;
|
|
144
|
+
/** The request field the main text goes in (`prompt`, `text_prompt`, …). */
|
|
145
|
+
readonly promptField?: string;
|
|
146
|
+
/** The request fields the model accepts, under their wire names. */
|
|
147
|
+
readonly requestFields: readonly string[];
|
|
148
|
+
readonly billingUnit?: AudioBillingUnit;
|
|
149
|
+
readonly references?: AudioReferenceLimits;
|
|
150
|
+
readonly outputFormats?: readonly AudioOutputFormat[];
|
|
151
|
+
readonly defaultFormat?: string;
|
|
152
|
+
/** Declared choices for enumerated fields (`gender`, `genre`, …), under their wire names. */
|
|
153
|
+
readonly choices?: Readonly<Record<string, readonly string[]>>;
|
|
154
|
+
readonly maxPromptChars?: number;
|
|
155
|
+
/** Transcription input limits. */
|
|
156
|
+
readonly maxInputBytes?: number;
|
|
157
|
+
readonly maxInputSeconds?: number;
|
|
158
|
+
readonly inputMimes?: readonly string[];
|
|
159
|
+
readonly languages?: readonly string[];
|
|
160
|
+
}
|
|
99
161
|
/** One media model of the catalog. */
|
|
100
162
|
export interface MediaModel {
|
|
101
163
|
readonly id: string;
|
|
102
164
|
readonly name: string;
|
|
103
165
|
readonly description?: string;
|
|
104
166
|
readonly kind: MediaKind;
|
|
105
|
-
/**
|
|
106
|
-
readonly
|
|
167
|
+
/** Other ids the gateway answers to for this model. */
|
|
168
|
+
readonly aliases?: readonly string[];
|
|
169
|
+
/** For audio models: what they produce, from `audio.generation_kind` only; absent when undeclared. */
|
|
170
|
+
readonly audioKind?: Exclude<AudioGenerationKind, 'transcription'>;
|
|
107
171
|
/** Endpoints the catalog lists for the model. */
|
|
108
172
|
readonly endpoints: readonly string[];
|
|
109
173
|
readonly inputModalities: readonly string[];
|
|
110
174
|
readonly pricing?: MediaPricing;
|
|
111
175
|
readonly video?: VideoCapabilities;
|
|
176
|
+
readonly audio?: AudioCapabilities;
|
|
112
177
|
}
|
|
113
178
|
type Json = Record<string, unknown>;
|
|
114
179
|
/**
|
|
@@ -124,6 +189,12 @@ export declare function parseVideoCapabilities(raw: Json): VideoCapabilities;
|
|
|
124
189
|
* @returns the usable modes and their constraints.
|
|
125
190
|
*/
|
|
126
191
|
export declare function effectiveVideoModes(video: VideoCapabilities): Partial<Record<VideoMode, VideoModeConstraint>>;
|
|
192
|
+
/**
|
|
193
|
+
* Parse an audio capability block.
|
|
194
|
+
* @param raw - the block.
|
|
195
|
+
* @returns the declared capabilities; `generationKind` is absent unless declared.
|
|
196
|
+
*/
|
|
197
|
+
export declare function parseAudioCapabilities(raw: Json): AudioCapabilities;
|
|
127
198
|
/**
|
|
128
199
|
* Parse a `/v1/models` body into its media models.
|
|
129
200
|
* @param body - `{data:[...]}` or a bare array.
|
package/lib/gateway/http.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface GatewayCredential {
|
|
|
21
21
|
}
|
|
22
22
|
/** Construction options; `fetch` and `sleep` are test seams. */
|
|
23
23
|
export interface GatewayHttpOptions {
|
|
24
|
-
/** Gateway origin, such as `https://vibedev.
|
|
24
|
+
/** Gateway origin, such as `https://api.vibedev.studio`. */
|
|
25
25
|
readonly origin: string;
|
|
26
26
|
/** The credential for the next request; undefined while nobody is signed in. */
|
|
27
27
|
readonly resolveCredential: () => Promise<GatewayCredential | undefined>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Production API origin. Storage URLs are returned by the server, not derived from this address. */
|
|
2
|
+
export declare const DEFAULT_GATEWAY_ORIGIN = "https://api.vibedev.studio";
|
|
3
|
+
/** Validate a bare HTTP(S) origin and canonicalize default ports, casing and trailing slash. */
|
|
4
|
+
export declare function normalizeGatewayOrigin(value: string): string;
|
|
5
|
+
/** Stable, filesystem-safe identity; ports and schemes remain separate boundaries. */
|
|
6
|
+
export declare function gatewayId(origin: string): string;
|
|
7
|
+
/** Every gateway uses its own namespace; never read the unmarked historical root. */
|
|
8
|
+
export declare function gatewayStateDirectory(root: string, origin: string): string;
|
|
9
|
+
/** Ignore the old shared key variable; development requires an explicitly named, gateway-specific variable. */
|
|
10
|
+
export declare function developmentKey(origin: string, name: string, env?: Readonly<Record<string, string | undefined>>): string | undefined;
|
package/lib/index.d.ts
CHANGED
|
@@ -24,11 +24,13 @@ import type { Context, Volatile } from '@deepseek-ai/cordis';
|
|
|
24
24
|
import Schema from '@deepseek-ai/schemastery';
|
|
25
25
|
export { MediaError } from './gateway/errors.js';
|
|
26
26
|
export { MediaHostService } from './service.js';
|
|
27
|
-
export type { HostTarget, MediaTaskView } from './service.js';
|
|
27
|
+
export type { HostTarget, MediaOutputView, MediaTaskView } from './service.js';
|
|
28
|
+
export type { AudioForm, AudioFormField, AudioMakeKind, AudioRequest } from './audio/request.js';
|
|
29
|
+
export type { AudioQuote } from './pricing.js';
|
|
28
30
|
export type { ImageRequest } from './tools/image.js';
|
|
29
31
|
export type { VideoRequest } from './tools/video.js';
|
|
30
32
|
export { parseMediaCatalog } from './gateway/catalog.js';
|
|
31
|
-
export type { MediaModel, VideoCapabilities, VideoMode } from './gateway/catalog.js';
|
|
33
|
+
export type { AudioCapabilities, AudioGenerationKind, MediaModel, PriceUnit, VideoCapabilities, VideoMode } from './gateway/catalog.js';
|
|
32
34
|
export { ACCOUNT_ROUTE_PREFIX, AccountService } from './account/index.js';
|
|
33
35
|
export type { AccountSource, AccountView } from './account/index.js';
|
|
34
36
|
export { GATEWAY_SEARCH_PROVIDER_ID as SEARCH_PROVIDER_ID } from './search/provider.js';
|
|
@@ -55,6 +57,7 @@ export interface Config {
|
|
|
55
57
|
videoModel: Volatile<string>;
|
|
56
58
|
musicModel: Volatile<string>;
|
|
57
59
|
podcastModel: Volatile<string>;
|
|
60
|
+
speechModel: Volatile<string>;
|
|
58
61
|
transcriptionModel: Volatile<string>;
|
|
59
62
|
/** Gateway origin. */
|
|
60
63
|
gatewayOrigin: string;
|
|
@@ -78,6 +81,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
78
81
|
videoModel: Schema<string, string, "volatile-defined">;
|
|
79
82
|
musicModel: Schema<string, string, "volatile-defined">;
|
|
80
83
|
podcastModel: Schema<string, string, "volatile-defined">;
|
|
84
|
+
speechModel: Schema<string, string, "volatile-defined">;
|
|
81
85
|
transcriptionModel: Schema<string, string, "volatile-defined">;
|
|
82
86
|
gatewayOrigin: Schema<string, string, "defined">;
|
|
83
87
|
client: Schema<string, string, "defined">;
|
|
@@ -95,6 +99,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
95
99
|
videoModel: Schema<string, string, "volatile-defined">;
|
|
96
100
|
musicModel: Schema<string, string, "volatile-defined">;
|
|
97
101
|
podcastModel: Schema<string, string, "volatile-defined">;
|
|
102
|
+
speechModel: Schema<string, string, "volatile-defined">;
|
|
98
103
|
transcriptionModel: Schema<string, string, "volatile-defined">;
|
|
99
104
|
gatewayOrigin: Schema<string, string, "defined">;
|
|
100
105
|
client: Schema<string, string, "defined">;
|