@elisym/cli 0.36.0 → 0.38.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/index.js +218 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-deprecation
|
|
2
2
|
import { randomBytes, createHash } from 'node:crypto';
|
|
3
|
-
import { writeFile, readFile, realpath, stat, unlink, readdir, mkdtemp, rm, mkdir, chmod,
|
|
3
|
+
import { writeFile, readFile, realpath, stat, open, unlink, readdir, mkdtemp, rm, mkdir, chmod, rename, link } from 'node:fs/promises';
|
|
4
4
|
import { dirname, join, resolve, sep, basename, extname, relative } from 'node:path';
|
|
5
5
|
import { nip19, generateSecretKey, getPublicKey, verifyEvent } from 'nostr-tools';
|
|
6
6
|
import { bytesToHex, hexToBytes } from 'nostr-tools/utils';
|
|
7
7
|
import * as nip44 from 'nostr-tools/nip44';
|
|
8
8
|
import { finalizeEvent, generateSecretKey as generateSecretKey$1, getPublicKey as getPublicKey$1, verifyEvent as verifyEvent$1 } from 'nostr-tools/pure';
|
|
9
9
|
import Decimal2 from 'decimal.js-light';
|
|
10
|
+
import { readFileSync, constants, existsSync, readdirSync, statSync, realpathSync, renameSync, chmodSync, mkdirSync, writeFileSync, unlinkSync, appendFileSync, rmdirSync } from 'node:fs';
|
|
10
11
|
import { ReadableStream } from 'node:stream/web';
|
|
11
|
-
import { readFileSync, existsSync, readdirSync, statSync, realpathSync, renameSync, chmodSync, mkdirSync, writeFileSync, unlinkSync, appendFileSync, rmdirSync } from 'node:fs';
|
|
12
12
|
import { DEFAULTS, SolanaPaymentStrategy, validateAgentName, RELAYS, ElisymIdentity, splAssetsForNetwork, formatSol, formatAssetAmount, deleteControlCharacters, signerFromSecretKeyBase58, resolveUsdcAsset, ElisymClient, KIND_EXTERNAL_IDENTITIES, POLICY_D_TAG_PREFIX, KIND_LONG_FORM_ARTICLE, jobRequestKind, DEFAULT_KIND_OFFSET, toDTag, createBlossomTransport, generateSolanaWallet, verifyAgentIdentities, getProtocolConfig, getProtocolProgramId, calculateProtocolFee, LIMITS, makeCensor, DEFAULT_REDACT_PATHS, flattenForComparison, POLICY_T_TAG, SESSION_ID_REGEX, createSlidingWindowLimiter, excerptUntrusted, isScriptBillingExhaustedError, excerptUntrustedTail, scriptOutput, isScriptExecutionError, utf8ByteLength, readAcceptedTransports, resolveDelegationAsset, MAX_PROOF_TTL_SECS, PROOF_CLOCK_SKEW_SECS, verifyDelegationAuthProof, deriveOwnerDelegationAta, getDelegation, buildDelegatedTransfer, buildSignedPull, sendConfirmToTerminal, parseDelegatedPayment, confirmPullToTerminal, isDefinitelyUnpaid, decodeJobPayload, isLlmHealthError, BoundedSet, KIND_JOB_FEEDBACK, encodeSecretKeyBase58, GITHUB_USERNAME_REGEX, X_USERNAME_REGEX, normalizeNip05Identifier, splitNip05Identifier, clipToCodeUnits, degenerateReference, PROVIDER_REFUSED_PREFIX, PROVIDER_FAILED_MESSAGE, NATIVE_SOL, GIST_ID_REGEX, TWEET_ID_REGEX } from '@elisym/sdk';
|
|
13
13
|
import { ElisymYamlSchema, resolveInHome, resolveInProject, createAgentDir, writeYamlInitial, writeExampleSkillTemplate, writeSecrets, listAgents, loadAgent, writeYaml, agentPaths, ensureGitignoreHasX402Entries, readMediaCache, ensureGitignoreHasPrivateStateEntries, loadPoliciesFromDir, ensureGitignoreHasDelegationNoncesEntry, ensureGitignoreHasIrohEntry, ensureGitignoreHasSessionsEntry, readAgentPublic, isBlockingNodeSync, AgentNameSchema, lookupCachedUrl, newCacheEntry, isBlockingNode, writeMediaCache } from '@elisym/sdk/agent-store';
|
|
14
14
|
import { isAddress, createSolanaRpc, address, signature } from '@solana/kit';
|
|
@@ -81,7 +81,7 @@ var init_errors = __esm({
|
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
// src/commands/askr/constants.ts
|
|
84
|
-
var ASKR_COMMAND, DEADLINE_MS, ADMIN_URL, CONTACT_URL, PRICING_URL, FIND_STORE_ID_URL, UPGRADE, WIDGET_SCRIPT_URL, WIDGET_ELEMENT, API_OVERRIDE_ENV, RELAY_OVERRIDE_ENV, UNSAFE_OVERRIDE_ENV, LOCAL_HOSTS, NOT_AUTHORIZED_MESSAGE, SYNC_BUSY_MESSAGE, STORE_POLL_MS, SYNC_POLL_MS, PROBE_RETRY_MS, MIN_REAL_CALL_MS, PREVIEW_TIMEOUT_MS, NOT_AUTHORIZED_RETRY_MS, MAX_CATALOG_BODY_BYTES, MAX_AHEAD_SECS, ABSENT_WARNING_BPS, ABSENT_WARNING_COUNT, SAMPLE_SIZE, MAX_ISSUES, PROFILE_RE, DEFAULT_PROFILE, POLICY_SLUG_RE;
|
|
84
|
+
var ASKR_COMMAND, DEADLINE_MS, ADMIN_URL, CONTACT_URL, PRICING_URL, FIND_STORE_ID_URL, UPGRADE, WIDGET_SCRIPT_URL, WIDGET_ELEMENT, STORE_FILES_BASE, ASKR_SITE_URL, API_OVERRIDE_ENV, RELAY_OVERRIDE_ENV, UNSAFE_OVERRIDE_ENV, LOCAL_HOSTS, NOT_AUTHORIZED_MESSAGE, SYNC_BUSY_MESSAGE, STORE_POLL_MS, SYNC_POLL_MS, PROBE_RETRY_MS, MIN_REAL_CALL_MS, PREVIEW_TIMEOUT_MS, NOT_AUTHORIZED_RETRY_MS, MAX_CATALOG_BODY_BYTES, MAX_AHEAD_SECS, ABSENT_WARNING_BPS, ABSENT_WARNING_COUNT, SAMPLE_SIZE, MAX_ISSUES, PROFILE_RE, DEFAULT_PROFILE, POLICY_SLUG_RE;
|
|
85
85
|
var init_constants = __esm({
|
|
86
86
|
"src/commands/askr/constants.ts"() {
|
|
87
87
|
ASKR_COMMAND = "npx -y @elisym/cli@latest askr";
|
|
@@ -98,6 +98,8 @@ var init_constants = __esm({
|
|
|
98
98
|
};
|
|
99
99
|
WIDGET_SCRIPT_URL = "https://app.askr.elisym.network/widget.js";
|
|
100
100
|
WIDGET_ELEMENT = "askr-chat";
|
|
101
|
+
STORE_FILES_BASE = "https://app.askr.elisym.network/s";
|
|
102
|
+
ASKR_SITE_URL = "https://askr.elisym.network";
|
|
101
103
|
API_OVERRIDE_ENV = "ELISYM_ASKR_API";
|
|
102
104
|
RELAY_OVERRIDE_ENV = "ELISYM_ASKR_RELAY";
|
|
103
105
|
UNSAFE_OVERRIDE_ENV = "ELISYM_ASKR_UNSAFE_TEST";
|
|
@@ -485,7 +487,10 @@ function awaitingPlanOf(view) {
|
|
|
485
487
|
return view.status === "pending" && view.tier === null;
|
|
486
488
|
}
|
|
487
489
|
function planHintOf(view) {
|
|
488
|
-
|
|
490
|
+
if (!awaitingPlanOf(view)) {
|
|
491
|
+
return CONTACT_HINT;
|
|
492
|
+
}
|
|
493
|
+
return view.billing?.checkoutAvailable === true ? CHOOSE_PLAN_BILLING_HINT : CHOOSE_PLAN_HINT;
|
|
489
494
|
}
|
|
490
495
|
function inactiveExit(view, exitCode = EXIT.LIMIT) {
|
|
491
496
|
return new AskrExit(exitCode, "inactive", {
|
|
@@ -568,13 +573,14 @@ async function waitPublished(session, first, onStopped) {
|
|
|
568
573
|
function stoppedKinds(view) {
|
|
569
574
|
return view.events.failing.filter((event) => event.stopped).map((event) => event.kind);
|
|
570
575
|
}
|
|
571
|
-
var CHOOSE_PLAN_HINT, CONTACT_HINT, INIT_FIRST_HINT, CLOCK_HINT, UNAUTHORIZED_HINTS, MOVED_HINT;
|
|
576
|
+
var CHOOSE_PLAN_HINT, CHOOSE_PLAN_BILLING_HINT, CONTACT_HINT, INIT_FIRST_HINT, CLOCK_HINT, UNAUTHORIZED_HINTS, MOVED_HINT;
|
|
572
577
|
var init_store = __esm({
|
|
573
578
|
"src/commands/askr/store.ts"() {
|
|
574
579
|
init_constants();
|
|
575
580
|
init_errors();
|
|
576
581
|
init_owner_key();
|
|
577
582
|
CHOOSE_PLAN_HINT = "choose a plan: askr plan free (only if the human chose Free), or message us with your Store ID for a paid plan";
|
|
583
|
+
CHOOSE_PLAN_BILLING_HINT = "choose a plan: askr plan free (only if the human chose Free), or askr plan <starter|growth|pro|scale> [--yearly] for the paid plan the human chose, then give them its checkoutUrl to pay";
|
|
578
584
|
CONTACT_HINT = `message us with your Store ID: ${CONTACT_URL}`;
|
|
579
585
|
INIT_FIRST_HINT = "run askr init first";
|
|
580
586
|
CLOCK_HINT = "check this computer's clock: it is off by more than a minute";
|
|
@@ -1297,13 +1303,62 @@ var plan_exports = {};
|
|
|
1297
1303
|
__export(plan_exports, {
|
|
1298
1304
|
runPlan: () => runPlan
|
|
1299
1305
|
});
|
|
1300
|
-
async function
|
|
1306
|
+
async function runCheckout(session, plan, options) {
|
|
1307
|
+
const key = await useOwnerKey(session);
|
|
1308
|
+
const interval = options.yearly === true ? "year" : "month";
|
|
1309
|
+
const result = await session.call("POST", "/v1/admin/billing/checkout", {
|
|
1310
|
+
plan,
|
|
1311
|
+
interval
|
|
1312
|
+
});
|
|
1313
|
+
if (!result.ok) {
|
|
1314
|
+
switch (result.code) {
|
|
1315
|
+
case "billing_unavailable":
|
|
1316
|
+
case "plan_unavailable":
|
|
1317
|
+
throw new AskrExit(EXIT.LIMIT, result.code, {
|
|
1318
|
+
hint: `this plan cannot be bought here right now: ${PAID_HINT}`,
|
|
1319
|
+
fields: { upgrade: UPGRADE }
|
|
1320
|
+
});
|
|
1321
|
+
case "subscription_exists":
|
|
1322
|
+
throw new AskrExit(EXIT.REFUSED, "subscription_exists", {
|
|
1323
|
+
hint: `the store already has a paid plan: change it under Manage billing in the admin (${session.adminUrl})`
|
|
1324
|
+
});
|
|
1325
|
+
case "suspended":
|
|
1326
|
+
throw new AskrExit(EXIT.REFUSED, "suspended", {
|
|
1327
|
+
hint: `the store is suspended: ${CONTACT_HINT}`
|
|
1328
|
+
});
|
|
1329
|
+
case "operator_managed":
|
|
1330
|
+
throw new AskrExit(EXIT.REFUSED, "operator_managed", {
|
|
1331
|
+
hint: `we manage this store's plan: ${CONTACT_HINT}`
|
|
1332
|
+
});
|
|
1333
|
+
default:
|
|
1334
|
+
throw refusalExit(session, result);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
return {
|
|
1338
|
+
exitCode: EXIT.OK,
|
|
1339
|
+
output: {
|
|
1340
|
+
ok: true,
|
|
1341
|
+
storeId: key.storeId,
|
|
1342
|
+
plan,
|
|
1343
|
+
interval,
|
|
1344
|
+
checkoutUrl: result.body.url,
|
|
1345
|
+
hint: "give the human this checkoutUrl to open and pay (never open it yourself); the store goes live once the payment went through: check with askr status"
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
async function runPlan(session, plan, options = {}) {
|
|
1350
|
+
if (PAID_PLANS.includes(plan)) {
|
|
1351
|
+
return runCheckout(session, plan, options);
|
|
1352
|
+
}
|
|
1301
1353
|
if (plan !== FREE) {
|
|
1302
|
-
throw new AskrExit(EXIT.BAD_INPUT, "
|
|
1303
|
-
hint: "
|
|
1354
|
+
throw new AskrExit(EXIT.BAD_INPUT, "unknown_plan", {
|
|
1355
|
+
hint: "plans: free, starter, growth, pro, scale (Enterprise: message us with your Store ID)",
|
|
1304
1356
|
fields: { upgrade: UPGRADE }
|
|
1305
1357
|
});
|
|
1306
1358
|
}
|
|
1359
|
+
if (options.yearly === true) {
|
|
1360
|
+
throw new AskrExit(EXIT.BAD_INPUT, "bad_flag", { hint: "--yearly is for a paid plan" });
|
|
1361
|
+
}
|
|
1307
1362
|
const key = await useOwnerKey(session);
|
|
1308
1363
|
const result = await session.call(
|
|
1309
1364
|
"POST",
|
|
@@ -1368,13 +1423,15 @@ async function runPlan(session, plan) {
|
|
|
1368
1423
|
}
|
|
1369
1424
|
};
|
|
1370
1425
|
}
|
|
1371
|
-
var FREE;
|
|
1426
|
+
var FREE, PAID_PLANS, PAID_HINT;
|
|
1372
1427
|
var init_plan = __esm({
|
|
1373
1428
|
"src/commands/askr/plan.ts"() {
|
|
1374
1429
|
init_constants();
|
|
1375
1430
|
init_errors();
|
|
1376
1431
|
init_store();
|
|
1377
1432
|
FREE = "free";
|
|
1433
|
+
PAID_PLANS = ["starter", "growth", "pro", "scale"];
|
|
1434
|
+
PAID_HINT = "paid plans: message us with your Store ID";
|
|
1378
1435
|
}
|
|
1379
1436
|
});
|
|
1380
1437
|
|
|
@@ -2094,6 +2151,21 @@ function money(value) {
|
|
|
2094
2151
|
return "0";
|
|
2095
2152
|
}
|
|
2096
2153
|
}
|
|
2154
|
+
function billingOf(view) {
|
|
2155
|
+
const billing = view.billing;
|
|
2156
|
+
if (billing === void 0) {
|
|
2157
|
+
return null;
|
|
2158
|
+
}
|
|
2159
|
+
return {
|
|
2160
|
+
enabled: billing.enabled,
|
|
2161
|
+
plan: billing.plan,
|
|
2162
|
+
interval: billing.interval,
|
|
2163
|
+
status: billing.status,
|
|
2164
|
+
currentPeriodEnd: billing.currentPeriodEnd,
|
|
2165
|
+
cancelAtPeriodEnd: billing.cancelAtPeriodEnd,
|
|
2166
|
+
checkoutAvailable: billing.checkoutAvailable
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2097
2169
|
function connectorOf(view) {
|
|
2098
2170
|
const connector = view.connector;
|
|
2099
2171
|
if (connector === null) {
|
|
@@ -2243,6 +2315,7 @@ async function runStatus(session, options) {
|
|
|
2243
2315
|
todaySpentUsd: money(view.usage.today.spent),
|
|
2244
2316
|
monthSpentUsd: money(view.usage.month.spent)
|
|
2245
2317
|
},
|
|
2318
|
+
billing: billingOf(view),
|
|
2246
2319
|
ownerKeyFile: key.path,
|
|
2247
2320
|
adminUrl: session.adminUrl,
|
|
2248
2321
|
upgrade: UPGRADE
|
|
@@ -2279,6 +2352,113 @@ var init_status = __esm({
|
|
|
2279
2352
|
BUDGET_HINT = "the store reached its plan's monthly limit, so the chat does not answer until the plan is upgraded or the next month starts: to upgrade, message us with your Store ID (upgrade.contact)";
|
|
2280
2353
|
}
|
|
2281
2354
|
});
|
|
2355
|
+
function storeLlmsTxtUrl(npub) {
|
|
2356
|
+
return `${STORE_FILES_BASE}/${npub}/llms.txt`;
|
|
2357
|
+
}
|
|
2358
|
+
function storeCatalogJsonUrl(npub) {
|
|
2359
|
+
return `${STORE_FILES_BASE}/${npub}/catalog.json`;
|
|
2360
|
+
}
|
|
2361
|
+
function headingName(name) {
|
|
2362
|
+
const line = name.replace(/\s+/gu, " ").replace(/^[#\s]+/u, "").trim();
|
|
2363
|
+
return line === "" ? "This store" : line;
|
|
2364
|
+
}
|
|
2365
|
+
function siteLlmsTxtSection(npub) {
|
|
2366
|
+
return [
|
|
2367
|
+
LLMS_SECTION_HEADING,
|
|
2368
|
+
"",
|
|
2369
|
+
`- [Products and policies for AI agents](${storeLlmsTxtUrl(npub)}): every product with its price and page, and the store's policies, read-only`,
|
|
2370
|
+
`- [Catalog as JSON](${storeCatalogJsonUrl(npub)}): the same, machine-readable`,
|
|
2371
|
+
`- [Askr](${ASKR_SITE_URL}): the shopping assistant this store uses. Purchases happen on this site's product pages.`,
|
|
2372
|
+
""
|
|
2373
|
+
].join("\n");
|
|
2374
|
+
}
|
|
2375
|
+
function siteLlmsTxt(npub, storeName) {
|
|
2376
|
+
const name = headingName(storeName);
|
|
2377
|
+
return [
|
|
2378
|
+
`# ${name}`,
|
|
2379
|
+
"",
|
|
2380
|
+
`> ${name} has a shopping assistant, Askr: the chat on every page of this site answers questions about products, prices and policies.`,
|
|
2381
|
+
"",
|
|
2382
|
+
siteLlmsTxtSection(npub)
|
|
2383
|
+
].join("\n");
|
|
2384
|
+
}
|
|
2385
|
+
function notWritable(hint) {
|
|
2386
|
+
return new AskrExit(EXIT.BAD_INPUT, "file_not_writable", { hint: `--llms-txt: ${hint}` });
|
|
2387
|
+
}
|
|
2388
|
+
function codeOf(error) {
|
|
2389
|
+
return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
2390
|
+
}
|
|
2391
|
+
async function create(path, text) {
|
|
2392
|
+
try {
|
|
2393
|
+
await writeFile(path, text, { encoding: "utf-8", flag: "wx" });
|
|
2394
|
+
return "created";
|
|
2395
|
+
} catch (error) {
|
|
2396
|
+
throw notWritable(
|
|
2397
|
+
codeOf(error) === "EEXIST" ? "something else is at that path" : "cannot write there"
|
|
2398
|
+
);
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
async function appendTo(handle, npub) {
|
|
2402
|
+
const info = await handle.stat();
|
|
2403
|
+
if (!info.isFile()) {
|
|
2404
|
+
throw notWritable("not a regular file");
|
|
2405
|
+
}
|
|
2406
|
+
if (info.size > MAX_EXISTING_LLMS_BYTES) {
|
|
2407
|
+
throw notWritable("the file there is over 1 MiB: not an llms.txt");
|
|
2408
|
+
}
|
|
2409
|
+
const existing = await handle.readFile({ encoding: "utf-8" });
|
|
2410
|
+
if (existing.includes("\0")) {
|
|
2411
|
+
throw notWritable("the file there is not text");
|
|
2412
|
+
}
|
|
2413
|
+
if (existing.includes(storeLlmsTxtUrl(npub))) {
|
|
2414
|
+
return "unchanged";
|
|
2415
|
+
}
|
|
2416
|
+
let separator = "\n\n";
|
|
2417
|
+
if (existing === "" || existing.endsWith("\n\n") || existing.endsWith("\r\n\r\n")) {
|
|
2418
|
+
separator = "";
|
|
2419
|
+
} else if (existing.endsWith("\r\n")) {
|
|
2420
|
+
separator = "\r\n";
|
|
2421
|
+
} else if (existing.endsWith("\n")) {
|
|
2422
|
+
separator = "\n";
|
|
2423
|
+
}
|
|
2424
|
+
await handle.appendFile(`${separator}${siteLlmsTxtSection(npub)}`, { encoding: "utf-8" });
|
|
2425
|
+
return "appended";
|
|
2426
|
+
}
|
|
2427
|
+
async function writeSiteLlmsTxt(path, npub, storeName) {
|
|
2428
|
+
if (basename(path) !== LLMS_FILE_NAME) {
|
|
2429
|
+
throw notWritable("name a file called llms.txt (at your site root)");
|
|
2430
|
+
}
|
|
2431
|
+
let handle;
|
|
2432
|
+
try {
|
|
2433
|
+
handle = await open(path, constants.O_RDWR | constants.O_APPEND | NO_FOLLOW);
|
|
2434
|
+
} catch (error) {
|
|
2435
|
+
const code = codeOf(error);
|
|
2436
|
+
if (code === "ENOENT") {
|
|
2437
|
+
return create(path, siteLlmsTxt(npub, storeName));
|
|
2438
|
+
}
|
|
2439
|
+
throw notWritable(
|
|
2440
|
+
code === "ELOOP" ? "a link, not a regular file" : "cannot open the file there"
|
|
2441
|
+
);
|
|
2442
|
+
}
|
|
2443
|
+
try {
|
|
2444
|
+
return await appendTo(handle, npub);
|
|
2445
|
+
} catch (error) {
|
|
2446
|
+
throw error instanceof AskrExit ? error : notWritable("cannot write there");
|
|
2447
|
+
} finally {
|
|
2448
|
+
await handle.close();
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
var LLMS_SECTION_HEADING, LLMS_FILE_NAME, MAX_EXISTING_LLMS_BYTES, NO_FOLLOW;
|
|
2452
|
+
var init_llms_txt = __esm({
|
|
2453
|
+
"src/commands/askr/llms-txt.ts"() {
|
|
2454
|
+
init_constants();
|
|
2455
|
+
init_errors();
|
|
2456
|
+
LLMS_SECTION_HEADING = "## Shopping assistant";
|
|
2457
|
+
LLMS_FILE_NAME = "llms.txt";
|
|
2458
|
+
MAX_EXISTING_LLMS_BYTES = 1024 * 1024;
|
|
2459
|
+
NO_FOLLOW = constants.O_NOFOLLOW ?? 0;
|
|
2460
|
+
}
|
|
2461
|
+
});
|
|
2282
2462
|
|
|
2283
2463
|
// src/commands/askr/embed.ts
|
|
2284
2464
|
var embed_exports = {};
|
|
@@ -2306,13 +2486,14 @@ function cspSources(askr) {
|
|
|
2306
2486
|
{ directive: "img-src", sources: ["https:"] }
|
|
2307
2487
|
];
|
|
2308
2488
|
}
|
|
2309
|
-
async function runEmbed(session) {
|
|
2489
|
+
async function runEmbed(session, options = {}) {
|
|
2310
2490
|
const key = await useOwnerKey(session);
|
|
2311
2491
|
await readView(session);
|
|
2312
2492
|
const { config } = await readSigned(session, key.owner, key.secretKey);
|
|
2313
2493
|
if (config === void 0) {
|
|
2314
2494
|
throw new AskrExit(EXIT.BAD_INPUT, "no_settings", { hint: "run askr init first" });
|
|
2315
2495
|
}
|
|
2496
|
+
const written = options.llmsTxt === void 0 ? void 0 : await writeSiteLlmsTxt(options.llmsTxt, key.storeId, config.name);
|
|
2316
2497
|
return {
|
|
2317
2498
|
exitCode: EXIT.OK,
|
|
2318
2499
|
output: {
|
|
@@ -2323,7 +2504,10 @@ async function runEmbed(session) {
|
|
|
2323
2504
|
verificationMeta: verificationMeta(key.storeId),
|
|
2324
2505
|
csp: cspSources(session.askr),
|
|
2325
2506
|
platformHints: PLATFORM_HINTS,
|
|
2326
|
-
...config.source.kind === "admin" ? { addToCart: ADD_TO_CART } : {}
|
|
2507
|
+
...config.source.kind === "admin" ? { addToCart: ADD_TO_CART } : {},
|
|
2508
|
+
llmsTxt: siteLlmsTxt(key.storeId, config.name),
|
|
2509
|
+
llmsTxtUrl: storeLlmsTxtUrl(key.storeId),
|
|
2510
|
+
...written === void 0 ? {} : { llmsTxtFile: { path: options.llmsTxt, result: written } }
|
|
2327
2511
|
}
|
|
2328
2512
|
};
|
|
2329
2513
|
}
|
|
@@ -2332,6 +2516,7 @@ var init_embed = __esm({
|
|
|
2332
2516
|
"src/commands/askr/embed.ts"() {
|
|
2333
2517
|
init_constants();
|
|
2334
2518
|
init_errors();
|
|
2519
|
+
init_llms_txt();
|
|
2335
2520
|
init_read();
|
|
2336
2521
|
init_store();
|
|
2337
2522
|
ADD_TO_CART = `<script>
|
|
@@ -4004,9 +4189,12 @@ function registerAskr(program2, run, args, jsonErrors) {
|
|
|
4004
4189
|
(options) => run({ command: "init", options }, context(options))
|
|
4005
4190
|
);
|
|
4006
4191
|
askr.command("plan <plan>").description(
|
|
4007
|
-
"Choose a plan:
|
|
4008
|
-
).option(PROFILE_FLAG, PROFILE_HELP).action(
|
|
4009
|
-
(plan, options) => run(
|
|
4192
|
+
"Choose a plan: free starts at once; starter, growth, pro or scale prints a checkout link for the human to pay at. Run it only on the human's explicit choice"
|
|
4193
|
+
).option("--yearly", "a paid plan billed yearly instead of monthly").option(PROFILE_FLAG, PROFILE_HELP).action(
|
|
4194
|
+
(plan, options) => run(
|
|
4195
|
+
{ command: "plan", plan, options: options.yearly === true ? { yearly: true } : {} },
|
|
4196
|
+
context(options)
|
|
4197
|
+
)
|
|
4010
4198
|
);
|
|
4011
4199
|
askr.command("products").description("Publish products from a JSON or CSV file (source admin)").requiredOption("--file <path>", "products.json or products.csv").option(
|
|
4012
4200
|
"--replace",
|
|
@@ -4021,7 +4209,20 @@ function registerAskr(program2, run, args, jsonErrors) {
|
|
|
4021
4209
|
askr.command("status").description("Show the store: plan, products, policies, connector, usage").option("--probe", "also check that the chat is served on the first site").option(PROFILE_FLAG, PROFILE_HELP).action(
|
|
4022
4210
|
(options) => run({ command: "status", options }, context(options))
|
|
4023
4211
|
);
|
|
4024
|
-
askr.command("embed").description(
|
|
4212
|
+
askr.command("embed").description(
|
|
4213
|
+
"Print the widget snippet, the verification meta tag, the CSP sources and the site's llms.txt"
|
|
4214
|
+
).option(
|
|
4215
|
+
"--llms-txt <path>",
|
|
4216
|
+
"write the site's llms.txt there (appends the Askr part to an existing one)"
|
|
4217
|
+
).option(PROFILE_FLAG, PROFILE_HELP).action(
|
|
4218
|
+
(options) => run(
|
|
4219
|
+
{
|
|
4220
|
+
command: "embed",
|
|
4221
|
+
options: options.llmsTxt === void 0 ? {} : { llmsTxt: options.llmsTxt }
|
|
4222
|
+
},
|
|
4223
|
+
context(options)
|
|
4224
|
+
)
|
|
4225
|
+
);
|
|
4025
4226
|
askr.command("export-key").description(
|
|
4026
4227
|
"Write the owner key as a key file for your password manager (run it yourself, never by an agent)"
|
|
4027
4228
|
).requiredOption("--out <path>", "a new file to write (never overwritten)").option(PROFILE_FLAG, PROFILE_HELP).action(
|
|
@@ -4312,7 +4513,7 @@ async function dispatch(session, invocation) {
|
|
|
4312
4513
|
}
|
|
4313
4514
|
case "plan": {
|
|
4314
4515
|
const { runPlan: runPlan2 } = await Promise.resolve().then(() => (init_plan(), plan_exports));
|
|
4315
|
-
return runPlan2(session, invocation.plan);
|
|
4516
|
+
return runPlan2(session, invocation.plan, invocation.options);
|
|
4316
4517
|
}
|
|
4317
4518
|
case "products": {
|
|
4318
4519
|
const { runProducts: runProducts2 } = await Promise.resolve().then(() => (init_products(), products_exports));
|
|
@@ -4332,7 +4533,7 @@ async function dispatch(session, invocation) {
|
|
|
4332
4533
|
}
|
|
4333
4534
|
case "embed": {
|
|
4334
4535
|
const { runEmbed: runEmbed2 } = await Promise.resolve().then(() => (init_embed(), embed_exports));
|
|
4335
|
-
return runEmbed2(session);
|
|
4536
|
+
return runEmbed2(session, invocation.options);
|
|
4336
4537
|
}
|
|
4337
4538
|
case "export-key": {
|
|
4338
4539
|
const { runExportKey: runExportKey2 } = await Promise.resolve().then(() => (init_export_key(), export_key_exports));
|