dsh-github-copilot 0.4.0-alpha.53 → 0.4.0-alpha.55
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/AGENTS.md +2 -0
- package/CHANGELOG.md +10 -0
- package/README.md +15 -11
- package/README.zh.md +15 -11
- package/deployment-baseline.json +3 -2
- package/docs/automatic-model-routing.md +29 -3
- package/docs/copilot-usage.md +3 -1
- package/lib/client.js +6 -3
- package/lib/client.js.map +1 -1
- package/lib/index.js +29 -21
- package/lib/remote.js +1 -0
- package/lib/types/copilot-usage-host.d.ts +6 -1
- package/lib/types/copilot-usage-remote.d.ts +1 -0
- package/lib/types/copilot-usage-types.d.ts +1 -1
- package/package.json +4 -1
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.
|
|
1650
|
+
var version = "0.4.0-alpha.55";
|
|
1626
1651
|
//#endregion
|
|
1627
1652
|
//#region lib/types/probe.js
|
|
1628
1653
|
/**
|
|
@@ -6404,9 +6429,6 @@ function actualNotice(agent, model) {
|
|
|
6404
6429
|
}
|
|
6405
6430
|
});
|
|
6406
6431
|
}
|
|
6407
|
-
function appendAutoModelDecision(agent, event) {
|
|
6408
|
-
Reflect.apply(agent.session.append, agent.session, ["github-copilot/auto-model-decision", event]);
|
|
6409
|
-
}
|
|
6410
6432
|
/** Resolve virtual Auto once per Core turn before request/header persistence. */
|
|
6411
6433
|
function installAutoModelRouting(ctx, dependencies) {
|
|
6412
6434
|
const captured = /* @__PURE__ */ new WeakMap();
|
|
@@ -6428,7 +6450,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
6428
6450
|
}
|
|
6429
6451
|
};
|
|
6430
6452
|
}, { prepend: true });
|
|
6431
|
-
const removePreStep = agent.ctx.on("agent/pre-step", async ({ messages, turn,
|
|
6453
|
+
const removePreStep = agent.ctx.on("agent/pre-step", async ({ messages, turn, signal }, next) => {
|
|
6432
6454
|
const result = await next();
|
|
6433
6455
|
const entered = result.kind === "enter" ? result.messages : messages;
|
|
6434
6456
|
captured.set(agent, {
|
|
@@ -6475,7 +6497,7 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
6475
6497
|
captured.delete(agent);
|
|
6476
6498
|
routed.delete(agent);
|
|
6477
6499
|
});
|
|
6478
|
-
const removeRequest = ctx.on("agent/request", async ({ agent, turn,
|
|
6500
|
+
const removeRequest = ctx.on("agent/request", async ({ agent, turn, signal }, next) => {
|
|
6479
6501
|
const resolved = await next();
|
|
6480
6502
|
const pending = pendingAuto(ctx, agent);
|
|
6481
6503
|
const virtualPreference = resolved.provider === "github-copilot-preview" ? autoModelPreference(resolved.model) : void 0;
|
|
@@ -6511,20 +6533,6 @@ function installAutoModelRouting(ctx, dependencies) {
|
|
|
6511
6533
|
model: resolved.model
|
|
6512
6534
|
}]);
|
|
6513
6535
|
}
|
|
6514
|
-
appendAutoModelDecision(agent, {
|
|
6515
|
-
turn,
|
|
6516
|
-
step,
|
|
6517
|
-
provider: GITHUB_COPILOT_PREVIEW_PROVIDER_ID,
|
|
6518
|
-
model: state.decision.model.id,
|
|
6519
|
-
preference: state.decision.preference,
|
|
6520
|
-
taskClass: state.decision.taskClass,
|
|
6521
|
-
reason: state.decision.reason,
|
|
6522
|
-
candidateCount: state.decision.candidateCount,
|
|
6523
|
-
fittingCandidateCount: state.decision.fittingCandidateCount,
|
|
6524
|
-
estimatedInputTokens: state.decision.estimatedInputTokens,
|
|
6525
|
-
selectedInputBudget: state.decision.selectedInputBudget,
|
|
6526
|
-
inputFitDiagnostic: state.decision.inputFitDiagnostic
|
|
6527
|
-
});
|
|
6528
6536
|
state.recorded = true;
|
|
6529
6537
|
}
|
|
6530
6538
|
return {
|
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.
|
|
4
|
+
"version": "0.4.0-alpha.55",
|
|
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.29.0",
|
|
131
132
|
"zod": "^4.4.3"
|
|
132
133
|
},
|
|
133
134
|
"devDependencies": {
|
|
@@ -149,6 +150,8 @@
|
|
|
149
150
|
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
150
151
|
"@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
|
|
151
152
|
"@deepseek-ai/dsh-scope": "0.2.0-rc.2",
|
|
153
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
154
|
+
"@deepseek-ai/dsh-session-format-catalog": "0.2.0-rc.2",
|
|
152
155
|
"@deepseek-ai/dsh-settings": "0.2.0-rc.2",
|
|
153
156
|
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
|
|
154
157
|
"@deepseek-ai/dsh-tool-web": "0.2.0-rc.2",
|