@vibedev-si/dsh-vibedev 0.5.3 → 0.7.0

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.
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The 消息 page's Host routes, read from the gateway under the VibeDev account:
3
+ *
4
+ * - `GET /api/dsh-vibedev/announcements` — what this account may see right now, and how
5
+ * many of them it has not read. The gateway owns the targeting (subscription, balance)
6
+ * and the time window; this route only allowlists the fields the page renders and turns
7
+ * an endpoint the gateway has not shipped yet into `available: false`, so the page and
8
+ * the sidebar stay quiet instead of showing an error nobody can act on.
9
+ * - `POST /api/dsh-vibedev/announcements/read` — the read receipt for one message, with
10
+ * `{"id": <number>}` in the body. The Host's Fetch routes match an exact pathname (there
11
+ * are no `:id` patterns), so the identifier travels in the body, never in the path.
12
+ * Closing a dialog is not a receipt: the page sends this only when the person opened
13
+ * the message or pressed 「知道了」.
14
+ *
15
+ * Answers are never cached, because the unread count drives a badge.
16
+ * @module dsh-vibedev/announcements/routes
17
+ */
18
+ import type { ConnectionFetchRoute } from '@deepseek-ai/dsh-client-connection';
19
+ import type { AccountService } from '../account/index.js';
20
+ import type { GatewayHttp } from '../gateway/http.js';
21
+ /** The Host route the renderer polls. */
22
+ export declare const ANNOUNCEMENTS_ROUTE = "/api/dsh-vibedev/announcements";
23
+ /**
24
+ * The receipt's own Host route. A Host Fetch route owns one exact pathname, so this is a
25
+ * sibling of the list rather than a `:id` child of it; the id is in the request body.
26
+ */
27
+ export declare const ANNOUNCEMENTS_READ_ROUTE = "/api/dsh-vibedev/announcements/read";
28
+ /**
29
+ * Where the gateway serves the same list. Every account read goes to `/v1/account/*`
30
+ * (`auth/me`, `entitlements`, `model-plaza`, `payment/*`, and our own `feedback`), so
31
+ * announcements belong beside them; `/api/v1/vibedev/*` is only the sign-in and
32
+ * device-authorization surface (`app-token/*`, `link/redeem`).
33
+ */
34
+ export declare const GATEWAY_ANNOUNCEMENTS_PATH = "/v1/account/announcements";
35
+ /** One announcement, as the page renders it. */
36
+ export interface Announcement {
37
+ readonly id: number;
38
+ readonly title: string;
39
+ readonly content: string;
40
+ /** `popup` may interrupt at start-up once; `silent` only ever appears in the list. */
41
+ readonly notifyMode: 'popup' | 'silent';
42
+ readonly startsAt?: string;
43
+ readonly endsAt?: string;
44
+ /** `null` while unread. */
45
+ readonly readAt: string | null;
46
+ readonly createdAt: string;
47
+ }
48
+ /** One answer of the list route. `available: false` means this gateway cannot serve messages yet. */
49
+ export interface AnnouncementListing {
50
+ readonly available: boolean;
51
+ readonly items: readonly Announcement[];
52
+ readonly unread: number;
53
+ }
54
+ /** What the routes need. */
55
+ export interface AnnouncementRouteOptions {
56
+ readonly http: GatewayHttp;
57
+ readonly account: AccountService;
58
+ }
59
+ /**
60
+ * One announcement from the wire, with every field it needs and nothing else.
61
+ * @param value - one entry of the gateway's list.
62
+ * @returns the announcement, or undefined when the entry cannot be rendered.
63
+ */
64
+ export declare function parseAnnouncement(value: unknown): Announcement | undefined;
65
+ /**
66
+ * Both routes.
67
+ * @param options - the gateway client and the account whose credential the reads go with.
68
+ * @returns routes for the client connection.
69
+ */
70
+ export declare function announcementRoutes({ http, account }: AnnouncementRouteOptions): ConnectionFetchRoute[];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The content library's failures. Callers of `vibedevContent` (dsh-film's
3
+ * `GatewaySource`) route on three fields of the thrown object — `code`, `status`
4
+ * and `message`: `code === 'NOT_SIGNED_IN'` or `status === 401` means "signed
5
+ * out". The gateway client's own `MediaError` keeps `status` inside `details`,
6
+ * so this layer translates it into a `ContentError` that carries both on top.
7
+ * @module dsh-vibedev/content/errors
8
+ */
9
+ import { HarnessError } from '@deepseek-ai/dsh-llm';
10
+ /** The failure classes a content caller routes on. */
11
+ export type ContentErrorCode = 'NOT_SIGNED_IN' | 'NOT_FOUND' | 'RATE_LIMITED' | 'REFUSED' | 'GATEWAY_ERROR' | 'GATEWAY_BAD_RESPONSE' | 'NETWORK_ERROR' | 'INVALID_REQUEST' | 'BLOB_TOO_LARGE' | 'HASH_MISMATCH' | 'ABORTED';
12
+ /** What a failure may carry besides its message. */
13
+ export interface ContentErrorFacts {
14
+ /** HTTP status when the gateway answered. */
15
+ readonly status?: number;
16
+ /** How long the gateway asked the client to wait (429). */
17
+ readonly retryAfterMs?: number;
18
+ /** Whether the same request may succeed later. */
19
+ readonly retryable?: boolean;
20
+ }
21
+ /**
22
+ * One content failure, with `code` and `status` at the top level: the host
23
+ * contract reads them there, never inside a details object.
24
+ */
25
+ export declare class ContentError extends HarnessError {
26
+ /** Narrowed to the union below, so a caller can route on the exact failure class, not on any string. */
27
+ readonly code: ContentErrorCode;
28
+ readonly status?: number;
29
+ readonly retryAfterMs?: number;
30
+ readonly retryable: boolean;
31
+ /**
32
+ * @param message - what happened and what to do next.
33
+ * @param code - the stable failure class.
34
+ * @param facts - status, wait and retry facts.
35
+ * @param options - the underlying cause, when there is one.
36
+ */
37
+ constructor(message: string, code: ContentErrorCode, facts?: ContentErrorFacts, options?: ErrorOptions);
38
+ }
39
+ /**
40
+ * One failure from anywhere below this service, in the shape a content caller reads.
41
+ * @param error - whatever was thrown, including non-errors (`Promise.reject()`).
42
+ * @returns the failure to throw.
43
+ */
44
+ export declare function contentFailure(error: unknown): ContentError;
@@ -0,0 +1,99 @@
1
+ /**
2
+ * The content library host service, registered as `vibedevContent`: the current
3
+ * catalog (`GET /v1/film-library/catalog`, ETag-conditional) and one file by
4
+ * content hash (`GET /v1/film-library/blobs/{sha256}{ext}`), both through the
5
+ * same credential plane as every other gateway call. The credential never leaves
6
+ * this plugin: callers get the parsed catalog and verified bytes.
7
+ * @module dsh-vibedev/content/service
8
+ */
9
+ import type { MediaAccountContext } from '../contracts.js';
10
+ import type { GatewayHttp } from '../gateway/http.js';
11
+ /** One catalog read: unchanged content answers only `notModified`. */
12
+ export type ContentCatalogOutcome = {
13
+ readonly notModified: true;
14
+ } | {
15
+ readonly notModified: false;
16
+ readonly etag: string;
17
+ readonly body: unknown;
18
+ };
19
+ /** What a caller may pass to {@link ContentHostService.catalog}. */
20
+ export interface ContentCatalogRequest {
21
+ /** The ETag of the copy the caller already has; a 304 means it is still current. */
22
+ readonly etag?: string;
23
+ readonly signal?: AbortSignal;
24
+ }
25
+ /** The catalog schema this service understands (`pipeline/build.py` writes 1). */
26
+ export declare const CONTENT_CATALOG_SCHEMA = 1;
27
+ /** What a caller may pass to {@link ContentHostService.file}. */
28
+ export interface ContentFileRequest {
29
+ /** The content hash the catalog names (64 lowercase hex digits). */
30
+ readonly sha256: string;
31
+ /** The file's extension: `.webp` or `webp`, one of {@link CONTENT_BLOB_EXTENSIONS}. */
32
+ readonly extension: string;
33
+ readonly signal?: AbortSignal;
34
+ }
35
+ /** Every extension a catalog reference may carry (`docs/handoff/gateway.md` §2). */
36
+ export declare const CONTENT_BLOB_EXTENSIONS: readonly [".zip", ".webp", ".mp3", ".ogg", ".wav"];
37
+ /** The largest file this service returns: the gateway's own per-file limit is 5 MB. */
38
+ export declare const CONTENT_BLOB_MAX_BYTES: number;
39
+ /** Construction options. */
40
+ export interface ContentHostServiceOptions {
41
+ readonly http: GatewayHttp;
42
+ /** The plugin version, for callers that print it. */
43
+ readonly version: string;
44
+ /** The signed-in account, exactly as `vibedevMedia.account()` reports it. */
45
+ readonly account: () => Promise<MediaAccountContext>;
46
+ /**
47
+ * The longest one `catalog()` or `file()` call may take in all, retries and body included (default 90 s). Without
48
+ * one, a busy gateway could hold a caller through three attempts and two waits.
49
+ */
50
+ readonly deadlineMs?: number;
51
+ }
52
+ /** The creative library, for other plugins (dsh-film reads it as `vibedevContent`). */
53
+ export declare class ContentHostService {
54
+ private readonly options;
55
+ constructor(options: ContentHostServiceOptions);
56
+ get version(): string;
57
+ /** Whether a VibeDev account is signed in, on which gateway, and under which user. */
58
+ account(): Promise<MediaAccountContext>;
59
+ /**
60
+ * The catalog the gateway currently publishes.
61
+ * @param request - the caller's ETag, and a signal that cancels the read.
62
+ * @returns the catalog, or `notModified` when the caller's ETag is still current.
63
+ * @throws {@link ContentError} `NOT_SIGNED_IN` when nobody is signed in, `ABORTED` when the caller cancelled,
64
+ * `NETWORK_ERROR` when the transfer broke or outlasted the deadline.
65
+ */
66
+ catalog(request?: ContentCatalogRequest): Promise<ContentCatalogOutcome>;
67
+ /**
68
+ * One file the catalog references, by content hash.
69
+ * @param request - the hash, the extension and a signal that cancels the download.
70
+ * @returns the bytes, after checking them against the hash.
71
+ * @throws {@link ContentError} `NOT_FOUND` for a hash the gateway does not have,
72
+ * `HASH_MISMATCH` for bytes that are not the file the catalog named.
73
+ */
74
+ file(request: ContentFileRequest): Promise<Uint8Array>;
75
+ /**
76
+ * The storage URL a redirect names, read without the gateway credential.
77
+ * @param response - the redirect the gateway answered.
78
+ * @param signal - the caller's signal and this download's deadline, as one.
79
+ * @returns the storage response.
80
+ */
81
+ private follow;
82
+ /**
83
+ * Whether a hop may go to this address: https anywhere, plain http only from a gateway that is itself plain http
84
+ * (a development or loopback gateway).
85
+ * @param target - the resolved redirect target.
86
+ */
87
+ private mayFollowTo;
88
+ /**
89
+ * The caller's signal and this operation's own deadline, as one signal.
90
+ * @param callerSignal - the caller's signal, when it passed one.
91
+ */
92
+ private operationSignal;
93
+ /**
94
+ * One failure from below, in the shape a content caller reads.
95
+ * @param error - whatever was thrown.
96
+ * @param callerSignal - the caller's own signal: our deadline is not a cancellation.
97
+ */
98
+ private settled;
99
+ }
@@ -8,9 +8,9 @@ export interface BillingSource {
8
8
  readonly kind: 'balance' | 'subscription';
9
9
  readonly subscriptionId?: string | null;
10
10
  }
11
- export declare const ACCOUNT_PAGES: readonly ["dashboard", "usage", "subscriptions", "available_channels", "channel_status", "model_prices", "recharge", "orders", "redeem", "affiliate", "profile"];
11
+ export declare const ACCOUNT_PAGES: readonly ["dashboard", "usage", "subscriptions", "available_channels", "channel_status", "model_prices", "recharge", "orders", "redeem", "affiliate", "profile", "messages"];
12
12
  export type AccountCenterPage = typeof ACCOUNT_PAGES[number];
13
- export declare const NATIVE_ACCOUNT_PAGES: Set<"dashboard" | "usage" | "subscriptions" | "available_channels" | "channel_status" | "model_prices" | "recharge" | "orders" | "redeem" | "affiliate" | "profile">;
13
+ export declare const NATIVE_ACCOUNT_PAGES: Set<"dashboard" | "usage" | "subscriptions" | "available_channels" | "channel_status" | "model_prices" | "recharge" | "orders" | "redeem" | "affiliate" | "profile" | "messages">;
14
14
  export declare function normalizeAccountPage(page: AccountCenterPage): AccountCenterPage;
15
15
  export interface MediaAccountContext {
16
16
  readonly gatewayOrigin: string;
@@ -60,6 +60,17 @@ export interface GatewayRequest {
60
60
  readonly idempotencyKey?: string;
61
61
  /** Send without the credential (pre-signed upload URLs, public content links). */
62
62
  readonly anonymous?: boolean;
63
+ /**
64
+ * Return a `304 Not Modified` response itself instead of failing: a conditional read that found nothing new is an
65
+ * answer, not a refusal.
66
+ */
67
+ readonly allowNotModified?: boolean;
68
+ /**
69
+ * Redirect handling for this request. The default `error` refuses one, and `manual` hands the hop back so the caller
70
+ * follows it itself, without the credential. This client never follows a redirect on its own: no gateway call it
71
+ * makes is supposed to redirect, and following one blindly could carry the credential somewhere it does not belong.
72
+ */
73
+ readonly redirect?: 'error' | 'manual';
63
74
  /** Retries after a busy answer (429, or 503 with a busy code or `Retry-After`). Defaults to 2. */
64
75
  readonly busyRetries?: number;
65
76
  /** Longest single wait for a busy answer; a longer `Retry-After` fails at once. Defaults to 15 s. */
@@ -102,11 +113,12 @@ export declare class GatewayHttp {
102
113
  /** Whether a URL is on the gateway origin, and so may carry the credential. */
103
114
  isGatewayUrl(url: string): boolean;
104
115
  /**
105
- * Send one request and return the successful response.
116
+ * Send one request and return the answer the caller asked to see.
106
117
  * @param path - gateway path, or an absolute URL.
107
118
  * @param request - method, body, headers and retry policy.
108
- * @returns the 2xx response, body unread.
109
- * @throws {@link MediaError} for every refusal, with the gateway's code.
119
+ * @returns the 2xx response, or — only when the request asks for it — a `304` (`allowNotModified`) or a redirect hop
120
+ * (`redirect: 'manual'`); body unread.
121
+ * @throws {@link MediaError} for every other refusal, with the gateway's code.
110
122
  */
111
123
  send(path: string, request?: GatewayRequest): Promise<Response>;
112
124
  /**
package/lib/index.d.ts CHANGED
@@ -25,6 +25,10 @@ import Schema from '@deepseek-ai/schemastery';
25
25
  import { type ClaudeCacheTtl } from './llm/cache-ttl.js';
26
26
  export { MediaError } from './gateway/errors.js';
27
27
  export { MediaHostService } from './service.js';
28
+ export { ContentHostService } from './content/service.js';
29
+ export { ContentError } from './content/errors.js';
30
+ export type { ContentCatalogOutcome, ContentCatalogRequest, ContentFileRequest, ContentHostServiceOptions } from './content/service.js';
31
+ export type { ContentErrorCode, ContentErrorFacts } from './content/errors.js';
28
32
  export type { HostTarget, MediaOutputView, MediaTaskView } from './service.js';
29
33
  export type { TaskPhase, TaskQueue, TaskStage, TaskTiming } from './tasks/progress.js';
30
34
  export type { AudioForm, AudioFormField, AudioMakeKind, AudioRequest } from './audio/request.js';
@@ -72,6 +76,8 @@ export interface Config {
72
76
  reconcileAttempts: number;
73
77
  /** Ask the user before each paid request. */
74
78
  confirmSpending: Volatile<boolean>;
79
+ /** Send the generated images to the model; off by default, so a result is the saved paths. */
80
+ imagesInContext: Volatile<boolean>;
75
81
  /** Output folder, relative to the workspace (or absolute). */
76
82
  outputDir: Volatile<string>;
77
83
  /** Pinned models; empty lets the agent choose from the catalog. */
@@ -108,6 +114,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
108
114
  submitAttempts: Schema<number, number, "defined">;
109
115
  reconcileAttempts: Schema<number, number, "defined">;
110
116
  confirmSpending: Schema<boolean, boolean, "volatile-defined">;
117
+ imagesInContext: Schema<boolean, boolean, "volatile-defined">;
111
118
  outputDir: Schema<string, string, "volatile-defined">;
112
119
  imageModel: Schema<string, string, "volatile-defined">;
113
120
  videoModel: Schema<string, string, "volatile-defined">;
@@ -132,6 +139,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
132
139
  submitAttempts: Schema<number, number, "defined">;
133
140
  reconcileAttempts: Schema<number, number, "defined">;
134
141
  confirmSpending: Schema<boolean, boolean, "volatile-defined">;
142
+ imagesInContext: Schema<boolean, boolean, "volatile-defined">;
135
143
  outputDir: Schema<string, string, "volatile-defined">;
136
144
  imageModel: Schema<string, string, "volatile-defined">;
137
145
  videoModel: Schema<string, string, "volatile-defined">;