@adhdev/mesh-shared 1.0.60-rc.7 → 1.0.60-rc.71
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/brain-routing.d.ts +2 -2
- package/dist/index.d.ts +11 -0
- package/dist/index.js +3156 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2827 -45
- package/dist/index.mjs.map +1 -1
- package/dist/interpolation.d.ts +0 -9
- package/dist/keyed-doc-delta.d.ts +105 -0
- package/dist/magi.d.ts +1 -1
- package/dist/mesh-tool-names.d.ts +27 -2
- package/dist/mesh-vocabulary.d.ts +67 -0
- package/dist/mission-brief.d.ts +62 -0
- package/dist/outbound-message.d.ts +202 -0
- package/dist/path-ownership.d.ts +101 -0
- package/dist/protocol/daemon-server.d.ts +379 -0
- package/dist/protocol/dashboard-daemon-p2p.d.ts +213 -0
- package/dist/protocol/dashboard-server.d.ts +240 -0
- package/dist/protocol/dashboard-wire-version.d.ts +21 -0
- package/dist/protocol/envelope.d.ts +55 -0
- package/dist/protocol/index.d.ts +16 -0
- package/dist/session-launch.d.ts +113 -0
- package/dist/session-status.d.ts +75 -0
- package/dist/slot-proposal.d.ts +1 -1
- package/dist/turn-evidence.d.ts +434 -0
- package/dist/turn-ipc.d.ts +1040 -0
- package/dist/types.d.ts +11 -0
- package/dist/worker-protocol.d.ts +69 -0
- package/dist/ws-protocol.d.ts +69 -41
- package/package.json +1 -1
- package/src/brain-routing.ts +3 -3
- package/src/index.ts +11 -0
- package/src/interpolation.ts +0 -18
- package/src/keyed-doc-delta.ts +413 -0
- package/src/magi.ts +1 -1
- package/src/mesh-tool-names.ts +65 -19
- package/src/mesh-vocabulary.ts +95 -0
- package/src/mission-brief.ts +153 -0
- package/src/outbound-message.ts +320 -0
- package/src/path-ownership.ts +271 -0
- package/src/protocol/daemon-server.ts +541 -0
- package/src/protocol/dashboard-daemon-p2p.ts +273 -0
- package/src/protocol/dashboard-server.ts +340 -0
- package/src/protocol/dashboard-wire-version.ts +27 -0
- package/src/protocol/envelope.ts +75 -0
- package/src/protocol/index.ts +17 -0
- package/src/session-launch.ts +247 -0
- package/src/session-status.ts +164 -0
- package/src/slot-proposal.ts +1 -1
- package/src/turn-evidence.ts +596 -0
- package/src/turn-ipc.ts +2330 -0
- package/src/types.ts +8 -0
- package/src/worker-protocol.ts +164 -0
- package/src/ws-protocol.ts +98 -93
package/dist/types.d.ts
CHANGED
|
@@ -136,4 +136,15 @@ export interface RepoMeshSessionStatus {
|
|
|
136
136
|
startedAt?: string | null;
|
|
137
137
|
lastActivityAt?: string | null;
|
|
138
138
|
isCached?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Worker MCP delivery outcome for this session's launch (present only for a
|
|
141
|
+
* mesh-delegated launch). `reason` is a short enum code, never free text —
|
|
142
|
+
* see `WORKER_MCP_DELIVERY_REASONS` (daemon-core's `mesh/worker-mcp-isolation.ts`,
|
|
143
|
+
* the source of the vocabulary this field's values are drawn from; not
|
|
144
|
+
* re-exported here so mesh-shared stays a dependency-free leaf).
|
|
145
|
+
*/
|
|
146
|
+
workerMcp?: {
|
|
147
|
+
delivered: boolean;
|
|
148
|
+
reason?: string;
|
|
149
|
+
};
|
|
139
150
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* worker-protocol — what a delegated worker is told, and what it may call.
|
|
3
|
+
*
|
|
4
|
+
* Wiring-unification Phase F1 (docs/design/2026-09-23-wiring-unification.md §7b).
|
|
5
|
+
*
|
|
6
|
+
* Measured 2026-09-23 on the live preview ledger: 635 worker attempts in 14
|
|
7
|
+
* days, 3 `report_completion` calls. The worker MCP was delivered to every
|
|
8
|
+
* provider and never used, because nothing ever told the worker it existed —
|
|
9
|
+
* the dispatched task body carried no instruction and the coordinator prompt
|
|
10
|
+
* did not mention the worker tools at all. The only text a worker saw about
|
|
11
|
+
* its tools was the tool description.
|
|
12
|
+
*
|
|
13
|
+
* This module is the single source for BOTH sides of that contract:
|
|
14
|
+
* - `WORKER_TOOLS` — exactly what `adhdev mcp --mode worker` advertises
|
|
15
|
+
* (a parity test in mcp-server pins ListTools to this tuple);
|
|
16
|
+
* - `renderWorkerProtocolFooter()` — the block appended to EVERY dispatched
|
|
17
|
+
* task body, so a worker learns the protocol from the task itself;
|
|
18
|
+
* - `renderCoordinatorWorkerSection()` — the matching paragraph the
|
|
19
|
+
* coordinator prompt carries, so the coordinator expects structured reports
|
|
20
|
+
* and stops polling for them.
|
|
21
|
+
*
|
|
22
|
+
* Wiring-unification Phase H2 adds an optional mission-brief block: when a
|
|
23
|
+
* dispatched task belongs to a mission that carries a `MissionBrief`
|
|
24
|
+
* (`./mission-brief.ts`), `renderWorkerProtocolFooter` renders it ABOVE the
|
|
25
|
+
* `WORKER_PROTOCOL_FOOTER_MARKER` line. This is deliberate placement, not an
|
|
26
|
+
* accident of insertion order: `hasWorkerProtocolFooter` / `stripWorkerProtocolFooter`
|
|
27
|
+
* both key off the marker line alone, so a body with a brief block strips
|
|
28
|
+
* identically to one without — the brief is authored content from the
|
|
29
|
+
* coordinator's point of view (like the task message itself), never part of
|
|
30
|
+
* the protocol contract the marker demarcates.
|
|
31
|
+
*/
|
|
32
|
+
import { type MissionBrief } from './mission-brief';
|
|
33
|
+
export declare const WORKER_TOOLS: readonly ["report_completion", "progress_update", "peer_context_pull", "git_status", "git_log", "git_diff"];
|
|
34
|
+
export type WorkerTool = typeof WORKER_TOOLS[number];
|
|
35
|
+
export declare function isWorkerTool(value: unknown): value is WorkerTool;
|
|
36
|
+
/** Stable marker line so a body is never footered twice and tests can find it. */
|
|
37
|
+
export declare const WORKER_PROTOCOL_FOOTER_MARKER = "--- adhdev worker protocol ---";
|
|
38
|
+
export interface WorkerProtocolFooterInput {
|
|
39
|
+
taskId?: string;
|
|
40
|
+
taskMode?: string;
|
|
41
|
+
difficulty?: string;
|
|
42
|
+
readonly?: boolean;
|
|
43
|
+
/** Number of handoff notes enclosed above the footer, when any. */
|
|
44
|
+
enclosedHandoffNotes?: number;
|
|
45
|
+
/** H2: the owning mission's brief, when this task belongs to one. Rendered above the marker line — see module doc. */
|
|
46
|
+
missionBrief?: MissionBrief;
|
|
47
|
+
}
|
|
48
|
+
export declare function hasWorkerProtocolFooter(body: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The protocol block appended to a dispatched task. Written for the model that
|
|
51
|
+
* receives it: imperative, short, and explicit about what is NOT available so
|
|
52
|
+
* the worker does not go looking for coordinator tools.
|
|
53
|
+
*/
|
|
54
|
+
export declare function renderWorkerProtocolFooter(input?: WorkerProtocolFooterInput): string;
|
|
55
|
+
/**
|
|
56
|
+
* The authored text of a dispatched body: everything before the footer marker.
|
|
57
|
+
* Ledger descriptors, replay fixtures and tests compare authored text, never
|
|
58
|
+
* the protocol block.
|
|
59
|
+
*/
|
|
60
|
+
export declare function stripWorkerProtocolFooter(body: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Append the footer to a body that does not carry one yet. Idempotent.
|
|
63
|
+
*/
|
|
64
|
+
export declare function appendWorkerProtocolFooter(body: string, input?: WorkerProtocolFooterInput): string;
|
|
65
|
+
/**
|
|
66
|
+
* The paragraph the COORDINATOR prompt carries about its workers. Kept next to
|
|
67
|
+
* the footer so the two halves of the protocol cannot drift apart.
|
|
68
|
+
*/
|
|
69
|
+
export declare function renderCoordinatorWorkerSection(): string;
|
package/dist/ws-protocol.d.ts
CHANGED
|
@@ -1,50 +1,78 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ws-protocol —
|
|
3
|
-
*
|
|
2
|
+
* ws-protocol — name-only aliases for the daemon↔server WS surface and the
|
|
3
|
+
* daemon↔dashboard P2P DataChannel surface, plus the `auth_ok.payload.limits`
|
|
4
|
+
* contract.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* ServerToDaemon command set; it should adopt these unions and extend them
|
|
16
|
-
* (`ServerToDaemonMsg | <proprietary extras>`) rather than re-declaring the
|
|
17
|
-
* shared members. Members here are the ones OSS daemon-core itself produces
|
|
18
|
-
* or matches.
|
|
6
|
+
* Wiring-unification Phase A2: the typed frame unions now live in ./protocol
|
|
7
|
+
* (one file per link, payloads included). This file keeps the symbols that
|
|
8
|
+
* pre-dated them — `DaemonToServerWsMsg`, `ServerToDaemonWsMsg`,
|
|
9
|
+
* `P2PSignalingWsMsg`, `DashboardP2PMessageKind` and the two name arrays —
|
|
10
|
+
* DERIVED from the protocol unions rather than re-declared, so they cannot
|
|
11
|
+
* drift again. Before this derivation the list here said `offer|answer|ice`
|
|
12
|
+
* while the wire said `p2p_offer|p2p_answer|p2p_ice`, declared a `log` frame
|
|
13
|
+
* nothing sent or handled, omitted `daemon_mesh_command` (sent by a raw
|
|
14
|
+
* `ws.send`), and listed 12 of the ~27 P2P kinds — and nothing imported the
|
|
15
|
+
* drifted members, so nothing noticed.
|
|
19
16
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
import { type DaemonToServerType, type ServerToDaemonControlType, type P2PSignalType, type MeshP2PSignalType, type DashboardToDaemonP2PType, type DaemonToDashboardP2PType } from './protocol';
|
|
18
|
+
/** Messages the daemon sends UP to the Workers server over the WS bridge (see protocol/daemon-server.ts). */
|
|
19
|
+
export type DaemonToServerWsMsg = DaemonToServerType;
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* wake itself: `DaemonConnectionDO` has neither an alarm nor a timer, and
|
|
27
|
-
* adding one would hit the most request-quota-pressured axis in the system.
|
|
21
|
+
* Server→daemon CONTROL messages (see protocol/daemon-server.ts). The server
|
|
22
|
+
* additionally relays an open command namespace as the frame `type`
|
|
23
|
+
* (`ServerDirectCommandMsg`), which is deliberately not a member here.
|
|
28
24
|
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
export type
|
|
25
|
+
export type ServerToDaemonWsMsg = ServerToDaemonControlType;
|
|
26
|
+
/** P2P signaling relayed through the server WS — the `p2p_`/`mesh_p2p_` spellings the wire actually uses. */
|
|
27
|
+
export type P2PSignalingWsMsg = P2PSignalType | MeshP2PSignalType;
|
|
28
|
+
/** Every dashboard↔daemon P2P DataChannel JSON kind, both directions (see protocol/dashboard-daemon-p2p.ts). */
|
|
29
|
+
export type DashboardP2PMessageKind = DashboardToDaemonP2PType | DaemonToDashboardP2PType;
|
|
30
|
+
export declare const DAEMON_TO_SERVER_WS_MSGS: readonly DaemonToServerWsMsg[];
|
|
31
|
+
export declare const SERVER_TO_DAEMON_WS_MSGS: readonly ServerToDaemonWsMsg[];
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
33
|
+
* `auth_ok.payload.limits` — the plan-limit contract the server sends DOWN to
|
|
34
|
+
* the daemon for client-side enforcement.
|
|
35
|
+
*
|
|
36
|
+
* WHY THIS EXISTS: the wire spelling is `maxP2Pconnections` (lowercase `c`),
|
|
37
|
+
* inherited from `PlanLimits` in the proprietary server's plan-limits.ts. The
|
|
38
|
+
* daemon-cloud consumer independently declared the same field as
|
|
39
|
+
* `maxP2PConnections` (capital `C`) and assigned it from a `payload as any`
|
|
40
|
+
* cast — so the two spellings NEVER met under a type, TypeScript had nothing
|
|
41
|
+
* to compare, and the limit arrived as `undefined` at every comparison site.
|
|
42
|
+
* `undefined !== -1` passes the "is it unlimited?" guard, then every
|
|
43
|
+
* `count >= undefined` is false: enforcement silently degraded to unlimited on
|
|
44
|
+
* all plans, in production, for months.
|
|
45
|
+
*
|
|
46
|
+
* The lesson is NOT "pick a spelling" — it is that a cross-package wire
|
|
47
|
+
* contract asserted by hand on both ends with an `any` in between cannot fail
|
|
48
|
+
* loudly. Both producer (server) and consumer (daemon-cloud) must now import
|
|
49
|
+
* THIS symbol, so a rename breaks the build on both sides instead of silently
|
|
50
|
+
* disabling a paid-plan limit. Use `normalizeAuthOkLimits()` at the parse
|
|
51
|
+
* boundary; never re-spell these fields locally.
|
|
37
52
|
*/
|
|
38
|
-
|
|
39
|
-
/** P2P
|
|
40
|
-
|
|
53
|
+
export interface AuthOkPlanLimits {
|
|
54
|
+
/** P2P concurrent connection count (-1 = unlimited). WIRE SPELLING — lowercase `c`. */
|
|
55
|
+
maxP2Pconnections: number;
|
|
56
|
+
/** Screenshot send interval floor (seconds). 0 = real-time. */
|
|
57
|
+
screenshotIntervalSeconds: number;
|
|
58
|
+
/** Daily screenshot usage budget (minutes). -1 = unlimited. */
|
|
59
|
+
dailyScreenshotMinutes: number;
|
|
60
|
+
/** Max connectable machines/daemons (-1 = unlimited). */
|
|
61
|
+
maxMachines: number;
|
|
62
|
+
}
|
|
41
63
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* `
|
|
64
|
+
* Parse-boundary normalizer for `auth_ok.payload.limits`.
|
|
65
|
+
*
|
|
66
|
+
* Returns `null` when the payload carries no usable limits object, so callers
|
|
67
|
+
* keep their existing "no limits known yet" branch. Individual non-numeric or
|
|
68
|
+
* missing fields fall back to the UNLIMITED sentinel (-1) for count-style
|
|
69
|
+
* limits and 0 for the interval floor, matching how each consumer already
|
|
70
|
+
* treats "no constraint" — a malformed field must never be coerced to a
|
|
71
|
+
* MORE restrictive value than the server intended, or a server-side schema
|
|
72
|
+
* change would start throttling paying users.
|
|
73
|
+
*
|
|
74
|
+
* Accepts the capital-`C` misspelling as an input alias ONLY so a daemon
|
|
75
|
+
* talking to a mixed-version fleet cannot regress; output is always the
|
|
76
|
+
* canonical wire spelling.
|
|
45
77
|
*/
|
|
46
|
-
export
|
|
47
|
-
export declare const DAEMON_TO_SERVER_WS_MSGS: readonly DaemonToServerWsMsg[];
|
|
48
|
-
export declare const SERVER_TO_DAEMON_WS_MSGS: readonly ServerToDaemonWsMsg[];
|
|
49
|
-
export declare function isDaemonToServerWsMsg(value: unknown): value is DaemonToServerWsMsg;
|
|
50
|
-
export declare function isServerToDaemonWsMsg(value: unknown): value is ServerToDaemonWsMsg;
|
|
78
|
+
export declare function normalizeAuthOkLimits(raw: unknown): AuthOkPlanLimits | null;
|
package/package.json
CHANGED
package/src/brain-routing.ts
CHANGED
|
@@ -66,7 +66,7 @@ export function isMeshTaskDifficulty(value: unknown): value is MeshTaskDifficult
|
|
|
66
66
|
* a value that should never have been stamped provider-blind.
|
|
67
67
|
*
|
|
68
68
|
* 2. IT FOUGHT THE SLOTS. Operators express model choice per node via
|
|
69
|
-
* capability slots (`
|
|
69
|
+
* capability slots (`mesh_node_slots` action "set"), which know the provider. A
|
|
70
70
|
* mesh-wide preset that also picks a model duplicated that decision from a
|
|
71
71
|
* position with strictly less information, and needed the modelSource
|
|
72
72
|
* ('explicit' vs 'preset') precedence machinery plus a fail-closed
|
|
@@ -112,7 +112,7 @@ export function normalizeDifficultyBrainMap(raw: unknown): DifficultyBrainMap {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
115
|
-
// Node capability slots (
|
|
115
|
+
// Node capability slots (node capability slots design, 2026-07-09)
|
|
116
116
|
//
|
|
117
117
|
// A node's "Preferred AI tools" list is redefined as an ordered array of
|
|
118
118
|
// capability slots. Each slot bundles what used to be scattered across
|
|
@@ -252,7 +252,7 @@ export function deriveSlotsFromLegacy(input: {
|
|
|
252
252
|
* The reverse direction of deriveSlotsFromLegacy: derive the legacy
|
|
253
253
|
* `providerPriority` order from capability slots — each slot's provider, in
|
|
254
254
|
* first-appearance order, de-duplicated. Slot order = preference is the settled
|
|
255
|
-
* slots semantics (
|
|
255
|
+
* slots semantics (node capability slots design, 2026-07-09), so this is what readers of the
|
|
256
256
|
* legacy `policy.providerPriority` field must fall back to when a node declares
|
|
257
257
|
* slots but no explicit providerPriority (otherwise such a node reads as
|
|
258
258
|
* unlaunchable even though its slots fully determine the preference order).
|
package/src/index.ts
CHANGED
|
@@ -29,3 +29,14 @@ export * from './rpc-chunking'
|
|
|
29
29
|
export * from './semver-compare'
|
|
30
30
|
export * from './ws-protocol'
|
|
31
31
|
export * from './interactive-prompt-constants'
|
|
32
|
+
export * from './session-status'
|
|
33
|
+
export * from './mesh-vocabulary'
|
|
34
|
+
export * from './outbound-message'
|
|
35
|
+
export * from './worker-protocol'
|
|
36
|
+
export * from './protocol'
|
|
37
|
+
export * from './turn-evidence'
|
|
38
|
+
export * from './session-launch'
|
|
39
|
+
export * from './turn-ipc'
|
|
40
|
+
export * from './path-ownership'
|
|
41
|
+
export * from './mission-brief'
|
|
42
|
+
export * from './keyed-doc-delta'
|
package/src/interpolation.ts
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure {{key}} template interpolation shared by the mesh command paths.
|
|
3
|
-
*
|
|
4
|
-
* Hoisted from packages/daemon-cloud/src/mesh/mesh-interpolation.ts — the
|
|
5
|
-
* substitution is transport-agnostic (plain string/object work), so it belongs
|
|
6
|
-
* in the dependency-free mesh-shared leaf where standalone can reuse it too.
|
|
7
|
-
* The substitution semantics are byte-for-byte identical to the prior cloud copy.
|
|
8
|
-
*/
|
|
9
|
-
export function interpolateArgs(
|
|
10
|
-
args: Record<string, unknown>,
|
|
11
|
-
context: Record<string, unknown>,
|
|
12
|
-
): Record<string, unknown> {
|
|
13
|
-
const result: Record<string, unknown> = {};
|
|
14
|
-
for (const [k, v] of Object.entries(args)) {
|
|
15
|
-
result[k] = typeof v === 'string' ? interpolateString(v, context) : v;
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
1
|
|
|
20
2
|
export function interpolateString(template: string, ctx: Record<string, unknown>): string {
|
|
21
3
|
return template.replace(/\{\{(\w+)\}\}/g, (_, key) => {
|