Add lifecycle callbacks to SandboxRuntimeProvider for abort signal support

- Added onExecutionStart(sandboxId, signal) - called when sandbox execution begins
- Added onExecutionEnd(sandboxId) - called when sandbox execution ends
- Integrated callbacks in SandboxedIframe.execute()
- Enables providers to track and cancel async operations (e.g., userScript executions)
This commit is contained in:
Mario Zechner 2025-11-16 00:56:20 +01:00
parent 901449b38a
commit 3932c5e04c
2 changed files with 27 additions and 0 deletions

View file

@ -32,4 +32,21 @@ export interface SandboxRuntimeProvider {
* This will be appended to tool descriptions dynamically so the LLM knows what's available.
*/
getDescription(): string;
/**
* Optional lifecycle callback invoked when sandbox execution starts.
* Providers can use this to track abort signals for cancellation of async operations.
*
* @param sandboxId - The unique identifier for this sandbox execution
* @param signal - Optional AbortSignal that will be triggered if execution is cancelled
*/
onExecutionStart?(sandboxId: string, signal?: AbortSignal): void;
/**
* Optional lifecycle callback invoked when sandbox execution ends (success, error, or abort).
* Providers can use this to clean up any resources associated with the sandbox.
*
* @param sandboxId - The unique identifier for this sandbox execution
*/
onExecutionEnd?(sandboxId: string): void;
}