dsh-plugin-subscription-oauth 0.12.0 → 0.12.3

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/protocol.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  /** Prefix of every RPC method this plugin serves. */
13
13
  export declare const RPC_PREFIX = "subscription-oauth.";
14
14
  /** Endpoints the Settings page may call. */
15
- export declare const RPC_ENDPOINTS: readonly ["status", "login", "cancel", "logout", "setDefault", "refresh", "discover", "setModelVisible", "setModelOrder", "addModel", "removeModel", "usage", "reload", "setAutoOn", "deepseek-balance", "ccswitch-balance", "model-variants"];
15
+ export declare const RPC_ENDPOINTS: readonly ["status", "login", "cancel", "logout", "setDefault", "refresh", "discover", "setModelVisible", "setModelOrder", "addModel", "removeModel", "usage", "reload", "auto-state", "setAutoOn", "deepseek-balance", "ccswitch-balance", "model-variants"];
16
16
  /** One endpoint name. */
17
17
  export type RpcEndpoint = typeof RPC_ENDPOINTS[number];
18
18
  /** Client → host envelope. */
@@ -315,6 +315,10 @@ export interface RpcMap {
315
315
  payload: undefined;
316
316
  value: SubscriptionStatus;
317
317
  };
318
+ 'auto-state': {
319
+ payload: undefined;
320
+ value: AutoStateResult;
321
+ };
318
322
  setAutoOn: {
319
323
  payload: SetAutoOnRequest;
320
324
  value: AutoStateResult;
package/lib/protocol.js CHANGED
@@ -26,6 +26,7 @@ export const RPC_ENDPOINTS = [
26
26
  'removeModel',
27
27
  'usage',
28
28
  'reload',
29
+ 'auto-state',
29
30
  'setAutoOn',
30
31
  'deepseek-balance',
31
32
  'ccswitch-balance',
@@ -303,12 +303,13 @@ export class MimoAdapter extends LlmAdapter {
303
303
  }
304
304
  yield { type: 'text-delta', index: 0, text: delta };
305
305
  }
306
- if (chunk.usage !== undefined) {
307
- const input = chunk.usage.prompt_tokens ?? 0;
308
- const output = chunk.usage.completion_tokens ?? 0;
306
+ const usage = chunk.usage;
307
+ if (usage !== undefined && usage !== null) {
308
+ const input = usage.prompt_tokens ?? 0;
309
+ const output = usage.completion_tokens ?? 0;
309
310
  yield {
310
311
  type: 'usage',
311
- usage: { inputTokens: input, outputTokens: output, totalTokens: chunk.usage.total_tokens ?? input + output },
312
+ usage: { inputTokens: input, outputTokens: output, totalTokens: usage.total_tokens ?? input + output },
312
313
  };
313
314
  }
314
315
  }
@@ -115,7 +115,14 @@ export function createWorkBuddyProvider(options) {
115
115
  }
116
116
  try {
117
117
  const renewed = await refreshWorkBuddyToken(token, fetchFn);
118
- return { accessToken: renewed.accessToken, expiresAt: renewed.expiresAt };
118
+ // WorkBuddy rotates the refresh token: keep the new one so the next restart can
119
+ // still refresh, otherwise the stale token signs the account out.
120
+ return {
121
+ accessToken: renewed.accessToken,
122
+ expiresAt: renewed.expiresAt,
123
+ ...renewed.refreshToken === undefined ? {} : { refreshToken: renewed.refreshToken },
124
+ ...renewed.refreshExpiresAt === undefined ? {} : { refreshExpiresAt: renewed.refreshExpiresAt },
125
+ };
119
126
  }
120
127
  catch (error) {
121
128
  throw new ProviderError(`${WORKBUDDY_PROVIDER_NAME} token refresh failed: ${error instanceof Error ? error.message : String(error)}`, REAUTH_REQUIRED);
@@ -248,12 +248,13 @@ export class WorkBuddyAdapter extends LlmAdapter {
248
248
  }
249
249
  yield { type: 'text-delta', index: 0, text: delta };
250
250
  }
251
- if (chunk.usage !== undefined) {
252
- const input = chunk.usage.prompt_tokens ?? 0;
253
- const output = chunk.usage.completion_tokens ?? 0;
251
+ const usage = chunk.usage;
252
+ if (usage !== undefined && usage !== null) {
253
+ const input = usage.prompt_tokens ?? 0;
254
+ const output = usage.completion_tokens ?? 0;
254
255
  yield {
255
256
  type: 'usage',
256
- usage: { inputTokens: input, outputTokens: output, totalTokens: chunk.usage.total_tokens ?? input + output },
257
+ usage: { inputTokens: input, outputTokens: output, totalTokens: usage.total_tokens ?? input + output },
257
258
  };
258
259
  }
259
260
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-subscription-oauth",
3
- "version": "0.12.0",
3
+ "version": "0.12.3",
4
4
  "description": "Use subscription accounts as DeepSeek Harness LLM providers — Kimi Code (OAuth device flow), Grok / X Premium (OIDC + PKCE), Google Antigravity (Google OAuth + Cloud Code Assist) and GLM / BigModel (ZCode's browser sign-in) — with per-model visibility, drag-to-reorder Auto fallback and plan quotas from the web Settings page",
5
5
  "license": "MIT",
6
6
  "author": "EricFL1998",