dsh-github-copilot 0.4.0-alpha.40 → 0.4.0-alpha.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -5734,25 +5734,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5734
5734
  const ASSISTANT_ORIGIN_KEY = "github-copilot-assistant-origin";
5735
5735
  const CHAT_NODE_SLOT = "conversation.chat.node";
5736
5736
  const ASSISTANT_KEY = "assistant-step";
5737
- const noop$1 = () => {};
5738
- function record$2(value) {
5737
+ const noop$2 = () => {};
5738
+ function record$3(value) {
5739
5739
  return typeof value === "object" && value !== null;
5740
5740
  }
5741
- function sequence(value) {
5741
+ function sequence$1(value) {
5742
5742
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
5743
5743
  }
5744
5744
  function eventLocation(event) {
5745
- if (!record$2(event) || !record$2(event.data)) return void 0;
5745
+ if (!record$3(event) || !record$3(event.data)) return void 0;
5746
5746
  const { turn, step } = event.data;
5747
- return sequence(turn) && sequence(step) ? {
5747
+ return sequence$1(turn) && sequence$1(step) ? {
5748
5748
  turn,
5749
5749
  step
5750
5750
  } : void 0;
5751
5751
  }
5752
5752
  function messageOrigin(event) {
5753
- if (!record$2(event) || event.type !== "assistant/message" || event.surfaceOp !== "append" || !sequence(event.seq) || !record$2(event.data) || !record$2(event.data.message)) return void 0;
5753
+ if (!record$3(event) || event.type !== "assistant/message" || event.surfaceOp !== "append" || !sequence$1(event.seq) || !record$3(event.data) || !record$3(event.data.message)) return void 0;
5754
5754
  const source = event.data.message.source;
5755
- if (!record$2(source) || typeof source.provider !== "string" || source.provider.trim() === "" || typeof source.model !== "string" || source.model.trim() === "") return void 0;
5755
+ if (!record$3(source) || typeof source.provider !== "string" || source.provider.trim() === "" || typeof source.model !== "string" || source.model.trim() === "") return void 0;
5756
5756
  return {
5757
5757
  seq: event.seq,
5758
5758
  provider: source.provider,
@@ -5763,7 +5763,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5763
5763
  const assistantOriginDefinition = {
5764
5764
  kind: ASSISTANT_ORIGIN_KEY,
5765
5765
  match(event) {
5766
- if (!record$2(event)) return null;
5766
+ if (!record$3(event)) return null;
5767
5767
  const location = eventLocation(event);
5768
5768
  if (location === void 0) return null;
5769
5769
  if (event.type === "step/start") return {
@@ -5778,14 +5778,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5778
5778
  },
5779
5779
  start(_context, match) {
5780
5780
  const location = eventLocation(match.event);
5781
- if (location === void 0 || !record$2(match.event) || match.event.type !== "step/start") throw new Error("COPILOT_REASONING_ORIGIN_START: expected step/start");
5781
+ if (location === void 0 || !record$3(match.event) || match.event.type !== "step/start") throw new Error("COPILOT_REASONING_ORIGIN_START: expected step/start");
5782
5782
  return {
5783
5783
  ...location,
5784
5784
  origin: void 0
5785
5785
  };
5786
5786
  },
5787
5787
  update(context, match) {
5788
- if (!record$2(match.event) || match.event.type !== "assistant/message" || match.event.surfaceOp !== "append") return context.state;
5788
+ if (!record$3(match.event) || match.event.type !== "assistant/message" || match.event.surfaceOp !== "append") return context.state;
5789
5789
  return {
5790
5790
  ...context.state,
5791
5791
  origin: messageOrigin(match.event)
@@ -5796,7 +5796,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5796
5796
  let state = context.state;
5797
5797
  if (state === void 0) for (const match of context.matches) {
5798
5798
  const event = match.event;
5799
- if (!record$2(event) || event.type !== "assistant/message" || event.surfaceOp !== "append") continue;
5799
+ if (!record$3(event) || event.type !== "assistant/message" || event.surfaceOp !== "append") continue;
5800
5800
  const location = eventLocation(event);
5801
5801
  if (location !== void 0) state = {
5802
5802
  ...location,
@@ -5817,12 +5817,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5817
5817
  };
5818
5818
  /** Shallow UI-only projection. Unchanged input retains its exact props identity. */
5819
5819
  function projectReasoningPresentation(props, origin) {
5820
- if (!record$2(props) || !record$2(props.node) || props.node.kind !== ASSISTANT_KEY || !record$2(props.node.data) || !record$2(origin)) return props;
5820
+ if (!record$3(props) || !record$3(props.node) || props.node.kind !== ASSISTANT_KEY || !record$3(props.node.data) || !record$3(origin)) return props;
5821
5821
  const node = props.node;
5822
5822
  const data = node.data;
5823
- if (data.status !== "settled" || !record$2(data.finalNode) || !sequence(data.finalNode.seq) || origin.seq !== data.finalNode.seq) return props;
5823
+ if (data.status !== "settled" || !record$3(data.finalNode) || !sequence$1(data.finalNode.seq) || origin.seq !== data.finalNode.seq) return props;
5824
5824
  if (!(origin.provider === "github-copilot" || origin.provider === "github-copilot-preview") || typeof origin.model !== "string" || origin.model.trim() === "" || !Array.isArray(data.blocks)) return props;
5825
- const blocks = data.blocks.filter((block) => !(record$2(block) && block.kind === "reasoning" && typeof block.text === "string" && block.text.trim() === ""));
5825
+ const blocks = data.blocks.filter((block) => !(record$3(block) && block.kind === "reasoning" && typeof block.text === "string" && block.text.trim() === ""));
5826
5826
  if (blocks.length === data.blocks.length) return props;
5827
5827
  return {
5828
5828
  ...props,
@@ -5837,16 +5837,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5837
5837
  }
5838
5838
  const missingOriginSource = {
5839
5839
  getSnapshot: () => void 0,
5840
- subscribe: () => noop$1
5840
+ subscribe: () => noop$2
5841
5841
  };
5842
5842
  function originSource(props) {
5843
5843
  const node = props.node;
5844
- if (!record$2(node) || !record$2(node.location) || node.location.kind !== "step" || !record$2(node.location.step) || !record$2(node.location.step.data)) return missingOriginSource;
5844
+ if (!record$3(node) || !record$3(node.location) || node.location.kind !== "step" || !record$3(node.location.step) || !record$3(node.location.step.data)) return missingOriginSource;
5845
5845
  const store = node.location.step.data;
5846
5846
  if (typeof store.source !== "function") return missingOriginSource;
5847
5847
  try {
5848
5848
  const source = store.source(ASSISTANT_ORIGIN_KEY);
5849
- if (!record$2(source) || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function") return missingOriginSource;
5849
+ if (!record$3(source) || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function") return missingOriginSource;
5850
5850
  return source;
5851
5851
  } catch {
5852
5852
  return missingOriginSource;
@@ -5860,7 +5860,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5860
5860
  */
5861
5861
  function supportedNative(entry) {
5862
5862
  const component = entry.component;
5863
- 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$2(component) && component.$$typeof === Symbol.for("react.memo") && typeof component.type === "function" && component.type.name === "AssistantNodeView";
5863
+ 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$3(component) && component.$$typeof === Symbol.for("react.memo") && typeof component.type === "function" && component.type.name === "AssistantNodeView";
5864
5864
  }
5865
5865
  /**
5866
5866
  * Optional Client enhancement. The caller owns the returned disposer in its
@@ -5870,20 +5870,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5870
5870
  const { diagnostic } = capabilities;
5871
5871
  const slotsCandidate = capabilities.slots;
5872
5872
  const conversation = capabilities.uiConversation;
5873
- if (!record$2(slotsCandidate) || ![
5873
+ if (!record$3(slotsCandidate) || ![
5874
5874
  "entries",
5875
5875
  "spec",
5876
5876
  "subscribe",
5877
5877
  "inject",
5878
5878
  "register"
5879
- ].every((key) => typeof slotsCandidate[key] === "function") || !record$2(conversation) || !record$2(conversation.events) || typeof conversation.events.register !== "function") {
5879
+ ].every((key) => typeof slotsCandidate[key] === "function") || !record$3(conversation) || !record$3(conversation.events) || typeof conversation.events.register !== "function") {
5880
5880
  diagnostic("COPILOT_REASONING_PRESENTATION_UNAVAILABLE");
5881
- return noop$1;
5881
+ return noop$2;
5882
5882
  }
5883
5883
  const slots = slotsCandidate;
5884
5884
  const events = conversation.events;
5885
- let removeOrigin = noop$1;
5886
- let removeInjection = noop$1;
5885
+ let removeOrigin = noop$2;
5886
+ let removeInjection = noop$2;
5887
5887
  let disposed = false;
5888
5888
  try {
5889
5889
  removeOrigin = events.register(assistantOriginDefinition);
@@ -5891,7 +5891,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5891
5891
  const spec = slots.spec(CHAT_NODE_SLOT);
5892
5892
  if (spec?.kind !== "keyed" || spec.scope !== "session") {
5893
5893
  diagnostic("COPILOT_REASONING_SLOT_UNSUPPORTED");
5894
- return noop$1;
5894
+ return noop$2;
5895
5895
  }
5896
5896
  let active = true;
5897
5897
  let reconciling = false;
@@ -5899,7 +5899,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5899
5899
  let native;
5900
5900
  let failedNative;
5901
5901
  let wrapper;
5902
- let unregister = noop$1;
5902
+ let unregister = noop$2;
5903
5903
  let lastDiagnostic;
5904
5904
  const report = (code) => {
5905
5905
  if (lastDiagnostic !== code) diagnostic(code);
@@ -5907,7 +5907,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5907
5907
  };
5908
5908
  const retire = () => {
5909
5909
  const remove = unregister;
5910
- unregister = noop$1;
5910
+ unregister = noop$2;
5911
5911
  native = void 0;
5912
5912
  remove();
5913
5913
  wrapper = void 0;
@@ -5969,7 +5969,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5969
5969
  removeInjection();
5970
5970
  removeOrigin();
5971
5971
  diagnostic("COPILOT_REASONING_REGISTRATION_FAILED");
5972
- return noop$1;
5972
+ return noop$2;
5973
5973
  }
5974
5974
  return () => {
5975
5975
  if (disposed) return;
@@ -5979,6 +5979,160 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5979
5979
  };
5980
5980
  }
5981
5981
  //#endregion
5982
+ //#region lib/types/auto-model-presentation.js
5983
+ const AUTO_MODEL_ATTRIBUTION_KEY = "github-copilot-auto-model-attribution";
5984
+ const SLOT = "conversation.chat.turnTail";
5985
+ const noop$1 = () => {};
5986
+ function record$2(value) {
5987
+ return typeof value === "object" && value !== null;
5988
+ }
5989
+ function sequence(value) {
5990
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
5991
+ }
5992
+ function attribution(event) {
5993
+ if (!record$2(event) || event.type !== "github-copilot/auto-model-decision" || !record$2(event.data) || !sequence(event.data.turn) || event.data.provider !== "github-copilot-preview" || typeof event.data.model !== "string" || event.data.model.trim() === "" || ![
5994
+ "fast",
5995
+ "balanced",
5996
+ "strong"
5997
+ ].includes(String(event.data.taskClass)) || ![
5998
+ "short-text-turn",
5999
+ "standard-turn",
6000
+ "large-structured-turn",
6001
+ "image-capability"
6002
+ ].includes(String(event.data.reason)) || !sequence(event.data.candidateCount) || event.data.candidateCount < 1) return void 0;
6003
+ return {
6004
+ turn: event.data.turn,
6005
+ value: {
6006
+ provider: event.data.provider,
6007
+ model: event.data.model,
6008
+ taskClass: event.data.taskClass,
6009
+ reason: event.data.reason,
6010
+ candidateCount: event.data.candidateCount
6011
+ }
6012
+ };
6013
+ }
6014
+ const autoModelAttributionDefinition = {
6015
+ kind: AUTO_MODEL_ATTRIBUTION_KEY,
6016
+ match(event) {
6017
+ const parsed = attribution(event);
6018
+ return parsed === void 0 ? null : {
6019
+ id: String(parsed.turn),
6020
+ role: "start"
6021
+ };
6022
+ },
6023
+ start(_context, match) {
6024
+ const parsed = attribution(match.event);
6025
+ if (parsed === void 0) throw new Error("COPILOT_AUTO_ATTRIBUTION_START");
6026
+ return parsed;
6027
+ },
6028
+ update(context) {
6029
+ return context.state;
6030
+ },
6031
+ buildLocationData(context, scope, previous) {
6032
+ if (scope !== "turn") return null;
6033
+ const state = context.state ?? context.matches.map((match) => attribution(match.event)).find((value) => value !== void 0);
6034
+ if (state === void 0) return null;
6035
+ if (previous?.turn === state.turn && previous.key === "github-copilot-auto-model-attribution" && previous.value.provider === state.value.provider && previous.value.model === state.value.model && previous.value.reason === state.value.reason && previous.value.taskClass === state.value.taskClass && previous.value.candidateCount === state.value.candidateCount) return previous;
6036
+ return {
6037
+ kind: "turn",
6038
+ turn: state.turn,
6039
+ key: AUTO_MODEL_ATTRIBUTION_KEY,
6040
+ value: state.value
6041
+ };
6042
+ }
6043
+ };
6044
+ const missingSource = {
6045
+ getSnapshot: () => void 0,
6046
+ subscribe: () => noop$1
6047
+ };
6048
+ function sourceOf(props) {
6049
+ const turn = props.turn;
6050
+ if (!record$2(turn) || !record$2(turn.data) || typeof turn.data.source !== "function") return missingSource;
6051
+ try {
6052
+ const source = turn.data.source(AUTO_MODEL_ATTRIBUTION_KEY);
6053
+ return record$2(source) && typeof source.getSnapshot === "function" && typeof source.subscribe === "function" ? source : missingSource;
6054
+ } catch {
6055
+ return missingSource;
6056
+ }
6057
+ }
6058
+ function reasonText(value) {
6059
+ return `${value.reason === "short-text-turn" ? "Short text turn" : value.reason === "large-structured-turn" ? "Large structured turn" : value.reason === "image-capability" ? "Image-capable model required" : "Standard turn"}; selected from ${value.candidateCount} eligible account model${value.candidateCount === 1 ? "" : "s"}.`;
6060
+ }
6061
+ function Attribution(props) {
6062
+ const source = sourceOf(props);
6063
+ const value = react.useSyncExternalStore(source.subscribe, source.getSnapshot, source.getSnapshot);
6064
+ const [open, setOpen] = react.useState(false);
6065
+ if (!record$2(value) || typeof value.model !== "string" || typeof value.provider !== "string" || !sequence(value.candidateCount)) return null;
6066
+ const parsed = value;
6067
+ return react.createElement("span", {
6068
+ "data-copilot-auto-attribution": "",
6069
+ style: {
6070
+ display: "inline-flex",
6071
+ alignItems: "center",
6072
+ gap: 6,
6073
+ color: "var(--text-muted, #667085)",
6074
+ fontSize: 12
6075
+ }
6076
+ }, react.createElement("span", null, `Auto · ${parsed.model}`), react.createElement("button", {
6077
+ type: "button",
6078
+ "aria-label": "Why this model",
6079
+ "aria-expanded": open,
6080
+ title: open ? reasonText(parsed) : "Why this model",
6081
+ onClick: () => setOpen((current) => !current),
6082
+ style: {
6083
+ width: 18,
6084
+ height: 18,
6085
+ padding: 0,
6086
+ borderRadius: "50%",
6087
+ border: "1px solid currentColor",
6088
+ color: "inherit",
6089
+ background: "transparent",
6090
+ cursor: "pointer",
6091
+ fontSize: 11,
6092
+ lineHeight: "16px"
6093
+ }
6094
+ }, "?"), open ? react.createElement("span", { role: "status" }, reasonText(parsed)) : null);
6095
+ }
6096
+ function installAutoModelPresentation(capabilities) {
6097
+ const { diagnostic } = capabilities;
6098
+ const slotsCandidate = capabilities.slots;
6099
+ if (!record$2(slotsCandidate) || ![
6100
+ "spec",
6101
+ "inject",
6102
+ "register"
6103
+ ].every((key) => typeof slotsCandidate[key] === "function") || !record$2(capabilities.uiConversation) || !record$2(capabilities.uiConversation.events) || typeof capabilities.uiConversation.events.register !== "function") {
6104
+ diagnostic("COPILOT_AUTO_PRESENTATION_UNAVAILABLE");
6105
+ return noop$1;
6106
+ }
6107
+ const slots = slotsCandidate;
6108
+ const events = capabilities.uiConversation.events;
6109
+ let removeDefinition = noop$1;
6110
+ let removeInjection = noop$1;
6111
+ try {
6112
+ removeDefinition = events.register(autoModelAttributionDefinition);
6113
+ removeInjection = slots.inject(SLOT, () => {
6114
+ if (slots.spec(SLOT)?.kind !== "list" || slots.spec(SLOT)?.scope !== "session") {
6115
+ diagnostic("COPILOT_AUTO_TURN_TAIL_UNAVAILABLE");
6116
+ return noop$1;
6117
+ }
6118
+ return slots.register({
6119
+ name: SLOT,
6120
+ id: "github-copilot-auto-model",
6121
+ order: 20
6122
+ }, Attribution);
6123
+ });
6124
+ } catch {
6125
+ removeInjection();
6126
+ removeDefinition();
6127
+ diagnostic("COPILOT_AUTO_PRESENTATION_FAILED");
6128
+ return noop$1;
6129
+ }
6130
+ return () => {
6131
+ removeInjection();
6132
+ removeDefinition();
6133
+ };
6134
+ }
6135
+ //#endregion
5982
6136
  //#region lib/types/search-routing-policy.js
5983
6137
  /** Resolve old and new settings without guessing registered providers or dropping unknown ids. */
5984
6138
  function normalizeWebSearchRouting(config) {
@@ -6041,6 +6195,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6041
6195
  gap: "6px",
6042
6196
  minWidth: 0
6043
6197
  };
6198
+ const optionsRowStyle = {
6199
+ display: "flex",
6200
+ alignItems: "center",
6201
+ gap: "8px",
6202
+ flexWrap: "wrap"
6203
+ };
6044
6204
  const buttonStyle = {
6045
6205
  justifySelf: "start",
6046
6206
  padding: "9px 16px",
@@ -6073,6 +6233,252 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6073
6233
  if (code === "settings-rejected") return "The settings service rejected this change. Reload settings to check whether editing is available, then try again.";
6074
6234
  return "Could not confirm the save. Reload settings to check saved values before retrying. Your current choices have been kept.";
6075
6235
  }
6236
+ const searchDefaults = {
6237
+ enabled: true,
6238
+ providers: [],
6239
+ routeWebSearch: true,
6240
+ includeSources: true,
6241
+ stripServerTools: true,
6242
+ idleTimeoutMs: 3e5,
6243
+ probe: true,
6244
+ probeTimeoutMs: 3e4,
6245
+ searchFallback: "deepseek"
6246
+ };
6247
+ const timeoutLimit = 2147483647;
6248
+ function searchOptions(value) {
6249
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
6250
+ const source = record$1(value);
6251
+ const options = {
6252
+ ...searchDefaults,
6253
+ ...source
6254
+ };
6255
+ if (typeof options.enabled !== "boolean" || typeof options.routeWebSearch !== "boolean" || typeof options.includeSources !== "boolean" || typeof options.stripServerTools !== "boolean" || typeof options.probe !== "boolean" || !Array.isArray(options.providers) || options.providers.some((id) => typeof id !== "string") || options.searchFallback !== "deepseek" && options.searchFallback !== "none" || ![options.idleTimeoutMs, options.probeTimeoutMs].every((number) => typeof number === "number" && Number.isSafeInteger(number) && number >= 1 && number <= timeoutLimit)) return void 0;
6256
+ return {
6257
+ enabled: options.enabled,
6258
+ routeWebSearch: options.routeWebSearch,
6259
+ includeSources: options.includeSources,
6260
+ stripServerTools: options.stripServerTools,
6261
+ probe: options.probe,
6262
+ searchFallback: options.searchFallback,
6263
+ providers: options.providers.join(", "),
6264
+ idleTimeoutMs: String(options.idleTimeoutMs),
6265
+ probeTimeoutMs: String(options.probeTimeoutMs)
6266
+ };
6267
+ }
6268
+ /** Edit only explicit Copilot hosted-search leaves; provider routing remains a separate CAS. */
6269
+ function HostedSearchSettingsCard({ settings }) {
6270
+ const [draft, setDraft] = (0, react.useState)(() => searchOptions({}));
6271
+ const [saved, setSaved] = (0, react.useState)();
6272
+ const [revision, setRevision] = (0, react.useState)();
6273
+ const [writable, setWritable] = (0, react.useState)(false);
6274
+ const [loading, setLoading] = (0, react.useState)(true);
6275
+ const [saving, setSaving] = (0, react.useState)(false);
6276
+ const [message, setMessage] = (0, react.useState)("");
6277
+ const lifecycle = (0, react.useRef)({
6278
+ active: false,
6279
+ generation: 0,
6280
+ busy: false
6281
+ });
6282
+ const load = (0, react.useCallback)(async () => {
6283
+ const owner = lifecycle.current;
6284
+ if (!owner.active || owner.busy) return;
6285
+ const generation = ++owner.generation;
6286
+ owner.busy = true;
6287
+ setLoading(true);
6288
+ setWritable(false);
6289
+ setMessage("");
6290
+ try {
6291
+ const result = await settings.describe();
6292
+ if (!owner.active || generation !== owner.generation) return;
6293
+ if (!result.ok) {
6294
+ setMessage("Could not load Copilot search options. Reload to retry.");
6295
+ return;
6296
+ }
6297
+ const entry = result.value.namespaces.find((item) => item.ns === GITHUB_COPILOT_SETTINGS_NAMESPACE);
6298
+ const next = entry && searchOptions(entry.value);
6299
+ const nextRevision = revisionOf(entry?.revision);
6300
+ if (!next || nextRevision === void 0) {
6301
+ setMessage("Copilot search settings are unavailable or invalid. Review the saved configuration.");
6302
+ return;
6303
+ }
6304
+ setDraft(next);
6305
+ setSaved(next);
6306
+ setRevision(nextRevision);
6307
+ setWritable(result.value.writable === true);
6308
+ if (!result.value.writable) setMessage("Copilot search settings are read-only in this deployment.");
6309
+ } catch {
6310
+ if (owner.active && generation === owner.generation) setMessage("Could not load Copilot search options. Reload to retry.");
6311
+ } finally {
6312
+ if (owner.active && generation === owner.generation) {
6313
+ owner.busy = false;
6314
+ setLoading(false);
6315
+ }
6316
+ }
6317
+ }, [settings]);
6318
+ (0, react.useEffect)(() => {
6319
+ const owner = lifecycle.current;
6320
+ owner.active = true;
6321
+ load();
6322
+ return () => {
6323
+ owner.active = false;
6324
+ owner.generation++;
6325
+ owner.busy = false;
6326
+ };
6327
+ }, [load]);
6328
+ const update = (key, value) => {
6329
+ setDraft((current) => ({
6330
+ ...current,
6331
+ [key]: value
6332
+ }));
6333
+ setMessage("");
6334
+ };
6335
+ const disabled = loading || saving || !writable || revision === void 0 || saved === void 0;
6336
+ const save = async () => {
6337
+ const owner = lifecycle.current;
6338
+ if (disabled || owner.busy || saved === void 0 || revision === void 0) return;
6339
+ const ops = [];
6340
+ for (const key of [
6341
+ "enabled",
6342
+ "routeWebSearch",
6343
+ "includeSources",
6344
+ "stripServerTools",
6345
+ "probe",
6346
+ "searchFallback"
6347
+ ]) if (draft[key] !== saved[key]) ops.push({
6348
+ op: "set",
6349
+ path: [key],
6350
+ value: draft[key]
6351
+ });
6352
+ for (const key of ["idleTimeoutMs", "probeTimeoutMs"]) {
6353
+ if (draft[key] === saved[key]) continue;
6354
+ const value = Number(draft[key]);
6355
+ if (!/^\d+$/.test(draft[key]) || !Number.isSafeInteger(value) || value < 1 || value > timeoutLimit) {
6356
+ setMessage(`${key} must be a whole number between 1 and ${timeoutLimit}.`);
6357
+ return;
6358
+ }
6359
+ ops.push({
6360
+ op: "set",
6361
+ path: [key],
6362
+ value
6363
+ });
6364
+ }
6365
+ if (draft.providers !== saved.providers) {
6366
+ const providers = draft.providers.split(",").map((id) => id.trim());
6367
+ if (providers.some((id) => !id) && draft.providers.trim() !== "" || new Set(providers).size !== providers.length) {
6368
+ setMessage("Enter distinct route IDs separated by commas, or leave the allowlist empty.");
6369
+ return;
6370
+ }
6371
+ ops.push({
6372
+ op: "set",
6373
+ path: ["providers"],
6374
+ value: draft.providers.trim() === "" ? [] : providers
6375
+ });
6376
+ }
6377
+ if (ops.length === 0) {
6378
+ setMessage("No search options changed.");
6379
+ return;
6380
+ }
6381
+ const generation = owner.generation;
6382
+ owner.busy = true;
6383
+ setSaving(true);
6384
+ setMessage("");
6385
+ try {
6386
+ const result = await settings.mutate(GITHUB_COPILOT_SETTINGS_NAMESPACE, ops, revision);
6387
+ if (!owner.active || generation !== owner.generation) return;
6388
+ if (!result.ok) {
6389
+ setMessage(saveFailure(result.error));
6390
+ return;
6391
+ }
6392
+ const nextRevision = revisionOf(result.value.revision);
6393
+ if (nextRevision === void 0) {
6394
+ setRevision(void 0);
6395
+ setMessage("Save returned no revision. Reload settings before editing again.");
6396
+ return;
6397
+ }
6398
+ setRevision(nextRevision);
6399
+ setSaved(draft);
6400
+ setMessage("Saved Copilot search options. Availability is checked when you search.");
6401
+ } catch (error) {
6402
+ if (owner.active && generation === owner.generation) setMessage(saveFailure(error));
6403
+ } finally {
6404
+ if (owner.active && generation === owner.generation) {
6405
+ owner.busy = false;
6406
+ setSaving(false);
6407
+ }
6408
+ }
6409
+ };
6410
+ return (0, react.createElement)("details", {
6411
+ "data-dsh-copilot-search-options": true,
6412
+ style: cardStyle
6413
+ }, (0, react.createElement)("summary", { style: {
6414
+ cursor: "pointer",
6415
+ fontWeight: 600
6416
+ } }, "Copilot hosted-search options"), (0, react.createElement)("p", { style: hintStyle }, "These settings affect Copilot only. Disabling capability verification explicitly trusts the provider protocol. The allowlist restricts routes; it does not choose a search model."), ...[
6417
+ ["enabled", "Enable Copilot hosted search"],
6418
+ ["routeWebSearch", "Route web search through this plugin"],
6419
+ ["includeSources", "Include citations in inline requests"],
6420
+ ["stripServerTools", "Remove local variants of hosted-search tools"],
6421
+ ["probe", "Verify native search capability before use"]
6422
+ ].map(([key, label]) => (0, react.createElement)("label", {
6423
+ key,
6424
+ style: optionsRowStyle
6425
+ }, (0, react.createElement)("input", {
6426
+ type: "checkbox",
6427
+ disabled,
6428
+ checked: draft[key],
6429
+ "data-dsh-copilot-search-option": key,
6430
+ onChange: (event) => update(key, event.currentTarget.checked)
6431
+ }), label)), (0, react.createElement)("label", { style: fieldStyle }, "Allowed route IDs (comma-separated; empty follows the initiating route)", (0, react.createElement)("input", {
6432
+ type: "text",
6433
+ disabled,
6434
+ value: draft.providers,
6435
+ "data-dsh-copilot-search-option": "providers",
6436
+ onChange: (event) => update("providers", event.currentTarget.value)
6437
+ })), ...["idleTimeoutMs", "probeTimeoutMs"].map((key) => (0, react.createElement)("label", {
6438
+ key,
6439
+ style: fieldStyle
6440
+ }, key === "idleTimeoutMs" ? "Search idle timeout (ms)" : "Capability probe timeout (ms)", (0, react.createElement)("input", {
6441
+ type: "number",
6442
+ min: 1,
6443
+ max: timeoutLimit,
6444
+ step: 1,
6445
+ disabled,
6446
+ value: draft[key],
6447
+ "data-dsh-copilot-search-option": key,
6448
+ onChange: (event) => update(key, event.currentTarget.value)
6449
+ }))), (0, react.createElement)("label", { style: fieldStyle }, "Legacy failure fallback", (0, react.createElement)("select", {
6450
+ disabled,
6451
+ value: draft.searchFallback,
6452
+ style: nativeSelectStyle(disabled),
6453
+ "data-dsh-copilot-search-option": "searchFallback",
6454
+ onChange: (event) => update("searchFallback", event.currentTarget.value === "none" ? "none" : "deepseek")
6455
+ }, (0, react.createElement)("option", {
6456
+ value: "deepseek",
6457
+ style: nativeOptionStyle()
6458
+ }, "Use configured DeepSeek fallback"), (0, react.createElement)("option", {
6459
+ value: "none",
6460
+ style: nativeOptionStyle()
6461
+ }, "No legacy failure fallback"))), (0, react.createElement)("div", { style: optionsRowStyle }, (0, react.createElement)("button", {
6462
+ type: "button",
6463
+ style: buttonStyle,
6464
+ disabled,
6465
+ "data-dsh-copilot-search-options-save": true,
6466
+ onClick: () => {
6467
+ save();
6468
+ }
6469
+ }, saving ? "Saving…" : "Save Copilot search options"), (0, react.createElement)("button", {
6470
+ type: "button",
6471
+ style: buttonStyle,
6472
+ disabled: loading || saving,
6473
+ onClick: () => {
6474
+ load();
6475
+ }
6476
+ }, "Reload options")), (0, react.createElement)("p", {
6477
+ role: "status",
6478
+ "aria-live": "polite",
6479
+ style: hintStyle
6480
+ }, message));
6481
+ }
6076
6482
  /** Save provider routing independently of account discovery and provider-specific model settings. */
6077
6483
  function WebSearchRoutingCard(props) {
6078
6484
  const [draft, setDraft] = (0, react.useState)({
@@ -7833,8 +8239,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7833
8239
  /** Optional search settings must never hold account authorization UI in waiting. */
7834
8240
  function registerSearchUi(ctx) {
7835
8241
  let active = true;
7836
- let footerActive = false;
8242
+ let bundleActive = false;
8243
+ let footerReady = false;
7837
8244
  let sectionActive = false;
8245
+ let footerSeat;
7838
8246
  let fallback;
7839
8247
  const settings = ctx.remote.settings;
7840
8248
  const routing = ctx.remote.githubCopilotSearchRouting;
@@ -7843,7 +8251,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7843
8251
  routing
7844
8252
  });
7845
8253
  const syncFallback = () => {
7846
- if (active && sectionActive && !footerActive) fallback ??= ctx.slots.register({
8254
+ if (active && footerReady && !bundleActive && footerSeat === void 0) try {
8255
+ footerSeat = ctx.slots.register({
8256
+ name: "settings.models.footer",
8257
+ id: "github-copilot-search-routing",
8258
+ order: 20
8259
+ }, render);
8260
+ } catch {
8261
+ ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_FOOTER_UNAVAILABLE");
8262
+ }
8263
+ else if ((!active || !footerReady || bundleActive) && footerSeat !== void 0) {
8264
+ footerSeat();
8265
+ footerSeat = void 0;
8266
+ }
8267
+ if (active && sectionActive && !bundleActive && footerSeat === void 0) fallback ??= ctx.slots.register({
7847
8268
  name: "settings.section",
7848
8269
  id: "github-copilot-search-routing",
7849
8270
  order: 12,
@@ -7854,31 +8275,46 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7854
8275
  fallback = void 0;
7855
8276
  }
7856
8277
  };
7857
- let footer = () => {};
8278
+ let bundle = () => {};
7858
8279
  try {
7859
- footer = ctx.slots.inject("settings.models.footer", () => {
8280
+ bundle = ctx.slots.inject("plugins.bundle.config", () => {
8281
+ const spec = ctx.slots.spec?.("plugins.bundle.config");
8282
+ if (spec?.kind !== "keyed" || spec.scope !== "root") {
8283
+ ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_BUNDLE_UNAVAILABLE");
8284
+ return () => {};
8285
+ }
8286
+ let dispose;
7860
8287
  try {
7861
- const spec = ctx.slots.spec?.("settings.models.footer");
7862
- if (spec?.kind !== "list" || spec.scope !== "root") return () => {};
7863
- const dispose = ctx.slots.register({
7864
- name: "settings.models.footer",
7865
- id: "github-copilot-search-routing",
7866
- order: 20
7867
- }, render);
7868
- footerActive = true;
7869
- syncFallback();
7870
- let removed = false;
7871
- return () => {
7872
- if (removed) return;
7873
- removed = true;
7874
- dispose();
7875
- footerActive = false;
7876
- syncFallback();
7877
- };
8288
+ dispose = ctx.slots.register({
8289
+ name: "plugins.bundle.config",
8290
+ key: "dsh-github-copilot"
8291
+ }, ({ view }) => view === "page" ? (0, react.createElement)("div", null, render(), (0, react.createElement)(HostedSearchSettingsCard, { settings })) : null);
7878
8292
  } catch {
7879
- ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_FOOTER_UNAVAILABLE");
8293
+ ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_BUNDLE_UNAVAILABLE");
7880
8294
  return () => {};
7881
8295
  }
8296
+ bundleActive = true;
8297
+ syncFallback();
8298
+ return () => {
8299
+ dispose();
8300
+ bundleActive = false;
8301
+ syncFallback();
8302
+ };
8303
+ });
8304
+ } catch {
8305
+ ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_BUNDLE_UNAVAILABLE");
8306
+ }
8307
+ let footer = () => {};
8308
+ try {
8309
+ footer = ctx.slots.inject("settings.models.footer", () => {
8310
+ const spec = ctx.slots.spec?.("settings.models.footer");
8311
+ if (spec?.kind !== "list" || spec.scope !== "root") return () => {};
8312
+ footerReady = true;
8313
+ syncFallback();
8314
+ return () => {
8315
+ footerReady = false;
8316
+ syncFallback();
8317
+ };
7882
8318
  });
7883
8319
  } catch {
7884
8320
  ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_FOOTER_UNAVAILABLE");
@@ -7893,10 +8329,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7893
8329
  });
7894
8330
  return () => {
7895
8331
  active = false;
8332
+ bundle();
7896
8333
  footer();
7897
8334
  section();
8335
+ footerSeat?.();
7898
8336
  fallback?.();
7899
- fallback = void 0;
7900
8337
  };
7901
8338
  }
7902
8339
  /** Mount the plugin-owned Remote namespace and register the Models card seat. */
@@ -7916,11 +8353,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7916
8353
  "slots"
7917
8354
  ], registerSearchUi);
7918
8355
  const usageUi = ctx.inject(["remote.githubCopilotUsage", "slots"], registerCopilotUsageUi);
7919
- const presentation = ctx.inject(["uiConversation", "slots"], (scope) => installReasoningPresentation({
7920
- slots: scope.slots,
7921
- uiConversation: scope.get("uiConversation"),
7922
- diagnostic: (code) => scope.logger.warn(`[github-copilot] ${code}`)
7923
- }));
8356
+ const presentation = ctx.inject(["uiConversation", "slots"], (scope) => {
8357
+ const capabilities = {
8358
+ slots: scope.slots,
8359
+ uiConversation: scope.get("uiConversation"),
8360
+ diagnostic: (code) => scope.logger.warn(`[github-copilot] ${code}`)
8361
+ };
8362
+ const reasoning = installReasoningPresentation(capabilities);
8363
+ const auto = installAutoModelPresentation(capabilities);
8364
+ return () => {
8365
+ auto();
8366
+ reasoning();
8367
+ };
8368
+ });
7924
8369
  return async () => {
7925
8370
  await usageUi.dispose();
7926
8371
  await presentation.dispose();
@@ -7940,6 +8385,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7940
8385
  exports.GitHubCopilotPreviewFooter = GitHubCopilotPreviewFooter;
7941
8386
  exports.GitHubCopilotProviderCard = GitHubCopilotProviderCard;
7942
8387
  exports.GitHubCopilotSettingsSection = GitHubCopilotSettingsSection;
8388
+ exports.HostedSearchSettingsCard = HostedSearchSettingsCard;
7943
8389
  exports.WebSearchRoutingCard = WebSearchRoutingCard;
7944
8390
  exports.activeAuthorizationNotice = activeAuthorizationNotice;
7945
8391
  exports.apply = apply;