Class: ServiceSessionRegistry
Defined in: runtime/services/service-session-registry.ts:15
Reference-counted registry of active ServiceSession daemons keyed by (scopeKey, serviceNode.id) (SPEC.md §3.4.2).
Manages skill-scoped service acquisition, reference-counted release on completeSkill, step-boundary/suspension quiescing (quiesceScopeServices), and pre-drain re-acquisition (reacquireActiveSkillServices) with [SERVICE_REACQUIRED] note generation.
Constructors
Constructor
new ServiceSessionRegistry(): ServiceSessionRegistry;Returns
ServiceSessionRegistry
Methods
acquireSkillServices()
acquireSkillServices<THandle>(params): Promise<ReadonlyMap<string, ServiceSession<THandle>>>;Defined in: runtime/services/service-session-registry.ts:31
Acquires or increments reference counts for all unlockedServices declared on params.skill.
Spawns a new ServiceSession via registry.services[serviceNode.type] only when serviceNode.id is not already running in params.scopeKey.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
THandle | unknown | Runtime handle type of the active isolation scope. |
Parameters
| Parameter | Type | Description |
|---|---|---|
params | AcquireSkillServicesParams<THandle> | Skill service acquisition parameters. |
Returns
Promise<ReadonlyMap<string, ServiceSession<THandle>>>
Live service sessions for params.scopeKey.
getActiveSessionsForScope()
getActiveSessionsForScope<THandle>(scopeKey): ReadonlyMap<string, ServiceSession<THandle>>;Defined in: runtime/services/service-session-registry.ts:182
Returns a read-only snapshot map of active ServiceSession instances for scopeKey.
Used to populate ExecutionContext.activeServiceSessions during tool and check execution.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
THandle | unknown | Runtime handle type of the active isolation scope. |
Parameters
| Parameter | Type | Description |
|---|---|---|
scopeKey | string | Canonical scope key. |
Returns
ReadonlyMap<string, ServiceSession<THandle>>
Map of serviceId to live ServiceSession.
quiesceScopeServices()
quiesceScopeServices(scopeKey?): Promise<readonly string[]>;Defined in: runtime/services/service-session-registry.ts:101
Stops and unmounts all active ServiceSession daemons running in scopeKey (matching exact scopeKey and ${scopeKey}:* sub-scopes) or across all scopes.
Invoked at step boundaries (.act() to .evaluate()), on actor suspension, and during .onLimitExceeded() cleanup.
Parameters
| Parameter | Type | Description |
|---|---|---|
scopeKey? | string | Optional canonical scope key or prefix to quiesce; quiesces all scopes when omitted. |
Returns
Promise<readonly string[]>
Identifiers of stopped service sessions.
reacquireActiveSkillServices()
reacquireActiveSkillServices<THandle>(params): Promise<readonly string[]>;Defined in: runtime/services/service-session-registry.ts:146
Re-acquires background daemon sessions for all activeSkillIds before draining remainingCalls on resume (SPEC.md §3.4.2).
Returns [SERVICE_REACQUIRED] synchronization notes for every service session started during re-acquisition.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
THandle | unknown | Runtime handle type of the active isolation scope. |
Parameters
| Parameter | Type | Description |
|---|---|---|
params | ReacquireSkillServicesParams<THandle> | Re-acquisition parameters and active skill IDs. |
Returns
Promise<readonly string[]>
Formatted [SERVICE_REACQUIRED] note strings for newly started services.
releaseSkillServices()
releaseSkillServices(scopeKey, skillId): Promise<readonly string[]>;Defined in: runtime/services/service-session-registry.ts:66
Releases a skill's reference lease across all services in scopeKey, stopping any daemon whose reference count drops to zero.
Stops all zero-reference sessions via Promise.allSettled and rethrows the first error after all settle (SPEC.md §3.4.2).
Parameters
| Parameter | Type | Description |
|---|---|---|
scopeKey | string | Canonical scope key of the active isolation scope. |
skillId | string | Completed skill identifier releasing its service leases. |
Returns
Promise<readonly string[]>
Identifiers of service sessions that were stopped.