@thenavidm/threads-mcp-cli 1.1.1 → 2.0.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 +141 -88
- package/SKILL.md +9 -8
- package/dist/app.d.ts +9 -0
- package/dist/app.js +101 -0
- package/dist/app.js.map +1 -0
- package/dist/auth/login.js +2 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/refresh.d.ts +8 -0
- package/dist/auth/refresh.js +39 -0
- package/dist/auth/refresh.js.map +1 -0
- package/dist/doctor.d.ts +11 -4
- package/dist/doctor.js +64 -125
- package/dist/doctor.js.map +1 -1
- package/dist/{server.d.ts → guide.d.ts} +14 -17
- package/dist/{server.js → guide.js} +18 -122
- package/dist/guide.js.map +1 -0
- package/dist/index.d.ts +5 -8
- package/dist/index.js +9 -162
- package/dist/index.js.map +1 -1
- package/dist/npx.d.ts +2 -0
- package/dist/npx.js +14 -0
- package/dist/npx.js.map +1 -0
- package/dist/tools/accounts.d.ts +5 -18
- package/dist/tools/discover.d.ts +5 -46
- package/dist/tools/insights.d.ts +5 -36
- package/dist/tools/kit.d.ts +23 -49
- package/dist/tools/kit.js +64 -79
- package/dist/tools/kit.js.map +1 -1
- package/dist/tools/posts.d.ts +10 -161
- package/dist/tools/read.d.ts +3 -24
- package/dist/tools/replies.d.ts +8 -79
- package/package.json +13 -7
- package/dist/cli.d.ts +0 -59
- package/dist/cli.js +0 -444
- package/dist/cli.js.map +0 -1
- package/dist/safety.d.ts +0 -52
- package/dist/safety.js +0 -85
- package/dist/safety.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/transport/http.d.ts +0 -28
- package/dist/transport/http.js +0 -107
- package/dist/transport/http.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thenavidm/threads-mcp-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Threads MCP server and CLI for Claude Code and AI agents. 30 tools for posting, chained threads, carousels, replies and reply approvals, insights, keyword search and profile discovery.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"threads-mcp": "dist/index.js",
|
|
9
|
-
"threads-cli": "dist/index.js"
|
|
9
|
+
"threads-cli": "dist/index.js",
|
|
10
|
+
"threads-mcp-cli": "dist/npx.js"
|
|
10
11
|
},
|
|
11
12
|
"engines": {
|
|
12
|
-
"node": ">=
|
|
13
|
+
"node": ">=22"
|
|
13
14
|
},
|
|
14
15
|
"scripts": {
|
|
15
16
|
"build": "tsc",
|
|
@@ -22,12 +23,12 @@
|
|
|
22
23
|
"build:mcpb": "bash desktop-extension/build.sh"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"zod": "^
|
|
27
|
-
"zod-to-json-schema": "^3.24.1"
|
|
26
|
+
"@thenavidm/slipway": "^0.1.7",
|
|
27
|
+
"zod": "^4.2.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^22.10.0",
|
|
31
|
+
"ajv": "^8.20.0",
|
|
31
32
|
"typescript": "^5.7.0",
|
|
32
33
|
"vitest": "^2.1.0"
|
|
33
34
|
},
|
|
@@ -51,7 +52,12 @@
|
|
|
51
52
|
"claude",
|
|
52
53
|
"claude-code",
|
|
53
54
|
"ai-agents",
|
|
54
|
-
"llm-tools"
|
|
55
|
+
"llm-tools",
|
|
56
|
+
"cli",
|
|
57
|
+
"social-media",
|
|
58
|
+
"codex",
|
|
59
|
+
"slipway",
|
|
60
|
+
"meta-threads"
|
|
55
61
|
],
|
|
56
62
|
"files": [
|
|
57
63
|
"dist",
|
package/dist/cli.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The CLI adapter.
|
|
3
|
-
*
|
|
4
|
-
* `register()` in tools/kit.ts turns a `ToolSpec` into an MCP tool. This turns
|
|
5
|
-
* the same spec into a shell command, from the same `ALL_TOOLS` array, through
|
|
6
|
-
* the same handler and the same `WriteGuard`. Nothing is described twice, so a
|
|
7
|
-
* tool added tomorrow is a command tomorrow and the two surfaces cannot drift.
|
|
8
|
-
*
|
|
9
|
-
* The command IS the tool name. `create_post` runs as `create-post`, and the
|
|
10
|
-
* underscore form works too. Inventing a prettier command tree would mean a
|
|
11
|
-
* hand-written mapping, which is exactly the drift this avoids, and it would
|
|
12
|
-
* force anyone reading the SKILL.md to learn two vocabularies for one action.
|
|
13
|
-
*
|
|
14
|
-
* Zod is the only schema: every flag, its placeholder, its help text and its
|
|
15
|
-
* validation come from the shape the MCP tool already declares.
|
|
16
|
-
*/
|
|
17
|
-
import { type ZodRawShape } from "zod";
|
|
18
|
-
/** How a value reaches the parser, once the Zod wrappers are peeled off. */
|
|
19
|
-
type FlagKind = "string" | "number" | "boolean" | "enum" | "json";
|
|
20
|
-
type Flag = {
|
|
21
|
-
/** The schema key, e.g. `reply_control`. */
|
|
22
|
-
key: string;
|
|
23
|
-
/** The long flag, e.g. `--reply-control`. */
|
|
24
|
-
flag: string;
|
|
25
|
-
kind: FlagKind;
|
|
26
|
-
required: boolean;
|
|
27
|
-
repeatable: boolean;
|
|
28
|
-
choices?: string[];
|
|
29
|
-
help: string;
|
|
30
|
-
};
|
|
31
|
-
export declare function flagsFor(shape: ZodRawShape): Flag[];
|
|
32
|
-
/**
|
|
33
|
-
* Parse argv against a tool's flags.
|
|
34
|
-
*
|
|
35
|
-
* Zod does the real validation afterwards, so this only has to get the values
|
|
36
|
-
* into the right JavaScript types and catch the mistakes Zod would report in
|
|
37
|
-
* terms of a schema the person at the terminal never sees.
|
|
38
|
-
*/
|
|
39
|
-
export declare function parseArgs(argv: string[], flags: Flag[]): Record<string, unknown>;
|
|
40
|
-
/** Exit codes, so a script can branch without parsing the message. */
|
|
41
|
-
export declare const EXIT: {
|
|
42
|
-
readonly ok: 0;
|
|
43
|
-
readonly usage: 2;
|
|
44
|
-
readonly notFound: 3;
|
|
45
|
-
readonly auth: 4;
|
|
46
|
-
readonly api: 5;
|
|
47
|
-
readonly rateLimited: 7;
|
|
48
|
-
readonly config: 10;
|
|
49
|
-
};
|
|
50
|
-
/** Map a thrown error onto one of those, from the shape the API gave back. */
|
|
51
|
-
export declare function exitCodeFor(error: unknown): number;
|
|
52
|
-
/**
|
|
53
|
-
* `--select id,post.title` keeps only the named fields. Dotted paths descend,
|
|
54
|
-
* arrays are traversed element-wise. This is what makes a long feed affordable.
|
|
55
|
-
*/
|
|
56
|
-
export declare function selectFields(data: unknown, paths: string[]): unknown;
|
|
57
|
-
export declare function isCliCommand(argv: string[]): boolean;
|
|
58
|
-
export declare function runCli(argv: string[]): Promise<number>;
|
|
59
|
-
export {};
|
package/dist/cli.js
DELETED
|
@@ -1,444 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The CLI adapter.
|
|
3
|
-
*
|
|
4
|
-
* `register()` in tools/kit.ts turns a `ToolSpec` into an MCP tool. This turns
|
|
5
|
-
* the same spec into a shell command, from the same `ALL_TOOLS` array, through
|
|
6
|
-
* the same handler and the same `WriteGuard`. Nothing is described twice, so a
|
|
7
|
-
* tool added tomorrow is a command tomorrow and the two surfaces cannot drift.
|
|
8
|
-
*
|
|
9
|
-
* The command IS the tool name. `create_post` runs as `create-post`, and the
|
|
10
|
-
* underscore form works too. Inventing a prettier command tree would mean a
|
|
11
|
-
* hand-written mapping, which is exactly the drift this avoids, and it would
|
|
12
|
-
* force anyone reading the SKILL.md to learn two vocabularies for one action.
|
|
13
|
-
*
|
|
14
|
-
* Zod is the only schema: every flag, its placeholder, its help text and its
|
|
15
|
-
* validation come from the shape the MCP tool already declares.
|
|
16
|
-
*/
|
|
17
|
-
import { z } from "zod";
|
|
18
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
19
|
-
import { loadConfig } from "./config.js";
|
|
20
|
-
import { accountsFromStore } from "./auth/store.js";
|
|
21
|
-
import { ThreadsClient } from "./api/client.js";
|
|
22
|
-
import { WriteGuard } from "./safety.js";
|
|
23
|
-
import { ALL_TOOLS } from "./tools/index.js";
|
|
24
|
-
import { makeContext } from "./tools/kit.js";
|
|
25
|
-
import { ThreadsError } from "./api/errors.js";
|
|
26
|
-
/**
|
|
27
|
-
* Peel `.optional()`, `.default()` and `.nullable()` to reach the real type.
|
|
28
|
-
*
|
|
29
|
-
* A description can sit on either the wrapper or the inner type depending on
|
|
30
|
-
* the order the tool author chained them, so both are collected on the way
|
|
31
|
-
* down and the outermost one wins.
|
|
32
|
-
*/
|
|
33
|
-
function unwrap(schema) {
|
|
34
|
-
let inner = schema;
|
|
35
|
-
let optional = false;
|
|
36
|
-
let description = schema.description;
|
|
37
|
-
for (;;) {
|
|
38
|
-
const typeName = inner._def.typeName;
|
|
39
|
-
if (typeName === "ZodOptional" || typeName === "ZodDefault" || typeName === "ZodNullable") {
|
|
40
|
-
if (typeName !== "ZodNullable")
|
|
41
|
-
optional = true;
|
|
42
|
-
inner = inner._def.innerType;
|
|
43
|
-
description ??= inner.description;
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
return { inner, optional, description };
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function kindOf(schema) {
|
|
50
|
-
const typeName = schema._def.typeName;
|
|
51
|
-
switch (typeName) {
|
|
52
|
-
case "ZodString":
|
|
53
|
-
return { kind: "string", repeatable: false };
|
|
54
|
-
case "ZodNumber":
|
|
55
|
-
return { kind: "number", repeatable: false };
|
|
56
|
-
case "ZodBoolean":
|
|
57
|
-
return { kind: "boolean", repeatable: false };
|
|
58
|
-
case "ZodEnum":
|
|
59
|
-
return {
|
|
60
|
-
kind: "enum",
|
|
61
|
-
choices: schema._def.values,
|
|
62
|
-
repeatable: false,
|
|
63
|
-
};
|
|
64
|
-
case "ZodArray": {
|
|
65
|
-
// An array of scalars is repeatable (`--text a --text b`). An array of
|
|
66
|
-
// objects is not worth flattening, so it takes JSON.
|
|
67
|
-
const element = unwrap(schema._def.type).inner;
|
|
68
|
-
const elementKind = element._def.typeName;
|
|
69
|
-
// An enum element is a word you type, so it belongs with the scalars.
|
|
70
|
-
// Treating it as JSON meant `--metrics views` was rejected and you had to
|
|
71
|
-
// write `--metrics '"views"'` instead.
|
|
72
|
-
const scalar = elementKind === "ZodString" || elementKind === "ZodNumber" || elementKind === "ZodEnum";
|
|
73
|
-
return { kind: scalar ? "string" : "json", repeatable: true };
|
|
74
|
-
}
|
|
75
|
-
default:
|
|
76
|
-
// Objects, unions, records and anything else take a JSON literal.
|
|
77
|
-
return { kind: "json", repeatable: false };
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/** Turn one schema entry into a flag. */
|
|
81
|
-
function toFlag(key, schema) {
|
|
82
|
-
const { inner, optional, description } = unwrap(schema);
|
|
83
|
-
const { kind, choices, repeatable } = kindOf(inner);
|
|
84
|
-
return {
|
|
85
|
-
key,
|
|
86
|
-
flag: `--${key.replace(/_/g, "-")}`,
|
|
87
|
-
kind,
|
|
88
|
-
required: !optional,
|
|
89
|
-
repeatable,
|
|
90
|
-
choices,
|
|
91
|
-
help: description ?? "",
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export function flagsFor(shape) {
|
|
95
|
-
return Object.entries(shape).map(([key, schema]) => toFlag(key, schema));
|
|
96
|
-
}
|
|
97
|
-
class UsageError extends Error {
|
|
98
|
-
}
|
|
99
|
-
/** Accept a flag as `--foo-bar`, `--foo_bar`, or `foo_bar`. */
|
|
100
|
-
function normalize(token) {
|
|
101
|
-
return token.replace(/^--/, "").replace(/-/g, "_");
|
|
102
|
-
}
|
|
103
|
-
function coerce(flag, raw) {
|
|
104
|
-
switch (flag.kind) {
|
|
105
|
-
case "number": {
|
|
106
|
-
const value = Number(raw);
|
|
107
|
-
if (!Number.isFinite(value))
|
|
108
|
-
throw new UsageError(`${flag.flag} expects a number, got '${raw}'.`);
|
|
109
|
-
return value;
|
|
110
|
-
}
|
|
111
|
-
case "enum":
|
|
112
|
-
if (flag.choices && !flag.choices.includes(raw)) {
|
|
113
|
-
throw new UsageError(`${flag.flag} expects one of: ${flag.choices.join(", ")}. Got '${raw}'.`);
|
|
114
|
-
}
|
|
115
|
-
return raw;
|
|
116
|
-
case "json":
|
|
117
|
-
try {
|
|
118
|
-
return JSON.parse(raw);
|
|
119
|
-
}
|
|
120
|
-
catch {
|
|
121
|
-
throw new UsageError(`${flag.flag} expects JSON, got '${raw}'.`);
|
|
122
|
-
}
|
|
123
|
-
default:
|
|
124
|
-
return raw;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Parse argv against a tool's flags.
|
|
129
|
-
*
|
|
130
|
-
* Zod does the real validation afterwards, so this only has to get the values
|
|
131
|
-
* into the right JavaScript types and catch the mistakes Zod would report in
|
|
132
|
-
* terms of a schema the person at the terminal never sees.
|
|
133
|
-
*/
|
|
134
|
-
export function parseArgs(argv, flags) {
|
|
135
|
-
const byKey = new Map(flags.map((f) => [f.key, f]));
|
|
136
|
-
const out = {};
|
|
137
|
-
const positional = [];
|
|
138
|
-
for (let i = 0; i < argv.length; i++) {
|
|
139
|
-
const token = argv[i];
|
|
140
|
-
if (!token.startsWith("--")) {
|
|
141
|
-
positional.push(token);
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
// `--flag=value` and `--flag value` are both normal to type.
|
|
145
|
-
const equals = token.indexOf("=");
|
|
146
|
-
const name = normalize(equals === -1 ? token : token.slice(0, equals));
|
|
147
|
-
const flag = byKey.get(name);
|
|
148
|
-
if (!flag)
|
|
149
|
-
throw new UsageError(`Unknown option ${token}.`);
|
|
150
|
-
if (flag.kind === "boolean") {
|
|
151
|
-
if (equals !== -1) {
|
|
152
|
-
const value = token.slice(equals + 1);
|
|
153
|
-
out[flag.key] = value !== "false" && value !== "0";
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
out[flag.key] = true;
|
|
157
|
-
}
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
const raw = equals === -1 ? argv[++i] : token.slice(equals + 1);
|
|
161
|
-
if (raw === undefined)
|
|
162
|
-
throw new UsageError(`${flag.flag} expects a value.`);
|
|
163
|
-
const value = coerce(flag, raw);
|
|
164
|
-
if (flag.repeatable) {
|
|
165
|
-
out[flag.key] = [...(out[flag.key] ?? []), value];
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
out[flag.key] = value;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
// One bare argument fills the first required flag, so `search-keyword "cats"`
|
|
172
|
-
// works the way anyone would expect it to before reading any help.
|
|
173
|
-
if (positional.length > 0) {
|
|
174
|
-
const target = flags.find((f) => f.required && out[f.key] === undefined);
|
|
175
|
-
if (!target)
|
|
176
|
-
throw new UsageError(`Unexpected argument '${positional[0]}'.`);
|
|
177
|
-
if (positional.length > 1)
|
|
178
|
-
throw new UsageError(`Unexpected argument '${positional[1]}'.`);
|
|
179
|
-
const value = coerce(target, positional[0]);
|
|
180
|
-
out[target.key] = target.repeatable ? [value] : value;
|
|
181
|
-
}
|
|
182
|
-
return out;
|
|
183
|
-
}
|
|
184
|
-
/** Exit codes, so a script can branch without parsing the message. */
|
|
185
|
-
export const EXIT = {
|
|
186
|
-
ok: 0, usage: 2, notFound: 3, auth: 4, api: 5, rateLimited: 7, config: 10,
|
|
187
|
-
};
|
|
188
|
-
/** Map a thrown error onto one of those, from the shape the API gave back. */
|
|
189
|
-
export function exitCodeFor(error) {
|
|
190
|
-
const e = error;
|
|
191
|
-
const status = e?.status;
|
|
192
|
-
const text = `${e?.code ?? ""} ${e?.message ?? ""}`.toLowerCase();
|
|
193
|
-
if (status === 429 || /rate ?limit/.test(text))
|
|
194
|
-
return EXIT.rateLimited;
|
|
195
|
-
// Config before auth: "no account configured" mentions a token, and matching
|
|
196
|
-
// auth first sent someone who had configured nothing looking for an expired
|
|
197
|
-
// credential. Only when there is no HTTP status, so a real 401 still wins.
|
|
198
|
-
if (!status && /not configured|no [a-z ]*(account|profile|credential|token|key)s? (is |are )?configured|missing .*env/.test(text))
|
|
199
|
-
return EXIT.config;
|
|
200
|
-
if (status === 401 || status === 403 || /auth|credential|token|cookie|session/.test(text))
|
|
201
|
-
return EXIT.auth;
|
|
202
|
-
if (status === 404 || /not found/.test(text))
|
|
203
|
-
return EXIT.notFound;
|
|
204
|
-
// A refused write is the caller asking for something the guard will not do:
|
|
205
|
-
// that is a usage problem to fix in the command, not an API failure to retry.
|
|
206
|
-
if (/will not run without|read-only|is unavailable/.test(text))
|
|
207
|
-
return EXIT.usage;
|
|
208
|
-
if (/not configured|missing .*env|config/.test(text))
|
|
209
|
-
return EXIT.config;
|
|
210
|
-
if (typeof status === "number" && status >= 500)
|
|
211
|
-
return EXIT.api;
|
|
212
|
-
return EXIT.api;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* `--select id,post.title` keeps only the named fields. Dotted paths descend,
|
|
216
|
-
* arrays are traversed element-wise. This is what makes a long feed affordable.
|
|
217
|
-
*/
|
|
218
|
-
export function selectFields(data, paths) {
|
|
219
|
-
if (Array.isArray(data))
|
|
220
|
-
return data.map((d) => selectFields(d, paths));
|
|
221
|
-
if (data === null || typeof data !== "object")
|
|
222
|
-
return data;
|
|
223
|
-
const out = {};
|
|
224
|
-
for (const path of paths) {
|
|
225
|
-
const [head, ...rest] = path.split(".");
|
|
226
|
-
if (head === undefined)
|
|
227
|
-
continue;
|
|
228
|
-
const value = data[head];
|
|
229
|
-
if (value === undefined)
|
|
230
|
-
continue;
|
|
231
|
-
out[head] = rest.length ? selectFields(value, [rest.join(".")]) : value;
|
|
232
|
-
}
|
|
233
|
-
return out;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Print a handler result.
|
|
237
|
-
*
|
|
238
|
-
* Reading tools already return the tagged text from `format/`, which is the
|
|
239
|
-
* shaped-for-a-model output and is just as readable in a terminal. Writing
|
|
240
|
-
* tools return a small object. `--json` forces JSON either way so a script
|
|
241
|
-
* never has to know which kind of tool it called.
|
|
242
|
-
*/
|
|
243
|
-
function emit(data, format) {
|
|
244
|
-
if (format === "text" && typeof data === "string") {
|
|
245
|
-
process.stdout.write(data.endsWith("\n") ? data : `${data}\n`);
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const json = format === "compact" ? JSON.stringify(data) : JSON.stringify(data, null, 2);
|
|
249
|
-
process.stdout.write(`${json}\n`);
|
|
250
|
-
}
|
|
251
|
-
/** Errors are JSON on stderr, always, so a caller parses one shape. */
|
|
252
|
-
function emitError(error) {
|
|
253
|
-
const payload = error instanceof ThreadsError
|
|
254
|
-
? error.toJSON()
|
|
255
|
-
: { error: error?.message ?? String(error) };
|
|
256
|
-
process.stderr.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
257
|
-
}
|
|
258
|
-
/* -------------------------------------------------------------------- help */
|
|
259
|
-
function commandName(tool) {
|
|
260
|
-
return tool.replace(/_/g, "-");
|
|
261
|
-
}
|
|
262
|
-
/** Where help text starts, when the flag is short enough to leave room. */
|
|
263
|
-
const COLUMN = 34;
|
|
264
|
-
/**
|
|
265
|
-
* The name this was invoked as, so examples are copy-pasteable.
|
|
266
|
-
*
|
|
267
|
-
* The package ships two binaries onto the same file. Printing `threads-mcp` at
|
|
268
|
-
* someone who typed `threads-cli` hands them a command that works but is not
|
|
269
|
-
* the one they have in their fingers.
|
|
270
|
-
*/
|
|
271
|
-
function binName() {
|
|
272
|
-
const name = (process.argv[1] ?? "").split("/").pop() ?? "";
|
|
273
|
-
return name.startsWith("threads-cli") ? "threads-cli" : "threads-mcp";
|
|
274
|
-
}
|
|
275
|
-
function renderToolHelp(spec) {
|
|
276
|
-
const flags = flagsFor(spec.schema);
|
|
277
|
-
const required = flags.filter((f) => f.required);
|
|
278
|
-
const optional = flags.filter((f) => !f.required);
|
|
279
|
-
const usage = [
|
|
280
|
-
`${binName()} ${commandName(spec.name)}`,
|
|
281
|
-
...required.map((f) => `${f.flag} <${f.kind}>`),
|
|
282
|
-
optional.length > 0 ? "[options]" : "",
|
|
283
|
-
]
|
|
284
|
-
.filter(Boolean)
|
|
285
|
-
.join(" ");
|
|
286
|
-
const lines = [``, spec.description.trim(), ``, `Usage:`, ` ${usage}`, ``];
|
|
287
|
-
const describe = (list, heading) => {
|
|
288
|
-
if (list.length === 0)
|
|
289
|
-
return;
|
|
290
|
-
lines.push(`${heading}:`);
|
|
291
|
-
for (const f of list) {
|
|
292
|
-
const placeholder = f.kind === "boolean" ? "" : ` <${f.choices ? f.choices.join("|") : f.kind}>`;
|
|
293
|
-
const left = ` ${f.flag}${placeholder}`;
|
|
294
|
-
const help = f.repeatable ? `${f.help} Repeatable.` : f.help;
|
|
295
|
-
if (!help) {
|
|
296
|
-
lines.push(left);
|
|
297
|
-
}
|
|
298
|
-
else if (left.length < COLUMN) {
|
|
299
|
-
lines.push(`${left.padEnd(COLUMN)}${help}`);
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
// A long enum spelled out in the placeholder would push the help off
|
|
303
|
-
// the line, so it gets its own.
|
|
304
|
-
lines.push(left, `${" ".repeat(COLUMN)}${help}`);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
lines.push(``);
|
|
308
|
-
};
|
|
309
|
-
describe(required, "Required");
|
|
310
|
-
describe(optional, "Options");
|
|
311
|
-
lines.push(`Output:`);
|
|
312
|
-
lines.push(` --json force JSON`);
|
|
313
|
-
lines.push(` --compact force single-line JSON`);
|
|
314
|
-
lines.push(` --agent machine mode: JSON, compact, no prompts, no colour`);
|
|
315
|
-
lines.push(` --select <a,b.c> keep only these fields, dotted paths descend`);
|
|
316
|
-
lines.push(``);
|
|
317
|
-
lines.push(`Risk: ${spec.risk}`);
|
|
318
|
-
lines.push(``);
|
|
319
|
-
return lines.join("\n");
|
|
320
|
-
}
|
|
321
|
-
function renderToolList(tools) {
|
|
322
|
-
const width = Math.max(...tools.map((t) => commandName(t.name).length)) + 2;
|
|
323
|
-
const bin = binName();
|
|
324
|
-
const lines = [``, `${bin} commands (${tools.length})`, ``];
|
|
325
|
-
for (const tool of tools) {
|
|
326
|
-
const mark = tool.risk === "read" ? " " : tool.risk === "destructive" ? "!" : "*";
|
|
327
|
-
lines.push(` ${mark} ${commandName(tool.name).padEnd(width)}${tool.title}`);
|
|
328
|
-
}
|
|
329
|
-
lines.push(``);
|
|
330
|
-
lines.push(` * writes ! irreversible, needs --confirm`);
|
|
331
|
-
lines.push(``);
|
|
332
|
-
lines.push(` ${bin} <command> --help what it takes`);
|
|
333
|
-
lines.push(` ${bin} schema <command> the JSON schema an MCP client sees`);
|
|
334
|
-
lines.push(``);
|
|
335
|
-
return lines.join("\n");
|
|
336
|
-
}
|
|
337
|
-
/* ---------------------------------------------------------------- dispatch */
|
|
338
|
-
/** The tools this process will expose, with READ_ONLY applied exactly as the server applies it. */
|
|
339
|
-
function visibleTools(guard) {
|
|
340
|
-
return ALL_TOOLS.filter((tool) => !guard.readOnly || tool.risk === "read");
|
|
341
|
-
}
|
|
342
|
-
export function isCliCommand(argv) {
|
|
343
|
-
const first = argv[0];
|
|
344
|
-
if (!first || first.startsWith("-"))
|
|
345
|
-
return false;
|
|
346
|
-
if (first === "tools" || first === "schema")
|
|
347
|
-
return true;
|
|
348
|
-
const name = normalize(first);
|
|
349
|
-
return ALL_TOOLS.some((tool) => tool.name === name);
|
|
350
|
-
}
|
|
351
|
-
export async function runCli(argv) {
|
|
352
|
-
// The store is read here rather than inside loadConfig so that the config
|
|
353
|
-
// module stays free of filesystem access, exactly as index.ts does it. A CLI
|
|
354
|
-
// that skipped it would not see the token `threads-mcp login` wrote.
|
|
355
|
-
const stored = accountsFromStore(loadConfig().storePath);
|
|
356
|
-
const config = loadConfig(stored);
|
|
357
|
-
const guard = new WriteGuard(config, "cli");
|
|
358
|
-
const tools = visibleTools(guard);
|
|
359
|
-
const command = argv[0];
|
|
360
|
-
const rest = argv.slice(1);
|
|
361
|
-
if (command === "tools") {
|
|
362
|
-
process.stdout.write(renderToolList(tools));
|
|
363
|
-
return 0;
|
|
364
|
-
}
|
|
365
|
-
if (command === "schema") {
|
|
366
|
-
const wanted = normalize(rest[0] ?? "");
|
|
367
|
-
const spec = tools.find((t) => t.name === wanted);
|
|
368
|
-
if (!spec) {
|
|
369
|
-
emitError(new Error(`Unknown command '${rest[0] ?? ""}'. Run \`${binName()} tools\`.`));
|
|
370
|
-
return 1;
|
|
371
|
-
}
|
|
372
|
-
// The same JSON Schema an MCP client receives, so the two surfaces are
|
|
373
|
-
// provably one. Emitting the Zod object instead printed its internals
|
|
374
|
-
// (`_def`, `~standard`), which is not a schema anyone can consume.
|
|
375
|
-
emit(zodToJsonSchema(z.object(spec.schema).describe(spec.description)), "json");
|
|
376
|
-
return 0;
|
|
377
|
-
}
|
|
378
|
-
const name = normalize(command);
|
|
379
|
-
const spec = tools.find((t) => t.name === name);
|
|
380
|
-
if (!spec) {
|
|
381
|
-
const hidden = ALL_TOOLS.find((t) => t.name === name);
|
|
382
|
-
emitError(new Error(hidden
|
|
383
|
-
? `${name} is unavailable: this server is running with THREADS_READ_ONLY=1.`
|
|
384
|
-
: `Unknown command '${command}'. Run \`${binName()} tools\`.`));
|
|
385
|
-
return 1;
|
|
386
|
-
}
|
|
387
|
-
if (rest.includes("--help") || rest.includes("-h")) {
|
|
388
|
-
process.stdout.write(renderToolHelp(spec));
|
|
389
|
-
return 0;
|
|
390
|
-
}
|
|
391
|
-
// `--agent` is the whole machine-readable posture in one flag, so an agent
|
|
392
|
-
// does not have to remember four and silently forget one.
|
|
393
|
-
const agent = rest.includes("--agent");
|
|
394
|
-
const format = rest.includes("--compact") || agent ? "compact" : rest.includes("--json") ? "json" : "text";
|
|
395
|
-
const selectAt = rest.findIndex((t) => t === "--select" || t.startsWith("--select="));
|
|
396
|
-
const selectRaw = selectAt === -1
|
|
397
|
-
? undefined
|
|
398
|
-
: rest[selectAt].includes("=")
|
|
399
|
-
? rest[selectAt].split("=").slice(1).join("=")
|
|
400
|
-
: rest[selectAt + 1];
|
|
401
|
-
const select = selectRaw?.split(",").map((f) => f.trim()).filter(Boolean);
|
|
402
|
-
const consumed = new Set(["--json", "--compact", "--agent", "--no-color", "--no-input", "--yes"]);
|
|
403
|
-
const toolArgv = rest.filter((token, i) => {
|
|
404
|
-
if (consumed.has(token))
|
|
405
|
-
return false;
|
|
406
|
-
if (token === "--select" || token.startsWith("--select="))
|
|
407
|
-
return false;
|
|
408
|
-
if (selectAt !== -1 && i === selectAt + 1 && !rest[selectAt].includes("="))
|
|
409
|
-
return false;
|
|
410
|
-
return true;
|
|
411
|
-
});
|
|
412
|
-
try {
|
|
413
|
-
const parsed = parseArgs(toolArgv, flagsFor(spec.schema));
|
|
414
|
-
// Zod is the authority on validity, exactly as it is for an MCP call.
|
|
415
|
-
const args = z.object(spec.schema).parse(parsed);
|
|
416
|
-
const client = new ThreadsClient(config);
|
|
417
|
-
const ctx = makeContext(client, config, guard);
|
|
418
|
-
// The same gate the MCP path applies, so --confirm, READ_ONLY,
|
|
419
|
-
// ALLOW_DESTRUCTIVE and the audit log all behave identically here.
|
|
420
|
-
if (spec.risk !== "read") {
|
|
421
|
-
const summary = spec.summary?.(args) ?? spec.name;
|
|
422
|
-
guard.check(spec.name, spec.risk, args.confirm, summary);
|
|
423
|
-
}
|
|
424
|
-
const result = await spec.handler(args, ctx);
|
|
425
|
-
emit(select?.length ? selectFields(result, select) : result, format);
|
|
426
|
-
return EXIT.ok;
|
|
427
|
-
}
|
|
428
|
-
catch (error) {
|
|
429
|
-
if (error instanceof UsageError) {
|
|
430
|
-
emitError(error);
|
|
431
|
-
if (!agent)
|
|
432
|
-
process.stderr.write(renderToolHelp(spec));
|
|
433
|
-
return EXIT.usage;
|
|
434
|
-
}
|
|
435
|
-
if (error instanceof z.ZodError) {
|
|
436
|
-
const first = error.issues[0];
|
|
437
|
-
emitError(new Error(first ? `${first.path.join(".") || "argument"}: ${first.message}` : error.message));
|
|
438
|
-
return EXIT.usage;
|
|
439
|
-
}
|
|
440
|
-
emitError(error);
|
|
441
|
-
return exitCodeFor(error);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAqC,MAAM,KAAK,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAsC,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAiB/C;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,MAAkB;IAChC,IAAI,KAAK,GAAG,MAAM,CAAC;IACnB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IAErC,SAAS,CAAC;QACR,MAAM,QAAQ,GAAI,KAAyC,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC1E,IAAI,QAAQ,KAAK,aAAa,IAAI,QAAQ,KAAK,YAAY,IAAI,QAAQ,KAAK,aAAa,EAAE,CAAC;YAC1F,IAAI,QAAQ,KAAK,aAAa;gBAAE,QAAQ,GAAG,IAAI,CAAC;YAChD,KAAK,GAAI,KAAwD,CAAC,IAAI,CAAC,SAAS,CAAC;YACjF,WAAW,KAAK,KAAK,CAAC,WAAW,CAAC;YAClC,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AAI,KAAK,YAAY,UAAU,EAAE,CAAC;YAChC,SAAS,CAAC,KAAK,CAAC,CAAC;YACjB,IAAI,CAAC,KAAK;gBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QACD,IAAI,KAAK,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC9B,SAAS,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,UAAU,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YACxG,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QACD,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
package/dist/safety.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Decides whether a write is allowed to reach Threads.
|
|
3
|
-
*
|
|
4
|
-
* The hazard is specific and worth naming. A Threads post is public the instant
|
|
5
|
-
* it lands, and Threads has no edit endpoint: fixing a typo means deleting and
|
|
6
|
-
* republishing, which loses the replies and the likes and spends one of the
|
|
7
|
-
* hundred deletions the account gets each day. There is no unsend and no
|
|
8
|
-
* revision. None of that is dangerous when a person meant it.
|
|
9
|
-
*
|
|
10
|
-
* So: everything works, and the operations that reach other people need an
|
|
11
|
-
* explicit `confirm: true` the model has to set deliberately after reading a
|
|
12
|
-
* description that says why. That is a speed bump a careless call trips over
|
|
13
|
-
* and an intentional one clears in a single retry.
|
|
14
|
-
*
|
|
15
|
-
* Hiding a reply is not guarded. It is one call to undo and reversible from the
|
|
16
|
-
* app, and a confirmation on every hide would train the model to pass `confirm`
|
|
17
|
-
* reflexively, which is worse than not asking at all.
|
|
18
|
-
*
|
|
19
|
-
* THREADS_READ_ONLY=1 removes every write from the tool list entirely, for
|
|
20
|
-
* pointing an agent at an account it should only ever read.
|
|
21
|
-
*/
|
|
22
|
-
import type { Config } from "./config.js";
|
|
23
|
-
export type Risk =
|
|
24
|
-
/** Reads public data, or your own. */
|
|
25
|
-
"read"
|
|
26
|
-
/** Changes something reversible: hiding a reply, approving one. */
|
|
27
|
-
| "write"
|
|
28
|
-
/** Public the moment it runs, or cannot be undone. */
|
|
29
|
-
| "destructive";
|
|
30
|
-
/** Which surface a guard is protecting, so refusals name the right syntax. */
|
|
31
|
-
export type Surface = "mcp" | "cli";
|
|
32
|
-
export declare class WriteGuard {
|
|
33
|
-
private readonly config;
|
|
34
|
-
private readonly surface;
|
|
35
|
-
constructor(config: Config, surface?: Surface);
|
|
36
|
-
/** `--confirm` in a terminal, `confirm: true` in a tool call. */
|
|
37
|
-
private get confirmFlag();
|
|
38
|
-
get readOnly(): boolean;
|
|
39
|
-
check(tool: string, risk: Risk, confirm: boolean | undefined, summary: string): void;
|
|
40
|
-
/** Append-only record of every attempted write, when THREADS_AUDIT_LOG is set. */
|
|
41
|
-
private audit;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* MCP annotations for a risk level.
|
|
45
|
-
*
|
|
46
|
-
* Clients use these to decide what to auto-approve, so they have to be honest.
|
|
47
|
-
* `openWorldHint` is true for everything because every call leaves the machine,
|
|
48
|
-
* and `idempotentHint` is false for a post because calling it twice posts twice.
|
|
49
|
-
*/
|
|
50
|
-
export declare function annotationsFor(risk: Risk, options?: {
|
|
51
|
-
idempotent?: boolean;
|
|
52
|
-
}): Record<string, boolean>;
|