@peer2peer/cli 0.0.0-stage → 0.1.0

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