holosphere 1.1.21 → 1.3.0-alpha3

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/holosphere.d.ts CHANGED
@@ -2,600 +2,323 @@
2
2
  * Federation propagation options interface
3
3
  */
4
4
  interface PropagationOptions {
5
- /** Whether to use holograms instead of duplicating data (default: true) */
6
5
  useHolograms?: boolean;
7
- /** Specific target spaces to propagate to (default: all federated spaces) */
8
6
  targetSpaces?: string[];
9
- /** Password for accessing the source holon (if needed) */
10
7
  password?: string | null;
11
- /** Whether to automatically propagate to parent hexagons (default: true) */
12
8
  propagateToParents?: boolean;
13
- /** Maximum number of parent levels to propagate to (default: 15) */
14
9
  maxParentLevels?: number;
15
10
  }
16
11
 
17
- /**
18
- * Put options interface
19
- */
20
12
  interface PutOptions {
21
- /** Whether to automatically propagate to federated spaces (default: false) */
22
13
  autoPropagate?: boolean;
23
- /** Additional options to pass to propagate */
24
14
  propagationOptions?: PropagationOptions;
25
- /** Whether to disable hologram redirection logic when putting data (default: false) */
26
15
  disableHologramRedirection?: boolean;
16
+ actingAs?: string;
17
+ password?: string | null;
27
18
  }
28
19
 
29
- /**
30
- * Get options interface
31
- */
32
20
  interface GetOptions {
33
- /** Whether to automatically resolve holograms (default: true) */
34
21
  resolveHolograms?: boolean;
35
- /** Options passed to the schema validator */
36
22
  validationOptions?: object;
37
23
  }
38
24
 
39
- /**
40
- * Resolve Hologram options interface
41
- */
42
25
  interface ResolveHologramOptions {
43
- /** Whether to follow nested holograms (default: true) */
44
26
  followHolograms?: boolean;
45
- /** Internal use: Tracks visited souls to prevent loops */
46
27
  visited?: Set<string>;
47
28
  }
48
29
 
49
- /**
50
- * Represents a Hologram object, typically containing an id and a soul path.
51
- */
52
30
  interface Hologram {
53
31
  id: string;
54
32
  soul: string;
55
- [key: string]: any; // Allow other properties, e.g., _federation
33
+ [key: string]: any;
56
34
  }
57
35
 
58
36
  /**
59
- * Federation info interface
37
+ * Canonical envelope attached to data resolved from a hologram reference.
38
+ *
39
+ * Single source of truth for resolved-hologram metadata. Every read path that
40
+ * returns data resolved from a hologram (get, getAll, subscribe, getFederated,
41
+ * getGlobal, getAllGlobal) attaches this field via `attachHologramMeta`.
42
+ *
43
+ * On success: `isHologram === true` and source* fields point at the origin.
44
+ * On failure: `isHologram === false` and `error` describes why resolution failed.
60
45
  */
46
+ interface ResolvedHologramMeta {
47
+ isHologram: boolean;
48
+ soul: string;
49
+ sourceHolon?: string | null;
50
+ sourceLens?: string | null;
51
+ sourceKey?: string | null;
52
+ resolvedAt: number;
53
+ error?: string;
54
+ }
55
+
56
+ interface ResolvedHologramData {
57
+ _hologram: ResolvedHologramMeta;
58
+ [key: string]: any;
59
+ }
60
+
61
+ /**
62
+ * Per-partner directional lens config. Directions are from the holding
63
+ * space's perspective: `inbound` lenses are received from the partner,
64
+ * `outbound` lenses are sent to the partner.
65
+ */
66
+ interface FederationLensConfig {
67
+ inbound: string[];
68
+ outbound: string[];
69
+ timestamp: number;
70
+ }
71
+
61
72
  interface FederationInfo {
62
- /** Identifier of the holon */
63
73
  id: string;
64
- /** Name of the holon */
65
74
  name: string;
66
- /** List of federated space IDs (spaces this holon federates with) */
67
- federation: string[];
68
- /** List of spaces to notify about changes */
69
- notify: string[];
70
- /** Timestamp of last update */
75
+ /** Canonical list of all federation partners (any direction, including no lens flow yet). */
76
+ federated: string[];
77
+ /** Partners we receive data FROM (subset of `federated` with non-empty inbound lenses). */
78
+ inbound: string[];
79
+ /** Partners we send data TO (subset of `federated` with non-empty outbound lenses). */
80
+ outbound: string[];
81
+ /** Per-partner directional lens config. */
82
+ lensConfig: Record<string, FederationLensConfig>;
83
+ /** Optional display names for partners. */
84
+ partnerNames: Record<string, string>;
71
85
  timestamp: number;
72
86
  }
73
87
 
74
- /**
75
- * Options for federated data retrieval
76
- */
77
88
  interface GetFederatedOptions {
78
- /** Whether to aggregate results by ID */
79
89
  aggregate?: boolean;
80
- /** Field to use as ID */
81
90
  idField?: string;
82
- /** Fields to sum during aggregation */
83
91
  sumFields?: string[];
84
- /** Array fields to concatenate during aggregation */
85
92
  concatArrays?: string[];
86
- /** Whether to remove duplicates in concatenated arrays */
87
93
  removeDuplicates?: boolean;
88
- /** Custom merge function for aggregation */
89
94
  mergeStrategy?: (items: any[]) => any;
90
- /** Whether to include local data */
91
95
  includeLocal?: boolean;
92
- /** Whether to include federated data */
93
96
  includeFederated?: boolean;
94
- /** Whether to resolve federation references */
95
97
  resolveReferences?: boolean;
96
- /** Maximum number of federated spaces to query */
97
98
  maxFederatedSpaces?: number;
98
- /** Timeout in milliseconds for federated queries */
99
99
  timeout?: number;
100
100
  }
101
101
 
102
- /**
103
- * Results from a propagation operation
104
- */
105
102
  interface PropagationResult {
106
- /** Number of successfully propagated items */
107
103
  success: number;
108
- /** Number of errors encountered */
109
104
  errors: number;
110
- /** Details about errors */
111
105
  errorDetails: Array<{ space: string, error: string }>;
112
- /** Whether any propagation occurred */
113
106
  propagated: boolean;
114
- /** Whether references were used */
115
107
  referencesUsed: boolean;
116
- /** Error message if applicable */
117
108
  error?: string;
118
- /** Information message if applicable */
119
109
  message?: string;
120
- /** Parent propagation results */
121
110
  parentPropagation?: {
122
- /** Number of successfully propagated items to parents */
123
111
  success: number;
124
- /** Number of errors encountered during parent propagation */
125
112
  errors: number;
126
- /** Number of parent propagations skipped */
127
113
  skipped: number;
128
- /** Messages from parent propagation */
129
114
  messages: string[];
130
115
  };
131
116
  }
132
117
 
133
- /**
134
- * Result from a put operation
135
- */
136
118
  interface PutResult {
137
- /** Indicates if the put operation was successful */
138
119
  success: boolean;
139
- /** Indicates if the data ultimately put at the path was a hologram */
140
120
  isHologramAtPath?: boolean;
141
- /** The final holon where data was put (after potential redirection) */
142
121
  pathHolon: string;
143
- /** The final lens where data was put (after potential redirection) */
144
122
  pathLens: string;
145
- /** The final key under which data was put (after potential redirection) */
146
123
  pathKey: string;
147
- /** Result of any automatic propagation, if it occurred */
148
124
  propagationResult?: PropagationResult | null;
149
- /** Error message if the put operation failed at some point */
150
125
  error?: string;
151
126
  }
152
127
 
128
+ interface CanWriteResult {
129
+ canWrite: boolean;
130
+ reason: string;
131
+ accessType: string;
132
+ }
133
+
134
+ interface HoloSphereConfig {
135
+ appName?: string;
136
+ appname?: string;
137
+ privateKey?: Uint8Array | string | null;
138
+ strict?: boolean;
139
+ backend?: string;
140
+ openaiKey?: string | null;
141
+ nostr?: {
142
+ peers?: string[];
143
+ relays?: string[];
144
+ persistence?: boolean;
145
+ };
146
+ }
147
+
153
148
  declare class HoloSphere {
154
- private appname;
155
- private strict;
156
- private validator;
157
- public gun;
158
- private sea;
159
- private openai?;
160
- private subscriptions;
161
-
162
- /**
163
- * Initializes a new instance of the HoloSphere class.
164
- * @param {string} appname - The name of the application.
165
- * @param {boolean} strict - Whether to enforce strict schema validation.
166
- * @param {string|null} openaikey - The OpenAI API key.
167
- * @param {object|null} gunInstance - The Gun instance to use.
168
- */
169
- constructor(appname: string, strict?: boolean, openaikey?: string | null, gunInstance?: any);
170
-
171
- /**
172
- * Gets the Gun instance.
173
- * @returns {any} - The Gun instance.
174
- */
175
- getGun(): any;
149
+ appname: string;
150
+ config: HoloSphereConfig;
151
+ client: { publicKey: string };
152
+ gun: any;
153
+ subscriptions: Record<string, any>;
154
+
155
+ constructor(config: HoloSphereConfig);
156
+ constructor(appname: string, strict?: boolean, openaikey?: string | null, gunOptions?: any);
176
157
 
177
- // ================================ SCHEMA FUNCTIONS ================================
158
+ ready(): Promise<HoloSphere>;
159
+ getGun(): any;
178
160
 
179
- /**
180
- * Sets the JSON schema for a specific lens.
181
- * @param {string} lens - The lens identifier.
182
- * @param {object} schema - The JSON schema to set.
183
- * @returns {Promise<boolean>} - Resolves when the schema is set.
184
- */
161
+ // Schema
185
162
  setSchema(lens: string, schema: object): Promise<boolean>;
163
+ getSchema(lens: string, options?: { useCache?: boolean; maxCacheAge?: number }): Promise<object | null>;
164
+ clearSchemaCache(lens?: string | null): boolean;
186
165
 
187
- /**
188
- * Retrieves the JSON schema for a specific lens.
189
- * @param {string} lens - The lens identifier.
190
- * @returns {Promise<object|null>} - The retrieved schema or null if not found.
191
- */
192
- getSchema(lens: string): Promise<object | null>;
193
-
194
- // ================================ CONTENT FUNCTIONS ================================
195
-
196
- /**
197
- * Stores content in the specified holon and lens.
198
- * @param {string} holon - The holon identifier.
199
- * @param {string} lens - The lens under which to store the content.
200
- * @param {object} data - The data to store.
201
- * @param {string} [password] - Optional password for private holon.
202
- * @param {PutOptions} [options] - Additional options
203
- * @returns {Promise<any>} - Returns result object if successful
204
- */
166
+ // Content - v2-compatible signatures
167
+ put(holon: string, lens: string, data: object, options?: PutOptions): Promise<PutResult>;
205
168
  put(holon: string, lens: string, data: object, password?: string | null, options?: PutOptions): Promise<PutResult>;
206
-
207
- /**
208
- * Retrieves content from the specified holon and lens.
209
- * @param {string} holon - The holon identifier.
210
- * @param {string} lens - The lens from which to retrieve content.
211
- * @param {string} key - The specific key to retrieve.
212
- * @param {string} [password] - Optional password for private holon.
213
- * @param {GetOptions} [options] - Additional options
214
- * @returns {Promise<any|null>} - The retrieved content or null if not found.
215
- */
169
+ get(holon: string, lens: string): Promise<any | null>;
216
170
  get(holon: string, lens: string, key: string, password?: string | null, options?: GetOptions): Promise<any | null>;
217
-
218
- /**
219
- * Retrieves a node directly using its soul path
220
- * @param {string} soul - The soul path of the node
221
- * @returns {Promise<any>} - The retrieved node or null if not found.
222
- */
223
- getNodeBySoul(soul: string): Promise<any>;
224
-
225
- /**
226
- * Propagates data to federated holons
227
- * @param {string} holon - The holon identifier
228
- * @param {string} lens - The lens identifier
229
- * @param {object} data - The data to propagate
230
- * @param {PropagationOptions} [options] - Propagation options
231
- * @returns {Promise<PropagationResult>} - Result with success count and errors
232
- */
233
- propagate(holon: string, lens: string, data: object, options?: PropagationOptions): Promise<PropagationResult>;
234
-
235
- /**
236
- * Retrieves all content from the specified holon and lens.
237
- * @param {string} holon - The holon identifier.
238
- * @param {string} lens - The lens from which to retrieve content.
239
- * @param {string} [password] - Optional password for private holon.
240
- * @returns {Promise<Array<any>>} - The retrieved content.
241
- */
242
171
  getAll(holon: string, lens: string, password?: string | null): Promise<Array<any>>;
243
-
244
- /**
245
- * Deletes a specific key from a given holon and lens.
246
- * @param {string} holon - The holon identifier.
247
- * @param {string} lens - The lens from which to delete the key.
248
- * @param {string} key - The specific key to delete.
249
- * @param {string} [password] - Optional password for private holon.
250
- * @returns {Promise<boolean>} - Returns true if successful
251
- */
172
+ parse(rawData: any): Promise<object | null>;
252
173
  delete(holon: string, lens: string, key: string, password?: string | null): Promise<boolean>;
253
-
254
- /**
255
- * Deletes all keys from a given holon and lens.
256
- * @param {string} holon - The holon identifier.
257
- * @param {string} lens - The lens from which to delete all keys.
258
- * @param {string} [password] - Optional password for private holon.
259
- * @returns {Promise<boolean>} - Returns true if successful
260
- */
261
174
  deleteAll(holon: string, lens: string, password?: string | null): Promise<boolean>;
262
175
 
263
- // ================================ NODE FUNCTIONS ================================
264
-
265
- /**
266
- * Stores a specific gun node in a given holon and lens.
267
- * @param {string} holon - The holon identifier.
268
- * @param {string} lens - The lens under which to store the node.
269
- * @param {object} data - The node to store.
270
- * @returns {Promise<boolean>} - Returns true if successful
271
- */
176
+ // Node
272
177
  putNode(holon: string, lens: string, data: object): Promise<boolean>;
273
-
274
- /**
275
- * Retrieves a specific gun node from the specified holon and lens.
276
- * @param {string} holon - The holon identifier.
277
- * @param {string} lens - The lens identifier.
278
- * @param {string} key - The specific key to retrieve.
279
- * @returns {Promise<any|null>} - The retrieved node or null if not found.
280
- */
281
178
  getNode(holon: string, lens: string, key: string): Promise<any | null>;
282
-
283
- /**
284
- * Gets a Gun reference to a node by its soul
285
- * @param {string} soul - The soul path
286
- * @returns {any} - A Gun reference to the node
287
- */
288
179
  getNodeRef(soul: string): any;
289
-
290
- /**
291
- * Deletes a specific gun node from a given holon and lens.
292
- * @param {string} holon - The holon identifier.
293
- * @param {string} lens - The lens identifier.
294
- * @param {string} key - The key of the node to delete.
295
- * @returns {Promise<boolean>} - Returns true if successful
296
- */
180
+ getNodeBySoul(soul: string): Promise<any>;
297
181
  deleteNode(holon: string, lens: string, key: string): Promise<boolean>;
298
182
 
299
- // ================================ HOLOGRAM FUNCTIONS ================================
300
-
301
- /**
302
- * Creates a soul hologram object for a data item.
303
- * @param {string} holon - The holon where the original data is stored.
304
- * @param {string} lens - The lens where the original data is stored.
305
- * @param {object} data - The data to create a hologram for. Must have an 'id' field.
306
- * @returns {Hologram} - A hologram object containing id and soul.
307
- */
308
- createHologram(holon: string, lens: string, data: { id: string, [key: string]: any }): Hologram;
309
-
310
- /**
311
- * Checks if an object is a hologram (has id and soul).
312
- * @param {any} data - The data to check.
313
- * @returns {boolean} - True if the object is considered a hologram.
314
- */
315
- isHologram(data: any): data is Hologram;
316
-
317
- /**
318
- * Resolves a hologram to its actual data by following its soul path.
319
- * @param {Hologram} hologram - The hologram object to resolve.
320
- * @param {ResolveHologramOptions} [options] - Options for resolution.
321
- * @returns {Promise<object|null>} - The resolved data, null if not found, or the original hologram in case of loops/errors.
322
- */
323
- resolveHologram(hologram: Hologram, options?: ResolveHologramOptions): Promise<object | null>;
324
-
325
- // ================================ GLOBAL FUNCTIONS ================================
326
-
327
- /**
328
- * Stores data in a global (non-holon-specific) table.
329
- * @param {string} tableName - The table name to store data in.
330
- * @param {object} data - The data to store. If it has an 'id' field, it will be used as the key.
331
- * @param {string} [password] - Optional password for private holon.
332
- * @returns {Promise<void>}
333
- */
183
+ // Global
334
184
  putGlobal(tableName: string, data: object, password?: string | null): Promise<void>;
335
-
336
- /**
337
- * Retrieves a specific key from a global table.
338
- * @param {string} tableName - The table name to retrieve from.
339
- * @param {string} key - The key to retrieve.
340
- * @param {string} [password] - Optional password for private holon.
341
- * @returns {Promise<any|null>} - The parsed data for the key or null if not found.
342
- */
185
+ writeGlobal(tableName: string, data: object): Promise<void>;
343
186
  getGlobal(tableName: string, key: string, password?: string | null): Promise<any | null>;
344
-
345
- /**
346
- * Retrieves all data from a global table.
347
- * @param {string} tableName - The table name to retrieve data from.
348
- * @param {string} [password] - Optional password for private holon.
349
- * @returns {Promise<Array<any>>} - The parsed data from the table as an array.
350
- */
351
187
  getAllGlobal(tableName: string, password?: string | null): Promise<Array<any>>;
352
-
353
- /**
354
- * Deletes a specific key from a global table.
355
- * @param {string} tableName - The table name to delete from.
356
- * @param {string} key - The key to delete.
357
- * @param {string} [password] - Optional password for private holon.
358
- * @returns {Promise<boolean>} - Returns true if successful
359
- */
360
188
  deleteGlobal(tableName: string, key: string, password?: string | null): Promise<boolean>;
361
-
362
- /**
363
- * Deletes an entire global table.
364
- * @param {string} tableName - The table name to delete.
365
- * @param {string} [password] - Optional password for private holon.
366
- * @returns {Promise<boolean>} - Returns true if successful
367
- */
368
189
  deleteAllGlobal(tableName: string, password?: string | null): Promise<boolean>;
190
+ subscribeGlobal(lens: string, key: string | null, callback: (data: any, key?: string) => void, options?: { realtimeOnly?: boolean }): Promise<{ unsubscribe: () => void }>;
191
+ subscribeGlobal(lens: string, callback: (data: any, key?: string) => void): Promise<{ unsubscribe: () => void }>;
369
192
 
370
- // ================================ COMPUTE FUNCTIONS ================================
371
-
372
- /**
373
- * Computes operations across multiple layers up the hierarchy
374
- * @param {string} holon - Starting holon identifier
375
- * @param {string} lens - The lens to compute
376
- * @param {object} options - Computation options
377
- * @param {number} [maxLevels=15] - Maximum levels to compute up
378
- * @param {string} [password] - Optional password for private holons
379
- * @returns {Promise<Array<any>>} - Computation results
380
- */
381
- computeHierarchy(holon: string, lens: string, options: object, maxLevels?: number, password?: string | null): Promise<Array<any>>;
193
+ // Hologram
194
+ createHologram(holon: string, lens: string, data: { id: string, [key: string]: any }): Hologram;
195
+ isHologram(data: any): data is Hologram;
196
+ parseSoulPath(soul: string): { appname: string, holon: string, lens: string, key: string } | null;
197
+ resolveHologram(hologram: Hologram, options?: ResolveHologramOptions): Promise<ResolvedHologramData | null>;
198
+ attachHologramMeta<T extends object>(originalData: T, hologramSoul: string): T & ResolvedHologramData;
382
199
 
383
- /**
384
- * Computes operations on content within a holon and lens for one layer up.
385
- * @param {string} holon - The holon identifier.
386
- * @param {string} lens - The lens to compute.
387
- * @param {object|string} options - Computation options or operation name
388
- * @param {string} [password] - Optional password for private holons
389
- * @returns {Promise<any>} - Computation result
390
- */
391
- compute(holon: string, lens: string, options: object|string, password?: string | null): Promise<any>;
392
-
393
- /**
394
- * Upcasts content to parent holonagons recursively using federation and soul references.
395
- * @param {string} holon - The current holon identifier.
396
- * @param {string} lens - The lens under which to upcast.
397
- * @param {object} content - The content to upcast.
398
- * @param {number} [maxLevels=15] - Maximum levels to upcast.
399
- * @returns {Promise<object>} - The original content.
400
- */
200
+ // Compute
201
+ computeHierarchy(holon: string, lens: string, options: object, maxLevels?: number, password?: string | null): Promise<Array<any>>;
202
+ compute(holon: string, lens: string, options: object | string, password?: string | null): Promise<any>;
203
+ summarize(history: string): Promise<string>;
401
204
  upcast(holon: string, lens: string, content: object, maxLevels?: number): Promise<object>;
402
-
403
- /**
404
- * Updates the parent holon with a new report.
405
- * @param {string} id - The child holon identifier.
406
- * @param {string} report - The report to update.
407
- * @returns {Promise<object>} - The updated parent information.
408
- */
409
205
  updateParent(id: string, report: string): Promise<object>;
206
+ propagate(holon: string, lens: string, data: object, options?: PropagationOptions): Promise<PropagationResult>;
410
207
 
411
- // ================================ LOCATION FUNCTIONS ================================
412
-
413
- /**
414
- * Converts latitude and longitude to a holon identifier.
415
- * @param {number} lat - The latitude.
416
- * @param {number} lng - The longitude.
417
- * @param {number} resolution - The resolution level.
418
- * @returns {Promise<string>} - The resulting holon identifier.
419
- */
208
+ // Location
420
209
  getHolon(lat: number, lng: number, resolution: number): Promise<string>;
421
-
422
- /**
423
- * Retrieves all containing holonagons at all scales for given coordinates.
424
- * @param {number} lat - The latitude.
425
- * @param {number} lng - The longitude.
426
- * @returns {Array<string>} - List of holon identifiers.
427
- */
428
210
  getScalespace(lat: number, lng: number): string[];
429
-
430
- /**
431
- * Retrieves all containing holonagons at all scales for a given holon.
432
- * @param {string} holon - The holon identifier.
433
- * @returns {Array<string>} - List of holon identifiers.
434
- */
435
211
  getHolonScalespace(holon: string): string[];
436
212
 
437
- // ================================ SUBSCRIPTION FUNCTIONS ================================
438
-
439
- /**
440
- * Subscribes to changes in a specific holon and lens.
441
- * @param {string} holon - The holon identifier.
442
- * @param {string} lens - The lens to subscribe to.
443
- * @param {function} callback - The callback to execute on changes.
444
- * @returns {Promise<object>} - Subscription object with unsubscribe method
445
- */
213
+ // Subscription
446
214
  subscribe(holon: string, lens: string, callback: (data: any, key?: string) => void): Promise<{ unsubscribe: () => void }>;
447
215
 
448
- // ================================ FEDERATION FUNCTIONS ================================
449
-
450
- /**
451
- * Creates a federation relationship between two holons
452
- * @param {string} holonId1 - The first holon ID
453
- * @param {string} holonId2 - The second holon ID
454
- * @param {string} [password1] - Optional password for the first holon
455
- * @param {string} [password2] - Optional password for the second holon
456
- * @param {boolean} [bidirectional=true] - Whether to set up bidirectional notifications automatically
457
- * @param {object} [lensConfig] - Optional lens-specific configuration
458
- * @param {string[]} [lensConfig.federate] - List of lenses to federate (default: all)
459
- * @param {string[]} [lensConfig.notify] - List of lenses to notify (default: all)
460
- * @returns {Promise<boolean>} - True if federation was created successfully
461
- */
462
- federate(holonId1: string, holonId2: string, password1?: string | null, password2?: string | null, bidirectional?: boolean, lensConfig?: { federate?: string[], notify?: string[] }): Promise<boolean>;
463
-
464
- /**
465
- * Subscribes to federation notifications for a holon
466
- * @param {string} holonId - The holon ID to subscribe to
467
- * @param {string} [password] - Optional password for the holon
468
- * @param {function} callback - The callback to execute on notifications
469
- * @param {object} [options] - Subscription options
470
- * @returns {Promise<object>} - Subscription object with unsubscribe() method
471
- */
472
- subscribeFederation(holonId: string, password: string | null, callback: (data: any, federatedSpace?: string, lens?: string) => void, options?: { lenses?: string[], throttle?: number }): Promise<{ unsubscribe: () => void, getSubscriptionCount: () => number }>;
473
-
474
- /**
475
- * Gets federation info for a holon
476
- * @param {string} holonId - The holon ID
477
- * @param {string} [password] - Optional password for the holon
478
- * @returns {Promise<FederationInfo|null>} - Federation info or null if not found
479
- */
480
- getFederation(holonId: string, password?: string | null): Promise<FederationInfo | null>;
481
-
482
- /**
483
- * Retrieves the lens-specific configuration for a federation link between two holons.
484
- * @param {string} holonId - The ID of the source holon.
485
- * @param {string} targetHolonId - The ID of the target holon in the federation link.
486
- * @param {string} [password] - Optional password for the source holon.
487
- * @returns {Promise<{ federate: string[], notify: string[] } | null>} - An object with 'federate' and 'notify' arrays, or null if not found.
488
- */
489
- getFederatedConfig(holonId: string, targetHolonId: string, password?: string | null): Promise<{ federate: string[], notify: string[] } | null>;
490
-
491
- /**
492
- * Removes a federation relationship between holons
493
- * @param {string} holonId1 - The first holon ID
494
- * @param {string} holonId2 - The second holon ID
495
- * @param {string} [password1] - Optional password for the first holon
496
- * @param {string} [password2] - Optional password for the second holon
497
- * @returns {Promise<boolean>} - True if federation was removed successfully
498
- */
216
+ // Federation - v1 style
217
+ federate(holonId1: string, holonId2: string, password1?: string | null, password2?: string | null, bidirectional?: boolean, lensConfig?: { inbound?: string[], outbound?: string[] }): Promise<boolean>;
499
218
  unfederate(holonId1: string, holonId2: string, password1?: string | null, password2?: string | null): Promise<boolean>;
500
219
 
501
- /**
502
- * Removes a notification relationship between two spaces
503
- * @param {string} holonId1 - The space to modify (remove from its notify list)
504
- * @param {string} holonId2 - The space to be removed from notifications
505
- * @param {string} [password1] - Optional password for the first space
506
- * @returns {Promise<boolean>} - True if notification was removed successfully
507
- */
508
- removeNotify(holonId1: string, holonId2: string, password1?: string | null): Promise<boolean>;
220
+ // Federation - v2 style
221
+ federateHolon(sourceHolon: string, targetHolon: string, options?: { lensConfig?: { inbound?: string[]; outbound?: string[] }; partnerName?: string }): Promise<boolean>;
222
+ unfederateHolon(sourceHolon: string, targetHolon: string): Promise<boolean>;
509
223
 
510
- /**
511
- * Get and aggregate data from federated holons
512
- * @param {string} holon - The holon name
513
- * @param {string} lens - The lens name
514
- * @param {GetFederatedOptions} [options] - Options for retrieval and aggregation
515
- * @returns {Promise<Array<any>>} - Combined array of local and federated data
516
- */
224
+ subscribeFederation(holonId: string, password: string | null, callback: (data: any, federatedSpace?: string, lens?: string) => void, options?: { lenses?: string[], throttle?: number }): Promise<{ unsubscribe: () => void, getSubscriptionCount: () => number }>;
225
+ getFederation(holonId: string, password?: string | null): Promise<FederationInfo | null>;
226
+ getFederatedConfig(holonId: string, targetHolonId: string, password?: string | null): Promise<{ inbound: string[], outbound: string[] } | null>;
227
+ removeNotify(holonId1: string, holonId2: string, password1?: string | null): Promise<boolean>;
517
228
  getFederated(holon: string, lens: string, options?: GetFederatedOptions): Promise<Array<any>>;
518
-
519
- /**
520
- * Tracks a federated message across different chats
521
- * @param {string} originalChatId - The ID of the original chat
522
- * @param {string} messageId - The ID of the original message
523
- * @param {string} federatedChatId - The ID of the federated chat
524
- * @param {string} federatedMessageId - The ID of the message in the federated chat
525
- * @param {string} [type] - The type of message (e.g., 'quest', 'announcement')
526
- * @returns {Promise<void>}
527
- */
528
229
  federateMessage(originalChatId: string, messageId: string, federatedChatId: string, federatedMessageId: string, type?: string): Promise<void>;
529
-
530
- /**
531
- * Gets all federated messages for a given original message
532
- * @param {string} originalChatId - The ID of the original chat
533
- * @param {string} messageId - The ID of the original message
534
- * @returns {Promise<object|null>} - The tracking information for the message
535
- */
536
230
  getFederatedMessages(originalChatId: string, messageId: string): Promise<object | null>;
537
-
538
- /**
539
- * Updates a federated message across all federated chats
540
- * @param {string} originalChatId - The ID of the original chat
541
- * @param {string} messageId - The ID of the original message
542
- * @param {Function} updateCallback - Function to update the message in each chat
543
- * @returns {Promise<void>}
544
- */
545
231
  updateFederatedMessages(originalChatId: string, messageId: string, updateCallback: (chatId: string, messageId: string) => Promise<void>): Promise<void>;
546
-
547
- /**
548
- * Resets the federation settings for a holon
549
- * @param {string} holonId - The holon ID
550
- * @param {string} [password] - Optional password for the holon
551
- * @returns {Promise<boolean>} - True if federation was reset successfully
552
- */
553
232
  resetFederation(holonId: string, password?: string | null): Promise<boolean>;
554
233
 
555
- // ================================ UTILITY FUNCTIONS ================================
234
+ // Authorization
235
+ canWrite(holonId: string, lensName: string, actingAs: string, options?: any): Promise<CanWriteResult>;
236
+ addAllowedAuthor(pubkey: string): void;
237
+ removeAllowedAuthor(pubkey: string): void;
238
+ listAllowedAuthors(): string[];
556
239
 
557
- /**
558
- * Generates a unique ID for data items
559
- * @returns {string} A unique ID
560
- */
240
+ // Utility
561
241
  generateId(): string;
562
-
563
- /**
564
- * Closes the HoloSphere instance and cleans up resources.
565
- * @returns {Promise<void>}
566
- */
567
242
  close(): Promise<void>;
568
-
569
- /**
570
- * Configures radisk storage options for GunDB.
571
- * @param {object} options - Radisk configuration options
572
- * @param {string} [options.file='./radata'] - Directory for radisk storage
573
- * @param {boolean} [options.radisk=true] - Whether to enable radisk storage
574
- * @param {number} [options.until] - Timestamp until which to keep data
575
- * @param {number} [options.retry] - Number of retries for failed operations
576
- * @param {number} [options.timeout] - Timeout for operations in milliseconds
577
- */
578
- configureRadisk(options?: {
579
- file?: string;
580
- radisk?: boolean;
581
- until?: number | null;
582
- retry?: number;
583
- timeout?: number;
584
- }): void;
585
-
586
- /**
587
- * Gets radisk storage statistics and information.
588
- * @returns {object} Radisk statistics including file path, enabled status, and storage info
589
- */
590
- getRadiskStats(): {
591
- enabled: boolean;
592
- filePath: string;
593
- retry: number;
594
- timeout: number;
595
- until: number | null;
596
- peers: any[];
597
- localStorage: boolean;
598
- } | { error: string };
243
+ getVersion(): string;
244
+ userName(holonId: string): string;
245
+ configureRadisk(options?: { file?: string; radisk?: boolean; until?: number | null; retry?: number; timeout?: number }): void;
246
+ getRadiskStats(): { enabled: boolean; filePath: string; retry: number; timeout: number; until: number | null; peers: any[]; localStorage: boolean } | { error: string };
599
247
  }
600
248
 
249
+ // Named exports
250
+ export declare const version: string;
251
+
252
+ export declare const nostrUtils: {
253
+ generatePrivateKey(): string;
254
+ getPublicKey(privateKeyHex: string): string;
255
+ getPublicKeyFromBytes(privateKeyBytes: Uint8Array): string;
256
+ parseNsecOrHex(input: string): string | null;
257
+ parseNpubOrHex(input: string): string | null;
258
+ hexToNpub(hex: string): string;
259
+ hexToNsec(hex: string): string;
260
+ npubToHex(npub: string): string;
261
+ nsecToHex(nsec: string): string;
262
+ hexToBytes(hex: string): Uint8Array;
263
+ bytesToHex(bytes: Uint8Array): string;
264
+ shortenPubKey(pubkey: string, len?: number): string;
265
+ shortenNpub(npub: string, len?: number): string;
266
+ generateNonce(): string;
267
+ };
268
+
269
+ export declare function buildLensPath(appName: string, holonId: string, lens: string): string;
270
+
271
+ export declare const subscriptions: {
272
+ createSubscription(client: HoloSphere, path: string, callback: (data: any, key?: string) => void, options?: { realtimeOnly?: boolean; resolveHolograms?: boolean; appname?: string }): { unsubscribe: () => void; stop: () => void };
273
+ };
274
+
275
+ export declare const registry: {
276
+ storeInboundCapability(client: HoloSphere, appName: string, holonId: string, capability: any): Promise<{ success: boolean; id?: string; error?: string }>;
277
+ getInboundCapabilities(client: HoloSphere, appName: string, holonId: string): Promise<any[]>;
278
+ removeInboundCapability(client: HoloSphere, appName: string, holonId: string, capabilityId: string): Promise<boolean>;
279
+ };
280
+
281
+ export declare const handshake: {
282
+ subscribeToFederationDMs(holosphere: HoloSphere, privateKey: any, publicKey: string, handlers: {
283
+ onRequest?: (request: any, senderPubKey: string) => void;
284
+ onResponse?: (response: any, senderPubKey: string) => void;
285
+ onUpdate?: (update: any, senderPubKey: string) => void;
286
+ onUpdateResponse?: (response: any, senderPubKey: string) => void;
287
+ }): () => void;
288
+ initiateFederationHandshake(holosphere: HoloSphere, privateKey: any, params: {
289
+ partnerPubKey: string;
290
+ holonId: string;
291
+ holonName: string;
292
+ lensConfig?: any;
293
+ message?: string;
294
+ }): Promise<{ success: boolean; requestId?: string }>;
295
+ acceptFederationRequest(holosphere: HoloSphere, privateKey: any, params: {
296
+ requesterPubKey: string;
297
+ holonId: string;
298
+ holonName: string;
299
+ lensConfig?: any;
300
+ requestId?: string;
301
+ }): Promise<{ success: boolean }>;
302
+ rejectFederationRequest(holosphere: HoloSphere, privateKey: any, params: {
303
+ requesterPubKey: string;
304
+ holonId: string;
305
+ reason?: string;
306
+ requestId?: string;
307
+ }): Promise<{ success: boolean }>;
308
+ processFederationResponse(holosphere: HoloSphere, response: any, senderPubKey: string, options?: {
309
+ holonId: string;
310
+ inboundLenses?: string[];
311
+ }): Promise<{ success: boolean; responderHolonId?: string; error?: string }>;
312
+ requestFederationUpdate(holosphere: HoloSphere, privateKey: any, params: {
313
+ partnerPubKey: string;
314
+ holonId: string;
315
+ holonName: string;
316
+ newLensConfig?: any;
317
+ message?: string;
318
+ }): Promise<{ success: boolean }>;
319
+ acceptFederationUpdate(holosphere: HoloSphere, privateKey: any, params: any): Promise<{ success: boolean }>;
320
+ rejectFederationUpdate(holosphere: HoloSphere, privateKey: any, params: any): Promise<{ success: boolean }>;
321
+ };
322
+
601
323
  export default HoloSphere;
324
+ export { HoloSphere };