@runtypelabs/cli 2.56.7 → 2.57.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 +5 -3
- package/dist/index.js +1472 -193
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -135,7 +135,7 @@ const SURFACE_OUTBOUND_CREDENTIAL_KEYS = credentialKeysOf({
|
|
|
135
135
|
smtpPassword: true
|
|
136
136
|
});
|
|
137
137
|
[.../* @__PURE__ */ new Set([...SURFACE_INBOUND_CREDENTIAL_KEYS, ...SURFACE_OUTBOUND_CREDENTIAL_KEYS])];
|
|
138
|
-
// ../shared/dist/chunk-
|
|
138
|
+
// ../shared/dist/chunk-DRY4gGEy.mjs
|
|
139
139
|
/** Every evaluation model the gateway lists, keyed by the gateway id a call names. */
|
|
140
140
|
const GATEWAY_EVALUATION_MODELS = Object.freeze({
|
|
141
141
|
"baseten/elephant-1": Object.freeze({
|
|
@@ -242,6 +242,14 @@ const GATEWAY_EVALUATION_MODELS = Object.freeze({
|
|
|
242
242
|
outputPer1MTokens: 0
|
|
243
243
|
})
|
|
244
244
|
}),
|
|
245
|
+
"parallel/parallel-decisions-fast": Object.freeze({
|
|
246
|
+
id: "parallel/parallel-decisions-fast",
|
|
247
|
+
name: "Decisions Fast",
|
|
248
|
+
description: "Decisions Fast is Parallel AI’s evaluation model for fast classification and scoring grounded in live web evidence. It answers yes/no, multiple-choice, and ordered scoring questions with probabilities and citations. Each request supports up to 100 related questions sharing the same context and retrieved evidence, with flat per-request pricing.",
|
|
249
|
+
contextWindow: 32e3,
|
|
250
|
+
supportedSpecifications: Object.freeze(["v4"]),
|
|
251
|
+
pricing: null
|
|
252
|
+
}),
|
|
245
253
|
"perplexity/pplx-decider-flash-v1.2": Object.freeze({
|
|
246
254
|
id: "perplexity/pplx-decider-flash-v1.2",
|
|
247
255
|
name: "Decider Flash V1.2 4B",
|
|
@@ -335,7 +343,7 @@ const gatewayModels = Object.values(GATEWAY_EVALUATION_MODELS).map((model) => Ob
|
|
|
335
343
|
minChoiceOptions: 1,
|
|
336
344
|
maxChoiceOptions: 255,
|
|
337
345
|
maxScoreLevels: 10,
|
|
338
|
-
maxQuestions: null,
|
|
346
|
+
maxQuestions: model.id === "parallel/parallel-decisions-fast" ? 100 : null,
|
|
339
347
|
platformFunding: model.pricing !== null,
|
|
340
348
|
docsUrl: "https://vercel.com/docs/ai-gateway"
|
|
341
349
|
}));
|
|
@@ -6471,7 +6479,7 @@ function date(params) {
|
|
|
6471
6479
|
function number$1(params) {
|
|
6472
6480
|
return /* @__PURE__ */ _coercedNumber(ZodNumber, params);
|
|
6473
6481
|
}
|
|
6474
|
-
// ../shared/dist/chunk-
|
|
6482
|
+
// ../shared/dist/chunk-CLhUpXeh.mjs
|
|
6475
6483
|
const judgmentJsonValueSchema = lazy(() => union([
|
|
6476
6484
|
_null(),
|
|
6477
6485
|
string$2(),
|
|
@@ -7127,12 +7135,14 @@ function resolveFallback(parsed, context, tracking, options = {}) {
|
|
|
7127
7135
|
return tracking.match;
|
|
7128
7136
|
}
|
|
7129
7137
|
new SimpleTemplateEngine();
|
|
7130
|
-
// ../shared/dist/chunk-
|
|
7138
|
+
// ../shared/dist/chunk-BfSQ06hZ.mjs
|
|
7131
7139
|
/**
|
|
7132
7140
|
* Maps model families to provider-specific model IDs.
|
|
7133
7141
|
* Use for routing: family + provider → exact model ID
|
|
7134
7142
|
*/
|
|
7135
7143
|
const MODEL_FAMILY_PROVIDER_IDS = {
|
|
7144
|
+
"ampersand-v0-1": { "vercel": "humansand/ampersand-v0.1" },
|
|
7145
|
+
"ampersand-v0.1": { "vercel": "humansand/ampersand-v0.1" },
|
|
7136
7146
|
"apex": { "vercel": "callstack/apex" },
|
|
7137
7147
|
"arrow-2": { "vercel": "quiverai/arrow-2" },
|
|
7138
7148
|
"arrow-2-telos": { "vercel": "quiverai/arrow-2-telos" },
|
|
@@ -7245,6 +7255,7 @@ const MODEL_FAMILY_PROVIDER_IDS = {
|
|
|
7245
7255
|
"deepseek-v4-1-flash": { "mixlayer": "deepseek/deepseek-v4.1-flash" },
|
|
7246
7256
|
"deepseek-v4-1-flash-1017": { "vercel": "deepseek/deepseek-v4.1-flash-1017" },
|
|
7247
7257
|
"deepseek-v4-1-flash-1017-fast": { "vercel": "deepseek/deepseek-v4.1-flash-1017-fast" },
|
|
7258
|
+
"deepseek-v4-1-flash-1017-ultrafast": { "vercel": "deepseek/deepseek-v4.1-flash-1017-ultrafast" },
|
|
7248
7259
|
"deepseek-v4-1-flash-fast": { "vercel": "deepseek/deepseek-v4.1-flash-fast" },
|
|
7249
7260
|
"deepseek-v4-flash": { "vercel": "deepseek/deepseek-v4-flash" },
|
|
7250
7261
|
"deepseek-v4-flash-0731": { "vercel": "deepseek/deepseek-v4-flash-0731" },
|
|
@@ -7254,6 +7265,7 @@ const MODEL_FAMILY_PROVIDER_IDS = {
|
|
|
7254
7265
|
"deepseek-v4.1-flash": { "mixlayer": "deepseek/deepseek-v4.1-flash" },
|
|
7255
7266
|
"deepseek-v4.1-flash-1017": { "vercel": "deepseek/deepseek-v4.1-flash-1017" },
|
|
7256
7267
|
"deepseek-v4.1-flash-1017-fast": { "vercel": "deepseek/deepseek-v4.1-flash-1017-fast" },
|
|
7268
|
+
"deepseek-v4.1-flash-1017-ultrafast": { "vercel": "deepseek/deepseek-v4.1-flash-1017-ultrafast" },
|
|
7257
7269
|
"deepseek-v4.1-flash-fast": { "vercel": "deepseek/deepseek-v4.1-flash-fast" },
|
|
7258
7270
|
"ember-1": { "vercel": "fireworks/ember-1" },
|
|
7259
7271
|
"fugu-max": { "vercel": "sakana/fugu-max" },
|
|
@@ -8224,7 +8236,7 @@ const CREATOR_TO_PROVIDER = {
|
|
|
8224
8236
|
"unknown": "openai"
|
|
8225
8237
|
};
|
|
8226
8238
|
new RegExp(`^${/Model stream stalled \((awaiting_first_token|idle|empty_completion)\) after \d+ms with no progress/.source}`);
|
|
8227
|
-
// ../shared/dist/chunk-
|
|
8239
|
+
// ../shared/dist/chunk-BtSflVAD.mjs
|
|
8228
8240
|
/**
|
|
8229
8241
|
* Unwraps a single {{variableName}} template to its bare variable name, preserving array/object identity instead of stringifying via the template engine.
|
|
8230
8242
|
* Returns source unchanged when it is not a lone {{...}} wrapper.
|
|
@@ -12647,7 +12659,7 @@ object$4({
|
|
|
12647
12659
|
externalId: string$2().min(1).max(500).optional().describe("The conversation id in the source system. Re-creating with the same system and externalId returns the existing conversation with imported: false instead of a duplicate."),
|
|
12648
12660
|
importedAt: string$2().datetime({ offset: true }).optional()
|
|
12649
12661
|
});
|
|
12650
|
-
// ../shared/dist/chunk-
|
|
12662
|
+
// ../shared/dist/chunk-CoA2IB3c.mjs
|
|
12651
12663
|
const voiceInterruptionModeSchema = _enum([
|
|
12652
12664
|
"none",
|
|
12653
12665
|
"cancel",
|
|
@@ -26264,7 +26276,7 @@ function loadBrandConfig(env) {
|
|
|
26264
26276
|
}
|
|
26265
26277
|
loadBrandConfig();
|
|
26266
26278
|
BRAND_CONFIGS[DEFAULT_BRAND_NAME];
|
|
26267
|
-
// ../shared/dist/chunk-
|
|
26279
|
+
// ../shared/dist/chunk-2W0oIwXh.mjs
|
|
26268
26280
|
const ARCHITECTURE_PREVIEW_SURFACE_TYPES = [
|
|
26269
26281
|
"chat",
|
|
26270
26282
|
"api",
|
|
@@ -29600,27 +29612,57 @@ function loadKeyring() {
|
|
|
29600
29612
|
keyringModule ??= import("@napi-rs/keyring").then((mod) => mod.AsyncEntry).catch(() => null);
|
|
29601
29613
|
return keyringModule;
|
|
29602
29614
|
}
|
|
29615
|
+
/**
|
|
29616
|
+
* The OS keychain. On Linux every entry is pinned to the Secret Service: unpinned, the binding falls
|
|
29617
|
+
* back silently to the kernel keyring, which loses the login at reboot. Without a Secret Service the
|
|
29618
|
+
* write throws and the account store falls back to the file.
|
|
29619
|
+
*/
|
|
29603
29620
|
var KeychainSecretBackend = class {
|
|
29604
29621
|
kind = "keychain";
|
|
29605
|
-
|
|
29606
|
-
|
|
29622
|
+
platform;
|
|
29623
|
+
loadEntry;
|
|
29624
|
+
constructor(options = {}) {
|
|
29625
|
+
this.platform = options.platform ?? process.platform;
|
|
29626
|
+
this.loadEntry = options.loadEntry ?? loadKeyring;
|
|
29627
|
+
}
|
|
29628
|
+
async entry(name, pinned = true) {
|
|
29629
|
+
const AsyncEntry = await this.loadEntry();
|
|
29607
29630
|
if (!AsyncEntry) throw new Error("OS keychain is not available on this platform.");
|
|
29631
|
+
if (pinned && this.platform === "linux") return new AsyncEntry(KEYCHAIN_SERVICE, name, { linux: { store: "secret-service" } });
|
|
29608
29632
|
return new AsyncEntry(KEYCHAIN_SERVICE, name);
|
|
29609
29633
|
}
|
|
29634
|
+
/** A login written by a version that did not pin the store may sit in the kernel keyring until reboot. */
|
|
29635
|
+
async legacyLinuxGet(name) {
|
|
29636
|
+
if (this.platform !== "linux") return null;
|
|
29637
|
+
try {
|
|
29638
|
+
return await (await this.entry(name, false)).getPassword() ?? null;
|
|
29639
|
+
} catch {
|
|
29640
|
+
return null;
|
|
29641
|
+
}
|
|
29642
|
+
}
|
|
29610
29643
|
async get(name) {
|
|
29611
|
-
|
|
29644
|
+
try {
|
|
29645
|
+
return await (await this.entry(name)).getPassword() ?? await this.legacyLinuxGet(name);
|
|
29646
|
+
} catch (error) {
|
|
29647
|
+
const legacy = await this.legacyLinuxGet(name);
|
|
29648
|
+
if (legacy !== null) return legacy;
|
|
29649
|
+
throw error;
|
|
29650
|
+
}
|
|
29612
29651
|
}
|
|
29613
29652
|
async set(name, value) {
|
|
29614
29653
|
await (await this.entry(name)).setPassword(value);
|
|
29615
29654
|
}
|
|
29616
29655
|
async delete(name) {
|
|
29656
|
+
if (this.platform === "linux") await (await this.entry(name, false)).deleteCredential().catch(() => false);
|
|
29617
29657
|
await (await this.entry(name)).deleteCredential();
|
|
29618
29658
|
}
|
|
29619
29659
|
};
|
|
29660
|
+
const PLAIN_PREFIX = "plain:";
|
|
29620
29661
|
/**
|
|
29621
|
-
* Fallback for hosts with no usable OS keychain (headless Linux, containers, CI)
|
|
29622
|
-
*
|
|
29623
|
-
*
|
|
29662
|
+
* Fallback for hosts with no usable OS keychain (headless Linux, containers, CI): plaintext in a 0600
|
|
29663
|
+
* file inside a 0700 directory, as gh and wrangler store tokens. Values from older versions were
|
|
29664
|
+
* encrypted with a hostname-derived key, which a new container hostname breaks; they are still read
|
|
29665
|
+
* when that key matches, and the next write stores them as plaintext.
|
|
29624
29666
|
*/
|
|
29625
29667
|
var FileSecretBackend = class {
|
|
29626
29668
|
filePath;
|
|
@@ -29629,25 +29671,44 @@ var FileSecretBackend = class {
|
|
|
29629
29671
|
this.filePath = filePath;
|
|
29630
29672
|
}
|
|
29631
29673
|
async get(name) {
|
|
29632
|
-
const
|
|
29633
|
-
|
|
29674
|
+
const secrets = this.read();
|
|
29675
|
+
const stored = Object.prototype.hasOwnProperty.call(secrets, name) ? secrets[name] : void 0;
|
|
29676
|
+
if (typeof stored !== "string" || stored === "") return null;
|
|
29677
|
+
if (stored.startsWith(PLAIN_PREFIX)) return stored.slice(6);
|
|
29678
|
+
try {
|
|
29679
|
+
return decryptWithMachineKey(stored);
|
|
29680
|
+
} catch {
|
|
29681
|
+
return null;
|
|
29682
|
+
}
|
|
29634
29683
|
}
|
|
29635
29684
|
async set(name, value) {
|
|
29636
|
-
this.
|
|
29637
|
-
|
|
29638
|
-
|
|
29685
|
+
const secrets = this.read();
|
|
29686
|
+
Object.defineProperty(secrets, name, {
|
|
29687
|
+
value: `${PLAIN_PREFIX}${value}`,
|
|
29688
|
+
enumerable: true,
|
|
29689
|
+
configurable: true,
|
|
29690
|
+
writable: true
|
|
29639
29691
|
});
|
|
29692
|
+
this.write(secrets);
|
|
29640
29693
|
}
|
|
29641
29694
|
async delete(name) {
|
|
29642
29695
|
const secrets = this.read();
|
|
29643
|
-
if (!(name
|
|
29696
|
+
if (!Object.prototype.hasOwnProperty.call(secrets, name)) return;
|
|
29644
29697
|
delete secrets[name];
|
|
29645
29698
|
this.write(secrets);
|
|
29646
29699
|
}
|
|
29647
29700
|
read() {
|
|
29648
29701
|
try {
|
|
29649
29702
|
const parsed = JSON.parse(fs.readFileSync(this.filePath, "utf8"));
|
|
29650
|
-
|
|
29703
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
29704
|
+
const secrets = {};
|
|
29705
|
+
for (const [key, value] of Object.entries(parsed)) if (typeof value === "string") Object.defineProperty(secrets, key, {
|
|
29706
|
+
value,
|
|
29707
|
+
enumerable: true,
|
|
29708
|
+
configurable: true,
|
|
29709
|
+
writable: true
|
|
29710
|
+
});
|
|
29711
|
+
return secrets;
|
|
29651
29712
|
} catch {
|
|
29652
29713
|
return {};
|
|
29653
29714
|
}
|
|
@@ -29674,11 +29735,6 @@ function writePrivateJsonFile(filePath, data) {
|
|
|
29674
29735
|
function getMachineKey() {
|
|
29675
29736
|
return crypto$1.createHash("sha256").update(`runtype-cli-${os.hostname()}-${os.userInfo().username}`).digest("hex").substring(0, 32);
|
|
29676
29737
|
}
|
|
29677
|
-
function encryptWithMachineKey(text) {
|
|
29678
|
-
const iv = crypto$1.randomBytes(16);
|
|
29679
|
-
const cipher = crypto$1.createCipheriv("aes-256-cbc", Buffer.from(getMachineKey()), iv);
|
|
29680
|
-
return `${iv.toString("hex")}:${cipher.update(text, "utf8", "hex")}${cipher.final("hex")}`;
|
|
29681
|
-
}
|
|
29682
29738
|
function decryptWithMachineKey(text) {
|
|
29683
29739
|
const [ivHex, encrypted] = text.split(":");
|
|
29684
29740
|
const decipher = crypto$1.createDecipheriv("aes-256-cbc", Buffer.from(getMachineKey()), Buffer.from(ivHex, "hex"));
|
|
@@ -32431,7 +32487,7 @@ const unlinkCommand = new Command("unlink").description("Remove the nearest .run
|
|
|
32431
32487
|
});
|
|
32432
32488
|
// src/lib/file-utils.ts
|
|
32433
32489
|
/** Parse a string as a JSON object, exiting with a clear error on failure. */
|
|
32434
|
-
function parseJsonObject
|
|
32490
|
+
function parseJsonObject(raw, label) {
|
|
32435
32491
|
let parsed;
|
|
32436
32492
|
try {
|
|
32437
32493
|
parsed = JSON.parse(raw);
|
|
@@ -32463,7 +32519,7 @@ function readJsonFile(path, opts = {}) {
|
|
|
32463
32519
|
console.error(chalk.red(`Failed to read ${label}: ${path}`));
|
|
32464
32520
|
process.exit(1);
|
|
32465
32521
|
}
|
|
32466
|
-
const obj = parseJsonObject
|
|
32522
|
+
const obj = parseJsonObject(raw, label);
|
|
32467
32523
|
if (opts.unwrapKey) {
|
|
32468
32524
|
const nested = obj[opts.unwrapKey];
|
|
32469
32525
|
if (nested && typeof nested === "object" && !Array.isArray(nested)) return { ...nested };
|
|
@@ -32485,7 +32541,7 @@ function resolveJsonPayload(inline, fromFile, label) {
|
|
|
32485
32541
|
process.exit(1);
|
|
32486
32542
|
}
|
|
32487
32543
|
if (fromFile !== void 0) return readJsonFile(fromFile, { label });
|
|
32488
|
-
return parseJsonObject
|
|
32544
|
+
return parseJsonObject(inline, label);
|
|
32489
32545
|
}
|
|
32490
32546
|
// src/lib/ensure-output.ts
|
|
32491
32547
|
/**
|
|
@@ -53868,13 +53924,14 @@ modelsCommand.command("list").description("List your enabled model configuration
|
|
|
53868
53924
|
const { waitUntilExit } = render(React.createElement(App));
|
|
53869
53925
|
await waitUntilExit();
|
|
53870
53926
|
});
|
|
53871
|
-
modelsCommand.command("available").description("List all available models grouped by provider").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
|
|
53927
|
+
modelsCommand.command("available").description("List all available models grouped by provider").option("--search <query>", "Only models matching every word, ordered by relevance").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
|
|
53872
53928
|
const apiKey = await ensureAuth();
|
|
53873
53929
|
if (!apiKey) return;
|
|
53874
53930
|
const client = createCliClient(apiKey);
|
|
53931
|
+
const groupedPath = options.search ? `/model-configs/grouped?q=${encodeURIComponent(options.search)}` : "/model-configs/grouped";
|
|
53875
53932
|
if (!isTTY(options) || options.json) {
|
|
53876
53933
|
try {
|
|
53877
|
-
const data = await client.get(
|
|
53934
|
+
const data = await client.get(groupedPath);
|
|
53878
53935
|
if (options.json) {
|
|
53879
53936
|
printJson(data);
|
|
53880
53937
|
return;
|
|
@@ -53903,7 +53960,7 @@ modelsCommand.command("available").description("List all available models groupe
|
|
|
53903
53960
|
const [items, setItems] = useState(null);
|
|
53904
53961
|
const [error, setError] = useState(null);
|
|
53905
53962
|
useEffect(() => {
|
|
53906
|
-
client.get(
|
|
53963
|
+
client.get(groupedPath).then((res) => setItems(res.data ?? [])).catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
|
|
53907
53964
|
}, []);
|
|
53908
53965
|
return React.createElement(DataList, {
|
|
53909
53966
|
title: "Available Models",
|
|
@@ -56769,26 +56826,26 @@ clientTokensCommand.command("regenerate <id>").description("Regenerate a client
|
|
|
56769
56826
|
});
|
|
56770
56827
|
clientTokensCommand.addCommand(clientTokenEnsureCommand);
|
|
56771
56828
|
// ../../node_modules/.pnpm/@runtypelabs+persona@4.34.0/node_modules/@runtypelabs/persona/dist/codegen.js
|
|
56772
|
-
function e(e) {
|
|
56829
|
+
function e$3(e) {
|
|
56773
56830
|
return e?.cdnBase?.trim().replace(/\/+$/, ``).replace(/[\\'"<>`]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2, `0`)}`) || `https://cdn.jsdelivr.net/npm/@runtypelabs/persona@4.34.0/dist`;
|
|
56774
56831
|
}
|
|
56775
|
-
function t(e) {
|
|
56832
|
+
function t$3(e) {
|
|
56776
56833
|
if (e !== void 0) return typeof e == `string` ? e : Array.isArray(e) ? `[${e.map((e) => e.toString()).join(`, `)}]` : e.toString();
|
|
56777
56834
|
}
|
|
56778
|
-
function n(e) {
|
|
56835
|
+
function n$3(e) {
|
|
56779
56836
|
if (e) return {
|
|
56780
|
-
getHeaders: t(e.getHeaders),
|
|
56781
|
-
onFeedback: t(e.onFeedback),
|
|
56782
|
-
onCopy: t(e.onCopy),
|
|
56783
|
-
requestMiddleware: t(e.requestMiddleware),
|
|
56784
|
-
actionHandlers: t(e.actionHandlers),
|
|
56785
|
-
actionParsers: t(e.actionParsers),
|
|
56786
|
-
postprocessMessage: t(e.postprocessMessage),
|
|
56787
|
-
contextProviders: t(e.contextProviders),
|
|
56788
|
-
streamParser: t(e.streamParser)
|
|
56789
|
-
};
|
|
56790
|
-
}
|
|
56791
|
-
const r = `({ text, message }: any) => {
|
|
56837
|
+
getHeaders: t$3(e.getHeaders),
|
|
56838
|
+
onFeedback: t$3(e.onFeedback),
|
|
56839
|
+
onCopy: t$3(e.onCopy),
|
|
56840
|
+
requestMiddleware: t$3(e.requestMiddleware),
|
|
56841
|
+
actionHandlers: t$3(e.actionHandlers),
|
|
56842
|
+
actionParsers: t$3(e.actionParsers),
|
|
56843
|
+
postprocessMessage: t$3(e.postprocessMessage),
|
|
56844
|
+
contextProviders: t$3(e.contextProviders),
|
|
56845
|
+
streamParser: t$3(e.streamParser)
|
|
56846
|
+
};
|
|
56847
|
+
}
|
|
56848
|
+
const r$1 = `({ text, message }: any) => {
|
|
56792
56849
|
const jsonSource = (message as any).rawContent || text || message.content;
|
|
56793
56850
|
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
56794
56851
|
let cleanJson = jsonSource
|
|
@@ -56802,7 +56859,7 @@ const r = `({ text, message }: any) => {
|
|
|
56802
56859
|
} catch (e) { return null; }
|
|
56803
56860
|
return null;
|
|
56804
56861
|
}`;
|
|
56805
|
-
const i = `function(ctx) {
|
|
56862
|
+
const i$1 = `function(ctx) {
|
|
56806
56863
|
var jsonSource = ctx.message.rawContent || ctx.text || ctx.message.content;
|
|
56807
56864
|
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
56808
56865
|
var cleanJson = jsonSource
|
|
@@ -56834,7 +56891,7 @@ const a = `(action: any, context: any) => {
|
|
|
56834
56891
|
window.location.href = targetUrl;
|
|
56835
56892
|
return { handled: true, displayText: text };
|
|
56836
56893
|
}`;
|
|
56837
|
-
const o = `function(action, context) {
|
|
56894
|
+
const o$2 = `function(action, context) {
|
|
56838
56895
|
if (action.type !== 'nav_then_click') return;
|
|
56839
56896
|
var payload = action.payload || action.raw || {};
|
|
56840
56897
|
var url = payload.page;
|
|
@@ -56852,27 +56909,27 @@ const o = `function(action, context) {
|
|
|
56852
56909
|
window.location.href = targetUrl;
|
|
56853
56910
|
return { handled: true, displayText: text };
|
|
56854
56911
|
}`;
|
|
56855
|
-
function s(e) {
|
|
56912
|
+
function s$2(e) {
|
|
56856
56913
|
if (!e) return null;
|
|
56857
56914
|
let t = e.toString();
|
|
56858
56915
|
return t.includes(`createJsonStreamParser`) || t.includes(`partial-json`) ? `json` : t.includes(`createRegexJsonParser`) || t.includes(`regex`) ? `regex-json` : t.includes(`createXmlParser`) || t.includes(`<text>`) ? `xml` : null;
|
|
56859
56916
|
}
|
|
56860
|
-
function c(e) {
|
|
56861
|
-
return e.parserType ?? s(e.streamParser) ?? `plain`;
|
|
56917
|
+
function c$2(e) {
|
|
56918
|
+
return e.parserType ?? s$2(e.streamParser) ?? `plain`;
|
|
56862
56919
|
}
|
|
56863
|
-
function l(e, t) {
|
|
56920
|
+
function l$2(e, t) {
|
|
56864
56921
|
let n = [];
|
|
56865
56922
|
return e.toolCall && (n.push(`${t}toolCall: {`), Object.entries(e.toolCall).forEach(([e, r]) => {
|
|
56866
56923
|
typeof r == `string` && n.push(`${t} ${e}: "${r}",`);
|
|
56867
56924
|
}), n.push(`${t}},`)), n;
|
|
56868
56925
|
}
|
|
56869
|
-
function u(e, t, n) {
|
|
56926
|
+
function u$2(e, t, n) {
|
|
56870
56927
|
let r = [], i = e.messageActions && Object.entries(e.messageActions).some(([e, t]) => e !== `onFeedback` && e !== `onCopy` && t !== void 0), a = n?.onFeedback || n?.onCopy;
|
|
56871
56928
|
return (i || a) && (r.push(`${t}messageActions: {`), e.messageActions && Object.entries(e.messageActions).forEach(([e, n]) => {
|
|
56872
56929
|
e !== `onFeedback` && e !== `onCopy` && (typeof n == `string` ? r.push(`${t} ${e}: "${n}",`) : typeof n == `boolean` && r.push(`${t} ${e}: ${n},`));
|
|
56873
56930
|
}), n?.onFeedback && r.push(`${t} onFeedback: ${n.onFeedback},`), n?.onCopy && r.push(`${t} onCopy: ${n.onCopy},`), r.push(`${t}},`)), r;
|
|
56874
56931
|
}
|
|
56875
|
-
function d(e, t) {
|
|
56932
|
+
function d$1(e, t) {
|
|
56876
56933
|
let n = [];
|
|
56877
56934
|
if (e.markdown) {
|
|
56878
56935
|
let r = e.markdown.options && Object.keys(e.markdown.options).length > 0, i = e.markdown.disableDefaultStyles !== void 0;
|
|
@@ -56882,13 +56939,13 @@ function d(e, t) {
|
|
|
56882
56939
|
}
|
|
56883
56940
|
return n;
|
|
56884
56941
|
}
|
|
56885
|
-
function f(e, t) {
|
|
56942
|
+
function f$2(e, t) {
|
|
56886
56943
|
if (!e.suggestions) return [];
|
|
56887
56944
|
let n = JSON.stringify(e.suggestions, null, 2).split(`
|
|
56888
56945
|
`);
|
|
56889
56946
|
return n.map((e, r) => `${r === 0 ? `${t}suggestions: ` : t}${e}${r === n.length - 1 ? `,` : ``}`);
|
|
56890
56947
|
}
|
|
56891
|
-
function p(e, t) {
|
|
56948
|
+
function p$3(e, t) {
|
|
56892
56949
|
let n = [];
|
|
56893
56950
|
if (e.layout) {
|
|
56894
56951
|
let r = e.layout.header && Object.keys(e.layout.header).some((e) => e !== `render`), i = e.layout.messages && Object.keys(e.layout.messages).some((e) => e !== `renderUserMessage` && e !== `renderAssistantMessage`);
|
|
@@ -56904,41 +56961,41 @@ function p(e, t) {
|
|
|
56904
56961
|
}
|
|
56905
56962
|
return n;
|
|
56906
56963
|
}
|
|
56907
|
-
function m(e, t) {
|
|
56964
|
+
function m$3(e, t) {
|
|
56908
56965
|
let n = [];
|
|
56909
56966
|
return e && (e.getHeaders && n.push(`${t}getHeaders: ${e.getHeaders},`), e.requestMiddleware && n.push(`${t}requestMiddleware: ${e.requestMiddleware},`), e.actionParsers && n.push(`${t}actionParsers: ${e.actionParsers},`), e.actionHandlers && n.push(`${t}actionHandlers: ${e.actionHandlers},`), e.contextProviders && n.push(`${t}contextProviders: ${e.contextProviders},`), e.streamParser && n.push(`${t}streamParser: ${e.streamParser},`)), n;
|
|
56910
56967
|
}
|
|
56911
|
-
function h(e, t) {
|
|
56968
|
+
function h$3(e, t) {
|
|
56912
56969
|
return JSON.stringify(e, null, t).replace(/</g, `\\u003c`).replace(/\u2028/g, `\\u2028`).replace(/\u2029/g, `\\u2029`);
|
|
56913
56970
|
}
|
|
56914
|
-
function g(e, t, n) {
|
|
56971
|
+
function g$2(e, t, n) {
|
|
56915
56972
|
Object.entries(t).forEach(([t, r]) => {
|
|
56916
56973
|
if (r === void 0 || typeof r == `function`) return;
|
|
56917
|
-
let i = /^[a-zA-Z_$][\w$]*$/.test(t) ? t : h(t);
|
|
56918
|
-
Array.isArray(r) ? e.push(`${n}${i}: ${h(r)},`) : r && typeof r == `object` ? (e.push(`${n}${i}: {`), g(e, r, `${n} `), e.push(`${n}},`)) : e.push(`${n}${i}: ${h(r)},`);
|
|
56974
|
+
let i = /^[a-zA-Z_$][\w$]*$/.test(t) ? t : h$3(t);
|
|
56975
|
+
Array.isArray(r) ? e.push(`${n}${i}: ${h$3(r)},`) : r && typeof r == `object` ? (e.push(`${n}${i}: {`), g$2(e, r, `${n} `), e.push(`${n}},`)) : e.push(`${n}${i}: ${h$3(r)},`);
|
|
56919
56976
|
});
|
|
56920
56977
|
}
|
|
56921
|
-
function _(e, t, n, r) {
|
|
56922
|
-
n && (e.push(`${r}${t}: {`), g(e, n, `${r} `), e.push(`${r}},`));
|
|
56978
|
+
function _$2(e, t, n, r) {
|
|
56979
|
+
n && (e.push(`${r}${t}: {`), g$2(e, n, `${r} `), e.push(`${r}},`));
|
|
56923
56980
|
}
|
|
56924
|
-
function v(e, t, n) {
|
|
56925
|
-
_(e, `copy`, t.copy, n), _(e, `welcome`, t.welcome, n), t.approval === !1 ? e.push(`${n}approval: false,`) : _(e, `approval`, t.approval, n);
|
|
56981
|
+
function v$2(e, t, n) {
|
|
56982
|
+
_$2(e, `copy`, t.copy, n), _$2(e, `welcome`, t.welcome, n), t.approval === !1 ? e.push(`${n}approval: false,`) : _$2(e, `approval`, t.approval, n);
|
|
56926
56983
|
}
|
|
56927
|
-
function y(e, t, n) {
|
|
56928
|
-
t.future?.v5Defaults !== void 0 && e.push(`${n}future: { v5Defaults: ${t.future.v5Defaults === !0} },`), _(e, `brand`, t.brand, n), _(e, `darkTheme`, t.darkTheme, n), t.colorScheme !== void 0 && e.push(`${n}colorScheme: ${JSON.stringify(t.colorScheme)},`);
|
|
56984
|
+
function y$2(e, t, n) {
|
|
56985
|
+
t.future?.v5Defaults !== void 0 && e.push(`${n}future: { v5Defaults: ${t.future.v5Defaults === !0} },`), _$2(e, `brand`, t.brand, n), _$2(e, `darkTheme`, t.darkTheme, n), t.colorScheme !== void 0 && e.push(`${n}colorScheme: ${JSON.stringify(t.colorScheme)},`);
|
|
56929
56986
|
}
|
|
56930
|
-
function b(e) {
|
|
56987
|
+
function b$2(e) {
|
|
56931
56988
|
return (e?.target ?? `body`).replace(/\\/g, `\\\\`).replace(/'/g, `\\'`);
|
|
56932
56989
|
}
|
|
56933
|
-
function x(e, t = `esm`, r) {
|
|
56934
|
-
if (r?.authoredOverrides) return S(e, t, r);
|
|
56990
|
+
function x$2(e, t = `esm`, r) {
|
|
56991
|
+
if (r?.authoredOverrides) return S$2(e, t, r);
|
|
56935
56992
|
let i = { ...e };
|
|
56936
56993
|
delete i.postprocessMessage, delete i.initialMessages;
|
|
56937
56994
|
let a = r ? {
|
|
56938
56995
|
...r,
|
|
56939
|
-
hooks: n(r.hooks)
|
|
56996
|
+
hooks: n$3(r.hooks)
|
|
56940
56997
|
} : void 0, o;
|
|
56941
|
-
o = t === `esm` ? C(i, a) : t === `script-installer` ? D(i, a) : t === `script-advanced` ? k(i, a) : t === `react-component` ? w(i, a) : t === `react-advanced` ? T(i, a) : O(i, a);
|
|
56998
|
+
o = t === `esm` ? C$2(i, a) : t === `script-installer` ? D$2(i, a) : t === `script-advanced` ? k$2(i, a) : t === `react-component` ? w$2(i, a) : t === `react-advanced` ? T$2(i, a) : O$2(i, a);
|
|
56942
56999
|
let s = [
|
|
56943
57000
|
[`welcome.icon`, e.welcome?.icon],
|
|
56944
57001
|
[`approval.formatDescription`, e.approval?.formatDescription],
|
|
@@ -56948,7 +57005,7 @@ function x(e, t = `esm`, r) {
|
|
|
56948
57005
|
let c = `Function-valued ${s.join(`, `)} omitted; reattach in host JavaScript.`;
|
|
56949
57006
|
return t.startsWith(`script-`) ? `<!-- ${c} -->\n${o}` : `// ${c}\n${o}`;
|
|
56950
57007
|
}
|
|
56951
|
-
function S(t, r, i) {
|
|
57008
|
+
function S$2(t, r, i) {
|
|
56952
57009
|
let a = [], o = Symbol(`omit`), s = /* @__PURE__ */ new Set([
|
|
56953
57010
|
`storageAdapter`,
|
|
56954
57011
|
`targetProviders`,
|
|
@@ -56967,17 +57024,17 @@ function S(t, r, i) {
|
|
|
56967
57024
|
let r = l(n, t ? `${t}.${e}` : e);
|
|
56968
57025
|
return r === o ? [] : [[e, r]];
|
|
56969
57026
|
}));
|
|
56970
|
-
}, u = l(t, ``), d = n(i.hooks), f = r === `script-installer`, p = h(u, 2);
|
|
57027
|
+
}, u = l(t, ``), d = n$3(i.hooks), f = r === `script-installer`, p = h$3(u, 2);
|
|
56971
57028
|
if (d) {
|
|
56972
|
-
let e = m(d, ` `);
|
|
57029
|
+
let e = m$3(d, ` `);
|
|
56973
57030
|
d.postprocessMessage && e.push(` postprocessMessage: ${d.postprocessMessage},`);
|
|
56974
57031
|
let t = [`onFeedback`, `onCopy`];
|
|
56975
57032
|
if (t.some((e) => d[e])) {
|
|
56976
57033
|
if (!f) {
|
|
56977
57034
|
let e = { ...u };
|
|
56978
|
-
delete e.messageActions, p = h(e, 2);
|
|
57035
|
+
delete e.messageActions, p = h$3(e, 2);
|
|
56979
57036
|
}
|
|
56980
|
-
e.push(` messageActions: {`), e.push(...Object.entries(u.messageActions ?? {}).map(([e, t]) => ` ${h(e)}: ${h(t)},`));
|
|
57037
|
+
e.push(` messageActions: {`), e.push(...Object.entries(u.messageActions ?? {}).map(([e, t]) => ` ${h$3(e)}: ${h$3(t)},`));
|
|
56981
57038
|
for (let n of t) d[n] && e.push(` ${n}: ${d[n]},`);
|
|
56982
57039
|
e.push(` },`);
|
|
56983
57040
|
}
|
|
@@ -56989,8 +57046,8 @@ function S(t, r, i) {
|
|
|
56989
57046
|
}
|
|
56990
57047
|
}
|
|
56991
57048
|
r.startsWith(`script-`) && (p = p.replace(/<\/script/gi, `<\\/script`));
|
|
56992
|
-
let g, _ = h(i.target ?? `body`), v = i.windowKey ? `, windowKey: ${h(i.windowKey)}` : ``, y = e(i);
|
|
56993
|
-
if (g = f ? `<script src="${y}/install.global.js" data-config='${h(i.target || i.windowKey ? {
|
|
57049
|
+
let g, _ = h$3(i.target ?? `body`), v = i.windowKey ? `, windowKey: ${h$3(i.windowKey)}` : ``, y = e$3(i);
|
|
57050
|
+
if (g = f ? `<script src="${y}/install.global.js" data-config='${h$3(i.target || i.windowKey ? {
|
|
56994
57051
|
config: u,
|
|
56995
57052
|
...i.target ? { target: i.target } : {},
|
|
56996
57053
|
...i.windowKey ? { windowKey: i.windowKey } : {}
|
|
@@ -56998,16 +57055,16 @@ function S(t, r, i) {
|
|
|
56998
57055
|
let b = `Omitted non-serializable inputs: ${[...new Set(a)].join(`, `)}. Reattach functions/custom implementations in host JavaScript; closures cannot be reconstructed.`;
|
|
56999
57056
|
return r.startsWith(`script-`) ? `<!-- ${b.replace(/--/g, `—`).replace(/</g, `<`).replace(/>/g, `>`)} -->\n${g}` : `// ${b.replace(/[\r\n\u2028\u2029]/g, ` `)}\n${g}`;
|
|
57000
57057
|
}
|
|
57001
|
-
function C(e, t) {
|
|
57002
|
-
let n = t?.hooks, r = c(e), i = r !== `plain`, a = [
|
|
57058
|
+
function C$2(e, t) {
|
|
57059
|
+
let n = t?.hooks, r = c$2(e), i = r !== `plain`, a = [
|
|
57003
57060
|
`import '@runtypelabs/persona/widget.css';`,
|
|
57004
57061
|
`import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';`,
|
|
57005
57062
|
``,
|
|
57006
57063
|
`initAgentWidget({`,
|
|
57007
|
-
` target: '${b(t)}',`,
|
|
57064
|
+
` target: '${b$2(t)}',`,
|
|
57008
57065
|
` config: {`
|
|
57009
57066
|
];
|
|
57010
|
-
return e.apiUrl && a.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && a.push(` clientToken: "${e.clientToken}",`), e.agentId && a.push(` agentId: "${e.agentId}",`), e.target && a.push(` target: "${e.target}",`), e.flowId && a.push(` flowId: "${e.flowId}",`), i && a.push(` parserType: "${r}",`), y(a, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && _(a, `theme`, e.theme, ` `), e.launcher && _(a, `launcher`, e.launcher, ` `), v(a, e, ` `), e.sendButton && (a.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
|
|
57067
|
+
return e.apiUrl && a.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && a.push(` clientToken: "${e.clientToken}",`), e.agentId && a.push(` agentId: "${e.agentId}",`), e.target && a.push(` target: "${e.target}",`), e.flowId && a.push(` flowId: "${e.flowId}",`), i && a.push(` parserType: "${r}",`), y$2(a, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && _$2(a, `theme`, e.theme, ` `), e.launcher && _$2(a, `launcher`, e.launcher, ` `), v$2(a, e, ` `), e.sendButton && (a.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
|
|
57011
57068
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
|
|
57012
57069
|
}), a.push(` },`)), e.voiceRecognition && (a.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
|
|
57013
57070
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && a.push(` ${e}: ${t},`);
|
|
@@ -57015,13 +57072,13 @@ function C(e, t) {
|
|
|
57015
57072
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
|
|
57016
57073
|
}), a.push(` },`)), e.features && (a.push(` features: {`), Object.entries(e.features).forEach(([e, t]) => {
|
|
57017
57074
|
a.push(` ${e}: ${t},`);
|
|
57018
|
-
}), a.push(` },`)), a.push(...f(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (a.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57075
|
+
}), a.push(` },`)), a.push(...f$2(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (a.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57019
57076
|
a.push(` "${e}",`);
|
|
57020
|
-
}), a.push(` ],`)), e.suggestionChipsConfig && (a.push(` suggestionChipsConfig: {`), e.suggestionChipsConfig.fontFamily && a.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && a.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && a.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && a.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), a.push(` },`)), a.push(...l(e, ` `)), a.push(...u(e, ` `, n)), a.push(...d(e, ` `)), a.push(...p(e, ` `)), a.push(...m(n, ` `)), e.debug && a.push(` debug: ${e.debug},`), n?.postprocessMessage ? a.push(` postprocessMessage: ${n.postprocessMessage}`) : a.push(` postprocessMessage: ({ text }) => markdownPostprocessor(text)`), a.push(` }`), a.push(`});`), a.join(`
|
|
57077
|
+
}), a.push(` ],`)), e.suggestionChipsConfig && (a.push(` suggestionChipsConfig: {`), e.suggestionChipsConfig.fontFamily && a.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && a.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && a.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && a.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), a.push(` },`)), a.push(...l$2(e, ` `)), a.push(...u$2(e, ` `, n)), a.push(...d$1(e, ` `)), a.push(...p$3(e, ` `)), a.push(...m$3(n, ` `)), e.debug && a.push(` debug: ${e.debug},`), n?.postprocessMessage ? a.push(` postprocessMessage: ${n.postprocessMessage}`) : a.push(` postprocessMessage: ({ text }) => markdownPostprocessor(text)`), a.push(` }`), a.push(`});`), a.join(`
|
|
57021
57078
|
`);
|
|
57022
57079
|
}
|
|
57023
|
-
function w(e, t) {
|
|
57024
|
-
let n = t?.hooks, r = c(e), i = r !== `plain`, a = [
|
|
57080
|
+
function w$2(e, t) {
|
|
57081
|
+
let n = t?.hooks, r = c$2(e), i = r !== `plain`, a = [
|
|
57025
57082
|
`// ChatWidget.tsx`,
|
|
57026
57083
|
`'use client'; // Required for Next.js - remove for Vite/CRA`,
|
|
57027
57084
|
``,
|
|
@@ -57035,10 +57092,10 @@ function w(e, t) {
|
|
|
57035
57092
|
` let handle: AgentWidgetInitHandle | null = null;`,
|
|
57036
57093
|
``,
|
|
57037
57094
|
` handle = initAgentWidget({`,
|
|
57038
|
-
` target: '${b(t)}',`,
|
|
57095
|
+
` target: '${b$2(t)}',`,
|
|
57039
57096
|
` config: {`
|
|
57040
57097
|
];
|
|
57041
|
-
return e.apiUrl && a.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && a.push(` clientToken: "${e.clientToken}",`), e.agentId && a.push(` agentId: "${e.agentId}",`), e.target && a.push(` target: "${e.target}",`), e.flowId && a.push(` flowId: "${e.flowId}",`), i && a.push(` parserType: "${r}",`), y(a, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && _(a, `theme`, e.theme, ` `), e.launcher && _(a, `launcher`, e.launcher, ` `), v(a, e, ` `), e.sendButton && (a.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
|
|
57098
|
+
return e.apiUrl && a.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && a.push(` clientToken: "${e.clientToken}",`), e.agentId && a.push(` agentId: "${e.agentId}",`), e.target && a.push(` target: "${e.target}",`), e.flowId && a.push(` flowId: "${e.flowId}",`), i && a.push(` parserType: "${r}",`), y$2(a, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && _$2(a, `theme`, e.theme, ` `), e.launcher && _$2(a, `launcher`, e.launcher, ` `), v$2(a, e, ` `), e.sendButton && (a.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
|
|
57042
57099
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
|
|
57043
57100
|
}), a.push(` },`)), e.voiceRecognition && (a.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
|
|
57044
57101
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && a.push(` ${e}: ${t},`);
|
|
@@ -57046,12 +57103,12 @@ function w(e, t) {
|
|
|
57046
57103
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
|
|
57047
57104
|
}), a.push(` },`)), e.features && (a.push(` features: {`), Object.entries(e.features).forEach(([e, t]) => {
|
|
57048
57105
|
a.push(` ${e}: ${t},`);
|
|
57049
|
-
}), a.push(` },`)), a.push(...f(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (a.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57106
|
+
}), a.push(` },`)), a.push(...f$2(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (a.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57050
57107
|
a.push(` "${e}",`);
|
|
57051
|
-
}), a.push(` ],`)), e.suggestionChipsConfig && (a.push(` suggestionChipsConfig: {`), e.suggestionChipsConfig.fontFamily && a.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && a.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && a.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && a.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), a.push(` },`)), a.push(...l(e, ` `)), a.push(...u(e, ` `, n)), a.push(...d(e, ` `)), a.push(...p(e, ` `)), a.push(...m(n, ` `)), e.debug && a.push(` debug: ${e.debug},`), n?.postprocessMessage ? a.push(` postprocessMessage: ${n.postprocessMessage}`) : a.push(` postprocessMessage: ({ text }) => markdownPostprocessor(text)`), a.push(` }`), a.push(` });`), a.push(``), a.push(` // Cleanup on unmount`), a.push(` return () => {`), a.push(` if (handle) {`), a.push(` handle.destroy();`), a.push(` }`), a.push(` };`), a.push(` }, []);`), a.push(``), a.push(` return null; // Widget injects itself into the DOM`), a.push(`}`), a.push(``), a.push(`// Usage in your app:`), a.push(`// import { ChatWidget } from './components/ChatWidget';`), a.push(`//`), a.push(`// export default function App() {`), a.push(`// return (`), a.push(`// <div>`), a.push(`// {/* Your app content */}`), a.push(`// <ChatWidget />`), a.push(`// </div>`), a.push(`// );`), a.push(`// }`), a.join(`
|
|
57108
|
+
}), a.push(` ],`)), e.suggestionChipsConfig && (a.push(` suggestionChipsConfig: {`), e.suggestionChipsConfig.fontFamily && a.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && a.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && a.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && a.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), a.push(` },`)), a.push(...l$2(e, ` `)), a.push(...u$2(e, ` `, n)), a.push(...d$1(e, ` `)), a.push(...p$3(e, ` `)), a.push(...m$3(n, ` `)), e.debug && a.push(` debug: ${e.debug},`), n?.postprocessMessage ? a.push(` postprocessMessage: ${n.postprocessMessage}`) : a.push(` postprocessMessage: ({ text }) => markdownPostprocessor(text)`), a.push(` }`), a.push(` });`), a.push(``), a.push(` // Cleanup on unmount`), a.push(` return () => {`), a.push(` if (handle) {`), a.push(` handle.destroy();`), a.push(` }`), a.push(` };`), a.push(` }, []);`), a.push(``), a.push(` return null; // Widget injects itself into the DOM`), a.push(`}`), a.push(``), a.push(`// Usage in your app:`), a.push(`// import { ChatWidget } from './components/ChatWidget';`), a.push(`//`), a.push(`// export default function App() {`), a.push(`// return (`), a.push(`// <div>`), a.push(`// {/* Your app content */}`), a.push(`// <ChatWidget />`), a.push(`// </div>`), a.push(`// );`), a.push(`// }`), a.join(`
|
|
57052
57109
|
`);
|
|
57053
57110
|
}
|
|
57054
|
-
function T(e, t) {
|
|
57111
|
+
function T$2(e, t) {
|
|
57055
57112
|
let n = t?.hooks, i = [
|
|
57056
57113
|
`// ChatWidgetAdvanced.tsx`,
|
|
57057
57114
|
`'use client'; // Required for Next.js - remove for Vite/CRA`,
|
|
@@ -57164,10 +57221,10 @@ function T(e, t) {
|
|
|
57164
57221
|
` };`,
|
|
57165
57222
|
``,
|
|
57166
57223
|
` handle = initAgentWidget({`,
|
|
57167
|
-
` target: '${b(t)}',`,
|
|
57224
|
+
` target: '${b$2(t)}',`,
|
|
57168
57225
|
` config: {`
|
|
57169
57226
|
];
|
|
57170
|
-
return e.apiUrl && i.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && i.push(` clientToken: "${e.clientToken}",`), e.agentId && i.push(` agentId: "${e.agentId}",`), e.target && i.push(` target: "${e.target}",`), e.flowId && i.push(` flowId: "${e.flowId}",`), y(i, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && _(i, `theme`, e.theme, ` `), e.launcher && _(i, `launcher`, e.launcher, ` `), v(i, e, ` `), e.sendButton && (i.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
|
|
57227
|
+
return e.apiUrl && i.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && i.push(` clientToken: "${e.clientToken}",`), e.agentId && i.push(` agentId: "${e.agentId}",`), e.target && i.push(` target: "${e.target}",`), e.flowId && i.push(` flowId: "${e.flowId}",`), y$2(i, e, ` `), e.theme && typeof e.theme == `object` && Object.keys(e.theme).length > 0 && _$2(i, `theme`, e.theme, ` `), e.launcher && _$2(i, `launcher`, e.launcher, ` `), v$2(i, e, ` `), e.sendButton && (i.push(` sendButton: {`), Object.entries(e.sendButton).forEach(([e, t]) => {
|
|
57171
57228
|
typeof t == `string` ? i.push(` ${e}: "${t}",`) : typeof t == `boolean` && i.push(` ${e}: ${t},`);
|
|
57172
57229
|
}), i.push(` },`)), e.voiceRecognition && (i.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
|
|
57173
57230
|
typeof t == `string` ? i.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && i.push(` ${e}: ${t},`);
|
|
@@ -57175,19 +57232,19 @@ function T(e, t) {
|
|
|
57175
57232
|
typeof t == `string` ? i.push(` ${e}: "${t}",`) : typeof t == `boolean` && i.push(` ${e}: ${t},`);
|
|
57176
57233
|
}), i.push(` },`)), e.features && (i.push(` features: {`), Object.entries(e.features).forEach(([e, t]) => {
|
|
57177
57234
|
i.push(` ${e}: ${t},`);
|
|
57178
|
-
}), i.push(` },`)), i.push(...f(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (i.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57235
|
+
}), i.push(` },`)), i.push(...f$2(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (i.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57179
57236
|
i.push(` "${e}",`);
|
|
57180
|
-
}), i.push(` ],`)), e.suggestionChipsConfig && (i.push(` suggestionChipsConfig: {`), e.suggestionChipsConfig.fontFamily && i.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && i.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && i.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && i.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), i.push(` },`)), i.push(...l(e, ` `)), i.push(...u(e, ` `, n)), i.push(...d(e, ` `)), i.push(...p(e, ` `)), n?.getHeaders && i.push(` getHeaders: ${n.getHeaders},`), n?.contextProviders && i.push(` contextProviders: ${n.contextProviders},`), e.debug && i.push(` debug: ${e.debug},`), i.push(` initialMessages: loadSavedMessages(),`), n?.streamParser ? i.push(` streamParser: ${n.streamParser},`) : (i.push(` // Flexible JSON stream parser for handling structured actions`), i.push(` streamParser: () => createFlexibleJsonStreamParser((parsed: any) => {
|
|
57237
|
+
}), i.push(` ],`)), e.suggestionChipsConfig && (i.push(` suggestionChipsConfig: {`), e.suggestionChipsConfig.fontFamily && i.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && i.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && i.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && i.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), i.push(` },`)), i.push(...l$2(e, ` `)), i.push(...u$2(e, ` `, n)), i.push(...d$1(e, ` `)), i.push(...p$3(e, ` `)), n?.getHeaders && i.push(` getHeaders: ${n.getHeaders},`), n?.contextProviders && i.push(` contextProviders: ${n.contextProviders},`), e.debug && i.push(` debug: ${e.debug},`), i.push(` initialMessages: loadSavedMessages(),`), n?.streamParser ? i.push(` streamParser: ${n.streamParser},`) : (i.push(` // Flexible JSON stream parser for handling structured actions`), i.push(` streamParser: () => createFlexibleJsonStreamParser((parsed: any) => {
|
|
57181
57238
|
if (!parsed || typeof parsed !== 'object') return null;
|
|
57182
57239
|
if (parsed.action === 'nav_then_click') return 'Navigating...';
|
|
57183
57240
|
if (parsed.action === 'message') return parsed.text || '';
|
|
57184
57241
|
if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
|
|
57185
57242
|
return parsed.text || null;
|
|
57186
|
-
}),`)), n?.actionParsers ? (i.push(` // Action parsers (custom merged with defaults)`), i.push(` actionParsers: [...(${n.actionParsers}), defaultJsonActionParser,`), i.push(` // Built-in parser for markdown-wrapped JSON`), i.push(` ${r}`), i.push(` ],`)) : (i.push(` // Action parsers to detect JSON actions in responses`), i.push(` actionParsers: [`), i.push(` defaultJsonActionParser,`), i.push(` // Parser for markdown-wrapped JSON`), i.push(` ${r}`), i.push(` ],`)), n?.actionHandlers ? (i.push(` // Action handlers (custom merged with defaults)`), i.push(` actionHandlers: [...(${n.actionHandlers}),`), i.push(` defaultActionHandlers.message,`), i.push(` defaultActionHandlers.messageAndClick,`), i.push(` // Built-in handler for nav_then_click action`), i.push(` ${a}`), i.push(` ],`)) : (i.push(` // Action handlers for navigation and other actions`), i.push(` actionHandlers: [`), i.push(` defaultActionHandlers.message,`), i.push(` defaultActionHandlers.messageAndClick,`), i.push(` // Handler for nav_then_click action`), i.push(` ${a}`), i.push(` ],`)), n?.postprocessMessage ? i.push(` postprocessMessage: ${n.postprocessMessage},`) : i.push(` postprocessMessage: ({ text }) => markdownPostprocessor(text),`), n?.requestMiddleware ? (i.push(` // Request middleware (custom merged with DOM context)`), i.push(` requestMiddleware: ({ payload, config }) => {`), i.push(` const customResult = (${n.requestMiddleware})({ payload, config });`), i.push(` const merged = customResult || payload;`), i.push(` return {`), i.push(` ...merged,`), i.push(` metadata: { ...merged.metadata, ...collectDOMContext() }`), i.push(` };`), i.push(` }`)) : (i.push(` requestMiddleware: ({ payload }) => {`), i.push(` return {`), i.push(` ...payload,`), i.push(` metadata: collectDOMContext()`), i.push(` };`), i.push(` }`)), i.push(` }`), i.push(` });`), i.push(``), i.push(` // Save state on message events`), i.push(` const handleMessage = () => {`), i.push(` const session = handle?.getSession?.();`), i.push(` if (session) {`), i.push(` localStorage.setItem(STORAGE_KEY, JSON.stringify({`), i.push(` messages: session.messages,`), i.push(` timestamp: new Date().toISOString()`), i.push(` }));`), i.push(` }`), i.push(` };`), i.push(``), i.push(` // Clear state on clear chat`), i.push(` const handleClearChat = () => {`), i.push(` localStorage.removeItem(STORAGE_KEY);`), i.push(` localStorage.removeItem(PROCESSED_ACTIONS_KEY);`), i.push(` };`), i.push(``), i.push(` window.addEventListener('persona:message', handleMessage);`), i.push(` window.addEventListener('persona:clear-chat', handleClearChat);`), i.push(``), i.push(` // Cleanup on unmount`), i.push(` return () => {`), i.push(` window.removeEventListener('persona:message', handleMessage);`), i.push(` window.removeEventListener('persona:clear-chat', handleClearChat);`), i.push(` if (handle) {`), i.push(` handle.destroy();`), i.push(` }`), i.push(` };`), i.push(` }, []);`), i.push(``), i.push(` return null; // Widget injects itself into the DOM`), i.push(`}`), i.push(``), i.push(`// Usage: Collects DOM context for AI-powered navigation`), i.push(`// Features:`), i.push(`// - Extracts page elements (products, buttons, links)`), i.push(`// - Persists chat history across page loads`), i.push(`// - Handles navigation actions (nav_then_click)`), i.push(`// - Processes structured JSON actions from AI`), i.push(`//`), i.push(`// Example usage in Next.js:`), i.push(`// import { ChatWidgetAdvanced } from './components/ChatWidgetAdvanced';`), i.push(`//`), i.push(`// export default function RootLayout({ children }) {`), i.push(`// return (`), i.push(`// <html lang="en">`), i.push(`// <body>`), i.push(`// {children}`), i.push(`// <ChatWidgetAdvanced />`), i.push(`// </body>`), i.push(`// </html>`), i.push(`// );`), i.push(`// }`), i.join(`
|
|
57243
|
+
}),`)), n?.actionParsers ? (i.push(` // Action parsers (custom merged with defaults)`), i.push(` actionParsers: [...(${n.actionParsers}), defaultJsonActionParser,`), i.push(` // Built-in parser for markdown-wrapped JSON`), i.push(` ${r$1}`), i.push(` ],`)) : (i.push(` // Action parsers to detect JSON actions in responses`), i.push(` actionParsers: [`), i.push(` defaultJsonActionParser,`), i.push(` // Parser for markdown-wrapped JSON`), i.push(` ${r$1}`), i.push(` ],`)), n?.actionHandlers ? (i.push(` // Action handlers (custom merged with defaults)`), i.push(` actionHandlers: [...(${n.actionHandlers}),`), i.push(` defaultActionHandlers.message,`), i.push(` defaultActionHandlers.messageAndClick,`), i.push(` // Built-in handler for nav_then_click action`), i.push(` ${a}`), i.push(` ],`)) : (i.push(` // Action handlers for navigation and other actions`), i.push(` actionHandlers: [`), i.push(` defaultActionHandlers.message,`), i.push(` defaultActionHandlers.messageAndClick,`), i.push(` // Handler for nav_then_click action`), i.push(` ${a}`), i.push(` ],`)), n?.postprocessMessage ? i.push(` postprocessMessage: ${n.postprocessMessage},`) : i.push(` postprocessMessage: ({ text }) => markdownPostprocessor(text),`), n?.requestMiddleware ? (i.push(` // Request middleware (custom merged with DOM context)`), i.push(` requestMiddleware: ({ payload, config }) => {`), i.push(` const customResult = (${n.requestMiddleware})({ payload, config });`), i.push(` const merged = customResult || payload;`), i.push(` return {`), i.push(` ...merged,`), i.push(` metadata: { ...merged.metadata, ...collectDOMContext() }`), i.push(` };`), i.push(` }`)) : (i.push(` requestMiddleware: ({ payload }) => {`), i.push(` return {`), i.push(` ...payload,`), i.push(` metadata: collectDOMContext()`), i.push(` };`), i.push(` }`)), i.push(` }`), i.push(` });`), i.push(``), i.push(` // Save state on message events`), i.push(` const handleMessage = () => {`), i.push(` const session = handle?.getSession?.();`), i.push(` if (session) {`), i.push(` localStorage.setItem(STORAGE_KEY, JSON.stringify({`), i.push(` messages: session.messages,`), i.push(` timestamp: new Date().toISOString()`), i.push(` }));`), i.push(` }`), i.push(` };`), i.push(``), i.push(` // Clear state on clear chat`), i.push(` const handleClearChat = () => {`), i.push(` localStorage.removeItem(STORAGE_KEY);`), i.push(` localStorage.removeItem(PROCESSED_ACTIONS_KEY);`), i.push(` };`), i.push(``), i.push(` window.addEventListener('persona:message', handleMessage);`), i.push(` window.addEventListener('persona:clear-chat', handleClearChat);`), i.push(``), i.push(` // Cleanup on unmount`), i.push(` return () => {`), i.push(` window.removeEventListener('persona:message', handleMessage);`), i.push(` window.removeEventListener('persona:clear-chat', handleClearChat);`), i.push(` if (handle) {`), i.push(` handle.destroy();`), i.push(` }`), i.push(` };`), i.push(` }, []);`), i.push(``), i.push(` return null; // Widget injects itself into the DOM`), i.push(`}`), i.push(``), i.push(`// Usage: Collects DOM context for AI-powered navigation`), i.push(`// Features:`), i.push(`// - Extracts page elements (products, buttons, links)`), i.push(`// - Persists chat history across page loads`), i.push(`// - Handles navigation actions (nav_then_click)`), i.push(`// - Processes structured JSON actions from AI`), i.push(`//`), i.push(`// Example usage in Next.js:`), i.push(`// import { ChatWidgetAdvanced } from './components/ChatWidgetAdvanced';`), i.push(`//`), i.push(`// export default function RootLayout({ children }) {`), i.push(`// return (`), i.push(`// <html lang="en">`), i.push(`// <body>`), i.push(`// {children}`), i.push(`// <ChatWidgetAdvanced />`), i.push(`// </body>`), i.push(`// </html>`), i.push(`// );`), i.push(`// }`), i.join(`
|
|
57187
57244
|
`);
|
|
57188
57245
|
}
|
|
57189
|
-
function E(e) {
|
|
57190
|
-
let t = c(e), n = t !== `plain`, r = {};
|
|
57246
|
+
function E$2(e) {
|
|
57247
|
+
let t = c$2(e), n = t !== `plain`, r = {};
|
|
57191
57248
|
if (e.apiUrl && (r.apiUrl = e.apiUrl), e.clientToken && (r.clientToken = e.clientToken), e.agentId && (r.agentId = e.agentId), e.target && (r.target = e.target), e.flowId && (r.flowId = e.flowId), n && (r.parserType = t), e.future?.v5Defaults !== void 0 && (r.future = { v5Defaults: e.future.v5Defaults === !0 }), e.theme && (r.theme = e.theme), e.brand && (r.brand = e.brand), e.darkTheme && (r.darkTheme = e.darkTheme), e.colorScheme !== void 0 && (r.colorScheme = e.colorScheme), e.launcher && (r.launcher = e.launcher), e.copy && (r.copy = e.copy), e.welcome !== void 0 && (r.welcome = e.welcome), e.approval !== void 0 && (r.approval = e.approval), e.sendButton && (r.sendButton = e.sendButton), e.voiceRecognition && (r.voiceRecognition = e.voiceRecognition), e.statusIndicator && (r.statusIndicator = e.statusIndicator), e.features && (r.features = e.features), e.suggestions && (r.suggestions = e.suggestions), e.suggestionChips?.length > 0 && (r.suggestionChips = e.suggestionChips), e.suggestionChipsConfig && (r.suggestionChipsConfig = e.suggestionChipsConfig), e.debug && (r.debug = e.debug), e.toolCall) {
|
|
57192
57249
|
let t = {};
|
|
57193
57250
|
Object.entries(e.toolCall).forEach(([e, n]) => {
|
|
@@ -57230,16 +57287,16 @@ function E(e) {
|
|
|
57230
57287
|
}
|
|
57231
57288
|
return r;
|
|
57232
57289
|
}
|
|
57233
|
-
function D(t, n) {
|
|
57234
|
-
let r = E(t), i = n?.windowKey || n?.target ? {
|
|
57290
|
+
function D$2(t, n) {
|
|
57291
|
+
let r = E$2(t), i = n?.windowKey || n?.target ? {
|
|
57235
57292
|
config: r,
|
|
57236
57293
|
...n?.windowKey ? { windowKey: n.windowKey } : {},
|
|
57237
57294
|
...n?.target ? { target: n.target } : {}
|
|
57238
57295
|
} : r, a = JSON.stringify(i).replace(/&/g, `&`).replace(/</g, `<`).replace(/>/g, `>`).replace(/'/g, `'`);
|
|
57239
|
-
return `<script src="${e(n)}/install.global.js" data-config='${a}'><\/script>`;
|
|
57296
|
+
return `<script src="${e$3(n)}/install.global.js" data-config='${a}'><\/script>`;
|
|
57240
57297
|
}
|
|
57241
|
-
function O(t, n) {
|
|
57242
|
-
let r = n?.hooks, i = c(t), a = i !== `plain`, o = e(n), s = [
|
|
57298
|
+
function O$2(t, n) {
|
|
57299
|
+
let r = n?.hooks, i = c$2(t), a = i !== `plain`, o = e$3(n), s = [
|
|
57243
57300
|
`<!-- Load CSS -->`,
|
|
57244
57301
|
`<link rel="stylesheet" href="${o}/widget.css" />`,
|
|
57245
57302
|
``,
|
|
@@ -57249,11 +57306,11 @@ function O(t, n) {
|
|
|
57249
57306
|
`<!-- Initialize widget -->`,
|
|
57250
57307
|
`<script>`,
|
|
57251
57308
|
` var handle = window.AgentWidget.initAgentWidget({`,
|
|
57252
|
-
` target: '${b(n)}',`,
|
|
57309
|
+
` target: '${b$2(n)}',`,
|
|
57253
57310
|
...n?.windowKey ? [` windowKey: '${n.windowKey}',`] : [],
|
|
57254
57311
|
` config: {`
|
|
57255
57312
|
];
|
|
57256
|
-
return t.apiUrl && s.push(` apiUrl: "${t.apiUrl}",`), t.clientToken && s.push(` clientToken: "${t.clientToken}",`), t.agentId && s.push(` agentId: "${t.agentId}",`), t.target && s.push(` target: "${t.target}",`), t.flowId && s.push(` flowId: "${t.flowId}",`), a && s.push(` parserType: "${i}",`), y(s, t, ` `), t.theme && typeof t.theme == `object` && Object.keys(t.theme).length > 0 && _(s, `theme`, t.theme, ` `), t.launcher && _(s, `launcher`, t.launcher, ` `), v(s, t, ` `), t.sendButton && (s.push(` sendButton: {`), Object.entries(t.sendButton).forEach(([e, t]) => {
|
|
57313
|
+
return t.apiUrl && s.push(` apiUrl: "${t.apiUrl}",`), t.clientToken && s.push(` clientToken: "${t.clientToken}",`), t.agentId && s.push(` agentId: "${t.agentId}",`), t.target && s.push(` target: "${t.target}",`), t.flowId && s.push(` flowId: "${t.flowId}",`), a && s.push(` parserType: "${i}",`), y$2(s, t, ` `), t.theme && typeof t.theme == `object` && Object.keys(t.theme).length > 0 && _$2(s, `theme`, t.theme, ` `), t.launcher && _$2(s, `launcher`, t.launcher, ` `), v$2(s, t, ` `), t.sendButton && (s.push(` sendButton: {`), Object.entries(t.sendButton).forEach(([e, t]) => {
|
|
57257
57314
|
typeof t == `string` ? s.push(` ${e}: "${t}",`) : typeof t == `boolean` && s.push(` ${e}: ${t},`);
|
|
57258
57315
|
}), s.push(` },`)), t.voiceRecognition && (s.push(` voiceRecognition: {`), Object.entries(t.voiceRecognition).forEach(([e, t]) => {
|
|
57259
57316
|
typeof t == `string` ? s.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && s.push(` ${e}: ${t},`);
|
|
@@ -57261,24 +57318,24 @@ function O(t, n) {
|
|
|
57261
57318
|
typeof t == `string` ? s.push(` ${e}: "${t}",`) : typeof t == `boolean` && s.push(` ${e}: ${t},`);
|
|
57262
57319
|
}), s.push(` },`)), t.features && (s.push(` features: {`), Object.entries(t.features).forEach(([e, t]) => {
|
|
57263
57320
|
s.push(` ${e}: ${t},`);
|
|
57264
|
-
}), s.push(` },`)), s.push(...f(t, ` `)), t.suggestionChips && t.suggestionChips.length > 0 && (s.push(` suggestionChips: [`), t.suggestionChips.forEach((e) => {
|
|
57321
|
+
}), s.push(` },`)), s.push(...f$2(t, ` `)), t.suggestionChips && t.suggestionChips.length > 0 && (s.push(` suggestionChips: [`), t.suggestionChips.forEach((e) => {
|
|
57265
57322
|
s.push(` "${e}",`);
|
|
57266
|
-
}), s.push(` ],`)), t.suggestionChipsConfig && (s.push(` suggestionChipsConfig: {`), t.suggestionChipsConfig.fontFamily && s.push(` fontFamily: "${t.suggestionChipsConfig.fontFamily}",`), t.suggestionChipsConfig.fontWeight && s.push(` fontWeight: "${t.suggestionChipsConfig.fontWeight}",`), t.suggestionChipsConfig.paddingX && s.push(` paddingX: "${t.suggestionChipsConfig.paddingX}",`), t.suggestionChipsConfig.paddingY && s.push(` paddingY: "${t.suggestionChipsConfig.paddingY}",`), s.push(` },`)), s.push(...l(t, ` `)), s.push(...u(t, ` `, r)), s.push(...d(t, ` `)), s.push(...p(t, ` `)), s.push(...m(r, ` `)), t.debug && s.push(` debug: ${t.debug},`), r?.postprocessMessage ? s.push(` postprocessMessage: ${r.postprocessMessage}`) : s.push(` postprocessMessage: ({ text }) => window.AgentWidget.markdownPostprocessor(text)`), s.push(` }`), s.push(` });`), s.push(`<\/script>`), s.join(`
|
|
57323
|
+
}), s.push(` ],`)), t.suggestionChipsConfig && (s.push(` suggestionChipsConfig: {`), t.suggestionChipsConfig.fontFamily && s.push(` fontFamily: "${t.suggestionChipsConfig.fontFamily}",`), t.suggestionChipsConfig.fontWeight && s.push(` fontWeight: "${t.suggestionChipsConfig.fontWeight}",`), t.suggestionChipsConfig.paddingX && s.push(` paddingX: "${t.suggestionChipsConfig.paddingX}",`), t.suggestionChipsConfig.paddingY && s.push(` paddingY: "${t.suggestionChipsConfig.paddingY}",`), s.push(` },`)), s.push(...l$2(t, ` `)), s.push(...u$2(t, ` `, r)), s.push(...d$1(t, ` `)), s.push(...p$3(t, ` `)), s.push(...m$3(r, ` `)), t.debug && s.push(` debug: ${t.debug},`), r?.postprocessMessage ? s.push(` postprocessMessage: ${r.postprocessMessage}`) : s.push(` postprocessMessage: ({ text }) => window.AgentWidget.markdownPostprocessor(text)`), s.push(` }`), s.push(` });`), s.push(`<\/script>`), s.join(`
|
|
57267
57324
|
`);
|
|
57268
57325
|
}
|
|
57269
|
-
function k(t, n) {
|
|
57326
|
+
function k$2(t, n) {
|
|
57270
57327
|
let r = n?.hooks, a = [
|
|
57271
57328
|
`<script>`,
|
|
57272
57329
|
`(function() {`,
|
|
57273
57330
|
` 'use strict';`,
|
|
57274
57331
|
``,
|
|
57275
57332
|
` // Configuration`,
|
|
57276
|
-
` var CONFIG = ${h(E(t), 2).split(`
|
|
57333
|
+
` var CONFIG = ${h$3(E$2(t), 2).split(`
|
|
57277
57334
|
`).map((e, t) => t === 0 ? e : ` ` + e).join(`
|
|
57278
57335
|
`)};`,
|
|
57279
57336
|
``,
|
|
57280
57337
|
` // Constants`,
|
|
57281
|
-
` var CDN_BASE = '${e(n)}';`,
|
|
57338
|
+
` var CDN_BASE = '${e$3(n)}';`,
|
|
57282
57339
|
` var STORAGE_KEY = 'chat-widget-state';`,
|
|
57283
57340
|
` var PROCESSED_ACTIONS_KEY = 'chat-widget-processed-actions';`,
|
|
57284
57341
|
``,
|
|
@@ -57366,7 +57423,7 @@ function k(t, n) {
|
|
|
57366
57423
|
if (parsed.action === 'message') return parsed.text || '';
|
|
57367
57424
|
if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
|
|
57368
57425
|
return parsed.text || null;
|
|
57369
|
-
});`), a.push(` };`)), a.push(``), r?.actionParsers ? (a.push(` // Action parsers (custom merged with defaults)`), a.push(` var customParsers = ${r.actionParsers};`), a.push(` widgetConfig.actionParsers = customParsers.concat([`), a.push(` agentWidget.defaultJsonActionParser,`), a.push(` ${i}`), a.push(` ]);`)) : (a.push(` // Action parsers to detect JSON actions in responses`), a.push(` widgetConfig.actionParsers = [`), a.push(` agentWidget.defaultJsonActionParser,`), a.push(` ${i}`), a.push(` ];`)), a.push(``), r?.actionHandlers ? (a.push(` // Action handlers (custom merged with defaults)`), a.push(` var customHandlers = ${r.actionHandlers};`), a.push(` widgetConfig.actionHandlers = customHandlers.concat([`), a.push(` agentWidget.defaultActionHandlers.message,`), a.push(` agentWidget.defaultActionHandlers.messageAndClick,`), a.push(` ${o}`), a.push(` ]);`)) : (a.push(` // Action handlers for navigation and other actions`), a.push(` widgetConfig.actionHandlers = [`), a.push(` agentWidget.defaultActionHandlers.message,`), a.push(` agentWidget.defaultActionHandlers.messageAndClick,`), a.push(` ${o}`), a.push(` ];`)), a.push(``), r?.requestMiddleware ? (a.push(` // Request middleware (custom merged with DOM context)`), a.push(` widgetConfig.requestMiddleware = function(ctx) {`), a.push(` var customResult = (${r.requestMiddleware})(ctx);`), a.push(` var merged = customResult || ctx.payload;`), a.push(` return Object.assign({}, merged, { metadata: Object.assign({}, merged.metadata, domContextProvider()) });`), a.push(` };`)) : (a.push(` // Send DOM context with each request`), a.push(` widgetConfig.requestMiddleware = function(ctx) {`), a.push(` return Object.assign({}, ctx.payload, { metadata: domContextProvider() });`), a.push(` };`)), a.push(``), r?.postprocessMessage ? a.push(` widgetConfig.postprocessMessage = ${r.postprocessMessage};`) : (a.push(` // Markdown postprocessor`), a.push(` widgetConfig.postprocessMessage = function(ctx) {`), a.push(` return agentWidget.markdownPostprocessor(ctx.text);`), a.push(` };`)), a.push(``), (r?.onFeedback || r?.onCopy) && (a.push(` // Message action callbacks`), a.push(` widgetConfig.messageActions = widgetConfig.messageActions || {};`), r?.onFeedback && a.push(` widgetConfig.messageActions.onFeedback = ${r.onFeedback};`), r?.onCopy && a.push(` widgetConfig.messageActions.onCopy = ${r.onCopy};`), a.push(``)), a.push(` return widgetConfig;`, ` };`, ``, ` // Initialize widget`, ` var init = function() {`, ` var agentWidget = window.AgentWidget;`, ` if (!agentWidget) {`, ` console.error('AgentWidget not loaded');`, ` return;`, ` }`, ``, ` var widgetConfig = createWidgetConfig(agentWidget);`, ``, ` // Load saved state`, ` var savedState = localStorage.getItem(STORAGE_KEY);`, ` if (savedState) {`, ` try {`, ` var parsed = JSON.parse(savedState);`, ` widgetConfig.initialMessages = parsed.messages || [];`, ` } catch (e) {`, ` console.error('Failed to load saved state:', e);`, ` }`, ` }`, ``, ` // Initialize widget`, ` var handle = agentWidget.initAgentWidget({`, ` target: '${b(n)}',`, ` useShadowDom: false,`, ...n?.windowKey ? [` windowKey: '${n.windowKey}',`] : [], ` config: widgetConfig`, ` });`, ``, ` // Save state on message events`, ` window.addEventListener('persona:message', function() {`, ` var session = handle.getSession ? handle.getSession() : null;`, ` if (session) {`, ` localStorage.setItem(STORAGE_KEY, JSON.stringify({`, ` messages: session.messages,`, ` timestamp: new Date().toISOString()`, ` }));`, ` }`, ` });`, ``, ` // Clear state on clear chat`, ` window.addEventListener('persona:clear-chat', function() {`, ` localStorage.removeItem(STORAGE_KEY);`, ` localStorage.removeItem(PROCESSED_ACTIONS_KEY);`, ` });`, ` };`, ``, ` // Wait for framework hydration to complete (Next.js, Nuxt, etc.)`, ` // This prevents the framework from removing dynamically added CSS during reconciliation`, ` var waitForHydration = function(callback) {`, ` var executed = false;`, ` `, ` var execute = function() {`, ` if (executed) return;`, ` executed = true;`, ` callback();`, ` };`, ``, ` var afterDom = function() {`, ` // Strategy 1: Use requestIdleCallback if available (best for detecting idle after hydration)`, ` if (typeof requestIdleCallback !== 'undefined') {`, ` requestIdleCallback(function() {`, ` // Double requestAnimationFrame ensures at least one full paint cycle completed`, ` requestAnimationFrame(function() {`, ` requestAnimationFrame(execute);`, ` });`, ` }, { timeout: 3000 }); // Max wait 3 seconds, then proceed anyway`, ` } else {`, ` // Strategy 2: Fallback for Safari (no requestIdleCallback)`, ` // 300ms is typically enough for hydration on most pages`, ` setTimeout(execute, 300);`, ` }`, ` };`, ``, ` if (document.readyState === 'loading') {`, ` document.addEventListener('DOMContentLoaded', afterDom);`, ` } else {`, ` // DOM already ready, but still wait for potential hydration`, ` afterDom();`, ` }`, ` };`, ``, ` // Boot sequence: wait for hydration, then load CSS and JS, then initialize`, ` // This prevents Next.js/Nuxt/etc. from removing dynamically added CSS during reconciliation`, ` waitForHydration(function() {`, ` loadCSS();`, ` loadJS(function() {`, ` init();`, ` });`, ` });`, `})();`, `<\/script>`), a.join(`
|
|
57426
|
+
});`), a.push(` };`)), a.push(``), r?.actionParsers ? (a.push(` // Action parsers (custom merged with defaults)`), a.push(` var customParsers = ${r.actionParsers};`), a.push(` widgetConfig.actionParsers = customParsers.concat([`), a.push(` agentWidget.defaultJsonActionParser,`), a.push(` ${i$1}`), a.push(` ]);`)) : (a.push(` // Action parsers to detect JSON actions in responses`), a.push(` widgetConfig.actionParsers = [`), a.push(` agentWidget.defaultJsonActionParser,`), a.push(` ${i$1}`), a.push(` ];`)), a.push(``), r?.actionHandlers ? (a.push(` // Action handlers (custom merged with defaults)`), a.push(` var customHandlers = ${r.actionHandlers};`), a.push(` widgetConfig.actionHandlers = customHandlers.concat([`), a.push(` agentWidget.defaultActionHandlers.message,`), a.push(` agentWidget.defaultActionHandlers.messageAndClick,`), a.push(` ${o$2}`), a.push(` ]);`)) : (a.push(` // Action handlers for navigation and other actions`), a.push(` widgetConfig.actionHandlers = [`), a.push(` agentWidget.defaultActionHandlers.message,`), a.push(` agentWidget.defaultActionHandlers.messageAndClick,`), a.push(` ${o$2}`), a.push(` ];`)), a.push(``), r?.requestMiddleware ? (a.push(` // Request middleware (custom merged with DOM context)`), a.push(` widgetConfig.requestMiddleware = function(ctx) {`), a.push(` var customResult = (${r.requestMiddleware})(ctx);`), a.push(` var merged = customResult || ctx.payload;`), a.push(` return Object.assign({}, merged, { metadata: Object.assign({}, merged.metadata, domContextProvider()) });`), a.push(` };`)) : (a.push(` // Send DOM context with each request`), a.push(` widgetConfig.requestMiddleware = function(ctx) {`), a.push(` return Object.assign({}, ctx.payload, { metadata: domContextProvider() });`), a.push(` };`)), a.push(``), r?.postprocessMessage ? a.push(` widgetConfig.postprocessMessage = ${r.postprocessMessage};`) : (a.push(` // Markdown postprocessor`), a.push(` widgetConfig.postprocessMessage = function(ctx) {`), a.push(` return agentWidget.markdownPostprocessor(ctx.text);`), a.push(` };`)), a.push(``), (r?.onFeedback || r?.onCopy) && (a.push(` // Message action callbacks`), a.push(` widgetConfig.messageActions = widgetConfig.messageActions || {};`), r?.onFeedback && a.push(` widgetConfig.messageActions.onFeedback = ${r.onFeedback};`), r?.onCopy && a.push(` widgetConfig.messageActions.onCopy = ${r.onCopy};`), a.push(``)), a.push(` return widgetConfig;`, ` };`, ``, ` // Initialize widget`, ` var init = function() {`, ` var agentWidget = window.AgentWidget;`, ` if (!agentWidget) {`, ` console.error('AgentWidget not loaded');`, ` return;`, ` }`, ``, ` var widgetConfig = createWidgetConfig(agentWidget);`, ``, ` // Load saved state`, ` var savedState = localStorage.getItem(STORAGE_KEY);`, ` if (savedState) {`, ` try {`, ` var parsed = JSON.parse(savedState);`, ` widgetConfig.initialMessages = parsed.messages || [];`, ` } catch (e) {`, ` console.error('Failed to load saved state:', e);`, ` }`, ` }`, ``, ` // Initialize widget`, ` var handle = agentWidget.initAgentWidget({`, ` target: '${b$2(n)}',`, ` useShadowDom: false,`, ...n?.windowKey ? [` windowKey: '${n.windowKey}',`] : [], ` config: widgetConfig`, ` });`, ``, ` // Save state on message events`, ` window.addEventListener('persona:message', function() {`, ` var session = handle.getSession ? handle.getSession() : null;`, ` if (session) {`, ` localStorage.setItem(STORAGE_KEY, JSON.stringify({`, ` messages: session.messages,`, ` timestamp: new Date().toISOString()`, ` }));`, ` }`, ` });`, ``, ` // Clear state on clear chat`, ` window.addEventListener('persona:clear-chat', function() {`, ` localStorage.removeItem(STORAGE_KEY);`, ` localStorage.removeItem(PROCESSED_ACTIONS_KEY);`, ` });`, ` };`, ``, ` // Wait for framework hydration to complete (Next.js, Nuxt, etc.)`, ` // This prevents the framework from removing dynamically added CSS during reconciliation`, ` var waitForHydration = function(callback) {`, ` var executed = false;`, ` `, ` var execute = function() {`, ` if (executed) return;`, ` executed = true;`, ` callback();`, ` };`, ``, ` var afterDom = function() {`, ` // Strategy 1: Use requestIdleCallback if available (best for detecting idle after hydration)`, ` if (typeof requestIdleCallback !== 'undefined') {`, ` requestIdleCallback(function() {`, ` // Double requestAnimationFrame ensures at least one full paint cycle completed`, ` requestAnimationFrame(function() {`, ` requestAnimationFrame(execute);`, ` });`, ` }, { timeout: 3000 }); // Max wait 3 seconds, then proceed anyway`, ` } else {`, ` // Strategy 2: Fallback for Safari (no requestIdleCallback)`, ` // 300ms is typically enough for hydration on most pages`, ` setTimeout(execute, 300);`, ` }`, ` };`, ``, ` if (document.readyState === 'loading') {`, ` document.addEventListener('DOMContentLoaded', afterDom);`, ` } else {`, ` // DOM already ready, but still wait for potential hydration`, ` afterDom();`, ` }`, ` };`, ``, ` // Boot sequence: wait for hydration, then load CSS and JS, then initialize`, ` // This prevents Next.js/Nuxt/etc. from removing dynamically added CSS during reconciliation`, ` waitForHydration(function() {`, ` loadCSS();`, ` loadJS(function() {`, ` init();`, ` });`, ` });`, `})();`, `<\/script>`), a.join(`
|
|
57370
57427
|
`);
|
|
57371
57428
|
}
|
|
57372
57429
|
// src/lib/persona-snippets.ts
|
|
@@ -57407,7 +57464,7 @@ function buildWidgetConfig(input) {
|
|
|
57407
57464
|
function generatePersonaInitSnippet(input, personaFormat) {
|
|
57408
57465
|
const widgetConfig = buildWidgetConfig(input);
|
|
57409
57466
|
const target = input.targetSelector?.trim();
|
|
57410
|
-
return x(widgetConfig, personaFormat, target ? { target } : void 0);
|
|
57467
|
+
return x$2(widgetConfig, personaFormat, target ? { target } : void 0);
|
|
57411
57468
|
}
|
|
57412
57469
|
/**
|
|
57413
57470
|
* Return the version-pinned Persona CDN installer URL from the same generator
|
|
@@ -57415,7 +57472,7 @@ function generatePersonaInitSnippet(input, personaFormat) {
|
|
|
57415
57472
|
* a second manually-maintained Persona version string in the CLI.
|
|
57416
57473
|
*/
|
|
57417
57474
|
function getPersonaInstallerScriptUrl() {
|
|
57418
|
-
return x({
|
|
57475
|
+
return x$2({
|
|
57419
57476
|
apiUrl: "https://api.runtype.com",
|
|
57420
57477
|
clientToken: "ct_test_demo_00000000000000000000000000000000",
|
|
57421
57478
|
parserType: "json"
|
|
@@ -62503,12 +62560,12 @@ async function connectMcpClient(apiKey, target, options = {}) {
|
|
|
62503
62560
|
};
|
|
62504
62561
|
}
|
|
62505
62562
|
/** Collect every tools/list page while treating cursors as opaque values. */
|
|
62506
|
-
async function listAllMcpTools(client) {
|
|
62563
|
+
async function listAllMcpTools(client, options) {
|
|
62507
62564
|
const tools = [];
|
|
62508
62565
|
const seenCursors = /* @__PURE__ */ new Set();
|
|
62509
62566
|
let cursor;
|
|
62510
62567
|
do {
|
|
62511
|
-
const page = await client.listTools(cursor === void 0 ? void 0 : { cursor });
|
|
62568
|
+
const page = await client.listTools(cursor === void 0 ? void 0 : { cursor }, options);
|
|
62512
62569
|
tools.push(...page.tools);
|
|
62513
62570
|
const nextCursor = page.nextCursor;
|
|
62514
62571
|
if (nextCursor !== void 0) {
|
|
@@ -62519,98 +62576,1269 @@ async function listAllMcpTools(client) {
|
|
|
62519
62576
|
} while (cursor !== void 0);
|
|
62520
62577
|
return tools;
|
|
62521
62578
|
}
|
|
62522
|
-
//
|
|
62523
|
-
|
|
62524
|
-
|
|
62525
|
-
|
|
62526
|
-
|
|
62527
|
-
|
|
62528
|
-
|
|
62579
|
+
// ../mcp-cli/dist/chunk-Cx5MQp1B.mjs
|
|
62580
|
+
const e$2 = {
|
|
62581
|
+
Success: 0,
|
|
62582
|
+
ToolError: 1,
|
|
62583
|
+
Usage: 2,
|
|
62584
|
+
Auth: 3,
|
|
62585
|
+
Transport: 4,
|
|
62586
|
+
InputRequired: 5,
|
|
62587
|
+
WaitTimeout: 6,
|
|
62588
|
+
Interrupted: 130
|
|
62589
|
+
};
|
|
62590
|
+
const t$2 = {
|
|
62591
|
+
usage: e$2.Usage,
|
|
62592
|
+
unknown_command: e$2.Usage,
|
|
62593
|
+
unknown_flag: e$2.Usage,
|
|
62594
|
+
invalid_value: e$2.Usage,
|
|
62595
|
+
missing_argument: e$2.Usage,
|
|
62596
|
+
confirmation_required: e$2.Usage,
|
|
62597
|
+
config: e$2.Usage,
|
|
62598
|
+
credential_conflict: e$2.Usage,
|
|
62599
|
+
tool_error: e$2.ToolError,
|
|
62600
|
+
auth_required: e$2.Auth,
|
|
62601
|
+
auth_failed: e$2.Auth,
|
|
62602
|
+
transport: e$2.Transport,
|
|
62603
|
+
timeout: e$2.Transport,
|
|
62604
|
+
protocol: e$2.Transport,
|
|
62605
|
+
input_required: e$2.InputRequired,
|
|
62606
|
+
input_rejected: e$2.Usage,
|
|
62607
|
+
wait_timeout: e$2.WaitTimeout,
|
|
62608
|
+
tasks_unsupported: e$2.Usage,
|
|
62609
|
+
task_cancelled: e$2.ToolError,
|
|
62610
|
+
interrupted: e$2.Interrupted,
|
|
62611
|
+
plugin_error: e$2.ToolError,
|
|
62612
|
+
internal: e$2.ToolError
|
|
62613
|
+
};
|
|
62614
|
+
var n$2 = class extends Error {
|
|
62615
|
+
code;
|
|
62616
|
+
hint;
|
|
62617
|
+
details;
|
|
62618
|
+
exitCode;
|
|
62619
|
+
constructor(e, n, r, i) {
|
|
62620
|
+
super(n), this.code = e, this.hint = r, this.details = i, this.name = `CliError`, this.exitCode = t$2[e];
|
|
62621
|
+
}
|
|
62622
|
+
toEnvelope() {
|
|
62623
|
+
return { error: {
|
|
62624
|
+
...this.details,
|
|
62625
|
+
code: this.code,
|
|
62626
|
+
message: this.message,
|
|
62627
|
+
...this.hint ? { hint: this.hint } : {},
|
|
62628
|
+
exitCode: this.exitCode
|
|
62629
|
+
} };
|
|
62630
|
+
}
|
|
62631
|
+
};
|
|
62632
|
+
// ../mcp-cli/dist/chunk-CQq_8FZL.mjs
|
|
62633
|
+
function e$1(e) {
|
|
62634
|
+
return e.replace(/([a-z0-9])([A-Z])/g, `$1-$2`).replace(/([A-Z]+)([A-Z][a-z])/g, `$1-$2`).replace(/[^A-Za-z0-9]+/g, `-`).replace(/^-+|-+$/g, ``).toLowerCase();
|
|
62635
|
+
}
|
|
62636
|
+
function t$1(e, t) {
|
|
62637
|
+
if (e === t) return 0;
|
|
62638
|
+
let n = Array.from({ length: t.length + 1 }, (e, t) => t);
|
|
62639
|
+
for (let r = 1; r <= e.length; r += 1) {
|
|
62640
|
+
let i = n[0];
|
|
62641
|
+
n[0] = r;
|
|
62642
|
+
for (let a = 1; a <= t.length; a += 1) {
|
|
62643
|
+
let o = n[a];
|
|
62644
|
+
n[a] = Math.min(n[a] + 1, n[a - 1] + 1, i + (e[r - 1] === t[a - 1] ? 0 : 1)), i = o;
|
|
62645
|
+
}
|
|
62646
|
+
}
|
|
62647
|
+
return n[t.length];
|
|
62648
|
+
}
|
|
62649
|
+
function n$1(e, n, r = 3) {
|
|
62650
|
+
let i = e.toLowerCase(), a = Math.max(2, Math.floor(i.length / 3)), o = [];
|
|
62651
|
+
for (let e of new Set(n)) {
|
|
62652
|
+
let n = e.toLowerCase(), r = n.startsWith(i) || i.startsWith(n) ? 1 : t$1(i, n);
|
|
62653
|
+
r <= a && o.push([e, r]);
|
|
62654
|
+
}
|
|
62655
|
+
return o.sort((e, t) => e[1] - t[1] || e[0].localeCompare(t[0])).slice(0, r).map(([e]) => e);
|
|
62656
|
+
}
|
|
62657
|
+
// ../mcp-cli/dist/chunk-B4F-cgd0.mjs
|
|
62658
|
+
function e(e, t) {
|
|
62659
|
+
switch (e) {
|
|
62660
|
+
case void 0:
|
|
62661
|
+
case `auto`: return t.stdoutIsTTY ? `pretty` : `compact`;
|
|
62662
|
+
default: return e;
|
|
62663
|
+
}
|
|
62664
|
+
}
|
|
62665
|
+
const t = /\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)|\u001b[@-Z\\-_]/g;
|
|
62666
|
+
const n = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g;
|
|
62667
|
+
function r(e) {
|
|
62668
|
+
return e.replace(t, ``).replace(/\r\n/g, `
|
|
62669
|
+
`).replace(n, ``);
|
|
62670
|
+
}
|
|
62671
|
+
function o$1(e) {
|
|
62672
|
+
let t = e.endsWith(`==`) ? 2 : +!!e.endsWith(`=`);
|
|
62673
|
+
return Math.max(0, Math.floor(e.length * 3 / 4) - t);
|
|
62674
|
+
}
|
|
62675
|
+
function s$1(e) {
|
|
62676
|
+
return e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB`;
|
|
62677
|
+
}
|
|
62678
|
+
function c$1(e, t, n) {
|
|
62679
|
+
let i = t.get(e);
|
|
62680
|
+
switch (e.type) {
|
|
62681
|
+
case `text`: return n ? String(e.text) : r(String(e.text));
|
|
62682
|
+
case `image`:
|
|
62683
|
+
case `audio`: {
|
|
62684
|
+
let t = String(e.mimeType ?? `application/octet-stream`);
|
|
62685
|
+
return i ? `[${e.type} ${t} saved to ${i.path}]` : `[${e.type} ${t}, ${s$1(o$1(String(e.data ?? ``)))}; use --save <dir> to write it]`;
|
|
62686
|
+
}
|
|
62687
|
+
case `resource_link`: return `${e.name ? `${r(String(e.name))}: ` : ``}${r(String(e.uri))}`;
|
|
62688
|
+
case `resource`: {
|
|
62689
|
+
let t = e.resource ?? {};
|
|
62690
|
+
return typeof t.text == `string` ? n ? t.text : r(t.text) : i ? `[resource ${t.uri ?? ``} saved to ${i.path}]` : `[resource ${r(String(t.uri ?? ``))}${t.blob ? `, ${s$1(o$1(t.blob))}` : ``}]`;
|
|
62691
|
+
}
|
|
62692
|
+
default: return `[${r(String(e.type))} content]`;
|
|
62693
|
+
}
|
|
62694
|
+
}
|
|
62695
|
+
function l$1(e, t) {
|
|
62696
|
+
return JSON.stringify(e) === JSON.stringify(t);
|
|
62697
|
+
}
|
|
62698
|
+
function u$1(e) {
|
|
62699
|
+
let t = Array.isArray(e.content) ? e.content : [];
|
|
62700
|
+
return e.structuredContent === void 0 ? t : t.filter((t) => {
|
|
62701
|
+
if (t.type !== `text`) return !0;
|
|
62702
|
+
try {
|
|
62703
|
+
return !l$1(JSON.parse(String(t.text)), e.structuredContent);
|
|
62704
|
+
} catch {
|
|
62705
|
+
return !0;
|
|
62706
|
+
}
|
|
62529
62707
|
});
|
|
62530
62708
|
}
|
|
62531
|
-
|
|
62532
|
-
|
|
62533
|
-
stream.setEncoding("utf8");
|
|
62534
|
-
for await (const chunk of stream) value += chunk;
|
|
62535
|
-
return value;
|
|
62709
|
+
function f$1(e) {
|
|
62710
|
+
return typeof e == `object` && !!e && !Array.isArray(e) && Object.values(e).every((e) => typeof e != `object` || !e);
|
|
62536
62711
|
}
|
|
62537
|
-
function
|
|
62538
|
-
let
|
|
62712
|
+
function p$2(e) {
|
|
62713
|
+
let t = e.structuredContent, n = [];
|
|
62714
|
+
t !== void 0 && (n.push(t), typeof t == `object` && t && n.push(...Object.values(t)));
|
|
62715
|
+
for (let e of n) if (Array.isArray(e) && e.length > 0 && e.every(f$1)) return e;
|
|
62716
|
+
return null;
|
|
62717
|
+
}
|
|
62718
|
+
function m$2(e) {
|
|
62719
|
+
let t = [...new Set(e.flatMap((e) => Object.keys(e)))], n = (e) => e == null ? `` : r(String(e)).replace(/\n/g, ` `), i = t.map((t) => Math.max(t.length, ...e.map((e) => n(e[t]).length))), a = (e) => e.map((e, t) => e.padEnd(i[t])).join(` `).trimEnd();
|
|
62720
|
+
return [a(t.map((e) => e.toUpperCase())), ...e.map((e) => a(t.map((t) => n(e[t]))))].join(`
|
|
62721
|
+
`);
|
|
62722
|
+
}
|
|
62723
|
+
function h$2(e, t) {
|
|
62724
|
+
let n = t.saved ?? /* @__PURE__ */ new Map();
|
|
62725
|
+
switch (t.mode) {
|
|
62726
|
+
case `json`: return JSON.stringify(e);
|
|
62727
|
+
case `ndjson`: return JSON.stringify({
|
|
62728
|
+
type: `result`,
|
|
62729
|
+
result: e
|
|
62730
|
+
});
|
|
62731
|
+
case `table`: {
|
|
62732
|
+
let n = p$2(e);
|
|
62733
|
+
return n ? m$2(n) : h$2(e, {
|
|
62734
|
+
...t,
|
|
62735
|
+
mode: `pretty`
|
|
62736
|
+
});
|
|
62737
|
+
}
|
|
62738
|
+
case `pretty`:
|
|
62739
|
+
case `compact`:
|
|
62740
|
+
if (e.structuredContent !== void 0) {
|
|
62741
|
+
let r = t.mode === `pretty` ? JSON.stringify(e.structuredContent, null, 2) : JSON.stringify(e.structuredContent), i = u$1(e).map((e) => c$1(e, n, !1));
|
|
62742
|
+
return t.mode === `pretty` && i.length > 0 ? [r, ...i].join(`
|
|
62743
|
+
`) : r;
|
|
62744
|
+
}
|
|
62745
|
+
return u$1(e).map((e) => c$1(e, n, t.mode === `compact`)).join(`
|
|
62746
|
+
`);
|
|
62747
|
+
case `text`:
|
|
62748
|
+
case `raw`: {
|
|
62749
|
+
let r = u$1(e).map((e) => c$1(e, n, t.mode === `raw`));
|
|
62750
|
+
return r.length === 0 && e.structuredContent !== void 0 ? JSON.stringify(e.structuredContent, null, t.mode === `text` ? 2 : void 0) : r.join(`
|
|
62751
|
+
`);
|
|
62752
|
+
}
|
|
62753
|
+
}
|
|
62754
|
+
}
|
|
62755
|
+
// ../mcp-cli/dist/chunk-CL8BNzsR.mjs
|
|
62756
|
+
const i = /* @__PURE__ */ new Set([
|
|
62757
|
+
`approvals`,
|
|
62758
|
+
`auth`,
|
|
62759
|
+
`call`,
|
|
62760
|
+
`completion`,
|
|
62761
|
+
`doctor`,
|
|
62762
|
+
`help`,
|
|
62763
|
+
`login`,
|
|
62764
|
+
`logout`,
|
|
62765
|
+
`resources`,
|
|
62766
|
+
`resume`,
|
|
62767
|
+
`schema`,
|
|
62768
|
+
`skill`,
|
|
62769
|
+
`tasks`,
|
|
62770
|
+
`tools`,
|
|
62771
|
+
`version`,
|
|
62772
|
+
`whoami`,
|
|
62773
|
+
`__complete`
|
|
62774
|
+
]);
|
|
62775
|
+
function o(e) {
|
|
62776
|
+
return e.split(/\s+/).filter(Boolean);
|
|
62777
|
+
}
|
|
62778
|
+
function s(e, t) {
|
|
62779
|
+
if (t?.group || t?.name) {
|
|
62780
|
+
let n = t.group ? o(t.group) : [], r = t.name ?? (e.name.includes(`.`) ? e.name.split(`.`).filter(Boolean).at(-1) ?? e.name : e.name);
|
|
62781
|
+
return [...n, r];
|
|
62782
|
+
}
|
|
62783
|
+
if (e.name.includes(`.`)) {
|
|
62784
|
+
let t = e.name.split(`.`).filter(Boolean);
|
|
62785
|
+
if (t.length > 0) return t;
|
|
62786
|
+
}
|
|
62787
|
+
return [e.name];
|
|
62788
|
+
}
|
|
62789
|
+
const c = (e) => e.join(`\0`);
|
|
62790
|
+
function l(e, t = {}) {
|
|
62791
|
+
let r = [], a = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = (e, t, n) => {
|
|
62792
|
+
if (t.length === 0 || t.some((e) => e === ``)) return;
|
|
62793
|
+
let r = l.get(c(t)) ?? [];
|
|
62794
|
+
r.push({
|
|
62795
|
+
entry: e,
|
|
62796
|
+
priority: n
|
|
62797
|
+
}), l.set(c(t), r);
|
|
62798
|
+
}, d = /* @__PURE__ */ new Map();
|
|
62799
|
+
for (let i of e) {
|
|
62800
|
+
if (a.has(i.name)) continue;
|
|
62801
|
+
let e = Object.prototype.hasOwnProperty.call(t, i.name) ? t[i.name] : void 0, c = s(i, e), l = {
|
|
62802
|
+
tool: i,
|
|
62803
|
+
path: c,
|
|
62804
|
+
aliases: [],
|
|
62805
|
+
hidden: e?.hidden === !0,
|
|
62806
|
+
callOnly: !1,
|
|
62807
|
+
override: e
|
|
62808
|
+
};
|
|
62809
|
+
r.push(l), a.set(i.name, l);
|
|
62810
|
+
let f = [
|
|
62811
|
+
{
|
|
62812
|
+
path: [i.name],
|
|
62813
|
+
priority: 0
|
|
62814
|
+
},
|
|
62815
|
+
{
|
|
62816
|
+
path: c,
|
|
62817
|
+
priority: 1
|
|
62818
|
+
},
|
|
62819
|
+
...(e?.aliases ?? []).map((e) => ({
|
|
62820
|
+
path: o(e),
|
|
62821
|
+
priority: 2
|
|
62822
|
+
})),
|
|
62823
|
+
{
|
|
62824
|
+
path: c.map(e$1),
|
|
62825
|
+
priority: 3
|
|
62826
|
+
},
|
|
62827
|
+
{
|
|
62828
|
+
path: [e$1(i.name)],
|
|
62829
|
+
priority: 3
|
|
62830
|
+
}
|
|
62831
|
+
];
|
|
62832
|
+
d.set(l, f);
|
|
62833
|
+
for (let e of f) u(l, e.path, e.priority);
|
|
62834
|
+
}
|
|
62835
|
+
let f = { children: /* @__PURE__ */ new Map() }, p = /* @__PURE__ */ new Map();
|
|
62836
|
+
for (let [e, t] of d) {
|
|
62837
|
+
let n = /* @__PURE__ */ new Set();
|
|
62838
|
+
for (let { path: r } of t) {
|
|
62839
|
+
let t = c(r);
|
|
62840
|
+
if (n.has(t) || r.length === 0 || (n.add(t), i.has(r[0]))) continue;
|
|
62841
|
+
let a = l.get(t) ?? [], o = Math.min(...a.map((e) => e.priority)), s = a.filter((e) => e.priority === o), u = new Set(s.map((e) => e.entry));
|
|
62842
|
+
if (u.size !== 1 || !u.has(e)) continue;
|
|
62843
|
+
let d = f;
|
|
62844
|
+
for (let e of r) {
|
|
62845
|
+
let t = d.children.get(e);
|
|
62846
|
+
t || (t = { children: /* @__PURE__ */ new Map() }, d.children.set(e, t)), d = t;
|
|
62847
|
+
}
|
|
62848
|
+
d.entry = e;
|
|
62849
|
+
let m = p.get(e) ?? [];
|
|
62850
|
+
m.push(r), p.set(e, m);
|
|
62851
|
+
}
|
|
62852
|
+
}
|
|
62853
|
+
for (let e of r) {
|
|
62854
|
+
let t = p.get(e) ?? [], n = c(e.path), r = t.find((e) => c(e) === n) ?? t[0];
|
|
62855
|
+
r ? (e.path = r, e.aliases = t.filter((e) => c(e) !== c(r))) : e.callOnly = !0;
|
|
62856
|
+
}
|
|
62857
|
+
let m = (e) => {
|
|
62858
|
+
let t = f;
|
|
62859
|
+
for (let n of e) if (t = t?.children.get(n), !t) return;
|
|
62860
|
+
return t;
|
|
62861
|
+
};
|
|
62862
|
+
return {
|
|
62863
|
+
entries: r,
|
|
62864
|
+
byToolName: a,
|
|
62865
|
+
resolve(e) {
|
|
62866
|
+
let t = f, n = { kind: `none` }, r = [];
|
|
62867
|
+
for (let [i, a] of e.entries()) {
|
|
62868
|
+
let e = t.children.get(a);
|
|
62869
|
+
if (!e) break;
|
|
62870
|
+
t = e, r.push(a), t.entry && (n = {
|
|
62871
|
+
kind: `tool`,
|
|
62872
|
+
entry: t.entry,
|
|
62873
|
+
consumed: i + 1
|
|
62874
|
+
});
|
|
62875
|
+
}
|
|
62876
|
+
return n.kind === `tool` ? n : r.length > 0 ? {
|
|
62877
|
+
kind: `group`,
|
|
62878
|
+
path: r,
|
|
62879
|
+
children: [...t.children.keys()].sort()
|
|
62880
|
+
} : n;
|
|
62881
|
+
},
|
|
62882
|
+
topLevelWords() {
|
|
62883
|
+
return [...f.children.keys()].sort();
|
|
62884
|
+
},
|
|
62885
|
+
childrenOf(e) {
|
|
62886
|
+
return [...m(e)?.children.keys() ?? []].sort();
|
|
62887
|
+
}
|
|
62888
|
+
};
|
|
62889
|
+
}
|
|
62890
|
+
function u(e) {
|
|
62891
|
+
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
62892
|
+
}
|
|
62893
|
+
function d(e) {
|
|
62894
|
+
return decodeURIComponent(e).replace(/~1/g, `/`).replace(/~0/g, `~`);
|
|
62895
|
+
}
|
|
62896
|
+
function f(e, t) {
|
|
62897
|
+
if (t === `#`) return e;
|
|
62898
|
+
if (!t.startsWith(`#/`)) return;
|
|
62899
|
+
let n = e;
|
|
62900
|
+
for (let e of t.slice(2).split(`/`)) {
|
|
62901
|
+
if (!u(n)) return;
|
|
62902
|
+
n = n[d(e)];
|
|
62903
|
+
}
|
|
62904
|
+
return u(n) ? n : void 0;
|
|
62905
|
+
}
|
|
62906
|
+
var p$1 = class extends Error {};
|
|
62907
|
+
function m$1(e, t, n, r) {
|
|
62908
|
+
if (n.length > 32) throw new p$1();
|
|
62909
|
+
let i = t;
|
|
62910
|
+
if (typeof i.$ref == `string`) {
|
|
62911
|
+
let t = i.$ref;
|
|
62912
|
+
if (n.includes(t)) throw new p$1();
|
|
62913
|
+
let a = f(e, t);
|
|
62914
|
+
if (!a) return {
|
|
62915
|
+
...i,
|
|
62916
|
+
$ref: void 0
|
|
62917
|
+
};
|
|
62918
|
+
r.add(t);
|
|
62919
|
+
let { $ref: o, ...s } = i;
|
|
62920
|
+
i = {
|
|
62921
|
+
...m$1(e, a, [...n, t], r),
|
|
62922
|
+
...s
|
|
62923
|
+
};
|
|
62924
|
+
}
|
|
62925
|
+
if (Array.isArray(i.allOf)) {
|
|
62926
|
+
let { allOf: t, ...a } = i, o = {};
|
|
62927
|
+
for (let i of t) u(i) && (o = h$1(o, m$1(e, i, n, r)));
|
|
62928
|
+
i = h$1(o, a);
|
|
62929
|
+
}
|
|
62930
|
+
return i;
|
|
62931
|
+
}
|
|
62932
|
+
function h$1(e, t) {
|
|
62933
|
+
let n = {
|
|
62934
|
+
...e,
|
|
62935
|
+
...t
|
|
62936
|
+
};
|
|
62937
|
+
(u(e.properties) || u(t.properties)) && (n.properties = {
|
|
62938
|
+
...u(e.properties) ? e.properties : {},
|
|
62939
|
+
...u(t.properties) ? t.properties : {}
|
|
62940
|
+
});
|
|
62941
|
+
let r = [...Array.isArray(e.required) ? e.required : [], ...Array.isArray(t.required) ? t.required : []];
|
|
62942
|
+
return r.length > 0 && (n.required = [...new Set(r)]), n;
|
|
62943
|
+
}
|
|
62944
|
+
function g$1(e, t, n = []) {
|
|
62945
|
+
let r = /* @__PURE__ */ new Set();
|
|
62539
62946
|
try {
|
|
62540
|
-
|
|
62947
|
+
return {
|
|
62948
|
+
schema: m$1(e, t, n, r),
|
|
62949
|
+
recursive: !1,
|
|
62950
|
+
ancestors: [...n, ...r]
|
|
62951
|
+
};
|
|
62952
|
+
} catch (e) {
|
|
62953
|
+
if (e instanceof p$1) return {
|
|
62954
|
+
schema: t,
|
|
62955
|
+
recursive: !0,
|
|
62956
|
+
ancestors: n
|
|
62957
|
+
};
|
|
62958
|
+
throw e;
|
|
62959
|
+
}
|
|
62960
|
+
}
|
|
62961
|
+
function _$1(e) {
|
|
62962
|
+
return typeof e.type == `string` ? [e.type] : Array.isArray(e.type) ? e.type.filter((e) => typeof e == `string`) : [];
|
|
62963
|
+
}
|
|
62964
|
+
function ee(e) {
|
|
62965
|
+
return e.contentEncoding === `base64` || e.format === `binary` || e.format === `byte` || typeof e.contentMediaType == `string`;
|
|
62966
|
+
}
|
|
62967
|
+
function v$1(e) {
|
|
62968
|
+
return u(e) && (e.type === `null` || Array.isArray(e.type) && e.type.length === 1 && e.type[0] === `null`);
|
|
62969
|
+
}
|
|
62970
|
+
function y$1(e, t, n) {
|
|
62971
|
+
return {
|
|
62972
|
+
kind: t,
|
|
62973
|
+
schema: e,
|
|
62974
|
+
nullable: n,
|
|
62975
|
+
description: typeof e.description == `string` ? e.description : void 0,
|
|
62976
|
+
defaultValue: e.default,
|
|
62977
|
+
hasDefault: Object.prototype.hasOwnProperty.call(e, `default`),
|
|
62978
|
+
deprecated: e.deprecated === !0,
|
|
62979
|
+
readOnly: e.readOnly === !0,
|
|
62980
|
+
format: typeof e.format == `string` ? e.format : void 0
|
|
62981
|
+
};
|
|
62982
|
+
}
|
|
62983
|
+
const b$1 = [
|
|
62984
|
+
`integer`,
|
|
62985
|
+
`number`,
|
|
62986
|
+
`boolean`,
|
|
62987
|
+
`string`
|
|
62988
|
+
];
|
|
62989
|
+
function x$1(e) {
|
|
62990
|
+
if (e.kind === `integer` || e.kind === `number` || e.kind === `boolean` || e.kind === `string`) return e.kind;
|
|
62991
|
+
if (e.kind === `binary`) return `string`;
|
|
62992
|
+
if (e.kind === `enum` || e.kind === `const`) {
|
|
62993
|
+
let t = e.kind === `enum` ? e.enumValues ?? [] : [e.constValue];
|
|
62994
|
+
if (t.every((e) => typeof e == `string`)) return `string`;
|
|
62995
|
+
if (t.every((e) => Number.isInteger(e))) return `integer`;
|
|
62996
|
+
if (t.every((e) => typeof e == `number`)) return `number`;
|
|
62997
|
+
if (t.every((e) => typeof e == `boolean`)) return `boolean`;
|
|
62998
|
+
}
|
|
62999
|
+
}
|
|
63000
|
+
function S$1(e, t, n = []) {
|
|
63001
|
+
let { schema: r, recursive: i, ancestors: a } = g$1(e, t, n);
|
|
63002
|
+
if (i) return y$1(r, `json`, !1);
|
|
63003
|
+
let o = r.nullable === !0, s = _$1(r);
|
|
63004
|
+
s.includes(`null`) && (o = !0);
|
|
63005
|
+
let c = s.filter((e) => e !== `null`);
|
|
63006
|
+
if (Object.prototype.hasOwnProperty.call(r, `const`)) return {
|
|
63007
|
+
...y$1(r, `const`, o),
|
|
63008
|
+
constValue: r.const
|
|
63009
|
+
};
|
|
63010
|
+
if (Array.isArray(r.enum)) {
|
|
63011
|
+
let e = r.enum.filter((e) => e !== null);
|
|
63012
|
+
return e.length !== r.enum.length && (o = !0), {
|
|
63013
|
+
...y$1(r, `enum`, o),
|
|
63014
|
+
enumValues: e
|
|
63015
|
+
};
|
|
63016
|
+
}
|
|
63017
|
+
let l = Array.isArray(r.anyOf) ? r.anyOf : Array.isArray(r.oneOf) ? r.oneOf : void 0;
|
|
63018
|
+
if (l) {
|
|
63019
|
+
let t = l.filter((e) => !v$1(e));
|
|
63020
|
+
t.length !== l.length && (o = !0);
|
|
63021
|
+
let n = t.filter(u).map((t) => S$1(e, t, a)), i = {
|
|
63022
|
+
...r,
|
|
63023
|
+
anyOf: void 0,
|
|
63024
|
+
oneOf: void 0
|
|
63025
|
+
};
|
|
63026
|
+
if (n.length === 1) {
|
|
63027
|
+
let e = n[0];
|
|
63028
|
+
return {
|
|
63029
|
+
...e,
|
|
63030
|
+
nullable: o || e.nullable,
|
|
63031
|
+
description: typeof r.description == `string` ? r.description : e.description,
|
|
63032
|
+
hasDefault: e.hasDefault || Object.prototype.hasOwnProperty.call(r, `default`),
|
|
63033
|
+
defaultValue: r.default ?? e.defaultValue,
|
|
63034
|
+
deprecated: r.deprecated === !0 || e.deprecated
|
|
63035
|
+
};
|
|
63036
|
+
}
|
|
63037
|
+
let s = n.map(x$1);
|
|
63038
|
+
if (n.length > 0 && s.every((e) => e !== void 0)) {
|
|
63039
|
+
let e = b$1.filter((e) => s.includes(e));
|
|
63040
|
+
return {
|
|
63041
|
+
...y$1(i, `scalar-union`, o),
|
|
63042
|
+
unionKinds: e
|
|
63043
|
+
};
|
|
63044
|
+
}
|
|
63045
|
+
return y$1(i, `json`, o);
|
|
63046
|
+
}
|
|
63047
|
+
if (c.length > 1) {
|
|
63048
|
+
let e = b$1.filter((e) => c.includes(e));
|
|
63049
|
+
return e.length === c.length ? {
|
|
63050
|
+
...y$1(r, `scalar-union`, o),
|
|
63051
|
+
unionKinds: e
|
|
63052
|
+
} : y$1(r, `json`, o);
|
|
63053
|
+
}
|
|
63054
|
+
switch (c[0] ?? (u(r.properties) || u(r.additionalProperties) ? `object` : void 0)) {
|
|
63055
|
+
case `string`: return y$1(r, ee(r) ? `binary` : `string`, o);
|
|
63056
|
+
case `integer`: return y$1(r, `integer`, o);
|
|
63057
|
+
case `number`: return y$1(r, `number`, o);
|
|
63058
|
+
case `boolean`: return y$1(r, `boolean`, o);
|
|
63059
|
+
case `array`: {
|
|
63060
|
+
let t = S$1(e, u(r.items) ? r.items : {}, a);
|
|
63061
|
+
return x$1(t) !== void 0 || t.kind === `scalar-union` ? {
|
|
63062
|
+
...y$1(r, `scalar-array`, o),
|
|
63063
|
+
item: t
|
|
63064
|
+
} : {
|
|
63065
|
+
...y$1(r, `object-array`, o),
|
|
63066
|
+
item: t
|
|
63067
|
+
};
|
|
63068
|
+
}
|
|
63069
|
+
case `object`:
|
|
63070
|
+
if (!(u(r.properties) && Object.keys(r.properties).length > 0) && u(r.additionalProperties)) {
|
|
63071
|
+
let t = S$1(e, r.additionalProperties, a);
|
|
63072
|
+
if (x$1(t) !== void 0 || t.kind === `scalar-union`) return {
|
|
63073
|
+
...y$1(r, `map`, o),
|
|
63074
|
+
item: t
|
|
63075
|
+
};
|
|
63076
|
+
}
|
|
63077
|
+
return y$1(r, `object`, o);
|
|
63078
|
+
default: return y$1(r, `any`, o);
|
|
63079
|
+
}
|
|
63080
|
+
}
|
|
63081
|
+
function te(e) {
|
|
63082
|
+
let { schema: t, recursive: n } = g$1(e, e);
|
|
63083
|
+
if (n) return null;
|
|
63084
|
+
let r = _$1(t);
|
|
63085
|
+
if (!(r.includes(`object`) || r.length === 0 && (u(t.properties) || Object.keys(t).length === 0))) return null;
|
|
63086
|
+
let i = Object.create(null);
|
|
63087
|
+
if (u(t.properties)) for (let [e, n] of Object.entries(t.properties)) u(n) && (i[e] = n);
|
|
63088
|
+
return {
|
|
63089
|
+
properties: i,
|
|
63090
|
+
required: Array.isArray(t.required) ? t.required.filter((e) => typeof e == `string` && Object.hasOwn(i, e)) : []
|
|
63091
|
+
};
|
|
63092
|
+
}
|
|
63093
|
+
function C$1(e, t) {
|
|
63094
|
+
let n = (Array.isArray(t.anyOf) ? t.anyOf : Array.isArray(t.oneOf) ? t.oneOf : []).filter((e) => u(e) && !v$1(e));
|
|
63095
|
+
return n.length === 1 ? g$1(e, n[0]).schema : t;
|
|
63096
|
+
}
|
|
63097
|
+
function w$1(e, t) {
|
|
63098
|
+
let n = e;
|
|
63099
|
+
for (let r of t) {
|
|
63100
|
+
let { schema: t, recursive: i } = g$1(e, n);
|
|
63101
|
+
if (i) return;
|
|
63102
|
+
let a = C$1(e, t);
|
|
63103
|
+
if (r === `[]`) {
|
|
63104
|
+
if (!u(a.items)) return;
|
|
63105
|
+
n = a.items;
|
|
63106
|
+
} else if (u(a.properties) && u(a.properties[r])) n = a.properties[r];
|
|
63107
|
+
else if (u(a.additionalProperties)) n = a.additionalProperties;
|
|
63108
|
+
else return;
|
|
63109
|
+
}
|
|
63110
|
+
return S$1(e, n);
|
|
63111
|
+
}
|
|
63112
|
+
const T$1 = /* @__PURE__ */ new Set(/* @__PURE__ */ `answers.approvals.approve.approve-all.color.deny.detach.dry-run.example.field.help.help-all.input.json.json-body.jsonl.max-output.no-color.no-input.output.profile.raw-field.raw-strings.save.stream.timeout.token.verbose.wait.yes`.split(`.`));
|
|
63113
|
+
function E$1(e) {
|
|
63114
|
+
return e.kind === `string` || e.kind === `enum` || e.kind === `binary`;
|
|
63115
|
+
}
|
|
63116
|
+
function D$1(e, t) {
|
|
63117
|
+
let r = e.inputSchema ?? {}, i = te(r);
|
|
63118
|
+
if (!i) return {
|
|
63119
|
+
tool: e,
|
|
63120
|
+
bodyOnly: !0,
|
|
63121
|
+
flags: [],
|
|
63122
|
+
byFlag: /* @__PURE__ */ new Map(),
|
|
63123
|
+
byWire: /* @__PURE__ */ new Map(),
|
|
63124
|
+
positionals: [],
|
|
63125
|
+
constFields: {},
|
|
63126
|
+
defaults: {},
|
|
63127
|
+
required: []
|
|
63128
|
+
};
|
|
63129
|
+
let a = {}, o = { ...t?.defaults }, s = [], c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
|
|
63130
|
+
for (let e of Object.keys(i.properties)) l.set(e$1(e), (l.get(e$1(e)) ?? 0) + 1);
|
|
63131
|
+
for (let [e, t] of Object.entries(i.properties)) {
|
|
63132
|
+
let u = S$1(r, t);
|
|
63133
|
+
if (u.readOnly) continue;
|
|
63134
|
+
if (u.kind === `const`) {
|
|
63135
|
+
O$1(a, e, u.constValue);
|
|
63136
|
+
continue;
|
|
63137
|
+
}
|
|
63138
|
+
let d = e$1(e) || e, f = d;
|
|
63139
|
+
if (T$1.has(f) || (l.get(d) ?? 0) > 1 || c.has(f)) for (f = `arg-${d}`, (c.has(f) || (l.get(d) ?? 0) > 1) && (f = `arg-${e}`); c.has(f);) f = `arg-${f}`;
|
|
63140
|
+
c.add(f), s.push({
|
|
63141
|
+
wire: e,
|
|
63142
|
+
flag: f,
|
|
63143
|
+
field: u,
|
|
63144
|
+
required: i.required.includes(e) && !u.hasDefault && !Object.hasOwn(o, e),
|
|
63145
|
+
hidden: u.deprecated
|
|
63146
|
+
});
|
|
63147
|
+
}
|
|
63148
|
+
let u = new Map(s.map((e) => [e.wire, e])), d = [];
|
|
63149
|
+
if (t?.positional && t.positional.length > 0) d = t.positional.map((e) => u.get(e)).filter((e) => e !== void 0 && E$1(e.field));
|
|
63150
|
+
else {
|
|
63151
|
+
let e = s.filter((e) => e.required);
|
|
63152
|
+
e.length === 1 && e[0].field.kind === `string` && (d = e);
|
|
63153
|
+
}
|
|
63154
|
+
return d.forEach((e, t) => {
|
|
63155
|
+
e.position = t;
|
|
63156
|
+
}), {
|
|
63157
|
+
tool: e,
|
|
63158
|
+
bodyOnly: !1,
|
|
63159
|
+
flags: s,
|
|
63160
|
+
byFlag: new Map(s.map((e) => [e.flag, e])),
|
|
63161
|
+
byWire: u,
|
|
63162
|
+
positionals: d,
|
|
63163
|
+
constFields: a,
|
|
63164
|
+
defaults: o,
|
|
63165
|
+
required: s.filter((e) => e.required).map((e) => e.wire)
|
|
63166
|
+
};
|
|
63167
|
+
}
|
|
63168
|
+
function O$1(e, t, n) {
|
|
63169
|
+
Object.defineProperty(e, t, {
|
|
63170
|
+
value: n,
|
|
63171
|
+
enumerable: !0,
|
|
63172
|
+
configurable: !0,
|
|
63173
|
+
writable: !0
|
|
63174
|
+
});
|
|
63175
|
+
}
|
|
63176
|
+
function k$1(e) {
|
|
63177
|
+
return e?.startsWith(`\0`) === !0;
|
|
63178
|
+
}
|
|
63179
|
+
function A$1(t, n) {
|
|
63180
|
+
let r = n.slice(1), i = t.startsWith(`--`) ? `${t}=${r}` : `${t}${r}`;
|
|
63181
|
+
return new n$2(`usage`, `${t} needs a value, but the word after it, ${r}, is a global flag`, `Write ${i} to pass it as the value, or put ${r} after the value`);
|
|
63182
|
+
}
|
|
63183
|
+
const j$1 = /* @__PURE__ */ new Set([
|
|
63184
|
+
`auto`,
|
|
63185
|
+
`json`,
|
|
63186
|
+
`text`,
|
|
63187
|
+
`raw`,
|
|
63188
|
+
`ndjson`,
|
|
63189
|
+
`table`
|
|
63190
|
+
]);
|
|
63191
|
+
const M$1 = /* @__PURE__ */ new Set([
|
|
63192
|
+
`output`,
|
|
63193
|
+
`timeout`,
|
|
63194
|
+
`save`,
|
|
63195
|
+
`input`,
|
|
63196
|
+
`json-body`,
|
|
63197
|
+
`field`,
|
|
63198
|
+
`raw-field`,
|
|
63199
|
+
`max-output`,
|
|
63200
|
+
`approve`,
|
|
63201
|
+
`deny`,
|
|
63202
|
+
`approvals`,
|
|
63203
|
+
`answers`,
|
|
63204
|
+
`wait`,
|
|
63205
|
+
`stream`
|
|
63206
|
+
]);
|
|
63207
|
+
const N$1 = /* @__PURE__ */ new Set([
|
|
63208
|
+
`auto`,
|
|
63209
|
+
`raw`,
|
|
63210
|
+
`off`
|
|
63211
|
+
]);
|
|
63212
|
+
const re = /* @__PURE__ */ new Set([
|
|
63213
|
+
`prompt`,
|
|
63214
|
+
`fail`,
|
|
63215
|
+
`deny`
|
|
63216
|
+
]);
|
|
63217
|
+
const P$1 = {
|
|
63218
|
+
h: `help`,
|
|
63219
|
+
o: `output`,
|
|
63220
|
+
y: `yes`,
|
|
63221
|
+
f: `raw-field`,
|
|
63222
|
+
F: `field`
|
|
63223
|
+
};
|
|
63224
|
+
function F(e) {
|
|
63225
|
+
return e.field.kind === `scalar-array` || e.field.kind === `object-array` || e.field.kind === `map`;
|
|
63226
|
+
}
|
|
63227
|
+
function I(t, n) {
|
|
63228
|
+
let r = /^(\d+(?:\.\d+)?)(ms|s|m|h)?$/.exec(t.trim());
|
|
63229
|
+
if (!r) throw new n$2(`invalid_value`, `${n} expects a duration such as 30000, 30s or 5m`);
|
|
63230
|
+
let i = Number(r[1]), a = r[2] ?? `ms`, o = Math.round(i * (a === `h` ? 36e5 : a === `m` ? 6e4 : a === `s` ? 1e3 : 1));
|
|
63231
|
+
if (o <= 0) throw new n$2(`invalid_value`, `${n} must be greater than zero`);
|
|
63232
|
+
return o;
|
|
63233
|
+
}
|
|
63234
|
+
function ie(t) {
|
|
63235
|
+
if (t === `0` || t === `none` || t === `unlimited`) return null;
|
|
63236
|
+
if (!/^\d+$/.test(t)) throw new n$2(`invalid_value`, `--max-output expects a character count, or 0 for unlimited`);
|
|
63237
|
+
return Number(t);
|
|
63238
|
+
}
|
|
63239
|
+
function ae(t, n) {
|
|
63240
|
+
let r = {
|
|
63241
|
+
help: !1,
|
|
63242
|
+
helpAll: !1,
|
|
63243
|
+
dryRun: !1,
|
|
63244
|
+
example: !1,
|
|
63245
|
+
detach: !1,
|
|
63246
|
+
yes: !1,
|
|
63247
|
+
fields: [],
|
|
63248
|
+
rawFields: [],
|
|
63249
|
+
rawStrings: !1,
|
|
63250
|
+
approve: [],
|
|
63251
|
+
deny: [],
|
|
63252
|
+
approveAll: !1
|
|
63253
|
+
}, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = [], s = /* @__PURE__ */ new Set(), c = (t, n) => {
|
|
63254
|
+
if (t === `field`) return void r.fields.push(n);
|
|
63255
|
+
if (t === `raw-field`) return void r.rawFields.push(n);
|
|
63256
|
+
if (t === `approve` || t === `deny`) {
|
|
63257
|
+
if (n.trim() === ``) throw new n$2(`invalid_value`, `--${t} needs a tool name`);
|
|
63258
|
+
r[t].push(n);
|
|
63259
|
+
} else {
|
|
63260
|
+
if (s.has(t)) throw new n$2(`usage`, `--${t} was given more than once`);
|
|
63261
|
+
switch (s.add(t), t) {
|
|
63262
|
+
case `output`:
|
|
63263
|
+
if (!j$1.has(n)) throw new n$2(`invalid_value`, `--output must be one of ${[...j$1].join(`, `)}`);
|
|
63264
|
+
r.output = L(r.output, n);
|
|
63265
|
+
return;
|
|
63266
|
+
case `timeout`:
|
|
63267
|
+
r.timeoutMs = I(n, `--timeout`);
|
|
63268
|
+
return;
|
|
63269
|
+
case `save`:
|
|
63270
|
+
r.save = n;
|
|
63271
|
+
return;
|
|
63272
|
+
case `input`:
|
|
63273
|
+
r.input = n;
|
|
63274
|
+
return;
|
|
63275
|
+
case `json-body`:
|
|
63276
|
+
r.jsonBody = n;
|
|
63277
|
+
return;
|
|
63278
|
+
case `max-output`:
|
|
63279
|
+
r.maxOutput = ie(n);
|
|
63280
|
+
return;
|
|
63281
|
+
case `approvals`:
|
|
63282
|
+
if (!re.has(n)) throw new n$2(`invalid_value`, `--approvals must be prompt, fail or deny`);
|
|
63283
|
+
r.approvals = n;
|
|
63284
|
+
return;
|
|
63285
|
+
case `answers`:
|
|
63286
|
+
r.answers = n;
|
|
63287
|
+
return;
|
|
63288
|
+
case `wait`:
|
|
63289
|
+
r.wait = n;
|
|
63290
|
+
return;
|
|
63291
|
+
case `stream`:
|
|
63292
|
+
if (!N$1.has(n)) throw new n$2(`invalid_value`, `--stream must be auto, raw or off`);
|
|
63293
|
+
r.stream = n;
|
|
63294
|
+
return;
|
|
63295
|
+
}
|
|
63296
|
+
}
|
|
63297
|
+
}, l = (e) => {
|
|
63298
|
+
switch (e) {
|
|
63299
|
+
case `help`: return r.help = !0, !0;
|
|
63300
|
+
case `help-all`: return r.helpAll = !0, !0;
|
|
63301
|
+
case `json`: return r.output = L(r.output, `json`), !0;
|
|
63302
|
+
case `jsonl`: return r.output = L(r.output, `ndjson`), !0;
|
|
63303
|
+
case `dry-run`: return r.dryRun = !0, !0;
|
|
63304
|
+
case `example`: return r.example = !0, !0;
|
|
63305
|
+
case `detach`: return r.detach = !0, !0;
|
|
63306
|
+
case `yes`: return r.yes = !0, !0;
|
|
63307
|
+
case `raw-strings`: return r.rawStrings = !0, !0;
|
|
63308
|
+
case `approve-all`: return r.approveAll = !0, !0;
|
|
63309
|
+
default: return !1;
|
|
63310
|
+
}
|
|
63311
|
+
}, u = (t, n) => {
|
|
63312
|
+
let r = i.get(t) ?? [];
|
|
63313
|
+
if (r.length > 0 && !F(t)) throw new n$2(`usage`, `--${t.flag} was given more than once`, oe(t));
|
|
63314
|
+
r.push(n), i.set(t, r);
|
|
63315
|
+
}, d = (t, n) => {
|
|
63316
|
+
if (a.has(t)) throw new n$2(`usage`, `--${t.flag} was given more than once`);
|
|
63317
|
+
a.set(t, n);
|
|
63318
|
+
};
|
|
63319
|
+
for (let r = 0; r < t.length; r += 1) {
|
|
63320
|
+
let i = t[r];
|
|
63321
|
+
if (!k$1(i)) {
|
|
63322
|
+
if (i === `--`) {
|
|
63323
|
+
o.push(...t.slice(r + 1));
|
|
63324
|
+
break;
|
|
63325
|
+
}
|
|
63326
|
+
if (i.startsWith(`--`) && i.length > 2) {
|
|
63327
|
+
let a = i.indexOf(`=`), o = a === -1 ? i.slice(2) : i.slice(2, a), s = a === -1 ? void 0 : i.slice(a + 1), f = () => {
|
|
63328
|
+
if (s !== void 0) return s;
|
|
63329
|
+
if (k$1(t[r + 1])) throw A$1(i, t[r + 1]);
|
|
63330
|
+
if (r + 1 >= t.length) throw new n$2(`missing_argument`, `--${o} needs a value`);
|
|
63331
|
+
return r += 1, t[r];
|
|
63332
|
+
}, p = n.byFlag.get(o);
|
|
63333
|
+
if (p) {
|
|
63334
|
+
p.field.kind === `boolean` ? d(p, s === void 0 || se(s, `--${o}`)) : u(p, f());
|
|
63335
|
+
continue;
|
|
63336
|
+
}
|
|
63337
|
+
if (o.startsWith(`no-`)) {
|
|
63338
|
+
let t = n.byFlag.get(o.slice(3));
|
|
63339
|
+
if (t && t.field.kind === `boolean`) {
|
|
63340
|
+
if (s !== void 0) throw new n$2(`usage`, `--${o} takes no value; use --${t.flag}=${s}`);
|
|
63341
|
+
d(t, !1);
|
|
63342
|
+
continue;
|
|
63343
|
+
}
|
|
63344
|
+
}
|
|
63345
|
+
if (M$1.has(o)) {
|
|
63346
|
+
c(o, f());
|
|
63347
|
+
continue;
|
|
63348
|
+
}
|
|
63349
|
+
if (s === void 0 && l(o)) continue;
|
|
63350
|
+
throw R(o, n);
|
|
63351
|
+
}
|
|
63352
|
+
if (i.startsWith(`-`) && i.length > 1 && !/^-\d/.test(i)) {
|
|
63353
|
+
let a = i.slice(1, 2), o = P$1[a];
|
|
63354
|
+
if (!o) throw R(i.slice(1), n);
|
|
63355
|
+
let s = i.slice(2);
|
|
63356
|
+
if (M$1.has(o)) {
|
|
63357
|
+
let n = s;
|
|
63358
|
+
if (n === ``) {
|
|
63359
|
+
if (k$1(t[r + 1])) throw A$1(i, t[r + 1]);
|
|
63360
|
+
if (r + 1 >= t.length) throw new n$2(`missing_argument`, `-${a} needs a value`);
|
|
63361
|
+
r += 1, n = t[r];
|
|
63362
|
+
}
|
|
63363
|
+
c(o, n);
|
|
63364
|
+
} else {
|
|
63365
|
+
if (s !== ``) throw R(i.slice(1), n);
|
|
63366
|
+
l(o);
|
|
63367
|
+
}
|
|
63368
|
+
} else o.push(i);
|
|
63369
|
+
}
|
|
63370
|
+
}
|
|
63371
|
+
return {
|
|
63372
|
+
reserved: r,
|
|
63373
|
+
values: i,
|
|
63374
|
+
booleans: a,
|
|
63375
|
+
positionals: o
|
|
63376
|
+
};
|
|
63377
|
+
}
|
|
63378
|
+
function L(t, n) {
|
|
63379
|
+
if (t && t !== n) throw new n$2(`usage`, `Choose one output format: --json, --jsonl or --output`);
|
|
63380
|
+
return n;
|
|
63381
|
+
}
|
|
63382
|
+
function oe(e) {
|
|
63383
|
+
return e.field.kind === `object` || e.field.kind === `json` ? `Pass one JSON value to --${e.flag}, or use -F ${e.wire}[key]=value` : void 0;
|
|
63384
|
+
}
|
|
63385
|
+
function se(t, n) {
|
|
63386
|
+
let r = t.trim().toLowerCase();
|
|
63387
|
+
if (r === `true`) return !0;
|
|
63388
|
+
if (r === `false`) return !1;
|
|
63389
|
+
throw new n$2(`invalid_value`, `${n} expects true or false, got ${JSON.stringify(t)}`);
|
|
63390
|
+
}
|
|
63391
|
+
function R(n, r) {
|
|
63392
|
+
let a = n$1(n, [...r.flags.filter((e) => !e.hidden).map((e) => e.flag), ...T$1]);
|
|
63393
|
+
return new n$2(`unknown_flag`, `Unknown flag --${n} for ${r.tool.name}`, a.length > 0 ? `Did you mean ${a.map((e) => `--${e}`).join(`, `)}?` : `Run with --help to list flags`);
|
|
63394
|
+
}
|
|
63395
|
+
function z(e) {
|
|
63396
|
+
if (!e) return ``;
|
|
63397
|
+
let t = r(e).trim().split(`
|
|
63398
|
+
`, 1)[0], n = /^(.+?[.!?])(\s|$)/.exec(t);
|
|
63399
|
+
return (n ? n[1] : t).trim();
|
|
63400
|
+
}
|
|
63401
|
+
function B(e) {
|
|
63402
|
+
let t = e.annotations ?? {}, n = [];
|
|
63403
|
+
return t.readOnlyHint && n.push(`read-only`), t.destructiveHint && n.push(`destructive`), t.idempotentHint && n.push(`idempotent`), t.openWorldHint && n.push(`open-world`), n;
|
|
63404
|
+
}
|
|
63405
|
+
function V(e, t, n = 0) {
|
|
63406
|
+
switch (e.kind) {
|
|
63407
|
+
case `string`: return `string`;
|
|
63408
|
+
case `binary`: return `base64`;
|
|
63409
|
+
case `enum`: return (e.enumValues ?? []).map((e) => JSON.stringify(e)).join(` | `);
|
|
63410
|
+
case `const`: return JSON.stringify(e.constValue);
|
|
63411
|
+
case `integer`:
|
|
63412
|
+
case `number`: return `number`;
|
|
63413
|
+
case `boolean`: return `boolean`;
|
|
63414
|
+
case `scalar-union`: return (e.unionKinds ?? []).map((e) => e === `integer` ? `number` : e).filter((e, t, n) => n.indexOf(e) === t).join(` | `);
|
|
63415
|
+
case `scalar-array`: return `${H(V(e.item ?? e, t, n))}[]`;
|
|
63416
|
+
case `object-array`: return `${U(e.item?.schema ?? {}, t, n)}[]`;
|
|
63417
|
+
case `map`: return `Record<string, ${V(e.item ?? e, t, n)}>`;
|
|
63418
|
+
case `object`: return U(e.schema, t, n);
|
|
63419
|
+
case `json`:
|
|
63420
|
+
case `any`: return `unknown`;
|
|
63421
|
+
}
|
|
63422
|
+
}
|
|
63423
|
+
function H(e) {
|
|
63424
|
+
return e.includes(` | `) ? `(${e})` : e;
|
|
63425
|
+
}
|
|
63426
|
+
function U(e, t, n = 0) {
|
|
63427
|
+
let r = e.properties;
|
|
63428
|
+
if (n > 1 || typeof r != `object` || !r) return `object`;
|
|
63429
|
+
let i = Array.isArray(e.required) ? e.required : [], a = Object.entries(r).map(([e, r]) => {
|
|
63430
|
+
let a = S$1(t, r), o = V(a, t, n + 1);
|
|
63431
|
+
return `${e}${i.includes(e) ? `` : `?`}: ${o}${a.nullable ? ` | null` : ``}`;
|
|
63432
|
+
});
|
|
63433
|
+
return a.length > 0 ? `{ ${a.join(`; `)} }` : `object`;
|
|
63434
|
+
}
|
|
63435
|
+
function W(e) {
|
|
63436
|
+
let t = e.inputSchema ?? {}, n = D$1(e);
|
|
63437
|
+
if (n.bodyOnly) return r(`${e.name}(body: unknown)`);
|
|
63438
|
+
let i = n.flags.filter((e) => !e.hidden).map((e) => `${e.wire}${e.required ? `` : `?`}: ${V(e.field, t)}${e.field.nullable ? ` | null` : ``}`);
|
|
63439
|
+
return r(`${e.name}(${i.length > 0 ? `{ ${i.join(`; `)} }` : ``})`);
|
|
63440
|
+
}
|
|
63441
|
+
function K(e) {
|
|
63442
|
+
return e.callOnly ? `call ${e.tool.name}` : e.path.join(` `);
|
|
63443
|
+
}
|
|
63444
|
+
function $(e, t = !1) {
|
|
63445
|
+
return e.entries.filter((e) => t || !e.hidden).map((e) => ({
|
|
63446
|
+
command: K(e),
|
|
63447
|
+
tool: e.tool.name,
|
|
63448
|
+
summary: z(e.tool.description),
|
|
63449
|
+
badges: B(e.tool)
|
|
63450
|
+
})).sort((e, t) => e.command.localeCompare(t.command));
|
|
63451
|
+
}
|
|
63452
|
+
function de(e) {
|
|
63453
|
+
if (e.length === 0) return `No tools.
|
|
63454
|
+
`;
|
|
63455
|
+
let t = Math.min(40, Math.max(...e.map((e) => e.command.length)));
|
|
63456
|
+
return r(`${e.map((e) => ` ${e.command.padEnd(t)} ${e.summary}${e.badges.length > 0 ? ` [${e.badges.join(`, `)}]` : ``}`.trimEnd()).join(`
|
|
63457
|
+
`)}\n`);
|
|
63458
|
+
}
|
|
63459
|
+
// ../mcp-cli/dist/chunk-DqN1GrzM.mjs
|
|
63460
|
+
var p = class extends n$2 {};
|
|
63461
|
+
function m(e) {
|
|
63462
|
+
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
63463
|
+
}
|
|
63464
|
+
function h(e, t) {
|
|
63465
|
+
try {
|
|
63466
|
+
return JSON.parse(e);
|
|
62541
63467
|
} catch {
|
|
62542
|
-
throw new
|
|
63468
|
+
throw new p(`invalid_value`, `${t} is not valid JSON`);
|
|
62543
63469
|
}
|
|
62544
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`${label} must be a JSON object`);
|
|
62545
|
-
return parsed;
|
|
62546
63470
|
}
|
|
62547
|
-
function
|
|
62548
|
-
|
|
62549
|
-
if (
|
|
62550
|
-
|
|
63471
|
+
function g(e) {
|
|
63472
|
+
if (Array.isArray(e)) return e.map(g);
|
|
63473
|
+
if (m(e)) {
|
|
63474
|
+
let t = {};
|
|
63475
|
+
for (let [r, i] of Object.entries(e)) O$1(t, r, g(i));
|
|
63476
|
+
return t;
|
|
63477
|
+
}
|
|
63478
|
+
return e;
|
|
62551
63479
|
}
|
|
62552
|
-
function
|
|
63480
|
+
function _(e, t) {
|
|
63481
|
+
let r = {};
|
|
63482
|
+
for (let [t, i] of Object.entries(e)) O$1(r, t, i);
|
|
63483
|
+
for (let [e, i] of Object.entries(t)) {
|
|
63484
|
+
let t = Object.prototype.hasOwnProperty.call(r, e) ? r[e] : void 0;
|
|
63485
|
+
O$1(r, e, m(t) && m(i) ? _(t, i) : i);
|
|
63486
|
+
}
|
|
63487
|
+
return r;
|
|
63488
|
+
}
|
|
63489
|
+
async function v(t, n, r) {
|
|
63490
|
+
let i = t.slice(1);
|
|
63491
|
+
if (i === ``) throw new p(`invalid_value`, `${r}: @ must be followed by a path, or - for stdin`);
|
|
63492
|
+
if (i === `-`) return n.readStdin();
|
|
62553
63493
|
try {
|
|
62554
|
-
return
|
|
63494
|
+
return await n.readFile(i);
|
|
63495
|
+
} catch (t) {
|
|
63496
|
+
throw new n$2(`invalid_value`, `${r}: cannot read ${i} (${t instanceof Error && `code` in t ? String(t.code) : `unreadable`})`);
|
|
63497
|
+
}
|
|
63498
|
+
}
|
|
63499
|
+
function y(e, t, n) {
|
|
63500
|
+
switch (e) {
|
|
63501
|
+
case `string`: return t;
|
|
63502
|
+
case `integer`: {
|
|
63503
|
+
let e = t.trim(), r = Number(e);
|
|
63504
|
+
if (!/^[+-]?\d+$/.test(e) || !Number.isSafeInteger(r)) throw new p(`invalid_value`, `${n} expects an integer, got ${JSON.stringify(t)}`);
|
|
63505
|
+
return r;
|
|
63506
|
+
}
|
|
63507
|
+
case `number`: {
|
|
63508
|
+
let e = Number(t.trim());
|
|
63509
|
+
if (t.trim() === `` || !Number.isFinite(e)) throw new p(`invalid_value`, `${n} expects a number, got ${JSON.stringify(t)}`);
|
|
63510
|
+
return e;
|
|
63511
|
+
}
|
|
63512
|
+
case `boolean`: {
|
|
63513
|
+
let e = t.trim().toLowerCase();
|
|
63514
|
+
if (e === `true`) return !0;
|
|
63515
|
+
if (e === `false`) return !1;
|
|
63516
|
+
throw new p(`invalid_value`, `${n} expects true or false, got ${JSON.stringify(t)}`);
|
|
63517
|
+
}
|
|
63518
|
+
}
|
|
63519
|
+
}
|
|
63520
|
+
function b(e, t, n) {
|
|
63521
|
+
for (let r of e) try {
|
|
63522
|
+
return y(r, t, n);
|
|
62555
63523
|
} catch {
|
|
62556
|
-
|
|
63524
|
+
continue;
|
|
62557
63525
|
}
|
|
63526
|
+
throw new p(`invalid_value`, `${n} expects ${e.join(` or `)}, got ${JSON.stringify(t)}`);
|
|
63527
|
+
}
|
|
63528
|
+
function x(e, t, n) {
|
|
63529
|
+
let r = e.enumValues ?? [], i = r.find((e) => (typeof e == `string` ? e : JSON.stringify(e)) === t);
|
|
63530
|
+
if (i === void 0 && !r.includes(t)) throw new p(`invalid_value`, `${n} must be one of ${r.map((e) => typeof e == `string` ? e : JSON.stringify(e)).join(`, `)}`);
|
|
63531
|
+
return i ?? t;
|
|
63532
|
+
}
|
|
63533
|
+
async function S(e, t, n) {
|
|
63534
|
+
return e.startsWith(`@@`) ? e.slice(1) : e.startsWith(`@`) ? (await v(e, t, n)).toString(`utf8`) : e;
|
|
63535
|
+
}
|
|
63536
|
+
async function C(e, t, n, r) {
|
|
63537
|
+
switch (e.kind) {
|
|
63538
|
+
case `string`: return t;
|
|
63539
|
+
case `binary`: return t.startsWith(`@@`) ? t.slice(1) : t.startsWith(`@`) ? (await v(t, r, n)).toString(`base64`) : t;
|
|
63540
|
+
case `enum`: return x(e, t, n);
|
|
63541
|
+
case `integer`:
|
|
63542
|
+
case `number`:
|
|
63543
|
+
case `boolean`: return y(e.kind, t, n);
|
|
63544
|
+
case `scalar-union`: return b(e.unionKinds ?? [`string`], t, n);
|
|
63545
|
+
case `const`: return e.constValue;
|
|
63546
|
+
case `object`:
|
|
63547
|
+
case `object-array`:
|
|
63548
|
+
case `json`: {
|
|
63549
|
+
let i = g(h(await S(t, r, n), n));
|
|
63550
|
+
if (e.kind === `object` && !m(i)) throw new p(`invalid_value`, `${n} expects a JSON object`);
|
|
63551
|
+
return i;
|
|
63552
|
+
}
|
|
63553
|
+
case `any`: {
|
|
63554
|
+
let e = await S(t, r, n);
|
|
63555
|
+
try {
|
|
63556
|
+
return g(JSON.parse(e));
|
|
63557
|
+
} catch {
|
|
63558
|
+
return e;
|
|
63559
|
+
}
|
|
63560
|
+
}
|
|
63561
|
+
case `scalar-array`:
|
|
63562
|
+
case `map`: return C(e.item ?? {
|
|
63563
|
+
...e,
|
|
63564
|
+
kind: `any`
|
|
63565
|
+
}, t, n, r);
|
|
63566
|
+
}
|
|
63567
|
+
}
|
|
63568
|
+
async function w(t, r, i) {
|
|
63569
|
+
let a = `--${t.flag}`, o = t.field;
|
|
63570
|
+
if (o.kind === `scalar-array`) {
|
|
63571
|
+
let e = o.item ?? o, t = [];
|
|
63572
|
+
for (let n of r) if (r.length === 1 && n.trimStart().startsWith(`[`)) {
|
|
63573
|
+
let r = h(n, a);
|
|
63574
|
+
if (!Array.isArray(r)) throw new p(`invalid_value`, `${a} expects a JSON array`);
|
|
63575
|
+
for (let n of r) t.push(typeof n == `string` ? await C(e, n, a, i) : n);
|
|
63576
|
+
} else t.push(await C(e, n, a, i));
|
|
63577
|
+
return t;
|
|
63578
|
+
}
|
|
63579
|
+
if (o.kind === `object-array`) {
|
|
63580
|
+
let e = [];
|
|
63581
|
+
for (let t of r) {
|
|
63582
|
+
let n = await C({
|
|
63583
|
+
...o,
|
|
63584
|
+
kind: `json`
|
|
63585
|
+
}, t, a, i);
|
|
63586
|
+
Array.isArray(n) ? e.push(...n) : e.push(n);
|
|
63587
|
+
}
|
|
63588
|
+
return e;
|
|
63589
|
+
}
|
|
63590
|
+
if (o.kind === `map`) {
|
|
63591
|
+
let t = {};
|
|
63592
|
+
for (let s of r) {
|
|
63593
|
+
let r = s.indexOf(`=`);
|
|
63594
|
+
if (r <= 0) throw new p(`invalid_value`, `${a} expects key=value`);
|
|
63595
|
+
let c = s.slice(0, r);
|
|
63596
|
+
if (Object.prototype.hasOwnProperty.call(t, c)) throw new n$2(`usage`, `${a} sets ${c} more than once`);
|
|
63597
|
+
O$1(t, c, await C(o.item ?? o, s.slice(r + 1), `${a} ${c}`, i));
|
|
63598
|
+
}
|
|
63599
|
+
return t;
|
|
63600
|
+
}
|
|
63601
|
+
return C(o, r[0], a, i);
|
|
63602
|
+
}
|
|
63603
|
+
function T(t, n) {
|
|
63604
|
+
let r = n ? `-F` : `-f`, i = t.indexOf(`=`);
|
|
63605
|
+
if (i === -1 && /^[^[\]=]+(?:\[[^[\]]+\])*\[\]$/.test(t)) return {
|
|
63606
|
+
...T(`${t}=`, n),
|
|
63607
|
+
empty: !0
|
|
63608
|
+
};
|
|
63609
|
+
if (i <= 0) throw new n$2(`usage`, `${r} expects key=value, got ${JSON.stringify(t)}`);
|
|
63610
|
+
let a = t.slice(0, i), o = /^([^[\]]+)((?:\[[^[\]]*\])*)$/.exec(a);
|
|
63611
|
+
if (!o) throw new n$2(`usage`, `${r} key ${JSON.stringify(a)} is malformed`);
|
|
63612
|
+
let s = [o[1]], c = !1, l = [...o[2].matchAll(/\[([^[\]]*)\]/g)].map((e) => e[1]);
|
|
63613
|
+
for (let [t, n] of l.entries()) if (n === ``) {
|
|
63614
|
+
if (t !== l.length - 1) throw new n$2(`usage`, `${r} supports [] only at the end of a key`);
|
|
63615
|
+
c = !0;
|
|
63616
|
+
} else s.push(n);
|
|
63617
|
+
return {
|
|
63618
|
+
path: s,
|
|
63619
|
+
append: c,
|
|
63620
|
+
raw: t.slice(i + 1),
|
|
63621
|
+
typed: n
|
|
63622
|
+
};
|
|
63623
|
+
}
|
|
63624
|
+
async function E(e, n, r, i) {
|
|
63625
|
+
let a = `${e.typed ? `-F` : `-f`} ${e.path.join(`.`)}`;
|
|
63626
|
+
if (!e.typed || r) return e.raw;
|
|
63627
|
+
let s = w$1(n, e.append ? [...e.path, `[]`] : e.path), c = e.raw;
|
|
63628
|
+
if (c.startsWith(`@@`)) c = c.slice(1);
|
|
63629
|
+
else if (c.startsWith(`@`)) {
|
|
63630
|
+
let e = await v(c, i, a);
|
|
63631
|
+
if (s?.kind === `binary`) return e.toString(`base64`);
|
|
63632
|
+
if (c = e.toString(`utf8`), s && (s.kind === `string` || s.kind === `enum`)) return c;
|
|
63633
|
+
}
|
|
63634
|
+
if (c === `null`) return null;
|
|
63635
|
+
let l = D(c);
|
|
63636
|
+
return typeof l.value == `string` ? s?.kind === `enum` ? x(s, l.value, a) : l.value : s && (s.kind === `string` || s.kind === `binary`) ? c : s?.kind === `enum` ? x(s, c, a) : l.ok ? l.value : c;
|
|
63637
|
+
}
|
|
63638
|
+
function D(e) {
|
|
63639
|
+
try {
|
|
63640
|
+
return {
|
|
63641
|
+
ok: !0,
|
|
63642
|
+
value: g(JSON.parse(e))
|
|
63643
|
+
};
|
|
63644
|
+
} catch {
|
|
63645
|
+
return { ok: !1 };
|
|
63646
|
+
}
|
|
63647
|
+
}
|
|
63648
|
+
function O(t, r, i) {
|
|
63649
|
+
let a = t;
|
|
63650
|
+
for (let t of r.path.slice(0, -1)) {
|
|
63651
|
+
let i = Object.prototype.hasOwnProperty.call(a, t) ? a[t] : void 0;
|
|
63652
|
+
if (i === void 0) {
|
|
63653
|
+
let e = {};
|
|
63654
|
+
O$1(a, t, e), a = e;
|
|
63655
|
+
} else if (m(i)) a = i;
|
|
63656
|
+
else throw new n$2(`usage`, `-F ${r.path.join(`.`)} conflicts with a non-object value`);
|
|
63657
|
+
}
|
|
63658
|
+
let o = r.path[r.path.length - 1];
|
|
63659
|
+
if (r.append) {
|
|
63660
|
+
let t = Object.prototype.hasOwnProperty.call(a, o) ? a[o] : void 0, s = r.empty ? [] : [i];
|
|
63661
|
+
if (t === void 0) O$1(a, o, s);
|
|
63662
|
+
else if (Array.isArray(t)) t.push(...s);
|
|
63663
|
+
else throw new n$2(`usage`, `-F ${o}[] conflicts with a non-array value`);
|
|
63664
|
+
} else {
|
|
63665
|
+
if (Object.prototype.hasOwnProperty.call(a, o)) throw new n$2(`usage`, `${r.path.join(`.`)} is set more than once by -f/-F`);
|
|
63666
|
+
O$1(a, o, i);
|
|
63667
|
+
}
|
|
63668
|
+
}
|
|
63669
|
+
async function k(e, t) {
|
|
63670
|
+
let n = typeof e == `string` ? e : e.toString(`utf8`);
|
|
63671
|
+
if (n.trim() !== ``) return g(h(n, t));
|
|
63672
|
+
}
|
|
63673
|
+
function A(e, t) {
|
|
63674
|
+
if (t !== `@-`) return !1;
|
|
63675
|
+
switch (e.kind) {
|
|
63676
|
+
case `binary`:
|
|
63677
|
+
case `object`:
|
|
63678
|
+
case `object-array`:
|
|
63679
|
+
case `json`:
|
|
63680
|
+
case `any`: return !0;
|
|
63681
|
+
case `scalar-array`:
|
|
63682
|
+
case `map`: return A(e.item ?? {
|
|
63683
|
+
...e,
|
|
63684
|
+
kind: `any`
|
|
63685
|
+
}, t);
|
|
63686
|
+
default: return !1;
|
|
63687
|
+
}
|
|
63688
|
+
}
|
|
63689
|
+
function j(e, t) {
|
|
63690
|
+
let { field: n } = e;
|
|
63691
|
+
if (n.kind === `map`) return t.some((e) => e.indexOf(`=`) > 0 && A(n, e.slice(e.indexOf(`=`) + 1)));
|
|
63692
|
+
if (n.kind === `scalar-array` && t.length === 1 && t[0].trimStart().startsWith(`[`)) try {
|
|
63693
|
+
let e = JSON.parse(t[0]);
|
|
63694
|
+
return Array.isArray(e) && e.some((e) => typeof e == `string` && A(n, e));
|
|
63695
|
+
} catch {
|
|
63696
|
+
return !1;
|
|
63697
|
+
}
|
|
63698
|
+
return t.some((e) => A(n, e));
|
|
63699
|
+
}
|
|
63700
|
+
function M(e, t) {
|
|
63701
|
+
let { reserved: n } = e;
|
|
63702
|
+
if (n.input === `-` || !n.rawStrings && n.fields.some((e) => e.slice(e.indexOf(`=`) + 1) === `@-`) || e.positionals.some((e, n) => t.positionals[n] !== void 0 && A(t.positionals[n].field, e))) return !0;
|
|
63703
|
+
for (let [t, n] of e.values) if (j(t, n)) return !0;
|
|
63704
|
+
return !1;
|
|
63705
|
+
}
|
|
63706
|
+
function N(e, t) {
|
|
63707
|
+
return e.reserved.answers === `-` || M(e, t);
|
|
63708
|
+
}
|
|
63709
|
+
async function P(t, r, i) {
|
|
63710
|
+
let { reserved: a } = r;
|
|
63711
|
+
if (a.input !== void 0 && a.jsonBody !== void 0) throw new n$2(`usage`, `Use only one of --input and --json-body`);
|
|
63712
|
+
let o, s = !1;
|
|
63713
|
+
if (a.jsonBody !== void 0) o = await k(a.jsonBody, `--json-body`);
|
|
63714
|
+
else if (a.input !== void 0) o = await k(a.input === `-` ? await i.readStdin() : await v(`@${a.input}`, i, `--input`), a.input === `-` ? `stdin` : a.input);
|
|
63715
|
+
else if (!i.noInput && !N(r, t) && i.stdinIsPipedData()) {
|
|
63716
|
+
let e = await i.readStdin();
|
|
63717
|
+
e.length > 0 && (o = await k(e, `stdin`), s = o !== void 0);
|
|
63718
|
+
}
|
|
63719
|
+
let c = r.values.size > 0 || r.booleans.size > 0 || r.positionals.length > 0, l = a.fields.length > 0 || a.rawFields.length > 0;
|
|
63720
|
+
if (t.bodyOnly) {
|
|
63721
|
+
if (c || l) throw new n$2(`usage`, `${t.tool.name} takes its arguments as one JSON value`, `Use --json-body, --input <file|-> or pipe JSON on stdin`);
|
|
63722
|
+
return {
|
|
63723
|
+
args: o === void 0 ? {} : o,
|
|
63724
|
+
usedAutoStdin: s
|
|
63725
|
+
};
|
|
63726
|
+
}
|
|
63727
|
+
if (o !== void 0 && !m(o)) throw new n$2(`invalid_value`, `The arguments body must be a JSON object`);
|
|
63728
|
+
let u = o ?? {};
|
|
63729
|
+
if (l) {
|
|
63730
|
+
let e = {}, n = t.tool.inputSchema ?? {}, r = [...a.rawFields.map((e) => T(e, !1)), ...a.fields.map((e) => T(e, !0))];
|
|
63731
|
+
for (let o of r) {
|
|
63732
|
+
let r = o.path[0], s = t.byWire.has(r) ? r : t.byFlag.get(r)?.wire ?? r, c = {
|
|
63733
|
+
...o,
|
|
63734
|
+
path: [s, ...o.path.slice(1)]
|
|
63735
|
+
};
|
|
63736
|
+
O(e, c, c.empty ? void 0 : await E(c, n, a.rawStrings, i));
|
|
63737
|
+
}
|
|
63738
|
+
u = _(u, e);
|
|
63739
|
+
}
|
|
63740
|
+
let d = {};
|
|
63741
|
+
if (r.positionals.length > t.positionals.length) {
|
|
63742
|
+
let n = r.positionals.slice(t.positionals.length);
|
|
63743
|
+
throw new n$2(`usage`, `Unexpected argument${n.length > 1 ? `s` : ``}: ${n.map((e) => JSON.stringify(e)).join(` `)}`, t.positionals.length === 0 ? `Pass values as --flags; run with --help to list them` : void 0);
|
|
63744
|
+
}
|
|
63745
|
+
for (let [a, o] of r.positionals.entries()) {
|
|
63746
|
+
let s = t.positionals[a], c = r.values.get(s);
|
|
63747
|
+
if (c && c.some((e) => e !== o)) throw new n$2(`usage`, `${s.wire} was given both positionally and as --${s.flag}, with different values`);
|
|
63748
|
+
O$1(d, s.wire, await C(s.field, o, s.wire, i));
|
|
63749
|
+
}
|
|
63750
|
+
for (let [e, t] of r.values) O$1(d, e.wire, await w(e, t, i));
|
|
63751
|
+
for (let [e, t] of r.booleans) O$1(d, e.wire, t);
|
|
63752
|
+
u = _(u, d);
|
|
63753
|
+
for (let [e, r] of [...Object.entries(t.constFields), ...Object.entries(t.defaults)]) Object.prototype.hasOwnProperty.call(u, e) || O$1(u, e, structuredClone(r));
|
|
63754
|
+
let f = t.required.filter((e) => !Object.prototype.hasOwnProperty.call(u, e));
|
|
63755
|
+
if (f.length > 0) {
|
|
63756
|
+
let e = f.map((e) => {
|
|
63757
|
+
let n = t.byWire.get(e);
|
|
63758
|
+
return n?.position === void 0 ? `--${n?.flag ?? e}` : `<${n.flag}>`;
|
|
63759
|
+
});
|
|
63760
|
+
throw new p(`missing_argument`, `Missing required ${e.length > 1 ? `arguments` : `argument`}: ${e.join(`, `)}`, `Run with --help for usage`);
|
|
63761
|
+
}
|
|
63762
|
+
return {
|
|
63763
|
+
args: u,
|
|
63764
|
+
usedAutoStdin: s
|
|
63765
|
+
};
|
|
63766
|
+
}
|
|
63767
|
+
// src/lib/mcp-input.ts
|
|
63768
|
+
const SCHEMALESS = {
|
|
63769
|
+
name: "tool",
|
|
63770
|
+
inputSchema: { type: "object" }
|
|
63771
|
+
};
|
|
63772
|
+
function toMcpCliArgv(options) {
|
|
63773
|
+
return [
|
|
63774
|
+
...(options.rawField ?? []).flatMap((value) => ["-f", value]),
|
|
63775
|
+
...(options.field ?? []).flatMap((value) => ["-F", value]),
|
|
63776
|
+
...options.jsonBody !== void 0 ? ["--json-body", options.jsonBody] : [],
|
|
63777
|
+
...options.input !== void 0 ? ["--input", options.input] : []
|
|
63778
|
+
];
|
|
63779
|
+
}
|
|
63780
|
+
/** Whether resolving these arguments will consume the process stdin stream; the parser that reads it decides. */
|
|
63781
|
+
function usesMcpStdin(options) {
|
|
63782
|
+
const spec = D$1(SCHEMALESS);
|
|
63783
|
+
try {
|
|
63784
|
+
return N(ae(toMcpCliArgv(options), spec), spec);
|
|
63785
|
+
} catch {
|
|
63786
|
+
return false;
|
|
63787
|
+
}
|
|
63788
|
+
}
|
|
63789
|
+
/** `-F` is the only input whose meaning depends on the tool's schema. */
|
|
63790
|
+
function needsMcpToolSchema(options) {
|
|
63791
|
+
return (options.field ?? []).length > 0;
|
|
63792
|
+
}
|
|
63793
|
+
async function readStream(stream) {
|
|
63794
|
+
const chunks = [];
|
|
63795
|
+
for await (const chunk of stream) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
63796
|
+
return Buffer.concat(chunks);
|
|
62558
63797
|
}
|
|
62559
|
-
/**
|
|
63798
|
+
/**
|
|
63799
|
+
* Builds tools/call arguments with the `@runtypelabs/mcp-cli` input layer: `--input`/`--json-body`,
|
|
63800
|
+
* then `-f`/`-F` deep-merged over it. Given the tool, `-F id=123` stays a string for a string field.
|
|
63801
|
+
*/
|
|
62560
63802
|
async function resolveMcpArguments(options, dependencies = {}) {
|
|
62561
63803
|
let stdinPromise;
|
|
62562
63804
|
const deps = {
|
|
62563
|
-
readFile,
|
|
63805
|
+
readFile: (path) => readFile(path),
|
|
62564
63806
|
readStdin: () => {
|
|
62565
63807
|
stdinPromise ??= readStream(process.stdin);
|
|
62566
63808
|
return stdinPromise;
|
|
62567
63809
|
},
|
|
62568
63810
|
...dependencies
|
|
62569
63811
|
};
|
|
62570
|
-
const
|
|
62571
|
-
const
|
|
62572
|
-
|
|
62573
|
-
|
|
62574
|
-
|
|
62575
|
-
|
|
62576
|
-
|
|
62577
|
-
|
|
62578
|
-
|
|
62579
|
-
|
|
62580
|
-
|
|
62581
|
-
|
|
62582
|
-
|
|
62583
|
-
Object.defineProperty(result, key, {
|
|
62584
|
-
value,
|
|
62585
|
-
enumerable: true,
|
|
62586
|
-
configurable: true,
|
|
62587
|
-
writable: true
|
|
62588
|
-
});
|
|
62589
|
-
};
|
|
62590
|
-
for (const rawField of rawFields) {
|
|
62591
|
-
const [key, value] = splitField(rawField, "-f");
|
|
62592
|
-
setField(key, value);
|
|
62593
|
-
}
|
|
62594
|
-
for (const typedField of typedFields) {
|
|
62595
|
-
const [key, rawValue] = splitField(typedField, "-F");
|
|
62596
|
-
if (rawValue.startsWith("@")) {
|
|
62597
|
-
const path = rawValue.slice(1);
|
|
62598
|
-
if (!path) throw new Error("-F file references require @<path> or @-");
|
|
62599
|
-
setField(key, parseTypedValue(path === "-" ? await deps.readStdin() : await deps.readFile(path, "utf8")));
|
|
62600
|
-
} else setField(key, parseTypedValue(rawValue));
|
|
62601
|
-
}
|
|
62602
|
-
return result;
|
|
63812
|
+
const toolSpec = D$1(deps.tool ?? SCHEMALESS);
|
|
63813
|
+
const spec = toolSpec.bodyOnly ? D$1(SCHEMALESS) : {
|
|
63814
|
+
...toolSpec,
|
|
63815
|
+
required: [],
|
|
63816
|
+
positionals: []
|
|
63817
|
+
};
|
|
63818
|
+
const { args } = await P(spec, ae(toMcpCliArgv(options), spec), {
|
|
63819
|
+
readFile: deps.readFile,
|
|
63820
|
+
readStdin: deps.readStdin,
|
|
63821
|
+
stdinIsPipedData: () => false,
|
|
63822
|
+
noInput: true
|
|
63823
|
+
});
|
|
63824
|
+
return args;
|
|
62603
63825
|
}
|
|
62604
63826
|
// src/commands/mcp.ts
|
|
62605
63827
|
const defaultDependencies$1 = {
|
|
62606
63828
|
ensureAuth,
|
|
62607
63829
|
connect: connectMcpClient,
|
|
62608
|
-
resolveArguments: resolveMcpArguments,
|
|
63830
|
+
resolveArguments: (options, tool) => resolveMcpArguments(options, { tool }),
|
|
62609
63831
|
setExitCode: (code) => {
|
|
62610
63832
|
process.exitCode = code;
|
|
62611
63833
|
}
|
|
62612
63834
|
};
|
|
62613
63835
|
const DEFAULT_TOOL_TIMEOUT_MS = 93e4;
|
|
63836
|
+
const TOOL_SCHEMA_LOOKUP_TIMEOUT_MS = 1e4;
|
|
63837
|
+
/** Listing for `-F` must not make the SDK enforce `outputSchema`, which a call without `-F` never does. */
|
|
63838
|
+
function withoutOutputSchema(tool) {
|
|
63839
|
+
const { outputSchema: _outputSchema, ...definition } = tool;
|
|
63840
|
+
return definition;
|
|
63841
|
+
}
|
|
62614
63842
|
function collectField(value, previous) {
|
|
62615
63843
|
return previous.concat(value);
|
|
62616
63844
|
}
|
|
@@ -62649,10 +63877,11 @@ function printTools(tools, target) {
|
|
|
62649
63877
|
}
|
|
62650
63878
|
const label = target === "code" ? "Code Mode MCP Tools" : "MCP Tools";
|
|
62651
63879
|
console.log(chalk.cyan(`${label}:`));
|
|
62652
|
-
|
|
62653
|
-
|
|
62654
|
-
|
|
62655
|
-
}
|
|
63880
|
+
const rows = $(l(tools), true).map((row) => ({
|
|
63881
|
+
...row,
|
|
63882
|
+
command: row.tool
|
|
63883
|
+
}));
|
|
63884
|
+
process.stdout.write(de(rows));
|
|
62656
63885
|
console.log(chalk.dim(`\n Total: ${tools.length} tools`));
|
|
62657
63886
|
}
|
|
62658
63887
|
function printTool(tool) {
|
|
@@ -62669,6 +63898,14 @@ function printTool(tool) {
|
|
|
62669
63898
|
label: "Description",
|
|
62670
63899
|
value: tool.description
|
|
62671
63900
|
},
|
|
63901
|
+
{
|
|
63902
|
+
label: "Signature",
|
|
63903
|
+
value: W(tool)
|
|
63904
|
+
},
|
|
63905
|
+
{
|
|
63906
|
+
label: "Hints",
|
|
63907
|
+
value: B(tool).join(", ") || void 0
|
|
63908
|
+
},
|
|
62672
63909
|
{
|
|
62673
63910
|
label: "Input Schema",
|
|
62674
63911
|
value: tool.inputSchema
|
|
@@ -62692,12 +63929,10 @@ function printCallResult(result, json) {
|
|
|
62692
63929
|
printJson(result);
|
|
62693
63930
|
return;
|
|
62694
63931
|
}
|
|
62695
|
-
|
|
62696
|
-
|
|
62697
|
-
|
|
62698
|
-
|
|
62699
|
-
if (result.content.length > 0 && result.content.every((block) => block.type === "text")) {
|
|
62700
|
-
console.log(result.content.map((block) => block.text).join("\n"));
|
|
63932
|
+
const textOnly = result.content.length > 0 && result.content.every((block) => block.type === "text");
|
|
63933
|
+
if (result.structuredContent !== void 0 || textOnly) {
|
|
63934
|
+
const mode = e(void 0, { stdoutIsTTY: process.stdout.isTTY === true });
|
|
63935
|
+
console.log(h$2(result, { mode }));
|
|
62701
63936
|
return;
|
|
62702
63937
|
}
|
|
62703
63938
|
printJson(result);
|
|
@@ -62736,11 +63971,15 @@ function createMcpCommand(overrides = {}) {
|
|
|
62736
63971
|
addCommonOptions(command.command("call <name>").description("Call any MCP tool by name without local registration").option("-f, --raw-field <key=value>", "Add a string argument", collectField, []).option("-F, --field <key=value>", "Add a JSON-typed argument; use @<path> or @- to read its value", collectField, []).option("--json-body <json>", "Use an inline JSON object as the tool arguments").option("--input <file>", "Read the tool arguments JSON object from a file or - for stdin").option("--timeout <ms>", "Maximum time to wait for the tool result in milliseconds", parsePositiveInteger, DEFAULT_TOOL_TIMEOUT_MS)).action(async (name, options) => {
|
|
62737
63972
|
try {
|
|
62738
63973
|
await withMcpClient(options, dependencies, async (client) => {
|
|
62739
|
-
const
|
|
63974
|
+
const tool = needsMcpToolSchema(options) ? (await listAllMcpTools(client, { timeout: TOOL_SCHEMA_LOOKUP_TIMEOUT_MS }).catch(() => [])).find((item) => item.name === name) : void 0;
|
|
63975
|
+
const args = await dependencies.resolveArguments(options, tool);
|
|
62740
63976
|
const result = await client.callTool({
|
|
62741
63977
|
name,
|
|
62742
63978
|
arguments: args
|
|
62743
|
-
}, {
|
|
63979
|
+
}, {
|
|
63980
|
+
timeout: options.timeout,
|
|
63981
|
+
...tool ? { toolDefinition: withoutOutputSchema(tool) } : {}
|
|
63982
|
+
});
|
|
62744
63983
|
if (!("content" in result) || !Array.isArray(result.content)) throw new Error("Task-augmented MCP tool results are not supported by this command");
|
|
62745
63984
|
const callResult = result;
|
|
62746
63985
|
printCallResult(callResult, options.json);
|
|
@@ -69193,7 +70432,7 @@ const productKindSchema = _enum([
|
|
|
69193
70432
|
"external",
|
|
69194
70433
|
"spec_only"
|
|
69195
70434
|
]);
|
|
69196
|
-
// ../shared/dist/chunk-
|
|
70435
|
+
// ../shared/dist/chunk-CLmUyAjf.mjs
|
|
69197
70436
|
const amount = number$2().finite().nonnegative();
|
|
69198
70437
|
const tokens = amount.int();
|
|
69199
70438
|
/** Producer estimates for one turn, independent of Runtype's measured usage and billing. */
|
|
@@ -70989,6 +72228,10 @@ const toolDesignViewSchema = object$4({
|
|
|
70989
72228
|
chosenWrongly: number$2().int(),
|
|
70990
72229
|
/** Episodes with a wrong choice of this tool; absent on reports built before it was counted. */
|
|
70991
72230
|
chosenWronglyEpisodes: number$2().int().optional(),
|
|
72231
|
+
/** Calls naming this tool, including ones the proxy refused; absent on reports built before it was counted. */
|
|
72232
|
+
calls: number$2().int().optional(),
|
|
72233
|
+
/** Of those, the calls rejected for their arguments. */
|
|
72234
|
+
invalidArgumentCalls: number$2().int().optional(),
|
|
70992
72235
|
confusedWith: array(object$4({
|
|
70993
72236
|
tool: string$2(),
|
|
70994
72237
|
count: number$2().int()
|
|
@@ -71025,7 +72268,9 @@ const toolDesignViewSchema = object$4({
|
|
|
71025
72268
|
]),
|
|
71026
72269
|
times: number$2().int(),
|
|
71027
72270
|
episodes: number$2().int(),
|
|
71028
|
-
recoveredEpisodes: number$2().int()
|
|
72271
|
+
recoveredEpisodes: number$2().int(),
|
|
72272
|
+
/** The conversations that hit it; absent on reports built before they were listed. */
|
|
72273
|
+
episodeIds: array(string$2()).optional()
|
|
71029
72274
|
})),
|
|
71030
72275
|
wrongChoicesByClient: array(object$4({
|
|
71031
72276
|
clientModel: string$2(),
|
|
@@ -71051,8 +72296,14 @@ const overlayVerdictSchema = object$4({
|
|
|
71051
72296
|
passRateDifference: estimateIntervalSchema.nullable(),
|
|
71052
72297
|
verdict: simulationVerdictSchema,
|
|
71053
72298
|
hint: string$2().nullable(),
|
|
71054
|
-
/** The best overlay
|
|
71055
|
-
recommended: boolean()
|
|
72299
|
+
/** The best `better` overlay whose result stands on real answers, as the investment card judges; at most one. */
|
|
72300
|
+
recommended: boolean(),
|
|
72301
|
+
/** Injection and write-guard checks its own conversations failed; absent when none. Never recommended then. */
|
|
72302
|
+
safetyFailures: number$2().int().positive().optional(),
|
|
72303
|
+
/** Permission leaks on the targets its variants ran against, each target counted once; absent when none. */
|
|
72304
|
+
permissionLeaks: number$2().int().positive().optional(),
|
|
72305
|
+
/** Answers that weren't real decided the pairs that separate it, so its win doesn't hold without them. */
|
|
72306
|
+
heldBySynthesis: literal(true).optional()
|
|
71056
72307
|
});
|
|
71057
72308
|
/** The tool design view ("Agent experience", "The tool design view"); additive, so older reports render without it. */
|
|
71058
72309
|
const toolDesignSectionSchema = toolDesignViewSchema.extend({
|
|
@@ -71069,6 +72320,30 @@ const toolDesignSectionSchema = toolDesignViewSchema.extend({
|
|
|
71069
72320
|
overlays: array(overlayVerdictSchema).optional(),
|
|
71070
72321
|
/** Age in days of the oldest recorded answer the run replayed, as of its exchange cutoff; absent with no replay. */
|
|
71071
72322
|
recordedAnswerAgeDays: number$2().nonnegative().nullable().optional(),
|
|
72323
|
+
/** One row per scored conversation, for the "How each agent did" grid; absent on reports built before it. */
|
|
72324
|
+
conversations: array(object$4({
|
|
72325
|
+
episodeId: string$2(),
|
|
72326
|
+
variantId: string$2(),
|
|
72327
|
+
taskId: string$2().nullable(),
|
|
72328
|
+
clientModel: string$2(),
|
|
72329
|
+
trial: number$2().int().nonnegative(),
|
|
72330
|
+
outcome: _enum([
|
|
72331
|
+
"done",
|
|
72332
|
+
"doneAfterError",
|
|
72333
|
+
"wrongTool",
|
|
72334
|
+
"invalidArguments",
|
|
72335
|
+
"stuckOnError",
|
|
72336
|
+
"gaveUp"
|
|
72337
|
+
]),
|
|
72338
|
+
/** The tool the outcome is about: the one that errored, or the one picked wrongly. */
|
|
72339
|
+
tool: string$2().optional(),
|
|
72340
|
+
/** For a wrong tool: the tool the task needed. */
|
|
72341
|
+
intendedTool: string$2().optional(),
|
|
72342
|
+
/** For invalid arguments: the first argument path the server rejected. */
|
|
72343
|
+
argumentPath: string$2().optional(),
|
|
72344
|
+
/** For an error: its key in `errors`. */
|
|
72345
|
+
errorKey: string$2().optional()
|
|
72346
|
+
})).optional(),
|
|
71072
72347
|
/** Per tool: synthesized answers, contract failures, and how reviewers judged the frozen answers (D5). */
|
|
71073
72348
|
synthesis: array(object$4({
|
|
71074
72349
|
tool: string$2(),
|
|
@@ -71178,6 +72453,10 @@ const investmentSectionSchema = object$4({
|
|
|
71178
72453
|
clientModelStallPairsDropped: number$2().int().positive().optional(),
|
|
71179
72454
|
headline: _enum(["recommended", "indicative"]),
|
|
71180
72455
|
reason: string$2().nullable(),
|
|
72456
|
+
/** Injection and write-guard checks the design's own conversations failed; absent when none. Never recommended then. */
|
|
72457
|
+
safetyFailures: number$2().int().positive().optional(),
|
|
72458
|
+
/** Permission leaks on the targets its variants ran against, each target counted once; never recommended then. */
|
|
72459
|
+
permissionLeaks: number$2().int().positive().optional(),
|
|
71181
72460
|
success: object$4({
|
|
71182
72461
|
baseline: number$2(),
|
|
71183
72462
|
candidate: number$2(),
|