@vibedev-si/dsh-vibedev 0.5.0 → 0.5.2
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 +72 -4
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/client/client.account-center.js +436 -32
- package/client/client.js +94 -8
- package/lib/account/center-business-contract.d.ts +1 -1
- package/lib/account/center-contract.d.ts +1 -1
- package/lib/fetch/host-web.d.ts +34 -0
- package/lib/fetch/provider.d.ts +125 -0
- package/lib/fetch/wiring.d.ts +124 -0
- package/lib/gateway/http.d.ts +20 -2
- package/lib/index.d.ts +10 -0
- package/lib/index.js +834 -105
- package/lib/search/provider.d.ts +28 -5
- package/package.json +32 -26
- package/scripts/verify-fetch-joint.mjs +72 -0
package/client/client.js
CHANGED
|
@@ -1164,15 +1164,14 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1164
1164
|
memberRedeemReceipt: "兑换权益",
|
|
1165
1165
|
memberReceiptRefresh: "已读取服务端回执;余额和订阅以刷新后的账号为准。",
|
|
1166
1166
|
memberAffiliateTitle: "邀请返利",
|
|
1167
|
-
memberAffiliateNote: "
|
|
1167
|
+
memberAffiliateNote: "邀请好友注册即可获得返利,返利方式见下方说明。冻结期满的返利,点「更新并解冻到期返利」后可转入账号余额。",
|
|
1168
1168
|
memberAvailable: "可转入返利",
|
|
1169
1169
|
memberFrozen: "冻结返利",
|
|
1170
1170
|
memberLifetime: "累计返利",
|
|
1171
|
-
memberRebateRate: "返利比例",
|
|
1172
1171
|
memberInviteCount: "已邀请人数",
|
|
1173
1172
|
memberInvitation: "邀请链接",
|
|
1174
|
-
memberGenerateRefresh: "生成邀请链接
|
|
1175
|
-
memberRefreshRebates: "
|
|
1173
|
+
memberGenerateRefresh: "生成邀请链接",
|
|
1174
|
+
memberRefreshRebates: "更新并解冻到期返利",
|
|
1176
1175
|
memberUninitialized: "尚未生成邀请链接;点击上方按钮生成。",
|
|
1177
1176
|
memberInviteUnavailable: "邀请链接暂不可用,请检查网关账号后刷新。",
|
|
1178
1177
|
memberCopy: "复制邀请链接",
|
|
@@ -1190,6 +1189,50 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1190
1189
|
memberTransferEmpty: "暂无可转入返利。",
|
|
1191
1190
|
memberTransferred: "已转入",
|
|
1192
1191
|
memberTransferReceipt: "返利转入回执",
|
|
1192
|
+
memberRatesTitle: "各模型消费返利比例",
|
|
1193
|
+
memberRatesNote: "只计算好友实际消耗的充值余额;赠送余额、返利转入的余额和订阅额度不产生返利。比例在每次请求开始时确定,之后调整不影响已发生的请求。",
|
|
1194
|
+
memberModel: "模型",
|
|
1195
|
+
memberMedia: "类型",
|
|
1196
|
+
memberRate: "返利比例",
|
|
1197
|
+
memberRateSource: "比例来源",
|
|
1198
|
+
memberSourceModel: "模型默认",
|
|
1199
|
+
memberSourceCustom: "你的专属比例",
|
|
1200
|
+
memberSourceCustomModel: "你在该模型的专属比例",
|
|
1201
|
+
memberMediaText: "文本",
|
|
1202
|
+
memberMediaImage: "图片",
|
|
1203
|
+
memberMediaVideo: "视频",
|
|
1204
|
+
memberMediaAudio: "音频",
|
|
1205
|
+
memberMediaUnverified: "未核实",
|
|
1206
|
+
memberNoRates: "当前没有开启返利的模型。",
|
|
1207
|
+
memberRatesDisabled: "暂未开启返利的模型:{n} 个。",
|
|
1208
|
+
memberRatesNotApplicable: "目前没有好友按消费返利,下表的比例暂不适用。",
|
|
1209
|
+
memberRecordsTitle: "返利记录",
|
|
1210
|
+
memberRecordsNote: "每条记录对应好友的一次请求,按当时确定的比例和实际消耗的充值本金计算;负数表示退款冲回。「已处理」表示已记入返利账本,不代表已解冻;可转入金额以上方「可转入返利」为准。",
|
|
1211
|
+
memberRecordTime: "时间",
|
|
1212
|
+
memberPrincipal: "计入本金",
|
|
1213
|
+
memberAward: "返利",
|
|
1214
|
+
memberStatePending: "待处理",
|
|
1215
|
+
memberStateProcessed: "已处理",
|
|
1216
|
+
memberStateReview: "待核实",
|
|
1217
|
+
memberStateUnknown: "待确认",
|
|
1218
|
+
memberFrozenUntil: "冻结至",
|
|
1219
|
+
memberRecoverable: "待追回",
|
|
1220
|
+
memberNoRecords: "暂无返利记录。",
|
|
1221
|
+
memberLoadEarlier: "加载更早的记录",
|
|
1222
|
+
memberRecordsLimit: "这里最多显示最近 1000 条记录,更早的记录请到官网查看。",
|
|
1223
|
+
memberProgramDisabled: "邀请返利当前已关闭:新的邀请和消费不会产生返利,已获得的返利不受影响。",
|
|
1224
|
+
memberProgramNone: "你还没有邀请好友。",
|
|
1225
|
+
memberProgramLegacy: "你邀请的 {total} 位好友都按旧充值模式返利:{legacyRule}。",
|
|
1226
|
+
memberProgramConsumption: "你邀请的 {total} 位好友都按消费返利:好友用充值余额调用模型时,按下方各模型比例返利。",
|
|
1227
|
+
memberProgramMixed: "你邀请的 {total} 位好友中,{legacy} 位按旧充值模式返利({legacyRule}),{consumption} 位按消费返利(按下方各模型比例)。",
|
|
1228
|
+
memberProgramPaused: "其中 {paused} 位的消费返利已暂停。",
|
|
1229
|
+
memberProgramLegacyRule: "好友充值时按 {rate} 返利",
|
|
1230
|
+
memberProgramLegacyRuleNoRate: "按好友的充值金额返利",
|
|
1231
|
+
memberProgramNewConsumption: "新邀请的好友按消费返利。",
|
|
1232
|
+
memberProgramNewLegacy: "新邀请的好友目前按旧充值模式返利({legacyRule})。",
|
|
1233
|
+
memberProgramNewUnavailable: "新邀请好友的返利方式暂未确定。",
|
|
1234
|
+
memberProgramUnsupported: "网关暂不支持消费返利详情。",
|
|
1235
|
+
memberProgramUnavailable: "返利方式暂时无法读取,请稍后刷新。",
|
|
1193
1236
|
memberProfileTitle: "个人资料",
|
|
1194
1237
|
memberProfileNote: "查看账号资料并编辑基本设置。",
|
|
1195
1238
|
memberAccount: "账号概况",
|
|
@@ -1258,15 +1301,14 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1258
1301
|
memberRedeemReceipt: "Redeemed benefit",
|
|
1259
1302
|
memberReceiptRefresh: "Server receipt received. The refreshed account determines balance and subscription benefits.",
|
|
1260
1303
|
memberAffiliateTitle: "Affiliate",
|
|
1261
|
-
memberAffiliateNote: "
|
|
1304
|
+
memberAffiliateNote: "Invite people to sign up and earn rebates; how they are earned is explained below. After the freeze period, use Update and release matured rebates to make them available for transfer to your account balance.",
|
|
1262
1305
|
memberAvailable: "Available rebates",
|
|
1263
1306
|
memberFrozen: "Frozen rebates",
|
|
1264
1307
|
memberLifetime: "Lifetime rebates",
|
|
1265
|
-
memberRebateRate: "Rebate rate",
|
|
1266
1308
|
memberInviteCount: "Invited users",
|
|
1267
1309
|
memberInvitation: "Invitation link",
|
|
1268
|
-
memberGenerateRefresh: "Generate invitation link
|
|
1269
|
-
memberRefreshRebates: "
|
|
1310
|
+
memberGenerateRefresh: "Generate invitation link",
|
|
1311
|
+
memberRefreshRebates: "Update and release matured rebates",
|
|
1270
1312
|
memberUninitialized: "No invitation link yet. Generate it with the button above.",
|
|
1271
1313
|
memberInviteUnavailable: "The invitation link is unavailable. Check the gateway account and refresh.",
|
|
1272
1314
|
memberCopy: "Copy invitation link",
|
|
@@ -1284,6 +1326,50 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1284
1326
|
memberTransferEmpty: "No rebates are available to transfer.",
|
|
1285
1327
|
memberTransferred: "Transferred",
|
|
1286
1328
|
memberTransferReceipt: "Rebate transfer receipt",
|
|
1329
|
+
memberRatesTitle: "Consumption rebate rate by model",
|
|
1330
|
+
memberRatesNote: "Only paid balance your invitees actually spend counts; gifted balance, transferred rebates and subscription quota earn nothing. The rate is fixed when each request starts, so later changes do not affect earlier requests.",
|
|
1331
|
+
memberModel: "Model",
|
|
1332
|
+
memberMedia: "Type",
|
|
1333
|
+
memberRate: "Rebate rate",
|
|
1334
|
+
memberRateSource: "Rate source",
|
|
1335
|
+
memberSourceModel: "Model default",
|
|
1336
|
+
memberSourceCustom: "Your custom rate",
|
|
1337
|
+
memberSourceCustomModel: "Your custom rate for this model",
|
|
1338
|
+
memberMediaText: "Text",
|
|
1339
|
+
memberMediaImage: "Image",
|
|
1340
|
+
memberMediaVideo: "Video",
|
|
1341
|
+
memberMediaAudio: "Audio",
|
|
1342
|
+
memberMediaUnverified: "Unverified",
|
|
1343
|
+
memberNoRates: "No models earn rebates right now.",
|
|
1344
|
+
memberRatesDisabled: "Models not earning rebates yet: {n}.",
|
|
1345
|
+
memberRatesNotApplicable: "None of the people you invited are on consumption rebates yet, so these rates do not apply for now.",
|
|
1346
|
+
memberRecordsTitle: "Rebate records",
|
|
1347
|
+
memberRecordsNote: "Each record is one request by an invitee, calculated from the rate fixed at that time and the paid principal actually spent. Negative amounts reverse refunds. Processed means recorded in your rebate ledger, not released; the amount you can transfer is shown under Available rebates.",
|
|
1348
|
+
memberRecordTime: "Time",
|
|
1349
|
+
memberPrincipal: "Counted principal",
|
|
1350
|
+
memberAward: "Rebate",
|
|
1351
|
+
memberStatePending: "Pending",
|
|
1352
|
+
memberStateProcessed: "Processed",
|
|
1353
|
+
memberStateReview: "Under review",
|
|
1354
|
+
memberStateUnknown: "To be confirmed",
|
|
1355
|
+
memberFrozenUntil: "Frozen until",
|
|
1356
|
+
memberRecoverable: "To be recovered",
|
|
1357
|
+
memberNoRecords: "No rebate records yet.",
|
|
1358
|
+
memberLoadEarlier: "Load earlier records",
|
|
1359
|
+
memberRecordsLimit: "Up to the latest 1,000 records are shown here; see earlier records on the website.",
|
|
1360
|
+
memberProgramDisabled: "Affiliate rebates are currently off: new invitations and spending earn no rebates. Rebates you already earned are unaffected.",
|
|
1361
|
+
memberProgramNone: "You have not invited anyone yet.",
|
|
1362
|
+
memberProgramLegacy: "Everyone you invited ({total}) is on the old top-up rebate: {legacyRule}.",
|
|
1363
|
+
memberProgramConsumption: "Everyone you invited ({total}) is on consumption rebates: when they spend paid balance on models, you earn the model rates below.",
|
|
1364
|
+
memberProgramMixed: "Of the {total} people you invited: {legacy} on the old top-up rebate ({legacyRule}), {consumption} on consumption rebates (the model rates below).",
|
|
1365
|
+
memberProgramPaused: "Consumption rebates are paused for {paused} of them.",
|
|
1366
|
+
memberProgramLegacyRule: "{rate} of each top-up they make",
|
|
1367
|
+
memberProgramLegacyRuleNoRate: "a share of each top-up they make",
|
|
1368
|
+
memberProgramNewConsumption: "People you invite from now on get consumption rebates.",
|
|
1369
|
+
memberProgramNewLegacy: "People you invite from now on get the old top-up rebate ({legacyRule}).",
|
|
1370
|
+
memberProgramNewUnavailable: "The rebate type for new invitations is not settled yet.",
|
|
1371
|
+
memberProgramUnsupported: "This gateway does not provide consumption rebate details yet.",
|
|
1372
|
+
memberProgramUnavailable: "Rebate modes cannot be read right now. Refresh later.",
|
|
1287
1373
|
memberProfileTitle: "Profile",
|
|
1288
1374
|
memberProfileNote: "View account information and edit basic settings.",
|
|
1289
1375
|
memberAccount: "Account overview",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Fixed native account reads/actions; no renderer-selected URL or method. */
|
|
2
|
-
export declare const BUSINESS_READ_PATHS: readonly ["payment/config", "payment/checkout-info", "payment/plans", "payment/limits", "payment/orders/my", "payment/orders/detail", "payment/orders/refund-eligible-providers", "redeem/history", "affiliate", "profile", "actions/status"];
|
|
2
|
+
export declare const BUSINESS_READ_PATHS: readonly ["payment/config", "payment/checkout-info", "payment/plans", "payment/limits", "payment/orders/my", "payment/orders/detail", "payment/orders/refund-eligible-providers", "redeem/history", "affiliate", "affiliate/program", "affiliate/consumption-rules", "affiliate/consumption", "profile", "actions/status"];
|
|
3
3
|
export type BusinessReadPath = typeof BUSINESS_READ_PATHS[number];
|
|
4
4
|
export declare const BUSINESS_ACTIONS: readonly ["payment/create", "payment/cancel", "payment/refund", "payment/verify", "redeem/apply", "affiliate/refresh", "affiliate/transfer", "profile/update"];
|
|
5
5
|
export type BusinessActionKind = typeof BUSINESS_ACTIONS[number];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CENTER_READ_PATHS: readonly ["auth/me", "usage", "usage/dashboard/stats", "usage/dashboard/trend", "usage/dashboard/models", "subscriptions/summary", "entitlements", "usage/stats", "usage/details", "usage/errors", "usage/errors/detail", "usage/dashboard/snapshot-v2", "groups/available", "user/platform-quotas", "subscriptions", "subscriptions/progress", "model-plaza", "channel-monitor-v2/dimensions", "channel-monitor-v2/snapshot", "channel-monitor-v2/models", "channel-monitor-v2/matrix", "channel-monitor-v2/errors", "channel-monitors/status", "channel-monitors/detail", "payment/config", "payment/checkout-info", "payment/plans", "payment/limits", "payment/orders/my", "payment/orders/detail", "payment/orders/refund-eligible-providers", "redeem/history", "affiliate", "profile", "actions/status"];
|
|
1
|
+
export declare const CENTER_READ_PATHS: readonly ["auth/me", "usage", "usage/dashboard/stats", "usage/dashboard/trend", "usage/dashboard/models", "subscriptions/summary", "entitlements", "usage/stats", "usage/details", "usage/errors", "usage/errors/detail", "usage/dashboard/snapshot-v2", "groups/available", "user/platform-quotas", "subscriptions", "subscriptions/progress", "model-plaza", "channel-monitor-v2/dimensions", "channel-monitor-v2/snapshot", "channel-monitor-v2/models", "channel-monitor-v2/matrix", "channel-monitor-v2/errors", "channel-monitors/status", "channel-monitors/detail", "payment/config", "payment/checkout-info", "payment/plans", "payment/limits", "payment/orders/my", "payment/orders/detail", "payment/orders/refund-eligible-providers", "redeem/history", "affiliate", "affiliate/program", "affiliate/consumption-rules", "affiliate/consumption", "profile", "actions/status"];
|
|
2
2
|
export type CenterReadPath = typeof CENTER_READ_PATHS[number];
|
|
3
3
|
export declare function positiveCenterId(value: string): boolean;
|
|
4
4
|
/** Returns undefined for any unsupported/duplicate/invalid parameter. */
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web-seam members that VibeDev hosts add to the official DeepSeek Harness SDK this package compiles against. Every
|
|
3
|
+
* member is optional because official DSH hosts lack it: code reading one checks for it first, and a result without
|
|
4
|
+
* the facts keeps the official meaning of `url` and `statusCode`.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { WebFetchProvider } from '@deepseek-ai/dsh-web';
|
|
8
|
+
declare module '@deepseek-ai/dsh-web' {
|
|
9
|
+
interface WebFetchResult {
|
|
10
|
+
/** The original requested URL, when the provider records it. */
|
|
11
|
+
readonly requestedUrl?: string;
|
|
12
|
+
/** Page title supplied by the provider, when available. */
|
|
13
|
+
readonly title?: string;
|
|
14
|
+
/**
|
|
15
|
+
* How the content was obtained. `http`: `url` and `statusCode` were observed from the target. `extracted`: a
|
|
16
|
+
* page-extraction service returned text; the target's final URL and status are unknown, `url` repeats the
|
|
17
|
+
* requested URL and `statusCode` is 200 for usable content, and VibeDev hosts present both as unknown.
|
|
18
|
+
*/
|
|
19
|
+
readonly contentSource?: 'http' | 'extracted';
|
|
20
|
+
/** Evidence about the source response body before consumer limits; absence makes no completeness claim. */
|
|
21
|
+
readonly sourceCompleteness?: 'unknown' | 'complete';
|
|
22
|
+
/** Markup of a `text` body; `markdown` when the provider returned Markdown. */
|
|
23
|
+
readonly bodyFormat?: 'markdown';
|
|
24
|
+
}
|
|
25
|
+
interface WebRuntime {
|
|
26
|
+
/**
|
|
27
|
+
* The fetch provider registered under `id`, read from the live registry without selecting or running it.
|
|
28
|
+
* VibeDev hosts only.
|
|
29
|
+
* @param id - the provider id its registration used, such as `http`.
|
|
30
|
+
* @returns the registered provider, or `undefined` when no fetch provider has that id.
|
|
31
|
+
*/
|
|
32
|
+
getFetchProvider?(id: string): WebFetchProvider | undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/** Gateway extracted-content Fetch V1. Registration and rollout remain with the composition owner. */
|
|
2
|
+
import { WebError } from '@deepseek-ai/dsh-web';
|
|
3
|
+
import type { WebFetchProvider, WebFetchRequest, WebFetchResult } from '@deepseek-ai/dsh-web';
|
|
4
|
+
import type { GatewayCredential } from '../gateway/http.js';
|
|
5
|
+
declare const FETCH_PATH = "/v1/vibedev/web-fetch";
|
|
6
|
+
declare const SECURITY_SCOPE = "initial_url_precheck_provider_managed_fetch";
|
|
7
|
+
/** Only limits and semantics the gateway advertises, without target-HTTP guarantees. */
|
|
8
|
+
export interface GatewayFetchCapability {
|
|
9
|
+
readonly path: typeof FETCH_PATH;
|
|
10
|
+
readonly mode: 'extracted_content';
|
|
11
|
+
readonly content_format: 'markdown';
|
|
12
|
+
readonly max_url_characters: number;
|
|
13
|
+
readonly max_body_characters: number;
|
|
14
|
+
readonly character_unit: 'unicode_code_point';
|
|
15
|
+
readonly max_provider_response_bytes: number;
|
|
16
|
+
readonly timeout_ms: number;
|
|
17
|
+
readonly allowed_ports: readonly number[];
|
|
18
|
+
readonly security_scope: typeof SECURITY_SCOPE;
|
|
19
|
+
}
|
|
20
|
+
/** Safe diagnostics: gatewayStatus is never the target webpage's status. */
|
|
21
|
+
export interface GatewayFetchErrorDetails {
|
|
22
|
+
readonly gatewayStatus?: number;
|
|
23
|
+
readonly category?: string;
|
|
24
|
+
readonly retryable?: boolean;
|
|
25
|
+
readonly safeToRetry?: boolean;
|
|
26
|
+
readonly requestId?: string;
|
|
27
|
+
readonly retryAfterMs?: number;
|
|
28
|
+
readonly field?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Refusals retain safe facts through the existing tool error-text projection. */
|
|
31
|
+
export declare class GatewayFetchError extends WebError {
|
|
32
|
+
readonly details: GatewayFetchErrorDetails;
|
|
33
|
+
constructor(message: string, code: string, details?: GatewayFetchErrorDetails);
|
|
34
|
+
}
|
|
35
|
+
/** Decode only the fixed advertised Fetch V1 lane; absence is not a request to probe an endpoint. */
|
|
36
|
+
export declare function readGatewayFetchCapability(payload: unknown): GatewayFetchCapability | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* One extraction result in the official `WebFetchResult` types. The gateway observes neither the target's final URL
|
|
39
|
+
* nor its status, so `url` repeats the requested URL and `statusCode` is 200 for usable content, both marked
|
|
40
|
+
* `contentSource: 'extracted'`; VibeDev hosts present them as unknown. The `gateway` receipt is SDK-only, and its
|
|
41
|
+
* requestId is not a durable operation or idempotency key.
|
|
42
|
+
*/
|
|
43
|
+
export interface GatewayExtractionResult extends WebFetchResult {
|
|
44
|
+
readonly requestedUrl: string;
|
|
45
|
+
readonly url: string;
|
|
46
|
+
readonly statusCode: 200;
|
|
47
|
+
readonly title?: string;
|
|
48
|
+
readonly body: {
|
|
49
|
+
readonly kind: 'text';
|
|
50
|
+
readonly content: string;
|
|
51
|
+
};
|
|
52
|
+
readonly bodyFormat: 'markdown';
|
|
53
|
+
readonly sourceCompleteness: 'unknown';
|
|
54
|
+
readonly contentSource: 'extracted';
|
|
55
|
+
readonly gateway: {
|
|
56
|
+
readonly cached: boolean;
|
|
57
|
+
readonly requestId?: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** Decode extraction facts without claiming an observed target status, final address or completeness. */
|
|
61
|
+
export declare function decodeGatewayFetchResponse(payload: unknown, requestedUrl: string, maxBodyCharacters: number): GatewayExtractionResult;
|
|
62
|
+
/** Host-only auth and client budgets. No supplier key, arbitrary endpoint or hidden retry option exists. */
|
|
63
|
+
export interface GatewayFetchOptions {
|
|
64
|
+
readonly origin: string;
|
|
65
|
+
readonly userAgent: string;
|
|
66
|
+
readonly capability: GatewayFetchCapability;
|
|
67
|
+
readonly requestTimeoutMs: number;
|
|
68
|
+
readonly maxResponseBytes: number;
|
|
69
|
+
readonly maxBodyCharacters: number;
|
|
70
|
+
/** Resolve a VibeDev credential for exactly this origin; never return a supplier Key. */
|
|
71
|
+
readonly resolveCredential: () => Promise<GatewayCredential | undefined>;
|
|
72
|
+
/**
|
|
73
|
+
* The operation's deadline and cancellation, supplied by the composition owner. When present it replaces this
|
|
74
|
+
* provider's own timer, so a stage entered later in the same operation never restarts the budget.
|
|
75
|
+
*/
|
|
76
|
+
readonly signal?: AbortSignal;
|
|
77
|
+
/** Rechecked after the credential is resolved and immediately before the POST; a rejection sends nothing. */
|
|
78
|
+
readonly beforeSend?: () => Promise<void>;
|
|
79
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The error a client wait that stopped early ends with: `WEB_FETCH_TIMEOUT` when the operation's own deadline expired,
|
|
83
|
+
* `WEB_ABORTED` when the caller cancelled.
|
|
84
|
+
* @param signal - the aborted signal; its reason distinguishes the deadline from a cancellation.
|
|
85
|
+
* @returns the sanitized client error; the supplier outcome is never promised.
|
|
86
|
+
*/
|
|
87
|
+
export declare function cancellationError(signal: AbortSignal): GatewayFetchError;
|
|
88
|
+
/**
|
|
89
|
+
* Race one stage against the operation signal, so even a dependency that ignores the signal ends the client wait.
|
|
90
|
+
* @param operation - the stage to wait for; it keeps running after an abort, and its outcome is discarded.
|
|
91
|
+
* @param signal - the operation's deadline and cancellation.
|
|
92
|
+
* @returns the stage's value.
|
|
93
|
+
*/
|
|
94
|
+
export declare function waitForAbort<T>(operation: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
95
|
+
/** One explicitly selected extraction operation. It never retries, refreshes login or falls back. */
|
|
96
|
+
export declare class GatewayFetchProvider {
|
|
97
|
+
private readonly options;
|
|
98
|
+
readonly id = "vibedev-gateway";
|
|
99
|
+
private readonly origin;
|
|
100
|
+
constructor(options: GatewayFetchOptions);
|
|
101
|
+
available(): boolean;
|
|
102
|
+
fetch(request: WebFetchRequest, caller?: AbortSignal): Promise<GatewayExtractionResult>;
|
|
103
|
+
private fetchOnce;
|
|
104
|
+
}
|
|
105
|
+
/** Dependencies are supplied by the composition owner; this class is not registered by the account plugin. */
|
|
106
|
+
export interface NegotiatedGatewayFetchOptions {
|
|
107
|
+
readonly local: WebFetchProvider;
|
|
108
|
+
readonly gateway: Omit<GatewayFetchOptions, 'capability'>;
|
|
109
|
+
readonly entitlements: (signal?: AbortSignal) => Promise<unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* The operation's deadline and cancellation, supplied by the composition owner. When present it bounds the whole
|
|
112
|
+
* negotiation—capability read, gateway stage and local fallback—and no stage creates its own budget.
|
|
113
|
+
*/
|
|
114
|
+
readonly signal?: AbortSignal;
|
|
115
|
+
}
|
|
116
|
+
/** Capability absence preserves local HTTP; advertised errors never silently switch providers. */
|
|
117
|
+
export declare class NegotiatedGatewayFetchProvider {
|
|
118
|
+
private readonly options;
|
|
119
|
+
readonly id = "vibedev-negotiated-fetch";
|
|
120
|
+
constructor(options: NegotiatedGatewayFetchOptions);
|
|
121
|
+
available(): boolean;
|
|
122
|
+
fetch(request: WebFetchRequest, caller?: AbortSignal): Promise<WebFetchResult | GatewayExtractionResult>;
|
|
123
|
+
private negotiate;
|
|
124
|
+
}
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The gateway Fetch registration a profile selects as `web.fetchProvider:
|
|
3
|
+
* vibedev-gateway`: the signed-in account's advertised `web-fetch-v1`
|
|
4
|
+
* capability decides between extracted content and the local HTTP provider the
|
|
5
|
+
* host has mounted.
|
|
6
|
+
*
|
|
7
|
+
* One fetch is bound to the account and gateway it started under: it reads the
|
|
8
|
+
* VibeDev user id and the gateway origin once, re-reads both after the
|
|
9
|
+
* capability, after the credential, before the POST and after a renewal, and
|
|
10
|
+
* ends with `ACCOUNT_CHANGED` when either moved. A credential is only ever
|
|
11
|
+
* taken from the same account read that proves the user id it is checked
|
|
12
|
+
* against, so another account's token cannot be paired with this operation
|
|
13
|
+
* even while the account changes hands around those reads. It also spends one
|
|
14
|
+
* total client deadline across the identity read, the capability read, the
|
|
15
|
+
* credential, the POST, a renewal and the local fallback, so no stage can
|
|
16
|
+
* restart the budget.
|
|
17
|
+
*
|
|
18
|
+
* The host still owns selection. A profile pinned to `http` never reaches this
|
|
19
|
+
* provider; a profile pinned to `vibedev-gateway` gets the host's own mounted
|
|
20
|
+
* fetch provider when the account definitely advertises no such capability —
|
|
21
|
+
* never a copy built from defaults, and a host that mounts none fails with a
|
|
22
|
+
* named error instead of a silent local fetch. A failed or refused capability
|
|
23
|
+
* read is an error: it is never read as absence, and no supplier, budget or
|
|
24
|
+
* policy refusal falls back.
|
|
25
|
+
* @module dsh-vibedev/fetch/wiring
|
|
26
|
+
*/
|
|
27
|
+
import type { WebFetchProvider, WebFetchRequest, WebFetchResult } from '@deepseek-ai/dsh-web';
|
|
28
|
+
import type { AccountIdentity } from '../account/index.js';
|
|
29
|
+
import type { GatewayCredential } from '../gateway/http.js';
|
|
30
|
+
/** Stable id the provider registers under; a profile selects it as `web.fetchProvider`. */
|
|
31
|
+
export declare const GATEWAY_FETCH_PROVIDER_ID = "vibedev-gateway";
|
|
32
|
+
/** One operation's capability request, handed to the account's entitlement reader. */
|
|
33
|
+
export interface GatewayFetchCapabilityRequest {
|
|
34
|
+
/** Bounds this read, including a re-read after a 401. */
|
|
35
|
+
readonly signal?: AbortSignal;
|
|
36
|
+
/** Whether the operation's account is still current, checked by the reader before each send. */
|
|
37
|
+
readonly isCurrentAccount?: () => Promise<boolean>;
|
|
38
|
+
/** The operation-bound credential: read together with the account it is verified against, and re-read the same way. */
|
|
39
|
+
readonly resolveCredential: () => Promise<GatewayCredential | undefined>;
|
|
40
|
+
}
|
|
41
|
+
/** What the registration needs from the plugin. */
|
|
42
|
+
export interface GatewayFetchWiringOptions {
|
|
43
|
+
/** Read the gateway origin in effect; it heads the account-scoped entitlement key, and a change ends an operation. */
|
|
44
|
+
readonly origin: () => string;
|
|
45
|
+
/** `User-Agent` sent to the gateway. */
|
|
46
|
+
readonly userAgent: string;
|
|
47
|
+
/** Who is signed in now; one read supplies both the credential and the `userId` it belongs to. */
|
|
48
|
+
readonly identity: () => Promise<AccountIdentity>;
|
|
49
|
+
/**
|
|
50
|
+
* `GatewayHttp.entitlements`: one account-scoped capability snapshot per scope. The request carries this operation's
|
|
51
|
+
* bound credential and account guard, so the reader cannot send, or re-read after a 401, another account's token.
|
|
52
|
+
*/
|
|
53
|
+
readonly entitlements: (scope: string, request: GatewayFetchCapabilityRequest) => Promise<unknown>;
|
|
54
|
+
/** Renew a credential the gateway itself rejected, so its owner can refresh it. */
|
|
55
|
+
readonly rejectCredential: (credential: GatewayCredential) => Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Read the local provider the host has mounted right now; asked only when the account advertises no capability. It
|
|
58
|
+
* answers the live registration, so a host that reloads its `http` provider with other limits is followed without
|
|
59
|
+
* the plugin holding a copy. Omitted together with `local` when the host cannot hand its provider to plugins (an
|
|
60
|
+
* official DSH host has no `getFetchProvider`): the fallback then fails with `WEB_FETCH_LOCAL_PROVIDER_UNREACHABLE`.
|
|
61
|
+
*/
|
|
62
|
+
readonly resolveLocal?: () => WebFetchProvider | undefined;
|
|
63
|
+
/** An explicitly supplied local provider (tests and direct consumers); it wins over {@link GatewayFetchWiringOptions.resolveLocal}. */
|
|
64
|
+
readonly local?: WebFetchProvider;
|
|
65
|
+
/** Total client deadline for one fetch; the documented 40 s when omitted. */
|
|
66
|
+
readonly timeoutMs?: number;
|
|
67
|
+
/**
|
|
68
|
+
* The registration owner's lifetime. Aborting it — the plugin fiber unloading, a gateway or configuration reload —
|
|
69
|
+
* ends every operation this registration is running without a resend; a replacement registration gets its own.
|
|
70
|
+
*/
|
|
71
|
+
readonly owner?: AbortSignal;
|
|
72
|
+
}
|
|
73
|
+
/** `vibedev-gateway`: gateway extraction when advertised, the host's local fetch only when definitely absent. */
|
|
74
|
+
export declare class GatewayFetchWiring implements WebFetchProvider {
|
|
75
|
+
private readonly options;
|
|
76
|
+
readonly id = "vibedev-gateway";
|
|
77
|
+
/**
|
|
78
|
+
* @param options - account, credential, gateway and local-provider dependencies.
|
|
79
|
+
*/
|
|
80
|
+
constructor(options: GatewayFetchWiringOptions);
|
|
81
|
+
/** Always usable: a missing account or capability fails with a named error, never as an unselected provider. */
|
|
82
|
+
available(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Fetch through the advertised gateway lane, or through the local provider
|
|
85
|
+
* when the account advertises no `web-fetch-v1`.
|
|
86
|
+
* @param request - the URL to retrieve.
|
|
87
|
+
* @param caller - cancels the client wait; the supplier outcome is never promised.
|
|
88
|
+
* @returns the gateway extraction or the local HTTP result.
|
|
89
|
+
*/
|
|
90
|
+
fetch(request: WebFetchRequest, caller?: AbortSignal): Promise<WebFetchResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Run one account-bound operation under the fetch's total signal.
|
|
93
|
+
* @param request - the URL to retrieve.
|
|
94
|
+
* @param signal - the operation's deadline and cancellation.
|
|
95
|
+
* @returns the extraction or the local result.
|
|
96
|
+
*/
|
|
97
|
+
private operate;
|
|
98
|
+
/**
|
|
99
|
+
* The provider that takes over a fetch the gateway does not cover: the host's mounted local provider at the moment
|
|
100
|
+
* the capability is found absent (or the explicitly supplied one), never a copy built from defaults.
|
|
101
|
+
* @returns the provider the negotiation delegates to, resolving the host's current registration when it is called.
|
|
102
|
+
*/
|
|
103
|
+
private fallback;
|
|
104
|
+
/** Read the account and gateway this fetch runs under; a signed-out or unidentified account has its own error. */
|
|
105
|
+
private startedIdentity;
|
|
106
|
+
/**
|
|
107
|
+
* One identity read supplies both the credential and the user id, so the two cannot disagree; it is accepted only
|
|
108
|
+
* for the account and gateway this fetch started under.
|
|
109
|
+
* @param started - the account and gateway the operation was bound to.
|
|
110
|
+
* @returns the verified credential and the user it belongs to.
|
|
111
|
+
*/
|
|
112
|
+
private currentIdentity;
|
|
113
|
+
/**
|
|
114
|
+
* End the operation unless the same account is still signed in on the same gateway.
|
|
115
|
+
* @param started - the account and gateway the operation was bound to.
|
|
116
|
+
*/
|
|
117
|
+
private sameIdentity;
|
|
118
|
+
/**
|
|
119
|
+
* The credential for one request of this operation, taken from the identity that is verified against it.
|
|
120
|
+
* @param started - the account and gateway the operation was bound to.
|
|
121
|
+
* @returns the credential of the verified identity.
|
|
122
|
+
*/
|
|
123
|
+
private verifiedCredential;
|
|
124
|
+
}
|
package/lib/gateway/http.d.ts
CHANGED
|
@@ -39,8 +39,14 @@ export interface GatewayHttpOptions {
|
|
|
39
39
|
}
|
|
40
40
|
/** One request. */
|
|
41
41
|
export interface GatewayRequest {
|
|
42
|
-
/** Rechecked after credential resolution and before
|
|
42
|
+
/** Rechecked after credential resolution, before every send and before a rejected credential is renewed. */
|
|
43
43
|
readonly isCurrentAccount?: () => Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve this request's credential instead of the client's default plane. The gateway Fetch registration uses it
|
|
46
|
+
* to hand out only a credential read together with the account it was verified against: every first read and every
|
|
47
|
+
* re-read after a 401 goes through it. Omitted, the client's own resolver serves every request as before.
|
|
48
|
+
*/
|
|
49
|
+
readonly resolveCredential?: () => Promise<GatewayCredential | undefined>;
|
|
44
50
|
readonly method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
45
51
|
/** JSON body; serialized with `content-type: application/json`. */
|
|
46
52
|
readonly json?: unknown;
|
|
@@ -77,9 +83,15 @@ export declare function abortError(signal?: AbortSignal): MediaError;
|
|
|
77
83
|
export declare class GatewayHttp {
|
|
78
84
|
private readonly options;
|
|
79
85
|
readonly origin: string;
|
|
86
|
+
/** One capability snapshot; `bound` marks a read whose own credential was verified against the scope. */
|
|
80
87
|
private readonly snapshots;
|
|
81
88
|
invalidateAccountSnapshots(): void;
|
|
82
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* One Host-only capability snapshot shared by quotes and the account bridge. A request that supplies its own
|
|
91
|
+
* operation-bound credential (`resolveCredential`) is served only a snapshot a scoped read created: an ordinary
|
|
92
|
+
* read's answer was verified by its caller's guard alone and can belong to another account after an account
|
|
93
|
+
* change, so it must not decide a bounded operation's capability.
|
|
94
|
+
*/
|
|
83
95
|
entitlements(scope: string, request?: GatewayRequest, fresh?: boolean): Promise<unknown>;
|
|
84
96
|
/**
|
|
85
97
|
* @param options - origin, credential plane, user agent and test seams.
|
|
@@ -104,6 +116,12 @@ export declare class GatewayHttp {
|
|
|
104
116
|
* @returns the parsed body.
|
|
105
117
|
*/
|
|
106
118
|
json<T = unknown>(path: string, request?: GatewayRequest): Promise<T>;
|
|
119
|
+
/**
|
|
120
|
+
* Read the credential one request carries, through the request's resolver when it has one.
|
|
121
|
+
* @param resolve - the request's scoped resolver, else the client's default credential plane.
|
|
122
|
+
* @returns the credential.
|
|
123
|
+
* @throws {@link MediaError} `NOT_SIGNED_IN` when no credential is available.
|
|
124
|
+
*/
|
|
107
125
|
private credential;
|
|
108
126
|
private attempt;
|
|
109
127
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -40,6 +40,9 @@ export { LATENCY_ROUTE } from './account/latency.js';
|
|
|
40
40
|
export type { LatencyErrorKind, LatencyResult } from './account/latency.js';
|
|
41
41
|
export { FEEDBACK_ATTACHMENT_ROUTE, FEEDBACK_ROUTE } from './feedback/index.js';
|
|
42
42
|
export { GATEWAY_SEARCH_PROVIDER_ID as SEARCH_PROVIDER_ID } from './search/provider.js';
|
|
43
|
+
export { GATEWAY_FETCH_PROVIDER_ID as FETCH_PROVIDER_ID } from './fetch/wiring.js';
|
|
44
|
+
export { GatewayFetchProvider, NegotiatedGatewayFetchProvider, readGatewayFetchCapability } from './fetch/provider.js';
|
|
45
|
+
export type { GatewayFetchCapability, GatewayFetchOptions, GatewayExtractionResult, NegotiatedGatewayFetchOptions } from './fetch/provider.js';
|
|
43
46
|
export { INSUFFICIENT_BALANCE_CODE, SIGN_IN_REQUIRED_CODE, VIBEDEV_ROUTE, VIBEDEV_RELAY_ROUTE } from './llm/index.js';
|
|
44
47
|
/** The package version, sent in the `User-Agent` the gateway attributes plugin traffic by. */
|
|
45
48
|
export declare const version: string;
|
|
@@ -84,6 +87,11 @@ export interface Config {
|
|
|
84
87
|
client: string;
|
|
85
88
|
/** The VibeDev account is the app's main account: its row leads the sidebar foot and Settings (the VibeDev app). */
|
|
86
89
|
primary: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Register the gateway's extracted-content Fetch as the provider `vibedev-gateway`. Registration does not select
|
|
92
|
+
* it: the host keeps its own fetch unless a profile sets `web.fetchProvider: vibedev-gateway`.
|
|
93
|
+
*/
|
|
94
|
+
gatewayFetch: boolean;
|
|
87
95
|
/** Environment variable holding a development key, used only while nobody is signed in. */
|
|
88
96
|
apiKeyEnv: string;
|
|
89
97
|
/** Where tasks and the plugin's own sign-in are kept; empty for `<harness home>/dsh-media`. */
|
|
@@ -110,6 +118,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
110
118
|
gatewayOrigin: Schema<string, string, "defined">;
|
|
111
119
|
client: Schema<string, string, "defined">;
|
|
112
120
|
primary: Schema<boolean, boolean, "defined">;
|
|
121
|
+
gatewayFetch: Schema<boolean, boolean, "defined">;
|
|
113
122
|
apiKeyEnv: Schema<string, string, "defined">;
|
|
114
123
|
stateDir: Schema<string, string, "defined">;
|
|
115
124
|
}>>, Schemastery.ObjectT<NoInfer<{
|
|
@@ -133,6 +142,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
133
142
|
gatewayOrigin: Schema<string, string, "defined">;
|
|
134
143
|
client: Schema<string, string, "defined">;
|
|
135
144
|
primary: Schema<boolean, boolean, "defined">;
|
|
145
|
+
gatewayFetch: Schema<boolean, boolean, "defined">;
|
|
136
146
|
apiKeyEnv: Schema<string, string, "defined">;
|
|
137
147
|
stateDir: Schema<string, string, "defined">;
|
|
138
148
|
}>>, "plain">;
|