Resources
interface type-onlyRuntime-owned live resources (pty, child processes, connections).
Declaration
export interface Resources {
/**
* `dispose` is how a resource says what "shut down" means for it — the registry
* itself knows nothing about kinds, so a platform can introduce a resource type the
* runtime has never heard of and still have it cleaned up at process exit.
*
* Returns the PAIRED unregister for this exact registration: it removes the entry AND
* runs its dispose — out of the registry means shut down, or the process-exit sweep
* could no longer reach it. Both are identity-checked: a later overwrite by a successor
* turns the handle into a no-op and moves shutdown responsibility to the new
* registration — a dead generation can never touch a slot it no longer owns. This is
* the only way to remove a single entry; there is deliberately no release-by-id, which
* would be an unpaired delete aimed at whatever happens to occupy the slot.
*/
register(id: string, resource: unknown, dispose?: () => void): () => void;
claim<T = unknown>(id: string): T | undefined;
/**
* Disposes and removes every entry whose id belongs to the group (`terminal` covers
* `terminal:*`), in reverse registration order — later entries may depend on earlier
* ones, same convention as effects.
*
* A hook for IMPLEMENTATIONS, not a kernel mechanism: the kernel never calls it, and
* upgrade() has no opinion about resource compatibility. An impl's create() uses it to
* hard-stop the groups it cannot adopt from its predecessor (penguin does this over a
* declaration it leaves in the registry itself — see server hmr/platform.ts). Optional,
* so a registry that does not offer it simply carries every group across unchecked.
*/
disposeGroup?(group: string): void;
}Members (3)
register
register(id: string, resource: unknown, dispose?: () => void): () => voiddispose is how a resource says what "shut down" means for it — the registry
itself knows nothing about kinds, so a platform can introduce a resource type the
runtime has never heard of and still have it cleaned up at process exit.
Returns the PAIRED unregister for this exact registration: it removes the entry AND runs its dispose — out of the registry means shut down, or the process-exit sweep could no longer reach it. Both are identity-checked: a later overwrite by a successor turns the handle into a no-op and moves shutdown responsibility to the new registration — a dead generation can never touch a slot it no longer owns. This is the only way to remove a single entry; there is deliberately no release-by-id, which would be an unpaired delete aimed at whatever happens to occupy the slot.
stringunknown() => void() => voidclaim
claim<T = unknown>(id: string): T | undefinedstringT | undefineddisposeGroup
disposeGroup?(group: string): voidDisposes and removes every entry whose id belongs to the group (terminal covers
terminal:*), in reverse registration order — later entries may depend on earlier
ones, same convention as effects.
A hook for IMPLEMENTATIONS, not a kernel mechanism: the kernel never calls it, and upgrade() has no opinion about resource compatibility. An impl's create() uses it to hard-stop the groups it cannot adopt from its predecessor (penguin does this over a declaration it leaves in the registry itself — see server hmr/platform.ts). Optional, so a registry that does not offer it simply carries every group across unchecked.
stringvoid