Skip to content

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 ​

ts
new ServiceSessionRegistry(): ServiceSessionRegistry;

Returns ​

ServiceSessionRegistry

Methods ​

acquireSkillServices() ​

ts
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 ParameterDefault typeDescription
THandleunknownRuntime handle type of the active isolation scope.

Parameters ​

ParameterTypeDescription
paramsAcquireSkillServicesParams<THandle>Skill service acquisition parameters.

Returns ​

Promise<ReadonlyMap<string, ServiceSession<THandle>>>

Live service sessions for params.scopeKey.


getActiveSessionsForScope() ​

ts
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 ParameterDefault typeDescription
THandleunknownRuntime handle type of the active isolation scope.

Parameters ​

ParameterTypeDescription
scopeKeystringCanonical scope key.

Returns ​

ReadonlyMap<string, ServiceSession<THandle>>

Map of serviceId to live ServiceSession.


quiesceScopeServices() ​

ts
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 ​

ParameterTypeDescription
scopeKey?stringOptional canonical scope key or prefix to quiesce; quiesces all scopes when omitted.

Returns ​

Promise<readonly string[]>

Identifiers of stopped service sessions.


reacquireActiveSkillServices() ​

ts
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 ParameterDefault typeDescription
THandleunknownRuntime handle type of the active isolation scope.

Parameters ​

ParameterTypeDescription
paramsReacquireSkillServicesParams<THandle>Re-acquisition parameters and active skill IDs.

Returns ​

Promise<readonly string[]>

Formatted [SERVICE_REACQUIRED] note strings for newly started services.


releaseSkillServices() ​

ts
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 ​

ParameterTypeDescription
scopeKeystringCanonical scope key of the active isolation scope.
skillIdstringCompleted skill identifier releasing its service leases.

Returns ​

Promise<readonly string[]>

Identifiers of service sessions that were stopped.

Released under the MIT License.