@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
package/lib/account/index.d.ts
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
*
|
|
6
6
|
* - `GET /api/dsh-vibedev/account` — where the credential comes from (the
|
|
7
7
|
* app's account, the plugin's own sign-in, a development key, or none), who
|
|
8
|
-
* is signed in, the balance
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* is signed in, the balance (what can be spent, and what running tasks hold),
|
|
9
|
+
* when it was read, a sign-in waiting for the browser, and how many VibeDev
|
|
10
|
+
* models the pickers list; `?fresh=1` reads the balance again (a read that
|
|
11
|
+
* fails keeps the last balance, says when it was read, and says the read
|
|
12
|
+
* failed); `?since=<revision>` holds the request until the person or the
|
|
13
|
+
* balance changes (a charge is read again right after it ends), so the pages
|
|
14
|
+
* show a new balance within seconds instead of on their next minute poll;
|
|
13
15
|
* - `POST /api/dsh-vibedev/account/sign-in` — `{ open?: boolean }`: start the
|
|
14
16
|
* plugin's own sign-in; answers the authorization link (`open: false` leaves
|
|
15
17
|
* opening it to the page);
|
|
@@ -23,6 +25,7 @@
|
|
|
23
25
|
import type { ConnectionFetchRoute } from '@deepseek-ai/dsh-client-connection';
|
|
24
26
|
import type { CredentialChain } from '../auth/credentials.js';
|
|
25
27
|
import type { PluginLogin, SignInAttempt } from '../auth/login.js';
|
|
28
|
+
import type { GatewayCredential } from '../gateway/http.js';
|
|
26
29
|
/** Path prefix of the plugin's Host routes. */
|
|
27
30
|
export declare const ACCOUNT_ROUTE_PREFIX = "/api/dsh-vibedev/account";
|
|
28
31
|
/** Where the active credential comes from. */
|
|
@@ -36,11 +39,20 @@ export interface AccountView {
|
|
|
36
39
|
readonly email?: string;
|
|
37
40
|
readonly nickname?: string;
|
|
38
41
|
};
|
|
39
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* The balance, when it could be read: `amount` is what can be spent (the gateway's `balance`), `frozen` what
|
|
44
|
+
* running tasks hold (`frozen_balance`: a video or batch-image task moves a hold there when it is submitted and
|
|
45
|
+
* settles it when it ends; absent when the gateway does not say), both in `currency`.
|
|
46
|
+
*/
|
|
40
47
|
readonly balance?: {
|
|
41
48
|
readonly amount: string;
|
|
42
49
|
readonly currency: string;
|
|
50
|
+
readonly frozen?: string;
|
|
43
51
|
};
|
|
52
|
+
/** When the balance shown was read from the gateway (epoch ms): the last read that succeeded. */
|
|
53
|
+
readonly readAt?: number;
|
|
54
|
+
/** The latest read of the balance failed (epoch ms), after `readAt`: the balance shown, if any, is the older one. */
|
|
55
|
+
readonly readFailedAt?: number;
|
|
44
56
|
/** A sign-in waiting for the browser. */
|
|
45
57
|
readonly pending?: {
|
|
46
58
|
readonly url: string;
|
|
@@ -67,6 +79,18 @@ export interface AccountView {
|
|
|
67
79
|
*/
|
|
68
80
|
readonly revision: number;
|
|
69
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Who is signed in to VibeDev right now, for work that must go out under one account (feedback): the credential the
|
|
84
|
+
* next request would carry, and the VibeDev user id — `/v1/account/auth/me`'s `data.id`, else (the plugin's own
|
|
85
|
+
* sign-in, while the gateway cannot be read) the id the sign-in answer named. Undefined when neither is known.
|
|
86
|
+
*/
|
|
87
|
+
export type AccountIdentity = {
|
|
88
|
+
readonly signedIn: false;
|
|
89
|
+
} | {
|
|
90
|
+
readonly signedIn: true;
|
|
91
|
+
readonly credential: GatewayCredential;
|
|
92
|
+
readonly userId: string | undefined;
|
|
93
|
+
};
|
|
70
94
|
/** What the account routes need from the plugin. */
|
|
71
95
|
export interface AccountServiceOptions {
|
|
72
96
|
readonly origin: string;
|
|
@@ -102,6 +126,10 @@ export declare class AccountService {
|
|
|
102
126
|
private epoch;
|
|
103
127
|
/** When the last read after a charge started, to space them out. */
|
|
104
128
|
private lastSpendReadAt;
|
|
129
|
+
/** The last read that succeeded, kept for the pages while a later read fails. */
|
|
130
|
+
private lastGood;
|
|
131
|
+
/** The latest read failed, after the last one that succeeded. */
|
|
132
|
+
private failure;
|
|
105
133
|
/**
|
|
106
134
|
* @param options - origin, credential chain, the plugin's sign-in and the route's model state.
|
|
107
135
|
*/
|
|
@@ -135,6 +163,12 @@ export declare class AccountService {
|
|
|
135
163
|
* @returns the view.
|
|
136
164
|
*/
|
|
137
165
|
view(fresh?: boolean): Promise<AccountView>;
|
|
166
|
+
/**
|
|
167
|
+
* Who is signed in now, with the VibeDev user id when it can be known (a recent `/auth/me` read is reused, as for
|
|
168
|
+
* the pages).
|
|
169
|
+
* @returns the identity.
|
|
170
|
+
*/
|
|
171
|
+
identity(): Promise<AccountIdentity>;
|
|
138
172
|
/**
|
|
139
173
|
* `GET /v1/account/auth/me` for one token. A read younger than the TTL is
|
|
140
174
|
* reused; an older one is answered at once while a new read runs behind it.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The network latency from this Host to the VibeDev gateway, for the balance
|
|
3
|
+
* card (`POST /api/dsh-vibedev/latency`; `?fresh=1` measures again within the
|
|
4
|
+
* minute a measurement is kept).
|
|
5
|
+
*
|
|
6
|
+
* It times `GET {origin}/health` — no credential, no database on the gateway,
|
|
7
|
+
* and left out of its access log — from the Host process, over the same fetch
|
|
8
|
+
* (and so the same network path and proxy settings) the plugin's gateway and
|
|
9
|
+
* model requests use: one request first, untimed, to set up the connection
|
|
10
|
+
* (DNS, TCP, TLS), then four in a row on that connection, each given 5 s. The
|
|
11
|
+
* answer is their median, each of them, the first request's time and when it
|
|
12
|
+
* ended; or why it stopped (no answer in time, no connection, an HTTP status).
|
|
13
|
+
* This is how far away the gateway is on the network, not how fast a model is.
|
|
14
|
+
*
|
|
15
|
+
* One measurement runs at a time, and a result is reused for a minute.
|
|
16
|
+
* @module dsh-vibedev/account/latency
|
|
17
|
+
*/
|
|
18
|
+
import type { ConnectionFetchRoute } from '@deepseek-ai/dsh-client-connection';
|
|
19
|
+
/** Path of the latency route. */
|
|
20
|
+
export declare const LATENCY_ROUTE = "/api/dsh-vibedev/latency";
|
|
21
|
+
/** Why a measurement stopped. */
|
|
22
|
+
export type LatencyErrorKind = 'timeout' | 'network' | 'http';
|
|
23
|
+
/** One measurement. Times are whole milliseconds. */
|
|
24
|
+
export interface LatencyResult {
|
|
25
|
+
/** Median of the timed requests, when every request answered. */
|
|
26
|
+
readonly medianMs?: number;
|
|
27
|
+
/** Each timed request, in order (those that answered before one failed, on a failure). */
|
|
28
|
+
readonly samplesMs: readonly number[];
|
|
29
|
+
/** The first, untimed request, connection setup included; absent when it failed. */
|
|
30
|
+
readonly warmupMs?: number;
|
|
31
|
+
/** When the measurement ended (epoch ms). */
|
|
32
|
+
readonly measuredAt: number;
|
|
33
|
+
/** Why it stopped: no answer within 5 s, no connection (or a redirect), or an HTTP status other than 2xx. */
|
|
34
|
+
readonly error?: {
|
|
35
|
+
readonly kind: LatencyErrorKind;
|
|
36
|
+
readonly status?: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** What the probe needs. */
|
|
40
|
+
export interface LatencyProbeOptions {
|
|
41
|
+
readonly origin: string;
|
|
42
|
+
readonly userAgent: string;
|
|
43
|
+
/** The fetch the plugin's gateway requests use (the global one unless a test passes its own). */
|
|
44
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
45
|
+
/** Wall clock (epoch ms), for `measuredAt` and the minute a result is kept. */
|
|
46
|
+
readonly now?: () => number;
|
|
47
|
+
/** Monotonic clock (ms) one request is timed with. */
|
|
48
|
+
readonly clock?: () => number;
|
|
49
|
+
/** The per-request deadline (a test seam for `AbortSignal.timeout`). */
|
|
50
|
+
readonly timeout?: (ms: number) => AbortSignal;
|
|
51
|
+
/** The untimed pause before each timed request (a test seam). */
|
|
52
|
+
readonly pause?: () => Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/** Measures the network latency to the gateway. */
|
|
55
|
+
export declare class LatencyProbe {
|
|
56
|
+
private readonly options;
|
|
57
|
+
private last;
|
|
58
|
+
private running;
|
|
59
|
+
private readonly now;
|
|
60
|
+
private readonly clock;
|
|
61
|
+
/**
|
|
62
|
+
* @param options - the gateway origin, the plugin's user agent, and the fetch and clock seams.
|
|
63
|
+
*/
|
|
64
|
+
constructor(options: LatencyProbeOptions);
|
|
65
|
+
/**
|
|
66
|
+
* The latency, measured now or within the last minute. One measurement runs at a time: a call while one runs
|
|
67
|
+
* shares it.
|
|
68
|
+
* @param fresh - measure again even when the last result is younger than a minute.
|
|
69
|
+
* @returns the result (a failure is a result too, with its error).
|
|
70
|
+
*/
|
|
71
|
+
measure(fresh?: boolean): Promise<LatencyResult>;
|
|
72
|
+
private run;
|
|
73
|
+
/** One `GET /health`, timed until its body has been read (which also lets the connection be reused). */
|
|
74
|
+
private once;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The latency route.
|
|
78
|
+
* @param probe - the probe.
|
|
79
|
+
* @returns routes for the client connection.
|
|
80
|
+
*/
|
|
81
|
+
export declare function latencyRoutes(probe: LatencyProbe): ConnectionFetchRoute[];
|
|
@@ -798,7 +798,7 @@ function redactSensitive(body) {
|
|
|
798
798
|
*/
|
|
799
799
|
async function checkCredentialsFileSafety(path, onWarn = (m) => console.warn(`anthropic-sdk: ${m}`)) {
|
|
800
800
|
if (typeof process === "undefined" || process.platform === "win32") return;
|
|
801
|
-
const { fs } = await import("./node-
|
|
801
|
+
const { fs } = await import("./node-Br-0fshF.js").then((n) => n.i);
|
|
802
802
|
let resolved = path;
|
|
803
803
|
let st;
|
|
804
804
|
try {
|
|
@@ -818,7 +818,7 @@ async function checkCredentialsFileSafety(path, onWarn = (m) => console.warn(`an
|
|
|
818
818
|
* Creates the parent directory with mode 0700 and the file with mode 0600.
|
|
819
819
|
*/
|
|
820
820
|
async function writeCredentialsFileAtomic(targetPath, data) {
|
|
821
|
-
const { fs, path } = await import("./node-
|
|
821
|
+
const { fs, path } = await import("./node-Br-0fshF.js").then((n) => n.i);
|
|
822
822
|
const dir = path.dirname(targetPath);
|
|
823
823
|
await fs.promises.mkdir(dir, {
|
|
824
824
|
recursive: true,
|
|
@@ -1128,7 +1128,7 @@ const loadConfigWithSource = async (profile) => {
|
|
|
1128
1128
|
const profileName = profile ?? await getActiveProfileName();
|
|
1129
1129
|
if (profileName === null) return null;
|
|
1130
1130
|
validateProfileName(profileName);
|
|
1131
|
-
const { fs, path } = await import("./node-
|
|
1131
|
+
const { fs, path } = await import("./node-Br-0fshF.js").then((n) => n.i);
|
|
1132
1132
|
const configPath = path.join(rootConfigPath, "configs", `${profileName}.json`);
|
|
1133
1133
|
let configRaw;
|
|
1134
1134
|
try {
|
|
@@ -1205,12 +1205,12 @@ const getCredentialsPath = async (config, profile) => {
|
|
|
1205
1205
|
const profileName = profile ?? await getActiveProfileName();
|
|
1206
1206
|
if (!profileName) return null;
|
|
1207
1207
|
validateProfileName(profileName);
|
|
1208
|
-
const { path } = await import("./node-
|
|
1208
|
+
const { path } = await import("./node-Br-0fshF.js").then((n) => n.i);
|
|
1209
1209
|
return path.join(rootConfigPath, "credentials", `${profileName}.json`);
|
|
1210
1210
|
};
|
|
1211
1211
|
const getRootConfigPath = async () => {
|
|
1212
1212
|
if (!supportsLocalConfigFiles()) return null;
|
|
1213
|
-
const { path } = await import("./node-
|
|
1213
|
+
const { path } = await import("./node-Br-0fshF.js").then((n) => n.i);
|
|
1214
1214
|
const configDir = readEnv("ANTHROPIC_CONFIG_DIR");
|
|
1215
1215
|
if (configDir) return configDir;
|
|
1216
1216
|
if (getPlatformHeaders()["X-Stainless-OS"] === "Windows") {
|
|
@@ -1235,7 +1235,7 @@ const getActiveProfileName = async () => {
|
|
|
1235
1235
|
if (!rootConfigPath) return null;
|
|
1236
1236
|
const profileName = readEnv("ANTHROPIC_PROFILE");
|
|
1237
1237
|
if (profileName) return profileName;
|
|
1238
|
-
const { fs, path } = await import("./node-
|
|
1238
|
+
const { fs, path } = await import("./node-Br-0fshF.js").then((n) => n.i);
|
|
1239
1239
|
const filePath = path.join(rootConfigPath, "active_config");
|
|
1240
1240
|
try {
|
|
1241
1241
|
return (await fs.promises.readFile(filePath, "utf-8")).trim() || "default";
|
|
@@ -1253,7 +1253,7 @@ const getActiveProfileName = async () => {
|
|
|
1253
1253
|
function identityTokenFromFile(path) {
|
|
1254
1254
|
if (!path) throw new AnthropicError("Identity token file path is empty");
|
|
1255
1255
|
return async () => {
|
|
1256
|
-
const { fs } = await import("./node-
|
|
1256
|
+
const { fs } = await import("./node-Br-0fshF.js").then((n) => n.i);
|
|
1257
1257
|
let content;
|
|
1258
1258
|
try {
|
|
1259
1259
|
content = await fs.promises.readFile(path, "utf-8");
|
|
@@ -1341,7 +1341,7 @@ function oidcFederationProvider(config) {
|
|
|
1341
1341
|
*/
|
|
1342
1342
|
function userOAuthProvider(config) {
|
|
1343
1343
|
return async (opts) => {
|
|
1344
|
-
const { fs } = await import("./node-
|
|
1344
|
+
const { fs } = await import("./node-Br-0fshF.js").then((n) => n.i);
|
|
1345
1345
|
await checkCredentialsFileSafety(config.credentialsPath, config.onSafetyWarning);
|
|
1346
1346
|
let raw;
|
|
1347
1347
|
try {
|
|
@@ -1518,7 +1518,7 @@ function resolveIdentityTokenProvider(auth) {
|
|
|
1518
1518
|
*/
|
|
1519
1519
|
function cachedExchangeProvider(exchange, credentialsPath, onCacheWriteError, onSafetyWarning) {
|
|
1520
1520
|
return async (opts) => {
|
|
1521
|
-
const { fs } = await import("./node-
|
|
1521
|
+
const { fs } = await import("./node-Br-0fshF.js").then((n) => n.i);
|
|
1522
1522
|
await checkCredentialsFileSafety(credentialsPath, onSafetyWarning);
|
|
1523
1523
|
let existing;
|
|
1524
1524
|
try {
|
|
@@ -5211,7 +5211,7 @@ _EnvironmentWorker_signal = /* @__PURE__ */ new WeakMap(), _EnvironmentWorker_in
|
|
|
5211
5211
|
const ctrl = new AbortController();
|
|
5212
5212
|
const detachExternal = linkAbort(externalSignal, ctrl);
|
|
5213
5213
|
const lease = new Lease(ctrl);
|
|
5214
|
-
const agentToolset = await import("./node-
|
|
5214
|
+
const agentToolset = await import("./node-D58f7Ea6.js");
|
|
5215
5215
|
let leaseTtlMs;
|
|
5216
5216
|
let runner;
|
|
5217
5217
|
const heartbeatPromise = heartbeatLoop(sessionClient, work, lease, log, this.requestOptions, (ttlMs) => {
|
|
@@ -13469,4 +13469,4 @@ function mapStopReason(reason, stopDetails) {
|
|
|
13469
13469
|
//#endregion
|
|
13470
13470
|
export { checkMemorySyncInterval as a, decodeUTF8 as c, AnthropicError as d, __classPrivateFieldGet as f, MIN_MEMORY_SYNC_INTERVAL_MS as i, encodeUTF8 as l, promiseWithResolvers as n, isStatus as o, __classPrivateFieldSet as p, DEFAULT_MEMORY_SYNC_INTERVAL_MS as r, loggerFor as s, stream, streamSimple, anthropic_messages_exports as t, ToolError as u };
|
|
13471
13471
|
|
|
13472
|
-
//# sourceMappingURL=anthropic-messages-
|
|
13472
|
+
//# sourceMappingURL=anthropic-messages-BgIfgjNt.js.map
|
package/lib/audio/request.d.ts
CHANGED
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
* | podcast | model, prompt, source_url |
|
|
12
12
|
* | speech | as declared; Seed: model, text_prompt, references, audio_config, watermark |
|
|
13
13
|
*
|
|
14
|
+
* Seed (`seed-audio-1.0`) parses its body strictly: each reference is an object
|
|
15
|
+
* naming its input (`{"audio_url": "<url>"}`) and the watermark an object
|
|
16
|
+
* (`{"aigc_watermark": true}`); the model's declaration says so (the inputs of
|
|
17
|
+
* its reference union, `watermark_fields`), and only such a model gets them.
|
|
18
|
+
*
|
|
14
19
|
* The main text goes in the model's `prompt_field`. A field the model does not
|
|
15
20
|
* declare in `request_fields` is refused before anything is uploaded or charged;
|
|
16
21
|
* music and podcasts never take speech references, output formats, sample rates
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `client` block of a feedback upload: which VibeDev app the Host serves,
|
|
3
|
+
* its version, the DeepSeek Harness and plugin versions, the operating system
|
|
4
|
+
* and the locale.
|
|
5
|
+
* @module dsh-vibedev/feedback/client-info
|
|
6
|
+
*/
|
|
7
|
+
import { type FeedbackClient } from './wire.js';
|
|
8
|
+
export type HostApp = 'vibedev-desktop' | 'vibedev-web';
|
|
9
|
+
/** The process facts the client block is read from (a test seam). */
|
|
10
|
+
export interface HostFacts {
|
|
11
|
+
readonly versions: Readonly<Record<string, string | undefined>>;
|
|
12
|
+
/** The process has an IPC channel to the process that started it. */
|
|
13
|
+
readonly hasIpc: boolean;
|
|
14
|
+
readonly execPath: string;
|
|
15
|
+
readonly platform: string;
|
|
16
|
+
readonly arch: string;
|
|
17
|
+
readonly osRelease: string;
|
|
18
|
+
readonly locale: string | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* This process's facts.
|
|
22
|
+
* @returns the facts.
|
|
23
|
+
*/
|
|
24
|
+
export declare function hostFacts(): HostFacts;
|
|
25
|
+
/**
|
|
26
|
+
* Which app the Host serves. The VibeDev desktop app starts its Host from the window process on its own executable in
|
|
27
|
+
* Electron's Node mode, with an IPC channel back (apps/desktop/src/host-process.ts: `spawn(process.execPath, …,
|
|
28
|
+
* { stdio: [..., 'ipc'] })`); in that mode `process.versions.electron` is still set. `vibedev-app web` runs the same
|
|
29
|
+
* executable from a terminal, without that channel, and a DeepSeek Harness install runs on Node: both serve the
|
|
30
|
+
* browser. (Checked against VibeDev 0.2.1-rc.2.20261019.3: Electron 44.7.0, `process.send` present only with IPC.)
|
|
31
|
+
* @param facts - the process facts.
|
|
32
|
+
* @returns `vibedev-desktop` or `vibedev-web`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function hostApp(facts: HostFacts): HostApp;
|
|
35
|
+
/**
|
|
36
|
+
* The desktop app's own version, from its manifest beside the executable (`resources/app.asar/package.json`; on macOS
|
|
37
|
+
* `Contents/Resources`), which Electron's Node mode reads like any file.
|
|
38
|
+
* @param facts - the process facts.
|
|
39
|
+
* @param read - reads a file as text (a test seam).
|
|
40
|
+
* @returns the version, or undefined when there is no manifest to read.
|
|
41
|
+
*/
|
|
42
|
+
export declare function desktopAppVersion(facts: HostFacts, read?: (path: string) => string): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The client block for this Host.
|
|
45
|
+
* @param facts - the process facts.
|
|
46
|
+
* @param pluginVersion - this plugin's version.
|
|
47
|
+
* @param dshVersion - DeepSeek Harness's version (the LLM runtime's own manifest, as its User-Agent reports).
|
|
48
|
+
* @param read - reads the desktop manifest (a test seam).
|
|
49
|
+
* @returns the block, every field within the contract's limits.
|
|
50
|
+
*/
|
|
51
|
+
export declare function clientInfo(facts: HostFacts, pluginVersion: string, dshVersion?: string, read?: (path: string) => string): FeedbackClient;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User feedback that reaches VibeDev. VibeDev turns off DeepSeek Harness's own
|
|
3
|
+
* feedback upload (session-telemetry-otel), so a rating or a `/feedback`
|
|
4
|
+
* stayed in the local session log; this uploads them to the gateway
|
|
5
|
+
* (`POST /v1/account/feedback`) with the VibeDev account they were given
|
|
6
|
+
* under, plus feedback given through the account menu's dialog. See observe.ts
|
|
7
|
+
* for what counts as new feedback, uploader.ts for the answers and the account
|
|
8
|
+
* rule, queue.ts for what is kept.
|
|
9
|
+
* @module dsh-vibedev/feedback
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import type { AccountIdentity } from '../account/index.js';
|
|
13
|
+
import type { GatewayCredential } from '../gateway/http.js';
|
|
14
|
+
import { RecentErrors } from './recent-errors.js';
|
|
15
|
+
import { FeedbackUploader } from './uploader.js';
|
|
16
|
+
export { FEEDBACK_ATTACHMENT_ROUTE, FEEDBACK_ROUTE } from './routes.js';
|
|
17
|
+
/** What the feedback upload needs from the plugin. */
|
|
18
|
+
export interface FeedbackOptions {
|
|
19
|
+
/** The gateway and the plugin's user agent (`fetch` for tests). */
|
|
20
|
+
readonly gateway: {
|
|
21
|
+
readonly origin: string;
|
|
22
|
+
readonly userAgent: string;
|
|
23
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
24
|
+
};
|
|
25
|
+
/** This gateway's state directory (the sign-in lives there too). */
|
|
26
|
+
readonly gatewayDir: string;
|
|
27
|
+
readonly pluginVersion: string;
|
|
28
|
+
/** Who is signed in now, with the VibeDev user id (the account service). */
|
|
29
|
+
readonly identity: () => Promise<AccountIdentity>;
|
|
30
|
+
/** Let a credential's owner renew it after the gateway refused it. */
|
|
31
|
+
readonly rejectCredential: (credential: GatewayCredential) => Promise<void>;
|
|
32
|
+
/** Subscribe to sign-in changes; returns unsubscribe. */
|
|
33
|
+
readonly onCredentialChange: (listener: () => void) => () => void;
|
|
34
|
+
readonly log: (message: string) => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Install the feedback upload: listen for new feedback and recent failures, serve the dialog's routes, and send what
|
|
38
|
+
* the queue holds.
|
|
39
|
+
* @param ctx - the plugin context.
|
|
40
|
+
* @param options - the gateway, the state directory, who is signed in, and the sign-in hooks.
|
|
41
|
+
* @returns the uploader and the recent errors (for tests and other parts of the plugin).
|
|
42
|
+
*/
|
|
43
|
+
export declare function installFeedback(ctx: Context, options: FeedbackOptions): {
|
|
44
|
+
uploader: FeedbackUploader;
|
|
45
|
+
errors: RecentErrors;
|
|
46
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which new Session events are feedback to upload, and what each says.
|
|
3
|
+
*
|
|
4
|
+
* DeepSeek Harness records feedback as Session events, the way its own
|
|
5
|
+
* telemetry plugin finds them (session-telemetry-otel, `isFeedback`):
|
|
6
|
+
*
|
|
7
|
+
* - `feedback/record` — `/feedback` (and the `sessionFeedback.record` Remote):
|
|
8
|
+
* `{ text?, category? }` (@deepseek-ai/dsh-command-feedback);
|
|
9
|
+
* - `feedback/message-put` — a rating of an assistant message, created or
|
|
10
|
+
* edited: `{ sessionId, item: { messageId, rating, note?, category?, … } }`;
|
|
11
|
+
* - `feedback/message-delete` — a rating removed: never uploaded
|
|
12
|
+
* (@deepseek-ai/dsh-message-feedback).
|
|
13
|
+
*
|
|
14
|
+
* A live Session publishes each appended event on `session/event`; feedback on
|
|
15
|
+
* a Session that is not open is written to its log directly and announced on
|
|
16
|
+
* `feedback/committed` with the event last in the inspection. Restored and
|
|
17
|
+
* fork-seeded history never publishes, and inherited events (a fork's copy of
|
|
18
|
+
* its parent, `seq < inheritedEventCount`, or a rating whose `sessionId` is the
|
|
19
|
+
* parent's) are skipped, so only feedback given after the plugin started is
|
|
20
|
+
* uploaded; no log is ever scanned.
|
|
21
|
+
* @module dsh-vibedev/feedback/observe
|
|
22
|
+
*/
|
|
23
|
+
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
24
|
+
import type { SessionInspection } from '@deepseek-ai/dsh-session-persistence';
|
|
25
|
+
import { type FeedbackDraft } from './wire.js';
|
|
26
|
+
/** The Session an event belongs to, as far as telling new feedback from inherited feedback goes. */
|
|
27
|
+
export interface EventOwner {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly inheritedEventCount: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The feedback one newly appended event carries.
|
|
33
|
+
* @param owner - the Session the event was appended to.
|
|
34
|
+
* @param event - the event.
|
|
35
|
+
* @returns the draft, or undefined for anything else (another event, a deletion, inherited or empty feedback).
|
|
36
|
+
*/
|
|
37
|
+
export declare function draftFromEvent(owner: EventOwner, event: SessionEvent): FeedbackDraft | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The feedback a committed write to a Session that is not open carries: the inspection's last event.
|
|
40
|
+
* @param inspection - the committed log, the feedback last.
|
|
41
|
+
* @returns the draft, or undefined.
|
|
42
|
+
*/
|
|
43
|
+
export declare function draftFromCommitted(inspection: SessionInspection): FeedbackDraft | undefined;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feedback waiting to be uploaded, kept so a retry survives a restart: one
|
|
3
|
+
* JSON file next to the plugin's sign-in for this gateway
|
|
4
|
+
* (`<state dir>/gateways/<gateway id>/feedback-queue.json`), readable by its
|
|
5
|
+
* owner only, replaced atomically on every change. Each item is the exact body
|
|
6
|
+
* to send (its id is the idempotency key), the VibeDev account it belongs to,
|
|
7
|
+
* and when to try next.
|
|
8
|
+
*
|
|
9
|
+
* Caps: 200 items, 30 days, 4 MiB in all; past them the oldest give way.
|
|
10
|
+
* @module dsh-vibedev/feedback/queue
|
|
11
|
+
*/
|
|
12
|
+
import { type FeedbackBody } from './wire.js';
|
|
13
|
+
export declare const QUEUE_MAX_ITEMS = 200;
|
|
14
|
+
export declare const QUEUE_MAX_AGE_MS: number;
|
|
15
|
+
export declare const QUEUE_MAX_BYTES: number;
|
|
16
|
+
/**
|
|
17
|
+
* Whose feedback it is, so it only ever goes out under that VibeDev account:
|
|
18
|
+
*
|
|
19
|
+
* - `user`: the account signed in when it was given (its VibeDev user id);
|
|
20
|
+
* - `signed-out`: given while nobody was signed in — it goes with the next account that signs in (once that
|
|
21
|
+
* account's id is known), and from its first attempt on belongs to that account;
|
|
22
|
+
* - `unidentified`: given while signed in to an account whose id could not be read (the gateway unreachable, the
|
|
23
|
+
* app's account): only the same credential, in the same run, may send it, and once that credential's account id is
|
|
24
|
+
* known it belongs to that account; after a restart it waits out the caps, never sent under anyone else.
|
|
25
|
+
*/
|
|
26
|
+
export type FeedbackOwner = {
|
|
27
|
+
readonly kind: 'user';
|
|
28
|
+
readonly id: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: 'signed-out';
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: 'unidentified';
|
|
33
|
+
};
|
|
34
|
+
/** One waiting upload. */
|
|
35
|
+
export interface QueueItem {
|
|
36
|
+
readonly body: FeedbackBody;
|
|
37
|
+
readonly owner: FeedbackOwner;
|
|
38
|
+
readonly enqueuedAt: number;
|
|
39
|
+
/** Attempts that ended without a final answer. */
|
|
40
|
+
readonly attempts: number;
|
|
41
|
+
/** Not before this time (epoch ms). */
|
|
42
|
+
readonly nextAt: number;
|
|
43
|
+
/** What the last attempt ended with (status or code), for diagnostics; never the body. */
|
|
44
|
+
readonly last?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Construction options. */
|
|
47
|
+
export interface FeedbackQueueOptions {
|
|
48
|
+
readonly now?: () => number;
|
|
49
|
+
readonly maxItems?: number;
|
|
50
|
+
readonly maxAgeMs?: number;
|
|
51
|
+
readonly maxBytes?: number;
|
|
52
|
+
}
|
|
53
|
+
/** The persistent queue. All changes are serialized; reads see the latest state. */
|
|
54
|
+
export declare class FeedbackQueue {
|
|
55
|
+
readonly file: string;
|
|
56
|
+
private readonly options;
|
|
57
|
+
private state;
|
|
58
|
+
private loading;
|
|
59
|
+
private writing;
|
|
60
|
+
private readonly now;
|
|
61
|
+
/**
|
|
62
|
+
* @param file - the queue file.
|
|
63
|
+
* @param options - caps and the clock (test seams).
|
|
64
|
+
*/
|
|
65
|
+
constructor(file: string, options?: FeedbackQueueOptions);
|
|
66
|
+
/** Read the file once; a missing or unreadable file is an empty queue (and is replaced on the next change). */
|
|
67
|
+
load(): Promise<void>;
|
|
68
|
+
/** The waiting items, oldest first. */
|
|
69
|
+
items(): readonly QueueItem[];
|
|
70
|
+
/**
|
|
71
|
+
* Queue one body at the end.
|
|
72
|
+
* @param body - the exact body to send.
|
|
73
|
+
* @param owner - the VibeDev account it belongs to.
|
|
74
|
+
*/
|
|
75
|
+
add(body: FeedbackBody, owner: FeedbackOwner): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Record how an attempt ended without a final answer.
|
|
78
|
+
* @param id - the item's body id.
|
|
79
|
+
* @param change - the attempt count, when to try next, and what it ended with.
|
|
80
|
+
*/
|
|
81
|
+
update(id: string, change: Pick<QueueItem, 'attempts' | 'nextAt'> & {
|
|
82
|
+
readonly last?: string;
|
|
83
|
+
}): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Give an item to an account (feedback given signed out, or by an account not identified then, on its first
|
|
86
|
+
* attempt): from now on it goes out under that account only.
|
|
87
|
+
* @param id - the item's body id.
|
|
88
|
+
* @param owner - the account.
|
|
89
|
+
*/
|
|
90
|
+
bind(id: string, owner: FeedbackOwner): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Put a new body in an item's place (the gateway asked for a smaller one): same position and owner, attempts start
|
|
93
|
+
* over.
|
|
94
|
+
* @param id - the item's current body id.
|
|
95
|
+
* @param body - the new body.
|
|
96
|
+
*/
|
|
97
|
+
replace(id: string, body: FeedbackBody): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Take an item out (sent, or refused for good).
|
|
100
|
+
* @param id - the item's body id.
|
|
101
|
+
*/
|
|
102
|
+
remove(id: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Apply the caps: too old first, then the oldest past the count, then the oldest past the size.
|
|
105
|
+
* @returns whether anything was dropped.
|
|
106
|
+
*/
|
|
107
|
+
private prune;
|
|
108
|
+
/** Write the current state; owner-only from creation, replaced atomically, one write at a time. */
|
|
109
|
+
private save;
|
|
110
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The last failures this Host saw, in memory only, for the feedback dialog's
|
|
3
|
+
* optional attachment: a tool call that failed (`tool/result` with `isError`,
|
|
4
|
+
* named by its `tool/call`) and a turn that ended in a model or request error
|
|
5
|
+
* (`turn/end` with `reason.kind: 'error'`), each with its time and Session.
|
|
6
|
+
* Nothing is written anywhere; the user sees the exact text before choosing to
|
|
7
|
+
* send it.
|
|
8
|
+
* @module dsh-vibedev/feedback/recent-errors
|
|
9
|
+
*/
|
|
10
|
+
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
11
|
+
/** One failure. */
|
|
12
|
+
export interface RecentError {
|
|
13
|
+
readonly at: number;
|
|
14
|
+
readonly sessionRef: string;
|
|
15
|
+
readonly kind: 'tool' | 'model';
|
|
16
|
+
/** The failing tool's name, for a tool failure. */
|
|
17
|
+
readonly tool?: string;
|
|
18
|
+
readonly code?: string;
|
|
19
|
+
readonly status?: number;
|
|
20
|
+
/** The failure's own words, cut to 500 characters. */
|
|
21
|
+
readonly message: string;
|
|
22
|
+
}
|
|
23
|
+
/** The attachment as the user sees it and as it is sent. */
|
|
24
|
+
export interface ErrorLogAttachment {
|
|
25
|
+
readonly content: string;
|
|
26
|
+
readonly entries: number;
|
|
27
|
+
readonly bytes: number;
|
|
28
|
+
}
|
|
29
|
+
/** The last failures this Host saw. */
|
|
30
|
+
export declare class RecentErrors {
|
|
31
|
+
private readonly entries;
|
|
32
|
+
private readonly toolNames;
|
|
33
|
+
private readonly now;
|
|
34
|
+
private readonly max;
|
|
35
|
+
/**
|
|
36
|
+
* @param options - how many failures to keep, and the clock (test seams).
|
|
37
|
+
*/
|
|
38
|
+
constructor(options?: {
|
|
39
|
+
readonly max?: number;
|
|
40
|
+
readonly now?: () => number;
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Note one appended event.
|
|
44
|
+
* @param session - the Session it was appended to.
|
|
45
|
+
* @param event - the event.
|
|
46
|
+
*/
|
|
47
|
+
observe(session: {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
}, event: SessionEvent): void;
|
|
50
|
+
private push;
|
|
51
|
+
/** The kept failures, newest first. */
|
|
52
|
+
list(): readonly RecentError[];
|
|
53
|
+
/**
|
|
54
|
+
* The attachment text: a header, then one line per failure, newest first, cut to the attachment limit (so what
|
|
55
|
+
* gives way first is the oldest).
|
|
56
|
+
* @returns the text, its line count and its size; empty when nothing failed.
|
|
57
|
+
*/
|
|
58
|
+
attachment(): ErrorLogAttachment;
|
|
59
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The feedback dialog's Host routes (answers are never cached):
|
|
3
|
+
*
|
|
4
|
+
* - `GET /api/dsh-vibedev/feedback/attachment` — the exact text the "attach
|
|
5
|
+
* recent errors" box would send, its line count and size;
|
|
6
|
+
* - `POST /api/dsh-vibedev/feedback` — `{ category?, text?, attachment?:
|
|
7
|
+
* { content }, locale? }`: queued as `source: 'menu'` (an attachment only as
|
|
8
|
+
* an `error-log` the user consented to by ticking the box) and sent at once
|
|
9
|
+
* when it can be; answers `sent`, `queued` (with why) or `rejected`. Nothing
|
|
10
|
+
* is queued while nobody is signed in: feedback goes with the VibeDev
|
|
11
|
+
* account, never anonymously.
|
|
12
|
+
* @module dsh-vibedev/feedback/routes
|
|
13
|
+
*/
|
|
14
|
+
import type { ConnectionFetchRoute } from '@deepseek-ai/dsh-client-connection';
|
|
15
|
+
import type { RecentErrors } from './recent-errors.js';
|
|
16
|
+
import type { SubmitOutcome } from './uploader.js';
|
|
17
|
+
import { type FeedbackDraft } from './wire.js';
|
|
18
|
+
export declare const FEEDBACK_ROUTE = "/api/dsh-vibedev/feedback";
|
|
19
|
+
export declare const FEEDBACK_ATTACHMENT_ROUTE = "/api/dsh-vibedev/feedback/attachment";
|
|
20
|
+
/** What the routes need. */
|
|
21
|
+
export interface FeedbackRouteOptions {
|
|
22
|
+
readonly submit: (draft: FeedbackDraft, locale?: string) => Promise<SubmitOutcome>;
|
|
23
|
+
readonly errors: Pick<RecentErrors, 'attachment'>;
|
|
24
|
+
readonly hasCredential: () => Promise<boolean>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The feedback routes.
|
|
28
|
+
* @param options - the uploader's submit, the recent errors and the credential check.
|
|
29
|
+
* @returns routes for the client connection.
|
|
30
|
+
*/
|
|
31
|
+
export declare function feedbackRoutes(options: FeedbackRouteOptions): ConnectionFetchRoute[];
|