condukt 0.7.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 +29 -7
- package/dist/runtimes/copilot/copilot-adapter.js.map +1 -1
- package/dist/runtimes/copilot/copilot-backend.d.ts +38 -1
- 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 +16 -8
- package/dist/runtimes/copilot/sdk-backend.d.ts.map +1 -1
- package/dist/runtimes/copilot/sdk-backend.js +208 -59
- 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/runtimes/copilot/subprocess-backend.d.ts +2 -2
- package/dist/runtimes/copilot/subprocess-backend.d.ts.map +1 -1
- package/dist/runtimes/copilot/subprocess-backend.js +4 -1
- package/dist/runtimes/copilot/subprocess-backend.js.map +1 -1
- package/dist/runtimes/mock/mock-runtime.d.ts +4 -4
- package/dist/runtimes/mock/mock-runtime.d.ts.map +1 -1
- package/dist/runtimes/mock/mock-runtime.js +20 -5
- package/dist/runtimes/mock/mock-runtime.js.map +1 -1
- package/dist/src/agent-node.d.ts +8 -1
- package/dist/src/agent-node.d.ts.map +1 -1
- package/dist/src/agent-node.js +31 -2
- package/dist/src/agent-node.js.map +1 -1
- package/dist/src/agent.d.ts +4 -1
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +437 -230
- package/dist/src/agent.js.map +1 -1
- package/dist/src/events.d.ts +1 -0
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/panel-node.d.ts +8 -3
- package/dist/src/panel-node.d.ts.map +1 -1
- package/dist/src/panel-node.js +96 -62
- package/dist/src/panel-node.js.map +1 -1
- package/dist/src/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler.js +79 -19
- package/dist/src/scheduler.js.map +1 -1
- package/dist/src/types.d.ts +88 -2
- 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/dist/state/reducer.js +2 -2
- package/dist/state/reducer.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,
|
|
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"}
|
|
@@ -31,24 +31,46 @@ function adaptCopilotBackend(backend) {
|
|
|
31
31
|
isAvailable() {
|
|
32
32
|
return backend.isAvailable();
|
|
33
33
|
},
|
|
34
|
-
async createSession(config) {
|
|
34
|
+
async createSession(config, options) {
|
|
35
35
|
// Map flow SessionConfig → CopilotBackend SessionConfig. Forward every
|
|
36
36
|
// field SdkBackend consumes; systemMessage (role instructions + any
|
|
37
37
|
// response schema), the tool filters, and the context tier must reach the
|
|
38
38
|
// backend or the agent runs on the default persona with no system prompt.
|
|
39
39
|
const copilotConfig = {
|
|
40
40
|
model: config.model,
|
|
41
|
-
|
|
41
|
+
...(config.thinkingBudget !== undefined
|
|
42
|
+
? { thinkingBudget: config.thinkingBudget }
|
|
43
|
+
: {}),
|
|
42
44
|
cwd: config.cwd,
|
|
43
45
|
addDirs: config.addDirs,
|
|
44
46
|
timeout: config.timeout,
|
|
45
47
|
heartbeatTimeout: config.heartbeatTimeout,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
...(config.contextTier !== undefined
|
|
49
|
+
? { contextTier: config.contextTier }
|
|
50
|
+
: {}),
|
|
51
|
+
...(config.systemMessage !== undefined
|
|
52
|
+
? { systemMessage: config.systemMessage }
|
|
53
|
+
: {}),
|
|
54
|
+
...(config.availableTools !== undefined
|
|
55
|
+
? { availableTools: config.availableTools }
|
|
56
|
+
: {}),
|
|
57
|
+
...(config.excludedTools !== undefined
|
|
58
|
+
? { excludedTools: config.excludedTools }
|
|
59
|
+
: {}),
|
|
60
|
+
...(config.customAgents !== undefined
|
|
61
|
+
? { customAgents: config.customAgents }
|
|
62
|
+
: {}),
|
|
63
|
+
...(config.subagentRoster !== undefined
|
|
64
|
+
? { subagentRoster: config.subagentRoster }
|
|
65
|
+
: {}),
|
|
66
|
+
...(config.defaultAgent !== undefined
|
|
67
|
+
? { defaultAgent: config.defaultAgent }
|
|
68
|
+
: {}),
|
|
69
|
+
...(config.excludedBuiltinAgents !== undefined
|
|
70
|
+
? { excludedBuiltinAgents: config.excludedBuiltinAgents }
|
|
71
|
+
: {}),
|
|
50
72
|
};
|
|
51
|
-
const session = await backend.createSession(copilotConfig);
|
|
73
|
+
const session = await backend.createSession(copilotConfig, options);
|
|
52
74
|
// CopilotSession and AgentSession are structurally identical —
|
|
53
75
|
// same methods, same event signatures. Direct pass-through.
|
|
54
76
|
return session;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-adapter.js","sourceRoot":"","sources":["../../../runtimes/copilot/copilot-adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;
|
|
1
|
+
{"version":3,"file":"copilot-adapter.js","sourceRoot":"","sources":["../../../runtimes/copilot/copilot-adapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAuBH,kDA0DC;AAvED;;;;;;;;;;;;GAYG;AACH,SAAgB,mBAAmB,CAAC,OAAuB;IACzD,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAElB,WAAW;YACT,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;QAC/B,CAAC;QAED,KAAK,CAAC,aAAa,CACjB,MAAqB,EACrB,OAAgC;YAEhC,uEAAuE;YACvE,oEAAoE;YACpE,0EAA0E;YAC1E,0EAA0E;YAC1E,MAAM,aAAa,GAAG;gBACpB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,GAAG,CAAC,MAAM,CAAC,cAAc,KAAK,SAAS;oBACrC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE;oBAC3C,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,SAAS;oBAClC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE;oBACrC,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,MAAM,CAAC,aAAa,KAAK,SAAS;oBACpC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE;oBACzC,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,aAAa,KAAK,SAAS;oBACpC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE;oBACzC,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,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,32 @@
|
|
|
8
8
|
*
|
|
9
9
|
* The orchestrator depends on this interface, not on any implementation.
|
|
10
10
|
*/
|
|
11
|
+
import type { SubagentRosterOption } from './subagents';
|
|
12
|
+
export interface MCPServerConfig {
|
|
13
|
+
readonly type?: string;
|
|
14
|
+
readonly command?: string;
|
|
15
|
+
readonly args?: readonly string[];
|
|
16
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
17
|
+
readonly url?: string;
|
|
18
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
19
|
+
readonly tools?: readonly string[];
|
|
20
|
+
readonly timeout?: number;
|
|
21
|
+
readonly [key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface CustomAgentConfig {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly displayName?: string;
|
|
26
|
+
readonly description?: string;
|
|
27
|
+
readonly tools?: readonly string[] | null;
|
|
28
|
+
readonly prompt: string;
|
|
29
|
+
readonly mcpServers?: Readonly<Record<string, MCPServerConfig>>;
|
|
30
|
+
readonly infer?: boolean;
|
|
31
|
+
readonly skills?: readonly string[];
|
|
32
|
+
readonly model?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface DefaultAgentConfig {
|
|
35
|
+
readonly excludedTools?: readonly string[];
|
|
36
|
+
}
|
|
11
37
|
export interface SessionConfig {
|
|
12
38
|
/** Model to use: "claude-opus-4.6", "gpt-5.4", etc. */
|
|
13
39
|
readonly model: string;
|
|
@@ -29,6 +55,14 @@ export interface SessionConfig {
|
|
|
29
55
|
readonly availableTools?: readonly string[];
|
|
30
56
|
/** Tool deny-list: these tools are excluded (SdkBackend only). */
|
|
31
57
|
readonly excludedTools?: readonly string[];
|
|
58
|
+
/** Custom subagent definitions (SdkBackend only). */
|
|
59
|
+
readonly customAgents?: readonly CustomAgentConfig[];
|
|
60
|
+
/** Stable subagent model/settings roster, or false to opt out (SdkBackend only). */
|
|
61
|
+
readonly subagentRoster?: SubagentRosterOption;
|
|
62
|
+
/** Main-agent configuration (SdkBackend only). */
|
|
63
|
+
readonly defaultAgent?: DefaultAgentConfig;
|
|
64
|
+
/** Built-in subagents unavailable to this session (SdkBackend only). */
|
|
65
|
+
readonly excludedBuiltinAgents?: readonly string[];
|
|
32
66
|
}
|
|
33
67
|
/** Token usage metrics from assistant.usage events. */
|
|
34
68
|
export interface UsageData {
|
|
@@ -99,9 +133,12 @@ export interface CopilotSession {
|
|
|
99
133
|
/** Abort the session -- kill the agent process */
|
|
100
134
|
abort(): Promise<void>;
|
|
101
135
|
}
|
|
136
|
+
export interface SessionCreationOptions {
|
|
137
|
+
readonly signal?: AbortSignal;
|
|
138
|
+
}
|
|
102
139
|
export interface CopilotBackend {
|
|
103
140
|
/** Create a new agent session with the given configuration */
|
|
104
|
-
createSession(config: SessionConfig): Promise<CopilotSession>;
|
|
141
|
+
createSession(config: SessionConfig, options?: SessionCreationOptions): Promise<CopilotSession>;
|
|
105
142
|
/** Check if copilot CLI is available */
|
|
106
143
|
isAvailable(): Promise<boolean>;
|
|
107
144
|
/** Get the backend type name (for logging) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-backend.d.ts","sourceRoot":"","sources":["../../../runtimes/copilot/copilot-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,QAAQ,CAAC,cAAc,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAC9D,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;IAClD,kDAAkD;IAClD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,yEAAyE;IACzE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,yEAAyE;IACzE,QAAQ,CAAC,cAAc,CA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AAE,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 {
|
|
13
|
+
import type { Logger } from '../../src/types';
|
|
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,11 +37,13 @@ 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
|
-
createSession(config: SessionConfig): Promise<CopilotSession>;
|
|
47
|
+
createSession(config: SessionConfig, options?: SessionCreationOptions): Promise<CopilotSession>;
|
|
40
48
|
}
|
|
41
49
|
//# sourceMappingURL=sdk-backend.d.ts.map
|
|
@@ -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 {
|
|
@@ -179,8 +275,11 @@ class SdkBackend {
|
|
|
179
275
|
return false;
|
|
180
276
|
}
|
|
181
277
|
}
|
|
182
|
-
async createSession(config) {
|
|
183
|
-
|
|
278
|
+
async createSession(config, options) {
|
|
279
|
+
if (options?.signal?.aborted) {
|
|
280
|
+
throw new Error('Session creation aborted');
|
|
281
|
+
}
|
|
282
|
+
return new SdkSession(config, this.mcpConfigPath, this.configDirectory, this.subagentRoster, this.extraPathDirs, this.pathTools, this.logger);
|
|
184
283
|
}
|
|
185
284
|
}
|
|
186
285
|
exports.SdkBackend = SdkBackend;
|
|
@@ -203,9 +302,11 @@ class SdkSession {
|
|
|
203
302
|
handlers = [];
|
|
204
303
|
config;
|
|
205
304
|
mcpConfigPath;
|
|
206
|
-
|
|
305
|
+
configDirectory;
|
|
306
|
+
backendRoster;
|
|
207
307
|
extraPathDirs;
|
|
208
308
|
pathTools;
|
|
309
|
+
logger;
|
|
209
310
|
timeoutTimer = null;
|
|
210
311
|
heartbeatTimer = null;
|
|
211
312
|
compactionTimer = null;
|
|
@@ -236,12 +337,14 @@ class SdkSession {
|
|
|
236
337
|
// SDK manages the CLI process internally; no direct PID access
|
|
237
338
|
return null;
|
|
238
339
|
}
|
|
239
|
-
constructor(config, mcpConfigPath,
|
|
340
|
+
constructor(config, mcpConfigPath, configDirectory, backendRoster, extraPathDirs, pathTools, logger) {
|
|
240
341
|
this.config = config;
|
|
241
342
|
this.mcpConfigPath = mcpConfigPath;
|
|
242
|
-
this.
|
|
343
|
+
this.configDirectory = configDirectory;
|
|
344
|
+
this.backendRoster = backendRoster;
|
|
243
345
|
this.extraPathDirs = extraPathDirs;
|
|
244
346
|
this.pathTools = pathTools;
|
|
347
|
+
this.logger = logger;
|
|
245
348
|
}
|
|
246
349
|
/**
|
|
247
350
|
* Send a prompt to the agent. Creates the SDK client and session on first call.
|
|
@@ -276,7 +379,7 @@ class SdkSession {
|
|
|
276
379
|
const sdkModuleName = '@github/copilot-sdk';
|
|
277
380
|
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
278
381
|
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
279
|
-
const { CopilotClient, approveAll } = await dynamicImport(sdkModuleName);
|
|
382
|
+
const { CopilotClient, RuntimeConnection, approveAll } = await dynamicImport(sdkModuleName);
|
|
280
383
|
// ---------------------------------------------------------------
|
|
281
384
|
// Build hardened environment (strip NODE_OPTIONS, extend PATH)
|
|
282
385
|
// ---------------------------------------------------------------
|
|
@@ -299,8 +402,7 @@ class SdkSession {
|
|
|
299
402
|
// Create CopilotClient (process-per-session: new client each time)
|
|
300
403
|
// ---------------------------------------------------------------
|
|
301
404
|
const client = new CopilotClient({
|
|
302
|
-
|
|
303
|
-
autoRestart: false, // deprecated in SDK 0.2.0 (no-op), kept for defensive clarity
|
|
405
|
+
connection: RuntimeConnection.forStdio(),
|
|
304
406
|
env,
|
|
305
407
|
logLevel: 'warning',
|
|
306
408
|
});
|
|
@@ -308,49 +410,72 @@ class SdkSession {
|
|
|
308
410
|
// ---------------------------------------------------------------
|
|
309
411
|
// Create SDK session
|
|
310
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
|
+
}
|
|
311
432
|
const sessionConfig = {
|
|
312
433
|
model: this.config.model,
|
|
313
434
|
streaming: true,
|
|
314
435
|
onPermissionRequest: approveAll,
|
|
315
436
|
workingDirectory: this.config.cwd,
|
|
316
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
|
+
},
|
|
317
476
|
// Registered before createSession issues its RPC, closing the early-event
|
|
318
|
-
// gap for session.start and *_loaded events.
|
|
319
|
-
|
|
320
|
-
// future failure-shaped events without duplicating named event output.
|
|
321
|
-
onEvent: (e) => this.handleEarlyEvent(e),
|
|
322
|
-
};
|
|
323
|
-
if (this.config.contextTier) {
|
|
324
|
-
sessionConfig.contextTier = this.config.contextTier;
|
|
325
|
-
}
|
|
326
|
-
// CLI 1.0.11+ discovers MCP servers, skills, and custom instructions from
|
|
327
|
-
// configDir. Without this, the CLI searches workingDirectory (which is often
|
|
328
|
-
// a temp execution dir) and fails to find the project's .copilot/ config.
|
|
329
|
-
if (this.configDir) {
|
|
330
|
-
sessionConfig.configDir = this.configDir;
|
|
331
|
-
}
|
|
332
|
-
if (this.config.systemMessage) {
|
|
333
|
-
sessionConfig.systemMessage = {
|
|
334
|
-
mode: 'append',
|
|
335
|
-
content: this.config.systemMessage,
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
if (this.config.availableTools) {
|
|
339
|
-
sessionConfig.availableTools = [...this.config.availableTools];
|
|
340
|
-
}
|
|
341
|
-
if (this.config.excludedTools) {
|
|
342
|
-
sessionConfig.excludedTools = [...this.config.excludedTools];
|
|
343
|
-
}
|
|
344
|
-
if (mcpServers) {
|
|
345
|
-
sessionConfig.mcpServers = mcpServers;
|
|
346
|
-
}
|
|
347
|
-
// Enable infinite sessions with automatic context compaction.
|
|
348
|
-
// Without this, GPT models silently stop responding after ~140 tool calls
|
|
349
|
-
// when the context window fills up (no error, no idle — just silence).
|
|
350
|
-
sessionConfig.infiniteSessions = {
|
|
351
|
-
enabled: true,
|
|
352
|
-
backgroundCompactionThreshold: 0.75,
|
|
353
|
-
bufferExhaustionThreshold: 0.90,
|
|
477
|
+
// gap for session.start and *_loaded events.
|
|
478
|
+
onEvent: (event) => this.handleEarlyEvent(normalizeSdkEvent(event)),
|
|
354
479
|
};
|
|
355
480
|
const sdkSession = await client.createSession(sessionConfig);
|
|
356
481
|
if (this.aborted) {
|
|
@@ -361,6 +486,20 @@ class SdkSession {
|
|
|
361
486
|
return;
|
|
362
487
|
}
|
|
363
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
|
+
}
|
|
364
503
|
// Set autopilot mode explicitly (matches SubprocessBackend's --autopilot flag)
|
|
365
504
|
try {
|
|
366
505
|
await sdkSession.rpc.mode.set({ mode: 'autopilot' });
|
|
@@ -592,8 +731,18 @@ class SdkSession {
|
|
|
592
731
|
: typeof data?.errorCode === 'string'
|
|
593
732
|
? data.errorCode
|
|
594
733
|
: 'Unknown model call failure';
|
|
595
|
-
const
|
|
596
|
-
|
|
734
|
+
const rawStatusCode = data?.statusCode;
|
|
735
|
+
const statusCode = typeof rawStatusCode === 'number' || typeof rawStatusCode === 'string'
|
|
736
|
+
? rawStatusCode
|
|
737
|
+
: undefined;
|
|
738
|
+
const errorCode = typeof data?.errorCode === 'string' ? data.errorCode : undefined;
|
|
739
|
+
const status = statusCode !== undefined ? ` (HTTP ${statusCode})` : '';
|
|
740
|
+
const error = new Error(`Model call failed${status}: ${detail}`);
|
|
741
|
+
if (statusCode !== undefined)
|
|
742
|
+
Object.assign(error, { statusCode });
|
|
743
|
+
if (errorCode !== undefined)
|
|
744
|
+
Object.assign(error, { errorCode });
|
|
745
|
+
this.fail(error, 'model.call_failure', data);
|
|
597
746
|
});
|
|
598
747
|
// --- Context compaction (infinite sessions) ---
|
|
599
748
|
// During compaction the model goes silent. SUSPEND the heartbeat entirely
|
|
@@ -626,7 +775,7 @@ class SdkSession {
|
|
|
626
775
|
process.stderr.write('[SdkBackend] Compaction stuck 3min — forcing compact\n');
|
|
627
776
|
}
|
|
628
777
|
catch { /* */ }
|
|
629
|
-
await session.rpc.
|
|
778
|
+
await session.rpc.history.compact();
|
|
630
779
|
// Re-check guards after await — session may have been torn down
|
|
631
780
|
if (!this.compactionInProgress || !isActive())
|
|
632
781
|
return;
|