memax-sdk 0.7.0 → 0.8.0-alpha.212
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 +80 -30
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -1
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/notifications/items.d.ts +6 -0
- package/dist/notifications/items.d.ts.map +1 -1
- package/dist/notifications/items.js.map +1 -1
- package/dist/resources/auth.d.ts +55 -5
- package/dist/resources/auth.d.ts.map +1 -1
- package/dist/resources/auth.js +129 -8
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/boards.d.ts +19 -2
- package/dist/resources/boards.d.ts.map +1 -1
- package/dist/resources/boards.js +27 -2
- package/dist/resources/boards.js.map +1 -1
- package/dist/resources/memories.d.ts +8 -1
- package/dist/resources/memories.d.ts.map +1 -1
- package/dist/resources/memories.js +22 -3
- package/dist/resources/memories.js.map +1 -1
- package/dist/resources/notifications.d.ts +12 -11
- package/dist/resources/notifications.d.ts.map +1 -1
- package/dist/resources/notifications.js +3 -3
- package/dist/resources/notifications.js.map +1 -1
- package/dist/transport.d.ts +50 -5
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +222 -0
- package/dist/transport.js.map +1 -1
- package/dist/types.d.ts +215 -25
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/v2/export.d.ts +310 -0
- package/dist/v2/export.d.ts.map +1 -0
- package/dist/v2/export.js +517 -0
- package/dist/v2/export.js.map +1 -0
- package/dist/v2/resources.d.ts +831 -0
- package/dist/v2/resources.d.ts.map +1 -0
- package/dist/v2/resources.js +1269 -0
- package/dist/v2/resources.js.map +1 -0
- package/dist/v2/schema.gen.d.ts +10594 -0
- package/dist/v2/schema.gen.d.ts.map +1 -0
- package/dist/v2/schema.gen.js +7 -0
- package/dist/v2/schema.gen.js.map +1 -0
- package/dist/v2/sse.d.ts +31 -0
- package/dist/v2/sse.d.ts.map +1 -0
- package/dist/v2/sse.js +151 -0
- package/dist/v2/sse.js.map +1 -0
- package/dist/v2/types.d.ts +375 -0
- package/dist/v2/types.d.ts.map +1 -0
- package/dist/v2/types.js +2 -0
- package/dist/v2/types.js.map +1 -0
- package/dist/v2/verify.d.ts +96 -0
- package/dist/v2/verify.d.ts.map +1 -0
- package/dist/v2/verify.js +375 -0
- package/dist/v2/verify.js.map +1 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -43,25 +43,22 @@ const memax = new Memax({
|
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
// Push a memory
|
|
46
|
-
await memax.push(
|
|
47
|
-
|
|
48
|
-
tags: ["ops", "db"],
|
|
49
|
-
|
|
46
|
+
await memax.push(
|
|
47
|
+
"Our staging DB is pooled through PgBouncer in transaction mode.",
|
|
48
|
+
{ tags: ["ops", "db"] },
|
|
49
|
+
);
|
|
50
50
|
|
|
51
51
|
// Recall with natural language
|
|
52
|
-
const { memories } = await memax.recall({
|
|
53
|
-
query: "pooling strategy",
|
|
54
|
-
limit: 10,
|
|
55
|
-
});
|
|
52
|
+
const { memories } = await memax.recall("pooling strategy", { limit: 10 });
|
|
56
53
|
|
|
57
54
|
// Ask — grounded answer with citations
|
|
58
|
-
const { answer, citations } = await memax.ask(
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
const { answer, citations } = await memax.ask(
|
|
56
|
+
"What mode does PgBouncer run in for staging?",
|
|
57
|
+
);
|
|
61
58
|
|
|
62
59
|
console.log(answer);
|
|
63
60
|
for (const c of citations) {
|
|
64
|
-
console.log(` ↳ ${c.
|
|
61
|
+
console.log(` ↳ [${c.index}] ${c.memory_id} — ${c.title}`);
|
|
65
62
|
}
|
|
66
63
|
```
|
|
67
64
|
|
|
@@ -70,21 +67,75 @@ for (const c of citations) {
|
|
|
70
67
|
- **`push`** — save content, files, URLs, structured data; idempotent on content hash
|
|
71
68
|
- **`recall`** — vector + lexical hybrid search with optional reranking
|
|
72
69
|
- **`ask`** — AI-synthesized answer from your memory, with citations
|
|
73
|
-
- **`memories.*`** — list, get, update, delete; filter by hub,
|
|
74
|
-
- **`hubs.*`** — create, list, transfer, update members, manage roles
|
|
75
|
-
- **`invites.*`** —
|
|
70
|
+
- **`memories.*`** — list, get, update, delete; filter by hub, kind, topic, date
|
|
71
|
+
- **`hubs.*`** — create, list, transfer, update members, manage roles and invites
|
|
72
|
+
- **`invites.*`** — look up and accept a hub invite
|
|
76
73
|
- **`topics.*`** — inspect auto-generated topic clusters over your memory base
|
|
77
74
|
- **`events.subscribe()`** — live server-sent events: new memories, hub changes, dream completion
|
|
78
|
-
- **`
|
|
79
|
-
- **Typed errors** — `MemaxError` with `code`, `status
|
|
75
|
+
- **`v2.*`** — the `/v2` API: the V2 record, Review, receipts, compiled files, Ask, export (below)
|
|
76
|
+
- **Typed errors** — `MemaxError` with `code`, `status` and getters such as `isRateLimited` for clean client handling
|
|
80
77
|
- **Runtime-portable** — works wherever `fetch` works
|
|
81
78
|
|
|
79
|
+
## V2 API
|
|
80
|
+
|
|
81
|
+
`memax.v2` talks to the `/v2` API, the V2 record: every change is a
|
|
82
|
+
command with a receipt, agents propose and people keep. Its types are
|
|
83
|
+
generated from the API contract and live under the `V2` namespace.
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { Memax, refusalOf, type V2 } from "memax-sdk";
|
|
87
|
+
|
|
88
|
+
const memax = new Memax({ apiKey: process.env.MEMAX_API_KEY });
|
|
89
|
+
|
|
90
|
+
// Commands need an Idempotency-Key: choose one per intent, reuse it on retry.
|
|
91
|
+
const res: V2.CommandResult = await memax.v2.memories.remember(
|
|
92
|
+
"memax-v2", // space id or slug
|
|
93
|
+
{ statement: "River is our queue, not Kafka.", section: "decisions" },
|
|
94
|
+
{ idempotencyKey: crypto.randomUUID() },
|
|
95
|
+
);
|
|
96
|
+
res.outcome; // "applied" for a member or owner, "proposed" for an API key
|
|
97
|
+
|
|
98
|
+
// Display IDs repeat across tenants, so they travel with their space.
|
|
99
|
+
const { memory, versions, receipts } = await memax.v2.memories.get("M-0219", {
|
|
100
|
+
space: "memax-v2",
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Edits send the version they started from; a newer one is 412 edit_clash.
|
|
104
|
+
await memax.v2.memories.edit(
|
|
105
|
+
memory.id,
|
|
106
|
+
{ statement: "River is our only queue." },
|
|
107
|
+
{ idempotencyKey: crypto.randomUUID(), ifMatch: memory.version },
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
await memax.v2.memories.keep(
|
|
112
|
+
"M-0220",
|
|
113
|
+
{},
|
|
114
|
+
{ space: "memax-v2", idempotencyKey: crypto.randomUUID() },
|
|
115
|
+
);
|
|
116
|
+
} catch (err) {
|
|
117
|
+
refusalOf(err)?.code; // "person_must_review": API keys never keep
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const queue = await memax.v2.review.list("memax-v2"); // queue.total waiting
|
|
121
|
+
const activity = await memax.v2.receipts.list("memax-v2", { limit: 50 });
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`memax.v2.ask` streams a cited answer as server-sent events, and
|
|
125
|
+
`verifyExport` and `verifyReceiptChain` check an export and a space's
|
|
126
|
+
receipt chain against its signed checkpoints, with no dependencies.
|
|
127
|
+
|
|
128
|
+
The types are regenerated from `packages/server/openapi/v2.yaml` with
|
|
129
|
+
`pnpm --filter memax-sdk gen:v2`; `pnpm lint` fails when they are stale.
|
|
130
|
+
|
|
82
131
|
## Authentication
|
|
83
132
|
|
|
84
|
-
|
|
133
|
+
Create an API key in Settings on [memax.app](https://memax.app). For browser / user-session auth (OAuth flow), pass the session's token through `auth` instead:
|
|
85
134
|
|
|
86
135
|
```ts
|
|
87
|
-
const memax = new Memax({
|
|
136
|
+
const memax = new Memax({
|
|
137
|
+
auth: async () => ({ Authorization: `Bearer ${session.accessToken}` }),
|
|
138
|
+
});
|
|
88
139
|
```
|
|
89
140
|
|
|
90
141
|
To target a non-default Memax API endpoint:
|
|
@@ -92,7 +143,7 @@ To target a non-default Memax API endpoint:
|
|
|
92
143
|
```ts
|
|
93
144
|
const memax = new Memax({
|
|
94
145
|
apiKey: "...",
|
|
95
|
-
|
|
146
|
+
apiUrl: "https://api.memax.app",
|
|
96
147
|
});
|
|
97
148
|
```
|
|
98
149
|
|
|
@@ -104,12 +155,12 @@ All failures throw `MemaxError`. The instance carries enough to drive retry and
|
|
|
104
155
|
import { Memax, MemaxError } from "memax-sdk";
|
|
105
156
|
|
|
106
157
|
try {
|
|
107
|
-
await memax.recall(
|
|
158
|
+
await memax.recall("...");
|
|
108
159
|
} catch (err) {
|
|
109
160
|
if (err instanceof MemaxError) {
|
|
110
|
-
if (err.
|
|
111
|
-
// transient — back off and retry
|
|
112
|
-
} else if (err.
|
|
161
|
+
if (err.isRateLimited || err.isServerError || err.isNetwork) {
|
|
162
|
+
// transient — back off (err.retryAfterSeconds when the server says) and retry
|
|
163
|
+
} else if (err.isUnauthorized) {
|
|
113
164
|
// auth issue — prompt re-login
|
|
114
165
|
}
|
|
115
166
|
console.error(err.code, err.message);
|
|
@@ -121,15 +172,14 @@ try {
|
|
|
121
172
|
## Live events
|
|
122
173
|
|
|
123
174
|
```ts
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
console.log(event.type, event.data);
|
|
175
|
+
const stream = memax.events.subscribe({
|
|
176
|
+
onEvent: (event, data) => {
|
|
177
|
+
console.log(event, data);
|
|
128
178
|
},
|
|
129
|
-
);
|
|
179
|
+
});
|
|
130
180
|
|
|
131
181
|
// later
|
|
132
|
-
|
|
182
|
+
stream.abort();
|
|
133
183
|
```
|
|
134
184
|
|
|
135
185
|
## Links
|
package/dist/client.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { AccountResource } from "./resources/account.js";
|
|
|
17
17
|
import { EventsResource } from "./resources/events.js";
|
|
18
18
|
import { BarResource } from "./resources/bar.js";
|
|
19
19
|
import { ChatsResource } from "./resources/chats.js";
|
|
20
|
+
import { V2Resource } from "./v2/resources.js";
|
|
20
21
|
export declare class Memax {
|
|
21
22
|
readonly memories: MemoriesResource;
|
|
22
23
|
readonly configs: ConfigsResource;
|
|
@@ -36,6 +37,11 @@ export declare class Memax {
|
|
|
36
37
|
readonly events: EventsResource;
|
|
37
38
|
readonly bar: BarResource;
|
|
38
39
|
readonly chats: ChatsResource;
|
|
40
|
+
/**
|
|
41
|
+
* The /v2 API: the V2 record (spaces, memories, Review, receipts).
|
|
42
|
+
* Types are under the `V2` namespace export.
|
|
43
|
+
*/
|
|
44
|
+
readonly v2: V2Resource;
|
|
39
45
|
constructor(config: MemaxConfig);
|
|
40
46
|
push(...args: Parameters<MemoriesResource["push"]>): Promise<import("./types.js").Memory>;
|
|
41
47
|
recall(...args: Parameters<MemoriesResource["recall"]>): Promise<import("./types.js").RecallResult>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE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AC;gBAEZ,MAAM,EAAE,WAAW;IAgCzB,IAAI,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAIlD,MAAM,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAItD,GAAG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;CAGvD"}
|
package/dist/client.js
CHANGED
|
@@ -17,6 +17,7 @@ import { AccountResource } from "./resources/account.js";
|
|
|
17
17
|
import { EventsResource } from "./resources/events.js";
|
|
18
18
|
import { BarResource } from "./resources/bar.js";
|
|
19
19
|
import { ChatsResource } from "./resources/chats.js";
|
|
20
|
+
import { V2Resource } from "./v2/resources.js";
|
|
20
21
|
export class Memax {
|
|
21
22
|
memories;
|
|
22
23
|
configs;
|
|
@@ -36,6 +37,11 @@ export class Memax {
|
|
|
36
37
|
events;
|
|
37
38
|
bar;
|
|
38
39
|
chats;
|
|
40
|
+
/**
|
|
41
|
+
* The /v2 API: the V2 record (spaces, memories, Review, receipts).
|
|
42
|
+
* Types are under the `V2` namespace export.
|
|
43
|
+
*/
|
|
44
|
+
v2;
|
|
39
45
|
constructor(config) {
|
|
40
46
|
const transport = new ApiTransport(config);
|
|
41
47
|
const req = transport.request.bind(transport);
|
|
@@ -49,7 +55,7 @@ export class Memax {
|
|
|
49
55
|
this.memories = new MemoriesResource(req, stream, download);
|
|
50
56
|
this.configs = new ConfigsResource(req);
|
|
51
57
|
this.uploads = new UploadsResource(req);
|
|
52
|
-
this.auth = new AuthResource(req, apiUrl);
|
|
58
|
+
this.auth = new AuthResource(req, apiUrl, transport.form.bind(transport));
|
|
53
59
|
this.account = new AccountResource(req);
|
|
54
60
|
this.hubs = new HubsResource(req);
|
|
55
61
|
this.invites = new InvitesResource(req);
|
|
@@ -64,6 +70,7 @@ export class Memax {
|
|
|
64
70
|
this.events = new EventsResource(stream);
|
|
65
71
|
this.bar = new BarResource(req);
|
|
66
72
|
this.chats = new ChatsResource(req, stream);
|
|
73
|
+
this.v2 = new V2Resource(req, transport.open.bind(transport));
|
|
67
74
|
}
|
|
68
75
|
async push(...args) {
|
|
69
76
|
return this.memories.push(...args);
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,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IAAyC;QACpD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,15 @@ export type { Item, ChecklistItem, DigestItem, ItemProgress, PinContext, Checkli
|
|
|
6
6
|
export { SUPER_NOTIF_KINDS } from "./notifications/items.js";
|
|
7
7
|
export { actionToResolution, resolveFromAction, } from "./notifications/action-to-resolution.js";
|
|
8
8
|
export { MemaxError } from "./errors.js";
|
|
9
|
-
export
|
|
9
|
+
export * as V2 from "./v2/types.js";
|
|
10
|
+
export { V2Resource, V2SpacesResource, V2MemoriesResource, V2ReviewResource, V2ReceiptsResource, V2ReadsResource, V2AgentsResource, V2BriefsResource, V2TargetsResource, V2GatesResource, V2NoticesResource, V2SessionsResource, V2DreamResource, V2SettingsResource, V2AccountResource, V2PasskeysResource, undoableAction, refusalOf, forgetCarriesOf, askEventOf, } from "./v2/resources.js";
|
|
11
|
+
export { EventStreamParser, readEventStream } from "./v2/sse.js";
|
|
12
|
+
export type { ServerSentEvent } from "./v2/sse.js";
|
|
13
|
+
export { verifyReceiptChain, canonicalReceipt, checkpointStatement, receiptLeaf, genesisHash, merkleRoot, } from "./v2/verify.js";
|
|
14
|
+
export type { ChainReceipt, ChainReport, ChainProblem, ChainProblemKind, ChainCrypto, VerifyChainInput, } from "./v2/verify.js";
|
|
15
|
+
export { EXPORT_FORMAT, ExportFormatError, parseExport, parseFrontmatter, parseReceipts, splitDocument, verifyExport, } from "./v2/export.js";
|
|
16
|
+
export type { ExportFiles, ExportManifest, ExportManifestFile, ExportCheckpoints, ExportReceiptStamp, ExportedMemory, ExportedTombstone, ExportedBrief, ParsedExport, ExportProblem, ExportProblemKind, ExportReport, VerifyExportInput, } from "./v2/export.js";
|
|
17
|
+
export type { CommandOptions as V2CommandOptions, MemoryRefOptions as V2MemoryRefOptions, ReviewOptions as V2ReviewOptions, EditOptions as V2EditOptions, PageOptions as V2PageOptions, VersionedCommandOptions as V2VersionedCommandOptions, ListMemoriesOptions as V2ListMemoriesOptions, ListReceiptsOptions as V2ListReceiptsOptions, GetMemoryOptions as V2GetMemoryOptions, ListGatesOptions as V2ListGatesOptions, GateRefOptions as V2GateRefOptions, GateCommandOptions as V2GateCommandOptions, AskOptions as V2AskOptions, SpaceExport as V2SpaceExport, SettingsEditOptions as V2SettingsEditOptions, SessionCommandOptions as V2SessionCommandOptions, AccountCommandOptions as V2AccountCommandOptions, } from "./v2/resources.js";
|
|
18
|
+
export { passkeyCheckOf, encodePasskeyAnswer } from "./transport.js";
|
|
19
|
+
export type { MemaxConfig, AuthProvider, PasskeyCheck, PasskeyCheckHandler, PushOptions, RecallOptions, AskOptions, ListMemoriesOptions, HubUpdateParams, MemoryKind, MemoryStability, Memory, MemoryAttachment, AttachmentViewURL, MemoryLifecycle, MemoryUpdateInput, DreamActionRef, DreamTopicRef, ShareMemoryResult, BatchMoveResult, BatchAttributeResult, BatchMoveSkippedMemory, BatchMoveSkipReason, BatchDeleteResult, BatchDeleteSkippedMemory, BatchDeleteSkipReason, AgentConfigBatchDeleteResult, AgentConfigDeleteSkippedItem, AgentConfigDeleteSkipReason, RelatedMemory, RecalledMemory, RecallResult, SearchResult, BarSearchResult, BarTopicMatch, BarHubMatch, AskResult, ListMemoriesResult, Scope, AgentConfigClass, AgentConfig, Persona, PersonaRevision, PersonaRestoreResult, BoardKind, BoardStatus, BoardSlotState, BoardSlotAction, BoardFeedbackVerdict, Board, BoardSlotResolution, BoardSlot, BoardSlotVersion, BoardWithSlots, AgentConfigListResult, DeletedAgentConfig, SyncAction, SyncPlanAction, SyncManifestEntry, ConfigSyncRequest, AgentConfigSyncAck, ConfigSyncAckRequest, ConfigLocalDeleteRequest, RestoreDeletedConfigRequest, ConfigUpsertRequest, ConfigMergeRequest, UploadIntent, AuthProviderName, User, MeResponse, WebUi, AuthTokenPair, ExchangedTokens, DeviceSignIn, DeviceSignInOptions, DeviceSignInPoll, ImpersonationResult, AuthIdentity, UnlinkProviderResult, RequestEmailOtpOptions, RequestEmailOtpResponse, VerifyEmailOtpOptions, VerifyEmailOtpResponse, ApiKeyCreateOptions, ApiKey, ApiKeyListItem, UpdateApiKeyPayload, UpdateApiKeyResult, OAuthAutonomy, OAuthDecision, OAuthDecisionInput, OAuthRequest, OAuthRequestSpace, OAuthConsentTarget, UpdateProfileResult, DeleteAllDataResult, Hub, HubSettings, HubSettingsInput, HubWithRole, HubMember, HubInvite, HubInviteeInput, HubOwnershipTransfer, HubDetailResult, HubSummary, HubSummaryStats, HubSummaryHeader, HubSummaryMember, HubAccent, HubRole, HubType, HubHeaderState, HubHeaderAuroraMode, HubTimeBucket, HubGreetingKey, ContributorDeletePolicy, InviteDetails, InviteAcceptResult, DevFlagsSettings, Settings, SettingsUpdateInput, Usage, UsageWithLimits, PlanScope, PlanDefinition, UserLimits, Topic, TopicLifecycle, TopicDeltaSummary, TopicTree, TopicListResponse, TopicArchivedListResponse, TopicArchiveResult, TopicCreateParams, TopicUpdateParams, TopicUpdateErrorCode, TopicReorderOperation, TopicMemoriesResponse, DreamRun, DreamAction, DreamLatestRunSummary, DreamPendingReviewSummary, DreamIntelligenceSummary, DreamReport, DreamRunListOptions, DreamRunListResponse, DreamUsage, DreamUsageOptions, ReviewTopicMergePayload, ReviewTopicRestructurePayload, ReviewTopicRef, Notification, NotificationAudience, NotificationStatus, NotificationResolution, NotificationKind, NeedsActionNotificationKind, UpdateNotificationKind, NotificationKindCount, NotificationSummary, NotificationListQuery, NotificationListResponse, NotificationBulkQuery, NotificationBulkResult, NotificationResolveAction, NotificationResolveResult, ReviewContradictionPayload, ReviewMemoryRef, DreamRunCompletedPayload, DreamRunCounts, HubInvitePayload, HubInviteHubRef, HubInviteInviterRef, HubMemberJoinedPayload, HubMemberRef, HubInviteAcceptedPayload, HubInviteDeclinedPayload, HubInviteDeclinedByYouPayload, HubOwnershipTransferPayload, HubOwnershipTransferredPayload, SystemNoticePayload, GiftInviteLinkPayload, ConnectedAgent, ConnectedAgentWithStats, ConnectedAgentUpdate, DisconnectAgentResult, AgentDisconnectSkipReason, AgentDisconnectSkippedItem, ApiKeyRevokeResult, ApiKeyRevokeSkipReason, ApiKeyRevokeSkippedItem, ChatScopeType, ChatSessionStatus, ChatMessageRole, ChatMessageStatus, ChatSession, ChatMessage, ChatToolDescriptor, CreateChatSessionInput, PatchChatSessionInput, ListChatSessionsOptions, ListChatSessionsResult, ListChatMessagesOptions, ListChatMessagesResult, ChatTurnOutcome, SendChatMessageInput, SendChatMessageResult, CancelChatMessageResult, RegenerateChatMessageResult, DecideApprovalResult, ChatStreamOptions, ChatStreamEventName, } from "./types.js";
|
|
10
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,YAAY,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAMjF,YAAY,EACV,IAAI,EACJ,aAAa,EACb,UAAU,EACV,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,aAA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
CHANGED
|
@@ -9,4 +9,14 @@ export { actionToResolution, resolveFromAction, } from "./notifications/action-t
|
|
|
9
9
|
// Admin APIs are an internal, web-only surface and are intentionally not
|
|
10
10
|
// exported by this public SDK.
|
|
11
11
|
export { MemaxError } from "./errors.js";
|
|
12
|
+
// /v2 — the V2 record. Types are generated from
|
|
13
|
+
// packages/server/openapi/v2.yaml; use them as `V2.Memory`, `V2.PolicyCode`…
|
|
14
|
+
// (`export * as`, not `export type * as`, so the .d.ts parses on
|
|
15
|
+
// TypeScript before 5.0; the module holds only types.)
|
|
16
|
+
export * as V2 from "./v2/types.js";
|
|
17
|
+
export { V2Resource, V2SpacesResource, V2MemoriesResource, V2ReviewResource, V2ReceiptsResource, V2ReadsResource, V2AgentsResource, V2BriefsResource, V2TargetsResource, V2GatesResource, V2NoticesResource, V2SessionsResource, V2DreamResource, V2SettingsResource, V2AccountResource, V2PasskeysResource, undoableAction, refusalOf, forgetCarriesOf, askEventOf, } from "./v2/resources.js";
|
|
18
|
+
export { EventStreamParser, readEventStream } from "./v2/sse.js";
|
|
19
|
+
export { verifyReceiptChain, canonicalReceipt, checkpointStatement, receiptLeaf, genesisHash, merkleRoot, } from "./v2/verify.js";
|
|
20
|
+
export { EXPORT_FORMAT, ExportFormatError, parseExport, parseFrontmatter, parseReceipts, splitDocument, verifyExport, } from "./v2/export.js";
|
|
21
|
+
export { passkeyCheckOf, encodePasskeyAnswer } from "./transport.js";
|
|
12
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,mEAAmE;AACnE,gFAAgF;AAEhF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,uBAAuB,GACxB,MAA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X,WAAW,EACX,UAAU,GACX,MAAM,gBAAgB,CAAC;AASxB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,YAAY,GACb,MAAM,gBAAgB,CAAC;AAmCxB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -84,6 +84,12 @@ export interface ChecklistPayload {
|
|
|
84
84
|
description?: string;
|
|
85
85
|
items: ChecklistItem[];
|
|
86
86
|
required_ids?: string[];
|
|
87
|
+
/**
|
|
88
|
+
* Stamped when every required item is complete. The row stays
|
|
89
|
+
* pending so the card can show its finished state, and retires a day
|
|
90
|
+
* later. Render as "all done" while this is set.
|
|
91
|
+
*/
|
|
92
|
+
all_done_at?: string;
|
|
87
93
|
/** Compact-mode strip label. */
|
|
88
94
|
collapse_hint?: string;
|
|
89
95
|
pin_context?: PinContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../src/notifications/items.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;gDAC4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAc,SAAQ,IAAI;IACzC,YAAY,CAAC,EAAE,MAAM,CAA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CACtC;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAGhD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"items.js","sourceRoot":"","sources":["../../src/notifications/items.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wDAAwD;AACxD,gFAAgF;AAChF,EAAE;AACF,wEAAwE;AACxE,mEAAmE;AACnE,8DAA8D;AAC9D,uEAAuE;AACvE,2CAA2C;AAC3C,EAAE;AACF,6CAA6C;AAC7C,uEAAuE;AACvE,2DAA2D;
|
|
1
|
+
{"version":3,"file":"items.js","sourceRoot":"","sources":["../../src/notifications/items.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wDAAwD;AACxD,gFAAgF;AAChF,EAAE;AACF,wEAAwE;AACxE,mEAAmE;AACnE,8DAA8D;AAC9D,uEAAuE;AACvE,2CAA2C;AAC3C,EAAE;AACF,6CAA6C;AAC7C,uEAAuE;AACvE,2DAA2D;AAsH3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAS;IACpE,WAAW;IACX,QAAQ;CACT,CAAC,CAAC"}
|
package/dist/resources/auth.d.ts
CHANGED
|
@@ -1,9 +1,40 @@
|
|
|
1
|
-
import type { ApiKey, ApiKeyCreateOptions, ApiKeyListItem, ApiKeyRevokeResult, AuthIdentity, AuthProviderName, AuthTokenPair, ImpersonationResult, MeResponse,
|
|
2
|
-
import type { RequestFn } from "../transport.js";
|
|
1
|
+
import type { ApiKey, ApiKeyCreateOptions, ApiKeyListItem, ApiKeyRevokeResult, AuthIdentity, AuthProviderName, AuthTokenPair, DeviceSignIn, DeviceSignInOptions, DeviceSignInPoll, ExchangedTokens, ImpersonationResult, MeResponse, OAuthDecision, OAuthDecisionInput, OAuthRequest, RequestEmailOtpOptions, RequestEmailOtpResponse, UnlinkProviderResult, UpdateApiKeyPayload, UpdateApiKeyResult, UpdateProfileResult, VerifyEmailOtpOptions, VerifyEmailOtpResponse } from "../types.js";
|
|
2
|
+
import type { FormFn, RequestFn } from "../transport.js";
|
|
3
3
|
export declare class AuthResource {
|
|
4
4
|
private readonly req;
|
|
5
5
|
private readonly apiUrl;
|
|
6
|
-
|
|
6
|
+
private readonly form?;
|
|
7
|
+
constructor(req: RequestFn, apiUrl: string, form?: FormFn | undefined);
|
|
8
|
+
/**
|
|
9
|
+
* Ask for a device code (RFC 8628 §3.1), for signing the memax CLI in
|
|
10
|
+
* where no browser can open. Show the person `userCode` and
|
|
11
|
+
* `verificationUri` (or open `verificationUriComplete`), then poll with
|
|
12
|
+
* {@link pollDeviceSignIn} every `interval` seconds until it ends.
|
|
13
|
+
* Throws MemaxError `rate_limited` (too many codes from this address),
|
|
14
|
+
* `invalid_client`, or the network's errors.
|
|
15
|
+
*/
|
|
16
|
+
startDeviceSignIn(options?: DeviceSignInOptions): Promise<DeviceSignIn>;
|
|
17
|
+
/**
|
|
18
|
+
* Poll once for a device code's session (RFC 8628 §3.4). `pending` and
|
|
19
|
+
* `slow_down` mean keep polling (`slow_down`: 5 seconds longer between
|
|
20
|
+
* polls from now on); `signed_in` carries the person's CLI session, which
|
|
21
|
+
* the server issues once; `denied`, `expired` and `invalid` end it.
|
|
22
|
+
*/
|
|
23
|
+
pollDeviceSignIn(deviceCode: string, options?: {
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}): Promise<DeviceSignInPoll>;
|
|
26
|
+
/**
|
|
27
|
+
* Sign a session out (RFC 7009, `POST /oauth/revoke`): pass its refresh
|
|
28
|
+
* token, which ends the session even if that token was just replaced, or
|
|
29
|
+
* one of its access tokens. Its refresh token stops working at once, and
|
|
30
|
+
* the access tokens it minted within the hour. A token that names nothing
|
|
31
|
+
* succeeds too, so signing out twice is fine. Throws on a network error
|
|
32
|
+
* or a refusal (`invalid_request`, `rate_limited`).
|
|
33
|
+
*/
|
|
34
|
+
revoke(token: string, options?: {
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
private oauthForm;
|
|
7
38
|
me(): Promise<MeResponse>;
|
|
8
39
|
createKey(options: ApiKeyCreateOptions): Promise<ApiKey>;
|
|
9
40
|
listKeys(): Promise<ApiKeyListItem[]>;
|
|
@@ -28,8 +59,27 @@ export declare class AuthResource {
|
|
|
28
59
|
updateKey(id: string, payload: UpdateApiKeyPayload): Promise<UpdateApiKeyResult>;
|
|
29
60
|
updateProfile(displayName: string): Promise<UpdateProfileResult>;
|
|
30
61
|
refresh(refreshToken: string): Promise<AuthTokenPair>;
|
|
31
|
-
|
|
32
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Trades a sign-in's one-time code for its session. A session issued to
|
|
64
|
+
* the web app also says which web UI the person sees (`ui`).
|
|
65
|
+
*/
|
|
66
|
+
exchangeCode(code: string): Promise<ExchangedTokens>;
|
|
67
|
+
/**
|
|
68
|
+
* An MCP client's pending authorization request (OAuthConsent), for the
|
|
69
|
+
* person signed in on the web: the first person to open it is bound to
|
|
70
|
+
* it, and anyone else gets 404. Needs a session the web app was issued.
|
|
71
|
+
*/
|
|
72
|
+
openOAuthRequest(requestId: string): Promise<OAuthRequest>;
|
|
73
|
+
/**
|
|
74
|
+
* The bound person's answer: approve (one space) or deny. Answers where
|
|
75
|
+
* to send the browser: the client's registered redirect_uri with a code,
|
|
76
|
+
* or with access_denied.
|
|
77
|
+
*/
|
|
78
|
+
decideOAuthRequest(requestId: string, decision: OAuthDecisionInput): Promise<OAuthDecision>;
|
|
79
|
+
/** "Not you?": the bound person lets go of the request. */
|
|
80
|
+
releaseOAuthRequest(requestId: string): Promise<{
|
|
81
|
+
released: boolean;
|
|
82
|
+
}>;
|
|
33
83
|
githubLoginURL(redirectURI: string): string;
|
|
34
84
|
googleLoginURL(redirectURI: string): string;
|
|
35
85
|
providerLoginURL(provider: AuthProviderName, redirectURI: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/resources/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/resources/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,MAAM,EAAc,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA0BrE,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAFL,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhC;;;;;;;OAOG;IACG,iBAAiB,CACrB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,YAAY,CAAC;IA4BxB;;;;;OAKG;IACG,gBAAgB,CACpB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GACrC,OAAO,CAAC,gBAAgB,CAAC;IAmC5B;;;;;;;OAOG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WA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;;;;;;OASG;IACG,cAAc,CAClB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,sBAAsB,CAAC;IASlC,eAAe,CAAC,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM;IAIlE,cAAc,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAIzC,cAAc,CAClB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,oBAAoB,CAAC;IAIhC,+FAA+F;IACzF,WAAW,CAAC,MAAM,EAAE;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAKjC"}
|
package/dist/resources/auth.js
CHANGED
|
@@ -1,9 +1,113 @@
|
|
|
1
|
+
import { MemaxError } from "../errors.js";
|
|
2
|
+
/** An OAuth error answer as a MemaxError (`code` is OAuth's `error`). */
|
|
3
|
+
function oauthFailure(status, body, retryAfter) {
|
|
4
|
+
const code = status === 429
|
|
5
|
+
? "rate_limited"
|
|
6
|
+
: typeof body.error === "string"
|
|
7
|
+
? body.error
|
|
8
|
+
: "invalid_response";
|
|
9
|
+
const message = typeof body.error_description === "string"
|
|
10
|
+
? body.error_description
|
|
11
|
+
: `The sign-in server answered ${status}.`;
|
|
12
|
+
return new MemaxError(message, code, status, undefined, retryAfter);
|
|
13
|
+
}
|
|
14
|
+
/** The memax CLI's OAuth client id; only it signs in with a device code. */
|
|
15
|
+
const DEVICE_CLIENT_ID = "memax-cli";
|
|
16
|
+
const DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
|
|
1
17
|
export class AuthResource {
|
|
2
18
|
req;
|
|
3
19
|
apiUrl;
|
|
4
|
-
|
|
20
|
+
form;
|
|
21
|
+
constructor(req, apiUrl, form) {
|
|
5
22
|
this.req = req;
|
|
6
23
|
this.apiUrl = apiUrl;
|
|
24
|
+
this.form = form;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Ask for a device code (RFC 8628 §3.1), for signing the memax CLI in
|
|
28
|
+
* where no browser can open. Show the person `userCode` and
|
|
29
|
+
* `verificationUri` (or open `verificationUriComplete`), then poll with
|
|
30
|
+
* {@link pollDeviceSignIn} every `interval` seconds until it ends.
|
|
31
|
+
* Throws MemaxError `rate_limited` (too many codes from this address),
|
|
32
|
+
* `invalid_client`, or the network's errors.
|
|
33
|
+
*/
|
|
34
|
+
async startDeviceSignIn(options = {}) {
|
|
35
|
+
const { status, body, retryAfter } = await this.oauthForm("/oauth/device_authorization", {
|
|
36
|
+
client_id: DEVICE_CLIENT_ID,
|
|
37
|
+
client_version: options.clientVersion,
|
|
38
|
+
device_name: options.deviceName,
|
|
39
|
+
device_os: options.deviceOs,
|
|
40
|
+
space: options.space,
|
|
41
|
+
}, options.signal);
|
|
42
|
+
if (status !== 200 || typeof body.device_code !== "string") {
|
|
43
|
+
throw oauthFailure(status, body, retryAfter);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
deviceCode: body.device_code,
|
|
47
|
+
userCode: String(body.user_code ?? ""),
|
|
48
|
+
verificationUri: String(body.verification_uri ?? ""),
|
|
49
|
+
verificationUriComplete: typeof body.verification_uri_complete === "string"
|
|
50
|
+
? body.verification_uri_complete
|
|
51
|
+
: undefined,
|
|
52
|
+
expiresIn: Number(body.expires_in ?? 600),
|
|
53
|
+
interval: Math.max(1, Number(body.interval ?? 5)),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Poll once for a device code's session (RFC 8628 §3.4). `pending` and
|
|
58
|
+
* `slow_down` mean keep polling (`slow_down`: 5 seconds longer between
|
|
59
|
+
* polls from now on); `signed_in` carries the person's CLI session, which
|
|
60
|
+
* the server issues once; `denied`, `expired` and `invalid` end it.
|
|
61
|
+
*/
|
|
62
|
+
async pollDeviceSignIn(deviceCode, options = {}) {
|
|
63
|
+
const { status, body, retryAfter } = await this.oauthForm("/oauth/token", {
|
|
64
|
+
grant_type: DEVICE_GRANT,
|
|
65
|
+
client_id: DEVICE_CLIENT_ID,
|
|
66
|
+
device_code: deviceCode,
|
|
67
|
+
}, options.signal);
|
|
68
|
+
if (status === 200 && typeof body.access_token === "string") {
|
|
69
|
+
return {
|
|
70
|
+
status: "signed_in",
|
|
71
|
+
tokens: {
|
|
72
|
+
access_token: body.access_token,
|
|
73
|
+
refresh_token: String(body.refresh_token ?? ""),
|
|
74
|
+
expires_in: Number(body.expires_in ?? 3600),
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
switch (body.error) {
|
|
79
|
+
case "authorization_pending":
|
|
80
|
+
return { status: "pending" };
|
|
81
|
+
case "slow_down":
|
|
82
|
+
return { status: "slow_down" };
|
|
83
|
+
case "access_denied":
|
|
84
|
+
return { status: "denied" };
|
|
85
|
+
case "expired_token":
|
|
86
|
+
return { status: "expired" };
|
|
87
|
+
case "invalid_grant":
|
|
88
|
+
return { status: "invalid" };
|
|
89
|
+
}
|
|
90
|
+
throw oauthFailure(status, body, retryAfter);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Sign a session out (RFC 7009, `POST /oauth/revoke`): pass its refresh
|
|
94
|
+
* token, which ends the session even if that token was just replaced, or
|
|
95
|
+
* one of its access tokens. Its refresh token stops working at once, and
|
|
96
|
+
* the access tokens it minted within the hour. A token that names nothing
|
|
97
|
+
* succeeds too, so signing out twice is fine. Throws on a network error
|
|
98
|
+
* or a refusal (`invalid_request`, `rate_limited`).
|
|
99
|
+
*/
|
|
100
|
+
async revoke(token, options = {}) {
|
|
101
|
+
const { status, body, retryAfter } = await this.oauthForm("/oauth/revoke", { token }, options.signal);
|
|
102
|
+
if (status !== 200) {
|
|
103
|
+
throw oauthFailure(status, body, retryAfter);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async oauthForm(path, fields, signal) {
|
|
107
|
+
if (!this.form) {
|
|
108
|
+
throw new MemaxError("This client can't send OAuth forms.", "invalid_request", 0);
|
|
109
|
+
}
|
|
110
|
+
return this.form(path, fields, signal);
|
|
7
111
|
}
|
|
8
112
|
async me() {
|
|
9
113
|
return this.req("GET", "/v1/auth/me");
|
|
@@ -15,6 +119,7 @@ export class AuthResource {
|
|
|
15
119
|
hub_id: options.hubId,
|
|
16
120
|
hub_ids: options.hubIds,
|
|
17
121
|
agent_name: options.agentName,
|
|
122
|
+
standalone: options.standalone,
|
|
18
123
|
expires_in_days: options.expiresInDays,
|
|
19
124
|
scopes: options.scopes,
|
|
20
125
|
permissions: options.permissions,
|
|
@@ -64,18 +169,34 @@ export class AuthResource {
|
|
|
64
169
|
body: { refresh_token: refreshToken },
|
|
65
170
|
});
|
|
66
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Trades a sign-in's one-time code for its session. A session issued to
|
|
174
|
+
* the web app also says which web UI the person sees (`ui`).
|
|
175
|
+
*/
|
|
67
176
|
async exchangeCode(code) {
|
|
68
177
|
return this.req("POST", "/v1/auth/exchange", {
|
|
69
178
|
body: { code },
|
|
70
179
|
});
|
|
71
180
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
181
|
+
/**
|
|
182
|
+
* An MCP client's pending authorization request (OAuthConsent), for the
|
|
183
|
+
* person signed in on the web: the first person to open it is bound to
|
|
184
|
+
* it, and anyone else gets 404. Needs a session the web app was issued.
|
|
185
|
+
*/
|
|
186
|
+
async openOAuthRequest(requestId) {
|
|
187
|
+
return this.req("GET", `/oauth/authorize/requests/${encodeURIComponent(requestId)}`);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The bound person's answer: approve (one space) or deny. Answers where
|
|
191
|
+
* to send the browser: the client's registered redirect_uri with a code,
|
|
192
|
+
* or with access_denied.
|
|
193
|
+
*/
|
|
194
|
+
async decideOAuthRequest(requestId, decision) {
|
|
195
|
+
return this.req("POST", `/oauth/authorize/requests/${encodeURIComponent(requestId)}/decision`, { body: { ...decision } });
|
|
196
|
+
}
|
|
197
|
+
/** "Not you?": the bound person lets go of the request. */
|
|
198
|
+
async releaseOAuthRequest(requestId) {
|
|
199
|
+
return this.req("POST", `/oauth/authorize/requests/${encodeURIComponent(requestId)}/release`);
|
|
79
200
|
}
|
|
80
201
|
githubLoginURL(redirectURI) {
|
|
81
202
|
return `${this.apiUrl}/v1/auth/github?redirect_uri=${encodeURIComponent(redirectURI)}`;
|