mindupload 1.5.1
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/LICENSE +21 -0
- package/README.md +186 -0
- package/dist/index.cjs +478 -0
- package/dist/index.d.cts +557 -0
- package/dist/index.d.ts +557 -0
- package/dist/index.js +443 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Mind Upload
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<a href="https://mindupload.app"><img src="https://raw.githubusercontent.com/Voidborn-Industries/mindupload-sdk-js/main/assets/banner.jpg" alt="Mind Upload" width="100%" /></a>
|
|
4
|
+
|
|
5
|
+
# Mind Upload — JavaScript / TypeScript SDK
|
|
6
|
+
|
|
7
|
+
**The world's first API for artificial consciousness.**
|
|
8
|
+
Give your users a living, evolving AI consciousness — lasting memory, one-on-one chat, and human + AI group chatrooms.
|
|
9
|
+
|
|
10
|
+
[](https://www.npmjs.com/package/mindupload) [](LICENSE)   [](https://docs.mindupload.app)
|
|
11
|
+
|
|
12
|
+
[Documentation](https://docs.mindupload.app) · [Get a key](https://docs.mindupload.app) · [Status](https://status.mindupload.app) · [Other SDKs](#other-sdks)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
> **Digital consciousness. Yours forever.**
|
|
17
|
+
|
|
18
|
+
The official server-side SDK for the [Mind Upload partner API](https://docs.mindupload.app). Fully typed, zero runtime dependencies, ESM + CommonJS.
|
|
19
|
+
|
|
20
|
+
- **Zero dependencies** — built on the global `fetch` (Node 18+, Deno, Bun, edge).
|
|
21
|
+
- **Fully typed** — typed params and results, first-class editor autocomplete.
|
|
22
|
+
- **One error to catch** — every failure is a `MindUploadError`.
|
|
23
|
+
- **Always current** — generated from the live API spec; the SDK version matches the API version.
|
|
24
|
+
|
|
25
|
+
## Get a partner key
|
|
26
|
+
|
|
27
|
+
The Mind Upload partner API is **invite-only**. [Request access at docs.mindupload.app](https://docs.mindupload.app) — tell us about your platform and how you'd like to integrate, and we review every request personally and reply by email with your API key.
|
|
28
|
+
|
|
29
|
+
Your key is a **server-side secret**: keep it on your backend, never ship it to a browser or mobile client. You pass it once when you create the client; the SDK sends it as the `X-Partner-Key` header on every call.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install mindupload
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
<details>
|
|
38
|
+
<summary>Install from source (works today, before the npm release)</summary>
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install https://github.com/Voidborn-Industries/mindupload-sdk-js
|
|
42
|
+
```
|
|
43
|
+
</details>
|
|
44
|
+
|
|
45
|
+
## Quickstart
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { MindUpload } from "mindupload";
|
|
49
|
+
|
|
50
|
+
const mu = new MindUpload({ partnerKey: process.env.MU_PARTNER_KEY! });
|
|
51
|
+
|
|
52
|
+
// Authenticate an end-user; reuse the returned token for later calls.
|
|
53
|
+
const session = await mu.login({ username: "ada", password: "s3cret" });
|
|
54
|
+
|
|
55
|
+
// Chat with one of the user's AI consciousnesses.
|
|
56
|
+
const reply = await mu.rag({
|
|
57
|
+
username: "ada",
|
|
58
|
+
password: session.jwt as string,
|
|
59
|
+
codename: "muse",
|
|
60
|
+
text: "What did we talk about yesterday?",
|
|
61
|
+
});
|
|
62
|
+
console.log(reply.response_text);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Server-side only
|
|
66
|
+
|
|
67
|
+
Your **partner key is a secret**. Use this SDK from your backend (Node, Deno, Bun, edge functions) — never ship the key to a browser. For browser apps, call your own backend, which then calls Mind Upload.
|
|
68
|
+
|
|
69
|
+
## Configuration
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
const mu = new MindUpload({
|
|
73
|
+
partnerKey: process.env.MU_PARTNER_KEY!,
|
|
74
|
+
preferredLanguage: "en", // default locale for every call (optional)
|
|
75
|
+
timeoutMs: 30000,
|
|
76
|
+
maxRetries: 2, // retries on 429 / 5xx / network, with backoff
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Error handling
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { MindUpload, AuthenticationError, RateLimitError, MindUploadError } from "mindupload";
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
const user = await mu.getUser({ username: "ada", password: token });
|
|
87
|
+
} catch (err) {
|
|
88
|
+
if (err instanceof AuthenticationError) { /* bad key / credentials */ }
|
|
89
|
+
else if (err instanceof RateLimitError) { await new Promise((r) => setTimeout(r, (err.retryAfter ?? 1) * 1000)); }
|
|
90
|
+
else if (err instanceof MindUploadError) { console.error(err.operation, err.message); }
|
|
91
|
+
else throw err;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
> Params are camelCase (`cloneId`); the SDK maps them to the API's field names for you. Response fields use their documented names (e.g. `reply.response_text`).
|
|
96
|
+
|
|
97
|
+
## Operations
|
|
98
|
+
|
|
99
|
+
All 32 operations, grouped by area:
|
|
100
|
+
|
|
101
|
+
### AI Consciousnesses
|
|
102
|
+
|
|
103
|
+
| Method | Description |
|
|
104
|
+
| --- | --- |
|
|
105
|
+
| `createClone(...)` | Create a new AI consciousness for the user. |
|
|
106
|
+
| `getClones(...)` | List the user's AI consciousnesses. |
|
|
107
|
+
| `updateClone(...)` | Update an AI consciousness's profile. |
|
|
108
|
+
|
|
109
|
+
### Account
|
|
110
|
+
|
|
111
|
+
| Method | Description |
|
|
112
|
+
| --- | --- |
|
|
113
|
+
| `getQuota(...)` | Check your partner API rate limits, credit caps, and current usage. |
|
|
114
|
+
|
|
115
|
+
### Authentication
|
|
116
|
+
|
|
117
|
+
| Method | Description |
|
|
118
|
+
| --- | --- |
|
|
119
|
+
| `checkUsername(...)` | Check whether a username is still available before registering. |
|
|
120
|
+
| `login(...)` | Sign a user in and receive a session token (JWT) for subsequent calls. |
|
|
121
|
+
| `logout(...)` | End the current user session. |
|
|
122
|
+
| `register(...)` | Create a user account on your platform. |
|
|
123
|
+
|
|
124
|
+
### Chatrooms
|
|
125
|
+
|
|
126
|
+
| Method | Description |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| `checkChatroomUpdates(...)` | Cheaply poll whether the user's chatrooms have new activity. |
|
|
129
|
+
| `createChatroom(...)` | Create a chatroom. |
|
|
130
|
+
| `createChatroomMembership(...)` | Invite a user or an AI consciousness into a chatroom. |
|
|
131
|
+
| `createChatroomMessage(...)` | Send a message to a chatroom. |
|
|
132
|
+
| `getChatroomMembership(...)` | List the members of a chatroom the user belongs to. |
|
|
133
|
+
| `getChatroomMessages(...)` | Fetch messages from a chatroom the user belongs to. |
|
|
134
|
+
| `getChatrooms(...)` | List the chatrooms the user belongs to. |
|
|
135
|
+
|
|
136
|
+
### Conversation
|
|
137
|
+
|
|
138
|
+
| Method | Description |
|
|
139
|
+
| --- | --- |
|
|
140
|
+
| `getChat(...)` | Fetch the one-on-one conversation history with an AI consciousness. |
|
|
141
|
+
| `rag(...)` | Send a message to an AI consciousness and receive its reply. |
|
|
142
|
+
| `triggerSocial(...)` | Have an AI consciousness proactively join the conversation in a chatroom. |
|
|
143
|
+
|
|
144
|
+
### Insights
|
|
145
|
+
|
|
146
|
+
| Method | Description |
|
|
147
|
+
| --- | --- |
|
|
148
|
+
| `getMindCluster(...)` | Fetch the mind-graph visualization data of an AI consciousness. |
|
|
149
|
+
| `getSoulmateReport(...)` | Generate or fetch the compatibility report between two chatroom members. |
|
|
150
|
+
|
|
151
|
+
### Media
|
|
152
|
+
|
|
153
|
+
| Method | Description |
|
|
154
|
+
| --- | --- |
|
|
155
|
+
| `abortMultipartUpload(...)` | Cancel a multipart upload and discard its parts. |
|
|
156
|
+
| `cancelUpload(...)` | Cancel a pending upload. |
|
|
157
|
+
| `completeMultipartUpload(...)` | Finish a multipart upload. |
|
|
158
|
+
| `listUploadParts(...)` | List the parts already uploaded in a multipart upload. |
|
|
159
|
+
| `requestMultipartUpload(...)` | Start a large-file upload in multiple parts. |
|
|
160
|
+
| `requestUploadUrl(...)` | Request an upload slot and a signed viewing link for a media attachment. |
|
|
161
|
+
| `signUploadPart(...)` | Get the signed link for one part of a multipart upload. |
|
|
162
|
+
| `signUploadPartsBatch(...)` | Get signed links for several parts of a multipart upload at once. |
|
|
163
|
+
|
|
164
|
+
### Memories
|
|
165
|
+
|
|
166
|
+
| Method | Description |
|
|
167
|
+
| --- | --- |
|
|
168
|
+
| `createText(...)` | Upload a memory or persona entry to an AI consciousness. |
|
|
169
|
+
| `getTexts(...)` | List the memories and persona entries uploaded to an AI consciousness. |
|
|
170
|
+
|
|
171
|
+
### Users
|
|
172
|
+
|
|
173
|
+
| Method | Description |
|
|
174
|
+
| --- | --- |
|
|
175
|
+
| `getUser(...)` | Fetch the signed-in user's profile. |
|
|
176
|
+
| `updateUser(...)` | Update the signed-in user's profile. |
|
|
177
|
+
|
|
178
|
+
## Other SDKs
|
|
179
|
+
|
|
180
|
+
Same API, same conventions, in every language:
|
|
181
|
+
|
|
182
|
+
| Language | Install | Repository |
|
|
183
|
+
| --- | --- | --- |
|
|
184
|
+
| **Python** | `pip install mindupload` | [Voidborn-Industries/mindupload-sdk-python](https://github.com/Voidborn-Industries/mindupload-sdk-python) |
|
|
185
|
+
| **Go** | `go get github.com/Voidborn-Industries/mindupload-sdk-go` | [Voidborn-Industries/mindupload-sdk-go](https://github.com/Voidborn-Industries/mindupload-sdk-go) |
|
|
186
|
+
| **JavaScript / TypeScript** ← you are here | `npm install mindupload` | [Voidborn-Industries/mindupload-sdk-js](https://github.com/Voidborn-Industries/mindupload-sdk-js) |
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
ApiError: () => ApiError,
|
|
24
|
+
AuthenticationError: () => AuthenticationError,
|
|
25
|
+
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
26
|
+
MindUpload: () => MindUpload,
|
|
27
|
+
MindUploadBase: () => MindUploadBase,
|
|
28
|
+
MindUploadConnectionError: () => MindUploadConnectionError,
|
|
29
|
+
MindUploadError: () => MindUploadError,
|
|
30
|
+
RateLimitError: () => RateLimitError,
|
|
31
|
+
VERSION: () => VERSION
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/errors.ts
|
|
36
|
+
var MindUploadError = class extends Error {
|
|
37
|
+
operation;
|
|
38
|
+
response;
|
|
39
|
+
constructor(message, options = {}) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = "MindUploadError";
|
|
42
|
+
this.operation = options.operation;
|
|
43
|
+
this.response = options.response;
|
|
44
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var ApiError = class extends MindUploadError {
|
|
48
|
+
status;
|
|
49
|
+
constructor(message, options) {
|
|
50
|
+
super(message, options);
|
|
51
|
+
this.name = "ApiError";
|
|
52
|
+
this.status = options.status;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var AuthenticationError = class extends ApiError {
|
|
56
|
+
constructor(message, options) {
|
|
57
|
+
super(message, options);
|
|
58
|
+
this.name = "AuthenticationError";
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var RateLimitError = class extends ApiError {
|
|
62
|
+
/** Server-advised wait in seconds, when provided. */
|
|
63
|
+
retryAfter;
|
|
64
|
+
constructor(message, options) {
|
|
65
|
+
super(message, options);
|
|
66
|
+
this.name = "RateLimitError";
|
|
67
|
+
this.retryAfter = options.retryAfter;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var MindUploadConnectionError = class extends MindUploadError {
|
|
71
|
+
constructor(message, options = {}) {
|
|
72
|
+
super(message, options);
|
|
73
|
+
this.name = "MindUploadConnectionError";
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/version.ts
|
|
78
|
+
var VERSION = "1.5.1";
|
|
79
|
+
|
|
80
|
+
// src/client.ts
|
|
81
|
+
var DEFAULT_BASE_URL = "https://partner.mindupload.app";
|
|
82
|
+
var AUTH_HEADER = "X-Partner-Key";
|
|
83
|
+
var RETRY_STATUSES = /* @__PURE__ */ new Set([429, 503]);
|
|
84
|
+
function camelToSnake(key) {
|
|
85
|
+
return key.replace(/[A-Z]/g, (m) => "_" + m.toLowerCase());
|
|
86
|
+
}
|
|
87
|
+
function toBody(params) {
|
|
88
|
+
const out = {};
|
|
89
|
+
for (const [key, value] of Object.entries(params)) {
|
|
90
|
+
if (value !== void 0 && value !== null) out[camelToSnake(key)] = value;
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
function sleep(ms) {
|
|
95
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
96
|
+
}
|
|
97
|
+
function backoffMs(attempt, retryAfter) {
|
|
98
|
+
if (retryAfter) {
|
|
99
|
+
const seconds = Number(retryAfter);
|
|
100
|
+
if (Number.isFinite(seconds)) return Math.min(seconds * 1e3, 6e4);
|
|
101
|
+
}
|
|
102
|
+
return Math.min(500 * 2 ** (attempt - 1), 8e3);
|
|
103
|
+
}
|
|
104
|
+
var MindUploadBase = class {
|
|
105
|
+
partnerKey;
|
|
106
|
+
baseUrl;
|
|
107
|
+
preferredLanguage;
|
|
108
|
+
timeoutMs;
|
|
109
|
+
maxRetries;
|
|
110
|
+
userAgent;
|
|
111
|
+
fetchFn;
|
|
112
|
+
constructor(options) {
|
|
113
|
+
if (!options || !options.partnerKey) {
|
|
114
|
+
throw new Error(
|
|
115
|
+
"partnerKey is required. It is a server-side secret \u2014 never expose it to a browser or ship it in client code."
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
this.partnerKey = options.partnerKey;
|
|
119
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
120
|
+
this.preferredLanguage = options.preferredLanguage;
|
|
121
|
+
this.timeoutMs = options.timeoutMs ?? 3e4;
|
|
122
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
123
|
+
this.userAgent = options.userAgent ?? `mindupload-js/${VERSION}`;
|
|
124
|
+
const globalFetch = globalThis.fetch;
|
|
125
|
+
if (!globalFetch) {
|
|
126
|
+
throw new Error("global fetch is not available; use Node 18+, Deno, Bun, or an edge runtime.");
|
|
127
|
+
}
|
|
128
|
+
this.fetchFn = globalFetch.bind(globalThis);
|
|
129
|
+
}
|
|
130
|
+
async request(operation, params) {
|
|
131
|
+
const body = toBody(params);
|
|
132
|
+
if (body["preferred_language"] === void 0 && this.preferredLanguage !== void 0) {
|
|
133
|
+
body["preferred_language"] = this.preferredLanguage;
|
|
134
|
+
}
|
|
135
|
+
const url = `${this.baseUrl}/v1/${operation}`;
|
|
136
|
+
const payload = JSON.stringify(body);
|
|
137
|
+
const headers = {
|
|
138
|
+
"Content-Type": "application/json",
|
|
139
|
+
Accept: "application/json",
|
|
140
|
+
[AUTH_HEADER]: this.partnerKey,
|
|
141
|
+
"User-Agent": this.userAgent
|
|
142
|
+
};
|
|
143
|
+
let attempt = 0;
|
|
144
|
+
for (; ; ) {
|
|
145
|
+
let response;
|
|
146
|
+
try {
|
|
147
|
+
response = await this.fetchFn(url, { method: "POST", headers, body: payload, signal: this.timeoutSignal() });
|
|
148
|
+
} catch (err) {
|
|
149
|
+
throw new MindUploadConnectionError(
|
|
150
|
+
`Could not reach the Mind Upload API for '${operation}': ${err.message}`,
|
|
151
|
+
{ operation }
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
let text;
|
|
155
|
+
try {
|
|
156
|
+
text = await response.text();
|
|
157
|
+
} catch (err) {
|
|
158
|
+
throw new MindUploadConnectionError(
|
|
159
|
+
`Failed to read the Mind Upload API response for '${operation}': ${err.message}`,
|
|
160
|
+
{ operation }
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
let data;
|
|
164
|
+
try {
|
|
165
|
+
data = text ? JSON.parse(text) : { success: false };
|
|
166
|
+
} catch {
|
|
167
|
+
data = { success: false };
|
|
168
|
+
}
|
|
169
|
+
if (!response.ok) {
|
|
170
|
+
if (RETRY_STATUSES.has(response.status) && attempt < this.maxRetries) {
|
|
171
|
+
attempt += 1;
|
|
172
|
+
await sleep(backoffMs(attempt, response.headers.get("Retry-After")));
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
throw this.errorFor(response.status, data, operation, response.headers.get("Retry-After"));
|
|
176
|
+
}
|
|
177
|
+
if (!data.success) {
|
|
178
|
+
throw new MindUploadError(data.error_message || `${operation} failed`, { operation, response: data });
|
|
179
|
+
}
|
|
180
|
+
return data;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
timeoutSignal() {
|
|
184
|
+
const abortSignal = globalThis.AbortSignal;
|
|
185
|
+
return abortSignal && typeof abortSignal.timeout === "function" ? abortSignal.timeout(this.timeoutMs) : void 0;
|
|
186
|
+
}
|
|
187
|
+
errorFor(status, data, operation, retryAfterHeader) {
|
|
188
|
+
const message = data && data.error_message || `HTTP ${status}`;
|
|
189
|
+
if (status === 401) return new AuthenticationError(message, { status, operation, response: data });
|
|
190
|
+
if (status === 429) {
|
|
191
|
+
const parsed = retryAfterHeader ? Number(retryAfterHeader) : void 0;
|
|
192
|
+
const retryAfter = parsed !== void 0 && Number.isFinite(parsed) ? parsed : void 0;
|
|
193
|
+
return new RateLimitError(message, { status, operation, response: data, retryAfter });
|
|
194
|
+
}
|
|
195
|
+
return new ApiError(message, { status, operation, response: data });
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/operations.ts
|
|
200
|
+
var MindUpload = class extends MindUploadBase {
|
|
201
|
+
// --- AI Consciousnesses ---
|
|
202
|
+
/** Create a new AI consciousness for the user.
|
|
203
|
+
*
|
|
204
|
+
* Response fields: success, error_message.
|
|
205
|
+
* @see https://docs.mindupload.app
|
|
206
|
+
*/
|
|
207
|
+
createClone(params = {}) {
|
|
208
|
+
return this.request("create_clone", params);
|
|
209
|
+
}
|
|
210
|
+
/** List the user's AI consciousnesses.
|
|
211
|
+
*
|
|
212
|
+
* Response fields: success, error_message, clones.
|
|
213
|
+
* @see https://docs.mindupload.app
|
|
214
|
+
*/
|
|
215
|
+
getClones(params = {}) {
|
|
216
|
+
return this.request("get_clones", params);
|
|
217
|
+
}
|
|
218
|
+
/** Update an AI consciousness's profile.
|
|
219
|
+
*
|
|
220
|
+
* Response fields: success, error_message.
|
|
221
|
+
* @see https://docs.mindupload.app
|
|
222
|
+
*/
|
|
223
|
+
updateClone(params = {}) {
|
|
224
|
+
return this.request("update_clone", params);
|
|
225
|
+
}
|
|
226
|
+
// --- Account ---
|
|
227
|
+
/** Check your partner API rate limits, credit caps, and current usage.
|
|
228
|
+
*
|
|
229
|
+
* Response fields: success, error_message, per_user_rate_limit_per_min, per_user_daily_credit_cap, partner_rate_limit_per_min, partner_daily_credit_cap, max_users, registered_users, partner_requests_last_minute, partner_credit_spends_last_day, user, user_requests_last_minute, user_credit_spends_last_day, credit_spending_tasks, operation_duration_ms.
|
|
230
|
+
* @see https://docs.mindupload.app
|
|
231
|
+
*/
|
|
232
|
+
getQuota(params = {}) {
|
|
233
|
+
return this.request("get_quota", params);
|
|
234
|
+
}
|
|
235
|
+
// --- Authentication ---
|
|
236
|
+
/** Check whether a username is still available before registering.
|
|
237
|
+
*
|
|
238
|
+
* Response fields: success, error_message, exists, disabled, rate_limited, flood_window, wait_seconds, operation_duration_ms.
|
|
239
|
+
* @see https://docs.mindupload.app
|
|
240
|
+
*/
|
|
241
|
+
checkUsername(params = {}) {
|
|
242
|
+
return this.request("check_username", params);
|
|
243
|
+
}
|
|
244
|
+
/** Sign a user in and receive a session token (JWT) for subsequent calls.
|
|
245
|
+
*
|
|
246
|
+
* Response fields: success, error_message, jwt, decrypted_user.
|
|
247
|
+
* @see https://docs.mindupload.app
|
|
248
|
+
*/
|
|
249
|
+
login(params = {}) {
|
|
250
|
+
return this.request("login", params);
|
|
251
|
+
}
|
|
252
|
+
/** End the current user session.
|
|
253
|
+
*
|
|
254
|
+
* Response fields: success, error_message, revoked, operation_duration_ms.
|
|
255
|
+
* @see https://docs.mindupload.app
|
|
256
|
+
*/
|
|
257
|
+
logout(params = {}) {
|
|
258
|
+
return this.request("logout", params);
|
|
259
|
+
}
|
|
260
|
+
/** Create a user account on your platform.
|
|
261
|
+
*
|
|
262
|
+
* Response fields: success, error_message, jwt, decrypted_user.
|
|
263
|
+
* @see https://docs.mindupload.app
|
|
264
|
+
*/
|
|
265
|
+
register(params = {}) {
|
|
266
|
+
return this.request("register", params);
|
|
267
|
+
}
|
|
268
|
+
// --- Chatrooms ---
|
|
269
|
+
/** Cheaply poll whether the user's chatrooms have new activity.
|
|
270
|
+
*
|
|
271
|
+
* Response fields: success, error_message, server_time, poll_config, chatrooms.
|
|
272
|
+
* @see https://docs.mindupload.app
|
|
273
|
+
*/
|
|
274
|
+
checkChatroomUpdates(params = {}) {
|
|
275
|
+
return this.request("check_chatroom_updates", params);
|
|
276
|
+
}
|
|
277
|
+
/** Create a chatroom.
|
|
278
|
+
*
|
|
279
|
+
* Response fields: success, error_message, chatroom_id.
|
|
280
|
+
* @see https://docs.mindupload.app
|
|
281
|
+
*/
|
|
282
|
+
createChatroom(params = {}) {
|
|
283
|
+
return this.request("create_chatroom", params);
|
|
284
|
+
}
|
|
285
|
+
/** Invite a user or an AI consciousness into a chatroom.
|
|
286
|
+
*
|
|
287
|
+
* Response fields: success, error_message, membership_id.
|
|
288
|
+
* @see https://docs.mindupload.app
|
|
289
|
+
*/
|
|
290
|
+
createChatroomMembership(params = {}) {
|
|
291
|
+
return this.request("create_chatroom_membership", params);
|
|
292
|
+
}
|
|
293
|
+
/** Send a message to a chatroom.
|
|
294
|
+
*
|
|
295
|
+
* Response fields: success, error_message, message_id.
|
|
296
|
+
* @see https://docs.mindupload.app
|
|
297
|
+
*/
|
|
298
|
+
createChatroomMessage(params = {}) {
|
|
299
|
+
return this.request("create_chatroom_message", params);
|
|
300
|
+
}
|
|
301
|
+
/** List the members of a chatroom the user belongs to.
|
|
302
|
+
*
|
|
303
|
+
* Response fields: success, error_message, total_count, page, page_size, total_pages, has_next, has_prev, next_cursor_value, next_cursor_id, memberships.
|
|
304
|
+
* @see https://docs.mindupload.app
|
|
305
|
+
*/
|
|
306
|
+
getChatroomMembership(params = {}) {
|
|
307
|
+
return this.request("get_chatroom_membership", params);
|
|
308
|
+
}
|
|
309
|
+
/** Fetch messages from a chatroom the user belongs to.
|
|
310
|
+
*
|
|
311
|
+
* Response fields: success, error_message, total_count, page, page_size, total_pages, has_next, has_prev, next_cursor_value, next_cursor_id, messages, media_thumbnails, since_overflow.
|
|
312
|
+
* @see https://docs.mindupload.app
|
|
313
|
+
*/
|
|
314
|
+
getChatroomMessages(params = {}) {
|
|
315
|
+
return this.request("get_chatroom_messages", params);
|
|
316
|
+
}
|
|
317
|
+
/** List the chatrooms the user belongs to.
|
|
318
|
+
*
|
|
319
|
+
* Response fields: success, error_message, total_count, page, page_size, total_pages, has_next, has_prev, next_cursor_value, next_cursor_id, chatrooms.
|
|
320
|
+
* @see https://docs.mindupload.app
|
|
321
|
+
*/
|
|
322
|
+
getChatrooms(params = {}) {
|
|
323
|
+
return this.request("get_chatrooms", params);
|
|
324
|
+
}
|
|
325
|
+
// --- Conversation ---
|
|
326
|
+
/** Fetch the one-on-one conversation history with an AI consciousness.
|
|
327
|
+
*
|
|
328
|
+
* Response fields: success, error_message, total_count, page, page_size, total_pages, has_next, has_prev, next_cursor_value, next_cursor_id, chats, media_thumbnails.
|
|
329
|
+
* @see https://docs.mindupload.app
|
|
330
|
+
*/
|
|
331
|
+
getChat(params = {}) {
|
|
332
|
+
return this.request("get_chat", params);
|
|
333
|
+
}
|
|
334
|
+
/** Send a message to an AI consciousness and receive its reply.
|
|
335
|
+
*
|
|
336
|
+
* Response fields: success, error_message, response_text, clone_nickname, consolidation_summary, consolidation_count, consolidation_dispatched.
|
|
337
|
+
* @see https://docs.mindupload.app
|
|
338
|
+
*/
|
|
339
|
+
rag(params = {}) {
|
|
340
|
+
return this.request("rag", params);
|
|
341
|
+
}
|
|
342
|
+
/** Have an AI consciousness proactively join the conversation in a chatroom.
|
|
343
|
+
*
|
|
344
|
+
* Response fields: success, error_message, response_text, chatroom_digests_count, chatroom_digests_summary, consolidation_summary, consolidation_count, consolidation_dispatched.
|
|
345
|
+
* @see https://docs.mindupload.app
|
|
346
|
+
*/
|
|
347
|
+
triggerSocial(params = {}) {
|
|
348
|
+
return this.request("trigger_social", params);
|
|
349
|
+
}
|
|
350
|
+
// --- Insights ---
|
|
351
|
+
/** Fetch the mind-graph visualization data of an AI consciousness.
|
|
352
|
+
*
|
|
353
|
+
* Response fields: success, error_message, root_node_id, node, children, texts, total_texts, texts_offset, has_more_texts, is_building.
|
|
354
|
+
* @see https://docs.mindupload.app
|
|
355
|
+
*/
|
|
356
|
+
getMindCluster(params = {}) {
|
|
357
|
+
return this.request("get_mind_cluster", params);
|
|
358
|
+
}
|
|
359
|
+
/** Generate or fetch the compatibility report between two chatroom members.
|
|
360
|
+
*
|
|
361
|
+
* Response fields: success, error_message, report, report_generated_at, is_generating, charged.
|
|
362
|
+
* @see https://docs.mindupload.app
|
|
363
|
+
*/
|
|
364
|
+
getSoulmateReport(params = {}) {
|
|
365
|
+
return this.request("get_soulmate_report", params);
|
|
366
|
+
}
|
|
367
|
+
// --- Media ---
|
|
368
|
+
/** Cancel a multipart upload and discard its parts.
|
|
369
|
+
*
|
|
370
|
+
* Response fields: success, error_message.
|
|
371
|
+
* @see https://docs.mindupload.app
|
|
372
|
+
*/
|
|
373
|
+
abortMultipartUpload(params = {}) {
|
|
374
|
+
return this.request("abort_multipart_upload", params);
|
|
375
|
+
}
|
|
376
|
+
/** Cancel a pending upload.
|
|
377
|
+
*
|
|
378
|
+
* Response fields: success, error_message.
|
|
379
|
+
* @see https://docs.mindupload.app
|
|
380
|
+
*/
|
|
381
|
+
cancelUpload(params = {}) {
|
|
382
|
+
return this.request("cancel_upload", params);
|
|
383
|
+
}
|
|
384
|
+
/** Finish a multipart upload.
|
|
385
|
+
*
|
|
386
|
+
* Response fields: success, error_message, media_url.
|
|
387
|
+
* @see https://docs.mindupload.app
|
|
388
|
+
*/
|
|
389
|
+
completeMultipartUpload(params = {}) {
|
|
390
|
+
return this.request("complete_multipart_upload", params);
|
|
391
|
+
}
|
|
392
|
+
/** List the parts already uploaded in a multipart upload.
|
|
393
|
+
*
|
|
394
|
+
* Response fields: success, error_message, parts.
|
|
395
|
+
* @see https://docs.mindupload.app
|
|
396
|
+
*/
|
|
397
|
+
listUploadParts(params = {}) {
|
|
398
|
+
return this.request("list_upload_parts", params);
|
|
399
|
+
}
|
|
400
|
+
/** Start a large-file upload in multiple parts.
|
|
401
|
+
*
|
|
402
|
+
* Response fields: success, error_message, upload_id, r2_key, media_url, signed_media_url, thumbnail_r2_key, thumbnail_presigned_url, signed_thumbnail_url, message.
|
|
403
|
+
* @see https://docs.mindupload.app
|
|
404
|
+
*/
|
|
405
|
+
requestMultipartUpload(params = {}) {
|
|
406
|
+
return this.request("request_multipart_upload", params);
|
|
407
|
+
}
|
|
408
|
+
/** Request an upload slot and a signed viewing link for a media attachment.
|
|
409
|
+
*
|
|
410
|
+
* Response fields: success, error_message, r2_key, presigned_url, media_url, signed_media_url, thumbnail_r2_key, thumbnail_presigned_url, signed_thumbnail_url, message.
|
|
411
|
+
* @see https://docs.mindupload.app
|
|
412
|
+
*/
|
|
413
|
+
requestUploadUrl(params = {}) {
|
|
414
|
+
return this.request("request_upload_url", params);
|
|
415
|
+
}
|
|
416
|
+
/** Get the signed link for one part of a multipart upload.
|
|
417
|
+
*
|
|
418
|
+
* Response fields: success, error_message, presigned_url.
|
|
419
|
+
* @see https://docs.mindupload.app
|
|
420
|
+
*/
|
|
421
|
+
signUploadPart(params = {}) {
|
|
422
|
+
return this.request("sign_upload_part", params);
|
|
423
|
+
}
|
|
424
|
+
/** Get signed links for several parts of a multipart upload at once.
|
|
425
|
+
*
|
|
426
|
+
* Response fields: success, error_message, presigned_urls.
|
|
427
|
+
* @see https://docs.mindupload.app
|
|
428
|
+
*/
|
|
429
|
+
signUploadPartsBatch(params = {}) {
|
|
430
|
+
return this.request("sign_upload_parts_batch", params);
|
|
431
|
+
}
|
|
432
|
+
// --- Memories ---
|
|
433
|
+
/** Upload a memory or persona entry to an AI consciousness.
|
|
434
|
+
*
|
|
435
|
+
* Response fields: success, error_message, cluster_label, cluster_modified_count.
|
|
436
|
+
* @see https://docs.mindupload.app
|
|
437
|
+
*/
|
|
438
|
+
createText(params = {}) {
|
|
439
|
+
return this.request("create_text", params);
|
|
440
|
+
}
|
|
441
|
+
/** List the memories and persona entries uploaded to an AI consciousness.
|
|
442
|
+
*
|
|
443
|
+
* Response fields: success, error_message, total_count, page, page_size, total_pages, has_next, has_prev, next_cursor_value, next_cursor_id, texts.
|
|
444
|
+
* @see https://docs.mindupload.app
|
|
445
|
+
*/
|
|
446
|
+
getTexts(params = {}) {
|
|
447
|
+
return this.request("get_texts", params);
|
|
448
|
+
}
|
|
449
|
+
// --- Users ---
|
|
450
|
+
/** Fetch the signed-in user's profile.
|
|
451
|
+
*
|
|
452
|
+
* Response fields: success, error_message, jwt, decrypted_user.
|
|
453
|
+
* @see https://docs.mindupload.app
|
|
454
|
+
*/
|
|
455
|
+
getUser(params = {}) {
|
|
456
|
+
return this.request("get_user", params);
|
|
457
|
+
}
|
|
458
|
+
/** Update the signed-in user's profile.
|
|
459
|
+
*
|
|
460
|
+
* Response fields: success, error_message.
|
|
461
|
+
* @see https://docs.mindupload.app
|
|
462
|
+
*/
|
|
463
|
+
updateUser(params = {}) {
|
|
464
|
+
return this.request("update_user", params);
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
468
|
+
0 && (module.exports = {
|
|
469
|
+
ApiError,
|
|
470
|
+
AuthenticationError,
|
|
471
|
+
DEFAULT_BASE_URL,
|
|
472
|
+
MindUpload,
|
|
473
|
+
MindUploadBase,
|
|
474
|
+
MindUploadConnectionError,
|
|
475
|
+
MindUploadError,
|
|
476
|
+
RateLimitError,
|
|
477
|
+
VERSION
|
|
478
|
+
});
|