dsh-github-copilot 0.4.0-alpha.42 → 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
@@ -6195,6 +6195,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6195
6195
  gap: "6px",
6196
6196
  minWidth: 0
6197
6197
  };
6198
+ const optionsRowStyle = {
6199
+ display: "flex",
6200
+ alignItems: "center",
6201
+ gap: "8px",
6202
+ flexWrap: "wrap"
6203
+ };
6198
6204
  const buttonStyle = {
6199
6205
  justifySelf: "start",
6200
6206
  padding: "9px 16px",
@@ -6227,6 +6233,252 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6227
6233
  if (code === "settings-rejected") return "The settings service rejected this change. Reload settings to check whether editing is available, then try again.";
6228
6234
  return "Could not confirm the save. Reload settings to check saved values before retrying. Your current choices have been kept.";
6229
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
+ }
6230
6482
  /** Save provider routing independently of account discovery and provider-specific model settings. */
6231
6483
  function WebSearchRoutingCard(props) {
6232
6484
  const [draft, setDraft] = (0, react.useState)({
@@ -7987,8 +8239,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7987
8239
  /** Optional search settings must never hold account authorization UI in waiting. */
7988
8240
  function registerSearchUi(ctx) {
7989
8241
  let active = true;
7990
- let footerActive = false;
8242
+ let bundleActive = false;
8243
+ let footerReady = false;
7991
8244
  let sectionActive = false;
8245
+ let footerSeat;
7992
8246
  let fallback;
7993
8247
  const settings = ctx.remote.settings;
7994
8248
  const routing = ctx.remote.githubCopilotSearchRouting;
@@ -7997,7 +8251,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7997
8251
  routing
7998
8252
  });
7999
8253
  const syncFallback = () => {
8000
- 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({
8001
8268
  name: "settings.section",
8002
8269
  id: "github-copilot-search-routing",
8003
8270
  order: 12,
@@ -8008,31 +8275,46 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8008
8275
  fallback = void 0;
8009
8276
  }
8010
8277
  };
8011
- let footer = () => {};
8278
+ let bundle = () => {};
8012
8279
  try {
8013
- 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;
8014
8287
  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
- };
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);
8032
8292
  } catch {
8033
- ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_FOOTER_UNAVAILABLE");
8293
+ ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_BUNDLE_UNAVAILABLE");
8034
8294
  return () => {};
8035
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
+ };
8036
8318
  });
8037
8319
  } catch {
8038
8320
  ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_FOOTER_UNAVAILABLE");
@@ -8047,10 +8329,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8047
8329
  });
8048
8330
  return () => {
8049
8331
  active = false;
8332
+ bundle();
8050
8333
  footer();
8051
8334
  section();
8335
+ footerSeat?.();
8052
8336
  fallback?.();
8053
- fallback = void 0;
8054
8337
  };
8055
8338
  }
8056
8339
  /** Mount the plugin-owned Remote namespace and register the Models card seat. */
@@ -8102,6 +8385,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8102
8385
  exports.GitHubCopilotPreviewFooter = GitHubCopilotPreviewFooter;
8103
8386
  exports.GitHubCopilotProviderCard = GitHubCopilotProviderCard;
8104
8387
  exports.GitHubCopilotSettingsSection = GitHubCopilotSettingsSection;
8388
+ exports.HostedSearchSettingsCard = HostedSearchSettingsCard;
8105
8389
  exports.WebSearchRoutingCard = WebSearchRoutingCard;
8106
8390
  exports.activeAuthorizationNotice = activeAuthorizationNotice;
8107
8391
  exports.apply = apply;