poly-weaver 0.12.4 → 0.12.5

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.
Files changed (87) hide show
  1. package/dist/agents/runner.d.ts +2 -0
  2. package/dist/agents/runner.d.ts.map +1 -1
  3. package/dist/agents/runner.js +10 -0
  4. package/dist/agents/runner.js.map +1 -1
  5. package/dist/agents/session-resume.d.ts +3 -2
  6. package/dist/agents/session-resume.d.ts.map +1 -1
  7. package/dist/agents/session-resume.js +10 -3
  8. package/dist/agents/session-resume.js.map +1 -1
  9. package/dist/agents/simplifiers/index.d.ts.map +1 -1
  10. package/dist/agents/simplifiers/index.js +1 -5
  11. package/dist/agents/simplifiers/index.js.map +1 -1
  12. package/dist/auto-update/check-agent-updates.d.ts +1 -0
  13. package/dist/auto-update/check-agent-updates.d.ts.map +1 -1
  14. package/dist/auto-update/check-agent-updates.js +80 -8
  15. package/dist/auto-update/check-agent-updates.js.map +1 -1
  16. package/dist/auto-update/detect-agents.d.ts +1 -0
  17. package/dist/auto-update/detect-agents.d.ts.map +1 -1
  18. package/dist/auto-update/detect-agents.js +1 -1
  19. package/dist/auto-update/detect-agents.js.map +1 -1
  20. package/dist/auto-update/install-agents.js +4 -1
  21. package/dist/auto-update/install-agents.js.map +1 -1
  22. package/dist/offscreen/controller.d.ts.map +1 -1
  23. package/dist/offscreen/controller.js +8 -5
  24. package/dist/offscreen/controller.js.map +1 -1
  25. package/dist/offscreen/fork-busy.d.ts +3 -20
  26. package/dist/offscreen/fork-busy.d.ts.map +1 -1
  27. package/dist/offscreen/fork-busy.js +7 -76
  28. package/dist/offscreen/fork-busy.js.map +1 -1
  29. package/dist/offscreen/fork-launch.d.ts +3 -34
  30. package/dist/offscreen/fork-launch.d.ts.map +1 -1
  31. package/dist/offscreen/fork-launch.js +4 -102
  32. package/dist/offscreen/fork-launch.js.map +1 -1
  33. package/dist/providers/claude/strategy.d.ts +10 -1
  34. package/dist/providers/claude/strategy.d.ts.map +1 -1
  35. package/dist/providers/claude/strategy.js +128 -2
  36. package/dist/providers/claude/strategy.js.map +1 -1
  37. package/dist/providers/claude/trust.d.ts +2 -0
  38. package/dist/providers/claude/trust.d.ts.map +1 -0
  39. package/dist/providers/claude/trust.js +22 -0
  40. package/dist/providers/claude/trust.js.map +1 -0
  41. package/dist/providers/codex/config.js +1 -1
  42. package/dist/providers/codex/config.js.map +1 -1
  43. package/dist/providers/codex/strategy.d.ts +7 -1
  44. package/dist/providers/codex/strategy.d.ts.map +1 -1
  45. package/dist/providers/codex/strategy.js +83 -2
  46. package/dist/providers/codex/strategy.js.map +1 -1
  47. package/dist/providers/codex/trust.d.ts +2 -0
  48. package/dist/providers/codex/trust.d.ts.map +1 -0
  49. package/dist/providers/codex/trust.js +92 -0
  50. package/dist/providers/codex/trust.js.map +1 -0
  51. package/dist/providers/copilot/completion.d.ts +5 -3
  52. package/dist/providers/copilot/completion.d.ts.map +1 -1
  53. package/dist/providers/copilot/completion.js +188 -16
  54. package/dist/providers/copilot/completion.js.map +1 -1
  55. package/dist/providers/copilot/strategy.d.ts +9 -1
  56. package/dist/providers/copilot/strategy.d.ts.map +1 -1
  57. package/dist/providers/copilot/strategy.js +138 -2
  58. package/dist/providers/copilot/strategy.js.map +1 -1
  59. package/dist/providers/copilot/trust.d.ts +2 -0
  60. package/dist/providers/copilot/trust.d.ts.map +1 -0
  61. package/dist/providers/copilot/trust.js +45 -0
  62. package/dist/providers/copilot/trust.js.map +1 -0
  63. package/dist/providers/fork.d.ts +64 -0
  64. package/dist/providers/fork.d.ts.map +1 -0
  65. package/dist/providers/fork.js +2 -0
  66. package/dist/providers/fork.js.map +1 -0
  67. package/dist/providers/index.d.ts +2 -1
  68. package/dist/providers/index.d.ts.map +1 -1
  69. package/dist/providers/option-catalog.d.ts.map +1 -1
  70. package/dist/providers/option-catalog.js +14 -129
  71. package/dist/providers/option-catalog.js.map +1 -1
  72. package/dist/providers/trust-utils.d.ts +7 -0
  73. package/dist/providers/trust-utils.d.ts.map +1 -0
  74. package/dist/providers/trust-utils.js +49 -0
  75. package/dist/providers/trust-utils.js.map +1 -0
  76. package/dist/providers/trust.d.ts +1 -4
  77. package/dist/providers/trust.d.ts.map +1 -1
  78. package/dist/providers/trust.js +3 -204
  79. package/dist/providers/trust.js.map +1 -1
  80. package/dist/providers/types.d.ts +25 -0
  81. package/dist/providers/types.d.ts.map +1 -1
  82. package/dist/providers/types.js.map +1 -1
  83. package/package.json +1 -1
  84. package/dist/agents/simplifiers/prompts.d.ts +0 -11
  85. package/dist/agents/simplifiers/prompts.d.ts.map +0 -1
  86. package/dist/agents/simplifiers/prompts.js +0 -24
  87. package/dist/agents/simplifiers/prompts.js.map +0 -1
@@ -1,19 +1,47 @@
1
1
  import { countLines, latestLineIndex } from "../../session/reader.js";
2
2
  import { extractCopilotResponse } from "./session.js";
3
3
  import { AbstractCompletionDetector } from "../base-completion.js";
4
+ import { isRecord } from "../trust-utils.js";
5
+ const BACKGROUND_AGENT_LAUNCH_TOOLS = new Set(["task"]);
6
+ const BACKGROUND_AGENT_READ_TOOLS = new Set(["read_agent"]);
7
+ const BACKGROUND_SHELL_SIGNAL_TOOLS = new Set([
8
+ "powershell",
9
+ "bash",
10
+ "read_powershell",
11
+ "read_bash",
12
+ ]);
4
13
  export function isCopilotTurnComplete(lines) {
5
- let lastTurnStart = -1;
6
- let lastTurnEnd = -1;
7
- for (let i = 0; i < lines.length; i++) {
14
+ const { lastTurnStart, lastTurnEnd } = latestCopilotTurnBoundary(lines);
15
+ return lastTurnStart !== -1 && lastTurnEnd > lastTurnStart;
16
+ }
17
+ export function isCopilotTurnSettled(lines) {
18
+ const turn = latestCopilotTurnBoundary(lines);
19
+ if (turn.lastTurnStart === -1 || turn.lastTurnEnd <= turn.lastTurnStart) {
20
+ return false;
21
+ }
22
+ return outstandingBackgroundWork(lines, turn.lastTurnEnd).size === 0;
23
+ }
24
+ export function outstandingBackgroundWork(lines, endIdx = lines.length) {
25
+ const launched = new Set();
26
+ const completed = new Set();
27
+ const lastIdx = Math.min(endIdx, lines.length - 1);
28
+ const toolNamesByCallId = toolNamesByCallIdUpTo(lines, lastIdx);
29
+ for (let i = 0; i <= lastIdx; i++) {
8
30
  const line = lines[i];
9
- if (line.type === "assistant.turn_start") {
10
- lastTurnStart = i;
11
- }
12
- else if (line.type === "assistant.turn_end") {
13
- lastTurnEnd = i;
14
- }
31
+ const producingToolName = producingToolNameForCompletion(line, toolNamesByCallId);
32
+ const launchKey = backgroundLaunchKey(line, producingToolName);
33
+ if (launchKey)
34
+ launched.add(launchKey);
35
+ const completionKey = backgroundCompletionKey(line) ??
36
+ backgroundReadCompletionKey(line, producingToolName) ??
37
+ backgroundTerminationKey(line);
38
+ if (completionKey)
39
+ completed.add(completionKey);
15
40
  }
16
- return lastTurnStart !== -1 && lastTurnEnd > lastTurnStart;
41
+ for (const key of completed) {
42
+ launched.delete(key);
43
+ }
44
+ return launched;
17
45
  }
18
46
  export function latestCopilotSubmitIndex(lines) {
19
47
  return latestLineIndex(lines, isCopilotTurnInitiatingUserLine);
@@ -24,20 +52,20 @@ export function countCopilotSubmits(lines) {
24
52
  /**
25
53
  * Copilot completion detection.
26
54
  *
27
- * Primary signal: latest assistant turn has ended (`turn_end` occurs after
28
- * the latest `turn_start`) in the JSONL session file.
55
+ * Primary signal: latest assistant turn has ended and every background item
56
+ * launched at or before that `turn_end` has completed by then.
29
57
  * Secondary signal: quiet debounce (no new data for `quietMs`).
30
58
  */
31
59
  export class CopilotCompletionDetector extends AbstractCompletionDetector {
32
60
  exitToolName;
33
- latestTurnComplete = false;
61
+ primaryFired = false;
34
62
  exitToolCalled = false;
35
63
  constructor(pollMs = 500, quietMs = 500, exitToolName, markerFile, onActivation) {
36
64
  super(pollMs, quietMs, Infinity, markerFile, onActivation);
37
65
  this.exitToolName = exitToolName;
38
66
  }
39
67
  analyzeLines(lines) {
40
- this.latestTurnComplete = isCopilotTurnComplete(lines);
68
+ this.primaryFired = isCopilotTurnSettled(lines);
41
69
  this.exitToolCalled = false;
42
70
  if (this.exitToolName) {
43
71
  for (const line of lines) {
@@ -57,7 +85,7 @@ export class CopilotCompletionDetector extends AbstractCompletionDetector {
57
85
  }
58
86
  }
59
87
  isPrimarySignalFired() {
60
- return this.latestTurnComplete || this.exitToolCalled;
88
+ return this.primaryFired || this.exitToolCalled;
61
89
  }
62
90
  extractResponse(lines) {
63
91
  return extractCopilotResponse(lines);
@@ -66,10 +94,154 @@ export class CopilotCompletionDetector extends AbstractCompletionDetector {
66
94
  return this.exitToolCalled;
67
95
  }
68
96
  shouldSuppressPtyTimerReset() {
69
- return this.latestTurnComplete || this.exitToolCalled;
97
+ return this.primaryFired || this.exitToolCalled;
70
98
  }
71
99
  }
72
100
  function isCopilotTurnInitiatingUserLine(line) {
73
101
  return line.type === "user.message";
74
102
  }
103
+ function latestCopilotTurnBoundary(lines) {
104
+ let lastTurnStart = -1;
105
+ let lastTurnEnd = -1;
106
+ for (let i = 0; i < lines.length; i++) {
107
+ const line = lines[i];
108
+ if (line.type === "assistant.turn_start") {
109
+ lastTurnStart = i;
110
+ }
111
+ else if (line.type === "assistant.turn_end") {
112
+ lastTurnEnd = i;
113
+ }
114
+ }
115
+ return { lastTurnStart, lastTurnEnd };
116
+ }
117
+ function backgroundLaunchKey(line, producingToolName) {
118
+ if (line.type !== "tool.execution_complete")
119
+ return undefined;
120
+ const data = recordProp(line, "data");
121
+ if (data?.success !== true)
122
+ return undefined;
123
+ return (backgroundAgentLaunchKey(data, producingToolName) ??
124
+ backgroundShellLaunchKey(data, producingToolName));
125
+ }
126
+ function backgroundAgentLaunchKey(data, producingToolName) {
127
+ if (!isAllowedProducingTool(producingToolName, BACKGROUND_AGENT_LAUNCH_TOOLS)) {
128
+ return undefined;
129
+ }
130
+ const telemetry = recordProp(data, "toolTelemetry");
131
+ const properties = recordProp(telemetry, "properties");
132
+ if (properties?.execution_mode !== "background")
133
+ return undefined;
134
+ const restrictedProperties = recordProp(telemetry, "restrictedProperties");
135
+ const agentId = stringProp(restrictedProperties, "agent_id");
136
+ return agentId ? `agent:${agentId}` : undefined;
137
+ }
138
+ function backgroundShellLaunchKey(data, producingToolName) {
139
+ if (!isAllowedProducingTool(producingToolName, BACKGROUND_SHELL_SIGNAL_TOOLS)) {
140
+ return undefined;
141
+ }
142
+ const result = recordProp(data, "result");
143
+ const content = stringProp(result, "content");
144
+ const envelope = trailingRuntimeEnvelope(content);
145
+ if (!envelope || /\bstarted in background\b/i.test(envelope)) {
146
+ return undefined;
147
+ }
148
+ const match = /\bshellId:\s*([^\s,]+)\s+is still running\b/.exec(envelope);
149
+ return match?.[1] ? `shell:${match[1]}` : undefined;
150
+ }
151
+ function backgroundCompletionKey(line) {
152
+ if (line.type !== "system.notification")
153
+ return undefined;
154
+ const data = recordProp(line, "data");
155
+ const kind = recordProp(data, "kind");
156
+ if (kind?.type === "agent_completed") {
157
+ const agentId = stringProp(kind, "agentId");
158
+ return agentId ? `agent:${agentId}` : undefined;
159
+ }
160
+ if (kind?.type === "shell_completed") {
161
+ const shellId = stringProp(kind, "shellId");
162
+ return shellId ? `shell:${shellId}` : undefined;
163
+ }
164
+ return undefined;
165
+ }
166
+ function backgroundReadCompletionKey(line, producingToolName) {
167
+ if (line.type !== "tool.execution_complete")
168
+ return undefined;
169
+ const data = recordProp(line, "data");
170
+ if (data?.success !== true)
171
+ return undefined;
172
+ return (backgroundAgentReadCompletionKey(data, producingToolName) ??
173
+ backgroundShellReadCompletionKey(data, producingToolName));
174
+ }
175
+ function backgroundAgentReadCompletionKey(data, producingToolName) {
176
+ if (!isAllowedProducingTool(producingToolName, BACKGROUND_AGENT_READ_TOOLS)) {
177
+ return undefined;
178
+ }
179
+ const telemetry = recordProp(data, "toolTelemetry");
180
+ const properties = recordProp(telemetry, "properties");
181
+ const status = stringProp(properties, "status");
182
+ if (status !== "completed" && status !== "failed" && status !== "cancelled") {
183
+ return undefined;
184
+ }
185
+ const agentId = stringProp(properties, "agent_id");
186
+ return agentId ? `agent:${agentId}` : undefined;
187
+ }
188
+ function backgroundShellReadCompletionKey(data, producingToolName) {
189
+ if (!isAllowedProducingTool(producingToolName, BACKGROUND_SHELL_SIGNAL_TOOLS)) {
190
+ return undefined;
191
+ }
192
+ const result = recordProp(data, "result");
193
+ const content = stringProp(result, "content");
194
+ const envelope = trailingRuntimeEnvelope(content);
195
+ const match = /\bshellId:\s*([^\s,]+)\s+completed with exit code\b/.exec(envelope ?? "");
196
+ return match?.[1] ? `shell:${match[1]}` : undefined;
197
+ }
198
+ function backgroundTerminationKey(line) {
199
+ if (line.type !== "tool.execution_start")
200
+ return undefined;
201
+ const data = recordProp(line, "data");
202
+ const toolName = stringProp(data, "toolName");
203
+ if (toolName !== "stop_powershell" && toolName !== "stop_bash") {
204
+ return undefined;
205
+ }
206
+ const args = recordProp(data, "arguments");
207
+ const shellId = stringProp(args, "shellId");
208
+ return shellId ? `shell:${shellId}` : undefined;
209
+ }
210
+ function toolNamesByCallIdUpTo(lines, lastIdx) {
211
+ const toolNamesByCallId = new Map();
212
+ for (let i = 0; i <= lastIdx; i++) {
213
+ const line = lines[i];
214
+ if (line.type !== "tool.execution_start")
215
+ continue;
216
+ const data = recordProp(line, "data");
217
+ const toolCallId = stringProp(data, "toolCallId");
218
+ const toolName = stringProp(data, "toolName");
219
+ if (toolCallId && toolName) {
220
+ toolNamesByCallId.set(toolCallId, toolName);
221
+ }
222
+ }
223
+ return toolNamesByCallId;
224
+ }
225
+ function producingToolNameForCompletion(line, toolNamesByCallId) {
226
+ if (line.type !== "tool.execution_complete")
227
+ return undefined;
228
+ const data = recordProp(line, "data");
229
+ const toolCallId = stringProp(data, "toolCallId");
230
+ return toolCallId ? toolNamesByCallId.get(toolCallId) : undefined;
231
+ }
232
+ function isAllowedProducingTool(toolName, allowedTools) {
233
+ return toolName !== undefined && allowedTools.has(toolName);
234
+ }
235
+ function trailingRuntimeEnvelope(content) {
236
+ const match = /<([^<>]*)>$/.exec(content?.trimEnd() ?? "");
237
+ return match?.[1]?.trim();
238
+ }
239
+ function recordProp(record, key) {
240
+ const value = record?.[key];
241
+ return isRecord(value) ? value : undefined;
242
+ }
243
+ function stringProp(record, key) {
244
+ const value = record?.[key];
245
+ return typeof value === "string" && value.length > 0 ? value : undefined;
246
+ }
75
247
  //# sourceMappingURL=completion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"completion.js","sourceRoot":"","sources":["../../../src/providers/copilot/completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAoB,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,UAAU,qBAAqB,CAAC,KAAoB;IACxD,IAAI,aAAa,GAAG,CAAC,CAAC,CAAC;IACvB,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC;IAErB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,IAAI,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;YACzC,aAAa,GAAG,CAAC,CAAC;QACpB,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;YAC9C,WAAW,GAAG,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,aAAa,KAAK,CAAC,CAAC,IAAI,WAAW,GAAG,aAAa,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAoB;IAC3D,OAAO,eAAe,CAAC,KAAK,EAAE,+BAA+B,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAoB;IACtD,OAAO,UAAU,CAAC,KAAK,EAAE,+BAA+B,CAAC,CAAC;AAC5D,CAAC;A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andler } from "../fork.js";
2
+ import type { PlanModeConfig, ProviderStrategy, SessionHandler, BuildArgsOpts, ForkSubmitFloorPolicy, OptionCatalog } from "../types.js";
2
3
  import type { CompletionDetectorOptions } from "../types.js";
3
4
  import { CopilotCompletionDetector } from "./completion.js";
4
5
  export declare class CopilotStrategy implements ProviderStrategy {
@@ -7,9 +8,16 @@ export declare class CopilotStrategy implements ProviderStrategy {
7
8
  readonly command = "copilot";
8
9
  readonly exitSignal = "\u0003";
9
10
  readonly session: SessionHandler;
11
+ readonly fork: ForkHandler;
12
+ readonly forkSubmitFloor: ForkSubmitFloorPolicy;
10
13
  version: string | undefined;
11
14
  readonly planMode: PlanModeConfig;
15
+ readonly options: OptionCatalog;
12
16
  buildArgs(prompt: string, opts: BuildArgsOpts): Promise<string[]>;
17
+ ensureTrust(workdir: string): Promise<void>;
18
+ simplifierPrompt(outputPlanFile: string): string;
13
19
  createDetector(opts?: CompletionDetectorOptions): CopilotCompletionDetector;
20
+ private copilotModels;
21
+ private copilotSupportsMaxEffort;
14
22
  }
15
23
  //# sourceMappingURL=strategy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/providers/copilot/strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEnG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAG5D,qBAAa,eAAgB,YAAW,gBAAgB;IACtD,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,WAAW,wBAAwB;IAC5C,QAAQ,CAAC,OAAO,aAAa;IAC7B,QAAQ,CAAC,UAAU,YAAU;IAC7B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAA+B;IAC/D,OAAO,EAAE,MAAM,GAAG,SAAS,CA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;IAShD,cAAc,CAAC,IAAI,CAAC,EAAE,yBAAyB,GAAG,yBAAyB;IAU3E,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,wBAAwB;CAGjC"}
@@ -1,19 +1,64 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { rmSync } from "node:fs";
3
+ import { cp } from "node:fs/promises";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { SESSION_FILE_WAIT_DEFAULT_MS, waitForFile, } from "../../session/locator.js";
1
7
  import { flagIf } from "../types.js";
2
8
  import { versionGte } from "../version.js";
3
- import { CopilotCompletionDetector } from "./completion.js";
4
- import { CopilotSessionHandler } from "./session.js";
9
+ import { countCopilotSubmits, isCopilotTurnSettled, latestCopilotSubmitIndex, CopilotCompletionDetector, } from "./completion.js";
10
+ import { CopilotSessionHandler, getCopilotSessionDir } from "./session.js";
11
+ import { ensureCopilotTrust } from "./trust.js";
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+ const COPILOT_INQUIRY_DIR = join(__dirname, "../../offscreen/copilot-inquiry");
14
+ const DEFAULT_FORK_LOCATE_POLL_MS = 500;
15
+ const COPILOT_OPUS_4_8_MIN_CLI_VERSION = "1.0.55";
16
+ const COPILOT_SONNET_5_MIN_CLI_VERSION = "1.0.68";
17
+ const COPILOT_MAX_EFFORT_MIN_CLI_VERSION = "1.0.60";
18
+ const COPILOT_MODELS_LEGACY = [
19
+ "gpt-5.5",
20
+ "claude-opus-4.7-1m-internal",
21
+ ];
22
+ const COPILOT_MODELS_OPUS_4_8 = [
23
+ "gpt-5.5",
24
+ "claude-opus-4.8",
25
+ "claude-opus-4.7",
26
+ ];
27
+ const COPILOT_MODELS_SONNET_5 = [
28
+ "gpt-5.5",
29
+ "claude-sonnet-5",
30
+ "claude-opus-4.8",
31
+ "claude-opus-4.7",
32
+ ];
33
+ const COPILOT_BASE_EFFORTS = ["medium", "high", "xhigh"];
5
34
  export class CopilotStrategy {
6
35
  name = "copilot";
7
36
  displayName = "GitHub Copilot CLI";
8
37
  command = "copilot";
9
38
  exitSignal = "\x03";
10
39
  session = new CopilotSessionHandler();
40
+ fork = new CopilotForkHandler();
41
+ forkSubmitFloor = { from: "source" };
11
42
  version = undefined;
12
43
  planMode = {
13
44
  argPrefix: "/plan ",
14
45
  exitToolName: "exit_plan_mode",
15
46
  nativePlanFile: true,
16
47
  };
48
+ options = {
49
+ models: () => this.copilotModels(),
50
+ defaultModel: () => COPILOT_MODELS_LEGACY[0] ?? "",
51
+ efforts: (model) => {
52
+ const modelAllowsMax = isClaudeFamilyModel(model);
53
+ if (modelAllowsMax && this.copilotSupportsMaxEffort()) {
54
+ return [...COPILOT_BASE_EFFORTS, "max"];
55
+ }
56
+ return COPILOT_BASE_EFFORTS;
57
+ },
58
+ defaultEffort: () => "high",
59
+ isKnownModel: (model) => this.copilotModels().includes(model),
60
+ isKnownEffort: (effort, model) => this.options.efforts(model).includes(effort),
61
+ };
17
62
  async buildArgs(prompt, opts) {
18
63
  const modelFlags = opts.model ? ["--model", opts.model] : [];
19
64
  const effortFlags = opts.effort ? ["--effort", opts.effort] : [];
@@ -48,8 +93,99 @@ export class CopilotStrategy {
48
93
  const prefix = opts.promptPrefix ?? "";
49
94
  return ["-i", `${prefix}${prompt}`, ...optionFlags];
50
95
  }
96
+ async ensureTrust(workdir) {
97
+ await ensureCopilotTrust(workdir);
98
+ }
99
+ simplifierPrompt(outputPlanFile) {
100
+ return [
101
+ "Review the changed code for reuse, quality, and efficiency.",
102
+ "Identify issues and propose fixes.",
103
+ "",
104
+ `Write the simplification plan as markdown to: ${outputPlanFile}`,
105
+ ].join("\n");
106
+ }
51
107
  createDetector(opts) {
52
108
  return new CopilotCompletionDetector(100, 200, this.planMode.exitToolName, opts?.completionMarkerFile, opts?.onActivation);
53
109
  }
110
+ copilotModels() {
111
+ if (versionGte(this.version, COPILOT_SONNET_5_MIN_CLI_VERSION)) {
112
+ return COPILOT_MODELS_SONNET_5;
113
+ }
114
+ return versionGte(this.version, COPILOT_OPUS_4_8_MIN_CLI_VERSION)
115
+ ? COPILOT_MODELS_OPUS_4_8
116
+ : COPILOT_MODELS_LEGACY;
117
+ }
118
+ copilotSupportsMaxEffort() {
119
+ return versionGte(this.version, COPILOT_MAX_EFFORT_MIN_CLI_VERSION);
120
+ }
121
+ }
122
+ class CopilotForkHandler {
123
+ async buildLaunch(slot) {
124
+ const clonedId = randomUUID();
125
+ const sourceDir = copilotSourceDir(slot);
126
+ const targetDir = join(getCopilotSessionDir(), clonedId);
127
+ const cleanup = () => {
128
+ rmSync(targetDir, { recursive: true, force: true });
129
+ };
130
+ try {
131
+ await cp(sourceDir, targetDir, { recursive: true, errorOnExist: true, force: false });
132
+ const existing = process.env.COPILOT_CUSTOM_INSTRUCTIONS_DIRS;
133
+ const dirs = existing ? `${existing},${COPILOT_INQUIRY_DIR}` : COPILOT_INQUIRY_DIR;
134
+ return {
135
+ command: "copilot",
136
+ args: [
137
+ "--resume",
138
+ clonedId,
139
+ ...copilotFlags(slot),
140
+ ],
141
+ env: { COPILOT_CUSTOM_INSTRUCTIONS_DIRS: dirs },
142
+ forkSessionFile: join(targetDir, "events.jsonl"),
143
+ cleanup,
144
+ };
145
+ }
146
+ catch (err) {
147
+ cleanup();
148
+ throw err;
149
+ }
150
+ }
151
+ async captureLineage(slot, _workdir, launch) {
152
+ return { kind: "copilot", file: launch.forkSessionFile ?? slot.sourceSessionPath };
153
+ }
154
+ async locateSessionFile(lineage, opts = {}) {
155
+ if (lineage.kind !== "copilot")
156
+ return undefined;
157
+ try {
158
+ return await waitForFile(lineage.file, opts.timeoutMs ?? SESSION_FILE_WAIT_DEFAULT_MS, opts.pollMs ?? DEFAULT_FORK_LOCATE_POLL_MS, opts.signal);
159
+ }
160
+ catch {
161
+ return undefined;
162
+ }
163
+ }
164
+ turnComplete(lines) {
165
+ return isCopilotTurnSettled(lines);
166
+ }
167
+ latestSubmitIndex(lines) {
168
+ return latestCopilotSubmitIndex(lines);
169
+ }
170
+ submitCount(lines) {
171
+ return countCopilotSubmits(lines);
172
+ }
173
+ }
174
+ function copilotFlags(slot) {
175
+ return [
176
+ ...(slot.model ? ["--model", slot.model] : []),
177
+ ...(slot.effort ? ["--effort", slot.effort] : []),
178
+ ...(slot.yolo ? ["--allow-all"] : []),
179
+ "--mouse=on",
180
+ ];
181
+ }
182
+ function copilotSourceDir(slot) {
183
+ if (slot.sourceSessionPath.endsWith("events.jsonl")) {
184
+ return dirname(slot.sourceSessionPath);
185
+ }
186
+ return join(getCopilotSessionDir(), slot.sourceSessionId);
187
+ }
188
+ function isClaudeFamilyModel(model) {
189
+ return model?.startsWith("claude-") ?? false;
54
190
  }
55
191
  //# sourceMappingURL=strategy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../src/providers/copilot/strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,OAAO,eAAe;IACjB,IAAI,GAAG,SAAS,CAAC;IACjB,WAAW,GAAG,oBAAoB,CAAC;IACnC,OAAO,GAAG,SAAS,CAAC;IACpB,UAAU,GAAG,MAAM,CAAC;IACpB,OAAO,GAAmB,IAAI,qBAAqB,EAAE,CAAC;IAC/D,OAAO,GAAuB,SAAS,CAAC;IAC/B,QAAQ,GAAmB;QAClC,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,gBAAgB;QAC9B,cAAc,EAAE,IAAI;KACrB,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,IAAmB;QACjD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,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AAC,KAAoB;QAC/B,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,iBAAiB,CAAC,KAAoB;QACpC,OAAO,wBAAwB,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,WAAW,CAAC,KAAoB;QAC9B,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACF;AAED,SAAS,YAAY,CAAC,IAAsD;IAC1E,OAAO;QACL,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9C,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,YAAY;KACb,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAmB;IAC3C,IAAI,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACpD,OAAO,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,CAAC,oBAAoB,EAAE,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAyB;IACpD,OAAO,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function ensureCopilotTrust(workdir: string): Promise<void>;
2
+ //# sourceMappingURL=trust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trust.d.ts","sourceRoot":"","sources":["../../../src/providers/copilot/trust.ts"],"names":[],"mappings":"AAUA,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBvE"}
@@ -0,0 +1,45 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { compareCopilotPaths, normalizeCopilotTrustPath, parseJsonObject, readTextIfExists, } from "../trust-utils.js";
5
+ export async function ensureCopilotTrust(workdir) {
6
+ const configDir = join(homedir(), ".copilot");
7
+ const configPath = join(configDir, "config.json");
8
+ const normalizedWorkdir = normalizeCopilotTrustPath(workdir);
9
+ await mkdir(configDir, { recursive: true });
10
+ const content = await readTextIfExists(configPath) ?? "";
11
+ const { prefix, body, eol } = splitLeadingJsonComments(content);
12
+ const config = body.trim() === ""
13
+ ? {}
14
+ : parseJsonObject(body, configPath);
15
+ const trustedFolders = Array.isArray(config.trustedFolders)
16
+ ? [...config.trustedFolders]
17
+ : [];
18
+ const alreadyTrusted = trustedFolders.some((value) => typeof value === "string" && compareCopilotPaths(value, normalizedWorkdir));
19
+ if (alreadyTrusted)
20
+ return;
21
+ trustedFolders.push(normalizedWorkdir);
22
+ config.trustedFolders = trustedFolders;
23
+ const json = JSON.stringify(config, null, 2).replace(/\n/g, eol);
24
+ await writeFile(configPath, `${prefix}${json}${eol}`, "utf8");
25
+ }
26
+ function splitLeadingJsonComments(content) {
27
+ const eol = content.includes("\r\n") ? "\r\n" : "\n";
28
+ const lines = content === "" ? [] : content.split(/\r?\n/);
29
+ let index = 0;
30
+ while (index < lines.length) {
31
+ const trimmed = lines[index].trim();
32
+ if (trimmed === "" || trimmed.startsWith("//")) {
33
+ index++;
34
+ continue;
35
+ }
36
+ break;
37
+ }
38
+ const prefixLines = lines.slice(0, index);
39
+ return {
40
+ prefix: prefixLines.length === 0 ? "" : `${prefixLines.join(eol)}${eol}`,
41
+ body: lines.slice(index).join(eol),
42
+ eol,
43
+ };
44
+ }
45
+ //# sourceMappingURL=trust.js.map
@@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I,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE;QACxE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAClC,GAAG;KACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { BuiltinRole, DriverName } from "../flow/types.js";
2
+ import type { SessionLine } from "../session/reader.js";
3
+ export type OffscreenBinding = "primary" | "secondary";
4
+ export type ForkSourceKey = "interviewer" | "planner" | "reviewer-plan";
5
+ export interface ForkSourceConfig {
6
+ key: ForkSourceKey;
7
+ role: BuiltinRole;
8
+ variant?: string;
9
+ driver: string;
10
+ sessionKey: string;
11
+ model?: string;
12
+ effort?: string;
13
+ yolo?: boolean;
14
+ }
15
+ export interface OffscreenSlot {
16
+ binding: OffscreenBinding;
17
+ roleLabel: string;
18
+ hint: string;
19
+ summarizePrompt?: string;
20
+ summarizeHint?: string;
21
+ driver: DriverName;
22
+ sourceSessionId: string;
23
+ sourceSessionPath: string;
24
+ model?: string;
25
+ effort?: string;
26
+ yolo?: boolean;
27
+ }
28
+ export interface ForkLaunch {
29
+ command: string;
30
+ args: string[];
31
+ env?: Record<string, string>;
32
+ forkSessionFile?: string;
33
+ cleanup: () => void;
34
+ }
35
+ export type ForkLineage = {
36
+ kind: "copilot";
37
+ file: string;
38
+ } | {
39
+ kind: "codex";
40
+ sourceSessionId: string;
41
+ sessionsRoot?: string;
42
+ preForkFiles?: Set<string>;
43
+ } | {
44
+ kind: "claude";
45
+ projectDir: string;
46
+ preSnapshot: Set<string>;
47
+ sourceUuids: Set<string>;
48
+ sourceFile: string;
49
+ };
50
+ export type ForkSessionLocateOptions = {
51
+ signal?: AbortSignal;
52
+ timeoutMs?: number;
53
+ pollMs?: number;
54
+ };
55
+ export interface ForkHandler {
56
+ buildLaunch(slot: OffscreenSlot, workdir: string): Promise<ForkLaunch>;
57
+ captureLineage(slot: OffscreenSlot, workdir: string, launch: ForkLaunch): Promise<ForkLineage>;
58
+ locateSessionFile(lineage: ForkLineage, opts?: ForkSessionLocateOptions): Promise<string | undefined>;
59
+ turnComplete(lines: SessionLine[]): boolean;
60
+ latestSubmitIndex(lines: SessionLine[]): number;
61
+ submitCount(lines: SessionLine[]): number;
62
+ }
63
+ export declare const INQUIRY_ONLY_INSTRUCTION = "This session is solely for inquiry. Don't make edits, just answer questions.";
64
+ //# sourceMappingURL=fork.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fork.d.ts","sourceRoot":"","sources":["../../src/providers/fork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,SAAS,GAAG,eAAe,CAAC;AAExE,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,aAAa,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC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,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC/B,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAC5C,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAChD,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;CAC3C;AAED,eAAO,MAAM,wBAAwB,iFAC2C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const INQUIRY_ONLY_INSTRUCTION = "This session is solely for inquiry. Don't make edits, just answer questions.";
2
+ //# sourceMappingURL=fork.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fork.js","sourceRoot":"","sources":["../../src/providers/fork.ts"],"names":[],"mappings":"AAyEA,MAAM,CAAC,MAAM,wBAAwB,GACnC,8EAA8E,CAAC"}
@@ -4,5 +4,6 @@ export { CopilotStrategy } from "./copilot/index.js";
4
4
  export { invoke } from "./invoke.js";
5
5
  export { resolveProvider, computeFeatureGates, DEFAULT_GATES } from "./registry.js";
6
6
  export type { FeatureGates } from "./registry.js";
7
- export type { ProviderStrategy, SessionHandler, SessionSnapshot, PlanModeConfig, CompletionDetector, } from "./types.js";
7
+ export type { ProviderStrategy, SessionHandler, SessionSnapshot, PlanModeConfig, CompletionDetector, ForkSubmitFloorPolicy, OptionCatalog, } from "./types.js";
8
+ export type { ForkHandler, ForkLaunch, ForkLineage, ForkSessionLocateOptions, ForkSourceConfig, ForkSourceKey, OffscreenBinding, OffscreenSlot, } from "./fork.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACpF,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,EACd,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACpF,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,aAAa,GACd,MAAM,WAAW,CAAC"}