Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@azure/msal-node": "^5.1.4",
"@github/copilot-sdk": "^0.3.0",
"@github/copilot-sdk": "^1.0.5",
"@hyperlight-dev/js-host-api": "file:deps/js-host-api",
"@modelcontextprotocol/sdk": "^1.29.0",
"boxen": "^8.0.1",
Expand Down
14 changes: 9 additions & 5 deletions src/agent/error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@
// barrel (index.d.ts), so we define them locally to stay type-safe
// without reaching into node_modules internals.

/** Input provided to the onErrorOccurred hook by the SDK. */
/**
* Input provided to the onErrorOccurred hook by the SDK.
*
* Declared as a minimal structural subset of the SDK's ErrorOccurredHookInput
* (which extends BaseHookInput) — only the fields this handler reads. Keeping it
* a subset means the handler stays assignable to ErrorOccurredHandler as the SDK
* evolves surrounding fields (e.g. 1.0.5 dropped the previously-present
* `cwd`/`timestamp`).
*/
interface ErrorOccurredHookInput {
/** Human-readable error description. */
error: string;
/** Where the error occurred: model call, tool execution, etc. */
errorContext: "model_call" | "tool_execution" | "system" | "user_input";
/** Whether the SDK considers this error recoverable. */
recoverable: boolean;
/** Unix timestamp (ms) when the error occurred. */
timestamp: number;
/** Working directory at time of error. */
cwd: string;
}

/** Output returned from the onErrorOccurred hook to tell the SDK what to do. */
Expand Down
10 changes: 5 additions & 5 deletions src/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7439,9 +7439,9 @@ async function main(): Promise<void> {
);
}

// Clean up: destroy the session and stop the CLI server
// Clean up: disconnect the session and stop the CLI server
if (state.activeSession) {
await state.activeSession.destroy();
await state.activeSession.disconnect();
state.activeSession = null;
}
await client.stop();
Expand Down Expand Up @@ -7486,13 +7486,13 @@ process.on("SIGINT", async () => {
console.log();
}

// Graceful SDK shutdown — destroy session, then stop client
// Graceful SDK shutdown — disconnect session, then stop client
// with a timeout fallback to forceStop.
if (state.activeSession) {
try {
await state.activeSession.destroy();
await state.activeSession.disconnect();
} catch {
// Best-effort — don't block exit on destroy failure
// Best-effort — don't block exit on disconnect failure
}
state.activeSession = null;
}
Expand Down
8 changes: 4 additions & 4 deletions src/agent/slash-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ export async function handleSlashCommand(
return true;
}
try {
await state.activeSession.destroy();
await state.activeSession.disconnect();
state.activeSession = await state.copilotClient.createSession({
sessionId: makeSessionId(),
model: state.currentModel,
Expand Down Expand Up @@ -810,7 +810,7 @@ export async function handleSlashCommand(
// If no match, pass through — the SDK will error if invalid
}
if (state.activeSession) {
await state.activeSession.destroy();
await state.activeSession.disconnect();
}
state.activeSession = await state.copilotClient.resumeSession(
targetId,
Expand Down Expand Up @@ -1007,7 +1007,7 @@ export async function handleSlashCommand(

case "/history": {
// Display recent conversation messages from the active session.
// Uses the SDK's session.getMessages() to retrieve the full
// Uses the SDK's session.getEvents() to retrieve the full
// event log, then filters for user & assistant messages.
if (!state.activeSession) {
console.log(` ${C.err("❌ No active session.")}`);
Expand All @@ -1018,7 +1018,7 @@ export async function handleSlashCommand(
const showCount =
Number.isFinite(histCount) && histCount > 0 ? histCount : 10;
try {
const events = await state.activeSession.getMessages();
const events = await state.activeSession.getEvents();
// Filter to user/assistant messages — skip tool calls, deltas, etc.
const messages = events
.filter(
Expand Down
4 changes: 2 additions & 2 deletions src/plugin-system/auditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ export async function deepAudit(
};
} finally {
// Clean up the one-shot audit session.
// SDK's session.destroy() clears local handlers but does NOT
// SDK's session.disconnect() releases local handlers but does NOT
// remove the session from client.sessions — the zombie entry
// persists and can cause duplicate event dispatch. We must
// evict it ourselves.
Expand All @@ -977,7 +977,7 @@ export async function deepAudit(
const auditSessionId = session.sessionId;
const sessionsMap = (client as any).sessions as
Map<string, unknown> | undefined;
await session.destroy();
await session.disconnect();
sessionsMap?.delete(auditSessionId);
} catch {
// Best-effort cleanup — don't mask the original error
Expand Down
Loading