dsh-plugin-subscription-oauth 0.17.0 → 0.17.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/lib/client/FastModeButton.d.ts +0 -1
- package/lib/client/FastModeButton.js +48 -11
- package/lib/client.js +32 -9
- package/lib/client.js.map +1 -1
- package/lib/protocol.d.ts +9 -0
- package/lib/providers/ark-provider.js +10 -2
- package/lib/providers/ark.d.ts +8 -0
- package/lib/providers/ark.js +10 -0
- package/lib/providers/catalog.d.ts +2 -1
- package/lib/providers/catalog.js +2 -1
- package/lib/providers/glm-provider.js +10 -2
- package/lib/providers/glm.d.ts +8 -0
- package/lib/providers/glm.js +10 -0
- package/lib/providers/grok.d.ts +8 -0
- package/lib/providers/grok.js +18 -1
- package/lib/providers/kimi-provider.js +8 -1
- package/lib/providers/kimi.d.ts +18 -0
- package/lib/providers/kimi.js +54 -2
- package/lib/providers/workbuddy.d.ts +10 -8
- package/lib/providers/workbuddy.js +46 -33
- package/package.json +1 -1
|
@@ -23,7 +23,6 @@ import type { SessionStandardProps } from '@deepseek-ai/dsh-client-ui-slots';
|
|
|
23
23
|
import type { SubscriptionsCall } from './subscriptions-rpc.js';
|
|
24
24
|
/** Injected props the button is registered with. */
|
|
25
25
|
export interface FastModeButtonInjected {
|
|
26
|
-
/** The plugin's own RPC caller, for the one `model-variants` read. */
|
|
27
26
|
call: SubscriptionsCall;
|
|
28
27
|
/** Whether the provider is one this plugin serves. */
|
|
29
28
|
isOwnProvider: (provider: string) => boolean;
|
|
@@ -22,6 +22,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
22
22
|
import { useEffect, useState } from 'react';
|
|
23
23
|
import { providerOf } from './UsageChip.js';
|
|
24
24
|
import { fastModeCss } from './styles.js';
|
|
25
|
+
/**
|
|
26
|
+
* How many times a *loading* route is re-asked, and how long between attempts.
|
|
27
|
+
*
|
|
28
|
+
* The route answers `pending` while it has not read its listing, which is the only case
|
|
29
|
+
* worth asking again: a route that has read its listing and reports no variant means the
|
|
30
|
+
* model truly has none, and the button stays absent without further reads.
|
|
31
|
+
*/
|
|
32
|
+
const VARIANT_READ_ATTEMPTS = 6;
|
|
33
|
+
const VARIANT_READ_INTERVAL_MS = 1_000;
|
|
25
34
|
/**
|
|
26
35
|
* The quick-mode control, for the composer's row of standard controls.
|
|
27
36
|
*
|
|
@@ -43,17 +52,45 @@ export function FastModeButton({ call, isOwnProvider, modelDirectory, useProject
|
|
|
43
52
|
return;
|
|
44
53
|
}
|
|
45
54
|
let live = true;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
let timer;
|
|
56
|
+
// A variant is derived from the route's model listing, which is read asynchronously and
|
|
57
|
+
// may still be in flight when the composer mounts (a cold start, or the first run after
|
|
58
|
+
// an update). The route says so with `pending`, and only then is it worth asking again:
|
|
59
|
+
// a route that has read its listing and names no variant has answered for good.
|
|
60
|
+
let attempts = 0;
|
|
61
|
+
const ask = () => {
|
|
62
|
+
attempts += 1;
|
|
63
|
+
void call('model-variants', { provider, id: model })
|
|
64
|
+
.then((result) => {
|
|
65
|
+
if (!live)
|
|
66
|
+
return;
|
|
67
|
+
if (result?.fast !== undefined) {
|
|
68
|
+
// The rung is the provider's own word (xAI `lightspeed`, Kimi `highspeed`), so
|
|
69
|
+
// the picker reads a name the model's own docs use, not a generic "Fast".
|
|
70
|
+
setPair({ rung: result.fastRung ?? 'fast' });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
setPair(undefined);
|
|
74
|
+
// Still reading its listing: ask again, up to the cap, then accept the answer.
|
|
75
|
+
if (result?.pending === true && attempts < VARIANT_READ_ATTEMPTS) {
|
|
76
|
+
timer = setTimeout(ask, VARIANT_READ_INTERVAL_MS);
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
.catch(() => {
|
|
80
|
+
// A read that failed outright is worth one more try, on the same budget.
|
|
81
|
+
if (!live)
|
|
82
|
+
return;
|
|
83
|
+
setPair(undefined);
|
|
84
|
+
if (attempts < VARIANT_READ_ATTEMPTS)
|
|
85
|
+
timer = setTimeout(ask, VARIANT_READ_INTERVAL_MS);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
ask();
|
|
89
|
+
return () => {
|
|
90
|
+
live = false;
|
|
91
|
+
if (timer !== undefined)
|
|
92
|
+
clearTimeout(timer);
|
|
93
|
+
};
|
|
57
94
|
}, [provider, model, isOwnProvider, call]);
|
|
58
95
|
// A switch that landed clears the reason, so the marker follows the truth on screen.
|
|
59
96
|
useEffect(() => { setFailure(undefined); }, [model]);
|
package/lib/client.js
CHANGED
|
@@ -3061,6 +3061,15 @@ function UsageChip({ call, t, isOwnProvider, accountBalance, ccSwitchBalance, us
|
|
|
3061
3061
|
//#endregion
|
|
3062
3062
|
//#region src/client/FastModeButton.tsx
|
|
3063
3063
|
/**
|
|
3064
|
+
* How many times a *loading* route is re-asked, and how long between attempts.
|
|
3065
|
+
*
|
|
3066
|
+
* The route answers `pending` while it has not read its listing, which is the only case
|
|
3067
|
+
* worth asking again: a route that has read its listing and reports no variant means the
|
|
3068
|
+
* model truly has none, and the button stays absent without further reads.
|
|
3069
|
+
*/
|
|
3070
|
+
const VARIANT_READ_ATTEMPTS = 6;
|
|
3071
|
+
const VARIANT_READ_INTERVAL_MS = 1e3;
|
|
3072
|
+
/**
|
|
3064
3073
|
* The quick-mode control, for the composer's row of standard controls.
|
|
3065
3074
|
*
|
|
3066
3075
|
* @param props - injected RPC caller, directory, and the session standard kit.
|
|
@@ -3079,17 +3088,31 @@ function FastModeButton({ call, isOwnProvider, modelDirectory, useProjection })
|
|
|
3079
3088
|
return;
|
|
3080
3089
|
}
|
|
3081
3090
|
let live = true;
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
+
let timer;
|
|
3092
|
+
let attempts = 0;
|
|
3093
|
+
const ask = () => {
|
|
3094
|
+
attempts += 1;
|
|
3095
|
+
call("model-variants", {
|
|
3096
|
+
provider,
|
|
3097
|
+
id: model
|
|
3098
|
+
}).then((result) => {
|
|
3099
|
+
if (!live) return;
|
|
3100
|
+
if (result?.fast !== void 0) {
|
|
3101
|
+
setPair({ rung: result.fastRung ?? "fast" });
|
|
3102
|
+
return;
|
|
3103
|
+
}
|
|
3104
|
+
setPair(void 0);
|
|
3105
|
+
if (result?.pending === true && attempts < VARIANT_READ_ATTEMPTS) timer = setTimeout(ask, VARIANT_READ_INTERVAL_MS);
|
|
3106
|
+
}).catch(() => {
|
|
3107
|
+
if (!live) return;
|
|
3108
|
+
setPair(void 0);
|
|
3109
|
+
if (attempts < VARIANT_READ_ATTEMPTS) timer = setTimeout(ask, VARIANT_READ_INTERVAL_MS);
|
|
3110
|
+
});
|
|
3111
|
+
};
|
|
3112
|
+
ask();
|
|
3091
3113
|
return () => {
|
|
3092
3114
|
live = false;
|
|
3115
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
3093
3116
|
};
|
|
3094
3117
|
}, [
|
|
3095
3118
|
provider,
|