@apnex/network-adapter 0.1.2 → 0.1.5
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/dist/build-info.json +6 -0
- package/dist/file-logger.d.ts +42 -0
- package/dist/file-logger.js +122 -0
- package/dist/file-logger.js.map +1 -0
- package/dist/index.d.ts +37 -13
- package/dist/index.js +42 -15
- package/dist/index.js.map +1 -1
- package/dist/kernel/adapter-config.d.ts +47 -0
- package/dist/kernel/adapter-config.js +90 -0
- package/dist/kernel/adapter-config.js.map +1 -0
- package/dist/kernel/agent-client.d.ts +25 -20
- package/dist/kernel/build-identity.d.ts +24 -0
- package/dist/kernel/build-identity.js +45 -0
- package/dist/kernel/build-identity.js.map +1 -0
- package/dist/kernel/event-router.d.ts +22 -1
- package/dist/kernel/event-router.js +45 -7
- package/dist/kernel/event-router.js.map +1 -1
- package/dist/kernel/handshake.d.ts +40 -4
- package/dist/kernel/handshake.js +46 -7
- package/dist/kernel/handshake.js.map +1 -1
- package/dist/kernel/harness-manifest.d.ts +51 -0
- package/dist/kernel/harness-manifest.js +96 -0
- package/dist/kernel/harness-manifest.js.map +1 -0
- package/dist/kernel/liveness-signal.d.ts +35 -0
- package/dist/kernel/liveness-signal.js +61 -0
- package/dist/kernel/liveness-signal.js.map +1 -0
- package/dist/kernel/liveness-watchdog.d.ts +78 -0
- package/dist/kernel/liveness-watchdog.js +115 -0
- package/dist/kernel/liveness-watchdog.js.map +1 -0
- package/dist/kernel/mcp-agent-client.d.ts +2 -2
- package/dist/kernel/mcp-agent-client.js +49 -3
- package/dist/kernel/mcp-agent-client.js.map +1 -1
- package/dist/kernel/poll-backstop.d.ts +93 -4
- package/dist/kernel/poll-backstop.js +193 -25
- package/dist/kernel/poll-backstop.js.map +1 -1
- package/dist/kernel/state-sync.d.ts +2 -13
- package/dist/kernel/state-sync.js.map +1 -1
- package/dist/notification-log.d.ts +8 -0
- package/dist/notification-log.js +10 -0
- package/dist/notification-log.js.map +1 -1
- package/dist/observability.d.ts +24 -0
- package/dist/observability.js +52 -0
- package/dist/observability.js.map +1 -0
- package/dist/prompt-format.js +82 -9
- package/dist/prompt-format.js.map +1 -1
- package/dist/tool-manager/catalog/health-revision.d.ts +43 -0
- package/dist/tool-manager/catalog/health-revision.js +61 -0
- package/dist/tool-manager/catalog/health-revision.js.map +1 -0
- package/dist/tool-manager/{tool-catalog-cache.d.ts → catalog/tool-catalog-cache.d.ts} +39 -19
- package/dist/tool-manager/{tool-catalog-cache.js → catalog/tool-catalog-cache.js} +53 -26
- package/dist/tool-manager/catalog/tool-catalog-cache.js.map +1 -0
- package/dist/tool-manager/catalog/tool-surface-reconciler.d.ts +93 -0
- package/dist/tool-manager/catalog/tool-surface-reconciler.js +101 -0
- package/dist/tool-manager/catalog/tool-surface-reconciler.js.map +1 -0
- package/dist/tool-manager/contracts.d.ts +91 -0
- package/dist/tool-manager/contracts.js +20 -0
- package/dist/tool-manager/contracts.js.map +1 -0
- package/dist/tool-manager/dispatch/dispatch.d.ts +77 -0
- package/dist/tool-manager/dispatch/dispatch.js +170 -0
- package/dist/tool-manager/dispatch/dispatch.js.map +1 -0
- package/dist/tool-manager/dispatch/tool-call-policy.d.ts +32 -0
- package/dist/tool-manager/dispatch/tool-call-policy.js +56 -0
- package/dist/tool-manager/dispatch/tool-call-policy.js.map +1 -0
- package/dist/tool-manager/{dispatcher.d.ts → orchestrator/dispatcher.d.ts} +110 -31
- package/dist/tool-manager/orchestrator/dispatcher.js +559 -0
- package/dist/tool-manager/orchestrator/dispatcher.js.map +1 -0
- package/dist/tool-manager/work-protocol/claimable-digest-tracker.d.ts +60 -0
- package/dist/tool-manager/work-protocol/claimable-digest-tracker.js +66 -0
- package/dist/tool-manager/work-protocol/claimable-digest-tracker.js.map +1 -0
- package/dist/tool-manager/work-protocol/work-lease-tracker.d.ts +59 -0
- package/dist/tool-manager/work-protocol/work-lease-tracker.js +134 -0
- package/dist/tool-manager/work-protocol/work-lease-tracker.js.map +1 -0
- package/dist/wire/mcp-transport.d.ts +1 -1
- package/dist/wire/mcp-transport.js +31 -7
- package/dist/wire/mcp-transport.js.map +1 -1
- package/dist/wire/slot-gate.d.ts +40 -0
- package/dist/wire/slot-gate.js +61 -0
- package/dist/wire/slot-gate.js.map +1 -0
- package/dist/wire/transport.d.ts +18 -0
- package/package.json +6 -3
- package/dist/kernel/instance.d.ts +0 -40
- package/dist/kernel/instance.js +0 -79
- package/dist/kernel/instance.js.map +0 -1
- package/dist/tool-manager/dispatcher.js +0 -379
- package/dist/tool-manager/dispatcher.js.map +0 -1
- package/dist/tool-manager/tool-catalog-cache.js.map +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* claimable-digest-tracker.ts — idea-353 W1 inbound wake (level-triggered,
|
|
3
|
+
* idle-gated, idempotent claimable-digest).
|
|
4
|
+
*
|
|
5
|
+
* The C1 work-queue is a pull model with no wake-on-ready signal: an idle
|
|
6
|
+
* eligible agent never learns that newly-claimable work appeared and sits
|
|
7
|
+
* unclaimed until someone manually nudges it (proven 3× in dogfood-1). This
|
|
8
|
+
* tracker is the **decision core** of the inbound wake — given the set of
|
|
9
|
+
* truly-claimable work ids for the agent's role (read via the stable
|
|
10
|
+
* `list_ready_work` contract) and whether the agent is idle, it decides whether
|
|
11
|
+
* to surface a digest ("N items claimable for your role").
|
|
12
|
+
*
|
|
13
|
+
* The design's ONE genuinely-new substrate is this **level-trigger / de-dup
|
|
14
|
+
* state** (the FR-22 storm-risk locus). The rules:
|
|
15
|
+
*
|
|
16
|
+
* - **Idle-gated (AC4):** never surface while the agent is mid-task. A busy
|
|
17
|
+
* tick neither emits NOR advances the baseline — so items that appeared
|
|
18
|
+
* while the agent was working are surfaced on the FIRST idle tick, not
|
|
19
|
+
* silently swallowed.
|
|
20
|
+
* - **Level-triggered / idempotent (AC3):** emit ONLY on an upward edge —
|
|
21
|
+
* 0→N, or a genuinely-NEW claimable id appeared since the last surfaced
|
|
22
|
+
* set. A steady N>0, a re-tick, or a Hub restart (the in-memory baseline
|
|
23
|
+
* survives, since the adapter process does not restart) yields no new ids
|
|
24
|
+
* → no emit. ID-keyed, not count-keyed, so a swap (one item claimed away,
|
|
25
|
+
* another appearing at the same count) still edges.
|
|
26
|
+
*
|
|
27
|
+
* Pairs with the at-tick guard in the host: the tracker is only fed on a
|
|
28
|
+
* SUCCESSFUL `list_ready_work` read — a failed read (Hub mid-restart, agent not
|
|
29
|
+
* streaming) skips the tick entirely and leaves the baseline untouched, so a
|
|
30
|
+
* transient empty/aborted read cannot manufacture a false 0→N replay.
|
|
31
|
+
*
|
|
32
|
+
* Pure + synchronous: all I/O (the list_ready_work read, the host emit) lives
|
|
33
|
+
* in the host tick; this class holds only the de-dup state + the decision, so
|
|
34
|
+
* the storm-proof contract is unit-testable without a live Hub (AC3/AC4).
|
|
35
|
+
*/
|
|
36
|
+
export class ClaimableDigestTracker {
|
|
37
|
+
/** The claimable id set the agent was last woken about (the de-dup baseline). */
|
|
38
|
+
lastSurfaced = new Set();
|
|
39
|
+
/**
|
|
40
|
+
* Decide whether this tick should surface a claimable-digest wake.
|
|
41
|
+
* @param input current claimable ids + idle state for this tick.
|
|
42
|
+
*/
|
|
43
|
+
reconcile(input) {
|
|
44
|
+
const count = input.claimableIds.length;
|
|
45
|
+
// AC4 idle-gate: never surface while mid-task, and do NOT advance the
|
|
46
|
+
// baseline — accumulate so the first idle tick surfaces what appeared
|
|
47
|
+
// while the agent was busy.
|
|
48
|
+
if (!input.isIdle) {
|
|
49
|
+
return { emit: false, count, newCount: 0 };
|
|
50
|
+
}
|
|
51
|
+
const newIds = input.claimableIds.filter((id) => !this.lastSurfaced.has(id));
|
|
52
|
+
// AC3 level-trigger: emit only on an upward edge (0→N or a new id). A
|
|
53
|
+
// steady set / re-tick / Hub-restart-replay yields no new ids → no emit.
|
|
54
|
+
const emit = count > 0 && newIds.length > 0;
|
|
55
|
+
// Advance the baseline to the current set on every IDLE pass (emit or not),
|
|
56
|
+
// so a claimed-away item doesn't wedge the de-dup and a later re-appearance
|
|
57
|
+
// re-edges correctly.
|
|
58
|
+
this.lastSurfaced = new Set(input.claimableIds);
|
|
59
|
+
return { emit, count, newCount: newIds.length };
|
|
60
|
+
}
|
|
61
|
+
/** Diagnostic/test accessor for the current de-dup baseline size. */
|
|
62
|
+
getSurfacedCount() {
|
|
63
|
+
return this.lastSurfaced.size;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=claimable-digest-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claimable-digest-tracker.js","sourceRoot":"","sources":["../../../src/tool-manager/work-protocol/claimable-digest-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAkBH,MAAM,OAAO,sBAAsB;IACjC,iFAAiF;IACzE,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IAEzC;;;OAGG;IACH,SAAS,CAAC,KAA2B;QACnC,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC;QAExC,sEAAsE;QACtE,sEAAsE;QACtE,4BAA4B;QAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAClB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;QAC7C,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7E,sEAAsE;QACtE,yEAAyE;QACzE,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAE5C,4EAA4E;QAC5E,4EAA4E;QAC5E,sBAAsB;QACtB,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAEhD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IAClD,CAAC;IAED,qEAAqE;IACrE,gBAAgB;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* work-lease-tracker.ts — idea-353 W2 outbound stall-prompt state.
|
|
3
|
+
*
|
|
4
|
+
* The lease-escalation ladder (lease-TTL → sweeper → poison → thrash-quarantine,
|
|
5
|
+
* C1-R2) has no GENTLE first rung: a held item that stalls goes straight from
|
|
6
|
+
* "leased" to silently reaped. W2 adds that rung — prompt the holder to
|
|
7
|
+
* renew / block / abandon BEFORE the sweeper's hard reap. It's notification-
|
|
8
|
+
* shaping over the EXISTING verbs (renew_lease / block_work / abandon_work), not
|
|
9
|
+
* a new verb.
|
|
10
|
+
*
|
|
11
|
+
* The adapter holds no work-lease state of its own (all WorkItem/lease state is
|
|
12
|
+
* Hub-side, and there is no "my held work" query). Rather than add a Hub tool or
|
|
13
|
+
* a second per-tick round-trip, this tracker **observes the agent's own
|
|
14
|
+
* work-verb tool-call results** as they pass through the dispatcher and
|
|
15
|
+
* maintains a local map of held leases + their expiry. On the heartbeat tick the
|
|
16
|
+
* host asks which held leases are approaching expiry.
|
|
17
|
+
*
|
|
18
|
+
* Window model: each observe of a claim/renew/start result (re)opens a lease
|
|
19
|
+
* window `[windowStart=observe-time, expiresAt]` and clears the per-window
|
|
20
|
+
* prompt latch. A lease is "due" once the tick time crosses `thresholdFraction`
|
|
21
|
+
* of that window AND is still before `expiresAt` (the whole point is *before*
|
|
22
|
+
* the reap), and it has not already been prompted this window. A renew resets
|
|
23
|
+
* the window + latch, so a renewing holder is never re-pestered. Completing /
|
|
24
|
+
* abandoning / releasing / blocking the item drops it entirely.
|
|
25
|
+
*
|
|
26
|
+
* Scope (thin MVP): tracks leases this session observes. A lease claimed in a
|
|
27
|
+
* prior adapter process (pre-restart) is not tracked — named as deferred; the
|
|
28
|
+
* common stall (claim → heads-down → near-expiry without renew) is in-session.
|
|
29
|
+
*
|
|
30
|
+
* Pure: all parsing is synchronous off the already-unwrapped tool result; the
|
|
31
|
+
* host owns the tick clock + the emit. Unit-testable without a live Hub (AC2).
|
|
32
|
+
*/
|
|
33
|
+
export interface StallPrompt {
|
|
34
|
+
workId: string;
|
|
35
|
+
/** Ms remaining until the Hub sweeper may reap the lease. */
|
|
36
|
+
msUntilExpiry: number;
|
|
37
|
+
}
|
|
38
|
+
export declare class WorkLeaseTracker {
|
|
39
|
+
private leases;
|
|
40
|
+
/**
|
|
41
|
+
* Observe one of THIS agent's work-verb tool-call results as it passes
|
|
42
|
+
* through the dispatcher. Best-effort: an unrecognized verb or an
|
|
43
|
+
* unparseable result is a no-op.
|
|
44
|
+
*/
|
|
45
|
+
observe(method: string, args: Record<string, unknown> | undefined, result: unknown, nowMs: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* Held leases that have crossed `thresholdFraction` of their current window
|
|
48
|
+
* but not yet expired, and have not been prompted this window. The host
|
|
49
|
+
* emits a renew/block/abandon stall-prompt for each (then marks them).
|
|
50
|
+
*
|
|
51
|
+
* @param thresholdFraction window fraction at which to prompt (~0.5–0.75;
|
|
52
|
+
* default 0.6 = 60% of the lease life elapsed).
|
|
53
|
+
*/
|
|
54
|
+
dueForStallPrompt(nowMs: number, thresholdFraction?: number): StallPrompt[];
|
|
55
|
+
/** Latch a lease as prompted for its current window (call after emitting). */
|
|
56
|
+
markPrompted(workId: string): void;
|
|
57
|
+
/** Diagnostic/test accessor: number of currently-held tracked leases. */
|
|
58
|
+
size(): number;
|
|
59
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* work-lease-tracker.ts — idea-353 W2 outbound stall-prompt state.
|
|
3
|
+
*
|
|
4
|
+
* The lease-escalation ladder (lease-TTL → sweeper → poison → thrash-quarantine,
|
|
5
|
+
* C1-R2) has no GENTLE first rung: a held item that stalls goes straight from
|
|
6
|
+
* "leased" to silently reaped. W2 adds that rung — prompt the holder to
|
|
7
|
+
* renew / block / abandon BEFORE the sweeper's hard reap. It's notification-
|
|
8
|
+
* shaping over the EXISTING verbs (renew_lease / block_work / abandon_work), not
|
|
9
|
+
* a new verb.
|
|
10
|
+
*
|
|
11
|
+
* The adapter holds no work-lease state of its own (all WorkItem/lease state is
|
|
12
|
+
* Hub-side, and there is no "my held work" query). Rather than add a Hub tool or
|
|
13
|
+
* a second per-tick round-trip, this tracker **observes the agent's own
|
|
14
|
+
* work-verb tool-call results** as they pass through the dispatcher and
|
|
15
|
+
* maintains a local map of held leases + their expiry. On the heartbeat tick the
|
|
16
|
+
* host asks which held leases are approaching expiry.
|
|
17
|
+
*
|
|
18
|
+
* Window model: each observe of a claim/renew/start result (re)opens a lease
|
|
19
|
+
* window `[windowStart=observe-time, expiresAt]` and clears the per-window
|
|
20
|
+
* prompt latch. A lease is "due" once the tick time crosses `thresholdFraction`
|
|
21
|
+
* of that window AND is still before `expiresAt` (the whole point is *before*
|
|
22
|
+
* the reap), and it has not already been prompted this window. A renew resets
|
|
23
|
+
* the window + latch, so a renewing holder is never re-pestered. Completing /
|
|
24
|
+
* abandoning / releasing / blocking the item drops it entirely.
|
|
25
|
+
*
|
|
26
|
+
* Scope (thin MVP): tracks leases this session observes. A lease claimed in a
|
|
27
|
+
* prior adapter process (pre-restart) is not tracked — named as deferred; the
|
|
28
|
+
* common stall (claim → heads-down → near-expiry without renew) is in-session.
|
|
29
|
+
*
|
|
30
|
+
* Pure: all parsing is synchronous off the already-unwrapped tool result; the
|
|
31
|
+
* host owns the tick clock + the emit. Unit-testable without a live Hub (AC2).
|
|
32
|
+
*/
|
|
33
|
+
/** The work-verbs whose results open/refresh a tracked lease window. */
|
|
34
|
+
const LEASE_OPEN_VERBS = new Set(["claim_work", "renew_lease", "start_work"]);
|
|
35
|
+
/** The work-verbs whose results retire a held lease (no longer the holder's stall). */
|
|
36
|
+
const LEASE_CLOSE_VERBS = new Set([
|
|
37
|
+
"complete_work",
|
|
38
|
+
"abandon_work",
|
|
39
|
+
"release_work",
|
|
40
|
+
"block_work",
|
|
41
|
+
]);
|
|
42
|
+
/** A renew (or claim) reopens the window + clears the prompt latch; start_work
|
|
43
|
+
* only refreshes the known expiry without resetting the window. */
|
|
44
|
+
const WINDOW_RESET_VERBS = new Set(["claim_work", "renew_lease"]);
|
|
45
|
+
/** Pull `{ workId, expiresAtMs }` out of an already-unwrapped work-verb result.
|
|
46
|
+
* Tolerant: returns null on any shape that isn't a lease-bearing workItem. */
|
|
47
|
+
function parseLease(result) {
|
|
48
|
+
const wi = result?.workItem;
|
|
49
|
+
if (!wi || typeof wi.id !== "string")
|
|
50
|
+
return null;
|
|
51
|
+
const expiresAt = wi.lease?.expiresAt;
|
|
52
|
+
if (typeof expiresAt !== "string")
|
|
53
|
+
return null;
|
|
54
|
+
const expiresAtMs = Date.parse(expiresAt);
|
|
55
|
+
if (Number.isNaN(expiresAtMs))
|
|
56
|
+
return null;
|
|
57
|
+
return { workId: wi.id, expiresAtMs };
|
|
58
|
+
}
|
|
59
|
+
/** Pull a workId for a CLOSE verb — prefer the result workItem, fall back to args. */
|
|
60
|
+
function parseWorkId(result, args) {
|
|
61
|
+
const id = result?.workItem?.id;
|
|
62
|
+
if (typeof id === "string")
|
|
63
|
+
return id;
|
|
64
|
+
if (args && typeof args.workId === "string")
|
|
65
|
+
return args.workId;
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
export class WorkLeaseTracker {
|
|
69
|
+
leases = new Map();
|
|
70
|
+
/**
|
|
71
|
+
* Observe one of THIS agent's work-verb tool-call results as it passes
|
|
72
|
+
* through the dispatcher. Best-effort: an unrecognized verb or an
|
|
73
|
+
* unparseable result is a no-op.
|
|
74
|
+
*/
|
|
75
|
+
observe(method, args, result, nowMs) {
|
|
76
|
+
if (LEASE_CLOSE_VERBS.has(method)) {
|
|
77
|
+
const workId = parseWorkId(result, args);
|
|
78
|
+
if (workId)
|
|
79
|
+
this.leases.delete(workId);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (!LEASE_OPEN_VERBS.has(method))
|
|
83
|
+
return;
|
|
84
|
+
const parsed = parseLease(result);
|
|
85
|
+
if (!parsed)
|
|
86
|
+
return;
|
|
87
|
+
const existing = this.leases.get(parsed.workId);
|
|
88
|
+
const resetWindow = WINDOW_RESET_VERBS.has(method) || !existing;
|
|
89
|
+
this.leases.set(parsed.workId, {
|
|
90
|
+
workId: parsed.workId,
|
|
91
|
+
// claim/renew reopen the window at observe-time; start_work keeps the
|
|
92
|
+
// existing window start (it does not extend the lease).
|
|
93
|
+
windowStartMs: resetWindow ? nowMs : existing.windowStartMs,
|
|
94
|
+
expiresAtMs: parsed.expiresAtMs,
|
|
95
|
+
prompted: resetWindow ? false : existing.prompted,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Held leases that have crossed `thresholdFraction` of their current window
|
|
100
|
+
* but not yet expired, and have not been prompted this window. The host
|
|
101
|
+
* emits a renew/block/abandon stall-prompt for each (then marks them).
|
|
102
|
+
*
|
|
103
|
+
* @param thresholdFraction window fraction at which to prompt (~0.5–0.75;
|
|
104
|
+
* default 0.6 = 60% of the lease life elapsed).
|
|
105
|
+
*/
|
|
106
|
+
dueForStallPrompt(nowMs, thresholdFraction = 0.6) {
|
|
107
|
+
const due = [];
|
|
108
|
+
for (const lease of this.leases.values()) {
|
|
109
|
+
if (lease.prompted)
|
|
110
|
+
continue;
|
|
111
|
+
const windowLen = lease.expiresAtMs - lease.windowStartMs;
|
|
112
|
+
if (windowLen <= 0)
|
|
113
|
+
continue;
|
|
114
|
+
const elapsed = nowMs - lease.windowStartMs;
|
|
115
|
+
// Prompt window: [thresholdFraction*windowLen, windowLen) — past the
|
|
116
|
+
// threshold but BEFORE expiry (the gentle rung is "before the reap").
|
|
117
|
+
if (elapsed >= thresholdFraction * windowLen && nowMs < lease.expiresAtMs) {
|
|
118
|
+
due.push({ workId: lease.workId, msUntilExpiry: lease.expiresAtMs - nowMs });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return due;
|
|
122
|
+
}
|
|
123
|
+
/** Latch a lease as prompted for its current window (call after emitting). */
|
|
124
|
+
markPrompted(workId) {
|
|
125
|
+
const lease = this.leases.get(workId);
|
|
126
|
+
if (lease)
|
|
127
|
+
lease.prompted = true;
|
|
128
|
+
}
|
|
129
|
+
/** Diagnostic/test accessor: number of currently-held tracked leases. */
|
|
130
|
+
size() {
|
|
131
|
+
return this.leases.size;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=work-lease-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work-lease-tracker.js","sourceRoot":"","sources":["../../../src/tool-manager/work-protocol/work-lease-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,wEAAwE;AACxE,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;AAC9E,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,eAAe;IACf,cAAc;IACd,cAAc;IACd,YAAY;CACb,CAAC,CAAC;AAEH;oEACoE;AACpE,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;AAkBlE;+EAC+E;AAC/E,SAAS,UAAU,CACjB,MAAe;IAEf,MAAM,EAAE,GAAI,MAAwC,EAAE,QAEzC,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,CAAC,EAAE,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAClD,MAAM,SAAS,GAAG,E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YAAY,CAAC,MAAc;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,KAAK;YAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IACnC,CAAC;IAED,yEAAyE;IACzE,IAAI;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -74,7 +74,7 @@ export declare class McpTransport implements ITransport {
|
|
|
74
74
|
private totalReconnects;
|
|
75
75
|
private consecutiveReconnects;
|
|
76
76
|
private lastReconnectCause?;
|
|
77
|
-
private
|
|
77
|
+
private readonly slots;
|
|
78
78
|
private reconnecting;
|
|
79
79
|
private closed;
|
|
80
80
|
constructor(config: TransportConfig);
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
50
50
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
51
51
|
import { LoggingMessageNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
52
|
+
import { SlotGate } from "./slot-gate.js";
|
|
52
53
|
import { normalizeToILogger } from "../logger.js";
|
|
53
54
|
/**
|
|
54
55
|
* Wire-level reconnect backoff curve. Pure function so the invariant
|
|
@@ -64,6 +65,18 @@ export function computeReconnectBackoff(consecutiveReconnects, baseDelay, maxDel
|
|
|
64
65
|
const exp = Math.min(Math.max(consecutiveReconnects, 0), 6);
|
|
65
66
|
return Math.min(baseDelay * Math.pow(2, exp), maxDelay);
|
|
66
67
|
}
|
|
68
|
+
const DEFAULT_MAX_IN_FLIGHT = 8;
|
|
69
|
+
/**
|
|
70
|
+
* bug-171: resolve the in-flight concurrency cap. Explicit config wins;
|
|
71
|
+
* otherwise `OIS_ADAPTER_MAX_INFLIGHT` env var (integer); otherwise
|
|
72
|
+
* {@link DEFAULT_MAX_IN_FLIGHT}. Floored at 1 (a cap of 0 would deadlock every
|
|
73
|
+
* request) so a malformed override can never wedge the wire.
|
|
74
|
+
*/
|
|
75
|
+
function resolveMaxInFlight(explicit) {
|
|
76
|
+
const fromEnv = parseInt(process.env.OIS_ADAPTER_MAX_INFLIGHT ?? "", 10);
|
|
77
|
+
const chosen = explicit ?? (Number.isFinite(fromEnv) ? fromEnv : DEFAULT_MAX_IN_FLIGHT);
|
|
78
|
+
return Math.max(1, Math.floor(chosen));
|
|
79
|
+
}
|
|
67
80
|
export class McpTransport {
|
|
68
81
|
cfg;
|
|
69
82
|
log;
|
|
@@ -83,7 +96,11 @@ export class McpTransport {
|
|
|
83
96
|
totalReconnects = 0;
|
|
84
97
|
consecutiveReconnects = 0;
|
|
85
98
|
lastReconnectCause;
|
|
86
|
-
|
|
99
|
+
// bug-171: bounded-concurrency gate for `request()` — caps concurrent
|
|
100
|
+
// in-flight calls at `cfg.maxInFlight` so a parallel read burst cannot
|
|
101
|
+
// overwhelm + drop the single shared wire. Excess callers FIFO-queue for a
|
|
102
|
+
// slot. Constructed in the ctor once `cfg.maxInFlight` is resolved.
|
|
103
|
+
slots;
|
|
87
104
|
// Re-entrancy guard: prevents overlapping reconnects.
|
|
88
105
|
reconnecting = false;
|
|
89
106
|
// True once `close()` was called — suppresses further reconnect attempts.
|
|
@@ -97,9 +114,11 @@ export class McpTransport {
|
|
|
97
114
|
firstKeepaliveDeadline: config.firstKeepaliveDeadline ?? 60_000,
|
|
98
115
|
sseWatchdogInterval: config.sseWatchdogInterval ?? 30_000,
|
|
99
116
|
reconnectDelay: config.reconnectDelay ?? 5_000,
|
|
117
|
+
maxInFlight: resolveMaxInFlight(config.maxInFlight),
|
|
100
118
|
getLastEventId: config.getLastEventId,
|
|
101
119
|
};
|
|
102
120
|
this.log = normalizeToILogger(config.logger, "McpTransport");
|
|
121
|
+
this.slots = new SlotGate(this.cfg.maxInFlight);
|
|
103
122
|
}
|
|
104
123
|
// ── ITransport: public surface ──────────────────────────────────────
|
|
105
124
|
get wireState() {
|
|
@@ -139,11 +158,15 @@ export class McpTransport {
|
|
|
139
158
|
}
|
|
140
159
|
}
|
|
141
160
|
async request(method, params) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
161
|
+
// bug-171: acquire a concurrency slot BEFORE the wire-state guard so the
|
|
162
|
+
// guard (and the call) run at slot-grant time, not enqueue time — a caller
|
|
163
|
+
// parked through a wire drop fails per-call here instead of NPE-ing on a
|
|
164
|
+
// torn-down client. The slot is always released in `finally`.
|
|
165
|
+
await this.slots.acquire();
|
|
146
166
|
try {
|
|
167
|
+
if (this._wireState !== "connected" || !this.client) {
|
|
168
|
+
throw new Error(`McpTransport.request: wire is ${this._wireState}`);
|
|
169
|
+
}
|
|
147
170
|
const result = await this.client.callTool({
|
|
148
171
|
name: method,
|
|
149
172
|
arguments: params,
|
|
@@ -160,7 +183,7 @@ export class McpTransport {
|
|
|
160
183
|
return null;
|
|
161
184
|
}
|
|
162
185
|
finally {
|
|
163
|
-
this.
|
|
186
|
+
this.slots.release();
|
|
164
187
|
}
|
|
165
188
|
}
|
|
166
189
|
async listMethods() {
|
|
@@ -201,7 +224,8 @@ export class McpTransport {
|
|
|
201
224
|
consecutiveReconnects: this.consecutiveReconnects,
|
|
202
225
|
lastReconnectCause: this.lastReconnectCause,
|
|
203
226
|
lastKeepaliveAt: this.lastKeepaliveAt || undefined,
|
|
204
|
-
requestsInFlight: this.
|
|
227
|
+
requestsInFlight: this.slots.inFlight,
|
|
228
|
+
requestsQueued: this.slots.queued,
|
|
205
229
|
};
|
|
206
230
|
}
|
|
207
231
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-transport.js","sourceRoot":"","sources":["../../src/wire/mcp-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6B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AO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,GAAG,CAAC,GAAG,CACV,yBAAyB,EACzB,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,EACtB,6BAA6B,GAAG,EAAE,CACnC,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SlotGate — a minimal FIFO counting semaphore (bug-171).
|
|
3
|
+
*
|
|
4
|
+
* Bounds the number of concurrent in-flight `request()` calls over the single
|
|
5
|
+
* shared MCP wire. A broad parallel read burst (e.g. a verifier conformance
|
|
6
|
+
* sweep firing dozens of read-only Hub calls at once) could otherwise overwhelm
|
|
7
|
+
* the one connection and drop the whole transport (`-32000 Connection closed`),
|
|
8
|
+
* stranding the session behind reconnect backoff. The gate paces the burst:
|
|
9
|
+
* excess callers queue for a slot rather than all firing at once. Queued calls
|
|
10
|
+
* still complete — only their START is paced.
|
|
11
|
+
*
|
|
12
|
+
* Invariants:
|
|
13
|
+
* - The held count NEVER exceeds `max` (a parked caller is handed the
|
|
14
|
+
* releaser's slot directly — no decrement/re-increment window that could
|
|
15
|
+
* momentarily admit one over the cap).
|
|
16
|
+
* - Hand-off is FIFO (first parked, first resumed).
|
|
17
|
+
* - `max` is floored at 1 by the caller (a cap of 0 would deadlock).
|
|
18
|
+
*/
|
|
19
|
+
export declare class SlotGate {
|
|
20
|
+
private readonly max;
|
|
21
|
+
private held;
|
|
22
|
+
private readonly waiters;
|
|
23
|
+
constructor(max: number);
|
|
24
|
+
/**
|
|
25
|
+
* Acquire a slot. Resolves immediately (incrementing the held count) while
|
|
26
|
+
* below `max`; otherwise parks until a holder {@link release}s a slot to it.
|
|
27
|
+
* Always pair with exactly one `release()` in a `finally`.
|
|
28
|
+
*/
|
|
29
|
+
acquire(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Release a slot. If a caller is parked, hand the slot directly to the next
|
|
32
|
+
* (FIFO) — the held count stays the same, so the cap is never momentarily
|
|
33
|
+
* exceeded. Otherwise decrement.
|
|
34
|
+
*/
|
|
35
|
+
release(): void;
|
|
36
|
+
/** Slots currently held (in-flight). Never exceeds `max`. */
|
|
37
|
+
get inFlight(): number;
|
|
38
|
+
/** Callers currently parked waiting for a slot. */
|
|
39
|
+
get queued(): number;
|
|
40
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SlotGate — a minimal FIFO counting semaphore (bug-171).
|
|
3
|
+
*
|
|
4
|
+
* Bounds the number of concurrent in-flight `request()` calls over the single
|
|
5
|
+
* shared MCP wire. A broad parallel read burst (e.g. a verifier conformance
|
|
6
|
+
* sweep firing dozens of read-only Hub calls at once) could otherwise overwhelm
|
|
7
|
+
* the one connection and drop the whole transport (`-32000 Connection closed`),
|
|
8
|
+
* stranding the session behind reconnect backoff. The gate paces the burst:
|
|
9
|
+
* excess callers queue for a slot rather than all firing at once. Queued calls
|
|
10
|
+
* still complete — only their START is paced.
|
|
11
|
+
*
|
|
12
|
+
* Invariants:
|
|
13
|
+
* - The held count NEVER exceeds `max` (a parked caller is handed the
|
|
14
|
+
* releaser's slot directly — no decrement/re-increment window that could
|
|
15
|
+
* momentarily admit one over the cap).
|
|
16
|
+
* - Hand-off is FIFO (first parked, first resumed).
|
|
17
|
+
* - `max` is floored at 1 by the caller (a cap of 0 would deadlock).
|
|
18
|
+
*/
|
|
19
|
+
export class SlotGate {
|
|
20
|
+
max;
|
|
21
|
+
held = 0;
|
|
22
|
+
waiters = [];
|
|
23
|
+
constructor(max) {
|
|
24
|
+
this.max = max;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Acquire a slot. Resolves immediately (incrementing the held count) while
|
|
28
|
+
* below `max`; otherwise parks until a holder {@link release}s a slot to it.
|
|
29
|
+
* Always pair with exactly one `release()` in a `finally`.
|
|
30
|
+
*/
|
|
31
|
+
async acquire() {
|
|
32
|
+
if (this.held < this.max) {
|
|
33
|
+
this.held++;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
await new Promise((resolve) => this.waiters.push(resolve));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Release a slot. If a caller is parked, hand the slot directly to the next
|
|
40
|
+
* (FIFO) — the held count stays the same, so the cap is never momentarily
|
|
41
|
+
* exceeded. Otherwise decrement.
|
|
42
|
+
*/
|
|
43
|
+
release() {
|
|
44
|
+
const next = this.waiters.shift();
|
|
45
|
+
if (next) {
|
|
46
|
+
next();
|
|
47
|
+
}
|
|
48
|
+
else if (this.held > 0) {
|
|
49
|
+
this.held--;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Slots currently held (in-flight). Never exceeds `max`. */
|
|
53
|
+
get inFlight() {
|
|
54
|
+
return this.held;
|
|
55
|
+
}
|
|
56
|
+
/** Callers currently parked waiting for a slot. */
|
|
57
|
+
get queued() {
|
|
58
|
+
return this.waiters.length;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=slot-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-gate.js","sourceRoot":"","sources":["../../src/wire/slot-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,QAAQ;IAIU;IAHrB,IAAI,GAAG,CAAC,CAAC;IACA,OAAO,GAAsB,EAAE,CAAC;IAEjD,YAA6B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAE5C;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,OAAO;QACT,CAAC;QACD,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QAClC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,EAAE,CAAC;QACT,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IAED,6DAA6D;IAC7D,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,mDAAmD;IACnD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/wire/transport.d.ts
CHANGED
|
@@ -96,6 +96,18 @@ export interface TransportConfig {
|
|
|
96
96
|
firstKeepaliveDeadline?: number;
|
|
97
97
|
sseWatchdogInterval?: number;
|
|
98
98
|
reconnectDelay?: number;
|
|
99
|
+
/**
|
|
100
|
+
* bug-171: maximum concurrent in-flight `request()` calls over the single
|
|
101
|
+
* shared wire. Excess callers QUEUE (FIFO) for a slot rather than all firing
|
|
102
|
+
* at once — a broad parallel read burst (e.g. a verifier conformance sweep)
|
|
103
|
+
* could otherwise overwhelm the one connection and drop the whole transport
|
|
104
|
+
* (`-32000 Connection closed`), stranding the session behind reconnect
|
|
105
|
+
* backoff. Queued calls still complete; only their start is paced. Normal
|
|
106
|
+
* single-agent flow (1–3 concurrent) never reaches the cap, so it is
|
|
107
|
+
* invisible there. Defaults to `OIS_ADAPTER_MAX_INFLIGHT` env var (parsed as
|
|
108
|
+
* integer), falling back to 8. Floored at 1.
|
|
109
|
+
*/
|
|
110
|
+
maxInFlight?: number;
|
|
99
111
|
/**
|
|
100
112
|
* Logger injection. Preferred is `ILogger`; the string variant is a
|
|
101
113
|
* Phase-2 migration aid so existing string-logger call sites can
|
|
@@ -127,6 +139,12 @@ export interface TransportMetrics {
|
|
|
127
139
|
readonly lastReconnectCause?: WireReconnectCause;
|
|
128
140
|
readonly lastKeepaliveAt?: number;
|
|
129
141
|
readonly requestsInFlight: number;
|
|
142
|
+
/**
|
|
143
|
+
* bug-171: callers currently parked waiting for an in-flight slot (the
|
|
144
|
+
* concurrency cap is saturated). 0 in normal flow; a sustained positive
|
|
145
|
+
* value is the observable signal of a request burst being paced.
|
|
146
|
+
*/
|
|
147
|
+
readonly requestsQueued: number;
|
|
130
148
|
}
|
|
131
149
|
export interface ITransport {
|
|
132
150
|
/** Current coarse wire state. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apnex/network-adapter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Universal MCP Network Adapter — L4/L7 transport for OIS agentic network",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,15 +10,17 @@
|
|
|
10
10
|
"README.md"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
+
"prebuild": "node ../../scripts/build/write-build-info.js",
|
|
13
14
|
"build": "tsc",
|
|
15
|
+
"prepack": "node ../../scripts/build/write-build-info.js --assert",
|
|
14
16
|
"dev": "tsc --watch",
|
|
15
17
|
"test": "vitest run",
|
|
16
18
|
"test:watch": "vitest"
|
|
17
19
|
},
|
|
18
20
|
"dependencies": {
|
|
19
21
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
20
|
-
"@apnex/cognitive-layer": "^0.1.
|
|
21
|
-
"@apnex/message-router": "^0.1.
|
|
22
|
+
"@apnex/cognitive-layer": "^0.1.3",
|
|
23
|
+
"@apnex/message-router": "^0.1.3"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
|
24
26
|
"@types/express": "^5.0.6",
|
|
@@ -26,6 +28,7 @@
|
|
|
26
28
|
"express": "^5.2.1",
|
|
27
29
|
"tsx": "^4.21.0",
|
|
28
30
|
"typescript": "^5.7.0",
|
|
31
|
+
"ulidx": "^2.4.1",
|
|
29
32
|
"vitest": "^4.1.4",
|
|
30
33
|
"zod": "^4.3.6"
|
|
31
34
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* globalInstanceId bootstrap.
|
|
3
|
-
*
|
|
4
|
-
* Identity is decoupled from authentication: the Hub token grants *access*
|
|
5
|
-
* and *role*; the globalInstanceId grants *identity*. This lets tokens be
|
|
6
|
-
* rotated without orphaning Agent entities.
|
|
7
|
-
*
|
|
8
|
-
* Storage: ~/.ois/instance.json (owner-private, 0600). NOT workspace-local —
|
|
9
|
-
* workspace scoping fails on multi-terminal, clone, and accidental git commit.
|
|
10
|
-
*
|
|
11
|
-
* First call generates a new UUID v4. Subsequent calls read it. If the file
|
|
12
|
-
* is deleted or corrupted, a new UUID is generated → new fingerprint → Hub
|
|
13
|
-
* creates a new Agent. The old Agent remains append-only with its queue
|
|
14
|
-
* intact; use `migrate_agent_queue` to recover pending work.
|
|
15
|
-
*/
|
|
16
|
-
export interface LoadInstanceOptions {
|
|
17
|
-
/** Override the default ~/.ois/instance.json location (for tests). */
|
|
18
|
-
instanceFile?: string;
|
|
19
|
-
/** Optional logger for diagnostics (regeneration on corruption, etc.). */
|
|
20
|
-
log?: (msg: string) => void;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Load an existing globalInstanceId from disk or create a new one.
|
|
24
|
-
* Returns the UUID (or the env-provided string override). Idempotent
|
|
25
|
-
* across calls within a process.
|
|
26
|
-
*
|
|
27
|
-
* Precedence: `OIS_INSTANCE_ID` env var wins outright — used when the
|
|
28
|
-
* operator wants a stable, human-meaningful identity (e.g. "greg" or
|
|
29
|
-
* "kate") and is responsible for uniqueness themselves. Absent that,
|
|
30
|
-
* falls back to the file-persisted UUID (original behaviour). The env
|
|
31
|
-
* path does NOT touch the file, so the two schemes coexist cleanly:
|
|
32
|
-
* toggling the env var off restores the file-derived UUID untouched.
|
|
33
|
-
*
|
|
34
|
-
* This is a pragmatic escape hatch that unblocks multi-agent
|
|
35
|
-
* co-location on a single user account (two Claude instances on one
|
|
36
|
-
* laptop). A richer design — separate agentName metadata plus an
|
|
37
|
-
* agentId derived from multiple inputs — is queued for the Entity
|
|
38
|
-
* Registry SSOT mission.
|
|
39
|
-
*/
|
|
40
|
-
export declare function loadOrCreateGlobalInstanceId(opts?: LoadInstanceOptions): string;
|