dsh-github-copilot 0.4.0-alpha.127 → 0.4.0-alpha.128
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/CHANGELOG.md +6 -0
- package/README.md +8 -6
- package/README.zh.md +8 -6
- package/deployment-baseline.json +4 -2
- package/docs/copilot-usage.md +6 -0
- package/lib/client.js +248 -135
- package/lib/client.js.map +1 -1
- package/lib/index.js +188 -15
- package/lib/types/compaction-continuation-ui.d.ts +4 -5
- package/lib/types/context-evidence-ui.d.ts +5 -1
- package/lib/types/context-evidence.d.ts +120 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -6988,7 +6988,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6988
6988
|
};
|
|
6989
6989
|
//#endregion
|
|
6990
6990
|
//#region package.json
|
|
6991
|
-
var version = "0.4.0-alpha.
|
|
6991
|
+
var version = "0.4.0-alpha.128";
|
|
6992
6992
|
//#endregion
|
|
6993
6993
|
//#region lib/types/diagnostics-client.js
|
|
6994
6994
|
let owner;
|
|
@@ -11727,6 +11727,33 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11727
11727
|
seq: count,
|
|
11728
11728
|
route: routeSchema
|
|
11729
11729
|
}).strict();
|
|
11730
|
+
const stepSchema = object({
|
|
11731
|
+
turn: count,
|
|
11732
|
+
step: count
|
|
11733
|
+
}).strict();
|
|
11734
|
+
const compactionSchema = object({
|
|
11735
|
+
id: string().min(1).max(256),
|
|
11736
|
+
startSeq: count,
|
|
11737
|
+
endSeq: count.nullable(),
|
|
11738
|
+
state: _enum([
|
|
11739
|
+
"running",
|
|
11740
|
+
"completed",
|
|
11741
|
+
"failed",
|
|
11742
|
+
"unknown"
|
|
11743
|
+
]),
|
|
11744
|
+
checkpoint: boolean(),
|
|
11745
|
+
headerSeq: count.nullable(),
|
|
11746
|
+
requestRoute: routeSchema.nullable(),
|
|
11747
|
+
step: stepSchema.nullable(),
|
|
11748
|
+
request: _enum([
|
|
11749
|
+
"idle",
|
|
11750
|
+
"pending",
|
|
11751
|
+
"succeeded",
|
|
11752
|
+
"failed",
|
|
11753
|
+
"cancelled",
|
|
11754
|
+
"unknown"
|
|
11755
|
+
])
|
|
11756
|
+
}).strict();
|
|
11730
11757
|
const ContextEvidenceSchema = object({
|
|
11731
11758
|
route: routeSchema.nullable(),
|
|
11732
11759
|
sample: sampleSchema.nullable(),
|
|
@@ -11737,7 +11764,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11737
11764
|
"compaction",
|
|
11738
11765
|
"selection",
|
|
11739
11766
|
"unknown"
|
|
11740
|
-
])
|
|
11767
|
+
]),
|
|
11768
|
+
compaction: compactionSchema.nullable().optional(),
|
|
11769
|
+
activeStep: stepSchema.nullable().optional()
|
|
11741
11770
|
}).strict();
|
|
11742
11771
|
object({
|
|
11743
11772
|
inputTokens: count,
|
|
@@ -11748,118 +11777,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11748
11777
|
reasoningTokens: count.optional()
|
|
11749
11778
|
});
|
|
11750
11779
|
//#endregion
|
|
11751
|
-
//#region lib/types/context-evidence-ui.js
|
|
11752
|
-
const slot = "conversation.input.dock";
|
|
11753
|
-
const noop$1 = () => {};
|
|
11754
|
-
function record$1(value) {
|
|
11755
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11756
|
-
}
|
|
11757
|
-
function isSlots$1(value) {
|
|
11758
|
-
return record$1(value) && typeof value.spec === "function" && typeof value.inject === "function" && typeof value.register === "function";
|
|
11759
|
-
}
|
|
11760
|
-
function isLocale$1(value) {
|
|
11761
|
-
return record$1(value) && typeof value.getLocale === "function" && typeof value.subscribe === "function";
|
|
11762
|
-
}
|
|
11763
|
-
function isRuntime$1(value) {
|
|
11764
|
-
return record$1(value) && typeof value.sessionId === "string" && value.sessionId !== "" && typeof value.useSession === "function" && typeof value.useProjection === "function";
|
|
11765
|
-
}
|
|
11766
|
-
const copy = {
|
|
11767
|
-
en: {
|
|
11768
|
-
title: "Context unknown · native 0% is not an empty-context reading",
|
|
11769
|
-
explanation: "A failed Copilot attempt reported zero usage. The native 0% is not evidence of an empty context.",
|
|
11770
|
-
sample: "Last valid input sample (including cache)",
|
|
11771
|
-
historical: "Historical sample, not current occupancy. No percentage is inferred.",
|
|
11772
|
-
revoked: "No applicable historical input sample is available. Model changes, compaction and incomplete history invalidate earlier samples.",
|
|
11773
|
-
missing: "COPILOT_CONTEXT_PROJECTION_UNAVAILABLE: historical context evidence is unavailable.",
|
|
11774
|
-
unknown: "Context sampling evidence is incomplete. No current occupancy can be inferred."
|
|
11775
|
-
},
|
|
11776
|
-
zh: {
|
|
11777
|
-
title: "上下文未知 · 原生 0% 不代表上下文为空",
|
|
11778
|
-
explanation: "失败的 Copilot 请求记录了零用量。原生 0% 不代表上下文为空。",
|
|
11779
|
-
sample: "最后有效输入采样(含缓存)",
|
|
11780
|
-
historical: "这是历史采样,不是当前占用;不会据此推算百分比。",
|
|
11781
|
-
revoked: "没有仍适用的历史输入采样。模型切换、压缩或历史证据不完整会使旧采样失效。",
|
|
11782
|
-
missing: "COPILOT_CONTEXT_PROJECTION_UNAVAILABLE:无法获取历史上下文证据。",
|
|
11783
|
-
unknown: "上下文采样证据不完整,无法据此推断当前占用。"
|
|
11784
|
-
}
|
|
11785
|
-
};
|
|
11786
|
-
function ContextEvidenceNotice({ evidence, locale = "en", applicable = true }) {
|
|
11787
|
-
if (evidence !== void 0 && !evidence.invalid) return null;
|
|
11788
|
-
const text = locale.startsWith("zh") ? copy.zh : copy.en;
|
|
11789
|
-
const sample = applicable ? evidence?.sample : null;
|
|
11790
|
-
return (0, react.createElement)("details", {
|
|
11791
|
-
"data-copilot-composer-notice": "context",
|
|
11792
|
-
style: composerNoticeStyle
|
|
11793
|
-
}, (0, react.createElement)("summary", { style: {
|
|
11794
|
-
cursor: "pointer",
|
|
11795
|
-
fontFamily: "var(--dsw-font-family, inherit)",
|
|
11796
|
-
fontSize: "var(--dsh-content-font-size-secondary, 13px)",
|
|
11797
|
-
fontWeight: 400,
|
|
11798
|
-
lineHeight: "calc(20px + var(--dsh-content-font-delta-secondary, 0px))",
|
|
11799
|
-
color: "var(--dsw-alias-label-tertiary, GrayText)"
|
|
11800
|
-
} }, text.title), (0, react.createElement)("p", { style: composerNoticeParagraphStyle }, evidence === void 0 ? text.missing : evidence.reason === "unknown" ? text.unknown : text.explanation), sample ? (0, react.createElement)("p", { style: composerNoticeParagraphStyle }, `${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: composerNoticeParagraphStyle }, sample ? text.historical : text.revoked));
|
|
11801
|
-
}
|
|
11802
|
-
function Surface$1({ runtime, locale, diagnostic }) {
|
|
11803
|
-
const valid = runtime.useSession((value) => record$1(value) && value.sessionId === runtime.sessionId && value.removed === false && value.openState === "open");
|
|
11804
|
-
const selection = runtime.useProjection("modelSelection");
|
|
11805
|
-
const raw = runtime.useProjection(COPILOT_CONTEXT_EVIDENCE);
|
|
11806
|
-
const language = (0, react.useSyncExternalStore)((listener) => locale?.subscribe(listener) ?? noop$1, () => locale?.getLocale().active ?? "en", () => "en");
|
|
11807
|
-
const parsed = ContextEvidenceSchema.safeParse(raw);
|
|
11808
|
-
(0, react.useEffect)(() => {
|
|
11809
|
-
if (!parsed.success) diagnostic("COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
|
|
11810
|
-
}, [parsed.success, diagnostic]);
|
|
11811
|
-
if (!valid || !record$1(selection) || !record$1(selection.next)) return null;
|
|
11812
|
-
const next = selection.next;
|
|
11813
|
-
if (next.provider !== "github-copilot" && next.provider !== "github-copilot-preview") return null;
|
|
11814
|
-
const evidence = parsed.success ? parsed.data : void 0;
|
|
11815
|
-
const route = evidence?.route;
|
|
11816
|
-
const applicable = route !== null && route !== void 0 && next.provider === route.provider && (next.model === route.model || typeof next.model === "string" && autoModelPreference(next.model) !== void 0);
|
|
11817
|
-
return (0, react.createElement)(ContextEvidenceNotice, {
|
|
11818
|
-
evidence,
|
|
11819
|
-
locale: language,
|
|
11820
|
-
applicable
|
|
11821
|
-
});
|
|
11822
|
-
}
|
|
11823
|
-
/** Additive disclosure only: native input, context ring and billing remain untouched. */
|
|
11824
|
-
function registerContextEvidenceUi(ctx) {
|
|
11825
|
-
const diagnosed = /* @__PURE__ */ new Set();
|
|
11826
|
-
const diagnostic = (code) => {
|
|
11827
|
-
if (!diagnosed.has(code)) {
|
|
11828
|
-
diagnosed.add(code);
|
|
11829
|
-
ctx.logger.warn(`[github-copilot] ${code}`);
|
|
11830
|
-
}
|
|
11831
|
-
};
|
|
11832
|
-
const slots = ctx.get("slots");
|
|
11833
|
-
if (!isSlots$1(slots)) {
|
|
11834
|
-
diagnostic("COPILOT_CONTEXT_SLOT_UNAVAILABLE");
|
|
11835
|
-
return noop$1;
|
|
11836
|
-
}
|
|
11837
|
-
const candidate = ctx.get("locale");
|
|
11838
|
-
const locale = isLocale$1(candidate) ? candidate : void 0;
|
|
11839
|
-
return slots.inject(slot, () => {
|
|
11840
|
-
const spec = slots.spec(slot);
|
|
11841
|
-
if (spec?.kind !== "list" || spec.scope !== "session") {
|
|
11842
|
-
diagnostic("COPILOT_CONTEXT_SLOT_UNAVAILABLE");
|
|
11843
|
-
return noop$1;
|
|
11844
|
-
}
|
|
11845
|
-
return slots.register({
|
|
11846
|
-
name: slot,
|
|
11847
|
-
id: "github-copilot-context-evidence",
|
|
11848
|
-
order: 25
|
|
11849
|
-
}, (props) => {
|
|
11850
|
-
if (!isRuntime$1(props)) {
|
|
11851
|
-
diagnostic("COPILOT_CONTEXT_SESSION_RUNTIME_UNAVAILABLE");
|
|
11852
|
-
return null;
|
|
11853
|
-
}
|
|
11854
|
-
return (0, react.createElement)(Surface$1, {
|
|
11855
|
-
runtime: props,
|
|
11856
|
-
locale,
|
|
11857
|
-
diagnostic
|
|
11858
|
-
});
|
|
11859
|
-
});
|
|
11860
|
-
});
|
|
11861
|
-
}
|
|
11862
|
-
//#endregion
|
|
11863
11780
|
//#region lib/types/compaction-continuation-ui.js
|
|
11864
11781
|
const successLifetimeMs = 8e3;
|
|
11865
11782
|
/** Presentation only, retained across incidental mounts by the Client slot registration. */
|
|
@@ -11916,7 +11833,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11916
11833
|
this.listeners.clear();
|
|
11917
11834
|
}
|
|
11918
11835
|
};
|
|
11919
|
-
function CompactionContinuationNotice({ sessionId, remote, lifecycle, locale = "en", presentation: sharedPresentation }) {
|
|
11836
|
+
function CompactionContinuationNotice({ sessionId, remote, lifecycle, locale = "en", renderEvidence, presentation: sharedPresentation }) {
|
|
11920
11837
|
const [localPresentation] = (0, react.useState)(() => new CompactionNoticePresentation());
|
|
11921
11838
|
const presentation = sharedPresentation ?? localPresentation;
|
|
11922
11839
|
const version = (0, react.useSyncExternalStore)(presentation.subscribe, presentation.snapshot, presentation.snapshot);
|
|
@@ -11991,7 +11908,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11991
11908
|
version
|
|
11992
11909
|
]);
|
|
11993
11910
|
const zh = locale.startsWith("zh");
|
|
11994
|
-
if (!id || !state || !running && !presentation.visible(sessionId, id, state)) return null;
|
|
11911
|
+
if (!id || !state || !running && !presentation.visible(sessionId, id, state)) return renderEvidence?.(void 0, null, false) ?? null;
|
|
11995
11912
|
const dismiss = () => {
|
|
11996
11913
|
if (!running) presentation.dismiss(sessionId, id, state);
|
|
11997
11914
|
};
|
|
@@ -12015,13 +11932,222 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12015
11932
|
running,
|
|
12016
11933
|
onCancel: dismiss
|
|
12017
11934
|
}), close);
|
|
11935
|
+
if (renderEvidence && !error) return renderEvidence(status, close, true);
|
|
12018
11936
|
const text = error ? zh ? "无法确认压缩降级状态;请查看原生压缩结果。" : "Compaction recovery status is unavailable; check the native compaction result." : status?.state === "running" ? zh ? "正在使用可见历史降级压缩,隐藏推理上下文可能丢失。" : "Compacting with visible history; hidden reasoning context may be lost." : status?.state === "completed" ? zh ? "可见历史压缩已提交;隐藏推理上下文未带入摘要。" : "Visible-history compaction committed; hidden reasoning context was omitted from the summary." : status?.state === "cancelled" ? zh ? "可见历史压缩已取消;未确认提交恢复摘要。" : "Visible-history compaction cancelled; no recovery summary commit is confirmed." : zh ? "可见历史压缩失败;Session 尚未恢复。请查看原生失败原因。" : "Visible-history compaction failed; the Session is not recovered. Check the native failure.";
|
|
12019
11937
|
return (0, react.createElement)("section", {
|
|
12020
11938
|
"data-copilot-composer-notice": "compaction-continuation",
|
|
12021
11939
|
role: error || status?.state === "failed" ? "alert" : "status",
|
|
12022
11940
|
"aria-live": "polite",
|
|
12023
11941
|
style: composerNoticeSurfaceStyle
|
|
12024
|
-
}, (0, react.createElement)("p", { style: composerNoticeParagraphStyle }, text), close);
|
|
11942
|
+
}, (0, react.createElement)("p", { style: composerNoticeParagraphStyle }, text), close, error ? renderEvidence?.(void 0, null, false) : null);
|
|
11943
|
+
}
|
|
11944
|
+
//#endregion
|
|
11945
|
+
//#region lib/types/context-evidence-ui.js
|
|
11946
|
+
const slot = "conversation.input.dock";
|
|
11947
|
+
const noop$1 = () => {};
|
|
11948
|
+
function record$1(value) {
|
|
11949
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11950
|
+
}
|
|
11951
|
+
function isSlots$1(value) {
|
|
11952
|
+
return record$1(value) && typeof value.spec === "function" && typeof value.inject === "function" && typeof value.register === "function";
|
|
11953
|
+
}
|
|
11954
|
+
function isLocale$1(value) {
|
|
11955
|
+
return record$1(value) && typeof value.getLocale === "function" && typeof value.subscribe === "function";
|
|
11956
|
+
}
|
|
11957
|
+
function isRuntime$1(value) {
|
|
11958
|
+
return record$1(value) && typeof value.sessionId === "string" && value.sessionId !== "" && typeof value.useSession === "function" && typeof value.useProjection === "function";
|
|
11959
|
+
}
|
|
11960
|
+
const copy = {
|
|
11961
|
+
en: {
|
|
11962
|
+
title: "Context unknown · native 0% is not an empty-context reading",
|
|
11963
|
+
explanation: "A failed Copilot attempt reported zero usage. The native 0% is not evidence of an empty context.",
|
|
11964
|
+
sample: "Last valid input sample (including cache)",
|
|
11965
|
+
historical: "Historical sample, not current occupancy. No percentage is inferred.",
|
|
11966
|
+
revoked: "No applicable historical input sample is available. Model changes, compaction and incomplete history invalidate earlier samples.",
|
|
11967
|
+
missing: "COPILOT_CONTEXT_PROJECTION_UNAVAILABLE: historical context evidence is unavailable.",
|
|
11968
|
+
unknown: "Context sampling evidence is incomplete. No current occupancy can be inferred.",
|
|
11969
|
+
completed: "Compaction completed · context occupancy awaiting confirmation",
|
|
11970
|
+
completedSucceeded: "Compaction completed · subsequent request succeeded · context occupancy awaiting confirmation",
|
|
11971
|
+
completedFailed: "Compaction completed · subsequent request failed · context occupancy awaiting confirmation",
|
|
11972
|
+
completedCancelled: "Compaction completed · subsequent request cancelled · context occupancy awaiting confirmation",
|
|
11973
|
+
contextPending: "Context occupancy awaiting confirmation",
|
|
11974
|
+
contextSucceeded: "Subsequent request succeeded · context occupancy awaiting confirmation",
|
|
11975
|
+
contextFailed: "Subsequent request failed · context occupancy unknown",
|
|
11976
|
+
contextCancelled: "Subsequent request cancelled · context occupancy unknown",
|
|
11977
|
+
running: "Compacting with visible history; hidden reasoning context may be lost.",
|
|
11978
|
+
failed: "Visible-history compaction failed; no recovery summary commit is confirmed. Check the native failure.",
|
|
11979
|
+
cancelled: "Visible-history compaction cancelled; no recovery summary commit is confirmed.",
|
|
11980
|
+
nativeRunning: "Compacting context · context occupancy awaiting confirmation",
|
|
11981
|
+
nativeFailed: "Compaction did not complete · check the native result",
|
|
11982
|
+
nativeUnknown: "Compaction commit could not be confirmed · check the native result",
|
|
11983
|
+
omitted: "Hidden reasoning context was omitted from the summary. Visible messages and tool relations were preserved.",
|
|
11984
|
+
pending: "No subsequent normal request has completed yet.",
|
|
11985
|
+
succeeded: "Subsequent request succeeded.",
|
|
11986
|
+
requestFailed: "The latest subsequent request failed; compaction success does not confirm Session recovery.",
|
|
11987
|
+
requestCancelled: "The latest subsequent request was cancelled.",
|
|
11988
|
+
requestRunning: "Subsequent request in progress; success is not yet confirmed.",
|
|
11989
|
+
requestUnknown: "Subsequent request outcome is unconfirmed.",
|
|
11990
|
+
sampled: "An applicable post-compaction input sample is recorded. It is historical evidence, not current occupancy.",
|
|
11991
|
+
unsampled: "No applicable valid post-compaction input sample is confirmed. Request success alone does not establish occupancy.",
|
|
11992
|
+
zero: "Native 0% does not prove an empty context. No replacement percentage is estimated."
|
|
11993
|
+
},
|
|
11994
|
+
zh: {
|
|
11995
|
+
title: "上下文未知 · 原生 0% 不代表上下文为空",
|
|
11996
|
+
explanation: "失败的 Copilot 请求记录了零用量。原生 0% 不代表上下文为空。",
|
|
11997
|
+
sample: "最后有效输入采样(含缓存)",
|
|
11998
|
+
historical: "这是历史采样,不是当前占用;不会据此推算百分比。",
|
|
11999
|
+
revoked: "没有仍适用的历史输入采样。模型切换、压缩或历史证据不完整会使旧采样失效。",
|
|
12000
|
+
missing: "COPILOT_CONTEXT_PROJECTION_UNAVAILABLE:无法获取历史上下文证据。",
|
|
12001
|
+
unknown: "上下文采样证据不完整,无法据此推断当前占用。",
|
|
12002
|
+
completed: "压缩已完成 · 当前上下文占用待确认",
|
|
12003
|
+
completedSucceeded: "压缩已完成 · 后续请求已成功 · 上下文占用待确认",
|
|
12004
|
+
completedFailed: "压缩已完成 · 后续请求失败 · 上下文占用待确认",
|
|
12005
|
+
completedCancelled: "压缩已完成 · 后续请求已取消 · 上下文占用待确认",
|
|
12006
|
+
contextPending: "当前上下文占用待确认",
|
|
12007
|
+
contextSucceeded: "后续请求已成功 · 上下文占用待确认",
|
|
12008
|
+
contextFailed: "后续请求失败 · 上下文占用未知",
|
|
12009
|
+
contextCancelled: "后续请求已取消 · 上下文占用未知",
|
|
12010
|
+
running: "正在使用可见历史降级压缩,隐藏推理上下文可能丢失。",
|
|
12011
|
+
failed: "可见历史压缩失败;未确认提交恢复摘要。请查看原生失败原因。",
|
|
12012
|
+
cancelled: "可见历史压缩已取消;未确认提交恢复摘要。",
|
|
12013
|
+
nativeRunning: "正在压缩上下文 · 当前上下文占用待确认",
|
|
12014
|
+
nativeFailed: "压缩未完成 · 请查看原生结果",
|
|
12015
|
+
nativeUnknown: "无法确认压缩摘要已提交 · 请查看原生结果",
|
|
12016
|
+
omitted: "隐藏推理上下文未带入摘要;可见消息与工具调用关系保留。",
|
|
12017
|
+
pending: "压缩后尚无已完成的普通请求。",
|
|
12018
|
+
succeeded: "后续请求已成功。",
|
|
12019
|
+
requestFailed: "最近一次后续请求失败;压缩成功不代表 Session 已恢复。",
|
|
12020
|
+
requestCancelled: "最近一次后续请求已取消。",
|
|
12021
|
+
requestRunning: "后续请求进行中;尚未确认成功。",
|
|
12022
|
+
requestUnknown: "后续请求结果尚未确认。",
|
|
12023
|
+
sampled: "已记录仍适用的压缩后输入采样;这是历史证据,不是当前占用。",
|
|
12024
|
+
unsampled: "尚未确认仍适用的有效压缩后输入采样;请求成功不能单独证明占用。",
|
|
12025
|
+
zero: "原生 0% 不代表上下文为空;不会用另一个估算百分比替代。"
|
|
12026
|
+
}
|
|
12027
|
+
};
|
|
12028
|
+
function ContextEvidenceNotice({ evidence, locale = "en", applicable = true, compactionStatus, showCompactionResult = true, controls }) {
|
|
12029
|
+
const text = locale.startsWith("zh") ? copy.zh : copy.en;
|
|
12030
|
+
const native = evidence?.compaction;
|
|
12031
|
+
const status = showCompactionResult ? compactionStatus ?? (native ? {
|
|
12032
|
+
id: native.id,
|
|
12033
|
+
state: native.state
|
|
12034
|
+
} : void 0) : void 0;
|
|
12035
|
+
const sample = applicable ? evidence?.sample : null;
|
|
12036
|
+
const completed = status?.state === "completed";
|
|
12037
|
+
const following = applicable && native?.state === "completed" && (status === void 0 || native.id === status.id) ? native : void 0;
|
|
12038
|
+
const sampled = following?.endSeq !== null && following?.endSeq !== void 0 && sample !== null && sample !== void 0 && sample.tokens > 0 && sample.seq > following.endSeq && !evidence?.invalid;
|
|
12039
|
+
if (!status && evidence !== void 0 && !evidence.invalid && (!following || sampled)) return null;
|
|
12040
|
+
const title = status ? completed ? following?.request === "succeeded" ? text.completedSucceeded : following?.request === "failed" ? text.completedFailed : following?.request === "cancelled" ? text.completedCancelled : text.completed : status.state === "running" ? compactionStatus ? text.running : text.nativeRunning : status.state === "cancelled" ? text.cancelled : status.state === "failed" ? compactionStatus ? text.failed : text.nativeFailed : text.nativeUnknown : following ? following.request === "succeeded" ? text.contextSucceeded : following.request === "failed" ? text.contextFailed : following.request === "cancelled" ? text.contextCancelled : text.contextPending : text.title;
|
|
12041
|
+
const disclosure = (0, react.createElement)("details", {
|
|
12042
|
+
"data-copilot-composer-notice": controls === void 0 ? "context" : void 0,
|
|
12043
|
+
style: composerNoticeStyle
|
|
12044
|
+
}, (0, react.createElement)("summary", { style: {
|
|
12045
|
+
cursor: "pointer",
|
|
12046
|
+
fontFamily: "var(--dsw-font-family, inherit)",
|
|
12047
|
+
fontSize: "var(--dsh-content-font-size-secondary, 13px)",
|
|
12048
|
+
fontWeight: 400,
|
|
12049
|
+
lineHeight: "calc(20px + var(--dsh-content-font-delta-secondary, 0px))",
|
|
12050
|
+
color: "var(--dsw-alias-label-tertiary, GrayText)"
|
|
12051
|
+
} }, title), completed || following ? (0, react.createElement)("p", {
|
|
12052
|
+
role: "status",
|
|
12053
|
+
"aria-live": "polite",
|
|
12054
|
+
style: composerNoticeParagraphStyle
|
|
12055
|
+
}, following?.request === "succeeded" ? text.succeeded : following?.request === "failed" ? text.requestFailed : following?.request === "cancelled" ? text.requestCancelled : following?.request === "pending" ? text.requestRunning : following?.request === "idle" ? text.pending : text.requestUnknown) : null, completed || following ? (0, react.createElement)("p", { style: composerNoticeParagraphStyle }, sampled ? text.sampled : text.unsampled) : null, compactionStatus && completed ? (0, react.createElement)("p", { style: composerNoticeParagraphStyle }, text.omitted) : null, status || following ? (0, react.createElement)("p", { style: composerNoticeParagraphStyle }, text.zero) : null, evidence === void 0 || evidence.reason === "unknown" || evidence.reason === "failed-zero" ? (0, react.createElement)("p", { style: composerNoticeParagraphStyle }, evidence === void 0 ? text.missing : evidence.reason === "unknown" ? text.unknown : text.explanation) : null, sample && sample.tokens > 0 ? (0, react.createElement)("p", { style: composerNoticeParagraphStyle }, `${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: composerNoticeParagraphStyle }, sample && sample.tokens > 0 ? text.historical : text.revoked));
|
|
12056
|
+
return controls === void 0 ? disclosure : (0, react.createElement)("section", {
|
|
12057
|
+
"data-copilot-composer-notice": "context",
|
|
12058
|
+
style: composerNoticeStyle
|
|
12059
|
+
}, disclosure, controls);
|
|
12060
|
+
}
|
|
12061
|
+
function Surface$1({ runtime, locale, diagnostic, continuation, presentation }) {
|
|
12062
|
+
const valid = runtime.useSession((value) => record$1(value) && value.sessionId === runtime.sessionId && value.removed === false && value.openState === "open");
|
|
12063
|
+
const selection = runtime.useProjection("modelSelection");
|
|
12064
|
+
const raw = runtime.useProjection(COPILOT_CONTEXT_EVIDENCE);
|
|
12065
|
+
const lifecycle = runtime.useProjection(COMPACTION_CONTINUATION);
|
|
12066
|
+
const language = (0, react.useSyncExternalStore)((listener) => locale?.subscribe(listener) ?? noop$1, () => locale?.getLocale().active ?? "en", () => "en");
|
|
12067
|
+
const parsed = ContextEvidenceSchema.safeParse(raw);
|
|
12068
|
+
(0, react.useEffect)(() => {
|
|
12069
|
+
if (!parsed.success) diagnostic("COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
|
|
12070
|
+
}, [parsed.success, diagnostic]);
|
|
12071
|
+
if (!valid || !record$1(selection) || !record$1(selection.next)) return null;
|
|
12072
|
+
const next = selection.next;
|
|
12073
|
+
if (next.provider !== "github-copilot" && next.provider !== "github-copilot-preview") return null;
|
|
12074
|
+
const evidence = parsed.success ? parsed.data : void 0;
|
|
12075
|
+
const route = evidence?.route;
|
|
12076
|
+
const applicable = route !== null && route !== void 0 && next.provider === route.provider && (next.model === route.model || typeof next.model === "string" && autoModelPreference(next.model) !== void 0);
|
|
12077
|
+
const compact = CompactionContinuationLifecycleSchema.safeParse(lifecycle);
|
|
12078
|
+
const shown = next.provider === "github-copilot-preview" && compact.success && compact.data.id !== null && evidence?.compaction && evidence.compaction.id !== compact.data.id ? {
|
|
12079
|
+
...evidence,
|
|
12080
|
+
compaction: null,
|
|
12081
|
+
sample: null,
|
|
12082
|
+
invalid: true,
|
|
12083
|
+
reason: "compaction"
|
|
12084
|
+
} : evidence;
|
|
12085
|
+
const renderEvidence = (compactionStatus, controls, transient = true) => (0, react.createElement)(ContextEvidenceNotice, {
|
|
12086
|
+
evidence: shown,
|
|
12087
|
+
locale: language,
|
|
12088
|
+
applicable,
|
|
12089
|
+
compactionStatus,
|
|
12090
|
+
controls,
|
|
12091
|
+
showCompactionResult: transient
|
|
12092
|
+
});
|
|
12093
|
+
return next.provider === "github-copilot-preview" && compact.success && compact.data.id !== null ? (0, react.createElement)(CompactionContinuationNotice, {
|
|
12094
|
+
key: runtime.sessionId,
|
|
12095
|
+
sessionId: runtime.sessionId,
|
|
12096
|
+
remote: continuation,
|
|
12097
|
+
lifecycle,
|
|
12098
|
+
locale: language,
|
|
12099
|
+
renderEvidence,
|
|
12100
|
+
presentation
|
|
12101
|
+
}) : renderEvidence();
|
|
12102
|
+
}
|
|
12103
|
+
/** Additive disclosure only: native input, context ring and billing remain untouched. */
|
|
12104
|
+
function registerContextEvidenceUi(ctx) {
|
|
12105
|
+
const diagnosed = /* @__PURE__ */ new Set();
|
|
12106
|
+
const diagnostic = (code) => {
|
|
12107
|
+
if (!diagnosed.has(code)) {
|
|
12108
|
+
diagnosed.add(code);
|
|
12109
|
+
ctx.logger.warn(`[github-copilot] ${code}`);
|
|
12110
|
+
}
|
|
12111
|
+
};
|
|
12112
|
+
const slots = ctx.get("slots");
|
|
12113
|
+
if (!isSlots$1(slots)) {
|
|
12114
|
+
diagnostic("COPILOT_CONTEXT_SLOT_UNAVAILABLE");
|
|
12115
|
+
return noop$1;
|
|
12116
|
+
}
|
|
12117
|
+
const candidate = ctx.get("locale");
|
|
12118
|
+
const locale = isLocale$1(candidate) ? candidate : void 0;
|
|
12119
|
+
let faces;
|
|
12120
|
+
const presentation = new CompactionNoticePresentation();
|
|
12121
|
+
const remove = slots.inject(slot, () => {
|
|
12122
|
+
const spec = slots.spec(slot);
|
|
12123
|
+
if (spec?.kind !== "list" || spec.scope !== "session") {
|
|
12124
|
+
diagnostic("COPILOT_CONTEXT_SLOT_UNAVAILABLE");
|
|
12125
|
+
return noop$1;
|
|
12126
|
+
}
|
|
12127
|
+
faces ??= { continuation: ctx.remote.githubCopilotSessionContinuation };
|
|
12128
|
+
const { continuation } = faces;
|
|
12129
|
+
return slots.register({
|
|
12130
|
+
name: slot,
|
|
12131
|
+
id: "github-copilot-context-evidence",
|
|
12132
|
+
order: 25
|
|
12133
|
+
}, (props) => {
|
|
12134
|
+
if (!isRuntime$1(props)) {
|
|
12135
|
+
diagnostic("COPILOT_CONTEXT_SESSION_RUNTIME_UNAVAILABLE");
|
|
12136
|
+
return null;
|
|
12137
|
+
}
|
|
12138
|
+
return (0, react.createElement)(Surface$1, {
|
|
12139
|
+
runtime: props,
|
|
12140
|
+
locale,
|
|
12141
|
+
diagnostic,
|
|
12142
|
+
continuation,
|
|
12143
|
+
presentation
|
|
12144
|
+
});
|
|
12145
|
+
});
|
|
12146
|
+
});
|
|
12147
|
+
return () => {
|
|
12148
|
+
remove();
|
|
12149
|
+
presentation.dispose();
|
|
12150
|
+
};
|
|
12025
12151
|
}
|
|
12026
12152
|
//#endregion
|
|
12027
12153
|
//#region lib/types/replay-recovery-ui.js
|
|
@@ -12156,21 +12282,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12156
12282
|
function isRuntime(value) {
|
|
12157
12283
|
return record(value) && typeof value.sessionId === "string" && value.sessionId !== "" && typeof value.useSession === "function" && typeof value.useProjection === "function";
|
|
12158
12284
|
}
|
|
12159
|
-
function Surface({ runtime, remote, continuation, locale
|
|
12285
|
+
function Surface({ runtime, remote, continuation, locale }) {
|
|
12160
12286
|
const valid = runtime.useSession((value) => record(value) && value.sessionId === runtime.sessionId && value.removed === false && value.openState === "open");
|
|
12161
12287
|
const selected = runtime.useProjection("modelSelection");
|
|
12162
|
-
const compaction = runtime.useProjection(COMPACTION_CONTINUATION);
|
|
12163
12288
|
const running = runtime.useSession((value) => !record(value) || value.running !== false);
|
|
12164
12289
|
const lastError = runtime.useSession((value) => record(value) && typeof value.lastAgentError === "string" ? value.lastAgentError : "");
|
|
12165
12290
|
const language = (0, react.useSyncExternalStore)((listener) => locale?.subscribe(listener) ?? noop, () => locale?.getLocale().active ?? "en", () => "en");
|
|
12166
12291
|
if (!valid || !record(selected) || !record(selected.next) || selected.next.provider !== "github-copilot-preview") return null;
|
|
12167
|
-
return (0, react.createElement)("div", null, (0, react.createElement)(
|
|
12168
|
-
sessionId: runtime.sessionId,
|
|
12169
|
-
remote: continuation,
|
|
12170
|
-
lifecycle: compaction,
|
|
12171
|
-
locale: language,
|
|
12172
|
-
presentation
|
|
12173
|
-
}), (0, react.createElement)(ReplayRecoveryCard, {
|
|
12292
|
+
return (0, react.createElement)("div", null, (0, react.createElement)(ReplayRecoveryCard, {
|
|
12174
12293
|
key: JSON.stringify([runtime.sessionId, selected.next.model]),
|
|
12175
12294
|
sessionId: runtime.sessionId,
|
|
12176
12295
|
remote,
|
|
@@ -12187,12 +12306,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12187
12306
|
return noop;
|
|
12188
12307
|
}
|
|
12189
12308
|
const slots = candidate;
|
|
12190
|
-
const presentation = new CompactionNoticePresentation();
|
|
12191
12309
|
let faces;
|
|
12192
12310
|
const language = ctx.get("locale");
|
|
12193
12311
|
const locale = isLocale(language) ? language : void 0;
|
|
12194
12312
|
const name = "conversation.input.dock";
|
|
12195
|
-
|
|
12313
|
+
return slots.inject(name, () => {
|
|
12196
12314
|
const spec = slots.spec(name);
|
|
12197
12315
|
if (spec?.kind !== "list" || spec.scope !== "session") {
|
|
12198
12316
|
ctx.logger.warn("COPILOT_REPLAY_RECOVERY_SLOT_UNAVAILABLE");
|
|
@@ -12216,15 +12334,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12216
12334
|
runtime: props,
|
|
12217
12335
|
remote,
|
|
12218
12336
|
continuation,
|
|
12219
|
-
locale
|
|
12220
|
-
presentation
|
|
12337
|
+
locale
|
|
12221
12338
|
});
|
|
12222
12339
|
});
|
|
12223
12340
|
});
|
|
12224
|
-
return () => {
|
|
12225
|
-
remove();
|
|
12226
|
-
presentation.dispose();
|
|
12227
|
-
};
|
|
12228
12341
|
}
|
|
12229
12342
|
//#endregion
|
|
12230
12343
|
//#region lib/types/model-preferences-card.js
|
|
@@ -13708,7 +13821,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
13708
13821
|
"remote.githubCopilotSessionContinuation",
|
|
13709
13822
|
"slots"
|
|
13710
13823
|
], registerCopilotUsageUi);
|
|
13711
|
-
const contextUi = ctx.inject(["slots"], registerContextEvidenceUi);
|
|
13824
|
+
const contextUi = ctx.inject(["remote.githubCopilotSessionContinuation", "slots"], registerContextEvidenceUi);
|
|
13712
13825
|
const recoveryUi = ctx.inject([
|
|
13713
13826
|
"remote.githubCopilotReplayRecovery",
|
|
13714
13827
|
"remote.githubCopilotSessionContinuation",
|