dsh-github-copilot 0.4.0-alpha.105 → 0.4.0-alpha.107

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/client.js CHANGED
@@ -5790,6 +5790,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5790
5790
  }).strict()
5791
5791
  ]);
5792
5792
  //#endregion
5793
+ //#region lib/types/turn-request-models.js
5794
+ const count$2 = number().int().min(0).max(Number.MAX_SAFE_INTEGER);
5795
+ const RequestedModelsSchema = object({
5796
+ routes: array(object({
5797
+ provider: string().trim().min(1).max(1024),
5798
+ model: string().trim().min(1).max(1024)
5799
+ }).strict()).max(32),
5800
+ incomplete: boolean()
5801
+ }).strict();
5802
+ const row$1 = RequestedModelsSchema.extend({ turn: count$2 }).strict();
5803
+ object({
5804
+ active: object({
5805
+ turn: count$2,
5806
+ step: count$2.nullable()
5807
+ }).strict().nullable(),
5808
+ turns: array(row$1).max(128)
5809
+ }).strict();
5810
+ //#endregion
5793
5811
  //#region lib/types/turn-selection-remote.js
5794
5812
  const contribution$4 = {
5795
5813
  package: "dsh-github-copilot",
@@ -5812,6 +5830,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5812
5830
  codec: strictRemoteCodec("dsh-github-copilot#TurnSelectionTurn", number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
5813
5831
  }],
5814
5832
  result: strictRemoteCodec("dsh-github-copilot#TurnSelection", TurnSelectionSchema)
5833
+ }, {
5834
+ id: "dsh-github-copilot:githubCopilotTurnSelection.requestedModels",
5835
+ namespace: "githubCopilotTurnSelection",
5836
+ service: "githubCopilotTurnSelection",
5837
+ method: "requestedModels",
5838
+ invocation: { kind: "direct" },
5839
+ parameters: [{
5840
+ name: "agent",
5841
+ wire: "agentId",
5842
+ source: "lookup",
5843
+ lookup: "agent",
5844
+ codec: strictRemoteCodec("@deepseek-ai/dsh-session/types#SessionId", string().min(1).max(256))
5845
+ }, {
5846
+ name: "turn",
5847
+ wire: "turn",
5848
+ source: "json",
5849
+ codec: strictRemoteCodec("dsh-github-copilot#TurnSelectionTurn", number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
5850
+ }],
5851
+ result: strictRemoteCodec("dsh-github-copilot#RequestedModels", RequestedModelsSchema)
5815
5852
  }]
5816
5853
  };
5817
5854
  //#endregion
@@ -5917,7 +5954,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5917
5954
  userId: number().int().positive().max(Number.MAX_SAFE_INTEGER)
5918
5955
  }).strict().optional()
5919
5956
  }).strict()).max(32),
5920
- operation: _enum(["authorizing", "switching"]).optional(),
5957
+ operation: _enum([
5958
+ "authorizing",
5959
+ "verifying",
5960
+ "switching"
5961
+ ]).optional(),
5921
5962
  notices: array(object({
5922
5963
  message: string().min(1).max(512),
5923
5964
  url: literal("https://github.com/login/device").optional(),
@@ -6657,7 +6698,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6657
6698
  }
6658
6699
  //#endregion
6659
6700
  //#region lib/types/turn-selection-card.js
6660
- function TurnSelectionCard({ selection, locale = "en", incomplete = false, readState = "ready", retry, account, accountFailed = false, retryAccount }) {
6701
+ function turnAccountLabel(account, zh) {
6702
+ if (account.state !== "recorded" || account.identity === void 0) return zh ? "身份暂不可用" : "identity unavailable";
6703
+ return `@${account.identity.login}`;
6704
+ }
6705
+ function TurnSelectionCard({ selection, locale = "en", incomplete = false, readState = "ready", retry, account, accountFailed = false, retryAccount, models, modelsFailed = false, retryModels }) {
6661
6706
  const zh = locale.startsWith("zh");
6662
6707
  const id = (0, react.useId)();
6663
6708
  const [open, setOpen] = (0, react.useState)(false);
@@ -6687,7 +6732,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6687
6732
  window.removeEventListener("resize", place);
6688
6733
  window.removeEventListener("scroll", place, true);
6689
6734
  };
6690
- }, [open, accountOpen]);
6735
+ }, [
6736
+ open,
6737
+ accountOpen,
6738
+ models?.kind,
6739
+ models?.routes.length,
6740
+ modelsFailed,
6741
+ selection.mode
6742
+ ]);
6691
6743
  (0, react.useEffect)(() => {
6692
6744
  if (!open) return;
6693
6745
  const outside = (event) => {
@@ -6743,14 +6795,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6743
6795
  setAccountOpen(true);
6744
6796
  setOpen(true);
6745
6797
  }
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", {
6798
+ }, accountFailed ? zh ? "账号记录读取失败" : "Account unavailable" : account?.state === "recorded" ? `${zh ? "账号" : "Account"} · ${turnAccountLabel(account, zh)}` : zh ? "Account · 未知" : "Account · unknown"), (0, react.createElement)("span", {
6747
6799
  role: readState === "ready" ? void 0 : "status",
6748
6800
  title: readState === "ready" && selection.mode === "unknown" ? zh ? "本轮选择记录未保留;不从当前选择推断历史。" : "No retained selection evidence; the current picker is not historical evidence." : void 0
6749
6801
  }, readState === "loading" ? zh ? "正在读取选择记录…" : "Loading selection…" : readState === "failed" ? zh ? "选择记录读取失败" : "Selection unavailable" : label), readState === "failed" && retry ? (0, react.createElement)("button", {
6750
6802
  type: "button",
6751
6803
  style: button,
6752
6804
  onClick: retry
6753
- }, zh ? "重试" : "Retry") : null, readState === "ready" && (selection.mode === "auto" || incomplete) ? (0, react.createElement)("button", {
6805
+ }, zh ? "重试" : "Retry") : null, readState === "ready" && (selection.mode === "auto" || incomplete) || models !== void 0 || modelsFailed ? (0, react.createElement)("button", {
6754
6806
  ref: accountOpen ? void 0 : trigger,
6755
6807
  type: "button",
6756
6808
  style: {
@@ -6759,9 +6811,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6759
6811
  height: 24,
6760
6812
  flexShrink: 0
6761
6813
  },
6762
- "aria-label": zh ? "为什么本轮选择这个模型" : "Why this model was selected",
6763
- "aria-expanded": open,
6764
- "aria-controls": open ? id : void 0,
6814
+ "aria-label": zh ? "查看本轮模型与选择记录" : "View turn model and selection evidence",
6815
+ "aria-expanded": open && !accountOpen,
6816
+ "aria-controls": open && !accountOpen ? id : void 0,
6765
6817
  "aria-haspopup": "dialog",
6766
6818
  onClick: () => {
6767
6819
  setAccountOpen(false);
@@ -6772,14 +6824,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6772
6824
  id,
6773
6825
  popover: "manual",
6774
6826
  role: "dialog",
6775
- "aria-label": accountOpen ? zh ? "本轮账号" : "Turn account" : zh ? "本轮选择记录" : "Turn selection evidence",
6827
+ "aria-label": accountOpen ? zh ? "本轮账号" : "Turn account" : zh ? "本轮模型与选择记录" : "Turn model and selection evidence",
6776
6828
  style: {
6777
6829
  position: "fixed",
6778
6830
  inset: "auto",
6779
6831
  ...position,
6780
6832
  margin: 0,
6781
6833
  zIndex: 1e3,
6782
- width: 300,
6834
+ width: 390,
6783
6835
  maxWidth: "calc(100vw - 24px)",
6784
6836
  maxHeight: `calc(100dvh - ${position.top + 12}px)`,
6785
6837
  overflowY: "auto",
@@ -6792,11 +6844,29 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6792
6844
  color: "var(--dsw-alias-label-primary, CanvasText)",
6793
6845
  lineHeight: 1.6
6794
6846
  }
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", {
6847
+ }, (0, react.createElement)("strong", null, accountOpen ? zh ? "本轮账号" : "Turn account" : zh ? "本轮模型与选择记录" : "Turn model and selection evidence"), !accountOpen && models !== void 0 ? (0, react.createElement)("section", { "aria-label": zh ? "模型证据" : "Model evidence" }, (0, react.createElement)("p", { style: {
6848
+ fontWeight: 600,
6849
+ marginBottom: 6
6850
+ } }, models.kind === "recorded" ? zh ? "已记录模型" : "Recorded models" : models.kind === "requested" ? zh ? "请求模型" : "Requested model" : zh ? "模型记录不可用" : "Model evidence unavailable"), models.routes.length ? (0, react.createElement)("ul", { style: {
6851
+ listStyle: "none",
6852
+ padding: 0,
6853
+ margin: 0
6854
+ } }, ...models.routes.map((value) => (0, react.createElement)("li", {
6855
+ key: JSON.stringify([value.provider, value.model]),
6856
+ style: { marginBottom: 12 }
6857
+ }, (0, react.createElement)("div", { style: { fontSize: 16 } }, value.model), (0, react.createElement)("div", { style: { fontSize: 12 } }, value.provider)))) : (0, react.createElement)("p", null, zh ? "未知" : "Unknown"), models.kind === "recorded" && models.incomplete ? (0, react.createElement)("p", null, zh ? "失败尝试或缺失历史的模型归属不完整。" : "Model attribution is incomplete for failed attempts or missing history.") : null, (0, react.createElement)("p", null, models.kind === "recorded" ? zh ? "来自本轮成功消息的模型记录;不能证明所有失败尝试都使用了这些模型。" : "From this turn’s successful message sources; this does not prove which models all failed attempts used." : models.kind === "requested" ? zh ? "来自本轮已记录步骤内的请求配置,仅证明请求模型,不证明发送、成功执行或计费用量归属。" : "From request configuration inside a recorded step of this turn; not proof of dispatch, successful execution or billing attribution." : zh ? "没有可靠的本轮模型证据;不从当前选择、全局默认或相邻轮次倒推。" : "No reliable model evidence for this turn; the current picker, global default and adjacent turns cannot reconstruct it."), modelsFailed ? (0, react.createElement)("p", { role: "status" }, zh ? "部分模型证据读取失败,不等同于没有记录。" : "Some model evidence could not be read; this is not proof of missing evidence.") : null, modelsFailed && retryModels ? (0, react.createElement)("button", {
6858
+ type: "button",
6859
+ style: button,
6860
+ onClick: retryModels
6861
+ }, zh ? "重试" : "Retry") : null) : null, 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"}: ${turnAccountLabel(account, zh)}` : 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
6862
  type: "button",
6797
6863
  style: button,
6798
6864
  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", {
6865
+ }, zh ? "重试" : "Retry") : null) : (0, react.createElement)("details", { style: {
6866
+ borderTop: button.border,
6867
+ marginTop: 18,
6868
+ paddingTop: 12
6869
+ } }, (0, react.createElement)("summary", { style: { cursor: "pointer" } }, zh ? "为什么选择此模型" : "Why this model was selected"), 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."))) : (0, react.createElement)("p", null, selection.mode === "manual" ? zh ? "本轮捕获了明确的手动选择;选择记录不是执行证明。" : "An explicit manual selection was captured for this turn; selection is not execution proof." : zh ? "本轮选择记录未保留;不使用当前设置反推历史。" : "Selection evidence was not retained; today’s settings cannot reconstruct it.")), !accountOpen && incomplete && models === void 0 ? (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、失败状态和重试保持不变。" : "Model evidence is not billing attribution. Selection is not execution proof; native Usage is unchanged, as are failures and retries."), (0, react.createElement)("button", {
6800
6870
  ref: close,
6801
6871
  type: "button",
6802
6872
  style: button,
@@ -7178,6 +7248,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7178
7248
  getSnapshot: () => void 0,
7179
7249
  subscribe: () => noop$3
7180
7250
  };
7251
+ const failedSource = {
7252
+ ...missingSource,
7253
+ failed: true
7254
+ };
7181
7255
  function sourceOf(props, key, diagnostic, failure = "COPILOT_TURN_SELECTION_PROJECTION_FAILED") {
7182
7256
  const turn = props.turn;
7183
7257
  if (!record$4(turn) || !record$4(turn.data) || typeof turn.data.source !== "function") return missingSource;
@@ -7186,7 +7260,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7186
7260
  return record$4(source) && typeof source.getSnapshot === "function" && typeof source.subscribe === "function" ? source : missingSource;
7187
7261
  } catch {
7188
7262
  diagnostic(failure);
7189
- return missingSource;
7263
+ return failedSource;
7190
7264
  }
7191
7265
  }
7192
7266
  function iterable(value) {
@@ -7213,6 +7287,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7213
7287
  const [live, setLive] = react.useState({ mode: "unknown" });
7214
7288
  const [readState, setReadState] = react.useState("loading");
7215
7289
  const [readAttempt, setReadAttempt] = react.useState(0);
7290
+ const [requested, setRequested] = react.useState();
7291
+ const [modelsFailed, setModelsFailed] = react.useState(false);
7292
+ const [modelsAttempt, setModelsAttempt] = react.useState(0);
7216
7293
  const turn = record$4(props.turn) && sequence(props.turn.turn) ? props.turn.turn : void 0;
7217
7294
  const sessionId = typeof props.sessionId === "string" ? props.sessionId : void 0;
7218
7295
  const [account, setAccount] = react.useState();
@@ -7284,7 +7361,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7284
7361
  const language = react.useSyncExternalStore(props.locale ? (listener) => props.locale.subscribe(listener) : () => noop$3, () => props.locale?.getLocale().active ?? "en", () => "en");
7285
7362
  const source = sourceOf(props, AUTO_MODEL_ATTRIBUTION_KEY, props.diagnostic);
7286
7363
  const value = react.useSyncExternalStore(source.subscribe, source.getSnapshot, source.getSnapshot);
7287
- const provenanceSource = sourceOf(props, TURN_MODEL_PROVENANCE_KEY, props.diagnostic);
7364
+ const provenanceSource = sourceOf(props, TURN_MODEL_PROVENANCE_KEY, props.diagnostic, "COPILOT_TURN_MODEL_PROVENANCE_READ_FAILED");
7288
7365
  const provenance = react.useSyncExternalStore(provenanceSource.subscribe, provenanceSource.getSnapshot, provenanceSource.getSnapshot);
7289
7366
  const usageSource = sourceOf(props, TURN_USAGE_EVIDENCE_KEY, props.diagnostic, "COPILOT_TURN_USAGE_PROJECTION_FAILED");
7290
7367
  const usageEvidence = react.useSyncExternalStore(usageSource.subscribe, usageSource.getSnapshot, usageSource.getSnapshot);
@@ -7298,10 +7375,49 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7298
7375
  const evidence = isTurnModelProvenance(provenance) ? provenance : void 0;
7299
7376
  const native = record$4(props.tail) && record$4(props.tail.data) ? props.tail.data : void 0;
7300
7377
  const nativeCompleted = native?.turn === turn && sequence(native?.seq);
7301
- if (evidence?.ended !== true && !nativeCompleted) return null;
7302
- if (evidence === void 0) props.diagnostic("COPILOT_TURN_SELECTION_PROVENANCE_UNAVAILABLE");
7378
+ const completed = evidence?.ended === true || nativeCompleted;
7303
7379
  const nativeRoutes = nativeCompleted && record$4(native?.tokenUsage) && Array.isArray(native.tokenUsage.routes) ? native.tokenUsage.routes : [];
7304
- const copilot = (evidence?.routes ?? nativeRoutes).some((route) => record$4(route) && (route.provider === "github-copilot-preview" || route.provider === "github-copilot") && typeof route.model === "string" && route.model.trim() !== "");
7380
+ const recorded = evidence?.routes.length ? evidence.routes : nativeRoutes.filter((route) => record$4(route) && typeof route.provider === "string" && route.provider.trim() !== "" && typeof route.model === "string" && route.model.trim() !== "");
7381
+ const needsRequested = completed && recorded.length === 0;
7382
+ react.useEffect(() => {
7383
+ setRequested(void 0);
7384
+ setModelsFailed(false);
7385
+ if (!needsRequested || turn === void 0 || sessionId === void 0) return;
7386
+ const read = props.remote?.requestedModels;
7387
+ if (!read) {
7388
+ setModelsFailed(true);
7389
+ props.diagnostic("COPILOT_TURN_REQUEST_REMOTE_UNAVAILABLE");
7390
+ return;
7391
+ }
7392
+ let active = true;
7393
+ read(sessionId, turn).then((result) => {
7394
+ if (!active) return;
7395
+ const parsed = result.ok ? RequestedModelsSchema.safeParse(result.value) : void 0;
7396
+ if (parsed?.success) setRequested(parsed.data);
7397
+ else {
7398
+ setModelsFailed(true);
7399
+ props.diagnostic("COPILOT_TURN_REQUEST_READ_FAILED");
7400
+ }
7401
+ }, () => {
7402
+ if (active) {
7403
+ setModelsFailed(true);
7404
+ props.diagnostic("COPILOT_TURN_REQUEST_READ_FAILED");
7405
+ }
7406
+ });
7407
+ return () => {
7408
+ active = false;
7409
+ };
7410
+ }, [
7411
+ needsRequested,
7412
+ turn,
7413
+ sessionId,
7414
+ props.remote,
7415
+ props.diagnostic,
7416
+ modelsAttempt
7417
+ ]);
7418
+ if (!completed) return null;
7419
+ if (evidence === void 0) props.diagnostic("COPILOT_TURN_SELECTION_PROVENANCE_UNAVAILABLE");
7420
+ const copilot = (recorded.length ? recorded : requested?.incomplete === false ? requested.routes : []).some((route) => record$4(route) && (route.provider === "github-copilot-preview" || route.provider === "github-copilot") && typeof route.model === "string" && route.model.trim() !== "");
7305
7421
  const usageDiagnostic = turn === void 0 ? void 0 : turnUsageDiagnostic(turn, native, usageEvidence, copilot);
7306
7422
  if (!copilot && parsed === void 0 && live.mode === "unknown" && usageDiagnostic === void 0) return null;
7307
7423
  if (usageDiagnostic !== void 0 && !isTurnUsageEvidence(usageEvidence)) props.diagnostic("COPILOT_TURN_USAGE_EVIDENCE_UNAVAILABLE");
@@ -7312,11 +7428,28 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7312
7428
  candidateCount: parsed.candidateCount,
7313
7429
  fittingCandidateCount: parsed.fittingCandidateCount
7314
7430
  } : { mode: "unknown" };
7431
+ const nativeCompleteModels = nativeCompleted && nativeRoutes.length > 0 && nativeRoutes.every((route) => record$4(route) && typeof route.provider === "string" && route.provider.trim() !== "" && typeof route.model === "string" && route.model.trim() !== "");
7432
+ const models = nativeCompleteModels ? void 0 : recorded.length ? {
7433
+ kind: "recorded",
7434
+ routes: recorded,
7435
+ incomplete: evidence?.incomplete ?? true
7436
+ } : requested?.incomplete === false && requested.routes.length ? {
7437
+ kind: "requested",
7438
+ routes: requested.routes,
7439
+ incomplete: true
7440
+ } : {
7441
+ kind: "unknown",
7442
+ routes: [],
7443
+ incomplete: true
7444
+ };
7315
7445
  return react.createElement(react.Fragment, null, react.createElement(TurnSelectionCard, {
7316
7446
  selection,
7317
7447
  locale: language,
7318
- incomplete: evidence?.incomplete ?? true,
7448
+ incomplete: nativeCompleteModels ? false : evidence?.incomplete ?? true,
7319
7449
  readState: selection.mode === "unknown" ? readState : "ready",
7450
+ models,
7451
+ modelsFailed: modelsFailed || provenanceSource.failed === true,
7452
+ retryModels: props.remote?.requestedModels === void 0 && provenanceSource.failed !== true ? void 0 : () => setModelsAttempt((value) => value + 1),
7320
7453
  account,
7321
7454
  accountFailed,
7322
7455
  retryAccount: () => setAccountAttempt((value) => value + 1),
@@ -7374,7 +7507,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7374
7507
  }
7375
7508
  const slots = slotsCandidate;
7376
7509
  const face = record$4(capabilities.remote) ? capabilities.remote.githubCopilotTurnSelection : void 0;
7377
- const remote = record$4(face) && typeof face.get === "function" ? face : void 0;
7510
+ const getSelection = record$4(face) ? face.get : void 0;
7511
+ const getRequested = record$4(face) ? face.requestedModels : void 0;
7512
+ const remote = typeof getSelection === "function" ? {
7513
+ get: (agentId, turn) => getSelection(agentId, turn),
7514
+ ...typeof getRequested === "function" ? { requestedModels: (agentId, turn) => getRequested(agentId, turn) } : {}
7515
+ } : void 0;
7378
7516
  const accountFace = record$4(capabilities.remote) ? capabilities.remote.githubCopilotSessionAccount : void 0;
7379
7517
  const readAccount = record$4(accountFace) ? accountFace.turn : void 0;
7380
7518
  const accountRemote = typeof readAccount === "function" ? { turn: (agentId, turn) => readAccount(agentId, turn) } : void 0;
@@ -8375,6 +8513,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8375
8513
  }
8376
8514
  };
8377
8515
  //#endregion
8516
+ //#region lib/types/authorization-code-clipboard.js
8517
+ async function copyAuthorizationCode(code, clipboard) {
8518
+ const writer = clipboard ?? globalThis.navigator?.clipboard;
8519
+ if (writer === void 0) throw new Error("Clipboard access is unavailable");
8520
+ await writer.writeText(code);
8521
+ }
8522
+ //#endregion
8378
8523
  //#region lib/types/copilot-accounts-card.js
8379
8524
  /** Copy owned presentation fields before decoding traced Client values. */
8380
8525
  function accountsViewFrom(value) {
@@ -8442,16 +8587,163 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8442
8587
  lineHeight: 1.5,
8443
8588
  margin: "6px 0"
8444
8589
  };
8590
+ const accountCopy = {
8591
+ en: {
8592
+ identityChecking: "Checking GitHub identity…",
8593
+ identityUnavailable: "GitHub account identity unavailable",
8594
+ accounts: "GitHub accounts",
8595
+ scope: "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.",
8596
+ remoteUnavailable: "Account management is unavailable in this deployment.",
8597
+ readFailed: "Could not read account information. Retry before changing accounts.",
8598
+ switchUnavailable: "Account switching is temporarily unavailable. Refresh account information and try again. No running work will be cancelled.",
8599
+ routeBlocked: "Account switching is unavailable while a native Copilot route remains configured or selected.",
8600
+ evidenceIncomplete: "Account switching is unavailable because route or activity evidence is incomplete.",
8601
+ authorizationBusy: "Account switching is paused while GitHub authorization is in progress.",
8602
+ verifyingBusy: "Account switching is paused while the authorized account is being verified.",
8603
+ switchingBusy: "An account change is already in progress.",
8604
+ technicalDetails: "Technical details",
8605
+ currentDefault: "Current default",
8606
+ savedAuthorization: "Saved authorization",
8607
+ authorizationUnavailable: "Authorization unavailable",
8608
+ identityUnavailableLabel: "Identity unavailable",
8609
+ switch: "Switch",
8610
+ reauthorize: "Reauthorize",
8611
+ remove: "Remove",
8612
+ confirmRemoveTitle: "Confirm account removal",
8613
+ confirmSwitchTitle: "Confirm account switch",
8614
+ removePrompt: (account) => `Remove the saved authorization for ${account}? This does not revoke access at GitHub or delete conversations.`,
8615
+ switchPrompt: (account) => `Use ${account} for subsequent Copilot work? Existing selected models may be unavailable, and encrypted reasoning from another account may not replay. History will not be modified.`,
8616
+ confirmRemove: "Confirm removal",
8617
+ confirmSwitch: "Confirm switch",
8618
+ cancel: "Cancel",
8619
+ switchFailed: "Could not confirm the account change. Refresh account information before retrying.",
8620
+ authorizationFailed: "GitHub authorization did not complete. Try adding the account again.",
8621
+ authorizationUnavailableError: "GitHub authorization is unavailable in this deployment.",
8622
+ modelsFailed: "Could not verify the account’s available models. Try again.",
8623
+ identityFailed: "Could not verify the GitHub account identity. Try again.",
8624
+ accountFailed: "Could not update GitHub account information. Refresh and try again.",
8625
+ addingStarting: "Adding account…",
8626
+ addingWaiting: "Adding account — waiting for GitHub authorization",
8627
+ reauthorizingStarting: "Reauthorizing account…",
8628
+ reauthorizingWaiting: "Reauthorizing account — waiting for GitHub authorization",
8629
+ authorizationStarting: "GitHub authorization is starting…",
8630
+ authorizationWaiting: "Waiting for GitHub authorization…",
8631
+ verifyingAdding: "GitHub authorization complete — verifying account identity and available models",
8632
+ verifyingReauthorizing: "GitHub authorization complete — verifying the saved account identity and available models",
8633
+ verifying: "GitHub authorization complete — verifying account identity and available models",
8634
+ pendingDefault: "Your current default account will not change.",
8635
+ verificationLink: "Open GitHub verification",
8636
+ manualUrl: "If the browser does not open, copy this address:",
8637
+ codeLabel: "One-time authorization code",
8638
+ copyCode: "Copy authorization code",
8639
+ copyingCode: "Copying…",
8640
+ copiedCodeButton: "Code copied",
8641
+ copiedCode: "Authorization code copied to clipboard.",
8642
+ copyFailed: "Could not copy the code. Select it above and copy it manually.",
8643
+ cancelAdd: "Cancel adding account",
8644
+ cancelReauthorize: "Cancel reauthorization",
8645
+ cancelling: "Cancelling…",
8646
+ add: "Add GitHub account",
8647
+ refresh: "Refresh account information",
8648
+ refreshing: "Checking…"
8649
+ },
8650
+ zh: {
8651
+ identityChecking: "正在检查 GitHub 身份…",
8652
+ identityUnavailable: "GitHub 账号身份暂不可用",
8653
+ accounts: "GitHub 账号",
8654
+ scope: "全局默认账号用于后续继承默认值的新 turn。Credits 可为本 Session 后续 turn 指定账号。正在运行的 turn、Session 已指定账号、模型和对话历史保持不变。",
8655
+ remoteUnavailable: "当前部署无法管理账号。",
8656
+ readFailed: "无法读取账号信息。更改账号前请重试。",
8657
+ switchUnavailable: "暂时无法切换账号。请刷新账号信息后重试;不会取消正在运行的工作。",
8658
+ routeBlocked: "原生 Copilot 路由仍在配置或被选用,因此无法切换账号。",
8659
+ evidenceIncomplete: "路由或活动证据不完整,因此无法切换账号。",
8660
+ authorizationBusy: "GitHub 授权进行期间无法切换账号。",
8661
+ verifyingBusy: "正在验证已授权账号,暂时无法切换。",
8662
+ switchingBusy: "账号更改正在进行中。",
8663
+ technicalDetails: "诊断详情",
8664
+ currentDefault: "当前默认账号",
8665
+ savedAuthorization: "已保存授权",
8666
+ authorizationUnavailable: "授权暂不可用",
8667
+ identityUnavailableLabel: "身份暂不可用",
8668
+ switch: "切换",
8669
+ reauthorize: "重新授权",
8670
+ remove: "移除",
8671
+ confirmRemoveTitle: "确认移除账号",
8672
+ confirmSwitchTitle: "确认切换账号",
8673
+ removePrompt: (account) => `移除 ${account} 的已保存授权?这不会撤销 GitHub 端的访问权限,也不会删除对话。`,
8674
+ switchPrompt: (account) => `后续 Copilot 工作使用 ${account}?该账号可能没有当前已选模型,加密推理内容也可能绑定其他账号。不会修改历史记录。`,
8675
+ confirmRemove: "确认移除",
8676
+ confirmSwitch: "确认切换",
8677
+ cancel: "取消",
8678
+ switchFailed: "无法确认账号更改结果。请刷新账号信息后再试。",
8679
+ authorizationFailed: "GitHub 授权未完成。请重新添加账号。",
8680
+ authorizationUnavailableError: "当前部署无法使用 GitHub 授权。",
8681
+ modelsFailed: "无法验证该账号可用的模型,请重试。",
8682
+ identityFailed: "无法验证 GitHub 账号身份,请重试。",
8683
+ accountFailed: "无法更新 GitHub 账号信息。请刷新后重试。",
8684
+ addingStarting: "正在添加账号…",
8685
+ addingWaiting: "正在添加账号,等待 GitHub 授权",
8686
+ reauthorizingStarting: "正在重新授权账号…",
8687
+ reauthorizingWaiting: "正在重新授权账号,等待 GitHub 授权",
8688
+ authorizationStarting: "正在启动 GitHub 授权…",
8689
+ authorizationWaiting: "等待 GitHub 授权…",
8690
+ verifyingAdding: "GitHub 授权已完成,正在验证账号身份和可用模型",
8691
+ verifyingReauthorizing: "GitHub 授权已完成,正在验证已保存账号的身份和可用模型",
8692
+ verifying: "GitHub 授权已完成,正在验证账号身份和可用模型",
8693
+ pendingDefault: "当前默认账号不会更改。",
8694
+ verificationLink: "打开 GitHub 验证页",
8695
+ manualUrl: "如果浏览器未打开,请复制此网址:",
8696
+ codeLabel: "一次性授权码",
8697
+ copyCode: "复制授权码",
8698
+ copyingCode: "正在复制…",
8699
+ copiedCodeButton: "已复制授权码",
8700
+ copiedCode: "授权码已复制到剪贴板。",
8701
+ copyFailed: "无法复制授权码。请选中上方代码并手动复制。",
8702
+ cancelAdd: "取消添加账号",
8703
+ cancelReauthorize: "取消重新授权",
8704
+ cancelling: "正在取消…",
8705
+ add: "添加 GitHub 账号",
8706
+ refresh: "刷新账号信息",
8707
+ refreshing: "正在检查…"
8708
+ }
8709
+ };
8710
+ function accountProblemMessage(code, text) {
8711
+ switch (code) {
8712
+ case "COPILOT_ACCOUNTS_ROUTE_BLOCKED": return text.routeBlocked;
8713
+ case "COPILOT_ACCOUNTS_EVIDENCE_INCOMPLETE": return text.evidenceIncomplete;
8714
+ case "COPILOT_ACCOUNTS_BUSY": return text.switchUnavailable;
8715
+ case "COPILOT_ACCOUNTS_AUTH_FAILED": return text.authorizationFailed;
8716
+ case "COPILOT_ACCOUNTS_AUTH_UNAVAILABLE": return text.authorizationUnavailableError;
8717
+ case "COPILOT_ACCOUNTS_MODELS_FAILED": return text.modelsFailed;
8718
+ case "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE":
8719
+ case "COPILOT_ACCOUNTS_IDENTITY_INVALID":
8720
+ case "COPILOT_ACCOUNTS_IDENTITY_TIMEOUT":
8721
+ case "COPILOT_ACCOUNTS_IDENTITY_TLS":
8722
+ case "COPILOT_ACCOUNTS_IDENTITY_NETWORK":
8723
+ case "COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED":
8724
+ case "COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED":
8725
+ case "COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR":
8726
+ case "COPILOT_ACCOUNTS_IDENTITY_CHANGED": return text.identityFailed;
8727
+ case "COPILOT_ACCOUNTS_CONFLICT":
8728
+ case "COPILOT_ACCOUNTS_COMMIT_UNCERTAIN": return text.switchFailed;
8729
+ default: return text.accountFailed;
8730
+ }
8731
+ }
8445
8732
  function CopilotAccountsPanel(props) {
8446
8733
  const [view, setView] = (0, react.useState)();
8447
8734
  const [busy, setBusy] = (0, react.useState)(false);
8448
8735
  const [failed, setFailed] = (0, react.useState)(false);
8736
+ const [copyState, setCopyState] = (0, react.useState)("idle");
8737
+ const [cancelRequested, setCancelRequested] = (0, react.useState)(false);
8738
+ const [authorizationIntent, setAuthorizationIntent] = (0, react.useState)();
8449
8739
  const [confirmation, setConfirmation] = (0, react.useState)();
8450
8740
  const lifetime = (0, react.useRef)({
8451
8741
  active: false,
8452
8742
  generation: 0,
8453
- busy: false
8743
+ busy: false,
8744
+ copyGeneration: 0
8454
8745
  });
8746
+ const text = props.locale?.toLowerCase().startsWith("zh") ? accountCopy.zh : accountCopy.en;
8455
8747
  const run = (0, react.useCallback)(async (operation, changed = false, invalidate = changed) => {
8456
8748
  const owner = lifetime.current;
8457
8749
  if (!owner.active || owner.busy) return;
@@ -8467,11 +8759,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8467
8759
  const next = result.ok ? accountsViewFrom(result.value) : void 0;
8468
8760
  setView(next);
8469
8761
  setFailed(next === void 0);
8762
+ if (next?.operation === void 0) {
8763
+ setAuthorizationIntent(void 0);
8764
+ setCancelRequested(false);
8765
+ }
8470
8766
  if (next !== void 0 && changed && next.operation === void 0) props.onChanged?.();
8471
8767
  } catch {
8472
8768
  if (current()) {
8473
8769
  setView(void 0);
8474
8770
  setFailed(true);
8771
+ setAuthorizationIntent(void 0);
8772
+ setCancelRequested(false);
8475
8773
  }
8476
8774
  } finally {
8477
8775
  if (current()) {
@@ -8488,6 +8786,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8488
8786
  setConfirmation(void 0);
8489
8787
  setBusy(false);
8490
8788
  setFailed(false);
8789
+ setCopyState("idle");
8790
+ setCancelRequested(false);
8791
+ setAuthorizationIntent(void 0);
8491
8792
  if (props.remote !== void 0 && !props.authorizationBusy) run(() => props.remote.ensureIdentity());
8492
8793
  return () => {
8493
8794
  owner.active = false;
@@ -8518,7 +8819,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8518
8819
  run
8519
8820
  ]);
8520
8821
  (0, react.useEffect)(() => {
8521
- if (view?.operation !== "authorizing" || props.remote === void 0) return;
8822
+ if (view?.operation !== "authorizing" && view?.operation !== "verifying" || props.remote === void 0) return;
8522
8823
  const timer = window.setTimeout(() => {
8523
8824
  run(() => props.remote.get(), true, false);
8524
8825
  }, 1500);
@@ -8528,10 +8829,55 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8528
8829
  props.remote,
8529
8830
  run
8530
8831
  ]);
8832
+ const activeNotice = view?.operation === "authorizing" && !cancelRequested ? view.notices.at(-1) : void 0;
8833
+ const noticeCode = activeNotice?.code;
8834
+ (0, react.useEffect)(() => {
8835
+ lifetime.current.copyGeneration++;
8836
+ setCopyState("idle");
8837
+ }, [
8838
+ noticeCode,
8839
+ view?.operation,
8840
+ cancelRequested
8841
+ ]);
8842
+ (0, react.useEffect)(() => () => {
8843
+ lifetime.current.copyGeneration++;
8844
+ }, []);
8845
+ const copyCode = () => {
8846
+ const code = noticeCode;
8847
+ const owner = lifetime.current;
8848
+ if (!owner.active || code === void 0 || copyState === "copying" || cancelRequested) return;
8849
+ const generation = ++owner.copyGeneration;
8850
+ setCopyState("copying");
8851
+ copyAuthorizationCode(code).then(() => {
8852
+ if (owner.active && owner.copyGeneration === generation) setCopyState("copied");
8853
+ }, () => {
8854
+ if (owner.active && owner.copyGeneration === generation) setCopyState("failed");
8855
+ });
8856
+ };
8857
+ const cancelAuthorization = () => {
8858
+ if (props.remote === void 0 || busy) return;
8859
+ lifetime.current.copyGeneration++;
8860
+ setCopyState("idle");
8861
+ setCancelRequested(true);
8862
+ run(() => props.remote.cancel(), true);
8863
+ };
8864
+ const startAdd = () => {
8865
+ setAuthorizationIntent("add");
8866
+ setCancelRequested(false);
8867
+ run(() => props.remote.add(), true);
8868
+ };
8869
+ const startReauthorization = (accountId, revision) => {
8870
+ setAuthorizationIntent("reauthorize");
8871
+ setCancelRequested(false);
8872
+ run(() => props.remote.reauthorize(accountId, revision), true);
8873
+ };
8531
8874
  const identity = accountIdentityLabel(view);
8532
8875
  const selected = confirmation === void 0 ? void 0 : view?.accounts.find((item) => item.id === confirmation.id);
8533
- const selectedLabel = selected?.identityState === "ready" && selected.identity !== void 0 ? `@${selected.identity.login}` : "this account";
8876
+ const selectedLabel = selected?.identityState === "ready" && selected.identity !== void 0 ? `@${selected.identity.login}` : text.savedAuthorization;
8534
8877
  const pending = busy || props.authorizationBusy === true || view?.operation !== void 0;
8878
+ const authorizationOperation = view?.operation === "authorizing" || view?.operation === "verifying";
8879
+ const authorizationStatus = cancelRequested ? text.cancelling : view?.operation === "authorizing" ? authorizationIntent === "add" ? noticeCode === void 0 ? text.addingStarting : text.addingWaiting : authorizationIntent === "reauthorize" ? noticeCode === void 0 ? text.reauthorizingStarting : text.reauthorizingWaiting : noticeCode === void 0 ? text.authorizationStarting : text.authorizationWaiting : view?.operation === "verifying" ? authorizationIntent === "add" ? text.verifyingAdding : authorizationIntent === "reauthorize" ? text.verifyingReauthorizing : text.verifying : view?.operation === "switching" ? text.switchingBusy : void 0;
8880
+ const switchBlocker = view !== void 0 && view.switchable === false ? view.operation === "authorizing" ? text.authorizationBusy : view.operation === "verifying" ? text.verifyingBusy : view.operation === "switching" ? text.switchingBusy : view.diagnostic === "COPILOT_ACCOUNTS_ROUTE_BLOCKED" ? text.routeBlocked : view.diagnostic === "COPILOT_ACCOUNTS_EVIDENCE_INCOMPLETE" ? text.evidenceIncomplete : view.state === "error" ? void 0 : text.switchUnavailable : void 0;
8535
8881
  const control = (label, onClick, disabled = false) => (0, react.createElement)("button", {
8536
8882
  type: "button",
8537
8883
  style: {
@@ -8543,7 +8889,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8543
8889
  }, label);
8544
8890
  return (0, react.createElement)("div", {
8545
8891
  "data-copilot-accounts": "",
8546
- "aria-busy": busy,
8892
+ "aria-busy": pending,
8547
8893
  style: {
8548
8894
  minWidth: 0,
8549
8895
  overflowWrap: "anywhere"
@@ -8553,20 +8899,79 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8553
8899
  role: "status",
8554
8900
  "aria-live": "polite",
8555
8901
  "data-copilot-current-account": ""
8556
- }, identity ?? (busy ? "Checking GitHub identity…" : "GitHub account identity unavailable")), !props.expanded ? null : (0, react.createElement)("div", { style: {
8902
+ }, identity ?? (busy ? text.identityChecking : text.identityUnavailable)), !props.expanded ? null : (0, react.createElement)("div", { style: {
8557
8903
  display: "grid",
8558
8904
  gap: 10,
8559
8905
  marginBlock: 12
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", {
8906
+ } }, (0, react.createElement)("strong", null, text.accounts), (0, react.createElement)("p", { style: muted$1 }, text.scope), props.remote === void 0 ? (0, react.createElement)("p", {
8561
8907
  role: "status",
8562
8908
  style: muted$1
8563
- }, "COPILOT_ACCOUNTS_REMOTE_UNAVAILABLE · Account management is unavailable in this deployment.") : null, failed ? (0, react.createElement)("p", {
8909
+ }, text.remoteUnavailable) : null, failed ? (0, react.createElement)("p", {
8564
8910
  role: "alert",
8565
8911
  style: muted$1
8566
- }, "Could not read account information. Retry before changing accounts.") : null, view?.diagnostic === void 0 ? null : (0, react.createElement)("p", {
8912
+ }, text.readFailed) : null, view?.state === "error" && view.operation === void 0 && view.diagnostic !== void 0 ? (0, react.createElement)("p", {
8913
+ role: "alert",
8914
+ style: muted$1
8915
+ }, accountProblemMessage(view.diagnostic, text)) : null, switchBlocker === void 0 ? null : (0, react.createElement)("p", {
8567
8916
  role: "status",
8917
+ "aria-live": "polite",
8568
8918
  style: muted$1
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: {
8919
+ }, switchBlocker), authorizationStatus === void 0 ? null : (0, react.createElement)("div", {
8920
+ role: "status",
8921
+ "aria-live": "polite",
8922
+ "data-copilot-account-authorization": "",
8923
+ style: {
8924
+ display: "grid",
8925
+ gap: 8
8926
+ }
8927
+ }, (0, react.createElement)("strong", null, authorizationStatus), authorizationOperation ? (0, react.createElement)("p", { style: muted$1 }, text.pendingDefault) : null, activeNotice?.url === void 0 ? null : (0, react.createElement)("a", {
8928
+ href: activeNotice.url,
8929
+ target: externalLinkTarget(),
8930
+ rel: "noreferrer",
8931
+ style: {
8932
+ color: "inherit",
8933
+ width: "fit-content"
8934
+ }
8935
+ }, text.verificationLink), activeNotice?.url === void 0 ? null : (0, react.createElement)("p", { style: {
8936
+ ...muted$1,
8937
+ overflowWrap: "anywhere",
8938
+ userSelect: "all"
8939
+ } }, text.manualUrl, " ", activeNotice.url), activeNotice?.code === void 0 ? null : (0, react.createElement)("div", { style: {
8940
+ display: "flex",
8941
+ flexWrap: "wrap",
8942
+ alignItems: "center",
8943
+ gap: 8
8944
+ } }, (0, react.createElement)("span", { style: {
8945
+ color: secondary$1,
8946
+ fontSize: 13
8947
+ } }, text.codeLabel), (0, react.createElement)("code", {
8948
+ "data-copilot-account-device-code": "",
8949
+ style: {
8950
+ userSelect: "all",
8951
+ overflowWrap: "anywhere",
8952
+ fontSize: 17,
8953
+ fontWeight: 700,
8954
+ letterSpacing: "0.08em"
8955
+ }
8956
+ }, activeNotice.code), control(copyState === "copying" ? text.copyingCode : copyState === "copied" ? text.copiedCodeButton : text.copyCode, copyCode, copyState === "copying" || cancelRequested)), copyState === "copied" ? (0, react.createElement)("p", {
8957
+ role: "status",
8958
+ "aria-live": "polite",
8959
+ style: muted$1
8960
+ }, text.copiedCode) : null, copyState === "failed" ? (0, react.createElement)("p", {
8961
+ role: "alert",
8962
+ "aria-live": "polite",
8963
+ style: muted$1
8964
+ }, text.copyFailed) : null, view?.operation === "authorizing" ? (0, react.createElement)("div", { style: {
8965
+ display: "flex",
8966
+ flexWrap: "wrap",
8967
+ gap: 8
8968
+ } }, control(cancelRequested ? text.cancelling : authorizationIntent === "reauthorize" ? text.cancelReauthorize : text.cancelAdd, cancelAuthorization, busy || cancelRequested)) : null), view?.diagnostic === void 0 ? null : (0, react.createElement)("details", {
8969
+ "data-copilot-account-diagnostic": "",
8970
+ style: {
8971
+ color: secondary$1,
8972
+ fontSize: 13
8973
+ }
8974
+ }, (0, react.createElement)("summary", { style: { cursor: "pointer" } }, text.technicalDetails), (0, react.createElement)("code", { style: { overflowWrap: "anywhere" } }, view.diagnostic)), (0, react.createElement)("ul", { style: {
8570
8975
  padding: 0,
8571
8976
  margin: 0,
8572
8977
  listStyle: "none"
@@ -8583,18 +8988,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8583
8988
  }, (0, react.createElement)("div", { style: {
8584
8989
  minWidth: 0,
8585
8990
  flex: "1 1 180px"
8586
- } }, (0, react.createElement)("strong", null, account.identityState === "ready" && account.identity !== void 0 ? `@${account.identity.login}` : "Identity unavailable"), (0, react.createElement)("p", { style: muted$1 }, account.id === view?.activeAccountId ? "Active account" : account.configured ? "Saved authorization" : "Authorization unavailable")), account.id === view?.activeAccountId ? null : control("Switch", () => {
8991
+ } }, (0, react.createElement)("strong", null, account.identityState === "ready" && account.identity !== void 0 ? `@${account.identity.login}` : account.configured ? text.identityUnavailableLabel : text.authorizationUnavailable), (0, react.createElement)("p", { style: muted$1 }, account.id === view?.activeAccountId ? text.currentDefault : account.configured ? text.savedAuthorization : text.authorizationUnavailable)), account.id === view?.activeAccountId ? null : control(text.switch, () => {
8587
8992
  if (view?.revision !== void 0) setConfirmation({
8588
8993
  id: account.id,
8589
8994
  revision: view.revision,
8590
8995
  remove: false
8591
8996
  });
8592
- }, pending || view?.switchable !== true || view?.revision === void 0 || !account.configured), account.id === "canonical" ? null : control("Reauthorize", () => {
8997
+ }, pending || view?.switchable !== true || view?.revision === void 0 || !account.configured), account.id === "canonical" ? null : control(text.reauthorize, () => {
8593
8998
  if (props.remote !== void 0 && view?.revision !== void 0) {
8594
8999
  const revision = view.revision;
8595
- run(() => props.remote.reauthorize(account.id, revision), true);
9000
+ startReauthorization(account.id, revision);
8596
9001
  }
8597
- }, pending || view?.writable !== true || view?.switchable !== true || view?.revision === void 0), account.id === "canonical" || account.id === view?.activeAccountId ? null : control("Remove", () => {
9002
+ }, pending || view?.writable !== true || view?.switchable !== true || view?.revision === void 0), account.id === "canonical" || account.id === view?.activeAccountId ? null : control(text.remove, () => {
8598
9003
  if (view?.revision !== void 0) setConfirmation({
8599
9004
  id: account.id,
8600
9005
  revision: view.revision,
@@ -8602,7 +9007,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8602
9007
  });
8603
9008
  }, pending || view?.writable !== true || view?.revision === void 0)))), confirmation === void 0 ? null : (0, react.createElement)("div", {
8604
9009
  role: "group",
8605
- "aria-label": confirmation.remove ? "Confirm account removal" : "Confirm account switch",
9010
+ "aria-label": confirmation.remove ? text.confirmRemoveTitle : text.confirmSwitchTitle,
8606
9011
  style: {
8607
9012
  border: border$1,
8608
9013
  borderRadius: 8,
@@ -8612,31 +9017,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8612
9017
  ...muted$1,
8613
9018
  color: "inherit",
8614
9019
  marginTop: 0
8615
- } }, confirmation.remove ? `Remove the saved authorization for ${selectedLabel}? This does not revoke access at GitHub or delete conversations.` : `Use ${selectedLabel} for subsequent Copilot work? Existing selected models may be unavailable, and encrypted reasoning from another account may not replay. History will not be modified.`), (0, react.createElement)("div", { style: {
9020
+ } }, confirmation.remove ? text.removePrompt(selectedLabel) : text.switchPrompt(selectedLabel)), (0, react.createElement)("div", { style: {
8616
9021
  display: "flex",
8617
9022
  flexWrap: "wrap",
8618
9023
  gap: 8
8619
- } }, control(confirmation.remove ? "Confirm removal" : "Confirm switch", () => {
9024
+ } }, control(confirmation.remove ? text.confirmRemove : text.confirmSwitch, () => {
8620
9025
  const target = confirmation;
8621
9026
  setConfirmation(void 0);
8622
9027
  if (props.remote !== void 0) run(() => target.remove ? props.remote.removeAccount(target.id, target.revision) : props.remote.switchAccount(target.id, target.revision), true);
8623
- }, pending), control("Cancel", () => setConfirmation(void 0), pending))), ...(view?.notices ?? []).map((notice, index) => (0, react.createElement)("div", {
8624
- key: index,
8625
- style: muted$1
8626
- }, (0, react.createElement)("p", null, notice.message), notice.url === void 0 ? null : (0, react.createElement)("a", {
8627
- href: notice.url,
8628
- target: externalLinkTarget(),
8629
- rel: "noreferrer",
8630
- style: { color: "inherit" }
8631
- }, "Open GitHub verification"), notice.code === void 0 ? null : (0, react.createElement)("p", null, (0, react.createElement)("code", { style: { userSelect: "all" } }, notice.code)), notice.url === void 0 ? null : (0, react.createElement)("p", { style: { userSelect: "all" } }, notice.url))), (0, react.createElement)("div", { style: {
9028
+ }, pending), control(text.cancel, () => setConfirmation(void 0), pending))), (0, react.createElement)("div", { style: {
8632
9029
  display: "flex",
8633
9030
  flexWrap: "wrap",
8634
9031
  gap: 8
8635
- } }, view?.operation === "authorizing" ? control("Cancel account sign-in", () => {
8636
- if (props.remote !== void 0) run(() => props.remote.cancel(), true);
8637
- }, busy) : control("Add GitHub account", () => {
8638
- if (props.remote !== void 0) run(() => props.remote.add(), true);
8639
- }, pending || view?.writable !== true || view?.switchable !== true), control(busy ? "Checking…" : "Refresh account information", () => {
9032
+ } }, authorizationOperation ? null : control(text.add, () => {
9033
+ if (props.remote !== void 0) startAdd();
9034
+ }, pending || view?.writable !== true || view?.switchable !== true), control(busy ? text.refreshing : text.refresh, () => {
8640
9035
  if (props.remote !== void 0) run(() => props.remote.refreshIdentity());
8641
9036
  }, pending || props.remote === void 0))));
8642
9037
  }
@@ -8684,7 +9079,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8684
9079
  accountLoading: "Loading account selection…",
8685
9080
  accountMissing: "Account selection unavailable. Refresh to retry.",
8686
9081
  runningAccount: "Running turn remains on",
8687
- identityUnknown: "Identity unavailable"
9082
+ identityUnknown: "Identity unavailable",
9083
+ originalAuthorization: "Original authorization",
9084
+ savedAuthorization: "Saved authorization"
8688
9085
  },
8689
9086
  zh: {
8690
9087
  credits: "额度",
@@ -8727,7 +9124,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8727
9124
  accountLoading: "正在读取账号选择…",
8728
9125
  accountMissing: "账号选择暂不可用,请刷新重试。",
8729
9126
  runningAccount: "正在运行的 turn 仍使用",
8730
- identityUnknown: "身份暂不可用"
9127
+ identityUnknown: "身份暂不可用",
9128
+ originalAuthorization: "原始授权",
9129
+ savedAuthorization: "已保存授权"
8731
9130
  }
8732
9131
  };
8733
9132
  const secondary = "var(--dsw-alias-label-secondary, GrayText)";
@@ -8991,6 +9390,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8991
9390
  };
8992
9391
  }, [open, close]);
8993
9392
  const available = view?.state === "ready" || view?.state === "stale";
9393
+ const unknownSavedAccounts = (sessionAccount?.accounts.accounts ?? []).filter((account) => account.configured && account.id !== "canonical" && account.identity === void 0);
9394
+ const numberedUnknownAccounts = unknownSavedAccounts.length > 1 ? new Map(unknownSavedAccounts.map((account, index) => [account.id, index + 1])) : /* @__PURE__ */ new Map();
8994
9395
  const knownUnits = view?.billing === "credits" || view?.billing === "requests";
8995
9396
  const numbers = available && knownUnits;
8996
9397
  const used = numbers && amount(view.used) ? view.used : void 0;
@@ -9135,7 +9536,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
9135
9536
  onClick: () => {
9136
9537
  chooseAccount(account.id);
9137
9538
  }
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", {
9539
+ }, account.identity ? `@${account.identity.login}` : account.id === "canonical" ? `${t.originalAuthorization} · ${t.identityUnknown}` : `${t.savedAuthorization}${numberedUnknownAccounts.has(account.id) ? ` ${numberedUnknownAccounts.get(account.id)}` : ""} · ${t.identityUnknown}`))) : null, sessionAccount?.accounts.diagnostic === void 0 ? null : (0, react.createElement)("code", { style: muted }, sessionAccount.accounts.diagnostic), accountFailed || accountSaveFailed ? (0, react.createElement)("p", {
9139
9540
  role: "alert",
9140
9541
  style: muted
9141
9542
  }, accountSaveFailed ? t.accountSaveFailed : t.accountMissing) : null), view?.state === "stale" ? (0, react.createElement)("p", {
@@ -9993,6 +10394,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
9993
10394
  * Browser companion for the Models provider-card slot.
9994
10395
  */
9995
10396
  const inject = ["remote", "slots"];
10397
+ function isLocaleReader(value) {
10398
+ return typeof value === "object" && value !== null && "getLocale" in value && typeof value.getLocale === "function" && "subscribe" in value && typeof value.subscribe === "function";
10399
+ }
9996
10400
  function messageOf(result) {
9997
10401
  return result.ok ? "" : "COPILOT_AUTHORIZATION_REQUEST_FAILED";
9998
10402
  }
@@ -10154,12 +10558,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10154
10558
  textAlign: "center",
10155
10559
  userSelect: "all"
10156
10560
  };
10157
- /** Copy a one-time authorization code through the browser clipboard boundary. */
10158
- async function copyAuthorizationCode(code, clipboard) {
10159
- const writer = clipboard ?? globalThis.navigator?.clipboard;
10160
- if (writer === void 0) throw new Error("Clipboard access is unavailable");
10161
- await writer.writeText(code);
10162
- }
10163
10561
  /** Pure presentation for the in-flight GitHub device-code handoff. */
10164
10562
  function GitHubCopilotAuthorizationNotice(props) {
10165
10563
  const feedback = props.copyState === "copying" ? "Copying code…" : props.copyState === "copied" ? "Code copied to clipboard." : props.copyState === "failed" ? "Copy failed. Select the code and copy it manually." : "";
@@ -10623,7 +11021,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10623
11021
  expanded: manageOpen,
10624
11022
  onChanged: account.retryStatus,
10625
11023
  authorizationBusy,
10626
- configured: view?.configured
11024
+ configured: view?.configured,
11025
+ locale: props.locale
10627
11026
  }), (0, react.createElement)("div", { style: {
10628
11027
  display: "flex",
10629
11028
  alignItems: "center",
@@ -10708,7 +11107,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10708
11107
  function GitHubCopilotPreviewFooter(props) {
10709
11108
  return (0, react.createElement)("div", { "data-dsh-github-copilot-preview-footer": true }, (0, react.createElement)(GitHubCopilotCompactAccount, {
10710
11109
  remote: props.remote,
10711
- accountsRemote: props.accountsRemote
11110
+ accountsRemote: props.accountsRemote,
11111
+ locale: props.locale
10712
11112
  }));
10713
11113
  }
10714
11114
  /** Only the mounted canonical row owns embedded controls. Credential presence is not row presence. */
@@ -10796,6 +11196,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10796
11196
  function GitHubCopilotAccountSurface(props) {
10797
11197
  const token = (0, react.useMemo)(() => Symbol("github-copilot-account-surface"), []);
10798
11198
  const owner = (0, react.useSyncExternalStore)(props.surfaces.subscribe, props.surfaces.getSnapshot, props.surfaces.getSnapshot);
11199
+ const subscribeLocale = (0, react.useCallback)((listener) => props.localeReader?.subscribe(listener) ?? (() => {}), [props.localeReader]);
11200
+ const getLocale = (0, react.useCallback)(() => props.localeReader?.getLocale().active ?? "en", [props.localeReader]);
11201
+ const locale = (0, react.useSyncExternalStore)(subscribeLocale, getLocale, () => "en");
10799
11202
  (0, react.useLayoutEffect)(() => props.eligible === false ? void 0 : props.surfaces.mount(props.seat, token, props.remote), [
10800
11203
  props.surfaces,
10801
11204
  props.seat,
@@ -10809,17 +11212,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10809
11212
  remote: props.remote,
10810
11213
  accountsRemote: props.accountsRemote,
10811
11214
  account: owner.account,
10812
- embedded
11215
+ embedded,
11216
+ locale
10813
11217
  }));
10814
11218
  }
10815
11219
  /** Unified fallback when the Models footer extension is absent or incompatible. */
10816
11220
  function GitHubCopilotSettingsSection(props) {
10817
- return (0, react.createElement)("section", { "data-dsh-github-copilot-settings": true }, (0, react.createElement)(GitHubCopilotCompactAccount, { remote: props.remote }));
11221
+ return (0, react.createElement)("section", { "data-dsh-github-copilot-settings": true }, (0, react.createElement)(GitHubCopilotCompactAccount, {
11222
+ remote: props.remote,
11223
+ locale: props.locale
11224
+ }));
10818
11225
  }
10819
11226
  function registerUi(ctx) {
10820
11227
  const surfaces = createAccountSurfaces();
10821
11228
  const remote = ctx.remote.githubCopilot;
10822
11229
  const accountsRemote = ctx.remote.githubCopilotAccounts;
11230
+ const localeCandidate = ctx.get("locale");
11231
+ const localeReader = isLocaleReader(localeCandidate) ? localeCandidate : void 0;
10823
11232
  const disposeCredentials = ctx.remote.$on("credentials/reference-updated", () => surfaces.invalidate());
10824
11233
  const disposeReset = ctx.on("connection/reset", () => surfaces.invalidate());
10825
11234
  let active = true;
@@ -10842,7 +11251,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10842
11251
  surfaces,
10843
11252
  seat,
10844
11253
  remote,
10845
- accountsRemote
11254
+ accountsRemote,
11255
+ localeReader
10846
11256
  }));
10847
11257
  disposeFallback = () => {
10848
11258
  surfaces.revoke(seat);
@@ -10876,7 +11286,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10876
11286
  seat,
10877
11287
  remote,
10878
11288
  accountsRemote,
10879
- eligible: isGitHubCopilotAccountRow(props)
11289
+ eligible: isGitHubCopilotAccountRow(props),
11290
+ localeReader
10880
11291
  });
10881
11292
  });
10882
11293
  return () => {
@@ -10907,7 +11318,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10907
11318
  surfaces,
10908
11319
  seat,
10909
11320
  remote,
10910
- accountsRemote
11321
+ accountsRemote,
11322
+ localeReader
10911
11323
  }));
10912
11324
  } catch {
10913
11325
  reportFooterUnavailable();