@vibedev-si/dsh-vibedev 0.3.10 → 0.3.11

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/lib/service.d.ts CHANGED
@@ -18,6 +18,7 @@ import type { AudioForm, AudioRequest } from './audio/request.js';
18
18
  import type { MediaModel } from './gateway/catalog.js';
19
19
  import type { AudioQuote, VideoQuote, VideoQuoteRequest } from './pricing.js';
20
20
  import type { MediaRuntime } from './runtime.js';
21
+ import type { TaskQueue, TaskStage, TaskTiming } from './tasks/progress.js';
21
22
  import type { TaskRecord, TaskStatus } from './tasks/store.js';
22
23
  import type { ImageRequest } from './tools/image.js';
23
24
  import type { VideoRequest } from './tools/video.js';
@@ -52,6 +53,20 @@ export interface MediaTaskView {
52
53
  readonly model: string;
53
54
  readonly status: TaskStatus;
54
55
  readonly progress?: string;
56
+ /**
57
+ * What a running task is doing: `submitting` (not yet confirmed, or not yet
58
+ * submitted upstream), `queued`, `generating`, or `saving` (archived by the
59
+ * gateway or downloaded here). Finished tasks have none; read `status`.
60
+ */
61
+ readonly stage?: TaskStage;
62
+ /**
63
+ * The gateway's timing facts of a running task, every time in epoch
64
+ * milliseconds of this machine's clock (corrected by the gateway's
65
+ * `server_time`). Absent while the gateway gives none, and on finished tasks.
66
+ */
67
+ readonly timing?: TaskTiming;
68
+ /** The gateway's queue position of a running task; each part only when known. Absent on finished tasks. */
69
+ readonly queue?: TaskQueue;
55
70
  readonly outputs?: readonly MediaOutputView[];
56
71
  readonly error?: {
57
72
  readonly code: string;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Generation progress of video and audio tasks: the gateway's `timing`,
3
+ * `queue` and `next_poll_after_seconds`, normalized to this machine's clock,
4
+ * the stage callers show, and the coarse wording of the time left.
5
+ *
6
+ * Every fact is optional. A field of the wrong type, a negative number or an
7
+ * unknown word is dropped on its own; it never fails the task. Without any of
8
+ * them, tasks are followed and described exactly as before.
9
+ * @module dsh-vibedev/tasks/progress
10
+ */
11
+ /** The gateway's phase, after its aliases are read. */
12
+ export type TaskPhase = 'pending_submit' | 'queued' | 'generating' | 'archiving' | 'done';
13
+ /** What a running task is doing, as callers show it; finished tasks have none. */
14
+ export type TaskStage = 'submitting' | 'queued' | 'generating' | 'saving';
15
+ /** The gateway's timing facts, with every time in epoch milliseconds of this machine's clock. */
16
+ export interface TaskTiming {
17
+ readonly phase?: TaskPhase;
18
+ /** When the task started. */
19
+ readonly startedAt?: number;
20
+ /** When the current phase started. */
21
+ readonly phaseStartedAt?: number;
22
+ /** When the result is expected to be downloadable: the answer's arrival plus `estimated_remaining_seconds`. */
23
+ readonly estimatedCompletionAt?: number;
24
+ /** A cautious completion time: the answer's arrival plus `remaining_p90_seconds`. */
25
+ readonly p90CompletionAt?: number;
26
+ readonly estimateSource?: 'upstream' | 'history';
27
+ readonly confidence?: 'high' | 'medium' | 'low';
28
+ /** The provider's own progress, 0–1; present only when the provider reports one. */
29
+ readonly progress?: number;
30
+ /** When this machine received these facts. */
31
+ readonly observedAt: number;
32
+ }
33
+ /** A task's place in the gateway's queue; each part only when the gateway knows it. */
34
+ export interface TaskQueue {
35
+ readonly position?: number;
36
+ readonly positionMin?: number;
37
+ readonly positionMax?: number;
38
+ }
39
+ /** The progress facts of one gateway answer. */
40
+ export interface ProgressFacts {
41
+ readonly timing?: TaskTiming;
42
+ readonly queue?: TaskQueue;
43
+ /** The gateway's suggested wait before the next query, already kept within 2–30 seconds. */
44
+ readonly nextPollAfterSeconds?: number;
45
+ }
46
+ type Json = Record<string, unknown>;
47
+ /**
48
+ * Read the progress facts of a task answer.
49
+ * @param raw - the parsed task answer.
50
+ * @param receivedAt - when this machine received it (epoch ms); the anchor of every time.
51
+ * @returns only the facts the answer gives in a readable form.
52
+ */
53
+ export declare function parseProgress(raw: Json, receivedAt: number): ProgressFacts;
54
+ /** The local download of a finished task's results is recorded under this progress line. */
55
+ export declare const SAVING_PROGRESS = "saving the result";
56
+ /**
57
+ * The stage of a task: `submitting` while the gateway has not confirmed it or
58
+ * has not submitted it upstream, `saving` while the result is archived by the
59
+ * gateway or downloaded here, `queued`, and otherwise `generating`.
60
+ * @param task - the task's status, progress line and timing.
61
+ * @returns the stage, or undefined for a finished task.
62
+ */
63
+ export declare function stageOf(task: {
64
+ readonly status: string;
65
+ readonly progress?: string;
66
+ readonly timing?: TaskTiming;
67
+ }): TaskStage | undefined;
68
+ /** An English and a Chinese wording of the same fact. */
69
+ export interface Words {
70
+ readonly en: string;
71
+ readonly zh: string;
72
+ }
73
+ /**
74
+ * The time left, in coarse words: under a minute, about N minutes, or slower
75
+ * than estimated once the estimate has passed. An estimate the gateway marks
76
+ * as low confidence is not stated.
77
+ * @param timing - the task's timing.
78
+ * @param now - this machine's clock (epoch ms).
79
+ * @returns the wording, or undefined without a usable estimate.
80
+ */
81
+ export declare function remainingWords(timing: TaskTiming | undefined, now: number): Words | undefined;
82
+ /**
83
+ * How a running task with progress facts reads: stage, queue position, the
84
+ * provider's progress and the time left, in English with the Chinese wording
85
+ * after it (`queued, position 3 in the queue, about 2 min left (排队中 · 第 3 位 · 约 2 分钟)`).
86
+ * @param task - the task's status, progress line, timing and queue.
87
+ * @param now - this machine's clock (epoch ms).
88
+ * @returns the wording, or undefined when the task is finished or carries no progress facts.
89
+ */
90
+ export declare function progressWords(task: {
91
+ readonly status: string;
92
+ readonly progress?: string;
93
+ readonly timing?: TaskTiming;
94
+ readonly queue?: TaskQueue;
95
+ }, now: number): string | undefined;
96
+ export {};
@@ -9,8 +9,13 @@
9
9
  * (`pending`/`settled`), `billing_pending_reason`, `charged_cny` (kept as the
10
10
  * exact string given), `billed_tokens` and `estimated_cny`. A completed task
11
11
  * whose billing is pending has its result; only the charge is still to come.
12
+ *
13
+ * Newer gateways add progress facts (`timing`, `queue`,
14
+ * `next_poll_after_seconds`), read by {@link parseProgress} against the time
15
+ * the answer arrived.
12
16
  * @module dsh-vibedev/tasks/remote
13
17
  */
18
+ import type { ProgressFacts } from './progress.js';
14
19
  /** One produced file as the gateway describes it. */
15
20
  export interface RemoteOutput {
16
21
  /** Position in `outputs[]`, for `/content?index=N`. */
@@ -23,8 +28,8 @@ export interface RemoteOutput {
23
28
  /** The provider's original length this output is billed on, when it differs from playback (speech). */
24
29
  readonly originalSeconds?: number;
25
30
  }
26
- /** A task's state. */
27
- export interface RemoteTask {
31
+ /** A task's state, with the progress facts of the answer when the gateway gives them. */
32
+ export interface RemoteTask extends ProgressFacts {
28
33
  readonly id: string;
29
34
  /**
30
35
  * `completed` also covers `settlement_pending`: the result exists and is
@@ -67,12 +72,14 @@ export interface RemoteTask {
67
72
  /**
68
73
  * Read a video task.
69
74
  * @param body - the parsed answer.
75
+ * @param receivedAt - when this machine received it (epoch ms), the anchor of its progress times.
70
76
  * @returns the task, or undefined when the answer names no task id.
71
77
  */
72
- export declare function parseVideoTask(body: unknown): RemoteTask | undefined;
78
+ export declare function parseVideoTask(body: unknown, receivedAt?: number): RemoteTask | undefined;
73
79
  /**
74
80
  * Read a music or podcast task.
75
81
  * @param body - the parsed answer.
82
+ * @param receivedAt - when this machine received it (epoch ms), the anchor of its progress times.
76
83
  * @returns the task, or undefined when the answer names no task id.
77
84
  */
78
- export declare function parseAudioTask(body: unknown): RemoteTask | undefined;
85
+ export declare function parseAudioTask(body: unknown, receivedAt?: number): RemoteTask | undefined;
@@ -9,6 +9,7 @@
9
9
  * never poll and download the same one.
10
10
  * @module dsh-vibedev/tasks/store
11
11
  */
12
+ import type { TaskQueue, TaskTiming } from './progress.js';
12
13
  /** What a task produces. */
13
14
  export type TaskKind = 'video' | 'audio';
14
15
  /**
@@ -54,6 +55,10 @@ export interface TaskRecord {
54
55
  readonly gatewayId?: string;
55
56
  readonly status: TaskStatus;
56
57
  readonly progress?: string;
58
+ /** The gateway's latest timing facts, on this machine's clock; only while the task runs and the gateway gives them. */
59
+ readonly timing?: TaskTiming;
60
+ /** The gateway's latest queue position; only while the task runs and the gateway gives one. */
61
+ readonly queue?: TaskQueue;
57
62
  /** Outputs saved so far; a finished task lists every output. */
58
63
  readonly outputs?: readonly TaskOutput[];
59
64
  readonly error?: {
@@ -156,6 +156,12 @@ export declare class TaskTracker {
156
156
  * record holds, so a settled task is never downgraded by it.
157
157
  */
158
158
  private moneyOf;
159
+ /**
160
+ * The progress facts to record from an answer. Each answer replaces the
161
+ * last one's, so a fact it no longer gives is removed; a record that never
162
+ * had any (an older gateway) is left untouched.
163
+ */
164
+ private progressFactsOf;
159
165
  /** Record what the gateway says about a task; save the outputs of a finished one. */
160
166
  private apply;
161
167
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibedev-si/dsh-vibedev",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "VibeDev 账号与模型:在 DeepSeek Harness 里登录 VibeDev,与 DeepSeek 账号并存,使用 VibeDev 网关的模型(Claude、GPT 等),并生成图片、视频、音乐和播客 · VibeDev account and models for DeepSeek Harness: sign in to VibeDev next to the DeepSeek account and use the VibeDev gateway's models (Claude, GPT and more), plus image, video, music and podcast generation",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",