@github/copilot-sdk 1.0.7-preview.3 → 1.0.8-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.
@@ -520,6 +520,9 @@ class CopilotClient {
520
520
  }
521
521
  setupClientGlobalHandlers() {
522
522
  const handlers = {};
523
+ handlers.hooks = {
524
+ invoke: async (params) => await this.handleHooksInvoke(params)
525
+ };
523
526
  if (this.requestHandler) {
524
527
  handlers.llmInference = (0, import_copilotRequestHandler.createCopilotRequestAdapter)(this.requestHandler, () => {
525
528
  if (!this.connection) {
@@ -1074,7 +1077,8 @@ class CopilotClient {
1074
1077
  parameters: toJsonSchema(tool.parameters),
1075
1078
  overridesBuiltInTool: tool.overridesBuiltInTool,
1076
1079
  skipPermission: tool.skipPermission,
1077
- defer: tool.defer
1080
+ defer: tool.defer,
1081
+ metadata: tool.metadata
1078
1082
  })),
1079
1083
  toolSearch: config.toolSearch,
1080
1084
  canvases: config.canvases?.map((canvas) => canvas.declaration),
@@ -1273,7 +1277,8 @@ class CopilotClient {
1273
1277
  parameters: toJsonSchema(tool.parameters),
1274
1278
  overridesBuiltInTool: tool.overridesBuiltInTool,
1275
1279
  skipPermission: tool.skipPermission,
1276
- defer: tool.defer
1280
+ defer: tool.defer,
1281
+ metadata: tool.metadata
1277
1282
  })),
1278
1283
  toolSearch: config.toolSearch,
1279
1284
  canvases: config.canvases?.map((canvas) => canvas.declaration),
@@ -2063,10 +2068,6 @@ stderr: ${stderrOutput}`
2063
2068
  "autoModeSwitch.request",
2064
2069
  async (params) => await this.handleAutoModeSwitchRequest(params)
2065
2070
  );
2066
- this.connection.onRequest(
2067
- "hooks.invoke",
2068
- async (params) => await this.handleHooksInvoke(params)
2069
- );
2070
2071
  this.connection.onRequest(
2071
2072
  "systemMessage.transform",
2072
2073
  async (params) => await this.handleSystemMessageTransform(params)
@@ -762,6 +762,68 @@ function createSessionRpc(connection, sessionId) {
762
762
  }
763
763
  },
764
764
  /** @experimental */
765
+ factory: {
766
+ /**
767
+ * Runs a registered factory by name at the top level.
768
+ *
769
+ * @param params Parameters for invoking a registered factory.
770
+ *
771
+ * @returns Complete current or terminal factory run envelope.
772
+ */
773
+ run: async (params) => connection.sendRequest("session.factory.run", { sessionId, ...params }),
774
+ /**
775
+ * Gets the current or settled envelope for a factory run.
776
+ *
777
+ * @param params Parameters for retrieving a factory run.
778
+ *
779
+ * @returns Complete current or terminal factory run envelope.
780
+ */
781
+ getRun: async (params) => connection.sendRequest("session.factory.getRun", { sessionId, ...params }),
782
+ /**
783
+ * Requests cancellation of a factory run and returns its run envelope.
784
+ *
785
+ * @param params Parameters for cancelling a factory run.
786
+ *
787
+ * @returns Complete current or terminal factory run envelope.
788
+ */
789
+ cancel: async (params) => connection.sendRequest("session.factory.cancel", { sessionId, ...params }),
790
+ /**
791
+ * Records a batch of ordered factory progress lines.
792
+ *
793
+ * @param params Parameters for recording factory progress.
794
+ *
795
+ * @returns Acknowledgement that a factory request was accepted.
796
+ */
797
+ log: async (params) => connection.sendRequest("session.factory.log", { sessionId, ...params }),
798
+ /**
799
+ * Runs one factory-scoped subagent and returns its result.
800
+ *
801
+ * @param params Parameters for one factory-scoped subagent call.
802
+ *
803
+ * @returns Result of one factory-scoped subagent call.
804
+ */
805
+ agent: async (params) => connection.sendRequest("session.factory.agent", { sessionId, ...params }),
806
+ /** @experimental */
807
+ journal: {
808
+ /**
809
+ * Reads a memoized factory journal entry.
810
+ *
811
+ * @param params Parameters for reading a factory journal entry.
812
+ *
813
+ * @returns Result of reading a factory journal entry.
814
+ */
815
+ get: async (params) => connection.sendRequest("session.factory.journal.get", { sessionId, ...params }),
816
+ /**
817
+ * Stores a memoized factory journal entry.
818
+ *
819
+ * @param params Parameters for storing a factory journal entry.
820
+ *
821
+ * @returns Acknowledgement that a factory request was accepted.
822
+ */
823
+ put: async (params) => connection.sendRequest("session.factory.journal.put", { sessionId, ...params })
824
+ }
825
+ },
826
+ /** @experimental */
765
827
  model: {
766
828
  /**
767
829
  * Gets the currently selected model for the session.
@@ -1119,7 +1181,7 @@ function createSessionRpc(connection, sessionId) {
1119
1181
  */
1120
1182
  list: async () => connection.sendRequest("session.mcp.list", { sessionId }),
1121
1183
  /**
1122
- * Lists the tools exposed by a connected MCP server on this session's host.
1184
+ * Lists the tools exposed by a connected MCP server on this session's host. This performs a live `tools/list` request. Tool UI metadata is returned independently of whether MCP Apps rendering is enabled for the session.
1123
1185
  *
1124
1186
  * @param params Server name whose tool list should be returned.
1125
1187
  *
@@ -1794,11 +1856,11 @@ function createSessionRpc(connection, sessionId) {
1794
1856
  */
1795
1857
  getContextHeaviestMessages: async (params) => connection.sendRequest("session.metadata.getContextHeaviestMessages", { sessionId, ...params }),
1796
1858
  /**
1797
- * Records a working-directory/git context change and emits a `session.context_changed` event.
1859
+ * Records a working-directory/git context change and emits a `session.context_changed` event. For a local session, a report whose `cwd` diverges from the session's current working directory is ignored (the call still succeeds but records nothing and emits no event): a local session's working directory is authoritative and is moved via `metadata.setWorkingDirectory` (or an SDK `session.resume` that supplies a `workingDirectory`), not by this method.
1798
1860
  *
1799
1861
  * @param params Updated working-directory/git context to record on the session.
1800
1862
  *
1801
- * @returns Notify the session that its working directory context has changed. Emits a `session.context_changed` event so consumers (telemetry, OTel tracker, ACP, the timeline UI) can react. Use this when the host has detected a cwd/branch/repo change outside the session's normal lifecycle (e.g., after a shell command in interactive mode).
1863
+ * @returns Notify the session that its working directory context has changed. Emits a `session.context_changed` event so consumers (telemetry, OTel tracker, ACP, the timeline UI) can react. Use this when the host has detected a cwd/branch/repo change outside the session's normal lifecycle (e.g., after a shell command in interactive mode). For a local session, a report whose `cwd` diverges from the session's current working directory is ignored (the call still succeeds but records nothing and emits no event); move a local session's working directory via `metadata.setWorkingDirectory` instead.
1802
1864
  */
1803
1865
  recordContextChange: async (params) => connection.sendRequest("session.metadata.recordContextChange", { sessionId, ...params }),
1804
1866
  /**
@@ -2068,6 +2130,16 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
2068
2130
  if (!handler) throw new Error(`No providerToken handler registered for session: ${params.sessionId}`);
2069
2131
  return handler.getToken(params);
2070
2132
  });
2133
+ connection.onRequest("factory.execute", async (params) => {
2134
+ const handler = getHandlers(params.sessionId).factory;
2135
+ if (!handler) throw new Error(`No factory handler registered for session: ${params.sessionId}`);
2136
+ return handler.execute(params);
2137
+ });
2138
+ connection.onRequest("factory.abort", async (params) => {
2139
+ const handler = getHandlers(params.sessionId).factory;
2140
+ if (!handler) throw new Error(`No factory handler registered for session: ${params.sessionId}`);
2141
+ return handler.abort(params);
2142
+ });
2071
2143
  connection.onRequest("sessionFs.readFile", async (params) => {
2072
2144
  const handler = getHandlers(params.sessionId).sessionFs;
2073
2145
  if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
@@ -2145,6 +2217,11 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
2145
2217
  });
2146
2218
  }
2147
2219
  function registerClientGlobalApiHandlers(connection, handlers) {
2220
+ connection.onRequest("hooks.invoke", async (params) => {
2221
+ const handler = handlers.hooks;
2222
+ if (!handler) throw new Error("No hooks client-global handler registered");
2223
+ return handler.invoke(params);
2224
+ });
2148
2225
  connection.onRequest("llmInference.httpRequestStart", async (params) => {
2149
2226
  const handler = handlers.llmInference;
2150
2227
  if (!handler) throw new Error("No llmInference client-global handler registered");
package/dist/client.js CHANGED
@@ -497,6 +497,9 @@ class CopilotClient {
497
497
  }
498
498
  setupClientGlobalHandlers() {
499
499
  const handlers = {};
500
+ handlers.hooks = {
501
+ invoke: async (params) => await this.handleHooksInvoke(params)
502
+ };
500
503
  if (this.requestHandler) {
501
504
  handlers.llmInference = createCopilotRequestAdapter(this.requestHandler, () => {
502
505
  if (!this.connection) {
@@ -1051,7 +1054,8 @@ class CopilotClient {
1051
1054
  parameters: toJsonSchema(tool.parameters),
1052
1055
  overridesBuiltInTool: tool.overridesBuiltInTool,
1053
1056
  skipPermission: tool.skipPermission,
1054
- defer: tool.defer
1057
+ defer: tool.defer,
1058
+ metadata: tool.metadata
1055
1059
  })),
1056
1060
  toolSearch: config.toolSearch,
1057
1061
  canvases: config.canvases?.map((canvas) => canvas.declaration),
@@ -1250,7 +1254,8 @@ class CopilotClient {
1250
1254
  parameters: toJsonSchema(tool.parameters),
1251
1255
  overridesBuiltInTool: tool.overridesBuiltInTool,
1252
1256
  skipPermission: tool.skipPermission,
1253
- defer: tool.defer
1257
+ defer: tool.defer,
1258
+ metadata: tool.metadata
1254
1259
  })),
1255
1260
  toolSearch: config.toolSearch,
1256
1261
  canvases: config.canvases?.map((canvas) => canvas.declaration),
@@ -2040,10 +2045,6 @@ stderr: ${stderrOutput}`
2040
2045
  "autoModeSwitch.request",
2041
2046
  async (params) => await this.handleAutoModeSwitchRequest(params)
2042
2047
  );
2043
- this.connection.onRequest(
2044
- "hooks.invoke",
2045
- async (params) => await this.handleHooksInvoke(params)
2046
- );
2047
2048
  this.connection.onRequest(
2048
2049
  "systemMessage.transform",
2049
2050
  async (params) => await this.handleSystemMessageTransform(params)