dsh-github-copilot 0.4.0-alpha.43 → 0.4.0-alpha.46
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 +5 -5
- package/CHANGELOG.md +12 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +13 -11
- package/README.zh.md +13 -11
- package/deployment-baseline.json +7 -3
- package/docs/copilot-usage.md +2 -0
- package/lib/client.js +31 -13
- package/lib/client.js.map +1 -1
- package/lib/index.js +42 -13
- package/lib/remote.js +7 -1
- package/lib/types/authorization-controller.d.ts +4 -0
- package/lib/types/copilot-usage-remote.d.ts +1 -0
- package/lib/types/copilot-usage-types.d.ts +1 -1
- package/lib/types/remote.d.ts +5 -0
- package/package.json +2 -1
package/lib/index.js
CHANGED
|
@@ -1293,6 +1293,14 @@ const REFRESH_INTERVAL_MS = 1e4;
|
|
|
1293
1293
|
const FAILURE_COOLDOWN_MS = 3e4;
|
|
1294
1294
|
const TIMEOUT_MS = 1e4;
|
|
1295
1295
|
const MAX_BODY_BYTES = 262144;
|
|
1296
|
+
const CERTIFICATE_FAILURES = /* @__PURE__ */ new Set([
|
|
1297
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
1298
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
1299
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
1300
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
1301
|
+
"CERT_HAS_EXPIRED",
|
|
1302
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
1303
|
+
]);
|
|
1296
1304
|
var UsageFailure = class extends Error {
|
|
1297
1305
|
diagnostic;
|
|
1298
1306
|
constructor(diagnostic) {
|
|
@@ -1303,6 +1311,11 @@ var UsageFailure = class extends Error {
|
|
|
1303
1311
|
function failure$3(diagnostic) {
|
|
1304
1312
|
throw new UsageFailure(diagnostic);
|
|
1305
1313
|
}
|
|
1314
|
+
function certificateFailure(error) {
|
|
1315
|
+
if (!(error instanceof TypeError) || !("cause" in error)) return false;
|
|
1316
|
+
const cause = error.cause;
|
|
1317
|
+
return typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" && CERTIFICATE_FAILURES.has(cause.code);
|
|
1318
|
+
}
|
|
1306
1319
|
async function readBody(response, signal) {
|
|
1307
1320
|
const length = response.headers.get("content-length");
|
|
1308
1321
|
if (length !== null && (!/^\d+$/u.test(length) || Number(length) > MAX_BODY_BYTES)) {
|
|
@@ -1453,17 +1466,23 @@ var CopilotUsageSource = class {
|
|
|
1453
1466
|
}
|
|
1454
1467
|
}
|
|
1455
1468
|
async fetchQuota(auth, abort) {
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1469
|
+
let response;
|
|
1470
|
+
try {
|
|
1471
|
+
response = await this.fetcher(COPILOT_USAGE_ENDPOINT, {
|
|
1472
|
+
method: "GET",
|
|
1473
|
+
redirect: "error",
|
|
1474
|
+
signal: abort.signal,
|
|
1475
|
+
cache: "no-store",
|
|
1476
|
+
headers: {
|
|
1477
|
+
Authorization: `token ${auth.grant.refresh}`,
|
|
1478
|
+
Accept: "application/json",
|
|
1479
|
+
"X-GitHub-Api-Version": "2025-04-01"
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
} catch (error) {
|
|
1483
|
+
if (certificateFailure(error)) failure$3("COPILOT_USAGE_TLS");
|
|
1484
|
+
throw error;
|
|
1485
|
+
}
|
|
1467
1486
|
if (response.redirected || response.status >= 300 && response.status < 400) {
|
|
1468
1487
|
response.body?.cancel().catch(() => void 0);
|
|
1469
1488
|
failure$3("COPILOT_USAGE_REDIRECT");
|
|
@@ -1516,6 +1535,7 @@ var CopilotUsageSource = class {
|
|
|
1516
1535
|
}
|
|
1517
1536
|
const staleAllowed = [
|
|
1518
1537
|
"COPILOT_USAGE_NETWORK",
|
|
1538
|
+
"COPILOT_USAGE_TLS",
|
|
1519
1539
|
"COPILOT_USAGE_TIMEOUT",
|
|
1520
1540
|
"COPILOT_USAGE_HTTP_ERROR",
|
|
1521
1541
|
"COPILOT_USAGE_RATE_LIMITED"
|
|
@@ -1602,7 +1622,7 @@ let GitHubCopilotUsageController = (() => {
|
|
|
1602
1622
|
//#endregion
|
|
1603
1623
|
//#region package.json
|
|
1604
1624
|
var name$1 = "dsh-github-copilot";
|
|
1605
|
-
var version = "0.4.0-alpha.
|
|
1625
|
+
var version = "0.4.0-alpha.46";
|
|
1606
1626
|
//#endregion
|
|
1607
1627
|
//#region lib/types/probe.js
|
|
1608
1628
|
/**
|
|
@@ -4583,6 +4603,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
4583
4603
|
failure;
|
|
4584
4604
|
reconciliationFailed = false;
|
|
4585
4605
|
attempt;
|
|
4606
|
+
authorizationMilestone;
|
|
4586
4607
|
constructor(ctx) {
|
|
4587
4608
|
super(ctx, "githubCopilotAuthorization", { namespace: "githubCopilot" });
|
|
4588
4609
|
}
|
|
@@ -4625,7 +4646,8 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
4625
4646
|
route,
|
|
4626
4647
|
...catalog === void 0 ? {} : { catalog },
|
|
4627
4648
|
...discovered === void 0 ? {} : { accountModels: discovered },
|
|
4628
|
-
...this.failure === void 0 ? {} : { error: this.failure }
|
|
4649
|
+
...this.failure === void 0 ? {} : { error: this.failure },
|
|
4650
|
+
...this.authorizationMilestone === void 0 ? {} : { authorizationMilestone: this.authorizationMilestone }
|
|
4629
4651
|
};
|
|
4630
4652
|
}
|
|
4631
4653
|
/** Explicit model discovery: may refresh OAuth and GET the account catalog, never changes selection. */
|
|
@@ -4688,6 +4710,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
4688
4710
|
this.notices = [];
|
|
4689
4711
|
this.failure = void 0;
|
|
4690
4712
|
this.reconciliationFailed = false;
|
|
4713
|
+
this.authorizationMilestone = "AUTHORIZATION_REQUESTED";
|
|
4691
4714
|
let begun;
|
|
4692
4715
|
try {
|
|
4693
4716
|
begun = authorization.begin({
|
|
@@ -4695,9 +4718,11 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
4695
4718
|
method: oauth.id,
|
|
4696
4719
|
interaction: {
|
|
4697
4720
|
notify: (notice) => {
|
|
4721
|
+
this.authorizationMilestone = "INTERACTION_NOTICE_OBSERVED";
|
|
4698
4722
|
this.notices = [...this.notices, { ...notice }];
|
|
4699
4723
|
},
|
|
4700
4724
|
prompt: (prompt) => {
|
|
4725
|
+
this.authorizationMilestone = "INTERACTION_PROMPT_OBSERVED";
|
|
4701
4726
|
if (prompt.kind === "text" && /GitHub Enterprise URL\/domain/i.test(prompt.message)) return Promise.resolve("");
|
|
4702
4727
|
return Promise.reject(/* @__PURE__ */ new Error("github-copilot: this browser bridge cannot answer the authorization prompt"));
|
|
4703
4728
|
}
|
|
@@ -4709,11 +4734,13 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
4709
4734
|
const running = begun.then(async (outcome) => {
|
|
4710
4735
|
if (outcome.status === "authorized") {
|
|
4711
4736
|
this.notices = [];
|
|
4737
|
+
this.authorizationMilestone = void 0;
|
|
4712
4738
|
await this.ensureProviderProfile();
|
|
4713
4739
|
if (this.reconciliationFailed) this.failure = "COPILOT_ROUTE_REPAIR_FAILED";
|
|
4714
4740
|
return;
|
|
4715
4741
|
}
|
|
4716
4742
|
this.notices = [];
|
|
4743
|
+
this.authorizationMilestone = void 0;
|
|
4717
4744
|
}).catch(() => {
|
|
4718
4745
|
this.notices = [];
|
|
4719
4746
|
this.failure = "COPILOT_AUTHORIZATION_BEGIN_FAILED";
|
|
@@ -4731,6 +4758,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
4731
4758
|
"cancel"
|
|
4732
4759
|
]);
|
|
4733
4760
|
this.notices = [];
|
|
4761
|
+
this.authorizationMilestone = void 0;
|
|
4734
4762
|
authorization.cancel(GITHUB_COPILOT_CREDENTIAL_KEY);
|
|
4735
4763
|
return this.status();
|
|
4736
4764
|
}
|
|
@@ -4744,6 +4772,7 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
4744
4772
|
this.notices = [];
|
|
4745
4773
|
this.failure = void 0;
|
|
4746
4774
|
this.reconciliationFailed = false;
|
|
4775
|
+
this.authorizationMilestone = void 0;
|
|
4747
4776
|
return this.status();
|
|
4748
4777
|
}
|
|
4749
4778
|
async ensureProviderProfile() {
|
package/lib/remote.js
CHANGED
|
@@ -118,6 +118,7 @@ const COPILOT_USAGE_DIAGNOSTICS = [
|
|
|
118
118
|
"COPILOT_USAGE_POOLED_EXHAUSTED",
|
|
119
119
|
"COPILOT_USAGE_NO_ALLOCATION",
|
|
120
120
|
"COPILOT_USAGE_NETWORK",
|
|
121
|
+
"COPILOT_USAGE_TLS",
|
|
121
122
|
"COPILOT_USAGE_TIMEOUT",
|
|
122
123
|
"COPILOT_USAGE_BODY_TOO_LARGE",
|
|
123
124
|
"COPILOT_USAGE_REDIRECT",
|
|
@@ -266,7 +267,12 @@ const GitHubCopilotAuthorizationViewSchema = z.object({
|
|
|
266
267
|
"ROUTE_CONFLICT"
|
|
267
268
|
]).optional()
|
|
268
269
|
}).strict().optional(),
|
|
269
|
-
error: z.string().optional()
|
|
270
|
+
error: z.string().optional(),
|
|
271
|
+
authorizationMilestone: z.enum([
|
|
272
|
+
"AUTHORIZATION_REQUESTED",
|
|
273
|
+
"INTERACTION_PROMPT_OBSERVED",
|
|
274
|
+
"INTERACTION_NOTICE_OBSERVED"
|
|
275
|
+
]).optional()
|
|
270
276
|
}).strict();
|
|
271
277
|
const result = strictRemoteCodec(GITHUB_COPILOT_AUTHORIZATION_VIEW_TYPE_SYMBOL, GitHubCopilotAuthorizationViewSchema);
|
|
272
278
|
const GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL = "dsh-github-copilot#GitHubCopilotMigrationStatus";
|
|
@@ -61,7 +61,10 @@ export interface GitHubCopilotAuthorizationView {
|
|
|
61
61
|
readonly route?: GitHubCopilotRouteView;
|
|
62
62
|
readonly accountModels?: GitHubCopilotAccountModelsView;
|
|
63
63
|
readonly error?: string;
|
|
64
|
+
/** Latest fixed interaction milestone observed during a failed or active attempt; never a failure cause. */
|
|
65
|
+
readonly authorizationMilestone?: GitHubCopilotAuthorizationMilestone;
|
|
64
66
|
}
|
|
67
|
+
export type GitHubCopilotAuthorizationMilestone = 'AUTHORIZATION_REQUESTED' | 'INTERACTION_PROMPT_OBSERVED' | 'INTERACTION_NOTICE_OBSERVED';
|
|
65
68
|
/** Read-only legacy configuration planning; not-configured permits managed-only use and never requests creation. */
|
|
66
69
|
export declare function describeGitHubCopilotProviderProfile(ctx: Context): Promise<{
|
|
67
70
|
state: 'ready' | 'needs-repair' | 'not-configured' | 'conflict';
|
|
@@ -80,6 +83,7 @@ export declare class GitHubCopilotAuthorizationController extends TypertRemoteSe
|
|
|
80
83
|
private failure;
|
|
81
84
|
private reconciliationFailed;
|
|
82
85
|
private attempt;
|
|
86
|
+
private authorizationMilestone;
|
|
83
87
|
constructor(ctx: Context);
|
|
84
88
|
/** No-argument Ops evidence; deliberately independent of ordinary account status. */
|
|
85
89
|
migrationStatus(): GitHubCopilotMigrationStatus;
|
|
@@ -47,6 +47,7 @@ export declare const CopilotUsageViewSchema: z.ZodObject<{
|
|
|
47
47
|
COPILOT_USAGE_POOLED_EXHAUSTED: "COPILOT_USAGE_POOLED_EXHAUSTED";
|
|
48
48
|
COPILOT_USAGE_NO_ALLOCATION: "COPILOT_USAGE_NO_ALLOCATION";
|
|
49
49
|
COPILOT_USAGE_NETWORK: "COPILOT_USAGE_NETWORK";
|
|
50
|
+
COPILOT_USAGE_TLS: "COPILOT_USAGE_TLS";
|
|
50
51
|
COPILOT_USAGE_TIMEOUT: "COPILOT_USAGE_TIMEOUT";
|
|
51
52
|
COPILOT_USAGE_BODY_TOO_LARGE: "COPILOT_USAGE_BODY_TOO_LARGE";
|
|
52
53
|
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_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_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/lib/types/remote.d.ts
CHANGED
|
@@ -89,6 +89,11 @@ export declare const GitHubCopilotAuthorizationViewSchema: z.ZodObject<{
|
|
|
89
89
|
}>>;
|
|
90
90
|
}, z.core.$strict>>;
|
|
91
91
|
error: z.ZodOptional<z.ZodString>;
|
|
92
|
+
authorizationMilestone: z.ZodOptional<z.ZodEnum<{
|
|
93
|
+
AUTHORIZATION_REQUESTED: "AUTHORIZATION_REQUESTED";
|
|
94
|
+
INTERACTION_PROMPT_OBSERVED: "INTERACTION_PROMPT_OBSERVED";
|
|
95
|
+
INTERACTION_NOTICE_OBSERVED: "INTERACTION_NOTICE_OBSERVED";
|
|
96
|
+
}>>;
|
|
92
97
|
}, z.core.$strict>;
|
|
93
98
|
export declare const GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL = "dsh-github-copilot#GitHubCopilotMigrationStatus";
|
|
94
99
|
/** Independent Ops result: strict at every object level; no account or private Session data. */
|
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.46",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -166,6 +166,7 @@
|
|
|
166
166
|
"react-dom": "18.3.1",
|
|
167
167
|
"tsdown": "^0.22.2",
|
|
168
168
|
"typescript": "^5.9.0",
|
|
169
|
+
"unrun": "^0.3.1",
|
|
169
170
|
"vitest": "^3.2.0"
|
|
170
171
|
},
|
|
171
172
|
"main": "lib/index.js",
|