@github/copilot-sdk 1.0.17-unstable.37553872417.gc9f6176 → 1.0.18-preview.0

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/dist/client.js CHANGED
@@ -1184,6 +1184,9 @@ class CopilotClient {
1184
1184
  if (config.gitHubToken !== void 0 && config.gitHubTokenProvider !== void 0) {
1185
1185
  throw new Error("gitHubToken and gitHubTokenProvider are mutually exclusive");
1186
1186
  }
1187
+ if (config.cloud != null && config.skillProvider) {
1188
+ throw new Error("Skill providers are not supported for cloud sessions.");
1189
+ }
1187
1190
  if (!this.connection) {
1188
1191
  await this.start();
1189
1192
  }
@@ -1243,6 +1246,9 @@ class CopilotClient {
1243
1246
  if (config.hooks) {
1244
1247
  s.registerHooks(config.hooks);
1245
1248
  }
1249
+ if (config.skillProvider) {
1250
+ s.registerSkillProvider(config.skillProvider);
1251
+ }
1246
1252
  if (transformCallbacks) {
1247
1253
  s.registerTransformCallbacks(transformCallbacks);
1248
1254
  }
@@ -1349,6 +1355,7 @@ class CopilotClient {
1349
1355
  enableSessionStore: config.enableSessionStore,
1350
1356
  enableSkills: config.enableSkills,
1351
1357
  skillDirectories: config.skillDirectories,
1358
+ ...config.skillProvider ? { hasSkillProvider: true } : {},
1352
1359
  pluginDirectories: config.pluginDirectories,
1353
1360
  instructionDirectories: config.instructionDirectories,
1354
1361
  disabledSkills: config.disabledSkills,
@@ -1362,6 +1369,7 @@ class CopilotClient {
1362
1369
  featureFlags: config.featureFlags,
1363
1370
  expAssignments: config.expAssignments,
1364
1371
  enableManagedSettings: config.enableManagedSettings,
1372
+ enforceManagedModelDefaults: config.enforceManagedModelDefaults,
1365
1373
  managedSettings: config.managedSettings
1366
1374
  });
1367
1375
  const {
@@ -1502,6 +1510,9 @@ class CopilotClient {
1502
1510
  if (config.hooks) {
1503
1511
  session.registerHooks(config.hooks);
1504
1512
  }
1513
+ if (config.skillProvider) {
1514
+ session.registerSkillProvider(config.skillProvider);
1515
+ }
1505
1516
  const modeDefaults = this.configDefaultsForMode();
1506
1517
  config = { ...modeDefaults, ...config };
1507
1518
  config.customAgentsLocalOnly ??= modeDefaults.customAgentsLocalOnly;
@@ -1515,9 +1526,10 @@ class CopilotClient {
1515
1526
  if (config.onEvent) {
1516
1527
  session.on(config.onEvent);
1517
1528
  }
1529
+ const toolFilterOptions = this.resolveToolFilterOptions(config);
1518
1530
  this.setupSessionFs(session, config);
1531
+ const replacedSession = this.sessions.get(sessionId);
1519
1532
  this.sessions.set(sessionId, session);
1520
- const toolFilterOptions = this.resolveToolFilterOptions(config);
1521
1533
  const gitHubTokenProviderRegistrationId = this.registerGitHubTokenProvider(
1522
1534
  config.gitHubTokenProvider,
1523
1535
  sessionId
@@ -1610,6 +1622,7 @@ class CopilotClient {
1610
1622
  defaultAgent: config.defaultAgent,
1611
1623
  agent: config.agent,
1612
1624
  skillDirectories: config.skillDirectories,
1625
+ ...config.skillProvider ? { hasSkillProvider: true } : {},
1613
1626
  pluginDirectories: config.pluginDirectories,
1614
1627
  instructionDirectories: config.instructionDirectories,
1615
1628
  disabledSkills: config.disabledSkills,
@@ -1625,6 +1638,7 @@ class CopilotClient {
1625
1638
  featureFlags: config.featureFlags,
1626
1639
  expAssignments: config.expAssignments,
1627
1640
  enableManagedSettings: config.enableManagedSettings,
1641
+ enforceManagedModelDefaults: config.enforceManagedModelDefaults,
1628
1642
  managedSettings: config.managedSettings,
1629
1643
  ...extensionOptions?.requestedEnvironmentVariables ? {
1630
1644
  requestedEnvironmentVariables: extensionOptions.requestedEnvironmentVariables
@@ -1654,7 +1668,13 @@ class CopilotClient {
1654
1668
  this.commitGitHubTokenProvider(sessionId, gitHubTokenProviderRegistrationId);
1655
1669
  } catch (e) {
1656
1670
  session._markDisconnected();
1657
- this.sessions.delete(sessionId);
1671
+ if (this.sessions.get(sessionId) === session) {
1672
+ if (replacedSession) {
1673
+ this.sessions.set(sessionId, replacedSession);
1674
+ } else {
1675
+ this.sessions.delete(sessionId);
1676
+ }
1677
+ }
1658
1678
  if (gitHubTokenProviderRegistrationId !== void 0) {
1659
1679
  this.githubTokenProviders.delete(gitHubTokenProviderRegistrationId);
1660
1680
  }
@@ -2630,6 +2650,20 @@ stderr: ${stderrOutput}` : ""}`
2630
2650
  return await this.handleHooksInvoke(params);
2631
2651
  }
2632
2652
  );
2653
+ this.connection.onRequest(
2654
+ "skillProvider.list",
2655
+ async (params, token) => await this.resolveSkillProviderSession(params)._handleSkillProviderList(token)
2656
+ );
2657
+ this.connection.onRequest(
2658
+ "skillProvider.read",
2659
+ async (params, token) => {
2660
+ const session = this.resolveSkillProviderSession(params);
2661
+ if (typeof params.name !== "string") {
2662
+ throw new Error("Invalid skillProvider.read payload");
2663
+ }
2664
+ return await session._handleSkillProviderRead(params.name, token);
2665
+ }
2666
+ );
2633
2667
  const connection = this.connection;
2634
2668
  const messageWriter = this.messageWriter;
2635
2669
  const cliProcess = this.isExternalServer ? null : this.cliProcess;
@@ -2786,6 +2820,16 @@ stderr: ${stderrOutput}` : ""}`
2786
2820
  });
2787
2821
  return { response };
2788
2822
  }
2823
+ resolveSkillProviderSession(params) {
2824
+ if (!params || typeof params.sessionId !== "string") {
2825
+ throw new Error("Invalid skillProvider payload");
2826
+ }
2827
+ const session = this.sessions.get(params.sessionId);
2828
+ if (!session) {
2829
+ throw new Error(`Session not found: ${params.sessionId}`);
2830
+ }
2831
+ return session;
2832
+ }
2789
2833
  async handleHooksInvoke(params) {
2790
2834
  if (!params || typeof params.sessionId !== "string" || typeof params.hookType !== "string") {
2791
2835
  throw new Error("Invalid hooks invoke payload");
@@ -2,7 +2,7 @@ import type { CopilotSession } from "./session.js";
2
2
  import { type PermissionHandler, type ResumeSessionConfig } from "./types.js";
3
3
  import type { WorkflowHandle } from "./workflow.js";
4
4
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
5
- export type JoinSessionConfig = Omit<ResumeSessionConfig, "onPermissionRequest" | "extensionSdkPath"> & {
5
+ export type JoinSessionConfig = Omit<ResumeSessionConfig, "onPermissionRequest" | "extensionSdkPath" | "skillProvider"> & {
6
6
  onPermissionRequest?: PermissionHandler;
7
7
  /**
8
8
  * Names of sensitive environment variables this extension needs, such as
package/dist/extension.js CHANGED
@@ -22,11 +22,13 @@ async function joinSession(config = {}) {
22
22
  const client = new CopilotClient({ _internalConnection: { kind: "parent-process" } });
23
23
  const {
24
24
  extensionSdkPath: _stripped,
25
+ skillProvider: _strippedSkillProvider,
25
26
  workflows,
26
27
  requestedEnvironmentVariables,
27
28
  ...rest
28
29
  } = config;
29
30
  void _stripped;
31
+ void _strippedSkillProvider;
30
32
  return client.resumeSessionForExtension(
31
33
  sessionId,
32
34
  {