@runtypelabs/cli 2.56.7 → 2.57.1
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 +1568 -237
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
56
56
|
return target;
|
|
57
57
|
};
|
|
58
58
|
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
59
|
-
// ../shared/dist/chunk-
|
|
59
|
+
// ../shared/dist/chunk-7fm07YIO.mjs
|
|
60
60
|
/**
|
|
61
61
|
* Every product surface type the platform stores and serves. The single source for the FPO surface
|
|
62
62
|
* enum, the REST create and ensure schemas, and the shared `SurfaceType`; add a new type here only.
|
|
@@ -65,6 +65,7 @@ const PRODUCT_SURFACE_TYPES = [
|
|
|
65
65
|
"chat",
|
|
66
66
|
"mcp",
|
|
67
67
|
"mcp_code",
|
|
68
|
+
"cli",
|
|
68
69
|
"api",
|
|
69
70
|
"webhook",
|
|
70
71
|
"schedule",
|
|
@@ -110,7 +111,7 @@ function mergeResults(...results) {
|
|
|
110
111
|
merged.valid = merged.errors.length === 0;
|
|
111
112
|
return merged;
|
|
112
113
|
}
|
|
113
|
-
// ../shared/dist/chunk-
|
|
114
|
+
// ../shared/dist/chunk-BbTDzQd7.mjs
|
|
114
115
|
/** Names every key of `T` exactly once, so a new credential field fails the build. */
|
|
115
116
|
function credentialKeysOf(presence) {
|
|
116
117
|
return Object.keys(presence);
|
|
@@ -122,7 +123,8 @@ const SURFACE_INBOUND_CREDENTIAL_KEYS = credentialKeysOf({
|
|
|
122
123
|
secret: true,
|
|
123
124
|
publicKey: true,
|
|
124
125
|
authToken: true,
|
|
125
|
-
twilioAuthToken: true
|
|
126
|
+
twilioAuthToken: true,
|
|
127
|
+
identityClientSecret: true
|
|
126
128
|
});
|
|
127
129
|
const SURFACE_OUTBOUND_CREDENTIAL_KEYS = credentialKeysOf({
|
|
128
130
|
botToken: true,
|
|
@@ -135,7 +137,16 @@ const SURFACE_OUTBOUND_CREDENTIAL_KEYS = credentialKeysOf({
|
|
|
135
137
|
smtpPassword: true
|
|
136
138
|
});
|
|
137
139
|
[.../* @__PURE__ */ new Set([...SURFACE_INBOUND_CREDENTIAL_KEYS, ...SURFACE_OUTBOUND_CREDENTIAL_KEYS])];
|
|
138
|
-
|
|
140
|
+
const OFFERS_OAUTH = {
|
|
141
|
+
keys_only: false,
|
|
142
|
+
consent: true,
|
|
143
|
+
required: true,
|
|
144
|
+
none: false
|
|
145
|
+
};
|
|
146
|
+
/** Every `authMode` a surface can store. Any other stored value reads as unset. */
|
|
147
|
+
const SURFACE_AUTH_MODES = Object.keys(OFFERS_OAUTH);
|
|
148
|
+
new Set(SURFACE_AUTH_MODES.filter((mode) => OFFERS_OAUTH[mode]));
|
|
149
|
+
// ../shared/dist/chunk-DRY4gGEy.mjs
|
|
139
150
|
/** Every evaluation model the gateway lists, keyed by the gateway id a call names. */
|
|
140
151
|
const GATEWAY_EVALUATION_MODELS = Object.freeze({
|
|
141
152
|
"baseten/elephant-1": Object.freeze({
|
|
@@ -242,6 +253,14 @@ const GATEWAY_EVALUATION_MODELS = Object.freeze({
|
|
|
242
253
|
outputPer1MTokens: 0
|
|
243
254
|
})
|
|
244
255
|
}),
|
|
256
|
+
"parallel/parallel-decisions-fast": Object.freeze({
|
|
257
|
+
id: "parallel/parallel-decisions-fast",
|
|
258
|
+
name: "Decisions Fast",
|
|
259
|
+
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.",
|
|
260
|
+
contextWindow: 32e3,
|
|
261
|
+
supportedSpecifications: Object.freeze(["v4"]),
|
|
262
|
+
pricing: null
|
|
263
|
+
}),
|
|
245
264
|
"perplexity/pplx-decider-flash-v1.2": Object.freeze({
|
|
246
265
|
id: "perplexity/pplx-decider-flash-v1.2",
|
|
247
266
|
name: "Decider Flash V1.2 4B",
|
|
@@ -335,7 +354,7 @@ const gatewayModels = Object.values(GATEWAY_EVALUATION_MODELS).map((model) => Ob
|
|
|
335
354
|
minChoiceOptions: 1,
|
|
336
355
|
maxChoiceOptions: 255,
|
|
337
356
|
maxScoreLevels: 10,
|
|
338
|
-
maxQuestions: null,
|
|
357
|
+
maxQuestions: model.id === "parallel/parallel-decisions-fast" ? 100 : null,
|
|
339
358
|
platformFunding: model.pricing !== null,
|
|
340
359
|
docsUrl: "https://vercel.com/docs/ai-gateway"
|
|
341
360
|
}));
|
|
@@ -6471,7 +6490,7 @@ function date(params) {
|
|
|
6471
6490
|
function number$1(params) {
|
|
6472
6491
|
return /* @__PURE__ */ _coercedNumber(ZodNumber, params);
|
|
6473
6492
|
}
|
|
6474
|
-
// ../shared/dist/chunk-
|
|
6493
|
+
// ../shared/dist/chunk-CLhUpXeh.mjs
|
|
6475
6494
|
const judgmentJsonValueSchema = lazy(() => union([
|
|
6476
6495
|
_null(),
|
|
6477
6496
|
string$2(),
|
|
@@ -7127,12 +7146,14 @@ function resolveFallback(parsed, context, tracking, options = {}) {
|
|
|
7127
7146
|
return tracking.match;
|
|
7128
7147
|
}
|
|
7129
7148
|
new SimpleTemplateEngine();
|
|
7130
|
-
// ../shared/dist/chunk-
|
|
7149
|
+
// ../shared/dist/chunk-CYZSyWdd.mjs
|
|
7131
7150
|
/**
|
|
7132
7151
|
* Maps model families to provider-specific model IDs.
|
|
7133
7152
|
* Use for routing: family + provider → exact model ID
|
|
7134
7153
|
*/
|
|
7135
7154
|
const MODEL_FAMILY_PROVIDER_IDS = {
|
|
7155
|
+
"ampersand-v0-1": { "vercel": "humansand/ampersand-v0.1" },
|
|
7156
|
+
"ampersand-v0.1": { "vercel": "humansand/ampersand-v0.1" },
|
|
7136
7157
|
"apex": { "vercel": "callstack/apex" },
|
|
7137
7158
|
"arrow-2": { "vercel": "quiverai/arrow-2" },
|
|
7138
7159
|
"arrow-2-telos": { "vercel": "quiverai/arrow-2-telos" },
|
|
@@ -7147,9 +7168,13 @@ const MODEL_FAMILY_PROVIDER_IDS = {
|
|
|
7147
7168
|
"vercel": "anthropic/claude-fable-5.1"
|
|
7148
7169
|
},
|
|
7149
7170
|
"claude-fable-5-1-batch": { "vercel": "anthropic/claude-fable-5.1-batch" },
|
|
7171
|
+
"claude-fable-5-2": { "vercel": "anthropic/claude-fable-5.2" },
|
|
7172
|
+
"claude-fable-5-2-batch": { "vercel": "anthropic/claude-fable-5.2-batch" },
|
|
7150
7173
|
"claude-fable-5-batch": { "vercel": "anthropic/claude-fable-5-batch" },
|
|
7151
7174
|
"claude-fable-5.1": { "vercel": "anthropic/claude-fable-5.1" },
|
|
7152
7175
|
"claude-fable-5.1-batch": { "vercel": "anthropic/claude-fable-5.1-batch" },
|
|
7176
|
+
"claude-fable-5.2": { "vercel": "anthropic/claude-fable-5.2" },
|
|
7177
|
+
"claude-fable-5.2-batch": { "vercel": "anthropic/claude-fable-5.2-batch" },
|
|
7153
7178
|
"claude-haiku-4-5": {
|
|
7154
7179
|
"anthropic": "claude-haiku-4-5-20251001",
|
|
7155
7180
|
"vercel": "anthropic/claude-haiku-4.5"
|
|
@@ -7245,6 +7270,7 @@ const MODEL_FAMILY_PROVIDER_IDS = {
|
|
|
7245
7270
|
"deepseek-v4-1-flash": { "mixlayer": "deepseek/deepseek-v4.1-flash" },
|
|
7246
7271
|
"deepseek-v4-1-flash-1017": { "vercel": "deepseek/deepseek-v4.1-flash-1017" },
|
|
7247
7272
|
"deepseek-v4-1-flash-1017-fast": { "vercel": "deepseek/deepseek-v4.1-flash-1017-fast" },
|
|
7273
|
+
"deepseek-v4-1-flash-1017-ultrafast": { "vercel": "deepseek/deepseek-v4.1-flash-1017-ultrafast" },
|
|
7248
7274
|
"deepseek-v4-1-flash-fast": { "vercel": "deepseek/deepseek-v4.1-flash-fast" },
|
|
7249
7275
|
"deepseek-v4-flash": { "vercel": "deepseek/deepseek-v4-flash" },
|
|
7250
7276
|
"deepseek-v4-flash-0731": { "vercel": "deepseek/deepseek-v4-flash-0731" },
|
|
@@ -7254,6 +7280,7 @@ const MODEL_FAMILY_PROVIDER_IDS = {
|
|
|
7254
7280
|
"deepseek-v4.1-flash": { "mixlayer": "deepseek/deepseek-v4.1-flash" },
|
|
7255
7281
|
"deepseek-v4.1-flash-1017": { "vercel": "deepseek/deepseek-v4.1-flash-1017" },
|
|
7256
7282
|
"deepseek-v4.1-flash-1017-fast": { "vercel": "deepseek/deepseek-v4.1-flash-1017-fast" },
|
|
7283
|
+
"deepseek-v4.1-flash-1017-ultrafast": { "vercel": "deepseek/deepseek-v4.1-flash-1017-ultrafast" },
|
|
7257
7284
|
"deepseek-v4.1-flash-fast": { "vercel": "deepseek/deepseek-v4.1-flash-fast" },
|
|
7258
7285
|
"ember-1": { "vercel": "fireworks/ember-1" },
|
|
7259
7286
|
"fugu-max": { "vercel": "sakana/fugu-max" },
|
|
@@ -7827,6 +7854,7 @@ const MODEL_FAMILY_PROVIDER_IDS = {
|
|
|
7827
7854
|
"mistral-small": { "vercel": "mistral/mistral-small" },
|
|
7828
7855
|
"morph-v3-fast": { "vercel": "morph/morph-v3-fast" },
|
|
7829
7856
|
"morph-v3-large": { "vercel": "morph/morph-v3-large" },
|
|
7857
|
+
"muse-ember": { "vercel": "meta/muse-ember" },
|
|
7830
7858
|
"muse-glimmer-30b": { "vercel": "meta/muse-glimmer-30b" },
|
|
7831
7859
|
"muse-spark-1-1": { "vercel": "meta/muse-spark-1.1" },
|
|
7832
7860
|
"muse-spark-1-2": { "vercel": "meta/muse-spark-1.2" },
|
|
@@ -8224,7 +8252,7 @@ const CREATOR_TO_PROVIDER = {
|
|
|
8224
8252
|
"unknown": "openai"
|
|
8225
8253
|
};
|
|
8226
8254
|
new RegExp(`^${/Model stream stalled \((awaiting_first_token|idle|empty_completion)\) after \d+ms with no progress/.source}`);
|
|
8227
|
-
// ../shared/dist/chunk-
|
|
8255
|
+
// ../shared/dist/chunk-F1-FFFE7.mjs
|
|
8228
8256
|
/**
|
|
8229
8257
|
* Unwraps a single {{variableName}} template to its bare variable name, preserving array/object identity instead of stringifying via the template engine.
|
|
8230
8258
|
* Returns source unchanged when it is not a lone {{...}} wrapper.
|
|
@@ -12647,7 +12675,7 @@ object$4({
|
|
|
12647
12675
|
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
12676
|
importedAt: string$2().datetime({ offset: true }).optional()
|
|
12649
12677
|
});
|
|
12650
|
-
// ../shared/dist/chunk-
|
|
12678
|
+
// ../shared/dist/chunk-Dkn7TqhO.mjs
|
|
12651
12679
|
const voiceInterruptionModeSchema = _enum([
|
|
12652
12680
|
"none",
|
|
12653
12681
|
"cancel",
|
|
@@ -26264,12 +26292,13 @@ function loadBrandConfig(env) {
|
|
|
26264
26292
|
}
|
|
26265
26293
|
loadBrandConfig();
|
|
26266
26294
|
BRAND_CONFIGS[DEFAULT_BRAND_NAME];
|
|
26267
|
-
// ../shared/dist/chunk-
|
|
26295
|
+
// ../shared/dist/chunk-DV7xJaYR.mjs
|
|
26268
26296
|
const ARCHITECTURE_PREVIEW_SURFACE_TYPES = [
|
|
26269
26297
|
"chat",
|
|
26270
26298
|
"api",
|
|
26271
26299
|
"mcp",
|
|
26272
26300
|
"mcp_code",
|
|
26301
|
+
"cli",
|
|
26273
26302
|
"webhook",
|
|
26274
26303
|
"schedule",
|
|
26275
26304
|
"a2a",
|
|
@@ -27735,7 +27764,14 @@ object$4({
|
|
|
27735
27764
|
simulationsAvailable: boolean().optional(),
|
|
27736
27765
|
enableDelegateToRuntype: boolean().optional(),
|
|
27737
27766
|
enableDelegateToOtto: boolean().optional(),
|
|
27738
|
-
signalsConfigured: boolean().optional()
|
|
27767
|
+
signalsConfigured: boolean().optional(),
|
|
27768
|
+
enableCliSurface: boolean().optional(),
|
|
27769
|
+
enableCliSurfacePublish: boolean().optional(),
|
|
27770
|
+
enableCliSurfaceGraduation: boolean().optional(),
|
|
27771
|
+
enableMcpSurfaceSignIn: boolean().optional(),
|
|
27772
|
+
enableMcpSurfaceDeviceGrant: boolean().optional(),
|
|
27773
|
+
enableMcpSurfaceOobApprovals: boolean().optional(),
|
|
27774
|
+
enableMcpSurfaceCustomerIdp: boolean().optional()
|
|
27739
27775
|
});
|
|
27740
27776
|
const SLACK_REQUIRED_BOT_SCOPES = [
|
|
27741
27777
|
"channels:history",
|
|
@@ -29600,27 +29636,57 @@ function loadKeyring() {
|
|
|
29600
29636
|
keyringModule ??= import("@napi-rs/keyring").then((mod) => mod.AsyncEntry).catch(() => null);
|
|
29601
29637
|
return keyringModule;
|
|
29602
29638
|
}
|
|
29639
|
+
/**
|
|
29640
|
+
* The OS keychain. On Linux every entry is pinned to the Secret Service: unpinned, the binding falls
|
|
29641
|
+
* back silently to the kernel keyring, which loses the login at reboot. Without a Secret Service the
|
|
29642
|
+
* write throws and the account store falls back to the file.
|
|
29643
|
+
*/
|
|
29603
29644
|
var KeychainSecretBackend = class {
|
|
29604
29645
|
kind = "keychain";
|
|
29605
|
-
|
|
29606
|
-
|
|
29646
|
+
platform;
|
|
29647
|
+
loadEntry;
|
|
29648
|
+
constructor(options = {}) {
|
|
29649
|
+
this.platform = options.platform ?? process.platform;
|
|
29650
|
+
this.loadEntry = options.loadEntry ?? loadKeyring;
|
|
29651
|
+
}
|
|
29652
|
+
async entry(name, pinned = true) {
|
|
29653
|
+
const AsyncEntry = await this.loadEntry();
|
|
29607
29654
|
if (!AsyncEntry) throw new Error("OS keychain is not available on this platform.");
|
|
29655
|
+
if (pinned && this.platform === "linux") return new AsyncEntry(KEYCHAIN_SERVICE, name, { linux: { store: "secret-service" } });
|
|
29608
29656
|
return new AsyncEntry(KEYCHAIN_SERVICE, name);
|
|
29609
29657
|
}
|
|
29658
|
+
/** A login written by a version that did not pin the store may sit in the kernel keyring until reboot. */
|
|
29659
|
+
async legacyLinuxGet(name) {
|
|
29660
|
+
if (this.platform !== "linux") return null;
|
|
29661
|
+
try {
|
|
29662
|
+
return await (await this.entry(name, false)).getPassword() ?? null;
|
|
29663
|
+
} catch {
|
|
29664
|
+
return null;
|
|
29665
|
+
}
|
|
29666
|
+
}
|
|
29610
29667
|
async get(name) {
|
|
29611
|
-
|
|
29668
|
+
try {
|
|
29669
|
+
return await (await this.entry(name)).getPassword() ?? await this.legacyLinuxGet(name);
|
|
29670
|
+
} catch (error) {
|
|
29671
|
+
const legacy = await this.legacyLinuxGet(name);
|
|
29672
|
+
if (legacy !== null) return legacy;
|
|
29673
|
+
throw error;
|
|
29674
|
+
}
|
|
29612
29675
|
}
|
|
29613
29676
|
async set(name, value) {
|
|
29614
29677
|
await (await this.entry(name)).setPassword(value);
|
|
29615
29678
|
}
|
|
29616
29679
|
async delete(name) {
|
|
29680
|
+
if (this.platform === "linux") await (await this.entry(name, false)).deleteCredential().catch(() => false);
|
|
29617
29681
|
await (await this.entry(name)).deleteCredential();
|
|
29618
29682
|
}
|
|
29619
29683
|
};
|
|
29684
|
+
const PLAIN_PREFIX = "plain:";
|
|
29620
29685
|
/**
|
|
29621
|
-
* Fallback for hosts with no usable OS keychain (headless Linux, containers, CI)
|
|
29622
|
-
*
|
|
29623
|
-
*
|
|
29686
|
+
* Fallback for hosts with no usable OS keychain (headless Linux, containers, CI): plaintext in a 0600
|
|
29687
|
+
* file inside a 0700 directory, as gh and wrangler store tokens. Values from older versions were
|
|
29688
|
+
* encrypted with a hostname-derived key, which a new container hostname breaks; they are still read
|
|
29689
|
+
* when that key matches, and the next write stores them as plaintext.
|
|
29624
29690
|
*/
|
|
29625
29691
|
var FileSecretBackend = class {
|
|
29626
29692
|
filePath;
|
|
@@ -29629,25 +29695,44 @@ var FileSecretBackend = class {
|
|
|
29629
29695
|
this.filePath = filePath;
|
|
29630
29696
|
}
|
|
29631
29697
|
async get(name) {
|
|
29632
|
-
const
|
|
29633
|
-
|
|
29698
|
+
const secrets = this.read();
|
|
29699
|
+
const stored = Object.prototype.hasOwnProperty.call(secrets, name) ? secrets[name] : void 0;
|
|
29700
|
+
if (typeof stored !== "string" || stored === "") return null;
|
|
29701
|
+
if (stored.startsWith(PLAIN_PREFIX)) return stored.slice(6);
|
|
29702
|
+
try {
|
|
29703
|
+
return decryptWithMachineKey(stored);
|
|
29704
|
+
} catch {
|
|
29705
|
+
return null;
|
|
29706
|
+
}
|
|
29634
29707
|
}
|
|
29635
29708
|
async set(name, value) {
|
|
29636
|
-
this.
|
|
29637
|
-
|
|
29638
|
-
|
|
29709
|
+
const secrets = this.read();
|
|
29710
|
+
Object.defineProperty(secrets, name, {
|
|
29711
|
+
value: `${PLAIN_PREFIX}${value}`,
|
|
29712
|
+
enumerable: true,
|
|
29713
|
+
configurable: true,
|
|
29714
|
+
writable: true
|
|
29639
29715
|
});
|
|
29716
|
+
this.write(secrets);
|
|
29640
29717
|
}
|
|
29641
29718
|
async delete(name) {
|
|
29642
29719
|
const secrets = this.read();
|
|
29643
|
-
if (!(name
|
|
29720
|
+
if (!Object.prototype.hasOwnProperty.call(secrets, name)) return;
|
|
29644
29721
|
delete secrets[name];
|
|
29645
29722
|
this.write(secrets);
|
|
29646
29723
|
}
|
|
29647
29724
|
read() {
|
|
29648
29725
|
try {
|
|
29649
29726
|
const parsed = JSON.parse(fs.readFileSync(this.filePath, "utf8"));
|
|
29650
|
-
|
|
29727
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
29728
|
+
const secrets = {};
|
|
29729
|
+
for (const [key, value] of Object.entries(parsed)) if (typeof value === "string") Object.defineProperty(secrets, key, {
|
|
29730
|
+
value,
|
|
29731
|
+
enumerable: true,
|
|
29732
|
+
configurable: true,
|
|
29733
|
+
writable: true
|
|
29734
|
+
});
|
|
29735
|
+
return secrets;
|
|
29651
29736
|
} catch {
|
|
29652
29737
|
return {};
|
|
29653
29738
|
}
|
|
@@ -29674,11 +29759,6 @@ function writePrivateJsonFile(filePath, data) {
|
|
|
29674
29759
|
function getMachineKey() {
|
|
29675
29760
|
return crypto$1.createHash("sha256").update(`runtype-cli-${os.hostname()}-${os.userInfo().username}`).digest("hex").substring(0, 32);
|
|
29676
29761
|
}
|
|
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
29762
|
function decryptWithMachineKey(text) {
|
|
29683
29763
|
const [ivHex, encrypted] = text.split(":");
|
|
29684
29764
|
const decipher = crypto$1.createDecipheriv("aes-256-cbc", Buffer.from(getMachineKey()), Buffer.from(ivHex, "hex"));
|
|
@@ -32431,7 +32511,7 @@ const unlinkCommand = new Command("unlink").description("Remove the nearest .run
|
|
|
32431
32511
|
});
|
|
32432
32512
|
// src/lib/file-utils.ts
|
|
32433
32513
|
/** Parse a string as a JSON object, exiting with a clear error on failure. */
|
|
32434
|
-
function parseJsonObject
|
|
32514
|
+
function parseJsonObject(raw, label) {
|
|
32435
32515
|
let parsed;
|
|
32436
32516
|
try {
|
|
32437
32517
|
parsed = JSON.parse(raw);
|
|
@@ -32463,7 +32543,7 @@ function readJsonFile(path, opts = {}) {
|
|
|
32463
32543
|
console.error(chalk.red(`Failed to read ${label}: ${path}`));
|
|
32464
32544
|
process.exit(1);
|
|
32465
32545
|
}
|
|
32466
|
-
const obj = parseJsonObject
|
|
32546
|
+
const obj = parseJsonObject(raw, label);
|
|
32467
32547
|
if (opts.unwrapKey) {
|
|
32468
32548
|
const nested = obj[opts.unwrapKey];
|
|
32469
32549
|
if (nested && typeof nested === "object" && !Array.isArray(nested)) return { ...nested };
|
|
@@ -32485,7 +32565,7 @@ function resolveJsonPayload(inline, fromFile, label) {
|
|
|
32485
32565
|
process.exit(1);
|
|
32486
32566
|
}
|
|
32487
32567
|
if (fromFile !== void 0) return readJsonFile(fromFile, { label });
|
|
32488
|
-
return parseJsonObject
|
|
32568
|
+
return parseJsonObject(inline, label);
|
|
32489
32569
|
}
|
|
32490
32570
|
// src/lib/ensure-output.ts
|
|
32491
32571
|
/**
|
|
@@ -53868,13 +53948,14 @@ modelsCommand.command("list").description("List your enabled model configuration
|
|
|
53868
53948
|
const { waitUntilExit } = render(React.createElement(App));
|
|
53869
53949
|
await waitUntilExit();
|
|
53870
53950
|
});
|
|
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) => {
|
|
53951
|
+
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
53952
|
const apiKey = await ensureAuth();
|
|
53873
53953
|
if (!apiKey) return;
|
|
53874
53954
|
const client = createCliClient(apiKey);
|
|
53955
|
+
const groupedPath = options.search ? `/model-configs/grouped?q=${encodeURIComponent(options.search)}` : "/model-configs/grouped";
|
|
53875
53956
|
if (!isTTY(options) || options.json) {
|
|
53876
53957
|
try {
|
|
53877
|
-
const data = await client.get(
|
|
53958
|
+
const data = await client.get(groupedPath);
|
|
53878
53959
|
if (options.json) {
|
|
53879
53960
|
printJson(data);
|
|
53880
53961
|
return;
|
|
@@ -53903,7 +53984,7 @@ modelsCommand.command("available").description("List all available models groupe
|
|
|
53903
53984
|
const [items, setItems] = useState(null);
|
|
53904
53985
|
const [error, setError] = useState(null);
|
|
53905
53986
|
useEffect(() => {
|
|
53906
|
-
client.get(
|
|
53987
|
+
client.get(groupedPath).then((res) => setItems(res.data ?? [])).catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
|
|
53907
53988
|
}, []);
|
|
53908
53989
|
return React.createElement(DataList, {
|
|
53909
53990
|
title: "Available Models",
|
|
@@ -56769,26 +56850,26 @@ clientTokensCommand.command("regenerate <id>").description("Regenerate a client
|
|
|
56769
56850
|
});
|
|
56770
56851
|
clientTokensCommand.addCommand(clientTokenEnsureCommand);
|
|
56771
56852
|
// ../../node_modules/.pnpm/@runtypelabs+persona@4.34.0/node_modules/@runtypelabs/persona/dist/codegen.js
|
|
56772
|
-
function e(e) {
|
|
56853
|
+
function e$3(e) {
|
|
56773
56854
|
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
56855
|
}
|
|
56775
|
-
function t(e) {
|
|
56856
|
+
function t$3(e) {
|
|
56776
56857
|
if (e !== void 0) return typeof e == `string` ? e : Array.isArray(e) ? `[${e.map((e) => e.toString()).join(`, `)}]` : e.toString();
|
|
56777
56858
|
}
|
|
56778
|
-
function n(e) {
|
|
56859
|
+
function n$3(e) {
|
|
56779
56860
|
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) => {
|
|
56861
|
+
getHeaders: t$3(e.getHeaders),
|
|
56862
|
+
onFeedback: t$3(e.onFeedback),
|
|
56863
|
+
onCopy: t$3(e.onCopy),
|
|
56864
|
+
requestMiddleware: t$3(e.requestMiddleware),
|
|
56865
|
+
actionHandlers: t$3(e.actionHandlers),
|
|
56866
|
+
actionParsers: t$3(e.actionParsers),
|
|
56867
|
+
postprocessMessage: t$3(e.postprocessMessage),
|
|
56868
|
+
contextProviders: t$3(e.contextProviders),
|
|
56869
|
+
streamParser: t$3(e.streamParser)
|
|
56870
|
+
};
|
|
56871
|
+
}
|
|
56872
|
+
const r$1 = `({ text, message }: any) => {
|
|
56792
56873
|
const jsonSource = (message as any).rawContent || text || message.content;
|
|
56793
56874
|
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
56794
56875
|
let cleanJson = jsonSource
|
|
@@ -56802,7 +56883,7 @@ const r = `({ text, message }: any) => {
|
|
|
56802
56883
|
} catch (e) { return null; }
|
|
56803
56884
|
return null;
|
|
56804
56885
|
}`;
|
|
56805
|
-
const i = `function(ctx) {
|
|
56886
|
+
const i$1 = `function(ctx) {
|
|
56806
56887
|
var jsonSource = ctx.message.rawContent || ctx.text || ctx.message.content;
|
|
56807
56888
|
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
56808
56889
|
var cleanJson = jsonSource
|
|
@@ -56834,7 +56915,7 @@ const a = `(action: any, context: any) => {
|
|
|
56834
56915
|
window.location.href = targetUrl;
|
|
56835
56916
|
return { handled: true, displayText: text };
|
|
56836
56917
|
}`;
|
|
56837
|
-
const o = `function(action, context) {
|
|
56918
|
+
const o$2 = `function(action, context) {
|
|
56838
56919
|
if (action.type !== 'nav_then_click') return;
|
|
56839
56920
|
var payload = action.payload || action.raw || {};
|
|
56840
56921
|
var url = payload.page;
|
|
@@ -56852,27 +56933,27 @@ const o = `function(action, context) {
|
|
|
56852
56933
|
window.location.href = targetUrl;
|
|
56853
56934
|
return { handled: true, displayText: text };
|
|
56854
56935
|
}`;
|
|
56855
|
-
function s(e) {
|
|
56936
|
+
function s$2(e) {
|
|
56856
56937
|
if (!e) return null;
|
|
56857
56938
|
let t = e.toString();
|
|
56858
56939
|
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
56940
|
}
|
|
56860
|
-
function c(e) {
|
|
56861
|
-
return e.parserType ?? s(e.streamParser) ?? `plain`;
|
|
56941
|
+
function c$2(e) {
|
|
56942
|
+
return e.parserType ?? s$2(e.streamParser) ?? `plain`;
|
|
56862
56943
|
}
|
|
56863
|
-
function l(e, t) {
|
|
56944
|
+
function l$2(e, t) {
|
|
56864
56945
|
let n = [];
|
|
56865
56946
|
return e.toolCall && (n.push(`${t}toolCall: {`), Object.entries(e.toolCall).forEach(([e, r]) => {
|
|
56866
56947
|
typeof r == `string` && n.push(`${t} ${e}: "${r}",`);
|
|
56867
56948
|
}), n.push(`${t}},`)), n;
|
|
56868
56949
|
}
|
|
56869
|
-
function u(e, t, n) {
|
|
56950
|
+
function u$2(e, t, n) {
|
|
56870
56951
|
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
56952
|
return (i || a) && (r.push(`${t}messageActions: {`), e.messageActions && Object.entries(e.messageActions).forEach(([e, n]) => {
|
|
56872
56953
|
e !== `onFeedback` && e !== `onCopy` && (typeof n == `string` ? r.push(`${t} ${e}: "${n}",`) : typeof n == `boolean` && r.push(`${t} ${e}: ${n},`));
|
|
56873
56954
|
}), n?.onFeedback && r.push(`${t} onFeedback: ${n.onFeedback},`), n?.onCopy && r.push(`${t} onCopy: ${n.onCopy},`), r.push(`${t}},`)), r;
|
|
56874
56955
|
}
|
|
56875
|
-
function d(e, t) {
|
|
56956
|
+
function d$1(e, t) {
|
|
56876
56957
|
let n = [];
|
|
56877
56958
|
if (e.markdown) {
|
|
56878
56959
|
let r = e.markdown.options && Object.keys(e.markdown.options).length > 0, i = e.markdown.disableDefaultStyles !== void 0;
|
|
@@ -56882,13 +56963,13 @@ function d(e, t) {
|
|
|
56882
56963
|
}
|
|
56883
56964
|
return n;
|
|
56884
56965
|
}
|
|
56885
|
-
function f(e, t) {
|
|
56966
|
+
function f$2(e, t) {
|
|
56886
56967
|
if (!e.suggestions) return [];
|
|
56887
56968
|
let n = JSON.stringify(e.suggestions, null, 2).split(`
|
|
56888
56969
|
`);
|
|
56889
56970
|
return n.map((e, r) => `${r === 0 ? `${t}suggestions: ` : t}${e}${r === n.length - 1 ? `,` : ``}`);
|
|
56890
56971
|
}
|
|
56891
|
-
function p(e, t) {
|
|
56972
|
+
function p$3(e, t) {
|
|
56892
56973
|
let n = [];
|
|
56893
56974
|
if (e.layout) {
|
|
56894
56975
|
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 +56985,41 @@ function p(e, t) {
|
|
|
56904
56985
|
}
|
|
56905
56986
|
return n;
|
|
56906
56987
|
}
|
|
56907
|
-
function m(e, t) {
|
|
56988
|
+
function m$3(e, t) {
|
|
56908
56989
|
let n = [];
|
|
56909
56990
|
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
56991
|
}
|
|
56911
|
-
function h(e, t) {
|
|
56992
|
+
function h$3(e, t) {
|
|
56912
56993
|
return JSON.stringify(e, null, t).replace(/</g, `\\u003c`).replace(/\u2028/g, `\\u2028`).replace(/\u2029/g, `\\u2029`);
|
|
56913
56994
|
}
|
|
56914
|
-
function g(e, t, n) {
|
|
56995
|
+
function g$2(e, t, n) {
|
|
56915
56996
|
Object.entries(t).forEach(([t, r]) => {
|
|
56916
56997
|
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)},`);
|
|
56998
|
+
let i = /^[a-zA-Z_$][\w$]*$/.test(t) ? t : h$3(t);
|
|
56999
|
+
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
57000
|
});
|
|
56920
57001
|
}
|
|
56921
|
-
function _(e, t, n, r) {
|
|
56922
|
-
n && (e.push(`${r}${t}: {`), g(e, n, `${r} `), e.push(`${r}},`));
|
|
57002
|
+
function _$2(e, t, n, r) {
|
|
57003
|
+
n && (e.push(`${r}${t}: {`), g$2(e, n, `${r} `), e.push(`${r}},`));
|
|
56923
57004
|
}
|
|
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);
|
|
57005
|
+
function v$2(e, t, n) {
|
|
57006
|
+
_$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
57007
|
}
|
|
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)},`);
|
|
57008
|
+
function y$2(e, t, n) {
|
|
57009
|
+
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
57010
|
}
|
|
56930
|
-
function b(e) {
|
|
57011
|
+
function b$2(e) {
|
|
56931
57012
|
return (e?.target ?? `body`).replace(/\\/g, `\\\\`).replace(/'/g, `\\'`);
|
|
56932
57013
|
}
|
|
56933
|
-
function x(e, t = `esm`, r) {
|
|
56934
|
-
if (r?.authoredOverrides) return S(e, t, r);
|
|
57014
|
+
function x$2(e, t = `esm`, r) {
|
|
57015
|
+
if (r?.authoredOverrides) return S$2(e, t, r);
|
|
56935
57016
|
let i = { ...e };
|
|
56936
57017
|
delete i.postprocessMessage, delete i.initialMessages;
|
|
56937
57018
|
let a = r ? {
|
|
56938
57019
|
...r,
|
|
56939
|
-
hooks: n(r.hooks)
|
|
57020
|
+
hooks: n$3(r.hooks)
|
|
56940
57021
|
} : 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);
|
|
57022
|
+
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
57023
|
let s = [
|
|
56943
57024
|
[`welcome.icon`, e.welcome?.icon],
|
|
56944
57025
|
[`approval.formatDescription`, e.approval?.formatDescription],
|
|
@@ -56948,7 +57029,7 @@ function x(e, t = `esm`, r) {
|
|
|
56948
57029
|
let c = `Function-valued ${s.join(`, `)} omitted; reattach in host JavaScript.`;
|
|
56949
57030
|
return t.startsWith(`script-`) ? `<!-- ${c} -->\n${o}` : `// ${c}\n${o}`;
|
|
56950
57031
|
}
|
|
56951
|
-
function S(t, r, i) {
|
|
57032
|
+
function S$2(t, r, i) {
|
|
56952
57033
|
let a = [], o = Symbol(`omit`), s = /* @__PURE__ */ new Set([
|
|
56953
57034
|
`storageAdapter`,
|
|
56954
57035
|
`targetProviders`,
|
|
@@ -56967,17 +57048,17 @@ function S(t, r, i) {
|
|
|
56967
57048
|
let r = l(n, t ? `${t}.${e}` : e);
|
|
56968
57049
|
return r === o ? [] : [[e, r]];
|
|
56969
57050
|
}));
|
|
56970
|
-
}, u = l(t, ``), d = n(i.hooks), f = r === `script-installer`, p = h(u, 2);
|
|
57051
|
+
}, u = l(t, ``), d = n$3(i.hooks), f = r === `script-installer`, p = h$3(u, 2);
|
|
56971
57052
|
if (d) {
|
|
56972
|
-
let e = m(d, ` `);
|
|
57053
|
+
let e = m$3(d, ` `);
|
|
56973
57054
|
d.postprocessMessage && e.push(` postprocessMessage: ${d.postprocessMessage},`);
|
|
56974
57055
|
let t = [`onFeedback`, `onCopy`];
|
|
56975
57056
|
if (t.some((e) => d[e])) {
|
|
56976
57057
|
if (!f) {
|
|
56977
57058
|
let e = { ...u };
|
|
56978
|
-
delete e.messageActions, p = h(e, 2);
|
|
57059
|
+
delete e.messageActions, p = h$3(e, 2);
|
|
56979
57060
|
}
|
|
56980
|
-
e.push(` messageActions: {`), e.push(...Object.entries(u.messageActions ?? {}).map(([e, t]) => ` ${h(e)}: ${h(t)},`));
|
|
57061
|
+
e.push(` messageActions: {`), e.push(...Object.entries(u.messageActions ?? {}).map(([e, t]) => ` ${h$3(e)}: ${h$3(t)},`));
|
|
56981
57062
|
for (let n of t) d[n] && e.push(` ${n}: ${d[n]},`);
|
|
56982
57063
|
e.push(` },`);
|
|
56983
57064
|
}
|
|
@@ -56989,8 +57070,8 @@ function S(t, r, i) {
|
|
|
56989
57070
|
}
|
|
56990
57071
|
}
|
|
56991
57072
|
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 ? {
|
|
57073
|
+
let g, _ = h$3(i.target ?? `body`), v = i.windowKey ? `, windowKey: ${h$3(i.windowKey)}` : ``, y = e$3(i);
|
|
57074
|
+
if (g = f ? `<script src="${y}/install.global.js" data-config='${h$3(i.target || i.windowKey ? {
|
|
56994
57075
|
config: u,
|
|
56995
57076
|
...i.target ? { target: i.target } : {},
|
|
56996
57077
|
...i.windowKey ? { windowKey: i.windowKey } : {}
|
|
@@ -56998,16 +57079,16 @@ function S(t, r, i) {
|
|
|
56998
57079
|
let b = `Omitted non-serializable inputs: ${[...new Set(a)].join(`, `)}. Reattach functions/custom implementations in host JavaScript; closures cannot be reconstructed.`;
|
|
56999
57080
|
return r.startsWith(`script-`) ? `<!-- ${b.replace(/--/g, `—`).replace(/</g, `<`).replace(/>/g, `>`)} -->\n${g}` : `// ${b.replace(/[\r\n\u2028\u2029]/g, ` `)}\n${g}`;
|
|
57000
57081
|
}
|
|
57001
|
-
function C(e, t) {
|
|
57002
|
-
let n = t?.hooks, r = c(e), i = r !== `plain`, a = [
|
|
57082
|
+
function C$2(e, t) {
|
|
57083
|
+
let n = t?.hooks, r = c$2(e), i = r !== `plain`, a = [
|
|
57003
57084
|
`import '@runtypelabs/persona/widget.css';`,
|
|
57004
57085
|
`import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';`,
|
|
57005
57086
|
``,
|
|
57006
57087
|
`initAgentWidget({`,
|
|
57007
|
-
` target: '${b(t)}',`,
|
|
57088
|
+
` target: '${b$2(t)}',`,
|
|
57008
57089
|
` config: {`
|
|
57009
57090
|
];
|
|
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]) => {
|
|
57091
|
+
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
57092
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
|
|
57012
57093
|
}), a.push(` },`)), e.voiceRecognition && (a.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
|
|
57013
57094
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && a.push(` ${e}: ${t},`);
|
|
@@ -57015,13 +57096,13 @@ function C(e, t) {
|
|
|
57015
57096
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
|
|
57016
57097
|
}), a.push(` },`)), e.features && (a.push(` features: {`), Object.entries(e.features).forEach(([e, t]) => {
|
|
57017
57098
|
a.push(` ${e}: ${t},`);
|
|
57018
|
-
}), a.push(` },`)), a.push(...f(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (a.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57099
|
+
}), a.push(` },`)), a.push(...f$2(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (a.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57019
57100
|
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(`
|
|
57101
|
+
}), 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
57102
|
`);
|
|
57022
57103
|
}
|
|
57023
|
-
function w(e, t) {
|
|
57024
|
-
let n = t?.hooks, r = c(e), i = r !== `plain`, a = [
|
|
57104
|
+
function w$2(e, t) {
|
|
57105
|
+
let n = t?.hooks, r = c$2(e), i = r !== `plain`, a = [
|
|
57025
57106
|
`// ChatWidget.tsx`,
|
|
57026
57107
|
`'use client'; // Required for Next.js - remove for Vite/CRA`,
|
|
57027
57108
|
``,
|
|
@@ -57035,10 +57116,10 @@ function w(e, t) {
|
|
|
57035
57116
|
` let handle: AgentWidgetInitHandle | null = null;`,
|
|
57036
57117
|
``,
|
|
57037
57118
|
` handle = initAgentWidget({`,
|
|
57038
|
-
` target: '${b(t)}',`,
|
|
57119
|
+
` target: '${b$2(t)}',`,
|
|
57039
57120
|
` config: {`
|
|
57040
57121
|
];
|
|
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]) => {
|
|
57122
|
+
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
57123
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
|
|
57043
57124
|
}), a.push(` },`)), e.voiceRecognition && (a.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
|
|
57044
57125
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && a.push(` ${e}: ${t},`);
|
|
@@ -57046,12 +57127,12 @@ function w(e, t) {
|
|
|
57046
57127
|
typeof t == `string` ? a.push(` ${e}: "${t}",`) : typeof t == `boolean` && a.push(` ${e}: ${t},`);
|
|
57047
57128
|
}), a.push(` },`)), e.features && (a.push(` features: {`), Object.entries(e.features).forEach(([e, t]) => {
|
|
57048
57129
|
a.push(` ${e}: ${t},`);
|
|
57049
|
-
}), a.push(` },`)), a.push(...f(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (a.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57130
|
+
}), a.push(` },`)), a.push(...f$2(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (a.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57050
57131
|
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(`
|
|
57132
|
+
}), 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
57133
|
`);
|
|
57053
57134
|
}
|
|
57054
|
-
function T(e, t) {
|
|
57135
|
+
function T$2(e, t) {
|
|
57055
57136
|
let n = t?.hooks, i = [
|
|
57056
57137
|
`// ChatWidgetAdvanced.tsx`,
|
|
57057
57138
|
`'use client'; // Required for Next.js - remove for Vite/CRA`,
|
|
@@ -57164,10 +57245,10 @@ function T(e, t) {
|
|
|
57164
57245
|
` };`,
|
|
57165
57246
|
``,
|
|
57166
57247
|
` handle = initAgentWidget({`,
|
|
57167
|
-
` target: '${b(t)}',`,
|
|
57248
|
+
` target: '${b$2(t)}',`,
|
|
57168
57249
|
` config: {`
|
|
57169
57250
|
];
|
|
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]) => {
|
|
57251
|
+
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
57252
|
typeof t == `string` ? i.push(` ${e}: "${t}",`) : typeof t == `boolean` && i.push(` ${e}: ${t},`);
|
|
57172
57253
|
}), i.push(` },`)), e.voiceRecognition && (i.push(` voiceRecognition: {`), Object.entries(e.voiceRecognition).forEach(([e, t]) => {
|
|
57173
57254
|
typeof t == `string` ? i.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && i.push(` ${e}: ${t},`);
|
|
@@ -57175,19 +57256,19 @@ function T(e, t) {
|
|
|
57175
57256
|
typeof t == `string` ? i.push(` ${e}: "${t}",`) : typeof t == `boolean` && i.push(` ${e}: ${t},`);
|
|
57176
57257
|
}), i.push(` },`)), e.features && (i.push(` features: {`), Object.entries(e.features).forEach(([e, t]) => {
|
|
57177
57258
|
i.push(` ${e}: ${t},`);
|
|
57178
|
-
}), i.push(` },`)), i.push(...f(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (i.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57259
|
+
}), i.push(` },`)), i.push(...f$2(e, ` `)), e.suggestionChips && e.suggestionChips.length > 0 && (i.push(` suggestionChips: [`), e.suggestionChips.forEach((e) => {
|
|
57179
57260
|
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) => {
|
|
57261
|
+
}), 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
57262
|
if (!parsed || typeof parsed !== 'object') return null;
|
|
57182
57263
|
if (parsed.action === 'nav_then_click') return 'Navigating...';
|
|
57183
57264
|
if (parsed.action === 'message') return parsed.text || '';
|
|
57184
57265
|
if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
|
|
57185
57266
|
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(`
|
|
57267
|
+
}),`)), 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
57268
|
`);
|
|
57188
57269
|
}
|
|
57189
|
-
function E(e) {
|
|
57190
|
-
let t = c(e), n = t !== `plain`, r = {};
|
|
57270
|
+
function E$2(e) {
|
|
57271
|
+
let t = c$2(e), n = t !== `plain`, r = {};
|
|
57191
57272
|
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
57273
|
let t = {};
|
|
57193
57274
|
Object.entries(e.toolCall).forEach(([e, n]) => {
|
|
@@ -57230,16 +57311,16 @@ function E(e) {
|
|
|
57230
57311
|
}
|
|
57231
57312
|
return r;
|
|
57232
57313
|
}
|
|
57233
|
-
function D(t, n) {
|
|
57234
|
-
let r = E(t), i = n?.windowKey || n?.target ? {
|
|
57314
|
+
function D$2(t, n) {
|
|
57315
|
+
let r = E$2(t), i = n?.windowKey || n?.target ? {
|
|
57235
57316
|
config: r,
|
|
57236
57317
|
...n?.windowKey ? { windowKey: n.windowKey } : {},
|
|
57237
57318
|
...n?.target ? { target: n.target } : {}
|
|
57238
57319
|
} : 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>`;
|
|
57320
|
+
return `<script src="${e$3(n)}/install.global.js" data-config='${a}'><\/script>`;
|
|
57240
57321
|
}
|
|
57241
|
-
function O(t, n) {
|
|
57242
|
-
let r = n?.hooks, i = c(t), a = i !== `plain`, o = e(n), s = [
|
|
57322
|
+
function O$2(t, n) {
|
|
57323
|
+
let r = n?.hooks, i = c$2(t), a = i !== `plain`, o = e$3(n), s = [
|
|
57243
57324
|
`<!-- Load CSS -->`,
|
|
57244
57325
|
`<link rel="stylesheet" href="${o}/widget.css" />`,
|
|
57245
57326
|
``,
|
|
@@ -57249,11 +57330,11 @@ function O(t, n) {
|
|
|
57249
57330
|
`<!-- Initialize widget -->`,
|
|
57250
57331
|
`<script>`,
|
|
57251
57332
|
` var handle = window.AgentWidget.initAgentWidget({`,
|
|
57252
|
-
` target: '${b(n)}',`,
|
|
57333
|
+
` target: '${b$2(n)}',`,
|
|
57253
57334
|
...n?.windowKey ? [` windowKey: '${n.windowKey}',`] : [],
|
|
57254
57335
|
` config: {`
|
|
57255
57336
|
];
|
|
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]) => {
|
|
57337
|
+
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
57338
|
typeof t == `string` ? s.push(` ${e}: "${t}",`) : typeof t == `boolean` && s.push(` ${e}: ${t},`);
|
|
57258
57339
|
}), s.push(` },`)), t.voiceRecognition && (s.push(` voiceRecognition: {`), Object.entries(t.voiceRecognition).forEach(([e, t]) => {
|
|
57259
57340
|
typeof t == `string` ? s.push(` ${e}: "${t}",`) : (typeof t == `boolean` || typeof t == `number`) && s.push(` ${e}: ${t},`);
|
|
@@ -57261,24 +57342,24 @@ function O(t, n) {
|
|
|
57261
57342
|
typeof t == `string` ? s.push(` ${e}: "${t}",`) : typeof t == `boolean` && s.push(` ${e}: ${t},`);
|
|
57262
57343
|
}), s.push(` },`)), t.features && (s.push(` features: {`), Object.entries(t.features).forEach(([e, t]) => {
|
|
57263
57344
|
s.push(` ${e}: ${t},`);
|
|
57264
|
-
}), s.push(` },`)), s.push(...f(t, ` `)), t.suggestionChips && t.suggestionChips.length > 0 && (s.push(` suggestionChips: [`), t.suggestionChips.forEach((e) => {
|
|
57345
|
+
}), s.push(` },`)), s.push(...f$2(t, ` `)), t.suggestionChips && t.suggestionChips.length > 0 && (s.push(` suggestionChips: [`), t.suggestionChips.forEach((e) => {
|
|
57265
57346
|
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(`
|
|
57347
|
+
}), 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
57348
|
`);
|
|
57268
57349
|
}
|
|
57269
|
-
function k(t, n) {
|
|
57350
|
+
function k$2(t, n) {
|
|
57270
57351
|
let r = n?.hooks, a = [
|
|
57271
57352
|
`<script>`,
|
|
57272
57353
|
`(function() {`,
|
|
57273
57354
|
` 'use strict';`,
|
|
57274
57355
|
``,
|
|
57275
57356
|
` // Configuration`,
|
|
57276
|
-
` var CONFIG = ${h(E(t), 2).split(`
|
|
57357
|
+
` var CONFIG = ${h$3(E$2(t), 2).split(`
|
|
57277
57358
|
`).map((e, t) => t === 0 ? e : ` ` + e).join(`
|
|
57278
57359
|
`)};`,
|
|
57279
57360
|
``,
|
|
57280
57361
|
` // Constants`,
|
|
57281
|
-
` var CDN_BASE = '${e(n)}';`,
|
|
57362
|
+
` var CDN_BASE = '${e$3(n)}';`,
|
|
57282
57363
|
` var STORAGE_KEY = 'chat-widget-state';`,
|
|
57283
57364
|
` var PROCESSED_ACTIONS_KEY = 'chat-widget-processed-actions';`,
|
|
57284
57365
|
``,
|
|
@@ -57366,7 +57447,7 @@ function k(t, n) {
|
|
|
57366
57447
|
if (parsed.action === 'message') return parsed.text || '';
|
|
57367
57448
|
if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
|
|
57368
57449
|
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(`
|
|
57450
|
+
});`), 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
57451
|
`);
|
|
57371
57452
|
}
|
|
57372
57453
|
// src/lib/persona-snippets.ts
|
|
@@ -57407,7 +57488,7 @@ function buildWidgetConfig(input) {
|
|
|
57407
57488
|
function generatePersonaInitSnippet(input, personaFormat) {
|
|
57408
57489
|
const widgetConfig = buildWidgetConfig(input);
|
|
57409
57490
|
const target = input.targetSelector?.trim();
|
|
57410
|
-
return x(widgetConfig, personaFormat, target ? { target } : void 0);
|
|
57491
|
+
return x$2(widgetConfig, personaFormat, target ? { target } : void 0);
|
|
57411
57492
|
}
|
|
57412
57493
|
/**
|
|
57413
57494
|
* Return the version-pinned Persona CDN installer URL from the same generator
|
|
@@ -57415,7 +57496,7 @@ function generatePersonaInitSnippet(input, personaFormat) {
|
|
|
57415
57496
|
* a second manually-maintained Persona version string in the CLI.
|
|
57416
57497
|
*/
|
|
57417
57498
|
function getPersonaInstallerScriptUrl() {
|
|
57418
|
-
return x({
|
|
57499
|
+
return x$2({
|
|
57419
57500
|
apiUrl: "https://api.runtype.com",
|
|
57420
57501
|
clientToken: "ct_test_demo_00000000000000000000000000000000",
|
|
57421
57502
|
parserType: "json"
|
|
@@ -62503,12 +62584,12 @@ async function connectMcpClient(apiKey, target, options = {}) {
|
|
|
62503
62584
|
};
|
|
62504
62585
|
}
|
|
62505
62586
|
/** Collect every tools/list page while treating cursors as opaque values. */
|
|
62506
|
-
async function listAllMcpTools(client) {
|
|
62587
|
+
async function listAllMcpTools(client, options) {
|
|
62507
62588
|
const tools = [];
|
|
62508
62589
|
const seenCursors = /* @__PURE__ */ new Set();
|
|
62509
62590
|
let cursor;
|
|
62510
62591
|
do {
|
|
62511
|
-
const page = await client.listTools(cursor === void 0 ? void 0 : { cursor });
|
|
62592
|
+
const page = await client.listTools(cursor === void 0 ? void 0 : { cursor }, options);
|
|
62512
62593
|
tools.push(...page.tools);
|
|
62513
62594
|
const nextCursor = page.nextCursor;
|
|
62514
62595
|
if (nextCursor !== void 0) {
|
|
@@ -62519,98 +62600,1274 @@ async function listAllMcpTools(client) {
|
|
|
62519
62600
|
} while (cursor !== void 0);
|
|
62520
62601
|
return tools;
|
|
62521
62602
|
}
|
|
62522
|
-
//
|
|
62523
|
-
|
|
62524
|
-
|
|
62525
|
-
|
|
62526
|
-
|
|
62527
|
-
|
|
62528
|
-
|
|
62603
|
+
// ../mcp-cli/dist/chunk-Cx5MQp1B.mjs
|
|
62604
|
+
const e$2 = {
|
|
62605
|
+
Success: 0,
|
|
62606
|
+
ToolError: 1,
|
|
62607
|
+
Usage: 2,
|
|
62608
|
+
Auth: 3,
|
|
62609
|
+
Transport: 4,
|
|
62610
|
+
InputRequired: 5,
|
|
62611
|
+
WaitTimeout: 6,
|
|
62612
|
+
Interrupted: 130
|
|
62613
|
+
};
|
|
62614
|
+
const t$2 = {
|
|
62615
|
+
usage: e$2.Usage,
|
|
62616
|
+
unknown_command: e$2.Usage,
|
|
62617
|
+
unknown_flag: e$2.Usage,
|
|
62618
|
+
invalid_value: e$2.Usage,
|
|
62619
|
+
missing_argument: e$2.Usage,
|
|
62620
|
+
confirmation_required: e$2.Usage,
|
|
62621
|
+
config: e$2.Usage,
|
|
62622
|
+
credential_conflict: e$2.Usage,
|
|
62623
|
+
tool_error: e$2.ToolError,
|
|
62624
|
+
auth_required: e$2.Auth,
|
|
62625
|
+
auth_failed: e$2.Auth,
|
|
62626
|
+
transport: e$2.Transport,
|
|
62627
|
+
timeout: e$2.Transport,
|
|
62628
|
+
protocol: e$2.Transport,
|
|
62629
|
+
input_required: e$2.InputRequired,
|
|
62630
|
+
input_rejected: e$2.Usage,
|
|
62631
|
+
wait_timeout: e$2.WaitTimeout,
|
|
62632
|
+
tasks_unsupported: e$2.Usage,
|
|
62633
|
+
task_cancelled: e$2.ToolError,
|
|
62634
|
+
interrupted: e$2.Interrupted,
|
|
62635
|
+
plugin_error: e$2.ToolError,
|
|
62636
|
+
internal: e$2.ToolError
|
|
62637
|
+
};
|
|
62638
|
+
var n$2 = class extends Error {
|
|
62639
|
+
code;
|
|
62640
|
+
hint;
|
|
62641
|
+
details;
|
|
62642
|
+
exitCode;
|
|
62643
|
+
constructor(e, n, r, i) {
|
|
62644
|
+
super(n), this.code = e, this.hint = r, this.details = i, this.name = `CliError`, this.exitCode = t$2[e];
|
|
62645
|
+
}
|
|
62646
|
+
toEnvelope() {
|
|
62647
|
+
return { error: {
|
|
62648
|
+
...this.details,
|
|
62649
|
+
code: this.code,
|
|
62650
|
+
message: this.message,
|
|
62651
|
+
...this.hint ? { hint: this.hint } : {},
|
|
62652
|
+
exitCode: this.exitCode
|
|
62653
|
+
} };
|
|
62654
|
+
}
|
|
62655
|
+
};
|
|
62656
|
+
// ../mcp-cli/dist/chunk-CQq_8FZL.mjs
|
|
62657
|
+
function e$1(e) {
|
|
62658
|
+
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();
|
|
62659
|
+
}
|
|
62660
|
+
function t$1(e, t) {
|
|
62661
|
+
if (e === t) return 0;
|
|
62662
|
+
let n = Array.from({ length: t.length + 1 }, (e, t) => t);
|
|
62663
|
+
for (let r = 1; r <= e.length; r += 1) {
|
|
62664
|
+
let i = n[0];
|
|
62665
|
+
n[0] = r;
|
|
62666
|
+
for (let a = 1; a <= t.length; a += 1) {
|
|
62667
|
+
let o = n[a];
|
|
62668
|
+
n[a] = Math.min(n[a] + 1, n[a - 1] + 1, i + (e[r - 1] === t[a - 1] ? 0 : 1)), i = o;
|
|
62669
|
+
}
|
|
62670
|
+
}
|
|
62671
|
+
return n[t.length];
|
|
62672
|
+
}
|
|
62673
|
+
function n$1(e, n, r = 3) {
|
|
62674
|
+
let i = e.toLowerCase(), a = Math.max(2, Math.floor(i.length / 3)), o = [];
|
|
62675
|
+
for (let e of new Set(n)) {
|
|
62676
|
+
let n = e.toLowerCase(), r = n.startsWith(i) || i.startsWith(n) ? 1 : t$1(i, n);
|
|
62677
|
+
r <= a && o.push([e, r]);
|
|
62678
|
+
}
|
|
62679
|
+
return o.sort((e, t) => e[1] - t[1] || e[0].localeCompare(t[0])).slice(0, r).map(([e]) => e);
|
|
62680
|
+
}
|
|
62681
|
+
// ../mcp-cli/dist/chunk-B4F-cgd0.mjs
|
|
62682
|
+
function e(e, t) {
|
|
62683
|
+
switch (e) {
|
|
62684
|
+
case void 0:
|
|
62685
|
+
case `auto`: return t.stdoutIsTTY ? `pretty` : `compact`;
|
|
62686
|
+
default: return e;
|
|
62687
|
+
}
|
|
62688
|
+
}
|
|
62689
|
+
const t = /\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)|\u001b[@-Z\\-_]/g;
|
|
62690
|
+
const n = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g;
|
|
62691
|
+
function r(e) {
|
|
62692
|
+
return e.replace(t, ``).replace(/\r\n/g, `
|
|
62693
|
+
`).replace(n, ``);
|
|
62694
|
+
}
|
|
62695
|
+
function o$1(e) {
|
|
62696
|
+
let t = e.endsWith(`==`) ? 2 : +!!e.endsWith(`=`);
|
|
62697
|
+
return Math.max(0, Math.floor(e.length * 3 / 4) - t);
|
|
62698
|
+
}
|
|
62699
|
+
function s$1(e) {
|
|
62700
|
+
return e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB`;
|
|
62701
|
+
}
|
|
62702
|
+
function c$1(e, t, n) {
|
|
62703
|
+
let i = t.get(e);
|
|
62704
|
+
switch (e.type) {
|
|
62705
|
+
case `text`: return n ? String(e.text) : r(String(e.text));
|
|
62706
|
+
case `image`:
|
|
62707
|
+
case `audio`: {
|
|
62708
|
+
let t = String(e.mimeType ?? `application/octet-stream`);
|
|
62709
|
+
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]`;
|
|
62710
|
+
}
|
|
62711
|
+
case `resource_link`: return `${e.name ? `${r(String(e.name))}: ` : ``}${r(String(e.uri))}`;
|
|
62712
|
+
case `resource`: {
|
|
62713
|
+
let t = e.resource ?? {};
|
|
62714
|
+
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))}` : ``}]`;
|
|
62715
|
+
}
|
|
62716
|
+
default: return `[${r(String(e.type))} content]`;
|
|
62717
|
+
}
|
|
62718
|
+
}
|
|
62719
|
+
function l$1(e, t) {
|
|
62720
|
+
return JSON.stringify(e) === JSON.stringify(t);
|
|
62721
|
+
}
|
|
62722
|
+
function u$1(e) {
|
|
62723
|
+
let t = Array.isArray(e.content) ? e.content : [];
|
|
62724
|
+
return e.structuredContent === void 0 ? t : t.filter((t) => {
|
|
62725
|
+
if (t.type !== `text`) return !0;
|
|
62726
|
+
try {
|
|
62727
|
+
return !l$1(JSON.parse(String(t.text)), e.structuredContent);
|
|
62728
|
+
} catch {
|
|
62729
|
+
return !0;
|
|
62730
|
+
}
|
|
62529
62731
|
});
|
|
62530
62732
|
}
|
|
62531
|
-
|
|
62532
|
-
|
|
62533
|
-
stream.setEncoding("utf8");
|
|
62534
|
-
for await (const chunk of stream) value += chunk;
|
|
62535
|
-
return value;
|
|
62733
|
+
function f$1(e) {
|
|
62734
|
+
return typeof e == `object` && !!e && !Array.isArray(e) && Object.values(e).every((e) => typeof e != `object` || !e);
|
|
62536
62735
|
}
|
|
62537
|
-
function
|
|
62538
|
-
let
|
|
62736
|
+
function p$2(e) {
|
|
62737
|
+
let t = e.structuredContent, n = [];
|
|
62738
|
+
t !== void 0 && (n.push(t), typeof t == `object` && t && n.push(...Object.values(t)));
|
|
62739
|
+
for (let e of n) if (Array.isArray(e) && e.length > 0 && e.every(f$1)) return e;
|
|
62740
|
+
return null;
|
|
62741
|
+
}
|
|
62742
|
+
function m$2(e) {
|
|
62743
|
+
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();
|
|
62744
|
+
return [a(t.map((e) => e.toUpperCase())), ...e.map((e) => a(t.map((t) => n(e[t]))))].join(`
|
|
62745
|
+
`);
|
|
62746
|
+
}
|
|
62747
|
+
function h$2(e, t) {
|
|
62748
|
+
let n = t.saved ?? /* @__PURE__ */ new Map();
|
|
62749
|
+
switch (t.mode) {
|
|
62750
|
+
case `json`: return JSON.stringify(e);
|
|
62751
|
+
case `ndjson`: return JSON.stringify({
|
|
62752
|
+
type: `result`,
|
|
62753
|
+
result: e
|
|
62754
|
+
});
|
|
62755
|
+
case `table`: {
|
|
62756
|
+
let n = p$2(e);
|
|
62757
|
+
return n ? m$2(n) : h$2(e, {
|
|
62758
|
+
...t,
|
|
62759
|
+
mode: `pretty`
|
|
62760
|
+
});
|
|
62761
|
+
}
|
|
62762
|
+
case `pretty`:
|
|
62763
|
+
case `compact`:
|
|
62764
|
+
if (e.structuredContent !== void 0) {
|
|
62765
|
+
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));
|
|
62766
|
+
return t.mode === `pretty` && i.length > 0 ? [r, ...i].join(`
|
|
62767
|
+
`) : r;
|
|
62768
|
+
}
|
|
62769
|
+
return u$1(e).map((e) => c$1(e, n, t.mode === `compact`)).join(`
|
|
62770
|
+
`);
|
|
62771
|
+
case `text`:
|
|
62772
|
+
case `raw`: {
|
|
62773
|
+
let r = u$1(e).map((e) => c$1(e, n, t.mode === `raw`));
|
|
62774
|
+
return r.length === 0 && e.structuredContent !== void 0 ? JSON.stringify(e.structuredContent, null, t.mode === `text` ? 2 : void 0) : r.join(`
|
|
62775
|
+
`);
|
|
62776
|
+
}
|
|
62777
|
+
}
|
|
62778
|
+
}
|
|
62779
|
+
// ../mcp-cli/dist/chunk-Ce22LqPV.mjs
|
|
62780
|
+
const i = /* @__PURE__ */ new Set([
|
|
62781
|
+
`approvals`,
|
|
62782
|
+
`auth`,
|
|
62783
|
+
`call`,
|
|
62784
|
+
`completion`,
|
|
62785
|
+
`doctor`,
|
|
62786
|
+
`help`,
|
|
62787
|
+
`login`,
|
|
62788
|
+
`logout`,
|
|
62789
|
+
`resources`,
|
|
62790
|
+
`resume`,
|
|
62791
|
+
`schema`,
|
|
62792
|
+
`skill`,
|
|
62793
|
+
`tasks`,
|
|
62794
|
+
`tools`,
|
|
62795
|
+
`version`,
|
|
62796
|
+
`whoami`,
|
|
62797
|
+
`__complete`
|
|
62798
|
+
]);
|
|
62799
|
+
function o(e) {
|
|
62800
|
+
return e.split(/\s+/).filter(Boolean);
|
|
62801
|
+
}
|
|
62802
|
+
function s(e, t) {
|
|
62803
|
+
if (t?.group || t?.name) {
|
|
62804
|
+
let n = t.group ? o(t.group) : [], r = t.name ?? (e.name.includes(`.`) ? e.name.split(`.`).filter(Boolean).at(-1) ?? e.name : e.name);
|
|
62805
|
+
return [...n, r];
|
|
62806
|
+
}
|
|
62807
|
+
if (e.name.includes(`.`)) {
|
|
62808
|
+
let t = e.name.split(`.`).filter(Boolean);
|
|
62809
|
+
if (t.length > 0) return t;
|
|
62810
|
+
}
|
|
62811
|
+
return [e.name];
|
|
62812
|
+
}
|
|
62813
|
+
const c = (e) => e.join(`\0`);
|
|
62814
|
+
function l(e, t = {}) {
|
|
62815
|
+
let r = [], a = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = (e, t, n) => {
|
|
62816
|
+
if (t.length === 0 || t.some((e) => e === ``)) return;
|
|
62817
|
+
let r = l.get(c(t)) ?? [];
|
|
62818
|
+
r.push({
|
|
62819
|
+
entry: e,
|
|
62820
|
+
priority: n
|
|
62821
|
+
}), l.set(c(t), r);
|
|
62822
|
+
}, d = /* @__PURE__ */ new Map();
|
|
62823
|
+
for (let i of e) {
|
|
62824
|
+
if (a.has(i.name)) continue;
|
|
62825
|
+
let e = Object.prototype.hasOwnProperty.call(t, i.name) ? t[i.name] : void 0, c = s(i, e), l = {
|
|
62826
|
+
tool: e?.description ? {
|
|
62827
|
+
...i,
|
|
62828
|
+
description: e.description
|
|
62829
|
+
} : i,
|
|
62830
|
+
path: c,
|
|
62831
|
+
aliases: [],
|
|
62832
|
+
hidden: e?.hidden === !0,
|
|
62833
|
+
callOnly: !1,
|
|
62834
|
+
override: e
|
|
62835
|
+
};
|
|
62836
|
+
r.push(l), a.set(i.name, l);
|
|
62837
|
+
let f = [
|
|
62838
|
+
{
|
|
62839
|
+
path: [i.name],
|
|
62840
|
+
priority: 0
|
|
62841
|
+
},
|
|
62842
|
+
{
|
|
62843
|
+
path: c,
|
|
62844
|
+
priority: 1
|
|
62845
|
+
},
|
|
62846
|
+
...(e?.aliases ?? []).map((e) => ({
|
|
62847
|
+
path: o(e),
|
|
62848
|
+
priority: 2
|
|
62849
|
+
})),
|
|
62850
|
+
{
|
|
62851
|
+
path: c.map(e$1),
|
|
62852
|
+
priority: 3
|
|
62853
|
+
},
|
|
62854
|
+
{
|
|
62855
|
+
path: [e$1(i.name)],
|
|
62856
|
+
priority: 3
|
|
62857
|
+
}
|
|
62858
|
+
];
|
|
62859
|
+
d.set(l, f);
|
|
62860
|
+
for (let e of f) u(l, e.path, e.priority);
|
|
62861
|
+
}
|
|
62862
|
+
let f = { children: /* @__PURE__ */ new Map() }, p = /* @__PURE__ */ new Map();
|
|
62863
|
+
for (let [e, t] of d) {
|
|
62864
|
+
let n = /* @__PURE__ */ new Set();
|
|
62865
|
+
for (let { path: r } of t) {
|
|
62866
|
+
let t = c(r);
|
|
62867
|
+
if (n.has(t) || r.length === 0 || (n.add(t), i.has(r[0]))) continue;
|
|
62868
|
+
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));
|
|
62869
|
+
if (u.size !== 1 || !u.has(e)) continue;
|
|
62870
|
+
let d = f;
|
|
62871
|
+
for (let e of r) {
|
|
62872
|
+
let t = d.children.get(e);
|
|
62873
|
+
t || (t = { children: /* @__PURE__ */ new Map() }, d.children.set(e, t)), d = t;
|
|
62874
|
+
}
|
|
62875
|
+
d.entry = e;
|
|
62876
|
+
let m = p.get(e) ?? [];
|
|
62877
|
+
m.push(r), p.set(e, m);
|
|
62878
|
+
}
|
|
62879
|
+
}
|
|
62880
|
+
for (let e of r) {
|
|
62881
|
+
let t = p.get(e) ?? [], n = c(e.path), r = t.find((e) => c(e) === n) ?? t[0];
|
|
62882
|
+
r ? (e.path = r, e.aliases = t.filter((e) => c(e) !== c(r))) : e.callOnly = !0;
|
|
62883
|
+
}
|
|
62884
|
+
let m = (e) => {
|
|
62885
|
+
let t = f;
|
|
62886
|
+
for (let n of e) if (t = t?.children.get(n), !t) return;
|
|
62887
|
+
return t;
|
|
62888
|
+
};
|
|
62889
|
+
return {
|
|
62890
|
+
entries: r,
|
|
62891
|
+
byToolName: a,
|
|
62892
|
+
resolve(e) {
|
|
62893
|
+
let t = f, n = { kind: `none` }, r = [];
|
|
62894
|
+
for (let [i, a] of e.entries()) {
|
|
62895
|
+
let e = t.children.get(a);
|
|
62896
|
+
if (!e) break;
|
|
62897
|
+
t = e, r.push(a), t.entry && (n = {
|
|
62898
|
+
kind: `tool`,
|
|
62899
|
+
entry: t.entry,
|
|
62900
|
+
consumed: i + 1
|
|
62901
|
+
});
|
|
62902
|
+
}
|
|
62903
|
+
return n.kind === `tool` ? n : r.length > 0 ? {
|
|
62904
|
+
kind: `group`,
|
|
62905
|
+
path: r,
|
|
62906
|
+
children: [...t.children.keys()].sort()
|
|
62907
|
+
} : n;
|
|
62908
|
+
},
|
|
62909
|
+
topLevelWords() {
|
|
62910
|
+
return [...f.children.keys()].sort();
|
|
62911
|
+
},
|
|
62912
|
+
childrenOf(e) {
|
|
62913
|
+
return [...m(e)?.children.keys() ?? []].sort();
|
|
62914
|
+
}
|
|
62915
|
+
};
|
|
62916
|
+
}
|
|
62917
|
+
function u(e) {
|
|
62918
|
+
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
62919
|
+
}
|
|
62920
|
+
function d(e) {
|
|
62921
|
+
return decodeURIComponent(e).replace(/~1/g, `/`).replace(/~0/g, `~`);
|
|
62922
|
+
}
|
|
62923
|
+
function f(e, t) {
|
|
62924
|
+
if (t === `#`) return e;
|
|
62925
|
+
if (!t.startsWith(`#/`)) return;
|
|
62926
|
+
let n = e;
|
|
62927
|
+
for (let e of t.slice(2).split(`/`)) {
|
|
62928
|
+
if (!u(n)) return;
|
|
62929
|
+
n = n[d(e)];
|
|
62930
|
+
}
|
|
62931
|
+
return u(n) ? n : void 0;
|
|
62932
|
+
}
|
|
62933
|
+
var p$1 = class extends Error {};
|
|
62934
|
+
function m$1(e, t, n, r) {
|
|
62935
|
+
if (n.length > 32) throw new p$1();
|
|
62936
|
+
let i = t;
|
|
62937
|
+
if (typeof i.$ref == `string`) {
|
|
62938
|
+
let t = i.$ref;
|
|
62939
|
+
if (n.includes(t)) throw new p$1();
|
|
62940
|
+
let a = f(e, t);
|
|
62941
|
+
if (!a) return {
|
|
62942
|
+
...i,
|
|
62943
|
+
$ref: void 0
|
|
62944
|
+
};
|
|
62945
|
+
r.add(t);
|
|
62946
|
+
let { $ref: o, ...s } = i;
|
|
62947
|
+
i = {
|
|
62948
|
+
...m$1(e, a, [...n, t], r),
|
|
62949
|
+
...s
|
|
62950
|
+
};
|
|
62951
|
+
}
|
|
62952
|
+
if (Array.isArray(i.allOf)) {
|
|
62953
|
+
let { allOf: t, ...a } = i, o = {};
|
|
62954
|
+
for (let i of t) u(i) && (o = h$1(o, m$1(e, i, n, r)));
|
|
62955
|
+
i = h$1(o, a);
|
|
62956
|
+
}
|
|
62957
|
+
return i;
|
|
62958
|
+
}
|
|
62959
|
+
function h$1(e, t) {
|
|
62960
|
+
let n = {
|
|
62961
|
+
...e,
|
|
62962
|
+
...t
|
|
62963
|
+
};
|
|
62964
|
+
(u(e.properties) || u(t.properties)) && (n.properties = {
|
|
62965
|
+
...u(e.properties) ? e.properties : {},
|
|
62966
|
+
...u(t.properties) ? t.properties : {}
|
|
62967
|
+
});
|
|
62968
|
+
let r = [...Array.isArray(e.required) ? e.required : [], ...Array.isArray(t.required) ? t.required : []];
|
|
62969
|
+
return r.length > 0 && (n.required = [...new Set(r)]), n;
|
|
62970
|
+
}
|
|
62971
|
+
function g$1(e, t, n = []) {
|
|
62972
|
+
let r = /* @__PURE__ */ new Set();
|
|
62539
62973
|
try {
|
|
62540
|
-
|
|
62974
|
+
return {
|
|
62975
|
+
schema: m$1(e, t, n, r),
|
|
62976
|
+
recursive: !1,
|
|
62977
|
+
ancestors: [...n, ...r]
|
|
62978
|
+
};
|
|
62979
|
+
} catch (e) {
|
|
62980
|
+
if (e instanceof p$1) return {
|
|
62981
|
+
schema: t,
|
|
62982
|
+
recursive: !0,
|
|
62983
|
+
ancestors: n
|
|
62984
|
+
};
|
|
62985
|
+
throw e;
|
|
62986
|
+
}
|
|
62987
|
+
}
|
|
62988
|
+
function _$1(e) {
|
|
62989
|
+
return typeof e.type == `string` ? [e.type] : Array.isArray(e.type) ? e.type.filter((e) => typeof e == `string`) : [];
|
|
62990
|
+
}
|
|
62991
|
+
function ee(e) {
|
|
62992
|
+
return e.contentEncoding === `base64` || e.format === `binary` || e.format === `byte` || typeof e.contentMediaType == `string`;
|
|
62993
|
+
}
|
|
62994
|
+
function v$1(e) {
|
|
62995
|
+
return u(e) && (e.type === `null` || Array.isArray(e.type) && e.type.length === 1 && e.type[0] === `null`);
|
|
62996
|
+
}
|
|
62997
|
+
function y$1(e, t, n) {
|
|
62998
|
+
return {
|
|
62999
|
+
kind: t,
|
|
63000
|
+
schema: e,
|
|
63001
|
+
nullable: n,
|
|
63002
|
+
description: typeof e.description == `string` ? e.description : void 0,
|
|
63003
|
+
defaultValue: e.default,
|
|
63004
|
+
hasDefault: Object.prototype.hasOwnProperty.call(e, `default`),
|
|
63005
|
+
deprecated: e.deprecated === !0,
|
|
63006
|
+
readOnly: e.readOnly === !0,
|
|
63007
|
+
format: typeof e.format == `string` ? e.format : void 0
|
|
63008
|
+
};
|
|
63009
|
+
}
|
|
63010
|
+
const b$1 = [
|
|
63011
|
+
`integer`,
|
|
63012
|
+
`number`,
|
|
63013
|
+
`boolean`,
|
|
63014
|
+
`string`
|
|
63015
|
+
];
|
|
63016
|
+
function x$1(e) {
|
|
63017
|
+
if (e.kind === `integer` || e.kind === `number` || e.kind === `boolean` || e.kind === `string`) return e.kind;
|
|
63018
|
+
if (e.kind === `binary`) return `string`;
|
|
63019
|
+
if (e.kind === `enum` || e.kind === `const`) {
|
|
63020
|
+
let t = e.kind === `enum` ? e.enumValues ?? [] : [e.constValue];
|
|
63021
|
+
if (t.every((e) => typeof e == `string`)) return `string`;
|
|
63022
|
+
if (t.every((e) => Number.isInteger(e))) return `integer`;
|
|
63023
|
+
if (t.every((e) => typeof e == `number`)) return `number`;
|
|
63024
|
+
if (t.every((e) => typeof e == `boolean`)) return `boolean`;
|
|
63025
|
+
}
|
|
63026
|
+
}
|
|
63027
|
+
function S$1(e, t, n = []) {
|
|
63028
|
+
let { schema: r, recursive: i, ancestors: a } = g$1(e, t, n);
|
|
63029
|
+
if (i) return y$1(r, `json`, !1);
|
|
63030
|
+
let o = r.nullable === !0, s = _$1(r);
|
|
63031
|
+
s.includes(`null`) && (o = !0);
|
|
63032
|
+
let c = s.filter((e) => e !== `null`);
|
|
63033
|
+
if (Object.prototype.hasOwnProperty.call(r, `const`)) return {
|
|
63034
|
+
...y$1(r, `const`, o),
|
|
63035
|
+
constValue: r.const
|
|
63036
|
+
};
|
|
63037
|
+
if (Array.isArray(r.enum)) {
|
|
63038
|
+
let e = r.enum.filter((e) => e !== null);
|
|
63039
|
+
return e.length !== r.enum.length && (o = !0), {
|
|
63040
|
+
...y$1(r, `enum`, o),
|
|
63041
|
+
enumValues: e
|
|
63042
|
+
};
|
|
63043
|
+
}
|
|
63044
|
+
let l = Array.isArray(r.anyOf) ? r.anyOf : Array.isArray(r.oneOf) ? r.oneOf : void 0;
|
|
63045
|
+
if (l) {
|
|
63046
|
+
let t = l.filter((e) => !v$1(e));
|
|
63047
|
+
t.length !== l.length && (o = !0);
|
|
63048
|
+
let n = t.filter(u).map((t) => S$1(e, t, a)), i = {
|
|
63049
|
+
...r,
|
|
63050
|
+
anyOf: void 0,
|
|
63051
|
+
oneOf: void 0
|
|
63052
|
+
};
|
|
63053
|
+
if (n.length === 1) {
|
|
63054
|
+
let e = n[0];
|
|
63055
|
+
return {
|
|
63056
|
+
...e,
|
|
63057
|
+
nullable: o || e.nullable,
|
|
63058
|
+
description: typeof r.description == `string` ? r.description : e.description,
|
|
63059
|
+
hasDefault: e.hasDefault || Object.prototype.hasOwnProperty.call(r, `default`),
|
|
63060
|
+
defaultValue: r.default ?? e.defaultValue,
|
|
63061
|
+
deprecated: r.deprecated === !0 || e.deprecated
|
|
63062
|
+
};
|
|
63063
|
+
}
|
|
63064
|
+
let s = n.map(x$1);
|
|
63065
|
+
if (n.length > 0 && s.every((e) => e !== void 0)) {
|
|
63066
|
+
let e = b$1.filter((e) => s.includes(e));
|
|
63067
|
+
return {
|
|
63068
|
+
...y$1(i, `scalar-union`, o),
|
|
63069
|
+
unionKinds: e
|
|
63070
|
+
};
|
|
63071
|
+
}
|
|
63072
|
+
return y$1(i, `json`, o);
|
|
63073
|
+
}
|
|
63074
|
+
if (c.length > 1) {
|
|
63075
|
+
let e = b$1.filter((e) => c.includes(e));
|
|
63076
|
+
return e.length === c.length ? {
|
|
63077
|
+
...y$1(r, `scalar-union`, o),
|
|
63078
|
+
unionKinds: e
|
|
63079
|
+
} : y$1(r, `json`, o);
|
|
63080
|
+
}
|
|
63081
|
+
switch (c[0] ?? (u(r.properties) || u(r.additionalProperties) ? `object` : void 0)) {
|
|
63082
|
+
case `string`: return y$1(r, ee(r) ? `binary` : `string`, o);
|
|
63083
|
+
case `integer`: return y$1(r, `integer`, o);
|
|
63084
|
+
case `number`: return y$1(r, `number`, o);
|
|
63085
|
+
case `boolean`: return y$1(r, `boolean`, o);
|
|
63086
|
+
case `array`: {
|
|
63087
|
+
let t = S$1(e, u(r.items) ? r.items : {}, a);
|
|
63088
|
+
return x$1(t) !== void 0 || t.kind === `scalar-union` ? {
|
|
63089
|
+
...y$1(r, `scalar-array`, o),
|
|
63090
|
+
item: t
|
|
63091
|
+
} : {
|
|
63092
|
+
...y$1(r, `object-array`, o),
|
|
63093
|
+
item: t
|
|
63094
|
+
};
|
|
63095
|
+
}
|
|
63096
|
+
case `object`:
|
|
63097
|
+
if (!(u(r.properties) && Object.keys(r.properties).length > 0) && u(r.additionalProperties)) {
|
|
63098
|
+
let t = S$1(e, r.additionalProperties, a);
|
|
63099
|
+
if (x$1(t) !== void 0 || t.kind === `scalar-union`) return {
|
|
63100
|
+
...y$1(r, `map`, o),
|
|
63101
|
+
item: t
|
|
63102
|
+
};
|
|
63103
|
+
}
|
|
63104
|
+
return y$1(r, `object`, o);
|
|
63105
|
+
default: return y$1(r, `any`, o);
|
|
63106
|
+
}
|
|
63107
|
+
}
|
|
63108
|
+
function te(e) {
|
|
63109
|
+
let { schema: t, recursive: n } = g$1(e, e);
|
|
63110
|
+
if (n) return null;
|
|
63111
|
+
let r = _$1(t);
|
|
63112
|
+
if (!(r.includes(`object`) || r.length === 0 && (u(t.properties) || Object.keys(t).length === 0))) return null;
|
|
63113
|
+
let i = Object.create(null);
|
|
63114
|
+
if (u(t.properties)) for (let [e, n] of Object.entries(t.properties)) u(n) && (i[e] = n);
|
|
63115
|
+
return {
|
|
63116
|
+
properties: i,
|
|
63117
|
+
required: Array.isArray(t.required) ? t.required.filter((e) => typeof e == `string` && Object.hasOwn(i, e)) : []
|
|
63118
|
+
};
|
|
63119
|
+
}
|
|
63120
|
+
function ne(e, t) {
|
|
63121
|
+
let n = (Array.isArray(t.anyOf) ? t.anyOf : Array.isArray(t.oneOf) ? t.oneOf : []).filter((e) => u(e) && !v$1(e));
|
|
63122
|
+
return n.length === 1 ? g$1(e, n[0]).schema : t;
|
|
63123
|
+
}
|
|
63124
|
+
function re(e, t) {
|
|
63125
|
+
let n = e;
|
|
63126
|
+
for (let r of t) {
|
|
63127
|
+
let { schema: t, recursive: i } = g$1(e, n);
|
|
63128
|
+
if (i) return;
|
|
63129
|
+
let a = ne(e, t);
|
|
63130
|
+
if (r === `[]`) {
|
|
63131
|
+
if (!u(a.items)) return;
|
|
63132
|
+
n = a.items;
|
|
63133
|
+
} else if (u(a.properties) && u(a.properties[r])) n = a.properties[r];
|
|
63134
|
+
else if (u(a.additionalProperties)) n = a.additionalProperties;
|
|
63135
|
+
else return;
|
|
63136
|
+
}
|
|
63137
|
+
return S$1(e, n);
|
|
63138
|
+
}
|
|
63139
|
+
const C$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(`.`));
|
|
63140
|
+
function w$1(e) {
|
|
63141
|
+
return e.kind === `string` || e.kind === `enum` || e.kind === `binary`;
|
|
63142
|
+
}
|
|
63143
|
+
function T$1(e, t) {
|
|
63144
|
+
let r = e.inputSchema ?? {}, i = te(r);
|
|
63145
|
+
if (!i) return {
|
|
63146
|
+
tool: e,
|
|
63147
|
+
bodyOnly: !0,
|
|
63148
|
+
flags: [],
|
|
63149
|
+
byFlag: /* @__PURE__ */ new Map(),
|
|
63150
|
+
byWire: /* @__PURE__ */ new Map(),
|
|
63151
|
+
positionals: [],
|
|
63152
|
+
constFields: {},
|
|
63153
|
+
defaults: {},
|
|
63154
|
+
required: []
|
|
63155
|
+
};
|
|
63156
|
+
let a = {}, o = { ...t?.defaults }, s = [], c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
|
|
63157
|
+
for (let e of Object.keys(i.properties)) l.set(e$1(e), (l.get(e$1(e)) ?? 0) + 1);
|
|
63158
|
+
for (let [e, t] of Object.entries(i.properties)) {
|
|
63159
|
+
let u = S$1(r, t);
|
|
63160
|
+
if (u.readOnly) continue;
|
|
63161
|
+
if (u.kind === `const`) {
|
|
63162
|
+
E$1(a, e, u.constValue);
|
|
63163
|
+
continue;
|
|
63164
|
+
}
|
|
63165
|
+
let d = e$1(e) || e, f = d;
|
|
63166
|
+
if (C$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}`;
|
|
63167
|
+
c.add(f);
|
|
63168
|
+
let p = i.required.includes(e);
|
|
63169
|
+
p && u.hasDefault && !Object.hasOwn(o, e) && E$1(o, e, u.defaultValue), s.push({
|
|
63170
|
+
wire: e,
|
|
63171
|
+
flag: f,
|
|
63172
|
+
field: u,
|
|
63173
|
+
required: p && !Object.hasOwn(o, e),
|
|
63174
|
+
hidden: u.deprecated
|
|
63175
|
+
});
|
|
63176
|
+
}
|
|
63177
|
+
let u = new Map(s.map((e) => [e.wire, e])), d = [];
|
|
63178
|
+
if (t?.positional && t.positional.length > 0) d = t.positional.map((e) => u.get(e)).filter((e) => e !== void 0 && w$1(e.field));
|
|
63179
|
+
else {
|
|
63180
|
+
let e = s.filter((e) => e.required);
|
|
63181
|
+
e.length === 1 && e[0].field.kind === `string` && (d = e);
|
|
63182
|
+
}
|
|
63183
|
+
return d.forEach((e, t) => {
|
|
63184
|
+
e.position = t;
|
|
63185
|
+
}), {
|
|
63186
|
+
tool: e,
|
|
63187
|
+
bodyOnly: !1,
|
|
63188
|
+
flags: s,
|
|
63189
|
+
byFlag: new Map(s.map((e) => [e.flag, e])),
|
|
63190
|
+
byWire: u,
|
|
63191
|
+
positionals: d,
|
|
63192
|
+
constFields: a,
|
|
63193
|
+
defaults: o,
|
|
63194
|
+
required: s.filter((e) => e.required).map((e) => e.wire)
|
|
63195
|
+
};
|
|
63196
|
+
}
|
|
63197
|
+
function E$1(e, t, n) {
|
|
63198
|
+
Object.defineProperty(e, t, {
|
|
63199
|
+
value: n,
|
|
63200
|
+
enumerable: !0,
|
|
63201
|
+
configurable: !0,
|
|
63202
|
+
writable: !0
|
|
63203
|
+
});
|
|
63204
|
+
}
|
|
63205
|
+
function D$1(e) {
|
|
63206
|
+
return e?.startsWith(`\0`) === !0;
|
|
63207
|
+
}
|
|
63208
|
+
function O$1(t, n) {
|
|
63209
|
+
let r = n.slice(1), i = t.startsWith(`--`) ? `${t}=${r}` : `${t}${r}`;
|
|
63210
|
+
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`);
|
|
63211
|
+
}
|
|
63212
|
+
const k$1 = /* @__PURE__ */ new Set([
|
|
63213
|
+
`auto`,
|
|
63214
|
+
`json`,
|
|
63215
|
+
`text`,
|
|
63216
|
+
`raw`,
|
|
63217
|
+
`ndjson`,
|
|
63218
|
+
`table`
|
|
63219
|
+
]);
|
|
63220
|
+
const A$1 = /* @__PURE__ */ new Set([
|
|
63221
|
+
`output`,
|
|
63222
|
+
`timeout`,
|
|
63223
|
+
`save`,
|
|
63224
|
+
`input`,
|
|
63225
|
+
`json-body`,
|
|
63226
|
+
`field`,
|
|
63227
|
+
`raw-field`,
|
|
63228
|
+
`max-output`,
|
|
63229
|
+
`approve`,
|
|
63230
|
+
`deny`,
|
|
63231
|
+
`approvals`,
|
|
63232
|
+
`answers`,
|
|
63233
|
+
`wait`,
|
|
63234
|
+
`stream`
|
|
63235
|
+
]);
|
|
63236
|
+
const j$1 = /* @__PURE__ */ new Set([
|
|
63237
|
+
`auto`,
|
|
63238
|
+
`raw`,
|
|
63239
|
+
`off`
|
|
63240
|
+
]);
|
|
63241
|
+
const M$1 = /* @__PURE__ */ new Set([
|
|
63242
|
+
`prompt`,
|
|
63243
|
+
`fail`,
|
|
63244
|
+
`deny`
|
|
63245
|
+
]);
|
|
63246
|
+
const N$1 = {
|
|
63247
|
+
h: `help`,
|
|
63248
|
+
o: `output`,
|
|
63249
|
+
y: `yes`,
|
|
63250
|
+
f: `raw-field`,
|
|
63251
|
+
F: `field`
|
|
63252
|
+
};
|
|
63253
|
+
function P$1(e) {
|
|
63254
|
+
return e.field.kind === `scalar-array` || e.field.kind === `object-array` || e.field.kind === `map`;
|
|
63255
|
+
}
|
|
63256
|
+
function F(t, n) {
|
|
63257
|
+
let r = /^(\d+(?:\.\d+)?)(ms|s|m|h)?$/.exec(t.trim());
|
|
63258
|
+
if (!r) throw new n$2(`invalid_value`, `${n} expects a duration such as 30000, 30s or 5m`);
|
|
63259
|
+
let i = Number(r[1]), a = r[2] ?? `ms`, o = Math.round(i * (a === `h` ? 36e5 : a === `m` ? 6e4 : a === `s` ? 1e3 : 1));
|
|
63260
|
+
if (o <= 0) throw new n$2(`invalid_value`, `${n} must be greater than zero`);
|
|
63261
|
+
return o;
|
|
63262
|
+
}
|
|
63263
|
+
function I(t) {
|
|
63264
|
+
if (t === `0` || t === `none` || t === `unlimited`) return null;
|
|
63265
|
+
if (!/^\d+$/.test(t)) throw new n$2(`invalid_value`, `--max-output expects a character count, or 0 for unlimited`);
|
|
63266
|
+
return Number(t);
|
|
63267
|
+
}
|
|
63268
|
+
function ae(t, n) {
|
|
63269
|
+
let r = {
|
|
63270
|
+
help: !1,
|
|
63271
|
+
helpAll: !1,
|
|
63272
|
+
dryRun: !1,
|
|
63273
|
+
example: !1,
|
|
63274
|
+
detach: !1,
|
|
63275
|
+
yes: !1,
|
|
63276
|
+
fields: [],
|
|
63277
|
+
rawFields: [],
|
|
63278
|
+
rawStrings: !1,
|
|
63279
|
+
approve: [],
|
|
63280
|
+
deny: [],
|
|
63281
|
+
approveAll: !1
|
|
63282
|
+
}, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = [], s = /* @__PURE__ */ new Set(), c = (t, n) => {
|
|
63283
|
+
if (t === `field`) return void r.fields.push(n);
|
|
63284
|
+
if (t === `raw-field`) return void r.rawFields.push(n);
|
|
63285
|
+
if (t === `approve` || t === `deny`) {
|
|
63286
|
+
if (n.trim() === ``) throw new n$2(`invalid_value`, `--${t} needs a tool name`);
|
|
63287
|
+
r[t].push(n);
|
|
63288
|
+
} else {
|
|
63289
|
+
if (s.has(t)) throw new n$2(`usage`, `--${t} was given more than once`);
|
|
63290
|
+
switch (s.add(t), t) {
|
|
63291
|
+
case `output`:
|
|
63292
|
+
if (!k$1.has(n)) throw new n$2(`invalid_value`, `--output must be one of ${[...k$1].join(`, `)}`);
|
|
63293
|
+
r.output = L(r.output, n);
|
|
63294
|
+
return;
|
|
63295
|
+
case `timeout`:
|
|
63296
|
+
r.timeoutMs = F(n, `--timeout`);
|
|
63297
|
+
return;
|
|
63298
|
+
case `save`:
|
|
63299
|
+
r.save = n;
|
|
63300
|
+
return;
|
|
63301
|
+
case `input`:
|
|
63302
|
+
r.input = n;
|
|
63303
|
+
return;
|
|
63304
|
+
case `json-body`:
|
|
63305
|
+
r.jsonBody = n;
|
|
63306
|
+
return;
|
|
63307
|
+
case `max-output`:
|
|
63308
|
+
r.maxOutput = I(n);
|
|
63309
|
+
return;
|
|
63310
|
+
case `approvals`:
|
|
63311
|
+
if (!M$1.has(n)) throw new n$2(`invalid_value`, `--approvals must be prompt, fail or deny`);
|
|
63312
|
+
r.approvals = n;
|
|
63313
|
+
return;
|
|
63314
|
+
case `answers`:
|
|
63315
|
+
r.answers = n;
|
|
63316
|
+
return;
|
|
63317
|
+
case `wait`:
|
|
63318
|
+
r.wait = n;
|
|
63319
|
+
return;
|
|
63320
|
+
case `stream`:
|
|
63321
|
+
if (!j$1.has(n)) throw new n$2(`invalid_value`, `--stream must be auto, raw or off`);
|
|
63322
|
+
r.stream = n;
|
|
63323
|
+
return;
|
|
63324
|
+
}
|
|
63325
|
+
}
|
|
63326
|
+
}, l = (e) => {
|
|
63327
|
+
switch (e) {
|
|
63328
|
+
case `help`: return r.help = !0, !0;
|
|
63329
|
+
case `help-all`: return r.helpAll = !0, !0;
|
|
63330
|
+
case `json`: return r.output = L(r.output, `json`), !0;
|
|
63331
|
+
case `jsonl`: return r.output = L(r.output, `ndjson`), !0;
|
|
63332
|
+
case `dry-run`: return r.dryRun = !0, !0;
|
|
63333
|
+
case `example`: return r.example = !0, !0;
|
|
63334
|
+
case `detach`: return r.detach = !0, !0;
|
|
63335
|
+
case `yes`: return r.yes = !0, !0;
|
|
63336
|
+
case `raw-strings`: return r.rawStrings = !0, !0;
|
|
63337
|
+
case `approve-all`: return r.approveAll = !0, !0;
|
|
63338
|
+
default: return !1;
|
|
63339
|
+
}
|
|
63340
|
+
}, u = (t, n) => {
|
|
63341
|
+
let r = i.get(t) ?? [];
|
|
63342
|
+
if (r.length > 0 && !P$1(t)) throw new n$2(`usage`, `--${t.flag} was given more than once`, oe(t));
|
|
63343
|
+
r.push(n), i.set(t, r);
|
|
63344
|
+
}, d = (t, n) => {
|
|
63345
|
+
if (a.has(t)) throw new n$2(`usage`, `--${t.flag} was given more than once`);
|
|
63346
|
+
a.set(t, n);
|
|
63347
|
+
};
|
|
63348
|
+
for (let r = 0; r < t.length; r += 1) {
|
|
63349
|
+
let i = t[r];
|
|
63350
|
+
if (!D$1(i)) {
|
|
63351
|
+
if (i === `--`) {
|
|
63352
|
+
o.push(...t.slice(r + 1));
|
|
63353
|
+
break;
|
|
63354
|
+
}
|
|
63355
|
+
if (i.startsWith(`--`) && i.length > 2) {
|
|
63356
|
+
let a = i.indexOf(`=`), o = a === -1 ? i.slice(2) : i.slice(2, a), s = a === -1 ? void 0 : i.slice(a + 1), f = () => {
|
|
63357
|
+
if (s !== void 0) return s;
|
|
63358
|
+
if (D$1(t[r + 1])) throw O$1(i, t[r + 1]);
|
|
63359
|
+
if (r + 1 >= t.length) throw new n$2(`missing_argument`, `--${o} needs a value`);
|
|
63360
|
+
return r += 1, t[r];
|
|
63361
|
+
}, p = n.byFlag.get(o);
|
|
63362
|
+
if (p) {
|
|
63363
|
+
p.field.kind === `boolean` ? d(p, s === void 0 || se(s, `--${o}`)) : u(p, f());
|
|
63364
|
+
continue;
|
|
63365
|
+
}
|
|
63366
|
+
if (o.startsWith(`no-`)) {
|
|
63367
|
+
let t = n.byFlag.get(o.slice(3));
|
|
63368
|
+
if (t && t.field.kind === `boolean`) {
|
|
63369
|
+
if (s !== void 0) throw new n$2(`usage`, `--${o} takes no value; use --${t.flag}=${s}`);
|
|
63370
|
+
d(t, !1);
|
|
63371
|
+
continue;
|
|
63372
|
+
}
|
|
63373
|
+
}
|
|
63374
|
+
if (A$1.has(o)) {
|
|
63375
|
+
c(o, f());
|
|
63376
|
+
continue;
|
|
63377
|
+
}
|
|
63378
|
+
if (s === void 0 && l(o)) continue;
|
|
63379
|
+
throw R(o, n);
|
|
63380
|
+
}
|
|
63381
|
+
if (i.startsWith(`-`) && i.length > 1 && !/^-\d/.test(i)) {
|
|
63382
|
+
let a = i.slice(1, 2), o = N$1[a];
|
|
63383
|
+
if (!o) throw R(i.slice(1), n);
|
|
63384
|
+
let s = i.slice(2);
|
|
63385
|
+
if (A$1.has(o)) {
|
|
63386
|
+
let n = s;
|
|
63387
|
+
if (n === ``) {
|
|
63388
|
+
if (D$1(t[r + 1])) throw O$1(i, t[r + 1]);
|
|
63389
|
+
if (r + 1 >= t.length) throw new n$2(`missing_argument`, `-${a} needs a value`);
|
|
63390
|
+
r += 1, n = t[r];
|
|
63391
|
+
}
|
|
63392
|
+
c(o, n);
|
|
63393
|
+
} else {
|
|
63394
|
+
if (s !== ``) throw R(i.slice(1), n);
|
|
63395
|
+
l(o);
|
|
63396
|
+
}
|
|
63397
|
+
} else o.push(i);
|
|
63398
|
+
}
|
|
63399
|
+
}
|
|
63400
|
+
return {
|
|
63401
|
+
reserved: r,
|
|
63402
|
+
values: i,
|
|
63403
|
+
booleans: a,
|
|
63404
|
+
positionals: o
|
|
63405
|
+
};
|
|
63406
|
+
}
|
|
63407
|
+
function L(t, n) {
|
|
63408
|
+
if (t && t !== n) throw new n$2(`usage`, `Choose one output format: --json, --jsonl or --output`);
|
|
63409
|
+
return n;
|
|
63410
|
+
}
|
|
63411
|
+
function oe(e) {
|
|
63412
|
+
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;
|
|
63413
|
+
}
|
|
63414
|
+
function se(t, n) {
|
|
63415
|
+
let r = t.trim().toLowerCase();
|
|
63416
|
+
if (r === `true`) return !0;
|
|
63417
|
+
if (r === `false`) return !1;
|
|
63418
|
+
throw new n$2(`invalid_value`, `${n} expects true or false, got ${JSON.stringify(t)}`);
|
|
63419
|
+
}
|
|
63420
|
+
function R(n, r) {
|
|
63421
|
+
let a = n$1(n, [...r.flags.filter((e) => !e.hidden).map((e) => e.flag), ...C$1]);
|
|
63422
|
+
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`);
|
|
63423
|
+
}
|
|
63424
|
+
function z(e) {
|
|
63425
|
+
if (!e) return ``;
|
|
63426
|
+
let t = r(e).trim().split(`
|
|
63427
|
+
`, 1)[0], n = /^(.+?[.!?])(\s|$)/.exec(t);
|
|
63428
|
+
return (n ? n[1] : t).trim();
|
|
63429
|
+
}
|
|
63430
|
+
function B(e) {
|
|
63431
|
+
let t = e.annotations ?? {}, n = [];
|
|
63432
|
+
return t.readOnlyHint && n.push(`read-only`), t.destructiveHint && n.push(`destructive`), t.idempotentHint && n.push(`idempotent`), t.openWorldHint && n.push(`open-world`), n;
|
|
63433
|
+
}
|
|
63434
|
+
function V(e, t, n = 0) {
|
|
63435
|
+
switch (e.kind) {
|
|
63436
|
+
case `string`: return `string`;
|
|
63437
|
+
case `binary`: return `base64`;
|
|
63438
|
+
case `enum`: return (e.enumValues ?? []).map((e) => JSON.stringify(e)).join(` | `);
|
|
63439
|
+
case `const`: return JSON.stringify(e.constValue);
|
|
63440
|
+
case `integer`:
|
|
63441
|
+
case `number`: return `number`;
|
|
63442
|
+
case `boolean`: return `boolean`;
|
|
63443
|
+
case `scalar-union`: return (e.unionKinds ?? []).map((e) => e === `integer` ? `number` : e).filter((e, t, n) => n.indexOf(e) === t).join(` | `);
|
|
63444
|
+
case `scalar-array`: return `${H(V(e.item ?? e, t, n))}[]`;
|
|
63445
|
+
case `object-array`: return `${U(e.item?.schema ?? {}, t, n)}[]`;
|
|
63446
|
+
case `map`: return `Record<string, ${V(e.item ?? e, t, n)}>`;
|
|
63447
|
+
case `object`: return U(e.schema, t, n);
|
|
63448
|
+
case `json`:
|
|
63449
|
+
case `any`: return `unknown`;
|
|
63450
|
+
}
|
|
63451
|
+
}
|
|
63452
|
+
function H(e) {
|
|
63453
|
+
return e.includes(` | `) ? `(${e})` : e;
|
|
63454
|
+
}
|
|
63455
|
+
function U(e, t, n = 0) {
|
|
63456
|
+
let r = e.properties;
|
|
63457
|
+
if (n > 1 || typeof r != `object` || !r) return `object`;
|
|
63458
|
+
let i = Array.isArray(e.required) ? e.required : [], a = Object.entries(r).map(([e, r]) => {
|
|
63459
|
+
let a = S$1(t, r), o = V(a, t, n + 1);
|
|
63460
|
+
return `${e}${i.includes(e) ? `` : `?`}: ${o}${a.nullable ? ` | null` : ``}`;
|
|
63461
|
+
});
|
|
63462
|
+
return a.length > 0 ? `{ ${a.join(`; `)} }` : `object`;
|
|
63463
|
+
}
|
|
63464
|
+
function W(e) {
|
|
63465
|
+
let t = e.inputSchema ?? {}, n = T$1(e);
|
|
63466
|
+
if (n.bodyOnly) return r(`${e.name}(body: unknown)`);
|
|
63467
|
+
let i = n.flags.filter((e) => !e.hidden).map((e) => `${e.wire}${e.required ? `` : `?`}: ${V(e.field, t)}${e.field.nullable ? ` | null` : ``}`);
|
|
63468
|
+
return r(`${e.name}(${i.length > 0 ? `{ ${i.join(`; `)} }` : ``})`);
|
|
63469
|
+
}
|
|
63470
|
+
function K(e) {
|
|
63471
|
+
return e.callOnly ? `call ${e.tool.name}` : e.path.join(` `);
|
|
63472
|
+
}
|
|
63473
|
+
function $(e, t = !1) {
|
|
63474
|
+
return e.entries.filter((e) => t || !e.hidden).map((e) => ({
|
|
63475
|
+
command: K(e),
|
|
63476
|
+
tool: e.tool.name,
|
|
63477
|
+
summary: z(e.tool.description),
|
|
63478
|
+
badges: B(e.tool)
|
|
63479
|
+
})).sort((e, t) => e.command.localeCompare(t.command));
|
|
63480
|
+
}
|
|
63481
|
+
function de(e) {
|
|
63482
|
+
if (e.length === 0) return `No tools.
|
|
63483
|
+
`;
|
|
63484
|
+
let t = Math.min(40, Math.max(...e.map((e) => e.command.length)));
|
|
63485
|
+
return r(`${e.map((e) => ` ${e.command.padEnd(t)} ${e.summary}${e.badges.length > 0 ? ` [${e.badges.join(`, `)}]` : ``}`.trimEnd()).join(`
|
|
63486
|
+
`)}\n`);
|
|
63487
|
+
}
|
|
63488
|
+
// ../mcp-cli/dist/chunk-BRgLEWMS.mjs
|
|
63489
|
+
var p = class extends n$2 {};
|
|
63490
|
+
function m(e) {
|
|
63491
|
+
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
63492
|
+
}
|
|
63493
|
+
function h(e, t) {
|
|
63494
|
+
try {
|
|
63495
|
+
return JSON.parse(e);
|
|
62541
63496
|
} catch {
|
|
62542
|
-
throw new
|
|
63497
|
+
throw new p(`invalid_value`, `${t} is not valid JSON`);
|
|
62543
63498
|
}
|
|
62544
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`${label} must be a JSON object`);
|
|
62545
|
-
return parsed;
|
|
62546
63499
|
}
|
|
62547
|
-
function
|
|
62548
|
-
|
|
62549
|
-
if (
|
|
62550
|
-
|
|
63500
|
+
function g(e) {
|
|
63501
|
+
if (Array.isArray(e)) return e.map(g);
|
|
63502
|
+
if (m(e)) {
|
|
63503
|
+
let t = {};
|
|
63504
|
+
for (let [r, i] of Object.entries(e)) E$1(t, r, g(i));
|
|
63505
|
+
return t;
|
|
63506
|
+
}
|
|
63507
|
+
return e;
|
|
62551
63508
|
}
|
|
62552
|
-
function
|
|
63509
|
+
function _(e, t) {
|
|
63510
|
+
let r = {};
|
|
63511
|
+
for (let [t, i] of Object.entries(e)) E$1(r, t, i);
|
|
63512
|
+
for (let [e, i] of Object.entries(t)) {
|
|
63513
|
+
let t = Object.prototype.hasOwnProperty.call(r, e) ? r[e] : void 0;
|
|
63514
|
+
E$1(r, e, m(t) && m(i) ? _(t, i) : i);
|
|
63515
|
+
}
|
|
63516
|
+
return r;
|
|
63517
|
+
}
|
|
63518
|
+
async function v(t, n, r) {
|
|
63519
|
+
let i = t.slice(1);
|
|
63520
|
+
if (i === ``) throw new p(`invalid_value`, `${r}: @ must be followed by a path, or - for stdin`);
|
|
63521
|
+
if (i === `-`) return n.readStdin();
|
|
62553
63522
|
try {
|
|
62554
|
-
return
|
|
63523
|
+
return await n.readFile(i);
|
|
63524
|
+
} catch (t) {
|
|
63525
|
+
throw new n$2(`invalid_value`, `${r}: cannot read ${i} (${t instanceof Error && `code` in t ? String(t.code) : `unreadable`})`);
|
|
63526
|
+
}
|
|
63527
|
+
}
|
|
63528
|
+
function y(e, t, n) {
|
|
63529
|
+
switch (e) {
|
|
63530
|
+
case `string`: return t;
|
|
63531
|
+
case `integer`: {
|
|
63532
|
+
let e = t.trim(), r = Number(e);
|
|
63533
|
+
if (!/^[+-]?\d+$/.test(e) || !Number.isSafeInteger(r)) throw new p(`invalid_value`, `${n} expects an integer, got ${JSON.stringify(t)}`);
|
|
63534
|
+
return r;
|
|
63535
|
+
}
|
|
63536
|
+
case `number`: {
|
|
63537
|
+
let e = Number(t.trim());
|
|
63538
|
+
if (t.trim() === `` || !Number.isFinite(e)) throw new p(`invalid_value`, `${n} expects a number, got ${JSON.stringify(t)}`);
|
|
63539
|
+
return e;
|
|
63540
|
+
}
|
|
63541
|
+
case `boolean`: {
|
|
63542
|
+
let e = t.trim().toLowerCase();
|
|
63543
|
+
if (e === `true`) return !0;
|
|
63544
|
+
if (e === `false`) return !1;
|
|
63545
|
+
throw new p(`invalid_value`, `${n} expects true or false, got ${JSON.stringify(t)}`);
|
|
63546
|
+
}
|
|
63547
|
+
}
|
|
63548
|
+
}
|
|
63549
|
+
function b(e, t, n) {
|
|
63550
|
+
for (let r of e) try {
|
|
63551
|
+
return y(r, t, n);
|
|
62555
63552
|
} catch {
|
|
62556
|
-
|
|
63553
|
+
continue;
|
|
62557
63554
|
}
|
|
63555
|
+
throw new p(`invalid_value`, `${n} expects ${e.join(` or `)}, got ${JSON.stringify(t)}`);
|
|
63556
|
+
}
|
|
63557
|
+
function x(e, t, n) {
|
|
63558
|
+
let r = e.enumValues ?? [], i = r.find((e) => (typeof e == `string` ? e : JSON.stringify(e)) === t);
|
|
63559
|
+
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(`, `)}`);
|
|
63560
|
+
return i ?? t;
|
|
63561
|
+
}
|
|
63562
|
+
async function S(e, t, n) {
|
|
63563
|
+
return e.startsWith(`@@`) ? e.slice(1) : e.startsWith(`@`) ? (await v(e, t, n)).toString(`utf8`) : e;
|
|
63564
|
+
}
|
|
63565
|
+
async function C(e, t, n, r) {
|
|
63566
|
+
switch (e.kind) {
|
|
63567
|
+
case `string`: return t;
|
|
63568
|
+
case `binary`: return t.startsWith(`@@`) ? t.slice(1) : t.startsWith(`@`) ? (await v(t, r, n)).toString(`base64`) : t;
|
|
63569
|
+
case `enum`: return x(e, t, n);
|
|
63570
|
+
case `integer`:
|
|
63571
|
+
case `number`:
|
|
63572
|
+
case `boolean`: return y(e.kind, t, n);
|
|
63573
|
+
case `scalar-union`: return b(e.unionKinds ?? [`string`], t, n);
|
|
63574
|
+
case `const`: return e.constValue;
|
|
63575
|
+
case `object`:
|
|
63576
|
+
case `object-array`:
|
|
63577
|
+
case `json`: {
|
|
63578
|
+
let i = g(h(await S(t, r, n), n));
|
|
63579
|
+
if (e.kind === `object` && !m(i)) throw new p(`invalid_value`, `${n} expects a JSON object`);
|
|
63580
|
+
return i;
|
|
63581
|
+
}
|
|
63582
|
+
case `any`: {
|
|
63583
|
+
let e = await S(t, r, n);
|
|
63584
|
+
try {
|
|
63585
|
+
return g(JSON.parse(e));
|
|
63586
|
+
} catch {
|
|
63587
|
+
return e;
|
|
63588
|
+
}
|
|
63589
|
+
}
|
|
63590
|
+
case `scalar-array`:
|
|
63591
|
+
case `map`: return C(e.item ?? {
|
|
63592
|
+
...e,
|
|
63593
|
+
kind: `any`
|
|
63594
|
+
}, t, n, r);
|
|
63595
|
+
}
|
|
63596
|
+
}
|
|
63597
|
+
async function w(t, r, i) {
|
|
63598
|
+
let a = `--${t.flag}`, o = t.field;
|
|
63599
|
+
if (o.kind === `scalar-array`) {
|
|
63600
|
+
let e = o.item ?? o, t = [];
|
|
63601
|
+
for (let n of r) if (r.length === 1 && n.trimStart().startsWith(`[`)) {
|
|
63602
|
+
let r = h(n, a);
|
|
63603
|
+
if (!Array.isArray(r)) throw new p(`invalid_value`, `${a} expects a JSON array`);
|
|
63604
|
+
for (let n of r) t.push(typeof n == `string` ? await C(e, n, a, i) : n);
|
|
63605
|
+
} else t.push(await C(e, n, a, i));
|
|
63606
|
+
return t;
|
|
63607
|
+
}
|
|
63608
|
+
if (o.kind === `object-array`) {
|
|
63609
|
+
let e = [];
|
|
63610
|
+
for (let t of r) {
|
|
63611
|
+
let n = await C({
|
|
63612
|
+
...o,
|
|
63613
|
+
kind: `json`
|
|
63614
|
+
}, t, a, i);
|
|
63615
|
+
Array.isArray(n) ? e.push(...n) : e.push(n);
|
|
63616
|
+
}
|
|
63617
|
+
return e;
|
|
63618
|
+
}
|
|
63619
|
+
if (o.kind === `map`) {
|
|
63620
|
+
let t = {};
|
|
63621
|
+
for (let s of r) {
|
|
63622
|
+
let r = s.indexOf(`=`);
|
|
63623
|
+
if (r <= 0) throw new p(`invalid_value`, `${a} expects key=value`);
|
|
63624
|
+
let c = s.slice(0, r);
|
|
63625
|
+
if (Object.prototype.hasOwnProperty.call(t, c)) throw new n$2(`usage`, `${a} sets ${c} more than once`);
|
|
63626
|
+
E$1(t, c, await C(o.item ?? o, s.slice(r + 1), `${a} ${c}`, i));
|
|
63627
|
+
}
|
|
63628
|
+
return t;
|
|
63629
|
+
}
|
|
63630
|
+
return C(o, r[0], a, i);
|
|
63631
|
+
}
|
|
63632
|
+
function T(t, n) {
|
|
63633
|
+
let r = n ? `-F` : `-f`, i = t.indexOf(`=`);
|
|
63634
|
+
if (i === -1 && /^[^[\]=]+(?:\[[^[\]]+\])*\[\]$/.test(t)) return {
|
|
63635
|
+
...T(`${t}=`, n),
|
|
63636
|
+
empty: !0
|
|
63637
|
+
};
|
|
63638
|
+
if (i <= 0) throw new n$2(`usage`, `${r} expects key=value, got ${JSON.stringify(t)}`);
|
|
63639
|
+
let a = t.slice(0, i), o = /^([^[\]]+)((?:\[[^[\]]*\])*)$/.exec(a);
|
|
63640
|
+
if (!o) throw new n$2(`usage`, `${r} key ${JSON.stringify(a)} is malformed`);
|
|
63641
|
+
let s = [o[1]], c = !1, l = [...o[2].matchAll(/\[([^[\]]*)\]/g)].map((e) => e[1]);
|
|
63642
|
+
for (let [t, n] of l.entries()) if (n === ``) {
|
|
63643
|
+
if (t !== l.length - 1) throw new n$2(`usage`, `${r} supports [] only at the end of a key`);
|
|
63644
|
+
c = !0;
|
|
63645
|
+
} else s.push(n);
|
|
63646
|
+
return {
|
|
63647
|
+
path: s,
|
|
63648
|
+
append: c,
|
|
63649
|
+
raw: t.slice(i + 1),
|
|
63650
|
+
typed: n
|
|
63651
|
+
};
|
|
63652
|
+
}
|
|
63653
|
+
async function E(e, n, r, i) {
|
|
63654
|
+
let a = `${e.typed ? `-F` : `-f`} ${e.path.join(`.`)}`;
|
|
63655
|
+
if (!e.typed || r) return e.raw;
|
|
63656
|
+
let s = re(n, e.append ? [...e.path, `[]`] : e.path), c = e.raw;
|
|
63657
|
+
if (c.startsWith(`@@`)) c = c.slice(1);
|
|
63658
|
+
else if (c.startsWith(`@`)) {
|
|
63659
|
+
let e = await v(c, i, a);
|
|
63660
|
+
if (s?.kind === `binary`) return e.toString(`base64`);
|
|
63661
|
+
if (c = e.toString(`utf8`), s && (s.kind === `string` || s.kind === `enum`)) return c;
|
|
63662
|
+
}
|
|
63663
|
+
if (c === `null`) return null;
|
|
63664
|
+
let l = D(c);
|
|
63665
|
+
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;
|
|
63666
|
+
}
|
|
63667
|
+
function D(e) {
|
|
63668
|
+
try {
|
|
63669
|
+
return {
|
|
63670
|
+
ok: !0,
|
|
63671
|
+
value: g(JSON.parse(e))
|
|
63672
|
+
};
|
|
63673
|
+
} catch {
|
|
63674
|
+
return { ok: !1 };
|
|
63675
|
+
}
|
|
63676
|
+
}
|
|
63677
|
+
function O(t, r, i) {
|
|
63678
|
+
let a = t;
|
|
63679
|
+
for (let t of r.path.slice(0, -1)) {
|
|
63680
|
+
let i = Object.prototype.hasOwnProperty.call(a, t) ? a[t] : void 0;
|
|
63681
|
+
if (i === void 0) {
|
|
63682
|
+
let e = {};
|
|
63683
|
+
E$1(a, t, e), a = e;
|
|
63684
|
+
} else if (m(i)) a = i;
|
|
63685
|
+
else throw new n$2(`usage`, `-F ${r.path.join(`.`)} conflicts with a non-object value`);
|
|
63686
|
+
}
|
|
63687
|
+
let o = r.path[r.path.length - 1];
|
|
63688
|
+
if (r.append) {
|
|
63689
|
+
let t = Object.prototype.hasOwnProperty.call(a, o) ? a[o] : void 0, s = r.empty ? [] : [i];
|
|
63690
|
+
if (t === void 0) E$1(a, o, s);
|
|
63691
|
+
else if (Array.isArray(t)) t.push(...s);
|
|
63692
|
+
else throw new n$2(`usage`, `-F ${o}[] conflicts with a non-array value`);
|
|
63693
|
+
} else {
|
|
63694
|
+
if (Object.prototype.hasOwnProperty.call(a, o)) throw new n$2(`usage`, `${r.path.join(`.`)} is set more than once by -f/-F`);
|
|
63695
|
+
E$1(a, o, i);
|
|
63696
|
+
}
|
|
63697
|
+
}
|
|
63698
|
+
async function k(e, t) {
|
|
63699
|
+
let n = typeof e == `string` ? e : e.toString(`utf8`);
|
|
63700
|
+
if (n.trim() !== ``) return g(h(n, t));
|
|
63701
|
+
}
|
|
63702
|
+
function A(e, t) {
|
|
63703
|
+
if (t !== `@-`) return !1;
|
|
63704
|
+
switch (e.kind) {
|
|
63705
|
+
case `binary`:
|
|
63706
|
+
case `object`:
|
|
63707
|
+
case `object-array`:
|
|
63708
|
+
case `json`:
|
|
63709
|
+
case `any`: return !0;
|
|
63710
|
+
case `scalar-array`:
|
|
63711
|
+
case `map`: return A(e.item ?? {
|
|
63712
|
+
...e,
|
|
63713
|
+
kind: `any`
|
|
63714
|
+
}, t);
|
|
63715
|
+
default: return !1;
|
|
63716
|
+
}
|
|
63717
|
+
}
|
|
63718
|
+
function j(e, t) {
|
|
63719
|
+
let { field: n } = e;
|
|
63720
|
+
if (n.kind === `map`) return t.some((e) => e.indexOf(`=`) > 0 && A(n, e.slice(e.indexOf(`=`) + 1)));
|
|
63721
|
+
if (n.kind === `scalar-array` && t.length === 1 && t[0].trimStart().startsWith(`[`)) try {
|
|
63722
|
+
let e = JSON.parse(t[0]);
|
|
63723
|
+
return Array.isArray(e) && e.some((e) => typeof e == `string` && A(n, e));
|
|
63724
|
+
} catch {
|
|
63725
|
+
return !1;
|
|
63726
|
+
}
|
|
63727
|
+
return t.some((e) => A(n, e));
|
|
63728
|
+
}
|
|
63729
|
+
function M(e, t) {
|
|
63730
|
+
let { reserved: n } = e;
|
|
63731
|
+
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;
|
|
63732
|
+
for (let [t, n] of e.values) if (j(t, n)) return !0;
|
|
63733
|
+
return !1;
|
|
63734
|
+
}
|
|
63735
|
+
function N(e, t) {
|
|
63736
|
+
return e.reserved.answers === `-` || M(e, t);
|
|
63737
|
+
}
|
|
63738
|
+
async function P(t, r, i) {
|
|
63739
|
+
let { reserved: a } = r;
|
|
63740
|
+
if (a.input !== void 0 && a.jsonBody !== void 0) throw new n$2(`usage`, `Use only one of --input and --json-body`);
|
|
63741
|
+
let o, s = !1;
|
|
63742
|
+
if (a.jsonBody !== void 0) o = await k(a.jsonBody, `--json-body`);
|
|
63743
|
+
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);
|
|
63744
|
+
else if (!i.noInput && !N(r, t) && i.stdinIsPipedData()) {
|
|
63745
|
+
let e = await i.readStdin();
|
|
63746
|
+
e.length > 0 && (o = await k(e, `stdin`), s = o !== void 0);
|
|
63747
|
+
}
|
|
63748
|
+
let c = r.values.size > 0 || r.booleans.size > 0 || r.positionals.length > 0, l = a.fields.length > 0 || a.rawFields.length > 0;
|
|
63749
|
+
if (t.bodyOnly) {
|
|
63750
|
+
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`);
|
|
63751
|
+
return {
|
|
63752
|
+
args: o === void 0 ? {} : o,
|
|
63753
|
+
usedAutoStdin: s
|
|
63754
|
+
};
|
|
63755
|
+
}
|
|
63756
|
+
if (o !== void 0 && !m(o)) throw new n$2(`invalid_value`, `The arguments body must be a JSON object`);
|
|
63757
|
+
let u = o ?? {};
|
|
63758
|
+
if (l) {
|
|
63759
|
+
let e = {}, n = t.tool.inputSchema ?? {}, r = [...a.rawFields.map((e) => T(e, !1)), ...a.fields.map((e) => T(e, !0))];
|
|
63760
|
+
for (let o of r) {
|
|
63761
|
+
let r = o.path[0], s = t.byWire.has(r) ? r : t.byFlag.get(r)?.wire ?? r, c = {
|
|
63762
|
+
...o,
|
|
63763
|
+
path: [s, ...o.path.slice(1)]
|
|
63764
|
+
};
|
|
63765
|
+
O(e, c, c.empty ? void 0 : await E(c, n, a.rawStrings, i));
|
|
63766
|
+
}
|
|
63767
|
+
u = _(u, e);
|
|
63768
|
+
}
|
|
63769
|
+
let d = {};
|
|
63770
|
+
if (r.positionals.length > t.positionals.length) {
|
|
63771
|
+
let n = r.positionals.slice(t.positionals.length);
|
|
63772
|
+
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);
|
|
63773
|
+
}
|
|
63774
|
+
for (let [a, o] of r.positionals.entries()) {
|
|
63775
|
+
let s = t.positionals[a], c = r.values.get(s);
|
|
63776
|
+
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`);
|
|
63777
|
+
E$1(d, s.wire, await C(s.field, o, s.wire, i));
|
|
63778
|
+
}
|
|
63779
|
+
for (let [e, t] of r.values) E$1(d, e.wire, await w(e, t, i));
|
|
63780
|
+
for (let [e, t] of r.booleans) E$1(d, e.wire, t);
|
|
63781
|
+
u = _(u, d);
|
|
63782
|
+
for (let [e, r] of [...Object.entries(t.constFields), ...Object.entries(t.defaults)]) Object.prototype.hasOwnProperty.call(u, e) || E$1(u, e, structuredClone(r));
|
|
63783
|
+
let f = t.required.filter((e) => !Object.prototype.hasOwnProperty.call(u, e));
|
|
63784
|
+
if (f.length > 0) {
|
|
63785
|
+
let e = f.map((e) => {
|
|
63786
|
+
let n = t.byWire.get(e);
|
|
63787
|
+
return n?.position === void 0 ? `--${n?.flag ?? e}` : `<${n.flag}>`;
|
|
63788
|
+
});
|
|
63789
|
+
throw new p(`missing_argument`, `Missing required ${e.length > 1 ? `arguments` : `argument`}: ${e.join(`, `)}`, `Run with --help for usage`);
|
|
63790
|
+
}
|
|
63791
|
+
return {
|
|
63792
|
+
args: u,
|
|
63793
|
+
usedAutoStdin: s
|
|
63794
|
+
};
|
|
63795
|
+
}
|
|
63796
|
+
// src/lib/mcp-input.ts
|
|
63797
|
+
const SCHEMALESS = {
|
|
63798
|
+
name: "tool",
|
|
63799
|
+
inputSchema: { type: "object" }
|
|
63800
|
+
};
|
|
63801
|
+
function toMcpCliArgv(options) {
|
|
63802
|
+
return [
|
|
63803
|
+
...(options.rawField ?? []).flatMap((value) => ["-f", value]),
|
|
63804
|
+
...(options.field ?? []).flatMap((value) => ["-F", value]),
|
|
63805
|
+
...options.jsonBody !== void 0 ? ["--json-body", options.jsonBody] : [],
|
|
63806
|
+
...options.input !== void 0 ? ["--input", options.input] : []
|
|
63807
|
+
];
|
|
63808
|
+
}
|
|
63809
|
+
/** Whether resolving these arguments will consume the process stdin stream; the parser that reads it decides. */
|
|
63810
|
+
function usesMcpStdin(options) {
|
|
63811
|
+
const spec = T$1(SCHEMALESS);
|
|
63812
|
+
try {
|
|
63813
|
+
return N(ae(toMcpCliArgv(options), spec), spec);
|
|
63814
|
+
} catch {
|
|
63815
|
+
return false;
|
|
63816
|
+
}
|
|
63817
|
+
}
|
|
63818
|
+
/** `-F` is the only input whose meaning depends on the tool's schema. */
|
|
63819
|
+
function needsMcpToolSchema(options) {
|
|
63820
|
+
return (options.field ?? []).length > 0;
|
|
63821
|
+
}
|
|
63822
|
+
async function readStream(stream) {
|
|
63823
|
+
const chunks = [];
|
|
63824
|
+
for await (const chunk of stream) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
63825
|
+
return Buffer.concat(chunks);
|
|
62558
63826
|
}
|
|
62559
|
-
/**
|
|
63827
|
+
/**
|
|
63828
|
+
* Builds tools/call arguments with the `@runtypelabs/mcp-cli` input layer: `--input`/`--json-body`,
|
|
63829
|
+
* then `-f`/`-F` deep-merged over it. Given the tool, `-F id=123` stays a string for a string field.
|
|
63830
|
+
*/
|
|
62560
63831
|
async function resolveMcpArguments(options, dependencies = {}) {
|
|
62561
63832
|
let stdinPromise;
|
|
62562
63833
|
const deps = {
|
|
62563
|
-
readFile,
|
|
63834
|
+
readFile: (path) => readFile(path),
|
|
62564
63835
|
readStdin: () => {
|
|
62565
63836
|
stdinPromise ??= readStream(process.stdin);
|
|
62566
63837
|
return stdinPromise;
|
|
62567
63838
|
},
|
|
62568
63839
|
...dependencies
|
|
62569
63840
|
};
|
|
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;
|
|
63841
|
+
const toolSpec = T$1(deps.tool ?? SCHEMALESS);
|
|
63842
|
+
const spec = toolSpec.bodyOnly ? T$1(SCHEMALESS) : {
|
|
63843
|
+
...toolSpec,
|
|
63844
|
+
required: [],
|
|
63845
|
+
positionals: []
|
|
63846
|
+
};
|
|
63847
|
+
const { args } = await P(spec, ae(toMcpCliArgv(options), spec), {
|
|
63848
|
+
readFile: deps.readFile,
|
|
63849
|
+
readStdin: deps.readStdin,
|
|
63850
|
+
stdinIsPipedData: () => false,
|
|
63851
|
+
noInput: true
|
|
63852
|
+
});
|
|
63853
|
+
return args;
|
|
62603
63854
|
}
|
|
62604
63855
|
// src/commands/mcp.ts
|
|
62605
63856
|
const defaultDependencies$1 = {
|
|
62606
63857
|
ensureAuth,
|
|
62607
63858
|
connect: connectMcpClient,
|
|
62608
|
-
resolveArguments: resolveMcpArguments,
|
|
63859
|
+
resolveArguments: (options, tool) => resolveMcpArguments(options, { tool }),
|
|
62609
63860
|
setExitCode: (code) => {
|
|
62610
63861
|
process.exitCode = code;
|
|
62611
63862
|
}
|
|
62612
63863
|
};
|
|
62613
63864
|
const DEFAULT_TOOL_TIMEOUT_MS = 93e4;
|
|
63865
|
+
const TOOL_SCHEMA_LOOKUP_TIMEOUT_MS = 1e4;
|
|
63866
|
+
/** Listing for `-F` must not make the SDK enforce `outputSchema`, which a call without `-F` never does. */
|
|
63867
|
+
function withoutOutputSchema(tool) {
|
|
63868
|
+
const { outputSchema: _outputSchema, ...definition } = tool;
|
|
63869
|
+
return definition;
|
|
63870
|
+
}
|
|
62614
63871
|
function collectField(value, previous) {
|
|
62615
63872
|
return previous.concat(value);
|
|
62616
63873
|
}
|
|
@@ -62649,10 +63906,11 @@ function printTools(tools, target) {
|
|
|
62649
63906
|
}
|
|
62650
63907
|
const label = target === "code" ? "Code Mode MCP Tools" : "MCP Tools";
|
|
62651
63908
|
console.log(chalk.cyan(`${label}:`));
|
|
62652
|
-
|
|
62653
|
-
|
|
62654
|
-
|
|
62655
|
-
}
|
|
63909
|
+
const rows = $(l(tools), true).map((row) => ({
|
|
63910
|
+
...row,
|
|
63911
|
+
command: row.tool
|
|
63912
|
+
}));
|
|
63913
|
+
process.stdout.write(de(rows));
|
|
62656
63914
|
console.log(chalk.dim(`\n Total: ${tools.length} tools`));
|
|
62657
63915
|
}
|
|
62658
63916
|
function printTool(tool) {
|
|
@@ -62669,6 +63927,14 @@ function printTool(tool) {
|
|
|
62669
63927
|
label: "Description",
|
|
62670
63928
|
value: tool.description
|
|
62671
63929
|
},
|
|
63930
|
+
{
|
|
63931
|
+
label: "Signature",
|
|
63932
|
+
value: W(tool)
|
|
63933
|
+
},
|
|
63934
|
+
{
|
|
63935
|
+
label: "Hints",
|
|
63936
|
+
value: B(tool).join(", ") || void 0
|
|
63937
|
+
},
|
|
62672
63938
|
{
|
|
62673
63939
|
label: "Input Schema",
|
|
62674
63940
|
value: tool.inputSchema
|
|
@@ -62692,12 +63958,10 @@ function printCallResult(result, json) {
|
|
|
62692
63958
|
printJson(result);
|
|
62693
63959
|
return;
|
|
62694
63960
|
}
|
|
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"));
|
|
63961
|
+
const textOnly = result.content.length > 0 && result.content.every((block) => block.type === "text");
|
|
63962
|
+
if (result.structuredContent !== void 0 || textOnly) {
|
|
63963
|
+
const mode = e(void 0, { stdoutIsTTY: process.stdout.isTTY === true });
|
|
63964
|
+
console.log(h$2(result, { mode }));
|
|
62701
63965
|
return;
|
|
62702
63966
|
}
|
|
62703
63967
|
printJson(result);
|
|
@@ -62736,11 +64000,15 @@ function createMcpCommand(overrides = {}) {
|
|
|
62736
64000
|
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
64001
|
try {
|
|
62738
64002
|
await withMcpClient(options, dependencies, async (client) => {
|
|
62739
|
-
const
|
|
64003
|
+
const tool = needsMcpToolSchema(options) ? (await listAllMcpTools(client, { timeout: TOOL_SCHEMA_LOOKUP_TIMEOUT_MS }).catch(() => [])).find((item) => item.name === name) : void 0;
|
|
64004
|
+
const args = await dependencies.resolveArguments(options, tool);
|
|
62740
64005
|
const result = await client.callTool({
|
|
62741
64006
|
name,
|
|
62742
64007
|
arguments: args
|
|
62743
|
-
}, {
|
|
64008
|
+
}, {
|
|
64009
|
+
timeout: options.timeout,
|
|
64010
|
+
...tool ? { toolDefinition: withoutOutputSchema(tool) } : {}
|
|
64011
|
+
});
|
|
62744
64012
|
if (!("content" in result) || !Array.isArray(result.content)) throw new Error("Task-augmented MCP tool results are not supported by this command");
|
|
62745
64013
|
const callResult = result;
|
|
62746
64014
|
printCallResult(callResult, options.json);
|
|
@@ -69063,6 +70331,43 @@ function createHarnessCaptureFactory(options) {
|
|
|
69063
70331
|
});
|
|
69064
70332
|
return factory;
|
|
69065
70333
|
}
|
|
70334
|
+
// ../shared/dist/simulation/reported-usage.mjs
|
|
70335
|
+
const amount = number$2().finite().nonnegative();
|
|
70336
|
+
const tokens = amount.int();
|
|
70337
|
+
/** Producer estimates for one turn, independent of Runtype's measured usage and billing. */
|
|
70338
|
+
const reportedUsageSchema = object$4({
|
|
70339
|
+
costUsd: amount.nullable(),
|
|
70340
|
+
completeness: _enum(["complete", "partial"]),
|
|
70341
|
+
scope: string$2().min(1).max(120),
|
|
70342
|
+
models: array(object$4({
|
|
70343
|
+
model: string$2().min(1).max(200),
|
|
70344
|
+
canonicalModel: string$2().min(1).max(200).optional(),
|
|
70345
|
+
provider: string$2().max(100).optional(),
|
|
70346
|
+
pricingBasis: _enum([
|
|
70347
|
+
"list",
|
|
70348
|
+
"managed",
|
|
70349
|
+
"unknown"
|
|
70350
|
+
]).optional(),
|
|
70351
|
+
costUsd: amount.nullable().optional(),
|
|
70352
|
+
inputTokens: tokens.optional(),
|
|
70353
|
+
outputTokens: tokens.optional(),
|
|
70354
|
+
cacheReadInputTokens: tokens.optional(),
|
|
70355
|
+
cacheCreationInputTokens: tokens.optional()
|
|
70356
|
+
})).max(100).optional()
|
|
70357
|
+
});
|
|
70358
|
+
/** Known estimates and reporting coverage; a partial sum is never a whole-episode cost. */
|
|
70359
|
+
const selfReportedCostSchema = object$4({
|
|
70360
|
+
knownCostUsd: amount.nullable(),
|
|
70361
|
+
reportedTurns: tokens,
|
|
70362
|
+
totalTurns: tokens,
|
|
70363
|
+
completeTurns: tokens,
|
|
70364
|
+
unknownEpisodes: tokens.optional(),
|
|
70365
|
+
completeness: _enum([
|
|
70366
|
+
"complete",
|
|
70367
|
+
"partial",
|
|
70368
|
+
"unknown"
|
|
70369
|
+
])
|
|
70370
|
+
});
|
|
69066
70371
|
const simTerminationSchema = _enum([
|
|
69067
70372
|
"goal_met",
|
|
69068
70373
|
"gave_up",
|
|
@@ -69193,43 +70498,7 @@ const productKindSchema = _enum([
|
|
|
69193
70498
|
"external",
|
|
69194
70499
|
"spec_only"
|
|
69195
70500
|
]);
|
|
69196
|
-
// ../shared/dist/chunk-
|
|
69197
|
-
const amount = number$2().finite().nonnegative();
|
|
69198
|
-
const tokens = amount.int();
|
|
69199
|
-
/** Producer estimates for one turn, independent of Runtype's measured usage and billing. */
|
|
69200
|
-
const reportedUsageSchema = object$4({
|
|
69201
|
-
costUsd: amount.nullable(),
|
|
69202
|
-
completeness: _enum(["complete", "partial"]),
|
|
69203
|
-
scope: string$2().min(1).max(120),
|
|
69204
|
-
models: array(object$4({
|
|
69205
|
-
model: string$2().min(1).max(200),
|
|
69206
|
-
canonicalModel: string$2().min(1).max(200).optional(),
|
|
69207
|
-
provider: string$2().max(100).optional(),
|
|
69208
|
-
pricingBasis: _enum([
|
|
69209
|
-
"list",
|
|
69210
|
-
"managed",
|
|
69211
|
-
"unknown"
|
|
69212
|
-
]).optional(),
|
|
69213
|
-
costUsd: amount.nullable().optional(),
|
|
69214
|
-
inputTokens: tokens.optional(),
|
|
69215
|
-
outputTokens: tokens.optional(),
|
|
69216
|
-
cacheReadInputTokens: tokens.optional(),
|
|
69217
|
-
cacheCreationInputTokens: tokens.optional()
|
|
69218
|
-
})).max(100).optional()
|
|
69219
|
-
});
|
|
69220
|
-
/** Known estimates and reporting coverage; a partial sum is never a whole-episode cost. */
|
|
69221
|
-
const selfReportedCostSchema = object$4({
|
|
69222
|
-
knownCostUsd: amount.nullable(),
|
|
69223
|
-
reportedTurns: tokens,
|
|
69224
|
-
totalTurns: tokens,
|
|
69225
|
-
completeTurns: tokens,
|
|
69226
|
-
unknownEpisodes: tokens.optional(),
|
|
69227
|
-
completeness: _enum([
|
|
69228
|
-
"complete",
|
|
69229
|
-
"partial",
|
|
69230
|
-
"unknown"
|
|
69231
|
-
])
|
|
69232
|
-
});
|
|
70501
|
+
// ../shared/dist/chunk-BobaAxaK.mjs
|
|
69233
70502
|
/** The manifest file at the root of a candidate's source bundle. */
|
|
69234
70503
|
const CANDIDATE_MANIFEST_FILENAME = "runtype-candidate.json";
|
|
69235
70504
|
const candidateRuntimeSchema = _enum([
|
|
@@ -69805,7 +71074,8 @@ const targetRecordingSchema = object$4({
|
|
|
69805
71074
|
enabled: boolean(),
|
|
69806
71075
|
retentionDays: number$2().int().min(1).max(365)
|
|
69807
71076
|
});
|
|
69808
|
-
|
|
71077
|
+
/** One target's recording policy as admission froze it into the run plan. */
|
|
71078
|
+
const frozenTargetRecordingSchema = object$4({
|
|
69809
71079
|
mode: _enum([
|
|
69810
71080
|
"off",
|
|
69811
71081
|
"shape-only",
|
|
@@ -70989,6 +72259,10 @@ const toolDesignViewSchema = object$4({
|
|
|
70989
72259
|
chosenWrongly: number$2().int(),
|
|
70990
72260
|
/** Episodes with a wrong choice of this tool; absent on reports built before it was counted. */
|
|
70991
72261
|
chosenWronglyEpisodes: number$2().int().optional(),
|
|
72262
|
+
/** Calls naming this tool, including ones the proxy refused; absent on reports built before it was counted. */
|
|
72263
|
+
calls: number$2().int().optional(),
|
|
72264
|
+
/** Of those, the calls rejected for their arguments. */
|
|
72265
|
+
invalidArgumentCalls: number$2().int().optional(),
|
|
70992
72266
|
confusedWith: array(object$4({
|
|
70993
72267
|
tool: string$2(),
|
|
70994
72268
|
count: number$2().int()
|
|
@@ -71025,7 +72299,9 @@ const toolDesignViewSchema = object$4({
|
|
|
71025
72299
|
]),
|
|
71026
72300
|
times: number$2().int(),
|
|
71027
72301
|
episodes: number$2().int(),
|
|
71028
|
-
recoveredEpisodes: number$2().int()
|
|
72302
|
+
recoveredEpisodes: number$2().int(),
|
|
72303
|
+
/** The conversations that hit it; absent on reports built before they were listed. */
|
|
72304
|
+
episodeIds: array(string$2()).optional()
|
|
71029
72305
|
})),
|
|
71030
72306
|
wrongChoicesByClient: array(object$4({
|
|
71031
72307
|
clientModel: string$2(),
|
|
@@ -71051,8 +72327,14 @@ const overlayVerdictSchema = object$4({
|
|
|
71051
72327
|
passRateDifference: estimateIntervalSchema.nullable(),
|
|
71052
72328
|
verdict: simulationVerdictSchema,
|
|
71053
72329
|
hint: string$2().nullable(),
|
|
71054
|
-
/** The best overlay
|
|
71055
|
-
recommended: boolean()
|
|
72330
|
+
/** The best `better` overlay whose result stands on real answers, as the investment card judges; at most one. */
|
|
72331
|
+
recommended: boolean(),
|
|
72332
|
+
/** Injection and write-guard checks its own conversations failed; absent when none. Never recommended then. */
|
|
72333
|
+
safetyFailures: number$2().int().positive().optional(),
|
|
72334
|
+
/** Permission leaks on the targets its variants ran against, each target counted once; absent when none. */
|
|
72335
|
+
permissionLeaks: number$2().int().positive().optional(),
|
|
72336
|
+
/** Answers that weren't real decided the pairs that separate it, so its win doesn't hold without them. */
|
|
72337
|
+
heldBySynthesis: literal(true).optional()
|
|
71056
72338
|
});
|
|
71057
72339
|
/** The tool design view ("Agent experience", "The tool design view"); additive, so older reports render without it. */
|
|
71058
72340
|
const toolDesignSectionSchema = toolDesignViewSchema.extend({
|
|
@@ -71069,6 +72351,30 @@ const toolDesignSectionSchema = toolDesignViewSchema.extend({
|
|
|
71069
72351
|
overlays: array(overlayVerdictSchema).optional(),
|
|
71070
72352
|
/** Age in days of the oldest recorded answer the run replayed, as of its exchange cutoff; absent with no replay. */
|
|
71071
72353
|
recordedAnswerAgeDays: number$2().nonnegative().nullable().optional(),
|
|
72354
|
+
/** One row per scored conversation, for the "How each agent did" grid; absent on reports built before it. */
|
|
72355
|
+
conversations: array(object$4({
|
|
72356
|
+
episodeId: string$2(),
|
|
72357
|
+
variantId: string$2(),
|
|
72358
|
+
taskId: string$2().nullable(),
|
|
72359
|
+
clientModel: string$2(),
|
|
72360
|
+
trial: number$2().int().nonnegative(),
|
|
72361
|
+
outcome: _enum([
|
|
72362
|
+
"done",
|
|
72363
|
+
"doneAfterError",
|
|
72364
|
+
"wrongTool",
|
|
72365
|
+
"invalidArguments",
|
|
72366
|
+
"stuckOnError",
|
|
72367
|
+
"gaveUp"
|
|
72368
|
+
]),
|
|
72369
|
+
/** The tool the outcome is about: the one that errored, or the one picked wrongly. */
|
|
72370
|
+
tool: string$2().optional(),
|
|
72371
|
+
/** For a wrong tool: the tool the task needed. */
|
|
72372
|
+
intendedTool: string$2().optional(),
|
|
72373
|
+
/** For invalid arguments: the first argument path the server rejected. */
|
|
72374
|
+
argumentPath: string$2().optional(),
|
|
72375
|
+
/** For an error: its key in `errors`. */
|
|
72376
|
+
errorKey: string$2().optional()
|
|
72377
|
+
})).optional(),
|
|
71072
72378
|
/** Per tool: synthesized answers, contract failures, and how reviewers judged the frozen answers (D5). */
|
|
71073
72379
|
synthesis: array(object$4({
|
|
71074
72380
|
tool: string$2(),
|
|
@@ -71178,6 +72484,10 @@ const investmentSectionSchema = object$4({
|
|
|
71178
72484
|
clientModelStallPairsDropped: number$2().int().positive().optional(),
|
|
71179
72485
|
headline: _enum(["recommended", "indicative"]),
|
|
71180
72486
|
reason: string$2().nullable(),
|
|
72487
|
+
/** Injection and write-guard checks the design's own conversations failed; absent when none. Never recommended then. */
|
|
72488
|
+
safetyFailures: number$2().int().positive().optional(),
|
|
72489
|
+
/** Permission leaks on the targets its variants ran against, each target counted once; never recommended then. */
|
|
72490
|
+
permissionLeaks: number$2().int().positive().optional(),
|
|
71181
72491
|
success: object$4({
|
|
71182
72492
|
baseline: number$2(),
|
|
71183
72493
|
candidate: number$2(),
|
|
@@ -71885,10 +73195,18 @@ const draftSimulationToolsSchema = array(object$4({
|
|
|
71885
73195
|
/** The tool's input JSON Schema as the target listed it; the drafting agent reads its parameters. */
|
|
71886
73196
|
inputSchema: record$2(string$2(), unknown()).refine((schema) => jsonChars(schema) <= MAX_DRAFT_TOOL_INPUT_SCHEMA_CHARS, { message: `An inputSchema may take at most ${MAX_DRAFT_TOOL_INPUT_SCHEMA_CHARS} characters as JSON.` }).optional()
|
|
71887
73197
|
})).min(1).max(1e3).refine((tools) => tools.reduce((sum, tool) => sum + (tool.inputSchema ? jsonChars(tool.inputSchema) : 0), 0) <= MAX_DRAFT_TOOL_INPUT_SCHEMAS_TOTAL_CHARS, { message: `The inputSchemas of one request may take at most ${MAX_DRAFT_TOOL_INPUT_SCHEMAS_TOTAL_CHARS} characters together.` });
|
|
73198
|
+
/** Harder tasks than a simulation already runs: each chains two or more tool calls, around the tools agents used least. */
|
|
73199
|
+
const draftHarderTasksSchema = object$4({
|
|
73200
|
+
/** Tools agents called least in a report; when any is listed, every task uses at least one of them. */
|
|
73201
|
+
focusTools: array(string$2().min(1).max(128)).max(12),
|
|
73202
|
+
/** The titles of the tasks the simulation already has; a task repeating one is turned back. */
|
|
73203
|
+
existingTitles: array(string$2().min(1).max(255)).max(200)
|
|
73204
|
+
});
|
|
71888
73205
|
object$4({
|
|
71889
73206
|
targetName: string$2().min(1).max(255),
|
|
71890
73207
|
tools: draftSimulationToolsSchema,
|
|
71891
|
-
count: number$2().int().min(1).max(12).optional()
|
|
73208
|
+
count: number$2().int().min(1).max(12).optional(),
|
|
73209
|
+
harder: draftHarderTasksSchema.optional()
|
|
71892
73210
|
});
|
|
71893
73211
|
/** One drafted task; every `expectedTools` name is one the request listed. */
|
|
71894
73212
|
const draftedSimulationTaskSchema = object$4({
|
|
@@ -72003,11 +73321,18 @@ object$4({
|
|
|
72003
73321
|
trials: number$2().int().min(1).max(10).optional(),
|
|
72004
73322
|
trigger: simulationRunTriggerSchema.optional(),
|
|
72005
73323
|
/** The variant the others are compared against: one of the run's variants, over the simulation's own baseline. */
|
|
72006
|
-
baselineVariantId: entityId.optional()
|
|
73324
|
+
baselineVariantId: entityId.optional(),
|
|
73325
|
+
/**
|
|
73326
|
+
* A recording run: these server tools answer live on every variant, so the recorder keeps their real answers for
|
|
73327
|
+
* later replay. Every variant must be today's version (no overlay), and every target must record in `full`.
|
|
73328
|
+
*/
|
|
73329
|
+
recordTools: array(string$2().min(1).max(255)).min(1).max(64).optional()
|
|
72007
73330
|
});
|
|
72008
73331
|
discriminatedUnion("dryRun", [object$4({
|
|
72009
73332
|
dryRun: literal(true),
|
|
72010
|
-
estimate: runEstimateSchema
|
|
73333
|
+
estimate: runEstimateSchema,
|
|
73334
|
+
/** How each variant target would record this run, keyed by target id: the kill switch, then the target (D1). */
|
|
73335
|
+
recording: record$2(string$2(), frozenTargetRecordingSchema).optional()
|
|
72011
73336
|
}), object$4({
|
|
72012
73337
|
dryRun: literal(false),
|
|
72013
73338
|
runId: entityId,
|
|
@@ -72019,6 +73344,12 @@ const simulationRunResponseSchema = object$4({
|
|
|
72019
73344
|
run: simulationRunSchema,
|
|
72020
73345
|
reportId: entityId.nullable()
|
|
72021
73346
|
});
|
|
73347
|
+
object$4({
|
|
73348
|
+
/** Comma-separated server tools; the response then counts this run's live calls to each that the recorder kept. */
|
|
73349
|
+
recordedCallsFor: string$2().max(4096).optional() });
|
|
73350
|
+
simulationRunResponseSchema.extend({
|
|
73351
|
+
/** Per tool named in `recordedCallsFor`: this run's live calls the recorder kept, 0 for a tool with none. */
|
|
73352
|
+
recordedCalls: record$2(string$2(), number$2().int()).optional() });
|
|
72022
73353
|
object$4({ run: simulationRunSchema });
|
|
72023
73354
|
simulationRunResponseSchema.extend({ repair: object$4({
|
|
72024
73355
|
/** Episodes whose AI judge failed, graded again from their stored transcripts. */
|