@peer2peer/codex-bridge 0.1.2 → 0.1.3
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 +3 -3
- package/dist/lib.d.ts +22 -0
- package/dist/lib.js +43 -9
- package/dist/server.d.ts +1 -1
- package/dist/server.js +7 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Peer2Peer for Codex (the Codex bridge)
|
|
2
2
|
|
|
3
|
-
This connects OpenAI Codex CLI sessions to [Peer2Peer v3](https://github.com/ix-infrastructure/Peer2Peer/blob/v0.1.
|
|
3
|
+
This connects OpenAI Codex CLI sessions to [Peer2Peer v3](https://github.com/ix-infrastructure/Peer2Peer/blob/v0.1.3/docs/protocol.md). A Codex session can then see what your friends', circle-mates' and other devices' agent sessions (Claude Code or Codex) are working on, message them end-to-end encrypted, and get flagged when two sessions change the same files. There is no account and no login.
|
|
4
4
|
|
|
5
|
-
It is the Codex counterpart of the [Claude Code mod](https://github.com/ix-infrastructure/Peer2Peer/blob/v0.1.
|
|
5
|
+
It is the Codex counterpart of the [Claude Code mod](https://github.com/ix-infrastructure/Peer2Peer/blob/v0.1.3/mods/claude/peer2peer/README.md) and keeps the same rules. Both run over the same `p2p` CLI and the same relays, so a Claude session and a Codex session see and message each other with no extra setup.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -41,7 +41,7 @@ Then:
|
|
|
41
41
|
|
|
42
42
|
- **Restart Codex and trust the hooks once with `/hooks`.** Codex runs non-managed hooks only after you approve them, and again after any change to them.
|
|
43
43
|
- **Make your identity** in a terminal, once per machine: `node …/p2p.mjs setup`. Then join a friend with `node …/p2p.mjs join '<link or code>'`, or make a code for them with `invite`. A code on a relay on a private network (a Tailscale name, a LAN address) needs `--allow-private-relay` on the join (`node …/p2p.mjs join --allow-private-relay '<link>'`), unless that relay is already one of yours. Put the script on your `PATH` as `p2p` if you like.
|
|
44
|
-
- **Share your Codex sessions.** A session follows its project (the repository it works in): private until you share the project with `p2p project share [<circle>…] [--person <friend>]…` in it, a command only you run: the bridge's shell guard and the CLI refuse it from the model, best effort (for a hard barrier deny the model's sandbox access to `P2P_HOME`: [threat model](https://github.com/ix-infrastructure/Peer2Peer/blob/v0.1.
|
|
44
|
+
- **Share your Codex sessions.** A session follows its project (the repository it works in): private until you share the project with `p2p project share [<circle>…] [--person <friend>]…` in it, a command only you run: the bridge's shell guard and the CLI refuse it from the model, best effort (for a hard barrier deny the model's sandbox access to `P2P_HOME`: [threat model](https://github.com/ix-infrastructure/Peer2Peer/blob/v0.1.3/docs/security/threat-model.md#the-hard-barrier-sandbox-your-agents)). Every folder the session works in binds it to that project, and `p2p_send` refuses anyone the session's projects don't share. `p2p codex sessions` lists your live Codex sessions with their sids; the bridge registers each one, so only it speaks for them.
|
|
45
45
|
|
|
46
46
|
## What the model gets
|
|
47
47
|
|
package/dist/lib.d.ts
CHANGED
|
@@ -247,6 +247,28 @@ export declare function conflictMessage(files: readonly string[], repo: string):
|
|
|
247
247
|
* Only the person runs them, in a terminal, with `p2p`.
|
|
248
248
|
*/
|
|
249
249
|
export declare const MUTATING_TOOLS: Set<string>;
|
|
250
|
+
/**
|
|
251
|
+
* `p2p` verbs that change who reaches this user, or touch its keys, refused wherever they sit after the
|
|
252
|
+
* CLI's name. `history`: the person's messages (and `history --clear` deletes them); a session's own come
|
|
253
|
+
* through p2p_history. `unblock` lifts a block the person chose. `tui` is the person's full-screen
|
|
254
|
+
* terminal UI (it accepts, declines, trusts and sends on key presses). `release`: this bridge's held
|
|
255
|
+
* messages (`codex release`), refused in any position.
|
|
256
|
+
*/
|
|
257
|
+
export declare const MUTATING_ONE: ReadonlySet<string>;
|
|
258
|
+
/**
|
|
259
|
+
* Pairs of words (flags between them skipped). `identity rotate|follow|dispute` move the person's
|
|
260
|
+
* identity; `trust add|remove`, `invites revoke` and `circle hold` decide who reaches them; `extensions
|
|
261
|
+
* enable|disable` decide what code p2p runs with their identity; `ix import|resolve` act on a peer's
|
|
262
|
+
* note or reference in the person's own Ix graph, `ix note|subgraph|impact` send the person's Ix data
|
|
263
|
+
* and `ix config` sets how footprints name files. `project share|private`: who sees a project's sessions.
|
|
264
|
+
*/
|
|
265
|
+
export declare const MUTATING_TWO: ReadonlySet<string>;
|
|
266
|
+
/**
|
|
267
|
+
* Verbs refused only as the subcommand itself (common words in message text): `status` posts a
|
|
268
|
+
* session's status (its front end's job: this bridge posts its own), `receipt` reports for a session
|
|
269
|
+
* (its front end's job), `own-agents` decides whether your agent sessions skip the hold (yours).
|
|
270
|
+
*/
|
|
271
|
+
export declare const MUTATING_FIRST: ReadonlySet<string>;
|
|
250
272
|
/**
|
|
251
273
|
* Whether a `p2p send` command line gives --from-session as the CLI's option (the mod's
|
|
252
274
|
* `sendNamesFromSession`; both are pinned to the same vectors). `args` are the words after the CLI's
|
package/dist/lib.js
CHANGED
|
@@ -437,10 +437,31 @@ export const MUTATING_TOOLS = new Set([
|
|
|
437
437
|
"p2p_link",
|
|
438
438
|
"p2p_release",
|
|
439
439
|
]);
|
|
440
|
-
|
|
441
|
-
//
|
|
442
|
-
|
|
443
|
-
|
|
440
|
+
// The three lists below are the Claude mod's (hooks/lib.ts), word for word: both are pinned to
|
|
441
|
+
// mods/claude/peer2peer/tests/guard-verbs.vectors.ts, so a verb added to one and not the other fails
|
|
442
|
+
// both suites. Anything either guard refuses, the other refuses.
|
|
443
|
+
/**
|
|
444
|
+
* `p2p` verbs that change who reaches this user, or touch its keys, refused wherever they sit after the
|
|
445
|
+
* CLI's name. `history`: the person's messages (and `history --clear` deletes them); a session's own come
|
|
446
|
+
* through p2p_history. `unblock` lifts a block the person chose. `tui` is the person's full-screen
|
|
447
|
+
* terminal UI (it accepts, declines, trusts and sends on key presses). `release`: this bridge's held
|
|
448
|
+
* messages (`codex release`), refused in any position.
|
|
449
|
+
*/
|
|
450
|
+
export const MUTATING_ONE = new Set(["join", "accept", "invite", "backup", "setup", "init", "remove", "unfriend", "block", "unblock", "petname", "link", "release", "tui", "history"]);
|
|
451
|
+
/**
|
|
452
|
+
* Pairs of words (flags between them skipped). `identity rotate|follow|dispute` move the person's
|
|
453
|
+
* identity; `trust add|remove`, `invites revoke` and `circle hold` decide who reaches them; `extensions
|
|
454
|
+
* enable|disable` decide what code p2p runs with their identity; `ix import|resolve` act on a peer's
|
|
455
|
+
* note or reference in the person's own Ix graph, `ix note|subgraph|impact` send the person's Ix data
|
|
456
|
+
* and `ix config` sets how footprints name files. `project share|private`: who sees a project's sessions.
|
|
457
|
+
*/
|
|
458
|
+
export const MUTATING_TWO = new Set([
|
|
459
|
+
"trust add",
|
|
460
|
+
"trust remove",
|
|
461
|
+
"ix import",
|
|
462
|
+
"ix resolve",
|
|
463
|
+
"extensions enable",
|
|
464
|
+
"extensions disable",
|
|
444
465
|
"held approve",
|
|
445
466
|
"held decline",
|
|
446
467
|
"relays add",
|
|
@@ -453,23 +474,32 @@ const MUTATING_TWO = new Set([
|
|
|
453
474
|
"circle transfer",
|
|
454
475
|
"circle policy",
|
|
455
476
|
"circle default",
|
|
477
|
+
"circle hold",
|
|
456
478
|
"devices revoke",
|
|
457
479
|
"session roster",
|
|
458
480
|
"identity republish",
|
|
481
|
+
"identity rotate",
|
|
482
|
+
"identity follow",
|
|
483
|
+
"identity dispute",
|
|
459
484
|
"profile set",
|
|
460
485
|
"proof add",
|
|
486
|
+
"invites revoke",
|
|
487
|
+
"codex install",
|
|
461
488
|
"codex release",
|
|
462
489
|
"codex decline",
|
|
463
|
-
"
|
|
464
|
-
|
|
490
|
+
"ix note",
|
|
491
|
+
"ix subgraph",
|
|
492
|
+
"ix impact",
|
|
493
|
+
"ix config",
|
|
465
494
|
"project share",
|
|
466
495
|
"project private",
|
|
467
496
|
]);
|
|
468
497
|
/**
|
|
469
|
-
* Verbs refused only as the subcommand itself (common words in message text): `
|
|
470
|
-
* session (its front end's job
|
|
498
|
+
* Verbs refused only as the subcommand itself (common words in message text): `status` posts a
|
|
499
|
+
* session's status (its front end's job: this bridge posts its own), `receipt` reports for a session
|
|
500
|
+
* (its front end's job), `own-agents` decides whether your agent sessions skip the hold (yours).
|
|
471
501
|
*/
|
|
472
|
-
const MUTATING_FIRST = new Set(["receipt", "own-agents"]);
|
|
502
|
+
export const MUTATING_FIRST = new Set(["status", "receipt", "own-agents"]);
|
|
473
503
|
/** `p2p send` options that take the next word as their value, whatever it is (`--` and `--from-session=x` included). */
|
|
474
504
|
const SEND_VALUE_OPTIONS = new Set(["--to", "--project-dir"]);
|
|
475
505
|
/** Characters that can make a shell word other than what it reads as here: expansions, globs, quoting, or a redirection (`<`: shellTokens marks its target). */
|
|
@@ -1041,6 +1071,10 @@ export function mutatingP2PVerb(command, binNames = [], depth = 0, unread = fals
|
|
|
1041
1071
|
const two = `${plain[i]} ${plain[i + 1] ?? ""}`;
|
|
1042
1072
|
if (MUTATING_TWO.has(two))
|
|
1043
1073
|
return two;
|
|
1074
|
+
// `ix footprint` alone only computes and prints; publishing (and choosing plain names or skipping the
|
|
1075
|
+
// spacing for a publish) shares with the session's audience: the person's decision (as the mod reads it).
|
|
1076
|
+
if (two === "ix footprint" && after.some((w) => /^--(publish|names|force)(=|$)/.test(w)))
|
|
1077
|
+
return "ix footprint --publish";
|
|
1044
1078
|
}
|
|
1045
1079
|
if (MUTATING_FIRST.has(plain[0] ?? ""))
|
|
1046
1080
|
return plain[0];
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Readable, Writable } from "node:stream";
|
|
2
2
|
import { type HookReport, type WatchRunner } from "./bridge.js";
|
|
3
|
-
export declare const BRIDGE_VERSION = "0.1.
|
|
3
|
+
export declare const BRIDGE_VERSION = "0.1.3";
|
|
4
4
|
export type Env = Record<string, string | undefined>;
|
|
5
5
|
export declare function resolveHome(env: Env): string;
|
|
6
6
|
/** `p2p watch` as a child: stdout lines as they come; killed when `signal` aborts. */
|
package/dist/server.js
CHANGED
|
@@ -18,7 +18,7 @@ import { RolloutReader } from "./trusted.js";
|
|
|
18
18
|
import { lineFeeder, McpServer } from "./mcp.js";
|
|
19
19
|
import { nodeExec, P2P } from "./p2p.js";
|
|
20
20
|
import { makeTools, refuseMutating, serverInstructions } from "./tools.js";
|
|
21
|
-
export const BRIDGE_VERSION = "0.1.
|
|
21
|
+
export const BRIDGE_VERSION = "0.1.3";
|
|
22
22
|
export function resolveHome(env) {
|
|
23
23
|
const h = env.P2P_HOME?.trim();
|
|
24
24
|
return h ? h : join(userHome(), ".p2p");
|
|
@@ -169,10 +169,12 @@ export async function runMcpServer(o) {
|
|
|
169
169
|
const bin = p2pBin && isAbsolute(p2pBin) ? [p2pBin] : o.bin;
|
|
170
170
|
// The person token (projects.ts): this bridge speaks for the person's session, so its p2p runs pass it
|
|
171
171
|
// (the session is registered, its sends are its own). The model's shell never has it.
|
|
172
|
-
// Only
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
172
|
+
// Only the short `p2p` runs get it (`extra`, below), never the long-lived `p2p watch` (childWatch); and
|
|
173
|
+
// childEnv never passes one through from this bridge's own environment (CHILD_P2P_DENY), so `codex
|
|
174
|
+
// queue` and anything else this bridge runs can't.
|
|
175
|
+
// Read for every run, never kept: the CLI derives it from the identity's device key and the home's salt,
|
|
176
|
+
// replaces person.key when an identity is created or restored on this home (a join in the person's
|
|
177
|
+
// terminal while this session runs), and refuses the old one.
|
|
176
178
|
const front = () => {
|
|
177
179
|
const token = personTokenOf(home);
|
|
178
180
|
return token ? { P2P_PERSON_TOKEN: token } : {};
|