@peer2peer/cli 0.1.1 → 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 +16 -12
- package/dist/ancestry.d.ts +42 -2
- package/dist/ancestry.js +215 -32
- package/dist/app.d.ts +120 -0
- package/dist/app.js +254 -42
- package/dist/cli.d.ts +53 -5
- package/dist/cli.js +375 -35
- package/dist/config.d.ts +5 -0
- package/dist/doctor.d.ts +71 -2
- package/dist/doctor.js +123 -16
- package/dist/ext-host.js +5 -1
- package/dist/extensions.js +2 -2
- package/dist/format.d.ts +2 -0
- package/dist/format.js +5 -1
- package/dist/identity.d.ts +35 -5
- package/dist/identity.js +103 -26
- package/dist/ix-local.d.ts +63 -11
- package/dist/ix-local.js +81 -24
- package/dist/pretty.d.ts +3 -1
- package/dist/pretty.js +11 -3
- package/dist/projects.d.ts +119 -6
- package/dist/projects.js +494 -36
- package/dist/rotation.d.ts +20 -1
- package/dist/rotation.js +294 -20
- package/dist/sessions.d.ts +8 -0
- package/dist/sessions.js +73 -16
- package/dist/social.js +11 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/watch.js +43 -13
- package/package.json +6 -3
package/dist/projects.d.ts
CHANGED
|
@@ -33,8 +33,12 @@ export type OverWhy = "projects" | "folders" | "unresolved" | "front" | "constra
|
|
|
33
33
|
export declare function overWhys(v: unknown): OverWhy[];
|
|
34
34
|
/** At most this many folders a front end passes per call; past it the session is private. */
|
|
35
35
|
export declare const MAX_SESSION_DIRS = 512;
|
|
36
|
-
/**
|
|
37
|
-
|
|
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;
|
|
38
42
|
/** Bindings of sessions not seen for this long are dropped. */
|
|
39
43
|
export declare const SESSION_BINDING_TTL_MS: number;
|
|
40
44
|
/** At most this many circles and people in one project's policy. */
|
|
@@ -51,6 +55,8 @@ export interface ProjectRef {
|
|
|
51
55
|
remote?: string;
|
|
52
56
|
/** The repository asks to stay private (a committed PRIVATE_MARKER at `root`). */
|
|
53
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;
|
|
54
60
|
}
|
|
55
61
|
export type ProjectShare = "private" | {
|
|
56
62
|
circles: string[];
|
|
@@ -131,6 +137,16 @@ export type Ceiling = {
|
|
|
131
137
|
* message), `disjoint` (its projects share nobody in common, or nobody you can reach).
|
|
132
138
|
*/
|
|
133
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;
|
|
134
150
|
/**
|
|
135
151
|
* Whether `p` is a device or pseudo file (`/dev/null`, `/dev/tty`, `/proc/self/status`), never a
|
|
136
152
|
* project: it exists, isn't a folder, and its real path stays under /dev (and isn't a regular
|
|
@@ -247,6 +263,36 @@ export declare function makeProjectPrivate(app: App, dir: string): Promise<Proje
|
|
|
247
263
|
export declare function listProjects(app: App): Promise<ProjectView[]>;
|
|
248
264
|
/** `p2p project show`: the project at `dir` (a shared folder above it covers it), its policy and why. */
|
|
249
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;
|
|
250
296
|
/**
|
|
251
297
|
* Binds a session to the projects of `dirs` (sticky: a session's projects only ever grow until it
|
|
252
298
|
* ends), plus a constraint an own-device message carried. The person's own session is never
|
|
@@ -258,6 +304,7 @@ export declare function bindSession(app: App, sid: string, dirs: readonly string
|
|
|
258
304
|
over?: boolean | readonly OverWhy[];
|
|
259
305
|
constraint?: ProjectShare;
|
|
260
306
|
inbound?: boolean;
|
|
307
|
+
scratch?: SessionScratch;
|
|
261
308
|
}): Promise<SessionBinding | undefined>;
|
|
262
309
|
/**
|
|
263
310
|
* The variables Claude Code and Codex set in the commands their agents run (an allow-list, from
|
|
@@ -270,12 +317,67 @@ export declare function agentEnv(env: Record<string, string | undefined> | undef
|
|
|
270
317
|
/** Whether this call runs on an agent's behalf: its environment, or a Claude Code or Codex ancestor (ancestry.ts). */
|
|
271
318
|
export declare function agentContext(env: Record<string, string | undefined> | undefined): boolean;
|
|
272
319
|
export { isAgentProcess };
|
|
273
|
-
/**
|
|
320
|
+
/**
|
|
321
|
+
* `<home>/cli/person.key`: the secret the person's front ends (the Claude mod, the Codex bridge)
|
|
322
|
+
* pass back as P2P_PERSON_TOKEN. On a home with an identity it is derived, never just stored: an
|
|
323
|
+
* HMAC under this device's signing key over the home's salt (`person.salt`, replaced whenever an
|
|
324
|
+
* identity is created or restored here), so a person.key that anything else wrote never verifies
|
|
325
|
+
* (personTokenOk recomputes it). On a fresh home (no identity yet) it is a random value, as the
|
|
326
|
+
* front ends make it on a first run.
|
|
327
|
+
*/
|
|
274
328
|
export declare function personTokenFile(home: string): string;
|
|
275
|
-
/**
|
|
329
|
+
/** `<home>/cli/person.salt`: the per-home salt of the derived person token (replaced with the identity). */
|
|
330
|
+
export declare function personSaltFile(home: string): string;
|
|
331
|
+
/**
|
|
332
|
+
* Whether the files the person token rests on are this home's own: the `cli` folder, its keys and
|
|
333
|
+
* self documents, the token and its salt, and the `v3` store are no symbolic links, and the keys
|
|
334
|
+
* and self documents have one link each (the CLI writes them by rename, so a second hard link was
|
|
335
|
+
* made by something else). A home put together from links to another home's files (to pair that
|
|
336
|
+
* identity's keys with a token of the maker's choosing) is never the person's.
|
|
337
|
+
*/
|
|
338
|
+
export declare function homeFilesOwn(home: string): boolean;
|
|
339
|
+
/**
|
|
340
|
+
* Whether `token` is the one the identity keys `spk` derive in `home` (its salt), and the home's
|
|
341
|
+
* files are its own. Run against the keys a command actually loaded (App.load), so a home whose
|
|
342
|
+
* files changed after the token was checked never lends the token to other keys.
|
|
343
|
+
*/
|
|
344
|
+
export declare function personTokenMatchesKeys(home: string, spk: string, token: string): boolean;
|
|
345
|
+
/**
|
|
346
|
+
* The person token, made or brought up to date in the CLI's own folder (0600; the mod's guards keep
|
|
347
|
+
* the model from it). With an identity here: the derived token, written to person.key when the
|
|
348
|
+
* file holds anything else (a home from before derived tokens, a front end's random first-run
|
|
349
|
+
* value), never into a home whose files aren't its own (homeFilesOwn: "" then). Without one: the
|
|
350
|
+
* random first-run token, made once, exclusively.
|
|
351
|
+
*/
|
|
276
352
|
export declare function personToken(home: string): string;
|
|
277
|
-
/**
|
|
353
|
+
/**
|
|
354
|
+
* Replaces the person token with a fresh one. Called whenever an identity is first created or
|
|
355
|
+
* restored on a home (init, link join, backup restore; setup and join create through init; the new
|
|
356
|
+
* home a rotation makes), with the new identity's device signing seed (`spk`): a fresh salt, and
|
|
357
|
+
* the token it derives. A person.key that was already there may have been put there by anything
|
|
358
|
+
* that could write the folder before the identity existed, so it must not keep standing in for the
|
|
359
|
+
* person afterwards (it never verifies against the derived token). The command that creates the
|
|
360
|
+
* identity checked its token when it started, so a front end's first run still works; the front
|
|
361
|
+
* ends read person.key again when the CLI refuses their old token (`person_token_stale`). Written
|
|
362
|
+
* whole, before any key is written: if this fails, no identity is made here.
|
|
363
|
+
*/
|
|
364
|
+
export declare function renewPersonToken(home: string, spk?: string): string;
|
|
365
|
+
/** Whether `home` holds an identity: its keys and self documents (state.ts keeps them at <home>/cli/keys.json and self.json). */
|
|
366
|
+
export declare function identityHere(home: string): boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Whether P2P_PERSON_TOKEN is this home's person token (read only). It must be what person.key
|
|
369
|
+
* holds (a missing file is no match) and, on a home with an identity, the token that identity
|
|
370
|
+
* derives (recomputed here: a person.key written by anything else never verifies). Never on a home
|
|
371
|
+
* whose files aren't its own (homeFilesOwn).
|
|
372
|
+
*/
|
|
278
373
|
export declare function personTokenOk(env: Record<string, string | undefined> | undefined, home: string | undefined): boolean;
|
|
374
|
+
/**
|
|
375
|
+
* After a refused token: brings a person.key that holds something else (a front end's first-run
|
|
376
|
+
* value on a home that has an identity now, one from before derived tokens) up to the derived token,
|
|
377
|
+
* so the front end that reads it again gets one that verifies. A missing person.key stays missing
|
|
378
|
+
* (the next command makes it), and nothing is written into a home whose files aren't its own.
|
|
379
|
+
*/
|
|
380
|
+
export declare function healPersonToken(home: string): void;
|
|
279
381
|
/**
|
|
280
382
|
* Checks the person token once, at the start of a command, and takes it out of the environment
|
|
281
383
|
* (this object and the process's), so no child (git, ix, an extension's tool) ever inherits it.
|
|
@@ -292,7 +394,10 @@ export type ConfirmTty = (question: string) => Promise<boolean>;
|
|
|
292
394
|
*/
|
|
293
395
|
export declare function assertPersonForWidening(app: Pick<App, "env"> & {
|
|
294
396
|
front?: boolean;
|
|
295
|
-
|
|
397
|
+
home?: string;
|
|
398
|
+
}, what: string, confirm: ConfirmTty, why?: string, opts?: {
|
|
399
|
+
noTokenBeforeIdentity?: boolean;
|
|
400
|
+
}): Promise<void>;
|
|
296
401
|
/**
|
|
297
402
|
* For an act on a session that binds nothing (a delivery receipt): the session's front end (its
|
|
298
403
|
* token); or, outside any agent's session, a caller acting for a session no front end registered.
|
|
@@ -303,6 +408,10 @@ export declare function assertSpeaksFor(app: App, sid: string): Promise<void>;
|
|
|
303
408
|
export declare function personHere(app: Pick<App, "env"> & {
|
|
304
409
|
front?: boolean;
|
|
305
410
|
}): boolean;
|
|
411
|
+
/** personHere for a person-only act: an unreadable process tree counts as an agent's session (fail closed). */
|
|
412
|
+
export declare function personHereStrict(app: Pick<App, "env"> & {
|
|
413
|
+
front?: boolean;
|
|
414
|
+
}): boolean;
|
|
306
415
|
export declare function sessionBinding(app: App, sid: string): Promise<SessionBinding | undefined>;
|
|
307
416
|
/** One reason a session is private, as said to the person (and to a model that reads a refusal). */
|
|
308
417
|
export interface PrivateReason {
|
|
@@ -472,6 +581,10 @@ export declare const MAX_GRAPH_PATHS = 64;
|
|
|
472
581
|
export declare function projectGraphTarget(app: Pick<App, "env" | "file">, ref: Pick<ProjectRef, "id" | "name" | "repoPrivate">, doc: ProjectsDoc): GraphTarget;
|
|
473
582
|
/** How a target reads in one line: `local only (http://localhost:8090)`, or the circle's shared graph. */
|
|
474
583
|
export declare function describeGraphTarget(t: GraphTarget): string;
|
|
584
|
+
/** A target with, for a local one, why: the one wording `p2p project show|ls` and `p2p doctor` print. */
|
|
585
|
+
export declare function graphTargetLine(t: GraphTarget): string;
|
|
586
|
+
/** Who can read what a graph target holds: Ix keeps it in plaintext (docs/security/encryption.md). */
|
|
587
|
+
export declare function graphPlaintextNote(t: GraphTarget): string;
|
|
475
588
|
/**
|
|
476
589
|
* The Ix variables that could send an `ix` call somewhere other than its graph target, or carry a
|
|
477
590
|
* cloud credential: Ix Pro's PAT mode (IX_PAT, IX_ORG, its endpoint override), the cloud push and
|