dsh-github-copilot 0.4.0-alpha.104 → 0.4.0-alpha.106
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 +3 -1
- package/CHANGELOG.md +12 -0
- package/README.md +10 -6
- package/README.zh.md +10 -6
- package/deployment-baseline.json +12 -1
- package/docs/automatic-model-routing.md +29 -4
- package/docs/copilot-accounts.md +21 -3
- package/lib/client.js +201 -28
- package/lib/client.js.map +1 -1
- package/lib/index.js +370 -94
- package/lib/remote.js +46 -0
- package/lib/types/context-evidence.d.ts +4 -4
- package/lib/types/copilot-accounts-card.d.ts +1 -0
- package/lib/types/copilot-accounts-host.d.ts +8 -0
- 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 +1 -1
- package/lib/types/session-accounts-controller.d.ts +2 -0
- package/lib/types/session-accounts-remote.d.ts +7 -0
- package/lib/types/turn-request-models.d.ts +55 -0
- package/lib/types/turn-selection-card.d.ts +10 -1
- package/lib/types/turn-selection-host.d.ts +2 -0
- package/lib/types/turn-selection-remote.d.ts +2 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -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",
|
|
@@ -5784,6 +5790,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5784
5790
|
}).strict()
|
|
5785
5791
|
]);
|
|
5786
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
|
|
5787
5811
|
//#region lib/types/turn-selection-remote.js
|
|
5788
5812
|
const contribution$4 = {
|
|
5789
5813
|
package: "dsh-github-copilot",
|
|
@@ -5806,6 +5830,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5806
5830
|
codec: strictRemoteCodec("dsh-github-copilot#TurnSelectionTurn", number().int().nonnegative().max(Number.MAX_SAFE_INTEGER))
|
|
5807
5831
|
}],
|
|
5808
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)
|
|
5809
5852
|
}]
|
|
5810
5853
|
};
|
|
5811
5854
|
//#endregion
|
|
@@ -5937,6 +5980,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5937
5980
|
descriptors: [
|
|
5938
5981
|
"get",
|
|
5939
5982
|
"refreshIdentity",
|
|
5983
|
+
"ensureIdentity",
|
|
5940
5984
|
"add",
|
|
5941
5985
|
"cancel",
|
|
5942
5986
|
"switchAccount",
|
|
@@ -5990,6 +6034,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5990
6034
|
"get",
|
|
5991
6035
|
"set",
|
|
5992
6036
|
"refreshIdentity",
|
|
6037
|
+
"ensureIdentity",
|
|
5993
6038
|
"usage",
|
|
5994
6039
|
"refreshUsage",
|
|
5995
6040
|
"turn"
|
|
@@ -6649,7 +6694,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6649
6694
|
}
|
|
6650
6695
|
//#endregion
|
|
6651
6696
|
//#region lib/types/turn-selection-card.js
|
|
6652
|
-
function TurnSelectionCard({ selection, locale = "en", incomplete = false, readState = "ready", retry, account, accountFailed = false, retryAccount }) {
|
|
6697
|
+
function TurnSelectionCard({ selection, locale = "en", incomplete = false, readState = "ready", retry, account, accountFailed = false, retryAccount, models, modelsFailed = false, retryModels }) {
|
|
6653
6698
|
const zh = locale.startsWith("zh");
|
|
6654
6699
|
const id = (0, react.useId)();
|
|
6655
6700
|
const [open, setOpen] = (0, react.useState)(false);
|
|
@@ -6679,7 +6724,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6679
6724
|
window.removeEventListener("resize", place);
|
|
6680
6725
|
window.removeEventListener("scroll", place, true);
|
|
6681
6726
|
};
|
|
6682
|
-
}, [
|
|
6727
|
+
}, [
|
|
6728
|
+
open,
|
|
6729
|
+
accountOpen,
|
|
6730
|
+
models?.kind,
|
|
6731
|
+
models?.routes.length,
|
|
6732
|
+
modelsFailed,
|
|
6733
|
+
selection.mode
|
|
6734
|
+
]);
|
|
6683
6735
|
(0, react.useEffect)(() => {
|
|
6684
6736
|
if (!open) return;
|
|
6685
6737
|
const outside = (event) => {
|
|
@@ -6742,7 +6794,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6742
6794
|
type: "button",
|
|
6743
6795
|
style: button,
|
|
6744
6796
|
onClick: retry
|
|
6745
|
-
}, zh ? "重试" : "Retry") : null, readState === "ready" && (selection.mode === "auto" || incomplete) ? (0, react.createElement)("button", {
|
|
6797
|
+
}, zh ? "重试" : "Retry") : null, readState === "ready" && (selection.mode === "auto" || incomplete) || models !== void 0 || modelsFailed ? (0, react.createElement)("button", {
|
|
6746
6798
|
ref: accountOpen ? void 0 : trigger,
|
|
6747
6799
|
type: "button",
|
|
6748
6800
|
style: {
|
|
@@ -6751,9 +6803,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6751
6803
|
height: 24,
|
|
6752
6804
|
flexShrink: 0
|
|
6753
6805
|
},
|
|
6754
|
-
"aria-label": zh ? "
|
|
6755
|
-
"aria-expanded": open,
|
|
6756
|
-
"aria-controls": open ? id : void 0,
|
|
6806
|
+
"aria-label": zh ? "查看本轮模型与选择记录" : "View turn model and selection evidence",
|
|
6807
|
+
"aria-expanded": open && !accountOpen,
|
|
6808
|
+
"aria-controls": open && !accountOpen ? id : void 0,
|
|
6757
6809
|
"aria-haspopup": "dialog",
|
|
6758
6810
|
onClick: () => {
|
|
6759
6811
|
setAccountOpen(false);
|
|
@@ -6764,14 +6816,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6764
6816
|
id,
|
|
6765
6817
|
popover: "manual",
|
|
6766
6818
|
role: "dialog",
|
|
6767
|
-
"aria-label": accountOpen ? zh ? "本轮账号" : "Turn account" : zh ? "
|
|
6819
|
+
"aria-label": accountOpen ? zh ? "本轮账号" : "Turn account" : zh ? "本轮模型与选择记录" : "Turn model and selection evidence",
|
|
6768
6820
|
style: {
|
|
6769
6821
|
position: "fixed",
|
|
6770
6822
|
inset: "auto",
|
|
6771
6823
|
...position,
|
|
6772
6824
|
margin: 0,
|
|
6773
6825
|
zIndex: 1e3,
|
|
6774
|
-
width:
|
|
6826
|
+
width: 390,
|
|
6775
6827
|
maxWidth: "calc(100vw - 24px)",
|
|
6776
6828
|
maxHeight: `calc(100dvh - ${position.top + 12}px)`,
|
|
6777
6829
|
overflowY: "auto",
|
|
@@ -6784,11 +6836,29 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6784
6836
|
color: "var(--dsw-alias-label-primary, CanvasText)",
|
|
6785
6837
|
lineHeight: 1.6
|
|
6786
6838
|
}
|
|
6787
|
-
}, (0, react.createElement)("strong", null, accountOpen ? zh ? "本轮账号" : "Turn account" : zh ? "
|
|
6839
|
+
}, (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: {
|
|
6840
|
+
fontWeight: 600,
|
|
6841
|
+
marginBottom: 6
|
|
6842
|
+
} }, models.kind === "recorded" ? zh ? "已记录模型" : "Recorded models" : models.kind === "requested" ? zh ? "请求模型" : "Requested model" : zh ? "模型记录不可用" : "Model evidence unavailable"), models.routes.length ? (0, react.createElement)("ul", { style: {
|
|
6843
|
+
listStyle: "none",
|
|
6844
|
+
padding: 0,
|
|
6845
|
+
margin: 0
|
|
6846
|
+
} }, ...models.routes.map((value) => (0, react.createElement)("li", {
|
|
6847
|
+
key: JSON.stringify([value.provider, value.model]),
|
|
6848
|
+
style: { marginBottom: 12 }
|
|
6849
|
+
}, (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", {
|
|
6850
|
+
type: "button",
|
|
6851
|
+
style: button,
|
|
6852
|
+
onClick: retryModels
|
|
6853
|
+
}, 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"}: ${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", {
|
|
6788
6854
|
type: "button",
|
|
6789
6855
|
style: button,
|
|
6790
6856
|
onClick: retryAccount
|
|
6791
|
-
}, zh ? "重试" : "Retry") : null) :
|
|
6857
|
+
}, zh ? "重试" : "Retry") : null) : (0, react.createElement)("details", { style: {
|
|
6858
|
+
borderTop: button.border,
|
|
6859
|
+
marginTop: 18,
|
|
6860
|
+
paddingTop: 12
|
|
6861
|
+
} }, (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", {
|
|
6792
6862
|
ref: close,
|
|
6793
6863
|
type: "button",
|
|
6794
6864
|
style: button,
|
|
@@ -7170,6 +7240,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7170
7240
|
getSnapshot: () => void 0,
|
|
7171
7241
|
subscribe: () => noop$3
|
|
7172
7242
|
};
|
|
7243
|
+
const failedSource = {
|
|
7244
|
+
...missingSource,
|
|
7245
|
+
failed: true
|
|
7246
|
+
};
|
|
7173
7247
|
function sourceOf(props, key, diagnostic, failure = "COPILOT_TURN_SELECTION_PROJECTION_FAILED") {
|
|
7174
7248
|
const turn = props.turn;
|
|
7175
7249
|
if (!record$4(turn) || !record$4(turn.data) || typeof turn.data.source !== "function") return missingSource;
|
|
@@ -7178,7 +7252,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7178
7252
|
return record$4(source) && typeof source.getSnapshot === "function" && typeof source.subscribe === "function" ? source : missingSource;
|
|
7179
7253
|
} catch {
|
|
7180
7254
|
diagnostic(failure);
|
|
7181
|
-
return
|
|
7255
|
+
return failedSource;
|
|
7182
7256
|
}
|
|
7183
7257
|
}
|
|
7184
7258
|
function iterable(value) {
|
|
@@ -7205,6 +7279,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7205
7279
|
const [live, setLive] = react.useState({ mode: "unknown" });
|
|
7206
7280
|
const [readState, setReadState] = react.useState("loading");
|
|
7207
7281
|
const [readAttempt, setReadAttempt] = react.useState(0);
|
|
7282
|
+
const [requested, setRequested] = react.useState();
|
|
7283
|
+
const [modelsFailed, setModelsFailed] = react.useState(false);
|
|
7284
|
+
const [modelsAttempt, setModelsAttempt] = react.useState(0);
|
|
7208
7285
|
const turn = record$4(props.turn) && sequence(props.turn.turn) ? props.turn.turn : void 0;
|
|
7209
7286
|
const sessionId = typeof props.sessionId === "string" ? props.sessionId : void 0;
|
|
7210
7287
|
const [account, setAccount] = react.useState();
|
|
@@ -7276,7 +7353,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7276
7353
|
const language = react.useSyncExternalStore(props.locale ? (listener) => props.locale.subscribe(listener) : () => noop$3, () => props.locale?.getLocale().active ?? "en", () => "en");
|
|
7277
7354
|
const source = sourceOf(props, AUTO_MODEL_ATTRIBUTION_KEY, props.diagnostic);
|
|
7278
7355
|
const value = react.useSyncExternalStore(source.subscribe, source.getSnapshot, source.getSnapshot);
|
|
7279
|
-
const provenanceSource = sourceOf(props, TURN_MODEL_PROVENANCE_KEY, props.diagnostic);
|
|
7356
|
+
const provenanceSource = sourceOf(props, TURN_MODEL_PROVENANCE_KEY, props.diagnostic, "COPILOT_TURN_MODEL_PROVENANCE_READ_FAILED");
|
|
7280
7357
|
const provenance = react.useSyncExternalStore(provenanceSource.subscribe, provenanceSource.getSnapshot, provenanceSource.getSnapshot);
|
|
7281
7358
|
const usageSource = sourceOf(props, TURN_USAGE_EVIDENCE_KEY, props.diagnostic, "COPILOT_TURN_USAGE_PROJECTION_FAILED");
|
|
7282
7359
|
const usageEvidence = react.useSyncExternalStore(usageSource.subscribe, usageSource.getSnapshot, usageSource.getSnapshot);
|
|
@@ -7290,10 +7367,49 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7290
7367
|
const evidence = isTurnModelProvenance(provenance) ? provenance : void 0;
|
|
7291
7368
|
const native = record$4(props.tail) && record$4(props.tail.data) ? props.tail.data : void 0;
|
|
7292
7369
|
const nativeCompleted = native?.turn === turn && sequence(native?.seq);
|
|
7293
|
-
|
|
7294
|
-
if (evidence === void 0) props.diagnostic("COPILOT_TURN_SELECTION_PROVENANCE_UNAVAILABLE");
|
|
7370
|
+
const completed = evidence?.ended === true || nativeCompleted;
|
|
7295
7371
|
const nativeRoutes = nativeCompleted && record$4(native?.tokenUsage) && Array.isArray(native.tokenUsage.routes) ? native.tokenUsage.routes : [];
|
|
7296
|
-
const
|
|
7372
|
+
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() !== "");
|
|
7373
|
+
const needsRequested = completed && recorded.length === 0;
|
|
7374
|
+
react.useEffect(() => {
|
|
7375
|
+
setRequested(void 0);
|
|
7376
|
+
setModelsFailed(false);
|
|
7377
|
+
if (!needsRequested || turn === void 0 || sessionId === void 0) return;
|
|
7378
|
+
const read = props.remote?.requestedModels;
|
|
7379
|
+
if (!read) {
|
|
7380
|
+
setModelsFailed(true);
|
|
7381
|
+
props.diagnostic("COPILOT_TURN_REQUEST_REMOTE_UNAVAILABLE");
|
|
7382
|
+
return;
|
|
7383
|
+
}
|
|
7384
|
+
let active = true;
|
|
7385
|
+
read(sessionId, turn).then((result) => {
|
|
7386
|
+
if (!active) return;
|
|
7387
|
+
const parsed = result.ok ? RequestedModelsSchema.safeParse(result.value) : void 0;
|
|
7388
|
+
if (parsed?.success) setRequested(parsed.data);
|
|
7389
|
+
else {
|
|
7390
|
+
setModelsFailed(true);
|
|
7391
|
+
props.diagnostic("COPILOT_TURN_REQUEST_READ_FAILED");
|
|
7392
|
+
}
|
|
7393
|
+
}, () => {
|
|
7394
|
+
if (active) {
|
|
7395
|
+
setModelsFailed(true);
|
|
7396
|
+
props.diagnostic("COPILOT_TURN_REQUEST_READ_FAILED");
|
|
7397
|
+
}
|
|
7398
|
+
});
|
|
7399
|
+
return () => {
|
|
7400
|
+
active = false;
|
|
7401
|
+
};
|
|
7402
|
+
}, [
|
|
7403
|
+
needsRequested,
|
|
7404
|
+
turn,
|
|
7405
|
+
sessionId,
|
|
7406
|
+
props.remote,
|
|
7407
|
+
props.diagnostic,
|
|
7408
|
+
modelsAttempt
|
|
7409
|
+
]);
|
|
7410
|
+
if (!completed) return null;
|
|
7411
|
+
if (evidence === void 0) props.diagnostic("COPILOT_TURN_SELECTION_PROVENANCE_UNAVAILABLE");
|
|
7412
|
+
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() !== "");
|
|
7297
7413
|
const usageDiagnostic = turn === void 0 ? void 0 : turnUsageDiagnostic(turn, native, usageEvidence, copilot);
|
|
7298
7414
|
if (!copilot && parsed === void 0 && live.mode === "unknown" && usageDiagnostic === void 0) return null;
|
|
7299
7415
|
if (usageDiagnostic !== void 0 && !isTurnUsageEvidence(usageEvidence)) props.diagnostic("COPILOT_TURN_USAGE_EVIDENCE_UNAVAILABLE");
|
|
@@ -7304,11 +7420,28 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7304
7420
|
candidateCount: parsed.candidateCount,
|
|
7305
7421
|
fittingCandidateCount: parsed.fittingCandidateCount
|
|
7306
7422
|
} : { mode: "unknown" };
|
|
7423
|
+
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() !== "");
|
|
7424
|
+
const models = nativeCompleteModels ? void 0 : recorded.length ? {
|
|
7425
|
+
kind: "recorded",
|
|
7426
|
+
routes: recorded,
|
|
7427
|
+
incomplete: evidence?.incomplete ?? true
|
|
7428
|
+
} : requested?.incomplete === false && requested.routes.length ? {
|
|
7429
|
+
kind: "requested",
|
|
7430
|
+
routes: requested.routes,
|
|
7431
|
+
incomplete: true
|
|
7432
|
+
} : {
|
|
7433
|
+
kind: "unknown",
|
|
7434
|
+
routes: [],
|
|
7435
|
+
incomplete: true
|
|
7436
|
+
};
|
|
7307
7437
|
return react.createElement(react.Fragment, null, react.createElement(TurnSelectionCard, {
|
|
7308
7438
|
selection,
|
|
7309
7439
|
locale: language,
|
|
7310
|
-
incomplete: evidence?.incomplete ?? true,
|
|
7440
|
+
incomplete: nativeCompleteModels ? false : evidence?.incomplete ?? true,
|
|
7311
7441
|
readState: selection.mode === "unknown" ? readState : "ready",
|
|
7442
|
+
models,
|
|
7443
|
+
modelsFailed: modelsFailed || provenanceSource.failed === true,
|
|
7444
|
+
retryModels: props.remote?.requestedModels === void 0 && provenanceSource.failed !== true ? void 0 : () => setModelsAttempt((value) => value + 1),
|
|
7312
7445
|
account,
|
|
7313
7446
|
accountFailed,
|
|
7314
7447
|
retryAccount: () => setAccountAttempt((value) => value + 1),
|
|
@@ -7366,7 +7499,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7366
7499
|
}
|
|
7367
7500
|
const slots = slotsCandidate;
|
|
7368
7501
|
const face = record$4(capabilities.remote) ? capabilities.remote.githubCopilotTurnSelection : void 0;
|
|
7369
|
-
const
|
|
7502
|
+
const getSelection = record$4(face) ? face.get : void 0;
|
|
7503
|
+
const getRequested = record$4(face) ? face.requestedModels : void 0;
|
|
7504
|
+
const remote = typeof getSelection === "function" ? {
|
|
7505
|
+
get: (agentId, turn) => getSelection(agentId, turn),
|
|
7506
|
+
...typeof getRequested === "function" ? { requestedModels: (agentId, turn) => getRequested(agentId, turn) } : {}
|
|
7507
|
+
} : void 0;
|
|
7370
7508
|
const accountFace = record$4(capabilities.remote) ? capabilities.remote.githubCopilotSessionAccount : void 0;
|
|
7371
7509
|
const readAccount = record$4(accountFace) ? accountFace.turn : void 0;
|
|
7372
7510
|
const accountRemote = typeof readAccount === "function" ? { turn: (agentId, turn) => readAccount(agentId, turn) } : void 0;
|
|
@@ -8480,7 +8618,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8480
8618
|
setConfirmation(void 0);
|
|
8481
8619
|
setBusy(false);
|
|
8482
8620
|
setFailed(false);
|
|
8483
|
-
if (props.remote !== void 0 && !props.authorizationBusy) run(() => props.remote.
|
|
8621
|
+
if (props.remote !== void 0 && !props.authorizationBusy) run(() => props.remote.ensureIdentity());
|
|
8484
8622
|
return () => {
|
|
8485
8623
|
owner.active = false;
|
|
8486
8624
|
owner.generation++;
|
|
@@ -8492,6 +8630,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8492
8630
|
props.authorizationBusy,
|
|
8493
8631
|
props.configured
|
|
8494
8632
|
]);
|
|
8633
|
+
(0, react.useEffect)(() => {
|
|
8634
|
+
if (props.remote === void 0 || props.authorizationBusy || view?.operation !== void 0) return;
|
|
8635
|
+
const ensure = () => {
|
|
8636
|
+
if (document.visibilityState !== "hidden") run(() => props.remote.ensureIdentity());
|
|
8637
|
+
};
|
|
8638
|
+
const timer = window.setInterval(ensure, 6e4);
|
|
8639
|
+
document.addEventListener("visibilitychange", ensure);
|
|
8640
|
+
return () => {
|
|
8641
|
+
window.clearInterval(timer);
|
|
8642
|
+
document.removeEventListener("visibilitychange", ensure);
|
|
8643
|
+
};
|
|
8644
|
+
}, [
|
|
8645
|
+
props.remote,
|
|
8646
|
+
props.authorizationBusy,
|
|
8647
|
+
view?.operation,
|
|
8648
|
+
run
|
|
8649
|
+
]);
|
|
8495
8650
|
(0, react.useEffect)(() => {
|
|
8496
8651
|
if (view?.operation !== "authorizing" || props.remote === void 0) return;
|
|
8497
8652
|
const timer = window.setTimeout(() => {
|
|
@@ -8768,7 +8923,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8768
8923
|
generation: 0,
|
|
8769
8924
|
busy: false
|
|
8770
8925
|
});
|
|
8771
|
-
const identityRead = (0, react.useRef)(false);
|
|
8772
8926
|
const close = (0, react.useCallback)((restore = false) => {
|
|
8773
8927
|
setOpen(false);
|
|
8774
8928
|
if (restore) trigger.current?.focus();
|
|
@@ -8782,10 +8936,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8782
8936
|
setBusy(true);
|
|
8783
8937
|
setFailed(false);
|
|
8784
8938
|
try {
|
|
8785
|
-
const identityOperation = props.accountsRemote === void 0 ? void 0 : force
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8939
|
+
const identityOperation = props.accountsRemote === void 0 ? void 0 : (force ? props.accountsRemote.refreshIdentity() : props.accountsRemote.ensureIdentity()).catch(() => void 0);
|
|
8940
|
+
const [result, identityResult, sessionResult] = await Promise.all([
|
|
8941
|
+
force ? props.remote.refresh() : props.remote.get(),
|
|
8942
|
+
props.accountsRemote?.get().catch(() => void 0),
|
|
8943
|
+
props.sessionAccount?.get()
|
|
8944
|
+
]);
|
|
8789
8945
|
if (!current()) return;
|
|
8790
8946
|
const sessionView = sessionResult?.ok ? SessionAccountViewSchema.safeParse(sessionResult.value) : void 0;
|
|
8791
8947
|
setSessionAccount(sessionView?.success ? sessionView.data : void 0);
|
|
@@ -8797,6 +8953,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8797
8953
|
setView(void 0);
|
|
8798
8954
|
setFailed(true);
|
|
8799
8955
|
} else setView(parsed.data);
|
|
8956
|
+
owner.busy = false;
|
|
8957
|
+
setBusy(false);
|
|
8958
|
+
const renewed = await identityOperation;
|
|
8959
|
+
if (!current()) return;
|
|
8960
|
+
const renewedView = renewed?.ok === true ? accountsViewFrom(renewed.value) : void 0;
|
|
8961
|
+
if (renewedView !== void 0 && renewedView.activeAccountId === identityView?.activeAccountId) setAccounts(renewedView);
|
|
8962
|
+
else if (props.accountsRemote !== void 0) {
|
|
8963
|
+
setAccounts(void 0);
|
|
8964
|
+
if (renewedView !== void 0) {
|
|
8965
|
+
setView(void 0);
|
|
8966
|
+
setFailed(true);
|
|
8967
|
+
}
|
|
8968
|
+
}
|
|
8800
8969
|
} catch {
|
|
8801
8970
|
if (current()) {
|
|
8802
8971
|
setView(void 0);
|
|
@@ -8827,7 +8996,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8827
8996
|
setSavingAccount(false);
|
|
8828
8997
|
setAccountFailed(false);
|
|
8829
8998
|
setAccountSaveFailed(false);
|
|
8830
|
-
identityRead.current = false;
|
|
8831
8999
|
setFailed(false);
|
|
8832
9000
|
setBusy(false);
|
|
8833
9001
|
setOpen(false);
|
|
@@ -8849,7 +9017,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8849
9017
|
setView(void 0);
|
|
8850
9018
|
setBusy(false);
|
|
8851
9019
|
setFailed(false);
|
|
8852
|
-
identityRead.current = false;
|
|
8853
9020
|
if (!accountPresentationChanges.pending()) load(false);
|
|
8854
9021
|
});
|
|
8855
9022
|
return () => {
|
|
@@ -8886,7 +9053,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8886
9053
|
setSessionAccount(parsed.data);
|
|
8887
9054
|
setAccounts(parsed.data.accounts);
|
|
8888
9055
|
setView(void 0);
|
|
8889
|
-
identityRead.current = false;
|
|
8890
9056
|
setChoosingAccount(false);
|
|
8891
9057
|
owner.save = void 0;
|
|
8892
9058
|
setSavingAccount(false);
|
|
@@ -9185,7 +9351,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
9185
9351
|
return record$2(value) && typeof value.get === "function" && typeof value.refresh === "function";
|
|
9186
9352
|
}
|
|
9187
9353
|
function isSessionRemote(value) {
|
|
9188
|
-
return record$2(value) && typeof value.get === "function" && typeof value.set === "function" && typeof value.refreshIdentity === "function" && typeof value.usage === "function" && typeof value.refreshUsage === "function";
|
|
9354
|
+
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";
|
|
9189
9355
|
}
|
|
9190
9356
|
function isLocale$2(value) {
|
|
9191
9357
|
return record$2(value) && typeof value.getLocale === "function" && typeof value.subscribe === "function";
|
|
@@ -9234,6 +9400,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
9234
9400
|
ok: true,
|
|
9235
9401
|
value: result.value.accounts
|
|
9236
9402
|
} : result;
|
|
9403
|
+
},
|
|
9404
|
+
ensureIdentity: async () => {
|
|
9405
|
+
const result = await sessionRemote.ensureIdentity(id);
|
|
9406
|
+
return result.ok ? {
|
|
9407
|
+
ok: true,
|
|
9408
|
+
value: result.value.accounts
|
|
9409
|
+
} : result;
|
|
9237
9410
|
}
|
|
9238
9411
|
},
|
|
9239
9412
|
account: {
|
|
@@ -9284,7 +9457,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
9284
9457
|
if (isRemote(face)) remote = face;
|
|
9285
9458
|
else diagnostic("COPILOT_USAGE_REMOTE_UNAVAILABLE");
|
|
9286
9459
|
const accounts = record$2(namespaces) ? namespaces.githubCopilotAccounts : void 0;
|
|
9287
|
-
if (record$2(accounts) && typeof accounts.get === "function" && typeof accounts.refreshIdentity === "function") accountsRemote = accounts;
|
|
9460
|
+
if (record$2(accounts) && typeof accounts.get === "function" && typeof accounts.refreshIdentity === "function" && typeof accounts.ensureIdentity === "function") accountsRemote = accounts;
|
|
9288
9461
|
else diagnostic("COPILOT_ACCOUNTS_REMOTE_UNAVAILABLE");
|
|
9289
9462
|
const session = record$2(namespaces) ? namespaces.githubCopilotSessionAccount : void 0;
|
|
9290
9463
|
if (isSessionRemote(session)) sessionRemote = session;
|