@autoposting.ai/cli 0.2.31 → 0.3.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/dist/cli.cjs +173 -170
- package/dist/cli.cjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -9,9 +9,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
9
9
|
var __esm = (fn, res) => function __init() {
|
|
10
10
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
11
|
};
|
|
12
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
13
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
-
};
|
|
15
12
|
var __export = (target, all) => {
|
|
16
13
|
for (var name in all)
|
|
17
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -33,54 +30,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
30
|
mod
|
|
34
31
|
));
|
|
35
32
|
|
|
36
|
-
// ../sdk/dist/index.
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
// ../sdk/dist/index.mjs
|
|
34
|
+
function createError(status, body) {
|
|
35
|
+
const message = body.error ?? "An error occurred";
|
|
36
|
+
const code = body.code ?? "UNKNOWN";
|
|
37
|
+
if (status === 401) return new AuthenticationError(message, status, code);
|
|
38
|
+
if (status === 403) return new ScopeError(message, status, code);
|
|
39
|
+
if (status === 404) return new NotFoundError(message, status, code);
|
|
40
|
+
if (status === 400 || status === 422) return new ValidationError(message, status, code);
|
|
41
|
+
if (status === 429) return new RateLimitError(message, status, code);
|
|
42
|
+
if (status >= 500) return new ServerError(message, status, code);
|
|
43
|
+
return new AutopostingError(message, status, code);
|
|
44
|
+
}
|
|
45
|
+
var VERSION, AutopostingError, AuthenticationError, ScopeError, NotFoundError, ValidationError, RateLimitError, ServerError, Resource, AgentsResource, BillingResource, BrandsResource, CarouselsResource, ClipsResource, PostsResource, KbResource, IdeasResource, UsageResource, WebhooksResource, WorkspacesResource, Autoposting;
|
|
46
|
+
var init_dist = __esm({
|
|
47
|
+
"../sdk/dist/index.mjs"() {
|
|
39
48
|
"use strict";
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
43
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
44
|
-
var __export2 = (target, all) => {
|
|
45
|
-
for (var name in all)
|
|
46
|
-
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
47
|
-
};
|
|
48
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
49
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
50
|
-
for (let key of __getOwnPropNames2(from))
|
|
51
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
52
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
53
|
-
}
|
|
54
|
-
return to;
|
|
55
|
-
};
|
|
56
|
-
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
57
|
-
var index_exports = {};
|
|
58
|
-
__export2(index_exports, {
|
|
59
|
-
AgentsResource: () => AgentsResource,
|
|
60
|
-
AuthenticationError: () => AuthenticationError,
|
|
61
|
-
Autoposting: () => Autoposting13,
|
|
62
|
-
AutopostingError: () => AutopostingError,
|
|
63
|
-
BillingResource: () => BillingResource,
|
|
64
|
-
BrandsResource: () => BrandsResource,
|
|
65
|
-
CarouselsResource: () => CarouselsResource,
|
|
66
|
-
ClipsResource: () => ClipsResource,
|
|
67
|
-
IdeasResource: () => IdeasResource,
|
|
68
|
-
KbResource: () => KbResource,
|
|
69
|
-
NotFoundError: () => NotFoundError,
|
|
70
|
-
PostsResource: () => PostsResource,
|
|
71
|
-
RateLimitError: () => RateLimitError,
|
|
72
|
-
Resource: () => Resource,
|
|
73
|
-
ScopeError: () => ScopeError,
|
|
74
|
-
ServerError: () => ServerError,
|
|
75
|
-
UsageResource: () => UsageResource,
|
|
76
|
-
VERSION: () => VERSION3,
|
|
77
|
-
ValidationError: () => ValidationError,
|
|
78
|
-
WebhooksResource: () => WebhooksResource,
|
|
79
|
-
WorkspacesResource: () => WorkspacesResource
|
|
80
|
-
});
|
|
81
|
-
module2.exports = __toCommonJS(index_exports);
|
|
82
|
-
var VERSION3 = "0.1.0";
|
|
83
|
-
var AutopostingError = class extends Error {
|
|
49
|
+
VERSION = "0.3.0";
|
|
50
|
+
AutopostingError = class extends Error {
|
|
84
51
|
status;
|
|
85
52
|
code;
|
|
86
53
|
constructor(message, status, code) {
|
|
@@ -91,31 +58,20 @@ var require_dist = __commonJS({
|
|
|
91
58
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
92
59
|
}
|
|
93
60
|
};
|
|
94
|
-
|
|
61
|
+
AuthenticationError = class extends AutopostingError {
|
|
95
62
|
};
|
|
96
|
-
|
|
63
|
+
ScopeError = class extends AutopostingError {
|
|
97
64
|
};
|
|
98
|
-
|
|
65
|
+
NotFoundError = class extends AutopostingError {
|
|
99
66
|
};
|
|
100
|
-
|
|
67
|
+
ValidationError = class extends AutopostingError {
|
|
101
68
|
};
|
|
102
|
-
|
|
69
|
+
RateLimitError = class extends AutopostingError {
|
|
103
70
|
retryAfter;
|
|
104
71
|
};
|
|
105
|
-
|
|
72
|
+
ServerError = class extends AutopostingError {
|
|
106
73
|
};
|
|
107
|
-
|
|
108
|
-
const message = body.error ?? "An error occurred";
|
|
109
|
-
const code = body.code ?? "UNKNOWN";
|
|
110
|
-
if (status === 401) return new AuthenticationError(message, status, code);
|
|
111
|
-
if (status === 403) return new ScopeError(message, status, code);
|
|
112
|
-
if (status === 404) return new NotFoundError(message, status, code);
|
|
113
|
-
if (status === 400 || status === 422) return new ValidationError(message, status, code);
|
|
114
|
-
if (status === 429) return new RateLimitError(message, status, code);
|
|
115
|
-
if (status >= 500) return new ServerError(message, status, code);
|
|
116
|
-
return new AutopostingError(message, status, code);
|
|
117
|
-
}
|
|
118
|
-
var Resource = class {
|
|
74
|
+
Resource = class {
|
|
119
75
|
constructor(client) {
|
|
120
76
|
this.client = client;
|
|
121
77
|
}
|
|
@@ -136,7 +92,7 @@ var require_dist = __commonJS({
|
|
|
136
92
|
return this.client.request("DELETE", path2);
|
|
137
93
|
}
|
|
138
94
|
};
|
|
139
|
-
|
|
95
|
+
AgentsResource = class extends Resource {
|
|
140
96
|
list() {
|
|
141
97
|
return this.get("/agents");
|
|
142
98
|
}
|
|
@@ -162,7 +118,7 @@ var require_dist = __commonJS({
|
|
|
162
118
|
return this.get(`/agents/${id}/runs`);
|
|
163
119
|
}
|
|
164
120
|
};
|
|
165
|
-
|
|
121
|
+
BillingResource = class extends Resource {
|
|
166
122
|
status() {
|
|
167
123
|
return this.get("/billing/status");
|
|
168
124
|
}
|
|
@@ -170,7 +126,7 @@ var require_dist = __commonJS({
|
|
|
170
126
|
return this.get("/billing/credits");
|
|
171
127
|
}
|
|
172
128
|
};
|
|
173
|
-
|
|
129
|
+
BrandsResource = class extends Resource {
|
|
174
130
|
list() {
|
|
175
131
|
return this.get("/brands");
|
|
176
132
|
}
|
|
@@ -190,7 +146,7 @@ var require_dist = __commonJS({
|
|
|
190
146
|
return this.get(`/brands/${slug}/auth/status`);
|
|
191
147
|
}
|
|
192
148
|
};
|
|
193
|
-
|
|
149
|
+
CarouselsResource = class extends Resource {
|
|
194
150
|
list() {
|
|
195
151
|
return this.get("/carousels");
|
|
196
152
|
}
|
|
@@ -211,7 +167,7 @@ var require_dist = __commonJS({
|
|
|
211
167
|
return this.client.request("DELETE", `/carousels/${id}`);
|
|
212
168
|
}
|
|
213
169
|
};
|
|
214
|
-
|
|
170
|
+
ClipsResource = class extends Resource {
|
|
215
171
|
list() {
|
|
216
172
|
return this.client.request("GET", "/clips");
|
|
217
173
|
}
|
|
@@ -241,7 +197,7 @@ var require_dist = __commonJS({
|
|
|
241
197
|
return this.client.request("DELETE", `/clips/${id}`);
|
|
242
198
|
}
|
|
243
199
|
};
|
|
244
|
-
|
|
200
|
+
PostsResource = class extends Resource {
|
|
245
201
|
list(params) {
|
|
246
202
|
return this.client.request(
|
|
247
203
|
"GET",
|
|
@@ -283,7 +239,7 @@ var require_dist = __commonJS({
|
|
|
283
239
|
);
|
|
284
240
|
}
|
|
285
241
|
};
|
|
286
|
-
|
|
242
|
+
KbResource = class extends Resource {
|
|
287
243
|
list() {
|
|
288
244
|
return this.get("/kbs");
|
|
289
245
|
}
|
|
@@ -306,7 +262,7 @@ var require_dist = __commonJS({
|
|
|
306
262
|
return this.get(`/kbs/${id}/docs`);
|
|
307
263
|
}
|
|
308
264
|
};
|
|
309
|
-
|
|
265
|
+
IdeasResource = class extends Resource {
|
|
310
266
|
generate(params = {}) {
|
|
311
267
|
return this.post("/ideas/generate", params);
|
|
312
268
|
}
|
|
@@ -320,12 +276,12 @@ var require_dist = __commonJS({
|
|
|
320
276
|
return this.delete(`/ideas/${id}`);
|
|
321
277
|
}
|
|
322
278
|
};
|
|
323
|
-
|
|
279
|
+
UsageResource = class extends Resource {
|
|
324
280
|
summary() {
|
|
325
281
|
return this.get("/usage/summary");
|
|
326
282
|
}
|
|
327
283
|
};
|
|
328
|
-
|
|
284
|
+
WebhooksResource = class extends Resource {
|
|
329
285
|
list() {
|
|
330
286
|
return this.get("/webhooks");
|
|
331
287
|
}
|
|
@@ -345,7 +301,7 @@ var require_dist = __commonJS({
|
|
|
345
301
|
return this.post(`/webhooks/${id}/test`);
|
|
346
302
|
}
|
|
347
303
|
};
|
|
348
|
-
|
|
304
|
+
WorkspacesResource = class extends Resource {
|
|
349
305
|
constructor(client) {
|
|
350
306
|
super(client);
|
|
351
307
|
}
|
|
@@ -363,7 +319,7 @@ var require_dist = __commonJS({
|
|
|
363
319
|
return this.post("/orgs/set-active", { organizationId: id });
|
|
364
320
|
}
|
|
365
321
|
};
|
|
366
|
-
|
|
322
|
+
Autoposting = class {
|
|
367
323
|
/** @internal Not part of the public API — use SDK methods to make requests. */
|
|
368
324
|
_apiKey;
|
|
369
325
|
baseUrl;
|
|
@@ -420,7 +376,7 @@ var require_dist = __commonJS({
|
|
|
420
376
|
const isFormData = body instanceof FormData;
|
|
421
377
|
const headers = {
|
|
422
378
|
authorization: `Bearer ${this._apiKey}`,
|
|
423
|
-
"user-agent": `autoposting-sdk/${
|
|
379
|
+
"user-agent": `autoposting-sdk/${VERSION}`,
|
|
424
380
|
"x-source": "sdk",
|
|
425
381
|
...this.extraHeaders
|
|
426
382
|
};
|
|
@@ -1173,15 +1129,33 @@ var init_tools = __esm({
|
|
|
1173
1129
|
function ok(data) {
|
|
1174
1130
|
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
1175
1131
|
}
|
|
1132
|
+
function fail(error) {
|
|
1133
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1134
|
+
return { content: [{ type: "text", text: message }], isError: true };
|
|
1135
|
+
}
|
|
1176
1136
|
function parsePlatforms2(raw) {
|
|
1177
1137
|
if (typeof raw !== "string") return [];
|
|
1178
|
-
|
|
1138
|
+
const platforms = raw.split(",").map((p) => p.trim()).filter(Boolean);
|
|
1139
|
+
const invalid = platforms.filter((platform) => !PLATFORM_SET.has(platform));
|
|
1140
|
+
if (invalid.length > 0) {
|
|
1141
|
+
throw new Error(
|
|
1142
|
+
`Invalid platform(s): ${invalid.join(", ")}. Expected one of: ${PLATFORMS.join(", ")}.`
|
|
1143
|
+
);
|
|
1144
|
+
}
|
|
1145
|
+
return platforms;
|
|
1179
1146
|
}
|
|
1180
1147
|
function parseEvents(raw) {
|
|
1181
1148
|
if (typeof raw !== "string") return [];
|
|
1182
1149
|
return raw.split(",").map((e) => e.trim());
|
|
1183
1150
|
}
|
|
1184
1151
|
async function handleToolCall(name, args, client) {
|
|
1152
|
+
try {
|
|
1153
|
+
return await dispatchToolCall(name, args, client);
|
|
1154
|
+
} catch (error) {
|
|
1155
|
+
return fail(error);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
async function dispatchToolCall(name, args, client) {
|
|
1185
1159
|
switch (name) {
|
|
1186
1160
|
// Posts
|
|
1187
1161
|
case "list-posts": {
|
|
@@ -1225,7 +1199,10 @@ async function handleToolCall(name, args, client) {
|
|
|
1225
1199
|
return ok(result);
|
|
1226
1200
|
}
|
|
1227
1201
|
case "schedule-post": {
|
|
1228
|
-
const result = await client.posts.schedule(
|
|
1202
|
+
const result = await client.posts.schedule(
|
|
1203
|
+
args.id,
|
|
1204
|
+
args.scheduledAt
|
|
1205
|
+
);
|
|
1229
1206
|
return ok(result);
|
|
1230
1207
|
}
|
|
1231
1208
|
case "retry-post": {
|
|
@@ -1337,11 +1314,17 @@ async function handleToolCall(name, args, client) {
|
|
|
1337
1314
|
return ok({ deleted: true, id: args.id });
|
|
1338
1315
|
}
|
|
1339
1316
|
case "search-kb": {
|
|
1340
|
-
const result = await client.kb.search(
|
|
1317
|
+
const result = await client.kb.search(
|
|
1318
|
+
args.id,
|
|
1319
|
+
args.query
|
|
1320
|
+
);
|
|
1341
1321
|
return ok(result);
|
|
1342
1322
|
}
|
|
1343
1323
|
case "ingest-kb": {
|
|
1344
|
-
const result = await client.kb.ingestUrl(
|
|
1324
|
+
const result = await client.kb.ingestUrl(
|
|
1325
|
+
args.id,
|
|
1326
|
+
args.url
|
|
1327
|
+
);
|
|
1345
1328
|
return ok(result);
|
|
1346
1329
|
}
|
|
1347
1330
|
case "kb-docs": {
|
|
@@ -1478,9 +1461,18 @@ async function handleToolCall(name, args, client) {
|
|
|
1478
1461
|
};
|
|
1479
1462
|
}
|
|
1480
1463
|
}
|
|
1464
|
+
var PLATFORMS, PLATFORM_SET;
|
|
1481
1465
|
var init_handler = __esm({
|
|
1482
1466
|
"src/mcp/handler.ts"() {
|
|
1483
1467
|
"use strict";
|
|
1468
|
+
PLATFORMS = [
|
|
1469
|
+
"x",
|
|
1470
|
+
"linkedin",
|
|
1471
|
+
"instagram",
|
|
1472
|
+
"threads",
|
|
1473
|
+
"youtube"
|
|
1474
|
+
];
|
|
1475
|
+
PLATFORM_SET = new Set(PLATFORMS);
|
|
1484
1476
|
}
|
|
1485
1477
|
});
|
|
1486
1478
|
|
|
@@ -1490,9 +1482,9 @@ __export(server_exports, {
|
|
|
1490
1482
|
startMcpServer: () => startMcpServer
|
|
1491
1483
|
});
|
|
1492
1484
|
async function startMcpServer() {
|
|
1493
|
-
const client = new
|
|
1485
|
+
const client = new Autoposting();
|
|
1494
1486
|
const server = new import_server.Server(
|
|
1495
|
-
{ name: "autoposting-mcp", version:
|
|
1487
|
+
{ name: "autoposting-mcp", version: VERSION },
|
|
1496
1488
|
{ capabilities: { tools: {} } }
|
|
1497
1489
|
);
|
|
1498
1490
|
server.setRequestHandler(import_types.ListToolsRequestSchema, async () => ({
|
|
@@ -1505,14 +1497,14 @@ async function startMcpServer() {
|
|
|
1505
1497
|
const transport = new import_stdio.StdioServerTransport();
|
|
1506
1498
|
await server.connect(transport);
|
|
1507
1499
|
}
|
|
1508
|
-
var import_server, import_stdio, import_types
|
|
1500
|
+
var import_server, import_stdio, import_types;
|
|
1509
1501
|
var init_server = __esm({
|
|
1510
1502
|
"src/mcp/server.ts"() {
|
|
1511
1503
|
"use strict";
|
|
1512
1504
|
import_server = require("@modelcontextprotocol/sdk/server/index.js");
|
|
1513
1505
|
import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
1514
1506
|
import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
1515
|
-
|
|
1507
|
+
init_dist();
|
|
1516
1508
|
init_tools();
|
|
1517
1509
|
init_handler();
|
|
1518
1510
|
}
|
|
@@ -1520,10 +1512,11 @@ var init_server = __esm({
|
|
|
1520
1512
|
|
|
1521
1513
|
// src/cli.ts
|
|
1522
1514
|
var import_commander19 = require("commander");
|
|
1515
|
+
init_dist();
|
|
1523
1516
|
|
|
1524
1517
|
// src/commands/agents.ts
|
|
1525
1518
|
var import_commander = require("commander");
|
|
1526
|
-
|
|
1519
|
+
init_dist();
|
|
1527
1520
|
|
|
1528
1521
|
// src/auth/credential-store.ts
|
|
1529
1522
|
var import_node_fs = __toESM(require("fs"));
|
|
@@ -1771,7 +1764,7 @@ function createAgentsCommand() {
|
|
|
1771
1764
|
const spinner = printer.spinner("Fetching agents\u2026");
|
|
1772
1765
|
try {
|
|
1773
1766
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
1774
|
-
const client = new
|
|
1767
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
1775
1768
|
const list = await client.agents.list();
|
|
1776
1769
|
spinner.stop();
|
|
1777
1770
|
const rows = list.map((a) => ({
|
|
@@ -1795,7 +1788,7 @@ function createAgentsCommand() {
|
|
|
1795
1788
|
const spinner = printer.spinner(`Fetching agent "${id}"\u2026`);
|
|
1796
1789
|
try {
|
|
1797
1790
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
1798
|
-
const client = new
|
|
1791
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
1799
1792
|
const agent = await client.agents.retrieve(id);
|
|
1800
1793
|
spinner.stop();
|
|
1801
1794
|
printer.log(agent);
|
|
@@ -1812,7 +1805,7 @@ function createAgentsCommand() {
|
|
|
1812
1805
|
const spinner = printer.spinner("Creating agent\u2026");
|
|
1813
1806
|
try {
|
|
1814
1807
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
1815
|
-
const client = new
|
|
1808
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
1816
1809
|
const agent = await client.agents.create({
|
|
1817
1810
|
name: opts.name,
|
|
1818
1811
|
type: opts.type,
|
|
@@ -1839,7 +1832,7 @@ function createAgentsCommand() {
|
|
|
1839
1832
|
const spinner = printer.spinner(`Updating agent "${id}"\u2026`);
|
|
1840
1833
|
try {
|
|
1841
1834
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
1842
|
-
const client = new
|
|
1835
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
1843
1836
|
const agent = await client.agents.update(id, {
|
|
1844
1837
|
...opts.name ? { name: opts.name } : {},
|
|
1845
1838
|
...opts.prompt ? { prompt: opts.prompt } : {},
|
|
@@ -1866,7 +1859,7 @@ function createAgentsCommand() {
|
|
|
1866
1859
|
const spinner = printer.spinner(`Deleting agent "${id}"\u2026`);
|
|
1867
1860
|
try {
|
|
1868
1861
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
1869
|
-
const client = new
|
|
1862
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
1870
1863
|
await client.agents.remove(id);
|
|
1871
1864
|
spinner.stop();
|
|
1872
1865
|
printer.log(`Agent "${id}" deleted.`);
|
|
@@ -1882,7 +1875,7 @@ function createAgentsCommand() {
|
|
|
1882
1875
|
const spinner = printer.spinner(`Running agent "${id}"\u2026`);
|
|
1883
1876
|
try {
|
|
1884
1877
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
1885
|
-
const client = new
|
|
1878
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
1886
1879
|
const agentRun = await client.agents.run(id);
|
|
1887
1880
|
spinner.stop();
|
|
1888
1881
|
printer.log(agentRun);
|
|
@@ -1898,7 +1891,7 @@ function createAgentsCommand() {
|
|
|
1898
1891
|
const spinner = printer.spinner(`Toggling agent "${id}"\u2026`);
|
|
1899
1892
|
try {
|
|
1900
1893
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
1901
|
-
const client = new
|
|
1894
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
1902
1895
|
const agent = await client.agents.toggle(id);
|
|
1903
1896
|
spinner.stop();
|
|
1904
1897
|
printer.log(agent);
|
|
@@ -1914,7 +1907,7 @@ function createAgentsCommand() {
|
|
|
1914
1907
|
const spinner = printer.spinner(`Fetching runs for agent "${id}"\u2026`);
|
|
1915
1908
|
try {
|
|
1916
1909
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
1917
|
-
const client = new
|
|
1910
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
1918
1911
|
const list = await client.agents.runs(id);
|
|
1919
1912
|
spinner.stop();
|
|
1920
1913
|
const rows = list.map((r) => ({
|
|
@@ -2116,7 +2109,7 @@ Enter code ${userCode} at ${verificationUri}
|
|
|
2116
2109
|
|
|
2117
2110
|
// src/commands/billing.ts
|
|
2118
2111
|
var import_commander3 = require("commander");
|
|
2119
|
-
|
|
2112
|
+
init_dist();
|
|
2120
2113
|
function resolveExitCode2(err) {
|
|
2121
2114
|
const attached = err.exitCode;
|
|
2122
2115
|
if (typeof attached === "number") return attached;
|
|
@@ -2130,7 +2123,7 @@ function createBillingCommand() {
|
|
|
2130
2123
|
const spinner = printer.spinner("Fetching billing status\u2026");
|
|
2131
2124
|
try {
|
|
2132
2125
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2133
|
-
const client = new
|
|
2126
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2134
2127
|
const status = await client.billing.status();
|
|
2135
2128
|
spinner.stop();
|
|
2136
2129
|
printer.table(
|
|
@@ -2157,7 +2150,7 @@ function createBillingCommand() {
|
|
|
2157
2150
|
const spinner = printer.spinner("Fetching credit balance\u2026");
|
|
2158
2151
|
try {
|
|
2159
2152
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2160
|
-
const client = new
|
|
2153
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2161
2154
|
const credits = await client.billing.credits();
|
|
2162
2155
|
spinner.stop();
|
|
2163
2156
|
printer.table(
|
|
@@ -2188,7 +2181,7 @@ function createBillingCommand() {
|
|
|
2188
2181
|
|
|
2189
2182
|
// src/commands/brands.ts
|
|
2190
2183
|
var import_commander4 = require("commander");
|
|
2191
|
-
|
|
2184
|
+
init_dist();
|
|
2192
2185
|
function createBrandsCommand() {
|
|
2193
2186
|
const brands = new import_commander4.Command("brands").description("Manage brands");
|
|
2194
2187
|
brands.command("list").description("List all brands").action(async (_opts, cmd) => {
|
|
@@ -2197,7 +2190,7 @@ function createBrandsCommand() {
|
|
|
2197
2190
|
const spinner = printer.spinner("Fetching brands\u2026");
|
|
2198
2191
|
try {
|
|
2199
2192
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2200
|
-
const client = new
|
|
2193
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2201
2194
|
const list = await client.brands.list();
|
|
2202
2195
|
spinner.stop();
|
|
2203
2196
|
const rows = list.map((b) => ({
|
|
@@ -2219,7 +2212,7 @@ function createBrandsCommand() {
|
|
|
2219
2212
|
const spinner = printer.spinner(`Fetching brand "${slug}"\u2026`);
|
|
2220
2213
|
try {
|
|
2221
2214
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2222
|
-
const client = new
|
|
2215
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2223
2216
|
const brand = await client.brands.retrieve(slug);
|
|
2224
2217
|
spinner.stop();
|
|
2225
2218
|
printer.log(brand);
|
|
@@ -2235,7 +2228,7 @@ function createBrandsCommand() {
|
|
|
2235
2228
|
const spinner = printer.spinner("Creating brand\u2026");
|
|
2236
2229
|
try {
|
|
2237
2230
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2238
|
-
const client = new
|
|
2231
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2239
2232
|
const brand = await client.brands.create({
|
|
2240
2233
|
name: opts.name,
|
|
2241
2234
|
...opts.timezone ? { timezone: opts.timezone } : {}
|
|
@@ -2254,7 +2247,7 @@ function createBrandsCommand() {
|
|
|
2254
2247
|
const spinner = printer.spinner(`Updating brand "${slug}"\u2026`);
|
|
2255
2248
|
try {
|
|
2256
2249
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2257
|
-
const client = new
|
|
2250
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2258
2251
|
const brand = await client.brands.update(slug, {
|
|
2259
2252
|
...opts.name ? { name: opts.name } : {},
|
|
2260
2253
|
...opts.timezone ? { timezone: opts.timezone } : {}
|
|
@@ -2277,7 +2270,7 @@ function createBrandsCommand() {
|
|
|
2277
2270
|
const spinner = printer.spinner(`Deleting brand "${slug}"\u2026`);
|
|
2278
2271
|
try {
|
|
2279
2272
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2280
|
-
const client = new
|
|
2273
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2281
2274
|
await client.brands.remove(slug);
|
|
2282
2275
|
spinner.stop();
|
|
2283
2276
|
printer.log(`Brand "${slug}" deleted.`);
|
|
@@ -2293,7 +2286,7 @@ function createBrandsCommand() {
|
|
|
2293
2286
|
const spinner = printer.spinner(`Fetching auth status for "${slug}"\u2026`);
|
|
2294
2287
|
try {
|
|
2295
2288
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2296
|
-
const client = new
|
|
2289
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2297
2290
|
const connections = await client.brands.authStatus(slug);
|
|
2298
2291
|
spinner.stop();
|
|
2299
2292
|
const rows = connections.map((c) => ({
|
|
@@ -2314,7 +2307,7 @@ function createBrandsCommand() {
|
|
|
2314
2307
|
|
|
2315
2308
|
// src/commands/carousels.ts
|
|
2316
2309
|
var import_commander5 = require("commander");
|
|
2317
|
-
|
|
2310
|
+
init_dist();
|
|
2318
2311
|
function resolveExitCode3(err) {
|
|
2319
2312
|
const attached = err.exitCode;
|
|
2320
2313
|
if (typeof attached === "number") return attached;
|
|
@@ -2328,7 +2321,7 @@ function createCarouselsCommand() {
|
|
|
2328
2321
|
const spinner = printer.spinner("Fetching carousels\u2026");
|
|
2329
2322
|
try {
|
|
2330
2323
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2331
|
-
const client = new
|
|
2324
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2332
2325
|
const list = await client.carousels.list();
|
|
2333
2326
|
spinner.stop();
|
|
2334
2327
|
const rows = list.map((c) => ({
|
|
@@ -2351,7 +2344,7 @@ function createCarouselsCommand() {
|
|
|
2351
2344
|
const spinner = printer.spinner(`Fetching carousel "${id}"\u2026`);
|
|
2352
2345
|
try {
|
|
2353
2346
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2354
|
-
const client = new
|
|
2347
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2355
2348
|
const carousel = await client.carousels.retrieve(id);
|
|
2356
2349
|
spinner.stop();
|
|
2357
2350
|
printer.log(carousel);
|
|
@@ -2367,7 +2360,7 @@ function createCarouselsCommand() {
|
|
|
2367
2360
|
const spinner = printer.spinner("Creating carousel\u2026");
|
|
2368
2361
|
try {
|
|
2369
2362
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2370
|
-
const client = new
|
|
2363
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2371
2364
|
const carousel = await client.carousels.create(
|
|
2372
2365
|
opts.title ? { title: opts.title } : void 0
|
|
2373
2366
|
);
|
|
@@ -2385,7 +2378,7 @@ function createCarouselsCommand() {
|
|
|
2385
2378
|
const spinner = printer.spinner("Generating carousel\u2026");
|
|
2386
2379
|
try {
|
|
2387
2380
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2388
|
-
const client = new
|
|
2381
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2389
2382
|
const carousel = await client.carousels.generate({
|
|
2390
2383
|
topic: opts.topic,
|
|
2391
2384
|
...opts.brand ? { brandSlug: opts.brand } : {},
|
|
@@ -2405,7 +2398,7 @@ function createCarouselsCommand() {
|
|
|
2405
2398
|
const spinner = printer.spinner(`Converting carousel "${id}" to draft\u2026`);
|
|
2406
2399
|
try {
|
|
2407
2400
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2408
|
-
const client = new
|
|
2401
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2409
2402
|
const result = await client.carousels.draft(id);
|
|
2410
2403
|
spinner.stop();
|
|
2411
2404
|
printer.log(result);
|
|
@@ -2425,7 +2418,7 @@ function createCarouselsCommand() {
|
|
|
2425
2418
|
const spinner = printer.spinner(`Deleting carousel "${id}"\u2026`);
|
|
2426
2419
|
try {
|
|
2427
2420
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2428
|
-
const client = new
|
|
2421
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2429
2422
|
await client.carousels.remove(id);
|
|
2430
2423
|
spinner.stop();
|
|
2431
2424
|
printer.log(`Carousel "${id}" deleted.`);
|
|
@@ -2440,7 +2433,7 @@ function createCarouselsCommand() {
|
|
|
2440
2433
|
|
|
2441
2434
|
// src/commands/clips.ts
|
|
2442
2435
|
var import_commander6 = require("commander");
|
|
2443
|
-
|
|
2436
|
+
init_dist();
|
|
2444
2437
|
function resolveExitCode4(err) {
|
|
2445
2438
|
const attached = err.exitCode;
|
|
2446
2439
|
if (typeof attached === "number") return attached;
|
|
@@ -2454,7 +2447,7 @@ function createClipsCommand() {
|
|
|
2454
2447
|
const spinner = printer.spinner("Fetching clips\u2026");
|
|
2455
2448
|
try {
|
|
2456
2449
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2457
|
-
const client = new
|
|
2450
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2458
2451
|
const list = await client.clips.list();
|
|
2459
2452
|
spinner.stop();
|
|
2460
2453
|
const rows = list.map((c) => ({
|
|
@@ -2476,7 +2469,7 @@ function createClipsCommand() {
|
|
|
2476
2469
|
const spinner = printer.spinner(`Fetching clip "${id}"\u2026`);
|
|
2477
2470
|
try {
|
|
2478
2471
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2479
|
-
const client = new
|
|
2472
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2480
2473
|
const clip = await client.clips.retrieve(id);
|
|
2481
2474
|
spinner.stop();
|
|
2482
2475
|
printer.log(clip);
|
|
@@ -2492,7 +2485,7 @@ function createClipsCommand() {
|
|
|
2492
2485
|
const spinner = printer.spinner("Uploading clip\u2026");
|
|
2493
2486
|
try {
|
|
2494
2487
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2495
|
-
const client = new
|
|
2488
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2496
2489
|
const clip = await client.clips.upload(file, {
|
|
2497
2490
|
name: opts.name,
|
|
2498
2491
|
onProgress: (pct) => {
|
|
@@ -2513,7 +2506,7 @@ function createClipsCommand() {
|
|
|
2513
2506
|
const spinner = printer.spinner("Importing clip\u2026");
|
|
2514
2507
|
try {
|
|
2515
2508
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2516
|
-
const client = new
|
|
2509
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2517
2510
|
const clip = await client.clips.importUrl({
|
|
2518
2511
|
url: opts.url,
|
|
2519
2512
|
...opts.name ? { name: opts.name } : {}
|
|
@@ -2532,7 +2525,7 @@ function createClipsCommand() {
|
|
|
2532
2525
|
const spinner = printer.spinner(`Rendering clip "${id}"\u2026`);
|
|
2533
2526
|
try {
|
|
2534
2527
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2535
|
-
const client = new
|
|
2528
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2536
2529
|
const clip = await client.clips.render(id);
|
|
2537
2530
|
spinner.stop();
|
|
2538
2531
|
printer.log(clip);
|
|
@@ -2552,7 +2545,7 @@ function createClipsCommand() {
|
|
|
2552
2545
|
const spinner = printer.spinner(`Deleting clip "${id}"\u2026`);
|
|
2553
2546
|
try {
|
|
2554
2547
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2555
|
-
const client = new
|
|
2548
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2556
2549
|
await client.clips.remove(id);
|
|
2557
2550
|
spinner.stop();
|
|
2558
2551
|
printer.log(`Clip "${id}" deleted.`);
|
|
@@ -2567,7 +2560,7 @@ function createClipsCommand() {
|
|
|
2567
2560
|
|
|
2568
2561
|
// src/commands/posts.ts
|
|
2569
2562
|
var import_commander7 = require("commander");
|
|
2570
|
-
|
|
2563
|
+
init_dist();
|
|
2571
2564
|
function parsePlatforms(raw) {
|
|
2572
2565
|
return raw.split(",").map((p) => p.trim());
|
|
2573
2566
|
}
|
|
@@ -2584,7 +2577,7 @@ function createPostsCommand() {
|
|
|
2584
2577
|
const spinner = printer.spinner("Fetching posts\u2026");
|
|
2585
2578
|
try {
|
|
2586
2579
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2587
|
-
const client = new
|
|
2580
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2588
2581
|
const result = await client.posts.list({
|
|
2589
2582
|
brandSlug: opts.brand,
|
|
2590
2583
|
status: opts.status,
|
|
@@ -2613,7 +2606,7 @@ function createPostsCommand() {
|
|
|
2613
2606
|
const spinner = printer.spinner(`Fetching post "${id}"\u2026`);
|
|
2614
2607
|
try {
|
|
2615
2608
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2616
|
-
const client = new
|
|
2609
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2617
2610
|
const post = await client.posts.getById(id);
|
|
2618
2611
|
spinner.stop();
|
|
2619
2612
|
printer.log(post);
|
|
@@ -2630,7 +2623,7 @@ function createPostsCommand() {
|
|
|
2630
2623
|
const spinner = printer.spinner("Creating post\u2026");
|
|
2631
2624
|
try {
|
|
2632
2625
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2633
|
-
const client = new
|
|
2626
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2634
2627
|
const post = await client.posts.create({
|
|
2635
2628
|
brandSlug: opts.brand,
|
|
2636
2629
|
text: opts.text,
|
|
@@ -2653,7 +2646,7 @@ function createPostsCommand() {
|
|
|
2653
2646
|
const spinner = printer.spinner(`Updating post "${id}"\u2026`);
|
|
2654
2647
|
try {
|
|
2655
2648
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2656
|
-
const client = new
|
|
2649
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2657
2650
|
const post = await client.posts.update(id, {
|
|
2658
2651
|
...opts.text ? { text: opts.text } : {},
|
|
2659
2652
|
...opts.platforms ? { platforms: parsePlatforms(opts.platforms) } : {},
|
|
@@ -2678,7 +2671,7 @@ function createPostsCommand() {
|
|
|
2678
2671
|
const spinner = printer.spinner(`Deleting post "${id}"\u2026`);
|
|
2679
2672
|
try {
|
|
2680
2673
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2681
|
-
const client = new
|
|
2674
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2682
2675
|
await client.posts.remove(id);
|
|
2683
2676
|
spinner.stop();
|
|
2684
2677
|
printer.log(`Post "${id}" deleted.`);
|
|
@@ -2694,7 +2687,7 @@ function createPostsCommand() {
|
|
|
2694
2687
|
const spinner = printer.spinner(`Publishing post "${id}"\u2026`);
|
|
2695
2688
|
try {
|
|
2696
2689
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2697
|
-
const client = new
|
|
2690
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2698
2691
|
const post = await client.posts.publish(id);
|
|
2699
2692
|
spinner.stop();
|
|
2700
2693
|
printer.log(post);
|
|
@@ -2710,7 +2703,7 @@ function createPostsCommand() {
|
|
|
2710
2703
|
const spinner = printer.spinner(`Scheduling post "${id}"\u2026`);
|
|
2711
2704
|
try {
|
|
2712
2705
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2713
|
-
const client = new
|
|
2706
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2714
2707
|
const post = await client.posts.schedule(id, opts.at);
|
|
2715
2708
|
spinner.stop();
|
|
2716
2709
|
printer.log(post);
|
|
@@ -2726,7 +2719,7 @@ function createPostsCommand() {
|
|
|
2726
2719
|
const spinner = printer.spinner(`Retrying post "${id}"\u2026`);
|
|
2727
2720
|
try {
|
|
2728
2721
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2729
|
-
const client = new
|
|
2722
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2730
2723
|
const post = await client.posts.retry(id);
|
|
2731
2724
|
spinner.stop();
|
|
2732
2725
|
printer.log(post);
|
|
@@ -2742,7 +2735,7 @@ function createPostsCommand() {
|
|
|
2742
2735
|
const spinner = printer.spinner(`Rewriting post "${id}"\u2026`);
|
|
2743
2736
|
try {
|
|
2744
2737
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2745
|
-
const client = new
|
|
2738
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2746
2739
|
const post = await client.posts.rewrite(id);
|
|
2747
2740
|
spinner.stop();
|
|
2748
2741
|
printer.log(post);
|
|
@@ -2758,7 +2751,7 @@ function createPostsCommand() {
|
|
|
2758
2751
|
const spinner = printer.spinner(`Scoring post "${id}"\u2026`);
|
|
2759
2752
|
try {
|
|
2760
2753
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2761
|
-
const client = new
|
|
2754
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2762
2755
|
const result = await client.posts.score(id);
|
|
2763
2756
|
spinner.stop();
|
|
2764
2757
|
printer.log(result);
|
|
@@ -2773,7 +2766,7 @@ function createPostsCommand() {
|
|
|
2773
2766
|
|
|
2774
2767
|
// src/commands/kb.ts
|
|
2775
2768
|
var import_commander8 = require("commander");
|
|
2776
|
-
|
|
2769
|
+
init_dist();
|
|
2777
2770
|
function resolveExitCode6(err) {
|
|
2778
2771
|
const attached = err.exitCode;
|
|
2779
2772
|
if (typeof attached === "number") return attached;
|
|
@@ -2787,7 +2780,7 @@ function createKbCommand() {
|
|
|
2787
2780
|
const spinner = printer.spinner("Fetching knowledge bases\u2026");
|
|
2788
2781
|
try {
|
|
2789
2782
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2790
|
-
const client = new
|
|
2783
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2791
2784
|
const list = await client.kb.list();
|
|
2792
2785
|
spinner.stop();
|
|
2793
2786
|
const rows = list.map((k) => ({
|
|
@@ -2809,7 +2802,7 @@ function createKbCommand() {
|
|
|
2809
2802
|
const spinner = printer.spinner(`Fetching knowledge base "${id}"\u2026`);
|
|
2810
2803
|
try {
|
|
2811
2804
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2812
|
-
const client = new
|
|
2805
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2813
2806
|
const result = await client.kb.retrieve(id);
|
|
2814
2807
|
spinner.stop();
|
|
2815
2808
|
printer.log(result);
|
|
@@ -2825,7 +2818,7 @@ function createKbCommand() {
|
|
|
2825
2818
|
const spinner = printer.spinner("Creating knowledge base\u2026");
|
|
2826
2819
|
try {
|
|
2827
2820
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2828
|
-
const client = new
|
|
2821
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2829
2822
|
const result = await client.kb.create({ name: opts.name });
|
|
2830
2823
|
spinner.stop();
|
|
2831
2824
|
printer.log(result);
|
|
@@ -2845,7 +2838,7 @@ function createKbCommand() {
|
|
|
2845
2838
|
const spinner = printer.spinner(`Deleting knowledge base "${id}"\u2026`);
|
|
2846
2839
|
try {
|
|
2847
2840
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2848
|
-
const client = new
|
|
2841
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2849
2842
|
await client.kb.remove(id);
|
|
2850
2843
|
spinner.stop();
|
|
2851
2844
|
printer.log(`Knowledge base "${id}" deleted.`);
|
|
@@ -2861,7 +2854,7 @@ function createKbCommand() {
|
|
|
2861
2854
|
const spinner = printer.spinner(`Searching knowledge base "${id}"\u2026`);
|
|
2862
2855
|
try {
|
|
2863
2856
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2864
|
-
const client = new
|
|
2857
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2865
2858
|
const results = await client.kb.search(id, opts.query);
|
|
2866
2859
|
spinner.stop();
|
|
2867
2860
|
const rows = results.map((r) => ({
|
|
@@ -2882,7 +2875,7 @@ function createKbCommand() {
|
|
|
2882
2875
|
const spinner = printer.spinner(`Ingesting URL into knowledge base "${id}"\u2026`);
|
|
2883
2876
|
try {
|
|
2884
2877
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2885
|
-
const client = new
|
|
2878
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2886
2879
|
const doc = await client.kb.ingestUrl(id, opts.url);
|
|
2887
2880
|
spinner.stop();
|
|
2888
2881
|
printer.log(doc);
|
|
@@ -2898,7 +2891,7 @@ function createKbCommand() {
|
|
|
2898
2891
|
const spinner = printer.spinner(`Fetching documents for knowledge base "${id}"\u2026`);
|
|
2899
2892
|
try {
|
|
2900
2893
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2901
|
-
const client = new
|
|
2894
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2902
2895
|
const docs = await client.kb.docs(id);
|
|
2903
2896
|
spinner.stop();
|
|
2904
2897
|
const rows = docs.map((d) => ({
|
|
@@ -2920,7 +2913,7 @@ function createKbCommand() {
|
|
|
2920
2913
|
|
|
2921
2914
|
// src/commands/ideas.ts
|
|
2922
2915
|
var import_commander9 = require("commander");
|
|
2923
|
-
|
|
2916
|
+
init_dist();
|
|
2924
2917
|
function resolveExitCode7(err) {
|
|
2925
2918
|
const attached = err.exitCode;
|
|
2926
2919
|
if (typeof attached === "number") return attached;
|
|
@@ -2934,7 +2927,7 @@ function createIdeasCommand() {
|
|
|
2934
2927
|
const spinner = printer.spinner("Generating ideas\u2026");
|
|
2935
2928
|
try {
|
|
2936
2929
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2937
|
-
const client = new
|
|
2930
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2938
2931
|
const result = await client.ideas.generate({
|
|
2939
2932
|
...opts.kb ? { kbId: opts.kb } : {},
|
|
2940
2933
|
...opts.topic ? { topic: opts.topic } : {},
|
|
@@ -2960,7 +2953,7 @@ function createIdeasCommand() {
|
|
|
2960
2953
|
const spinner = printer.spinner("Fetching ideas\u2026");
|
|
2961
2954
|
try {
|
|
2962
2955
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2963
|
-
const client = new
|
|
2956
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2964
2957
|
const list = await client.ideas.list();
|
|
2965
2958
|
spinner.stop();
|
|
2966
2959
|
const rows = list.map((i) => ({
|
|
@@ -2983,7 +2976,7 @@ function createIdeasCommand() {
|
|
|
2983
2976
|
const spinner = printer.spinner(`Enriching idea "${id}"\u2026`);
|
|
2984
2977
|
try {
|
|
2985
2978
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
2986
|
-
const client = new
|
|
2979
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
2987
2980
|
const idea = await client.ideas.enrich(id);
|
|
2988
2981
|
spinner.stop();
|
|
2989
2982
|
printer.log(idea);
|
|
@@ -3003,7 +2996,7 @@ function createIdeasCommand() {
|
|
|
3003
2996
|
const spinner = printer.spinner(`Deleting idea "${id}"\u2026`);
|
|
3004
2997
|
try {
|
|
3005
2998
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
3006
|
-
const client = new
|
|
2999
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
3007
3000
|
await client.ideas.remove(id);
|
|
3008
3001
|
spinner.stop();
|
|
3009
3002
|
printer.log(`Idea "${id}" deleted.`);
|
|
@@ -3018,7 +3011,7 @@ function createIdeasCommand() {
|
|
|
3018
3011
|
|
|
3019
3012
|
// src/commands/usage.ts
|
|
3020
3013
|
var import_commander10 = require("commander");
|
|
3021
|
-
|
|
3014
|
+
init_dist();
|
|
3022
3015
|
function resolveExitCode8(err) {
|
|
3023
3016
|
const attached = err.exitCode;
|
|
3024
3017
|
if (typeof attached === "number") return attached;
|
|
@@ -3032,7 +3025,7 @@ function createUsageCommand() {
|
|
|
3032
3025
|
const spinner = printer.spinner("Fetching usage summary\u2026");
|
|
3033
3026
|
try {
|
|
3034
3027
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
3035
|
-
const client = new
|
|
3028
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
3036
3029
|
const summary = await client.usage.summary();
|
|
3037
3030
|
spinner.stop();
|
|
3038
3031
|
const rows = Object.entries(summary.platforms).map(([platform, stats]) => ({
|
|
@@ -3058,7 +3051,7 @@ function createUsageCommand() {
|
|
|
3058
3051
|
|
|
3059
3052
|
// src/commands/webhooks.ts
|
|
3060
3053
|
var import_commander11 = require("commander");
|
|
3061
|
-
|
|
3054
|
+
init_dist();
|
|
3062
3055
|
function resolveExitCode9(err) {
|
|
3063
3056
|
const attached = err.exitCode;
|
|
3064
3057
|
if (typeof attached === "number") return attached;
|
|
@@ -3072,7 +3065,7 @@ function createWebhooksCommand() {
|
|
|
3072
3065
|
const spinner = printer.spinner("Fetching webhooks\u2026");
|
|
3073
3066
|
try {
|
|
3074
3067
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
3075
|
-
const client = new
|
|
3068
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
3076
3069
|
const list = await client.webhooks.list();
|
|
3077
3070
|
spinner.stop();
|
|
3078
3071
|
const rows = list.map((w) => ({
|
|
@@ -3095,7 +3088,7 @@ function createWebhooksCommand() {
|
|
|
3095
3088
|
const spinner = printer.spinner(`Fetching webhook "${id}"\u2026`);
|
|
3096
3089
|
try {
|
|
3097
3090
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
3098
|
-
const client = new
|
|
3091
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
3099
3092
|
const webhook = await client.webhooks.retrieve(id);
|
|
3100
3093
|
spinner.stop();
|
|
3101
3094
|
printer.log(webhook);
|
|
@@ -3112,7 +3105,7 @@ function createWebhooksCommand() {
|
|
|
3112
3105
|
const spinner = printer.spinner("Creating webhook\u2026");
|
|
3113
3106
|
try {
|
|
3114
3107
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
3115
|
-
const client = new
|
|
3108
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
3116
3109
|
const webhook = await client.webhooks.create({
|
|
3117
3110
|
url: opts.url,
|
|
3118
3111
|
events: opts.events.split(",").map((e) => e.trim()),
|
|
@@ -3134,7 +3127,7 @@ function createWebhooksCommand() {
|
|
|
3134
3127
|
const spinner = printer.spinner(`Updating webhook "${id}"\u2026`);
|
|
3135
3128
|
try {
|
|
3136
3129
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
3137
|
-
const client = new
|
|
3130
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
3138
3131
|
const webhook = await client.webhooks.update(id, {
|
|
3139
3132
|
...opts.url ? { url: opts.url } : {},
|
|
3140
3133
|
...opts.events ? { events: opts.events.split(",").map((e) => e.trim()) } : {},
|
|
@@ -3159,7 +3152,7 @@ function createWebhooksCommand() {
|
|
|
3159
3152
|
const spinner = printer.spinner(`Deleting webhook "${id}"\u2026`);
|
|
3160
3153
|
try {
|
|
3161
3154
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
3162
|
-
const client = new
|
|
3155
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
3163
3156
|
await client.webhooks.remove(id);
|
|
3164
3157
|
spinner.stop();
|
|
3165
3158
|
printer.log(`Webhook "${id}" deleted.`);
|
|
@@ -3175,7 +3168,7 @@ function createWebhooksCommand() {
|
|
|
3175
3168
|
const spinner = printer.spinner(`Sending test event to webhook "${id}"\u2026`);
|
|
3176
3169
|
try {
|
|
3177
3170
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
3178
|
-
const client = new
|
|
3171
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
3179
3172
|
await client.webhooks.test(id);
|
|
3180
3173
|
spinner.stop();
|
|
3181
3174
|
printer.log(`Test event sent to webhook "${id}".`);
|
|
@@ -3190,7 +3183,7 @@ function createWebhooksCommand() {
|
|
|
3190
3183
|
|
|
3191
3184
|
// src/commands/workspaces.ts
|
|
3192
3185
|
var import_commander12 = require("commander");
|
|
3193
|
-
|
|
3186
|
+
init_dist();
|
|
3194
3187
|
function resolveExitCode10(err) {
|
|
3195
3188
|
const attached = err.exitCode;
|
|
3196
3189
|
if (typeof attached === "number") return attached;
|
|
@@ -3204,7 +3197,7 @@ function createWorkspacesCommand() {
|
|
|
3204
3197
|
const spinner = printer.spinner("Fetching workspaces\u2026");
|
|
3205
3198
|
try {
|
|
3206
3199
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
3207
|
-
const client = new
|
|
3200
|
+
const client = new Autoposting({ apiKey: cred.apiKey });
|
|
3208
3201
|
const list = await client.workspaces.list();
|
|
3209
3202
|
spinner.stop();
|
|
3210
3203
|
const rows = list.map((w) => ({
|
|
@@ -3228,7 +3221,7 @@ function createWorkspacesCommand() {
|
|
|
3228
3221
|
try {
|
|
3229
3222
|
const cred = resolveAuth({ apiKey: globals.apiKey });
|
|
3230
3223
|
const authSource = cred.source === "flag" || cred.source === "env" || cred.source === "stored" ? "api-key" : "session";
|
|
3231
|
-
const client = new
|
|
3224
|
+
const client = new Autoposting({ apiKey: cred.apiKey, authSource });
|
|
3232
3225
|
await client.workspaces.switchWorkspace(id);
|
|
3233
3226
|
spinner.stop();
|
|
3234
3227
|
printer.log(`Switched to workspace "${id}".`);
|
|
@@ -3243,8 +3236,8 @@ function createWorkspacesCommand() {
|
|
|
3243
3236
|
|
|
3244
3237
|
// src/commands/doctor.ts
|
|
3245
3238
|
var import_commander13 = require("commander");
|
|
3239
|
+
init_dist();
|
|
3246
3240
|
var import_node_fs2 = __toESM(require("fs"));
|
|
3247
|
-
var VERSION = "0.1.0";
|
|
3248
3241
|
var API_HEALTH_URL = "https://app.autoposting.ai/api/health";
|
|
3249
3242
|
async function runChecks() {
|
|
3250
3243
|
const results = [];
|
|
@@ -3273,7 +3266,11 @@ async function runChecks() {
|
|
|
3273
3266
|
value: isSecure ? `${credPath} (0600)` : `${credPath} (mode ${mode.toString(8)} \u2014 expected 0600)`
|
|
3274
3267
|
});
|
|
3275
3268
|
} catch {
|
|
3276
|
-
results.push({
|
|
3269
|
+
results.push({
|
|
3270
|
+
name: "Credentials",
|
|
3271
|
+
status: "warn",
|
|
3272
|
+
value: "no credentials file found"
|
|
3273
|
+
});
|
|
3277
3274
|
}
|
|
3278
3275
|
try {
|
|
3279
3276
|
const controller = new AbortController();
|
|
@@ -3385,11 +3382,13 @@ function createOpenCommand() {
|
|
|
3385
3382
|
|
|
3386
3383
|
// src/commands/update.ts
|
|
3387
3384
|
var import_commander16 = require("commander");
|
|
3385
|
+
init_dist();
|
|
3388
3386
|
var import_node_child_process2 = require("child_process");
|
|
3389
|
-
var
|
|
3390
|
-
var REGISTRY_URL = "https://registry.npmjs.org/autoposting-cli/latest";
|
|
3387
|
+
var REGISTRY_URL = "https://registry.npmjs.org/@autoposting.ai%2fcli/latest";
|
|
3391
3388
|
function createUpdateCommand() {
|
|
3392
|
-
return new import_commander16.Command("update").description(
|
|
3389
|
+
return new import_commander16.Command("update").description(
|
|
3390
|
+
"Check for a newer version of the CLI and optionally install it"
|
|
3391
|
+
).option("--yes", "Install the latest version without prompting").action(async (opts) => {
|
|
3393
3392
|
let latest;
|
|
3394
3393
|
try {
|
|
3395
3394
|
const controller = new AbortController();
|
|
@@ -3403,22 +3402,26 @@ function createUpdateCommand() {
|
|
|
3403
3402
|
const data = await res.json();
|
|
3404
3403
|
latest = data.version;
|
|
3405
3404
|
} catch (err) {
|
|
3406
|
-
console.error(
|
|
3405
|
+
console.error(
|
|
3406
|
+
`Error: could not reach npm registry \u2014 ${err.message}`
|
|
3407
|
+
);
|
|
3407
3408
|
process.exit(1);
|
|
3408
3409
|
}
|
|
3409
|
-
if (latest ===
|
|
3410
|
-
console.log(`You are already on the latest version (${
|
|
3410
|
+
if (latest === VERSION) {
|
|
3411
|
+
console.log(`You are already on the latest version (${VERSION}).`);
|
|
3411
3412
|
return;
|
|
3412
3413
|
}
|
|
3413
|
-
console.log(`Current version: ${
|
|
3414
|
+
console.log(`Current version: ${VERSION}`);
|
|
3414
3415
|
console.log(`Latest version: ${latest}`);
|
|
3415
3416
|
if (!opts.yes) {
|
|
3416
3417
|
console.log(`Run \`ap update --yes\` to install v${latest}.`);
|
|
3417
3418
|
return;
|
|
3418
3419
|
}
|
|
3419
|
-
console.log(`Installing autoposting
|
|
3420
|
+
console.log(`Installing @autoposting.ai/cli@${latest}\u2026`);
|
|
3420
3421
|
try {
|
|
3421
|
-
(0, import_node_child_process2.execSync)(`npm install -g autoposting
|
|
3422
|
+
(0, import_node_child_process2.execSync)(`npm install -g @autoposting.ai/cli@${latest}`, {
|
|
3423
|
+
stdio: "inherit"
|
|
3424
|
+
});
|
|
3422
3425
|
console.log(`Updated to v${latest}.`);
|
|
3423
3426
|
} catch (err) {
|
|
3424
3427
|
console.error(`Error: install failed \u2014 ${err.message}`);
|
|
@@ -3509,7 +3512,7 @@ function createMcpCommand() {
|
|
|
3509
3512
|
}
|
|
3510
3513
|
|
|
3511
3514
|
// src/cli.ts
|
|
3512
|
-
var program = new import_commander19.Command().name("autoposting").description("Autoposting CLI \u2014 manage social media from the terminal").version(
|
|
3515
|
+
var program = new import_commander19.Command().name("autoposting").description("Autoposting CLI \u2014 manage social media from the terminal").version(VERSION).option("--json", "Output as JSON").option("--quiet", "Suppress spinners and non-essential output").option("--format <type>", "Output format: table, json", "table").option("--api-key <key>", "API key (overrides env/stored credentials)").option("--no-color", "Disable color output").hook("preAction", (thisCommand) => {
|
|
3513
3516
|
const opts = thisCommand.opts();
|
|
3514
3517
|
if (!opts.color) disableColor();
|
|
3515
3518
|
});
|