dsh-github-copilot 0.4.0-alpha.30 → 0.4.0-alpha.32

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/remote.js CHANGED
@@ -43,7 +43,7 @@ const DualModelCreateSchema = z.object({
43
43
  expectedRevision: revision
44
44
  }).strict();
45
45
  const DualModelCreateResultSchema = z.object({ sessionId: id }).strict();
46
- const contribution$2 = {
46
+ const contribution$3 = {
47
47
  package: "dsh-github-copilot",
48
48
  descriptors: [
49
49
  {
@@ -85,7 +85,7 @@ const contribution$2 = {
85
85
  }
86
86
  ]
87
87
  };
88
- const contribution$1 = {
88
+ const contribution$2 = {
89
89
  package: "dsh-github-copilot",
90
90
  descriptors: [{
91
91
  id: "dsh-github-copilot:githubCopilotSearchRouting.providers",
@@ -101,6 +101,97 @@ const contribution$1 = {
101
101
  }]
102
102
  };
103
103
  //#endregion
104
+ //#region lib/types/copilot-usage-types.js
105
+ const COPILOT_USAGE_MAX_AMOUNT = 0xe8d4a51000;
106
+ const COPILOT_USAGE_MAX_TIMESTAMP = 0xe677d21fdbff;
107
+ const COPILOT_USAGE_DIAGNOSTICS = [
108
+ "COPILOT_USAGE_SIGNED_OUT",
109
+ "COPILOT_USAGE_INVALID_GRANT",
110
+ "COPILOT_USAGE_CREDENTIALS_UNAVAILABLE",
111
+ "COPILOT_USAGE_ENTERPRISE_UNSUPPORTED",
112
+ "COPILOT_USAGE_ACCOUNT_CHANGED",
113
+ "COPILOT_USAGE_DISPOSED",
114
+ "COPILOT_USAGE_BILLING_UNKNOWN",
115
+ "COPILOT_USAGE_SNAPSHOT_MISSING",
116
+ "COPILOT_USAGE_INVALID_RESPONSE",
117
+ "COPILOT_USAGE_POOLED_UNAVAILABLE",
118
+ "COPILOT_USAGE_POOLED_EXHAUSTED",
119
+ "COPILOT_USAGE_NO_ALLOCATION",
120
+ "COPILOT_USAGE_NETWORK",
121
+ "COPILOT_USAGE_TIMEOUT",
122
+ "COPILOT_USAGE_BODY_TOO_LARGE",
123
+ "COPILOT_USAGE_REDIRECT",
124
+ "COPILOT_USAGE_AUTH_REJECTED",
125
+ "COPILOT_USAGE_HTTP_ERROR",
126
+ "COPILOT_USAGE_RATE_LIMITED"
127
+ ];
128
+ //#endregion
129
+ //#region lib/types/copilot-usage-remote.js
130
+ const amount = z.number().finite().nonnegative().max(COPILOT_USAGE_MAX_AMOUNT);
131
+ const timestamp = z.number().int().nonnegative().max(COPILOT_USAGE_MAX_TIMESTAMP);
132
+ const CopilotUsageViewSchema = z.object({
133
+ state: z.enum([
134
+ "ready",
135
+ "stale",
136
+ "unavailable",
137
+ "signed-out"
138
+ ]),
139
+ billing: z.enum([
140
+ "credits",
141
+ "requests",
142
+ "unknown"
143
+ ]),
144
+ budget: z.enum([
145
+ "individual",
146
+ "pooled",
147
+ "unknown"
148
+ ]),
149
+ used: amount.optional(),
150
+ remaining: amount.optional(),
151
+ limit: amount.positive().optional(),
152
+ percentUsed: z.number().finite().min(0).max(100).optional(),
153
+ resetAt: timestamp.optional(),
154
+ observedAt: timestamp.optional(),
155
+ diagnostic: z.enum(COPILOT_USAGE_DIAGNOSTICS).optional()
156
+ }).strict().superRefine((view, ctx) => {
157
+ const invalid = () => ctx.addIssue({
158
+ code: "custom",
159
+ message: "Invalid account quota snapshot"
160
+ });
161
+ const hasAmounts = [
162
+ view.used,
163
+ view.remaining,
164
+ view.limit,
165
+ view.percentUsed
166
+ ].some((value) => value !== void 0);
167
+ if (view.state === "unavailable" || view.state === "signed-out") {
168
+ if (hasAmounts || view.observedAt !== void 0 || view.resetAt !== void 0 || view.diagnostic === void 0) invalid();
169
+ if (view.state === "signed-out" && (view.billing !== "unknown" || view.budget !== "unknown")) invalid();
170
+ return;
171
+ }
172
+ if (!hasAmounts || view.observedAt === void 0 || view.billing === "unknown" || view.budget === "unknown") invalid();
173
+ if (view.state === "stale" && view.diagnostic === void 0) invalid();
174
+ if (view.state === "ready" && view.diagnostic !== void 0) invalid();
175
+ if (view.budget === "pooled" && (view.billing !== "credits" || view.used === void 0 || view.remaining !== void 0 || view.limit !== void 0 || view.percentUsed !== void 0)) invalid();
176
+ if (view.limit !== void 0) {
177
+ if (view.used !== void 0 && view.used > view.limit || view.remaining !== void 0 && view.remaining > view.limit) invalid();
178
+ if (view.used !== void 0 && view.remaining !== void 0 && Math.abs(view.used + view.remaining - view.limit) > Math.max(1e-8, view.limit * 1e-12)) invalid();
179
+ if (view.remaining !== void 0 && view.percentUsed !== void 0 && Math.abs((1 - view.remaining / view.limit) * 100 - view.percentUsed) > 1) invalid();
180
+ }
181
+ });
182
+ const contribution$1 = {
183
+ package: "dsh-github-copilot",
184
+ descriptors: ["get", "refresh"].map((method) => ({
185
+ id: `dsh-github-copilot:githubCopilotUsage.${method}`,
186
+ namespace: "githubCopilotUsage",
187
+ service: "githubCopilotUsage",
188
+ method,
189
+ invocation: { kind: "direct" },
190
+ parameters: [],
191
+ result: strictRemoteCodec("dsh-github-copilot#CopilotUsageView", CopilotUsageViewSchema)
192
+ }))
193
+ };
194
+ //#endregion
104
195
  //#region lib/types/remote.js
105
196
  /**
106
197
  * Client-safe Remote contribution for the plugin-owned authorization bridge.
@@ -253,6 +344,7 @@ const contribution = {
253
344
  parameters: [],
254
345
  result: strictRemoteCodec(GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL, GitHubCopilotMigrationStatusSchema)
255
346
  },
347
+ ...contribution$3.descriptors,
256
348
  ...contribution$2.descriptors,
257
349
  ...contribution$1.descriptors
258
350
  ]
package/lib/routed-web.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as currentSearchInitiator, T as isPluginPreviewProvider, t as isCopilotSearchSelection, w as currentSearchSelection } from "./search-routing-pFLux0W7.js";
1
+ import { C as currentSearchInitiator, T as isPluginPreviewProvider, t as isCopilotSearchSelection, w as currentSearchSelection } from "./search-routing-DqLKem1c.js";
2
2
  import { WebError, WebRuntime } from "@deepseek-ai/dsh-web";
3
3
  //#region lib/types/routed-web.js
4
4
  /**
@@ -11,5 +11,5 @@ export declare function copilotEntitlementKey(grant: Pick<GitHubCopilotOAuthCred
11
11
  * Bind model discovery to the existing native OAuth lifecycle. No model catalog,
12
12
  * login, environment fallback or separate credential record is introduced here.
13
13
  */
14
- export declare function createAccountModelAuth(credentials: CredentialStore): Pick<AccountModelSourceDependencies, 'resolveAuth' | 'assertAuthCurrent'>;
14
+ export declare function createAccountModelAuth(credentials: CredentialStore, renewRejectedCredential?: (grant: GitHubCopilotOAuthCredential) => boolean): Pick<AccountModelSourceDependencies, 'resolveAuth' | 'assertAuthCurrent'>;
15
15
  //# sourceMappingURL=account-model-auth.d.ts.map
@@ -9,6 +9,7 @@ import type { GitHubCopilotAuthorizationView } from './authorization-controller.
9
9
  import type { ProviderCardExtrasOwnerProps, SettingsSectionOwnerProps } from './dsh-supported-types.ts';
10
10
  export { WebSearchRoutingCard } from './web-search-routing-card.ts';
11
11
  export { DualModelCard } from './dual-model-card.ts';
12
+ export { CopilotUsageCard } from './copilot-usage-card.ts';
12
13
  export declare const inject: string[];
13
14
  interface GitHubCopilotProviderCardProps extends ProviderCardExtrasOwnerProps {
14
15
  readonly remote: ClientContext['remote']['githubCopilot'];
@@ -0,0 +1,28 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { CopilotUsageView } from './copilot-usage-types.ts';
3
+ /** Client-only face: no credentials, provider transport or billing arithmetic. */
4
+ export interface CopilotUsageRemote {
5
+ get(): Promise<{
6
+ ok: true;
7
+ value: CopilotUsageView;
8
+ } | {
9
+ ok: false;
10
+ error: unknown;
11
+ }>;
12
+ refresh(): Promise<{
13
+ ok: true;
14
+ value: CopilotUsageView;
15
+ } | {
16
+ ok: false;
17
+ error: unknown;
18
+ }>;
19
+ }
20
+ export interface CopilotUsageCardProps {
21
+ remote?: CopilotUsageRemote;
22
+ /** Changes revoke every in-flight read, including switches between Copilot routes. */
23
+ contextKey: string;
24
+ locale?: string;
25
+ }
26
+ /** Mounted only for a proven effective Copilot selection in the owning Session. */
27
+ export declare function CopilotUsageCard(props: CopilotUsageCardProps): ReactElement;
28
+ //# sourceMappingURL=copilot-usage-card.d.ts.map
@@ -0,0 +1,48 @@
1
+ import { Context } from '@deepseek-ai/cordis';
2
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
3
+ import type { CopilotUsageView } from './copilot-usage-types.ts';
4
+ export declare const COPILOT_USAGE_ENDPOINT = "https://api.github.com/copilot_internal/user";
5
+ interface Dependencies {
6
+ readCredential(): Promise<unknown>;
7
+ fetch?: typeof globalThis.fetch;
8
+ now?: () => number;
9
+ }
10
+ /** One Host-owned, memory-only account cache. No auth renewal, persistence or model transport. */
11
+ export declare class CopilotUsageSource {
12
+ private readonly dependencies;
13
+ private readonly fetcher;
14
+ private readonly now;
15
+ private generation;
16
+ private disposed;
17
+ private key;
18
+ private cached;
19
+ private last;
20
+ private nextRefreshAt;
21
+ private failureUntil;
22
+ private flight;
23
+ constructor(dependencies: Dependencies);
24
+ invalidate(): void;
25
+ dispose(): void;
26
+ get(): Promise<CopilotUsageView>;
27
+ refresh(): Promise<CopilotUsageView>;
28
+ private active;
29
+ private readAuth;
30
+ private assertCurrent;
31
+ private diagnostic;
32
+ private load;
33
+ private fetchQuota;
34
+ private request;
35
+ }
36
+ declare module '@deepseek-ai/cordis' {
37
+ interface Context {
38
+ githubCopilotUsage: GitHubCopilotUsageController;
39
+ }
40
+ }
41
+ export default class GitHubCopilotUsageController extends TypertRemoteService {
42
+ private readonly source;
43
+ constructor(ctx: Context);
44
+ get(): Promise<CopilotUsageView>;
45
+ refresh(): Promise<CopilotUsageView>;
46
+ }
47
+ export {};
48
+ //# sourceMappingURL=copilot-usage-host.d.ts.map
@@ -0,0 +1,9 @@
1
+ import type { CopilotUsageView, CopilotUsageDiagnostic } from './copilot-usage-types.ts';
2
+ export declare function unavailableCopilotUsage(diagnostic: CopilotUsageDiagnostic, billing?: CopilotUsageView['billing'], budget?: CopilotUsageView['budget']): CopilotUsageView;
3
+ /**
4
+ * Pinned VS Code 44825207: parseQuotas/getQuotaUsage and chatStatusDashboard
5
+ * display account amounts directly. Only per-turn nano-AIU uses /1e9; it is
6
+ * intentionally absent here. Pooled credits_used never shares an entitlement.
7
+ */
8
+ export declare function normalizeCopilotUsage(input: unknown, observedAt: number): CopilotUsageView;
9
+ //# sourceMappingURL=copilot-usage-normalize.d.ts.map
@@ -0,0 +1,60 @@
1
+ import type { RemoteResult, TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol';
2
+ import { z } from 'zod';
3
+ import type { CopilotUsageView } from './copilot-usage-types.ts';
4
+ export type { CopilotUsageView } from './copilot-usage-types.ts';
5
+ declare module '@deepseek-ai/dsh-typert-protocol' {
6
+ interface TypertRemoteNamespaceMap {
7
+ githubCopilotUsage: {
8
+ get(): Promise<RemoteResult<CopilotUsageView>>;
9
+ refresh(): Promise<RemoteResult<CopilotUsageView>>;
10
+ };
11
+ }
12
+ }
13
+ export declare const CopilotUsageViewSchema: z.ZodObject<{
14
+ state: z.ZodEnum<{
15
+ ready: "ready";
16
+ stale: "stale";
17
+ "signed-out": "signed-out";
18
+ unavailable: "unavailable";
19
+ }>;
20
+ billing: z.ZodEnum<{
21
+ unknown: "unknown";
22
+ credits: "credits";
23
+ requests: "requests";
24
+ }>;
25
+ budget: z.ZodEnum<{
26
+ unknown: "unknown";
27
+ individual: "individual";
28
+ pooled: "pooled";
29
+ }>;
30
+ used: z.ZodOptional<z.ZodNumber>;
31
+ remaining: z.ZodOptional<z.ZodNumber>;
32
+ limit: z.ZodOptional<z.ZodNumber>;
33
+ percentUsed: z.ZodOptional<z.ZodNumber>;
34
+ resetAt: z.ZodOptional<z.ZodNumber>;
35
+ observedAt: z.ZodOptional<z.ZodNumber>;
36
+ diagnostic: z.ZodOptional<z.ZodEnum<{
37
+ COPILOT_USAGE_SIGNED_OUT: "COPILOT_USAGE_SIGNED_OUT";
38
+ COPILOT_USAGE_INVALID_GRANT: "COPILOT_USAGE_INVALID_GRANT";
39
+ COPILOT_USAGE_CREDENTIALS_UNAVAILABLE: "COPILOT_USAGE_CREDENTIALS_UNAVAILABLE";
40
+ COPILOT_USAGE_ENTERPRISE_UNSUPPORTED: "COPILOT_USAGE_ENTERPRISE_UNSUPPORTED";
41
+ COPILOT_USAGE_ACCOUNT_CHANGED: "COPILOT_USAGE_ACCOUNT_CHANGED";
42
+ COPILOT_USAGE_DISPOSED: "COPILOT_USAGE_DISPOSED";
43
+ COPILOT_USAGE_BILLING_UNKNOWN: "COPILOT_USAGE_BILLING_UNKNOWN";
44
+ COPILOT_USAGE_SNAPSHOT_MISSING: "COPILOT_USAGE_SNAPSHOT_MISSING";
45
+ COPILOT_USAGE_INVALID_RESPONSE: "COPILOT_USAGE_INVALID_RESPONSE";
46
+ COPILOT_USAGE_POOLED_UNAVAILABLE: "COPILOT_USAGE_POOLED_UNAVAILABLE";
47
+ COPILOT_USAGE_POOLED_EXHAUSTED: "COPILOT_USAGE_POOLED_EXHAUSTED";
48
+ COPILOT_USAGE_NO_ALLOCATION: "COPILOT_USAGE_NO_ALLOCATION";
49
+ COPILOT_USAGE_NETWORK: "COPILOT_USAGE_NETWORK";
50
+ COPILOT_USAGE_TIMEOUT: "COPILOT_USAGE_TIMEOUT";
51
+ COPILOT_USAGE_BODY_TOO_LARGE: "COPILOT_USAGE_BODY_TOO_LARGE";
52
+ COPILOT_USAGE_REDIRECT: "COPILOT_USAGE_REDIRECT";
53
+ COPILOT_USAGE_AUTH_REJECTED: "COPILOT_USAGE_AUTH_REJECTED";
54
+ COPILOT_USAGE_HTTP_ERROR: "COPILOT_USAGE_HTTP_ERROR";
55
+ COPILOT_USAGE_RATE_LIMITED: "COPILOT_USAGE_RATE_LIMITED";
56
+ }>>;
57
+ }, z.core.$strict>;
58
+ declare const contribution: TypertRemoteContribution;
59
+ export default contribution;
60
+ //# sourceMappingURL=copilot-usage-remote.d.ts.map
@@ -0,0 +1,19 @@
1
+ /** Client-safe account snapshot. Amounts are credits or requests, never token estimates. */
2
+ export interface CopilotUsageView {
3
+ readonly state: 'ready' | 'stale' | 'unavailable' | 'signed-out';
4
+ readonly billing: 'credits' | 'requests' | 'unknown';
5
+ readonly budget: 'individual' | 'pooled' | 'unknown';
6
+ readonly used?: number;
7
+ readonly remaining?: number;
8
+ readonly limit?: number;
9
+ readonly percentUsed?: number;
10
+ /** Unix epoch milliseconds, only when explicitly reported by the supplier. */
11
+ readonly resetAt?: number;
12
+ readonly observedAt?: number;
13
+ readonly diagnostic?: string;
14
+ }
15
+ export declare const COPILOT_USAGE_MAX_AMOUNT = 1000000000000;
16
+ export declare const COPILOT_USAGE_MAX_TIMESTAMP = 253402300799999;
17
+ export declare const COPILOT_USAGE_DIAGNOSTICS: readonly ["COPILOT_USAGE_SIGNED_OUT", "COPILOT_USAGE_INVALID_GRANT", "COPILOT_USAGE_CREDENTIALS_UNAVAILABLE", "COPILOT_USAGE_ENTERPRISE_UNSUPPORTED", "COPILOT_USAGE_ACCOUNT_CHANGED", "COPILOT_USAGE_DISPOSED", "COPILOT_USAGE_BILLING_UNKNOWN", "COPILOT_USAGE_SNAPSHOT_MISSING", "COPILOT_USAGE_INVALID_RESPONSE", "COPILOT_USAGE_POOLED_UNAVAILABLE", "COPILOT_USAGE_POOLED_EXHAUSTED", "COPILOT_USAGE_NO_ALLOCATION", "COPILOT_USAGE_NETWORK", "COPILOT_USAGE_TIMEOUT", "COPILOT_USAGE_BODY_TOO_LARGE", "COPILOT_USAGE_REDIRECT", "COPILOT_USAGE_AUTH_REJECTED", "COPILOT_USAGE_HTTP_ERROR", "COPILOT_USAGE_RATE_LIMITED"];
18
+ export type CopilotUsageDiagnostic = typeof COPILOT_USAGE_DIAGNOSTICS[number];
19
+ //# sourceMappingURL=copilot-usage-types.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ /** Public additive dock only; native composer, ContextMeter and other features stay owned by Core. */
3
+ export declare function registerCopilotUsageUi(ctx: Context): () => void;
4
+ //# sourceMappingURL=copilot-usage-ui.d.ts.map
@@ -0,0 +1,3 @@
1
+ /** Use Desktop's public v1 navigation handoff instead of WebView popup creation. */
2
+ export declare function externalLinkTarget(): '_self' | '_blank';
3
+ //# sourceMappingURL=external-link.d.ts.map
@@ -11,6 +11,8 @@ export interface PreviewProviderGuard {
11
11
  signal: AbortSignal;
12
12
  release(): void;
13
13
  }>;
14
+ /** Actual model HTTP 401 only; called after release, without replaying the request. */
15
+ onUnauthorized?(): void;
14
16
  }
15
17
  /** Guard for one selected model in an account-bound descriptor snapshot. */
16
18
  export interface AccountProviderGuard extends PreviewProviderGuard {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-github-copilot",
3
3
  "description": "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
4
- "version": "0.4.0-alpha.30",
4
+ "version": "0.4.0-alpha.32",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",
@@ -56,6 +56,7 @@
56
56
  "docs/dual-model.md",
57
57
  "docs/official-first-016-alpha2.md",
58
58
  "docs/copilot-compaction.md",
59
+ "docs/copilot-usage.md",
59
60
  "docs/images/dual-model-provenance.json",
60
61
  "scripts/check-search-composition.mjs",
61
62
  "docs/images/"
@@ -1,7 +1,7 @@
1
+ import { getSupportedThinkingLevels } from "@earendil-works/pi-ai";
2
+ import { builtinProviders, getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
1
3
  import { attributionHeaders } from "@deepseek-ai/dsh-llm";
2
4
  import { WebError } from "@deepseek-ai/dsh-web";
3
- import { builtinProviders, getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
4
- import { getSupportedThinkingLevels } from "@earendil-works/pi-ai";
5
5
  //#region lib/types/copilot-identity.js
6
6
  /** Native OAuth ownership and the sole plugin-owned, account-discovered route. */
7
7
  const GITHUB_COPILOT_CREDENTIAL_KEY$1 = "llm-pi-ai/github-copilot";