dsh-github-copilot 0.4.0-alpha.54 → 0.4.0-alpha.56

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/index.js CHANGED
@@ -5,6 +5,8 @@ import * as dshScope from "@deepseek-ai/dsh-scope";
5
5
  import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
6
6
  import z from "@deepseek-ai/schemastery";
7
7
  import { z as z$1 } from "zod";
8
+ import { getCACertificates } from "node:tls";
9
+ import { Agent } from "undici";
8
10
  import { createModels, getSupportedThinkingLevels, hasApi, lazyStream } from "@earendil-works/pi-ai";
9
11
  import { githubCopilotProvider } from "@earendil-works/pi-ai/providers/github-copilot";
10
12
  import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
@@ -1362,6 +1364,7 @@ var CopilotUsageSource = class {
1362
1364
  dependencies;
1363
1365
  fetcher;
1364
1366
  now;
1367
+ dispatcher;
1365
1368
  generation = 0;
1366
1369
  disposed = false;
1367
1370
  key;
@@ -1388,6 +1391,9 @@ var CopilotUsageSource = class {
1388
1391
  dispose() {
1389
1392
  this.disposed = true;
1390
1393
  this.invalidate();
1394
+ const dispatcher = this.dispatcher;
1395
+ this.dispatcher = void 0;
1396
+ return dispatcher?.destroy() ?? Promise.resolve();
1391
1397
  }
1392
1398
  get() {
1393
1399
  return this.load(false);
@@ -1428,6 +1434,24 @@ var CopilotUsageSource = class {
1428
1434
  diagnostic(error) {
1429
1435
  return error instanceof UsageFailure ? error.diagnostic : "COPILOT_USAGE_NETWORK";
1430
1436
  }
1437
+ quotaDispatcher() {
1438
+ if (this.dispatcher) return this.dispatcher;
1439
+ try {
1440
+ const certificates = this.dependencies.getCACertificates ?? getCACertificates;
1441
+ const defaults = certificates("default");
1442
+ const system = certificates("system");
1443
+ if (!Array.isArray(defaults) || !Array.isArray(system) || system.length === 0 || [...defaults, ...system].some((ca) => typeof ca !== "string" || ca.length === 0)) failure$3("COPILOT_USAGE_TRUST_UNAVAILABLE");
1444
+ const ca = [.../* @__PURE__ */ new Set([...defaults, ...system])];
1445
+ this.dispatcher = (this.dependencies.createDispatcher ?? ((options) => new Agent(options)))({ connect: {
1446
+ ca,
1447
+ rejectUnauthorized: true
1448
+ } });
1449
+ if (!this.dispatcher) failure$3("COPILOT_USAGE_TRUST_UNAVAILABLE");
1450
+ return this.dispatcher;
1451
+ } catch {
1452
+ failure$3("COPILOT_USAGE_TRUST_UNAVAILABLE");
1453
+ }
1454
+ }
1431
1455
  async load(force) {
1432
1456
  let generation = this.generation;
1433
1457
  let auth;
@@ -1477,7 +1501,8 @@ var CopilotUsageSource = class {
1477
1501
  Authorization: `token ${auth.grant.refresh}`,
1478
1502
  Accept: "application/json",
1479
1503
  "X-GitHub-Api-Version": "2025-04-01"
1480
- }
1504
+ },
1505
+ ...!this.dependencies.fetch && { dispatcher: this.quotaDispatcher() }
1481
1506
  });
1482
1507
  } catch (error) {
1483
1508
  if (certificateFailure(error)) failure$3("COPILOT_USAGE_TLS");
@@ -1622,7 +1647,7 @@ let GitHubCopilotUsageController = (() => {
1622
1647
  //#endregion
1623
1648
  //#region package.json
1624
1649
  var name$1 = "dsh-github-copilot";
1625
- var version = "0.4.0-alpha.54";
1650
+ var version = "0.4.0-alpha.56";
1626
1651
  //#endregion
1627
1652
  //#region lib/types/probe.js
1628
1653
  /**
package/lib/remote.js CHANGED
@@ -119,6 +119,7 @@ const COPILOT_USAGE_DIAGNOSTICS = [
119
119
  "COPILOT_USAGE_NO_ALLOCATION",
120
120
  "COPILOT_USAGE_NETWORK",
121
121
  "COPILOT_USAGE_TLS",
122
+ "COPILOT_USAGE_TRUST_UNAVAILABLE",
122
123
  "COPILOT_USAGE_TIMEOUT",
123
124
  "COPILOT_USAGE_BODY_TOO_LARGE",
124
125
  "COPILOT_USAGE_REDIRECT",
@@ -1,17 +1,21 @@
1
1
  import { Context } from '@deepseek-ai/cordis';
2
2
  import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
3
+ import { Agent } from 'undici';
3
4
  import type { CopilotUsageView } from './copilot-usage-types.ts';
4
5
  export declare const COPILOT_USAGE_ENDPOINT = "https://api.github.com/copilot_internal/user";
5
6
  interface Dependencies {
6
7
  readCredential(): Promise<unknown>;
7
8
  fetch?: typeof globalThis.fetch;
8
9
  now?: () => number;
10
+ getCACertificates?: (type: 'default' | 'system') => string[];
11
+ createDispatcher?: (options: Agent.Options) => Agent;
9
12
  }
10
13
  /** One Host-owned, memory-only account cache. No auth renewal, persistence or model transport. */
11
14
  export declare class CopilotUsageSource {
12
15
  private readonly dependencies;
13
16
  private readonly fetcher;
14
17
  private readonly now;
18
+ private dispatcher;
15
19
  private generation;
16
20
  private disposed;
17
21
  private key;
@@ -22,13 +26,14 @@ export declare class CopilotUsageSource {
22
26
  private flight;
23
27
  constructor(dependencies: Dependencies);
24
28
  invalidate(): void;
25
- dispose(): void;
29
+ dispose(): Promise<void>;
26
30
  get(): Promise<CopilotUsageView>;
27
31
  refresh(): Promise<CopilotUsageView>;
28
32
  private active;
29
33
  private readAuth;
30
34
  private assertCurrent;
31
35
  private diagnostic;
36
+ private quotaDispatcher;
32
37
  private load;
33
38
  private fetchQuota;
34
39
  private request;
@@ -48,6 +48,7 @@ export declare const CopilotUsageViewSchema: z.ZodObject<{
48
48
  COPILOT_USAGE_NO_ALLOCATION: "COPILOT_USAGE_NO_ALLOCATION";
49
49
  COPILOT_USAGE_NETWORK: "COPILOT_USAGE_NETWORK";
50
50
  COPILOT_USAGE_TLS: "COPILOT_USAGE_TLS";
51
+ COPILOT_USAGE_TRUST_UNAVAILABLE: "COPILOT_USAGE_TRUST_UNAVAILABLE";
51
52
  COPILOT_USAGE_TIMEOUT: "COPILOT_USAGE_TIMEOUT";
52
53
  COPILOT_USAGE_BODY_TOO_LARGE: "COPILOT_USAGE_BODY_TOO_LARGE";
53
54
  COPILOT_USAGE_REDIRECT: "COPILOT_USAGE_REDIRECT";
@@ -14,6 +14,6 @@ export interface CopilotUsageView {
14
14
  }
15
15
  export declare const COPILOT_USAGE_MAX_AMOUNT = 1000000000000;
16
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_TLS", "COPILOT_USAGE_TIMEOUT", "COPILOT_USAGE_BODY_TOO_LARGE", "COPILOT_USAGE_REDIRECT", "COPILOT_USAGE_AUTH_REJECTED", "COPILOT_USAGE_HTTP_ERROR", "COPILOT_USAGE_RATE_LIMITED"];
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_TLS", "COPILOT_USAGE_TRUST_UNAVAILABLE", "COPILOT_USAGE_TIMEOUT", "COPILOT_USAGE_BODY_TOO_LARGE", "COPILOT_USAGE_REDIRECT", "COPILOT_USAGE_AUTH_REJECTED", "COPILOT_USAGE_HTTP_ERROR", "COPILOT_USAGE_RATE_LIMITED"];
18
18
  export type CopilotUsageDiagnostic = typeof COPILOT_USAGE_DIAGNOSTICS[number];
19
19
  //# sourceMappingURL=copilot-usage-types.d.ts.map
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.54",
4
+ "version": "0.4.0-alpha.56",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",
@@ -128,6 +128,7 @@
128
128
  },
129
129
  "dependencies": {
130
130
  "@earendil-works/pi-ai": "0.87.1",
131
+ "undici": "6.28.1",
131
132
  "zod": "^4.4.3"
132
133
  },
133
134
  "devDependencies": {