dsh-github-copilot 0.4.0-alpha.72 → 0.4.0-alpha.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -1
- package/CHANGELOG.md +6 -0
- package/README.md +8 -7
- package/README.zh.md +8 -7
- package/deployment-baseline.json +20 -1
- package/docs/copilot-usage.md +12 -0
- package/lib/client.js +244 -98
- package/lib/client.js.map +1 -1
- package/lib/index.js +203 -3
- package/lib/types/context-evidence-ui.d.ts +11 -0
- package/lib/types/context-evidence.d.ts +108 -0
- package/lib/types/context-usage-guard.d.ts +10 -0
- package/package.json +2 -1
package/lib/client.js
CHANGED
|
@@ -5891,21 +5891,26 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5891
5891
|
]
|
|
5892
5892
|
};
|
|
5893
5893
|
const GITHUB_COPILOT_PREVIEW_PROVIDER_ID = "github-copilot-preview";
|
|
5894
|
+
function autoModelPreference(model) {
|
|
5895
|
+
if (model === "auto") return "balance";
|
|
5896
|
+
if (model === "auto-efficiency") return "efficiency";
|
|
5897
|
+
if (model === "auto-intelligence") return "intelligence";
|
|
5898
|
+
}
|
|
5894
5899
|
//#endregion
|
|
5895
5900
|
//#region lib/types/reasoning-presentation.js
|
|
5896
5901
|
/** Plugin-owned, Step-scoped provenance; never a model route or durable message. */
|
|
5897
5902
|
const ASSISTANT_ORIGIN_KEY = "github-copilot-assistant-origin";
|
|
5898
5903
|
const CHAT_NODE_SLOT = "conversation.chat.node";
|
|
5899
5904
|
const ASSISTANT_KEY = "assistant-step";
|
|
5900
|
-
const noop$
|
|
5901
|
-
function record$
|
|
5905
|
+
const noop$3 = () => {};
|
|
5906
|
+
function record$5(value) {
|
|
5902
5907
|
return typeof value === "object" && value !== null;
|
|
5903
5908
|
}
|
|
5904
5909
|
function sequence$1(value) {
|
|
5905
5910
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
5906
5911
|
}
|
|
5907
5912
|
function eventLocation(event) {
|
|
5908
|
-
if (!record$
|
|
5913
|
+
if (!record$5(event) || !record$5(event.data)) return void 0;
|
|
5909
5914
|
const { turn, step } = event.data;
|
|
5910
5915
|
return sequence$1(turn) && sequence$1(step) ? {
|
|
5911
5916
|
turn,
|
|
@@ -5913,9 +5918,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5913
5918
|
} : void 0;
|
|
5914
5919
|
}
|
|
5915
5920
|
function messageOrigin(event) {
|
|
5916
|
-
if (!record$
|
|
5921
|
+
if (!record$5(event) || event.type !== "assistant/message" || event.surfaceOp !== "append" || !sequence$1(event.seq) || !record$5(event.data) || !record$5(event.data.message)) return void 0;
|
|
5917
5922
|
const source = event.data.message.source;
|
|
5918
|
-
if (!record$
|
|
5923
|
+
if (!record$5(source) || typeof source.provider !== "string" || source.provider.trim() === "" || typeof source.model !== "string" || source.model.trim() === "") return void 0;
|
|
5919
5924
|
return {
|
|
5920
5925
|
seq: event.seq,
|
|
5921
5926
|
provider: source.provider,
|
|
@@ -5926,7 +5931,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5926
5931
|
const assistantOriginDefinition = {
|
|
5927
5932
|
kind: ASSISTANT_ORIGIN_KEY,
|
|
5928
5933
|
match(event) {
|
|
5929
|
-
if (!record$
|
|
5934
|
+
if (!record$5(event)) return null;
|
|
5930
5935
|
const location = eventLocation(event);
|
|
5931
5936
|
if (location === void 0) return null;
|
|
5932
5937
|
if (event.type === "step/start") return {
|
|
@@ -5941,14 +5946,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5941
5946
|
},
|
|
5942
5947
|
start(_context, match) {
|
|
5943
5948
|
const location = eventLocation(match.event);
|
|
5944
|
-
if (location === void 0 || !record$
|
|
5949
|
+
if (location === void 0 || !record$5(match.event) || match.event.type !== "step/start") throw new Error("COPILOT_REASONING_ORIGIN_START: expected step/start");
|
|
5945
5950
|
return {
|
|
5946
5951
|
...location,
|
|
5947
5952
|
origin: void 0
|
|
5948
5953
|
};
|
|
5949
5954
|
},
|
|
5950
5955
|
update(context, match) {
|
|
5951
|
-
if (!record$
|
|
5956
|
+
if (!record$5(match.event) || match.event.type !== "assistant/message" || match.event.surfaceOp !== "append") return context.state;
|
|
5952
5957
|
return {
|
|
5953
5958
|
...context.state,
|
|
5954
5959
|
origin: messageOrigin(match.event)
|
|
@@ -5959,7 +5964,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5959
5964
|
let state = context.state;
|
|
5960
5965
|
if (state === void 0) for (const match of context.matches) {
|
|
5961
5966
|
const event = match.event;
|
|
5962
|
-
if (!record$
|
|
5967
|
+
if (!record$5(event) || event.type !== "assistant/message" || event.surfaceOp !== "append") continue;
|
|
5963
5968
|
const location = eventLocation(event);
|
|
5964
5969
|
if (location !== void 0) state = {
|
|
5965
5970
|
...location,
|
|
@@ -5980,12 +5985,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5980
5985
|
};
|
|
5981
5986
|
/** Shallow UI-only projection. Unchanged input retains its exact props identity. */
|
|
5982
5987
|
function projectReasoningPresentation(props, origin) {
|
|
5983
|
-
if (!record$
|
|
5988
|
+
if (!record$5(props) || !record$5(props.node) || props.node.kind !== ASSISTANT_KEY || !record$5(props.node.data) || !record$5(origin)) return props;
|
|
5984
5989
|
const node = props.node;
|
|
5985
5990
|
const data = node.data;
|
|
5986
|
-
if (data.status !== "settled" || !record$
|
|
5991
|
+
if (data.status !== "settled" || !record$5(data.finalNode) || !sequence$1(data.finalNode.seq) || origin.seq !== data.finalNode.seq) return props;
|
|
5987
5992
|
if (!(origin.provider === "github-copilot" || origin.provider === "github-copilot-preview") || typeof origin.model !== "string" || origin.model.trim() === "" || !Array.isArray(data.blocks)) return props;
|
|
5988
|
-
const blocks = data.blocks.filter((block) => !(record$
|
|
5993
|
+
const blocks = data.blocks.filter((block) => !(record$5(block) && block.kind === "reasoning" && typeof block.text === "string" && block.text.trim() === ""));
|
|
5989
5994
|
if (blocks.length === data.blocks.length) return props;
|
|
5990
5995
|
return {
|
|
5991
5996
|
...props,
|
|
@@ -6000,16 +6005,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6000
6005
|
}
|
|
6001
6006
|
const missingOriginSource = {
|
|
6002
6007
|
getSnapshot: () => void 0,
|
|
6003
|
-
subscribe: () => noop$
|
|
6008
|
+
subscribe: () => noop$3
|
|
6004
6009
|
};
|
|
6005
6010
|
function originSource(props) {
|
|
6006
6011
|
const node = props.node;
|
|
6007
|
-
if (!record$
|
|
6012
|
+
if (!record$5(node) || !record$5(node.location) || node.location.kind !== "step" || !record$5(node.location.step) || !record$5(node.location.step.data)) return missingOriginSource;
|
|
6008
6013
|
const store = node.location.step.data;
|
|
6009
6014
|
if (typeof store.source !== "function") return missingOriginSource;
|
|
6010
6015
|
try {
|
|
6011
6016
|
const source = store.source(ASSISTANT_ORIGIN_KEY);
|
|
6012
|
-
if (!record$
|
|
6017
|
+
if (!record$5(source) || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function") return missingOriginSource;
|
|
6013
6018
|
return source;
|
|
6014
6019
|
} catch {
|
|
6015
6020
|
return missingOriginSource;
|
|
@@ -6023,7 +6028,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6023
6028
|
*/
|
|
6024
6029
|
function supportedNative(entry) {
|
|
6025
6030
|
const component = entry.component;
|
|
6026
|
-
return (entry.options.priority ?? 0) === 0 && entry.locale === "chat" && entry.options.id === void 0 && entry.options.order === void 0 && entry.options.label === void 0 && entry.inject === void 0 && entry.store === void 0 && entry.children === void 0 && entry.select === void 0 && record$
|
|
6031
|
+
return (entry.options.priority ?? 0) === 0 && entry.locale === "chat" && entry.options.id === void 0 && entry.options.order === void 0 && entry.options.label === void 0 && entry.inject === void 0 && entry.store === void 0 && entry.children === void 0 && entry.select === void 0 && record$5(component) && component.$$typeof === Symbol.for("react.memo") && typeof component.type === "function" && component.type.name === "AssistantNodeView";
|
|
6027
6032
|
}
|
|
6028
6033
|
/**
|
|
6029
6034
|
* Optional Client enhancement. The caller owns the returned disposer in its
|
|
@@ -6033,20 +6038,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6033
6038
|
const { diagnostic } = capabilities;
|
|
6034
6039
|
const slotsCandidate = capabilities.slots;
|
|
6035
6040
|
const conversation = capabilities.uiConversation;
|
|
6036
|
-
if (!record$
|
|
6041
|
+
if (!record$5(slotsCandidate) || ![
|
|
6037
6042
|
"entries",
|
|
6038
6043
|
"spec",
|
|
6039
6044
|
"subscribe",
|
|
6040
6045
|
"inject",
|
|
6041
6046
|
"register"
|
|
6042
|
-
].every((key) => typeof slotsCandidate[key] === "function") || !record$
|
|
6047
|
+
].every((key) => typeof slotsCandidate[key] === "function") || !record$5(conversation) || !record$5(conversation.events) || typeof conversation.events.register !== "function") {
|
|
6043
6048
|
diagnostic("COPILOT_REASONING_PRESENTATION_UNAVAILABLE");
|
|
6044
|
-
return noop$
|
|
6049
|
+
return noop$3;
|
|
6045
6050
|
}
|
|
6046
6051
|
const slots = slotsCandidate;
|
|
6047
6052
|
const events = conversation.events;
|
|
6048
|
-
let removeOrigin = noop$
|
|
6049
|
-
let removeInjection = noop$
|
|
6053
|
+
let removeOrigin = noop$3;
|
|
6054
|
+
let removeInjection = noop$3;
|
|
6050
6055
|
let disposed = false;
|
|
6051
6056
|
try {
|
|
6052
6057
|
removeOrigin = events.register(assistantOriginDefinition);
|
|
@@ -6054,7 +6059,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6054
6059
|
const spec = slots.spec(CHAT_NODE_SLOT);
|
|
6055
6060
|
if (spec?.kind !== "keyed" || spec.scope !== "session") {
|
|
6056
6061
|
diagnostic("COPILOT_REASONING_SLOT_UNSUPPORTED");
|
|
6057
|
-
return noop$
|
|
6062
|
+
return noop$3;
|
|
6058
6063
|
}
|
|
6059
6064
|
let active = true;
|
|
6060
6065
|
let reconciling = false;
|
|
@@ -6062,7 +6067,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6062
6067
|
let native;
|
|
6063
6068
|
let failedNative;
|
|
6064
6069
|
let wrapper;
|
|
6065
|
-
let unregister = noop$
|
|
6070
|
+
let unregister = noop$3;
|
|
6066
6071
|
let lastDiagnostic;
|
|
6067
6072
|
const report = (code) => {
|
|
6068
6073
|
if (lastDiagnostic !== code) diagnostic(code);
|
|
@@ -6070,7 +6075,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6070
6075
|
};
|
|
6071
6076
|
const retire = () => {
|
|
6072
6077
|
const remove = unregister;
|
|
6073
|
-
unregister = noop$
|
|
6078
|
+
unregister = noop$3;
|
|
6074
6079
|
native = void 0;
|
|
6075
6080
|
remove();
|
|
6076
6081
|
wrapper = void 0;
|
|
@@ -6132,7 +6137,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6132
6137
|
removeInjection();
|
|
6133
6138
|
removeOrigin();
|
|
6134
6139
|
diagnostic("COPILOT_REASONING_REGISTRATION_FAILED");
|
|
6135
|
-
return noop$
|
|
6140
|
+
return noop$3;
|
|
6136
6141
|
}
|
|
6137
6142
|
return () => {
|
|
6138
6143
|
if (disposed) return;
|
|
@@ -6144,14 +6149,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6144
6149
|
//#endregion
|
|
6145
6150
|
//#region lib/types/turn-model-provenance.js
|
|
6146
6151
|
const TURN_MODEL_PROVENANCE_KEY = "github-copilot-turn-model-provenance";
|
|
6147
|
-
function record$
|
|
6152
|
+
function record$4(value) {
|
|
6148
6153
|
return typeof value === "object" && value !== null;
|
|
6149
6154
|
}
|
|
6150
6155
|
function isTurnModelProvenance(value) {
|
|
6151
|
-
return record$
|
|
6156
|
+
return record$4(value) && typeof value.ended === "boolean" && typeof value.incomplete === "boolean" && Array.isArray(value.routes) && value.routes.every((route) => record$4(route) && typeof route.provider === "string" && route.provider.trim() !== "" && typeof route.model === "string" && route.model.trim() !== "");
|
|
6152
6157
|
}
|
|
6153
6158
|
function coordinates(event) {
|
|
6154
|
-
if (!record$
|
|
6159
|
+
if (!record$4(event) || typeof event.type !== "string" || !record$4(event.data) || !Number.isSafeInteger(event.data.turn) || typeof event.data.turn !== "number" || event.data.turn < 0 || ![
|
|
6155
6160
|
"turn/start",
|
|
6156
6161
|
"turn/end",
|
|
6157
6162
|
"step/start",
|
|
@@ -6184,8 +6189,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6184
6189
|
let missing = false;
|
|
6185
6190
|
let route;
|
|
6186
6191
|
if (parsed.type === "assistant/message") {
|
|
6187
|
-
const source = record$
|
|
6188
|
-
if (record$
|
|
6192
|
+
const source = record$4(parsed.data.message) ? parsed.data.message.source : void 0;
|
|
6193
|
+
if (record$4(source) && typeof source.provider === "string" && source.provider.trim() !== "" && typeof source.model === "string" && source.model.trim() !== "") route = {
|
|
6189
6194
|
provider: source.provider,
|
|
6190
6195
|
model: source.model
|
|
6191
6196
|
};
|
|
@@ -6368,15 +6373,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6368
6373
|
//#region lib/types/auto-model-presentation.js
|
|
6369
6374
|
const AUTO_MODEL_ATTRIBUTION_KEY = "github-copilot-auto-model-attribution";
|
|
6370
6375
|
const SLOT = "conversation.chat.assistant-actions";
|
|
6371
|
-
const noop$
|
|
6372
|
-
function record$
|
|
6376
|
+
const noop$2 = () => {};
|
|
6377
|
+
function record$3(value) {
|
|
6373
6378
|
return typeof value === "object" && value !== null;
|
|
6374
6379
|
}
|
|
6375
6380
|
function sequence(value) {
|
|
6376
6381
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
6377
6382
|
}
|
|
6378
6383
|
function attribution(event) {
|
|
6379
|
-
if (!record$
|
|
6384
|
+
if (!record$3(event) || event.type !== "github-copilot/auto-model-decision" || !record$3(event.data) || !sequence(event.data.turn) || event.data.provider !== "github-copilot-preview" || typeof event.data.model !== "string" || event.data.model.trim() === "" || ![
|
|
6380
6385
|
"fast",
|
|
6381
6386
|
"balanced",
|
|
6382
6387
|
"strong"
|
|
@@ -6438,14 +6443,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6438
6443
|
};
|
|
6439
6444
|
const missingSource = {
|
|
6440
6445
|
getSnapshot: () => void 0,
|
|
6441
|
-
subscribe: () => noop$
|
|
6446
|
+
subscribe: () => noop$2
|
|
6442
6447
|
};
|
|
6443
6448
|
function sourceOf(props, key, diagnostic) {
|
|
6444
6449
|
const turn = props.turn;
|
|
6445
|
-
if (!record$
|
|
6450
|
+
if (!record$3(turn) || !record$3(turn.data) || typeof turn.data.source !== "function") return missingSource;
|
|
6446
6451
|
try {
|
|
6447
6452
|
const source = turn.data.source(key);
|
|
6448
|
-
return record$
|
|
6453
|
+
return record$3(source) && typeof source.getSnapshot === "function" && typeof source.subscribe === "function" ? source : missingSource;
|
|
6449
6454
|
} catch {
|
|
6450
6455
|
diagnostic("COPILOT_TURN_SELECTION_PROJECTION_FAILED");
|
|
6451
6456
|
return missingSource;
|
|
@@ -6456,7 +6461,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6456
6461
|
}
|
|
6457
6462
|
function findTail(snapshot, messageId, diagnostic) {
|
|
6458
6463
|
if (typeof messageId !== "string") return void 0;
|
|
6459
|
-
if (!record$
|
|
6464
|
+
if (!record$3(snapshot) || !record$3(snapshot.nodes) || typeof snapshot.nodes.values !== "function") {
|
|
6460
6465
|
diagnostic("COPILOT_TURN_SELECTION_CHAT_NODES_UNAVAILABLE");
|
|
6461
6466
|
return;
|
|
6462
6467
|
}
|
|
@@ -6466,14 +6471,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6466
6471
|
return;
|
|
6467
6472
|
}
|
|
6468
6473
|
for (const node of nodes) {
|
|
6469
|
-
if (!record$
|
|
6474
|
+
if (!record$3(node) || node.kind !== "turn-tail" || !record$3(node.data) || !record$3(node.data.closing)) continue;
|
|
6470
6475
|
const closing = node.data.closing;
|
|
6471
|
-
if (record$
|
|
6476
|
+
if (record$3(closing.finalNode) && closing.finalNode.messageId === messageId && record$3(node.location)) return node;
|
|
6472
6477
|
}
|
|
6473
6478
|
}
|
|
6474
6479
|
function Attribution(props) {
|
|
6475
6480
|
const [live, setLive] = react.useState({ mode: "unknown" });
|
|
6476
|
-
const turn = record$
|
|
6481
|
+
const turn = record$3(props.turn) && sequence(props.turn.turn) ? props.turn.turn : void 0;
|
|
6477
6482
|
const sessionId = typeof props.sessionId === "string" ? props.sessionId : void 0;
|
|
6478
6483
|
react.useEffect(() => {
|
|
6479
6484
|
setLive({ mode: "unknown" });
|
|
@@ -6496,7 +6501,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6496
6501
|
turn,
|
|
6497
6502
|
props.diagnostic
|
|
6498
6503
|
]);
|
|
6499
|
-
const language = react.useSyncExternalStore(props.locale ? (listener) => props.locale.subscribe(listener) : () => noop$
|
|
6504
|
+
const language = react.useSyncExternalStore(props.locale ? (listener) => props.locale.subscribe(listener) : () => noop$2, () => props.locale?.getLocale().active ?? "en", () => "en");
|
|
6500
6505
|
const source = sourceOf(props, AUTO_MODEL_ATTRIBUTION_KEY, props.diagnostic);
|
|
6501
6506
|
const value = react.useSyncExternalStore(source.subscribe, source.getSnapshot, source.getSnapshot);
|
|
6502
6507
|
const provenanceSource = sourceOf(props, TURN_MODEL_PROVENANCE_KEY, props.diagnostic);
|
|
@@ -6504,17 +6509,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6504
6509
|
const parsed = attribution({
|
|
6505
6510
|
type: "github-copilot/auto-model-decision",
|
|
6506
6511
|
data: {
|
|
6507
|
-
...record$
|
|
6512
|
+
...record$3(value) ? value : {},
|
|
6508
6513
|
turn: 0
|
|
6509
6514
|
}
|
|
6510
6515
|
})?.value;
|
|
6511
6516
|
const evidence = isTurnModelProvenance(provenance) ? provenance : void 0;
|
|
6512
|
-
const native = record$
|
|
6517
|
+
const native = record$3(props.tail) && record$3(props.tail.data) ? props.tail.data : void 0;
|
|
6513
6518
|
const nativeCompleted = native?.turn === turn && sequence(native?.seq);
|
|
6514
6519
|
if (evidence?.ended !== true && !nativeCompleted) return null;
|
|
6515
6520
|
if (evidence === void 0) props.diagnostic("COPILOT_TURN_SELECTION_PROVENANCE_UNAVAILABLE");
|
|
6516
|
-
const nativeRoutes = nativeCompleted && record$
|
|
6517
|
-
if (!(evidence?.routes ?? nativeRoutes).some((route) => record$
|
|
6521
|
+
const nativeRoutes = nativeCompleted && record$3(native?.tokenUsage) && Array.isArray(native.tokenUsage.routes) ? native.tokenUsage.routes : [];
|
|
6522
|
+
if (!(evidence?.routes ?? nativeRoutes).some((route) => record$3(route) && (route.provider === "github-copilot-preview" || route.provider === "github-copilot") && typeof route.model === "string" && route.model.trim() !== "") && parsed === void 0 && live.mode === "unknown") return null;
|
|
6518
6523
|
const selection = live.mode !== "unknown" ? live : parsed?.preference ? {
|
|
6519
6524
|
mode: "auto",
|
|
6520
6525
|
preference: parsed.preference,
|
|
@@ -6529,13 +6534,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6529
6534
|
});
|
|
6530
6535
|
}
|
|
6531
6536
|
function installAutoModelProjections(capabilities) {
|
|
6532
|
-
if (!record$
|
|
6537
|
+
if (!record$3(capabilities.uiConversation) || !record$3(capabilities.uiConversation.events) || typeof capabilities.uiConversation.events.register !== "function") {
|
|
6533
6538
|
capabilities.diagnostic("COPILOT_AUTO_PROJECTIONS_UNAVAILABLE");
|
|
6534
|
-
return noop$
|
|
6539
|
+
return noop$2;
|
|
6535
6540
|
}
|
|
6536
6541
|
const events = capabilities.uiConversation.events;
|
|
6537
|
-
let removeDefinition = noop$
|
|
6538
|
-
let removeProvenance = noop$
|
|
6542
|
+
let removeDefinition = noop$2;
|
|
6543
|
+
let removeProvenance = noop$2;
|
|
6539
6544
|
try {
|
|
6540
6545
|
removeDefinition = events.register(autoModelAttributionDefinition);
|
|
6541
6546
|
removeProvenance = events.register(turnModelProvenanceDefinition);
|
|
@@ -6543,7 +6548,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6543
6548
|
removeProvenance();
|
|
6544
6549
|
removeDefinition();
|
|
6545
6550
|
capabilities.diagnostic("COPILOT_AUTO_PROJECTIONS_FAILED");
|
|
6546
|
-
return noop$
|
|
6551
|
+
return noop$2;
|
|
6547
6552
|
}
|
|
6548
6553
|
return () => {
|
|
6549
6554
|
removeProvenance();
|
|
@@ -6559,18 +6564,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6559
6564
|
}
|
|
6560
6565
|
};
|
|
6561
6566
|
const slotsCandidate = capabilities.slots;
|
|
6562
|
-
if (!record$
|
|
6567
|
+
if (!record$3(slotsCandidate) || ![
|
|
6563
6568
|
"spec",
|
|
6564
6569
|
"inject",
|
|
6565
6570
|
"register"
|
|
6566
6571
|
].every((key) => typeof slotsCandidate[key] === "function")) {
|
|
6567
6572
|
diagnostic("COPILOT_AUTO_PRESENTATION_UNAVAILABLE");
|
|
6568
|
-
return noop$
|
|
6573
|
+
return noop$2;
|
|
6569
6574
|
}
|
|
6570
6575
|
const slots = slotsCandidate;
|
|
6571
|
-
const face = record$
|
|
6572
|
-
const remote = record$
|
|
6573
|
-
const locale = record$
|
|
6576
|
+
const face = record$3(capabilities.remote) ? capabilities.remote.githubCopilotTurnSelection : void 0;
|
|
6577
|
+
const remote = record$3(face) && typeof face.get === "function" ? face : void 0;
|
|
6578
|
+
const locale = record$3(capabilities.locale) && typeof capabilities.locale.getLocale === "function" && typeof capabilities.locale.subscribe === "function" ? capabilities.locale : void 0;
|
|
6574
6579
|
if (!remote) diagnostic("COPILOT_TURN_SELECTION_REMOTE_UNAVAILABLE");
|
|
6575
6580
|
function Entry(props) {
|
|
6576
6581
|
if (typeof props.useChat !== "function") {
|
|
@@ -6579,8 +6584,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6579
6584
|
}
|
|
6580
6585
|
const useChat = props.useChat;
|
|
6581
6586
|
const tail = useChat((snapshot) => findTail(snapshot, props.messageId, diagnostic));
|
|
6582
|
-
const turn = record$
|
|
6583
|
-
if (!record$
|
|
6587
|
+
const turn = record$3(tail) && record$3(tail.location) ? tail.location.turn : void 0;
|
|
6588
|
+
if (!record$3(turn) || !sequence(turn.turn)) return null;
|
|
6584
6589
|
return react.createElement(Attribution, {
|
|
6585
6590
|
...props,
|
|
6586
6591
|
key: `${props.sessionId}:${turn.turn}`,
|
|
@@ -6591,16 +6596,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6591
6596
|
diagnostic
|
|
6592
6597
|
});
|
|
6593
6598
|
}
|
|
6594
|
-
const removeProjections = capabilities.uiConversation === void 0 ? noop$
|
|
6599
|
+
const removeProjections = capabilities.uiConversation === void 0 ? noop$2 : installAutoModelProjections({
|
|
6595
6600
|
uiConversation: capabilities.uiConversation,
|
|
6596
6601
|
diagnostic
|
|
6597
6602
|
});
|
|
6598
|
-
let removeInjection = noop$
|
|
6603
|
+
let removeInjection = noop$2;
|
|
6599
6604
|
try {
|
|
6600
6605
|
removeInjection = slots.inject(SLOT, () => {
|
|
6601
6606
|
if (slots.spec(SLOT)?.kind !== "list" || slots.spec(SLOT)?.scope !== "session") {
|
|
6602
6607
|
diagnostic("COPILOT_AUTO_ACTIONS_SLOT_UNAVAILABLE");
|
|
6603
|
-
return noop$
|
|
6608
|
+
return noop$2;
|
|
6604
6609
|
}
|
|
6605
6610
|
return slots.register({
|
|
6606
6611
|
name: SLOT,
|
|
@@ -6612,7 +6617,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6612
6617
|
removeInjection();
|
|
6613
6618
|
removeProjections();
|
|
6614
6619
|
diagnostic("COPILOT_AUTO_PRESENTATION_FAILED");
|
|
6615
|
-
return noop$
|
|
6620
|
+
return noop$2;
|
|
6616
6621
|
}
|
|
6617
6622
|
return () => {
|
|
6618
6623
|
removeInjection();
|
|
@@ -6720,7 +6725,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6720
6725
|
overflowWrap: "anywhere",
|
|
6721
6726
|
margin: 0
|
|
6722
6727
|
};
|
|
6723
|
-
function record$
|
|
6728
|
+
function record$2(value) {
|
|
6724
6729
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
6725
6730
|
}
|
|
6726
6731
|
function revisionOf(value) {
|
|
@@ -6730,7 +6735,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6730
6735
|
return id === GITHUB_COPILOT_SEARCH_PROVIDER ? "GitHub Copilot" : id === DEEPSEEK_SEARCH_PROVIDER ? "DeepSeek" : id;
|
|
6731
6736
|
}
|
|
6732
6737
|
function saveFailure(error) {
|
|
6733
|
-
const code = record$
|
|
6738
|
+
const code = record$2(error).code;
|
|
6734
6739
|
if (code === "settings-conflict") return "Search settings changed since you opened this page. Reload settings, then review and save your choices again.";
|
|
6735
6740
|
if (code === "settings-rejected") return "The settings service rejected this change. Reload settings to check whether editing is available, then try again.";
|
|
6736
6741
|
return "Could not confirm the save. Reload settings to check saved values before retrying. Your current choices have been kept.";
|
|
@@ -6749,7 +6754,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6749
6754
|
const timeoutLimit = 2147483647;
|
|
6750
6755
|
function searchOptions(value) {
|
|
6751
6756
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
6752
|
-
const source = record$
|
|
6757
|
+
const source = record$2(value);
|
|
6753
6758
|
const options = {
|
|
6754
6759
|
...searchDefaults,
|
|
6755
6760
|
...source
|
|
@@ -7023,9 +7028,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7023
7028
|
}
|
|
7024
7029
|
const copilot = result.value.namespaces.find((entry) => entry.ns === GITHUB_COPILOT_SETTINGS_NAMESPACE);
|
|
7025
7030
|
const legacyRouting = result.value.namespaces.find((entry) => entry.ns === WEB_SEARCH_ROUTING_SETTINGS_NAMESPACE);
|
|
7026
|
-
const copilotValue = record$
|
|
7027
|
-
const copilotRoutingValue = record$
|
|
7028
|
-
const legacyRoutingValue = record$
|
|
7031
|
+
const copilotValue = record$2(copilot?.value);
|
|
7032
|
+
const copilotRoutingValue = record$2(copilotValue.searchRouting);
|
|
7033
|
+
const legacyRoutingValue = record$2(legacyRouting?.value);
|
|
7029
7034
|
const routingValue = Object.keys(copilotRoutingValue).length > 0 ? copilotRoutingValue : legacyRoutingValue;
|
|
7030
7035
|
const normalized = normalizeWebSearchRouting({
|
|
7031
7036
|
searchProvider: typeof routingValue.searchProvider === "string" ? routingValue.searchProvider : void 0,
|
|
@@ -7542,7 +7547,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7542
7547
|
}
|
|
7543
7548
|
//#endregion
|
|
7544
7549
|
//#region lib/types/copilot-usage-card.js
|
|
7545
|
-
const copy = {
|
|
7550
|
+
const copy$1 = {
|
|
7546
7551
|
en: {
|
|
7547
7552
|
credits: "Credits",
|
|
7548
7553
|
requests: "Premium requests",
|
|
@@ -7649,7 +7654,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7649
7654
|
/** Mounted only for a proven effective Copilot selection in the owning Session. */
|
|
7650
7655
|
function CopilotUsageCard(props) {
|
|
7651
7656
|
const language = props.locale?.toLowerCase().startsWith("zh") ? "zh-CN" : "en-US";
|
|
7652
|
-
const t = language === "zh-CN" ? copy.zh : copy.en;
|
|
7657
|
+
const t = language === "zh-CN" ? copy$1.zh : copy$1.en;
|
|
7653
7658
|
const id = (0, react.useId)();
|
|
7654
7659
|
const [view, setView] = (0, react.useState)();
|
|
7655
7660
|
const [busy, setBusy] = (0, react.useState)(false);
|
|
@@ -7936,26 +7941,26 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7936
7941
|
}
|
|
7937
7942
|
//#endregion
|
|
7938
7943
|
//#region lib/types/copilot-usage-ui.js
|
|
7939
|
-
const slot = "conversation.composer.dock";
|
|
7940
|
-
const noop = () => {};
|
|
7941
|
-
const emptySubscribe = () => noop;
|
|
7942
|
-
function record(value) {
|
|
7944
|
+
const slot$1 = "conversation.composer.dock";
|
|
7945
|
+
const noop$1 = () => {};
|
|
7946
|
+
const emptySubscribe = () => noop$1;
|
|
7947
|
+
function record$1(value) {
|
|
7943
7948
|
return typeof value === "object" && value !== null;
|
|
7944
7949
|
}
|
|
7945
|
-
function isSlots(value) {
|
|
7946
|
-
return record(value) && typeof value.spec === "function" && typeof value.inject === "function" && typeof value.register === "function";
|
|
7950
|
+
function isSlots$1(value) {
|
|
7951
|
+
return record$1(value) && typeof value.spec === "function" && typeof value.inject === "function" && typeof value.register === "function";
|
|
7947
7952
|
}
|
|
7948
7953
|
function isRemote(value) {
|
|
7949
|
-
return record(value) && typeof value.get === "function" && typeof value.refresh === "function";
|
|
7954
|
+
return record$1(value) && typeof value.get === "function" && typeof value.refresh === "function";
|
|
7950
7955
|
}
|
|
7951
|
-
function isLocale(value) {
|
|
7952
|
-
return record(value) && typeof value.getLocale === "function" && typeof value.subscribe === "function";
|
|
7956
|
+
function isLocale$1(value) {
|
|
7957
|
+
return record$1(value) && typeof value.getLocale === "function" && typeof value.subscribe === "function";
|
|
7953
7958
|
}
|
|
7954
|
-
function isRuntime(value) {
|
|
7955
|
-
return record(value) && typeof value.sessionId === "string" && value.sessionId !== "" && typeof value.useSession === "function" && typeof value.useProjection === "function";
|
|
7959
|
+
function isRuntime$1(value) {
|
|
7960
|
+
return record$1(value) && typeof value.sessionId === "string" && value.sessionId !== "" && typeof value.useSession === "function" && typeof value.useProjection === "function";
|
|
7956
7961
|
}
|
|
7957
7962
|
function selection(value) {
|
|
7958
|
-
return record(value) && typeof value.provider === "string" && value.provider.trim() !== "" && typeof value.model === "string" && value.model.trim() !== "";
|
|
7963
|
+
return record$1(value) && typeof value.provider === "string" && value.provider.trim() !== "" && typeof value.model === "string" && value.model.trim() !== "";
|
|
7959
7964
|
}
|
|
7960
7965
|
/**
|
|
7961
7966
|
* Verified alpha.2 wire projection: next = pending ?? lastUsed; lastUsed is
|
|
@@ -7963,13 +7968,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7963
7968
|
* catalog. A blank Session without explicit selection waits for that evidence.
|
|
7964
7969
|
*/
|
|
7965
7970
|
function effectiveCopilot(projection) {
|
|
7966
|
-
if (!record(projection) || !(projection.lastUsed === null || selection(projection.lastUsed)) || !(projection.next === null || selection(projection.next))) return void 0;
|
|
7971
|
+
if (!record$1(projection) || !(projection.lastUsed === null || selection(projection.lastUsed)) || !(projection.next === null || selection(projection.next))) return void 0;
|
|
7967
7972
|
const next = projection.next;
|
|
7968
7973
|
if (!selection(next)) return void 0;
|
|
7969
7974
|
return next.provider === "github-copilot" || next.provider === "github-copilot-preview" ? next : void 0;
|
|
7970
7975
|
}
|
|
7971
|
-
function Surface({ runtime, remote, locale, diagnostic }) {
|
|
7972
|
-
const valid = runtime.useSession((session) => record(session) && session.sessionId === runtime.sessionId && session.removed === false && session.openState === "open");
|
|
7976
|
+
function Surface$1({ runtime, remote, locale, diagnostic }) {
|
|
7977
|
+
const valid = runtime.useSession((session) => record$1(session) && session.sessionId === runtime.sessionId && session.removed === false && session.openState === "open");
|
|
7973
7978
|
const projection = runtime.useProjection("modelSelection");
|
|
7974
7979
|
const language = (0, react.useSyncExternalStore)(locale === void 0 ? emptySubscribe : (listener) => locale.subscribe(listener), () => locale?.getLocale().active ?? "en", () => "en");
|
|
7975
7980
|
const current = effectiveCopilot(projection);
|
|
@@ -7999,45 +8004,45 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7999
8004
|
}
|
|
8000
8005
|
};
|
|
8001
8006
|
const candidate = ctx.slots;
|
|
8002
|
-
if (!isSlots(candidate)) {
|
|
8007
|
+
if (!isSlots$1(candidate)) {
|
|
8003
8008
|
diagnostic("COPILOT_USAGE_SLOT_UNAVAILABLE");
|
|
8004
|
-
return noop;
|
|
8009
|
+
return noop$1;
|
|
8005
8010
|
}
|
|
8006
8011
|
const slots = candidate;
|
|
8007
8012
|
let remote;
|
|
8008
8013
|
try {
|
|
8009
8014
|
const namespaces = ctx.remote;
|
|
8010
|
-
const face = record(namespaces) ? namespaces.githubCopilotUsage : void 0;
|
|
8015
|
+
const face = record$1(namespaces) ? namespaces.githubCopilotUsage : void 0;
|
|
8011
8016
|
if (isRemote(face)) remote = face;
|
|
8012
8017
|
else diagnostic("COPILOT_USAGE_REMOTE_UNAVAILABLE");
|
|
8013
8018
|
} catch {
|
|
8014
8019
|
diagnostic("COPILOT_USAGE_REMOTE_UNAVAILABLE");
|
|
8015
8020
|
}
|
|
8016
8021
|
const localeCandidate = ctx.get("locale");
|
|
8017
|
-
const locale = isLocale(localeCandidate) ? localeCandidate : void 0;
|
|
8022
|
+
const locale = isLocale$1(localeCandidate) ? localeCandidate : void 0;
|
|
8018
8023
|
let active = true;
|
|
8019
8024
|
let remove;
|
|
8020
|
-
let injection = noop;
|
|
8025
|
+
let injection = noop$1;
|
|
8021
8026
|
try {
|
|
8022
|
-
if (slots.spec(slot) === void 0) diagnostic("COPILOT_USAGE_SLOT_UNAVAILABLE");
|
|
8023
|
-
injection = slots.inject(slot, () => {
|
|
8024
|
-
if (!active) return noop;
|
|
8025
|
-
const spec = slots.spec(slot);
|
|
8027
|
+
if (slots.spec(slot$1) === void 0) diagnostic("COPILOT_USAGE_SLOT_UNAVAILABLE");
|
|
8028
|
+
injection = slots.inject(slot$1, () => {
|
|
8029
|
+
if (!active) return noop$1;
|
|
8030
|
+
const spec = slots.spec(slot$1);
|
|
8026
8031
|
if (spec?.kind !== "list" || spec.scope !== "session") {
|
|
8027
8032
|
diagnostic("COPILOT_USAGE_SLOT_UNAVAILABLE");
|
|
8028
|
-
return noop;
|
|
8033
|
+
return noop$1;
|
|
8029
8034
|
}
|
|
8030
8035
|
try {
|
|
8031
8036
|
const dispose = slots.register({
|
|
8032
|
-
name: slot,
|
|
8037
|
+
name: slot$1,
|
|
8033
8038
|
id: "github-copilot-usage",
|
|
8034
8039
|
order: 20
|
|
8035
8040
|
}, (props) => {
|
|
8036
|
-
if (!isRuntime(props)) {
|
|
8041
|
+
if (!isRuntime$1(props)) {
|
|
8037
8042
|
diagnostic("COPILOT_USAGE_SESSION_RUNTIME_UNAVAILABLE");
|
|
8038
8043
|
return null;
|
|
8039
8044
|
}
|
|
8040
|
-
return (0, react.createElement)(Surface, {
|
|
8045
|
+
return (0, react.createElement)(Surface$1, {
|
|
8041
8046
|
runtime: props,
|
|
8042
8047
|
remote,
|
|
8043
8048
|
locale,
|
|
@@ -8055,7 +8060,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8055
8060
|
return cleanup;
|
|
8056
8061
|
} catch {
|
|
8057
8062
|
diagnostic("COPILOT_USAGE_SLOT_UNAVAILABLE");
|
|
8058
|
-
return noop;
|
|
8063
|
+
return noop$1;
|
|
8059
8064
|
}
|
|
8060
8065
|
});
|
|
8061
8066
|
} catch {
|
|
@@ -8069,6 +8074,145 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8069
8074
|
};
|
|
8070
8075
|
}
|
|
8071
8076
|
//#endregion
|
|
8077
|
+
//#region lib/types/context-evidence.js
|
|
8078
|
+
const COPILOT_CONTEXT_EVIDENCE = "githubCopilotContextEvidence";
|
|
8079
|
+
const count = number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
8080
|
+
const routeSchema = object({
|
|
8081
|
+
provider: string().min(1),
|
|
8082
|
+
model: string().min(1)
|
|
8083
|
+
}).strict();
|
|
8084
|
+
const sampleSchema = object({
|
|
8085
|
+
tokens: count,
|
|
8086
|
+
seq: count,
|
|
8087
|
+
route: routeSchema
|
|
8088
|
+
}).strict();
|
|
8089
|
+
const ContextEvidenceSchema = object({
|
|
8090
|
+
route: routeSchema.nullable(),
|
|
8091
|
+
sample: sampleSchema.nullable(),
|
|
8092
|
+
invalid: boolean(),
|
|
8093
|
+
reason: _enum([
|
|
8094
|
+
"none",
|
|
8095
|
+
"failed-zero",
|
|
8096
|
+
"compaction",
|
|
8097
|
+
"selection",
|
|
8098
|
+
"unknown"
|
|
8099
|
+
])
|
|
8100
|
+
}).strict();
|
|
8101
|
+
object({
|
|
8102
|
+
inputTokens: count,
|
|
8103
|
+
outputTokens: count,
|
|
8104
|
+
cacheReadTokens: count.optional(),
|
|
8105
|
+
cacheWriteTokens: count.optional(),
|
|
8106
|
+
totalTokens: count.optional(),
|
|
8107
|
+
reasoningTokens: count.optional()
|
|
8108
|
+
});
|
|
8109
|
+
//#endregion
|
|
8110
|
+
//#region lib/types/context-evidence-ui.js
|
|
8111
|
+
const slot = "conversation.composer.dock";
|
|
8112
|
+
const noop = () => {};
|
|
8113
|
+
function record(value) {
|
|
8114
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8115
|
+
}
|
|
8116
|
+
function isSlots(value) {
|
|
8117
|
+
return record(value) && typeof value.spec === "function" && typeof value.inject === "function" && typeof value.register === "function";
|
|
8118
|
+
}
|
|
8119
|
+
function isLocale(value) {
|
|
8120
|
+
return record(value) && typeof value.getLocale === "function" && typeof value.subscribe === "function";
|
|
8121
|
+
}
|
|
8122
|
+
function isRuntime(value) {
|
|
8123
|
+
return record(value) && typeof value.sessionId === "string" && value.sessionId !== "" && typeof value.useSession === "function" && typeof value.useProjection === "function";
|
|
8124
|
+
}
|
|
8125
|
+
const copy = {
|
|
8126
|
+
en: {
|
|
8127
|
+
title: "Context reading unavailable",
|
|
8128
|
+
explanation: "A failed Copilot attempt reported zero usage. The native 0% is not evidence of an empty context.",
|
|
8129
|
+
sample: "Last valid input sample (including cache)",
|
|
8130
|
+
historical: "Historical sample, not current occupancy. No percentage is inferred.",
|
|
8131
|
+
revoked: "No applicable historical input sample is available. Model changes, compaction and incomplete history invalidate earlier samples.",
|
|
8132
|
+
missing: "COPILOT_CONTEXT_PROJECTION_UNAVAILABLE: historical context evidence is unavailable.",
|
|
8133
|
+
unknown: "Context sampling evidence is incomplete. No current occupancy can be inferred."
|
|
8134
|
+
},
|
|
8135
|
+
zh: {
|
|
8136
|
+
title: "上下文读数暂不可用",
|
|
8137
|
+
explanation: "失败的 Copilot 请求记录了零用量。原生 0% 不代表上下文为空。",
|
|
8138
|
+
sample: "最后有效输入采样(含缓存)",
|
|
8139
|
+
historical: "这是历史采样,不是当前占用;不会据此推算百分比。",
|
|
8140
|
+
revoked: "没有仍适用的历史输入采样。模型切换、压缩或历史证据不完整会使旧采样失效。",
|
|
8141
|
+
missing: "COPILOT_CONTEXT_PROJECTION_UNAVAILABLE:无法获取历史上下文证据。",
|
|
8142
|
+
unknown: "上下文采样证据不完整,无法据此推断当前占用。"
|
|
8143
|
+
}
|
|
8144
|
+
};
|
|
8145
|
+
function ContextEvidenceNotice({ evidence, locale = "en", applicable = true }) {
|
|
8146
|
+
if (evidence !== void 0 && !evidence.invalid) return null;
|
|
8147
|
+
const text = locale.startsWith("zh") ? copy.zh : copy.en;
|
|
8148
|
+
const sample = applicable ? evidence?.sample : null;
|
|
8149
|
+
return (0, react.createElement)("details", { style: {
|
|
8150
|
+
maxWidth: "min(100%, 38rem)",
|
|
8151
|
+
fontSize: "inherit",
|
|
8152
|
+
overflowWrap: "anywhere"
|
|
8153
|
+
} }, (0, react.createElement)("summary", { style: { cursor: "pointer" } }, text.title), (0, react.createElement)("p", { style: { marginBlock: "0.5rem" } }, evidence === void 0 ? text.missing : evidence.reason === "unknown" ? text.unknown : text.explanation), sample ? (0, react.createElement)("p", { style: { marginBlock: "0.5rem" } }, `${text.sample}: ${new Intl.NumberFormat(locale.startsWith("zh") ? "zh-CN" : "en-US").format(sample.tokens)} tokens`) : null, evidence === void 0 ? null : (0, react.createElement)("p", { style: { marginBlock: "0.5rem" } }, sample ? text.historical : text.revoked));
|
|
8154
|
+
}
|
|
8155
|
+
function Surface({ runtime, locale, diagnostic }) {
|
|
8156
|
+
const valid = runtime.useSession((value) => record(value) && value.sessionId === runtime.sessionId && value.removed === false && value.openState === "open");
|
|
8157
|
+
const selection = runtime.useProjection("modelSelection");
|
|
8158
|
+
const raw = runtime.useProjection(COPILOT_CONTEXT_EVIDENCE);
|
|
8159
|
+
const language = (0, react.useSyncExternalStore)((listener) => locale?.subscribe(listener) ?? noop, () => locale?.getLocale().active ?? "en", () => "en");
|
|
8160
|
+
const parsed = ContextEvidenceSchema.safeParse(raw);
|
|
8161
|
+
(0, react.useEffect)(() => {
|
|
8162
|
+
if (!parsed.success) diagnostic("COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
|
|
8163
|
+
}, [parsed.success, diagnostic]);
|
|
8164
|
+
if (!valid || !record(selection) || !record(selection.next)) return null;
|
|
8165
|
+
const next = selection.next;
|
|
8166
|
+
if (next.provider !== "github-copilot" && next.provider !== "github-copilot-preview") return null;
|
|
8167
|
+
const evidence = parsed.success ? parsed.data : void 0;
|
|
8168
|
+
const route = evidence?.route;
|
|
8169
|
+
const applicable = route !== null && route !== void 0 && next.provider === route.provider && (next.model === route.model || typeof next.model === "string" && autoModelPreference(next.model) !== void 0);
|
|
8170
|
+
return (0, react.createElement)(ContextEvidenceNotice, {
|
|
8171
|
+
evidence,
|
|
8172
|
+
locale: language,
|
|
8173
|
+
applicable
|
|
8174
|
+
});
|
|
8175
|
+
}
|
|
8176
|
+
/** Additive disclosure only: native input, context ring and billing remain untouched. */
|
|
8177
|
+
function registerContextEvidenceUi(ctx) {
|
|
8178
|
+
const diagnosed = /* @__PURE__ */ new Set();
|
|
8179
|
+
const diagnostic = (code) => {
|
|
8180
|
+
if (!diagnosed.has(code)) {
|
|
8181
|
+
diagnosed.add(code);
|
|
8182
|
+
ctx.logger.warn(`[github-copilot] ${code}`);
|
|
8183
|
+
}
|
|
8184
|
+
};
|
|
8185
|
+
const slots = ctx.get("slots");
|
|
8186
|
+
if (!isSlots(slots)) {
|
|
8187
|
+
diagnostic("COPILOT_CONTEXT_SLOT_UNAVAILABLE");
|
|
8188
|
+
return noop;
|
|
8189
|
+
}
|
|
8190
|
+
const candidate = ctx.get("locale");
|
|
8191
|
+
const locale = isLocale(candidate) ? candidate : void 0;
|
|
8192
|
+
return slots.inject(slot, () => {
|
|
8193
|
+
const spec = slots.spec(slot);
|
|
8194
|
+
if (spec?.kind !== "list" || spec.scope !== "session") {
|
|
8195
|
+
diagnostic("COPILOT_CONTEXT_SLOT_UNAVAILABLE");
|
|
8196
|
+
return noop;
|
|
8197
|
+
}
|
|
8198
|
+
return slots.register({
|
|
8199
|
+
name: slot,
|
|
8200
|
+
id: "github-copilot-context-evidence",
|
|
8201
|
+
order: 25
|
|
8202
|
+
}, (props) => {
|
|
8203
|
+
if (!isRuntime(props)) {
|
|
8204
|
+
diagnostic("COPILOT_CONTEXT_SESSION_RUNTIME_UNAVAILABLE");
|
|
8205
|
+
return null;
|
|
8206
|
+
}
|
|
8207
|
+
return (0, react.createElement)(Surface, {
|
|
8208
|
+
runtime: props,
|
|
8209
|
+
locale,
|
|
8210
|
+
diagnostic
|
|
8211
|
+
});
|
|
8212
|
+
});
|
|
8213
|
+
});
|
|
8214
|
+
}
|
|
8215
|
+
//#endregion
|
|
8072
8216
|
//#region lib/types/model-preferences-card.js
|
|
8073
8217
|
const controlStyle = {
|
|
8074
8218
|
color: "inherit",
|
|
@@ -9356,6 +9500,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
9356
9500
|
"slots"
|
|
9357
9501
|
], registerSearchUi);
|
|
9358
9502
|
const usageUi = ctx.inject(["remote.githubCopilotUsage", "slots"], registerCopilotUsageUi);
|
|
9503
|
+
const contextUi = ctx.inject(["slots"], registerContextEvidenceUi);
|
|
9359
9504
|
const autoUi = ctx.inject(["remote.githubCopilotTurnSelection", "slots"], (scope) => installAutoModelPresentation({
|
|
9360
9505
|
slots: scope.slots,
|
|
9361
9506
|
remote: scope.remote,
|
|
@@ -9378,6 +9523,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
9378
9523
|
};
|
|
9379
9524
|
});
|
|
9380
9525
|
return async () => {
|
|
9526
|
+
await contextUi.dispose();
|
|
9381
9527
|
await usageUi.dispose();
|
|
9382
9528
|
await autoUi.dispose();
|
|
9383
9529
|
await presentation.dispose();
|