@agentvault/grok-bridge 0.4.40 → 0.4.43
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/README.md +21 -1
- package/dist/bridge.d.ts +63 -1
- package/dist/channel-config.d.ts +32 -0
- package/dist/file-refs.d.ts +115 -0
- package/dist/file-turn.d.ts +90 -0
- package/dist/grok-driver.d.ts +23 -2
- package/dist/grok-room-http.d.ts +3 -0
- package/dist/grok-room-mcp.d.ts +14 -1
- package/dist/grok-room-plugin.d.ts +2 -0
- package/dist/grok-session.d.ts +61 -0
- package/dist/grok-spawn.d.ts +21 -0
- package/dist/identity-prompt.d.ts +7 -1
- package/dist/index.js +10878 -2371
- package/dist/lane.d.ts +109 -0
- package/dist/owner-grant.d.ts +131 -0
- package/dist/profile-router.d.ts +71 -0
- package/dist/room-context.d.ts +26 -1
- package/dist/sender-binding.d.ts +77 -0
- package/dist/service/doctor-cli.d.ts +6 -0
- package/dist/service/doctor-cli.d.ts.map +1 -1
- package/dist/service/doctor.d.ts +29 -0
- package/dist/service/doctor.d.ts.map +1 -1
- package/dist/session-taint.d.ts +48 -0
- package/dist/tool-profile.d.ts +303 -0
- package/package.json +4 -1
package/dist/lane.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1814: one grok child with everything that belongs to it — its own room MCP
|
|
3
|
+
* listener (so a `say` routes to THIS child's session), its own plugin dir,
|
|
4
|
+
* the child process, its GrokDriver and its GrokSession.
|
|
5
|
+
*
|
|
6
|
+
* The bridge runs two: the OWNER lane (grok's full toolset, the owner's
|
|
7
|
+
* attested 1:1 only) and the RESTRICTED lane (every other turn; started with
|
|
8
|
+
* the restricted tool profile, tool-profile.ts). The owner lane uses the
|
|
9
|
+
* fence's `GROK_HOME`; the restricted lane its own, emptied every start, and
|
|
10
|
+
* the fence's credential store by reference (PR #1824 review r3). index.ts
|
|
11
|
+
* builds them through `createLane`, and so does the
|
|
12
|
+
* real-binary gate, so the gate measures the wiring production runs.
|
|
13
|
+
*
|
|
14
|
+
* `createLane` does not start the ACP session (`lane.driver.start()`): the
|
|
15
|
+
* caller attaches its exit and error handlers first.
|
|
16
|
+
*/
|
|
17
|
+
import { type ChildProcess } from "node:child_process";
|
|
18
|
+
import type { ToolSpanSink } from "@agentvault/agentvault";
|
|
19
|
+
import { GrokDriver } from "./grok-driver.js";
|
|
20
|
+
import { GrokSession } from "./grok-session.js";
|
|
21
|
+
import { type GrokSpawn } from "./grok-spawn.js";
|
|
22
|
+
import { type RoomMcpServer } from "./grok-room-http.js";
|
|
23
|
+
import { type GrokToolProfile, type RestrictedReadiness } from "./tool-profile.js";
|
|
24
|
+
import type { ToolProfileRouter } from "./profile-router.js";
|
|
25
|
+
export interface LaneOpts {
|
|
26
|
+
profile: GrokToolProfile;
|
|
27
|
+
grokPath?: string;
|
|
28
|
+
/** The agent's fenced HOME (the owner child's GROK_HOME is `<fenceHome>/.grok`; the restricted child gets its own, r3). */
|
|
29
|
+
fenceHome: string;
|
|
30
|
+
workspaceDir: string;
|
|
31
|
+
apiKey?: string;
|
|
32
|
+
/** GROK_SANDBOX for the child. */
|
|
33
|
+
sandboxProfile: string;
|
|
34
|
+
identity: string;
|
|
35
|
+
log: (m: string) => void;
|
|
36
|
+
onFatal: (error: unknown) => void | Promise<void>;
|
|
37
|
+
telemetry?: () => ToolSpanSink | null | undefined;
|
|
38
|
+
agentName?: string | (() => string | undefined);
|
|
39
|
+
/**
|
|
40
|
+
* Attached the moment the child is spawned, before anything can await: a
|
|
41
|
+
* spawn failure (ENOENT) is emitted on the next tick, and an 'error' with no
|
|
42
|
+
* listener kills this process with an opaque stack.
|
|
43
|
+
*/
|
|
44
|
+
onChildError: (err: NodeJS.ErrnoException, spec: GrokSpawn) => void;
|
|
45
|
+
onChildExit: (code: number | null, signal: NodeJS.Signals | null) => void;
|
|
46
|
+
/** The child's stderr. Read always: an unread pipe fills and blocks the child. */
|
|
47
|
+
onStderr?: (chunk: Buffer) => void;
|
|
48
|
+
/** Test seam: added to the child's env last (the gate's fake model endpoint). */
|
|
49
|
+
extraEnv?: NodeJS.ProcessEnv;
|
|
50
|
+
/** Test seam: the per-turn timeout. */
|
|
51
|
+
turnTimeoutMs?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface Lane {
|
|
54
|
+
profile: GrokToolProfile;
|
|
55
|
+
mcp: RoomMcpServer;
|
|
56
|
+
child: ChildProcess;
|
|
57
|
+
driver: GrokDriver;
|
|
58
|
+
session: GrokSession;
|
|
59
|
+
spawnSpec: GrokSpawn;
|
|
60
|
+
/** The child's GROK_HOME: the fence's for the owner, its own emptied one for the restricted child. */
|
|
61
|
+
grokHome: string;
|
|
62
|
+
/** The child's working directory: the workspace for the owner, its own emptied dir for the restricted child. */
|
|
63
|
+
cwd: string;
|
|
64
|
+
}
|
|
65
|
+
/** Where a lane's plugin dir and (restricted) profile live, inside the fence but outside GROK_HOME and the cwd. */
|
|
66
|
+
export declare function lanePaths(fenceHome: string, profile: GrokToolProfile): {
|
|
67
|
+
pluginDir: string;
|
|
68
|
+
profileDir?: string;
|
|
69
|
+
cwdDir?: string;
|
|
70
|
+
grokHomeDir?: string;
|
|
71
|
+
};
|
|
72
|
+
export declare function createLane(o: LaneOpts): Promise<Lane>;
|
|
73
|
+
/**
|
|
74
|
+
* PR #1824 review: after the restricted lane's session has started, decide
|
|
75
|
+
* whether it may run room, A2A and non-owner turns (tool-profile.ts
|
|
76
|
+
* `restrictedTurnReadiness`: verified grok version, clean fence config) and
|
|
77
|
+
* tell the router. Until this runs the router refuses them (it starts
|
|
78
|
+
* refused). Logs the version lines and every reason. index.ts and the gate
|
|
79
|
+
* both call this, so the gate measures the decision production makes.
|
|
80
|
+
*/
|
|
81
|
+
export declare function applyRestrictedReadiness(restricted: Pick<Lane, "driver" | "cwd"> & {
|
|
82
|
+
grokHome?: string;
|
|
83
|
+
}, router: Pick<ToolProfileRouter, "setRestrictedRefusal">, o: {
|
|
84
|
+
grokHome?: string;
|
|
85
|
+
log: (m: string) => void;
|
|
86
|
+
systemDir?: string;
|
|
87
|
+
quiet?: boolean;
|
|
88
|
+
}): RestrictedReadiness;
|
|
89
|
+
/**
|
|
90
|
+
* PR #1824 review r2: grok can rewrite `managed_config.toml` from remote
|
|
91
|
+
* settings after start, and an operator can edit any config. Re-run the
|
|
92
|
+
* readiness check on a timer AND whenever `managed_config.toml` changes (its
|
|
93
|
+
* mtime, polled), and tell the caller when the answer flips. A flip to
|
|
94
|
+
* refused stops restricted turns at once (the router is told inside
|
|
95
|
+
* `applyRestrictedReadiness`); a flip back allows them again. Returns stop().
|
|
96
|
+
*/
|
|
97
|
+
export declare function watchRestrictedReadiness(restricted: Pick<Lane, "driver" | "cwd"> & {
|
|
98
|
+
grokHome?: string;
|
|
99
|
+
}, router: Pick<ToolProfileRouter, "setRestrictedRefusal">, o: {
|
|
100
|
+
grokHome?: string;
|
|
101
|
+
log: (m: string) => void;
|
|
102
|
+
systemDir?: string;
|
|
103
|
+
/** The answer at start (applyRestrictedReadiness's return). */
|
|
104
|
+
initial: RestrictedReadiness;
|
|
105
|
+
onChange: (r: RestrictedReadiness) => void;
|
|
106
|
+
intervalMs?: number;
|
|
107
|
+
watchIntervalMs?: number;
|
|
108
|
+
}): () => void;
|
|
109
|
+
//# sourceMappingURL=lane.d.ts.map
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1820 part 2 (completes #1803) — a queued 1:1 owner turn keeps its owner
|
|
3
|
+
* grant only while the device that sent it is still a current owner device.
|
|
4
|
+
*
|
|
5
|
+
* SecureChannel decides `ownerDm1to1` when it hands the message over, against
|
|
6
|
+
* a fresh owner list, and stamps `senderDeviceId` (from the server's delivery
|
|
7
|
+
* row) and `ownerDevicesGen` (its owner-list generation at that moment). A turn
|
|
8
|
+
* can then wait in this bridge's queue while the owner revokes that device.
|
|
9
|
+
* So the grant is re-decided at RELEASE, when the turn actually starts:
|
|
10
|
+
*
|
|
11
|
+
* - `owner_devices_changed` (content-free) marks every grant taken before it
|
|
12
|
+
* as downgraded: nothing queued keeps owner power on the old answer;
|
|
13
|
+
* - a channel whose owner-list generation moved since the grant (an event, or
|
|
14
|
+
* a reconnect that may have missed one) also counts as downgraded;
|
|
15
|
+
* - a downgraded grant stands only if `isCurrentOwnerDevice(senderDeviceId)`
|
|
16
|
+
* says yes NOW. It fails closed: no sender id, no such method (an older
|
|
17
|
+
* plugin), a throw or a non-`true` answer all mean "not the owner".
|
|
18
|
+
*
|
|
19
|
+
* An older plugin (no generation, no event) changes nothing: its grants are
|
|
20
|
+
* never downgraded unless the event fires.
|
|
21
|
+
*
|
|
22
|
+
* #1826 review M3: "couldn't confirm" is not "confirmed not the owner". A
|
|
23
|
+
* re-check answers a tri-state (`OwnerStatus`): `"not_owner"` only when a
|
|
24
|
+
* fresh, successful owner-list read lacks the device (or there is no sender
|
|
25
|
+
* id); `"unknown"` when the list could not be read (a deploy blip, a timeout,
|
|
26
|
+
* a read overtaken by another change). Both run without the owner grant (tools
|
|
27
|
+
* stay off). `"not_owner"` may abort a running turn; `"unknown"` never does.
|
|
28
|
+
*
|
|
29
|
+
* #1826 review round 2 (M4): a persistent lane (the claude listener, grok's
|
|
30
|
+
* restricted session, muse's shared lane) is tainted by any 1:1 that is not
|
|
31
|
+
* CONFIRMED the owner's after the release re-check — `"not_owner"`, or still
|
|
32
|
+
* `"unknown"` after `confirmStatusRetrying`'s retries. Only a single blip that
|
|
33
|
+
* resolves within the retries avoids the taint. The re-check as a whole is
|
|
34
|
+
* bounded (`UNKNOWN_RECHECK_BUDGET_MS`, L5), so an outage cannot hold a
|
|
35
|
+
* serial queue for long.
|
|
36
|
+
*
|
|
37
|
+
* #1800 PR D (design-1800 §3.3, sink 8): owner power follows the BOUND
|
|
38
|
+
* sender only. A 1:1 whose `senderBinding` is not `"bound"` (a missing
|
|
39
|
+
* verdict included) is `"not_owner"` whatever else its metadata says, its
|
|
40
|
+
* grant carries no sender id, and `confirmStatus` answers `"not_owner"`
|
|
41
|
+
* without asking the channel: an unbound frame is never re-checked, so a
|
|
42
|
+
* re-check can never re-escalate it on the server's claimed id.
|
|
43
|
+
*
|
|
44
|
+
* The same file is in each room bridge (claude, grok, muse, openai); keep the
|
|
45
|
+
* copies identical.
|
|
46
|
+
*/
|
|
47
|
+
export type OwnerStatus = "owner" | "not_owner" | "unknown";
|
|
48
|
+
export interface OwnerGrantChannel {
|
|
49
|
+
ownerDevicesGeneration?: () => number;
|
|
50
|
+
isCurrentOwnerDevice?: (deviceId: string | null | undefined) => Promise<boolean>;
|
|
51
|
+
/** #1826 M3: the tri-state re-check (absent on an older plugin). */
|
|
52
|
+
ownerDeviceStatus?: (deviceId: string | null | undefined) => Promise<OwnerStatus>;
|
|
53
|
+
on?: (event: string, listener: (...args: any[]) => void) => unknown;
|
|
54
|
+
}
|
|
55
|
+
export interface OwnerGrant {
|
|
56
|
+
readonly senderDeviceId?: string;
|
|
57
|
+
/** The channel's owner-list generation when SecureChannel decided `ownerDm1to1`. */
|
|
58
|
+
readonly ownerDevicesGen?: number;
|
|
59
|
+
/** This bridge's count of `owner_devices_changed` events when the grant was taken. */
|
|
60
|
+
readonly changes: number;
|
|
61
|
+
/** #1826 M3: taken from a 1:1 the channel could not confirm (`senderOwnerStatus: "unknown"`): always re-checked. */
|
|
62
|
+
readonly unconfirmed?: boolean;
|
|
63
|
+
/** #1800 PR D: taken from a frame whose sender is not BOUND: never the owner, never re-checked. */
|
|
64
|
+
readonly unbound?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* #1826 M3 — the owner verdict a 1:1 arrived with. `"owner"` only for
|
|
68
|
+
* `ownerDm1to1 === true`; `"unknown"` only when the channel says it could not
|
|
69
|
+
* confirm (`senderOwnerStatus: "unknown"`); anything else, an older plugin
|
|
70
|
+
* included, is `"not_owner"` — today's unattested behaviour.
|
|
71
|
+
*
|
|
72
|
+
* #1800 PR D: both `"owner"` and `"unknown"` also need `senderBinding ===
|
|
73
|
+
* "bound"`. An unbound frame (or one with no verdict) is `"not_owner"`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function handoverOwnerStatus(metadata: unknown): OwnerStatus;
|
|
76
|
+
export declare class OwnerGrants {
|
|
77
|
+
private readonly channel;
|
|
78
|
+
private changes;
|
|
79
|
+
/** `subscribe: false` when the caller registers `owner_devices_changed` itself (to remove it on stop). */
|
|
80
|
+
constructor(channel: OwnerGrantChannel, subscribe?: boolean);
|
|
81
|
+
/** `owner_devices_changed`: every grant taken before now is downgraded. */
|
|
82
|
+
changed(): void;
|
|
83
|
+
/** Record the grant of an owner-attested 1:1 message, at queue time. */
|
|
84
|
+
grant(metadata: unknown): OwnerGrant;
|
|
85
|
+
/** Has the owner list changed since this grant was taken? */
|
|
86
|
+
downgraded(grant: OwnerGrant): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* At release: does the grant still stand? Fails closed. A grant the owner
|
|
89
|
+
* list has not changed under answers `true` SYNCHRONOUSLY, so a caller that
|
|
90
|
+
* skips the await on `true` releases an untouched turn on the same tick it
|
|
91
|
+
* always did; only a downgraded grant waits for the re-check.
|
|
92
|
+
*/
|
|
93
|
+
confirm(grant: OwnerGrant): true | Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* #1826 M3 — the tri-state twin of `confirm()`. `"owner"` synchronously for
|
|
96
|
+
* an untouched grant. Otherwise the channel's `ownerDeviceStatus` (a throw or
|
|
97
|
+
* an unrecognised answer is `"unknown"`: nothing was confirmed). An older
|
|
98
|
+
* plugin with only `isCurrentOwnerDevice` answers `"owner"`/`"not_owner"` as
|
|
99
|
+
* before (a throw there is `"not_owner"`, today's fail-closed behaviour).
|
|
100
|
+
* No sender id is `"not_owner"`.
|
|
101
|
+
*
|
|
102
|
+
* #1800 PR D: an UNBOUND grant is `"not_owner"` before anything else, and
|
|
103
|
+
* the channel is never asked (no re-check of an unbound frame).
|
|
104
|
+
*/
|
|
105
|
+
confirmStatus(grant: OwnerGrant): "owner" | Promise<OwnerStatus>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* #1826 M3 — how long a release waits for an `"unknown"` to become an answer:
|
|
109
|
+
* re-asked after each delay (the plugin retries a failed owner-list read on a
|
|
110
|
+
* short backoff), so a deploy blip costs the owner a few seconds, not a
|
|
111
|
+
* limited turn. Still `"unknown"` after the last one: the turn runs limited.
|
|
112
|
+
*/
|
|
113
|
+
export declare const UNKNOWN_RETRY_MS: readonly number[];
|
|
114
|
+
/**
|
|
115
|
+
* #1826 review round 2 (L5) — the most one release re-check may take in all:
|
|
116
|
+
* every read, every retry delay, every read timeout. Past it the answer is
|
|
117
|
+
* `"unknown"` (limited, and a persistent lane is tainted), so a backend outage
|
|
118
|
+
* costs a serial queue at most this per unconfirmed turn.
|
|
119
|
+
*/
|
|
120
|
+
export declare const UNKNOWN_RECHECK_BUDGET_MS = 5000;
|
|
121
|
+
/**
|
|
122
|
+
* `confirmStatus()`, re-asked while the answer is `"unknown"` (bounded by
|
|
123
|
+
* `delays`, and in total by `budgetMs`). `"owner"` synchronously for an
|
|
124
|
+
* untouched grant, as before.
|
|
125
|
+
*/
|
|
126
|
+
export declare function confirmStatusRetrying(grants: OwnerGrants, grant: OwnerGrant, delays?: readonly number[], budgetMs?: number): "owner" | Promise<OwnerStatus>;
|
|
127
|
+
/** Settle a `confirmStatus()` answer (or a caller's own closure); a rejection is `"unknown"`. */
|
|
128
|
+
export declare function settleOwnerStatus(verdict: "owner" | Promise<OwnerStatus>): Promise<OwnerStatus>;
|
|
129
|
+
/** Settle a `confirm()` answer (or a caller's own confirm closure), failing closed. */
|
|
130
|
+
export declare function settleOwnerGrant(verdict: true | Promise<boolean>): Promise<boolean>;
|
|
131
|
+
//# sourceMappingURL=owner-grant.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1814: hands each turn to the grok child its tool profile names.
|
|
3
|
+
*
|
|
4
|
+
* Two GrokSessions, one per child (lane.ts): the OWNER child keeps grok's
|
|
5
|
+
* full toolset and runs only the owner's attested 1:1; the RESTRICTED child
|
|
6
|
+
* runs every other turn with no read, exec or network tools (tool-profile.ts).
|
|
7
|
+
* The bridge decides the profile per push (`grokToolProfileFor`) and passes it
|
|
8
|
+
* as `PushOpts.toolProfile`; this class only routes on it.
|
|
9
|
+
*
|
|
10
|
+
* FAIL CLOSED: a push goes to the owner child only when it says
|
|
11
|
+
* `toolProfile: "owner"` AND an owner session exists. Absent, misspelled, or
|
|
12
|
+
* any other value runs restricted — and a restricted turn is refused outright
|
|
13
|
+
* until `setRestrictedRefusal(null)` (PR #1824 review).
|
|
14
|
+
*
|
|
15
|
+
* Side effect, intended (design §13.1 "partitioning"): the owner 1:1's grok
|
|
16
|
+
* transcript no longer receives room or foreign content, which used to share
|
|
17
|
+
* one session with it.
|
|
18
|
+
*/
|
|
19
|
+
import type { PushOpts, ReplySink, RoomSession, StopReason } from "./grok-session.js";
|
|
20
|
+
import type { GrokToolProfile } from "./tool-profile.js";
|
|
21
|
+
/** What the router needs from a GrokSession. */
|
|
22
|
+
export interface RoutedSession extends RoomSession {
|
|
23
|
+
/** PR #1824 review r3: drop turns queued but not yet running (their file tokens end). */
|
|
24
|
+
dropQueued?(): number;
|
|
25
|
+
stop(opts: {
|
|
26
|
+
reason: StopReason;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
invalidate(): void;
|
|
29
|
+
turnInFlight(): boolean;
|
|
30
|
+
idle(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare class ToolProfileRouter implements RoomSession {
|
|
33
|
+
private readonly lanes;
|
|
34
|
+
private readonly opts;
|
|
35
|
+
/**
|
|
36
|
+
* PR #1824 review: why restricted turns are refused right now, or null when
|
|
37
|
+
* they may run. STARTS REFUSED: index.ts clears it only after
|
|
38
|
+
* `restrictedTurnReadiness` passes (verified grok version, clean fence
|
|
39
|
+
* config). A refused turn never reaches grok; the owner 1:1 is unaffected.
|
|
40
|
+
*/
|
|
41
|
+
private refusal;
|
|
42
|
+
private refusedCount;
|
|
43
|
+
constructor(lanes: {
|
|
44
|
+
owner?: RoutedSession;
|
|
45
|
+
restricted: RoutedSession;
|
|
46
|
+
}, opts?: {
|
|
47
|
+
log?: (m: string) => void;
|
|
48
|
+
/** Called for each refused restricted turn (index.ts sends ONE owner notice). */
|
|
49
|
+
onRefused?: (opts: PushOpts | undefined, reason: string) => void;
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Refuse (a reason) or allow (null) restricted turns. PR #1824 review r3: a
|
|
53
|
+
* refusal also drops restricted turns already QUEUED behind the running
|
|
54
|
+
* one, so a flip to refused cannot be outrun by a backlog. (A turn already
|
|
55
|
+
* running finishes: grok does not hot-load the config the check reads.)
|
|
56
|
+
*/
|
|
57
|
+
setRestrictedRefusal(reason: string | null): void;
|
|
58
|
+
restrictedRefusal(): string | null;
|
|
59
|
+
/** The profile a push with these opts runs under. */
|
|
60
|
+
profileFor(opts?: PushOpts): GrokToolProfile;
|
|
61
|
+
push(text: string, reply?: ReplySink, opts?: PushOpts): void;
|
|
62
|
+
private all;
|
|
63
|
+
/** Both stop together: each caps its own notices, so the bound does not grow. */
|
|
64
|
+
stop(opts: {
|
|
65
|
+
reason: StopReason;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
invalidate(): void;
|
|
68
|
+
turnInFlight(): boolean;
|
|
69
|
+
idle(): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=profile-router.d.ts.map
|
package/dist/room-context.d.ts
CHANGED
|
@@ -48,6 +48,19 @@ export interface RoomContextEntry {
|
|
|
48
48
|
text: string;
|
|
49
49
|
/** ISO time the message was sent (from the emit), or received if absent. */
|
|
50
50
|
at: string;
|
|
51
|
+
/**
|
|
52
|
+
* #1762 PR-C — opaque to this buffer: the held message's turn authority
|
|
53
|
+
* (a parked FileTurn). Handed back by `take()` when the context is
|
|
54
|
+
* delivered, and to `onDrop` when the entry leaves WITHOUT being delivered
|
|
55
|
+
* (overflow, the room evicted, `clear`) — a true drop.
|
|
56
|
+
*/
|
|
57
|
+
turn?: unknown;
|
|
58
|
+
/**
|
|
59
|
+
* #1762 PR-C: not from this agent's own owner (an agent, another account,
|
|
60
|
+
* an unknown sender, or a foreign file). Delivered to the listener, it
|
|
61
|
+
* taints the session (session-taint.ts). Absent reads as foreign.
|
|
62
|
+
*/
|
|
63
|
+
foreign?: boolean;
|
|
51
64
|
}
|
|
52
65
|
export interface RoomContextLimits {
|
|
53
66
|
/** Messages kept per room. */
|
|
@@ -75,17 +88,29 @@ export declare function sanitizeLabel(name: string, max?: number): string;
|
|
|
75
88
|
/** A fresh per-turn delimiter id: 12 hex chars from 6 random bytes. */
|
|
76
89
|
export declare function newContextId(): string;
|
|
77
90
|
export declare class RoomContextBuffer {
|
|
91
|
+
/** #1762 PR-C: an entry left without being delivered (overflow, room evicted, `clear`). */
|
|
92
|
+
private readonly onDrop;
|
|
78
93
|
private readonly limits;
|
|
79
94
|
/** Insertion order IS recency order: a touched room is re-inserted at the end. */
|
|
80
95
|
private rooms;
|
|
81
|
-
constructor(limits?: Partial<RoomContextLimits
|
|
96
|
+
constructor(limits?: Partial<RoomContextLimits>,
|
|
97
|
+
/** #1762 PR-C: an entry left without being delivered (overflow, room evicted, `clear`). */
|
|
98
|
+
onDrop?: (entry: RoomContextEntry) => void);
|
|
99
|
+
private dropped;
|
|
82
100
|
add(roomId: string, entry: RoomContextEntry): void;
|
|
83
101
|
/** The held messages for a room, oldest first. Does not clear. */
|
|
84
102
|
peek(roomId: string): {
|
|
85
103
|
entries: readonly RoomContextEntry[];
|
|
86
104
|
dropped: number;
|
|
87
105
|
};
|
|
106
|
+
/** The room's held messages leave WITHOUT being delivered (room left, pruned): a true drop. */
|
|
88
107
|
clear(roomId: string): void;
|
|
108
|
+
/**
|
|
109
|
+
* #1762 PR-C — the room's held messages were DELIVERED with a turn: remove
|
|
110
|
+
* and return them (with their `turn`), so the caller folds each into it.
|
|
111
|
+
* Never calls `onDrop`.
|
|
112
|
+
*/
|
|
113
|
+
take(roomId: string): RoomContextEntry[];
|
|
89
114
|
size(roomId: string): number;
|
|
90
115
|
chars(roomId: string): number;
|
|
91
116
|
roomCount(): number;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1800 PR D — this bridge's defence in depth for the sender binding that
|
|
3
|
+
* SecureChannel does (#1800 PR B, design-1800 §3.3, sinks 7-9).
|
|
4
|
+
*
|
|
5
|
+
* SecureChannel binds a frame's server-claimed `sender_device_id` to the MLS
|
|
6
|
+
* leaf that signed it and stamps the verdict as `senderBinding`. Only
|
|
7
|
+
* `"bound"` may carry anything a known sender gets. The channel already strips
|
|
8
|
+
* an unbound frame (no `senderDeviceId`, `ownerDm1to1: false`,
|
|
9
|
+
* `senderOwnerStatus: "not_owner"`, `senderIsAgent` undefined, label
|
|
10
|
+
* "Unverified sender"). This bridge does not rely on that: it keys on the
|
|
11
|
+
* verdict itself, so a future plugin regression that stamps owner fields on an
|
|
12
|
+
* unbound frame still buys that frame nothing here.
|
|
13
|
+
*
|
|
14
|
+
* - A 1:1 is the owner's only when `senderBinding === "bound"`
|
|
15
|
+
* (`owner-grant.ts`: `handoverOwnerStatus`, `grant`, `confirmStatus`).
|
|
16
|
+
* - A room sender that is not bound is NOT a known human: the room protocol
|
|
17
|
+
* (`@all`, a plain-name summon, the private-room rule, the agent-loop brake
|
|
18
|
+
* and so `replyExpected`) sees it as it sees an agent. `@name` still works.
|
|
19
|
+
* - It is labelled "Unverified sender", never by the name the server's claim
|
|
20
|
+
* would resolve to; it is never the owner and carries no device id.
|
|
21
|
+
* - A history line recorded from an unbound sender reads "unverified sender"
|
|
22
|
+
* in any seed built from it, never "owner".
|
|
23
|
+
*
|
|
24
|
+
* A MISSING verdict is unbound (fail closed): this bridge bundles the plugin,
|
|
25
|
+
* so there is no older emitter to be kind to, and a future emit site that
|
|
26
|
+
* forgets the field must not fall back to believing the wire.
|
|
27
|
+
*
|
|
28
|
+
* The same file is in each room bridge (claude, grok, muse, openai); keep the
|
|
29
|
+
* copies identical.
|
|
30
|
+
*/
|
|
31
|
+
/** What an unbound sender is called, everywhere a name would appear. */
|
|
32
|
+
export declare const UNVERIFIED_SENDER = "Unverified sender";
|
|
33
|
+
/** The label a seed gives a history line from an unbound sender. */
|
|
34
|
+
export declare const UNVERIFIED_HISTORY_SENDER = "unverified sender";
|
|
35
|
+
/** True only when SecureChannel bound this frame's claimed sender to its MLS sender. A missing verdict is not bound. */
|
|
36
|
+
export declare function isBoundSender(metadata: unknown): boolean;
|
|
37
|
+
/** The room-sender fields a bridge may act on, after the binding. */
|
|
38
|
+
export interface RoomSenderView {
|
|
39
|
+
/** The name the model and the logs see. */
|
|
40
|
+
senderName: string;
|
|
41
|
+
/**
|
|
42
|
+
* What the room protocol sees. A bound sender keeps SecureChannel's
|
|
43
|
+
* classification (`undefined` for an unknown roster member, as before). An
|
|
44
|
+
* unbound sender is `true`: not a known human, so no `@all`, no plain-name
|
|
45
|
+
* summon, no private-room turn, and it is answered only when it `@names`
|
|
46
|
+
* this agent — exactly as an agent sender is (the plugin's OpenClaw gate
|
|
47
|
+
* does the same, `openclaw-entry.ts`).
|
|
48
|
+
*/
|
|
49
|
+
senderIsAgent: boolean | undefined;
|
|
50
|
+
/** #1459 owner power: never for an unbound sender. */
|
|
51
|
+
senderIsOwner: boolean | undefined;
|
|
52
|
+
/** The bound device id only; never the claim. */
|
|
53
|
+
senderDeviceId?: string;
|
|
54
|
+
/** True when the sender is not bound (a missing verdict included). */
|
|
55
|
+
unverifiedSender: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** One room frame's sender, as this bridge may use it. */
|
|
58
|
+
export declare function roomSenderView(metadata: {
|
|
59
|
+
senderBinding?: unknown;
|
|
60
|
+
senderName?: unknown;
|
|
61
|
+
senderIsAgent?: unknown;
|
|
62
|
+
senderIsOwner?: unknown;
|
|
63
|
+
senderDeviceId?: unknown;
|
|
64
|
+
} | null | undefined): RoomSenderView;
|
|
65
|
+
/**
|
|
66
|
+
* The sender label a seed gives one history line. SecureChannel's read APIs
|
|
67
|
+
* return `"unverified"` for a line recorded from an unbound sender (#1800 PR
|
|
68
|
+
* B); that line reads "unverified sender", never "owner". An `unverified:
|
|
69
|
+
* true` flag on the entry, or a missing or empty sender, reads the same. Any
|
|
70
|
+
* other label (`"owner"`, `"agent"`, and #1848's `"member"` for a room or
|
|
71
|
+
* 1:1 line from anyone but the bound owner) is kept as it was.
|
|
72
|
+
*/
|
|
73
|
+
export declare function historySenderLabel(entry: {
|
|
74
|
+
sender?: unknown;
|
|
75
|
+
unverified?: unknown;
|
|
76
|
+
} | null | undefined): string;
|
|
77
|
+
//# sourceMappingURL=sender-binding.d.ts.map
|
|
@@ -14,6 +14,12 @@ import { type DeviceProbe, type DoctorDeps } from "./doctor.js";
|
|
|
14
14
|
* dead".
|
|
15
15
|
*/
|
|
16
16
|
export declare function fetchDeviceStatus(apiUrl: string, deviceId: string, doFetch?: typeof fetch): Promise<DeviceProbe>;
|
|
17
|
+
/**
|
|
18
|
+
* #1807: the installed grok CLI's version, read from `grok --version`
|
|
19
|
+
* ("grok 1.0.46 (<hash>) [stable]"). The binary the daemon spawns:
|
|
20
|
+
* AV_GROK_PATH, else `grok` on PATH. Null when it cannot be run or read.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readGrokVersion(env: NodeJS.ProcessEnv, run?: (cmd: string, args: string[]) => string): string | null;
|
|
17
23
|
export declare function realDoctorDeps(env: NodeJS.ProcessEnv): DoctorDeps;
|
|
18
24
|
/**
|
|
19
25
|
* Handle `agentvault-grok-bridge doctor`. Returns true when handled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor-cli.d.ts","sourceRoot":"","sources":["../../src/service/doctor-cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doctor-cli.d.ts","sourceRoot":"","sources":["../../src/service/doctor-cli.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAoBrB;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,OAAO,KAAa,GAC5B,OAAO,CAAC,WAAW,CAAC,CAuBtB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,GAAG,GAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,MACsF,GAC3H,MAAM,GAAG,IAAI,CAOf;AA+BD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,UAAU,CA0BjE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;CAAO,GACrF,OAAO,CAAC,OAAO,CAAC,CAelB"}
|
package/dist/service/doctor.d.ts
CHANGED
|
@@ -67,6 +67,28 @@ export interface DoctorReport {
|
|
|
67
67
|
unsupervised: UnsupervisedFinding[];
|
|
68
68
|
/** AgentVault services from other families. Found, listed, NOT checked. */
|
|
69
69
|
notChecked: string[];
|
|
70
|
+
/** #1807: the installed grok CLI against the versions the @-file reference
|
|
71
|
+
* neutralizer was verified on. Absent when the deps carry no probe. */
|
|
72
|
+
grokCli?: {
|
|
73
|
+
verdict: Verdict;
|
|
74
|
+
detail: string;
|
|
75
|
+
};
|
|
76
|
+
/** #1814 (PR #1824 review): the installed grok CLI against the versions the
|
|
77
|
+
* restricted tool profile was verified on. Absent when the deps carry no probe. */
|
|
78
|
+
grokToolProfile?: {
|
|
79
|
+
verdict: Verdict;
|
|
80
|
+
detail: string;
|
|
81
|
+
};
|
|
82
|
+
/** PR #1824 review r2: machine-wide grok config (`/etc/grok`). Absent when the deps name no dir. */
|
|
83
|
+
grokSystemConfig?: {
|
|
84
|
+
verdict: Verdict;
|
|
85
|
+
detail: string;
|
|
86
|
+
};
|
|
87
|
+
/** PR #1824 final round: macOS device-management preferences for grok (`ai.x.grok`). */
|
|
88
|
+
grokMacosPrefs?: {
|
|
89
|
+
verdict: Verdict;
|
|
90
|
+
detail: string;
|
|
91
|
+
};
|
|
70
92
|
}
|
|
71
93
|
export interface DoctorDeps {
|
|
72
94
|
backend: ServiceBackend;
|
|
@@ -87,6 +109,13 @@ export interface DoctorDeps {
|
|
|
87
109
|
fetchStatus: (apiUrl: string, deviceId: string) => Promise<DeviceProbe>;
|
|
88
110
|
/** Labels belonging to other AgentVault families installed on this machine. */
|
|
89
111
|
otherLabels: () => string[];
|
|
112
|
+
/** #1807: the installed grok CLI's version (`grok --version`), or null when
|
|
113
|
+
* it could not be run or read — that is SKIP, never a problem found. */
|
|
114
|
+
grokVersion?: () => string | null;
|
|
115
|
+
/** PR #1824 review r2: the machine-wide grok config dir to inspect (`/etc/grok` in production). */
|
|
116
|
+
systemGrokDir?: string;
|
|
117
|
+
/** PR #1824 final round: the macOS `ai.x.grok` preferences check (production: the real one). */
|
|
118
|
+
macosPrefsProblems?: () => string[];
|
|
90
119
|
}
|
|
91
120
|
export declare function buildDoctorReport(d: DoctorDeps): Promise<DoctorReport>;
|
|
92
121
|
export declare function formatDoctorReport(r: DoctorReport): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/service/doctor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/service/doctor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EA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,YAAY,GAAG,MAAM,EAAE,CAiE5D"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* grok versions in which a `session/new` was verified to start with NOTHING
|
|
3
|
+
* from earlier sessions (no memory injection, no session search). EMPTY: no
|
|
4
|
+
* version has been verified (the binary is closed). Add a version only with
|
|
5
|
+
* the evidence recorded beside it; until then every session is tainted.
|
|
6
|
+
*/
|
|
7
|
+
export declare const VERIFIED_GROK_FRESH_SESSION_VERSIONS: ReadonlySet<string>;
|
|
8
|
+
export declare class SessionTaint {
|
|
9
|
+
private readonly opts;
|
|
10
|
+
/** Tainted until `begin()` proves the session new: fail closed before start. */
|
|
11
|
+
private tainted;
|
|
12
|
+
/** The session's grok version is one whose fresh sessions were verified clean. Per process. */
|
|
13
|
+
private cliVerified;
|
|
14
|
+
private sessionId?;
|
|
15
|
+
/** The record as it stood when this process's session began (what a resume would carry over). */
|
|
16
|
+
private prior?;
|
|
17
|
+
private readonly verified;
|
|
18
|
+
constructor(opts?: {
|
|
19
|
+
file?: string;
|
|
20
|
+
log?: (m: string) => void;
|
|
21
|
+
verifiedVersions?: ReadonlySet<string>;
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* The session is starting. `resumeSessionId` set means it RESUMES that
|
|
25
|
+
* session (its transcript carries over): the recorded taint for that id
|
|
26
|
+
* applies, and no record means tainted. Unset means a new session: clean —
|
|
27
|
+
* unless input is already QUEUED for it (`queued > 0`). Either way the CLI
|
|
28
|
+
* is unverified until `noteSessionId` says otherwise.
|
|
29
|
+
*/
|
|
30
|
+
begin(o?: {
|
|
31
|
+
resumeSessionId?: string;
|
|
32
|
+
queued?: number;
|
|
33
|
+
}): void;
|
|
34
|
+
/**
|
|
35
|
+
* The session id and the grok version that serves it (ACP `initialize`
|
|
36
|
+
* `agentInfo.version`). A version not verified for clean fresh sessions — or
|
|
37
|
+
* NO version — taints the session durably. An id equal to the recorded one is
|
|
38
|
+
* a resume: its recorded taint carries over.
|
|
39
|
+
*/
|
|
40
|
+
noteSessionId(id: unknown, cliVersion?: unknown): void;
|
|
41
|
+
/** Non-eligible content entered the session: taint it, durably. */
|
|
42
|
+
taint(reason: string): void;
|
|
43
|
+
/** No room file: tainted, or the grok version not (yet) verified. */
|
|
44
|
+
isTainted(): boolean;
|
|
45
|
+
private read;
|
|
46
|
+
private write;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=session-taint.d.ts.map
|