dsh-github-copilot 0.4.0-alpha.110 → 0.4.0-alpha.111
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 +6 -0
- package/README.md +8 -8
- package/README.zh.md +8 -8
- package/deployment-baseline.json +4 -1
- package/docs/copilot-accounts.md +16 -3
- package/lib/client.js +30 -29
- package/lib/client.js.map +1 -1
- package/lib/index.js +59 -8
- package/lib/types/copilot-accounts-host.d.ts +1 -0
- package/lib/types/session-accounts-host.d.ts +1 -0
- package/lib/types/session-accounts.d.ts +2 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2993,7 +2993,7 @@ function createAccountProvider(descriptors, guard, baseURL) {
|
|
|
2993
2993
|
var package_default = {
|
|
2994
2994
|
name: "dsh-github-copilot",
|
|
2995
2995
|
description: "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
|
|
2996
|
-
version: "0.4.0-alpha.
|
|
2996
|
+
version: "0.4.0-alpha.111",
|
|
2997
2997
|
publishConfig: {
|
|
2998
2998
|
"access": "public",
|
|
2999
2999
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -3544,8 +3544,7 @@ var CopilotAccountsHost = class {
|
|
|
3544
3544
|
};
|
|
3545
3545
|
}
|
|
3546
3546
|
cachedIdentity(accountId) {
|
|
3547
|
-
|
|
3548
|
-
return cached && Date.now() - cached.at < IDENTITY_TTL ? cached.identity : void 0;
|
|
3547
|
+
return this.identities.get(accountId)?.identity;
|
|
3549
3548
|
}
|
|
3550
3549
|
capture(accountId) {
|
|
3551
3550
|
const selected = this.selection();
|
|
@@ -3659,7 +3658,7 @@ var CopilotAccountsHost = class {
|
|
|
3659
3658
|
seen.add(accountId);
|
|
3660
3659
|
const configured = owned.find((row) => row.key === record.key)?.kind === "grant";
|
|
3661
3660
|
const cached = this.identities.get(accountId);
|
|
3662
|
-
const identity = configured
|
|
3661
|
+
const identity = configured ? cached?.identity : void 0;
|
|
3663
3662
|
rows.push({
|
|
3664
3663
|
id: accountId,
|
|
3665
3664
|
configured,
|
|
@@ -3815,7 +3814,11 @@ var CopilotAccountsHost = class {
|
|
|
3815
3814
|
}
|
|
3816
3815
|
async ensureIdentity() {
|
|
3817
3816
|
try {
|
|
3818
|
-
|
|
3817
|
+
const selected = this.selection().accountId;
|
|
3818
|
+
const view = await this.ensureAccountNamesFor(selected);
|
|
3819
|
+
if (view.state === "error") return view;
|
|
3820
|
+
if (this.selection().accountId !== selected) fail("COPILOT_ACCOUNTS_CHANGED");
|
|
3821
|
+
return view;
|
|
3819
3822
|
} catch (error) {
|
|
3820
3823
|
return {
|
|
3821
3824
|
...await this.get(),
|
|
@@ -3834,13 +3837,24 @@ var CopilotAccountsHost = class {
|
|
|
3834
3837
|
async ensureIdentityFor(accountId) {
|
|
3835
3838
|
return this.readIdentity(accountId, false);
|
|
3836
3839
|
}
|
|
3840
|
+
async ensureAccountNamesFor(accountId) {
|
|
3841
|
+
const view = await this.ensureIdentityFor(accountId);
|
|
3842
|
+
if (view.state === "error") return view;
|
|
3843
|
+
const missing = view.accounts.filter((row) => row.configured && row.id !== accountId && !this.cachedIdentity(row.id));
|
|
3844
|
+
await Promise.all(missing.map(async (row) => {
|
|
3845
|
+
const result = await this.ensureIdentityFor(row.id);
|
|
3846
|
+
if (result.state === "error") this.ctx.logger.warn("[github-copilot] %s", result.diagnostic ?? "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE");
|
|
3847
|
+
}));
|
|
3848
|
+
return this.viewForAccount(accountId);
|
|
3849
|
+
}
|
|
3837
3850
|
async readIdentity(accountId, force) {
|
|
3838
3851
|
id(accountId);
|
|
3839
3852
|
if (this.disposed) fail("COPILOT_ACCOUNTS_DISPOSED");
|
|
3840
3853
|
let flight = this.identityFlights.get(accountId);
|
|
3841
3854
|
let problem;
|
|
3842
3855
|
const failed = this.identityFailures.get(accountId);
|
|
3843
|
-
|
|
3856
|
+
const cached = this.identities.get(accountId);
|
|
3857
|
+
if (flight === void 0 && !force && cached && Date.now() - cached.at < IDENTITY_TTL) return this.viewForAccount(accountId);
|
|
3844
3858
|
if (flight === void 0 && !force && failed && Date.now() - failed.at < IDENTITY_FAILURE_COOLDOWN) problem = failed.diagnostic;
|
|
3845
3859
|
else {
|
|
3846
3860
|
if (flight === void 0) {
|
|
@@ -4839,6 +4853,7 @@ function resolveSessionAccount(sessionId, preferences, globalAccountId) {
|
|
|
4839
4853
|
var SessionAccountTurns = class {
|
|
4840
4854
|
active = /* @__PURE__ */ new Map();
|
|
4841
4855
|
signals = /* @__PURE__ */ new WeakMap();
|
|
4856
|
+
identities = /* @__PURE__ */ new WeakMap();
|
|
4842
4857
|
history = /* @__PURE__ */ new Map();
|
|
4843
4858
|
admit(agent, turn, signal, selection) {
|
|
4844
4859
|
if (!Number.isSafeInteger(turn) || turn < 0 || signal.aborted) throw new Error("COPILOT_SESSION_ACCOUNT_TURN_INVALID");
|
|
@@ -4871,10 +4886,12 @@ var SessionAccountTurns = class {
|
|
|
4871
4886
|
this.history.set(agent, turns);
|
|
4872
4887
|
if (this.history.size > 64) this.history.delete(this.history.keys().next().value);
|
|
4873
4888
|
}
|
|
4889
|
+
if (identity) this.captureIdentity(admission.signal, identity);
|
|
4890
|
+
const captured = this.identities.get(admission);
|
|
4874
4891
|
if (!turns.has(turn)) turns.set(turn, Object.freeze({
|
|
4875
4892
|
accountId: admission.accountId,
|
|
4876
4893
|
source: admission.source,
|
|
4877
|
-
...
|
|
4894
|
+
...captured ? { identity: captured } : {}
|
|
4878
4895
|
}));
|
|
4879
4896
|
if (turns.size > 128) turns.delete(turns.keys().next().value);
|
|
4880
4897
|
}
|
|
@@ -4909,6 +4926,18 @@ var SessionAccountTurns = class {
|
|
|
4909
4926
|
const entry = this.signals.get(signal);
|
|
4910
4927
|
if (entry && this.active.get(entry.agent) === entry.admission) this.record(entry.agent, entry.admission.turn, identity);
|
|
4911
4928
|
}
|
|
4929
|
+
captureIdentity(signal, identity) {
|
|
4930
|
+
const entry = this.signals.get(signal);
|
|
4931
|
+
if (!entry || signal.aborted || this.active.get(entry.agent) !== entry.admission || this.identities.has(entry.admission)) return;
|
|
4932
|
+
const captured = Object.freeze({ ...identity });
|
|
4933
|
+
this.identities.set(entry.admission, captured);
|
|
4934
|
+
const turns = this.history.get(entry.agent);
|
|
4935
|
+
const evidence = turns?.get(entry.admission.turn);
|
|
4936
|
+
if (turns && evidence && !evidence.identity) turns.set(entry.admission.turn, Object.freeze({
|
|
4937
|
+
...evidence,
|
|
4938
|
+
identity: captured
|
|
4939
|
+
}));
|
|
4940
|
+
}
|
|
4912
4941
|
};
|
|
4913
4942
|
//#endregion
|
|
4914
4943
|
//#region lib/types/session-accounts-host.js
|
|
@@ -4941,6 +4970,7 @@ var SessionAccountsHost = class {
|
|
|
4941
4970
|
try {
|
|
4942
4971
|
this.turns.admit(agent.session, turn, signal, selected);
|
|
4943
4972
|
this.leases.set(agent.session, lease);
|
|
4973
|
+
this.captureIdentity(signal, selected.accountId);
|
|
4944
4974
|
return lease.binding;
|
|
4945
4975
|
} catch (error) {
|
|
4946
4976
|
lease.release();
|
|
@@ -4968,6 +4998,27 @@ var SessionAccountsHost = class {
|
|
|
4968
4998
|
if (!accounts) throw new Error("COPILOT_SESSION_ACCOUNTS_UNAVAILABLE");
|
|
4969
4999
|
return accounts.host.captureAccount(accountId);
|
|
4970
5000
|
}
|
|
5001
|
+
captureIdentity(signal, accountId) {
|
|
5002
|
+
const accounts = this.ctx.get("githubCopilotAccounts");
|
|
5003
|
+
if (!accounts) throw new Error("COPILOT_SESSION_ACCOUNTS_UNAVAILABLE");
|
|
5004
|
+
const cached = accounts.host.cachedIdentity(accountId);
|
|
5005
|
+
if (cached) {
|
|
5006
|
+
this.turns.captureIdentity(signal, cached);
|
|
5007
|
+
return;
|
|
5008
|
+
}
|
|
5009
|
+
const admission = this.turns.forSignal(signal);
|
|
5010
|
+
accounts.host.ensureIdentityFor(accountId).then((view) => {
|
|
5011
|
+
if (this.turns.forSignal(signal) !== admission || signal.aborted) return;
|
|
5012
|
+
if (view.state === "error") {
|
|
5013
|
+
this.ctx.logger.warn("[github-copilot] %s", view.diagnostic ?? "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE");
|
|
5014
|
+
return;
|
|
5015
|
+
}
|
|
5016
|
+
const identity = accounts.host.cachedIdentity(accountId);
|
|
5017
|
+
if (identity) this.turns.captureIdentity(signal, identity);
|
|
5018
|
+
}, () => {
|
|
5019
|
+
if (this.turns.forSignal(signal) === admission && !signal.aborted) this.ctx.logger.warn("[github-copilot] COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE");
|
|
5020
|
+
});
|
|
5021
|
+
}
|
|
4971
5022
|
recordRequest(signal) {
|
|
4972
5023
|
const admission = signal === void 0 ? void 0 : this.turns.forSignal(signal);
|
|
4973
5024
|
if (admission && signal) this.turns.recordSignal(signal, this.ctx.get("githubCopilotAccounts")?.host.cachedIdentity(admission.accountId));
|
|
@@ -5193,7 +5244,7 @@ let SessionAccountController = (() => {
|
|
|
5193
5244
|
const selected = this.owner.selected(agent);
|
|
5194
5245
|
const accounts = this.ctx.get("githubCopilotAccounts");
|
|
5195
5246
|
if (!accounts) throw new Error("COPILOT_SESSION_ACCOUNTS_UNAVAILABLE");
|
|
5196
|
-
const identity = await (force ? accounts.host.refreshIdentityFor(selected.accountId) : accounts.host.
|
|
5247
|
+
const identity = await (force ? accounts.host.refreshIdentityFor(selected.accountId) : accounts.host.ensureAccountNamesFor(selected.accountId));
|
|
5197
5248
|
const latest = await this.get(agent);
|
|
5198
5249
|
if (latest.accountId !== selected.accountId || latest.source !== selected.source) throw new Error("COPILOT_ACCOUNTS_CHANGED");
|
|
5199
5250
|
return {
|
|
@@ -56,6 +56,7 @@ export declare class CopilotAccountsHost {
|
|
|
56
56
|
viewForAccount(accountId: string): Promise<CopilotAccountsView>;
|
|
57
57
|
refreshIdentityFor(accountId: string): Promise<CopilotAccountsView>;
|
|
58
58
|
ensureIdentityFor(accountId: string): Promise<CopilotAccountsView>;
|
|
59
|
+
ensureAccountNamesFor(accountId: string): Promise<CopilotAccountsView>;
|
|
59
60
|
private readIdentity;
|
|
60
61
|
private validateModels;
|
|
61
62
|
private assertIdentityCurrent;
|
|
@@ -24,6 +24,7 @@ export declare class SessionAccountsHost {
|
|
|
24
24
|
remove(session: object): void;
|
|
25
25
|
dispose(): void;
|
|
26
26
|
bindingForAccount(accountId: string): CopilotAccountBinding;
|
|
27
|
+
private captureIdentity;
|
|
27
28
|
recordRequest(signal?: AbortSignal): void;
|
|
28
29
|
requestBinding(signal?: AbortSignal): CopilotAccountBinding;
|
|
29
30
|
set(agent: SessionOwner, accountId: string | null, revision: number): Promise<void>;
|
|
@@ -21,6 +21,7 @@ export declare function resolveSessionAccount(sessionId: string, preferences: re
|
|
|
21
21
|
export declare class SessionAccountTurns {
|
|
22
22
|
private readonly active;
|
|
23
23
|
private readonly signals;
|
|
24
|
+
private readonly identities;
|
|
24
25
|
private readonly history;
|
|
25
26
|
admit(agent: object, turn: number, signal: AbortSignal, selection: SessionAccountSelection): Admission;
|
|
26
27
|
record(agent: object, turn: number, identity?: CopilotAccountIdentity): void;
|
|
@@ -31,6 +32,7 @@ export declare class SessionAccountTurns {
|
|
|
31
32
|
remove(agent: object): void;
|
|
32
33
|
clear(): void;
|
|
33
34
|
recordSignal(signal: AbortSignal, identity?: CopilotAccountIdentity): void;
|
|
35
|
+
captureIdentity(signal: AbortSignal, identity: CopilotAccountIdentity): void;
|
|
34
36
|
}
|
|
35
37
|
export {};
|
|
36
38
|
//# sourceMappingURL=session-accounts.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.111",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/",
|