geniffy 0.1.1 → 0.3.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.
- package/README.md +78 -4
- package/dist/claude.d.ts +95 -0
- package/dist/claude.js +399 -0
- package/dist/index.d.ts +223 -23
- package/dist/index.js +276 -30
- package/package.json +14 -3
package/dist/index.d.ts
CHANGED
|
@@ -7,16 +7,18 @@
|
|
|
7
7
|
* const { answer } = await g.ask("Who signs the Lumen renewal?");
|
|
8
8
|
*
|
|
9
9
|
* No dependencies: the platform's fetch, FormData and Blob (Node 18+, Deno, Bun, edge runtimes).
|
|
10
|
-
* Retries: reads
|
|
11
|
-
* 429, so a retry never saves a note twice.
|
|
10
|
+
* Retries: reads, deletes and files.put (the same text twice is the same file) are retried on network errors,
|
|
11
|
+
* 408, 429 and 5xx; adding is retried only on 429, so a retry never saves a note twice.
|
|
12
12
|
*/
|
|
13
|
-
export declare const VERSION = "0.
|
|
13
|
+
export declare const VERSION = "0.3.0";
|
|
14
14
|
export declare const DEFAULT_BASE_URL = "https://api.geniffy.com";
|
|
15
15
|
export type Kind = "all" | "people" | "plan" | "pref" | "detail";
|
|
16
16
|
export interface SourceRef {
|
|
17
17
|
id: string | null;
|
|
18
18
|
kind: string;
|
|
19
19
|
title: string;
|
|
20
|
+
/** the labels on that source */
|
|
21
|
+
labels?: Labels;
|
|
20
22
|
}
|
|
21
23
|
export interface Memory {
|
|
22
24
|
id: number;
|
|
@@ -56,7 +58,16 @@ export interface Source {
|
|
|
56
58
|
size_bytes?: number | null;
|
|
57
59
|
added_by?: string | null;
|
|
58
60
|
added_at?: string | null;
|
|
61
|
+
/** your own id for it, when you gave one */
|
|
62
|
+
external_id?: string | null;
|
|
63
|
+
/** your own name/value pairs on it */
|
|
64
|
+
labels?: Labels;
|
|
59
65
|
}
|
|
66
|
+
/** A source's labels: your own name/value pairs, such as { channel: "email" }. */
|
|
67
|
+
export type Labels = Record<string, string>;
|
|
68
|
+
/** A filter by labels: every name must match, and a list of values is any one of them
|
|
69
|
+
* ({ channel: ["email", "chat"] }). */
|
|
70
|
+
export type LabelFilter = Record<string, string | string[]>;
|
|
60
71
|
export interface SourcePage {
|
|
61
72
|
sources: Source[];
|
|
62
73
|
total: number;
|
|
@@ -89,7 +100,10 @@ export interface ClientOptions {
|
|
|
89
100
|
* You usually want `client.space(id)` instead: one client for the process, one bound client per
|
|
90
101
|
* request, so a space can never be forgotten on a call.
|
|
91
102
|
*/
|
|
92
|
-
space?: string;
|
|
103
|
+
space?: string | number;
|
|
104
|
+
/** For a package built on this SDK: its own name and version ("geniffy-ai-sdk/0.1.0"), sent after the SDK's,
|
|
105
|
+
* so the Requests page shows which integration made each call. */
|
|
106
|
+
integration?: string;
|
|
93
107
|
}
|
|
94
108
|
export declare class GeniffyError extends Error {
|
|
95
109
|
readonly status?: number;
|
|
@@ -127,12 +141,18 @@ export declare class InternalServerError extends GeniffyError {
|
|
|
127
141
|
type Body = {
|
|
128
142
|
json?: unknown;
|
|
129
143
|
form?: FormData;
|
|
130
|
-
query?: Record<string, string | number | undefined>;
|
|
144
|
+
query?: Record<string, string | number | string[] | undefined>;
|
|
131
145
|
};
|
|
132
146
|
export declare class Geniffy {
|
|
133
147
|
#private;
|
|
134
148
|
readonly memories: Memories;
|
|
135
149
|
readonly sources: Sources;
|
|
150
|
+
/** Files kept with their exact text, such as the ones Claude's memory tool writes (see `geniffy/claude`) */
|
|
151
|
+
readonly files: Files;
|
|
152
|
+
/** Keys limited to one of your users, on a client bound to them: client.space(id).keys */
|
|
153
|
+
readonly keys: Keys;
|
|
154
|
+
/** The sections profiles are grouped into: every user's on the plain client, one user's on client.space(id) */
|
|
155
|
+
readonly sections: Sections;
|
|
136
156
|
readonly maxRetries: number;
|
|
137
157
|
readonly timeout: number;
|
|
138
158
|
/** The one of your users this client is bound to, or "" for your own memory. */
|
|
@@ -147,18 +167,24 @@ export declare class Geniffy {
|
|
|
147
167
|
* await mem.memories.add("Prefers WhatsApp.");
|
|
148
168
|
* const answer = await mem.ask("How should we reach them?");
|
|
149
169
|
*
|
|
150
|
-
* `space` is your own name for that user and nothing is read into it:
|
|
151
|
-
*
|
|
170
|
+
* `space` is your own name for that user and nothing is read into it: the id you already give them,
|
|
171
|
+
* up to 128 letters, digits, dots, dashes or underscores, so an id rather than an email. A blank one
|
|
172
|
+
* (or undefined, or null) throws rather than reading your own memory.
|
|
152
173
|
*/
|
|
153
|
-
space(space: string): Geniffy;
|
|
174
|
+
space(space: string | number): Geniffy;
|
|
154
175
|
/** @internal */
|
|
155
|
-
request<T>(method: "GET" | "POST" | "DELETE" | "PATCH", path: string, body?: Body): Promise<T>;
|
|
156
|
-
/** An answer from your memory only. `answer` is null when nothing you added supports one.
|
|
157
|
-
|
|
158
|
-
|
|
176
|
+
request<T>(method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", path: string, body?: Body): Promise<T>;
|
|
177
|
+
/** An answer from your memory only. `answer` is null when nothing you added supports one. With labels, only
|
|
178
|
+
* from what the sources carrying them said. */
|
|
179
|
+
ask(question: string, opts?: {
|
|
180
|
+
labels?: LabelFilter;
|
|
181
|
+
}): Promise<Answer>;
|
|
182
|
+
/** The memories that best match `q`, best first. `labels: { channel: "email" }` keeps to the sources
|
|
183
|
+
* carrying them: every name must match, and a list of values is any one of them. */
|
|
159
184
|
search(q: string, opts?: {
|
|
160
185
|
limit?: number;
|
|
161
186
|
kind?: Kind;
|
|
187
|
+
labels?: LabelFilter;
|
|
162
188
|
}): Promise<Memory[]>;
|
|
163
189
|
/**
|
|
164
190
|
* The memories that bear on a question, already written out for YOUR prompt.
|
|
@@ -175,21 +201,28 @@ export declare class Geniffy {
|
|
|
175
201
|
limit?: number;
|
|
176
202
|
kind?: Kind;
|
|
177
203
|
withSources?: boolean;
|
|
204
|
+
labels?: LabelFilter;
|
|
178
205
|
}): Promise<string>;
|
|
179
206
|
/** The same, with the memories behind it and whether anything was found. */
|
|
180
207
|
contextFull(question: string, opts?: {
|
|
181
208
|
limit?: number;
|
|
182
209
|
kind?: Kind;
|
|
183
210
|
withSources?: boolean;
|
|
211
|
+
labels?: LabelFilter;
|
|
184
212
|
}): Promise<ContextResult>;
|
|
185
213
|
/** What stays true about someone, and what is going on with them now. */
|
|
186
214
|
profile(subject?: string): Promise<Profile>;
|
|
187
215
|
/** What to read before dealing with someone. */
|
|
188
216
|
brief(subject?: string, opts?: {
|
|
189
217
|
limit?: number;
|
|
218
|
+
labels?: LabelFilter;
|
|
190
219
|
}): Promise<Brief>;
|
|
191
220
|
/** What the memory holds and what connects to what. Every line has a memory behind it. */
|
|
192
221
|
graph(): Promise<Graph>;
|
|
222
|
+
/** Everything held, as the user's own copy: every memory, current or not, with its status and the sentence it
|
|
223
|
+
* came from, every source, and every file by its path (files.get(path) reads each one's text). On
|
|
224
|
+
* client.space(id), for a user who asks what you hold about them. */
|
|
225
|
+
export(): Promise<Export>;
|
|
193
226
|
/** Whose key this is, and which space this client is reading. */
|
|
194
227
|
me(): Promise<{
|
|
195
228
|
name: string | null;
|
|
@@ -202,7 +235,7 @@ export declare class Geniffy {
|
|
|
202
235
|
* Everything one of your users ever said, gone: facts, sources, all of it. This is the call to
|
|
203
236
|
* make when they ask to be forgotten. It cannot be undone.
|
|
204
237
|
*/
|
|
205
|
-
forgetSpace(space: string): Promise<void>;
|
|
238
|
+
forgetSpace(space: string | number): Promise<void>;
|
|
206
239
|
}
|
|
207
240
|
export interface BatchResult {
|
|
208
241
|
results: Array<{
|
|
@@ -238,6 +271,19 @@ export interface Brief {
|
|
|
238
271
|
memories: Memory[];
|
|
239
272
|
total: number;
|
|
240
273
|
}
|
|
274
|
+
/** A user's own copy of what is held. */
|
|
275
|
+
export interface Export {
|
|
276
|
+
exported_at: string;
|
|
277
|
+
/** where the memory is kept */
|
|
278
|
+
stored_in: string;
|
|
279
|
+
memories: (Memory & {
|
|
280
|
+
quote?: string | null;
|
|
281
|
+
})[];
|
|
282
|
+
sources: Source[];
|
|
283
|
+
/** every file kept, by path and without its text, which files.get(path) returns exactly as written (left out by
|
|
284
|
+
* an API from before files) */
|
|
285
|
+
files?: FileEntry[];
|
|
286
|
+
}
|
|
241
287
|
export interface Graph {
|
|
242
288
|
nodes: Array<{
|
|
243
289
|
id: string;
|
|
@@ -271,29 +317,52 @@ export interface ChatMessage {
|
|
|
271
317
|
/** Who, when the role does not say: a tool name, a participant. */
|
|
272
318
|
name?: string;
|
|
273
319
|
}
|
|
274
|
-
|
|
320
|
+
/** When a note or conversation from the past was said: a Date, or an ISO 8601 string (2026-03-04,
|
|
321
|
+
* 2026-03-04T09:30:00Z). What it teaches is dated by it. Left out, now. */
|
|
322
|
+
export interface SaidAt {
|
|
323
|
+
saidAt?: Date | string;
|
|
324
|
+
}
|
|
325
|
+
/** Your own id for what you add: a ticket's, a document's, a conversation's. Sent again under the same id,
|
|
326
|
+
* the source is updated rather than added twice: only what changed is learned, and what was removed is
|
|
327
|
+
* taken back. Find or delete it by the same id with `sources.get({ externalId })` and `sources.delete`.
|
|
328
|
+
* An id that starts with "file:" is refused: those name the files kept with `files.put`. */
|
|
329
|
+
export interface ExternalId {
|
|
330
|
+
externalId?: string;
|
|
331
|
+
}
|
|
332
|
+
/** Up to 20 of your own name/value pairs ({ channel: "email", project: "apollo" }) to filter search, context,
|
|
333
|
+
* ask, list and brief by. Sent again under the same externalId they replace the old ones, with nothing learned
|
|
334
|
+
* again; left out, they are kept; {} clears them. */
|
|
335
|
+
export interface WithLabels {
|
|
336
|
+
labels?: Labels;
|
|
337
|
+
}
|
|
338
|
+
export type AddInput = string | ({
|
|
275
339
|
text: string;
|
|
276
340
|
title?: string;
|
|
277
|
-
} | {
|
|
341
|
+
} & SaidAt & ExternalId & WithLabels) | ({
|
|
278
342
|
url: string;
|
|
279
343
|
title?: string;
|
|
280
|
-
}
|
|
344
|
+
} & ExternalId & WithLabels)
|
|
281
345
|
/** A conversation as your framework already holds it. System and developer messages are skipped, and
|
|
282
346
|
* who said what is kept, so the user's words become facts about the user and not about your assistant. */
|
|
283
|
-
| {
|
|
347
|
+
| ({
|
|
284
348
|
messages: ChatMessage[];
|
|
285
349
|
title?: string;
|
|
350
|
+
} & SaidAt & ExternalId & WithLabels);
|
|
351
|
+
/** A source named by Geniffy's id, or by the external id you added it under. */
|
|
352
|
+
export type SourceLookup = string | {
|
|
353
|
+
externalId: string;
|
|
286
354
|
};
|
|
287
355
|
export declare class Memories {
|
|
288
356
|
private readonly client;
|
|
289
357
|
constructor(client: Geniffy);
|
|
290
358
|
/** Add a note (a string or { text }), or a web page ({ url }) that Geniffy reads once. */
|
|
291
359
|
add(input: AddInput): Promise<Source>;
|
|
292
|
-
/** Add a PDF
|
|
360
|
+
/** Add a file: PDF, Word (.docx), PowerPoint (.pptx), Excel (.xlsx), or text (.txt, .md, .csv, .html). Under an
|
|
361
|
+
* externalId, a new version updates the source that id names. */
|
|
293
362
|
addFile(file: Blob | ArrayBuffer | Uint8Array, opts?: {
|
|
294
363
|
filename?: string;
|
|
295
364
|
title?: string;
|
|
296
|
-
}): Promise<Source>;
|
|
365
|
+
} & ExternalId & WithLabels): Promise<Source>;
|
|
297
366
|
/**
|
|
298
367
|
* Up to a hundred at once. One bad item does not take the rest down: every item comes back in
|
|
299
368
|
* the order you sent it, with either its source or why it was refused.
|
|
@@ -306,32 +375,105 @@ export declare class Memories {
|
|
|
306
375
|
corrected: boolean;
|
|
307
376
|
source: Source;
|
|
308
377
|
}>;
|
|
309
|
-
/** One page of memories, newest first. */
|
|
378
|
+
/** One page of memories, newest first; with labels, only what the sources carrying them said. */
|
|
310
379
|
list(opts?: {
|
|
311
380
|
kind?: Kind;
|
|
312
381
|
limit?: number;
|
|
313
382
|
cursor?: number;
|
|
383
|
+
labels?: LabelFilter;
|
|
314
384
|
}): Promise<MemoryPage>;
|
|
315
385
|
/** Every memory, newest first, a page at a time: for await (const m of g.memories.iterate()) */
|
|
316
386
|
iterate(opts?: {
|
|
317
387
|
kind?: Kind;
|
|
318
388
|
pageSize?: number;
|
|
389
|
+
labels?: LabelFilter;
|
|
319
390
|
}): AsyncGenerator<Memory>;
|
|
320
391
|
/** A memory, the sentence it came from, and the values it held before. */
|
|
321
392
|
get(id: number): Promise<MemoryDetail>;
|
|
322
393
|
/** Forget a memory for good. */
|
|
323
394
|
delete(id: number): Promise<void>;
|
|
324
395
|
}
|
|
396
|
+
/** A key limited to one of your users: it reads and writes their memory and nothing else. */
|
|
397
|
+
export interface Key {
|
|
398
|
+
id: number;
|
|
399
|
+
name: string;
|
|
400
|
+
/** the user it is limited to */
|
|
401
|
+
space: string;
|
|
402
|
+
/** the key itself: only when it is made, never again */
|
|
403
|
+
key?: string | null;
|
|
404
|
+
starts_with?: string | null;
|
|
405
|
+
created_at?: string | null;
|
|
406
|
+
last_used_at?: string | null;
|
|
407
|
+
/** when it stops working by itself; null: when it is revoked */
|
|
408
|
+
expires_at?: string | null;
|
|
409
|
+
}
|
|
410
|
+
/** Keys limited to one of your users, on a client bound to that user: `client.space(id).keys`. Such a key is
|
|
411
|
+
* safe to hand to that user's own app or device, since it reaches their memory and nothing else. */
|
|
412
|
+
export declare class Keys {
|
|
413
|
+
private readonly client;
|
|
414
|
+
constructor(client: Geniffy);
|
|
415
|
+
/** A new key limited to this client's user. `key` is shown once. rpm: requests a minute (up to 600, the default).
|
|
416
|
+
* expiresAt: when it stops working by itself (a Date, or an ISO date it works through); left out, never. */
|
|
417
|
+
create(opts?: {
|
|
418
|
+
name?: string;
|
|
419
|
+
rpm?: number;
|
|
420
|
+
expiresAt?: Date | string;
|
|
421
|
+
}): Promise<Key>;
|
|
422
|
+
/** The keys limited to this client's user that still work. */
|
|
423
|
+
list(): Promise<Key[]>;
|
|
424
|
+
/** One of this user's keys stops at once. */
|
|
425
|
+
revoke(id: number): Promise<void>;
|
|
426
|
+
}
|
|
427
|
+
/** A section a profile is grouped into. */
|
|
428
|
+
export interface Section {
|
|
429
|
+
id?: number | null;
|
|
430
|
+
name: string;
|
|
431
|
+
description?: string;
|
|
432
|
+
keywords?: string[];
|
|
433
|
+
topics?: string[];
|
|
434
|
+
/** "every user", "this user" or "built in" */
|
|
435
|
+
applies_to?: string;
|
|
436
|
+
}
|
|
437
|
+
/** The sections profiles are grouped into. On the plain client, for every one of your users; on a client bound
|
|
438
|
+
* to one user (`client.space(id).sections`), for that user only. A memory goes in a section when one of its
|
|
439
|
+
* keywords appears in it, or its topic is one of the section's. */
|
|
440
|
+
export declare class Sections {
|
|
441
|
+
private readonly client;
|
|
442
|
+
constructor(client: Geniffy);
|
|
443
|
+
/** The sections, the app's own first, then the built-in ones. */
|
|
444
|
+
list(): Promise<Section[]>;
|
|
445
|
+
/** Add a section (or, under a name it already has, update it). Profiles regroup within a minute or so. */
|
|
446
|
+
create(section: {
|
|
447
|
+
name: string;
|
|
448
|
+
keywords?: string[];
|
|
449
|
+
topics?: string[];
|
|
450
|
+
description?: string;
|
|
451
|
+
}): Promise<Section>;
|
|
452
|
+
delete(id: number): Promise<void>;
|
|
453
|
+
}
|
|
325
454
|
export declare class Sources {
|
|
326
455
|
private readonly client;
|
|
327
456
|
constructor(client: Geniffy);
|
|
457
|
+
/** What was added, newest first; with labels, only the sources carrying them. */
|
|
328
458
|
list(opts?: {
|
|
329
459
|
limit?: number;
|
|
330
460
|
cursor?: number;
|
|
461
|
+
labels?: LabelFilter;
|
|
331
462
|
}): Promise<SourcePage>;
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
463
|
+
/** Delete every source carrying these labels, and every memory learned only from them: the call when your
|
|
464
|
+
* user disconnects a data source whose things you added under its label. Resolves to how many.
|
|
465
|
+
*
|
|
466
|
+
* `keep`: the external ids to leave, for the end of a sync that read everything: every other source with
|
|
467
|
+
* these labels, such as what is gone from the data source, is deleted. */
|
|
468
|
+
deleteLabelled(labels: LabelFilter, opts?: {
|
|
469
|
+
keep?: Iterable<string>;
|
|
470
|
+
}): Promise<number>;
|
|
471
|
+
private deleteAllBut;
|
|
472
|
+
/** A source, by its id or as { externalId } (a NotFoundError when no source has that external id). */
|
|
473
|
+
get(ref: SourceLookup): Promise<Source>;
|
|
474
|
+
/** Delete a source and every memory learned only from it, by its id or as { externalId }: the call for a
|
|
475
|
+
* record your app deleted. */
|
|
476
|
+
delete(ref: SourceLookup): Promise<void>;
|
|
335
477
|
/** Wait until Geniffy has learned from a source (or could not), then return it. Geniffy holds the
|
|
336
478
|
* call open until the source is done, so this returns the moment it is, usually in one call. */
|
|
337
479
|
wait(id: string, opts?: {
|
|
@@ -339,4 +481,62 @@ export declare class Sources {
|
|
|
339
481
|
intervalMs?: number;
|
|
340
482
|
}): Promise<Source>;
|
|
341
483
|
}
|
|
484
|
+
/** A file kept in a memory, without its text. */
|
|
485
|
+
export interface FileEntry {
|
|
486
|
+
/** such as /memories/notes.md */
|
|
487
|
+
path: string;
|
|
488
|
+
/** how long its text is, in characters */
|
|
489
|
+
size: number;
|
|
490
|
+
updated_at: string;
|
|
491
|
+
}
|
|
492
|
+
/** A file and its text, exactly as it was put. */
|
|
493
|
+
export interface MemoryFile extends FileEntry {
|
|
494
|
+
text: string;
|
|
495
|
+
}
|
|
496
|
+
/** What files.put did. */
|
|
497
|
+
export interface FileInfo extends FileEntry {
|
|
498
|
+
/** true when no file had that path before */
|
|
499
|
+
created: boolean;
|
|
500
|
+
/** the source it is learned from, titled by its path */
|
|
501
|
+
source: SourceRef;
|
|
502
|
+
}
|
|
503
|
+
export interface FilePage {
|
|
504
|
+
files: FileEntry[];
|
|
505
|
+
total: number;
|
|
506
|
+
next: number | null;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Files kept exactly as they were written, each under a path such as /memories/notes.md: what an agent keeps for
|
|
510
|
+
* itself, like the notes Claude's memory tool writes (see `geniffy/claude`). Geniffy also learns from each file like
|
|
511
|
+
* a note titled by its path, so context() and ask() recall what it says, and deleting it takes back what only it
|
|
512
|
+
* taught.
|
|
513
|
+
*
|
|
514
|
+
* A path starts with "/" and has at most 255 characters, with no empty, "." or ".." parts and no backslash.
|
|
515
|
+
*/
|
|
516
|
+
export declare class Files {
|
|
517
|
+
private readonly client;
|
|
518
|
+
constructor(client: Geniffy);
|
|
519
|
+
/** Create a file, or replace its text. The text is kept exactly as sent, whitespace and line endings included,
|
|
520
|
+
* and learned like a note; a replace learns only what changed. An empty file is kept too, with nothing learned
|
|
521
|
+
* from it. labels: as on memories.add. */
|
|
522
|
+
put(path: string, text: string, opts?: WithLabels): Promise<FileInfo>;
|
|
523
|
+
/** A file and its exact text (a NotFoundError when no file has that path). */
|
|
524
|
+
get(path: string): Promise<MemoryFile>;
|
|
525
|
+
/** The files whose paths start with `prefix`, by path, without their text ("/", the default, for all of them).
|
|
526
|
+
* Up to 200 a page; `next` is the cursor of the page after, null at the end. */
|
|
527
|
+
list(opts?: {
|
|
528
|
+
prefix?: string;
|
|
529
|
+
limit?: number;
|
|
530
|
+
cursor?: number;
|
|
531
|
+
}): Promise<FilePage>;
|
|
532
|
+
/** Delete a file, its text and what only it taught (a NotFoundError when no file has that path). */
|
|
533
|
+
delete(path: string): Promise<void>;
|
|
534
|
+
/** Delete every file whose path starts with `prefix` ("/memories/" for everything in that folder), with what
|
|
535
|
+
* only they taught. Resolves to how many. */
|
|
536
|
+
deletePrefix(prefix: string): Promise<number>;
|
|
537
|
+
/** Move a file, or, when `from` is a folder, every file in it, keeping the text and what was learned. A
|
|
538
|
+
* NotFoundError when there is nothing to move; a BadRequestError with code "conflict" when a destination is
|
|
539
|
+
* already taken, and then nothing moves. Resolves to how many files moved. */
|
|
540
|
+
move(from: string, to: string): Promise<number>;
|
|
541
|
+
}
|
|
342
542
|
export default Geniffy;
|