@lumavox/server 0.14.7 → 0.19.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 +3 -3
- package/dist/gen/index.d.ts +1 -1
- package/dist/gen/types.gen.d.ts +749 -57
- package/dist/index.d.ts +1 -1
- package/dist/resources/end-users.d.ts +31 -5
- package/dist/resources/end-users.js +28 -6
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type * from "./gen/index.js";
|
|
|
10
10
|
export type { Page } from "./paging.js";
|
|
11
11
|
export type { AgentKnowledge, AgentSettings, Agents, AgentTools, } from "./resources/agents.js";
|
|
12
12
|
export type { AssetListParams, Assets, AssetUploadFields, FolderListParams, Folders, } from "./resources/assets.js";
|
|
13
|
-
export type { EndUserCreated, EndUserExport, EndUserListParams, EndUsers, } from "./resources/end-users.js";
|
|
13
|
+
export type { EndUserCreated, EndUserExport, EndUserListParams, EndUserMemories, EndUserMemoryListParams, EndUsers, } from "./resources/end-users.js";
|
|
14
14
|
export type { EphemeralKeyCreateOptions, EphemeralKeyListParams, EphemeralKeyRevokeOptions, EphemeralKeys, } from "./resources/ephemeral-keys.js";
|
|
15
15
|
export type { GenerationListParams, Generations, Jobs, Skybox, } from "./resources/generations.js";
|
|
16
16
|
export type { Knowledge, KnowledgeInsightsParams, KnowledgeListParams, KnowledgeUploadFields, } from "./resources/knowledge.js";
|
|
@@ -23,21 +23,23 @@
|
|
|
23
23
|
* page), reads each transcript back to its start by `messages.next_cursor`
|
|
24
24
|
* (200 messages a page, four sessions at a time), reads their facts (200
|
|
25
25
|
* a page) — those a later conversation replaced too, which are still held
|
|
26
|
-
* until they are deleted 30 days on — and
|
|
27
|
-
* after an abort or a
|
|
28
|
-
* too. The cost: one mint (and `limits()` when cold) + ⌈S/200⌉
|
|
29
|
-
* Σ⌈M/200⌉ transcript pages + ⌈F/200⌉ fact pages +
|
|
26
|
+
* until they are deleted 30 days on — and their memories (100 a page, the
|
|
27
|
+
* route's most), and revokes the key in `finally` — after an abort or a
|
|
28
|
+
* failure too. The cost: one mint (and `limits()` when cold) + ⌈S/200⌉
|
|
29
|
+
* lists + Σ⌈M/200⌉ transcript pages + ⌈F/200⌉ fact pages + ⌈T/100⌉
|
|
30
|
+
* memory pages + one revoke. **Its ceilings**: the
|
|
30
31
|
* key is ordinary, so at the person's live-key cap or the plan's mint rate
|
|
31
32
|
* the export fails as the mint does (422, 429) and can be retried once a
|
|
32
33
|
* key lapses; it lives five minutes, so a history that takes longer to
|
|
33
34
|
* read fails with a 401; its one micro-credit is set aside like any key's,
|
|
34
35
|
* so an organisation with no balance cannot export (402).
|
|
35
36
|
*/
|
|
36
|
-
import type { EndUserCreateRequest, EndUserDeleted, EndUserInfo, EndUserPage, EndUserUpdateRequest, FactCreateRequest, FactInfo, FactUpdateRequest, ListEndUsersData, SessionDetail } from "../gen/index.js";
|
|
37
|
+
import type { EndUserCreateRequest, EndUserDeleted, EndUserInfo, EndUserPage, EndUserUpdateRequest, FactCreateRequest, FactInfo, FactUpdateRequest, ListEndUserMemoriesData, ListEndUsersData, MemoriesDeleted, MemoryInfo, MemoryPage, SessionDetail } from "../gen/index.js";
|
|
37
38
|
import { type RequestOptions, type Transport } from "../transport.js";
|
|
38
39
|
import type { EphemeralKeys } from "./ephemeral-keys.js";
|
|
39
40
|
import { Editable } from "./resource.js";
|
|
40
41
|
export type EndUserListParams = NonNullable<ListEndUsersData["query"]>;
|
|
42
|
+
export type EndUserMemoryListParams = NonNullable<ListEndUserMemoriesData["query"]>;
|
|
41
43
|
/** An end user `create` answered, and whether this call made them. */
|
|
42
44
|
export type EndUserCreated = EndUserInfo & {
|
|
43
45
|
/**
|
|
@@ -58,6 +60,8 @@ export interface EndUserExport {
|
|
|
58
60
|
sessions: SessionDetail[];
|
|
59
61
|
/** What is remembered about them, oldest first — the newest 100 for now. */
|
|
60
62
|
facts: FactInfo[];
|
|
63
|
+
/** Every topic of their life the agents remember, the topic last talked about first. */
|
|
64
|
+
memories: MemoryInfo[];
|
|
61
65
|
}
|
|
62
66
|
/** A fact `facts.add` answered, and whether this call made it. */
|
|
63
67
|
export type FactAdded = FactInfo & {
|
|
@@ -80,9 +84,31 @@ export interface EndUserFacts {
|
|
|
80
84
|
/** Forgets one: `true`, or `false` when there is none by that id. */
|
|
81
85
|
delete(id: string, factId: string, options?: RequestOptions): Promise<boolean>;
|
|
82
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* `endUsers.memories`: what the agents remember of one person's life, one
|
|
89
|
+
* memory per topic, from your server with no key minted for them —
|
|
90
|
+
* `/v1/end-users/{id}/memories`. Read and forgotten, never written: only
|
|
91
|
+
* a conversation writes one.
|
|
92
|
+
*/
|
|
93
|
+
export interface EndUserMemories {
|
|
94
|
+
/** Every memory, the topic last talked about first, page after page (100 a page by default). */
|
|
95
|
+
list(id: string, params?: Omit<EndUserMemoryListParams, "cursor">, options?: RequestOptions): AsyncGenerator<MemoryInfo, void, undefined>;
|
|
96
|
+
/** One page, with the `next_cursor` of the next. */
|
|
97
|
+
page(id: string, params?: EndUserMemoryListParams, options?: RequestOptions): Promise<MemoryPage>;
|
|
98
|
+
/** One memory. A `NotFoundError` when there is none, or no such person. */
|
|
99
|
+
get(id: string, memoryId: string, options?: RequestOptions): Promise<MemoryInfo>;
|
|
100
|
+
/**
|
|
101
|
+
* Forgets one: `true`, or `false` when there is none by that id. A later
|
|
102
|
+
* conversation about the topic starts a new one.
|
|
103
|
+
*/
|
|
104
|
+
delete(id: string, memoryId: string, options?: RequestOptions): Promise<boolean>;
|
|
105
|
+
/** Forgets every memory of theirs: how many went. Their facts and conversations stay. */
|
|
106
|
+
deleteAll(id: string, options?: RequestOptions): Promise<MemoriesDeleted>;
|
|
107
|
+
}
|
|
83
108
|
export declare class EndUsers extends Editable<EndUserInfo, EndUserUpdateRequest, EndUserInfo, EndUserDeleted | null> {
|
|
84
109
|
private readonly keys;
|
|
85
110
|
readonly facts: EndUserFacts;
|
|
111
|
+
readonly memories: EndUserMemories;
|
|
86
112
|
constructor(api: Transport, base: string, keys: EphemeralKeys);
|
|
87
113
|
/**
|
|
88
114
|
* Makes a person, or finds the one your `external_id` already names.
|
|
@@ -23,10 +23,11 @@
|
|
|
23
23
|
* page), reads each transcript back to its start by `messages.next_cursor`
|
|
24
24
|
* (200 messages a page, four sessions at a time), reads their facts (200
|
|
25
25
|
* a page) — those a later conversation replaced too, which are still held
|
|
26
|
-
* until they are deleted 30 days on — and
|
|
27
|
-
* after an abort or a
|
|
28
|
-
* too. The cost: one mint (and `limits()` when cold) + ⌈S/200⌉
|
|
29
|
-
* Σ⌈M/200⌉ transcript pages + ⌈F/200⌉ fact pages +
|
|
26
|
+
* until they are deleted 30 days on — and their memories (100 a page, the
|
|
27
|
+
* route's most), and revokes the key in `finally` — after an abort or a
|
|
28
|
+
* failure too. The cost: one mint (and `limits()` when cold) + ⌈S/200⌉
|
|
29
|
+
* lists + Σ⌈M/200⌉ transcript pages + ⌈F/200⌉ fact pages + ⌈T/100⌉
|
|
30
|
+
* memory pages + one revoke. **Its ceilings**: the
|
|
30
31
|
* key is ordinary, so at the person's live-key cap or the plan's mint rate
|
|
31
32
|
* the export fails as the mint does (422, 429) and can be retried once a
|
|
32
33
|
* key lapses; it lives five minutes, so a history that takes longer to
|
|
@@ -38,6 +39,8 @@ import { orNull, segment, } from "../transport.js";
|
|
|
38
39
|
import { Editable } from "./resource.js";
|
|
39
40
|
/** The routes' largest page, for end users, sessions and transcripts alike. */
|
|
40
41
|
const PAGE = 200;
|
|
42
|
+
/** The memories' largest page: each carries its topic's whole story. */
|
|
43
|
+
const MEMORY_PAGE = 100;
|
|
41
44
|
/** The export key's lifetime and limit: the shortest useful, the least set aside. */
|
|
42
45
|
const EXPORT_TTL_S = 300;
|
|
43
46
|
const EXPORT_CREDIT_MICROS = 1;
|
|
@@ -68,6 +71,8 @@ export class EndUsers extends Editable {
|
|
|
68
71
|
super(api, base);
|
|
69
72
|
this.keys = keys;
|
|
70
73
|
const fact = (id, factId) => this.at(id, `/facts/${segment(factId)}`);
|
|
74
|
+
/** A `DELETE` of one thing: `true`, or `false` for a 404 — already gone. */
|
|
75
|
+
const drop = (path, options) => orNull(this.send("DELETE", path, options)).then((gone) => gone !== null);
|
|
71
76
|
this.facts = {
|
|
72
77
|
list: (id, params = {}, options) => this.each(this.at(id, "/facts"), params, options, PAGE),
|
|
73
78
|
add: async (id, body, options) => {
|
|
@@ -75,7 +80,15 @@ export class EndUsers extends Editable {
|
|
|
75
80
|
return { ...answer.data, created: answer.status === 201 };
|
|
76
81
|
},
|
|
77
82
|
update: (id, factId, body, options) => this.send("PATCH", fact(id, factId), options, body),
|
|
78
|
-
delete: (id, factId, options) =>
|
|
83
|
+
delete: (id, factId, options) => drop(fact(id, factId), options),
|
|
84
|
+
};
|
|
85
|
+
const memories = (id, rest = "") => this.at(id, `/memories${rest}`);
|
|
86
|
+
this.memories = {
|
|
87
|
+
list: (id, params = {}, options) => this.each(memories(id), params, options, MEMORY_PAGE),
|
|
88
|
+
page: (id, params = {}, options) => this.send("GET", memories(id), options, params),
|
|
89
|
+
get: (id, memoryId, options) => this.send("GET", memories(id, `/${segment(memoryId)}`), options),
|
|
90
|
+
delete: (id, memoryId, options) => drop(memories(id, `/${segment(memoryId)}`), options),
|
|
91
|
+
deleteAll: (id, options) => this.send("DELETE", memories(id), options),
|
|
79
92
|
};
|
|
80
93
|
}
|
|
81
94
|
/**
|
|
@@ -142,7 +155,16 @@ export class EndUsers extends Editable {
|
|
|
142
155
|
cursor,
|
|
143
156
|
include_replaced: true,
|
|
144
157
|
})));
|
|
145
|
-
|
|
158
|
+
const memories = await all(pages((cursor) => read("/v1/agent/memories", {
|
|
159
|
+
limit: MEMORY_PAGE,
|
|
160
|
+
cursor,
|
|
161
|
+
})));
|
|
162
|
+
return {
|
|
163
|
+
end_user_id: key.end_user_id ?? id,
|
|
164
|
+
sessions,
|
|
165
|
+
facts,
|
|
166
|
+
memories,
|
|
167
|
+
};
|
|
146
168
|
}
|
|
147
169
|
finally {
|
|
148
170
|
// Without the caller's signal: an aborted export still revokes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumavox/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "The Lumavox API from your server: end users, ephemeral keys and the rest, typed from the published OpenAPI document. Zero dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"typecheck": "tsc --noEmit && tsc --noEmit -p test"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@biomejs/biome": "2.6.
|
|
44
|
-
"@cloudflare/vitest-plugin": "1.
|
|
45
|
-
"@cloudflare/workers-types": "^5.
|
|
43
|
+
"@biomejs/biome": "2.6.4",
|
|
44
|
+
"@cloudflare/vitest-plugin": "1.5.1",
|
|
45
|
+
"@cloudflare/workers-types": "^5.20261104.1",
|
|
46
46
|
"@hey-api/openapi-ts": "^0.99.0",
|
|
47
47
|
"@types/node": "^24",
|
|
48
|
-
"esbuild": "^0.28.
|
|
48
|
+
"esbuild": "^0.28.2",
|
|
49
49
|
"typescript": "^6",
|
|
50
|
-
"vitest": "^
|
|
50
|
+
"vitest": "^5.1.0"
|
|
51
51
|
}
|
|
52
52
|
}
|