@peer2peer/cli 0.0.0-stage → 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.
Files changed (111) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +370 -2
  3. package/dist/ancestry.d.ts +13 -0
  4. package/dist/ancestry.js +71 -0
  5. package/dist/app.d.ts +368 -0
  6. package/dist/app.js +1181 -0
  7. package/dist/bin.d.ts +2 -0
  8. package/dist/bin.js +56 -0
  9. package/dist/circle-ops.d.ts +402 -0
  10. package/dist/circle-ops.js +1725 -0
  11. package/dist/cli.d.ts +660 -0
  12. package/dist/cli.js +1787 -0
  13. package/dist/codes.d.ts +231 -0
  14. package/dist/codes.js +998 -0
  15. package/dist/config.d.ts +159 -0
  16. package/dist/config.js +294 -0
  17. package/dist/doctor.d.ts +113 -0
  18. package/dist/doctor.js +930 -0
  19. package/dist/errors.d.ts +8 -0
  20. package/dist/errors.js +29 -0
  21. package/dist/ext-host.d.ts +38 -0
  22. package/dist/ext-host.js +293 -0
  23. package/dist/extensions.d.ts +487 -0
  24. package/dist/extensions.js +406 -0
  25. package/dist/features.d.ts +91 -0
  26. package/dist/features.js +164 -0
  27. package/dist/format.d.ts +57 -0
  28. package/dist/format.js +248 -0
  29. package/dist/graph-memory.d.ts +107 -0
  30. package/dist/graph-memory.js +393 -0
  31. package/dist/history.d.ts +155 -0
  32. package/dist/history.js +697 -0
  33. package/dist/identity.d.ts +239 -0
  34. package/dist/identity.js +759 -0
  35. package/dist/inbound.d.ts +32 -0
  36. package/dist/inbound.js +261 -0
  37. package/dist/index.d.ts +8 -0
  38. package/dist/index.js +14 -0
  39. package/dist/ix-local.d.ts +76 -0
  40. package/dist/ix-local.js +203 -0
  41. package/dist/join-answers.d.ts +49 -0
  42. package/dist/join-answers.js +149 -0
  43. package/dist/outbox.d.ts +109 -0
  44. package/dist/outbox.js +337 -0
  45. package/dist/pretty.d.ts +100 -0
  46. package/dist/pretty.js +256 -0
  47. package/dist/procstart.d.ts +1 -0
  48. package/dist/procstart.js +66 -0
  49. package/dist/progress.d.ts +30 -0
  50. package/dist/progress.js +78 -0
  51. package/dist/projects.d.ts +491 -0
  52. package/dist/projects.js +1383 -0
  53. package/dist/prompt/picker.d.ts +64 -0
  54. package/dist/prompt/picker.js +152 -0
  55. package/dist/prompt/tty.d.ts +29 -0
  56. package/dist/prompt/tty.js +122 -0
  57. package/dist/readonly.d.ts +20 -0
  58. package/dist/readonly.js +50 -0
  59. package/dist/receipts.d.ts +99 -0
  60. package/dist/receipts.js +182 -0
  61. package/dist/relay-client.d.ts +277 -0
  62. package/dist/relay-client.js +873 -0
  63. package/dist/relay-info.d.ts +24 -0
  64. package/dist/relay-info.js +53 -0
  65. package/dist/rotation.d.ts +402 -0
  66. package/dist/rotation.js +2054 -0
  67. package/dist/running.d.ts +5 -0
  68. package/dist/running.js +74 -0
  69. package/dist/sessions.d.ts +355 -0
  70. package/dist/sessions.js +1247 -0
  71. package/dist/shortcode.d.ts +149 -0
  72. package/dist/shortcode.js +465 -0
  73. package/dist/social.d.ts +139 -0
  74. package/dist/social.js +485 -0
  75. package/dist/state.d.ts +509 -0
  76. package/dist/state.js +220 -0
  77. package/dist/stdin.d.ts +17 -0
  78. package/dist/stdin.js +46 -0
  79. package/dist/sync.d.ts +77 -0
  80. package/dist/sync.js +375 -0
  81. package/dist/transient.d.ts +1 -0
  82. package/dist/transient.js +28 -0
  83. package/dist/trust.d.ts +37 -0
  84. package/dist/trust.js +134 -0
  85. package/dist/tty-confirm.d.ts +2 -0
  86. package/dist/tty-confirm.js +53 -0
  87. package/dist/tui/command.d.ts +20 -0
  88. package/dist/tui/command.js +70 -0
  89. package/dist/tui/frame.d.ts +43 -0
  90. package/dist/tui/frame.js +111 -0
  91. package/dist/tui/model.d.ts +221 -0
  92. package/dist/tui/model.js +259 -0
  93. package/dist/tui/sanitize.d.ts +13 -0
  94. package/dist/tui/sanitize.js +151 -0
  95. package/dist/tui/terminal.d.ts +88 -0
  96. package/dist/tui/terminal.js +354 -0
  97. package/dist/tui/tui.d.ts +78 -0
  98. package/dist/tui/tui.js +612 -0
  99. package/dist/tui/view.d.ts +4 -0
  100. package/dist/tui/view.js +358 -0
  101. package/dist/unknown-kinds.d.ts +12 -0
  102. package/dist/unknown-kinds.js +66 -0
  103. package/dist/version.d.ts +1 -0
  104. package/dist/version.js +5 -0
  105. package/dist/want-pow.d.ts +12 -0
  106. package/dist/want-pow.js +46 -0
  107. package/dist/watch.d.ts +35 -0
  108. package/dist/watch.js +331 -0
  109. package/dist/xstate.d.ts +125 -0
  110. package/dist/xstate.js +422 -0
  111. package/package.json +60 -4
package/dist/cli.d.ts ADDED
@@ -0,0 +1,660 @@
1
+ import type { Readable, Writable } from "node:stream";
2
+ import { Command } from "commander";
3
+ import { App, type Io } from "./app.js";
4
+ import { type Env } from "./config.js";
5
+ import * as circles from "./circle-ops.js";
6
+ import { ExtensionRegistry } from "./extensions.js";
7
+ import * as codes from "./codes.js";
8
+ import * as identity from "./identity.js";
9
+ import * as rotation from "./rotation.js";
10
+ import * as sessions from "./sessions.js";
11
+ import * as projects from "./projects.js";
12
+ import * as social from "./social.js";
13
+ import { watch } from "./watch.js";
14
+ import * as doctorOps from "./doctor.js";
15
+ import type { Terminal } from "./tui/terminal.js";
16
+ import { VERSION } from "./version.js";
17
+ export { VERSION };
18
+ /** How long a command that ran out of time waits for in-flight sends and writes to settle. */
19
+ export declare const SETTLE_MS = 5000;
20
+ /** The operations the commands call: real modules by default, fakes in parser tests. */
21
+ export declare const realOps: {
22
+ watch: typeof watch;
23
+ doctor: typeof doctorOps.doctor;
24
+ sessionWorkdir(env: Record<string, string | undefined>): string;
25
+ sessionDirs(env: Record<string, string | undefined>): {
26
+ dirs: string[];
27
+ over: boolean;
28
+ why: projects.OverWhy[];
29
+ };
30
+ overWhys(v: unknown): projects.OverWhy[];
31
+ pseudoPath(p: string): boolean;
32
+ braceChoice(c: string): boolean;
33
+ dirProjectId(root: string): string;
34
+ normalizeRemote(url: string): string | undefined;
35
+ projectOf(dir: string, doc?: projects.ProjectsDoc): projects.ProjectRef;
36
+ projectsDoc(app: App): Promise<projects.ProjectsDoc>;
37
+ shareOf(doc: projects.ProjectsDoc, id: string): projects.ProjectShare;
38
+ projectView(app: App, ref: Pick<projects.ProjectRef, "id" | "name" | "kind" | "root" | "remote" | "repoPrivate">, doc?: projects.ProjectsDoc): Promise<projects.ProjectView>;
39
+ broadRoot(root: string, env?: Record<string, string | undefined>): string | undefined;
40
+ nestedBoundaries(root: string): {
41
+ repos: string[];
42
+ private: string[];
43
+ capped: boolean;
44
+ };
45
+ shareProject(app: App, dir: string, targets: {
46
+ circles?: string[];
47
+ people?: string[];
48
+ add?: boolean;
49
+ subfolders?: boolean;
50
+ }): Promise<{
51
+ project: projects.ProjectView;
52
+ warnings: string[];
53
+ }>;
54
+ makeProjectPrivate(app: App, dir: string): Promise<projects.ProjectView>;
55
+ listProjects(app: App): Promise<projects.ProjectView[]>;
56
+ showProject(app: App, dir: string): Promise<projects.ProjectView>;
57
+ bindSession(app: App, sid: string, dirs: readonly string[], o?: {
58
+ person?: boolean;
59
+ over?: boolean | readonly projects.OverWhy[];
60
+ constraint?: projects.ProjectShare;
61
+ inbound?: boolean;
62
+ }): Promise<projects.SessionBinding | undefined>;
63
+ agentEnv(env: Record<string, string | undefined> | undefined): boolean;
64
+ agentContext(env: Record<string, string | undefined> | undefined): boolean;
65
+ personTokenFile(home: string): string;
66
+ personToken(home: string): string;
67
+ personTokenOk(env: Record<string, string | undefined> | undefined, home: string | undefined): boolean;
68
+ takePersonToken(env: Record<string, string | undefined>, home: string | undefined): boolean;
69
+ assertPersonForWidening(app: Pick<App, "env"> & {
70
+ front?: boolean;
71
+ }, what: string, confirm: projects.ConfirmTty, why?: string): Promise<void>;
72
+ assertSpeaksFor(app: App, sid: string): Promise<void>;
73
+ personHere(app: Pick<App, "env"> & {
74
+ front?: boolean;
75
+ }): boolean;
76
+ sessionBinding(app: App, sid: string): Promise<projects.SessionBinding | undefined>;
77
+ privateReasons(doc: projects.ProjectsDoc, b: projects.SessionBinding): projects.PrivateReason[];
78
+ privateRemedy(causes: readonly projects.PrivateCause[], names: string[]): string;
79
+ stickyPrivate(c: projects.Ceiling): boolean;
80
+ sessionCeiling(app: App, sid: string, binding?: projects.SessionBinding | null): Promise<projects.Ceiling>;
81
+ ceilingAudience(app: App, c: projects.Ceiling): Promise<Set<string> | undefined>;
82
+ shareHint(names: string[]): string;
83
+ assertMayReach(app: App, sid: string, userId: string, o?: {
84
+ person?: boolean;
85
+ address?: string;
86
+ }): Promise<void>;
87
+ friendIds(app: App): Promise<Set<string>>;
88
+ sessionProjectView(app: App, sid: string): Promise<projects.SessionProjectView>;
89
+ showSession(app: App, sid: string): Promise<projects.SessionShow>;
90
+ defaultCircleNotice(app: App, sid: string): Promise<string | undefined>;
91
+ isLoopbackEndpoint(url: unknown): url is string;
92
+ normalizeLoopbackEndpoint(url: unknown): string | undefined;
93
+ localGraphEndpoint(_env: Record<string, string | undefined>, file?: {
94
+ ixEndpoint?: unknown;
95
+ }): string;
96
+ graphTargetOf(inputs: readonly projects.GraphShareInput[], o: {
97
+ local: string;
98
+ sharedGraphs?: ReadonlyMap<string, string>;
99
+ }): projects.GraphTarget;
100
+ normalizeSharedEndpoint(url: unknown): string | undefined;
101
+ graphTarget(app: App, o?: {
102
+ sid?: string;
103
+ dirs?: readonly string[];
104
+ paths?: readonly string[];
105
+ over?: boolean;
106
+ }, sharedGraphs?: ReadonlyMap<string, string>): Promise<projects.GraphTarget>;
107
+ projectGraphTarget(app: Pick<App, "env" | "file">, ref: Pick<projects.ProjectRef, "id" | "name" | "repoPrivate">, doc: projects.ProjectsDoc): projects.GraphTarget;
108
+ describeGraphTarget(t: projects.GraphTarget): string;
109
+ graphPinnedEnv(env: Record<string, string | undefined>, target: projects.GraphTarget, base?: Record<string, string | undefined>): Record<string, string | undefined>;
110
+ PERSON_SESSION: "tui";
111
+ PRIVATE_MARKER: ".p2p-private";
112
+ MAX_SESSION_DIRS: 512;
113
+ MAX_SESSION_PROJECTS: 16;
114
+ SESSION_BINDING_TTL_MS: number;
115
+ MAX_PROJECT_SHARES: 32;
116
+ MAX_SESSION_CONSTRAINTS: 16;
117
+ MAX_UNDER: 64;
118
+ NESTED_SCAN_DEPTH: 4;
119
+ NESTED_SCAN_ENTRIES: 2000;
120
+ AGENT_ENV_VARS: readonly string[];
121
+ isAgentProcess: typeof projects.isAgentProcess;
122
+ PROJECT_NOTICE_PREFIX: "project boundaries:";
123
+ GRAPH_LOCAL_ONLY: "local only";
124
+ DEFAULT_IX_ENDPOINT: "http://localhost:8090";
125
+ SHARED_GRAPHS: ReadonlyMap<string, string>;
126
+ MAX_GRAPH_PATHS: 64;
127
+ IX_CLOUD_ENV: readonly string[];
128
+ IX_KEEP: readonly string[];
129
+ readRotationState(home: string): Promise<rotation.RotationState | undefined>;
130
+ adoptHome(app: App, src: string, tag: string): Promise<string>;
131
+ raiseRotationAlert(app: App, r: import("@peer2peer/core/v3").VerifiedRotation, by?: string): Promise<boolean>;
132
+ alertForeignRotations(app: App): Promise<void>;
133
+ friendVerdict(st: rotation.RotationState, peer: string): {
134
+ invite: boolean;
135
+ why?: string;
136
+ };
137
+ rotatePlan(app: App, opts?: rotation.RotateOptions): Promise<rotation.RotationPlan>;
138
+ rotateCancel(app: App): Promise<{
139
+ cancelled: boolean;
140
+ to?: string;
141
+ }>;
142
+ rotate(app: App, opts?: rotation.RotateOptions): Promise<rotation.RotateResult>;
143
+ untrustedImportSigner(app: App, did: string): Promise<string | undefined>;
144
+ rotateResend(app: App): Promise<{
145
+ sent: number;
146
+ failed: string[];
147
+ remaining: number;
148
+ throttled: boolean;
149
+ }>;
150
+ rotationsFor(app: App, old: string): Promise<import("@peer2peer/core/v3").VerifiedRotation[]>;
151
+ rotationConflict(app: App, r: import("@peer2peer/core/v3").VerifiedRotation): Promise<string[] | undefined>;
152
+ importRotationApprovals(app: App, list: unknown): Promise<void>;
153
+ importRotationDispute(app: App, body: unknown): Promise<void>;
154
+ resolveDispute(app: App, id: string, choice: {
155
+ keep?: string;
156
+ neither?: boolean;
157
+ }): Promise<Record<string, unknown>>;
158
+ importRotationResolved(app: App, body: unknown, fromDid?: string): Promise<void>;
159
+ publishedByOld(app: App, r: import("@peer2peer/core/v3").VerifiedRotation): Promise<boolean>;
160
+ noteRotation(app: App, r: import("@peer2peer/core/v3").VerifiedRotation): Promise<boolean>;
161
+ noteDocRotations(app: App, userId: string): Promise<void>;
162
+ onRotationContact(app: App, env: string, at: number, from: import("./inbound.js").EventFrom, rotation: import("@peer2peer/core/v3").VerifiedRotation, invite: {
163
+ jws: string;
164
+ exp: number;
165
+ iss: string;
166
+ }): Promise<import("./inbound.js").NewEvent[]>;
167
+ approveRotation(app: App, item: import("./state.js").HeldItem, opts?: {
168
+ force?: boolean;
169
+ }): Promise<Record<string, unknown>>;
170
+ circleHeld(app: App, cid: string): Promise<boolean>;
171
+ onRotationJoin(app: App, env: string, at: number, from: import("./inbound.js").EventFrom, statement: import("@peer2peer/core/v3").RotationStatement, sender: string, joins: readonly {
172
+ iss: string;
173
+ cid: string;
174
+ op: string;
175
+ jws: string;
176
+ }[]): Promise<rotation.RotationJoinOutcome>;
177
+ retryRotationJoins(app: App): Promise<import("./inbound.js").NewEvent[]>;
178
+ approveRotationJoin(app: App, item: import("./state.js").HeldItem, opts?: {
179
+ force?: boolean;
180
+ }): Promise<Record<string, unknown>>;
181
+ noteOwnRotation(app: App, body: unknown, fromDid?: string): Promise<void>;
182
+ followHeld(app: App, idOrItem: string | import("./state.js").HeldItem): Promise<{
183
+ userId: string;
184
+ address: string;
185
+ did: string;
186
+ from: string;
187
+ keyholder: boolean;
188
+ }>;
189
+ recoverInterruptedFollow(home: string): Promise<boolean>;
190
+ relinkRotated(app: App, code: string, opts?: {
191
+ label?: string;
192
+ }): Promise<{
193
+ compareCode: string;
194
+ did: string;
195
+ wait: () => Promise<{
196
+ from: string;
197
+ userId: string;
198
+ address: string;
199
+ did: string;
200
+ keyholder: boolean;
201
+ }>;
202
+ }>;
203
+ DEVICE_SEEN_WINDOW_SEC: number;
204
+ RESEND_PER_HOUR: 50;
205
+ shellQuote(s: string): string;
206
+ joinCommandFor(web: string, privateRelay: boolean): string;
207
+ inviteMessage(web: string, privateRelay: boolean): string;
208
+ relayLooksPrivate(relay: string): Promise<boolean>;
209
+ inviteCode(app: App, opts: {
210
+ label?: string;
211
+ circles?: string[];
212
+ noCircle?: boolean;
213
+ to?: string;
214
+ ttlDays?: number;
215
+ relay?: string;
216
+ }): Promise<codes.InviteCodeResult>;
217
+ importCodes(app: App, recs: unknown[]): Promise<void>;
218
+ codeByInv(app: App, inv: string): Promise<import("./state.js").CodeRecord | undefined>;
219
+ onCodeRedeemed(app: App, env: string, at: number, from: import("./inbound.js").EventFrom, rec: import("./state.js").CodeRecord, who: string): Promise<import("./inbound.js").NewEvent[]>;
220
+ previewText(p: codes.CodePreview): string;
221
+ joinCode(app: App, input: string, opts?: codes.JoinCodeOpts): Promise<codes.JoinCodeResult>;
222
+ shownCode(input: string): string;
223
+ previewCode(app: App, input: string, opts?: {
224
+ allowPrivateRelay?: boolean;
225
+ }): Promise<codes.CodePreview>;
226
+ finishCodeJoins(app: App): Promise<import("./inbound.js").NewEvent[]>;
227
+ listCodes(app: App): Promise<codes.CodeRow[]>;
228
+ revokeCode(app: App, input: string): Promise<{
229
+ code: string;
230
+ revoked: boolean;
231
+ wasOpen: boolean;
232
+ redeemedBy: string | null;
233
+ }>;
234
+ removeUser(app: App, who: string): Promise<codes.RemoveResult>;
235
+ CODE_LABEL_MAX: 64;
236
+ codeHint: (code: string) => string;
237
+ PLUGIN_INSTALL: string[];
238
+ CODEX_INSTALL_URL: "https://github.com/ix-infrastructure/Peer2Peer/blob/main/packages/codex-bridge/README.md#install";
239
+ CodePreviewReady: typeof codes.CodePreviewReady;
240
+ checkSid(sid: string | undefined, flag?: string): string;
241
+ sessionRef(own: string, sid: string): string;
242
+ docFromStored(sid: string, r: {
243
+ ver: number;
244
+ jws: string;
245
+ }, did: string, want?: {
246
+ vis: "circle" | "private";
247
+ circle?: string;
248
+ }): import("./state.js").SessionDoc;
249
+ isAutoRoster(d: import("./state.js").SessionDoc): boolean;
250
+ getSession(app: App, sid: string, notes?: string[]): Promise<import("./state.js").SessionDoc>;
251
+ roster(app: App, sid: string, opts: {
252
+ circle?: string;
253
+ private?: boolean;
254
+ add?: string[];
255
+ remove?: string[];
256
+ }): Promise<sessions.RosterView>;
257
+ sessionAudience(app: App, sid: string): Promise<{
258
+ vis: "circle" | "private";
259
+ circle?: string;
260
+ open?: true;
261
+ people: number;
262
+ members: string[];
263
+ } | undefined>;
264
+ rosterAudience(app: App, s: import("./state.js").SessionDoc): Promise<string[]>;
265
+ buildStatus(o: sessions.StatusOpts, prev?: import("@peer2peer/core/v3").StatusBody, warnings?: string[]): import("@peer2peer/core/v3").StatusBody;
266
+ withoutAgentCount(summary: string): string;
267
+ normalizeAgents(raw: unknown, mainFiles?: readonly string[]): import("@peer2peer/core/v3").StatusAgent[];
268
+ statusWithoutAgents(s: import("@peer2peer/core/v3").StatusBody): import("@peer2peer/core/v3").StatusBody;
269
+ understandsAgents(peers: Record<string, import("./state.js").PeerStatusRec>, u: string, self: {
270
+ userId: string;
271
+ did: string;
272
+ }, now?: number): boolean;
273
+ mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]>;
274
+ sendStatus(app: App, o: sessions.StatusOpts): Promise<sessions.StatusResult>;
275
+ listPeers(app: App, opts?: {
276
+ all?: boolean;
277
+ }): Promise<sessions.PeerRow[]>;
278
+ parseTarget(to: string): {
279
+ user: string;
280
+ pick?: string;
281
+ };
282
+ tuiTaintNote(app: App, toUserId: string, now?: number): Promise<string | undefined>;
283
+ sendSharing(app: App, o: sessions.SendOpts): Promise<{
284
+ result: sessions.SendResult;
285
+ shared?: {
286
+ userId: string;
287
+ address: string;
288
+ };
289
+ }>;
290
+ sendMessage(app: App, o: sessions.SendOpts): Promise<sessions.SendResult>;
291
+ sendExtension(app: App, o: sessions.SendExtOpts): Promise<import("./extensions.js").ExtSendResult>;
292
+ onSessionEnvelope(app: App, env: string, r: import("@peer2peer/core/v3").AcceptedMessageV3): Promise<import("./inbound.js").NewEvent[]>;
293
+ bindFromEnv(app: App, sid: string, extra?: readonly string[], o?: {
294
+ person?: boolean;
295
+ over?: projects.OverWhy[];
296
+ }): Promise<void>;
297
+ sessionsWithin(app: App, b: import("@peer2peer/core/v3").ProjectBound, now?: number): Promise<string[]>;
298
+ bindBound(app: App, sid: string, bound: unknown): Promise<projects.SessionProjectView>;
299
+ mayReach(app: App, sid: string, user: string): Promise<boolean>;
300
+ routableSessions(app: App, sender: string, now?: number): Promise<string[]>;
301
+ expireSubs(app: App, now?: number): Promise<void>;
302
+ SID_RE: RegExp;
303
+ MAX_TEXT_BYTES: number;
304
+ MAX_FILES: 25;
305
+ IDLE_SUB_TTL_MS: 3600000;
306
+ CLI_STATUS_CAPS: readonly string[];
307
+ MAX_STATUS_PATHS: 60;
308
+ STATUS_SOFT_MAX_BYTES: number;
309
+ OPEN_CIRCLE_SHARED: "is shared with an open circle (its policy is open now): anyone its owner admits can see it; `p2p session roster <sid> --private` (or /peers private) stops that";
310
+ CODE_JOIN_NO_FOLLOW: "kept as it was: a code you redeemed set your default circle, and a session already running doesn't move into a circle by itself; share it with `p2p session roster <sid> --circle <cid>` (or /peers circle <cid>). New sessions start in it";
311
+ OPEN_CIRCLE_NO_FOLLOW: "kept private: your default circle is open (anyone its owner admits can see what's shared there), so a session already running doesn't move into it by itself; share it with `p2p session roster <sid> --circle <cid>` (or /peers circle <cid>)";
312
+ STATUS_FANOUT: 8;
313
+ OFFLINE_TARGET_MS: number;
314
+ LOCAL_SEND_TTL_MS: number;
315
+ LOCAL_SENDS_MAX: 4096;
316
+ TUI_TAINT_MS: number;
317
+ MAX_EXT_PLAINTEXT_BYTES: number;
318
+ resolveCircle(app: App, input: string): Promise<import("@peer2peer/core/v3").LoadedCircle>;
319
+ encodeCircleLink(head: string, hint: circles.CircleHint | undefined, web?: boolean): string;
320
+ parseCircleLink(link: string): {
321
+ head: string;
322
+ hint?: circles.CircleHint;
323
+ };
324
+ circleLink(app: App, cidOrName: string): Promise<{
325
+ cid: string;
326
+ link: string;
327
+ web: string;
328
+ policy: import("@peer2peer/core/v3").CirclePolicy;
329
+ }>;
330
+ signOwnJoin(app: App, cid: string, at: string): Promise<import("@peer2peer/core/v3").VerifiedMembership>;
331
+ resignJoin(app: App, cid: string): Promise<boolean>;
332
+ recordJoin(app: App, v: import("@peer2peer/core/v3").VerifiedMembership): Promise<void>;
333
+ createCircleCmd(app: App, name: string, opts: {
334
+ open?: boolean;
335
+ }): Promise<circles.CircleSummary & {
336
+ link?: string;
337
+ }>;
338
+ listCircles(app: App): Promise<circles.CircleSummary[]>;
339
+ circleMembers(app: App, cidOrName: string): Promise<{
340
+ circle: circles.CircleSummary;
341
+ founder: string;
342
+ members: circles.MemberRow[];
343
+ }>;
344
+ setDefaultCircle(app: App, cidOrName: string | undefined, opts?: {
345
+ byJoin?: boolean;
346
+ }): Promise<{
347
+ defaultCircle: string | null;
348
+ }>;
349
+ ownerPublish(app: App, cid: string, p: import("@peer2peer/core/v3").NextVersionParams, opts?: {
350
+ alsoTo?: string[];
351
+ }): Promise<import("@peer2peer/core/v3").VerifiedCircleVersion>;
352
+ distribute(app: App, cid: string, extra?: readonly string[]): Promise<{
353
+ delivered: string[];
354
+ failed: string[];
355
+ }>;
356
+ deliverCircle(app: App, to: string, body: {
357
+ circles?: string[];
358
+ joins?: string[];
359
+ ops?: string[];
360
+ }, extraCaps?: string[]): Promise<import("./app.js").Delivery>;
361
+ inviteToCircle(app: App, cidOrName: string, who: string): Promise<{
362
+ cid: string;
363
+ invited: string;
364
+ address: string;
365
+ added: boolean;
366
+ delivered: import("./app.js").Delivery;
367
+ }>;
368
+ addMemberViaCode(app: App, cid: string, u: string): Promise<{
369
+ status: "added" | "already" | "proposed" | "failed";
370
+ name?: string;
371
+ reason?: string;
372
+ }>;
373
+ removeMember(app: App, cid: string, u: string): Promise<"removed" | "proposed" | "not-member" | "not-allowed">;
374
+ memberCaps(c: import("@peer2peer/core/v3").LoadedCircle, u: string): string[];
375
+ recordJoinAnswer(app: App, from: string, versions: readonly string[], joins: readonly string[], opts?: {
376
+ cid?: string;
377
+ part?: import("@peer2peer/core/v3").AnswerPart;
378
+ }): Promise<boolean>;
379
+ contiguousTop(versions: readonly string[] | undefined): number;
380
+ answerComplete(versions: readonly string[] | undefined, parts: Record<string, import("./state.js").AnswerPartsRec> | undefined, offeredVer: number): boolean;
381
+ joinCircle(app: App, input: circles.JoinInput, opts?: {
382
+ waitSec?: number;
383
+ yes?: boolean;
384
+ confirm?: (q: string) => Promise<boolean>;
385
+ }): Promise<circles.JoinResult>;
386
+ joinFromLink(app: App, link: string, opts: {
387
+ waitSec?: number;
388
+ yes?: boolean;
389
+ confirm?: (q: string) => Promise<boolean>;
390
+ allowPrivateRelay?: boolean;
391
+ }): Promise<circles.JoinResult>;
392
+ joinFromHeld(app: App, item: import("./state.js").HeldItem, opts: {
393
+ waitSec?: number;
394
+ yes?: boolean;
395
+ confirm?: (q: string) => Promise<boolean>;
396
+ }): Promise<circles.JoinResult>;
397
+ renewOpenJoinCaps(app: App): Promise<number>;
398
+ rekeyJoinsExcluding(app: App, blocked: string): Promise<string[]>;
399
+ leaveCircle(app: App, cidOrName: string): Promise<{
400
+ cid: string;
401
+ left: boolean;
402
+ told: number;
403
+ }>;
404
+ propose(app: App, cidOrName: string, op: string, arg: string): Promise<{
405
+ cid: string;
406
+ op: string;
407
+ applied: boolean;
408
+ ver?: number;
409
+ sentTo?: string;
410
+ }>;
411
+ transfer(app: App, cidOrName: string, who: string | undefined, opts: {
412
+ accept?: boolean;
413
+ consent?: string;
414
+ }): Promise<Record<string, unknown>>;
415
+ setPolicy(app: App, cidOrName: string, policy: string): Promise<{
416
+ cid: string;
417
+ policy: import("@peer2peer/core/v3").CirclePolicy;
418
+ ver: number;
419
+ }>;
420
+ setCircleHold(app: App, cidOrName: string, on: boolean | undefined): Promise<{
421
+ cid: string;
422
+ hold: boolean;
423
+ }>;
424
+ approveJoinRequest(app: App, item: import("./state.js").HeldItem): Promise<{
425
+ cid: string;
426
+ added: string;
427
+ ver: number;
428
+ }>;
429
+ onCircleEnvelope(app: App, env: string, r: import("@peer2peer/core/v3").AcceptedMessageV3, relay: string): Promise<import("./inbound.js").NewEvent[]>;
430
+ answerAllowance(app: App, asker: string, pool: circles.AnswerPool, cid: string): Promise<circles.AnswerAllowance & {
431
+ last: circles.WantAnswersDoc["last"];
432
+ pows: Set<string>;
433
+ }>;
434
+ chargeAnswer(app: App, asker: string, pool: circles.AnswerPool, bytes: number, mark?: {
435
+ cid: string;
436
+ ver: number;
437
+ resent: boolean;
438
+ pow?: string;
439
+ }): Promise<circles.AnswerAllowance & {
440
+ receipt?: circles.AnswerReceipt;
441
+ }>;
442
+ settleAnswer(app: App, r: circles.AnswerReceipt, spent: number): Promise<void>;
443
+ refundAnswer(app: App, r: circles.AnswerReceipt): Promise<void>;
444
+ answerParts(versions: readonly string[], statements: readonly string[], budget: number, cost: (plainBytes: number) => number): {
445
+ parts: {
446
+ circles: string[];
447
+ joins: string[];
448
+ }[];
449
+ bytes: number;
450
+ sentVersions: number;
451
+ };
452
+ answeringDevice(view: {
453
+ devices: readonly string[];
454
+ keyholders: readonly string[];
455
+ }): string | undefined;
456
+ answeringRank(view: {
457
+ devices: readonly string[];
458
+ keyholders: readonly string[];
459
+ }, did: string): number | undefined;
460
+ answerDeferredWants(app: App): Promise<number>;
461
+ importWantAnswered(app: App, recs: unknown): Promise<void>;
462
+ noteRefused(app: App, asker: string, cid: string): Promise<void>;
463
+ JOIN_REASK_MS: 60000;
464
+ ANSWERS_PER_ASKER_PER_HOUR: 10;
465
+ MAX_ANSWER_ASKERS: 2048;
466
+ MAX_ANSWER_CIRCLES: 512;
467
+ MAX_POOL_ENTRIES: 4096;
468
+ ANSWER_ATTEMPT_MIN_BYTES: 4096;
469
+ MAX_DEFERRED_WANTS: 64;
470
+ MAX_DEFERRED_PER_ASKER: 4;
471
+ DEFERRED_WANT_MAX_AGE_MS: number;
472
+ sealedCost: (relays: number) => (plainBytes: number) => number;
473
+ mintInvite(app: App, opts: {
474
+ aud: string;
475
+ uses: number;
476
+ ttlSec: number;
477
+ extraSync?: Partial<import("./sync.js").SyncBody>;
478
+ }): Promise<social.MintedInvite>;
479
+ invite(app: App, opts: {
480
+ to?: string;
481
+ uses?: number;
482
+ ttlDays?: number;
483
+ }): Promise<social.InviteResult>;
484
+ inviteRelays(jws: string): string[];
485
+ guardInviteLink(app: App, input: string, opts?: {
486
+ allowPrivateRelay?: boolean;
487
+ }): Promise<void>;
488
+ guardForeignRelays(app: App, input: readonly string[], what: string, allow: boolean, opts?: {
489
+ code?: boolean;
490
+ }): Promise<void>;
491
+ accept(app: App, input: string): Promise<social.AcceptResult>;
492
+ refuseIfUnfriendedAfter(app: App, invite: {
493
+ iss: string;
494
+ iat: number;
495
+ }): Promise<void>;
496
+ onContact(app: App, env: string, r: import("@peer2peer/core/v3").AcceptedMessageV3): Promise<import("./inbound.js").NewEvent[]>;
497
+ onUnfriendKind(app: App, env: string, r: import("@peer2peer/core/v3").AcceptedMessageV3): Promise<import("./inbound.js").NewEvent[]>;
498
+ unfriend(app: App, who: string): Promise<{
499
+ unfriended: string;
500
+ address: string;
501
+ delivered: import("./app.js").Delivery[];
502
+ revoked: number;
503
+ }>;
504
+ block(app: App, who: string): Promise<{
505
+ blocked: string;
506
+ address: string;
507
+ revoked: number;
508
+ rekeyedCircles: string[];
509
+ }>;
510
+ unblock(app: App, who: string): Promise<{
511
+ unblocked: string;
512
+ address: string;
513
+ }>;
514
+ petname(app: App, who: string, name: string | undefined): Promise<{
515
+ userId: string;
516
+ petname: string | null;
517
+ address: string;
518
+ }>;
519
+ friends(app: App): Promise<{
520
+ friends: social.FriendRow[];
521
+ invites: {
522
+ outgoing: {
523
+ inv: string;
524
+ aud: string;
525
+ exp: number;
526
+ }[];
527
+ held: number;
528
+ };
529
+ blocked: {
530
+ userId: string;
531
+ address: string;
532
+ }[];
533
+ }>;
534
+ withHeldId(item: Omit<import("./state.js").HeldItem, "id">): import("./state.js").HeldItem;
535
+ hold(app: App, item: import("./state.js").HeldItem): Promise<void>;
536
+ dropHeld(app: App, pred: (h: import("./state.js").HeldItem) => boolean): Promise<import("./state.js").HeldItem[]>;
537
+ listHeld(app: App): Promise<(import("./state.js").HeldItem & {
538
+ address: string;
539
+ summary: string;
540
+ oldAddress?: string;
541
+ confirmedByDocument?: boolean;
542
+ choices?: {
543
+ userId: string;
544
+ address: string;
545
+ }[];
546
+ })[]>;
547
+ getHeld(app: App, id: string): Promise<import("./state.js").HeldItem>;
548
+ HELD_ID_MIN_PREFIX: 8;
549
+ init(app: App, opts: {
550
+ name?: string;
551
+ relays?: string[];
552
+ }): Promise<identity.InitResult>;
553
+ setup(app: App, opts: {
554
+ name?: string;
555
+ relays?: string[];
556
+ backup?: "file" | "print" | "none";
557
+ backupFile?: string;
558
+ }): Promise<identity.SetupResult>;
559
+ relaysList(app: App): Promise<{
560
+ relays: string[];
561
+ }>;
562
+ reissueForRelays(app: App): Promise<{
563
+ capsReissued: number;
564
+ rejoined: string[];
565
+ }>;
566
+ relaysAdd(app: App, url: string): Promise<identity.RelaysChange>;
567
+ relaysRemove(app: App, url: string): Promise<identity.RelaysChange>;
568
+ devices(app: App): Promise<identity.DeviceRow[]>;
569
+ whoami(app: App): Promise<identity.WhoamiResult>;
570
+ revokeDevice(app: App, did: string): Promise<{
571
+ revoked: string;
572
+ ver: number;
573
+ capsReissued: number;
574
+ rejoined: string[];
575
+ warnings: string[];
576
+ }>;
577
+ linkStart(app: App, opts?: {
578
+ keyholder?: boolean;
579
+ relay?: string;
580
+ }): Promise<identity.LinkStart>;
581
+ linkJoin(app: App, code: string, opts?: {
582
+ label?: string;
583
+ maxWaitMs?: number;
584
+ }): Promise<identity.LinkJoin>;
585
+ backupShow(app: App): Promise<{
586
+ phrase: string;
587
+ words: number;
588
+ }>;
589
+ backupRestore(app: App, phrase: string, opts: {
590
+ relays?: string[];
591
+ name?: string;
592
+ keepDevices?: boolean;
593
+ newChain?: boolean;
594
+ }): Promise<identity.RestoreResult>;
595
+ lostKeyholderWarning(n: number): string;
596
+ avatarValue(input: string, read?: (p: string) => Promise<Uint8Array>): Promise<string>;
597
+ profileSet(app: App, opts: {
598
+ bio?: string;
599
+ avatar?: string;
600
+ links?: string[];
601
+ clear?: boolean;
602
+ }): Promise<{
603
+ profile: import("@peer2peer/core/v3").DisplayProfile;
604
+ ver: number;
605
+ }>;
606
+ profileShow(app: App, who?: string): Promise<{
607
+ userId: string;
608
+ address: string;
609
+ profile: import("@peer2peer/core/v3").DisplayProfile;
610
+ }>;
611
+ proofAdd(app: App, kind: string, claimRaw: string, opts: {
612
+ gist?: string;
613
+ }): Promise<identity.ProofAddResult>;
614
+ defaultProofFetchers(): import("@peer2peer/core/v3").ProofFetchers;
615
+ proofVerify(app: App, who: string, fetchers?: import("@peer2peer/core/v3").ProofFetchers): Promise<{
616
+ userId: string;
617
+ address: string;
618
+ proofs: identity.ProofCheck[];
619
+ }>;
620
+ BACKUP_FILE_NAME: "backup-phrase.txt";
621
+ };
622
+ export type Ops = typeof realOps;
623
+ export interface ProgramDeps {
624
+ env: Env;
625
+ io: Io;
626
+ ops?: Partial<Ops>;
627
+ /** Builds the context (tests inject one). */
628
+ makeApp?: (env: Env, io: Io, opts?: {
629
+ readOnly?: boolean;
630
+ }) => App;
631
+ /** Installed extensions (main() loads them; tests inject a registry). Absent: none. */
632
+ extensions?: ExtensionRegistry;
633
+ /** For `watch`. */
634
+ signal?: AbortSignal;
635
+ writeLine?: (line: string) => Promise<boolean>;
636
+ /** `tui` (tests): a fake terminal instead of process.stdin/stdout. */
637
+ terminal?: Terminal;
638
+ /** `codex`: the running p2p script (default: process.argv[1]). */
639
+ scriptPath?: string;
640
+ /** `codex install`: the command that runs node in the printed config (default: `node`). */
641
+ nodeCommand?: string;
642
+ /** `codex mcp`: the MCP transport (default: process stdin/stdout). */
643
+ stdin?: Readable;
644
+ stdout?: Writable;
645
+ /** `codex release|decline`: whether stdin and stdout are a real terminal (default: process.stdin/stdout). */
646
+ isTTY?: boolean;
647
+ /** `--no-input` (anywhere on the command line): no pickers and no questions, as in a script. */
648
+ noInput?: boolean;
649
+ /** The person token was valid (main() checks it once and removes it from the environment: projects.ts). */
650
+ front?: boolean;
651
+ /** The person's "yes" on their controlling terminal (tty-confirm.ts; tests stand in). */
652
+ confirmTty?: projects.ConfirmTty;
653
+ }
654
+ /** The widening command `cmd` is (its path from the program, with `session roster` only when it adds), or undefined. */
655
+ export declare function wideningOf(cmd: Command): string | undefined;
656
+ export declare function buildProgram(deps: ProgramDeps): Command;
657
+ /** Writes a line to stdout; resolves false once the reader is gone (EPIPE). */
658
+ export declare function stdoutWriter(ctl: AbortController): (line: string) => Promise<boolean>;
659
+ /** Parses and runs; returns the exit code. */
660
+ export declare function main(argvIn: string[], deps: ProgramDeps): Promise<number>;