@peer2peer/cli 0.1.0 → 0.1.2

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.
@@ -18,11 +18,27 @@ export declare function sessionWorkdir(env: Record<string, string | undefined>):
18
18
  export declare function sessionDirs(env: Record<string, string | undefined>): {
19
19
  dirs: string[];
20
20
  over: boolean;
21
+ why: OverWhy[];
21
22
  };
23
+ /**
24
+ * Why a session went private for good, past a cap or a gap in what its front end saw:
25
+ * - `projects`: more than MAX_SESSION_PROJECTS projects;
26
+ * - `folders`: more folders than a front end or the CLI keeps (MAX_SESSION_DIRS per call);
27
+ * - `unresolved`: a path its front end couldn't resolve (a variable or `$(…)` it doesn't know, in the path's first segment);
28
+ * - `front`: its front end lost track (a forked conversation, a record it couldn't read; an older front end's bare "over");
29
+ * - `constraints`: more than MAX_SESSION_CONSTRAINTS bounds from own-session messages.
30
+ */
31
+ export type OverWhy = "projects" | "folders" | "unresolved" | "front" | "constraints";
32
+ /** A front end's over reasons (`unresolved,folders`, an array, or `1`/`true` from an older one): an unknown word counts as `front`, never as nothing. */
33
+ export declare function overWhys(v: unknown): OverWhy[];
22
34
  /** At most this many folders a front end passes per call; past it the session is private. */
23
35
  export declare const MAX_SESSION_DIRS = 512;
24
- /** At most this many projects per session; past it the session is private. */
25
- export declare const MAX_SESSION_PROJECTS = 16;
36
+ /**
37
+ * At most this many projects per session; past it the session is private. A storage bound only:
38
+ * a session's ceiling is the intersection of all its projects' policies, so a higher cap never
39
+ * lets a session reach anyone a smaller one wouldn't.
40
+ */
41
+ export declare const MAX_SESSION_PROJECTS = 64;
26
42
  /** Bindings of sessions not seen for this long are dropped. */
27
43
  export declare const SESSION_BINDING_TTL_MS: number;
28
44
  /** At most this many circles and people in one project's policy. */
@@ -39,6 +55,8 @@ export interface ProjectRef {
39
55
  remote?: string;
40
56
  /** The repository asks to stay private (a committed PRIVATE_MARKER at `root`). */
41
57
  repoPrivate?: true;
58
+ /** A `.git` is there but can't be read as a repository (a folder project at that level). */
59
+ brokenGit?: true;
42
60
  }
43
61
  export type ProjectShare = "private" | {
44
62
  circles: string[];
@@ -49,6 +67,11 @@ export interface ProjectPolicyRec {
49
67
  root: string;
50
68
  remote?: string;
51
69
  share: ProjectShare;
70
+ /**
71
+ * A folder project's share covers its subfolders too (`p2p project share --subfolders`). Without
72
+ * it (every policy from before it), the policy is for that folder alone.
73
+ */
74
+ covers?: true;
52
75
  at: number;
53
76
  }
54
77
  export interface ProjectsDoc {
@@ -58,12 +81,10 @@ export interface ProjectsDoc {
58
81
  noticeAt?: number;
59
82
  }
60
83
  export interface SessionBinding {
61
- projects: Record<string, {
62
- name: string;
63
- repoPrivate?: true;
64
- }>;
65
- /** More than MAX_SESSION_PROJECTS projects or MAX_SESSION_DIRS folders: private. */
84
+ projects: Record<string, BoundProject>;
85
+ /** Past a cap, or a path its front end couldn't resolve: private (overWhy says which; absent in bindings from before it). */
66
86
  over?: true;
87
+ overWhy?: OverWhy[];
67
88
  /**
68
89
  * What other sessions of this user that sent to this one could reach (own-device messages carry
69
90
  * their sender's ceiling): intersected in, sticky, so a private session can't launder through a
@@ -74,22 +95,73 @@ export interface SessionBinding {
74
95
  unregistered?: true;
75
96
  /** A front end holding the person token (personTokenOk) has used it. */
76
97
  registered?: true;
98
+ /** When this binding began (ms): a session id bound anew (its old binding expired) starts again here (history.ts). */
99
+ since?: number;
77
100
  at: number;
78
101
  }
79
102
  /** At most this many constraints a session keeps; past it, private. */
80
103
  export declare const MAX_SESSION_CONSTRAINTS = 16;
81
104
  export type SessionProjectsDoc = Record<string, SessionBinding>;
105
+ export interface BoundProject {
106
+ name: string;
107
+ /** Its folder (git: the working tree it was first seen in), for `p2p session show`. */
108
+ root?: string;
109
+ repoPrivate?: true;
110
+ /**
111
+ * Folders below `root` that a shared folder covered (dir projects only, at most MAX_UNDER): a
112
+ * policy given to one of them later still narrows this session. `underOver`: more than that,
113
+ * so any policy below `root` does.
114
+ */
115
+ under?: string[];
116
+ underOver?: true;
117
+ }
118
+ /** At most this many covered subfolders a bound folder project remembers; past it, every policy below it counts. */
119
+ export declare const MAX_UNDER = 64;
82
120
  /** What a session may reach. `none`: the person's own session, or one not bound yet. */
83
121
  export type Ceiling = {
84
122
  kind: "none";
85
123
  } | {
86
124
  kind: "private";
87
125
  why: string;
126
+ causes: PrivateCause[];
127
+ blocking?: string[];
88
128
  } | {
89
129
  kind: "shared";
90
130
  circles: string[];
91
131
  people: string[];
92
132
  };
133
+ /**
134
+ * Why a session is private: an over reason (OverWhy), `unregistered` (an agent named it, no front
135
+ * end registered it), `repo-private` (`.p2p-private`), `private` (a project made private),
136
+ * `unshared` (a project never shared), `sent-private` (a private session of yours sent it a
137
+ * message), `disjoint` (its projects share nobody in common, or nobody you can reach).
138
+ */
139
+ export type PrivateCause = OverWhy | "legacy-over" | "unregistered" | "repo-private" | "private" | "unshared" | "sent-private" | "disjoint";
140
+ /** Whether a path, as written, has a `..` segment (`a/../b`, `..`, `a/..`). */
141
+ export declare function hasDotDot(p: string): boolean;
142
+ /**
143
+ * `p` as the file system walks it (POSIX): each existing prefix is resolved through its symlinks
144
+ * before the next segment applies, so `link/../x` is the link's target's parent's `x`, never the
145
+ * `x` beside the link (path.resolve collapses `..` as text). Past the first segment that doesn't
146
+ * exist, the rest is applied as text. Relative paths start at the process's cwd. On Windows,
147
+ * path.resolve.
148
+ */
149
+ export declare function physicalPath(p: string): string;
150
+ /**
151
+ * Whether `p` is a device or pseudo file (`/dev/null`, `/dev/tty`, `/proc/self/status`), never a
152
+ * project: it exists, isn't a folder, and its real path stays under /dev (and isn't a regular
153
+ * file there, like one in /dev/shm), /proc or /sys. A path through /proc to a real file
154
+ * (`/proc/self/cwd/x`, `/proc/<pid>/root/…`) resolves out of it and binds as usual; one that
155
+ * doesn't exist binds its nearest existing parent as every path does.
156
+ */
157
+ export declare function pseudoPath(p: string): boolean;
158
+ /**
159
+ * Whether a path component holds a brace expansion with a choice: a `{`, then `,` or `..` with no
160
+ * brace between, then `}` (`{.git,x}`, `{a..z}`). One pass, so it stays linear on any input.
161
+ */
162
+ export declare function braceChoice(c: string): boolean;
163
+ /** A folder project's id: its real path, hashed. */
164
+ export declare function dirProjectId(root: string): string;
93
165
  /**
94
166
  * A remote URL as one canonical string: scheme, credentials, port-less ssh form, trailing `.git`
95
167
  * and slashes dropped, host lower-cased. `https://u:t@GitHub.com/a/b.git` and `git@github.com:a/b`
@@ -100,8 +172,25 @@ export declare function normalizeRemote(url: string): string | undefined;
100
172
  * The project `dir` belongs to, read from the files alone (git is never run: no hook, fsmonitor
101
173
  * or config of the repository's can execute). A `.git` directory or `gitdir:` file up the tree
102
174
  * marks a working tree; its common dir (`commondir` for a linked worktree) identifies the clone.
175
+ * A bare repository (isBareRepo) is a git project too, and a `.git` that can't be read as one is
176
+ * a folder project of its own.
177
+ *
178
+ * Outside git, a folder project. With `doc` (the policies), the nearest folder at or above `dir`
179
+ * that has a policy of its own is the project when that is `dir`'s own folder, or when its share
180
+ * covers subfolders (`covers`, given with `p2p project share --subfolders`; a policy without it
181
+ * is for that folder alone, as before). The walk stops at the first folder with a policy (the
182
+ * nearest one wins, so a private subfolder stays private; one that doesn't cover leaves `dir`'s
183
+ * own folder as the project), and it never crosses:
184
+ * - a git repository (found first: a nested repository is always its own project);
185
+ * - a `.p2p-private` (at or above `dir`: the folder project is private, whatever covers it);
186
+ * - a folder whose `.git` or `.p2p-private` the path itself names (namedStop: a command that may
187
+ * have just removed it);
188
+ * - the nearest existing folder, when `dir` itself isn't there (deleted or moved since the
189
+ * session named it, or not made yet): that folder is the project unless it has a policy, so a
190
+ * repository removed after a session read it is never covered from above.
191
+ * Without `doc` (sharing, `project show`): the folder itself.
103
192
  */
104
- export declare function projectOf(dir: string): ProjectRef;
193
+ export declare function projectOf(dir: string, doc?: ProjectsDoc): ProjectRef;
105
194
  export declare function projectsDoc(app: App): Promise<ProjectsDoc>;
106
195
  /** A project's share as stored, or `private` (no policy: private by default). */
107
196
  export declare function shareOf(doc: ProjectsDoc, id: string): ProjectShare;
@@ -126,8 +215,33 @@ export interface ProjectView {
126
215
  /** Why it is private although a policy shares it, or `unmapped` when none does. */
127
216
  why?: string;
128
217
  repoPrivate?: true;
218
+ /** A folder whose share covers its subfolders (`p2p project share --subfolders`). */
219
+ covers?: true;
220
+ /** Which Ix graph its work may reach (graphTarget): `local` (only this machine's) today. */
221
+ graph: GraphTarget;
129
222
  }
130
223
  export declare function projectView(app: App, ref: Pick<ProjectRef, "id" | "name" | "kind" | "root" | "remote" | "repoPrivate">, doc?: ProjectsDoc): Promise<ProjectView>;
224
+ /**
225
+ * Why `root` may not cover its subfolders (a share for it alone is still allowed), or undefined:
226
+ * the file system's root, a home folder or a folder above one (`$HOME`, `/Users`, `/home/<u>`),
227
+ * the temporary folders (`/tmp`, `/private/tmp`, `/var/folders/…`, os.tmpdir() and above it), and
228
+ * the system's top folders. Everything below them would be one project.
229
+ */
230
+ export declare function broadRoot(root: string, env?: Record<string, string | undefined>): string | undefined;
231
+ /** At most this deep and this many entries `nestedBoundaries` looks through below a covering share. */
232
+ export declare const NESTED_SCAN_DEPTH = 4;
233
+ export declare const NESTED_SCAN_ENTRIES = 2000;
234
+ /**
235
+ * The nested git repositories (a `.git`, or a bare repository) and `.p2p-private` folders below
236
+ * `root`, for the warning a covering share prints: each stays its own project, but only while its
237
+ * marker is there. Bounded (NESTED_SCAN_DEPTH, NESTED_SCAN_ENTRIES: `capped` past it); symlinks
238
+ * are never followed.
239
+ */
240
+ export declare function nestedBoundaries(root: string): {
241
+ repos: string[];
242
+ private: string[];
243
+ capped: boolean;
244
+ };
131
245
  /**
132
246
  * `p2p project share`: share the project at `dir` with circles you joined and friends. Replaces the
133
247
  * project's shares with exactly these (`add` keeps the ones it has). Only ever the person's
@@ -138,6 +252,7 @@ export declare function shareProject(app: App, dir: string, targets: {
138
252
  circles?: string[];
139
253
  people?: string[];
140
254
  add?: boolean;
255
+ subfolders?: boolean;
141
256
  }): Promise<{
142
257
  project: ProjectView;
143
258
  warnings: string[];
@@ -146,8 +261,38 @@ export declare function shareProject(app: App, dir: string, targets: {
146
261
  export declare function makeProjectPrivate(app: App, dir: string): Promise<ProjectView>;
147
262
  /** `p2p project ls`: every project with a policy on this device. */
148
263
  export declare function listProjects(app: App): Promise<ProjectView[]>;
149
- /** `p2p project show`: the project at `dir`, its policy and why. */
264
+ /** `p2p project show`: the project at `dir` (a shared folder above it covers it), its policy and why. */
150
265
  export declare function showProject(app: App, dir: string): Promise<ProjectView>;
266
+ /**
267
+ * The folders an agent keeps for this one session (Claude Code: its background tasks' output, the
268
+ * large tool results it saved, its subagents' transcripts, a background job's folder), which its
269
+ * front end names in SCRATCH_ENV. What is in them came from the session's own tool calls, whose
270
+ * real paths were bound already, so a path in them is the session, not a project of its own.
271
+ * Each is matched by the session's exact id, on real paths:
272
+ * - `bases`: a folder whose `<one folder>/<sid>` subtree is this session's: `<tmp>/claude-<uid>`
273
+ * (`<tmp>/claude-<uid>/<project>/<sid>/tasks/…`) and `<config>/projects`
274
+ * (`<config>/projects/<project>/<sid>/tool-results/…`, `…/subagents/…`). Never what is shared
275
+ * across sessions there (`<config>/projects/<project>/memory`, other sessions' transcripts);
276
+ * - `jobs`: the session's background job folder (`<config>/jobs/<id>`, `<id>` the start of `sid`,
277
+ * so a job's next conversation after a /clear, which has a new id, has none).
278
+ */
279
+ export interface SessionScratch {
280
+ sid: string;
281
+ bases: string[];
282
+ jobs: string[];
283
+ }
284
+ /** The variable a front end names its session's scratch in (JSON: `{sid, tmp: [..], config, job}`). */
285
+ export declare const SCRATCH_ENV = "P2P_SESSION_SCRATCH";
286
+ /** At most this many entries a scratch folder is scanned for symlinks; past it nothing in it is skipped (fails closed: paths there bind). */
287
+ export declare const SCRATCH_SCAN_ENTRIES = 4096;
288
+ /**
289
+ * The scratch a front end named (SCRATCH_ENV), checked: the id's shape; each folder there this
290
+ * user's own and not a symlink; the temporary one named as Claude Code names it (`claude-<uid>`);
291
+ * the job folder right in `<config>/jobs`, its name the start of the id. Anything else: none.
292
+ */
293
+ export declare function sessionScratch(raw: string | undefined): SessionScratch | undefined;
294
+ /** The scratch folder (`<base>/<project>/<sid>`, or the job folder) the real folder `dir` is in, if any. */
295
+ export declare function scratchRoot(dir: string, s: SessionScratch): string | undefined;
151
296
  /**
152
297
  * Binds a session to the projects of `dirs` (sticky: a session's projects only ever grow until it
153
298
  * ends), plus a constraint an own-device message carried. The person's own session is never
@@ -156,9 +301,10 @@ export declare function showProject(app: App, dir: string): Promise<ProjectView>
156
301
  */
157
302
  export declare function bindSession(app: App, sid: string, dirs: readonly string[], o?: {
158
303
  person?: boolean;
159
- over?: boolean;
304
+ over?: boolean | readonly OverWhy[];
160
305
  constraint?: ProjectShare;
161
306
  inbound?: boolean;
307
+ scratch?: SessionScratch;
162
308
  }): Promise<SessionBinding | undefined>;
163
309
  /**
164
310
  * The variables Claude Code and Codex set in the commands their agents run (an allow-list, from
@@ -175,6 +321,19 @@ export { isAgentProcess };
175
321
  export declare function personTokenFile(home: string): string;
176
322
  /** The person token, made once (exclusively, 0600, in the CLI's own folder, which the mod's guards keep from the model). */
177
323
  export declare function personToken(home: string): string;
324
+ /**
325
+ * Replaces the person token with a fresh one. Called whenever an identity is first created or
326
+ * restored on a home (init, link join, backup restore; setup and join create through init): a
327
+ * person.key that was already there may have been put there by anything that could write the
328
+ * folder before the identity existed, so it must not keep standing in for the person afterwards.
329
+ * The command that creates the identity checked its token when it started, so a front end's first
330
+ * run still works; the front ends read person.key again when the CLI refuses their old token
331
+ * (`person_token_stale`). Written whole: a new 0600 file made exclusively beside it, then renamed
332
+ * over it (a planted symlink is replaced, never followed).
333
+ */
334
+ export declare function renewPersonToken(home: string): string;
335
+ /** Whether `home` holds an identity: its keys and self documents (state.ts keeps them at <home>/cli/keys.json and self.json). */
336
+ export declare function identityHere(home: string): boolean;
178
337
  /** Whether P2P_PERSON_TOKEN is this home's person token (read only: a missing file is no match). */
179
338
  export declare function personTokenOk(env: Record<string, string | undefined> | undefined, home: string | undefined): boolean;
180
339
  /**
@@ -188,16 +347,44 @@ export type ConfirmTty = (question: string) => Promise<boolean>;
188
347
  * Lets a command that widens who reaches this user (sharing a project, a session, a default
189
348
  * circle, invites, joins, trust, friends) run only for the person: their front end's token; or,
190
349
  * outside any agent's session, their "yes" typed on the controlling terminal (never stdin, never a
191
- * flag: a process detached from every terminal can't give it). Reads are never asked.
350
+ * flag: a process detached from every terminal can't give it). Reads are never asked, except for
351
+ * the person's own messages (history.ts), which pass their own `why`.
192
352
  */
193
353
  export declare function assertPersonForWidening(app: Pick<App, "env"> & {
194
354
  front?: boolean;
195
- }, what: string, confirm: ConfirmTty): Promise<void>;
355
+ home?: string;
356
+ }, what: string, confirm: ConfirmTty, why?: string, opts?: {
357
+ noTokenBeforeIdentity?: boolean;
358
+ }): Promise<void>;
359
+ /**
360
+ * For an act on a session that binds nothing (a delivery receipt): the session's front end (its
361
+ * token); or, outside any agent's session, a caller acting for a session no front end registered.
362
+ * An agent's own shell never may, as for statuses and sends (bindSession).
363
+ */
364
+ export declare function assertSpeaksFor(app: App, sid: string): Promise<void>;
196
365
  /** Whether a person-only path (session `tui`) may run here: the person's front end, or no agent in sight (then a terminal "yes" too). */
197
366
  export declare function personHere(app: Pick<App, "env"> & {
198
367
  front?: boolean;
199
368
  }): boolean;
200
369
  export declare function sessionBinding(app: App, sid: string): Promise<SessionBinding | undefined>;
370
+ /** One reason a session is private, as said to the person (and to a model that reads a refusal). */
371
+ export interface PrivateReason {
372
+ cause: PrivateCause;
373
+ why: string;
374
+ /** The project it is about, when it is one project's policy. */
375
+ project?: string;
376
+ }
377
+ /** Why a binding is private, every cause (no network: `disjoint` needs the store, see sessionCeiling). */
378
+ export declare function privateReasons(doc: ProjectsDoc, b: SessionBinding): PrivateReason[];
379
+ /**
380
+ * What the person can do about a private session, for an error a model may read: a share only
381
+ * when a share can lift it, never the "share each project" hint for a cause that lasts until the
382
+ * session ends (a cap, an unresolved path, a dropped front end, `.p2p-private`, a private
383
+ * session's message).
384
+ */
385
+ export declare function privateRemedy(causes: readonly PrivateCause[], names: string[]): string;
386
+ /** Whether a ceiling's privacy can only end with the session (privateRemedy says to start a new one). */
387
+ export declare function stickyPrivate(c: Ceiling): boolean;
201
388
  /**
202
389
  * The most a session may reach: the intersection of every bound project's policy. Unmapped,
203
390
  * private and repository-private projects make it private, and so does an empty intersection.
@@ -227,10 +414,36 @@ export interface SessionProjectView {
227
414
  /** `private`: only your own devices see it; `shared`: the circles and people below (all its projects share them). */
228
415
  policy: "private" | "shared" | "none";
229
416
  why?: string;
417
+ /** Why it is private, as codes (PrivateCause). */
418
+ causes?: PrivateCause[];
230
419
  circles?: string[];
231
420
  people?: string[];
232
421
  }
233
422
  export declare function sessionProjectView(app: App, sid: string): Promise<SessionProjectView>;
423
+ /** `p2p session show`: one session's bound projects, each one's policy, and every reason it is private. */
424
+ export interface SessionShow {
425
+ sid: string;
426
+ policy: "private" | "shared" | "none";
427
+ /** Every reason it is private (empty when it isn't). */
428
+ reasons: PrivateReason[];
429
+ /** What the person can do about it (privateRemedy). */
430
+ remedy?: string;
431
+ /** Who it reaches, when shared: circle ids and userIds. */
432
+ circles?: string[];
433
+ people?: string[];
434
+ projects: (ProjectView & {
435
+ under?: string[];
436
+ underOver?: true;
437
+ })[];
438
+ /** Bounds own-session messages carried in (projects.v1). */
439
+ constraints: number;
440
+ }
441
+ /**
442
+ * `p2p session show <sid>`: read only, and the person's: their front end (the person token) or
443
+ * their own terminal outside any agent's session. An agent's shell is refused, so no session reads
444
+ * another's bindings (or its own: the model has the not_shared reason already).
445
+ */
446
+ export declare function showSession(app: App, sid: string): Promise<SessionShow>;
234
447
  /**
235
448
  * The one-time notice for a user who relied on the default circle: shown once per device, the
236
449
  * first time a session of theirs is private only because its project was never shared.
@@ -238,3 +451,108 @@ export declare function sessionProjectView(app: App, sid: string): Promise<Sessi
238
451
  export declare function defaultCircleNotice(app: App, sid: string): Promise<string | undefined>;
239
452
  /** The text of the one-time notice starts so (the mod and the Codex bridge match it). */
240
453
  export declare const PROJECT_NOTICE_PREFIX = "project boundaries:";
454
+ /**
455
+ * Where Ix calls made for a project (or a session) may go. `local`: this machine's own Ix backend,
456
+ * the only target today. `shared`: the shared graph of exactly one circle the project is shared
457
+ * with (Ix-memory, through Ix Pro), once one exists: a later PR adds the registry of shared
458
+ * graphs, and until then nothing resolves to it.
459
+ */
460
+ export type GraphTarget = {
461
+ kind: "local";
462
+ endpoint: string;
463
+ why: string;
464
+ } | {
465
+ kind: "shared";
466
+ circle: string;
467
+ endpoint: string;
468
+ };
469
+ /** What `p2p doctor` and `p2p project show` print for a local target. */
470
+ export declare const GRAPH_LOCAL_ONLY = "local only";
471
+ /** Ix's own default backend (ix-cli config.ts DEFAULT_ENDPOINT): `ix docker` runs it on this machine. */
472
+ export declare const DEFAULT_IX_ENDPOINT = "http://localhost:8090";
473
+ /**
474
+ * Whether `url` is an Ix backend on this machine: http(s) to localhost, 127.0.0.0/8 or ::1, with no
475
+ * credentials, query or fragment. Anything else (a cloud URL, a LAN host, `localhost.example.com`,
476
+ * `http://127.0.0.1@evil.example`) is not.
477
+ */
478
+ export declare function isLoopbackEndpoint(url: unknown): url is string;
479
+ /** A loopback endpoint as one canonical string: `origin + pathname`, trailing slashes dropped. Undefined when it isn't one. */
480
+ export declare function normalizeLoopbackEndpoint(url: unknown): string | undefined;
481
+ /**
482
+ * The local Ix endpoint every `local` target names: `ixEndpoint` in config.json (the person's own
483
+ * file) when it is a loopback URL, else Ix's default. Never from the environment (an agent or a
484
+ * project config can set that), and never a non-loopback URL. On a shared machine another user can
485
+ * listen on a loopback port first (threat model, "Graph targets").
486
+ */
487
+ export declare function localGraphEndpoint(_env: Record<string, string | undefined>, file?: {
488
+ ixEndpoint?: unknown;
489
+ }): string;
490
+ /**
491
+ * The circles that have a shared graph, and its endpoint. None yet: the shared cloud graph (epic #41
492
+ * piece 3) comes in a later PR, which fills this from settled, person-made state. Nothing in the
493
+ * environment, config.json, a repository or a peer's message can add to it.
494
+ */
495
+ export declare const SHARED_GRAPHS: ReadonlyMap<string, string>;
496
+ /** One input to a graph target: a bound project's (or a constraint's) share, as the ceiling sees it. */
497
+ export interface GraphShareInput {
498
+ name: string;
499
+ share: ProjectShare;
500
+ repoPrivate?: true;
501
+ }
502
+ /**
503
+ * The graph target of a set of projects (pure: graphTarget gathers the inputs). Intersection, like
504
+ * the session ceiling: any private, repository-private or unmapped project makes it local, and so
505
+ * does an empty set. A shared target needs every input shared with the same circle, and exactly one
506
+ * such circle with a shared graph (an https endpoint); people-only shares, no common circle, or a
507
+ * choice of several circles all stay local.
508
+ */
509
+ export declare function graphTargetOf(inputs: readonly GraphShareInput[], o: {
510
+ local: string;
511
+ sharedGraphs?: ReadonlyMap<string, string>;
512
+ }): GraphTarget;
513
+ /** A shared graph's endpoint as `origin + pathname` (https, off this machine, no credentials, query or fragment), else undefined. */
514
+ export declare function normalizeSharedEndpoint(url: unknown): string | undefined;
515
+ /**
516
+ * The chokepoint for every Ix call Peer2Peer makes or lets an extension make (ext-ix takes its
517
+ * endpoint only from here, ExtContext.graphTarget): the graph a session, the folders it works in,
518
+ * or both may reach. A session bound to a private project, or one whose ceiling is private for any
519
+ * reason (an unregistered agent session, too many projects, a private session's message), is local.
520
+ * The folders' own projects are intersected in, so a session can't name a shared sibling to widen
521
+ * a private repository it works in. The process's own cwd and every path the call names (`paths`:
522
+ * its targets, `--path`, `--changed`, the child's cwd) are intersected in as well. A named session
523
+ * that isn't bound yet is local, and a `shared` result needs a session a front end registered (its
524
+ * person token). Read only: binds nothing.
525
+ */
526
+ export declare function graphTarget(app: App, o?: {
527
+ sid?: string;
528
+ dirs?: readonly string[];
529
+ paths?: readonly string[];
530
+ over?: boolean;
531
+ }, sharedGraphs?: ReadonlyMap<string, string>): Promise<GraphTarget>;
532
+ /** At most this many paths one Ix call may name for its graph target; past it, local. */
533
+ export declare const MAX_GRAPH_PATHS = 64;
534
+ /** One project's graph target (`p2p project show`, `p2p doctor`). */
535
+ export declare function projectGraphTarget(app: Pick<App, "env" | "file">, ref: Pick<ProjectRef, "id" | "name" | "repoPrivate">, doc: ProjectsDoc): GraphTarget;
536
+ /** How a target reads in one line: `local only (http://localhost:8090)`, or the circle's shared graph. */
537
+ export declare function describeGraphTarget(t: GraphTarget): string;
538
+ /** A target with, for a local one, why: the one wording `p2p project show|ls` and `p2p doctor` print. */
539
+ export declare function graphTargetLine(t: GraphTarget): string;
540
+ /** Who can read what a graph target holds: Ix keeps it in plaintext (docs/security/encryption.md). */
541
+ export declare function graphPlaintextNote(t: GraphTarget): string;
542
+ /**
543
+ * The Ix variables that could send an `ix` call somewhere other than its graph target, or carry a
544
+ * cloud credential: Ix Pro's PAT mode (IX_PAT, IX_ORG, its endpoint override), the cloud push and
545
+ * ingestion knobs, the OAuth secret, auto-map routing to the cloud. Every IX_* variable outside
546
+ * IX_KEEP is dropped as well; these are named so tests and docs can point at them.
547
+ */
548
+ export declare const IX_CLOUD_ENV: readonly string[];
549
+ /** IX_* variables an `ix` call keeps: which binary (read by ext-ix, not ix), where Ix keeps its local state, and the local backend's token (Ix sends it to a loopback endpoint only). */
550
+ export declare const IX_KEEP: readonly string[];
551
+ /**
552
+ * The environment an extension gets (ExtContext.env), with the target pinned: every IX_* variable
553
+ * outside IX_KEEP set to undefined (so a `{...process.env, ...ctx.env}` merge drops it too: an older
554
+ * ext-ix spreads it), IX_ENDPOINT set to the target's endpoint, and readers kept from starting a
555
+ * background `ix map` (Ix Pro routes a map to the cloud when an org session is active, whatever
556
+ * IX_ENDPOINT says). Defence in depth: ext-ix builds its own allowlisted env from the target.
557
+ */
558
+ export declare function graphPinnedEnv(env: Record<string, string | undefined>, target: GraphTarget, base?: Record<string, string | undefined>): Record<string, string | undefined>;