condukt 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtimes/copilot/copilot-adapter.d.ts.map +1 -1
- package/dist/runtimes/copilot/copilot-adapter.js +3 -0
- package/dist/runtimes/copilot/copilot-adapter.js.map +1 -1
- package/dist/runtimes/copilot/copilot-backend.d.ts +5 -2
- package/dist/runtimes/copilot/copilot-backend.d.ts.map +1 -1
- package/dist/runtimes/copilot/index.d.ts +2 -0
- package/dist/runtimes/copilot/index.d.ts.map +1 -1
- package/dist/runtimes/copilot/index.js +4 -1
- package/dist/runtimes/copilot/index.js.map +1 -1
- package/dist/runtimes/copilot/sdk-backend.d.ts +14 -6
- package/dist/runtimes/copilot/sdk-backend.d.ts.map +1 -1
- package/dist/runtimes/copilot/sdk-backend.js +192 -78
- package/dist/runtimes/copilot/sdk-backend.js.map +1 -1
- package/dist/runtimes/copilot/subagents.d.ts +16 -0
- package/dist/runtimes/copilot/subagents.d.ts.map +1 -0
- package/dist/runtimes/copilot/subagents.js +37 -0
- package/dist/runtimes/copilot/subagents.js.map +1 -0
- package/dist/src/agent-node.d.ts +2 -1
- package/dist/src/agent-node.d.ts.map +1 -1
- package/dist/src/agent-node.js +9 -5
- package/dist/src/agent-node.js.map +1 -1
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +4 -1
- package/dist/src/agent.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/panel-node.d.ts +2 -1
- package/dist/src/panel-node.d.ts.map +1 -1
- package/dist/src/panel-node.js +9 -5
- package/dist/src/panel-node.js.map +1 -1
- package/dist/src/types.d.ts +25 -6
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +12 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-adapter.d.ts","sourceRoot":"","sources":["../../../runtimes/copilot/copilot-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"copilot-adapter.d.ts","sourceRoot":"","sources":["../../../runtimes/copilot/copilot-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG,YAAY,CA0DzE"}
|
|
@@ -60,6 +60,9 @@ function adaptCopilotBackend(backend) {
|
|
|
60
60
|
...(config.customAgents !== undefined
|
|
61
61
|
? { customAgents: config.customAgents }
|
|
62
62
|
: {}),
|
|
63
|
+
...(config.subagentRoster !== undefined
|
|
64
|
+
? { subagentRoster: config.subagentRoster }
|
|
65
|
+
: {}),
|
|
63
66
|
...(config.defaultAgent !== undefined
|
|
64
67
|
? { defaultAgent: config.defaultAgent }
|
|
65
68
|
: {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-adapter.js","sourceRoot":"","sources":["../../../runtimes/copilot/copilot-adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAuBH,
|
|
1
|
+
{"version":3,"file":"copilot-adapter.js","sourceRoot":"","sources":["../../../runtimes/copilot/copilot-adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAuBH,kDA0DC;AAvED;;;;;;;;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SAAS;oBACnC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE;oBACvC,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,MAAM,CAAC,cAAc,KAAK,SAAS;oBACrC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE;oBAC3C,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,MAAM,CAAC,YAAY,KAAK,SAAS;oBACnC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE;oBACvC,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,MAAM,CAAC,qBAAqB,KAAK,SAAS;oBAC5C,CAAC,CAAC,EAAE,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,EAAE;oBACzD,CAAC,CAAC,EAAE,CAAC;aACR,CAAC;YAEF,MAAM,OAAO,GAAmB,MAAM,OAAO,CAAC,aAAa,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YAEpF,+DAA+D;YAC/D,4DAA4D;YAC5D,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* The orchestrator depends on this interface, not on any implementation.
|
|
10
10
|
*/
|
|
11
|
+
import type { SubagentRosterOption } from './subagents';
|
|
11
12
|
export interface MCPServerConfig {
|
|
12
13
|
readonly type?: string;
|
|
13
14
|
readonly command?: string;
|
|
@@ -16,6 +17,7 @@ export interface MCPServerConfig {
|
|
|
16
17
|
readonly url?: string;
|
|
17
18
|
readonly headers?: Readonly<Record<string, string>>;
|
|
18
19
|
readonly tools?: readonly string[];
|
|
20
|
+
readonly timeout?: number;
|
|
19
21
|
readonly [key: string]: unknown;
|
|
20
22
|
}
|
|
21
23
|
export interface CustomAgentConfig {
|
|
@@ -31,7 +33,6 @@ export interface CustomAgentConfig {
|
|
|
31
33
|
}
|
|
32
34
|
export interface DefaultAgentConfig {
|
|
33
35
|
readonly excludedTools?: readonly string[];
|
|
34
|
-
readonly [key: string]: unknown;
|
|
35
36
|
}
|
|
36
37
|
export interface SessionConfig {
|
|
37
38
|
/** Model to use: "claude-opus-4.6", "gpt-5.4", etc. */
|
|
@@ -54,8 +55,10 @@ export interface SessionConfig {
|
|
|
54
55
|
readonly availableTools?: readonly string[];
|
|
55
56
|
/** Tool deny-list: these tools are excluded (SdkBackend only). */
|
|
56
57
|
readonly excludedTools?: readonly string[];
|
|
57
|
-
/** Custom subagent
|
|
58
|
+
/** Custom subagent definitions (SdkBackend only). */
|
|
58
59
|
readonly customAgents?: readonly CustomAgentConfig[];
|
|
60
|
+
/** Stable subagent model/settings roster, or false to opt out (SdkBackend only). */
|
|
61
|
+
readonly subagentRoster?: SubagentRosterOption;
|
|
59
62
|
/** Main-agent configuration (SdkBackend only). */
|
|
60
63
|
readonly defaultAgent?: DefaultAgentConfig;
|
|
61
64
|
/** Built-in subagents unavailable to this session (SdkBackend only). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-backend.d.ts","sourceRoot":"","sources":["../../../runtimes/copilot/copilot-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,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K,IAAI,GAAG,IAAI,CAAC;IAC/H,wBAAwB;IACxB,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAClG,4CAA4C;IAC5C,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAChG,wCAAwC;IACxC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI,CAAC;IACvE,kEAAkE;IAClE,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC;IAEhG,kDAAkD;IAClD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,aAAa,CACX,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3B,wCAAwC;IACxC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhC,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -2,6 +2,8 @@ export type { CopilotBackend, CopilotSession, SessionConfig as CopilotSessionCon
|
|
|
2
2
|
export { SubprocessBackend } from './subprocess-backend';
|
|
3
3
|
export { SdkBackend } from './sdk-backend';
|
|
4
4
|
export type { SdkBackendOptions } from './sdk-backend';
|
|
5
|
+
export { DEFAULT_SUBAGENT_ROSTER, mergeSubagentRosters } from './subagents';
|
|
6
|
+
export type { SubagentRoster, SubagentRosterEntry, SubagentRosterOption, SubagentRosterValue, } from './subagents';
|
|
5
7
|
export { adaptCopilotBackend } from './copilot-adapter';
|
|
6
8
|
export { isProcessAlive, killProcessTree } from './process-killer';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../runtimes/copilot/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,IAAI,oBAAoB,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxK,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../runtimes/copilot/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,IAAI,oBAAoB,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxK,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC5E,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.killProcessTree = exports.isProcessAlive = exports.adaptCopilotBackend = exports.SdkBackend = exports.SubprocessBackend = void 0;
|
|
3
|
+
exports.killProcessTree = exports.isProcessAlive = exports.adaptCopilotBackend = exports.mergeSubagentRosters = exports.DEFAULT_SUBAGENT_ROSTER = exports.SdkBackend = exports.SubprocessBackend = void 0;
|
|
4
4
|
var subprocess_backend_1 = require("./subprocess-backend");
|
|
5
5
|
Object.defineProperty(exports, "SubprocessBackend", { enumerable: true, get: function () { return subprocess_backend_1.SubprocessBackend; } });
|
|
6
6
|
var sdk_backend_1 = require("./sdk-backend");
|
|
7
7
|
Object.defineProperty(exports, "SdkBackend", { enumerable: true, get: function () { return sdk_backend_1.SdkBackend; } });
|
|
8
|
+
var subagents_1 = require("./subagents");
|
|
9
|
+
Object.defineProperty(exports, "DEFAULT_SUBAGENT_ROSTER", { enumerable: true, get: function () { return subagents_1.DEFAULT_SUBAGENT_ROSTER; } });
|
|
10
|
+
Object.defineProperty(exports, "mergeSubagentRosters", { enumerable: true, get: function () { return subagents_1.mergeSubagentRosters; } });
|
|
8
11
|
var copilot_adapter_1 = require("./copilot-adapter");
|
|
9
12
|
Object.defineProperty(exports, "adaptCopilotBackend", { enumerable: true, get: function () { return copilot_adapter_1.adaptCopilotBackend; } });
|
|
10
13
|
var process_killer_1 = require("./process-killer");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../runtimes/copilot/index.ts"],"names":[],"mappings":";;;AACA,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AAEnB,qDAAwD;AAA/C,sHAAA,mBAAmB,OAAA;AAC5B,mDAAmE;AAA1D,gHAAA,cAAc,OAAA;AAAE,iHAAA,eAAe,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../runtimes/copilot/index.ts"],"names":[],"mappings":";;;AACA,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AAEnB,yCAA4E;AAAnE,oHAAA,uBAAuB,OAAA;AAAE,iHAAA,oBAAoB,OAAA;AAOtD,qDAAwD;AAA/C,sHAAA,mBAAmB,OAAA;AAC5B,mDAAmE;AAA1D,gHAAA,cAAc,OAAA;AAAE,iHAAA,eAAe,OAAA"}
|
|
@@ -10,16 +10,22 @@
|
|
|
10
10
|
* plus optional rich events (intent, usage, tool_complete_rich,
|
|
11
11
|
* subagent_start, subagent_end, permission).
|
|
12
12
|
*/
|
|
13
|
+
import type { Logger } from '../../src/types';
|
|
13
14
|
import type { CopilotBackend, CopilotSession, SessionConfig, SessionCreationOptions } from './copilot-backend';
|
|
15
|
+
import type { SubagentRoster } from './subagents';
|
|
14
16
|
export interface SdkBackendOptions {
|
|
15
17
|
/** Path to .copilot/mcp.json for MCP server configuration. */
|
|
16
|
-
mcpConfigPath?: string;
|
|
18
|
+
readonly mcpConfigPath?: string;
|
|
17
19
|
/** Extra directories to add to PATH (e.g. .tools/bin). */
|
|
18
|
-
extraPathDirs?: readonly string[];
|
|
20
|
+
readonly extraPathDirs?: readonly string[];
|
|
19
21
|
/** Additional tool names to resolve and add to PATH (e.g. ['az', 'dotnet']). */
|
|
20
|
-
pathTools?: readonly string[];
|
|
21
|
-
/**
|
|
22
|
-
configDir?: string;
|
|
22
|
+
readonly pathTools?: readonly string[];
|
|
23
|
+
/** Existing Copilot home/config directory passed through to the SDK untouched. */
|
|
24
|
+
readonly configDir?: string;
|
|
25
|
+
/** Opt-in per-agent overrides merged over the stable default roster; omit or pass false for no roster. */
|
|
26
|
+
readonly subagentRoster?: SubagentRoster | false;
|
|
27
|
+
/** Receives non-fatal backend diagnostics. */
|
|
28
|
+
readonly logger?: Logger;
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
25
31
|
* CopilotBackend implementation using @github/copilot-sdk.
|
|
@@ -31,9 +37,11 @@ export interface SdkBackendOptions {
|
|
|
31
37
|
export declare class SdkBackend implements CopilotBackend {
|
|
32
38
|
readonly name = "sdk";
|
|
33
39
|
private readonly mcpConfigPath;
|
|
34
|
-
private readonly
|
|
40
|
+
private readonly configDirectory;
|
|
41
|
+
private readonly subagentRoster;
|
|
35
42
|
private readonly extraPathDirs;
|
|
36
43
|
private readonly pathTools;
|
|
44
|
+
private readonly logger;
|
|
37
45
|
constructor(options?: SdkBackendOptions);
|
|
38
46
|
isAvailable(): Promise<boolean>;
|
|
39
47
|
createSession(config: SessionConfig, options?: SessionCreationOptions): Promise<CopilotSession>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-backend.d.ts","sourceRoot":"","sources":["../../../runtimes/copilot/sdk-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"sdk-backend.d.ts","sourceRoot":"","sources":["../../../runtimes/copilot/sdk-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,sBAAsB,EAIvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMlD,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,gFAAgF;IAChF,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,kFAAkF;IAClF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,0GAA0G;IAC1G,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,KAAK,CAAC;IACjD,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AA6OD;;;;;;GAMG;AACH,qBAAa,UAAW,YAAW,cAAc;IAC/C,QAAQ,CAAC,IAAI,SAAS;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IACrD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAqC;IACpE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IAClD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,OAAO,GAAE,iBAAsB;IASrC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAY/B,aAAa,CACjB,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,cAAc,CAAC;CAc3B"}
|
|
@@ -49,7 +49,20 @@ exports.SdkBackend = void 0;
|
|
|
49
49
|
const cp = __importStar(require("child_process"));
|
|
50
50
|
const fs = __importStar(require("fs"));
|
|
51
51
|
const path = __importStar(require("path"));
|
|
52
|
+
const types_1 = require("../../src/types");
|
|
52
53
|
const lifecycle_events_1 = require("./lifecycle-events");
|
|
54
|
+
const subagents_1 = require("./subagents");
|
|
55
|
+
function normalizeSdkEvent(event) {
|
|
56
|
+
if (typeof event !== 'object' || event === null)
|
|
57
|
+
return {};
|
|
58
|
+
const candidate = event;
|
|
59
|
+
return {
|
|
60
|
+
...(typeof candidate.type === 'string' ? { type: candidate.type } : {}),
|
|
61
|
+
...(typeof candidate.data === 'object' && candidate.data !== null
|
|
62
|
+
? { data: candidate.data }
|
|
63
|
+
: {}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
53
66
|
const NAMED_SDK_EVENTS = new Set([
|
|
54
67
|
'assistant.message', 'assistant.message_delta',
|
|
55
68
|
'assistant.reasoning', 'assistant.reasoning_delta',
|
|
@@ -119,24 +132,75 @@ function extractArgSummary(args) {
|
|
|
119
132
|
* Parse .copilot/mcp.json format and convert to SDK-compatible MCPServerConfig.
|
|
120
133
|
* Adds `tools: ["*"]` to each entry to enable all tools.
|
|
121
134
|
*/
|
|
135
|
+
function stringArray(value) {
|
|
136
|
+
return Array.isArray(value) && value.every((item) => typeof item === 'string')
|
|
137
|
+
? value
|
|
138
|
+
: undefined;
|
|
139
|
+
}
|
|
140
|
+
function stringRecord(value) {
|
|
141
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
142
|
+
return undefined;
|
|
143
|
+
const entries = Object.entries(value);
|
|
144
|
+
return entries.every((entry) => typeof entry[1] === 'string')
|
|
145
|
+
? Object.fromEntries(entries)
|
|
146
|
+
: undefined;
|
|
147
|
+
}
|
|
148
|
+
function nonNegativeFiniteNumber(value) {
|
|
149
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0
|
|
150
|
+
? value
|
|
151
|
+
: undefined;
|
|
152
|
+
}
|
|
153
|
+
function parseMcpServer(value, forceAllTools = false) {
|
|
154
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
155
|
+
return undefined;
|
|
156
|
+
const entry = value;
|
|
157
|
+
const configuredTools = stringArray(entry.tools);
|
|
158
|
+
const tools = forceAllTools ? ['*'] : configuredTools;
|
|
159
|
+
const timeout = nonNegativeFiniteNumber(entry.timeout);
|
|
160
|
+
if (entry.type === 'http' || entry.type === 'sse') {
|
|
161
|
+
if (typeof entry.url !== 'string')
|
|
162
|
+
return undefined;
|
|
163
|
+
const headers = stringRecord(entry.headers);
|
|
164
|
+
return {
|
|
165
|
+
type: entry.type,
|
|
166
|
+
url: entry.url,
|
|
167
|
+
...(headers !== undefined ? { headers } : {}),
|
|
168
|
+
...(tools !== undefined ? { tools } : {}),
|
|
169
|
+
...(timeout !== undefined ? { timeout } : {}),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (typeof entry.command !== 'string')
|
|
173
|
+
return undefined;
|
|
174
|
+
const args = stringArray(entry.args);
|
|
175
|
+
const env = stringRecord(entry.env);
|
|
176
|
+
return {
|
|
177
|
+
type: entry.type === 'stdio' ? 'stdio' : 'local',
|
|
178
|
+
command: entry.command,
|
|
179
|
+
...(args !== undefined ? { args } : {}),
|
|
180
|
+
...(env !== undefined ? { env } : {}),
|
|
181
|
+
...(typeof entry.workingDirectory === 'string'
|
|
182
|
+
? { workingDirectory: entry.workingDirectory }
|
|
183
|
+
: {}),
|
|
184
|
+
...(tools !== undefined ? { tools } : {}),
|
|
185
|
+
...(timeout !== undefined ? { timeout } : {}),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
122
188
|
function parseMcpConfig(configPath) {
|
|
123
189
|
try {
|
|
124
190
|
if (!fs.existsSync(configPath))
|
|
125
191
|
return null;
|
|
126
192
|
const raw = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
127
|
-
|
|
128
|
-
|
|
193
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
194
|
+
return null;
|
|
195
|
+
const root = raw;
|
|
196
|
+
const servers = root.mcpServers ?? root.servers ?? root;
|
|
197
|
+
if (!servers || typeof servers !== 'object' || Array.isArray(servers))
|
|
129
198
|
return null;
|
|
130
199
|
const result = {};
|
|
131
200
|
for (const [name, config] of Object.entries(servers)) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
result[name] = {
|
|
136
|
-
...entry,
|
|
137
|
-
type: entry.type === 'stdio' ? 'local' : (entry.type ?? 'local'),
|
|
138
|
-
tools: ['*'],
|
|
139
|
-
};
|
|
201
|
+
const parsed = parseMcpServer(config, true);
|
|
202
|
+
if (parsed)
|
|
203
|
+
result[name] = parsed;
|
|
140
204
|
}
|
|
141
205
|
return Object.keys(result).length > 0 ? result : null;
|
|
142
206
|
}
|
|
@@ -145,6 +209,34 @@ function parseMcpConfig(configPath) {
|
|
|
145
209
|
return null;
|
|
146
210
|
}
|
|
147
211
|
}
|
|
212
|
+
function toSdkMcpServers(servers) {
|
|
213
|
+
if (servers === undefined)
|
|
214
|
+
return undefined;
|
|
215
|
+
const converted = {};
|
|
216
|
+
for (const [name, server] of Object.entries(servers)) {
|
|
217
|
+
const parsed = parseMcpServer(server);
|
|
218
|
+
if (parsed)
|
|
219
|
+
converted[name] = parsed;
|
|
220
|
+
}
|
|
221
|
+
return converted;
|
|
222
|
+
}
|
|
223
|
+
function toSdkCustomAgent(agent) {
|
|
224
|
+
return {
|
|
225
|
+
name: agent.name,
|
|
226
|
+
prompt: agent.prompt,
|
|
227
|
+
...(agent.displayName !== undefined ? { displayName: agent.displayName } : {}),
|
|
228
|
+
...(agent.description !== undefined ? { description: agent.description } : {}),
|
|
229
|
+
...(agent.tools !== undefined
|
|
230
|
+
? { tools: agent.tools === null ? null : [...agent.tools] }
|
|
231
|
+
: {}),
|
|
232
|
+
...(agent.mcpServers !== undefined
|
|
233
|
+
? { mcpServers: toSdkMcpServers(agent.mcpServers) }
|
|
234
|
+
: {}),
|
|
235
|
+
...(agent.infer !== undefined ? { infer: agent.infer } : {}),
|
|
236
|
+
...(agent.skills !== undefined ? { skills: [...agent.skills] } : {}),
|
|
237
|
+
...(agent.model !== undefined ? { model: agent.model } : {}),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
148
240
|
// ---------------------------------------------------------------------------
|
|
149
241
|
// SdkBackend
|
|
150
242
|
// ---------------------------------------------------------------------------
|
|
@@ -158,14 +250,18 @@ function parseMcpConfig(configPath) {
|
|
|
158
250
|
class SdkBackend {
|
|
159
251
|
name = 'sdk';
|
|
160
252
|
mcpConfigPath;
|
|
161
|
-
|
|
253
|
+
configDirectory;
|
|
254
|
+
subagentRoster;
|
|
162
255
|
extraPathDirs;
|
|
163
256
|
pathTools;
|
|
257
|
+
logger;
|
|
164
258
|
constructor(options = {}) {
|
|
165
259
|
this.mcpConfigPath = options.mcpConfigPath;
|
|
166
|
-
this.
|
|
260
|
+
this.configDirectory = options.configDir;
|
|
261
|
+
this.subagentRoster = options.subagentRoster;
|
|
167
262
|
this.extraPathDirs = options.extraPathDirs ?? [];
|
|
168
263
|
this.pathTools = options.pathTools ?? [];
|
|
264
|
+
this.logger = options.logger ?? types_1.NO_OP_LOGGER;
|
|
169
265
|
}
|
|
170
266
|
async isAvailable() {
|
|
171
267
|
try {
|
|
@@ -183,7 +279,7 @@ class SdkBackend {
|
|
|
183
279
|
if (options?.signal?.aborted) {
|
|
184
280
|
throw new Error('Session creation aborted');
|
|
185
281
|
}
|
|
186
|
-
return new SdkSession(config, this.mcpConfigPath, this.
|
|
282
|
+
return new SdkSession(config, this.mcpConfigPath, this.configDirectory, this.subagentRoster, this.extraPathDirs, this.pathTools, this.logger);
|
|
187
283
|
}
|
|
188
284
|
}
|
|
189
285
|
exports.SdkBackend = SdkBackend;
|
|
@@ -206,9 +302,11 @@ class SdkSession {
|
|
|
206
302
|
handlers = [];
|
|
207
303
|
config;
|
|
208
304
|
mcpConfigPath;
|
|
209
|
-
|
|
305
|
+
configDirectory;
|
|
306
|
+
backendRoster;
|
|
210
307
|
extraPathDirs;
|
|
211
308
|
pathTools;
|
|
309
|
+
logger;
|
|
212
310
|
timeoutTimer = null;
|
|
213
311
|
heartbeatTimer = null;
|
|
214
312
|
compactionTimer = null;
|
|
@@ -239,12 +337,14 @@ class SdkSession {
|
|
|
239
337
|
// SDK manages the CLI process internally; no direct PID access
|
|
240
338
|
return null;
|
|
241
339
|
}
|
|
242
|
-
constructor(config, mcpConfigPath,
|
|
340
|
+
constructor(config, mcpConfigPath, configDirectory, backendRoster, extraPathDirs, pathTools, logger) {
|
|
243
341
|
this.config = config;
|
|
244
342
|
this.mcpConfigPath = mcpConfigPath;
|
|
245
|
-
this.
|
|
343
|
+
this.configDirectory = configDirectory;
|
|
344
|
+
this.backendRoster = backendRoster;
|
|
246
345
|
this.extraPathDirs = extraPathDirs;
|
|
247
346
|
this.pathTools = pathTools;
|
|
347
|
+
this.logger = logger;
|
|
248
348
|
}
|
|
249
349
|
/**
|
|
250
350
|
* Send a prompt to the agent. Creates the SDK client and session on first call.
|
|
@@ -279,7 +379,7 @@ class SdkSession {
|
|
|
279
379
|
const sdkModuleName = '@github/copilot-sdk';
|
|
280
380
|
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
281
381
|
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
282
|
-
const { CopilotClient, approveAll } = await dynamicImport(sdkModuleName);
|
|
382
|
+
const { CopilotClient, RuntimeConnection, approveAll } = await dynamicImport(sdkModuleName);
|
|
283
383
|
// ---------------------------------------------------------------
|
|
284
384
|
// Build hardened environment (strip NODE_OPTIONS, extend PATH)
|
|
285
385
|
// ---------------------------------------------------------------
|
|
@@ -302,8 +402,7 @@ class SdkSession {
|
|
|
302
402
|
// Create CopilotClient (process-per-session: new client each time)
|
|
303
403
|
// ---------------------------------------------------------------
|
|
304
404
|
const client = new CopilotClient({
|
|
305
|
-
|
|
306
|
-
autoRestart: false, // deprecated in SDK 0.2.0 (no-op), kept for defensive clarity
|
|
405
|
+
connection: RuntimeConnection.forStdio(),
|
|
307
406
|
env,
|
|
308
407
|
logLevel: 'warning',
|
|
309
408
|
});
|
|
@@ -311,71 +410,72 @@ class SdkSession {
|
|
|
311
410
|
// ---------------------------------------------------------------
|
|
312
411
|
// Create SDK session
|
|
313
412
|
// ---------------------------------------------------------------
|
|
413
|
+
const sessionRoster = this.config.subagentRoster;
|
|
414
|
+
let roster;
|
|
415
|
+
if (sessionRoster === false || (sessionRoster === undefined && this.backendRoster === false)) {
|
|
416
|
+
roster = false;
|
|
417
|
+
}
|
|
418
|
+
else if (sessionRoster !== undefined
|
|
419
|
+
&& this.backendRoster !== undefined
|
|
420
|
+
&& this.backendRoster !== false) {
|
|
421
|
+
roster = (0, subagents_1.mergeSubagentRosters)(subagents_1.DEFAULT_SUBAGENT_ROSTER, (0, subagents_1.mergeSubagentRosters)(this.backendRoster, sessionRoster));
|
|
422
|
+
}
|
|
423
|
+
else if (sessionRoster !== undefined) {
|
|
424
|
+
roster = (0, subagents_1.mergeSubagentRosters)(subagents_1.DEFAULT_SUBAGENT_ROSTER, sessionRoster);
|
|
425
|
+
}
|
|
426
|
+
else if (this.backendRoster !== undefined && this.backendRoster !== false) {
|
|
427
|
+
roster = (0, subagents_1.mergeSubagentRosters)(subagents_1.DEFAULT_SUBAGENT_ROSTER, this.backendRoster);
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
roster = this.backendRoster;
|
|
431
|
+
}
|
|
314
432
|
const sessionConfig = {
|
|
315
433
|
model: this.config.model,
|
|
316
434
|
streaming: true,
|
|
317
435
|
onPermissionRequest: approveAll,
|
|
318
436
|
workingDirectory: this.config.cwd,
|
|
319
437
|
reasoningEffort: this.config.thinkingBudget,
|
|
438
|
+
...(this.config.contextTier !== undefined
|
|
439
|
+
? { contextTier: this.config.contextTier }
|
|
440
|
+
: {}),
|
|
441
|
+
...(this.configDirectory !== undefined
|
|
442
|
+
? { configDirectory: this.configDirectory }
|
|
443
|
+
: {}),
|
|
444
|
+
...(this.config.systemMessage !== undefined
|
|
445
|
+
? { systemMessage: { mode: 'append', content: this.config.systemMessage } }
|
|
446
|
+
: {}),
|
|
447
|
+
...(this.config.availableTools !== undefined
|
|
448
|
+
? { availableTools: [...this.config.availableTools] }
|
|
449
|
+
: {}),
|
|
450
|
+
...(this.config.excludedTools !== undefined
|
|
451
|
+
? { excludedTools: [...this.config.excludedTools] }
|
|
452
|
+
: {}),
|
|
453
|
+
...(this.config.customAgents !== undefined
|
|
454
|
+
? { customAgents: this.config.customAgents.map(toSdkCustomAgent) }
|
|
455
|
+
: {}),
|
|
456
|
+
...(this.config.defaultAgent !== undefined
|
|
457
|
+
? {
|
|
458
|
+
defaultAgent: {
|
|
459
|
+
...(this.config.defaultAgent.excludedTools !== undefined
|
|
460
|
+
? { excludedTools: [...this.config.defaultAgent.excludedTools] }
|
|
461
|
+
: {}),
|
|
462
|
+
},
|
|
463
|
+
}
|
|
464
|
+
: {}),
|
|
465
|
+
...(this.config.excludedBuiltinAgents !== undefined
|
|
466
|
+
? { excludedBuiltinAgents: [...this.config.excludedBuiltinAgents] }
|
|
467
|
+
: {}),
|
|
468
|
+
...(mcpServers !== null ? { mcpServers } : {}),
|
|
469
|
+
// Enable infinite sessions with automatic context compaction.
|
|
470
|
+
// Without this, GPT models can go silent when the context window fills.
|
|
471
|
+
infiniteSessions: {
|
|
472
|
+
enabled: true,
|
|
473
|
+
backgroundCompactionThreshold: 0.75,
|
|
474
|
+
bufferExhaustionThreshold: 0.90,
|
|
475
|
+
},
|
|
320
476
|
// Registered before createSession issues its RPC, closing the early-event
|
|
321
|
-
// gap for session.start and *_loaded events.
|
|
322
|
-
|
|
323
|
-
// future failure-shaped events without duplicating named event output.
|
|
324
|
-
onEvent: (e) => this.handleEarlyEvent(e),
|
|
325
|
-
};
|
|
326
|
-
if (this.config.contextTier) {
|
|
327
|
-
sessionConfig.contextTier = this.config.contextTier;
|
|
328
|
-
}
|
|
329
|
-
// CLI 1.0.11+ discovers MCP servers, skills, and custom instructions from
|
|
330
|
-
// configDir. Without this, the CLI searches workingDirectory (which is often
|
|
331
|
-
// a temp execution dir) and fails to find the project's .copilot/ config.
|
|
332
|
-
if (this.configDir) {
|
|
333
|
-
sessionConfig.configDir = this.configDir;
|
|
334
|
-
}
|
|
335
|
-
if (this.config.systemMessage) {
|
|
336
|
-
sessionConfig.systemMessage = {
|
|
337
|
-
mode: 'append',
|
|
338
|
-
content: this.config.systemMessage,
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
if (this.config.availableTools) {
|
|
342
|
-
sessionConfig.availableTools = [...this.config.availableTools];
|
|
343
|
-
}
|
|
344
|
-
if (this.config.excludedTools) {
|
|
345
|
-
sessionConfig.excludedTools = [...this.config.excludedTools];
|
|
346
|
-
}
|
|
347
|
-
if (this.config.customAgents) {
|
|
348
|
-
sessionConfig.customAgents = this.config.customAgents.map((customAgent) => ({
|
|
349
|
-
...customAgent,
|
|
350
|
-
...(customAgent.tools !== undefined && customAgent.tools !== null
|
|
351
|
-
? { tools: [...customAgent.tools] }
|
|
352
|
-
: {}),
|
|
353
|
-
...(customAgent.skills !== undefined
|
|
354
|
-
? { skills: [...customAgent.skills] }
|
|
355
|
-
: {}),
|
|
356
|
-
}));
|
|
357
|
-
}
|
|
358
|
-
if (this.config.defaultAgent) {
|
|
359
|
-
sessionConfig.defaultAgent = {
|
|
360
|
-
...this.config.defaultAgent,
|
|
361
|
-
...(this.config.defaultAgent.excludedTools !== undefined
|
|
362
|
-
? { excludedTools: [...this.config.defaultAgent.excludedTools] }
|
|
363
|
-
: {}),
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
if (this.config.excludedBuiltinAgents) {
|
|
367
|
-
sessionConfig.excludedBuiltinAgents = [...this.config.excludedBuiltinAgents];
|
|
368
|
-
}
|
|
369
|
-
if (mcpServers) {
|
|
370
|
-
sessionConfig.mcpServers = mcpServers;
|
|
371
|
-
}
|
|
372
|
-
// Enable infinite sessions with automatic context compaction.
|
|
373
|
-
// Without this, GPT models silently stop responding after ~140 tool calls
|
|
374
|
-
// when the context window fills up (no error, no idle — just silence).
|
|
375
|
-
sessionConfig.infiniteSessions = {
|
|
376
|
-
enabled: true,
|
|
377
|
-
backgroundCompactionThreshold: 0.75,
|
|
378
|
-
bufferExhaustionThreshold: 0.90,
|
|
477
|
+
// gap for session.start and *_loaded events.
|
|
478
|
+
onEvent: (event) => this.handleEarlyEvent(normalizeSdkEvent(event)),
|
|
379
479
|
};
|
|
380
480
|
const sdkSession = await client.createSession(sessionConfig);
|
|
381
481
|
if (this.aborted) {
|
|
@@ -386,6 +486,20 @@ class SdkSession {
|
|
|
386
486
|
return;
|
|
387
487
|
}
|
|
388
488
|
this._sdkSession = sdkSession;
|
|
489
|
+
// Apply the live override before any prompt can dispatch a subagent.
|
|
490
|
+
// This experimental RPC degrades safely if the installed CLI rejects it.
|
|
491
|
+
if (roster !== undefined && roster !== false) {
|
|
492
|
+
try {
|
|
493
|
+
await sdkSession.rpc.tools.updateSubagentSettings({
|
|
494
|
+
subagents: { agents: roster },
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
catch (err) {
|
|
498
|
+
this.logger.warn('Failed to apply Copilot subagent roster; using default settings', {
|
|
499
|
+
error: err instanceof Error ? err.message : String(err),
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
}
|
|
389
503
|
// Set autopilot mode explicitly (matches SubprocessBackend's --autopilot flag)
|
|
390
504
|
try {
|
|
391
505
|
await sdkSession.rpc.mode.set({ mode: 'autopilot' });
|
|
@@ -661,7 +775,7 @@ class SdkSession {
|
|
|
661
775
|
process.stderr.write('[SdkBackend] Compaction stuck 3min — forcing compact\n');
|
|
662
776
|
}
|
|
663
777
|
catch { /* */ }
|
|
664
|
-
await session.rpc.
|
|
778
|
+
await session.rpc.history.compact();
|
|
665
779
|
// Re-check guards after await — session may have been torn down
|
|
666
780
|
if (!this.compactionInProgress || !isActive())
|
|
667
781
|
return;
|