@microsoft/copilot-sdk 2.0.0-preview.0 → 2.0.0-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/dist/types.js CHANGED
@@ -11,39 +11,67 @@ const RuntimeConnection = {
11
11
  /**
12
12
  * Spawn a runtime child process and communicate over its stdin/stdout.
13
13
  */
14
- forStdio(opts = {}) {
15
- return { kind: "stdio", path: opts.path, args: opts.args, env: opts.env };
14
+ forSpawnedStdio(opts = {}) {
15
+ return {
16
+ kind: "spawned-stdio",
17
+ path: opts.path,
18
+ args: opts.args,
19
+ env: opts.env,
20
+ workingDirectory: opts.workingDirectory,
21
+ baseDirectory: opts.baseDirectory,
22
+ sessionIdleTimeoutSeconds: opts.sessionIdleTimeoutSeconds
23
+ };
16
24
  },
17
25
  /**
18
26
  * Spawn a runtime child process that listens on a TCP socket and connect to it.
19
27
  */
20
- forTcp(opts = {}) {
28
+ forSpawnedTcp(opts = {}) {
21
29
  return {
22
- kind: "tcp",
23
- port: opts.port,
24
- connectionToken: opts.connectionToken,
30
+ kind: "spawned-tcp",
25
31
  path: opts.path,
26
32
  args: opts.args,
27
- env: opts.env
33
+ env: opts.env,
34
+ workingDirectory: opts.workingDirectory,
35
+ baseDirectory: opts.baseDirectory,
36
+ sessionIdleTimeoutSeconds: opts.sessionIdleTimeoutSeconds,
37
+ port: opts.port,
38
+ connectionToken: opts.connectionToken
28
39
  };
29
40
  },
30
41
  /**
31
- * Connect to an already-running runtime at the given URL. The SDK does not
32
- * spawn a process in this mode.
42
+ * Connect to an already-running runtime over plaintext TCP without owning its lifetime.
33
43
  */
34
- forUri(url, opts = {}) {
35
- return { kind: "uri", url, connectionToken: opts.connectionToken };
44
+ forTcp(host, port, opts = {}) {
45
+ return { kind: "tcp", host, port, connectionToken: opts.connectionToken };
36
46
  },
37
47
  /**
38
48
  * Host the runtime in-process over the native runtime library's C ABI (FFI).
39
49
  *
40
50
  * The default when no connection or environment override is supplied.
41
- * Runtime configuration from `gitHubToken`, `telemetry` and
51
+ * Runtime configuration from `github.token`, `observability.telemetry` and
42
52
  * `baseDirectory` is scoped to this host, not the process environment.
43
53
  * Client-level `env` and `workingDirectory` are unsupported.
44
54
  */
45
55
  forInProcess(options = {}) {
46
- return { kind: "inprocess", ...options };
56
+ return { ...options, kind: "inprocess" };
57
+ },
58
+ /**
59
+ * Resolves the SDK/deployment default at factory-call time, without starting a runtime.
60
+ * Honors COPILOT_SDK_DEFAULT_CONNECTION (stdio/inprocess, case-insensitive);
61
+ * unset or empty uses the installed SDK's default. Invalid values throw.
62
+ * Use a concrete factory when the hosting mode must be fixed.
63
+ */
64
+ forDefault(options = {}) {
65
+ const value = process.env.COPILOT_SDK_DEFAULT_CONNECTION;
66
+ if (value?.toLowerCase() === "stdio") {
67
+ return RuntimeConnection.forSpawnedStdio(options);
68
+ }
69
+ if (!value || value.toLowerCase() === "inprocess") {
70
+ return RuntimeConnection.forInProcess(options);
71
+ }
72
+ throw new Error(
73
+ `Invalid COPILOT_SDK_DEFAULT_CONNECTION value '${value}'. Expected 'inprocess', 'stdio', or unset.`
74
+ );
47
75
  }
48
76
  };
49
77
  function convertMcpCallToolResult(callResult) {
package/docs/examples.md CHANGED
@@ -625,7 +625,7 @@ const session = await joinSession({
625
625
 
626
626
  ### Handling agent questions (ask_user)
627
627
 
628
- Register `onUserInputRequest` to enable the agent's `ask_user` tool:
628
+ Register `interaction.onUserInputRequest` to enable the agent's `ask_user` tool:
629
629
 
630
630
  ```js
631
631
  const session = await joinSession({
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "url": "https://github.com/github/copilot-agent-runtime.git",
6
6
  "directory": "src/sdk/nodejs"
7
7
  },
8
- "version": "2.0.0-preview.0",
9
- "copilotCliVersion": "1.0.106-9.unstable.r43755488033.g11df7b2",
8
+ "version": "2.0.0-preview.1",
9
+ "copilotCliVersion": "1.0.113-0.unstable.r43977958116.g150b9c6",
10
10
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
11
11
  "main": "./dist/cjs/index.js",
12
12
  "types": "./dist/index.d.ts",
@@ -119,18 +119,18 @@
119
119
  "README.md"
120
120
  ],
121
121
  "copilotRuntime": {
122
- "sourceSha": "11df7b2f4261f1febf57351922f4daf3ba33dc3a",
123
- "version": "1.0.106-9.unstable.r43755488033.g11df7b2",
122
+ "sourceSha": "150b9c6656492f7d90a35e7cc85141e8fc71a823",
123
+ "version": "1.0.113-0.unstable.r43977958116.g150b9c6",
124
124
  "visibility": "public"
125
125
  },
126
126
  "optionalDependencies": {
127
- "@microsoft/copilot-sdk-darwin-arm64": "2.0.0-preview.0",
128
- "@microsoft/copilot-sdk-darwin-x64": "2.0.0-preview.0",
129
- "@microsoft/copilot-sdk-linux-arm64": "2.0.0-preview.0",
130
- "@microsoft/copilot-sdk-linux-x64": "2.0.0-preview.0",
131
- "@microsoft/copilot-sdk-linuxmusl-arm64": "2.0.0-preview.0",
132
- "@microsoft/copilot-sdk-linuxmusl-x64": "2.0.0-preview.0",
133
- "@microsoft/copilot-sdk-win32-arm64": "2.0.0-preview.0",
134
- "@microsoft/copilot-sdk-win32-x64": "2.0.0-preview.0"
127
+ "@microsoft/copilot-sdk-darwin-arm64": "2.0.0-preview.1",
128
+ "@microsoft/copilot-sdk-darwin-x64": "2.0.0-preview.1",
129
+ "@microsoft/copilot-sdk-linux-arm64": "2.0.0-preview.1",
130
+ "@microsoft/copilot-sdk-linux-x64": "2.0.0-preview.1",
131
+ "@microsoft/copilot-sdk-linuxmusl-arm64": "2.0.0-preview.1",
132
+ "@microsoft/copilot-sdk-linuxmusl-x64": "2.0.0-preview.1",
133
+ "@microsoft/copilot-sdk-win32-arm64": "2.0.0-preview.1",
134
+ "@microsoft/copilot-sdk-win32-x64": "2.0.0-preview.1"
135
135
  }
136
136
  }