@github/copilot-sdk 1.0.17-preview.5 → 1.0.17-preview.6
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 +41 -0
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +44 -2
- package/dist/cjs/extension.js +2 -0
- package/dist/cjs/generated/rpc.js +165 -0
- package/dist/cjs/session.js +67 -0
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.js +44 -2
- package/dist/extension.d.ts +1 -1
- package/dist/extension.js +2 -0
- package/dist/generated/rpc.d.ts +381 -1
- package/dist/generated/rpc.js +165 -0
- package/dist/generated/session-events.d.ts +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/session.d.ts +7 -0
- package/dist/session.js +67 -0
- package/dist/types.d.ts +69 -0
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -369,6 +369,7 @@ Create a new conversation session.
|
|
|
369
369
|
- `askUserVariant?: "legacy" | "elicitation"` - Selects the model-facing `ask_user` tool shape when creating or cold-resuming a session. Defaults to `"legacy"`; use `"elicitation"` with `onElicitationRequest`.
|
|
370
370
|
- `onElicitationRequest?: ElicitationHandler` - Handler for elicitation requests dispatched by the server. Enables this client to present form-based UI dialogs on behalf of the agent or other session participants. See [Elicitation Requests](#elicitation-requests) section.
|
|
371
371
|
- `hooks?: SessionHooks` - Hook handlers for session lifecycle events. See [Session Hooks](#session-hooks) section.
|
|
372
|
+
- `skillProvider?: SkillProvider` - **Experimental.** Serves skills from host storage instead of skill directories. Not persisted; pass it again on resume. See [Skill providers](#skill-providers-experimental).
|
|
372
373
|
|
|
373
374
|
```typescript
|
|
374
375
|
const session = await client.createSession({
|
|
@@ -1120,6 +1121,46 @@ const session = await client.createSession({
|
|
|
1120
1121
|
});
|
|
1121
1122
|
```
|
|
1122
1123
|
|
|
1124
|
+
### Skill providers (experimental)
|
|
1125
|
+
|
|
1126
|
+
A skill provider serves skills from your own storage, such as a database, instead of `SKILL.md`
|
|
1127
|
+
files on disk. Provider skills join the session's skill catalog and load on demand through the
|
|
1128
|
+
`skill` tool, just like file-based skills.
|
|
1129
|
+
|
|
1130
|
+
```typescript
|
|
1131
|
+
import type { SkillProvider } from "@github/copilot-sdk";
|
|
1132
|
+
|
|
1133
|
+
const skillProvider: SkillProvider = {
|
|
1134
|
+
listSkills: async () => [
|
|
1135
|
+
{ name: "release-notes", description: "Writes release notes in the team's format." },
|
|
1136
|
+
],
|
|
1137
|
+
readSkill: async (name, { signal }) => (await db.findSkill(name, { signal }))?.markdown ?? null,
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
const session = await client.createSession({
|
|
1141
|
+
onPermissionRequest: approveAll,
|
|
1142
|
+
skillProvider,
|
|
1143
|
+
});
|
|
1144
|
+
```
|
|
1145
|
+
|
|
1146
|
+
- `listSkills()` returns the catalog metadata. `readSkill(name)` returns the skill's markdown, or
|
|
1147
|
+
`null`/`undefined` if the skill no longer exists. The markdown may omit YAML frontmatter; when
|
|
1148
|
+
frontmatter is present, its fields must agree with the listed metadata, and `allowed-tools` is
|
|
1149
|
+
read only from frontmatter.
|
|
1150
|
+
- Each call receives `{ signal }`, an `AbortSignal` that fires when the runtime cancels the call,
|
|
1151
|
+
for example after its 30-second limit or when the session disconnects. It doesn't fire when the
|
|
1152
|
+
connection closes or the client is force-stopped; a running call then continues until it returns.
|
|
1153
|
+
- The provider is never persisted. Pass it again to `resumeSession`; resuming without it unbinds
|
|
1154
|
+
the provider.
|
|
1155
|
+
- A provider enables skills unless you set `enableSkills: false`, which keeps it bound but unused.
|
|
1156
|
+
In `mode: "empty"`, skills stay disabled until you set `enableSkills: true`.
|
|
1157
|
+
- Errors thrown by the provider are reported to the model as a generic load failure; their
|
|
1158
|
+
messages are not forwarded.
|
|
1159
|
+
- The runtime may call the provider concurrently, so both methods must be safe for concurrent use.
|
|
1160
|
+
- Skill providers are not supported for cloud sessions.
|
|
1161
|
+
|
|
1162
|
+
See [Custom skills](../docs/features/skills.md#skill-providers-experimental) for limits and details.
|
|
1163
|
+
|
|
1123
1164
|
### Multiple Sessions
|
|
1124
1165
|
|
|
1125
1166
|
```typescript
|
package/dist/cjs/cliVersion.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(cliVersion_exports, {
|
|
|
22
22
|
COPILOT_CLI_VERSION: () => COPILOT_CLI_VERSION
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(cliVersion_exports);
|
|
25
|
-
const COPILOT_CLI_VERSION = "1.0.
|
|
25
|
+
const COPILOT_CLI_VERSION = "1.0.93-0";
|
|
26
26
|
const COPILOT_CLI_USE_NPM_PACKAGE = false;
|
|
27
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
28
|
0 && (module.exports = {
|
package/dist/cjs/client.js
CHANGED
|
@@ -1204,6 +1204,9 @@ class CopilotClient {
|
|
|
1204
1204
|
if (config.gitHubToken !== void 0 && config.gitHubTokenProvider !== void 0) {
|
|
1205
1205
|
throw new Error("gitHubToken and gitHubTokenProvider are mutually exclusive");
|
|
1206
1206
|
}
|
|
1207
|
+
if (config.cloud != null && config.skillProvider) {
|
|
1208
|
+
throw new Error("Skill providers are not supported for cloud sessions.");
|
|
1209
|
+
}
|
|
1207
1210
|
if (!this.connection) {
|
|
1208
1211
|
await this.start();
|
|
1209
1212
|
}
|
|
@@ -1263,6 +1266,9 @@ class CopilotClient {
|
|
|
1263
1266
|
if (config.hooks) {
|
|
1264
1267
|
s.registerHooks(config.hooks);
|
|
1265
1268
|
}
|
|
1269
|
+
if (config.skillProvider) {
|
|
1270
|
+
s.registerSkillProvider(config.skillProvider);
|
|
1271
|
+
}
|
|
1266
1272
|
if (transformCallbacks) {
|
|
1267
1273
|
s.registerTransformCallbacks(transformCallbacks);
|
|
1268
1274
|
}
|
|
@@ -1369,6 +1375,7 @@ class CopilotClient {
|
|
|
1369
1375
|
enableSessionStore: config.enableSessionStore,
|
|
1370
1376
|
enableSkills: config.enableSkills,
|
|
1371
1377
|
skillDirectories: config.skillDirectories,
|
|
1378
|
+
...config.skillProvider ? { hasSkillProvider: true } : {},
|
|
1372
1379
|
pluginDirectories: config.pluginDirectories,
|
|
1373
1380
|
instructionDirectories: config.instructionDirectories,
|
|
1374
1381
|
disabledSkills: config.disabledSkills,
|
|
@@ -1522,6 +1529,9 @@ class CopilotClient {
|
|
|
1522
1529
|
if (config.hooks) {
|
|
1523
1530
|
session.registerHooks(config.hooks);
|
|
1524
1531
|
}
|
|
1532
|
+
if (config.skillProvider) {
|
|
1533
|
+
session.registerSkillProvider(config.skillProvider);
|
|
1534
|
+
}
|
|
1525
1535
|
const modeDefaults = this.configDefaultsForMode();
|
|
1526
1536
|
config = { ...modeDefaults, ...config };
|
|
1527
1537
|
config.customAgentsLocalOnly ??= modeDefaults.customAgentsLocalOnly;
|
|
@@ -1535,9 +1545,10 @@ class CopilotClient {
|
|
|
1535
1545
|
if (config.onEvent) {
|
|
1536
1546
|
session.on(config.onEvent);
|
|
1537
1547
|
}
|
|
1548
|
+
const toolFilterOptions = this.resolveToolFilterOptions(config);
|
|
1538
1549
|
this.setupSessionFs(session, config);
|
|
1550
|
+
const replacedSession = this.sessions.get(sessionId);
|
|
1539
1551
|
this.sessions.set(sessionId, session);
|
|
1540
|
-
const toolFilterOptions = this.resolveToolFilterOptions(config);
|
|
1541
1552
|
const gitHubTokenProviderRegistrationId = this.registerGitHubTokenProvider(
|
|
1542
1553
|
config.gitHubTokenProvider,
|
|
1543
1554
|
sessionId
|
|
@@ -1630,6 +1641,7 @@ class CopilotClient {
|
|
|
1630
1641
|
defaultAgent: config.defaultAgent,
|
|
1631
1642
|
agent: config.agent,
|
|
1632
1643
|
skillDirectories: config.skillDirectories,
|
|
1644
|
+
...config.skillProvider ? { hasSkillProvider: true } : {},
|
|
1633
1645
|
pluginDirectories: config.pluginDirectories,
|
|
1634
1646
|
instructionDirectories: config.instructionDirectories,
|
|
1635
1647
|
disabledSkills: config.disabledSkills,
|
|
@@ -1674,7 +1686,13 @@ class CopilotClient {
|
|
|
1674
1686
|
this.commitGitHubTokenProvider(sessionId, gitHubTokenProviderRegistrationId);
|
|
1675
1687
|
} catch (e) {
|
|
1676
1688
|
session._markDisconnected();
|
|
1677
|
-
this.sessions.
|
|
1689
|
+
if (this.sessions.get(sessionId) === session) {
|
|
1690
|
+
if (replacedSession) {
|
|
1691
|
+
this.sessions.set(sessionId, replacedSession);
|
|
1692
|
+
} else {
|
|
1693
|
+
this.sessions.delete(sessionId);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1678
1696
|
if (gitHubTokenProviderRegistrationId !== void 0) {
|
|
1679
1697
|
this.githubTokenProviders.delete(gitHubTokenProviderRegistrationId);
|
|
1680
1698
|
}
|
|
@@ -2650,6 +2668,20 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
2650
2668
|
return await this.handleHooksInvoke(params);
|
|
2651
2669
|
}
|
|
2652
2670
|
);
|
|
2671
|
+
this.connection.onRequest(
|
|
2672
|
+
"skillProvider.list",
|
|
2673
|
+
async (params, token) => await this.resolveSkillProviderSession(params)._handleSkillProviderList(token)
|
|
2674
|
+
);
|
|
2675
|
+
this.connection.onRequest(
|
|
2676
|
+
"skillProvider.read",
|
|
2677
|
+
async (params, token) => {
|
|
2678
|
+
const session = this.resolveSkillProviderSession(params);
|
|
2679
|
+
if (typeof params.name !== "string") {
|
|
2680
|
+
throw new Error("Invalid skillProvider.read payload");
|
|
2681
|
+
}
|
|
2682
|
+
return await session._handleSkillProviderRead(params.name, token);
|
|
2683
|
+
}
|
|
2684
|
+
);
|
|
2653
2685
|
const connection = this.connection;
|
|
2654
2686
|
const messageWriter = this.messageWriter;
|
|
2655
2687
|
const cliProcess = this.isExternalServer ? null : this.cliProcess;
|
|
@@ -2806,6 +2838,16 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
2806
2838
|
});
|
|
2807
2839
|
return { response };
|
|
2808
2840
|
}
|
|
2841
|
+
resolveSkillProviderSession(params) {
|
|
2842
|
+
if (!params || typeof params.sessionId !== "string") {
|
|
2843
|
+
throw new Error("Invalid skillProvider payload");
|
|
2844
|
+
}
|
|
2845
|
+
const session = this.sessions.get(params.sessionId);
|
|
2846
|
+
if (!session) {
|
|
2847
|
+
throw new Error(`Session not found: ${params.sessionId}`);
|
|
2848
|
+
}
|
|
2849
|
+
return session;
|
|
2850
|
+
}
|
|
2809
2851
|
async handleHooksInvoke(params) {
|
|
2810
2852
|
if (!params || typeof params.sessionId !== "string" || typeof params.hookType !== "string") {
|
|
2811
2853
|
throw new Error("Invalid hooks invoke payload");
|
package/dist/cjs/extension.js
CHANGED
|
@@ -41,11 +41,13 @@ async function joinSession(config = {}) {
|
|
|
41
41
|
const client = new import_client.CopilotClient({ _internalConnection: { kind: "parent-process" } });
|
|
42
42
|
const {
|
|
43
43
|
extensionSdkPath: _stripped,
|
|
44
|
+
skillProvider: _strippedSkillProvider,
|
|
44
45
|
workflows,
|
|
45
46
|
requestedEnvironmentVariables,
|
|
46
47
|
...rest
|
|
47
48
|
} = config;
|
|
48
49
|
void _stripped;
|
|
50
|
+
void _strippedSkillProvider;
|
|
49
51
|
return client.resumeSessionForExtension(
|
|
50
52
|
sessionId,
|
|
51
53
|
{
|
|
@@ -980,6 +980,37 @@ function createServerRpc(connection) {
|
|
|
980
980
|
* @returns Outcome of an agentRegistry.spawn call.
|
|
981
981
|
*/
|
|
982
982
|
spawn: async (params) => connection.sendRequest("agentRegistry.spawn", params)
|
|
983
|
+
},
|
|
984
|
+
/** @experimental */
|
|
985
|
+
connectors: {
|
|
986
|
+
/**
|
|
987
|
+
* Returns feature availability.
|
|
988
|
+
*
|
|
989
|
+
* @returns Feature availability.
|
|
990
|
+
*/
|
|
991
|
+
getCapabilities: async () => connection.sendRequest("connectors.getCapabilities", {}),
|
|
992
|
+
/**
|
|
993
|
+
* Returns eligible accounts.
|
|
994
|
+
*
|
|
995
|
+
* @returns Eligible accounts.
|
|
996
|
+
*/
|
|
997
|
+
getAccounts: async () => connection.sendRequest("connectors.getAccounts", {}),
|
|
998
|
+
/**
|
|
999
|
+
* Lists entries for the selected account.
|
|
1000
|
+
*
|
|
1001
|
+
* @param params Selected account.
|
|
1002
|
+
*
|
|
1003
|
+
* @returns Entries for the selected account.
|
|
1004
|
+
*/
|
|
1005
|
+
list: async (params) => connection.sendRequest("connectors.list", params),
|
|
1006
|
+
/**
|
|
1007
|
+
* Refreshes entries for the selected account.
|
|
1008
|
+
*
|
|
1009
|
+
* @param params Selected account.
|
|
1010
|
+
*
|
|
1011
|
+
* @returns Entries for the selected account.
|
|
1012
|
+
*/
|
|
1013
|
+
refresh: async (params) => connection.sendRequest("connectors.refresh", params)
|
|
983
1014
|
}
|
|
984
1015
|
};
|
|
985
1016
|
}
|
|
@@ -1035,6 +1066,110 @@ function createInternalServerRpc(connection) {
|
|
|
1035
1066
|
*/
|
|
1036
1067
|
connect: async (params) => connection.sendRequest("connect", params),
|
|
1037
1068
|
/** @experimental */
|
|
1069
|
+
agents: {
|
|
1070
|
+
/**
|
|
1071
|
+
* Lists the agents this runtime ships, by name. A consumer separating shipped agents from ones the user or a plugin authored should compare against these names rather than against `AgentInfo.source`: an authored agent may carry the `builtin` source while not being one of these, and the runtime treats the two as separate questions. `disableableNames` is the subset a user may turn off, which a client needs to decide whether to offer a toggle. `yamlBasedNames` is the subset backed by a shipped YAML definition, which a client needs before asking the runtime to load one.
|
|
1072
|
+
*
|
|
1073
|
+
* @returns The agents this runtime ships, named so a consumer can tell them apart from authored ones.
|
|
1074
|
+
*/
|
|
1075
|
+
getBuiltins: async () => connection.sendRequest("agents.getBuiltins", {}),
|
|
1076
|
+
/**
|
|
1077
|
+
* Lists the shipped agents a client should offer right now, filtered by the feature flags it passes. `getBuiltins` names every agent the runtime knows about; some of those are gated, so a client rendering a picker wants this narrower list together with the description to show beside each name.
|
|
1078
|
+
*
|
|
1079
|
+
* @param params The feature flags to evaluate shipped agents against.
|
|
1080
|
+
*
|
|
1081
|
+
* @returns The shipped agents available under the requested flags.
|
|
1082
|
+
*/
|
|
1083
|
+
getAvailableBuiltins: async (params) => connection.sendRequest("agents.getAvailableBuiltins", params),
|
|
1084
|
+
/**
|
|
1085
|
+
* Loads one shipped agent's YAML definition, for a client that needs what the agent declares rather than only its name. `getBuiltins` reports which names have a definition to load: a name outside its `yamlBasedNames` is special-cased in code and has none. The definition crosses as its own JSON rather than as contract-typed fields, because the runtime parses it with the agent schema's tolerant shape and re-typing it here would drop the keys that shape accepts and this one does not. The projected `__nativeCustomAgent` view the runtime derives is included, so a caller reading the declared model and a caller rendering the agent see the same definition.
|
|
1086
|
+
*
|
|
1087
|
+
* @param params The shipped agent whose definition to load.
|
|
1088
|
+
*
|
|
1089
|
+
* @returns One shipped agent's definition.
|
|
1090
|
+
*/
|
|
1091
|
+
getBuiltinDefinition: async (params) => connection.sendRequest("agents.getBuiltinDefinition", params),
|
|
1092
|
+
/**
|
|
1093
|
+
* Projects one shipped agent the way a picker lists it, reading only the metadata at the head of the definition file and stopping before the prompt body. `getBuiltinDefinition` answers the whole definition instead, so a client listing every shipped agent should prefer this one: the cost of a listing grows with the number of agents, and the prompt body is the part a listing never shows. The two also differ in shape. This returns the projected custom agent on its own, whereas `getBuiltinDefinition` returns the authored definition with that projection nested under `__nativeCustomAgent`.
|
|
1094
|
+
*
|
|
1095
|
+
* @param params The shipped agent whose listing entry to load.
|
|
1096
|
+
*
|
|
1097
|
+
* @returns One shipped agent, projected for a listing.
|
|
1098
|
+
*/
|
|
1099
|
+
getBuiltinListingDefinition: async (params) => connection.sendRequest("agents.getBuiltinListingDefinition", params),
|
|
1100
|
+
/**
|
|
1101
|
+
* Resolves the model a custom agent asks for against the models actually available, and answers both the model to switch to and the warning a user should see when the agent's preference cannot be met. A custom agent may name several acceptable models in preference order, so the decision is a match rather than a lookup, and an agent whose preference is unavailable is a normal outcome that produces a warning rather than an error. A host must call this rather than pick the first available name itself, because the preference order and the wording of the warning are what keep one installation's agent selection the same as another's.
|
|
1102
|
+
*
|
|
1103
|
+
* @param params The models a custom agent asks for, and the models actually available.
|
|
1104
|
+
*
|
|
1105
|
+
* @returns The model to switch to, and the warning to show when the agent's preference could not be met.
|
|
1106
|
+
*/
|
|
1107
|
+
customAgentInitialModelDecision: async (params) => connection.sendRequest("agents.customAgentInitialModelDecision", params)
|
|
1108
|
+
},
|
|
1109
|
+
/** @experimental */
|
|
1110
|
+
gitHubRepository: {
|
|
1111
|
+
/**
|
|
1112
|
+
* Resolves the GitHub repository that owns a working-tree path by reading the selected git remote configured for it, preferring `origin`. Returns a null `repository` when the path is inside a git working tree but that selected remote does not resolve to a GitHub host. Fails when the path is not inside a git working tree at all, so a caller can tell 'not a repository' apart from 'a repository with no GitHub remote'.
|
|
1113
|
+
*
|
|
1114
|
+
* @param params Working-tree path whose owning GitHub repository should be resolved.
|
|
1115
|
+
*
|
|
1116
|
+
* @returns The GitHub repository that owns the requested path, when the selected remote (`origin`, else the first) is on a GitHub host.
|
|
1117
|
+
*/
|
|
1118
|
+
atPath: async (params) => connection.sendRequest("gitHubRepository.atPath", params)
|
|
1119
|
+
},
|
|
1120
|
+
/** @experimental */
|
|
1121
|
+
gitHubOwners: {
|
|
1122
|
+
/**
|
|
1123
|
+
* Registers a cancellable owner listing and returns its request id. Separate from `gitHubOwners.list` so the id exists before the listing starts: a caller that abandons the listing the moment it begins would otherwise have nothing to name in `gitHubOwners.cancel`. The id serves one listing only. Long-abandoned unused ids can be released by later allocations.
|
|
1124
|
+
*
|
|
1125
|
+
* @returns A freshly registered request id. Registering it before the listing starts is what lets a cancel that races the request still find the owner listing slot. The id serves one listing only. Long-abandoned unused ids can be released by later allocations.
|
|
1126
|
+
*/
|
|
1127
|
+
nextRequestId: async () => connection.sendRequest("gitHubOwners.nextRequestId", {}),
|
|
1128
|
+
/**
|
|
1129
|
+
* Lists the logins the authenticated user may act as — their own account first, then the organizations they belong to — by asking the GitHub API under the supplied credential. No credential travels in the request: `authInfo` selects one the runtime already holds, and the runtime resolves the token and the GitHub host from it. A failure the caller should render arrives as `message`; one it should raise arrives as `throwError`.
|
|
1130
|
+
*
|
|
1131
|
+
* @param params Credential to list owners under, and the request id that makes the listing cancellable.
|
|
1132
|
+
*
|
|
1133
|
+
* @returns Outcome of an owner listing. Exactly one of `owners` and `message` is present, except that `throwError` reports a failure the caller is expected to raise rather than render.
|
|
1134
|
+
*/
|
|
1135
|
+
list: async (params) => connection.sendRequest("gitHubOwners.list", params),
|
|
1136
|
+
/**
|
|
1137
|
+
* Abandons an owner listing started with the given request id. Answers `canceled: true` while a listing with that id is running. Answers `canceled: false` when the id was never registered, was registered but not used, was released after being abandoned, or its listing has ended. Canceling an unused id releases it, and a later `list` with that id is refused. The cancel acts only on owner listings and never reaches another request of the host.
|
|
1138
|
+
*
|
|
1139
|
+
* @param params The owner listing to abandon.
|
|
1140
|
+
*
|
|
1141
|
+
* @returns Whether the id named a running owner listing.
|
|
1142
|
+
*/
|
|
1143
|
+
cancel: async (params) => connection.sendRequest("gitHubOwners.cancel", params)
|
|
1144
|
+
},
|
|
1145
|
+
/** @experimental */
|
|
1146
|
+
git: {
|
|
1147
|
+
/**
|
|
1148
|
+
* Reads the remote that the branch checked out in a working tree tracks, as `branch.<name>.remote` configures it. Reports `origin` rather than failing whenever there is no tracking configuration to read — on a detached HEAD, on a branch with no upstream, or when git itself fails — because a caller asking which remote to talk to needs an answer it can act on, not an error. Marked internal because it exists to carry a CLI call site off the napi boundary onto the SDK contract; it is migration plumbing, not a surface consumers are meant to depend on.
|
|
1149
|
+
*
|
|
1150
|
+
* @param params Working-tree path a git query applies to.
|
|
1151
|
+
*
|
|
1152
|
+
* @returns The remote the checked-out branch tracks.
|
|
1153
|
+
*/
|
|
1154
|
+
currentBranchRemote: async (params) => connection.sendRequest("git.currentBranchRemote", params),
|
|
1155
|
+
/**
|
|
1156
|
+
* Collects the repository context of a working directory in one call: working tree root, repository identifier and host, current branch, and the HEAD and base commits. Every repository field is omitted when the path is not inside a git working tree, and the requested path is echoed back as `cwd`. The answer is the same `SessionWorkingDirectoryContext` that `session.metadata.recordContextChange` accepts, so a caller polling for a context change can forward the result unchanged. Marked internal because it exists to carry a CLI call site off the napi boundary onto the SDK contract; it is migration plumbing, not a surface consumers are meant to depend on. It can become public once an SDK consumer needs to derive session context from a directory itself.
|
|
1157
|
+
*
|
|
1158
|
+
* @param params Working-tree path a git query applies to.
|
|
1159
|
+
*
|
|
1160
|
+
* @returns Updated working directory and git context. Emitted as the new payload of `session.context_changed`.
|
|
1161
|
+
*/
|
|
1162
|
+
workingDirectoryContext: async (params) => connection.sendRequest("git.workingDirectoryContext", params),
|
|
1163
|
+
/**
|
|
1164
|
+
* Lists the GitHub repositories a working tree's remotes point at, one entry per distinct repository, so a caller can resolve a base and head repository without parsing remote URLs itself. When several remotes name the same repository, only the first is listed, and the entry keeps that remote name. Remotes pointing at no GitHub host are left out, so an empty list means the tree reaches GitHub through no remote. Failing to read the remotes is reported as an error rather than as an empty list, because the two mean different things to a caller. Marked internal because it exists to carry a CLI call site off the napi boundary onto the SDK contract; it is migration plumbing, not a surface consumers are meant to depend on.
|
|
1165
|
+
*
|
|
1166
|
+
* @param params Git working tree whose GitHub remotes should be listed.
|
|
1167
|
+
*
|
|
1168
|
+
* @returns The GitHub repositories a working tree's remotes point at.
|
|
1169
|
+
*/
|
|
1170
|
+
reposFromRemotes: async (params) => connection.sendRequest("git.reposFromRemotes", params)
|
|
1171
|
+
},
|
|
1172
|
+
/** @experimental */
|
|
1038
1173
|
sessions: {
|
|
1039
1174
|
/**
|
|
1040
1175
|
* Reads lightweight persisted metadata for one local session without opening it.
|
|
@@ -1074,6 +1209,30 @@ function createInternalServerRpc(connection) {
|
|
|
1074
1209
|
* @param params Session ID to delete from disk.
|
|
1075
1210
|
*/
|
|
1076
1211
|
delete: async (params) => connection.sendRequest("sessions.delete", params),
|
|
1212
|
+
/**
|
|
1213
|
+
* Creates the workspace record for a session that has not been opened yet. A host that hands a session off to another application — writing the record and then launching that application against the session ID — needs the record on disk before any session exists to carry it, which the session-scoped workspace methods cannot do. Replaces any existing record and resets the checkpoint index. When writing to the local filesystem, a stored `fork_count` survives on disk. Returns the record it built, so a surviving stored `fork_count` can differ from the answer.
|
|
1214
|
+
*
|
|
1215
|
+
* @param params Identity, state location and starting context for a workspace record.
|
|
1216
|
+
*
|
|
1217
|
+
* @returns The workspace record that was written.
|
|
1218
|
+
*/
|
|
1219
|
+
createWorkspace: async (params) => connection.sendRequest("sessions.createWorkspace", params),
|
|
1220
|
+
/**
|
|
1221
|
+
* Reads a session's workspace record straight from disk, without opening the session. Resuming by session ID has to know where the session lives before it can connect, so the lookup cannot come from the session-scoped workspace methods, which resolve their location from a live session's context. Returns no record when the file is absent.
|
|
1222
|
+
*
|
|
1223
|
+
* @param params Where the session's state lives, as a root directory and the session ID under it.
|
|
1224
|
+
*
|
|
1225
|
+
* @returns The workspace record on disk, omitted when the session has none.
|
|
1226
|
+
*/
|
|
1227
|
+
loadWorkspace: async (params) => connection.sendRequest("sessions.loadWorkspace", params),
|
|
1228
|
+
/**
|
|
1229
|
+
* Merges fields into a session's workspace record on disk, creating the record when it is absent. The counterpart to `sessions.loadWorkspace`, for the same before-the-session-exists case. It preserves stored workspace-schema fields the request does not supply, does not preserve stored keys outside the workspace schema, and never replaces a stored `fork_count`.
|
|
1230
|
+
*
|
|
1231
|
+
* @param params Where the session's state lives, plus workspace-schema fields to merge into its workspace record. Stored keys outside the schema are not preserved, and a stored `fork_count` is never replaced.
|
|
1232
|
+
*
|
|
1233
|
+
* @returns The merge completed. The record carries the supplied workspace-schema fields, but a stored `fork_count` stays.
|
|
1234
|
+
*/
|
|
1235
|
+
updateWorkspaceFields: async (params) => connection.sendRequest("sessions.updateWorkspaceFields", params),
|
|
1077
1236
|
/**
|
|
1078
1237
|
* Gets the dynamic-context board entry count associated with a session, when available. Internal: this exists solely so CLI telemetry events (`rem_spawn_gate`, `rem_consolidation_complete`) can pair START / END board counts around the detached rem-agent spawn. "Dynamic context board" is a runtime-internal concept that is not part of the public SDK contract; the long-term plan is to relocate the telemetry emission into the runtime so this method can be deleted entirely.
|
|
1079
1238
|
*
|
|
@@ -3407,6 +3566,12 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
3407
3566
|
},
|
|
3408
3567
|
/** @experimental */
|
|
3409
3568
|
mcp: {
|
|
3569
|
+
/**
|
|
3570
|
+
* Records the IDE the host is connected to, so the agent's system prompt can name it and its workspace folder. Null or an omitted `ide` clears the recorded value, which is how a host reports that it is disconnected; there is no separate clear method. Both `ideName` and `workspaceFolder` are required together, because half a state cannot be attributed to a project.
|
|
3571
|
+
*
|
|
3572
|
+
* @param params Records which IDE the host is connected to, or clears it.
|
|
3573
|
+
*/
|
|
3574
|
+
setConnectedIdeInfo: async (params) => connection.sendRequest("session.mcp.setConnectedIdeInfo", { ...params, sessionId }),
|
|
3410
3575
|
/**
|
|
3411
3576
|
* Reloads MCP server connections for the session with an explicit host-provided configuration.
|
|
3412
3577
|
*
|
package/dist/cjs/session.js
CHANGED
|
@@ -284,6 +284,7 @@ class CopilotSession {
|
|
|
284
284
|
elicitationHandler;
|
|
285
285
|
exitPlanModeHandler;
|
|
286
286
|
autoModeSwitchHandler;
|
|
287
|
+
skillProvider;
|
|
287
288
|
hooks;
|
|
288
289
|
transformCallbacks;
|
|
289
290
|
_rpc = null;
|
|
@@ -696,6 +697,7 @@ class CopilotSession {
|
|
|
696
697
|
this.elicitationHandler = void 0;
|
|
697
698
|
this.exitPlanModeHandler = void 0;
|
|
698
699
|
this.autoModeSwitchHandler = void 0;
|
|
700
|
+
this.skillProvider = void 0;
|
|
699
701
|
this.commandHandlers.clear();
|
|
700
702
|
this.canvases.clear();
|
|
701
703
|
this.workflows.clear();
|
|
@@ -1602,6 +1604,68 @@ class CopilotSession {
|
|
|
1602
1604
|
registerUserInputHandler(handler) {
|
|
1603
1605
|
this.userInputHandler = handler;
|
|
1604
1606
|
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Registers the session's skill provider.
|
|
1609
|
+
*
|
|
1610
|
+
* @param provider - The skill provider, or undefined to remove it
|
|
1611
|
+
* @internal This method is typically called internally when creating a session.
|
|
1612
|
+
*/
|
|
1613
|
+
registerSkillProvider(provider) {
|
|
1614
|
+
this.skillProvider = provider;
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Handles a `skillProvider.list` request from the runtime.
|
|
1618
|
+
*
|
|
1619
|
+
* @internal This method is for internal use by the SDK.
|
|
1620
|
+
*/
|
|
1621
|
+
async _handleSkillProviderList(token) {
|
|
1622
|
+
const provider = this.requireSkillProvider();
|
|
1623
|
+
return await this.callSkillProvider("listSkills", token, async (options) => ({
|
|
1624
|
+
skills: await provider.listSkills(options) ?? []
|
|
1625
|
+
}));
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Handles a `skillProvider.read` request from the runtime.
|
|
1629
|
+
*
|
|
1630
|
+
* @internal This method is for internal use by the SDK.
|
|
1631
|
+
*/
|
|
1632
|
+
async _handleSkillProviderRead(name, token) {
|
|
1633
|
+
const provider = this.requireSkillProvider();
|
|
1634
|
+
return await this.callSkillProvider("readSkill", token, async (options) => ({
|
|
1635
|
+
markdown: await provider.readSkill(name, options) ?? null
|
|
1636
|
+
}));
|
|
1637
|
+
}
|
|
1638
|
+
requireSkillProvider() {
|
|
1639
|
+
if (!this.skillProvider) {
|
|
1640
|
+
throw new Error(`No skill provider for session: ${this.sessionId}`);
|
|
1641
|
+
}
|
|
1642
|
+
return this.skillProvider;
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Runs a provider call with an abort signal tied to the runtime's request
|
|
1646
|
+
* cancellation. Failures are logged locally and reported generically.
|
|
1647
|
+
*/
|
|
1648
|
+
async callSkillProvider(operation, token, call) {
|
|
1649
|
+
const controller = new AbortController();
|
|
1650
|
+
const subscription = token?.onCancellationRequested(() => controller.abort());
|
|
1651
|
+
if (token?.isCancellationRequested) {
|
|
1652
|
+
controller.abort();
|
|
1653
|
+
}
|
|
1654
|
+
try {
|
|
1655
|
+
return await call({ signal: controller.signal });
|
|
1656
|
+
} catch (error) {
|
|
1657
|
+
if (controller.signal.aborted) {
|
|
1658
|
+
throw new import_node.ResponseError(-32800, `Skill provider ${operation} cancelled`);
|
|
1659
|
+
}
|
|
1660
|
+
console.error(`Skill provider ${operation} failed`, {
|
|
1661
|
+
sessionId: this.sessionId,
|
|
1662
|
+
error
|
|
1663
|
+
});
|
|
1664
|
+
throw skillProviderFailure(operation);
|
|
1665
|
+
} finally {
|
|
1666
|
+
subscription?.dispose();
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1605
1669
|
/**
|
|
1606
1670
|
* Registers hook handlers for session lifecycle events.
|
|
1607
1671
|
*
|
|
@@ -1955,6 +2019,9 @@ function toCanvasRpcError(error) {
|
|
|
1955
2019
|
const message = error instanceof Error ? error.message : String(error);
|
|
1956
2020
|
return new import_node.ResponseError(import_node.ErrorCodes.InternalError, message, { code, message });
|
|
1957
2021
|
}
|
|
2022
|
+
function skillProviderFailure(operation) {
|
|
2023
|
+
return new import_node.ResponseError(import_node.ErrorCodes.InternalError, `Skill provider ${operation} failed`);
|
|
2024
|
+
}
|
|
1958
2025
|
function strictJsonValidationError(context, category, message, path) {
|
|
1959
2026
|
return new import_node.ResponseError(import_node.ErrorCodes.InternalError, message, {
|
|
1960
2027
|
code: context.code,
|
package/dist/cliVersion.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const COPILOT_CLI_VERSION = "1.0.
|
|
1
|
+
export declare const COPILOT_CLI_VERSION = "1.0.93-0";
|
|
2
2
|
export declare const COPILOT_CLI_USE_NPM_PACKAGE = false;
|
package/dist/cliVersion.js
CHANGED
package/dist/client.d.ts
CHANGED
|
@@ -507,6 +507,7 @@ export declare class CopilotClient {
|
|
|
507
507
|
private handleUserInputRequest;
|
|
508
508
|
private handleExitPlanModeRequest;
|
|
509
509
|
private handleAutoModeSwitchRequest;
|
|
510
|
+
private resolveSkillProviderSession;
|
|
510
511
|
private handleHooksInvoke;
|
|
511
512
|
private handleSystemMessageTransform;
|
|
512
513
|
}
|
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.
|
|
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");
|
package/dist/extension.d.ts
CHANGED
|
@@ -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
|
{
|