feat(coding-agent): allow project trust extensions to defer

This commit is contained in:
Mario Zechner
2026-06-08 13:38:29 +02:00
parent 085a08582f
commit d8aef0feff
10 changed files with 72 additions and 19 deletions

View File

@@ -100,6 +100,7 @@ export type {
ModelSelectSource,
ProjectTrustContext,
ProjectTrustEvent,
ProjectTrustEventDecision,
ProjectTrustEventResult,
ProjectTrustHandler,
// Provider Registration

View File

@@ -202,13 +202,16 @@ export async function emitProjectTrustEvent(
const errors: ExtensionError[] = [];
for (const ext of extensionsResult.extensions) {
// A single extension may register multiple handlers for the same event.
// The first project_trust handler that returns a decision wins.
// The first project_trust handler that returns yes/no wins; undecided falls through.
const handlers = ext.handlers.get("project_trust");
if (!handlers || handlers.length === 0) continue;
for (const handler of handlers) {
try {
const handlerResult = (await handler(event, ctx)) as ProjectTrustEventResult;
if (handlerResult.trusted === "undecided") {
continue;
}
return { result: handlerResult, errors };
} catch (error) {
errors.push({

View File

@@ -503,8 +503,10 @@ export interface ProjectTrustEvent {
cwd: string;
}
export type ProjectTrustEventDecision = "yes" | "no" | "undecided";
export interface ProjectTrustEventResult {
trusted: boolean;
trusted: ProjectTrustEventDecision;
remember?: boolean;
}