@agentvault/openai-bridge 0.1.22 → 0.1.24
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 +27 -4
- package/dist/avroom-mcp.d.ts +96 -0
- package/dist/avroom-stdio.d.ts +39 -0
- package/dist/avroom-stdio.js +154 -0
- package/dist/bridge.d.ts +125 -12
- package/dist/channel-config.d.ts +29 -0
- package/dist/cli.d.ts +1 -1
- package/dist/codex-version.d.ts +29 -0
- package/dist/content-send.d.ts +100 -0
- package/dist/driver.d.ts +126 -2
- package/dist/file-turn.d.ts +95 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9356 -1625
- package/dist/owner-grant.d.ts +131 -0
- package/dist/owner-lane.d.ts +40 -0
- package/dist/runtime.d.ts +26 -1
- package/dist/sender-binding.d.ts +77 -0
- package/package.json +1 -1
|
@@ -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,40 @@
|
|
|
1
|
+
export declare function ownerLaneKey(deviceId: string, roomId: string): string;
|
|
2
|
+
export declare class OwnerLaneTaint {
|
|
3
|
+
private readonly opts;
|
|
4
|
+
private records;
|
|
5
|
+
constructor(opts?: {
|
|
6
|
+
file?: string;
|
|
7
|
+
log?: (line: string) => void;
|
|
8
|
+
codexVersion?: string;
|
|
9
|
+
});
|
|
10
|
+
/** Can the NEXT run on this lane attest? `stored` is the driver's stored session id (undefined: none). */
|
|
11
|
+
clean(key: string, stored: string | undefined): boolean;
|
|
12
|
+
/** May this lane rotate to a new session at all (a new session can only be clean on a verified version)? */
|
|
13
|
+
canRotate(): boolean;
|
|
14
|
+
/** Non-eligible content entered this lane's session (or may have): taint it, durably. */
|
|
15
|
+
taint(key: string, reason: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* A run on this lane finished in `sessionId`. It stays clean only if every
|
|
18
|
+
* input was eligible AND the session was new, or was clean before.
|
|
19
|
+
*/
|
|
20
|
+
record(key: string, sessionId: string, o: {
|
|
21
|
+
fresh: boolean;
|
|
22
|
+
cleanInput: boolean;
|
|
23
|
+
}): void;
|
|
24
|
+
private read;
|
|
25
|
+
private write;
|
|
26
|
+
}
|
|
27
|
+
/** This process's own owner-lane turns, per room: the ONLY source of the owner lane's seed (X-1). */
|
|
28
|
+
export declare class OwnerLaneTranscript {
|
|
29
|
+
private readonly max;
|
|
30
|
+
private readonly maxRooms;
|
|
31
|
+
private readonly rooms;
|
|
32
|
+
constructor(max?: number, maxRooms?: number);
|
|
33
|
+
add(roomId: string, owner: string, reply: string): void;
|
|
34
|
+
entries(roomId: string): Array<{
|
|
35
|
+
sender: "owner" | "agent";
|
|
36
|
+
text: string;
|
|
37
|
+
}>;
|
|
38
|
+
clear(roomId: string): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=owner-lane.d.ts.map
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import type { EventEmitter } from "node:events";
|
|
2
2
|
import type { SecureChannelConfig } from "@agentvault/agentvault";
|
|
3
3
|
import { type DriverOptions } from "./driver.js";
|
|
4
|
-
import { type BridgeChannel, type TurnDriver } from "./bridge.js";
|
|
4
|
+
import { type BridgeChannel, type BridgeOptions, type TurnDriver } from "./bridge.js";
|
|
5
5
|
import { type RunConfig } from "./cli.js";
|
|
6
|
+
import { TurnInbox } from "./file-turn.js";
|
|
7
|
+
import type { Layout } from "./driver.js";
|
|
8
|
+
/**
|
|
9
|
+
* #1762 PR-X — where the per-turn sockets live: the 0700 state root, unless
|
|
10
|
+
* its path is too long for a Unix socket (macOS: 104 bytes), in which case a
|
|
11
|
+
* private 0700 folder under the temp dir (made once, checked: a real
|
|
12
|
+
* directory, ours, 0700). Failing that, the state root, where the
|
|
13
|
+
* endpoint then refuses to open and the turn says files are unavailable.
|
|
14
|
+
*/
|
|
15
|
+
export declare function socketDirFor(layout: Layout, report?: (event: string) => void): string | (() => string);
|
|
16
|
+
/**
|
|
17
|
+
* #1762 PR-X — the file-send wiring production runs with: the per-turn MCP
|
|
18
|
+
* socket folder (the 0700 state root), node's ABSOLUTE path (the Codex child
|
|
19
|
+
* PATH is /usr/bin:/bin) and the shim built next to this bundle, plus the
|
|
20
|
+
* owner lane's durable taint in the data dir.
|
|
21
|
+
*/
|
|
22
|
+
export declare function bridgeFileOptions(layout: Layout, inbox: TurnInbox, report: (event: string) => void, opts?: {
|
|
23
|
+
node?: string;
|
|
24
|
+
shim?: string;
|
|
25
|
+
}): BridgeOptions;
|
|
6
26
|
export interface RuntimeChannel extends BridgeChannel {
|
|
7
27
|
start(): Promise<void>;
|
|
8
28
|
stop(): Promise<void>;
|
|
@@ -14,6 +34,11 @@ export interface RuntimeDependencies {
|
|
|
14
34
|
report(event: string): void;
|
|
15
35
|
shutdownMs?: number;
|
|
16
36
|
deliveryTimeoutMs?: number;
|
|
37
|
+
/** Test seam: node and shim paths for the per-turn MCP server. */
|
|
38
|
+
files?: {
|
|
39
|
+
node?: string;
|
|
40
|
+
shim?: string;
|
|
41
|
+
};
|
|
17
42
|
}
|
|
18
43
|
/** #1560: the CodexDriver's options, with a recovered session reported to the
|
|
19
44
|
* bridge log by its code only. */
|
|
@@ -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
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@agentvault/openai-bridge", "version": "0.1.
|
|
2
|
+
"name": "@agentvault/openai-bridge", "version": "0.1.24", "type": "module",
|
|
3
3
|
"description": "AgentVault OpenAI Codex bridge for encrypted owner messages and rooms",
|
|
4
4
|
"main": "dist/index.js", "types": "dist/index.d.ts",
|
|
5
5
|
"bin": { "agentvault-openai-bridge": "dist/index.js" },
|