Merge branch 'stack/agent-profiles-5-web-ui' into stack/agent-profiles-8-authoring
# Conflicts: # packages/preset/agent-presets/src/index.ts # packages/preset/agent-presets/tests/mount.spec.ts
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* projection units exist exactly once, keyed per session inside the plugins
|
||||
* themselves (they predate presets and were written for a shared world). An
|
||||
* agent joins by having its scope key parented to the mount's
|
||||
* ({@link setScopeParent}), which makes the mount's registrations visible to
|
||||
* ({@link bindScopeParent}), which makes the mount's registrations visible to
|
||||
* that agent's views and the mount's listeners receive that agent's events —
|
||||
* and a host reader with no agent at all (a cold transcript read) resolves
|
||||
* the same standing registrations by preset id.
|
||||
@@ -24,7 +24,7 @@
|
||||
import { stat } from 'node:fs/promises'
|
||||
import { Context, Service } from 'cordis'
|
||||
import z from 'schemastery'
|
||||
import { createScope, scopeOf, setScopeParent, type Scope, type ScopeKey } from '@deepseek-ai/dsh-scope'
|
||||
import { bindScopeParent, createScope, scopeOf, type Scope, type ScopeKey, type ScopeParentBinding } from '@deepseek-ai/dsh-scope'
|
||||
import { settingsNamespace, type SettingsScope, type default as SettingsService } from '@deepseek-ai/dsh-settings'
|
||||
import { discoverPresets } from './discovery.ts'
|
||||
import { copyComposition, deleteComposition, readComposition } from './authoring.ts'
|
||||
@@ -202,6 +202,14 @@ export class AgentPresets extends Service {
|
||||
*/
|
||||
private readonly standing = new Map<string, Promise<StandingMount>>()
|
||||
|
||||
/**
|
||||
* Parent bindings of the agents this roster composed, keyed by the agent's
|
||||
* scope key. The binding is dsh-scope's only re-link capability; holding it
|
||||
* here makes this service the sole authority that can move an agent between
|
||||
* standing compositions. WeakMap: entries die with their agents.
|
||||
*/
|
||||
private readonly bindings = new WeakMap<ScopeKey, ScopeParentBinding>()
|
||||
|
||||
/**
|
||||
* Compose one agent from a preset: ensure the preset's standing mount, then
|
||||
* parent the agent's scope key to it so the mount's registrations and
|
||||
@@ -222,7 +230,11 @@ export class AgentPresets extends Service {
|
||||
}
|
||||
const preset = await this.resolveMountable(id)
|
||||
const standing = await this.ensureStanding(preset)
|
||||
setScopeParent(agentKey, standing.key)
|
||||
// The one bind of this agent's ancestry. The binding is the only re-link
|
||||
// authority, held privately so nothing outside this roster can move a
|
||||
// composed agent to another preset; a later recompose layer re-links
|
||||
// through it under the caller-owned blank-session contract.
|
||||
this.bindings.set(agentKey, bindScopeParent(agentKey, standing.key))
|
||||
return preset
|
||||
}
|
||||
|
||||
@@ -325,7 +337,10 @@ export class AgentPresets extends Service {
|
||||
* and permanent, so the old composition stays for its other agents and the
|
||||
* new one is ensured BEFORE the link moves. An unknown or unusable preset
|
||||
* therefore throws with the agent exactly as it was — there is no torn-down
|
||||
* state to restore.
|
||||
* state to restore. The re-link runs through the binding this roster kept
|
||||
* from the agent's mount — dsh-scope's only re-link authority. An agent
|
||||
* that never composed one has nothing to re-link: the switch is then the
|
||||
* agent's first bind, exactly a mount.
|
||||
* @param agentCtx - the agent's scope context.
|
||||
* @param id - the preset to compose the agent from instead.
|
||||
* @returns the preset now installed.
|
||||
@@ -338,7 +353,12 @@ export class AgentPresets extends Service {
|
||||
}
|
||||
const preset = await this.resolveMountable(id)
|
||||
const standing = await this.ensureStanding(preset)
|
||||
setScopeParent(agentKey, standing.key)
|
||||
const binding = this.bindings.get(agentKey)
|
||||
if (binding === undefined) {
|
||||
this.bindings.set(agentKey, bindScopeParent(agentKey, standing.key))
|
||||
} else {
|
||||
binding.rebind(standing.key)
|
||||
}
|
||||
return preset
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user