@github/copilot-sdk 1.0.8-preview.0 → 1.0.9-preview.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/README.md +12 -1
- package/dist/cjs/generated/rpc.js +376 -11
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/session.js +9 -3
- package/dist/cjs/sessionFsProvider.js +43 -0
- package/dist/cjs/types.js +3 -0
- package/dist/generated/rpc.d.ts +2448 -227
- package/dist/generated/rpc.js +376 -11
- package/dist/generated/session-events.d.ts +260 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -0
- package/dist/session.js +9 -3
- package/dist/sessionFsProvider.d.ts +38 -2
- package/dist/sessionFsProvider.js +42 -0
- package/dist/types.d.ts +54 -3
- package/dist/types.js +2 -0
- package/package.json +2 -2
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
class SessionFsSqliteTransactionFailure extends Error {
|
|
2
|
+
/** Failure classification reported to the runtime. */
|
|
3
|
+
errorClass;
|
|
4
|
+
constructor(message, errorClass = "fatal") {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "SessionFsSqliteTransactionFailure";
|
|
7
|
+
this.errorClass = errorClass;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
1
10
|
function normalizeSqliteParams(params) {
|
|
2
11
|
if (!params) {
|
|
3
12
|
return void 0;
|
|
@@ -113,6 +122,29 @@ function createSessionFsAdapter(provider) {
|
|
|
113
122
|
);
|
|
114
123
|
return result ?? { rows: [], columns: [], rowsAffected: 0 };
|
|
115
124
|
},
|
|
125
|
+
sqliteTransaction: async ({ statements }) => {
|
|
126
|
+
if (!provider.sqlite?.transaction) {
|
|
127
|
+
return {
|
|
128
|
+
results: [],
|
|
129
|
+
error: {
|
|
130
|
+
errorClass: "fatal",
|
|
131
|
+
message: "SQLite transactions are not supported by this provider"
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const results = await provider.sqlite.transaction(
|
|
137
|
+
statements.map((statement) => ({
|
|
138
|
+
queryType: statement.queryType,
|
|
139
|
+
query: statement.query,
|
|
140
|
+
params: normalizeSqliteParams(statement.params)
|
|
141
|
+
}))
|
|
142
|
+
);
|
|
143
|
+
return { results: results.map((result) => ({ ...result })) };
|
|
144
|
+
} catch (err) {
|
|
145
|
+
return { results: [], error: toSqliteTransactionError(err) };
|
|
146
|
+
}
|
|
147
|
+
},
|
|
116
148
|
sqliteExists: async () => {
|
|
117
149
|
if (!provider.sqlite) {
|
|
118
150
|
throw new Error("SQLite is not supported by this provider");
|
|
@@ -126,6 +158,16 @@ function toSessionFsError(err) {
|
|
|
126
158
|
const code = e.code === "ENOENT" ? "ENOENT" : "UNKNOWN";
|
|
127
159
|
return { code, message: e.message ?? String(err) };
|
|
128
160
|
}
|
|
161
|
+
function toSqliteTransactionError(err) {
|
|
162
|
+
if (err instanceof SessionFsSqliteTransactionFailure) {
|
|
163
|
+
return { errorClass: err.errorClass, message: err.message };
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
errorClass: "fatal",
|
|
167
|
+
message: err instanceof Error ? err.message : String(err)
|
|
168
|
+
};
|
|
169
|
+
}
|
|
129
170
|
export {
|
|
171
|
+
SessionFsSqliteTransactionFailure,
|
|
130
172
|
createSessionFsAdapter
|
|
131
173
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -20,6 +20,9 @@ export type { SessionFsFileInfo } from "./sessionFsProvider.js";
|
|
|
20
20
|
export type { SessionFsSqliteQueryResult } from "./sessionFsProvider.js";
|
|
21
21
|
export type { SessionFsSqliteQueryType } from "./sessionFsProvider.js";
|
|
22
22
|
export type { SessionFsSqliteProvider } from "./sessionFsProvider.js";
|
|
23
|
+
export type { SessionFsSqliteStatement } from "./sessionFsProvider.js";
|
|
24
|
+
export type { SessionFsSqliteTransactionErrorClass } from "./sessionFsProvider.js";
|
|
25
|
+
export { SessionFsSqliteTransactionFailure } from "./sessionFsProvider.js";
|
|
23
26
|
export type { LlmInferenceHeaders } from "./generated/rpc.js";
|
|
24
27
|
export type { CopilotRequestContext } from "./copilotRequestHandler.js";
|
|
25
28
|
export { CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, } from "./copilotRequestHandler.js";
|
|
@@ -1154,6 +1157,45 @@ export interface ErrorOccurredHookOutput {
|
|
|
1154
1157
|
export type ErrorOccurredHandler = (input: ErrorOccurredHookInput, invocation: {
|
|
1155
1158
|
sessionId: string;
|
|
1156
1159
|
}) => Promise<ErrorOccurredHookOutput | void> | ErrorOccurredHookOutput | void;
|
|
1160
|
+
/**
|
|
1161
|
+
* Input for the agent-stop hook.
|
|
1162
|
+
*
|
|
1163
|
+
* Fires for the top-level (main) agent when it reaches a natural terminal stop
|
|
1164
|
+
* — i.e. the agent has gone idle without a pending non-terminal tool call and
|
|
1165
|
+
* was not aborted or blocked by a rejected tool. (For sub-agents, the runtime
|
|
1166
|
+
* fires a separate sub-agent stop lifecycle.)
|
|
1167
|
+
*/
|
|
1168
|
+
export interface AgentStopHookInput extends BaseHookInput {
|
|
1169
|
+
/** Why the agent stopped (for example, `"end_turn"`). */
|
|
1170
|
+
stopReason?: string;
|
|
1171
|
+
/** Path to the on-disk session transcript, when available. */
|
|
1172
|
+
transcriptPath?: string;
|
|
1173
|
+
/**
|
|
1174
|
+
* True when this stop is a re-entry triggered by a previous agent-stop
|
|
1175
|
+
* `block` decision (Claude-compatible `stop_hook_active` semantics). Lets a
|
|
1176
|
+
* handler avoid blocking indefinitely.
|
|
1177
|
+
*/
|
|
1178
|
+
stopHookActive?: boolean;
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Output for the agent-stop hook.
|
|
1182
|
+
*
|
|
1183
|
+
* Return `{ decision: "block", reason }` to keep the agent running: the
|
|
1184
|
+
* `reason` is enqueued as a follow-up user message so the agent continues
|
|
1185
|
+
* working (for example, to remediate findings surfaced by the hook). The
|
|
1186
|
+
* runtime caps consecutive blocks to prevent runaway loops. Returning nothing
|
|
1187
|
+
* (or omitting `decision`) lets the agent stop normally.
|
|
1188
|
+
*/
|
|
1189
|
+
export interface AgentStopHookOutput {
|
|
1190
|
+
decision?: "block";
|
|
1191
|
+
reason?: string;
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Handler for the agent-stop hook.
|
|
1195
|
+
*/
|
|
1196
|
+
export type AgentStopHandler = (input: AgentStopHookInput, invocation: {
|
|
1197
|
+
sessionId: string;
|
|
1198
|
+
}) => Promise<AgentStopHookOutput | void> | AgentStopHookOutput | void;
|
|
1157
1199
|
/**
|
|
1158
1200
|
* Configuration for session hooks
|
|
1159
1201
|
*/
|
|
@@ -1197,6 +1239,15 @@ export interface SessionHooks {
|
|
|
1197
1239
|
* Called when an error occurs
|
|
1198
1240
|
*/
|
|
1199
1241
|
onErrorOccurred?: ErrorOccurredHandler;
|
|
1242
|
+
/**
|
|
1243
|
+
* Called when the top-level agent reaches a natural terminal stop (it went
|
|
1244
|
+
* idle without pending work and was not aborted). Return
|
|
1245
|
+
* `{ decision: "block", reason }` to keep the agent running with `reason`
|
|
1246
|
+
* enqueued as a follow-up message — for example, to have the agent
|
|
1247
|
+
* remediate findings the handler surfaced. Returning nothing lets the
|
|
1248
|
+
* agent stop.
|
|
1249
|
+
*/
|
|
1250
|
+
onAgentStop?: AgentStopHandler;
|
|
1200
1251
|
}
|
|
1201
1252
|
/**
|
|
1202
1253
|
* Base interface for MCP server configuration.
|
|
@@ -1302,8 +1353,8 @@ export interface CustomAgentConfig {
|
|
|
1302
1353
|
model?: string;
|
|
1303
1354
|
/**
|
|
1304
1355
|
* Reasoning effort level for this agent's model.
|
|
1305
|
-
* When omitted,
|
|
1306
|
-
*
|
|
1356
|
+
* When omitted, the runtime resolves the effort from model configuration,
|
|
1357
|
+
* then inherits the parent effort only if this agent uses the same model.
|
|
1307
1358
|
*/
|
|
1308
1359
|
reasoningEffort?: ReasoningEffort;
|
|
1309
1360
|
}
|
|
@@ -2157,7 +2208,7 @@ export interface ProviderConfig {
|
|
|
2157
2208
|
*/
|
|
2158
2209
|
azure?: {
|
|
2159
2210
|
/**
|
|
2160
|
-
* API version.
|
|
2211
|
+
* API version. When omitted, the runtime uses the GA versionless v1 route.
|
|
2161
2212
|
*/
|
|
2162
2213
|
apiVersion?: string;
|
|
2163
2214
|
};
|
package/dist/types.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createSessionFsAdapter } from "./sessionFsProvider.js";
|
|
2
|
+
import { SessionFsSqliteTransactionFailure } from "./sessionFsProvider.js";
|
|
2
3
|
import {
|
|
3
4
|
CopilotRequestHandler,
|
|
4
5
|
CopilotWebSocketHandler,
|
|
@@ -122,6 +123,7 @@ export {
|
|
|
122
123
|
CopilotWebSocketHandler,
|
|
123
124
|
RuntimeConnection,
|
|
124
125
|
SYSTEM_MESSAGE_SECTIONS,
|
|
126
|
+
SessionFsSqliteTransactionFailure,
|
|
125
127
|
approveAll,
|
|
126
128
|
convertMcpCallToolResult,
|
|
127
129
|
createSessionFsAdapter,
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/github/copilot-sdk.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.0.
|
|
7
|
+
"version": "1.0.9-preview.0",
|
|
8
8
|
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
|
|
9
9
|
"main": "./dist/cjs/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"author": "GitHub",
|
|
57
57
|
"license": "MIT",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@github/copilot": "^1.0.
|
|
59
|
+
"@github/copilot": "^1.0.76-5",
|
|
60
60
|
"koffi": "^3.1.0",
|
|
61
61
|
"vscode-jsonrpc": "^8.2.1",
|
|
62
62
|
"zod": "^4.3.6"
|