@peer2peer/cli 0.1.0 → 0.1.1
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 +14 -10
- package/dist/app.d.ts +5 -0
- package/dist/app.js +5 -1
- package/dist/cli.d.ts +53 -4
- package/dist/cli.js +147 -10
- package/dist/config.d.ts +47 -0
- package/dist/config.js +51 -0
- package/dist/doctor.d.ts +14 -0
- package/dist/doctor.js +114 -1
- package/dist/ext-host.d.ts +6 -0
- package/dist/ext-host.js +36 -2
- package/dist/extensions.d.ts +101 -0
- package/dist/extensions.js +11 -0
- package/dist/graph-memory.d.ts +107 -0
- package/dist/graph-memory.js +393 -0
- package/dist/history.d.ts +155 -0
- package/dist/history.js +697 -0
- package/dist/identity.d.ts +3 -0
- package/dist/identity.js +8 -0
- package/dist/inbound.js +4 -1
- package/dist/ix-local.d.ts +76 -0
- package/dist/ix-local.js +203 -0
- package/dist/projects.d.ts +261 -10
- package/dist/projects.js +753 -69
- package/dist/receipts.js +3 -1
- package/dist/sessions.d.ts +20 -5
- package/dist/sessions.js +112 -17
- package/dist/state.d.ts +26 -0
- package/dist/state.js +3 -0
- package/dist/tui/model.d.ts +7 -1
- package/dist/tui/model.js +8 -4
- package/dist/tui/tui.d.ts +9 -2
- package/dist/tui/tui.js +47 -6
- package/dist/tui/view.js +6 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/watch.js +6 -0
- package/package.json +3 -3
package/dist/projects.d.ts
CHANGED
|
@@ -18,7 +18,19 @@ 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
36
|
/** At most this many projects per session; past it the session is private. */
|
|
@@ -49,6 +61,11 @@ export interface ProjectPolicyRec {
|
|
|
49
61
|
root: string;
|
|
50
62
|
remote?: string;
|
|
51
63
|
share: ProjectShare;
|
|
64
|
+
/**
|
|
65
|
+
* A folder project's share covers its subfolders too (`p2p project share --subfolders`). Without
|
|
66
|
+
* it (every policy from before it), the policy is for that folder alone.
|
|
67
|
+
*/
|
|
68
|
+
covers?: true;
|
|
52
69
|
at: number;
|
|
53
70
|
}
|
|
54
71
|
export interface ProjectsDoc {
|
|
@@ -58,12 +75,10 @@ export interface ProjectsDoc {
|
|
|
58
75
|
noticeAt?: number;
|
|
59
76
|
}
|
|
60
77
|
export interface SessionBinding {
|
|
61
|
-
projects: Record<string,
|
|
62
|
-
|
|
63
|
-
repoPrivate?: true;
|
|
64
|
-
}>;
|
|
65
|
-
/** More than MAX_SESSION_PROJECTS projects or MAX_SESSION_DIRS folders: private. */
|
|
78
|
+
projects: Record<string, BoundProject>;
|
|
79
|
+
/** Past a cap, or a path its front end couldn't resolve: private (overWhy says which; absent in bindings from before it). */
|
|
66
80
|
over?: true;
|
|
81
|
+
overWhy?: OverWhy[];
|
|
67
82
|
/**
|
|
68
83
|
* What other sessions of this user that sent to this one could reach (own-device messages carry
|
|
69
84
|
* their sender's ceiling): intersected in, sticky, so a private session can't launder through a
|
|
@@ -74,22 +89,63 @@ export interface SessionBinding {
|
|
|
74
89
|
unregistered?: true;
|
|
75
90
|
/** A front end holding the person token (personTokenOk) has used it. */
|
|
76
91
|
registered?: true;
|
|
92
|
+
/** When this binding began (ms): a session id bound anew (its old binding expired) starts again here (history.ts). */
|
|
93
|
+
since?: number;
|
|
77
94
|
at: number;
|
|
78
95
|
}
|
|
79
96
|
/** At most this many constraints a session keeps; past it, private. */
|
|
80
97
|
export declare const MAX_SESSION_CONSTRAINTS = 16;
|
|
81
98
|
export type SessionProjectsDoc = Record<string, SessionBinding>;
|
|
99
|
+
export interface BoundProject {
|
|
100
|
+
name: string;
|
|
101
|
+
/** Its folder (git: the working tree it was first seen in), for `p2p session show`. */
|
|
102
|
+
root?: string;
|
|
103
|
+
repoPrivate?: true;
|
|
104
|
+
/**
|
|
105
|
+
* Folders below `root` that a shared folder covered (dir projects only, at most MAX_UNDER): a
|
|
106
|
+
* policy given to one of them later still narrows this session. `underOver`: more than that,
|
|
107
|
+
* so any policy below `root` does.
|
|
108
|
+
*/
|
|
109
|
+
under?: string[];
|
|
110
|
+
underOver?: true;
|
|
111
|
+
}
|
|
112
|
+
/** At most this many covered subfolders a bound folder project remembers; past it, every policy below it counts. */
|
|
113
|
+
export declare const MAX_UNDER = 64;
|
|
82
114
|
/** What a session may reach. `none`: the person's own session, or one not bound yet. */
|
|
83
115
|
export type Ceiling = {
|
|
84
116
|
kind: "none";
|
|
85
117
|
} | {
|
|
86
118
|
kind: "private";
|
|
87
119
|
why: string;
|
|
120
|
+
causes: PrivateCause[];
|
|
121
|
+
blocking?: string[];
|
|
88
122
|
} | {
|
|
89
123
|
kind: "shared";
|
|
90
124
|
circles: string[];
|
|
91
125
|
people: string[];
|
|
92
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* Why a session is private: an over reason (OverWhy), `unregistered` (an agent named it, no front
|
|
129
|
+
* end registered it), `repo-private` (`.p2p-private`), `private` (a project made private),
|
|
130
|
+
* `unshared` (a project never shared), `sent-private` (a private session of yours sent it a
|
|
131
|
+
* message), `disjoint` (its projects share nobody in common, or nobody you can reach).
|
|
132
|
+
*/
|
|
133
|
+
export type PrivateCause = OverWhy | "legacy-over" | "unregistered" | "repo-private" | "private" | "unshared" | "sent-private" | "disjoint";
|
|
134
|
+
/**
|
|
135
|
+
* Whether `p` is a device or pseudo file (`/dev/null`, `/dev/tty`, `/proc/self/status`), never a
|
|
136
|
+
* project: it exists, isn't a folder, and its real path stays under /dev (and isn't a regular
|
|
137
|
+
* file there, like one in /dev/shm), /proc or /sys. A path through /proc to a real file
|
|
138
|
+
* (`/proc/self/cwd/x`, `/proc/<pid>/root/…`) resolves out of it and binds as usual; one that
|
|
139
|
+
* doesn't exist binds its nearest existing parent as every path does.
|
|
140
|
+
*/
|
|
141
|
+
export declare function pseudoPath(p: string): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Whether a path component holds a brace expansion with a choice: a `{`, then `,` or `..` with no
|
|
144
|
+
* brace between, then `}` (`{.git,x}`, `{a..z}`). One pass, so it stays linear on any input.
|
|
145
|
+
*/
|
|
146
|
+
export declare function braceChoice(c: string): boolean;
|
|
147
|
+
/** A folder project's id: its real path, hashed. */
|
|
148
|
+
export declare function dirProjectId(root: string): string;
|
|
93
149
|
/**
|
|
94
150
|
* A remote URL as one canonical string: scheme, credentials, port-less ssh form, trailing `.git`
|
|
95
151
|
* and slashes dropped, host lower-cased. `https://u:t@GitHub.com/a/b.git` and `git@github.com:a/b`
|
|
@@ -100,8 +156,25 @@ export declare function normalizeRemote(url: string): string | undefined;
|
|
|
100
156
|
* The project `dir` belongs to, read from the files alone (git is never run: no hook, fsmonitor
|
|
101
157
|
* or config of the repository's can execute). A `.git` directory or `gitdir:` file up the tree
|
|
102
158
|
* marks a working tree; its common dir (`commondir` for a linked worktree) identifies the clone.
|
|
159
|
+
* A bare repository (isBareRepo) is a git project too, and a `.git` that can't be read as one is
|
|
160
|
+
* a folder project of its own.
|
|
161
|
+
*
|
|
162
|
+
* Outside git, a folder project. With `doc` (the policies), the nearest folder at or above `dir`
|
|
163
|
+
* that has a policy of its own is the project when that is `dir`'s own folder, or when its share
|
|
164
|
+
* covers subfolders (`covers`, given with `p2p project share --subfolders`; a policy without it
|
|
165
|
+
* is for that folder alone, as before). The walk stops at the first folder with a policy (the
|
|
166
|
+
* nearest one wins, so a private subfolder stays private; one that doesn't cover leaves `dir`'s
|
|
167
|
+
* own folder as the project), and it never crosses:
|
|
168
|
+
* - a git repository (found first: a nested repository is always its own project);
|
|
169
|
+
* - a `.p2p-private` (at or above `dir`: the folder project is private, whatever covers it);
|
|
170
|
+
* - a folder whose `.git` or `.p2p-private` the path itself names (namedStop: a command that may
|
|
171
|
+
* have just removed it);
|
|
172
|
+
* - the nearest existing folder, when `dir` itself isn't there (deleted or moved since the
|
|
173
|
+
* session named it, or not made yet): that folder is the project unless it has a policy, so a
|
|
174
|
+
* repository removed after a session read it is never covered from above.
|
|
175
|
+
* Without `doc` (sharing, `project show`): the folder itself.
|
|
103
176
|
*/
|
|
104
|
-
export declare function projectOf(dir: string): ProjectRef;
|
|
177
|
+
export declare function projectOf(dir: string, doc?: ProjectsDoc): ProjectRef;
|
|
105
178
|
export declare function projectsDoc(app: App): Promise<ProjectsDoc>;
|
|
106
179
|
/** A project's share as stored, or `private` (no policy: private by default). */
|
|
107
180
|
export declare function shareOf(doc: ProjectsDoc, id: string): ProjectShare;
|
|
@@ -126,8 +199,33 @@ export interface ProjectView {
|
|
|
126
199
|
/** Why it is private although a policy shares it, or `unmapped` when none does. */
|
|
127
200
|
why?: string;
|
|
128
201
|
repoPrivate?: true;
|
|
202
|
+
/** A folder whose share covers its subfolders (`p2p project share --subfolders`). */
|
|
203
|
+
covers?: true;
|
|
204
|
+
/** Which Ix graph its work may reach (graphTarget): `local` (only this machine's) today. */
|
|
205
|
+
graph: GraphTarget;
|
|
129
206
|
}
|
|
130
207
|
export declare function projectView(app: App, ref: Pick<ProjectRef, "id" | "name" | "kind" | "root" | "remote" | "repoPrivate">, doc?: ProjectsDoc): Promise<ProjectView>;
|
|
208
|
+
/**
|
|
209
|
+
* Why `root` may not cover its subfolders (a share for it alone is still allowed), or undefined:
|
|
210
|
+
* the file system's root, a home folder or a folder above one (`$HOME`, `/Users`, `/home/<u>`),
|
|
211
|
+
* the temporary folders (`/tmp`, `/private/tmp`, `/var/folders/…`, os.tmpdir() and above it), and
|
|
212
|
+
* the system's top folders. Everything below them would be one project.
|
|
213
|
+
*/
|
|
214
|
+
export declare function broadRoot(root: string, env?: Record<string, string | undefined>): string | undefined;
|
|
215
|
+
/** At most this deep and this many entries `nestedBoundaries` looks through below a covering share. */
|
|
216
|
+
export declare const NESTED_SCAN_DEPTH = 4;
|
|
217
|
+
export declare const NESTED_SCAN_ENTRIES = 2000;
|
|
218
|
+
/**
|
|
219
|
+
* The nested git repositories (a `.git`, or a bare repository) and `.p2p-private` folders below
|
|
220
|
+
* `root`, for the warning a covering share prints: each stays its own project, but only while its
|
|
221
|
+
* marker is there. Bounded (NESTED_SCAN_DEPTH, NESTED_SCAN_ENTRIES: `capped` past it); symlinks
|
|
222
|
+
* are never followed.
|
|
223
|
+
*/
|
|
224
|
+
export declare function nestedBoundaries(root: string): {
|
|
225
|
+
repos: string[];
|
|
226
|
+
private: string[];
|
|
227
|
+
capped: boolean;
|
|
228
|
+
};
|
|
131
229
|
/**
|
|
132
230
|
* `p2p project share`: share the project at `dir` with circles you joined and friends. Replaces the
|
|
133
231
|
* project's shares with exactly these (`add` keeps the ones it has). Only ever the person's
|
|
@@ -138,6 +236,7 @@ export declare function shareProject(app: App, dir: string, targets: {
|
|
|
138
236
|
circles?: string[];
|
|
139
237
|
people?: string[];
|
|
140
238
|
add?: boolean;
|
|
239
|
+
subfolders?: boolean;
|
|
141
240
|
}): Promise<{
|
|
142
241
|
project: ProjectView;
|
|
143
242
|
warnings: string[];
|
|
@@ -146,7 +245,7 @@ export declare function shareProject(app: App, dir: string, targets: {
|
|
|
146
245
|
export declare function makeProjectPrivate(app: App, dir: string): Promise<ProjectView>;
|
|
147
246
|
/** `p2p project ls`: every project with a policy on this device. */
|
|
148
247
|
export declare function listProjects(app: App): Promise<ProjectView[]>;
|
|
149
|
-
/** `p2p project show`: the project at `dir
|
|
248
|
+
/** `p2p project show`: the project at `dir` (a shared folder above it covers it), its policy and why. */
|
|
150
249
|
export declare function showProject(app: App, dir: string): Promise<ProjectView>;
|
|
151
250
|
/**
|
|
152
251
|
* Binds a session to the projects of `dirs` (sticky: a session's projects only ever grow until it
|
|
@@ -156,7 +255,7 @@ export declare function showProject(app: App, dir: string): Promise<ProjectView>
|
|
|
156
255
|
*/
|
|
157
256
|
export declare function bindSession(app: App, sid: string, dirs: readonly string[], o?: {
|
|
158
257
|
person?: boolean;
|
|
159
|
-
over?: boolean;
|
|
258
|
+
over?: boolean | readonly OverWhy[];
|
|
160
259
|
constraint?: ProjectShare;
|
|
161
260
|
inbound?: boolean;
|
|
162
261
|
}): Promise<SessionBinding | undefined>;
|
|
@@ -188,16 +287,41 @@ export type ConfirmTty = (question: string) => Promise<boolean>;
|
|
|
188
287
|
* Lets a command that widens who reaches this user (sharing a project, a session, a default
|
|
189
288
|
* circle, invites, joins, trust, friends) run only for the person: their front end's token; or,
|
|
190
289
|
* 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
|
|
290
|
+
* flag: a process detached from every terminal can't give it). Reads are never asked, except for
|
|
291
|
+
* the person's own messages (history.ts), which pass their own `why`.
|
|
192
292
|
*/
|
|
193
293
|
export declare function assertPersonForWidening(app: Pick<App, "env"> & {
|
|
194
294
|
front?: boolean;
|
|
195
|
-
}, what: string, confirm: ConfirmTty): Promise<void>;
|
|
295
|
+
}, what: string, confirm: ConfirmTty, why?: string): Promise<void>;
|
|
296
|
+
/**
|
|
297
|
+
* For an act on a session that binds nothing (a delivery receipt): the session's front end (its
|
|
298
|
+
* token); or, outside any agent's session, a caller acting for a session no front end registered.
|
|
299
|
+
* An agent's own shell never may, as for statuses and sends (bindSession).
|
|
300
|
+
*/
|
|
301
|
+
export declare function assertSpeaksFor(app: App, sid: string): Promise<void>;
|
|
196
302
|
/** 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
303
|
export declare function personHere(app: Pick<App, "env"> & {
|
|
198
304
|
front?: boolean;
|
|
199
305
|
}): boolean;
|
|
200
306
|
export declare function sessionBinding(app: App, sid: string): Promise<SessionBinding | undefined>;
|
|
307
|
+
/** One reason a session is private, as said to the person (and to a model that reads a refusal). */
|
|
308
|
+
export interface PrivateReason {
|
|
309
|
+
cause: PrivateCause;
|
|
310
|
+
why: string;
|
|
311
|
+
/** The project it is about, when it is one project's policy. */
|
|
312
|
+
project?: string;
|
|
313
|
+
}
|
|
314
|
+
/** Why a binding is private, every cause (no network: `disjoint` needs the store, see sessionCeiling). */
|
|
315
|
+
export declare function privateReasons(doc: ProjectsDoc, b: SessionBinding): PrivateReason[];
|
|
316
|
+
/**
|
|
317
|
+
* What the person can do about a private session, for an error a model may read: a share only
|
|
318
|
+
* when a share can lift it, never the "share each project" hint for a cause that lasts until the
|
|
319
|
+
* session ends (a cap, an unresolved path, a dropped front end, `.p2p-private`, a private
|
|
320
|
+
* session's message).
|
|
321
|
+
*/
|
|
322
|
+
export declare function privateRemedy(causes: readonly PrivateCause[], names: string[]): string;
|
|
323
|
+
/** Whether a ceiling's privacy can only end with the session (privateRemedy says to start a new one). */
|
|
324
|
+
export declare function stickyPrivate(c: Ceiling): boolean;
|
|
201
325
|
/**
|
|
202
326
|
* The most a session may reach: the intersection of every bound project's policy. Unmapped,
|
|
203
327
|
* private and repository-private projects make it private, and so does an empty intersection.
|
|
@@ -227,10 +351,36 @@ export interface SessionProjectView {
|
|
|
227
351
|
/** `private`: only your own devices see it; `shared`: the circles and people below (all its projects share them). */
|
|
228
352
|
policy: "private" | "shared" | "none";
|
|
229
353
|
why?: string;
|
|
354
|
+
/** Why it is private, as codes (PrivateCause). */
|
|
355
|
+
causes?: PrivateCause[];
|
|
230
356
|
circles?: string[];
|
|
231
357
|
people?: string[];
|
|
232
358
|
}
|
|
233
359
|
export declare function sessionProjectView(app: App, sid: string): Promise<SessionProjectView>;
|
|
360
|
+
/** `p2p session show`: one session's bound projects, each one's policy, and every reason it is private. */
|
|
361
|
+
export interface SessionShow {
|
|
362
|
+
sid: string;
|
|
363
|
+
policy: "private" | "shared" | "none";
|
|
364
|
+
/** Every reason it is private (empty when it isn't). */
|
|
365
|
+
reasons: PrivateReason[];
|
|
366
|
+
/** What the person can do about it (privateRemedy). */
|
|
367
|
+
remedy?: string;
|
|
368
|
+
/** Who it reaches, when shared: circle ids and userIds. */
|
|
369
|
+
circles?: string[];
|
|
370
|
+
people?: string[];
|
|
371
|
+
projects: (ProjectView & {
|
|
372
|
+
under?: string[];
|
|
373
|
+
underOver?: true;
|
|
374
|
+
})[];
|
|
375
|
+
/** Bounds own-session messages carried in (projects.v1). */
|
|
376
|
+
constraints: number;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* `p2p session show <sid>`: read only, and the person's: their front end (the person token) or
|
|
380
|
+
* their own terminal outside any agent's session. An agent's shell is refused, so no session reads
|
|
381
|
+
* another's bindings (or its own: the model has the not_shared reason already).
|
|
382
|
+
*/
|
|
383
|
+
export declare function showSession(app: App, sid: string): Promise<SessionShow>;
|
|
234
384
|
/**
|
|
235
385
|
* The one-time notice for a user who relied on the default circle: shown once per device, the
|
|
236
386
|
* first time a session of theirs is private only because its project was never shared.
|
|
@@ -238,3 +388,104 @@ export declare function sessionProjectView(app: App, sid: string): Promise<Sessi
|
|
|
238
388
|
export declare function defaultCircleNotice(app: App, sid: string): Promise<string | undefined>;
|
|
239
389
|
/** The text of the one-time notice starts so (the mod and the Codex bridge match it). */
|
|
240
390
|
export declare const PROJECT_NOTICE_PREFIX = "project boundaries:";
|
|
391
|
+
/**
|
|
392
|
+
* Where Ix calls made for a project (or a session) may go. `local`: this machine's own Ix backend,
|
|
393
|
+
* the only target today. `shared`: the shared graph of exactly one circle the project is shared
|
|
394
|
+
* with (Ix-memory, through Ix Pro), once one exists: a later PR adds the registry of shared
|
|
395
|
+
* graphs, and until then nothing resolves to it.
|
|
396
|
+
*/
|
|
397
|
+
export type GraphTarget = {
|
|
398
|
+
kind: "local";
|
|
399
|
+
endpoint: string;
|
|
400
|
+
why: string;
|
|
401
|
+
} | {
|
|
402
|
+
kind: "shared";
|
|
403
|
+
circle: string;
|
|
404
|
+
endpoint: string;
|
|
405
|
+
};
|
|
406
|
+
/** What `p2p doctor` and `p2p project show` print for a local target. */
|
|
407
|
+
export declare const GRAPH_LOCAL_ONLY = "local only";
|
|
408
|
+
/** Ix's own default backend (ix-cli config.ts DEFAULT_ENDPOINT): `ix docker` runs it on this machine. */
|
|
409
|
+
export declare const DEFAULT_IX_ENDPOINT = "http://localhost:8090";
|
|
410
|
+
/**
|
|
411
|
+
* Whether `url` is an Ix backend on this machine: http(s) to localhost, 127.0.0.0/8 or ::1, with no
|
|
412
|
+
* credentials, query or fragment. Anything else (a cloud URL, a LAN host, `localhost.example.com`,
|
|
413
|
+
* `http://127.0.0.1@evil.example`) is not.
|
|
414
|
+
*/
|
|
415
|
+
export declare function isLoopbackEndpoint(url: unknown): url is string;
|
|
416
|
+
/** A loopback endpoint as one canonical string: `origin + pathname`, trailing slashes dropped. Undefined when it isn't one. */
|
|
417
|
+
export declare function normalizeLoopbackEndpoint(url: unknown): string | undefined;
|
|
418
|
+
/**
|
|
419
|
+
* The local Ix endpoint every `local` target names: `ixEndpoint` in config.json (the person's own
|
|
420
|
+
* file) when it is a loopback URL, else Ix's default. Never from the environment (an agent or a
|
|
421
|
+
* project config can set that), and never a non-loopback URL. On a shared machine another user can
|
|
422
|
+
* listen on a loopback port first (threat model, "Graph targets").
|
|
423
|
+
*/
|
|
424
|
+
export declare function localGraphEndpoint(_env: Record<string, string | undefined>, file?: {
|
|
425
|
+
ixEndpoint?: unknown;
|
|
426
|
+
}): string;
|
|
427
|
+
/**
|
|
428
|
+
* The circles that have a shared graph, and its endpoint. None yet: the shared cloud graph (epic #41
|
|
429
|
+
* piece 3) comes in a later PR, which fills this from settled, person-made state. Nothing in the
|
|
430
|
+
* environment, config.json, a repository or a peer's message can add to it.
|
|
431
|
+
*/
|
|
432
|
+
export declare const SHARED_GRAPHS: ReadonlyMap<string, string>;
|
|
433
|
+
/** One input to a graph target: a bound project's (or a constraint's) share, as the ceiling sees it. */
|
|
434
|
+
export interface GraphShareInput {
|
|
435
|
+
name: string;
|
|
436
|
+
share: ProjectShare;
|
|
437
|
+
repoPrivate?: true;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* The graph target of a set of projects (pure: graphTarget gathers the inputs). Intersection, like
|
|
441
|
+
* the session ceiling: any private, repository-private or unmapped project makes it local, and so
|
|
442
|
+
* does an empty set. A shared target needs every input shared with the same circle, and exactly one
|
|
443
|
+
* such circle with a shared graph (an https endpoint); people-only shares, no common circle, or a
|
|
444
|
+
* choice of several circles all stay local.
|
|
445
|
+
*/
|
|
446
|
+
export declare function graphTargetOf(inputs: readonly GraphShareInput[], o: {
|
|
447
|
+
local: string;
|
|
448
|
+
sharedGraphs?: ReadonlyMap<string, string>;
|
|
449
|
+
}): GraphTarget;
|
|
450
|
+
/** A shared graph's endpoint as `origin + pathname` (https, off this machine, no credentials, query or fragment), else undefined. */
|
|
451
|
+
export declare function normalizeSharedEndpoint(url: unknown): string | undefined;
|
|
452
|
+
/**
|
|
453
|
+
* The chokepoint for every Ix call Peer2Peer makes or lets an extension make (ext-ix takes its
|
|
454
|
+
* endpoint only from here, ExtContext.graphTarget): the graph a session, the folders it works in,
|
|
455
|
+
* or both may reach. A session bound to a private project, or one whose ceiling is private for any
|
|
456
|
+
* reason (an unregistered agent session, too many projects, a private session's message), is local.
|
|
457
|
+
* The folders' own projects are intersected in, so a session can't name a shared sibling to widen
|
|
458
|
+
* a private repository it works in. The process's own cwd and every path the call names (`paths`:
|
|
459
|
+
* its targets, `--path`, `--changed`, the child's cwd) are intersected in as well. A named session
|
|
460
|
+
* that isn't bound yet is local, and a `shared` result needs a session a front end registered (its
|
|
461
|
+
* person token). Read only: binds nothing.
|
|
462
|
+
*/
|
|
463
|
+
export declare function graphTarget(app: App, o?: {
|
|
464
|
+
sid?: string;
|
|
465
|
+
dirs?: readonly string[];
|
|
466
|
+
paths?: readonly string[];
|
|
467
|
+
over?: boolean;
|
|
468
|
+
}, sharedGraphs?: ReadonlyMap<string, string>): Promise<GraphTarget>;
|
|
469
|
+
/** At most this many paths one Ix call may name for its graph target; past it, local. */
|
|
470
|
+
export declare const MAX_GRAPH_PATHS = 64;
|
|
471
|
+
/** One project's graph target (`p2p project show`, `p2p doctor`). */
|
|
472
|
+
export declare function projectGraphTarget(app: Pick<App, "env" | "file">, ref: Pick<ProjectRef, "id" | "name" | "repoPrivate">, doc: ProjectsDoc): GraphTarget;
|
|
473
|
+
/** How a target reads in one line: `local only (http://localhost:8090)`, or the circle's shared graph. */
|
|
474
|
+
export declare function describeGraphTarget(t: GraphTarget): string;
|
|
475
|
+
/**
|
|
476
|
+
* The Ix variables that could send an `ix` call somewhere other than its graph target, or carry a
|
|
477
|
+
* cloud credential: Ix Pro's PAT mode (IX_PAT, IX_ORG, its endpoint override), the cloud push and
|
|
478
|
+
* ingestion knobs, the OAuth secret, auto-map routing to the cloud. Every IX_* variable outside
|
|
479
|
+
* IX_KEEP is dropped as well; these are named so tests and docs can point at them.
|
|
480
|
+
*/
|
|
481
|
+
export declare const IX_CLOUD_ENV: readonly string[];
|
|
482
|
+
/** 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). */
|
|
483
|
+
export declare const IX_KEEP: readonly string[];
|
|
484
|
+
/**
|
|
485
|
+
* The environment an extension gets (ExtContext.env), with the target pinned: every IX_* variable
|
|
486
|
+
* outside IX_KEEP set to undefined (so a `{...process.env, ...ctx.env}` merge drops it too: an older
|
|
487
|
+
* ext-ix spreads it), IX_ENDPOINT set to the target's endpoint, and readers kept from starting a
|
|
488
|
+
* background `ix map` (Ix Pro routes a map to the cloud when an org session is active, whatever
|
|
489
|
+
* IX_ENDPOINT says). Defence in depth: ext-ix builds its own allowlisted env from the target.
|
|
490
|
+
*/
|
|
491
|
+
export declare function graphPinnedEnv(env: Record<string, string | undefined>, target: GraphTarget, base?: Record<string, string | undefined>): Record<string, string | undefined>;
|