dsh-subscriptions 0.2.0 → 0.2.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 +212 -180
- package/lib/auth/claude-code-creds.js +31 -9
- package/lib/auth/device-flow.js +16 -9
- package/lib/auth/oauth-flow.js +13 -10
- package/lib/auth/rpc.js +74 -23
- package/lib/auth/store.js +80 -31
- package/lib/client/CursorCard.d.ts +1 -1
- package/lib/client/CursorCard.js +50 -16
- package/lib/client/ExternalUsageCards.d.ts +1 -1
- package/lib/client/ExternalUsageCards.js +37 -16
- package/lib/client/ImageGallery.d.ts +2 -2
- package/lib/client/ImageGallery.js +92 -33
- package/lib/client/ImageGenerateToolview.js +50 -14
- package/lib/client/OllamaCard.d.ts +1 -1
- package/lib/client/OllamaCard.js +26 -8
- package/lib/client/OllamaSettingsManager.js +113 -30
- package/lib/client/ProviderAccountManager.d.ts +1 -1
- package/lib/client/ProviderAccountManager.js +164 -49
- package/lib/client/ProviderModelEditor.js +107 -26
- package/lib/client/SpeedSelect.d.ts +62 -14
- package/lib/client/SpeedSelect.js +257 -46
- package/lib/client/SubscriptionUsageBadge.d.ts +4 -10
- package/lib/client/SubscriptionUsageBadge.js +300 -112
- package/lib/client/SubscriptionsSection.js +258 -85
- package/lib/client/UsageBadgeDisplaySetting.js +35 -12
- package/lib/client/UsageMeter.d.ts +1 -1
- package/lib/client/UsageMeter.js +62 -24
- package/lib/client/VideoGenerateToolview.js +69 -17
- package/lib/client/account-preferences.d.ts +8 -0
- package/lib/client/account-preferences.js +20 -5
- package/lib/client/host-contract.d.ts +11 -2
- package/lib/client/host-contract.js +20 -3
- package/lib/client/index.d.ts +5 -5
- package/lib/client/index.js +34 -12
- package/lib/client/locales.d.ts +10 -0
- package/lib/client/locales.js +61 -51
- package/lib/client/ollama-draft.js +21 -12
- package/lib/client/reset-action.js +6 -4
- package/lib/client/reset-credits-view.d.ts +1 -1
- package/lib/client/reset-credits-view.js +66 -17
- package/lib/client/subscription-card-styles.js +94 -24
- package/lib/client/usage-color-preferences.js +4 -2
- package/lib/client/usage-pace.js +30 -12
- package/lib/client.js +287 -47
- package/lib/client.js.map +1 -1
- package/lib/http.js +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +118 -64
- package/lib/model-defaults.js +4 -2
- package/lib/provider-settings.d.ts +12 -0
- package/lib/provider-settings.js +58 -16
- package/lib/providers/account-preferences.js +51 -22
- package/lib/providers/accounts.js +15 -9
- package/lib/providers/antigravity-oauth-client.js +2 -2
- package/lib/providers/antigravity.js +141 -68
- package/lib/providers/catalog-store.js +120 -41
- package/lib/providers/claude-cli-version.js +3 -3
- package/lib/providers/claude.d.ts +9 -2
- package/lib/providers/claude.js +153 -90
- package/lib/providers/codex-client-version.js +3 -3
- package/lib/providers/codex-search.js +40 -13
- package/lib/providers/codex.js +196 -112
- package/lib/providers/common.js +71 -39
- package/lib/providers/copilot.js +143 -82
- package/lib/providers/cursor-adapter.js +42 -18
- package/lib/providers/cursor-auth.d.ts +1 -1
- package/lib/providers/cursor-auth.js +69 -24
- package/lib/providers/cursor-model-settings.js +14 -5
- package/lib/providers/cursor-usage.js +27 -13
- package/lib/providers/external-usage-controller.js +14 -5
- package/lib/providers/external-usage.js +59 -23
- package/lib/providers/grok.js +152 -89
- package/lib/providers/image-pool.js +29 -11
- package/lib/providers/minimax-usage.js +31 -11
- package/lib/providers/npm-cli-version.js +10 -3
- package/lib/providers/ollama-settings.js +24 -8
- package/lib/providers/ollama-web.js +29 -11
- package/lib/providers/ollama.js +129 -66
- package/lib/providers/pool-family.js +11 -3
- package/lib/providers/pool-health.js +28 -8
- package/lib/providers/pool-usage.js +16 -9
- package/lib/providers/pool.d.ts +8 -0
- package/lib/providers/pool.js +81 -42
- package/lib/providers/rate-limit.js +8 -2
- package/lib/providers/replay.js +40 -17
- package/lib/providers/reset-redemption.js +18 -6
- package/lib/tools/image-generate.js +123 -65
- package/lib/tools/registration.js +5 -2
- package/lib/tools/video-generate.js +51 -31
- package/lib/tools/x-search.js +50 -22
- package/lib/translate/anthropic.js +85 -37
- package/lib/translate/antigravity-schema.js +71 -28
- package/lib/translate/antigravity-thinking.js +22 -9
- package/lib/translate/antigravity.js +141 -50
- package/lib/translate/chat-completions.js +67 -23
- package/lib/translate/resolved.js +55 -21
- package/lib/translate/responses.js +69 -29
- package/lib/translate/sse.js +4 -1
- package/package.json +26 -4
|
@@ -15,7 +15,9 @@ export class CodexWebSearchProvider {
|
|
|
15
15
|
constructor(options) {
|
|
16
16
|
this.options = options;
|
|
17
17
|
}
|
|
18
|
-
available() {
|
|
18
|
+
available() {
|
|
19
|
+
return this.options.enabled?.() ?? true;
|
|
20
|
+
}
|
|
19
21
|
async search(request, signal) {
|
|
20
22
|
throwIfAborted(signal);
|
|
21
23
|
let session;
|
|
@@ -50,10 +52,10 @@ export class CodexWebSearchProvider {
|
|
|
50
52
|
response = await fetchFn(CODEX_SEARCH_URL, {
|
|
51
53
|
method: 'POST',
|
|
52
54
|
headers: {
|
|
53
|
-
|
|
55
|
+
authorization: `Bearer ${session.accessToken}`,
|
|
54
56
|
'chatgpt-account-id': session.accountId,
|
|
55
57
|
'content-type': 'application/json',
|
|
56
|
-
|
|
58
|
+
originator: 'codex_cli_rs',
|
|
57
59
|
...attributionHeaders(),
|
|
58
60
|
},
|
|
59
61
|
body: JSON.stringify(body),
|
|
@@ -73,7 +75,9 @@ export class CodexWebSearchProvider {
|
|
|
73
75
|
await discard(response);
|
|
74
76
|
throw new WebError('Codex Web Search was rate-limited; retry later', 'CODEX_SEARCH_RATE_LIMIT');
|
|
75
77
|
}
|
|
76
|
-
if (response.status >= 500 &&
|
|
78
|
+
if (response.status >= 500 &&
|
|
79
|
+
response.status <= 599 &&
|
|
80
|
+
attempt < MAX_ATTEMPTS) {
|
|
77
81
|
await discard(response);
|
|
78
82
|
await abortableDelay(retryBaseMs * 2 ** (attempt - 1), signal);
|
|
79
83
|
continue;
|
|
@@ -106,14 +110,20 @@ export function normalizeCodexSearchResponse(value) {
|
|
|
106
110
|
for (const candidate of value.results) {
|
|
107
111
|
if (!record(candidate))
|
|
108
112
|
continue;
|
|
109
|
-
const rawUrl = safeString(candidate.url, 8192) ??
|
|
113
|
+
const rawUrl = safeString(candidate.url, 8192) ??
|
|
114
|
+
safeString(candidate.source_url, 8192);
|
|
110
115
|
const url = rawUrl === undefined ? undefined : httpUrl(rawUrl);
|
|
111
116
|
if (url === undefined || seen.has(url))
|
|
112
117
|
continue;
|
|
113
118
|
seen.add(url);
|
|
114
|
-
const title = safeString(candidate.title, 1000) ??
|
|
119
|
+
const title = safeString(candidate.title, 1000) ??
|
|
120
|
+
safeString(candidate.source_title, 1000);
|
|
115
121
|
const snippet = safeString(candidate.snippet, 4000) ?? safeString(candidate.text, 4000);
|
|
116
|
-
sources.push({
|
|
122
|
+
sources.push({
|
|
123
|
+
url,
|
|
124
|
+
...(title ? { title } : {}),
|
|
125
|
+
...(snippet ? { snippet } : {}),
|
|
126
|
+
});
|
|
117
127
|
}
|
|
118
128
|
return { content: value.output, sources, truncated: false };
|
|
119
129
|
}
|
|
@@ -124,6 +134,8 @@ function safeString(value, max) {
|
|
|
124
134
|
if (typeof value !== 'string')
|
|
125
135
|
return undefined;
|
|
126
136
|
const text = value.trim();
|
|
137
|
+
// The class is the C0 control range being rejected, not an accidental escape.
|
|
138
|
+
// eslint-disable-next-line no-control-regex -- reject NUL through unit separator in provider text
|
|
127
139
|
if (!text || text.length > max || /[\u0000-\u001f]/.test(text))
|
|
128
140
|
return undefined;
|
|
129
141
|
return text;
|
|
@@ -131,7 +143,9 @@ function safeString(value, max) {
|
|
|
131
143
|
function httpUrl(value) {
|
|
132
144
|
try {
|
|
133
145
|
const parsed = new URL(value);
|
|
134
|
-
return parsed.protocol === 'http:' || parsed.protocol === 'https:'
|
|
146
|
+
return parsed.protocol === 'http:' || parsed.protocol === 'https:'
|
|
147
|
+
? parsed.href
|
|
148
|
+
: undefined;
|
|
135
149
|
}
|
|
136
150
|
catch {
|
|
137
151
|
return undefined;
|
|
@@ -141,7 +155,9 @@ async function discard(response) {
|
|
|
141
155
|
try {
|
|
142
156
|
await response.body?.cancel();
|
|
143
157
|
}
|
|
144
|
-
catch {
|
|
158
|
+
catch {
|
|
159
|
+
/* best effort */
|
|
160
|
+
}
|
|
145
161
|
}
|
|
146
162
|
function throwIfAborted(signal) {
|
|
147
163
|
if (signal?.aborted)
|
|
@@ -156,9 +172,18 @@ function abortableDelay(ms, signal) {
|
|
|
156
172
|
return Promise.resolve();
|
|
157
173
|
}
|
|
158
174
|
return new Promise((resolve, reject) => {
|
|
159
|
-
const timer = setTimeout(() => {
|
|
160
|
-
|
|
161
|
-
|
|
175
|
+
const timer = setTimeout(() => {
|
|
176
|
+
cleanup();
|
|
177
|
+
resolve();
|
|
178
|
+
}, ms);
|
|
179
|
+
const onAbort = () => {
|
|
180
|
+
cleanup();
|
|
181
|
+
reject(cancelled(signal?.reason));
|
|
182
|
+
};
|
|
183
|
+
const cleanup = () => {
|
|
184
|
+
clearTimeout(timer);
|
|
185
|
+
signal?.removeEventListener('abort', onAbort);
|
|
186
|
+
};
|
|
162
187
|
signal?.addEventListener('abort', onAbort, { once: true });
|
|
163
188
|
});
|
|
164
189
|
}
|
|
@@ -196,6 +221,8 @@ async function boundedText(response, signal) {
|
|
|
196
221
|
try {
|
|
197
222
|
reader.releaseLock();
|
|
198
223
|
}
|
|
199
|
-
catch {
|
|
224
|
+
catch {
|
|
225
|
+
/* best effort */
|
|
226
|
+
}
|
|
200
227
|
}
|
|
201
228
|
}
|