Protected Readonly_Protected Readonly_Protected Readonly_The ID of the user each task was created for. Kept beside the task rather than on it, because the task is the wire shape returned to clients.
Protected Readonly_Configured retention window in milliseconds.
Optional human-readable identifier surfaced in shutdown logs and used for
de-duplication when Register is called repeatedly with the same instance
but no name. Falls back to the constructor name.
Use Size.
Cancel an in-flight task, aborting its registered AbortController (if any) and
notifying any active SSE subscribers immediately.
Async caller-scoped task cancellation for IA2ATaskStore.
OptionalcontextUser: UserInfoOptional_provider: IMetadataProviderDrops a task from this process's cache (and its listeners and abort controller).
The task with this ID when it belongs to userId, otherwise undefined. A task that belongs
to someone else is indistinguishable from one that does not exist, so a caller cannot learn
another user's task IDs, nor read, continue or cancel their tasks.
Async caller-scoped task lookup for IA2ATaskStore.
OptionalcontextUser: UserInfoOptional_provider: IMetadataProviderNotify all subscribers of a task state change. Automatically cleans up listeners and abort controllers once the task reaches a terminal state.
Notifies subscribers and persists the updated task state.
OptionalcontextUser: UserInfoOptionalprovider: IMetadataProviderRegister an AbortController for an in-flight task so CancelTask can propagate
cancellation down to AgentOperations / AgentRunner.
Async persistence hook for IA2ATaskStore. In-memory store updates local Map only.
OptionalcontextUser: UserInfoOptional_provider: IMetadataProviderStores a task.
OptionalownerUserId: stringThe user the task was created for. Only that user can retrieve it through GetForUser; a task stored without an owner is retrievable by no one. Omit it when replacing a stored task, to keep its owner.
Stop the sweep timer and drop all tasks, listeners, and abort controllers. Idempotent.
Begin the periodic sweep. Idempotent; calling twice is safe. Uses unref()
so the sweep timer doesn't hold the process alive on its own.
Subscribe to event-driven updates for a specific task ID (replaces 500ms polling). Returns an unsubscribe function.
Drop terminal-state tasks that haven't been updated in retentionMs.
Returns the count evicted (useful for tests and diagnostics).
Bounded in-memory task store with periodic terminal-state cleanup.
Replaces the unbounded module-level
Map<string, Task>that was the single largest leak found in the audit (R2-C11): tasks accumulated forever with theirmessages[]andartifacts[]arrays, growing memory roughly astasks × messages × artifact-bytes. The store keeps the sameMap-like surface (set/get/delete/has/size) so callers don't change, and adds a sweeper that drops tasks in terminal state older thanretentionMs. ImplementsIShutdownableso the sweeper timer is cleared during graceful shutdown.