dsh-github-copilot 0.4.0-alpha.103 → 0.4.0-alpha.105
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 -1
- package/CHANGELOG.md +14 -0
- package/README.md +23 -11
- package/README.zh.md +21 -10
- package/deployment-baseline.json +25 -1
- package/docs/copilot-accounts.md +66 -26
- package/docs/copilot-usage.md +5 -3
- package/lib/client.js +372 -37
- package/lib/client.js.map +1 -1
- package/lib/index.js +1039 -237
- package/lib/remote.js +75 -10
- package/lib/routed-web.js +1 -1
- package/lib/{search-routing-CqysPLve.js → search-routing-CHyF6TbO.js} +1 -1
- package/lib/types/config.d.ts +7 -2
- package/lib/types/copilot-accounts-card.d.ts +1 -0
- package/lib/types/copilot-accounts-host.d.ts +18 -2
- package/lib/types/copilot-accounts-remote.d.ts +7 -0
- package/lib/types/copilot-accounts-types.d.ts +1 -1
- package/lib/types/copilot-usage-card.d.ts +18 -1
- package/lib/types/copilot-usage-host.d.ts +3 -0
- package/lib/types/preview-route.d.ts +1 -1
- package/lib/types/replay-recovery-host.d.ts +2 -2
- package/lib/types/session-accounts-controller.d.ts +20 -0
- package/lib/types/session-accounts-host.d.ts +32 -0
- package/lib/types/session-accounts-remote.d.ts +113 -0
- package/lib/types/session-accounts.d.ts +36 -0
- package/lib/types/turn-selection-card.d.ts +5 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -5491,7 +5491,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5491
5491
|
expectedRevision: revision$1
|
|
5492
5492
|
}).strict();
|
|
5493
5493
|
const DualModelCreateResultSchema = object({ sessionId: id }).strict();
|
|
5494
|
-
const contribution$
|
|
5494
|
+
const contribution$7 = {
|
|
5495
5495
|
package: "dsh-github-copilot",
|
|
5496
5496
|
descriptors: [
|
|
5497
5497
|
{
|
|
@@ -5539,7 +5539,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5539
5539
|
supported: boolean(),
|
|
5540
5540
|
providers: array(object({ id: string().min(1).max(512) }).strict()).max(512)
|
|
5541
5541
|
}).strict();
|
|
5542
|
-
const contribution$
|
|
5542
|
+
const contribution$6 = {
|
|
5543
5543
|
package: "dsh-github-copilot",
|
|
5544
5544
|
descriptors: [{
|
|
5545
5545
|
id: "dsh-github-copilot:githubCopilotSearchRouting.providers",
|
|
@@ -5594,6 +5594,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5594
5594
|
"COPILOT_ACCOUNTS_MODELS_FAILED",
|
|
5595
5595
|
"COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE",
|
|
5596
5596
|
"COPILOT_ACCOUNTS_IDENTITY_INVALID",
|
|
5597
|
+
"COPILOT_ACCOUNTS_IDENTITY_TIMEOUT",
|
|
5598
|
+
"COPILOT_ACCOUNTS_IDENTITY_TLS",
|
|
5599
|
+
"COPILOT_ACCOUNTS_IDENTITY_NETWORK",
|
|
5600
|
+
"COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED",
|
|
5601
|
+
"COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED",
|
|
5602
|
+
"COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR",
|
|
5597
5603
|
"COPILOT_ACCOUNTS_IDENTITY_CHANGED",
|
|
5598
5604
|
"COPILOT_ACCOUNTS_DUPLICATE",
|
|
5599
5605
|
"COPILOT_ACCOUNTS_ENTERPRISE_UNSUPPORTED",
|
|
@@ -5661,7 +5667,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5661
5667
|
if (view.remaining !== void 0 && view.percentUsed !== void 0 && Math.abs((1 - view.remaining / view.limit) * 100 - view.percentUsed) > 1) invalid();
|
|
5662
5668
|
}
|
|
5663
5669
|
});
|
|
5664
|
-
const contribution$
|
|
5670
|
+
const contribution$5 = {
|
|
5665
5671
|
package: "dsh-github-copilot",
|
|
5666
5672
|
descriptors: ["get", "refresh"].map((method) => ({
|
|
5667
5673
|
id: `dsh-github-copilot:githubCopilotUsage.${method}`,
|
|
@@ -5785,7 +5791,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5785
5791
|
]);
|
|
5786
5792
|
//#endregion
|
|
5787
5793
|
//#region lib/types/turn-selection-remote.js
|
|
5788
|
-
const contribution$
|
|
5794
|
+
const contribution$4 = {
|
|
5789
5795
|
package: "dsh-github-copilot",
|
|
5790
5796
|
descriptors: [{
|
|
5791
5797
|
id: "dsh-github-copilot:githubCopilotTurnSelection.get",
|
|
@@ -5821,14 +5827,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5821
5827
|
}).strict()]);
|
|
5822
5828
|
//#endregion
|
|
5823
5829
|
//#region lib/types/replay-recovery-remote.js
|
|
5824
|
-
const agent = {
|
|
5830
|
+
const agent$1 = {
|
|
5825
5831
|
name: "agent",
|
|
5826
5832
|
wire: "agentId",
|
|
5827
5833
|
source: "lookup",
|
|
5828
5834
|
lookup: "agent",
|
|
5829
5835
|
codec: strictRemoteCodec("@deepseek-ai/dsh-session/types#SessionId", string().min(1).max(256))
|
|
5830
5836
|
};
|
|
5831
|
-
const contribution$
|
|
5837
|
+
const contribution$3 = {
|
|
5832
5838
|
package: "dsh-github-copilot",
|
|
5833
5839
|
descriptors: [
|
|
5834
5840
|
{
|
|
@@ -5837,7 +5843,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5837
5843
|
service: "githubCopilotReplayRecovery",
|
|
5838
5844
|
method: "get",
|
|
5839
5845
|
invocation: { kind: "direct" },
|
|
5840
|
-
parameters: [agent],
|
|
5846
|
+
parameters: [agent$1],
|
|
5841
5847
|
result: strictRemoteCodec("dsh-github-copilot#ReplayRecoveryView", ReplayRecoveryViewSchema)
|
|
5842
5848
|
},
|
|
5843
5849
|
{
|
|
@@ -5847,7 +5853,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5847
5853
|
method: "authorize",
|
|
5848
5854
|
invocation: { kind: "direct" },
|
|
5849
5855
|
parameters: [
|
|
5850
|
-
agent,
|
|
5856
|
+
agent$1,
|
|
5851
5857
|
{
|
|
5852
5858
|
name: "revision",
|
|
5853
5859
|
wire: "revision",
|
|
@@ -5870,7 +5876,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5870
5876
|
method: "setEnabled",
|
|
5871
5877
|
invocation: { kind: "direct" },
|
|
5872
5878
|
parameters: [
|
|
5873
|
-
agent,
|
|
5879
|
+
agent$1,
|
|
5874
5880
|
{
|
|
5875
5881
|
name: "revision",
|
|
5876
5882
|
wire: "revision",
|
|
@@ -5932,11 +5938,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5932
5938
|
if (row.identity !== void 0 && !row.configured) invalid();
|
|
5933
5939
|
}
|
|
5934
5940
|
});
|
|
5935
|
-
const contribution$
|
|
5941
|
+
const contribution$2 = {
|
|
5936
5942
|
package: "dsh-github-copilot",
|
|
5937
5943
|
descriptors: [
|
|
5938
5944
|
"get",
|
|
5939
5945
|
"refreshIdentity",
|
|
5946
|
+
"ensureIdentity",
|
|
5940
5947
|
"add",
|
|
5941
5948
|
"cancel",
|
|
5942
5949
|
"switchAccount",
|
|
@@ -5963,6 +5970,63 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5963
5970
|
}))
|
|
5964
5971
|
};
|
|
5965
5972
|
//#endregion
|
|
5973
|
+
//#region lib/types/session-accounts-remote.js
|
|
5974
|
+
const SessionAccountViewSchema = object({
|
|
5975
|
+
source: _enum(["global", "session"]),
|
|
5976
|
+
accountId: CopilotAccountIdSchema,
|
|
5977
|
+
globalAccountId: CopilotAccountIdSchema,
|
|
5978
|
+
runningAccountId: CopilotAccountIdSchema.optional(),
|
|
5979
|
+
accounts: CopilotAccountsViewSchema
|
|
5980
|
+
}).strict().refine((view) => view.accountId === view.accounts.activeAccountId, { message: "Session account identity mismatch" });
|
|
5981
|
+
const TurnAccountViewSchema = discriminatedUnion("state", [object({ state: literal("unknown") }).strict(), object({
|
|
5982
|
+
state: literal("recorded"),
|
|
5983
|
+
accountId: CopilotAccountIdSchema,
|
|
5984
|
+
source: _enum(["global", "session"]),
|
|
5985
|
+
identity: CopilotAccountsViewSchema.shape.accounts.element.shape.identity
|
|
5986
|
+
}).strict()]);
|
|
5987
|
+
const agent = {
|
|
5988
|
+
name: "agent",
|
|
5989
|
+
wire: "agentId",
|
|
5990
|
+
source: "lookup",
|
|
5991
|
+
lookup: "agent",
|
|
5992
|
+
codec: strictRemoteCodec("@deepseek-ai/dsh-session/types#SessionId", string().min(1).max(256))
|
|
5993
|
+
};
|
|
5994
|
+
const contribution$1 = {
|
|
5995
|
+
package: "dsh-github-copilot",
|
|
5996
|
+
descriptors: [
|
|
5997
|
+
"get",
|
|
5998
|
+
"set",
|
|
5999
|
+
"refreshIdentity",
|
|
6000
|
+
"ensureIdentity",
|
|
6001
|
+
"usage",
|
|
6002
|
+
"refreshUsage",
|
|
6003
|
+
"turn"
|
|
6004
|
+
].map((method) => ({
|
|
6005
|
+
id: `dsh-github-copilot:githubCopilotSessionAccount.${method}`,
|
|
6006
|
+
namespace: "githubCopilotSessionAccount",
|
|
6007
|
+
service: "githubCopilotSessionAccount",
|
|
6008
|
+
method,
|
|
6009
|
+
invocation: { kind: "direct" },
|
|
6010
|
+
parameters: [agent, ...method === "set" ? [{
|
|
6011
|
+
name: "accountId",
|
|
6012
|
+
wire: "accountId",
|
|
6013
|
+
source: "json",
|
|
6014
|
+
codec: strictRemoteCodec("dsh-github-copilot#SessionAccountChoice", CopilotAccountIdSchema.nullable())
|
|
6015
|
+
}, {
|
|
6016
|
+
name: "revision",
|
|
6017
|
+
wire: "revision",
|
|
6018
|
+
source: "json",
|
|
6019
|
+
codec: strictRemoteCodec("dsh-github-copilot#SessionAccountRevision", number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
|
|
6020
|
+
}] : method === "turn" ? [{
|
|
6021
|
+
name: "turn",
|
|
6022
|
+
wire: "turn",
|
|
6023
|
+
source: "json",
|
|
6024
|
+
codec: strictRemoteCodec("dsh-github-copilot#SessionAccountTurn", number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
|
|
6025
|
+
}] : []],
|
|
6026
|
+
result: method === "usage" || method === "refreshUsage" ? strictRemoteCodec("dsh-github-copilot#CopilotUsageView", CopilotUsageViewSchema) : method === "turn" ? strictRemoteCodec("dsh-github-copilot#TurnAccountView", TurnAccountViewSchema) : strictRemoteCodec("dsh-github-copilot#SessionAccountView", SessionAccountViewSchema)
|
|
6027
|
+
}))
|
|
6028
|
+
};
|
|
6029
|
+
//#endregion
|
|
5966
6030
|
//#region lib/types/remote.js
|
|
5967
6031
|
/**
|
|
5968
6032
|
* Client-safe Remote contribution for the plugin-owned authorization bridge.
|
|
@@ -6171,6 +6235,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6171
6235
|
parameters: [],
|
|
6172
6236
|
result: strictRemoteCodec(GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL, GitHubCopilotMigrationStatusSchema)
|
|
6173
6237
|
},
|
|
6238
|
+
...contribution$7.descriptors,
|
|
6174
6239
|
...contribution$6.descriptors,
|
|
6175
6240
|
...contribution$5.descriptors,
|
|
6176
6241
|
...contribution$4.descriptors,
|
|
@@ -6592,10 +6657,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6592
6657
|
}
|
|
6593
6658
|
//#endregion
|
|
6594
6659
|
//#region lib/types/turn-selection-card.js
|
|
6595
|
-
function TurnSelectionCard({ selection, locale = "en", incomplete = false, readState = "ready", retry }) {
|
|
6660
|
+
function TurnSelectionCard({ selection, locale = "en", incomplete = false, readState = "ready", retry, account, accountFailed = false, retryAccount }) {
|
|
6596
6661
|
const zh = locale.startsWith("zh");
|
|
6597
6662
|
const id = (0, react.useId)();
|
|
6598
6663
|
const [open, setOpen] = (0, react.useState)(false);
|
|
6664
|
+
const [accountOpen, setAccountOpen] = (0, react.useState)(false);
|
|
6599
6665
|
const [position, setPosition] = (0, react.useState)({
|
|
6600
6666
|
left: 12,
|
|
6601
6667
|
top: 12
|
|
@@ -6621,7 +6687,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6621
6687
|
window.removeEventListener("resize", place);
|
|
6622
6688
|
window.removeEventListener("scroll", place, true);
|
|
6623
6689
|
};
|
|
6624
|
-
}, [open]);
|
|
6690
|
+
}, [open, accountOpen]);
|
|
6625
6691
|
(0, react.useEffect)(() => {
|
|
6626
6692
|
if (!open) return;
|
|
6627
6693
|
const outside = (event) => {
|
|
@@ -6663,7 +6729,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6663
6729
|
maxWidth: "100%",
|
|
6664
6730
|
fontSize: "var(--dsh-content-font-size-secondary, 13px)",
|
|
6665
6731
|
color: "var(--dsw-alias-label-tertiary, GrayText)"
|
|
6666
|
-
} }, (0, react.createElement)("
|
|
6732
|
+
} }, account === void 0 && !accountFailed ? null : (0, react.createElement)("button", {
|
|
6733
|
+
ref: accountOpen ? trigger : void 0,
|
|
6734
|
+
type: "button",
|
|
6735
|
+
style: {
|
|
6736
|
+
...button,
|
|
6737
|
+
border: 0,
|
|
6738
|
+
padding: "1px 5px"
|
|
6739
|
+
},
|
|
6740
|
+
"aria-haspopup": "dialog",
|
|
6741
|
+
"aria-expanded": open && accountOpen,
|
|
6742
|
+
onClick: () => {
|
|
6743
|
+
setAccountOpen(true);
|
|
6744
|
+
setOpen(true);
|
|
6745
|
+
}
|
|
6746
|
+
}, accountFailed ? zh ? "账号记录读取失败" : "Account unavailable" : account?.state === "recorded" ? `Account · ${account.identity ? "@" + account.identity.login : account.accountId === "canonical" ? "Canonical" : account.accountId.slice(0, 8)}` : zh ? "Account · 未知" : "Account · unknown"), (0, react.createElement)("span", {
|
|
6667
6747
|
role: readState === "ready" ? void 0 : "status",
|
|
6668
6748
|
title: readState === "ready" && selection.mode === "unknown" ? zh ? "本轮选择记录未保留;不从当前选择推断历史。" : "No retained selection evidence; the current picker is not historical evidence." : void 0
|
|
6669
6749
|
}, readState === "loading" ? zh ? "正在读取选择记录…" : "Loading selection…" : readState === "failed" ? zh ? "选择记录读取失败" : "Selection unavailable" : label), readState === "failed" && retry ? (0, react.createElement)("button", {
|
|
@@ -6671,7 +6751,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6671
6751
|
style: button,
|
|
6672
6752
|
onClick: retry
|
|
6673
6753
|
}, zh ? "重试" : "Retry") : null, readState === "ready" && (selection.mode === "auto" || incomplete) ? (0, react.createElement)("button", {
|
|
6674
|
-
ref: trigger,
|
|
6754
|
+
ref: accountOpen ? void 0 : trigger,
|
|
6675
6755
|
type: "button",
|
|
6676
6756
|
style: {
|
|
6677
6757
|
...button,
|
|
@@ -6683,13 +6763,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6683
6763
|
"aria-expanded": open,
|
|
6684
6764
|
"aria-controls": open ? id : void 0,
|
|
6685
6765
|
"aria-haspopup": "dialog",
|
|
6686
|
-
onClick: () =>
|
|
6766
|
+
onClick: () => {
|
|
6767
|
+
setAccountOpen(false);
|
|
6768
|
+
setOpen((value) => !value);
|
|
6769
|
+
}
|
|
6687
6770
|
}, "ⓘ") : null, open ? (0, react.createElement)("div", {
|
|
6688
6771
|
ref: panel,
|
|
6689
6772
|
id,
|
|
6690
6773
|
popover: "manual",
|
|
6691
6774
|
role: "dialog",
|
|
6692
|
-
"aria-label": zh ? "本轮选择记录" : "Turn selection evidence",
|
|
6775
|
+
"aria-label": accountOpen ? zh ? "本轮账号" : "Turn account" : zh ? "本轮选择记录" : "Turn selection evidence",
|
|
6693
6776
|
style: {
|
|
6694
6777
|
position: "fixed",
|
|
6695
6778
|
inset: "auto",
|
|
@@ -6709,7 +6792,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6709
6792
|
color: "var(--dsw-alias-label-primary, CanvasText)",
|
|
6710
6793
|
lineHeight: 1.6
|
|
6711
6794
|
}
|
|
6712
|
-
}, (0, react.createElement)("strong", null, zh ? "
|
|
6795
|
+
}, (0, react.createElement)("strong", null, accountOpen ? zh ? "本轮账号" : "Turn account" : zh ? "为什么本轮选择这个模型" : "Why this model was selected"), accountOpen ? (0, react.createElement)("div", null, (0, react.createElement)("p", null, accountFailed ? zh ? "无法读取本轮账号记录,不等同于没有记录。" : "Could not read account evidence; this is not proof of missing evidence." : account?.state === "recorded" ? `${zh ? "账号" : "Account"}: ${account.identity ? "@" + account.identity.login : account.accountId}` : zh ? "本轮没有保留账号证据,不从当前账号选择推断历史。" : "No retained account evidence; the current account selection cannot reconstruct history."), account?.state === "recorded" ? (0, react.createElement)("p", null, account.source === "global" ? zh ? "本轮发送时跟随全局默认,账号已锁定。" : "Inherited the global default at turn admission; account was frozen." : zh ? "本轮使用 Session 指定账号,账号已锁定。" : "Used the Session override; account was frozen.") : null, (0, react.createElement)("p", null, zh ? "这是有原生流返回的请求账号记录,不是单轮费用或子 Agent 的账号汇总。仅保留在 Host 生命周期内;重启后缺失显示未知。" : "Account evidence from a native stream delivery, not turn billing or subagent attribution. Retained for the Host lifetime only; missing evidence after restart is unknown."), accountFailed && retryAccount ? (0, react.createElement)("button", {
|
|
6796
|
+
type: "button",
|
|
6797
|
+
style: button,
|
|
6798
|
+
onClick: retryAccount
|
|
6799
|
+
}, zh ? "重试" : "Retry") : null) : selection.mode === "auto" ? explanation === void 0 ? (0, react.createElement)("p", null, zh ? "本轮未保留详细选模原因;不使用当前设置反推历史。" : "Detailed selection reasons were not retained for this turn; today’s settings cannot reconstruct them.") : (0, react.createElement)("div", null, (0, react.createElement)("p", null, explanation.conclusion), (0, react.createElement)("p", null, explanation.choice), (0, react.createElement)("details", null, (0, react.createElement)("summary", null, zh ? "查看判断依据" : "Assessment details"), (0, react.createElement)("p", null, explanation.assessment), (0, react.createElement)("p", null, zh ? `${selection.candidateCount} 个合格候选;${selection.fittingCandidateCount ?? "未知"} 个可容纳估算输入。` : `${selection.candidateCount} eligible candidates; ${selection.fittingCandidateCount ?? "unknown"} fit the estimated input.`), explanation.diagnostic ? (0, react.createElement)("p", null, explanation.diagnostic) : null, explanation.semantic ? (0, react.createElement)("p", null, explanation.semantic) : null, (0, react.createElement)("p", null, zh ? "分类来自供应方;不保证实际速度、费用或任务质量。" : "Supplier categories do not guarantee actual speed, cost or task quality."))) : null, !accountOpen && incomplete ? (0, react.createElement)("p", null, zh ? "模型归属不完整:部分尝试或历史未记录模型。原生 Usage 保持不变。" : "Model attribution is incomplete: some attempts or history have no recorded model. Native Usage is unchanged.") : null, accountOpen ? null : (0, react.createElement)("p", null, zh ? "此记录说明选择方式,不证明执行;实际模型以原生 Usage 为准。" : "Selection evidence is not execution proof; see native Usage for recorded models."), (0, react.createElement)("button", {
|
|
6713
6800
|
ref: close,
|
|
6714
6801
|
type: "button",
|
|
6715
6802
|
style: button,
|
|
@@ -7128,6 +7215,38 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7128
7215
|
const [readAttempt, setReadAttempt] = react.useState(0);
|
|
7129
7216
|
const turn = record$4(props.turn) && sequence(props.turn.turn) ? props.turn.turn : void 0;
|
|
7130
7217
|
const sessionId = typeof props.sessionId === "string" ? props.sessionId : void 0;
|
|
7218
|
+
const [account, setAccount] = react.useState();
|
|
7219
|
+
const [accountFailed, setAccountFailed] = react.useState(false);
|
|
7220
|
+
const [accountAttempt, setAccountAttempt] = react.useState(0);
|
|
7221
|
+
react.useEffect(() => {
|
|
7222
|
+
setAccount(void 0);
|
|
7223
|
+
setAccountFailed(false);
|
|
7224
|
+
if (turn === void 0 || sessionId === void 0 || props.accountRemote === void 0) return;
|
|
7225
|
+
let active = true;
|
|
7226
|
+
props.accountRemote.turn(sessionId, turn).then((result) => {
|
|
7227
|
+
if (!active) return;
|
|
7228
|
+
const parsed = result.ok ? TurnAccountViewSchema.safeParse(result.value) : void 0;
|
|
7229
|
+
if (parsed?.success) setAccount(parsed.data);
|
|
7230
|
+
else {
|
|
7231
|
+
setAccountFailed(true);
|
|
7232
|
+
props.diagnostic("COPILOT_TURN_ACCOUNT_READ_FAILED");
|
|
7233
|
+
}
|
|
7234
|
+
}, () => {
|
|
7235
|
+
if (active) {
|
|
7236
|
+
setAccountFailed(true);
|
|
7237
|
+
props.diagnostic("COPILOT_TURN_ACCOUNT_READ_FAILED");
|
|
7238
|
+
}
|
|
7239
|
+
});
|
|
7240
|
+
return () => {
|
|
7241
|
+
active = false;
|
|
7242
|
+
};
|
|
7243
|
+
}, [
|
|
7244
|
+
props.accountRemote,
|
|
7245
|
+
sessionId,
|
|
7246
|
+
turn,
|
|
7247
|
+
props.diagnostic,
|
|
7248
|
+
accountAttempt
|
|
7249
|
+
]);
|
|
7131
7250
|
react.useEffect(() => {
|
|
7132
7251
|
setLive({ mode: "unknown" });
|
|
7133
7252
|
if (turn === void 0 || sessionId === void 0 || props.remote === void 0) {
|
|
@@ -7198,6 +7317,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7198
7317
|
locale: language,
|
|
7199
7318
|
incomplete: evidence?.incomplete ?? true,
|
|
7200
7319
|
readState: selection.mode === "unknown" ? readState : "ready",
|
|
7320
|
+
account,
|
|
7321
|
+
accountFailed,
|
|
7322
|
+
retryAccount: () => setAccountAttempt((value) => value + 1),
|
|
7201
7323
|
retry: props.remote === void 0 ? void 0 : () => setReadAttempt((value) => value + 1)
|
|
7202
7324
|
}), usageDiagnostic === void 0 ? null : react.createElement(TurnUsageNotice, {
|
|
7203
7325
|
diagnostic: usageDiagnostic,
|
|
@@ -7253,6 +7375,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7253
7375
|
const slots = slotsCandidate;
|
|
7254
7376
|
const face = record$4(capabilities.remote) ? capabilities.remote.githubCopilotTurnSelection : void 0;
|
|
7255
7377
|
const remote = record$4(face) && typeof face.get === "function" ? face : void 0;
|
|
7378
|
+
const accountFace = record$4(capabilities.remote) ? capabilities.remote.githubCopilotSessionAccount : void 0;
|
|
7379
|
+
const readAccount = record$4(accountFace) ? accountFace.turn : void 0;
|
|
7380
|
+
const accountRemote = typeof readAccount === "function" ? { turn: (agentId, turn) => readAccount(agentId, turn) } : void 0;
|
|
7256
7381
|
const locale = record$4(capabilities.locale) && typeof capabilities.locale.getLocale === "function" && typeof capabilities.locale.subscribe === "function" ? capabilities.locale : void 0;
|
|
7257
7382
|
if (!remote) diagnostic("COPILOT_TURN_SELECTION_REMOTE_UNAVAILABLE");
|
|
7258
7383
|
function Entry(props) {
|
|
@@ -7270,6 +7395,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7270
7395
|
turn,
|
|
7271
7396
|
tail,
|
|
7272
7397
|
remote,
|
|
7398
|
+
accountRemote,
|
|
7273
7399
|
locale,
|
|
7274
7400
|
diagnostic
|
|
7275
7401
|
});
|
|
@@ -8362,7 +8488,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8362
8488
|
setConfirmation(void 0);
|
|
8363
8489
|
setBusy(false);
|
|
8364
8490
|
setFailed(false);
|
|
8365
|
-
if (props.remote !== void 0 && !props.authorizationBusy) run(() => props.remote.
|
|
8491
|
+
if (props.remote !== void 0 && !props.authorizationBusy) run(() => props.remote.ensureIdentity());
|
|
8366
8492
|
return () => {
|
|
8367
8493
|
owner.active = false;
|
|
8368
8494
|
owner.generation++;
|
|
@@ -8374,6 +8500,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8374
8500
|
props.authorizationBusy,
|
|
8375
8501
|
props.configured
|
|
8376
8502
|
]);
|
|
8503
|
+
(0, react.useEffect)(() => {
|
|
8504
|
+
if (props.remote === void 0 || props.authorizationBusy || view?.operation !== void 0) return;
|
|
8505
|
+
const ensure = () => {
|
|
8506
|
+
if (document.visibilityState !== "hidden") run(() => props.remote.ensureIdentity());
|
|
8507
|
+
};
|
|
8508
|
+
const timer = window.setInterval(ensure, 6e4);
|
|
8509
|
+
document.addEventListener("visibilitychange", ensure);
|
|
8510
|
+
return () => {
|
|
8511
|
+
window.clearInterval(timer);
|
|
8512
|
+
document.removeEventListener("visibilitychange", ensure);
|
|
8513
|
+
};
|
|
8514
|
+
}, [
|
|
8515
|
+
props.remote,
|
|
8516
|
+
props.authorizationBusy,
|
|
8517
|
+
view?.operation,
|
|
8518
|
+
run
|
|
8519
|
+
]);
|
|
8377
8520
|
(0, react.useEffect)(() => {
|
|
8378
8521
|
if (view?.operation !== "authorizing" || props.remote === void 0) return;
|
|
8379
8522
|
const timer = window.setTimeout(() => {
|
|
@@ -8414,7 +8557,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8414
8557
|
display: "grid",
|
|
8415
8558
|
gap: 10,
|
|
8416
8559
|
marginBlock: 12
|
|
8417
|
-
} }, (0, react.createElement)("strong", null, "GitHub accounts"), (0, react.createElement)("p", { style: muted$1 }, "
|
|
8560
|
+
} }, (0, react.createElement)("strong", null, "GitHub accounts"), (0, react.createElement)("p", { style: muted$1 }, "Global default for new inherited turns. Credits can override this Session’s subsequent turns. Running turns, explicit Session accounts, models and conversation history stay unchanged."), props.remote === void 0 ? (0, react.createElement)("p", {
|
|
8418
8561
|
role: "status",
|
|
8419
8562
|
style: muted$1
|
|
8420
8563
|
}, "COPILOT_ACCOUNTS_REMOTE_UNAVAILABLE · Account management is unavailable in this deployment.") : null, failed ? (0, react.createElement)("p", {
|
|
@@ -8423,7 +8566,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8423
8566
|
}, "Could not read account information. Retry before changing accounts.") : null, view?.diagnostic === void 0 ? null : (0, react.createElement)("p", {
|
|
8424
8567
|
role: "status",
|
|
8425
8568
|
style: muted$1
|
|
8426
|
-
}, view.diagnostic), view?.switchable === false ? (0, react.createElement)("p", { style: muted$1 }, "Switching is unavailable
|
|
8569
|
+
}, view.diagnostic), view?.switchable === false ? (0, react.createElement)("p", { style: muted$1 }, "Switching is unavailable during account management or unbound preparation, while native Copilot routes remain configured, or when route evidence is incomplete. Account-pinned managed turns can continue. No running work will be cancelled.") : null, (0, react.createElement)("ul", { style: {
|
|
8427
8570
|
padding: 0,
|
|
8428
8571
|
margin: 0,
|
|
8429
8572
|
listStyle: "none"
|
|
@@ -8532,7 +8675,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8532
8675
|
manual: "If the browser does not open, copy this address:",
|
|
8533
8676
|
rounding: "Amounts rounded for display. GitHub billing is authoritative.",
|
|
8534
8677
|
low: "Low remaining budget",
|
|
8535
|
-
missing: "COPILOT_USAGE_REMOTE_UNAVAILABLE · Account usage is unavailable in this deployment."
|
|
8678
|
+
missing: "COPILOT_USAGE_REMOTE_UNAVAILABLE · Account usage is unavailable in this deployment.",
|
|
8679
|
+
switchAccount: "Switch account",
|
|
8680
|
+
followGlobal: "Follow global default",
|
|
8681
|
+
sessionSpecified: "Session override",
|
|
8682
|
+
switchScope: "Applies to this Session’s subsequent turns. Running turns and other Sessions are unchanged.",
|
|
8683
|
+
accountSaveFailed: "Could not save the Session account. Refresh and try again.",
|
|
8684
|
+
accountLoading: "Loading account selection…",
|
|
8685
|
+
accountMissing: "Account selection unavailable. Refresh to retry.",
|
|
8686
|
+
runningAccount: "Running turn remains on",
|
|
8687
|
+
identityUnknown: "Identity unavailable"
|
|
8536
8688
|
},
|
|
8537
8689
|
zh: {
|
|
8538
8690
|
credits: "额度",
|
|
@@ -8566,7 +8718,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8566
8718
|
manual: "若浏览器未打开,请复制此地址:",
|
|
8567
8719
|
rounding: "显示数值经过四舍五入,账单以 GitHub 为准。",
|
|
8568
8720
|
low: "剩余额度较低",
|
|
8569
|
-
missing: "COPILOT_USAGE_REMOTE_UNAVAILABLE · 当前部署无法提供账号用量。"
|
|
8721
|
+
missing: "COPILOT_USAGE_REMOTE_UNAVAILABLE · 当前部署无法提供账号用量。",
|
|
8722
|
+
switchAccount: "切换账号",
|
|
8723
|
+
followGlobal: "跟随全局默认",
|
|
8724
|
+
sessionSpecified: "Session 已指定",
|
|
8725
|
+
switchScope: "用于本 Session 后续 turn,不影响正在运行的 turn 或其他 Session。",
|
|
8726
|
+
accountSaveFailed: "无法保存 Session 账号,请刷新后重试。",
|
|
8727
|
+
accountLoading: "正在读取账号选择…",
|
|
8728
|
+
accountMissing: "账号选择暂不可用,请刷新重试。",
|
|
8729
|
+
runningAccount: "正在运行的 turn 仍使用",
|
|
8730
|
+
identityUnknown: "身份暂不可用"
|
|
8570
8731
|
}
|
|
8571
8732
|
};
|
|
8572
8733
|
const secondary = "var(--dsw-alias-label-secondary, GrayText)";
|
|
@@ -8612,6 +8773,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8612
8773
|
const id = (0, react.useId)();
|
|
8613
8774
|
const [view, setView] = (0, react.useState)();
|
|
8614
8775
|
const [accounts, setAccounts] = (0, react.useState)();
|
|
8776
|
+
const [sessionAccount, setSessionAccount] = (0, react.useState)();
|
|
8777
|
+
const [choosingAccount, setChoosingAccount] = (0, react.useState)(false);
|
|
8778
|
+
const [savingAccount, setSavingAccount] = (0, react.useState)(false);
|
|
8779
|
+
const [accountFailed, setAccountFailed] = (0, react.useState)(false);
|
|
8780
|
+
const [accountSaveFailed, setAccountSaveFailed] = (0, react.useState)(false);
|
|
8615
8781
|
const [busy, setBusy] = (0, react.useState)(false);
|
|
8616
8782
|
const [failed, setFailed] = (0, react.useState)(false);
|
|
8617
8783
|
const [open, setOpen] = (0, react.useState)(false);
|
|
@@ -8627,35 +8793,55 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8627
8793
|
generation: 0,
|
|
8628
8794
|
busy: false
|
|
8629
8795
|
});
|
|
8630
|
-
const identityRead = (0, react.useRef)(false);
|
|
8631
8796
|
const close = (0, react.useCallback)((restore = false) => {
|
|
8632
8797
|
setOpen(false);
|
|
8633
8798
|
if (restore) trigger.current?.focus();
|
|
8634
8799
|
}, []);
|
|
8635
8800
|
const load = (0, react.useCallback)(async (force) => {
|
|
8636
8801
|
const owner = lifecycle.current;
|
|
8637
|
-
if (!owner.active || owner.busy || accountPresentationChanges.pending() || props.remote === void 0 || document.visibilityState === "hidden") return;
|
|
8802
|
+
if (!owner.active || owner.busy || owner.save !== void 0 || accountPresentationChanges.pending() || props.remote === void 0 || document.visibilityState === "hidden") return;
|
|
8638
8803
|
owner.busy = true;
|
|
8639
8804
|
const generation = ++owner.generation;
|
|
8640
8805
|
const current = () => owner.active && owner.generation === generation;
|
|
8641
8806
|
setBusy(true);
|
|
8642
8807
|
setFailed(false);
|
|
8643
8808
|
try {
|
|
8644
|
-
const identityOperation = props.accountsRemote === void 0 ? void 0 : force
|
|
8645
|
-
|
|
8646
|
-
|
|
8809
|
+
const identityOperation = props.accountsRemote === void 0 ? void 0 : (force ? props.accountsRemote.refreshIdentity() : props.accountsRemote.ensureIdentity()).catch(() => void 0);
|
|
8810
|
+
const [result, identityResult, sessionResult] = await Promise.all([
|
|
8811
|
+
force ? props.remote.refresh() : props.remote.get(),
|
|
8812
|
+
props.accountsRemote?.get().catch(() => void 0),
|
|
8813
|
+
props.sessionAccount?.get()
|
|
8814
|
+
]);
|
|
8647
8815
|
if (!current()) return;
|
|
8816
|
+
const sessionView = sessionResult?.ok ? SessionAccountViewSchema.safeParse(sessionResult.value) : void 0;
|
|
8817
|
+
setSessionAccount(sessionView?.success ? sessionView.data : void 0);
|
|
8818
|
+
setAccountFailed(props.sessionAccount !== void 0 && sessionView?.success !== true);
|
|
8648
8819
|
const identityView = identityResult?.ok === true ? accountsViewFrom(identityResult.value) : void 0;
|
|
8649
8820
|
setAccounts(identityView);
|
|
8650
8821
|
const parsed = result.ok ? CopilotUsageViewSchema.safeParse(result.value) : void 0;
|
|
8651
|
-
if (parsed?.success !== true || props.accountsRemote !== void 0 && (identityView === void 0 || parsed.data.accountId !== identityView.activeAccountId)) {
|
|
8822
|
+
if (parsed?.success !== true || props.accountsRemote !== void 0 && (identityView === void 0 || parsed.data.accountId !== identityView.activeAccountId) || props.sessionAccount !== void 0 && (sessionView?.success !== true || parsed.data.accountId !== sessionView.data.accountId)) {
|
|
8652
8823
|
setView(void 0);
|
|
8653
8824
|
setFailed(true);
|
|
8654
8825
|
} else setView(parsed.data);
|
|
8826
|
+
owner.busy = false;
|
|
8827
|
+
setBusy(false);
|
|
8828
|
+
const renewed = await identityOperation;
|
|
8829
|
+
if (!current()) return;
|
|
8830
|
+
const renewedView = renewed?.ok === true ? accountsViewFrom(renewed.value) : void 0;
|
|
8831
|
+
if (renewedView !== void 0 && renewedView.activeAccountId === identityView?.activeAccountId) setAccounts(renewedView);
|
|
8832
|
+
else if (props.accountsRemote !== void 0) {
|
|
8833
|
+
setAccounts(void 0);
|
|
8834
|
+
if (renewedView !== void 0) {
|
|
8835
|
+
setView(void 0);
|
|
8836
|
+
setFailed(true);
|
|
8837
|
+
}
|
|
8838
|
+
}
|
|
8655
8839
|
} catch {
|
|
8656
8840
|
if (current()) {
|
|
8657
8841
|
setView(void 0);
|
|
8658
8842
|
setAccounts(void 0);
|
|
8843
|
+
setSessionAccount(void 0);
|
|
8844
|
+
setAccountFailed(props.sessionAccount !== void 0);
|
|
8659
8845
|
setFailed(true);
|
|
8660
8846
|
}
|
|
8661
8847
|
} finally {
|
|
@@ -8667,14 +8853,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8667
8853
|
}, [
|
|
8668
8854
|
props.remote,
|
|
8669
8855
|
props.accountsRemote,
|
|
8670
|
-
props.contextKey
|
|
8856
|
+
props.contextKey,
|
|
8857
|
+
props.sessionAccount
|
|
8671
8858
|
]);
|
|
8672
8859
|
(0, react.useEffect)(() => {
|
|
8673
8860
|
const owner = lifecycle.current;
|
|
8674
8861
|
owner.active = true;
|
|
8675
8862
|
setView(void 0);
|
|
8676
8863
|
setAccounts(void 0);
|
|
8677
|
-
|
|
8864
|
+
setSessionAccount(void 0);
|
|
8865
|
+
setChoosingAccount(false);
|
|
8866
|
+
setSavingAccount(false);
|
|
8867
|
+
setAccountFailed(false);
|
|
8868
|
+
setAccountSaveFailed(false);
|
|
8678
8869
|
setFailed(false);
|
|
8679
8870
|
setBusy(false);
|
|
8680
8871
|
setOpen(false);
|
|
@@ -8689,7 +8880,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8689
8880
|
const unsubscribe = accountPresentationChanges.subscribe(() => {
|
|
8690
8881
|
owner.generation++;
|
|
8691
8882
|
owner.busy = false;
|
|
8883
|
+
owner.save = void 0;
|
|
8884
|
+
setSavingAccount(false);
|
|
8692
8885
|
setAccounts(void 0);
|
|
8886
|
+
setSessionAccount(void 0);
|
|
8693
8887
|
setView(void 0);
|
|
8694
8888
|
setBusy(false);
|
|
8695
8889
|
setFailed(false);
|
|
@@ -8704,6 +8898,49 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8704
8898
|
unsubscribe();
|
|
8705
8899
|
};
|
|
8706
8900
|
}, [load, props.remote]);
|
|
8901
|
+
const chooseAccount = async (accountId) => {
|
|
8902
|
+
const owner = lifecycle.current;
|
|
8903
|
+
const revision = sessionAccount?.accounts.revision;
|
|
8904
|
+
if (!owner.active || owner.save !== void 0 || props.sessionAccount === void 0 || revision === void 0) return;
|
|
8905
|
+
const save = Symbol();
|
|
8906
|
+
owner.save = save;
|
|
8907
|
+
const generation = ++owner.generation;
|
|
8908
|
+
owner.busy = false;
|
|
8909
|
+
setBusy(false);
|
|
8910
|
+
setSavingAccount(true);
|
|
8911
|
+
setAccountSaveFailed(false);
|
|
8912
|
+
try {
|
|
8913
|
+
const result = await props.sessionAccount.set(accountId, revision);
|
|
8914
|
+
if (!owner.active || owner.generation !== generation) return;
|
|
8915
|
+
const parsed = result.ok ? SessionAccountViewSchema.safeParse(result.value) : void 0;
|
|
8916
|
+
if (!parsed?.success) {
|
|
8917
|
+
setAccountSaveFailed(true);
|
|
8918
|
+
setView(void 0);
|
|
8919
|
+
setAccounts(void 0);
|
|
8920
|
+
setSessionAccount(void 0);
|
|
8921
|
+
return;
|
|
8922
|
+
}
|
|
8923
|
+
setSessionAccount(parsed.data);
|
|
8924
|
+
setAccounts(parsed.data.accounts);
|
|
8925
|
+
setView(void 0);
|
|
8926
|
+
setChoosingAccount(false);
|
|
8927
|
+
owner.save = void 0;
|
|
8928
|
+
setSavingAccount(false);
|
|
8929
|
+
await load(false);
|
|
8930
|
+
} catch {
|
|
8931
|
+
if (owner.active && owner.generation === generation) {
|
|
8932
|
+
setAccountSaveFailed(true);
|
|
8933
|
+
setView(void 0);
|
|
8934
|
+
setAccounts(void 0);
|
|
8935
|
+
setSessionAccount(void 0);
|
|
8936
|
+
}
|
|
8937
|
+
} finally {
|
|
8938
|
+
if (owner.active && owner.save === save) {
|
|
8939
|
+
owner.save = void 0;
|
|
8940
|
+
setSavingAccount(false);
|
|
8941
|
+
}
|
|
8942
|
+
}
|
|
8943
|
+
};
|
|
8707
8944
|
(0, react.useLayoutEffect)(() => {
|
|
8708
8945
|
if (!open) return;
|
|
8709
8946
|
panel.current?.showPopover?.();
|
|
@@ -8774,6 +9011,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8774
9011
|
].filter(Boolean).join(" · ")}${used === void 0 && remaining === void 0 ? ` · ${busy ? t.loading : t.unavailable}` : ""}`;
|
|
8775
9012
|
const observed = available ? dateLabel(view.observedAt, language) : void 0;
|
|
8776
9013
|
const reset = available && view.resetAt !== void 0 && view.observedAt !== void 0 && view.resetAt > view.observedAt ? dateLabel(view.resetAt, language) : void 0;
|
|
9014
|
+
const runningIdentity = sessionAccount?.accounts.accounts.find((account) => account.id === sessionAccount.runningAccountId)?.identity;
|
|
8777
9015
|
return (0, react.createElement)("span", { style: {
|
|
8778
9016
|
display: "inline-flex",
|
|
8779
9017
|
minWidth: 0,
|
|
@@ -8843,7 +9081,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8843
9081
|
color: "inherit"
|
|
8844
9082
|
},
|
|
8845
9083
|
"data-copilot-credits-account": ""
|
|
8846
|
-
}, accountIdentityLabel(accounts) ?? t.identityUnavailable), (0, react.createElement)("p", {
|
|
9084
|
+
}, accountIdentityLabel(accounts) ?? t.identityUnavailable), props.sessionAccount === void 0 ? null : (0, react.createElement)("p", {
|
|
9085
|
+
style: muted,
|
|
9086
|
+
"data-copilot-account-source": ""
|
|
9087
|
+
}, sessionAccount === void 0 ? busy ? t.accountLoading : t.accountMissing : sessionAccount.source === "global" ? t.followGlobal : t.sessionSpecified), (0, react.createElement)("p", {
|
|
8847
9088
|
id: `${id}-scope`,
|
|
8848
9089
|
style: muted
|
|
8849
9090
|
}, t.account)), (0, react.createElement)("button", {
|
|
@@ -8854,7 +9095,50 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8854
9095
|
onClick: () => {
|
|
8855
9096
|
close(true);
|
|
8856
9097
|
}
|
|
8857
|
-
}, "×")),
|
|
9098
|
+
}, "×")), props.sessionAccount === void 0 ? null : (0, react.createElement)("div", { style: separator }, (0, react.createElement)("div", { style: row }, (0, react.createElement)("p", { style: muted }, t.switchScope), (0, react.createElement)("button", {
|
|
9099
|
+
type: "button",
|
|
9100
|
+
style: {
|
|
9101
|
+
...button,
|
|
9102
|
+
flexShrink: 0
|
|
9103
|
+
},
|
|
9104
|
+
disabled: sessionAccount === void 0 || sessionAccount.accounts.revision === void 0 || busy || savingAccount,
|
|
9105
|
+
"aria-expanded": choosingAccount,
|
|
9106
|
+
onClick: () => setChoosingAccount((value) => !value)
|
|
9107
|
+
}, t.switchAccount)), sessionAccount?.runningAccountId === void 0 ? null : (0, react.createElement)("p", { style: muted }, `${t.runningAccount}: ${runningIdentity ? "@" + runningIdentity.login : t.identityUnknown}`), choosingAccount && sessionAccount ? (0, react.createElement)("div", {
|
|
9108
|
+
role: "group",
|
|
9109
|
+
"aria-label": t.switchAccount,
|
|
9110
|
+
style: {
|
|
9111
|
+
display: "grid",
|
|
9112
|
+
gap: 6,
|
|
9113
|
+
marginTop: 10
|
|
9114
|
+
}
|
|
9115
|
+
}, (0, react.createElement)("button", {
|
|
9116
|
+
type: "button",
|
|
9117
|
+
style: {
|
|
9118
|
+
...button,
|
|
9119
|
+
textAlign: "left"
|
|
9120
|
+
},
|
|
9121
|
+
disabled: savingAccount,
|
|
9122
|
+
"aria-pressed": sessionAccount.source === "global",
|
|
9123
|
+
onClick: () => {
|
|
9124
|
+
chooseAccount(null);
|
|
9125
|
+
}
|
|
9126
|
+
}, t.followGlobal), ...sessionAccount.accounts.accounts.filter((account) => account.configured).map((account) => (0, react.createElement)("button", {
|
|
9127
|
+
key: account.id,
|
|
9128
|
+
type: "button",
|
|
9129
|
+
style: {
|
|
9130
|
+
...button,
|
|
9131
|
+
textAlign: "left"
|
|
9132
|
+
},
|
|
9133
|
+
disabled: savingAccount,
|
|
9134
|
+
"aria-pressed": sessionAccount.source === "session" && sessionAccount.accountId === account.id,
|
|
9135
|
+
onClick: () => {
|
|
9136
|
+
chooseAccount(account.id);
|
|
9137
|
+
}
|
|
9138
|
+
}, account.identity ? `@${account.identity.login}` : `${t.identityUnknown} · ${account.id === "canonical" ? "Canonical" : account.id.slice(0, 8)}`))) : null, sessionAccount?.accounts.diagnostic === void 0 ? null : (0, react.createElement)("code", { style: muted }, sessionAccount.accounts.diagnostic), accountFailed || accountSaveFailed ? (0, react.createElement)("p", {
|
|
9139
|
+
role: "alert",
|
|
9140
|
+
style: muted
|
|
9141
|
+
}, accountSaveFailed ? t.accountSaveFailed : t.accountMissing) : null), view?.state === "stale" ? (0, react.createElement)("p", {
|
|
8858
9142
|
role: "status",
|
|
8859
9143
|
style: muted
|
|
8860
9144
|
}, t.stale) : null, view?.diagnostic === void 0 ? null : (0, react.createElement)("code", { style: muted }, view.diagnostic), props.remote === void 0 ? (0, react.createElement)("p", {
|
|
@@ -8936,6 +9220,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8936
9220
|
function isRemote(value) {
|
|
8937
9221
|
return record$2(value) && typeof value.get === "function" && typeof value.refresh === "function";
|
|
8938
9222
|
}
|
|
9223
|
+
function isSessionRemote(value) {
|
|
9224
|
+
return record$2(value) && typeof value.get === "function" && typeof value.set === "function" && typeof value.refreshIdentity === "function" && typeof value.ensureIdentity === "function" && typeof value.usage === "function" && typeof value.refreshUsage === "function";
|
|
9225
|
+
}
|
|
8939
9226
|
function isLocale$2(value) {
|
|
8940
9227
|
return record$2(value) && typeof value.getLocale === "function" && typeof value.subscribe === "function";
|
|
8941
9228
|
}
|
|
@@ -8956,11 +9243,48 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8956
9243
|
if (!selection(next)) return void 0;
|
|
8957
9244
|
return next.provider === "github-copilot" || next.provider === "github-copilot-preview" ? next : void 0;
|
|
8958
9245
|
}
|
|
8959
|
-
function Surface$2({ runtime, remote, accountsRemote, locale, diagnostic }) {
|
|
9246
|
+
function Surface$2({ runtime, remote, accountsRemote, sessionRemote, locale, diagnostic }) {
|
|
8960
9247
|
const valid = runtime.useSession((session) => record$2(session) && session.sessionId === runtime.sessionId && session.removed === false && session.openState === "open");
|
|
8961
9248
|
const projection = runtime.useProjection("modelSelection");
|
|
8962
9249
|
const language = (0, react.useSyncExternalStore)(locale === void 0 ? emptySubscribe : (listener) => locale.subscribe(listener), () => locale?.getLocale().active ?? "en", () => "en");
|
|
8963
9250
|
const current = effectiveCopilot(projection);
|
|
9251
|
+
const bound = (0, react.useMemo)(() => {
|
|
9252
|
+
if (sessionRemote === void 0) return void 0;
|
|
9253
|
+
const id = runtime.sessionId;
|
|
9254
|
+
return {
|
|
9255
|
+
usage: {
|
|
9256
|
+
get: () => sessionRemote.usage(id),
|
|
9257
|
+
refresh: () => sessionRemote.refreshUsage(id)
|
|
9258
|
+
},
|
|
9259
|
+
identity: {
|
|
9260
|
+
get: async () => {
|
|
9261
|
+
const result = await sessionRemote.get(id);
|
|
9262
|
+
return result.ok ? {
|
|
9263
|
+
ok: true,
|
|
9264
|
+
value: result.value.accounts
|
|
9265
|
+
} : result;
|
|
9266
|
+
},
|
|
9267
|
+
refreshIdentity: async () => {
|
|
9268
|
+
const result = await sessionRemote.refreshIdentity(id);
|
|
9269
|
+
return result.ok ? {
|
|
9270
|
+
ok: true,
|
|
9271
|
+
value: result.value.accounts
|
|
9272
|
+
} : result;
|
|
9273
|
+
},
|
|
9274
|
+
ensureIdentity: async () => {
|
|
9275
|
+
const result = await sessionRemote.ensureIdentity(id);
|
|
9276
|
+
return result.ok ? {
|
|
9277
|
+
ok: true,
|
|
9278
|
+
value: result.value.accounts
|
|
9279
|
+
} : result;
|
|
9280
|
+
}
|
|
9281
|
+
},
|
|
9282
|
+
account: {
|
|
9283
|
+
get: () => sessionRemote.get(id),
|
|
9284
|
+
set: (account, revision) => sessionRemote.set(id, account, revision)
|
|
9285
|
+
}
|
|
9286
|
+
};
|
|
9287
|
+
}, [sessionRemote, runtime.sessionId]);
|
|
8964
9288
|
(0, react.useEffect)(() => {
|
|
8965
9289
|
if (projection === void 0) diagnostic("COPILOT_USAGE_MODEL_PROJECTION_UNAVAILABLE");
|
|
8966
9290
|
}, [projection, diagnostic]);
|
|
@@ -8973,8 +9297,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8973
9297
|
return (0, react.createElement)(CopilotUsageCard, {
|
|
8974
9298
|
key: contextKey,
|
|
8975
9299
|
contextKey,
|
|
8976
|
-
remote,
|
|
8977
|
-
accountsRemote,
|
|
9300
|
+
remote: current.provider === "github-copilot-preview" ? bound?.usage : remote,
|
|
9301
|
+
accountsRemote: current.provider === "github-copilot-preview" ? bound?.identity : accountsRemote,
|
|
9302
|
+
sessionAccount: current.provider === "github-copilot-preview" ? bound?.account : void 0,
|
|
8978
9303
|
locale: language
|
|
8979
9304
|
});
|
|
8980
9305
|
}
|
|
@@ -8995,14 +9320,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8995
9320
|
const slots = candidate;
|
|
8996
9321
|
let remote;
|
|
8997
9322
|
let accountsRemote;
|
|
9323
|
+
let sessionRemote;
|
|
8998
9324
|
try {
|
|
8999
9325
|
const namespaces = ctx.remote;
|
|
9000
9326
|
const face = record$2(namespaces) ? namespaces.githubCopilotUsage : void 0;
|
|
9001
9327
|
if (isRemote(face)) remote = face;
|
|
9002
9328
|
else diagnostic("COPILOT_USAGE_REMOTE_UNAVAILABLE");
|
|
9003
9329
|
const accounts = record$2(namespaces) ? namespaces.githubCopilotAccounts : void 0;
|
|
9004
|
-
if (record$2(accounts) && typeof accounts.get === "function" && typeof accounts.refreshIdentity === "function") accountsRemote = accounts;
|
|
9330
|
+
if (record$2(accounts) && typeof accounts.get === "function" && typeof accounts.refreshIdentity === "function" && typeof accounts.ensureIdentity === "function") accountsRemote = accounts;
|
|
9005
9331
|
else diagnostic("COPILOT_ACCOUNTS_REMOTE_UNAVAILABLE");
|
|
9332
|
+
const session = record$2(namespaces) ? namespaces.githubCopilotSessionAccount : void 0;
|
|
9333
|
+
if (isSessionRemote(session)) sessionRemote = session;
|
|
9334
|
+
else diagnostic("COPILOT_SESSION_ACCOUNTS_REMOTE_UNAVAILABLE");
|
|
9006
9335
|
} catch {
|
|
9007
9336
|
diagnostic("COPILOT_USAGE_REMOTE_UNAVAILABLE");
|
|
9008
9337
|
}
|
|
@@ -9034,6 +9363,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
9034
9363
|
runtime: props,
|
|
9035
9364
|
remote,
|
|
9036
9365
|
accountsRemote,
|
|
9366
|
+
sessionRemote,
|
|
9037
9367
|
locale,
|
|
9038
9368
|
diagnostic
|
|
9039
9369
|
});
|
|
@@ -10753,11 +11083,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
10753
11083
|
const usageUi = ctx.inject([
|
|
10754
11084
|
"remote.githubCopilotUsage",
|
|
10755
11085
|
"remote.githubCopilotAccounts",
|
|
11086
|
+
"remote.githubCopilotSessionAccount",
|
|
10756
11087
|
"slots"
|
|
10757
11088
|
], registerCopilotUsageUi);
|
|
10758
11089
|
const contextUi = ctx.inject(["slots"], registerContextEvidenceUi);
|
|
10759
11090
|
const recoveryUi = ctx.inject(["remote.githubCopilotReplayRecovery", "slots"], registerReplayRecoveryUi);
|
|
10760
|
-
const autoUi = ctx.inject([
|
|
11091
|
+
const autoUi = ctx.inject([
|
|
11092
|
+
"remote.githubCopilotTurnSelection",
|
|
11093
|
+
"remote.githubCopilotSessionAccount",
|
|
11094
|
+
"slots"
|
|
11095
|
+
], (scope) => installAutoModelPresentation({
|
|
10761
11096
|
slots: scope.slots,
|
|
10762
11097
|
remote: scope.remote,
|
|
10763
11098
|
locale: scope.get("locale"),
|