@github/copilot-sdk 0.2.1-preview.0 → 0.2.1-preview.1

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/README.md CHANGED
@@ -60,7 +60,10 @@ await client.stop();
60
60
  Sessions also support `Symbol.asyncDispose` for use with [`await using`](https://github.com/tc39/proposal-explicit-resource-management) (TypeScript 5.2+/Node.js 18.0+):
61
61
 
62
62
  ```typescript
63
- await using session = await client.createSession({ model: "gpt-5", onPermissionRequest: approveAll });
63
+ await using session = await client.createSession({
64
+ model: "gpt-5",
65
+ onPermissionRequest: approveAll,
66
+ });
64
67
  // session is automatically disconnected when leaving scope
65
68
  ```
66
69
 
@@ -76,7 +79,7 @@ new CopilotClient(options?: CopilotClientOptions)
76
79
 
77
80
  **Options:**
78
81
 
79
- - `cliPath?: string` - Path to CLI executable (default: "copilot" from PATH)
82
+ - `cliPath?: string` - Path to CLI executable (default: uses COPILOT_CLI_PATH env var or bundled instance)
80
83
  - `cliArgs?: string[]` - Extra arguments prepended before SDK-managed flags (e.g. `["./dist-cli/index.js"]` when using `node`)
81
84
  - `cliUrl?: string` - URL of existing CLI server to connect to (e.g., `"localhost:8080"`, `"http://127.0.0.1:9000"`, or just `"8080"`). When provided, the client will not spawn a CLI process.
82
85
  - `port?: number` - Server port (default: 0 for random)
@@ -184,6 +187,7 @@ const unsubscribe = client.on((event) => {
184
187
  ```
185
188
 
186
189
  **Lifecycle Event Types:**
190
+
187
191
  - `session.created` - A new session was created
188
192
  - `session.deleted` - A session was deleted
189
193
  - `session.updated` - A session was updated (e.g., new messages)
@@ -293,7 +297,7 @@ if (session.capabilities.ui?.elicitation) {
293
297
 
294
298
  Interactive UI methods for showing dialogs to the user. Only available when the CLI host supports elicitation (`session.capabilities.ui?.elicitation === true`). See [UI Elicitation](#ui-elicitation) for full details.
295
299
 
296
- ##### `destroy(): Promise<void>` *(deprecated)*
300
+ ##### `destroy(): Promise<void>` _(deprecated)_
297
301
 
298
302
  Deprecated — use `disconnect()` instead.
299
303
 
@@ -454,8 +458,10 @@ defineTool("edit_file", {
454
458
  description: "Custom file editor with project-specific validation",
455
459
  parameters: z.object({ path: z.string(), content: z.string() }),
456
460
  overridesBuiltInTool: true,
457
- handler: async ({ path, content }) => { /* your logic */ },
458
- })
461
+ handler: async ({ path, content }) => {
462
+ /* your logic */
463
+ },
464
+ });
459
465
  ```
460
466
 
461
467
  #### Skipping Permission Prompts
@@ -467,8 +473,10 @@ defineTool("safe_lookup", {
467
473
  description: "A read-only lookup that needs no confirmation",
468
474
  parameters: z.object({ id: z.string() }),
469
475
  skipPermission: true,
470
- handler: async ({ id }) => { /* your logic */ },
471
- })
476
+ handler: async ({ id }) => {
477
+ /* your logic */
478
+ },
479
+ });
472
480
  ```
473
481
 
474
482
  ### Commands
@@ -571,7 +579,10 @@ const session = await client.createSession({
571
579
  mode: "customize",
572
580
  sections: {
573
581
  // Replace the tone/style section
574
- tone: { action: "replace", content: "Respond in a warm, professional tone. Be thorough in explanations." },
582
+ tone: {
583
+ action: "replace",
584
+ content: "Respond in a warm, professional tone. Be thorough in explanations.",
585
+ },
575
586
  // Remove coding-specific rules
576
587
  code_change_rules: { action: "remove" },
577
588
  // Append to existing guidelines
@@ -586,6 +597,7 @@ const session = await client.createSession({
586
597
  Available section IDs: `identity`, `tone`, `tool_efficiency`, `environment_context`, `code_change_rules`, `guidelines`, `safety`, `tool_instructions`, `custom_instructions`, `last_instructions`. Use the `SYSTEM_PROMPT_SECTIONS` constant for descriptions of each section.
587
598
 
588
599
  Each section override supports four actions:
600
+
589
601
  - **`replace`** — Replace the section content entirely
590
602
  - **`remove`** — Remove the section from the prompt
591
603
  - **`append`** — Add content after the existing section
@@ -624,7 +636,7 @@ const session = await client.createSession({
624
636
  model: "gpt-5",
625
637
  infiniteSessions: {
626
638
  enabled: true,
627
- backgroundCompactionThreshold: 0.80, // Start compacting at 80% context usage
639
+ backgroundCompactionThreshold: 0.8, // Start compacting at 80% context usage
628
640
  bufferExhaustionThreshold: 0.95, // Block at 95% until compaction completes
629
641
  },
630
642
  });
@@ -723,8 +735,8 @@ const session = await client.createSession({
723
735
  const session = await client.createSession({
724
736
  model: "gpt-4",
725
737
  provider: {
726
- type: "azure", // Must be "azure" for Azure endpoints, NOT "openai"
727
- baseUrl: "https://my-resource.openai.azure.com", // Just the host, no path
738
+ type: "azure", // Must be "azure" for Azure endpoints, NOT "openai"
739
+ baseUrl: "https://my-resource.openai.azure.com", // Just the host, no path
728
740
  apiKey: process.env.AZURE_OPENAI_KEY,
729
741
  azure: {
730
742
  apiVersion: "2024-10-21",
@@ -734,6 +746,7 @@ const session = await client.createSession({
734
746
  ```
735
747
 
736
748
  > **Important notes:**
749
+ >
737
750
  > - When using a custom provider, the `model` parameter is **required**. The SDK will throw an error if no model is specified.
738
751
  > - For Azure OpenAI endpoints (`*.openai.azure.com`), you **must** use `type: "azure"`, not `type: "openai"`.
739
752
  > - The `baseUrl` should be just the host (e.g., `https://my-resource.openai.azure.com`). Do **not** include `/openai/v1` in the URL - the SDK handles path construction automatically.
@@ -744,9 +757,9 @@ The SDK supports OpenTelemetry for distributed tracing. Provide a `telemetry` co
744
757
 
745
758
  ```typescript
746
759
  const client = new CopilotClient({
747
- telemetry: {
748
- otlpEndpoint: "http://localhost:4318",
749
- },
760
+ telemetry: {
761
+ otlpEndpoint: "http://localhost:4318",
762
+ },
750
763
  });
751
764
  ```
752
765
 
@@ -772,12 +785,12 @@ If you're already using `@opentelemetry/api` in your app and want this linkage,
772
785
  import { propagation, context } from "@opentelemetry/api";
773
786
 
774
787
  const client = new CopilotClient({
775
- telemetry: { otlpEndpoint: "http://localhost:4318" },
776
- onGetTraceContext: () => {
777
- const carrier: Record<string, string> = {};
778
- propagation.inject(context.active(), carrier);
779
- return carrier;
780
- },
788
+ telemetry: { otlpEndpoint: "http://localhost:4318" },
789
+ onGetTraceContext: () => {
790
+ const carrier: Record<string, string> = {};
791
+ propagation.inject(context.active(), carrier);
792
+ return carrier;
793
+ },
781
794
  });
782
795
  ```
783
796
 
@@ -837,14 +850,15 @@ const session = await client.createSession({
837
850
 
838
851
  ### Permission Result Kinds
839
852
 
840
- | Kind | Meaning |
841
- |------|---------|
842
- | `"approved"` | Allow the tool to run |
843
- | `"denied-interactively-by-user"` | User explicitly denied the request |
844
- | `"denied-no-approval-rule-and-could-not-request-from-user"` | No approval rule matched and user could not be asked |
845
- | `"denied-by-rules"` | Denied by a policy rule |
846
- | `"denied-by-content-exclusion-policy"` | Denied due to a content exclusion policy |
847
- | `"no-result"` | Leave the request unanswered (only valid with protocol v1; rejected by protocol v2 servers) |
853
+ | Kind | Meaning |
854
+ | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
855
+ | `"approved"` | Allow the tool to run |
856
+ | `"denied-interactively-by-user"` | User explicitly denied the request |
857
+ | `"denied-no-approval-rule-and-could-not-request-from-user"` | No approval rule matched and user could not be asked |
858
+ | `"denied-by-rules"` | Denied by a policy rule |
859
+ | `"denied-by-content-exclusion-policy"` | Denied due to a content exclusion policy |
860
+ | `"no-result"` | Leave the request unanswered (only valid with protocol v1; rejected by protocol v2 servers) |
861
+
848
862
  ### Resuming Sessions
849
863
 
850
864
  Pass `onPermissionRequest` when resuming a session too — it is required:
@@ -175,8 +175,9 @@ class CopilotClient {
175
175
  }
176
176
  this.onListModels = options.onListModels;
177
177
  this.onGetTraceContext = options.onGetTraceContext;
178
+ const effectiveEnv = options.env ?? process.env;
178
179
  this.options = {
179
- cliPath: options.cliUrl ? void 0 : options.cliPath || getBundledCliPath(),
180
+ cliPath: options.cliUrl ? void 0 : options.cliPath || effectiveEnv.COPILOT_CLI_PATH || getBundledCliPath(),
180
181
  cliArgs: options.cliArgs ?? [],
181
182
  cwd: options.cwd ?? process.cwd(),
182
183
  port: options.port || 0,
@@ -187,7 +188,7 @@ class CopilotClient {
187
188
  logLevel: options.logLevel || "debug",
188
189
  autoStart: options.autoStart ?? true,
189
190
  autoRestart: false,
190
- env: options.env ?? process.env,
191
+ env: effectiveEnv,
191
192
  githubToken: options.githubToken,
192
193
  // Default useLoggedInUser to false when githubToken is provided, otherwise true
193
194
  useLoggedInUser: options.useLoggedInUser ?? (options.githubToken ? false : true),
package/dist/client.js CHANGED
@@ -155,8 +155,9 @@ class CopilotClient {
155
155
  }
156
156
  this.onListModels = options.onListModels;
157
157
  this.onGetTraceContext = options.onGetTraceContext;
158
+ const effectiveEnv = options.env ?? process.env;
158
159
  this.options = {
159
- cliPath: options.cliUrl ? void 0 : options.cliPath || getBundledCliPath(),
160
+ cliPath: options.cliUrl ? void 0 : options.cliPath || effectiveEnv.COPILOT_CLI_PATH || getBundledCliPath(),
160
161
  cliArgs: options.cliArgs ?? [],
161
162
  cwd: options.cwd ?? process.cwd(),
162
163
  port: options.port || 0,
@@ -167,7 +168,7 @@ class CopilotClient {
167
168
  logLevel: options.logLevel || "debug",
168
169
  autoStart: options.autoStart ?? true,
169
170
  autoRestart: false,
170
- env: options.env ?? process.env,
171
+ env: effectiveEnv,
171
172
  githubToken: options.githubToken,
172
173
  // Default useLoggedInUser to false when githubToken is provided, otherwise true
173
174
  useLoggedInUser: options.useLoggedInUser ?? (options.githubToken ? false : true),
@@ -89,6 +89,10 @@ export type SessionEvent = {
89
89
  * Whether the session was already in use by another client at start time
90
90
  */
91
91
  alreadyInUse?: boolean;
92
+ /**
93
+ * Whether this session supports remote steering via Mission Control
94
+ */
95
+ steerable?: boolean;
92
96
  };
93
97
  } | {
94
98
  /**
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/github/copilot-sdk.git"
6
6
  },
7
- "version": "0.2.1-preview.0",
7
+ "version": "0.2.1-preview.1",
8
8
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
9
9
  "main": "./dist/cjs/index.js",
10
10
  "types": "./dist/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "author": "GitHub",
57
57
  "license": "MIT",
58
58
  "dependencies": {
59
- "@github/copilot": "^1.0.11",
59
+ "@github/copilot": "^1.0.12-0",
60
60
  "vscode-jsonrpc": "^8.2.1",
61
61
  "zod": "^4.3.6"
62
62
  },