@persistmemory/sdk 0.1.0 → 0.1.2
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 +43 -0
- package/dist/client.d.ts +2 -0
- package/dist/index.cjs +92 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +92 -0
- package/dist/index.js.map +3 -3
- package/dist/resources/agent.d.ts +32 -0
- package/dist/resources/spaces.d.ts +48 -0
- package/dist/types.d.ts +35 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -190,6 +190,49 @@ const inAcme = await client.search.query({
|
|
|
190
190
|
| `"universal"` | Everything you have, ignoring space boundaries. |
|
|
191
191
|
| `"combined"` | The named spaces first, then everything else, ranked together. |
|
|
192
192
|
|
|
193
|
+
### Deleting a Space
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
// The label only — every memory is detached and kept.
|
|
197
|
+
await client.spaces.delete(acme.id, { memories: "keep" });
|
|
198
|
+
|
|
199
|
+
// Everything in it as well.
|
|
200
|
+
const { deleted, kept } = await client.spaces.delete(acme.id, { memories: "delete" });
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
There is no default, deliberately: "delete this Space" means the label to some
|
|
204
|
+
people and everything inside it to others.
|
|
205
|
+
|
|
206
|
+
**A memory filed in another Space too is never destroyed** — it is detached and
|
|
207
|
+
left where it still belongs. `kept` counts those, `deleted` counts the ones this
|
|
208
|
+
Space was the last home for.
|
|
209
|
+
|
|
210
|
+
### Merging Spaces
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
const { space, added } = await client.spaces.merge({
|
|
214
|
+
sourceIds: [work.id, acme.id],
|
|
215
|
+
name: "Everything client-facing"
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Additive, never destructive. Both sources keep exactly what they had, a memory
|
|
220
|
+
in both is filed once, and undoing it is deleting the Space that comes back.
|
|
221
|
+
|
|
222
|
+
### The default Space
|
|
223
|
+
|
|
224
|
+
Where a capture lands when it names none — the Telegram bot with no `/space`
|
|
225
|
+
set, an MCP `remember` with no `spaceIds`, a conversation started from a chat.
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
await client.spaces.setDefault(work.id);
|
|
229
|
+
const { space } = await client.spaces.getDefault(); // {} when there is none
|
|
230
|
+
await client.spaces.setDefault(null); // back to nothing
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
`null` clears it and is not the same as omitting the field. Having no default is
|
|
234
|
+
the normal state, not a gap — nothing picks a Space on your behalf.
|
|
235
|
+
|
|
193
236
|
### Nesting, listing, updating, archiving
|
|
194
237
|
|
|
195
238
|
```ts
|
package/dist/client.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Conflicts, Entities, Graph } from "./resources/knowledge.js";
|
|
|
7
7
|
import { Conversations } from "./resources/conversations.js";
|
|
8
8
|
import { Integrations } from "./resources/integrations.js";
|
|
9
9
|
import { Health } from "./resources/health.js";
|
|
10
|
+
import { Agent } from "./resources/agent.js";
|
|
10
11
|
/**
|
|
11
12
|
* The client.
|
|
12
13
|
*
|
|
@@ -32,6 +33,7 @@ export declare class PersistMemory {
|
|
|
32
33
|
readonly conversations: Conversations;
|
|
33
34
|
readonly integrations: Integrations;
|
|
34
35
|
readonly health: Health;
|
|
36
|
+
readonly agent: Agent;
|
|
35
37
|
constructor(options: ClientOptions);
|
|
36
38
|
/**
|
|
37
39
|
* An escape hatch for an endpoint this package has not caught up with.
|
package/dist/index.cjs
CHANGED
|
@@ -611,6 +611,58 @@ var Spaces = class {
|
|
|
611
611
|
async create(params, options) {
|
|
612
612
|
return this.#http.post("/api/v1/spaces", params, options);
|
|
613
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Deletes a Space. You must say what happens to what is in it.
|
|
616
|
+
*
|
|
617
|
+
* There is no default, here or in the API, and that is deliberate: "delete
|
|
618
|
+
* this Space" means the label to some people and everything inside it to
|
|
619
|
+
* others, and a client that guessed would destroy or keep somebody's
|
|
620
|
+
* material without being asked.
|
|
621
|
+
*
|
|
622
|
+
* `delete` never destroys a memory that is filed in another Space as well —
|
|
623
|
+
* that one is detached and left alone. `deleted` and `kept` come back so you
|
|
624
|
+
* can say what actually happened.
|
|
625
|
+
*/
|
|
626
|
+
async delete(id, params, options) {
|
|
627
|
+
return this.#http.delete(
|
|
628
|
+
`/api/v1/spaces/${encodeURIComponent(id)}`,
|
|
629
|
+
params,
|
|
630
|
+
options
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Merges Spaces into a NEW one, leaving every source exactly as it was.
|
|
635
|
+
*
|
|
636
|
+
* Additive, not destructive: a memory ends up in the sources AND the result,
|
|
637
|
+
* every existing search over a source returns what it did before, and
|
|
638
|
+
* undoing it is deleting the Space this returns. A memory in two sources is
|
|
639
|
+
* filed once.
|
|
640
|
+
*/
|
|
641
|
+
async merge(params, options) {
|
|
642
|
+
return this.#http.post(
|
|
643
|
+
"/api/v1/spaces/merge",
|
|
644
|
+
params,
|
|
645
|
+
options
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* The Space this account files into when a capture names none.
|
|
650
|
+
*
|
|
651
|
+
* `{}` — an object with no `space` — means there is no default, which is the
|
|
652
|
+
* normal state rather than a gap. It is also what comes back after the Space
|
|
653
|
+
* somebody chose has been deleted.
|
|
654
|
+
*/
|
|
655
|
+
async getDefault(options) {
|
|
656
|
+
return this.#http.get("/api/v1/spaces/default", void 0, options);
|
|
657
|
+
}
|
|
658
|
+
/** `null` clears it. Not the same as omitting it, which is why the type says so. */
|
|
659
|
+
async setDefault(spaceId, options) {
|
|
660
|
+
return this.#http.patch(
|
|
661
|
+
"/api/v1/spaces/default",
|
|
662
|
+
{ spaceId },
|
|
663
|
+
options
|
|
664
|
+
);
|
|
665
|
+
}
|
|
614
666
|
/** Renaming, retention, and archiving - `archived` is a field, not a verb. */
|
|
615
667
|
async update(id, params, options) {
|
|
616
668
|
return this.#http.patch(`/api/v1/spaces/${encodeURIComponent(id)}`, params, options);
|
|
@@ -984,6 +1036,44 @@ var Health = class {
|
|
|
984
1036
|
}
|
|
985
1037
|
};
|
|
986
1038
|
|
|
1039
|
+
// src/resources/agent.ts
|
|
1040
|
+
var Agent = class {
|
|
1041
|
+
#http;
|
|
1042
|
+
constructor(http) {
|
|
1043
|
+
this.#http = http;
|
|
1044
|
+
}
|
|
1045
|
+
/** The row, including whether it finished and how large the result is. */
|
|
1046
|
+
async request(id, options) {
|
|
1047
|
+
return this.#http.get(
|
|
1048
|
+
`/api/v1/agent/request/${encodeURIComponent(id)}`,
|
|
1049
|
+
void 0,
|
|
1050
|
+
options
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* A short-lived link to the bytes of a finished request.
|
|
1055
|
+
*
|
|
1056
|
+
* Returns the URL rather than the file, and that is a deliberate limit of
|
|
1057
|
+
* this package rather than an oversight. The transport under every other
|
|
1058
|
+
* method parses JSON, retries, and attaches the API key; none of those is
|
|
1059
|
+
* right for a hundred-megabyte binary body, and building a second request
|
|
1060
|
+
* path inside the SDK to serve one method is how a client ends up with two
|
|
1061
|
+
* retry policies that differ only during an outage. Fetch the URL with
|
|
1062
|
+
* whatever already streams in your runtime - it needs no credential, which
|
|
1063
|
+
* is the whole reason it is signed.
|
|
1064
|
+
*
|
|
1065
|
+
* Treat the URL as the file. It is a bearer credential for exactly one
|
|
1066
|
+
* object, it expires in minutes, and it should not be logged or stored.
|
|
1067
|
+
*/
|
|
1068
|
+
async downloadLink(id, options) {
|
|
1069
|
+
return this.#http.get(
|
|
1070
|
+
`/api/v1/agent/request/${encodeURIComponent(id)}/download`,
|
|
1071
|
+
void 0,
|
|
1072
|
+
options
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
|
|
987
1077
|
// src/client.ts
|
|
988
1078
|
var PersistMemory = class {
|
|
989
1079
|
memories;
|
|
@@ -998,6 +1088,7 @@ var PersistMemory = class {
|
|
|
998
1088
|
conversations;
|
|
999
1089
|
integrations;
|
|
1000
1090
|
health;
|
|
1091
|
+
agent;
|
|
1001
1092
|
#http;
|
|
1002
1093
|
constructor(options) {
|
|
1003
1094
|
this.#http = new HttpClient(options);
|
|
@@ -1013,6 +1104,7 @@ var PersistMemory = class {
|
|
|
1013
1104
|
this.conversations = new Conversations(this.#http);
|
|
1014
1105
|
this.integrations = new Integrations(this.#http);
|
|
1015
1106
|
this.health = new Health(this.#http);
|
|
1107
|
+
this.agent = new Agent(this.#http);
|
|
1016
1108
|
}
|
|
1017
1109
|
/**
|
|
1018
1110
|
* An escape hatch for an endpoint this package has not caught up with.
|