@leemour/max-cli 0.6.0 → 0.8.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 +201 -74
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +4 -4
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/schema.d.ts +13 -8
- package/dist/cache/schema.d.ts.map +1 -1
- package/dist/cache/schema.js +84 -23
- package/dist/cache/schema.js.map +1 -1
- package/dist/cache/store.d.ts +15 -0
- package/dist/cache/store.d.ts.map +1 -1
- package/dist/cache/store.js +32 -3
- package/dist/cache/store.js.map +1 -1
- package/dist/client.d.ts +205 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +866 -31
- package/dist/client.js.map +1 -1
- package/dist/commands/account.d.ts.map +1 -1
- package/dist/commands/account.js +71 -3
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/chats.d.ts.map +1 -1
- package/dist/commands/chats.js +167 -0
- package/dist/commands/chats.js.map +1 -1
- package/dist/commands/complete.d.ts +10 -0
- package/dist/commands/complete.d.ts.map +1 -0
- package/dist/commands/complete.js +89 -0
- package/dist/commands/complete.js.map +1 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +10 -4
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/contacts.d.ts +3 -0
- package/dist/commands/contacts.d.ts.map +1 -1
- package/dist/commands/contacts.js +85 -0
- package/dist/commands/contacts.js.map +1 -1
- package/dist/commands/context.d.ts +22 -3
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +26 -7
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/export.d.ts +3 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +83 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/folders.d.ts +4 -0
- package/dist/commands/folders.d.ts.map +1 -0
- package/dist/commands/folders.js +76 -0
- package/dist/commands/folders.js.map +1 -0
- package/dist/commands/inbox.js +2 -2
- package/dist/commands/inbox.js.map +1 -1
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +24 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/messages.d.ts.map +1 -1
- package/dist/commands/messages.js +210 -5
- package/dist/commands/messages.js.map +1 -1
- package/dist/commands/models.d.ts +7 -0
- package/dist/commands/models.d.ts.map +1 -0
- package/dist/commands/models.js +47 -0
- package/dist/commands/models.js.map +1 -0
- package/dist/commands/reactions.d.ts.map +1 -1
- package/dist/commands/reactions.js +17 -0
- package/dist/commands/reactions.js.map +1 -1
- package/dist/commands/serve.d.ts +10 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +98 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +16 -3
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/update.d.ts +7 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +53 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/watch.d.ts +9 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +64 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/config.d.ts +32 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +82 -5
- package/dist/config.js.map +1 -1
- package/dist/domain/map.d.ts +8 -1
- package/dist/domain/map.d.ts.map +1 -1
- package/dist/domain/map.js +47 -1
- package/dist/domain/map.js.map +1 -1
- package/dist/domain/models.d.ts +61 -0
- package/dist/domain/models.d.ts.map +1 -1
- package/dist/domain/models.js.map +1 -1
- package/dist/download.d.ts +2 -0
- package/dist/download.d.ts.map +1 -1
- package/dist/download.js +11 -0
- package/dist/download.js.map +1 -1
- package/dist/export.d.ts +26 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +75 -0
- package/dist/export.js.map +1 -0
- package/dist/generated/client.generated.d.ts +28 -0
- package/dist/generated/client.generated.d.ts.map +1 -1
- package/dist/generated/client.generated.js +28 -0
- package/dist/generated/client.generated.js.map +1 -1
- package/dist/generated/opcodes.generated.d.ts +23 -13
- package/dist/generated/opcodes.generated.d.ts.map +1 -1
- package/dist/generated/opcodes.generated.js +23 -13
- package/dist/generated/opcodes.generated.js.map +1 -1
- package/dist/generated/operations.generated.d.ts +180 -6
- package/dist/generated/operations.generated.d.ts.map +1 -1
- package/dist/generated/operations.generated.js +29 -4
- package/dist/generated/operations.generated.js.map +1 -1
- package/dist/mcp/confirm.d.ts +31 -0
- package/dist/mcp/confirm.d.ts.map +1 -0
- package/dist/mcp/confirm.js +62 -0
- package/dist/mcp/confirm.js.map +1 -0
- package/dist/mcp/instructions.d.ts +14 -0
- package/dist/mcp/instructions.d.ts.map +1 -0
- package/dist/mcp/instructions.js +39 -0
- package/dist/mcp/instructions.js.map +1 -0
- package/dist/mcp/server.d.ts +25 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +57 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/session.d.ts +28 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +91 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/tools.d.ts +15 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +351 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +23 -2
- package/dist/program.js.map +1 -1
- package/dist/protocol/connection.d.ts +10 -8
- package/dist/protocol/connection.d.ts.map +1 -1
- package/dist/protocol/connection.js +64 -7
- package/dist/protocol/connection.js.map +1 -1
- package/dist/protocol/frame.d.ts +2 -1
- package/dist/protocol/frame.d.ts.map +1 -1
- package/dist/protocol/frame.js.map +1 -1
- package/dist/rendering/messages.d.ts.map +1 -1
- package/dist/rendering/messages.js +17 -9
- package/dist/rendering/messages.js.map +1 -1
- package/dist/sends/guard.d.ts +8 -3
- package/dist/sends/guard.d.ts.map +1 -1
- package/dist/sends/guard.js +40 -15
- package/dist/sends/guard.js.map +1 -1
- package/dist/sends/journal.d.ts +20 -2
- package/dist/sends/journal.d.ts.map +1 -1
- package/dist/sends/journal.js.map +1 -1
- package/dist/sends/permissions.d.ts +11 -0
- package/dist/sends/permissions.d.ts.map +1 -0
- package/dist/sends/permissions.js +47 -0
- package/dist/sends/permissions.js.map +1 -0
- package/dist/server/lines.d.ts +9 -0
- package/dist/server/lines.d.ts.map +1 -0
- package/dist/server/lines.js +25 -0
- package/dist/server/lines.js.map +1 -0
- package/dist/server/server-connection.d.ts +45 -0
- package/dist/server/server-connection.d.ts.map +1 -0
- package/dist/server/server-connection.js +201 -0
- package/dist/server/server-connection.js.map +1 -0
- package/dist/server/server.d.ts +69 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +360 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/start.d.ts +28 -0
- package/dist/server/start.d.ts.map +1 -0
- package/dist/server/start.js +80 -0
- package/dist/server/start.js.map +1 -0
- package/dist/server/subscribe.d.ts +9 -0
- package/dist/server/subscribe.d.ts.map +1 -0
- package/dist/server/subscribe.js +26 -0
- package/dist/server/subscribe.js.map +1 -0
- package/dist/session/adopt.d.ts.map +1 -1
- package/dist/session/adopt.js +4 -0
- package/dist/session/adopt.js.map +1 -1
- package/dist/session/browser.d.ts +1 -1
- package/dist/session/browser.d.ts.map +1 -1
- package/dist/session/browser.js +86 -59
- package/dist/session/browser.js.map +1 -1
- package/dist/session/handshake.d.ts +1 -1
- package/dist/session/store.d.ts +2 -0
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js +4 -0
- package/dist/session/store.js.map +1 -1
- package/dist/spec/define.d.ts.map +1 -1
- package/dist/spec/define.js +14 -1
- package/dist/spec/define.js.map +1 -1
- package/dist/spec/index.d.ts.map +1 -1
- package/dist/spec/index.js +30 -7
- package/dist/spec/index.js.map +1 -1
- package/dist/spec/operations/account.d.ts +20 -0
- package/dist/spec/operations/account.d.ts.map +1 -0
- package/dist/spec/operations/account.js +62 -0
- package/dist/spec/operations/account.js.map +1 -0
- package/dist/spec/operations/chats.d.ts +66 -2
- package/dist/spec/operations/chats.d.ts.map +1 -1
- package/dist/spec/operations/chats.js +153 -5
- package/dist/spec/operations/chats.js.map +1 -1
- package/dist/spec/operations/contacts.d.ts +19 -1
- package/dist/spec/operations/contacts.d.ts.map +1 -1
- package/dist/spec/operations/contacts.js +49 -6
- package/dist/spec/operations/contacts.js.map +1 -1
- package/dist/spec/operations/folders.d.ts +24 -0
- package/dist/spec/operations/folders.d.ts.map +1 -0
- package/dist/spec/operations/folders.js +64 -0
- package/dist/spec/operations/folders.js.map +1 -0
- package/dist/spec/operations/messages.d.ts +56 -6
- package/dist/spec/operations/messages.d.ts.map +1 -1
- package/dist/spec/operations/messages.js +104 -21
- package/dist/spec/operations/messages.js.map +1 -1
- package/dist/spec/operations/session.d.ts +7 -0
- package/dist/spec/operations/session.d.ts.map +1 -1
- package/dist/spec/operations/session.js +17 -0
- package/dist/spec/operations/session.js.map +1 -1
- package/dist/spec/operations/uploads.d.ts +18 -0
- package/dist/spec/operations/uploads.d.ts.map +1 -0
- package/dist/spec/operations/uploads.js +35 -0
- package/dist/spec/operations/uploads.js.map +1 -0
- package/dist/testing/mock-max.d.ts +12 -2
- package/dist/testing/mock-max.d.ts.map +1 -1
- package/dist/testing/mock-max.js +15 -2
- package/dist/testing/mock-max.js.map +1 -1
- package/dist/testing/sandbox.js +2 -0
- package/dist/testing/sandbox.js.map +1 -1
- package/dist/transcribe/index.d.ts +34 -0
- package/dist/transcribe/index.d.ts.map +1 -0
- package/dist/transcribe/index.js +43 -0
- package/dist/transcribe/index.js.map +1 -0
- package/dist/transcribe/install.d.ts +18 -0
- package/dist/transcribe/install.d.ts.map +1 -0
- package/dist/transcribe/install.js +67 -0
- package/dist/transcribe/install.js.map +1 -0
- package/dist/transcribe/models.d.ts +32 -0
- package/dist/transcribe/models.d.ts.map +1 -0
- package/dist/transcribe/models.js +124 -0
- package/dist/transcribe/models.js.map +1 -0
- package/dist/transcribe/speech.d.ts +25 -0
- package/dist/transcribe/speech.d.ts.map +1 -0
- package/dist/transcribe/speech.js +105 -0
- package/dist/transcribe/speech.js.map +1 -0
- package/dist/update.d.ts +26 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +42 -0
- package/dist/update.js.map +1 -0
- package/dist/upload.d.ts +10 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +61 -0
- package/dist/upload.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +17 -3
- package/skills/max-cli/SKILL.md +28 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MaxClient } from "../client.js";
|
|
2
|
+
import type { CommandContext } from "../commands/context.js";
|
|
3
|
+
export interface SessionOptions {
|
|
4
|
+
/** Close the connection after this long without a call. */
|
|
5
|
+
idleMs?: number;
|
|
6
|
+
/** Log in again after this long, whatever the traffic: the chat list is what the login answered. */
|
|
7
|
+
maxAgeMs?: number;
|
|
8
|
+
now?: () => number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* **One connection for the whole agent session, and never for long** (`NEED-152`).
|
|
12
|
+
*
|
|
13
|
+
* The CLI logs in once per command. Here the process outlives the call, so the connection is kept
|
|
14
|
+
* between calls — and dropped after `idleMs` of quiet, after `maxAgeMs` whatever the traffic, and
|
|
15
|
+
* after any failure that may have been the connection's. The age limit is there because a login
|
|
16
|
+
* answers the chat list and the profile once; without it an agent that keeps talking would read a
|
|
17
|
+
* snapshot that never moves.
|
|
18
|
+
*
|
|
19
|
+
* Calls run **one at a time**. A client may send read-only calls in parallel, and one socket with
|
|
20
|
+
* one `seq` space is not the place to find out whether MAX minds.
|
|
21
|
+
*/
|
|
22
|
+
export declare class MaxSession {
|
|
23
|
+
#private;
|
|
24
|
+
constructor(context: CommandContext, { idleMs, maxAgeMs, now }?: SessionOptions);
|
|
25
|
+
use<T>(name: string, body: (client: MaxClient, release: () => Promise<void>) => Promise<T>): Promise<T>;
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/mcp/session.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,cAAc,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAI5D,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oGAAoG;IACpG,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAWD;;;;;;;;;;;GAWG;AACH,qBAAa,UAAU;;gBAWT,OAAO,EAAE,cAAc,EAAE,EAAE,MAAgB,EAAE,QAAkB,EAAE,GAAc,EAAE,GAAE,cAAmB;IAOlH,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAMjG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAiD7B"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { isCliError } from "@leemour/cli-core";
|
|
2
|
+
import { openProfileCache } from "../cache/index.js";
|
|
3
|
+
/** The caller's mistake, not the connection's — nothing about the socket is in doubt after these. */
|
|
4
|
+
const HARMLESS = new Set(["validation_error", "not_found", "permission_error", "confirmation_required", "rate_limited"]);
|
|
5
|
+
/**
|
|
6
|
+
* **One connection for the whole agent session, and never for long** (`NEED-152`).
|
|
7
|
+
*
|
|
8
|
+
* The CLI logs in once per command. Here the process outlives the call, so the connection is kept
|
|
9
|
+
* between calls — and dropped after `idleMs` of quiet, after `maxAgeMs` whatever the traffic, and
|
|
10
|
+
* after any failure that may have been the connection's. The age limit is there because a login
|
|
11
|
+
* answers the chat list and the profile once; without it an agent that keeps talking would read a
|
|
12
|
+
* snapshot that never moves.
|
|
13
|
+
*
|
|
14
|
+
* Calls run **one at a time**. A client may send read-only calls in parallel, and one socket with
|
|
15
|
+
* one `seq` space is not the place to find out whether MAX minds.
|
|
16
|
+
*/
|
|
17
|
+
export class MaxSession {
|
|
18
|
+
#context;
|
|
19
|
+
#idleMs;
|
|
20
|
+
#maxAgeMs;
|
|
21
|
+
#now;
|
|
22
|
+
#held;
|
|
23
|
+
#idle;
|
|
24
|
+
#queue = Promise.resolve();
|
|
25
|
+
#events = () => { };
|
|
26
|
+
#closed = false;
|
|
27
|
+
constructor(context, { idleMs = 120_000, maxAgeMs = 300_000, now = Date.now } = {}) {
|
|
28
|
+
this.#context = context;
|
|
29
|
+
this.#idleMs = idleMs;
|
|
30
|
+
this.#maxAgeMs = maxAgeMs;
|
|
31
|
+
this.#now = now;
|
|
32
|
+
}
|
|
33
|
+
use(name, body) {
|
|
34
|
+
const turn = this.#queue.then(() => this.#call(name, body));
|
|
35
|
+
this.#queue = turn.catch(() => { });
|
|
36
|
+
return turn;
|
|
37
|
+
}
|
|
38
|
+
async close() {
|
|
39
|
+
this.#closed = true;
|
|
40
|
+
await this.#queue;
|
|
41
|
+
await this.#release();
|
|
42
|
+
}
|
|
43
|
+
async #call(name, body) {
|
|
44
|
+
if (this.#closed)
|
|
45
|
+
throw new Error("the MCP server is shutting down");
|
|
46
|
+
clearTimeout(this.#idle);
|
|
47
|
+
try {
|
|
48
|
+
return await this.#context.run(name, async (events) => {
|
|
49
|
+
this.#events = events ?? (() => { });
|
|
50
|
+
return body(await this.#hold(), () => this.#release());
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (!(isCliError(error) && HARMLESS.has(error.code)))
|
|
55
|
+
await this.#release();
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
this.#events = () => { };
|
|
60
|
+
if (this.#held) {
|
|
61
|
+
this.#idle = setTimeout(() => void this.#release(), this.#idleMs);
|
|
62
|
+
this.#idle.unref();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async #hold() {
|
|
67
|
+
if (this.#held && this.#now() - this.#held.openedAt >= this.#maxAgeMs)
|
|
68
|
+
await this.#release();
|
|
69
|
+
if (this.#held)
|
|
70
|
+
return this.#held.client;
|
|
71
|
+
const { settings, renderer, createClient } = this.#context;
|
|
72
|
+
const cache = await openProfileCache(settings.profile, { onProblem: (message) => renderer.note(message) });
|
|
73
|
+
const client = createClient({ events: (event) => this.#events(event), ...(cache ? { cache } : {}) });
|
|
74
|
+
this.#held = { client, cache, openedAt: this.#now() };
|
|
75
|
+
return client;
|
|
76
|
+
}
|
|
77
|
+
async #release() {
|
|
78
|
+
clearTimeout(this.#idle);
|
|
79
|
+
const held = this.#held;
|
|
80
|
+
this.#held = undefined;
|
|
81
|
+
if (!held)
|
|
82
|
+
return;
|
|
83
|
+
try {
|
|
84
|
+
await held.client.close();
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
held.cache?.close();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/mcp/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAepD,qGAAqG;AACrG,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,kBAA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CAAA;QAExC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC1D,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC1G,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;QACpG,IAAI,CAAC,KAAK,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAA;QACrD,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACxB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAA;QACvB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QACtB,IAAI,CAAC,IAAI;YAAE,OAAM;QACjB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAC3B,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,CAAA;QACrB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type McpServer } from "@modelcontextprotocol/server";
|
|
2
|
+
import type { Permission } from "../sends/permissions.js";
|
|
3
|
+
import type { MaxSession } from "./session.js";
|
|
4
|
+
export declare const registerTools: (server: McpServer, session: MaxSession, { allowSend, confirmSend, allowMarkRead, allowDelete, defaultLimit, profile, transcribeModel, permitted, }: {
|
|
5
|
+
allowSend: boolean;
|
|
6
|
+
confirmSend?: boolean;
|
|
7
|
+
allowMarkRead?: boolean;
|
|
8
|
+
allowDelete?: boolean;
|
|
9
|
+
defaultLimit: number;
|
|
10
|
+
profile: string;
|
|
11
|
+
transcribeModel?: string;
|
|
12
|
+
/** What the profile allows; `undefined` is everything. The guard refuses anyway — this only hides. */
|
|
13
|
+
permitted?: readonly Permission[];
|
|
14
|
+
}) => void;
|
|
15
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EAGf,MAAM,8BAA8B,CAAA;AAQrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAKzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAyX9C,eAAO,MAAM,aAAa,GACxB,QAAQ,SAAS,EACjB,SAAS,UAAU,EACnB,4GASG;IACD,SAAS,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sGAAsG;IACtG,SAAS,CAAC,EAAE,SAAS,UAAU,EAAE,CAAA;CAClC,KACA,IAuCF,CAAA"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { CliError, isCliError } from "@leemour/cli-core";
|
|
2
|
+
import { isInputRequiredResult, } from "@modelcontextprotocol/server";
|
|
3
|
+
import { toStandardJsonSchema } from "@valibot/to-json-schema";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
import { openProfileCache } from "../cache/index.js";
|
|
6
|
+
import { DELETE_AT_ONCE } from "../client.js";
|
|
7
|
+
import { sendTime } from "../config.js";
|
|
8
|
+
import { maskedProfile } from "../domain/map.js";
|
|
9
|
+
import { transcribe } from "../transcribe/index.js";
|
|
10
|
+
import { modelsDirectory } from "../transcribe/install.js";
|
|
11
|
+
import { DEFAULT_MODEL, speechModel } from "../transcribe/models.js";
|
|
12
|
+
import { confirmer, sendOptions } from "./confirm.js";
|
|
13
|
+
const chat = v.pipe(v.string(), v.minLength(1), v.description("chat id, or part of a chat name"));
|
|
14
|
+
const message = v.pipe(v.string(), v.regex(/^\d+$/), v.description("message id"));
|
|
15
|
+
const limit = v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(100), v.description("how many")));
|
|
16
|
+
const page = v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.description("which page, from 1")));
|
|
17
|
+
const READ = { readOnlyHint: true, destructiveHint: false, openWorldHint: true };
|
|
18
|
+
const WRITE = {
|
|
19
|
+
readOnlyHint: false,
|
|
20
|
+
destructiveHint: true,
|
|
21
|
+
idempotentHint: false,
|
|
22
|
+
openWorldHint: true,
|
|
23
|
+
};
|
|
24
|
+
const APPROVE = { "anthropic/requiresUserInteraction": true };
|
|
25
|
+
/** Typed where it is written; erased here because the SDK checks the arguments against `input` first. */
|
|
26
|
+
const tool = (definition) => definition;
|
|
27
|
+
/** The same envelope `--json` prints for every listing. */
|
|
28
|
+
const envelope = ({ items, hasMore }, pageNumber, pageSize) => ({
|
|
29
|
+
items,
|
|
30
|
+
page: pageNumber,
|
|
31
|
+
limit: pageSize,
|
|
32
|
+
hasMore,
|
|
33
|
+
});
|
|
34
|
+
const window = (args, defaults) => {
|
|
35
|
+
const size = args.limit ?? defaults.limit;
|
|
36
|
+
const number = args.page ?? 1;
|
|
37
|
+
return { size, number, request: { limit: size, offset: (number - 1) * size } };
|
|
38
|
+
};
|
|
39
|
+
const READ_TOOLS = {
|
|
40
|
+
max_account_show: tool({
|
|
41
|
+
title: "Who this is",
|
|
42
|
+
description: "The MAX account this server is logged in as.",
|
|
43
|
+
input: v.object({}),
|
|
44
|
+
annotations: { ...READ, idempotentHint: true },
|
|
45
|
+
// Always masked: an agent has no reason to hold the owner's number (`NEED-209`).
|
|
46
|
+
answer: async (client) => maskedProfile(await client.account.me()),
|
|
47
|
+
}),
|
|
48
|
+
max_chats_list: tool({
|
|
49
|
+
title: "List chats",
|
|
50
|
+
description: "Chats the owner is in, most recent first. Use it to find a chat's id before reading or sending. " +
|
|
51
|
+
"Returns { items, page, limit, hasMore }.",
|
|
52
|
+
input: v.object({
|
|
53
|
+
search: v.optional(v.pipe(v.string(), v.minLength(3), v.description("only chats whose name contains this"))),
|
|
54
|
+
kind: v.optional(v.picklist(["dialog", "group", "channel"])),
|
|
55
|
+
unread: v.optional(v.pipe(v.boolean(), v.description("only chats with unread messages"))),
|
|
56
|
+
limit,
|
|
57
|
+
page,
|
|
58
|
+
}),
|
|
59
|
+
annotations: READ,
|
|
60
|
+
answer: async (client, { search: query, kind, unread, ...paging }, defaults) => {
|
|
61
|
+
const { size, number, request } = window(paging, defaults);
|
|
62
|
+
const found = await client.chats.list({
|
|
63
|
+
...request,
|
|
64
|
+
...(query === undefined ? {} : { query }),
|
|
65
|
+
...(kind === undefined ? {} : { kind }),
|
|
66
|
+
...(unread === true ? { unread } : {}),
|
|
67
|
+
});
|
|
68
|
+
return envelope(found, number, size);
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
max_chats_show: tool({
|
|
72
|
+
title: "Show a chat",
|
|
73
|
+
description: "One chat: its kind, unread count, last message time and who is in it.",
|
|
74
|
+
input: v.object({ chat }),
|
|
75
|
+
annotations: READ,
|
|
76
|
+
answer: (client, args) => client.chats.show(args.chat),
|
|
77
|
+
}),
|
|
78
|
+
max_contacts_list: tool({
|
|
79
|
+
title: "List contacts",
|
|
80
|
+
description: "People the owner has a one-to-one chat with. Returns { items, page, limit, hasMore }.",
|
|
81
|
+
input: v.object({
|
|
82
|
+
search: v.optional(v.pipe(v.string(), v.minLength(3), v.description("only people whose name contains this"))),
|
|
83
|
+
order: v.optional(v.picklist(["recent", "name"])),
|
|
84
|
+
limit,
|
|
85
|
+
page,
|
|
86
|
+
}),
|
|
87
|
+
annotations: READ,
|
|
88
|
+
answer: async (client, { search: query, order, ...paging }, defaults) => {
|
|
89
|
+
const { size, number, request } = window(paging, defaults);
|
|
90
|
+
const found = await client.contacts.list({
|
|
91
|
+
...request,
|
|
92
|
+
...(query === undefined ? {} : { query }),
|
|
93
|
+
...(order === undefined ? {} : { order }),
|
|
94
|
+
});
|
|
95
|
+
return envelope(found, number, size);
|
|
96
|
+
},
|
|
97
|
+
}),
|
|
98
|
+
max_contacts_show: tool({
|
|
99
|
+
title: "Show a person",
|
|
100
|
+
description: "One person and the chats shared with them.",
|
|
101
|
+
input: v.object({
|
|
102
|
+
person: v.pipe(v.string(), v.minLength(1), v.description("person id, @username, or part of a name")),
|
|
103
|
+
}),
|
|
104
|
+
annotations: READ,
|
|
105
|
+
answer: (client, args) => client.contacts.show(args.person),
|
|
106
|
+
}),
|
|
107
|
+
max_messages_scheduled: tool({
|
|
108
|
+
title: "Messages scheduled in a chat",
|
|
109
|
+
description: "Messages waiting to be sent later in a chat, soonest first, each with `scheduledFor`. " +
|
|
110
|
+
"Check here after a scheduled send ended in outcome_unknown. Cancelling is done in the MAX app.",
|
|
111
|
+
input: v.object({ chat }),
|
|
112
|
+
annotations: READ,
|
|
113
|
+
answer: async (client, args) => client.messages.scheduled(await client.chats.resolve(args.chat)),
|
|
114
|
+
}),
|
|
115
|
+
max_messages_list: tool({
|
|
116
|
+
title: "Read a chat",
|
|
117
|
+
description: "Recent messages in a chat, oldest first. Does not mark anything read. For older messages pass " +
|
|
118
|
+
"`before` = the id of the first item; for newer, `after` = the id of the last. Returns { items, page, limit, hasMore }.",
|
|
119
|
+
input: v.object({
|
|
120
|
+
chat,
|
|
121
|
+
limit,
|
|
122
|
+
before: v.optional(v.pipe(v.string(), v.description("a message id or an ISO 8601 time"))),
|
|
123
|
+
after: v.optional(v.pipe(v.string(), v.description("a message id or an ISO 8601 time; not with before"))),
|
|
124
|
+
}),
|
|
125
|
+
annotations: READ,
|
|
126
|
+
answer: async (client, args, defaults) => {
|
|
127
|
+
if (args.before !== undefined && args.after !== undefined) {
|
|
128
|
+
throw new CliError("validation_error", "before and after are two directions; give one of them");
|
|
129
|
+
}
|
|
130
|
+
const size = args.limit ?? defaults.limit;
|
|
131
|
+
const chatId = await client.chats.resolve(args.chat);
|
|
132
|
+
const anchor = args.after !== undefined
|
|
133
|
+
? { after: client.messages.moment(args.after, "after") }
|
|
134
|
+
: args.before !== undefined
|
|
135
|
+
? { before: client.messages.moment(args.before, "before") }
|
|
136
|
+
: {};
|
|
137
|
+
return envelope(await client.messages.list(chatId, { limit: size, ...anchor }), 1, size);
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
140
|
+
max_messages_search: tool({
|
|
141
|
+
title: "Search messages",
|
|
142
|
+
description: "Find messages in what this machine has already read — it never asks MAX, so an empty answer means " +
|
|
143
|
+
'"not in what was read", not "never said". Returns { items, page, limit, hasMore }.',
|
|
144
|
+
input: v.object({
|
|
145
|
+
text: v.pipe(v.string(), v.minLength(3), v.description("what to look for; at least 3 characters")),
|
|
146
|
+
chat: v.optional(v.pipe(v.string(), v.regex(/^-?\d+$/), v.description("only this chat, by id"))),
|
|
147
|
+
limit,
|
|
148
|
+
}),
|
|
149
|
+
annotations: { ...READ, openWorldHint: false },
|
|
150
|
+
answer: async (client, args, defaults) => {
|
|
151
|
+
const size = args.limit ?? defaults.limit;
|
|
152
|
+
const found = await client.messages.search(args.text, {
|
|
153
|
+
limit: size,
|
|
154
|
+
...(args.chat === undefined ? {} : { chatId: args.chat }),
|
|
155
|
+
});
|
|
156
|
+
return envelope(found, 1, size);
|
|
157
|
+
},
|
|
158
|
+
}),
|
|
159
|
+
max_messages_transcribe: tool({
|
|
160
|
+
title: "Transcribe a voice message",
|
|
161
|
+
description: "The text of one voice message, heard on the owner's machine by a local speech model; the recording goes " +
|
|
162
|
+
"nowhere. Up to a minute for five minutes of speech; asked again, it answers from the cache. Refuses when " +
|
|
163
|
+
"the model is not downloaded: the owner runs `max models audio download <id>` in a terminal.",
|
|
164
|
+
input: v.object({ chat, message }),
|
|
165
|
+
annotations: READ,
|
|
166
|
+
answer: async (client, args, { profile, transcribeModel, release }) => {
|
|
167
|
+
const model = speechModel(transcribeModel);
|
|
168
|
+
const directory = modelsDirectory();
|
|
169
|
+
const chatId = await client.chats.resolve(args.chat);
|
|
170
|
+
// Its own handle: `release` closes the session's, and the text is saved after that.
|
|
171
|
+
const cache = await openProfileCache(profile);
|
|
172
|
+
try {
|
|
173
|
+
return await transcribe(client, chatId, args.message, { model, directory, cache, release });
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
cache?.close();
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
}),
|
|
180
|
+
max_messages_context: tool({
|
|
181
|
+
title: "Show a message",
|
|
182
|
+
description: "One message by id, and optionally the messages either side of it, oldest first. The one asked for " +
|
|
183
|
+
"carries anchor: true.",
|
|
184
|
+
input: v.object({
|
|
185
|
+
chat,
|
|
186
|
+
message,
|
|
187
|
+
before: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(100))),
|
|
188
|
+
after: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(100))),
|
|
189
|
+
}),
|
|
190
|
+
annotations: READ,
|
|
191
|
+
answer: async (client, args) => {
|
|
192
|
+
const chatId = await client.chats.resolve(args.chat);
|
|
193
|
+
return {
|
|
194
|
+
items: await client.messages.around(chatId, args.message, { before: args.before ?? 0, after: args.after ?? 0 }),
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Registered only with `--allow-send`, so a server started without it has no way to write at all —
|
|
201
|
+
* not a refusal at call time, an absence from the list.
|
|
202
|
+
*
|
|
203
|
+
* `requiresUserInteraction` is Claude Code's: an approval dialog on every call that allow-rules do
|
|
204
|
+
* not skip. Other clients ask by `destructiveHint` or `readOnlyHint`.
|
|
205
|
+
*/
|
|
206
|
+
const SEND_TOOLS = {
|
|
207
|
+
max_messages_send: tool({
|
|
208
|
+
title: "Send a message",
|
|
209
|
+
description: "Send one text message as the owner. Only when the owner asked for this exact text to this exact chat. " +
|
|
210
|
+
"A name that matches several chats is refused with the candidates — pick an id, never guess. " +
|
|
211
|
+
"On outcome_unknown, retry with the cid it returns and MAX drops the duplicate. " +
|
|
212
|
+
"With `at`, MAX sends it later and the answer carries `scheduledFor`; never retry a scheduled send — " +
|
|
213
|
+
"read max_messages_scheduled instead.",
|
|
214
|
+
input: v.object({
|
|
215
|
+
chat,
|
|
216
|
+
text: v.pipe(v.string(), v.minLength(1)),
|
|
217
|
+
silent: v.optional(v.pipe(v.boolean(), v.description("deliver without a notification"))),
|
|
218
|
+
cid: v.optional(v.pipe(v.number(), v.integer(), v.description("from an earlier outcome_unknown"))),
|
|
219
|
+
at: v.optional(v.pipe(v.string(), v.description("send later: 2026-09-25T09:00 (owner's local time) or 30m, 2h, 1d; 1 minute to 1 year ahead"))),
|
|
220
|
+
}),
|
|
221
|
+
annotations: WRITE,
|
|
222
|
+
_meta: APPROVE,
|
|
223
|
+
answer: async (client, args) => {
|
|
224
|
+
const at = args.at === undefined ? undefined : sendTime(args.at);
|
|
225
|
+
const chatId = await client.chats.resolve(args.chat);
|
|
226
|
+
return client.messages.send(chatId, args.text, sendOptions(args, at));
|
|
227
|
+
},
|
|
228
|
+
}),
|
|
229
|
+
max_messages_edit: tool({
|
|
230
|
+
title: "Edit a message",
|
|
231
|
+
description: "Replace the text of one of the owner's own messages. Only when the owner asked for this exact change. " +
|
|
232
|
+
"The other person may have read the old text already. Attachments stay.",
|
|
233
|
+
input: v.object({ chat, message, text: v.pipe(v.string(), v.minLength(1)) }),
|
|
234
|
+
annotations: WRITE,
|
|
235
|
+
_meta: APPROVE,
|
|
236
|
+
answer: async (client, args) => client.messages.edit(await client.chats.resolve(args.chat), args.message, args.text),
|
|
237
|
+
}),
|
|
238
|
+
max_messages_forward: tool({
|
|
239
|
+
title: "Forward a message",
|
|
240
|
+
description: "Forward one message to another chat as the owner. Only when the owner asked for this message to this chat. " +
|
|
241
|
+
"On outcome_unknown, retry with the cid it returns and MAX drops the duplicate.",
|
|
242
|
+
input: v.object({
|
|
243
|
+
chat: v.pipe(chat, v.description("the chat the message is in")),
|
|
244
|
+
message,
|
|
245
|
+
to: v.pipe(chat, v.description("the chat to forward it to")),
|
|
246
|
+
cid: v.optional(v.pipe(v.number(), v.integer(), v.description("from an earlier outcome_unknown"))),
|
|
247
|
+
}),
|
|
248
|
+
annotations: WRITE,
|
|
249
|
+
_meta: APPROVE,
|
|
250
|
+
answer: async (client, args) => client.messages.forward(await client.chats.resolve(args.chat), args.message, await client.chats.resolve(args.to), args.cid === undefined ? {} : { cid: args.cid }),
|
|
251
|
+
}),
|
|
252
|
+
max_messages_pin: tool({
|
|
253
|
+
title: "Pin a message",
|
|
254
|
+
description: "Pin one message in a chat, replacing what was pinned. Members are not notified.",
|
|
255
|
+
input: v.object({ chat, message }),
|
|
256
|
+
annotations: WRITE,
|
|
257
|
+
_meta: APPROVE,
|
|
258
|
+
answer: async (client, args) => client.messages.pin(await client.chats.resolve(args.chat), args.message),
|
|
259
|
+
}),
|
|
260
|
+
max_messages_unpin: tool({
|
|
261
|
+
title: "Unpin a message",
|
|
262
|
+
description: "Unpin whatever message is pinned in a chat.",
|
|
263
|
+
input: v.object({ chat }),
|
|
264
|
+
annotations: WRITE,
|
|
265
|
+
_meta: APPROVE,
|
|
266
|
+
answer: async (client, args) => client.messages.pin(await client.chats.resolve(args.chat), null),
|
|
267
|
+
}),
|
|
268
|
+
};
|
|
269
|
+
/** Registered only with `--allow-mark-read`: the other person sees it, and `--allow-send` does not imply it. */
|
|
270
|
+
/** Which profile permission each writing tool needs (`CLI-37`). */
|
|
271
|
+
const TOOL_PERMISSION = {
|
|
272
|
+
max_messages_send: "send",
|
|
273
|
+
max_messages_edit: "edit",
|
|
274
|
+
max_messages_forward: "forward",
|
|
275
|
+
max_messages_pin: "pin",
|
|
276
|
+
max_messages_unpin: "pin",
|
|
277
|
+
max_chats_read: "read",
|
|
278
|
+
max_messages_delete: "delete",
|
|
279
|
+
};
|
|
280
|
+
const MARK_READ_TOOLS = {
|
|
281
|
+
max_chats_read: tool({
|
|
282
|
+
title: "Mark a chat read",
|
|
283
|
+
description: "Mark a chat read up to a message, or up to its newest message. The other person sees that it was read. Only when the owner asked for it.",
|
|
284
|
+
input: v.object({ chat, message: v.optional(message) }),
|
|
285
|
+
annotations: WRITE,
|
|
286
|
+
_meta: APPROVE,
|
|
287
|
+
answer: async (client, args) => client.chats.markRead(await client.chats.resolve(args.chat), args.message),
|
|
288
|
+
}),
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Registered only with `--allow-delete`, which `--allow-send` does not imply, and only for the owner:
|
|
292
|
+
* deleting for everyone is the command's alone (`NEED-240`). The server's flag is the owner's word.
|
|
293
|
+
*/
|
|
294
|
+
const DELETE_TOOLS = {
|
|
295
|
+
max_messages_delete: tool({
|
|
296
|
+
title: "Delete messages for the owner",
|
|
297
|
+
description: `Delete up to ${DELETE_AT_ONCE} messages from the owner's view of a chat; the other people still see them. ` +
|
|
298
|
+
"Cannot be undone. Only when the owner asked for these exact messages to be deleted.",
|
|
299
|
+
input: v.object({ chat, messages: v.pipe(v.array(message), v.minLength(1), v.maxLength(DELETE_AT_ONCE)) }),
|
|
300
|
+
annotations: WRITE,
|
|
301
|
+
_meta: APPROVE,
|
|
302
|
+
answer: async (client, args) => client.messages.delete(await client.chats.resolve(args.chat), args.messages),
|
|
303
|
+
}),
|
|
304
|
+
};
|
|
305
|
+
const answered = (value) => ({
|
|
306
|
+
content: [{ type: "text", text: JSON.stringify(value) }],
|
|
307
|
+
structuredContent: value,
|
|
308
|
+
});
|
|
309
|
+
/** The same object the CLI prints on stderr, so an agent reads one error shape from both. */
|
|
310
|
+
const failed = (error) => {
|
|
311
|
+
const body = isCliError(error)
|
|
312
|
+
? { code: error.code, message: error.message, ...error.details }
|
|
313
|
+
: { code: "generic_failure", message: error instanceof Error ? error.message : String(error) };
|
|
314
|
+
return {
|
|
315
|
+
content: [{ type: "text", text: JSON.stringify({ error: body }) }],
|
|
316
|
+
structuredContent: { error: body },
|
|
317
|
+
isError: true,
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
export const registerTools = (server, session, { allowSend, confirmSend = false, allowMarkRead = false, allowDelete = false, defaultLimit, profile, transcribeModel = DEFAULT_MODEL, permitted, }) => {
|
|
321
|
+
const confirmed = confirmSend ? confirmer() : undefined;
|
|
322
|
+
const offered = {
|
|
323
|
+
...(allowSend ? SEND_TOOLS : {}),
|
|
324
|
+
...(allowMarkRead ? MARK_READ_TOOLS : {}),
|
|
325
|
+
...(allowDelete ? DELETE_TOOLS : {}),
|
|
326
|
+
};
|
|
327
|
+
const tools = {
|
|
328
|
+
...READ_TOOLS,
|
|
329
|
+
...Object.fromEntries(Object.entries(offered).filter(([name]) => !permitted || permitted.includes(TOOL_PERMISSION[name]))),
|
|
330
|
+
};
|
|
331
|
+
for (const [name, definition] of Object.entries(tools)) {
|
|
332
|
+
server.registerTool(name, {
|
|
333
|
+
title: definition.title,
|
|
334
|
+
description: definition.description,
|
|
335
|
+
inputSchema: toStandardJsonSchema(definition.input),
|
|
336
|
+
annotations: definition.annotations,
|
|
337
|
+
...(definition._meta ? { _meta: definition._meta } : {}),
|
|
338
|
+
}, async (args, ctx) => {
|
|
339
|
+
try {
|
|
340
|
+
const result = await session.use(name.replace(/^max_/, "mcp ").replaceAll("_", " "), (client, release) => confirmed && name === "max_messages_send"
|
|
341
|
+
? confirmed(client, args, ctx)
|
|
342
|
+
: definition.answer(client, args, { limit: defaultLimit, profile, transcribeModel, release }));
|
|
343
|
+
return isInputRequiredResult(result) ? result : answered(result);
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
return failed(error);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAEL,qBAAqB,GAItB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAkB,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,SAAS,EAAiB,WAAW,EAAE,MAAM,cAAc,CAAA;AAGpE,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,iCAAiC,CAAC,CAAC,CAAA;AACjG,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAA;A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U,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACzD,EACD,KAAK,EAAE,IAA6B,EAAE,GAAkB,EAAE,EAAE;YAC1D,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CACvG,SAAS,IAAI,IAAI,KAAK,mBAAmB;oBACvC,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,IAA2B,EAAE,GAAG,CAAC;oBACrD,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC,CAChG,CAAA;gBACD,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YAClE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;YACtB,CAAC;QACH,CAAC,CACF,CAAA;IACH,CAAC;AACH,CAAC,CAAA"}
|
package/dist/program.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,OAAO,EAEb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAA;AAQnD,OAAO,EAAE,KAAK,WAAW,EAAW,MAAM,uBAAuB,CAAA;AAoBjE,MAAM,WAAW,UAAW,SAAQ,WAAW;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,6EAA6E;IAC7E,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,mGAAmG;IACnG,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5B,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,eAAc,cAAmB,KAAG,OAqEjE,CAAA;AAOD;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,GAAU,MAAM,MAAM,EAAE,EAAE,UAAS,UAAe,KAAG,OAAO,CAAC,MAAM,CAmElF,CAAA"}
|
package/dist/program.js
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
import { CliError, exitCodeFor, GENERIC_FAILURE, processStreams } from "@leemour/cli-core";
|
|
1
|
+
import { CliError, exitCodeFor, GENERIC_FAILURE, processStreams, visibleControls, } from "@leemour/cli-core";
|
|
2
2
|
import { Command, CommanderError } from "commander";
|
|
3
3
|
import { accountCommand } from "./commands/account.js";
|
|
4
4
|
import { cacheCommand } from "./commands/cache.js";
|
|
5
5
|
import { chatsCommand } from "./commands/chats.js";
|
|
6
6
|
import { commandsCommand } from "./commands/commands.js";
|
|
7
|
+
import { completeCommand } from "./commands/complete.js";
|
|
7
8
|
import { configCommand } from "./commands/config.js";
|
|
8
9
|
import { contactsCommand } from "./commands/contacts.js";
|
|
9
10
|
import { provide } from "./commands/context.js";
|
|
10
11
|
import { doctorCommand } from "./commands/doctor.js";
|
|
12
|
+
import { exportCommand } from "./commands/export.js";
|
|
11
13
|
import { inboxCommand } from "./commands/inbox.js";
|
|
14
|
+
import { mcpCommand } from "./commands/mcp.js";
|
|
12
15
|
import { messagesCommand } from "./commands/messages.js";
|
|
16
|
+
import { modelsCommand } from "./commands/models.js";
|
|
13
17
|
import { reactionsCommand } from "./commands/reactions.js";
|
|
14
18
|
import { recipientsCommand } from "./commands/recipients.js";
|
|
15
19
|
import { runsCommand } from "./commands/runs.js";
|
|
16
20
|
import { sendsCommand } from "./commands/sends.js";
|
|
21
|
+
import { serveCommand } from "./commands/serve.js";
|
|
17
22
|
import { sessionCommand } from "./commands/session.js";
|
|
18
23
|
import { skillCommand } from "./commands/skill.js";
|
|
24
|
+
import { selfUpdateCommand } from "./commands/update.js";
|
|
25
|
+
import { watchCommand } from "./commands/watch.js";
|
|
19
26
|
import { commandWords, liftProfile } from "./profile.js";
|
|
27
|
+
import { updateNotice } from "./update.js";
|
|
20
28
|
import { VERSION } from "./version.js";
|
|
21
29
|
/**
|
|
22
30
|
* The command tree, built fresh on each call.
|
|
@@ -43,6 +51,8 @@ export const createProgram = ({ out, err } = {}) => {
|
|
|
43
51
|
.option("--offline", "answer from what was recorded and never connect; fails if nothing was")
|
|
44
52
|
.option("--record", "keep this run under `max runs` — ids and timings, never message content")
|
|
45
53
|
.option("--no-record", "do not keep it, whatever the configuration says")
|
|
54
|
+
.option("--serve", "start `max serve` in the background if it is not running (the default)")
|
|
55
|
+
.option("--no-serve", "do not start it; log in on this command's own connection unless one is running")
|
|
46
56
|
.showHelpAfterError();
|
|
47
57
|
// One resource per command, one action per subcommand — `max chats list`, `max messages send`.
|
|
48
58
|
// The shape `braze-cli` uses, and the reason there is no `max send`: an action is never a
|
|
@@ -52,16 +62,23 @@ export const createProgram = ({ out, err } = {}) => {
|
|
|
52
62
|
program.addCommand(chatsCommand());
|
|
53
63
|
program.addCommand(contactsCommand());
|
|
54
64
|
program.addCommand(messagesCommand());
|
|
65
|
+
program.addCommand(exportCommand());
|
|
66
|
+
program.addCommand(modelsCommand());
|
|
55
67
|
program.addCommand(reactionsCommand());
|
|
56
68
|
program.addCommand(recipientsCommand());
|
|
57
69
|
program.addCommand(sendsCommand());
|
|
58
70
|
program.addCommand(inboxCommand());
|
|
71
|
+
program.addCommand(serveCommand());
|
|
72
|
+
program.addCommand(watchCommand());
|
|
59
73
|
program.addCommand(configCommand());
|
|
60
74
|
program.addCommand(doctorCommand());
|
|
61
75
|
program.addCommand(cacheCommand());
|
|
62
76
|
program.addCommand(runsCommand());
|
|
63
77
|
program.addCommand(skillCommand());
|
|
64
78
|
program.addCommand(commandsCommand());
|
|
79
|
+
program.addCommand(selfUpdateCommand());
|
|
80
|
+
program.addCommand(completeCommand(), { hidden: true });
|
|
81
|
+
program.addCommand(mcpCommand());
|
|
65
82
|
// Depth-first: Commander does not pass `configureOutput` down to a command added with
|
|
66
83
|
// `addCommand`, so `max messages --help` would write to the real terminal while the top level
|
|
67
84
|
// wrote to the injected streams — and a test reading stdout would see nothing at all.
|
|
@@ -117,8 +134,12 @@ export const run = async (argv, options = {}) => {
|
|
|
117
134
|
});
|
|
118
135
|
return exitCodeFor("validation_error");
|
|
119
136
|
}
|
|
137
|
+
const notice = updateNotice(rest, { tty: options.tty, environment: options.update });
|
|
120
138
|
try {
|
|
121
139
|
await program.parseAsync(rest, { from: "user" });
|
|
140
|
+
const line = await notice;
|
|
141
|
+
if (line)
|
|
142
|
+
streams.diagnostic(line);
|
|
122
143
|
return process.exitCode === undefined ? 0 : Number(process.exitCode);
|
|
123
144
|
}
|
|
124
145
|
catch (error) {
|
|
@@ -148,6 +169,6 @@ export const run = async (argv, options = {}) => {
|
|
|
148
169
|
*/
|
|
149
170
|
const report = (streams, options, error) => {
|
|
150
171
|
const interactive = options.tty ?? process.stdout.isTTY === true;
|
|
151
|
-
streams.diagnostic(interactive ? `\u2717 ${error.message}` : JSON.stringify({ error }));
|
|
172
|
+
streams.diagnostic(interactive ? `\u2717 ${visibleControls(error.message)}` : JSON.stringify({ error }));
|
|
152
173
|
};
|
|
153
174
|
//# sourceMappingURL=program.js.map
|