vidpipe 1.3.29 → 1.3.31

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/cli.js CHANGED
@@ -6207,18 +6207,45 @@ function createServerRpc(connection) {
6207
6207
  return {
6208
6208
  ping: async (params) => connection.sendRequest("ping", params),
6209
6209
  models: {
6210
- list: async () => connection.sendRequest("models.list", {})
6210
+ list: async (params) => connection.sendRequest("models.list", params)
6211
6211
  },
6212
6212
  tools: {
6213
6213
  list: async (params) => connection.sendRequest("tools.list", params)
6214
6214
  },
6215
6215
  account: {
6216
- getQuota: async () => connection.sendRequest("account.getQuota", {})
6216
+ getQuota: async (params) => connection.sendRequest("account.getQuota", params)
6217
+ },
6218
+ mcp: {
6219
+ config: {
6220
+ list: async () => connection.sendRequest("mcp.config.list", {}),
6221
+ add: async (params) => connection.sendRequest("mcp.config.add", params),
6222
+ update: async (params) => connection.sendRequest("mcp.config.update", params),
6223
+ remove: async (params) => connection.sendRequest("mcp.config.remove", params),
6224
+ enable: async (params) => connection.sendRequest("mcp.config.enable", params),
6225
+ disable: async (params) => connection.sendRequest("mcp.config.disable", params)
6226
+ },
6227
+ discover: async (params) => connection.sendRequest("mcp.discover", params)
6228
+ },
6229
+ skills: {
6230
+ config: {
6231
+ setDisabledSkills: async (params) => connection.sendRequest("skills.config.setDisabledSkills", params)
6232
+ },
6233
+ discover: async (params) => connection.sendRequest("skills.discover", params)
6234
+ },
6235
+ sessionFs: {
6236
+ setProvider: async (params) => connection.sendRequest("sessionFs.setProvider", params)
6237
+ },
6238
+ /** @experimental */
6239
+ sessions: {
6240
+ fork: async (params) => connection.sendRequest("sessions.fork", params)
6217
6241
  }
6218
6242
  };
6219
6243
  }
6220
6244
  function createSessionRpc(connection, sessionId) {
6221
6245
  return {
6246
+ auth: {
6247
+ getStatus: async () => connection.sendRequest("session.auth.getStatus", { sessionId })
6248
+ },
6222
6249
  model: {
6223
6250
  getCurrent: async () => connection.sendRequest("session.model.getCurrent", { sessionId }),
6224
6251
  switchTo: async (params) => connection.sendRequest("session.model.switchTo", { sessionId, ...params })
@@ -6227,15 +6254,23 @@ function createSessionRpc(connection, sessionId) {
6227
6254
  get: async () => connection.sendRequest("session.mode.get", { sessionId }),
6228
6255
  set: async (params) => connection.sendRequest("session.mode.set", { sessionId, ...params })
6229
6256
  },
6257
+ name: {
6258
+ get: async () => connection.sendRequest("session.name.get", { sessionId }),
6259
+ set: async (params) => connection.sendRequest("session.name.set", { sessionId, ...params })
6260
+ },
6230
6261
  plan: {
6231
6262
  read: async () => connection.sendRequest("session.plan.read", { sessionId }),
6232
6263
  update: async (params) => connection.sendRequest("session.plan.update", { sessionId, ...params }),
6233
6264
  delete: async () => connection.sendRequest("session.plan.delete", { sessionId })
6234
6265
  },
6235
- workspace: {
6236
- listFiles: async () => connection.sendRequest("session.workspace.listFiles", { sessionId }),
6237
- readFile: async (params) => connection.sendRequest("session.workspace.readFile", { sessionId, ...params }),
6238
- createFile: async (params) => connection.sendRequest("session.workspace.createFile", { sessionId, ...params })
6266
+ workspaces: {
6267
+ getWorkspace: async () => connection.sendRequest("session.workspaces.getWorkspace", { sessionId }),
6268
+ listFiles: async () => connection.sendRequest("session.workspaces.listFiles", { sessionId }),
6269
+ readFile: async (params) => connection.sendRequest("session.workspaces.readFile", { sessionId, ...params }),
6270
+ createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { sessionId, ...params })
6271
+ },
6272
+ instructions: {
6273
+ getSources: async () => connection.sendRequest("session.instructions.getSources", { sessionId })
6239
6274
  },
6240
6275
  /** @experimental */
6241
6276
  fleet: {
@@ -6261,7 +6296,11 @@ function createSessionRpc(connection, sessionId) {
6261
6296
  list: async () => connection.sendRequest("session.mcp.list", { sessionId }),
6262
6297
  enable: async (params) => connection.sendRequest("session.mcp.enable", { sessionId, ...params }),
6263
6298
  disable: async (params) => connection.sendRequest("session.mcp.disable", { sessionId, ...params }),
6264
- reload: async () => connection.sendRequest("session.mcp.reload", { sessionId })
6299
+ reload: async () => connection.sendRequest("session.mcp.reload", { sessionId }),
6300
+ /** @experimental */
6301
+ oauth: {
6302
+ login: async (params) => connection.sendRequest("session.mcp.oauth.login", { sessionId, ...params })
6303
+ }
6265
6304
  },
6266
6305
  /** @experimental */
6267
6306
  plugins: {
@@ -6274,10 +6313,6 @@ function createSessionRpc(connection, sessionId) {
6274
6313
  disable: async (params) => connection.sendRequest("session.extensions.disable", { sessionId, ...params }),
6275
6314
  reload: async () => connection.sendRequest("session.extensions.reload", { sessionId })
6276
6315
  },
6277
- /** @experimental */
6278
- compaction: {
6279
- compact: async () => connection.sendRequest("session.compaction.compact", { sessionId })
6280
- },
6281
6316
  tools: {
6282
6317
  handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { sessionId, ...params })
6283
6318
  },
@@ -6285,18 +6320,82 @@ function createSessionRpc(connection, sessionId) {
6285
6320
  handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params })
6286
6321
  },
6287
6322
  ui: {
6288
- elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params })
6323
+ elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params }),
6324
+ handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { sessionId, ...params })
6289
6325
  },
6290
6326
  permissions: {
6291
- handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { sessionId, ...params })
6327
+ handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { sessionId, ...params }),
6328
+ setApproveAll: async (params) => connection.sendRequest("session.permissions.setApproveAll", { sessionId, ...params }),
6329
+ resetSessionApprovals: async () => connection.sendRequest("session.permissions.resetSessionApprovals", { sessionId })
6292
6330
  },
6293
6331
  log: async (params) => connection.sendRequest("session.log", { sessionId, ...params }),
6294
6332
  shell: {
6295
6333
  exec: async (params) => connection.sendRequest("session.shell.exec", { sessionId, ...params }),
6296
6334
  kill: async (params) => connection.sendRequest("session.shell.kill", { sessionId, ...params })
6335
+ },
6336
+ /** @experimental */
6337
+ history: {
6338
+ compact: async () => connection.sendRequest("session.history.compact", { sessionId }),
6339
+ truncate: async (params) => connection.sendRequest("session.history.truncate", { sessionId, ...params })
6340
+ },
6341
+ /** @experimental */
6342
+ usage: {
6343
+ getMetrics: async () => connection.sendRequest("session.usage.getMetrics", { sessionId })
6297
6344
  }
6298
6345
  };
6299
6346
  }
6347
+ function registerClientSessionApiHandlers(connection, getHandlers) {
6348
+ connection.onRequest("sessionFs.readFile", async (params) => {
6349
+ const handler = getHandlers(params.sessionId).sessionFs;
6350
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
6351
+ return handler.readFile(params);
6352
+ });
6353
+ connection.onRequest("sessionFs.writeFile", async (params) => {
6354
+ const handler = getHandlers(params.sessionId).sessionFs;
6355
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
6356
+ return handler.writeFile(params);
6357
+ });
6358
+ connection.onRequest("sessionFs.appendFile", async (params) => {
6359
+ const handler = getHandlers(params.sessionId).sessionFs;
6360
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
6361
+ return handler.appendFile(params);
6362
+ });
6363
+ connection.onRequest("sessionFs.exists", async (params) => {
6364
+ const handler = getHandlers(params.sessionId).sessionFs;
6365
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
6366
+ return handler.exists(params);
6367
+ });
6368
+ connection.onRequest("sessionFs.stat", async (params) => {
6369
+ const handler = getHandlers(params.sessionId).sessionFs;
6370
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
6371
+ return handler.stat(params);
6372
+ });
6373
+ connection.onRequest("sessionFs.mkdir", async (params) => {
6374
+ const handler = getHandlers(params.sessionId).sessionFs;
6375
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
6376
+ return handler.mkdir(params);
6377
+ });
6378
+ connection.onRequest("sessionFs.readdir", async (params) => {
6379
+ const handler = getHandlers(params.sessionId).sessionFs;
6380
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
6381
+ return handler.readdir(params);
6382
+ });
6383
+ connection.onRequest("sessionFs.readdirWithTypes", async (params) => {
6384
+ const handler = getHandlers(params.sessionId).sessionFs;
6385
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
6386
+ return handler.readdirWithTypes(params);
6387
+ });
6388
+ connection.onRequest("sessionFs.rm", async (params) => {
6389
+ const handler = getHandlers(params.sessionId).sessionFs;
6390
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
6391
+ return handler.rm(params);
6392
+ });
6393
+ connection.onRequest("sessionFs.rename", async (params) => {
6394
+ const handler = getHandlers(params.sessionId).sessionFs;
6395
+ if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
6396
+ return handler.rename(params);
6397
+ });
6398
+ }
6300
6399
  var init_rpc = __esm({
6301
6400
  "node_modules/@github/copilot-sdk/dist/generated/rpc.js"() {
6302
6401
  "use strict";
@@ -6331,6 +6430,25 @@ var init_telemetry = __esm({
6331
6430
  });
6332
6431
 
6333
6432
  // node_modules/@github/copilot-sdk/dist/session.js
6433
+ function isToolResultObject(value) {
6434
+ if (typeof value !== "object" || value === null) {
6435
+ return false;
6436
+ }
6437
+ if (!("textResultForLlm" in value) || typeof value.textResultForLlm !== "string") {
6438
+ return false;
6439
+ }
6440
+ if (!("resultType" in value) || typeof value.resultType !== "string") {
6441
+ return false;
6442
+ }
6443
+ const allowedResultTypes = [
6444
+ "success",
6445
+ "failure",
6446
+ "rejected",
6447
+ "denied",
6448
+ "timeout"
6449
+ ];
6450
+ return allowedResultTypes.includes(value.resultType);
6451
+ }
6334
6452
  var import_node, NO_RESULT_PERMISSION_V2_ERROR, CopilotSession;
6335
6453
  var init_session = __esm({
6336
6454
  "node_modules/@github/copilot-sdk/dist/session.js"() {
@@ -6358,12 +6476,17 @@ var init_session = __esm({
6358
6476
  eventHandlers = /* @__PURE__ */ new Set();
6359
6477
  typedEventHandlers = /* @__PURE__ */ new Map();
6360
6478
  toolHandlers = /* @__PURE__ */ new Map();
6479
+ commandHandlers = /* @__PURE__ */ new Map();
6361
6480
  permissionHandler;
6362
6481
  userInputHandler;
6482
+ elicitationHandler;
6363
6483
  hooks;
6364
6484
  transformCallbacks;
6365
6485
  _rpc = null;
6366
6486
  traceContextProvider;
6487
+ _capabilities = {};
6488
+ /** @internal Client session API handlers, populated by CopilotClient during create/resume. */
6489
+ clientSessionApis = {};
6367
6490
  /**
6368
6491
  * Typed session-scoped RPC methods.
6369
6492
  */
@@ -6381,6 +6504,33 @@ var init_session = __esm({
6381
6504
  get workspacePath() {
6382
6505
  return this._workspacePath;
6383
6506
  }
6507
+ /**
6508
+ * Host capabilities reported when the session was created or resumed.
6509
+ * Use this to check feature support before calling capability-gated APIs.
6510
+ */
6511
+ get capabilities() {
6512
+ return this._capabilities;
6513
+ }
6514
+ /**
6515
+ * Interactive UI methods for showing dialogs to the user.
6516
+ * Only available when the CLI host supports elicitation
6517
+ * (`session.capabilities.ui?.elicitation === true`).
6518
+ *
6519
+ * @example
6520
+ * ```typescript
6521
+ * if (session.capabilities.ui?.elicitation) {
6522
+ * const ok = await session.ui.confirm("Deploy to production?");
6523
+ * }
6524
+ * ```
6525
+ */
6526
+ get ui() {
6527
+ return {
6528
+ elicitation: (params) => this._elicitation(params),
6529
+ confirm: (message) => this._confirm(message),
6530
+ select: (message, options) => this._select(message, options),
6531
+ input: (message, options) => this._input(message, options)
6532
+ };
6533
+ }
6384
6534
  /**
6385
6535
  * Sends a message to this session and waits for the response.
6386
6536
  *
@@ -6405,7 +6555,8 @@ var init_session = __esm({
6405
6555
  sessionId: this.sessionId,
6406
6556
  prompt: options.prompt,
6407
6557
  attachments: options.attachments,
6408
- mode: options.mode
6558
+ mode: options.mode,
6559
+ requestHeaders: options.requestHeaders
6409
6560
  });
6410
6561
  return response.messageId;
6411
6562
  }
@@ -6546,10 +6697,33 @@ var init_session = __esm({
6546
6697
  );
6547
6698
  }
6548
6699
  } else if (event.type === "permission.requested") {
6549
- const { requestId, permissionRequest } = event.data;
6700
+ const { requestId, permissionRequest, resolvedByHook } = event.data;
6701
+ if (resolvedByHook) {
6702
+ return;
6703
+ }
6550
6704
  if (this.permissionHandler) {
6551
6705
  void this._executePermissionAndRespond(requestId, permissionRequest);
6552
6706
  }
6707
+ } else if (event.type === "command.execute") {
6708
+ const { requestId, commandName, command, args } = event.data;
6709
+ void this._executeCommandAndRespond(requestId, commandName, command, args);
6710
+ } else if (event.type === "elicitation.requested") {
6711
+ if (this.elicitationHandler) {
6712
+ const { message, requestedSchema, mode, elicitationSource, url, requestId } = event.data;
6713
+ void this._handleElicitationRequest(
6714
+ {
6715
+ sessionId: this.sessionId,
6716
+ message,
6717
+ requestedSchema,
6718
+ mode,
6719
+ elicitationSource,
6720
+ url
6721
+ },
6722
+ requestId
6723
+ );
6724
+ }
6725
+ } else if (event.type === "capabilities.changed") {
6726
+ this._capabilities = { ...this._capabilities, ...event.data };
6553
6727
  }
6554
6728
  }
6555
6729
  /**
@@ -6571,6 +6745,8 @@ var init_session = __esm({
6571
6745
  result = "";
6572
6746
  } else if (typeof rawResult === "string") {
6573
6747
  result = rawResult;
6748
+ } else if (isToolResultObject(rawResult)) {
6749
+ result = rawResult;
6574
6750
  } else {
6575
6751
  result = JSON.stringify(rawResult);
6576
6752
  }
@@ -6604,7 +6780,7 @@ var init_session = __esm({
6604
6780
  await this.rpc.permissions.handlePendingPermissionRequest({
6605
6781
  requestId,
6606
6782
  result: {
6607
- kind: "denied-no-approval-rule-and-could-not-request-from-user"
6783
+ kind: "user-not-available"
6608
6784
  }
6609
6785
  });
6610
6786
  } catch (rpcError) {
@@ -6614,6 +6790,39 @@ var init_session = __esm({
6614
6790
  }
6615
6791
  }
6616
6792
  }
6793
+ /**
6794
+ * Executes a command handler and sends the result back via RPC.
6795
+ * @internal
6796
+ */
6797
+ async _executeCommandAndRespond(requestId, commandName, command, args) {
6798
+ const handler = this.commandHandlers.get(commandName);
6799
+ if (!handler) {
6800
+ try {
6801
+ await this.rpc.commands.handlePendingCommand({
6802
+ requestId,
6803
+ error: `Unknown command: ${commandName}`
6804
+ });
6805
+ } catch (rpcError) {
6806
+ if (!(rpcError instanceof import_node.ConnectionError || rpcError instanceof import_node.ResponseError)) {
6807
+ throw rpcError;
6808
+ }
6809
+ }
6810
+ return;
6811
+ }
6812
+ try {
6813
+ await handler({ sessionId: this.sessionId, command, commandName, args });
6814
+ await this.rpc.commands.handlePendingCommand({ requestId });
6815
+ } catch (error) {
6816
+ const message = error instanceof Error ? error.message : String(error);
6817
+ try {
6818
+ await this.rpc.commands.handlePendingCommand({ requestId, error: message });
6819
+ } catch (rpcError) {
6820
+ if (!(rpcError instanceof import_node.ConnectionError || rpcError instanceof import_node.ResponseError)) {
6821
+ throw rpcError;
6822
+ }
6823
+ }
6824
+ }
6825
+ }
6617
6826
  /**
6618
6827
  * Registers custom tool handlers for this session.
6619
6828
  *
@@ -6642,6 +6851,133 @@ var init_session = __esm({
6642
6851
  getToolHandler(name) {
6643
6852
  return this.toolHandlers.get(name);
6644
6853
  }
6854
+ /**
6855
+ * Registers command handlers for this session.
6856
+ *
6857
+ * @param commands - An array of command definitions with handlers, or undefined to clear
6858
+ * @internal This method is typically called internally when creating/resuming a session.
6859
+ */
6860
+ registerCommands(commands) {
6861
+ this.commandHandlers.clear();
6862
+ if (!commands) {
6863
+ return;
6864
+ }
6865
+ for (const cmd of commands) {
6866
+ this.commandHandlers.set(cmd.name, cmd.handler);
6867
+ }
6868
+ }
6869
+ /**
6870
+ * Registers the elicitation handler for this session.
6871
+ *
6872
+ * @param handler - The handler to invoke when the server dispatches an elicitation request
6873
+ * @internal This method is typically called internally when creating/resuming a session.
6874
+ */
6875
+ registerElicitationHandler(handler) {
6876
+ this.elicitationHandler = handler;
6877
+ }
6878
+ /**
6879
+ * Handles an elicitation.requested broadcast event.
6880
+ * Invokes the registered handler and responds via handlePendingElicitation RPC.
6881
+ * @internal
6882
+ */
6883
+ async _handleElicitationRequest(context, requestId) {
6884
+ if (!this.elicitationHandler) {
6885
+ return;
6886
+ }
6887
+ try {
6888
+ const result = await this.elicitationHandler(context);
6889
+ await this.rpc.ui.handlePendingElicitation({ requestId, result });
6890
+ } catch {
6891
+ try {
6892
+ await this.rpc.ui.handlePendingElicitation({
6893
+ requestId,
6894
+ result: { action: "cancel" }
6895
+ });
6896
+ } catch (rpcError) {
6897
+ if (!(rpcError instanceof import_node.ConnectionError || rpcError instanceof import_node.ResponseError)) {
6898
+ throw rpcError;
6899
+ }
6900
+ }
6901
+ }
6902
+ }
6903
+ /**
6904
+ * Sets the host capabilities for this session.
6905
+ *
6906
+ * @param capabilities - The capabilities object from the create/resume response
6907
+ * @internal This method is typically called internally when creating/resuming a session.
6908
+ */
6909
+ setCapabilities(capabilities) {
6910
+ this._capabilities = capabilities ?? {};
6911
+ }
6912
+ assertElicitation() {
6913
+ if (!this._capabilities.ui?.elicitation) {
6914
+ throw new Error(
6915
+ "Elicitation is not supported by the host. Check session.capabilities.ui?.elicitation before calling UI methods."
6916
+ );
6917
+ }
6918
+ }
6919
+ async _elicitation(params) {
6920
+ this.assertElicitation();
6921
+ return this.rpc.ui.elicitation({
6922
+ message: params.message,
6923
+ requestedSchema: params.requestedSchema
6924
+ });
6925
+ }
6926
+ async _confirm(message) {
6927
+ this.assertElicitation();
6928
+ const result = await this.rpc.ui.elicitation({
6929
+ message,
6930
+ requestedSchema: {
6931
+ type: "object",
6932
+ properties: {
6933
+ confirmed: { type: "boolean", default: true }
6934
+ },
6935
+ required: ["confirmed"]
6936
+ }
6937
+ });
6938
+ return result.action === "accept" && result.content?.confirmed === true;
6939
+ }
6940
+ async _select(message, options) {
6941
+ this.assertElicitation();
6942
+ const result = await this.rpc.ui.elicitation({
6943
+ message,
6944
+ requestedSchema: {
6945
+ type: "object",
6946
+ properties: {
6947
+ selection: { type: "string", enum: options }
6948
+ },
6949
+ required: ["selection"]
6950
+ }
6951
+ });
6952
+ if (result.action === "accept" && result.content?.selection != null) {
6953
+ return result.content.selection;
6954
+ }
6955
+ return null;
6956
+ }
6957
+ async _input(message, options) {
6958
+ this.assertElicitation();
6959
+ const field = { type: "string" };
6960
+ if (options?.title) field.title = options.title;
6961
+ if (options?.description) field.description = options.description;
6962
+ if (options?.minLength != null) field.minLength = options.minLength;
6963
+ if (options?.maxLength != null) field.maxLength = options.maxLength;
6964
+ if (options?.format) field.format = options.format;
6965
+ if (options?.default != null) field.default = options.default;
6966
+ const result = await this.rpc.ui.elicitation({
6967
+ message,
6968
+ requestedSchema: {
6969
+ type: "object",
6970
+ properties: {
6971
+ value: field
6972
+ },
6973
+ required: ["value"]
6974
+ }
6975
+ });
6976
+ if (result.action === "accept" && result.content?.value != null) {
6977
+ return result.content.value;
6978
+ }
6979
+ return null;
6980
+ }
6645
6981
  /**
6646
6982
  * Registers a handler for permission requests.
6647
6983
  *
@@ -6722,7 +7058,7 @@ var init_session = __esm({
6722
7058
  */
6723
7059
  async _handlePermissionRequestV2(request) {
6724
7060
  if (!this.permissionHandler) {
6725
- return { kind: "denied-no-approval-rule-and-could-not-request-from-user" };
7061
+ return { kind: "user-not-available" };
6726
7062
  }
6727
7063
  try {
6728
7064
  const result = await this.permissionHandler(request, {
@@ -6736,7 +7072,7 @@ var init_session = __esm({
6736
7072
  if (error instanceof Error && error.message === NO_RESULT_PERMISSION_V2_ERROR) {
6737
7073
  throw error;
6738
7074
  }
6739
- return { kind: "denied-no-approval-rule-and-could-not-request-from-user" };
7075
+ return { kind: "user-not-available" };
6740
7076
  }
6741
7077
  }
6742
7078
  /**
@@ -6925,6 +7261,120 @@ var init_session = __esm({
6925
7261
  }
6926
7262
  });
6927
7263
 
7264
+ // node_modules/@github/copilot-sdk/dist/sessionFsProvider.js
7265
+ function createSessionFsAdapter(provider) {
7266
+ return {
7267
+ readFile: async ({ path }) => {
7268
+ try {
7269
+ const content = await provider.readFile(path);
7270
+ return { content };
7271
+ } catch (err) {
7272
+ return { content: "", error: toSessionFsError(err) };
7273
+ }
7274
+ },
7275
+ writeFile: async ({ path, content, mode }) => {
7276
+ try {
7277
+ await provider.writeFile(path, content, mode);
7278
+ return void 0;
7279
+ } catch (err) {
7280
+ return toSessionFsError(err);
7281
+ }
7282
+ },
7283
+ appendFile: async ({ path, content, mode }) => {
7284
+ try {
7285
+ await provider.appendFile(path, content, mode);
7286
+ return void 0;
7287
+ } catch (err) {
7288
+ return toSessionFsError(err);
7289
+ }
7290
+ },
7291
+ exists: async ({ path }) => {
7292
+ try {
7293
+ return { exists: await provider.exists(path) };
7294
+ } catch {
7295
+ return { exists: false };
7296
+ }
7297
+ },
7298
+ stat: async ({ path }) => {
7299
+ try {
7300
+ return await provider.stat(path);
7301
+ } catch (err) {
7302
+ return {
7303
+ isFile: false,
7304
+ isDirectory: false,
7305
+ size: 0,
7306
+ mtime: (/* @__PURE__ */ new Date()).toISOString(),
7307
+ birthtime: (/* @__PURE__ */ new Date()).toISOString(),
7308
+ error: toSessionFsError(err)
7309
+ };
7310
+ }
7311
+ },
7312
+ mkdir: async ({ path, recursive, mode }) => {
7313
+ try {
7314
+ await provider.mkdir(path, recursive ?? false, mode);
7315
+ return void 0;
7316
+ } catch (err) {
7317
+ return toSessionFsError(err);
7318
+ }
7319
+ },
7320
+ readdir: async ({ path }) => {
7321
+ try {
7322
+ const entries = await provider.readdir(path);
7323
+ return { entries };
7324
+ } catch (err) {
7325
+ return { entries: [], error: toSessionFsError(err) };
7326
+ }
7327
+ },
7328
+ readdirWithTypes: async ({ path }) => {
7329
+ try {
7330
+ const entries = await provider.readdirWithTypes(path);
7331
+ return { entries };
7332
+ } catch (err) {
7333
+ return { entries: [], error: toSessionFsError(err) };
7334
+ }
7335
+ },
7336
+ rm: async ({ path, recursive, force }) => {
7337
+ try {
7338
+ await provider.rm(path, recursive ?? false, force ?? false);
7339
+ return void 0;
7340
+ } catch (err) {
7341
+ return toSessionFsError(err);
7342
+ }
7343
+ },
7344
+ rename: async ({ src, dest }) => {
7345
+ try {
7346
+ await provider.rename(src, dest);
7347
+ return void 0;
7348
+ } catch (err) {
7349
+ return toSessionFsError(err);
7350
+ }
7351
+ }
7352
+ };
7353
+ }
7354
+ function toSessionFsError(err) {
7355
+ const e = err;
7356
+ const code = e.code === "ENOENT" ? "ENOENT" : "UNKNOWN";
7357
+ return { code, message: e.message ?? String(err) };
7358
+ }
7359
+ var init_sessionFsProvider = __esm({
7360
+ "node_modules/@github/copilot-sdk/dist/sessionFsProvider.js"() {
7361
+ "use strict";
7362
+ }
7363
+ });
7364
+
7365
+ // node_modules/@github/copilot-sdk/dist/types.js
7366
+ var approveAll, defaultJoinSessionPermissionHandler;
7367
+ var init_types3 = __esm({
7368
+ "node_modules/@github/copilot-sdk/dist/types.js"() {
7369
+ "use strict";
7370
+ init_sessionFsProvider();
7371
+ approveAll = () => ({ kind: "approve-once" });
7372
+ defaultJoinSessionPermissionHandler = () => ({
7373
+ kind: "no-result"
7374
+ });
7375
+ }
7376
+ });
7377
+
6928
7378
  // node_modules/@github/copilot-sdk/dist/client.js
6929
7379
  import { spawn } from "child_process";
6930
7380
  import { randomUUID } from "crypto";
@@ -6999,9 +7449,12 @@ var init_client = __esm({
6999
7449
  init_rpc();
7000
7450
  init_sdkProtocolVersion();
7001
7451
  init_session();
7452
+ init_sessionFsProvider();
7002
7453
  init_telemetry();
7454
+ init_types3();
7003
7455
  MIN_PROTOCOL_VERSION = 2;
7004
- CopilotClient = class {
7456
+ CopilotClient = class _CopilotClient {
7457
+ cliStartTimeout = null;
7005
7458
  cliProcess = null;
7006
7459
  connection = null;
7007
7460
  socket = null;
@@ -7024,6 +7477,8 @@ var init_client = __esm({
7024
7477
  processExitPromise = null;
7025
7478
  // Rejects when CLI process exits
7026
7479
  negotiatedProtocolVersion = null;
7480
+ /** Connection-level session filesystem config, set via constructor option. */
7481
+ sessionFsConfig = null;
7027
7482
  /**
7028
7483
  * Typed server-scoped RPC methods.
7029
7484
  * @throws Error if the client is not connected
@@ -7067,11 +7522,14 @@ var init_client = __esm({
7067
7522
  "isChildProcess must be used in conjunction with useStdio and not with cliUrl"
7068
7523
  );
7069
7524
  }
7070
- if (options.cliUrl && (options.githubToken || options.useLoggedInUser !== void 0)) {
7525
+ if (options.cliUrl && (options.gitHubToken || options.useLoggedInUser !== void 0)) {
7071
7526
  throw new Error(
7072
- "githubToken and useLoggedInUser cannot be used with cliUrl (external server manages its own auth)"
7527
+ "gitHubToken and useLoggedInUser cannot be used with cliUrl (external server manages its own auth)"
7073
7528
  );
7074
7529
  }
7530
+ if (options.sessionFs) {
7531
+ this.validateSessionFsConfig(options.sessionFs);
7532
+ }
7075
7533
  if (options.cliUrl) {
7076
7534
  const { host, port } = this.parseCliUrl(options.cliUrl);
7077
7535
  this.actualHost = host;
@@ -7083,8 +7541,10 @@ var init_client = __esm({
7083
7541
  }
7084
7542
  this.onListModels = options.onListModels;
7085
7543
  this.onGetTraceContext = options.onGetTraceContext;
7544
+ this.sessionFsConfig = options.sessionFs ?? null;
7545
+ const effectiveEnv = options.env ?? process.env;
7086
7546
  this.options = {
7087
- cliPath: options.cliUrl ? void 0 : options.cliPath || getBundledCliPath(),
7547
+ cliPath: options.cliUrl ? void 0 : options.cliPath || effectiveEnv.COPILOT_CLI_PATH || getBundledCliPath(),
7088
7548
  cliArgs: options.cliArgs ?? [],
7089
7549
  cwd: options.cwd ?? process.cwd(),
7090
7550
  port: options.port || 0,
@@ -7095,11 +7555,12 @@ var init_client = __esm({
7095
7555
  logLevel: options.logLevel || "debug",
7096
7556
  autoStart: options.autoStart ?? true,
7097
7557
  autoRestart: false,
7098
- env: options.env ?? process.env,
7099
- githubToken: options.githubToken,
7100
- // Default useLoggedInUser to false when githubToken is provided, otherwise true
7101
- useLoggedInUser: options.useLoggedInUser ?? (options.githubToken ? false : true),
7102
- telemetry: options.telemetry
7558
+ env: effectiveEnv,
7559
+ gitHubToken: options.gitHubToken,
7560
+ // Default useLoggedInUser to false when gitHubToken is provided, otherwise true
7561
+ useLoggedInUser: options.useLoggedInUser ?? (options.gitHubToken ? false : true),
7562
+ telemetry: options.telemetry,
7563
+ sessionIdleTimeoutSeconds: options.sessionIdleTimeoutSeconds ?? 0
7103
7564
  };
7104
7565
  }
7105
7566
  /**
@@ -7124,6 +7585,17 @@ var init_client = __esm({
7124
7585
  }
7125
7586
  return { host, port };
7126
7587
  }
7588
+ validateSessionFsConfig(config2) {
7589
+ if (!config2.initialCwd) {
7590
+ throw new Error("sessionFs.initialCwd is required");
7591
+ }
7592
+ if (!config2.sessionStatePath) {
7593
+ throw new Error("sessionFs.sessionStatePath is required");
7594
+ }
7595
+ if (config2.conventions !== "windows" && config2.conventions !== "posix") {
7596
+ throw new Error("sessionFs.conventions must be either 'windows' or 'posix'");
7597
+ }
7598
+ }
7127
7599
  /**
7128
7600
  * Starts the CLI server and establishes a connection.
7129
7601
  *
@@ -7153,6 +7625,13 @@ var init_client = __esm({
7153
7625
  }
7154
7626
  await this.connectToServer();
7155
7627
  await this.verifyProtocolVersion();
7628
+ if (this.sessionFsConfig) {
7629
+ await this.connection.sendRequest("sessionFs.setProvider", {
7630
+ initialCwd: this.sessionFsConfig.initialCwd,
7631
+ sessionStatePath: this.sessionFsConfig.sessionStatePath,
7632
+ conventions: this.sessionFsConfig.conventions
7633
+ });
7634
+ }
7156
7635
  this.state = "connected";
7157
7636
  } catch (error) {
7158
7637
  this.state = "error";
@@ -7247,6 +7726,10 @@ var init_client = __esm({
7247
7726
  }
7248
7727
  this.cliProcess = null;
7249
7728
  }
7729
+ if (this.cliStartTimeout) {
7730
+ clearTimeout(this.cliStartTimeout);
7731
+ this.cliStartTimeout = null;
7732
+ }
7250
7733
  this.state = "disconnected";
7251
7734
  this.actualPort = null;
7252
7735
  this.stderrBuffer = "";
@@ -7304,6 +7787,10 @@ var init_client = __esm({
7304
7787
  }
7305
7788
  this.cliProcess = null;
7306
7789
  }
7790
+ if (this.cliStartTimeout) {
7791
+ clearTimeout(this.cliStartTimeout);
7792
+ this.cliStartTimeout = null;
7793
+ }
7307
7794
  this.state = "disconnected";
7308
7795
  this.actualPort = null;
7309
7796
  this.stderrBuffer = "";
@@ -7359,10 +7846,14 @@ var init_client = __esm({
7359
7846
  this.onGetTraceContext
7360
7847
  );
7361
7848
  session.registerTools(config2.tools);
7849
+ session.registerCommands(config2.commands);
7362
7850
  session.registerPermissionHandler(config2.onPermissionRequest);
7363
7851
  if (config2.onUserInputRequest) {
7364
7852
  session.registerUserInputHandler(config2.onUserInputRequest);
7365
7853
  }
7854
+ if (config2.onElicitationRequest) {
7855
+ session.registerElicitationHandler(config2.onElicitationRequest);
7856
+ }
7366
7857
  if (config2.hooks) {
7367
7858
  session.registerHooks(config2.hooks);
7368
7859
  }
@@ -7376,6 +7867,17 @@ var init_client = __esm({
7376
7867
  session.on(config2.onEvent);
7377
7868
  }
7378
7869
  this.sessions.set(sessionId, session);
7870
+ if (this.sessionFsConfig) {
7871
+ if (config2.createSessionFsHandler) {
7872
+ session.clientSessionApis.sessionFs = createSessionFsAdapter(
7873
+ config2.createSessionFsHandler(session)
7874
+ );
7875
+ } else {
7876
+ throw new Error(
7877
+ "createSessionFsHandler is required in session config when sessionFs is enabled in client options."
7878
+ );
7879
+ }
7880
+ }
7379
7881
  try {
7380
7882
  const response = await this.connection.sendRequest("session.create", {
7381
7883
  ...await getTraceContext(this.onGetTraceContext),
@@ -7390,26 +7892,37 @@ var init_client = __esm({
7390
7892
  overridesBuiltInTool: tool.overridesBuiltInTool,
7391
7893
  skipPermission: tool.skipPermission
7392
7894
  })),
7895
+ commands: config2.commands?.map((cmd) => ({
7896
+ name: cmd.name,
7897
+ description: cmd.description
7898
+ })),
7393
7899
  systemMessage: wireSystemMessage,
7394
7900
  availableTools: config2.availableTools,
7395
7901
  excludedTools: config2.excludedTools,
7396
7902
  provider: config2.provider,
7903
+ modelCapabilities: config2.modelCapabilities,
7397
7904
  requestPermission: true,
7398
7905
  requestUserInput: !!config2.onUserInputRequest,
7906
+ requestElicitation: !!config2.onElicitationRequest,
7399
7907
  hooks: !!(config2.hooks && Object.values(config2.hooks).some(Boolean)),
7400
7908
  workingDirectory: config2.workingDirectory,
7401
7909
  streaming: config2.streaming,
7910
+ includeSubAgentStreamingEvents: config2.includeSubAgentStreamingEvents ?? true,
7402
7911
  mcpServers: config2.mcpServers,
7403
7912
  envValueMode: "direct",
7404
7913
  customAgents: config2.customAgents,
7914
+ defaultAgent: config2.defaultAgent,
7405
7915
  agent: config2.agent,
7406
7916
  configDir: config2.configDir,
7917
+ enableConfigDiscovery: config2.enableConfigDiscovery,
7407
7918
  skillDirectories: config2.skillDirectories,
7408
7919
  disabledSkills: config2.disabledSkills,
7409
- infiniteSessions: config2.infiniteSessions
7920
+ infiniteSessions: config2.infiniteSessions,
7921
+ gitHubToken: config2.gitHubToken
7410
7922
  });
7411
- const { workspacePath } = response;
7923
+ const { workspacePath, capabilities } = response;
7412
7924
  session["_workspacePath"] = workspacePath;
7925
+ session.setCapabilities(capabilities);
7413
7926
  } catch (e) {
7414
7927
  this.sessions.delete(sessionId);
7415
7928
  throw e;
@@ -7460,10 +7973,14 @@ var init_client = __esm({
7460
7973
  this.onGetTraceContext
7461
7974
  );
7462
7975
  session.registerTools(config2.tools);
7976
+ session.registerCommands(config2.commands);
7463
7977
  session.registerPermissionHandler(config2.onPermissionRequest);
7464
7978
  if (config2.onUserInputRequest) {
7465
7979
  session.registerUserInputHandler(config2.onUserInputRequest);
7466
7980
  }
7981
+ if (config2.onElicitationRequest) {
7982
+ session.registerElicitationHandler(config2.onElicitationRequest);
7983
+ }
7467
7984
  if (config2.hooks) {
7468
7985
  session.registerHooks(config2.hooks);
7469
7986
  }
@@ -7477,6 +7994,17 @@ var init_client = __esm({
7477
7994
  session.on(config2.onEvent);
7478
7995
  }
7479
7996
  this.sessions.set(sessionId, session);
7997
+ if (this.sessionFsConfig) {
7998
+ if (config2.createSessionFsHandler) {
7999
+ session.clientSessionApis.sessionFs = createSessionFsAdapter(
8000
+ config2.createSessionFsHandler(session)
8001
+ );
8002
+ } else {
8003
+ throw new Error(
8004
+ "createSessionFsHandler is required in session config when sessionFs is enabled in client options."
8005
+ );
8006
+ }
8007
+ }
7480
8008
  try {
7481
8009
  const response = await this.connection.sendRequest("session.resume", {
7482
8010
  ...await getTraceContext(this.onGetTraceContext),
@@ -7494,24 +8022,35 @@ var init_client = __esm({
7494
8022
  overridesBuiltInTool: tool.overridesBuiltInTool,
7495
8023
  skipPermission: tool.skipPermission
7496
8024
  })),
8025
+ commands: config2.commands?.map((cmd) => ({
8026
+ name: cmd.name,
8027
+ description: cmd.description
8028
+ })),
7497
8029
  provider: config2.provider,
7498
- requestPermission: true,
8030
+ modelCapabilities: config2.modelCapabilities,
8031
+ requestPermission: config2.onPermissionRequest !== defaultJoinSessionPermissionHandler,
7499
8032
  requestUserInput: !!config2.onUserInputRequest,
8033
+ requestElicitation: !!config2.onElicitationRequest,
7500
8034
  hooks: !!(config2.hooks && Object.values(config2.hooks).some(Boolean)),
7501
8035
  workingDirectory: config2.workingDirectory,
7502
8036
  configDir: config2.configDir,
8037
+ enableConfigDiscovery: config2.enableConfigDiscovery,
7503
8038
  streaming: config2.streaming,
8039
+ includeSubAgentStreamingEvents: config2.includeSubAgentStreamingEvents ?? true,
7504
8040
  mcpServers: config2.mcpServers,
7505
8041
  envValueMode: "direct",
7506
8042
  customAgents: config2.customAgents,
8043
+ defaultAgent: config2.defaultAgent,
7507
8044
  agent: config2.agent,
7508
8045
  skillDirectories: config2.skillDirectories,
7509
8046
  disabledSkills: config2.disabledSkills,
7510
8047
  infiniteSessions: config2.infiniteSessions,
7511
- disableResume: config2.disableResume
8048
+ disableResume: config2.disableResume,
8049
+ gitHubToken: config2.gitHubToken
7512
8050
  });
7513
- const { workspacePath } = response;
8051
+ const { workspacePath, capabilities } = response;
7514
8052
  session["_workspacePath"] = workspacePath;
8053
+ session.setCapabilities(capabilities);
7515
8054
  } catch (e) {
7516
8055
  this.sessions.delete(sessionId);
7517
8056
  throw e;
@@ -7604,6 +8143,22 @@ var init_client = __esm({
7604
8143
  const result = await this.connection.sendRequest("models.list", {});
7605
8144
  const response = result;
7606
8145
  models = response.models;
8146
+ for (const model of models) {
8147
+ const m = model;
8148
+ if (!m.capabilities) {
8149
+ m.capabilities = {
8150
+ supports: {},
8151
+ limits: { max_context_window_tokens: 0 }
8152
+ };
8153
+ } else {
8154
+ if (!m.capabilities.supports) m.capabilities.supports = {};
8155
+ if (!m.capabilities.limits) {
8156
+ m.capabilities.limits = { max_context_window_tokens: 0 };
8157
+ } else if (m.capabilities.limits.max_context_window_tokens === void 0) {
8158
+ m.capabilities.limits.max_context_window_tokens = 0;
8159
+ }
8160
+ }
8161
+ }
7607
8162
  }
7608
8163
  this.modelsCache = [...models];
7609
8164
  return [...models];
@@ -7707,16 +8262,50 @@ var init_client = __esm({
7707
8262
  if (!this.connection) {
7708
8263
  throw new Error("Client not connected");
7709
8264
  }
7710
- const response = await this.connection.sendRequest("session.list", { filter });
8265
+ const response = await this.connection.sendRequest("session.list", {
8266
+ filter
8267
+ });
7711
8268
  const { sessions } = response;
7712
- return sessions.map((s) => ({
7713
- sessionId: s.sessionId,
7714
- startTime: new Date(s.startTime),
7715
- modifiedTime: new Date(s.modifiedTime),
7716
- summary: s.summary,
7717
- isRemote: s.isRemote,
7718
- context: s.context
7719
- }));
8269
+ return sessions.map(_CopilotClient.toSessionMetadata);
8270
+ }
8271
+ /**
8272
+ * Gets metadata for a specific session by ID.
8273
+ *
8274
+ * This provides an efficient O(1) lookup of a single session's metadata
8275
+ * instead of listing all sessions. Returns undefined if the session is not found.
8276
+ *
8277
+ * @param sessionId - The ID of the session to look up
8278
+ * @returns A promise that resolves with the session metadata, or undefined if not found
8279
+ * @throws Error if the client is not connected
8280
+ *
8281
+ * @example
8282
+ * ```typescript
8283
+ * const metadata = await client.getSessionMetadata("session-123");
8284
+ * if (metadata) {
8285
+ * console.log(`Session started at: ${metadata.startTime}`);
8286
+ * }
8287
+ * ```
8288
+ */
8289
+ async getSessionMetadata(sessionId) {
8290
+ if (!this.connection) {
8291
+ throw new Error("Client not connected");
8292
+ }
8293
+ const response = await this.connection.sendRequest("session.getMetadata", { sessionId });
8294
+ const { session } = response;
8295
+ if (!session) {
8296
+ return void 0;
8297
+ }
8298
+ return _CopilotClient.toSessionMetadata(session);
8299
+ }
8300
+ static toSessionMetadata(raw) {
8301
+ return {
8302
+ sessionId: raw.sessionId,
8303
+ startTime: new Date(raw.startTime),
8304
+ modifiedTime: new Date(raw.modifiedTime),
8305
+ summary: raw.summary,
8306
+ isRemote: raw.isRemote,
8307
+ context: raw.context
8308
+ };
7720
8309
  }
7721
8310
  /**
7722
8311
  * Gets the foreground session ID in TUI+server mode.
@@ -7807,16 +8396,22 @@ var init_client = __esm({
7807
8396
  } else if (this.options.port > 0) {
7808
8397
  args.push("--port", this.options.port.toString());
7809
8398
  }
7810
- if (this.options.githubToken) {
8399
+ if (this.options.gitHubToken) {
7811
8400
  args.push("--auth-token-env", "COPILOT_SDK_AUTH_TOKEN");
7812
8401
  }
7813
8402
  if (!this.options.useLoggedInUser) {
7814
8403
  args.push("--no-auto-login");
7815
8404
  }
8405
+ if (this.options.sessionIdleTimeoutSeconds !== void 0 && this.options.sessionIdleTimeoutSeconds > 0) {
8406
+ args.push(
8407
+ "--session-idle-timeout",
8408
+ this.options.sessionIdleTimeoutSeconds.toString()
8409
+ );
8410
+ }
7816
8411
  const envWithoutNodeDebug = { ...this.options.env };
7817
8412
  delete envWithoutNodeDebug.NODE_DEBUG;
7818
- if (this.options.githubToken) {
7819
- envWithoutNodeDebug.COPILOT_SDK_AUTH_TOKEN = this.options.githubToken;
8413
+ if (this.options.gitHubToken) {
8414
+ envWithoutNodeDebug.COPILOT_SDK_AUTH_TOKEN = this.options.gitHubToken;
7820
8415
  }
7821
8416
  if (!this.options.cliPath) {
7822
8417
  throw new Error(
@@ -7940,7 +8535,7 @@ stderr: ${stderrOutput}`
7940
8535
  }
7941
8536
  }
7942
8537
  });
7943
- setTimeout(() => {
8538
+ this.cliStartTimeout = setTimeout(() => {
7944
8539
  if (!resolved) {
7945
8540
  resolved = true;
7946
8541
  reject(new Error("Timeout waiting for CLI server to start"));
@@ -8046,6 +8641,12 @@ stderr: ${stderrOutput}`
8046
8641
  "systemMessage.transform",
8047
8642
  async (params) => await this.handleSystemMessageTransform(params)
8048
8643
  );
8644
+ const sessions = this.sessions;
8645
+ registerClientSessionApiHandlers(this.connection, (sessionId) => {
8646
+ const session = sessions.get(sessionId);
8647
+ if (!session) throw new Error(`No session found for sessionId: ${sessionId}`);
8648
+ return session.clientSessionApis;
8649
+ });
8049
8650
  this.connection.onClose(() => {
8050
8651
  this.state = "disconnected";
8051
8652
  });
@@ -8191,7 +8792,7 @@ stderr: ${stderrOutput}`
8191
8792
  }
8192
8793
  return {
8193
8794
  result: {
8194
- kind: "denied-no-approval-rule-and-could-not-request-from-user"
8795
+ kind: "user-not-available"
8195
8796
  }
8196
8797
  };
8197
8798
  }
@@ -8222,15 +8823,6 @@ stderr: ${stderrOutput}`
8222
8823
  }
8223
8824
  });
8224
8825
 
8225
- // node_modules/@github/copilot-sdk/dist/types.js
8226
- var approveAll;
8227
- var init_types3 = __esm({
8228
- "node_modules/@github/copilot-sdk/dist/types.js"() {
8229
- "use strict";
8230
- approveAll = () => ({ kind: "approved" });
8231
- }
8232
- });
8233
-
8234
8826
  // node_modules/@github/copilot-sdk/dist/index.js
8235
8827
  var init_dist = __esm({
8236
8828
  "node_modules/@github/copilot-sdk/dist/index.js"() {