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

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,
@@ -1502,6 +1509,9 @@ class CopilotClient {
1502
1509
  if (config.hooks) {
1503
1510
  session.registerHooks(config.hooks);
1504
1511
  }
1512
+ if (config.skillProvider) {
1513
+ session.registerSkillProvider(config.skillProvider);
1514
+ }
1505
1515
  const modeDefaults = this.configDefaultsForMode();
1506
1516
  config = { ...modeDefaults, ...config };
1507
1517
  config.customAgentsLocalOnly ??= modeDefaults.customAgentsLocalOnly;
@@ -1515,9 +1525,10 @@ class CopilotClient {
1515
1525
  if (config.onEvent) {
1516
1526
  session.on(config.onEvent);
1517
1527
  }
1528
+ const toolFilterOptions = this.resolveToolFilterOptions(config);
1518
1529
  this.setupSessionFs(session, config);
1530
+ const replacedSession = this.sessions.get(sessionId);
1519
1531
  this.sessions.set(sessionId, session);
1520
- const toolFilterOptions = this.resolveToolFilterOptions(config);
1521
1532
  const gitHubTokenProviderRegistrationId = this.registerGitHubTokenProvider(
1522
1533
  config.gitHubTokenProvider,
1523
1534
  sessionId
@@ -1610,6 +1621,7 @@ class CopilotClient {
1610
1621
  defaultAgent: config.defaultAgent,
1611
1622
  agent: config.agent,
1612
1623
  skillDirectories: config.skillDirectories,
1624
+ ...config.skillProvider ? { hasSkillProvider: true } : {},
1613
1625
  pluginDirectories: config.pluginDirectories,
1614
1626
  instructionDirectories: config.instructionDirectories,
1615
1627
  disabledSkills: config.disabledSkills,
@@ -1654,7 +1666,13 @@ class CopilotClient {
1654
1666
  this.commitGitHubTokenProvider(sessionId, gitHubTokenProviderRegistrationId);
1655
1667
  } catch (e) {
1656
1668
  session._markDisconnected();
1657
- this.sessions.delete(sessionId);
1669
+ if (this.sessions.get(sessionId) === session) {
1670
+ if (replacedSession) {
1671
+ this.sessions.set(sessionId, replacedSession);
1672
+ } else {
1673
+ this.sessions.delete(sessionId);
1674
+ }
1675
+ }
1658
1676
  if (gitHubTokenProviderRegistrationId !== void 0) {
1659
1677
  this.githubTokenProviders.delete(gitHubTokenProviderRegistrationId);
1660
1678
  }
@@ -2630,6 +2648,20 @@ stderr: ${stderrOutput}` : ""}`
2630
2648
  return await this.handleHooksInvoke(params);
2631
2649
  }
2632
2650
  );
2651
+ this.connection.onRequest(
2652
+ "skillProvider.list",
2653
+ async (params, token) => await this.resolveSkillProviderSession(params)._handleSkillProviderList(token)
2654
+ );
2655
+ this.connection.onRequest(
2656
+ "skillProvider.read",
2657
+ async (params, token) => {
2658
+ const session = this.resolveSkillProviderSession(params);
2659
+ if (typeof params.name !== "string") {
2660
+ throw new Error("Invalid skillProvider.read payload");
2661
+ }
2662
+ return await session._handleSkillProviderRead(params.name, token);
2663
+ }
2664
+ );
2633
2665
  const connection = this.connection;
2634
2666
  const messageWriter = this.messageWriter;
2635
2667
  const cliProcess = this.isExternalServer ? null : this.cliProcess;
@@ -2786,6 +2818,16 @@ stderr: ${stderrOutput}` : ""}`
2786
2818
  });
2787
2819
  return { response };
2788
2820
  }
2821
+ resolveSkillProviderSession(params) {
2822
+ if (!params || typeof params.sessionId !== "string") {
2823
+ throw new Error("Invalid skillProvider payload");
2824
+ }
2825
+ const session = this.sessions.get(params.sessionId);
2826
+ if (!session) {
2827
+ throw new Error(`Session not found: ${params.sessionId}`);
2828
+ }
2829
+ return session;
2830
+ }
2789
2831
  async handleHooksInvoke(params) {
2790
2832
  if (!params || typeof params.sessionId !== "string" || typeof params.hookType !== "string") {
2791
2833
  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
  {