fix: close PI-090 review findings

This commit is contained in:
2026-08-23 15:58:32 +08:00
parent 13ab383e53
commit 7e024093b1
11 changed files with 325 additions and 66 deletions

View File

@@ -88,7 +88,20 @@ interface ChangeRefreshBridgeRequest {
resourceId: string;
}
type BridgeRequest = LeaseBridgeRequest | SubagentBridgeRequest | ProductToolBridgeRequest | ChangeRefreshBridgeRequest;
interface ChangeTouchedBridgeRequest {
action: 'changes.touched';
conversationId: string;
workerGeneration: number;
runId: string;
resourceId: string;
paths: string[];
}
type BridgeRequest = LeaseBridgeRequest
| SubagentBridgeRequest
| ProductToolBridgeRequest
| ChangeRefreshBridgeRequest
| ChangeTouchedBridgeRequest;
export interface PiExtensionSubagentBridge {
scheduler: PiSubagentScheduler;
@@ -111,6 +124,12 @@ function bridgeRequest(value: unknown): value is BridgeRequest {
return typeof value.toolName === 'string' && 'input' in value;
}
if (value.action === 'changes.bash') return true;
if (value.action === 'changes.touched') {
return Array.isArray(value.paths)
&& value.paths.length > 0
&& value.paths.length <= 200
&& value.paths.every((filePath) => typeof filePath === 'string');
}
return (value.action === 'lease.acquire' || value.action === 'lease.release')
&& (value.leaseId === undefined || typeof value.leaseId === 'string');
}
@@ -304,6 +323,19 @@ export class PiManagedExtensionHost {
this.respond(response, 200, { marked: true });
return;
}
if (value.action === 'changes.touched') {
if (!this.productTools) {
this.respond(response, 503, { error: 'Conversation change tracker is unavailable' });
return;
}
await this.productTools.recordTouchedPaths(
record.conversationId,
value.runId,
value.paths,
);
this.respond(response, 200, { recorded: true });
return;
}
if (value.action === 'product.invoke') {
if (record.role !== 'parent') {
this.respond(response, 403, { error: 'Child workers cannot invoke parent product tools' });