dsh-tool-manager 1.2.10 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/DESIGN.md +62 -1
- package/README.md +8 -2
- package/dist/catalog.d.ts +2 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +2 -1
- package/dist/catalog.js.map +1 -1
- package/dist/client.js +71 -3
- package/dist/composition-watch.d.ts +17 -2
- package/dist/composition-watch.d.ts.map +1 -1
- package/dist/composition-watch.js +40 -13
- package/dist/composition-watch.js.map +1 -1
- package/dist/dsh.d.ts +41 -2
- package/dist/dsh.d.ts.map +1 -1
- package/dist/dsh.js +30 -0
- package/dist/dsh.js.map +1 -1
- package/dist/index.d.ts +16 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +251 -40
- package/dist/index.js.map +1 -1
- package/dist/notices.d.ts +74 -0
- package/dist/notices.d.ts.map +1 -0
- package/dist/notices.js +99 -0
- package/dist/notices.js.map +1 -0
- package/dist/preset-repair.d.ts +128 -0
- package/dist/preset-repair.d.ts.map +1 -0
- package/dist/preset-repair.js +279 -0
- package/dist/preset-repair.js.map +1 -0
- package/dist/runtime.d.ts +133 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +615 -20
- package/dist/runtime.js.map +1 -1
- package/dist/snapshot.d.ts.map +1 -1
- package/dist/snapshot.js +0 -1
- package/dist/snapshot.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-facing notices.
|
|
3
|
+
*
|
|
4
|
+
* A registry reload is invisible to the transcript when the tool-manager
|
|
5
|
+
* re-attaches the Session, but when it cannot, the *person* has to know: the
|
|
6
|
+
* Session silently lost its preset tools and no amount of model-side wording
|
|
7
|
+
* helps. These notices are collected on the Host and rendered as a banner in
|
|
8
|
+
* the Web UI, so the reader learns about it where they are actually looking.
|
|
9
|
+
*/
|
|
10
|
+
export interface UserNotice {
|
|
11
|
+
id: string;
|
|
12
|
+
/** Epoch milliseconds, for ordering and display. */
|
|
13
|
+
at: number;
|
|
14
|
+
/**
|
|
15
|
+
* Which stage this notice describes: `reloading` is the transient "a registry
|
|
16
|
+
* reload just happened, a repair is coming", `failed` is the durable "the
|
|
17
|
+
* repair could not work, restart DSH". They share a Session and preset, so the
|
|
18
|
+
* stage is part of the identity rather than a replacement.
|
|
19
|
+
*/
|
|
20
|
+
kind: "reloading" | "failed";
|
|
21
|
+
/** The Session that lost tools, when the notice is about one. */
|
|
22
|
+
sessionId?: string;
|
|
23
|
+
/** The preset it was running. */
|
|
24
|
+
presetId?: string;
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
export interface UserNoticeInput {
|
|
28
|
+
kind: UserNotice["kind"];
|
|
29
|
+
sessionId?: string;
|
|
30
|
+
presetId?: string;
|
|
31
|
+
message: string;
|
|
32
|
+
}
|
|
33
|
+
/** In-memory notice box: one row per affected Session and preset. */
|
|
34
|
+
export declare class UserNotices {
|
|
35
|
+
private readonly items;
|
|
36
|
+
private sequence;
|
|
37
|
+
/**
|
|
38
|
+
* Record one notice, collapsing repeats of the same Session and preset.
|
|
39
|
+
*
|
|
40
|
+
* The runtime can attempt a repair more than once (each step retries), and a
|
|
41
|
+
* banner that multiplies on every retry is noise; the message is the same.
|
|
42
|
+
* @param input - what happened and to whom.
|
|
43
|
+
* @returns the stored notice, or `undefined` when it was already present.
|
|
44
|
+
*/
|
|
45
|
+
add(input: UserNoticeInput): UserNotice | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Drop a notice once its cause is gone.
|
|
48
|
+
*
|
|
49
|
+
* A `reloading` notice promises a repair, and a `failed` one claims the repair
|
|
50
|
+
* cannot work; when the repair does succeed both are stale, so a late success
|
|
51
|
+
* withdraws the whole story rather than leaving a "restart DSH" banner behind.
|
|
52
|
+
* @param sessionId - the Session that was repaired.
|
|
53
|
+
* @param presetId - the preset it was re-attached to.
|
|
54
|
+
*/
|
|
55
|
+
settle(sessionId: string | undefined, presetId: string | undefined): void;
|
|
56
|
+
/** Current notices, oldest first. */
|
|
57
|
+
list(): readonly UserNotice[];
|
|
58
|
+
/**
|
|
59
|
+
* Dismiss notices the reader has seen.
|
|
60
|
+
* @param ids - identifiers to drop; unknown ids are ignored.
|
|
61
|
+
* @returns how many were dropped.
|
|
62
|
+
*/
|
|
63
|
+
ack(ids: readonly string[]): number;
|
|
64
|
+
/** Whether anything is waiting to be read. */
|
|
65
|
+
get pending(): boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The Host-wide notice box.
|
|
69
|
+
*
|
|
70
|
+
* A plugin restart must not lose an unread notice, and the reader dismisses
|
|
71
|
+
* through whichever instance is live at that moment.
|
|
72
|
+
*/
|
|
73
|
+
export declare function userNotices(): UserNotices;
|
|
74
|
+
//# sourceMappingURL=notices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notices.d.ts","sourceRoot":"","sources":["../src/notices.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,oDAAoD;IACpD,EAAE,EAAE,MAAM,CAAC;IACX;;;;;OAKG;IACH,IAAI,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC7B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAoBD,qEAAqE;AACrE,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,QAAQ,CAAK;IAErB;;;;;;;OAOG;IACH,GAAG,CAAC,KAAK,EAAE,eAAe,GAAG,UAAU,GAAG,SAAS;IAqBnD;;;;;;;;OAQG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAQzE,qCAAqC;IACrC,IAAI,IAAI,SAAS,UAAU,EAAE;IAI7B;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;IAWnC,8CAA8C;IAC9C,IAAI,OAAO,IAAI,OAAO,CAErB;CACF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,WAAW,CAEzC"}
|
package/dist/notices.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** How many unacknowledged notices to keep before dropping the oldest. */
|
|
2
|
+
const LIMIT = 20;
|
|
3
|
+
/**
|
|
4
|
+
* The one notice box per Host, kept on the global object.
|
|
5
|
+
*
|
|
6
|
+
* This plugin declares `agentPresets` in `inject`, so DSH restarts it whenever
|
|
7
|
+
* the registry is replaced — the very moment a notice matters. An instance-local
|
|
8
|
+
* box would drop the banner exactly when the reader needs to see it.
|
|
9
|
+
*/
|
|
10
|
+
const BOX_KEY = Symbol.for("dsh-tool-manager.notice-box");
|
|
11
|
+
function sharedBox() {
|
|
12
|
+
const holder = globalThis;
|
|
13
|
+
holder[BOX_KEY] ??= new UserNotices();
|
|
14
|
+
return holder[BOX_KEY];
|
|
15
|
+
}
|
|
16
|
+
/** In-memory notice box: one row per affected Session and preset. */
|
|
17
|
+
export class UserNotices {
|
|
18
|
+
items = [];
|
|
19
|
+
sequence = 0;
|
|
20
|
+
/**
|
|
21
|
+
* Record one notice, collapsing repeats of the same Session and preset.
|
|
22
|
+
*
|
|
23
|
+
* The runtime can attempt a repair more than once (each step retries), and a
|
|
24
|
+
* banner that multiplies on every retry is noise; the message is the same.
|
|
25
|
+
* @param input - what happened and to whom.
|
|
26
|
+
* @returns the stored notice, or `undefined` when it was already present.
|
|
27
|
+
*/
|
|
28
|
+
add(input) {
|
|
29
|
+
const duplicate = this.items.find((item) => (item.kind === input.kind
|
|
30
|
+
&& item.sessionId === input.sessionId
|
|
31
|
+
&& item.presetId === input.presetId));
|
|
32
|
+
if (duplicate !== undefined)
|
|
33
|
+
return undefined;
|
|
34
|
+
this.sequence += 1;
|
|
35
|
+
const notice = {
|
|
36
|
+
id: `notice-${this.sequence}`,
|
|
37
|
+
at: Date.now(),
|
|
38
|
+
kind: input.kind,
|
|
39
|
+
message: input.message,
|
|
40
|
+
...(input.sessionId === undefined ? {} : { sessionId: input.sessionId }),
|
|
41
|
+
...(input.presetId === undefined ? {} : { presetId: input.presetId }),
|
|
42
|
+
};
|
|
43
|
+
this.items.push(notice);
|
|
44
|
+
if (this.items.length > LIMIT)
|
|
45
|
+
this.items.splice(0, this.items.length - LIMIT);
|
|
46
|
+
return notice;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Drop a notice once its cause is gone.
|
|
50
|
+
*
|
|
51
|
+
* A `reloading` notice promises a repair, and a `failed` one claims the repair
|
|
52
|
+
* cannot work; when the repair does succeed both are stale, so a late success
|
|
53
|
+
* withdraws the whole story rather than leaving a "restart DSH" banner behind.
|
|
54
|
+
* @param sessionId - the Session that was repaired.
|
|
55
|
+
* @param presetId - the preset it was re-attached to.
|
|
56
|
+
*/
|
|
57
|
+
settle(sessionId, presetId) {
|
|
58
|
+
for (let index = this.items.length - 1; index >= 0; index -= 1) {
|
|
59
|
+
const item = this.items[index];
|
|
60
|
+
if (item.sessionId !== sessionId || item.presetId !== presetId)
|
|
61
|
+
continue;
|
|
62
|
+
this.items.splice(index, 1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Current notices, oldest first. */
|
|
66
|
+
list() {
|
|
67
|
+
return this.items;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Dismiss notices the reader has seen.
|
|
71
|
+
* @param ids - identifiers to drop; unknown ids are ignored.
|
|
72
|
+
* @returns how many were dropped.
|
|
73
|
+
*/
|
|
74
|
+
ack(ids) {
|
|
75
|
+
const wanted = new Set(ids);
|
|
76
|
+
let dropped = 0;
|
|
77
|
+
for (let index = this.items.length - 1; index >= 0; index -= 1) {
|
|
78
|
+
if (!wanted.has(this.items[index].id))
|
|
79
|
+
continue;
|
|
80
|
+
this.items.splice(index, 1);
|
|
81
|
+
dropped += 1;
|
|
82
|
+
}
|
|
83
|
+
return dropped;
|
|
84
|
+
}
|
|
85
|
+
/** Whether anything is waiting to be read. */
|
|
86
|
+
get pending() {
|
|
87
|
+
return this.items.length > 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The Host-wide notice box.
|
|
92
|
+
*
|
|
93
|
+
* A plugin restart must not lose an unread notice, and the reader dismisses
|
|
94
|
+
* through whichever instance is live at that moment.
|
|
95
|
+
*/
|
|
96
|
+
export function userNotices() {
|
|
97
|
+
return sharedBox();
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=notices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notices.js","sourceRoot":"","sources":["../src/notices.ts"],"names":[],"mappings":"AAkCA,0EAA0E;AAC1E,MAAM,KAAK,GAAG,EAAE,CAAC;AAEjB;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAE1D,SAAS,SAAS;IAChB,MAAM,MAAM,GAAG,UAAgE,CAAC;IAChF,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,WAAW,EAAE,CAAC;IACtC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC;AAED,qEAAqE;AACrE,MAAM,OAAO,WAAW;IACL,KAAK,GAAiB,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
2
|
+
* Re-attach live Agents to the registry instance that replaced the one they
|
|
3
|
+
* were composed against.
|
|
4
|
+
*
|
|
5
|
+
* DSH replaces the whole `agent-preset-registry` service when the Loader
|
|
6
|
+
* restarts that node, and `dsh-scope` refuses to bind a scope key twice
|
|
7
|
+
* (`bindScopeParent()` throws for a key that already has a parent). The
|
|
8
|
+
* replacement instance therefore cannot `join()` an Agent composed by the
|
|
9
|
+
* retired one: `composedPreset()` answers `undefined`, the preset's standing
|
|
10
|
+
* composition was disposed with the old fiber, and the Session silently runs
|
|
11
|
+
* on whatever the root bundle provides.
|
|
12
|
+
*
|
|
13
|
+
* The re-link capability does exist — it is the `ScopeParentBinding` handle
|
|
14
|
+
* `bindScopeParent()` returned to the instance that bound the Agent, and its
|
|
15
|
+
* `rebind()` re-links an already-bound key by design. That handle lives in the
|
|
16
|
+
* registry's per-instance `bindings` WeakMap, and nothing public exposes the
|
|
17
|
+
* Agent's scope key, but both are plain data this plugin can still reach:
|
|
18
|
+
*
|
|
19
|
+
* - the retired instance stays alive while a reference exists, and its
|
|
20
|
+
* `bindings` map still holds the handle it took for each live Agent;
|
|
21
|
+
* - the key is the `Symbol("dsh.scope")`-tagged own property `createScope()`
|
|
22
|
+
* defined on the Agent's context, and a `WeakMap.get()` probe identifies it
|
|
23
|
+
* without depending on the symbol's identity.
|
|
24
|
+
*
|
|
25
|
+
* Replaying the registry's own `bind()`/`join()` bookkeeping against the live
|
|
26
|
+
* instance then restores the Agent without a restart. Everything here is
|
|
27
|
+
* feature-detected: a DSH that renames or privatizes these fields gets a
|
|
28
|
+
* refused repair and one warning, never a throw.
|
|
29
|
+
*/
|
|
30
|
+
import type { AgentLike, AgentPresetsLike } from "./dsh.js";
|
|
31
|
+
/** One re-attach attempt, recorded so a live Host can explain itself. */
|
|
32
|
+
export interface RepairAttempt {
|
|
33
|
+
at: number;
|
|
34
|
+
id?: string;
|
|
35
|
+
preset?: string;
|
|
36
|
+
/** How it ended: `re-attached`, `same-instance`, or why it gave up. */
|
|
37
|
+
outcome: string;
|
|
38
|
+
}
|
|
39
|
+
/** What one live Agent resolves, for `GET /tool-manager/api/repair`. */
|
|
40
|
+
export interface RepairAgentDiagnostics {
|
|
41
|
+
id?: string;
|
|
42
|
+
/** The preset the live instance reports for this Agent, if any. */
|
|
43
|
+
composed?: string;
|
|
44
|
+
/** The preset its Session log declares. */
|
|
45
|
+
declared?: string;
|
|
46
|
+
/** The preset this plugin last used for it. */
|
|
47
|
+
preset?: string;
|
|
48
|
+
/** How many tools its baseline snapshot holds. */
|
|
49
|
+
baseline?: number;
|
|
50
|
+
}
|
|
51
|
+
/** What the repair can see right now, for `GET /tool-manager/api/repair`. */
|
|
52
|
+
export interface RepairDiagnostics {
|
|
53
|
+
/** Whether a live registry instance is known. */
|
|
54
|
+
live: boolean;
|
|
55
|
+
/** Whether the instance it replaced is still reachable for its handles. */
|
|
56
|
+
retired: boolean;
|
|
57
|
+
/** Whether the live instance exposes the internals the repair needs. */
|
|
58
|
+
liveCapable: boolean;
|
|
59
|
+
/** Whether the retired instance still exposes its bindings map. */
|
|
60
|
+
retiredCapable: boolean;
|
|
61
|
+
/** Why a repair was refused, newest last; empty when nothing was refused. */
|
|
62
|
+
refusals: readonly string[];
|
|
63
|
+
/** The most recent re-attach attempts, newest last. */
|
|
64
|
+
attempts: readonly RepairAttempt[];
|
|
65
|
+
}
|
|
66
|
+
export interface PresetRepairOptions {
|
|
67
|
+
/** Report a refusal or failure once per reason, so a broken host stays quiet. */
|
|
68
|
+
warn: (message: string) => void;
|
|
69
|
+
}
|
|
70
|
+
/** The last registry instance this plugin saw, plus the one it replaced. */
|
|
71
|
+
export declare class PresetBindingRepair {
|
|
72
|
+
private readonly options;
|
|
73
|
+
private readonly reported;
|
|
74
|
+
/** Refusals in the order they happened, for diagnostics(). */
|
|
75
|
+
private readonly refused;
|
|
76
|
+
/** Recent re-attach attempts, newest last, for diagnostics(). */
|
|
77
|
+
private readonly attempts;
|
|
78
|
+
constructor(options: PresetRepairOptions);
|
|
79
|
+
/** Remember the instance DSH publishes, keeping the one it replaced. */
|
|
80
|
+
observe(live: AgentPresetsLike | undefined): void;
|
|
81
|
+
/**
|
|
82
|
+
* The preset an Agent was last bound to, read from the binding itself.
|
|
83
|
+
*
|
|
84
|
+
* The Session projection is the authoritative answer for what an Agent
|
|
85
|
+
* *should* run, but it belongs to one registry instance and is rebuilt lazily;
|
|
86
|
+
* the binding that is about to be repaired still names the composition the
|
|
87
|
+
* Agent actually lost, which is enough to restore it.
|
|
88
|
+
* @param agent - the Agent to inspect.
|
|
89
|
+
* @returns the preset id, when any instance still holds a binding for it.
|
|
90
|
+
*/
|
|
91
|
+
boundPreset(agent: AgentLike): string | undefined;
|
|
92
|
+
/** Record one attempt so a live Host can explain what it decided. */
|
|
93
|
+
private note;
|
|
94
|
+
/**
|
|
95
|
+
* Move one Agent's preset ancestry onto the live instance's revision.
|
|
96
|
+
*
|
|
97
|
+
* Mirrors `mount()`: `retain()` leases the revision, the re-linked binding
|
|
98
|
+
* takes its own reference, and the lease is released afterwards. A revision
|
|
99
|
+
* the live instance does not have throws (`agent-preset/not-found`,
|
|
100
|
+
* `agent-preset/invalid`) and the caller decides what to report.
|
|
101
|
+
* @param agent - the Agent to re-attach.
|
|
102
|
+
* @param wanted - the preset its Session runs; read from the lost binding when
|
|
103
|
+
* the Session projection is not available on the replacement instance.
|
|
104
|
+
* @returns whether the Agent now resolves that preset on the live instance.
|
|
105
|
+
*/
|
|
106
|
+
relink(agent: AgentLike, wanted: string | undefined): Promise<boolean>;
|
|
107
|
+
/**
|
|
108
|
+
* Re-mount an Agent on the instance that already knows it.
|
|
109
|
+
*
|
|
110
|
+
* `mount()` is the registry's own entry point: it leases the current revision
|
|
111
|
+
* of `presetId`, and `bind()` sees the existing binding and calls `rebind()`
|
|
112
|
+
* instead of `bindScopeParent()`. That is precisely the path a definition
|
|
113
|
+
* re-registration needs, so the plugin never has to reimplement it.
|
|
114
|
+
* @param live - the registry instance DSH currently publishes.
|
|
115
|
+
* @param agent - the Agent to re-attach.
|
|
116
|
+
* @param presetId - the preset its Session runs.
|
|
117
|
+
* @returns whether the Agent now resolves that preset.
|
|
118
|
+
*/
|
|
119
|
+
private remount;
|
|
120
|
+
/** Publish the re-linked binding and release the revision when the Agent dies. */
|
|
121
|
+
private adopt;
|
|
122
|
+
/** Drop the retired instance's reference to the revision it used to hold. */
|
|
123
|
+
private release;
|
|
124
|
+
/** Snapshot what the repair can see, so a live Host can be diagnosed. */
|
|
125
|
+
diagnostics(): RepairDiagnostics;
|
|
126
|
+
private refuse;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=preset-repair.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-repair.d.ts","sourceRoot":"","sources":["../src/preset-repair.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAyC5D,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wEAAwE;AACxE,MAAM,WAAW,sBAAsB;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,IAAI,EAAE,OAAO,CAAC;IACd,2EAA2E;IAC3E,OAAO,EAAE,O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diagnostics. */
|
|
3
|
+
const ATTEMPT_LIMIT = 20;
|
|
4
|
+
function registryHistory() {
|
|
5
|
+
const holder = globalThis;
|
|
6
|
+
holder[HISTORY_KEY] ??= {};
|
|
7
|
+
return holder[HISTORY_KEY];
|
|
8
|
+
}
|
|
9
|
+
/** The last registry instance this plugin saw, plus the one it replaced. */
|
|
10
|
+
export class PresetBindingRepair {
|
|
11
|
+
options;
|
|
12
|
+
reported = new Set();
|
|
13
|
+
/** Refusals in the order they happened, for diagnostics(). */
|
|
14
|
+
refused = [];
|
|
15
|
+
/** Recent re-attach attempts, newest last, for diagnostics(). */
|
|
16
|
+
attempts = [];
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
}
|
|
20
|
+
/** Remember the instance DSH publishes, keeping the one it replaced. */
|
|
21
|
+
observe(live) {
|
|
22
|
+
if (live === undefined)
|
|
23
|
+
return;
|
|
24
|
+
const history = registryHistory();
|
|
25
|
+
if (history.live === live)
|
|
26
|
+
return;
|
|
27
|
+
history.retired = history.live;
|
|
28
|
+
history.live = live;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The preset an Agent was last bound to, read from the binding itself.
|
|
32
|
+
*
|
|
33
|
+
* The Session projection is the authoritative answer for what an Agent
|
|
34
|
+
* *should* run, but it belongs to one registry instance and is rebuilt lazily;
|
|
35
|
+
* the binding that is about to be repaired still names the composition the
|
|
36
|
+
* Agent actually lost, which is enough to restore it.
|
|
37
|
+
* @param agent - the Agent to inspect.
|
|
38
|
+
* @returns the preset id, when any instance still holds a binding for it.
|
|
39
|
+
*/
|
|
40
|
+
boundPreset(agent) {
|
|
41
|
+
const history = registryHistory();
|
|
42
|
+
for (const candidate of [history.retired, history.live]) {
|
|
43
|
+
const bindings = candidate?.bindings;
|
|
44
|
+
if (bindings === undefined || typeof bindings.get !== "function")
|
|
45
|
+
continue;
|
|
46
|
+
const key = scopeKeyOf(agent.ctx, bindings);
|
|
47
|
+
if (key === undefined)
|
|
48
|
+
continue;
|
|
49
|
+
const presetId = bindings.get(key)?.generation?.mount?.presetId;
|
|
50
|
+
if (typeof presetId === "string")
|
|
51
|
+
return presetId;
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
/** Record one attempt so a live Host can explain what it decided. */
|
|
56
|
+
note(agent, presetId, outcome) {
|
|
57
|
+
this.attempts.push({
|
|
58
|
+
at: Date.now(),
|
|
59
|
+
...(agent.id === undefined ? {} : { id: agent.id }),
|
|
60
|
+
...(presetId === undefined ? {} : { preset: presetId }),
|
|
61
|
+
outcome,
|
|
62
|
+
});
|
|
63
|
+
if (this.attempts.length > ATTEMPT_LIMIT)
|
|
64
|
+
this.attempts.splice(0, this.attempts.length - ATTEMPT_LIMIT);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Move one Agent's preset ancestry onto the live instance's revision.
|
|
68
|
+
*
|
|
69
|
+
* Mirrors `mount()`: `retain()` leases the revision, the re-linked binding
|
|
70
|
+
* takes its own reference, and the lease is released afterwards. A revision
|
|
71
|
+
* the live instance does not have throws (`agent-preset/not-found`,
|
|
72
|
+
* `agent-preset/invalid`) and the caller decides what to report.
|
|
73
|
+
* @param agent - the Agent to re-attach.
|
|
74
|
+
* @param wanted - the preset its Session runs; read from the lost binding when
|
|
75
|
+
* the Session projection is not available on the replacement instance.
|
|
76
|
+
* @returns whether the Agent now resolves that preset on the live instance.
|
|
77
|
+
*/
|
|
78
|
+
async relink(agent, wanted) {
|
|
79
|
+
const history = registryHistory();
|
|
80
|
+
const live = history.live;
|
|
81
|
+
const retired = history.retired;
|
|
82
|
+
const presetId = wanted ?? this.boundPreset(agent);
|
|
83
|
+
if (live === undefined) {
|
|
84
|
+
this.note(agent, presetId, "no-live-instance");
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (presetId === undefined) {
|
|
88
|
+
this.note(agent, presetId, "no-preset-id");
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
// Case A: the instance is the same, but the definition was re-registered
|
|
92
|
+
// (`dsh-agent-preset` restarts whenever `agentPresets` is replaced). The
|
|
93
|
+
// Agent still holds a binding here, so the registry's own bind() path can
|
|
94
|
+
// rebind it; no handle from a dead instance is needed.
|
|
95
|
+
const sameInstance = live.bindings !== undefined
|
|
96
|
+
&& scopeKeyOf(agent.ctx, live.bindings) !== undefined;
|
|
97
|
+
if (sameInstance) {
|
|
98
|
+
this.note(agent, presetId, "same-instance");
|
|
99
|
+
return this.remount(live, agent, presetId);
|
|
100
|
+
}
|
|
101
|
+
// Case B: the instance was replaced. Only the retired instance still holds
|
|
102
|
+
// the `ScopeParentBinding` this Agent needs, so it has to be reachable.
|
|
103
|
+
if (retired === undefined || live === retired) {
|
|
104
|
+
this.note(agent, presetId, "no-retired-instance");
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (typeof live.retain !== "function" || typeof live.collect !== "function") {
|
|
108
|
+
return this.refuse("no-retain", "the registry exposes no retain()/collect()");
|
|
109
|
+
}
|
|
110
|
+
const bindings = retired.bindings;
|
|
111
|
+
if (bindings === undefined || typeof bindings.get !== "function") {
|
|
112
|
+
return this.refuse("no-bindings", "the replaced registry exposes no bindings map");
|
|
113
|
+
}
|
|
114
|
+
const key = scopeKeyOf(agent.ctx, bindings);
|
|
115
|
+
if (key === undefined) {
|
|
116
|
+
return this.refuse(`no-key:${agent.id ?? "?"}`, `Agent ${agent.id ?? "<unknown>"} has no binding on the replaced registry instance`);
|
|
117
|
+
}
|
|
118
|
+
const binding = bindings.get(key);
|
|
119
|
+
const parent = binding?.parent;
|
|
120
|
+
if (typeof parent?.rebind !== "function") {
|
|
121
|
+
return this.refuse(`no-rebind:${agent.id ?? "?"}`, `Agent ${agent.id ?? "<unknown>"}: the retained binding exposes no rebind()`);
|
|
122
|
+
}
|
|
123
|
+
const generation = await live.retain(presetId);
|
|
124
|
+
try {
|
|
125
|
+
// The re-linked binding holds its own reference, exactly as join() takes one.
|
|
126
|
+
generation.users = (generation.users ?? 0) + 1;
|
|
127
|
+
try {
|
|
128
|
+
parent.rebind(generation.key);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
generation.users -= 1;
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
this.adopt(live, bindings, agent, key, parent, generation);
|
|
135
|
+
this.release(live, binding?.generation);
|
|
136
|
+
emitToolsChange(live);
|
|
137
|
+
const composed = typeof live.composedPreset === "function"
|
|
138
|
+
? live.composedPreset(agent.ctx)
|
|
139
|
+
: generation.mount?.presetId;
|
|
140
|
+
this.note(agent, presetId, composed === presetId ? "re-attached" : `composed=${String(composed)}`);
|
|
141
|
+
return composed === presetId;
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
// Drop the lease retain() took; the binding keeps its own reference.
|
|
145
|
+
generation.users = (generation.users ?? 1) - 1;
|
|
146
|
+
await live.collect(generation);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Re-mount an Agent on the instance that already knows it.
|
|
151
|
+
*
|
|
152
|
+
* `mount()` is the registry's own entry point: it leases the current revision
|
|
153
|
+
* of `presetId`, and `bind()` sees the existing binding and calls `rebind()`
|
|
154
|
+
* instead of `bindScopeParent()`. That is precisely the path a definition
|
|
155
|
+
* re-registration needs, so the plugin never has to reimplement it.
|
|
156
|
+
* @param live - the registry instance DSH currently publishes.
|
|
157
|
+
* @param agent - the Agent to re-attach.
|
|
158
|
+
* @param presetId - the preset its Session runs.
|
|
159
|
+
* @returns whether the Agent now resolves that preset.
|
|
160
|
+
*/
|
|
161
|
+
async remount(live, agent, presetId) {
|
|
162
|
+
if (typeof live.mount !== "function") {
|
|
163
|
+
return this.refuse("no-mount", "the registry exposes no mount() to re-attach a known Agent");
|
|
164
|
+
}
|
|
165
|
+
await live.mount(agent.ctx, presetId);
|
|
166
|
+
const composed = typeof live.composedPreset === "function"
|
|
167
|
+
? live.composedPreset(agent.ctx)
|
|
168
|
+
: presetId;
|
|
169
|
+
return composed === presetId;
|
|
170
|
+
}
|
|
171
|
+
/** Publish the re-linked binding and release the revision when the Agent dies. */
|
|
172
|
+
adopt(live, bindings, agent, key, parent, generation) {
|
|
173
|
+
const next = { parent, generation };
|
|
174
|
+
// Keep both maps consistent: future bind() calls on either instance rebind
|
|
175
|
+
// instead of trying to join a key that already has a parent.
|
|
176
|
+
bindings.set?.(key, next);
|
|
177
|
+
live.bindings?.set?.(key, next);
|
|
178
|
+
const release = () => {
|
|
179
|
+
live.bindings?.delete?.(key);
|
|
180
|
+
bindings.delete?.(key);
|
|
181
|
+
generation.users = (generation.users ?? 1) - 1;
|
|
182
|
+
void live.collect?.(generation);
|
|
183
|
+
};
|
|
184
|
+
// The registry wires the same release through the Agent's own effect; do it
|
|
185
|
+
// here so the revision cannot outlive the Agent that joined it.
|
|
186
|
+
try {
|
|
187
|
+
agent.ctx.effect?.(() => release, "tool-manager.preset-relink");
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// A refused effect only costs a retained revision, never correctness.
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** Drop the retired instance's reference to the revision it used to hold. */
|
|
194
|
+
release(live, generation) {
|
|
195
|
+
if (generation === undefined || typeof generation.users !== "number")
|
|
196
|
+
return;
|
|
197
|
+
generation.users -= 1;
|
|
198
|
+
void live.collect?.(generation);
|
|
199
|
+
}
|
|
200
|
+
/** Snapshot what the repair can see, so a live Host can be diagnosed. */
|
|
201
|
+
diagnostics() {
|
|
202
|
+
const history = registryHistory();
|
|
203
|
+
const live = history.live;
|
|
204
|
+
const retired = history.retired;
|
|
205
|
+
return {
|
|
206
|
+
live: live !== undefined,
|
|
207
|
+
retired: retired !== undefined && retired !== live,
|
|
208
|
+
liveCapable: typeof live?.retain === "function" && typeof live?.collect === "function",
|
|
209
|
+
retiredCapable: retired?.bindings !== undefined && typeof retired.bindings.get === "function",
|
|
210
|
+
refusals: [...this.refused],
|
|
211
|
+
attempts: [...this.attempts],
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
refuse(key, reason) {
|
|
215
|
+
if (!this.reported.has(key)) {
|
|
216
|
+
this.reported.add(key);
|
|
217
|
+
this.refused.push(`${key}: ${reason}`);
|
|
218
|
+
this.options.warn(`tool-manager: cannot re-attach a Session to the reloaded agent preset registry: ${reason}.`);
|
|
219
|
+
}
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Read the scope key `createScope()` tagged onto a context.
|
|
225
|
+
*
|
|
226
|
+
* The tag is a symbol-keyed property whose value is the key itself. It is not
|
|
227
|
+
* necessarily an own property: `Context.extend()` returns a shadowed object when
|
|
228
|
+
* the context has a use-site shadow, and the tag then lives on the prototype.
|
|
229
|
+
* Walking the whole chain and probing each symbol value against the retired
|
|
230
|
+
* instance's bindings map finds it without hardcoding the symbol's identity.
|
|
231
|
+
*/
|
|
232
|
+
function scopeKeyOf(ctx, bindings) {
|
|
233
|
+
if (ctx === null || typeof ctx !== "object")
|
|
234
|
+
return undefined;
|
|
235
|
+
for (let cursor = ctx; cursor !== null; cursor = Object.getPrototypeOf(cursor)) {
|
|
236
|
+
let keys;
|
|
237
|
+
try {
|
|
238
|
+
keys = Reflect.ownKeys(cursor);
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
for (const symbol of keys) {
|
|
244
|
+
if (typeof symbol !== "symbol")
|
|
245
|
+
continue;
|
|
246
|
+
let value;
|
|
247
|
+
try {
|
|
248
|
+
value = ctx[symbol];
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (value === null || value === undefined)
|
|
254
|
+
continue;
|
|
255
|
+
if (typeof value !== "object" && typeof value !== "function")
|
|
256
|
+
continue;
|
|
257
|
+
let bound;
|
|
258
|
+
try {
|
|
259
|
+
bound = bindings.get(value);
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
if (bound !== undefined)
|
|
265
|
+
return value;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
/** Emit the invalidation the registry raises after any composition change. */
|
|
271
|
+
function emitToolsChange(live) {
|
|
272
|
+
try {
|
|
273
|
+
live.owner?.emit?.("tools/change");
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
// Observers are best-effort; the next step resolves tools anyway.
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=preset-repair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-repair.js","sourceRoot":"","sources":["../src/preset-repair.ts"],"names":[],"mappings":"AAiIA,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AAE3E,+DAA+D;AAC/D,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,SAAS,eAAe;IACtB,MAAM,MAAM,GAAG,UAAoE,CAAC;IACpF,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC;AAC7B,CAAC;AAED,4EAA4E;AAC5E,MAAM,OAAO,mBAAmB;IAOD;IANZ,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9C,8DAA8D;IAC7C,OAAO,GAAa,EAAE,CAAC;IACxC,iEAAiE;IAChD,QAAQ,GAAoB,EAAE,CAAC;IAEhD,YAA6B,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;IAAG,CAAC;IAE7D,wEAAwE;IACxE,OAAO,CAAC,IAAkC;QACxC,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO;QAC/B,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO;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