feat(core): add foundation for subagent tool isolation (#22708)

This commit is contained in:
AK
2026-03-16 20:54:33 -07:00
committed by GitHub
parent abe83fce0b
commit 695bcaea0d
9 changed files with 203 additions and 9 deletions
+19
View File
@@ -435,6 +435,25 @@ export abstract class DeclarativeTool<
readonly extensionId?: string,
) {}
clone(messageBus?: MessageBus): this {
// Note: we cannot use structuredClone() here because it does not preserve
// prototype chains or handle non-serializable properties (like functions).
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const cloned = Object.assign(
// eslint-disable-next-line no-restricted-syntax
Object.create(Object.getPrototypeOf(this)),
this,
) as this;
if (messageBus) {
Object.defineProperty(cloned, 'messageBus', {
value: messageBus,
writable: false,
configurable: true,
});
}
return cloned;
}
get isReadOnly(): boolean {
return READ_ONLY_KINDS.includes(this.kind);
}