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

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
@@ -5644,7 +5644,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5644
5644
  "ROUTE_CONFLICT"
5645
5645
  ]).optional()
5646
5646
  }).strict().optional(),
5647
- error: string().optional()
5647
+ error: string().optional(),
5648
+ authorizationMilestone: _enum([
5649
+ "AUTHORIZATION_REQUESTED",
5650
+ "INTERACTION_PROMPT_OBSERVED",
5651
+ "INTERACTION_NOTICE_OBSERVED"
5652
+ ]).optional()
5648
5653
  }).strict();
5649
5654
  const result = strictRemoteCodec(GITHUB_COPILOT_AUTHORIZATION_VIEW_TYPE_SYMBOL, GitHubCopilotAuthorizationViewSchema);
5650
5655
  const GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL = "dsh-github-copilot#GitHubCopilotMigrationStatus";
@@ -6195,6 +6200,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6195
6200
  gap: "6px",
6196
6201
  minWidth: 0
6197
6202
  };
6203
+ const optionsRowStyle = {
6204
+ display: "flex",
6205
+ alignItems: "center",
6206
+ gap: "8px",
6207
+ flexWrap: "wrap"
6208
+ };
6198
6209
  const buttonStyle = {
6199
6210
  justifySelf: "start",
6200
6211
  padding: "9px 16px",
@@ -6227,6 +6238,252 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6227
6238
  if (code === "settings-rejected") return "The settings service rejected this change. Reload settings to check whether editing is available, then try again.";
6228
6239
  return "Could not confirm the save. Reload settings to check saved values before retrying. Your current choices have been kept.";
6229
6240
  }
6241
+ const searchDefaults = {
6242
+ enabled: true,
6243
+ providers: [],
6244
+ routeWebSearch: true,
6245
+ includeSources: true,
6246
+ stripServerTools: true,
6247
+ idleTimeoutMs: 3e5,
6248
+ probe: true,
6249
+ probeTimeoutMs: 3e4,
6250
+ searchFallback: "deepseek"
6251
+ };
6252
+ const timeoutLimit = 2147483647;
6253
+ function searchOptions(value) {
6254
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
6255
+ const source = record$1(value);
6256
+ const options = {
6257
+ ...searchDefaults,
6258
+ ...source
6259
+ };
6260
+ 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;
6261
+ return {
6262
+ enabled: options.enabled,
6263
+ routeWebSearch: options.routeWebSearch,
6264
+ includeSources: options.includeSources,
6265
+ stripServerTools: options.stripServerTools,
6266
+ probe: options.probe,
6267
+ searchFallback: options.searchFallback,
6268
+ providers: options.providers.join(", "),
6269
+ idleTimeoutMs: String(options.idleTimeoutMs),
6270
+ probeTimeoutMs: String(options.probeTimeoutMs)
6271
+ };
6272
+ }
6273
+ /** Edit only explicit Copilot hosted-search leaves; provider routing remains a separate CAS. */
6274
+ function HostedSearchSettingsCard({ settings }) {
6275
+ const [draft, setDraft] = (0, react.useState)(() => searchOptions({}));
6276
+ const [saved, setSaved] = (0, react.useState)();
6277
+ const [revision, setRevision] = (0, react.useState)();
6278
+ const [writable, setWritable] = (0, react.useState)(false);
6279
+ const [loading, setLoading] = (0, react.useState)(true);
6280
+ const [saving, setSaving] = (0, react.useState)(false);
6281
+ const [message, setMessage] = (0, react.useState)("");
6282
+ const lifecycle = (0, react.useRef)({
6283
+ active: false,
6284
+ generation: 0,
6285
+ busy: false
6286
+ });
6287
+ const load = (0, react.useCallback)(async () => {
6288
+ const owner = lifecycle.current;
6289
+ if (!owner.active || owner.busy) return;
6290
+ const generation = ++owner.generation;
6291
+ owner.busy = true;
6292
+ setLoading(true);
6293
+ setWritable(false);
6294
+ setMessage("");
6295
+ try {
6296
+ const result = await settings.describe();
6297
+ if (!owner.active || generation !== owner.generation) return;
6298
+ if (!result.ok) {
6299
+ setMessage("Could not load Copilot search options. Reload to retry.");
6300
+ return;
6301
+ }
6302
+ const entry = result.value.namespaces.find((item) => item.ns === GITHUB_COPILOT_SETTINGS_NAMESPACE);
6303
+ const next = entry && searchOptions(entry.value);
6304
+ const nextRevision = revisionOf(entry?.revision);
6305
+ if (!next || nextRevision === void 0) {
6306
+ setMessage("Copilot search settings are unavailable or invalid. Review the saved configuration.");
6307
+ return;
6308
+ }
6309
+ setDraft(next);
6310
+ setSaved(next);
6311
+ setRevision(nextRevision);
6312
+ setWritable(result.value.writable === true);
6313
+ if (!result.value.writable) setMessage("Copilot search settings are read-only in this deployment.");
6314
+ } catch {
6315
+ if (owner.active && generation === owner.generation) setMessage("Could not load Copilot search options. Reload to retry.");
6316
+ } finally {
6317
+ if (owner.active && generation === owner.generation) {
6318
+ owner.busy = false;
6319
+ setLoading(false);
6320
+ }
6321
+ }
6322
+ }, [settings]);
6323
+ (0, react.useEffect)(() => {
6324
+ const owner = lifecycle.current;
6325
+ owner.active = true;
6326
+ load();
6327
+ return () => {
6328
+ owner.active = false;
6329
+ owner.generation++;
6330
+ owner.busy = false;
6331
+ };
6332
+ }, [load]);
6333
+ const update = (key, value) => {
6334
+ setDraft((current) => ({
6335
+ ...current,
6336
+ [key]: value
6337
+ }));
6338
+ setMessage("");
6339
+ };
6340
+ const disabled = loading || saving || !writable || revision === void 0 || saved === void 0;
6341
+ const save = async () => {
6342
+ const owner = lifecycle.current;
6343
+ if (disabled || owner.busy || saved === void 0 || revision === void 0) return;
6344
+ const ops = [];
6345
+ for (const key of [
6346
+ "enabled",
6347
+ "routeWebSearch",
6348
+ "includeSources",
6349
+ "stripServerTools",
6350
+ "probe",
6351
+ "searchFallback"
6352
+ ]) if (draft[key] !== saved[key]) ops.push({
6353
+ op: "set",
6354
+ path: [key],
6355
+ value: draft[key]
6356
+ });
6357
+ for (const key of ["idleTimeoutMs", "probeTimeoutMs"]) {
6358
+ if (draft[key] === saved[key]) continue;
6359
+ const value = Number(draft[key]);
6360
+ if (!/^\d+$/.test(draft[key]) || !Number.isSafeInteger(value) || value < 1 || value > timeoutLimit) {
6361
+ setMessage(`${key} must be a whole number between 1 and ${timeoutLimit}.`);
6362
+ return;
6363
+ }
6364
+ ops.push({
6365
+ op: "set",
6366
+ path: [key],
6367
+ value
6368
+ });
6369
+ }
6370
+ if (draft.providers !== saved.providers) {
6371
+ const providers = draft.providers.split(",").map((id) => id.trim());
6372
+ if (providers.some((id) => !id) && draft.providers.trim() !== "" || new Set(providers).size !== providers.length) {
6373
+ setMessage("Enter distinct route IDs separated by commas, or leave the allowlist empty.");
6374
+ return;
6375
+ }
6376
+ ops.push({
6377
+ op: "set",
6378
+ path: ["providers"],
6379
+ value: draft.providers.trim() === "" ? [] : providers
6380
+ });
6381
+ }
6382
+ if (ops.length === 0) {
6383
+ setMessage("No search options changed.");
6384
+ return;
6385
+ }
6386
+ const generation = owner.generation;
6387
+ owner.busy = true;
6388
+ setSaving(true);
6389
+ setMessage("");
6390
+ try {
6391
+ const result = await settings.mutate(GITHUB_COPILOT_SETTINGS_NAMESPACE, ops, revision);
6392
+ if (!owner.active || generation !== owner.generation) return;
6393
+ if (!result.ok) {
6394
+ setMessage(saveFailure(result.error));
6395
+ return;
6396
+ }
6397
+ const nextRevision = revisionOf(result.value.revision);
6398
+ if (nextRevision === void 0) {
6399
+ setRevision(void 0);
6400
+ setMessage("Save returned no revision. Reload settings before editing again.");
6401
+ return;
6402
+ }
6403
+ setRevision(nextRevision);
6404
+ setSaved(draft);
6405
+ setMessage("Saved Copilot search options. Availability is checked when you search.");
6406
+ } catch (error) {
6407
+ if (owner.active && generation === owner.generation) setMessage(saveFailure(error));
6408
+ } finally {
6409
+ if (owner.active && generation === owner.generation) {
6410
+ owner.busy = false;
6411
+ setSaving(false);
6412
+ }
6413
+ }
6414
+ };
6415
+ return (0, react.createElement)("details", {
6416
+ "data-dsh-copilot-search-options": true,
6417
+ style: cardStyle
6418
+ }, (0, react.createElement)("summary", { style: {
6419
+ cursor: "pointer",
6420
+ fontWeight: 600
6421
+ } }, "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."), ...[
6422
+ ["enabled", "Enable Copilot hosted search"],
6423
+ ["routeWebSearch", "Route web search through this plugin"],
6424
+ ["includeSources", "Include citations in inline requests"],
6425
+ ["stripServerTools", "Remove local variants of hosted-search tools"],
6426
+ ["probe", "Verify native search capability before use"]
6427
+ ].map(([key, label]) => (0, react.createElement)("label", {
6428
+ key,
6429
+ style: optionsRowStyle
6430
+ }, (0, react.createElement)("input", {
6431
+ type: "checkbox",
6432
+ disabled,
6433
+ checked: draft[key],
6434
+ "data-dsh-copilot-search-option": key,
6435
+ onChange: (event) => update(key, event.currentTarget.checked)
6436
+ }), label)), (0, react.createElement)("label", { style: fieldStyle }, "Allowed route IDs (comma-separated; empty follows the initiating route)", (0, react.createElement)("input", {
6437
+ type: "text",
6438
+ disabled,
6439
+ value: draft.providers,
6440
+ "data-dsh-copilot-search-option": "providers",
6441
+ onChange: (event) => update("providers", event.currentTarget.value)
6442
+ })), ...["idleTimeoutMs", "probeTimeoutMs"].map((key) => (0, react.createElement)("label", {
6443
+ key,
6444
+ style: fieldStyle
6445
+ }, key === "idleTimeoutMs" ? "Search idle timeout (ms)" : "Capability probe timeout (ms)", (0, react.createElement)("input", {
6446
+ type: "number",
6447
+ min: 1,
6448
+ max: timeoutLimit,
6449
+ step: 1,
6450
+ disabled,
6451
+ value: draft[key],
6452
+ "data-dsh-copilot-search-option": key,
6453
+ onChange: (event) => update(key, event.currentTarget.value)
6454
+ }))), (0, react.createElement)("label", { style: fieldStyle }, "Legacy failure fallback", (0, react.createElement)("select", {
6455
+ disabled,
6456
+ value: draft.searchFallback,
6457
+ style: nativeSelectStyle(disabled),
6458
+ "data-dsh-copilot-search-option": "searchFallback",
6459
+ onChange: (event) => update("searchFallback", event.currentTarget.value === "none" ? "none" : "deepseek")
6460
+ }, (0, react.createElement)("option", {
6461
+ value: "deepseek",
6462
+ style: nativeOptionStyle()
6463
+ }, "Use configured DeepSeek fallback"), (0, react.createElement)("option", {
6464
+ value: "none",
6465
+ style: nativeOptionStyle()
6466
+ }, "No legacy failure fallback"))), (0, react.createElement)("div", { style: optionsRowStyle }, (0, react.createElement)("button", {
6467
+ type: "button",
6468
+ style: buttonStyle,
6469
+ disabled,
6470
+ "data-dsh-copilot-search-options-save": true,
6471
+ onClick: () => {
6472
+ save();
6473
+ }
6474
+ }, saving ? "Saving…" : "Save Copilot search options"), (0, react.createElement)("button", {
6475
+ type: "button",
6476
+ style: buttonStyle,
6477
+ disabled: loading || saving,
6478
+ onClick: () => {
6479
+ load();
6480
+ }
6481
+ }, "Reload options")), (0, react.createElement)("p", {
6482
+ role: "status",
6483
+ "aria-live": "polite",
6484
+ style: hintStyle
6485
+ }, message));
6486
+ }
6230
6487
  /** Save provider routing independently of account discovery and provider-specific model settings. */
6231
6488
  function WebSearchRoutingCard(props) {
6232
6489
  const [draft, setDraft] = (0, react.useState)({
@@ -7112,6 +7369,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7112
7369
  "error"
7113
7370
  ].includes(owned.phase) || typeof owned.configured !== "boolean" || typeof owned.writable !== "boolean" || typeof owned.inFlight !== "boolean") return void 0;
7114
7371
  if (owned.error !== void 0 && typeof owned.error !== "string") owned.error = "COPILOT_AUTHORIZATION_FAILED";
7372
+ const milestone = source.authorizationMilestone;
7373
+ if (typeof milestone === "string" && [
7374
+ "AUTHORIZATION_REQUESTED",
7375
+ "INTERACTION_PROMPT_OBSERVED",
7376
+ "INTERACTION_NOTICE_OBSERVED"
7377
+ ].includes(milestone)) owned.authorizationMilestone = milestone;
7115
7378
  const notices = source.notices;
7116
7379
  if (!Array.isArray(notices)) return void 0;
7117
7380
  owned.notices = notices.map((notice) => {
@@ -7616,9 +7879,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7616
7879
  maxWidth: "100%",
7617
7880
  cursor: "pointer"
7618
7881
  };
7619
- function compactErrorMessage(code) {
7882
+ function compactErrorMessage(code, milestone) {
7620
7883
  if (code === "COPILOT_MODEL_DISCOVERY_FAILED") return "Could not refresh models. Try again.";
7621
- if (code === "COPILOT_AUTHORIZATION_BEGIN_FAILED") return "GitHub sign-in did not complete. Try again. If it continues, share diagnostic code COPILOT_AUTHORIZATION_BEGIN_FAILED with support.";
7884
+ if (code === "COPILOT_AUTHORIZATION_BEGIN_FAILED") return `GitHub sign-in did not complete.${milestone === void 0 ? "" : ` Latest observed milestone: ${milestone}.`} Try again. If it continues, share diagnostic code COPILOT_AUTHORIZATION_BEGIN_FAILED with support.`;
7622
7885
  if (code === "COPILOT_ROUTE_REPAIR_FAILED") return "GitHub sign-in completed, but model configuration repair failed. Authentication is retained. Open Manage and choose Repair model configuration. If it continues, share diagnostic code COPILOT_ROUTE_REPAIR_FAILED with support.";
7623
7886
  if (code === "COPILOT_AUTHORIZATION_START_FAILED") return "Could not confirm sign-in. Retry status to check.";
7624
7887
  if (code === "COPILOT_AUTHORIZATION_CANCEL_FAILED") return "Could not confirm cancellation. Retry status to check.";
@@ -7719,7 +7982,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7719
7982
  fontSize: "13px",
7720
7983
  overflowWrap: "anywhere"
7721
7984
  }
7722
- }, compactErrorMessage(state.error)), authorizing ? (0, react.createElement)("div", {
7985
+ }, compactErrorMessage(state.error, view?.authorizationMilestone)), authorizing ? (0, react.createElement)("div", {
7723
7986
  "data-dsh-github-copilot-auto-authorization": true,
7724
7987
  style: {
7725
7988
  marginTop: "8px",
@@ -7987,8 +8250,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7987
8250
  /** Optional search settings must never hold account authorization UI in waiting. */
7988
8251
  function registerSearchUi(ctx) {
7989
8252
  let active = true;
7990
- let footerActive = false;
8253
+ let bundleActive = false;
8254
+ let footerReady = false;
7991
8255
  let sectionActive = false;
8256
+ let footerSeat;
7992
8257
  let fallback;
7993
8258
  const settings = ctx.remote.settings;
7994
8259
  const routing = ctx.remote.githubCopilotSearchRouting;
@@ -7997,7 +8262,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7997
8262
  routing
7998
8263
  });
7999
8264
  const syncFallback = () => {
8000
- if (active && sectionActive && !footerActive) fallback ??= ctx.slots.register({
8265
+ if (active && footerReady && !bundleActive && footerSeat === void 0) try {
8266
+ footerSeat = ctx.slots.register({
8267
+ name: "settings.models.footer",
8268
+ id: "github-copilot-search-routing",
8269
+ order: 20
8270
+ }, render);
8271
+ } catch {
8272
+ ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_FOOTER_UNAVAILABLE");
8273
+ }
8274
+ else if ((!active || !footerReady || bundleActive) && footerSeat !== void 0) {
8275
+ footerSeat();
8276
+ footerSeat = void 0;
8277
+ }
8278
+ if (active && sectionActive && !bundleActive && footerSeat === void 0) fallback ??= ctx.slots.register({
8001
8279
  name: "settings.section",
8002
8280
  id: "github-copilot-search-routing",
8003
8281
  order: 12,
@@ -8008,31 +8286,46 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8008
8286
  fallback = void 0;
8009
8287
  }
8010
8288
  };
8011
- let footer = () => {};
8289
+ let bundle = () => {};
8012
8290
  try {
8013
- footer = ctx.slots.inject("settings.models.footer", () => {
8291
+ bundle = ctx.slots.inject("plugins.bundle.config", () => {
8292
+ const spec = ctx.slots.spec?.("plugins.bundle.config");
8293
+ if (spec?.kind !== "keyed" || spec.scope !== "root") {
8294
+ ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_BUNDLE_UNAVAILABLE");
8295
+ return () => {};
8296
+ }
8297
+ let dispose;
8014
8298
  try {
8015
- const spec = ctx.slots.spec?.("settings.models.footer");
8016
- if (spec?.kind !== "list" || spec.scope !== "root") return () => {};
8017
- const dispose = ctx.slots.register({
8018
- name: "settings.models.footer",
8019
- id: "github-copilot-search-routing",
8020
- order: 20
8021
- }, render);
8022
- footerActive = true;
8023
- syncFallback();
8024
- let removed = false;
8025
- return () => {
8026
- if (removed) return;
8027
- removed = true;
8028
- dispose();
8029
- footerActive = false;
8030
- syncFallback();
8031
- };
8299
+ dispose = ctx.slots.register({
8300
+ name: "plugins.bundle.config",
8301
+ key: "dsh-github-copilot"
8302
+ }, ({ view }) => view === "page" ? (0, react.createElement)("div", null, render(), (0, react.createElement)(HostedSearchSettingsCard, { settings })) : null);
8032
8303
  } catch {
8033
- ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_FOOTER_UNAVAILABLE");
8304
+ ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_BUNDLE_UNAVAILABLE");
8034
8305
  return () => {};
8035
8306
  }
8307
+ bundleActive = true;
8308
+ syncFallback();
8309
+ return () => {
8310
+ dispose();
8311
+ bundleActive = false;
8312
+ syncFallback();
8313
+ };
8314
+ });
8315
+ } catch {
8316
+ ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_BUNDLE_UNAVAILABLE");
8317
+ }
8318
+ let footer = () => {};
8319
+ try {
8320
+ footer = ctx.slots.inject("settings.models.footer", () => {
8321
+ const spec = ctx.slots.spec?.("settings.models.footer");
8322
+ if (spec?.kind !== "list" || spec.scope !== "root") return () => {};
8323
+ footerReady = true;
8324
+ syncFallback();
8325
+ return () => {
8326
+ footerReady = false;
8327
+ syncFallback();
8328
+ };
8036
8329
  });
8037
8330
  } catch {
8038
8331
  ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_FOOTER_UNAVAILABLE");
@@ -8047,10 +8340,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8047
8340
  });
8048
8341
  return () => {
8049
8342
  active = false;
8343
+ bundle();
8050
8344
  footer();
8051
8345
  section();
8346
+ footerSeat?.();
8052
8347
  fallback?.();
8053
- fallback = void 0;
8054
8348
  };
8055
8349
  }
8056
8350
  /** Mount the plugin-owned Remote namespace and register the Models card seat. */
@@ -8102,6 +8396,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8102
8396
  exports.GitHubCopilotPreviewFooter = GitHubCopilotPreviewFooter;
8103
8397
  exports.GitHubCopilotProviderCard = GitHubCopilotProviderCard;
8104
8398
  exports.GitHubCopilotSettingsSection = GitHubCopilotSettingsSection;
8399
+ exports.HostedSearchSettingsCard = HostedSearchSettingsCard;
8105
8400
  exports.WebSearchRoutingCard = WebSearchRoutingCard;
8106
8401
  exports.activeAuthorizationNotice = activeAuthorizationNotice;
8107
8402
  exports.apply = apply;