feat(coding-agent): add extension project trust decisions
This commit is contained in:
@@ -3,7 +3,12 @@ import { basename, join, resolve } from "node:path";
|
||||
import { resolvePath } from "../utils/paths.ts";
|
||||
import type { AgentSession } from "./agent-session.ts";
|
||||
import type { AgentSessionRuntimeDiagnostic, AgentSessionServices } from "./agent-session-services.ts";
|
||||
import type { ReplacedSessionContext, SessionShutdownEvent, SessionStartEvent } from "./extensions/index.ts";
|
||||
import type {
|
||||
ProjectTrustContext,
|
||||
ReplacedSessionContext,
|
||||
SessionShutdownEvent,
|
||||
SessionStartEvent,
|
||||
} from "./extensions/index.ts";
|
||||
import { emitSessionShutdownEvent } from "./extensions/runner.ts";
|
||||
import type { CreateAgentSessionResult } from "./sdk.ts";
|
||||
import { assertSessionCwdExists } from "./session-cwd.ts";
|
||||
@@ -32,6 +37,7 @@ export type CreateAgentSessionRuntimeFactory = (options: {
|
||||
agentDir: string;
|
||||
sessionManager: SessionManager;
|
||||
sessionStartEvent?: SessionStartEvent;
|
||||
projectTrustContext?: ProjectTrustContext;
|
||||
}) => Promise<CreateAgentSessionRuntimeResult>;
|
||||
|
||||
/**
|
||||
@@ -186,7 +192,11 @@ export class AgentSessionRuntime {
|
||||
|
||||
async switchSession(
|
||||
sessionPath: string,
|
||||
options?: { cwdOverride?: string; withSession?: (ctx: ReplacedSessionContext) => Promise<void> },
|
||||
options?: {
|
||||
cwdOverride?: string;
|
||||
withSession?: (ctx: ReplacedSessionContext) => Promise<void>;
|
||||
projectTrustContextFactory?: (cwd: string) => ProjectTrustContext;
|
||||
},
|
||||
): Promise<{ cancelled: boolean }> {
|
||||
const beforeResult = await this.emitBeforeSwitch("resume", sessionPath);
|
||||
if (beforeResult.cancelled) {
|
||||
@@ -203,6 +213,7 @@ export class AgentSessionRuntime {
|
||||
agentDir: this.services.agentDir,
|
||||
sessionManager,
|
||||
sessionStartEvent: { type: "session_start", reason: "resume", previousSessionFile },
|
||||
projectTrustContext: options?.projectTrustContextFactory?.(sessionManager.getCwd()),
|
||||
}),
|
||||
);
|
||||
await this.finishSessionReplacement(options?.withSession);
|
||||
|
||||
Reference in New Issue
Block a user