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

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) {
@@ -7916,11 +8070,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7916
8070
  "slots"
7917
8071
  ], registerSearchUi);
7918
8072
  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
- }));
8073
+ const presentation = ctx.inject(["uiConversation", "slots"], (scope) => {
8074
+ const capabilities = {
8075
+ slots: scope.slots,
8076
+ uiConversation: scope.get("uiConversation"),
8077
+ diagnostic: (code) => scope.logger.warn(`[github-copilot] ${code}`)
8078
+ };
8079
+ const reasoning = installReasoningPresentation(capabilities);
8080
+ const auto = installAutoModelPresentation(capabilities);
8081
+ return () => {
8082
+ auto();
8083
+ reasoning();
8084
+ };
8085
+ });
7924
8086
  return async () => {
7925
8087
  await usageUi.dispose();
7926
8088
  await presentation.dispose();