@grackle-ai/runtime-copilot 0.82.2
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/copilot.d.ts +63 -0
- package/dist/copilot.d.ts.map +1 -0
- package/dist/copilot.js +375 -0
- package/dist/copilot.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/package.json +47 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { AgentSession } from "@grackle-ai/runtime-sdk";
|
|
2
|
+
import { BaseAgentSession, BaseAgentRuntime } from "@grackle-ai/runtime-sdk";
|
|
3
|
+
/** Cached result of the Copilot SDK import. */
|
|
4
|
+
interface CopilotSdkModule {
|
|
5
|
+
CopilotClient: new (opts?: Record<string, unknown>) => any;
|
|
6
|
+
defineTool: (name: string, opts: Record<string, unknown>) => unknown;
|
|
7
|
+
/** Pre-built permission handler that approves all tool invocations. */
|
|
8
|
+
approveAll: any;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @internal For testing only — inject a mock SDK to bypass the dynamic import.
|
|
12
|
+
* Pass `undefined` to reset the cache so the real import is attempted again.
|
|
13
|
+
*/
|
|
14
|
+
export declare function _setCopilotSdkForTesting(mock: CopilotSdkModule | undefined): void;
|
|
15
|
+
/** @internal Resolve a GitHub token from well-known environment variables. Returns undefined if none set. */
|
|
16
|
+
export declare function resolveGithubToken(): string | undefined;
|
|
17
|
+
/** @internal Parse BYOK provider config from environment variable. Returns undefined if not set or malformed. */
|
|
18
|
+
export declare function resolveProviderConfig(): Record<string, unknown> | undefined;
|
|
19
|
+
export { resolveMcpServers } from "@grackle-ai/runtime-sdk";
|
|
20
|
+
/**
|
|
21
|
+
* An in-progress Copilot agent session that streams events via the Copilot SDK.
|
|
22
|
+
*
|
|
23
|
+
* @internal Exported only for unit testing of the kill/abort path. Do not use outside of tests.
|
|
24
|
+
*/
|
|
25
|
+
export declare class CopilotSession extends BaseAgentSession {
|
|
26
|
+
runtimeName: string;
|
|
27
|
+
protected readonly runtimeDisplayName: string;
|
|
28
|
+
protected readonly noMessagesError: string;
|
|
29
|
+
private copilotClient?;
|
|
30
|
+
private copilotSession?;
|
|
31
|
+
/** Callbacks for the current query's idle promise (reset per sendAndWaitForIdle call). */
|
|
32
|
+
private idleResolve?;
|
|
33
|
+
private idleReject?;
|
|
34
|
+
/** Count of meaningful messages in the current query (reset per sendAndWaitForIdle call). */
|
|
35
|
+
private currentMessageCount;
|
|
36
|
+
/** System context is injected via sessionConfig.systemMessage, not prepended to the prompt. */
|
|
37
|
+
protected buildInitialPrompt(): string;
|
|
38
|
+
protected setupSdk(): Promise<void>;
|
|
39
|
+
protected setupForResume(): Promise<void>;
|
|
40
|
+
protected runInitialQuery(prompt: string): Promise<number>;
|
|
41
|
+
protected executeFollowUp(text: string): Promise<void>;
|
|
42
|
+
protected canAcceptInput(): boolean;
|
|
43
|
+
protected abortActive(): void;
|
|
44
|
+
protected releaseResources(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Send a prompt to the Copilot session and wait for it to go idle.
|
|
47
|
+
* Resets the message counter for this query. Returns the message count.
|
|
48
|
+
*/
|
|
49
|
+
private sendAndWaitForIdle;
|
|
50
|
+
/** Tear down the Copilot session and client. */
|
|
51
|
+
private cleanup;
|
|
52
|
+
}
|
|
53
|
+
/** Runtime that delegates to the GitHub Copilot SDK (`@github/copilot-sdk`). */
|
|
54
|
+
export declare class CopilotRuntime extends BaseAgentRuntime {
|
|
55
|
+
name: string;
|
|
56
|
+
protected resumePrompt: string;
|
|
57
|
+
protected createSession(id: string, prompt: string, model: string, maxTurns: number, resumeSessionId?: string, branch?: string, workingDirectory?: string, systemContext?: string, mcpServers?: Record<string, unknown>, _hooks?: Record<string, unknown>, // Hooks not supported by Copilot SDK — accepted for interface compatibility
|
|
58
|
+
mcpBroker?: {
|
|
59
|
+
url: string;
|
|
60
|
+
token: string;
|
|
61
|
+
}, useWorktrees?: boolean): AgentSession;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=copilot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot.d.ts","sourceRoot":"","sources":["../src/copilot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAiG,MAAM,yBAAyB,CAAC;AAiB5K,+CAA+C;AAC/C,UAAU,gBAAgB;IAExB,aAAa,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC;IAC3D,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;IACrE,uEAAuE;IAEvE,UAAU,EAAE,GAAG,CAAC;CACjB;AAKD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI,CAEjF;AAmCD,6GAA6G;AAC7G,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAQvD;AAED,iHAAiH;AACjH,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAW3E;AAID,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,gBAAgB;IAC3C,WAAW,EAAE,MAAM,CAAa;IACvC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAa;IAC1D,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAC6G;IAGvJ,OAAO,CAAC,aAAa,CAAC,CAAM;IAE5B,OAAO,CAAC,cAAc,CAAC,CAAM;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/copilot.js
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { BaseAgentSession, BaseAgentRuntime, resolveWorkingDirectory, resolveMcpServers, logger, ensureRuntimeInstalled, importFromRuntime } from "@grackle-ai/runtime-sdk";
|
|
2
|
+
// ─── Environment variable names ────────────────────────────
|
|
3
|
+
// All configuration is driven by environment variables so the
|
|
4
|
+
// runtime works identically across Docker, local, SSH, etc.
|
|
5
|
+
/** Path to the Copilot CLI binary. Defaults to "copilot" (resolved via PATH). */
|
|
6
|
+
const ENV_COPILOT_CLI_PATH = "COPILOT_CLI_PATH";
|
|
7
|
+
/** URL of an external Copilot CLI server (e.g. "localhost:4321"). Skips spawning a local CLI process. */
|
|
8
|
+
const ENV_COPILOT_CLI_URL = "COPILOT_CLI_URL";
|
|
9
|
+
/** JSON-encoded provider config for BYOK scenarios (type, baseUrl, apiKey, etc.). */
|
|
10
|
+
const ENV_COPILOT_PROVIDER_CONFIG = "COPILOT_PROVIDER_CONFIG";
|
|
11
|
+
/** GitHub token environment variables checked in priority order. */
|
|
12
|
+
const GITHUB_TOKEN_ENV_VARS = ["COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"];
|
|
13
|
+
/** Promise for the one-time SDK import, cached to avoid race conditions. */
|
|
14
|
+
let sdkPromise;
|
|
15
|
+
/**
|
|
16
|
+
* @internal For testing only — inject a mock SDK to bypass the dynamic import.
|
|
17
|
+
* Pass `undefined` to reset the cache so the real import is attempted again.
|
|
18
|
+
*/
|
|
19
|
+
export function _setCopilotSdkForTesting(mock) {
|
|
20
|
+
sdkPromise = mock !== undefined ? Promise.resolve(mock) : undefined;
|
|
21
|
+
}
|
|
22
|
+
/** Dynamically import the Copilot SDK so the module is optional at install time. */
|
|
23
|
+
function getCopilotSdk() {
|
|
24
|
+
if (!sdkPromise) {
|
|
25
|
+
sdkPromise = (async () => {
|
|
26
|
+
try {
|
|
27
|
+
await ensureRuntimeInstalled("copilot");
|
|
28
|
+
const mod = await importFromRuntime("copilot", "@github/copilot-sdk");
|
|
29
|
+
if (typeof mod.CopilotClient !== "function") {
|
|
30
|
+
throw new Error("CopilotClient not found in @github/copilot-sdk");
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
CopilotClient: mod.CopilotClient,
|
|
34
|
+
defineTool: mod.defineTool,
|
|
35
|
+
approveAll: mod.approveAll,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
// Reset so the next attempt retries the import
|
|
40
|
+
sdkPromise = undefined;
|
|
41
|
+
logger.warn({ err }, "Failed to import Copilot SDK");
|
|
42
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
43
|
+
throw new Error(`Copilot SDK failed to load: ${detail}\n` +
|
|
44
|
+
"Runtime packages are installed in ~/.grackle/runtimes/copilot/.\n" +
|
|
45
|
+
"The Copilot CLI must also be installed and available in PATH (or set COPILOT_CLI_URL for an external server).");
|
|
46
|
+
}
|
|
47
|
+
})();
|
|
48
|
+
}
|
|
49
|
+
return sdkPromise;
|
|
50
|
+
}
|
|
51
|
+
// ─── Helpers ───────────────────────────────────────────────
|
|
52
|
+
/** @internal Resolve a GitHub token from well-known environment variables. Returns undefined if none set. */
|
|
53
|
+
export function resolveGithubToken() {
|
|
54
|
+
for (const varName of GITHUB_TOKEN_ENV_VARS) {
|
|
55
|
+
const value = process.env[varName];
|
|
56
|
+
if (value) {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
/** @internal Parse BYOK provider config from environment variable. Returns undefined if not set or malformed. */
|
|
63
|
+
export function resolveProviderConfig() {
|
|
64
|
+
const raw = process.env[ENV_COPILOT_PROVIDER_CONFIG];
|
|
65
|
+
if (!raw) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return JSON.parse(raw);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
logger.warn("Malformed COPILOT_PROVIDER_CONFIG environment variable, ignoring");
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Re-export resolveMcpServers so existing imports from this module continue to work.
|
|
77
|
+
// Note: the return type is now ResolvedMcpConfig (from runtime-utils) instead of Record<string, unknown> | undefined.
|
|
78
|
+
export { resolveMcpServers } from "@grackle-ai/runtime-sdk";
|
|
79
|
+
// ─── Session ───────────────────────────────────────────────
|
|
80
|
+
/**
|
|
81
|
+
* An in-progress Copilot agent session that streams events via the Copilot SDK.
|
|
82
|
+
*
|
|
83
|
+
* @internal Exported only for unit testing of the kill/abort path. Do not use outside of tests.
|
|
84
|
+
*/
|
|
85
|
+
export class CopilotSession extends BaseAgentSession {
|
|
86
|
+
runtimeName = "copilot";
|
|
87
|
+
runtimeDisplayName = "Copilot";
|
|
88
|
+
noMessagesError = "Copilot returned no messages. Check authentication: set GITHUB_TOKEN, GH_TOKEN, or COPILOT_GITHUB_TOKEN (or use COPILOT_PROVIDER_CONFIG for BYOK).";
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
+
copilotClient;
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
copilotSession;
|
|
93
|
+
/** Callbacks for the current query's idle promise (reset per sendAndWaitForIdle call). */
|
|
94
|
+
idleResolve;
|
|
95
|
+
idleReject;
|
|
96
|
+
/** Count of meaningful messages in the current query (reset per sendAndWaitForIdle call). */
|
|
97
|
+
currentMessageCount = 0;
|
|
98
|
+
/** System context is injected via sessionConfig.systemMessage, not prepended to the prompt. */
|
|
99
|
+
buildInitialPrompt() {
|
|
100
|
+
return this.prompt;
|
|
101
|
+
}
|
|
102
|
+
// ─── BaseAgentSession hooks ──────────────────────────────
|
|
103
|
+
async setupSdk() {
|
|
104
|
+
const ts = () => new Date().toISOString();
|
|
105
|
+
const copilotSdk = await getCopilotSdk();
|
|
106
|
+
// ── Resolve working directory ──
|
|
107
|
+
const workingDirectory = await resolveWorkingDirectory({
|
|
108
|
+
branch: this.branch,
|
|
109
|
+
workingDirectory: this.workingDirectory,
|
|
110
|
+
useWorktrees: this.useWorktrees,
|
|
111
|
+
eventQueue: this.eventQueue,
|
|
112
|
+
});
|
|
113
|
+
// ── Create CopilotClient ──
|
|
114
|
+
const clientOptions = {
|
|
115
|
+
autoStart: false,
|
|
116
|
+
useStdio: true,
|
|
117
|
+
};
|
|
118
|
+
const cliUrl = process.env[ENV_COPILOT_CLI_URL];
|
|
119
|
+
if (cliUrl) {
|
|
120
|
+
clientOptions.cliUrl = cliUrl;
|
|
121
|
+
clientOptions.useStdio = false;
|
|
122
|
+
}
|
|
123
|
+
const cliPath = process.env[ENV_COPILOT_CLI_PATH];
|
|
124
|
+
if (cliPath && !cliUrl) {
|
|
125
|
+
clientOptions.cliPath = cliPath;
|
|
126
|
+
}
|
|
127
|
+
const githubToken = resolveGithubToken();
|
|
128
|
+
if (githubToken) {
|
|
129
|
+
clientOptions.githubToken = githubToken;
|
|
130
|
+
clientOptions.useLoggedInUser = false;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
clientOptions.useLoggedInUser = true;
|
|
134
|
+
}
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
136
|
+
this.copilotClient = new copilotSdk.CopilotClient(clientOptions);
|
|
137
|
+
await this.copilotClient.start();
|
|
138
|
+
this.eventQueue.push({ type: "system", timestamp: ts(), content: "Copilot CLI server connected" });
|
|
139
|
+
// ── Build session config ──
|
|
140
|
+
// onPermissionRequest is REQUIRED by the SDK — use approveAll for headless operation
|
|
141
|
+
const sessionConfig = {
|
|
142
|
+
model: this.model,
|
|
143
|
+
streaming: true,
|
|
144
|
+
onPermissionRequest: copilotSdk.approveAll,
|
|
145
|
+
};
|
|
146
|
+
// Inject system context via SDK-native systemMessage
|
|
147
|
+
if (this.systemContext) {
|
|
148
|
+
sessionConfig.systemMessage = { mode: "append", content: this.systemContext };
|
|
149
|
+
}
|
|
150
|
+
// BYOK provider config
|
|
151
|
+
const providerConfig = resolveProviderConfig();
|
|
152
|
+
if (providerConfig) {
|
|
153
|
+
sessionConfig.provider = providerConfig;
|
|
154
|
+
}
|
|
155
|
+
// MCP servers
|
|
156
|
+
const mcpConfig = resolveMcpServers(this.mcpServers, this.mcpBroker);
|
|
157
|
+
if (mcpConfig.servers) {
|
|
158
|
+
sessionConfig.mcpServers = mcpConfig.servers;
|
|
159
|
+
}
|
|
160
|
+
// Note: Copilot SDK does not have a maxTurns config option.
|
|
161
|
+
// The session runs until idle. Log if the caller requested a limit.
|
|
162
|
+
if (this.maxTurns > 0) {
|
|
163
|
+
logger.info({ maxTurns: this.maxTurns }, "maxTurns requested but Copilot SDK does not support turn limits — session will run until idle");
|
|
164
|
+
}
|
|
165
|
+
// Working directory (SDK uses "workingDirectory", not "cwd")
|
|
166
|
+
if (workingDirectory) {
|
|
167
|
+
sessionConfig.workingDirectory = workingDirectory;
|
|
168
|
+
}
|
|
169
|
+
// ── Create or resume session ──
|
|
170
|
+
if (this.resumeSessionId) {
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
172
|
+
this.copilotSession = await this.copilotClient.resumeSession(this.resumeSessionId, sessionConfig);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
176
|
+
this.copilotSession = await this.copilotClient.createSession(sessionConfig);
|
|
177
|
+
}
|
|
178
|
+
this.runtimeSessionId = this.copilotSession.sessionId || this.id;
|
|
179
|
+
this.eventQueue.push({ type: "runtime_session_id", timestamp: ts(), content: this.runtimeSessionId });
|
|
180
|
+
this.eventQueue.push({
|
|
181
|
+
type: "system",
|
|
182
|
+
timestamp: ts(),
|
|
183
|
+
content: `Copilot session created (model: ${this.model}, session: ${this.runtimeSessionId})`,
|
|
184
|
+
});
|
|
185
|
+
// ── Subscribe to events (once; persist for the session lifetime) ──
|
|
186
|
+
// All SessionEvent objects have shape: { id, timestamp, parentId, type, data: { ... } }
|
|
187
|
+
// Stream text deltas — data: { messageId, deltaContent, parentToolCallId? }
|
|
188
|
+
this.copilotSession.on("assistant.message_delta", (event) => {
|
|
189
|
+
if (this.killed) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const data = event.data;
|
|
193
|
+
const deltaContent = (data?.deltaContent ?? "");
|
|
194
|
+
if (deltaContent) {
|
|
195
|
+
this.currentMessageCount++;
|
|
196
|
+
this.eventQueue.push({
|
|
197
|
+
type: "text",
|
|
198
|
+
timestamp: ts(),
|
|
199
|
+
content: deltaContent,
|
|
200
|
+
raw: event,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
// Final assistant message — data: { messageId, content, toolRequests?, ... }
|
|
205
|
+
// We stream via deltas above, so this is mainly for bookkeeping.
|
|
206
|
+
this.copilotSession.on("assistant.message", (event) => {
|
|
207
|
+
if (this.killed) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const data = event.data;
|
|
211
|
+
if (data?.content) {
|
|
212
|
+
this.currentMessageCount++;
|
|
213
|
+
// Deltas already streamed the text incrementally; no need to re-emit.
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
// Tool execution start — data: { toolCallId, toolName, arguments?, mcpServerName?, ... }
|
|
217
|
+
this.copilotSession.on("tool.execution_start", (event) => {
|
|
218
|
+
if (this.killed) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const data = event.data;
|
|
222
|
+
const toolName = (data?.toolName ?? "unknown");
|
|
223
|
+
const toolArgs = data?.arguments ?? {};
|
|
224
|
+
this.currentMessageCount++;
|
|
225
|
+
this.eventQueue.push({
|
|
226
|
+
type: "tool_use",
|
|
227
|
+
timestamp: ts(),
|
|
228
|
+
content: JSON.stringify({ tool: toolName, args: toolArgs }),
|
|
229
|
+
raw: event,
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
// Tool execution complete — data: { toolCallId, success, result?, error?, ... }
|
|
233
|
+
this.copilotSession.on("tool.execution_complete", (event) => {
|
|
234
|
+
if (this.killed) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const data = event.data;
|
|
238
|
+
// result is a ToolResultObject { textResultForLlm, resultType, ... } or undefined
|
|
239
|
+
const result = data?.result;
|
|
240
|
+
const error = data?.error;
|
|
241
|
+
let output;
|
|
242
|
+
if (error) {
|
|
243
|
+
output = error;
|
|
244
|
+
}
|
|
245
|
+
else if (result === undefined) {
|
|
246
|
+
output = "";
|
|
247
|
+
}
|
|
248
|
+
else if (typeof result === "string") {
|
|
249
|
+
output = result;
|
|
250
|
+
}
|
|
251
|
+
else if (typeof result === "object" && result.textResultForLlm) {
|
|
252
|
+
output = result.textResultForLlm;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
output = JSON.stringify(result);
|
|
256
|
+
}
|
|
257
|
+
this.currentMessageCount++;
|
|
258
|
+
this.eventQueue.push({
|
|
259
|
+
type: "tool_result",
|
|
260
|
+
timestamp: ts(),
|
|
261
|
+
content: output,
|
|
262
|
+
raw: event,
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
// Session idle = query completed (ephemeral event, data is empty)
|
|
266
|
+
this.copilotSession.on("session.idle", () => {
|
|
267
|
+
this.idleResolve?.();
|
|
268
|
+
});
|
|
269
|
+
// Usage data — fires after each LLM API call with per-request token counts
|
|
270
|
+
// Note: Copilot SDK's `cost` field is in nano-AIU (GitHub billing units), not USD.
|
|
271
|
+
// We emit tokens only; cost_usd is 0 until a conversion rate is available.
|
|
272
|
+
this.copilotSession.on("assistant.usage", (event) => {
|
|
273
|
+
if (this.killed) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const data = event.data;
|
|
277
|
+
const inputTokens = (Number(data?.inputTokens) || 0)
|
|
278
|
+
+ (Number(data?.cacheReadTokens) || 0)
|
|
279
|
+
+ (Number(data?.cacheWriteTokens) || 0);
|
|
280
|
+
const outputTokens = Number(data?.outputTokens) || 0;
|
|
281
|
+
if (inputTokens > 0 || outputTokens > 0) {
|
|
282
|
+
this.eventQueue.push({
|
|
283
|
+
type: "usage",
|
|
284
|
+
timestamp: ts(),
|
|
285
|
+
content: JSON.stringify({ input_tokens: inputTokens, output_tokens: outputTokens, cost_usd: 0 }),
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
// Session error — data: { errorType, message, stack?, statusCode? }
|
|
290
|
+
this.copilotSession.on("session.error", (event) => {
|
|
291
|
+
const data = event.data;
|
|
292
|
+
const message = (data?.message ?? String(event));
|
|
293
|
+
this.eventQueue.push({ type: "error", timestamp: ts(), content: message, raw: event });
|
|
294
|
+
this.idleReject?.(new Error(message));
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
async setupForResume() {
|
|
298
|
+
this.eventQueue.push({
|
|
299
|
+
type: "system",
|
|
300
|
+
timestamp: new Date().toISOString(),
|
|
301
|
+
content: `Session resumed (id: ${this.resumeSessionId})`,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
async runInitialQuery(prompt) {
|
|
305
|
+
return this.sendAndWaitForIdle(prompt);
|
|
306
|
+
}
|
|
307
|
+
async executeFollowUp(text) {
|
|
308
|
+
await this.sendAndWaitForIdle(text);
|
|
309
|
+
}
|
|
310
|
+
canAcceptInput() {
|
|
311
|
+
return !!this.copilotSession;
|
|
312
|
+
}
|
|
313
|
+
abortActive() {
|
|
314
|
+
if (this.copilotSession) {
|
|
315
|
+
try {
|
|
316
|
+
// abort() may be synchronous (returning void) or asynchronous (returning a Promise).
|
|
317
|
+
// Wrapping in Promise.resolve() handles both cases safely: if abort() returns void,
|
|
318
|
+
// Promise.resolve(undefined) is a no-op resolved promise; if it returns a rejected
|
|
319
|
+
// promise, the .catch() suppresses the error on a best-effort basis.
|
|
320
|
+
Promise.resolve(this.copilotSession.abort()).catch(() => { });
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
// Suppress synchronous throws from abort() so kill() always completes cleanly.
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
releaseResources() {
|
|
328
|
+
this.cleanup().catch(() => { });
|
|
329
|
+
}
|
|
330
|
+
// ─── Copilot-specific internals ───────────────────────────
|
|
331
|
+
/**
|
|
332
|
+
* Send a prompt to the Copilot session and wait for it to go idle.
|
|
333
|
+
* Resets the message counter for this query. Returns the message count.
|
|
334
|
+
*/
|
|
335
|
+
async sendAndWaitForIdle(prompt) {
|
|
336
|
+
this.currentMessageCount = 0;
|
|
337
|
+
const idlePromise = new Promise((resolve, reject) => {
|
|
338
|
+
this.idleResolve = resolve;
|
|
339
|
+
this.idleReject = reject;
|
|
340
|
+
});
|
|
341
|
+
await this.copilotSession.send({ prompt });
|
|
342
|
+
await idlePromise;
|
|
343
|
+
return this.currentMessageCount;
|
|
344
|
+
}
|
|
345
|
+
/** Tear down the Copilot session and client. */
|
|
346
|
+
async cleanup() {
|
|
347
|
+
try {
|
|
348
|
+
if (this.copilotSession) {
|
|
349
|
+
await this.copilotSession.destroy();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
catch { /* best-effort */ }
|
|
353
|
+
try {
|
|
354
|
+
if (this.copilotClient) {
|
|
355
|
+
// stop() returns Promise<Error[]> — log any errors but don't throw
|
|
356
|
+
const errors = await this.copilotClient.stop();
|
|
357
|
+
if (Array.isArray(errors) && errors.length > 0) {
|
|
358
|
+
logger.warn({ errors: errors.map(String) }, "Errors during Copilot client shutdown");
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
catch { /* best-effort */ }
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// ─── Runtime ───────────────────────────────────────────────
|
|
366
|
+
/** Runtime that delegates to the GitHub Copilot SDK (`@github/copilot-sdk`). */
|
|
367
|
+
export class CopilotRuntime extends BaseAgentRuntime {
|
|
368
|
+
name = "copilot";
|
|
369
|
+
resumePrompt = "(resumed)";
|
|
370
|
+
createSession(id, prompt, model, maxTurns, resumeSessionId, branch, workingDirectory, systemContext, mcpServers, _hooks, // Hooks not supported by Copilot SDK — accepted for interface compatibility
|
|
371
|
+
mcpBroker, useWorktrees) {
|
|
372
|
+
return new CopilotSession(id, prompt, model, maxTurns, resumeSessionId, branch, workingDirectory, systemContext, mcpServers, undefined, mcpBroker, useWorktrees);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
//# sourceMappingURL=copilot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot.js","sourceRoot":"","sources":["../src/copilot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5K,8DAA8D;AAC9D,8DAA8D;AAC9D,4DAA4D;AAE5D,iFAAiF;AACjF,MAAM,oBAAoB,GAAW,kBAAkB,CAAC;AACxD,yGAAyG;AACzG,MAAM,mBAAmB,GAAW,iBAAiB,CAAC;AACtD,qFAAqF;AACrF,MAAM,2BAA2B,GAAW,yBAAyB,CAAC;AACtE,oEAAoE;AACpE,MAAM,qBAAqB,GAAsB,CAAC,sBAAsB,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;AActG,4EAA4E;AAC5E,IAAI,UAAiD,CAAC;AAEtD;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAkC;IACzE,UAAU,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtE,CAAC;AAED,oFAAoF;AACpF,SAAS,aAAa;IACpB,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,UAAU,GAAG,CAAC,KAAK,IAA+B,EAAE;YAClD,IAAI,CAAC;gBACH,M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E,CAAC;gBACvB,mEAAmE;gBACnE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,EAAe,CAAC;gBAC5D,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC/C,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,uCAAuC,CAAC,CAAC;gBACvF,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC/B,CAAC;CACF;AAED,8DAA8D;AAE9D,gFAAgF;AAChF,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IAC3C,IAAI,GAAW,SAAS,CAAC;IACtB,YAAY,GAAW,WAAW,CAAC;IAEnC,aAAa,CACrB,EAAU,EACV,MAAc,EACd,KAAa,EACb,QAAgB,EAChB,eAAwB,EACxB,MAAe,EACf,gBAAyB,EACzB,aAAsB,EACtB,UAAoC,EACpC,MAAgC,EAAE,4EAA4E;IAC9G,SAA0C,EAC1C,YAAsB;QAEtB,OAAO,IAAI,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IACnK,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.57.7"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@grackle-ai/runtime-copilot",
|
|
3
|
+
"version": "0.82.2",
|
|
4
|
+
"description": "Grackle GitHub Copilot runtime implementation",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/nick-pape/grackle.git",
|
|
9
|
+
"directory": "packages/runtime-copilot"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"grackle",
|
|
13
|
+
"runtime",
|
|
14
|
+
"copilot",
|
|
15
|
+
"github"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://github.com/nick-pape/grackle#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/nick-pape/grackle/issues"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=22.0.0"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "dist/index.js",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@grackle-ai/runtime-sdk": "0.82.2",
|
|
32
|
+
"@grackle-ai/common": "0.82.2"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@rushstack/heft": "1.2.7",
|
|
36
|
+
"@types/node": "^22.0.0",
|
|
37
|
+
"vitest": "^3.1.1",
|
|
38
|
+
"@grackle-ai/heft-rig": "0.0.1"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "heft build --clean",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"clean": "heft clean",
|
|
44
|
+
"_phase:build": "heft run --only build -- --clean",
|
|
45
|
+
"_phase:test": "vitest run"
|
|
46
|
+
}
|
|
47
|
+
}
|