@runtypelabs/cli 2.16.13 → 2.16.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +607 -261
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __require = /* @__PURE__ */ ((
|
|
4
|
+
var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
|
|
5
5
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
-
}) :
|
|
6
|
+
}) : x2)(function(x2) {
|
|
7
7
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
|
-
throw Error('Dynamic require of "' +
|
|
8
|
+
throw Error('Dynamic require of "' + x2 + '" is not supported');
|
|
9
9
|
});
|
|
10
10
|
var __esm = (fn, res) => function __init() {
|
|
11
11
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -741,10 +741,10 @@ function evaluateOperand(operand, context) {
|
|
|
741
741
|
}
|
|
742
742
|
function countTrailingBackslashes(s, i) {
|
|
743
743
|
let n = 0;
|
|
744
|
-
let
|
|
745
|
-
while (
|
|
744
|
+
let j2 = i - 1;
|
|
745
|
+
while (j2 >= 0 && s[j2] === "\\") {
|
|
746
746
|
n++;
|
|
747
|
-
|
|
747
|
+
j2--;
|
|
748
748
|
}
|
|
749
749
|
return n;
|
|
750
750
|
}
|
|
@@ -1581,8 +1581,8 @@ function assertNever(_x) {
|
|
|
1581
1581
|
function assert(_) {
|
|
1582
1582
|
}
|
|
1583
1583
|
function getEnumValues(entries) {
|
|
1584
|
-
const numericValues = Object.values(entries).filter((
|
|
1585
|
-
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_,
|
|
1584
|
+
const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
|
|
1585
|
+
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v2]) => v2);
|
|
1586
1586
|
return values;
|
|
1587
1587
|
}
|
|
1588
1588
|
function joinValues(array2, separator = "|") {
|
|
@@ -1636,9 +1636,9 @@ function defineLazy(object2, key, getter) {
|
|
|
1636
1636
|
}
|
|
1637
1637
|
return value;
|
|
1638
1638
|
},
|
|
1639
|
-
set(
|
|
1639
|
+
set(v2) {
|
|
1640
1640
|
Object.defineProperty(object2, key, {
|
|
1641
|
-
value:
|
|
1641
|
+
value: v2
|
|
1642
1642
|
// configurable: true,
|
|
1643
1643
|
});
|
|
1644
1644
|
},
|
|
@@ -1710,8 +1710,8 @@ var allowsEval = /* @__PURE__ */ cached(() => {
|
|
|
1710
1710
|
return false;
|
|
1711
1711
|
}
|
|
1712
1712
|
try {
|
|
1713
|
-
const
|
|
1714
|
-
new
|
|
1713
|
+
const F2 = Function;
|
|
1714
|
+
new F2("");
|
|
1715
1715
|
return true;
|
|
1716
1716
|
} catch (_) {
|
|
1717
1717
|
return false;
|
|
@@ -2059,21 +2059,21 @@ function required(Class2, schema, mask) {
|
|
|
2059
2059
|
});
|
|
2060
2060
|
return clone(schema, def);
|
|
2061
2061
|
}
|
|
2062
|
-
function aborted(
|
|
2063
|
-
if (
|
|
2062
|
+
function aborted(x2, startIndex = 0) {
|
|
2063
|
+
if (x2.aborted === true)
|
|
2064
2064
|
return true;
|
|
2065
|
-
for (let i = startIndex; i <
|
|
2066
|
-
if (
|
|
2065
|
+
for (let i = startIndex; i < x2.issues.length; i++) {
|
|
2066
|
+
if (x2.issues[i]?.continue !== true) {
|
|
2067
2067
|
return true;
|
|
2068
2068
|
}
|
|
2069
2069
|
}
|
|
2070
2070
|
return false;
|
|
2071
2071
|
}
|
|
2072
|
-
function explicitlyAborted(
|
|
2073
|
-
if (
|
|
2072
|
+
function explicitlyAborted(x2, startIndex = 0) {
|
|
2073
|
+
if (x2.aborted === true)
|
|
2074
2074
|
return true;
|
|
2075
|
-
for (let i = startIndex; i <
|
|
2076
|
-
if (
|
|
2075
|
+
for (let i = startIndex; i < x2.issues.length; i++) {
|
|
2076
|
+
if (x2.issues[i]?.continue === false) {
|
|
2077
2077
|
return true;
|
|
2078
2078
|
}
|
|
2079
2079
|
}
|
|
@@ -3150,19 +3150,19 @@ var Doc = class {
|
|
|
3150
3150
|
return;
|
|
3151
3151
|
}
|
|
3152
3152
|
const content = arg;
|
|
3153
|
-
const lines = content.split("\n").filter((
|
|
3154
|
-
const minIndent = Math.min(...lines.map((
|
|
3155
|
-
const dedented = lines.map((
|
|
3153
|
+
const lines = content.split("\n").filter((x2) => x2);
|
|
3154
|
+
const minIndent = Math.min(...lines.map((x2) => x2.length - x2.trimStart().length));
|
|
3155
|
+
const dedented = lines.map((x2) => x2.slice(minIndent)).map((x2) => " ".repeat(this.indent * 2) + x2);
|
|
3156
3156
|
for (const line of dedented) {
|
|
3157
3157
|
this.content.push(line);
|
|
3158
3158
|
}
|
|
3159
3159
|
}
|
|
3160
3160
|
compile() {
|
|
3161
|
-
const
|
|
3161
|
+
const F2 = Function;
|
|
3162
3162
|
const args = this?.args;
|
|
3163
3163
|
const content = this?.content ?? [``];
|
|
3164
|
-
const lines = [...content.map((
|
|
3165
|
-
return new
|
|
3164
|
+
const lines = [...content.map((x2) => ` ${x2}`)];
|
|
3165
|
+
return new F2(...args, lines.join("\n"));
|
|
3166
3166
|
}
|
|
3167
3167
|
};
|
|
3168
3168
|
|
|
@@ -3325,10 +3325,10 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
|
3325
3325
|
v7: 7,
|
|
3326
3326
|
v8: 8
|
|
3327
3327
|
};
|
|
3328
|
-
const
|
|
3329
|
-
if (
|
|
3328
|
+
const v2 = versionMap[def.version];
|
|
3329
|
+
if (v2 === void 0)
|
|
3330
3330
|
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
3331
|
-
def.pattern ?? (def.pattern = uuid(
|
|
3331
|
+
def.pattern ?? (def.pattern = uuid(v2));
|
|
3332
3332
|
} else
|
|
3333
3333
|
def.pattern ?? (def.pattern = uuid());
|
|
3334
3334
|
$ZodStringFormat.init(inst, def);
|
|
@@ -3538,7 +3538,7 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
3538
3538
|
function isValidBase64URL(data) {
|
|
3539
3539
|
if (!base64url.test(data))
|
|
3540
3540
|
return false;
|
|
3541
|
-
const base643 = data.replace(/[-_]/g, (
|
|
3541
|
+
const base643 = data.replace(/[-_]/g, (c2) => c2 === "-" ? "+" : "/");
|
|
3542
3542
|
const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
|
|
3543
3543
|
return isValidBase64(padded);
|
|
3544
3544
|
}
|
|
@@ -3933,8 +3933,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3933
3933
|
const field = shape[key]._zod;
|
|
3934
3934
|
if (field.values) {
|
|
3935
3935
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
3936
|
-
for (const
|
|
3937
|
-
propValues[key].add(
|
|
3936
|
+
for (const v2 of field.values)
|
|
3937
|
+
propValues[key].add(v2);
|
|
3938
3938
|
}
|
|
3939
3939
|
}
|
|
3940
3940
|
return propValues;
|
|
@@ -4229,10 +4229,10 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
4229
4229
|
const pv = option._zod.propValues;
|
|
4230
4230
|
if (!pv || Object.keys(pv).length === 0)
|
|
4231
4231
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
4232
|
-
for (const [k,
|
|
4232
|
+
for (const [k, v2] of Object.entries(pv)) {
|
|
4233
4233
|
if (!propValues[k])
|
|
4234
4234
|
propValues[k] = /* @__PURE__ */ new Set();
|
|
4235
|
-
for (const val of
|
|
4235
|
+
for (const val of v2) {
|
|
4236
4236
|
propValues[k].add(val);
|
|
4237
4237
|
}
|
|
4238
4238
|
}
|
|
@@ -4246,11 +4246,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
4246
4246
|
const values = o._zod.propValues?.[def.discriminator];
|
|
4247
4247
|
if (!values || values.size === 0)
|
|
4248
4248
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
4249
|
-
for (const
|
|
4250
|
-
if (map2.has(
|
|
4251
|
-
throw new Error(`Duplicate discriminator value "${String(
|
|
4249
|
+
for (const v2 of values) {
|
|
4250
|
+
if (map2.has(v2)) {
|
|
4251
|
+
throw new Error(`Duplicate discriminator value "${String(v2)}"`);
|
|
4252
4252
|
}
|
|
4253
|
-
map2.set(
|
|
4253
|
+
map2.set(v2, o);
|
|
4254
4254
|
}
|
|
4255
4255
|
}
|
|
4256
4256
|
return map2;
|
|
@@ -4371,7 +4371,7 @@ function handleIntersectionResults(result, left, right) {
|
|
|
4371
4371
|
result.issues.push(iss);
|
|
4372
4372
|
}
|
|
4373
4373
|
}
|
|
4374
|
-
const bothKeys = [...unrecKeys].filter(([,
|
|
4374
|
+
const bothKeys = [...unrecKeys].filter(([, f2]) => f2.l && f2.r).map(([k]) => k);
|
|
4375
4375
|
if (bothKeys.length && unrecIssue) {
|
|
4376
4376
|
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
4377
4377
|
}
|
|
@@ -4885,8 +4885,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
|
4885
4885
|
var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
4886
4886
|
$ZodType.init(inst, def);
|
|
4887
4887
|
defineLazy(inst._zod, "values", () => {
|
|
4888
|
-
const
|
|
4889
|
-
return
|
|
4888
|
+
const v2 = def.innerType._zod.values;
|
|
4889
|
+
return v2 ? new Set([...v2].filter((x2) => x2 !== void 0)) : void 0;
|
|
4890
4890
|
});
|
|
4891
4891
|
inst._zod.parse = (payload, ctx) => {
|
|
4892
4892
|
const result = def.innerType._zod.run(payload, ctx);
|
|
@@ -5177,9 +5177,9 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
5177
5177
|
return payload;
|
|
5178
5178
|
};
|
|
5179
5179
|
inst.input = (...args) => {
|
|
5180
|
-
const
|
|
5180
|
+
const F2 = inst.constructor;
|
|
5181
5181
|
if (Array.isArray(args[0])) {
|
|
5182
|
-
return new
|
|
5182
|
+
return new F2({
|
|
5183
5183
|
type: "function",
|
|
5184
5184
|
input: new $ZodTuple({
|
|
5185
5185
|
type: "tuple",
|
|
@@ -5189,15 +5189,15 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
5189
5189
|
output: inst._def.output
|
|
5190
5190
|
});
|
|
5191
5191
|
}
|
|
5192
|
-
return new
|
|
5192
|
+
return new F2({
|
|
5193
5193
|
type: "function",
|
|
5194
5194
|
input: args[0],
|
|
5195
5195
|
output: inst._def.output
|
|
5196
5196
|
});
|
|
5197
5197
|
};
|
|
5198
5198
|
inst.output = (output) => {
|
|
5199
|
-
const
|
|
5200
|
-
return new
|
|
5199
|
+
const F2 = inst.constructor;
|
|
5200
|
+
return new F2({
|
|
5201
5201
|
type: "function",
|
|
5202
5202
|
input: inst._def.input,
|
|
5203
5203
|
output
|
|
@@ -7283,7 +7283,7 @@ var error17 = () => {
|
|
|
7283
7283
|
if (issue2.values.length === 1) {
|
|
7284
7284
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${stringifyPrimitive(issue2.values[0])}`;
|
|
7285
7285
|
}
|
|
7286
|
-
const stringified = issue2.values.map((
|
|
7286
|
+
const stringified = issue2.values.map((v2) => stringifyPrimitive(v2));
|
|
7287
7287
|
if (issue2.values.length === 2) {
|
|
7288
7288
|
return `\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${stringified[0]} \u05D0\u05D5 ${stringified[1]}`;
|
|
7289
7289
|
}
|
|
@@ -11252,8 +11252,8 @@ var $ZodRegistry = class {
|
|
|
11252
11252
|
if (p) {
|
|
11253
11253
|
const pm = { ...this.get(p) ?? {} };
|
|
11254
11254
|
delete pm.id;
|
|
11255
|
-
const
|
|
11256
|
-
return Object.keys(
|
|
11255
|
+
const f2 = { ...pm, ...this._map.get(schema) };
|
|
11256
|
+
return Object.keys(f2).length ? f2 : void 0;
|
|
11257
11257
|
}
|
|
11258
11258
|
return this._map.get(schema);
|
|
11259
11259
|
}
|
|
@@ -12038,7 +12038,7 @@ function _set(Class2, valueType, params) {
|
|
|
12038
12038
|
}
|
|
12039
12039
|
// @__NO_SIDE_EFFECTS__
|
|
12040
12040
|
function _enum(Class2, values, params) {
|
|
12041
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
12041
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
12042
12042
|
return new Class2({
|
|
12043
12043
|
type: "enum",
|
|
12044
12044
|
entries,
|
|
@@ -12243,8 +12243,8 @@ function _stringbool(Classes, _params) {
|
|
|
12243
12243
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
12244
12244
|
let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
|
|
12245
12245
|
if (params.case !== "sensitive") {
|
|
12246
|
-
truthyArray = truthyArray.map((
|
|
12247
|
-
falsyArray = falsyArray.map((
|
|
12246
|
+
truthyArray = truthyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
|
|
12247
|
+
falsyArray = falsyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
|
|
12248
12248
|
}
|
|
12249
12249
|
const truthySet = new Set(truthyArray);
|
|
12250
12250
|
const falsySet = new Set(falsyArray);
|
|
@@ -12786,9 +12786,9 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
|
12786
12786
|
var enumProcessor = (schema, _ctx, json2, _params) => {
|
|
12787
12787
|
const def = schema._zod.def;
|
|
12788
12788
|
const values = getEnumValues(def.entries);
|
|
12789
|
-
if (values.every((
|
|
12789
|
+
if (values.every((v2) => typeof v2 === "number"))
|
|
12790
12790
|
json2.type = "number";
|
|
12791
|
-
if (values.every((
|
|
12791
|
+
if (values.every((v2) => typeof v2 === "string"))
|
|
12792
12792
|
json2.type = "string";
|
|
12793
12793
|
json2.enum = values;
|
|
12794
12794
|
};
|
|
@@ -12821,13 +12821,13 @@ var literalProcessor = (schema, ctx, json2, _params) => {
|
|
|
12821
12821
|
json2.const = val;
|
|
12822
12822
|
}
|
|
12823
12823
|
} else {
|
|
12824
|
-
if (vals.every((
|
|
12824
|
+
if (vals.every((v2) => typeof v2 === "number"))
|
|
12825
12825
|
json2.type = "number";
|
|
12826
|
-
if (vals.every((
|
|
12826
|
+
if (vals.every((v2) => typeof v2 === "string"))
|
|
12827
12827
|
json2.type = "string";
|
|
12828
|
-
if (vals.every((
|
|
12828
|
+
if (vals.every((v2) => typeof v2 === "boolean"))
|
|
12829
12829
|
json2.type = "boolean";
|
|
12830
|
-
if (vals.every((
|
|
12830
|
+
if (vals.every((v2) => v2 === null))
|
|
12831
12831
|
json2.type = "null";
|
|
12832
12832
|
json2.enum = vals;
|
|
12833
12833
|
}
|
|
@@ -12863,7 +12863,7 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
|
|
|
12863
12863
|
Object.assign(_json, file2);
|
|
12864
12864
|
} else {
|
|
12865
12865
|
Object.assign(_json, file2);
|
|
12866
|
-
_json.anyOf = mime.map((
|
|
12866
|
+
_json.anyOf = mime.map((m2) => ({ contentMediaType: m2 }));
|
|
12867
12867
|
}
|
|
12868
12868
|
} else {
|
|
12869
12869
|
Object.assign(_json, file2);
|
|
@@ -12925,11 +12925,11 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
12925
12925
|
}
|
|
12926
12926
|
const allKeys = new Set(Object.keys(shape));
|
|
12927
12927
|
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
12928
|
-
const
|
|
12928
|
+
const v2 = def.shape[key]._zod;
|
|
12929
12929
|
if (ctx.io === "input") {
|
|
12930
|
-
return
|
|
12930
|
+
return v2.optin === void 0;
|
|
12931
12931
|
} else {
|
|
12932
|
-
return
|
|
12932
|
+
return v2.optout === void 0;
|
|
12933
12933
|
}
|
|
12934
12934
|
}));
|
|
12935
12935
|
if (requiredKeys.size > 0) {
|
|
@@ -12950,7 +12950,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
12950
12950
|
var unionProcessor = (schema, ctx, json2, params) => {
|
|
12951
12951
|
const def = schema._zod.def;
|
|
12952
12952
|
const isExclusive = def.inclusive === false;
|
|
12953
|
-
const options = def.options.map((
|
|
12953
|
+
const options = def.options.map((x2, i) => process2(x2, ctx, {
|
|
12954
12954
|
...params,
|
|
12955
12955
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
12956
12956
|
}));
|
|
@@ -12983,7 +12983,7 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
12983
12983
|
json2.type = "array";
|
|
12984
12984
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
12985
12985
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
12986
|
-
const prefixItems = def.items.map((
|
|
12986
|
+
const prefixItems = def.items.map((x2, i) => process2(x2, ctx, {
|
|
12987
12987
|
...params,
|
|
12988
12988
|
path: [...params.path, prefixPath, i]
|
|
12989
12989
|
}));
|
|
@@ -13049,7 +13049,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
13049
13049
|
}
|
|
13050
13050
|
const keyValues = keyType._zod.values;
|
|
13051
13051
|
if (keyValues) {
|
|
13052
|
-
const validKeyValues = [...keyValues].filter((
|
|
13052
|
+
const validKeyValues = [...keyValues].filter((v2) => typeof v2 === "string" || typeof v2 === "number");
|
|
13053
13053
|
if (validKeyValues.length > 0) {
|
|
13054
13054
|
json2.required = validKeyValues;
|
|
13055
13055
|
}
|
|
@@ -13614,12 +13614,12 @@ function _installLazyMethods(inst, group, methods) {
|
|
|
13614
13614
|
});
|
|
13615
13615
|
return bound;
|
|
13616
13616
|
},
|
|
13617
|
-
set(
|
|
13617
|
+
set(v2) {
|
|
13618
13618
|
Object.defineProperty(this, key, {
|
|
13619
13619
|
configurable: true,
|
|
13620
13620
|
writable: true,
|
|
13621
13621
|
enumerable: true,
|
|
13622
|
-
value:
|
|
13622
|
+
value: v2
|
|
13623
13623
|
});
|
|
13624
13624
|
}
|
|
13625
13625
|
});
|
|
@@ -14210,9 +14210,9 @@ var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
|
|
|
14210
14210
|
inst._zod.processJSONSchema = (ctx, json2, params) => dateProcessor(inst, ctx, json2, params);
|
|
14211
14211
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
14212
14212
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
14213
|
-
const
|
|
14214
|
-
inst.minDate =
|
|
14215
|
-
inst.maxDate =
|
|
14213
|
+
const c2 = inst._zod.bag;
|
|
14214
|
+
inst.minDate = c2.minimum ? new Date(c2.minimum) : null;
|
|
14215
|
+
inst.maxDate = c2.maximum ? new Date(c2.maximum) : null;
|
|
14216
14216
|
});
|
|
14217
14217
|
function date3(params) {
|
|
14218
14218
|
return _date(ZodDate, params);
|
|
@@ -14507,7 +14507,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
14507
14507
|
};
|
|
14508
14508
|
});
|
|
14509
14509
|
function _enum2(values, params) {
|
|
14510
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((
|
|
14510
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
|
|
14511
14511
|
return new ZodEnum({
|
|
14512
14512
|
type: "enum",
|
|
14513
14513
|
entries,
|
|
@@ -15059,10 +15059,10 @@ function convertBaseSchema(schema, ctx) {
|
|
|
15059
15059
|
if (enumValues.length === 1) {
|
|
15060
15060
|
return z.literal(enumValues[0]);
|
|
15061
15061
|
}
|
|
15062
|
-
if (enumValues.every((
|
|
15062
|
+
if (enumValues.every((v2) => typeof v2 === "string")) {
|
|
15063
15063
|
return z.enum(enumValues);
|
|
15064
15064
|
}
|
|
15065
|
-
const literalSchemas = enumValues.map((
|
|
15065
|
+
const literalSchemas = enumValues.map((v2) => z.literal(v2));
|
|
15066
15066
|
if (literalSchemas.length < 2) {
|
|
15067
15067
|
return literalSchemas[0];
|
|
15068
15068
|
}
|
|
@@ -15438,6 +15438,14 @@ var externalAgentContextSchema = external_exports.object({
|
|
|
15438
15438
|
taskId: external_exports.string().optional()
|
|
15439
15439
|
});
|
|
15440
15440
|
var tokensSchema = external_exports.object({ input: external_exports.number(), output: external_exports.number() });
|
|
15441
|
+
var wireStopReasonSchema = external_exports.enum([
|
|
15442
|
+
"end_turn",
|
|
15443
|
+
"max_tool_calls",
|
|
15444
|
+
"length",
|
|
15445
|
+
"content_filter",
|
|
15446
|
+
"error",
|
|
15447
|
+
"unknown"
|
|
15448
|
+
]);
|
|
15441
15449
|
var estimatedContextBreakdownSchema = external_exports.object({
|
|
15442
15450
|
estimatedTotalTokens: external_exports.number(),
|
|
15443
15451
|
categories: external_exports.record(external_exports.string(), external_exports.object({ estimatedTokens: external_exports.number(), chars: external_exports.number() })),
|
|
@@ -15494,7 +15502,7 @@ var agentTurnCompleteEventSchema = external_exports.object({
|
|
|
15494
15502
|
content: external_exports.string().optional(),
|
|
15495
15503
|
tokens: tokensSchema.optional(),
|
|
15496
15504
|
cost: external_exports.number().optional(),
|
|
15497
|
-
stopReason:
|
|
15505
|
+
stopReason: wireStopReasonSchema.optional(),
|
|
15498
15506
|
estimatedContextBreakdown: estimatedContextBreakdownSchema.optional()
|
|
15499
15507
|
});
|
|
15500
15508
|
var agentToolStartEventSchema = external_exports.object({
|
|
@@ -15618,7 +15626,10 @@ var agentReflectionEventSchema = external_exports.object({
|
|
|
15618
15626
|
...baseAgentEvent,
|
|
15619
15627
|
type: external_exports.literal("agent_reflection"),
|
|
15620
15628
|
iteration: external_exports.number(),
|
|
15621
|
-
reflection: external_exports.string().optional()
|
|
15629
|
+
reflection: external_exports.string().optional(),
|
|
15630
|
+
// The runtime `AgentEventEmitter` injects an ISO timestamp on emit; mirrored
|
|
15631
|
+
// here for wire-superset parity (the api emitter omits it).
|
|
15632
|
+
timestamp: external_exports.string().optional()
|
|
15622
15633
|
});
|
|
15623
15634
|
var agentSkillLoadedEventSchema = external_exports.object({
|
|
15624
15635
|
...baseAgentEvent,
|
|
@@ -15628,7 +15639,9 @@ var agentSkillLoadedEventSchema = external_exports.object({
|
|
|
15628
15639
|
/** Skill slug (the part after `skill:`). */
|
|
15629
15640
|
skill: external_exports.string(),
|
|
15630
15641
|
/** Names of the capability tools this skill activated for later turns. */
|
|
15631
|
-
activatedCapabilities: external_exports.array(external_exports.string())
|
|
15642
|
+
activatedCapabilities: external_exports.array(external_exports.string()),
|
|
15643
|
+
// Runtime emitter injects an ISO timestamp on emit (api emitter omits it).
|
|
15644
|
+
timestamp: external_exports.string().optional()
|
|
15632
15645
|
});
|
|
15633
15646
|
var agentSkillProposedEventSchema = external_exports.object({
|
|
15634
15647
|
...baseAgentEvent,
|
|
@@ -15640,7 +15653,9 @@ var agentSkillProposedEventSchema = external_exports.object({
|
|
|
15640
15653
|
/** Review outcome: queued for review, or auto-published under the opt-out. */
|
|
15641
15654
|
outcome: external_exports.enum(["pending_approval", "auto_published"]),
|
|
15642
15655
|
/** Proposal audit-row id (for the dashboard review queue). */
|
|
15643
|
-
proposalId: external_exports.string().optional()
|
|
15656
|
+
proposalId: external_exports.string().optional(),
|
|
15657
|
+
// Runtime emitter injects an ISO timestamp on emit (api emitter omits it).
|
|
15658
|
+
timestamp: external_exports.string().optional()
|
|
15644
15659
|
});
|
|
15645
15660
|
var agentCompleteEventSchema = external_exports.object({
|
|
15646
15661
|
...baseAgentEvent,
|
|
@@ -15666,7 +15681,9 @@ var agentErrorEventSchema = external_exports.object({
|
|
|
15666
15681
|
message: external_exports.string(),
|
|
15667
15682
|
details: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
15668
15683
|
}),
|
|
15669
|
-
recoverable: external_exports.boolean()
|
|
15684
|
+
recoverable: external_exports.boolean(),
|
|
15685
|
+
// Runtime emitter injects an ISO timestamp on emit (api emitter omits it).
|
|
15686
|
+
timestamp: external_exports.string().optional()
|
|
15670
15687
|
});
|
|
15671
15688
|
var agentPingEventSchema = external_exports.object({
|
|
15672
15689
|
...baseAgentEvent,
|
|
@@ -15730,6 +15747,9 @@ var flowCompleteEventSchema = external_exports.object({
|
|
|
15730
15747
|
// The agent-dispatch / claude-managed paths emit via `formatFlowComplete({ success, duration })`,
|
|
15731
15748
|
// which omits both flowId and completedAt — so both are optional on the wire superset.
|
|
15732
15749
|
flowId: external_exports.string().optional(),
|
|
15750
|
+
// The api raw-write paths (engine.ts / virtual-flow.ts) spread `flowName: flow.name`
|
|
15751
|
+
// onto flow_complete; declared on flow_start too. Optional on the superset.
|
|
15752
|
+
flowName: external_exports.string().optional(),
|
|
15733
15753
|
// emitter/runtime send success+duration; api raw-writes send the step counts instead.
|
|
15734
15754
|
success: external_exports.boolean().optional(),
|
|
15735
15755
|
duration: external_exports.number().optional(),
|
|
@@ -15793,6 +15813,11 @@ var stepStartEventSchema = external_exports.object({
|
|
|
15793
15813
|
totalSteps: external_exports.number().optional(),
|
|
15794
15814
|
startedAt: external_exports.string(),
|
|
15795
15815
|
estimatedTokens: external_exports.number().optional(),
|
|
15816
|
+
// The step output-variable name. The api step-orchestrator spreads it onto
|
|
15817
|
+
// step_start (context + prompt step paths) and it survives the user-facing
|
|
15818
|
+
// filter; dashboard clients read it to unwrap the step's
|
|
15819
|
+
// `{ [outputVariable]: <rendered> }` envelope at render time.
|
|
15820
|
+
outputVariable: external_exports.string().optional(),
|
|
15796
15821
|
stepId: external_exports.string().optional(),
|
|
15797
15822
|
stepName: external_exports.string().optional(),
|
|
15798
15823
|
toolContext: toolContextSchema.optional()
|
|
@@ -15829,6 +15854,12 @@ var stepCompleteEventSchema = external_exports.object({
|
|
|
15829
15854
|
result: external_exports.unknown().optional(),
|
|
15830
15855
|
output: external_exports.unknown().optional(),
|
|
15831
15856
|
executionTime: external_exports.number().optional(),
|
|
15857
|
+
// Per-model-invocation finish reason. Only prompt steps carry it (the api
|
|
15858
|
+
// step-orchestrator raw-write spreads `...(emittedStopReason ? { stopReason } : {})`;
|
|
15859
|
+
// context steps omit it). Same `wireStopReasonSchema` vocabulary as
|
|
15860
|
+
// `agentTurnCompleteEventSchema.stopReason`. Persona reads it to attach a
|
|
15861
|
+
// stop-reason notice to the final assistant message.
|
|
15862
|
+
stopReason: wireStopReasonSchema.optional(),
|
|
15832
15863
|
stepId: external_exports.string().optional(),
|
|
15833
15864
|
stepName: external_exports.string().optional(),
|
|
15834
15865
|
toolContext: toolContextSchema.optional()
|
|
@@ -17393,41 +17424,41 @@ var PROVIDER_SECRET_SPECS = [
|
|
|
17393
17424
|
{
|
|
17394
17425
|
providerId: "google-vertex-anthropic",
|
|
17395
17426
|
// Must come before google-vertex (shares vertex prefix) and anthropic (matches */claude-*).
|
|
17396
|
-
matches: (
|
|
17427
|
+
matches: (m2) => m2.startsWith("vertex-anthropic/"),
|
|
17397
17428
|
secretNames: ["GOOGLE_VERTEX_PROJECT", "GOOGLE_VERTEX_LOCATION", "GOOGLE_VERTEX_CREDENTIALS"]
|
|
17398
17429
|
},
|
|
17399
17430
|
{
|
|
17400
17431
|
providerId: "google-vertex",
|
|
17401
17432
|
// Must come before google (matches */gemini-*).
|
|
17402
|
-
matches: (
|
|
17433
|
+
matches: (m2) => m2.startsWith("vertex/"),
|
|
17403
17434
|
secretNames: ["GOOGLE_VERTEX_PROJECT", "GOOGLE_VERTEX_LOCATION", "GOOGLE_VERTEX_CREDENTIALS"]
|
|
17404
17435
|
},
|
|
17405
17436
|
{
|
|
17406
17437
|
providerId: "vercel-gateway",
|
|
17407
17438
|
// Must come before openai — vercel/openai/gpt-4o would otherwise match openai.
|
|
17408
|
-
matches: (
|
|
17439
|
+
matches: (m2) => m2.startsWith("vercel/") || m2.startsWith("vercel."),
|
|
17409
17440
|
secretNames: ["VERCEL_AI_GATEWAY_API_KEY"]
|
|
17410
17441
|
},
|
|
17411
17442
|
{
|
|
17412
17443
|
providerId: "cloudflare-gateway",
|
|
17413
17444
|
// Must come before workers-ai — cloudflare/<provider>/<model> needs gateway routing.
|
|
17414
|
-
matches: (
|
|
17445
|
+
matches: (m2) => m2.startsWith("cloudflare/") || m2.startsWith("cloudflare:"),
|
|
17415
17446
|
secretNames: ["CF_ACCOUNT_ID", "CF_AI_GATEWAY_ID"]
|
|
17416
17447
|
},
|
|
17417
17448
|
{
|
|
17418
17449
|
providerId: "bedrock",
|
|
17419
|
-
matches: (
|
|
17450
|
+
matches: (m2) => m2.startsWith("bedrock/"),
|
|
17420
17451
|
secretNames: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION"]
|
|
17421
17452
|
},
|
|
17422
17453
|
{
|
|
17423
17454
|
providerId: "tinfoil",
|
|
17424
|
-
matches: (
|
|
17455
|
+
matches: (m2) => m2.startsWith("tinfoil/") || m2.startsWith("tinfoil:"),
|
|
17425
17456
|
secretNames: ["TINFOIL_API_KEY"]
|
|
17426
17457
|
},
|
|
17427
17458
|
{
|
|
17428
17459
|
providerId: "generic-openai",
|
|
17429
17460
|
// Must come before openai — shares the openai substring in its prefix.
|
|
17430
|
-
matches: (
|
|
17461
|
+
matches: (m2) => m2.startsWith("generic-openai/") || m2.startsWith("generic-openai:"),
|
|
17431
17462
|
secretNames: ["GENERIC_OPENAI_API_KEY", "GENERIC_OPENAI_BASE_URL"]
|
|
17432
17463
|
},
|
|
17433
17464
|
{
|
|
@@ -17436,34 +17467,34 @@ var PROVIDER_SECRET_SPECS = [
|
|
|
17436
17467
|
// host. Models are addressed only with the explicit `general-compute/` prefix
|
|
17437
17468
|
// (e.g. `general-compute/minimax-m2.7`) so they never collide with the same
|
|
17438
17469
|
// bare model id served by another gateway (Vercel already routes `minimax-m2.7`).
|
|
17439
|
-
matches: (
|
|
17470
|
+
matches: (m2) => m2.startsWith("general-compute/") || m2.startsWith("general-compute:"),
|
|
17440
17471
|
secretNames: ["GENERAL_COMPUTE_API_KEY"]
|
|
17441
17472
|
},
|
|
17442
17473
|
{
|
|
17443
17474
|
providerId: "workers-ai",
|
|
17444
17475
|
// Uses a CF platform binding, not a secret — secretNames is intentionally empty.
|
|
17445
|
-
matches: (
|
|
17476
|
+
matches: (m2) => m2.startsWith("@cf/") || m2.startsWith("workers-ai/"),
|
|
17446
17477
|
secretNames: []
|
|
17447
17478
|
},
|
|
17448
17479
|
{
|
|
17449
17480
|
providerId: "togetherai",
|
|
17450
|
-
matches: (
|
|
17481
|
+
matches: (m2) => m2.startsWith("together/") || m2.startsWith("togetherai/"),
|
|
17451
17482
|
secretNames: ["TOGETHER_API_KEY"]
|
|
17452
17483
|
},
|
|
17453
17484
|
// ----- Base providers (broader patterns — must come last) -----
|
|
17454
17485
|
{
|
|
17455
17486
|
providerId: "anthropic",
|
|
17456
|
-
matches: (
|
|
17487
|
+
matches: (m2) => m2.startsWith("anthropic/") || m2.startsWith("claude-") || m2.includes("/claude-"),
|
|
17457
17488
|
secretNames: ["ANTHROPIC_API_KEY"]
|
|
17458
17489
|
},
|
|
17459
17490
|
{
|
|
17460
17491
|
providerId: "openai",
|
|
17461
|
-
matches: (
|
|
17492
|
+
matches: (m2) => m2.startsWith("openai/") || m2.startsWith("gpt-") || m2.startsWith("o1-") || m2.startsWith("o3-") || m2.startsWith("o4-") || m2.includes("/gpt-"),
|
|
17462
17493
|
secretNames: ["OPENAI_API_KEY"]
|
|
17463
17494
|
},
|
|
17464
17495
|
{
|
|
17465
17496
|
providerId: "google",
|
|
17466
|
-
matches: (
|
|
17497
|
+
matches: (m2) => m2.startsWith("google/") || m2.startsWith("gemini-") || m2.includes("/gemini-"),
|
|
17467
17498
|
secretNames: ["GOOGLE_API_KEY"]
|
|
17468
17499
|
},
|
|
17469
17500
|
{
|
|
@@ -17472,12 +17503,12 @@ var PROVIDER_SECRET_SPECS = [
|
|
|
17472
17503
|
// explicit prefixes. Does NOT match closed Alibaba models (qwen3.5-flash/plus)
|
|
17473
17504
|
// which route through Vercel Gateway. See mixlayer-executor.ts for the
|
|
17474
17505
|
// canonical predicate mirrored here.
|
|
17475
|
-
matches: (
|
|
17506
|
+
matches: (m2) => m2.startsWith("mixlayer/") || m2.startsWith("modelsocket/") || m2.startsWith("qwen/") || m2.startsWith("kimi-") || m2.includes("/kimi-") || /(?:^|\/)qwen3[.-]5-\d+b(?:-a\d+b)?$/i.test(m2),
|
|
17476
17507
|
secretNames: ["MIXLAYER_API_KEY"]
|
|
17477
17508
|
},
|
|
17478
17509
|
{
|
|
17479
17510
|
providerId: "xai",
|
|
17480
|
-
matches: (
|
|
17511
|
+
matches: (m2) => m2.startsWith("grok-") || m2.startsWith("xai/"),
|
|
17481
17512
|
secretNames: ["XAI_API_KEY"]
|
|
17482
17513
|
}
|
|
17483
17514
|
];
|
|
@@ -17488,6 +17519,102 @@ function resolveModelSecretNames(model) {
|
|
|
17488
17519
|
}
|
|
17489
17520
|
return [];
|
|
17490
17521
|
}
|
|
17522
|
+
var RUNTIME_ARTIFACT_MANIFEST_VERSION = "2026-06-08";
|
|
17523
|
+
var runtimeArtifactResourceTypeSchema = external_exports.enum(["flow", "agent"]);
|
|
17524
|
+
var runtimeArtifactEntrypointSchema = external_exports.enum(["flow", "agent"]);
|
|
17525
|
+
var runtimeArtifactStatusSchema = external_exports.enum([
|
|
17526
|
+
"queued",
|
|
17527
|
+
"analyzing",
|
|
17528
|
+
"ineligible",
|
|
17529
|
+
"building",
|
|
17530
|
+
"uploaded",
|
|
17531
|
+
"active",
|
|
17532
|
+
"unhealthy",
|
|
17533
|
+
"failed",
|
|
17534
|
+
"disabled",
|
|
17535
|
+
"superseded"
|
|
17536
|
+
]);
|
|
17537
|
+
var runtimeArtifactSandboxSchema = external_exports.enum([
|
|
17538
|
+
"none",
|
|
17539
|
+
"worker-loader",
|
|
17540
|
+
"runtype-sandbox",
|
|
17541
|
+
"daytona"
|
|
17542
|
+
]);
|
|
17543
|
+
var runtimeArtifactServiceBackingSchema = external_exports.enum(["none", "service-binding"]);
|
|
17544
|
+
var runtimeArtifactPersistenceSchema = external_exports.enum(["none", "kv", "service-binding"]);
|
|
17545
|
+
var runtimeArtifactKeyModeSchema = external_exports.enum(["own", "platform", "hybrid"]);
|
|
17546
|
+
var runtimeArtifactBindingTypeSchema = external_exports.enum([
|
|
17547
|
+
"service",
|
|
17548
|
+
"kv_namespace",
|
|
17549
|
+
"dispatch_namespace",
|
|
17550
|
+
"worker_loader",
|
|
17551
|
+
"ai",
|
|
17552
|
+
"vectorize",
|
|
17553
|
+
"r2_bucket",
|
|
17554
|
+
"d1_database",
|
|
17555
|
+
"queue",
|
|
17556
|
+
"durable_object_namespace",
|
|
17557
|
+
"secret",
|
|
17558
|
+
"var"
|
|
17559
|
+
]);
|
|
17560
|
+
var runtimeArtifactBindingSchema = external_exports.object({
|
|
17561
|
+
name: external_exports.string().min(1),
|
|
17562
|
+
type: runtimeArtifactBindingTypeSchema,
|
|
17563
|
+
target: external_exports.string().min(1).optional(),
|
|
17564
|
+
optional: external_exports.boolean().optional()
|
|
17565
|
+
});
|
|
17566
|
+
var runtimeArtifactEligibilityReasonSchema = external_exports.object({
|
|
17567
|
+
code: external_exports.string().min(1),
|
|
17568
|
+
detail: external_exports.string().min(1),
|
|
17569
|
+
severity: external_exports.enum(["warning", "error"]).default("error")
|
|
17570
|
+
});
|
|
17571
|
+
var runtimeArtifactManifestSchema = external_exports.object({
|
|
17572
|
+
version: external_exports.literal(RUNTIME_ARTIFACT_MANIFEST_VERSION),
|
|
17573
|
+
resource: external_exports.object({
|
|
17574
|
+
type: runtimeArtifactResourceTypeSchema,
|
|
17575
|
+
id: external_exports.string().min(1),
|
|
17576
|
+
versionId: external_exports.string().min(1),
|
|
17577
|
+
exportHash: external_exports.string().min(1)
|
|
17578
|
+
}),
|
|
17579
|
+
runtime: external_exports.object({
|
|
17580
|
+
packageVersion: external_exports.string().min(1),
|
|
17581
|
+
schemaVersion: external_exports.string().min(1).optional(),
|
|
17582
|
+
entrypoint: runtimeArtifactEntrypointSchema
|
|
17583
|
+
}),
|
|
17584
|
+
capabilities: external_exports.object({
|
|
17585
|
+
stepTypes: external_exports.array(external_exports.string().min(1)),
|
|
17586
|
+
modelProviders: external_exports.array(external_exports.string().min(1)),
|
|
17587
|
+
runtimeToolTypes: external_exports.array(external_exports.string().min(1)),
|
|
17588
|
+
builtinToolIds: external_exports.array(external_exports.string().min(1)),
|
|
17589
|
+
hasSubagents: external_exports.boolean(),
|
|
17590
|
+
hasMcpServers: external_exports.boolean(),
|
|
17591
|
+
hasSkills: external_exports.boolean(),
|
|
17592
|
+
sandbox: runtimeArtifactSandboxSchema,
|
|
17593
|
+
records: runtimeArtifactServiceBackingSchema,
|
|
17594
|
+
vectorStore: runtimeArtifactServiceBackingSchema,
|
|
17595
|
+
persistence: runtimeArtifactPersistenceSchema
|
|
17596
|
+
}),
|
|
17597
|
+
cloudflare: external_exports.object({
|
|
17598
|
+
compatibilityDate: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
17599
|
+
compatibilityFlags: external_exports.array(external_exports.string().min(1)),
|
|
17600
|
+
bindings: external_exports.array(runtimeArtifactBindingSchema),
|
|
17601
|
+
limits: external_exports.object({
|
|
17602
|
+
cpuMs: external_exports.number().int().positive(),
|
|
17603
|
+
subRequests: external_exports.number().int().positive()
|
|
17604
|
+
}),
|
|
17605
|
+
tags: external_exports.array(external_exports.string().min(1)).max(8)
|
|
17606
|
+
}),
|
|
17607
|
+
security: external_exports.object({
|
|
17608
|
+
keyMode: runtimeArtifactKeyModeSchema,
|
|
17609
|
+
requiresDirectProviderSecrets: external_exports.boolean(),
|
|
17610
|
+
secretNames: external_exports.array(external_exports.string().min(1)),
|
|
17611
|
+
contextTokenAudience: external_exports.string().min(1)
|
|
17612
|
+
}),
|
|
17613
|
+
eligibility: external_exports.object({
|
|
17614
|
+
eligible: external_exports.boolean(),
|
|
17615
|
+
reasons: external_exports.array(runtimeArtifactEligibilityReasonSchema)
|
|
17616
|
+
})
|
|
17617
|
+
});
|
|
17491
17618
|
var EMIT_ARTIFACT_MARKDOWN_TOOL_ID = "emit_artifact_markdown";
|
|
17492
17619
|
var EMIT_ARTIFACT_COMPONENT_TOOL_ID = "emit_artifact_component";
|
|
17493
17620
|
var EMIT_ARTIFACT_MARKDOWN_FULL_ID = `builtin:${EMIT_ARTIFACT_MARKDOWN_TOOL_ID}`;
|
|
@@ -31786,10 +31913,10 @@ function isToolCompatibleWithModel(toolId, modelId, provider) {
|
|
|
31786
31913
|
if (!tool.modelCompatibility || tool.modelCompatibility.length === 0) {
|
|
31787
31914
|
return true;
|
|
31788
31915
|
}
|
|
31789
|
-
const compatibility = tool.modelCompatibility.find((
|
|
31916
|
+
const compatibility = tool.modelCompatibility.find((c2) => c2.provider === providerKey);
|
|
31790
31917
|
if (!compatibility) return true;
|
|
31791
31918
|
if (compatibility.models.length === 0) return true;
|
|
31792
|
-
return compatibility.models.some((
|
|
31919
|
+
return compatibility.models.some((m2) => modelId.includes(m2));
|
|
31793
31920
|
}
|
|
31794
31921
|
var SLACK_INTEGRATION = {
|
|
31795
31922
|
id: "slack",
|
|
@@ -33183,7 +33310,7 @@ var DEFAULT_MODELS_FOR_NEW_ACCOUNTS = [
|
|
|
33183
33310
|
// Google models (routed via Cloudflare Workers AI)
|
|
33184
33311
|
{ provider: "runtype", modelId: "gemma-4-26b-a4b-it", isDefault: false }
|
|
33185
33312
|
];
|
|
33186
|
-
var DEFAULT_MODEL_ID = DEFAULT_MODELS_FOR_NEW_ACCOUNTS.find((
|
|
33313
|
+
var DEFAULT_MODEL_ID = DEFAULT_MODELS_FOR_NEW_ACCOUNTS.find((m2) => m2.isDefault)?.modelId ?? "qwen/qwen3.5-9b";
|
|
33187
33314
|
var MODEL_FAMILY_PROVIDER_IDS = {
|
|
33188
33315
|
"claude-4-opus": {
|
|
33189
33316
|
"vercel": "anthropic/claude-4-opus"
|
|
@@ -34438,7 +34565,7 @@ var PLATFORM_KEY_PROVIDER_MAP = {
|
|
|
34438
34565
|
"mock": false
|
|
34439
34566
|
};
|
|
34440
34567
|
var PLATFORM_KEY_PROVIDERS = new Set(
|
|
34441
|
-
Object.entries(PLATFORM_KEY_PROVIDER_MAP).filter(([,
|
|
34568
|
+
Object.entries(PLATFORM_KEY_PROVIDER_MAP).filter(([, v2]) => v2).map(([k]) => k)
|
|
34442
34569
|
);
|
|
34443
34570
|
var MANUAL_PROVIDER_MAP_OVERRIDES = {
|
|
34444
34571
|
// Bedrock uses different model ID format
|
|
@@ -35489,18 +35616,18 @@ function extractSecretReferencesFromAnyValue(value, maxDepth = 10) {
|
|
|
35489
35616
|
const keys = /* @__PURE__ */ new Set();
|
|
35490
35617
|
walk(value, 0);
|
|
35491
35618
|
return Array.from(keys);
|
|
35492
|
-
function walk(
|
|
35619
|
+
function walk(v2, depth) {
|
|
35493
35620
|
if (depth > maxDepth) return;
|
|
35494
|
-
if (typeof
|
|
35495
|
-
for (const key of extractSecretReferences(
|
|
35621
|
+
if (typeof v2 === "string") {
|
|
35622
|
+
for (const key of extractSecretReferences(v2)) keys.add(key);
|
|
35496
35623
|
return;
|
|
35497
35624
|
}
|
|
35498
|
-
if (Array.isArray(
|
|
35499
|
-
for (const item of
|
|
35625
|
+
if (Array.isArray(v2)) {
|
|
35626
|
+
for (const item of v2) walk(item, depth + 1);
|
|
35500
35627
|
return;
|
|
35501
35628
|
}
|
|
35502
|
-
if (
|
|
35503
|
-
for (const inner of Object.values(
|
|
35629
|
+
if (v2 && typeof v2 === "object") {
|
|
35630
|
+
for (const inner of Object.values(v2)) {
|
|
35504
35631
|
walk(inner, depth + 1);
|
|
35505
35632
|
}
|
|
35506
35633
|
}
|
|
@@ -35722,7 +35849,7 @@ var capabilitySchema = external_exports.object({
|
|
|
35722
35849
|
}).refine(
|
|
35723
35850
|
(cap) => {
|
|
35724
35851
|
const set2 = [cap.flow, cap.agent, cap.existingFlowId, cap.existingAgentId].filter(
|
|
35725
|
-
(
|
|
35852
|
+
(v2) => v2 !== void 0 && v2 !== null
|
|
35726
35853
|
);
|
|
35727
35854
|
return set2.length === 1;
|
|
35728
35855
|
},
|
|
@@ -36090,7 +36217,7 @@ function validateCapability(cap, index, context) {
|
|
|
36090
36217
|
const result = emptyResult();
|
|
36091
36218
|
const base = `capabilities[${index}]`;
|
|
36092
36219
|
const backings = [cap.flow, cap.agent, cap.existingFlowId, cap.existingAgentId].filter(
|
|
36093
|
-
(
|
|
36220
|
+
(v2) => v2 !== void 0 && v2 !== null
|
|
36094
36221
|
);
|
|
36095
36222
|
if (backings.length === 0) {
|
|
36096
36223
|
result.errors.push(
|
|
@@ -36224,7 +36351,7 @@ function validateSurfaceDefinition(surface, index) {
|
|
|
36224
36351
|
}
|
|
36225
36352
|
function validateConnectivity(fpo) {
|
|
36226
36353
|
const result = emptyResult();
|
|
36227
|
-
const capabilityIds = new Set(fpo.capabilities.map((
|
|
36354
|
+
const capabilityIds = new Set(fpo.capabilities.map((c2) => c2.id));
|
|
36228
36355
|
for (const [si, surface] of fpo.surfaces.entries()) {
|
|
36229
36356
|
if (!surface.routes) continue;
|
|
36230
36357
|
for (const [ri, route] of surface.routes.entries()) {
|
|
@@ -36261,7 +36388,7 @@ function validateConnectivity(fpo) {
|
|
|
36261
36388
|
);
|
|
36262
36389
|
}
|
|
36263
36390
|
}
|
|
36264
|
-
const capabilityMap = new Map(fpo.capabilities.map((
|
|
36391
|
+
const capabilityMap = new Map(fpo.capabilities.map((c2) => [c2.id, c2]));
|
|
36265
36392
|
for (const [ci, cap] of fpo.capabilities.entries()) {
|
|
36266
36393
|
if (!cap.agent?.capabilityToolRefs) continue;
|
|
36267
36394
|
for (const [ri, ref] of cap.agent.capabilityToolRefs.entries()) {
|
|
@@ -37604,7 +37731,7 @@ ${lines.join("\n")}`;
|
|
|
37604
37731
|
var PLATFORM_FEATURES_SUMMARY = (() => {
|
|
37605
37732
|
const integrations = PLATFORM_CATALOG.availableIntegrations.map((i) => i.provider).join(", ");
|
|
37606
37733
|
const stepTypes = FLOW_STEP_TYPES.filter((t) => t !== "prompt").join(", ");
|
|
37607
|
-
const models = DEFAULT_MODELS_FOR_NEW_ACCOUNTS.map((
|
|
37734
|
+
const models = DEFAULT_MODELS_FOR_NEW_ACCOUNTS.map((m2) => m2.modelId).join(", ");
|
|
37608
37735
|
return `## Available Platform Features
|
|
37609
37736
|
|
|
37610
37737
|
- **Built-in tools**: GPT Image 2 image generation, provider-native web search (OpenAI web search, Anthropic web search/fetch, xAI Live Search for Grok-3 series, xAI X Search / Web Search agentic tools for Grok-4 series), Exa (AI search), Firecrawl (simple web scraping), Browser Run tools (rendered markdown, HTML, screenshots, snapshots, selector scraping, JSON extraction, link harvesting \u2014 stateless), Browser Session tools (persistent interactive browsing: open, navigate, click, type, scroll, screenshot, evaluate, close), Browser Agent (autonomous higher-level alternative \u2014 give a natural-language goal plus a startUrl or sessionId and the agent navigates/clicks/extracts on its own), Store Asset (host any file from a URL or base64 inline content \u2014 returns a permanent public or signed private URL, downloads as attachment), Publish Page (host HTML that renders inline in the browser at a shareable 7-day /preview/ URL under a locked-down CSP), vector search, UCP commerce tools (discovery, catalog, cart, checkout, orders for any UCP-enabled merchant)
|
|
@@ -38817,7 +38944,7 @@ import { theme } from "@runtypelabs/ink-components";
|
|
|
38817
38944
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
38818
38945
|
function EntityCard({ fields, title }) {
|
|
38819
38946
|
const visibleFields = fields.filter(
|
|
38820
|
-
(
|
|
38947
|
+
(f2) => f2.value !== null && f2.value !== void 0
|
|
38821
38948
|
);
|
|
38822
38949
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
38823
38950
|
title && /* @__PURE__ */ jsx(Text, { color: theme.primary, bold: true, children: title }),
|
|
@@ -41481,8 +41608,8 @@ configCommand.command("get [key]").description("Get configuration value").action
|
|
|
41481
41608
|
const allConfig = config2.store;
|
|
41482
41609
|
if (Object.keys(allConfig).length > 0) {
|
|
41483
41610
|
console.log(chalk9.cyan("Current Configuration:"));
|
|
41484
|
-
for (const [k,
|
|
41485
|
-
console.log(` ${chalk9.green(k)}: ${
|
|
41611
|
+
for (const [k, v2] of Object.entries(allConfig)) {
|
|
41612
|
+
console.log(` ${chalk9.green(k)}: ${v2}`);
|
|
41486
41613
|
}
|
|
41487
41614
|
} else {
|
|
41488
41615
|
console.log(chalk9.gray("No configuration set"));
|
|
@@ -43050,7 +43177,7 @@ logsCommand.command("stats").description("Aggregate log stats: totals, counts by
|
|
|
43050
43177
|
const formatCounts = (counts) => {
|
|
43051
43178
|
const entries = Object.entries(counts);
|
|
43052
43179
|
if (entries.length === 0) return "(none)";
|
|
43053
|
-
return entries.map(([k,
|
|
43180
|
+
return entries.map(([k, v2]) => `${k}=${v2}`).join(", ");
|
|
43054
43181
|
};
|
|
43055
43182
|
if (!isTTY(options) || options.json) {
|
|
43056
43183
|
try {
|
|
@@ -44369,8 +44496,8 @@ var dispatchCommand = new Command14("dispatch").description("Execute a flow or a
|
|
|
44369
44496
|
}
|
|
44370
44497
|
if (options.variable && options.variable.length > 0) {
|
|
44371
44498
|
const variables = {};
|
|
44372
|
-
for (const
|
|
44373
|
-
const [key, ...rest] =
|
|
44499
|
+
for (const v2 of options.variable) {
|
|
44500
|
+
const [key, ...rest] = v2.split("=");
|
|
44374
44501
|
variables[key] = rest.join("=");
|
|
44375
44502
|
}
|
|
44376
44503
|
payload.variables = variables;
|
|
@@ -44648,7 +44775,7 @@ Messages (${messages.length}):`));
|
|
|
44648
44775
|
try {
|
|
44649
44776
|
const data = await client.get(`/conversations/${id}`);
|
|
44650
44777
|
const messages = data.messages ?? [];
|
|
44651
|
-
const messageSummary = messages.length === 0 ? "No messages" : messages.map((
|
|
44778
|
+
const messageSummary = messages.length === 0 ? "No messages" : messages.map((m2) => `${m2.role}: ${m2.content}`).join("\n");
|
|
44652
44779
|
setResultNode(
|
|
44653
44780
|
React14.createElement(EntityCard, {
|
|
44654
44781
|
fields: [
|
|
@@ -47712,7 +47839,7 @@ function BlinkingTextInput({
|
|
|
47712
47839
|
return;
|
|
47713
47840
|
}
|
|
47714
47841
|
blinkRef.current = setInterval(() => {
|
|
47715
|
-
setBlinkVisible((
|
|
47842
|
+
setBlinkVisible((v2) => !v2);
|
|
47716
47843
|
}, CURSOR_BLINK_MS);
|
|
47717
47844
|
return () => {
|
|
47718
47845
|
if (blinkRef.current) {
|
|
@@ -47870,7 +47997,7 @@ function ModelPicker({ currentModel, onSelect, onCancel, models }) {
|
|
|
47870
47997
|
if (!search.trim()) return sorted;
|
|
47871
47998
|
const q = search.toLowerCase();
|
|
47872
47999
|
return sorted.filter(
|
|
47873
|
-
(
|
|
48000
|
+
(m2) => m2.label.toLowerCase().includes(q) || m2.value.toLowerCase().includes(q) || m2.group.toLowerCase().includes(q)
|
|
47874
48001
|
);
|
|
47875
48002
|
}, [sorted, search]);
|
|
47876
48003
|
const searchRef = useRef6("");
|
|
@@ -48250,8 +48377,8 @@ function TextArea({
|
|
|
48250
48377
|
const separator = theme21.separator ?? " \xB7 ";
|
|
48251
48378
|
const [lines, setLines] = useState23(() => splitLines(defaultValue));
|
|
48252
48379
|
const [cursor, setCursor] = useState23(() => {
|
|
48253
|
-
const
|
|
48254
|
-
return { line:
|
|
48380
|
+
const l2 = splitLines(defaultValue);
|
|
48381
|
+
return { line: l2.length - 1, col: l2[l2.length - 1].length };
|
|
48255
48382
|
});
|
|
48256
48383
|
const [scrollOffset, setScrollOffset] = useState23(0);
|
|
48257
48384
|
const [blinkVisible, setBlinkVisible] = useState23(true);
|
|
@@ -48262,7 +48389,7 @@ function TextArea({
|
|
|
48262
48389
|
cursorRef.current = cursor;
|
|
48263
48390
|
useEffect20(() => {
|
|
48264
48391
|
blinkRef.current = setInterval(() => {
|
|
48265
|
-
setBlinkVisible((
|
|
48392
|
+
setBlinkVisible((v2) => !v2);
|
|
48266
48393
|
}, CURSOR_BLINK_MS);
|
|
48267
48394
|
return () => {
|
|
48268
48395
|
if (blinkRef.current) {
|
|
@@ -48959,11 +49086,11 @@ function compactRawStreamEventForCopy(event) {
|
|
|
48959
49086
|
data = JSON.parse(JSON.stringify(event.listData, stringCompactionReplacer));
|
|
48960
49087
|
} else {
|
|
48961
49088
|
data = {};
|
|
48962
|
-
for (const [k,
|
|
49089
|
+
for (const [k, v2] of Object.entries(event.data)) {
|
|
48963
49090
|
if (STREAM_EVENT_HEAVY_KEYS.has(k)) {
|
|
48964
|
-
data[k] = compactHeavyField(
|
|
49091
|
+
data[k] = compactHeavyField(v2);
|
|
48965
49092
|
} else {
|
|
48966
|
-
data[k] = compactJsonLike(
|
|
49093
|
+
data[k] = compactJsonLike(v2);
|
|
48967
49094
|
}
|
|
48968
49095
|
}
|
|
48969
49096
|
}
|
|
@@ -49034,10 +49161,10 @@ function compactSessionSummaryForContextExport(s) {
|
|
|
49034
49161
|
...s.toolTraceSummary !== void 0 ? { toolTraceSummary: compactLongText(s.toolTraceSummary) } : {}
|
|
49035
49162
|
};
|
|
49036
49163
|
}
|
|
49037
|
-
function compactContinuationForContextExport(
|
|
49164
|
+
function compactContinuationForContextExport(c2) {
|
|
49038
49165
|
return {
|
|
49039
|
-
...
|
|
49040
|
-
...
|
|
49166
|
+
...c2,
|
|
49167
|
+
...c2.userMessage !== void 0 ? { userMessage: compactLongText(c2.userMessage) } : {}
|
|
49041
49168
|
};
|
|
49042
49169
|
}
|
|
49043
49170
|
function compactMarathonStateJsonForContextExport(parsed) {
|
|
@@ -49055,11 +49182,11 @@ function compactMarathonStateJsonForContextExport(parsed) {
|
|
|
49055
49182
|
(snap) => compactSessionSnapshotForContextExport(snap)
|
|
49056
49183
|
);
|
|
49057
49184
|
} else if (key === "messages" && Array.isArray(value)) {
|
|
49058
|
-
out[key] = value.map((
|
|
49185
|
+
out[key] = value.map((m2) => compactAgentMessageForContextExport(m2));
|
|
49059
49186
|
} else if (key === "sessions" && Array.isArray(value)) {
|
|
49060
49187
|
out[key] = value.map((s) => compactSessionSummaryForContextExport(s));
|
|
49061
49188
|
} else if (key === "continuations" && Array.isArray(value)) {
|
|
49062
|
-
out[key] = value.map((
|
|
49189
|
+
out[key] = value.map((c2) => compactContinuationForContextExport(c2));
|
|
49063
49190
|
} else if (key === "lastOutput" || key === "bootstrapContext" || key === "originalMessage" || key === "lastError" || key === "phaseTransitionSummary") {
|
|
49064
49191
|
out[key] = typeof value === "string" ? compactLongText(value) : value;
|
|
49065
49192
|
} else if (key === "workflowState" && value && typeof value === "object") {
|
|
@@ -49698,8 +49825,8 @@ function copyToClipboard(text) {
|
|
|
49698
49825
|
}
|
|
49699
49826
|
function isBlank(s) {
|
|
49700
49827
|
for (let i = 0; i < s.length; i++) {
|
|
49701
|
-
const
|
|
49702
|
-
if (
|
|
49828
|
+
const c2 = s.charCodeAt(i);
|
|
49829
|
+
if (c2 !== 32 && c2 !== 9 && c2 !== 10 && c2 !== 13) return false;
|
|
49703
49830
|
}
|
|
49704
49831
|
return true;
|
|
49705
49832
|
}
|
|
@@ -52351,7 +52478,7 @@ function findLatestStateFile(stateDir) {
|
|
|
52351
52478
|
let latest = null;
|
|
52352
52479
|
for (const dir of dirs) {
|
|
52353
52480
|
if (!fs7.existsSync(dir)) continue;
|
|
52354
|
-
const files = fs7.readdirSync(dir).filter((
|
|
52481
|
+
const files = fs7.readdirSync(dir).filter((f2) => f2.endsWith(".json"));
|
|
52355
52482
|
for (const file2 of files) {
|
|
52356
52483
|
const fullPath = path8.join(dir, file2);
|
|
52357
52484
|
const stat = fs7.statSync(fullPath);
|
|
@@ -53696,7 +53823,7 @@ function loadRules(cwd) {
|
|
|
53696
53823
|
if (!fs11.existsSync(rulesDir)) return [];
|
|
53697
53824
|
const rules = [];
|
|
53698
53825
|
try {
|
|
53699
|
-
const entries = fs11.readdirSync(rulesDir).filter((
|
|
53826
|
+
const entries = fs11.readdirSync(rulesDir).filter((f2) => f2.endsWith(".md"));
|
|
53700
53827
|
for (const entry of entries) {
|
|
53701
53828
|
const filePath = path12.join(rulesDir, entry);
|
|
53702
53829
|
try {
|
|
@@ -53950,15 +54077,15 @@ function loadPlaybook(nameOrPath, cwd) {
|
|
|
53950
54077
|
validatePlaybook(config3, candidate);
|
|
53951
54078
|
const milestoneModels = {};
|
|
53952
54079
|
const milestoneFallbackModels = {};
|
|
53953
|
-
for (const
|
|
53954
|
-
if (
|
|
53955
|
-
if (
|
|
53956
|
-
milestoneFallbackModels[
|
|
54080
|
+
for (const m2 of config3.milestones) {
|
|
54081
|
+
if (m2.model) milestoneModels[m2.name] = m2.model;
|
|
54082
|
+
if (m2.fallbackModels?.length) {
|
|
54083
|
+
milestoneFallbackModels[m2.name] = m2.fallbackModels.map(normalizeFallbackModel);
|
|
53957
54084
|
}
|
|
53958
54085
|
}
|
|
53959
54086
|
return {
|
|
53960
54087
|
workflow: convertToWorkflow(config3),
|
|
53961
|
-
milestones: config3.milestones.map((
|
|
54088
|
+
milestones: config3.milestones.map((m2) => m2.name),
|
|
53962
54089
|
milestoneModels: Object.keys(milestoneModels).length > 0 ? milestoneModels : void 0,
|
|
53963
54090
|
milestoneFallbackModels: Object.keys(milestoneFallbackModels).length > 0 ? milestoneFallbackModels : void 0,
|
|
53964
54091
|
verification: config3.verification,
|
|
@@ -53968,7 +54095,7 @@ function loadPlaybook(nameOrPath, cwd) {
|
|
|
53968
54095
|
}
|
|
53969
54096
|
throw new Error(
|
|
53970
54097
|
`Playbook '${nameOrPath}' not found. Searched:
|
|
53971
|
-
${candidates.map((
|
|
54098
|
+
${candidates.map((c2) => ` ${c2}`).join("\n")}`
|
|
53972
54099
|
);
|
|
53973
54100
|
}
|
|
53974
54101
|
|
|
@@ -54224,7 +54351,7 @@ async function taskAction(agent, options) {
|
|
|
54224
54351
|
options.model,
|
|
54225
54352
|
options.planningModel,
|
|
54226
54353
|
options.executionModel
|
|
54227
|
-
].filter((
|
|
54354
|
+
].filter((m2) => Boolean(m2))
|
|
54228
54355
|
)
|
|
54229
54356
|
];
|
|
54230
54357
|
let resolvedToolIds = [];
|
|
@@ -55275,11 +55402,11 @@ Saving state... done. Session saved to ${filePath}`);
|
|
|
55275
55402
|
if (finalState.continuations && finalState.continuations.length > 0) {
|
|
55276
55403
|
console.log(chalk23.dim("\nContinuation history:"));
|
|
55277
55404
|
for (let i = 0; i < finalState.continuations.length; i++) {
|
|
55278
|
-
const
|
|
55279
|
-
const msg =
|
|
55280
|
-
const modelName =
|
|
55405
|
+
const c2 = finalState.continuations[i];
|
|
55406
|
+
const msg = c2.userMessage ? ` "${c2.userMessage.slice(0, 50)}"` : " (no message)";
|
|
55407
|
+
const modelName = c2.model ? ` [${c2.model}]` : "";
|
|
55281
55408
|
console.log(
|
|
55282
|
-
chalk23.gray(` #${i + 1}: ${
|
|
55409
|
+
chalk23.gray(` #${i + 1}: ${c2.continuedAt}${modelName}${msg} \u2014 $${c2.segmentCost.toFixed(4)}`)
|
|
55283
55410
|
);
|
|
55284
55411
|
}
|
|
55285
55412
|
}
|
|
@@ -55924,10 +56051,10 @@ modelsCommand.command("available").description("List all available models groupe
|
|
|
55924
56051
|
const group = item;
|
|
55925
56052
|
return React17.createElement(EntityCard, {
|
|
55926
56053
|
title: `${group.provider} / ${group.baseModel}`,
|
|
55927
|
-
fields: group.variants.map((
|
|
55928
|
-
label:
|
|
55929
|
-
value:
|
|
55930
|
-
color:
|
|
56054
|
+
fields: group.variants.map((v2) => ({
|
|
56055
|
+
label: v2.modelId,
|
|
56056
|
+
value: v2.configured ? "configured" : "available",
|
|
56057
|
+
color: v2.configured ? "green" : void 0
|
|
55931
56058
|
}))
|
|
55932
56059
|
});
|
|
55933
56060
|
},
|
|
@@ -57744,14 +57871,304 @@ import { execFileSync } from "child_process";
|
|
|
57744
57871
|
// src/lib/persona-init.ts
|
|
57745
57872
|
init_credential_store();
|
|
57746
57873
|
|
|
57874
|
+
// ../../node_modules/.pnpm/@runtypelabs+persona@3.29.0/node_modules/@runtypelabs/persona/dist/codegen.js
|
|
57875
|
+
var S = { name: "@runtypelabs/persona", version: "3.29.0", description: "Themeable, pluggable streaming agent widget for websites, in plain JS with support for voice input and reasoning / tool output.", type: "module", main: "dist/index.cjs", module: "dist/index.js", types: "dist/index.d.ts", exports: { ".": { types: "./dist/index.d.ts", import: "./dist/index.js", require: "./dist/index.cjs" }, "./theme-reference": { types: "./dist/theme-reference.d.ts", import: "./dist/theme-reference.js", require: "./dist/theme-reference.cjs" }, "./codegen": { types: "./dist/codegen.d.ts", import: "./dist/codegen.js", require: "./dist/codegen.cjs" }, "./theme-editor": { types: "./dist/theme-editor.d.ts", import: "./dist/theme-editor.js", require: "./dist/theme-editor.cjs" }, "./testing": { types: "./dist/testing.d.ts", import: "./dist/testing.js", require: "./dist/testing.cjs" }, "./smart-dom-reader": { types: "./dist/smart-dom-reader.d.ts", import: "./dist/smart-dom-reader.js", require: "./dist/smart-dom-reader.cjs" }, "./animations/glyph-cycle": { types: "./dist/animations/glyph-cycle.d.ts", import: "./dist/animations/glyph-cycle.js", require: "./dist/animations/glyph-cycle.cjs" }, "./animations/wipe": { types: "./dist/animations/wipe.d.ts", import: "./dist/animations/wipe.js", require: "./dist/animations/wipe.cjs" }, "./widget.css": "./dist/widget.css" }, files: ["dist", "src"], scripts: { build: "rimraf dist && pnpm run build:styles && pnpm run build:client && pnpm run build:installer && pnpm run build:launcher && pnpm run build:theme-ref && pnpm run build:codegen && pnpm run build:theme-editor && pnpm run build:testing && pnpm run build:smart-dom-reader && pnpm run build:animations", "build:theme-editor": "tsup src/theme-editor.ts --format esm,cjs --minify --dts --out-dir dist --no-splitting", "build:testing": "tsup src/testing.ts --format esm,cjs --minify --dts --out-dir dist --no-splitting", "build:smart-dom-reader": "tsup src/smart-dom-reader.ts --format esm,cjs --minify --dts --out-dir dist --no-splitting", "build:animations": "tsup src/animations/glyph-cycle.ts src/animations/wipe.ts --format esm,cjs --minify --dts --out-dir dist/animations --no-splitting", "build:theme-ref": "tsup src/theme-reference.ts --format esm,cjs --minify --dts", "build:codegen": "tsup src/codegen.ts --format esm,cjs --minify --dts", "build:styles": `node -e "const fs=require('fs');fs.mkdirSync('dist',{recursive:true});fs.copyFileSync('src/styles/widget.css','dist/widget.css');"`, "build:client": `tsup src/index.ts --format esm,cjs --minify --sourcemap --splitting false --dts --loader ".css=text" && tsup src/index-global.ts --format iife --global-name AgentWidget --minify --sourcemap --splitting false --out-dir dist --loader ".css=text" && node -e "const fs=require('fs');for(const ext of ['.global.js','.global.js.map']){const from='dist/index-global'+ext;if(fs.existsSync(from))fs.renameSync(from,'dist/index'+ext);}"`, "build:installer": "tsup src/install.ts --format iife --global-name SiteAgentInstaller --out-dir dist --minify --sourcemap --no-splitting", "build:launcher": `tsup src/launcher-global.ts --format iife --global-name AgentWidgetLauncher --minify --sourcemap --splitting false --out-dir dist && node -e "const fs=require('fs');for(const ext of ['.global.js','.global.js.map']){const from='dist/launcher-global'+ext;if(fs.existsSync(from))fs.renameSync(from,'dist/launcher'+ext);}"`, lint: "eslint . --ext .ts", typecheck: "pnpm run check:runtype-types && tsc --noEmit", test: "vitest", "test:ui": "vitest --ui", "test:run": "vitest run", size: "size-limit", "fetch:runtype-openapi": "node scripts/fetch-runtype-openapi.mjs", "generate:runtype-types": "pnpm run fetch:runtype-openapi && node scripts/generate-runtype-openapi-types.mjs", "check:runtype-types": "pnpm run fetch:runtype-openapi && node scripts/generate-runtype-openapi-types.mjs --check" }, dependencies: { "@mcp-b/webmcp-polyfill": "^3.0.0", dompurify: "^3.3.3", idiomorph: "^0.7.4", lucide: "^0.552.0", marked: "^12.0.2", "partial-json": "^0.1.7", zod: "^3.22.4" }, devDependencies: { "@size-limit/file": "^12.1.0", "@types/node": "^20.12.7", "@typescript-eslint/eslint-plugin": "^7.0.0", "@typescript-eslint/parser": "^7.0.0", "@vitest/ui": "^4.0.9", eslint: "^8.57.0", "eslint-config-prettier": "^9.1.0", "fake-indexeddb": "^6.2.5", rimraf: "^5.0.5", "size-limit": "^12.1.0", tsup: "^8.0.1", typescript: "^5.4.5", vitest: "^4.0.9" }, engines: { node: ">=20.0.0" }, author: "Runtype", license: "MIT", keywords: ["ai", "chat", "widget", "streaming", "typescript", "persona", "agent"], repository: { type: "git", url: "git+https://github.com/runtypelabs/persona.git", directory: "packages/widget" }, bugs: { url: "https://github.com/runtypelabs/persona/issues" }, homepage: "https://github.com/runtypelabs/persona/tree/main/packages/widget#readme", publishConfig: { access: "public" } };
|
|
57876
|
+
var c = S.version;
|
|
57877
|
+
function u(e) {
|
|
57878
|
+
if (e !== void 0) return typeof e == "string" ? e : Array.isArray(e) ? `[${e.map((r) => r.toString()).join(", ")}]` : e.toString();
|
|
57879
|
+
}
|
|
57880
|
+
function T(e) {
|
|
57881
|
+
if (e) return { getHeaders: u(e.getHeaders), onFeedback: u(e.onFeedback), onCopy: u(e.onCopy), requestMiddleware: u(e.requestMiddleware), actionHandlers: u(e.actionHandlers), actionParsers: u(e.actionParsers), postprocessMessage: u(e.postprocessMessage), contextProviders: u(e.contextProviders), streamParser: u(e.streamParser) };
|
|
57882
|
+
}
|
|
57883
|
+
var x = `({ text, message }: any) => {
|
|
57884
|
+
const jsonSource = (message as any).rawContent || text || message.content;
|
|
57885
|
+
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
57886
|
+
let cleanJson = jsonSource
|
|
57887
|
+
.replace(/^\`\`\`(?:json)?\\s*\\n?/, '')
|
|
57888
|
+
.replace(/\\n?\`\`\`\\s*$/, '')
|
|
57889
|
+
.trim();
|
|
57890
|
+
if (!cleanJson.startsWith('{') || !cleanJson.endsWith('}')) return null;
|
|
57891
|
+
try {
|
|
57892
|
+
const parsed = JSON.parse(cleanJson);
|
|
57893
|
+
if (parsed.action) return { type: parsed.action, payload: parsed };
|
|
57894
|
+
} catch (e) { return null; }
|
|
57895
|
+
return null;
|
|
57896
|
+
}`;
|
|
57897
|
+
var A = `function(ctx) {
|
|
57898
|
+
var jsonSource = ctx.message.rawContent || ctx.text || ctx.message.content;
|
|
57899
|
+
if (!jsonSource || typeof jsonSource !== 'string') return null;
|
|
57900
|
+
var cleanJson = jsonSource
|
|
57901
|
+
.replace(/^\`\`\`(?:json)?\\s*\\n?/, '')
|
|
57902
|
+
.replace(/\\n?\`\`\`\\s*$/, '')
|
|
57903
|
+
.trim();
|
|
57904
|
+
if (!cleanJson.startsWith('{') || !cleanJson.endsWith('}')) return null;
|
|
57905
|
+
try {
|
|
57906
|
+
var parsed = JSON.parse(cleanJson);
|
|
57907
|
+
if (parsed.action) return { type: parsed.action, payload: parsed };
|
|
57908
|
+
} catch (e) { return null; }
|
|
57909
|
+
return null;
|
|
57910
|
+
}`;
|
|
57911
|
+
var O = `(action: any, context: any) => {
|
|
57912
|
+
if (action.type !== 'nav_then_click') return;
|
|
57913
|
+
const payload = action.payload || action.raw || {};
|
|
57914
|
+
const url = payload?.page;
|
|
57915
|
+
const text = payload?.on_load_text || 'Navigating...';
|
|
57916
|
+
if (!url) return { handled: true, displayText: text };
|
|
57917
|
+
const messageId = context.message?.id;
|
|
57918
|
+
const processedActions = JSON.parse(localStorage.getItem(PROCESSED_ACTIONS_KEY) || '[]');
|
|
57919
|
+
const actionKey = \`nav_\${messageId}_\${url}\`;
|
|
57920
|
+
if (processedActions.includes(actionKey)) {
|
|
57921
|
+
return { handled: true, displayText: text };
|
|
57922
|
+
}
|
|
57923
|
+
processedActions.push(actionKey);
|
|
57924
|
+
localStorage.setItem(PROCESSED_ACTIONS_KEY, JSON.stringify(processedActions));
|
|
57925
|
+
const targetUrl = url.startsWith('http') ? url : new URL(url, window.location.origin).toString();
|
|
57926
|
+
window.location.href = targetUrl;
|
|
57927
|
+
return { handled: true, displayText: text };
|
|
57928
|
+
}`;
|
|
57929
|
+
var E = `function(action, context) {
|
|
57930
|
+
if (action.type !== 'nav_then_click') return;
|
|
57931
|
+
var payload = action.payload || action.raw || {};
|
|
57932
|
+
var url = payload.page;
|
|
57933
|
+
var text = payload.on_load_text || 'Navigating...';
|
|
57934
|
+
if (!url) return { handled: true, displayText: text };
|
|
57935
|
+
var messageId = context.message ? context.message.id : null;
|
|
57936
|
+
var processedActions = JSON.parse(localStorage.getItem(PROCESSED_ACTIONS_KEY) || '[]');
|
|
57937
|
+
var actionKey = 'nav_' + messageId + '_' + url;
|
|
57938
|
+
if (processedActions.includes(actionKey)) {
|
|
57939
|
+
return { handled: true, displayText: text };
|
|
57940
|
+
}
|
|
57941
|
+
processedActions.push(actionKey);
|
|
57942
|
+
localStorage.setItem(PROCESSED_ACTIONS_KEY, JSON.stringify(processedActions));
|
|
57943
|
+
var targetUrl = url.startsWith('http') ? url : new URL(url, window.location.origin).toString();
|
|
57944
|
+
window.location.href = targetUrl;
|
|
57945
|
+
return { handled: true, displayText: text };
|
|
57946
|
+
}`;
|
|
57947
|
+
var M = `(parsed: any) => {
|
|
57948
|
+
if (!parsed || typeof parsed !== 'object') return null;
|
|
57949
|
+
if (parsed.action === 'nav_then_click') return 'Navigating...';
|
|
57950
|
+
if (parsed.action === 'message') return parsed.text || '';
|
|
57951
|
+
if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
|
|
57952
|
+
return parsed.text || null;
|
|
57953
|
+
}`;
|
|
57954
|
+
var R = `function(parsed) {
|
|
57955
|
+
if (!parsed || typeof parsed !== 'object') return null;
|
|
57956
|
+
if (parsed.action === 'nav_then_click') return 'Navigating...';
|
|
57957
|
+
if (parsed.action === 'message') return parsed.text || '';
|
|
57958
|
+
if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
|
|
57959
|
+
return parsed.text || null;
|
|
57960
|
+
}`;
|
|
57961
|
+
function v(e) {
|
|
57962
|
+
if (!e) return null;
|
|
57963
|
+
let r = e.toString();
|
|
57964
|
+
return r.includes("createJsonStreamParser") || r.includes("partial-json") ? "json" : r.includes("createRegexJsonParser") || r.includes("regex") ? "regex-json" : r.includes("createXmlParser") || r.includes("<text>") ? "xml" : null;
|
|
57965
|
+
}
|
|
57966
|
+
function h(e) {
|
|
57967
|
+
var r, n;
|
|
57968
|
+
return (n = (r = e.parserType) != null ? r : v(e.streamParser)) != null ? n : "plain";
|
|
57969
|
+
}
|
|
57970
|
+
function f(e, r) {
|
|
57971
|
+
let n = [];
|
|
57972
|
+
return e.toolCall && (n.push(`${r}toolCall: {`), Object.entries(e.toolCall).forEach(([s, o]) => {
|
|
57973
|
+
typeof o == "string" && n.push(`${r} ${s}: "${o}",`);
|
|
57974
|
+
}), n.push(`${r}},`)), n;
|
|
57975
|
+
}
|
|
57976
|
+
function m(e, r, n) {
|
|
57977
|
+
let s = [], o = e.messageActions && Object.entries(e.messageActions).some(([i, a]) => i !== "onFeedback" && i !== "onCopy" && a !== void 0), t = (n == null ? void 0 : n.onFeedback) || (n == null ? void 0 : n.onCopy);
|
|
57978
|
+
return (o || t) && (s.push(`${r}messageActions: {`), e.messageActions && Object.entries(e.messageActions).forEach(([i, a]) => {
|
|
57979
|
+
i === "onFeedback" || i === "onCopy" || (typeof a == "string" ? s.push(`${r} ${i}: "${a}",`) : typeof a == "boolean" && s.push(`${r} ${i}: ${a},`));
|
|
57980
|
+
}), n != null && n.onFeedback && s.push(`${r} onFeedback: ${n.onFeedback},`), n != null && n.onCopy && s.push(`${r} onCopy: ${n.onCopy},`), s.push(`${r}},`)), s;
|
|
57981
|
+
}
|
|
57982
|
+
function y(e, r) {
|
|
57983
|
+
let n = [];
|
|
57984
|
+
if (e.markdown) {
|
|
57985
|
+
let s = e.markdown.options && Object.keys(e.markdown.options).length > 0, o = e.markdown.disableDefaultStyles !== void 0;
|
|
57986
|
+
(s || o) && (n.push(`${r}markdown: {`), s && (n.push(`${r} options: {`), Object.entries(e.markdown.options).forEach(([t, i]) => {
|
|
57987
|
+
typeof i == "string" ? n.push(`${r} ${t}: "${i}",`) : typeof i == "boolean" && n.push(`${r} ${t}: ${i},`);
|
|
57988
|
+
}), n.push(`${r} },`)), o && n.push(`${r} disableDefaultStyles: ${e.markdown.disableDefaultStyles},`), n.push(`${r}},`));
|
|
57989
|
+
}
|
|
57990
|
+
return n;
|
|
57991
|
+
}
|
|
57992
|
+
function C(e, r) {
|
|
57993
|
+
let n = [];
|
|
57994
|
+
if (e.layout) {
|
|
57995
|
+
let s = e.layout.header && Object.keys(e.layout.header).some((t) => t !== "render"), o = e.layout.messages && Object.keys(e.layout.messages).some((t) => t !== "renderUserMessage" && t !== "renderAssistantMessage");
|
|
57996
|
+
(s || o) && (n.push(`${r}layout: {`), s && (n.push(`${r} header: {`), Object.entries(e.layout.header).forEach(([t, i]) => {
|
|
57997
|
+
t !== "render" && (typeof i == "string" ? n.push(`${r} ${t}: "${i}",`) : typeof i == "boolean" && n.push(`${r} ${t}: ${i},`));
|
|
57998
|
+
}), n.push(`${r} },`)), o && (n.push(`${r} messages: {`), Object.entries(e.layout.messages).forEach(([t, i]) => {
|
|
57999
|
+
t === "renderUserMessage" || t === "renderAssistantMessage" || (t === "avatar" && typeof i == "object" && i !== null ? (n.push(`${r} avatar: {`), Object.entries(i).forEach(([a, p]) => {
|
|
58000
|
+
typeof p == "string" ? n.push(`${r} ${a}: "${p}",`) : typeof p == "boolean" && n.push(`${r} ${a}: ${p},`);
|
|
58001
|
+
}), n.push(`${r} },`)) : t === "timestamp" && typeof i == "object" && i !== null ? Object.entries(i).some(([p]) => p !== "format") && (n.push(`${r} timestamp: {`), Object.entries(i).forEach(([p, d]) => {
|
|
58002
|
+
p !== "format" && (typeof d == "string" ? n.push(`${r} ${p}: "${d}",`) : typeof d == "boolean" && n.push(`${r} ${p}: ${d},`));
|
|
58003
|
+
}), n.push(`${r} },`)) : typeof i == "string" ? n.push(`${r} ${t}: "${i}",`) : typeof i == "boolean" && n.push(`${r} ${t}: ${i},`));
|
|
58004
|
+
}), n.push(`${r} },`)), n.push(`${r}},`));
|
|
58005
|
+
}
|
|
58006
|
+
return n;
|
|
58007
|
+
}
|
|
58008
|
+
function $(e, r) {
|
|
58009
|
+
let n = [];
|
|
58010
|
+
return e && (e.getHeaders && n.push(`${r}getHeaders: ${e.getHeaders},`), e.requestMiddleware && n.push(`${r}requestMiddleware: ${e.requestMiddleware},`), e.actionParsers && n.push(`${r}actionParsers: ${e.actionParsers},`), e.actionHandlers && n.push(`${r}actionHandlers: ${e.actionHandlers},`), e.contextProviders && n.push(`${r}contextProviders: ${e.contextProviders},`), e.streamParser && n.push(`${r}streamParser: ${e.streamParser},`)), n;
|
|
58011
|
+
}
|
|
58012
|
+
function j(e, r, n) {
|
|
58013
|
+
Object.entries(r).forEach(([s, o]) => {
|
|
58014
|
+
if (!(o === void 0 || typeof o == "function")) {
|
|
58015
|
+
if (Array.isArray(o)) {
|
|
58016
|
+
e.push(`${n}${s}: ${JSON.stringify(o)},`);
|
|
58017
|
+
return;
|
|
58018
|
+
}
|
|
58019
|
+
if (o && typeof o == "object") {
|
|
58020
|
+
e.push(`${n}${s}: {`), j(e, o, `${n} `), e.push(`${n}},`);
|
|
58021
|
+
return;
|
|
58022
|
+
}
|
|
58023
|
+
e.push(`${n}${s}: ${JSON.stringify(o)},`);
|
|
58024
|
+
}
|
|
58025
|
+
});
|
|
58026
|
+
}
|
|
58027
|
+
function l(e, r, n, s) {
|
|
58028
|
+
n && (e.push(`${s}${r}: {`), j(e, n, `${s} `), e.push(`${s}},`));
|
|
58029
|
+
}
|
|
58030
|
+
function g(e) {
|
|
58031
|
+
var r;
|
|
58032
|
+
return ((r = e == null ? void 0 : e.target) != null ? r : "body").replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
58033
|
+
}
|
|
58034
|
+
function I(e, r = "esm", n) {
|
|
58035
|
+
let s = { ...e };
|
|
58036
|
+
delete s.postprocessMessage, delete s.initialMessages;
|
|
58037
|
+
let o = n ? { ...n, hooks: T(n.hooks) } : void 0;
|
|
58038
|
+
return r === "esm" ? W(s, o) : r === "script-installer" ? D(s, o) : r === "script-advanced" ? J(s, o) : r === "react-component" ? H(s, o) : r === "react-advanced" ? N(s, o) : F(s, o);
|
|
58039
|
+
}
|
|
58040
|
+
function W(e, r) {
|
|
58041
|
+
let n = r == null ? void 0 : r.hooks, s = h(e), o = s !== "plain", t = ["import '@runtypelabs/persona/widget.css';", "import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';", "", "initAgentWidget({", ` target: '${g(r)}',`, " config: {"];
|
|
58042
|
+
return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && l(t, "theme", e.theme, " "), e.launcher && l(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([i, a]) => {
|
|
58043
|
+
t.push(` ${i}: "${a}",`);
|
|
58044
|
+
}), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([i, a]) => {
|
|
58045
|
+
typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
|
|
58046
|
+
}), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([i, a]) => {
|
|
58047
|
+
typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" ? t.push(` ${i}: ${a},`) : typeof a == "number" && t.push(` ${i}: ${a},`);
|
|
58048
|
+
}), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([i, a]) => {
|
|
58049
|
+
typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
|
|
58050
|
+
}), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([i, a]) => {
|
|
58051
|
+
t.push(` ${i}: ${a},`);
|
|
58052
|
+
}), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((i) => {
|
|
58053
|
+
t.push(` "${i}",`);
|
|
58054
|
+
}), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...f(e, " ")), t.push(...m(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n != null && n.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text)"), t.push(" }"), t.push("});"), t.join(`
|
|
58055
|
+
`);
|
|
58056
|
+
}
|
|
58057
|
+
function H(e, r) {
|
|
58058
|
+
let n = r == null ? void 0 : r.hooks, s = h(e), o = s !== "plain", t = ["// ChatWidget.tsx", "'use client'; // Required for Next.js - remove for Vite/CRA", "", "import { useEffect } from 'react';", "import '@runtypelabs/persona/widget.css';", "import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';", "import type { AgentWidgetInitHandle } from '@runtypelabs/persona';", "", "export function ChatWidget() {", " useEffect(() => {", " let handle: AgentWidgetInitHandle | null = null;", "", " handle = initAgentWidget({", ` target: '${g(r)}',`, " config: {"];
|
|
58059
|
+
return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && l(t, "theme", e.theme, " "), e.launcher && l(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([i, a]) => {
|
|
58060
|
+
t.push(` ${i}: "${a}",`);
|
|
58061
|
+
}), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([i, a]) => {
|
|
58062
|
+
typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
|
|
58063
|
+
}), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([i, a]) => {
|
|
58064
|
+
typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" ? t.push(` ${i}: ${a},`) : typeof a == "number" && t.push(` ${i}: ${a},`);
|
|
58065
|
+
}), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([i, a]) => {
|
|
58066
|
+
typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
|
|
58067
|
+
}), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([i, a]) => {
|
|
58068
|
+
t.push(` ${i}: ${a},`);
|
|
58069
|
+
}), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((i) => {
|
|
58070
|
+
t.push(` "${i}",`);
|
|
58071
|
+
}), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...f(e, " ")), t.push(...m(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n != null && n.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text)"), t.push(" }"), t.push(" });"), t.push(""), t.push(" // Cleanup on unmount"), t.push(" return () => {"), t.push(" if (handle) {"), t.push(" handle.destroy();"), t.push(" }"), t.push(" };"), t.push(" }, []);"), t.push(""), t.push(" return null; // Widget injects itself into the DOM"), t.push("}"), t.push(""), t.push("// Usage in your app:"), t.push("// import { ChatWidget } from './components/ChatWidget';"), t.push("//"), t.push("// export default function App() {"), t.push("// return ("), t.push("// <div>"), t.push("// {/* Your app content */}"), t.push("// <ChatWidget />"), t.push("// </div>"), t.push("// );"), t.push("// }"), t.join(`
|
|
58072
|
+
`);
|
|
58073
|
+
}
|
|
58074
|
+
function N(e, r) {
|
|
58075
|
+
let n = r == null ? void 0 : r.hooks, s = ["// ChatWidgetAdvanced.tsx", "'use client'; // Required for Next.js - remove for Vite/CRA", "", "import { useEffect } from 'react';", "import '@runtypelabs/persona/widget.css';", "import {", " initAgentWidget,", " createFlexibleJsonStreamParser,", " defaultJsonActionParser,", " defaultActionHandlers,", " markdownPostprocessor", "} from '@runtypelabs/persona';", "import type { AgentWidgetInitHandle } from '@runtypelabs/persona';", "", "const STORAGE_KEY = 'chat-widget-state';", "const PROCESSED_ACTIONS_KEY = 'chat-widget-processed-actions';", "", "// Types for DOM elements", "interface PageElement {", " type: string;", " tagName: string;", " selector: string;", " innerText: string;", " href?: string;", "}", "", "interface DOMContext {", " page_elements: PageElement[];", " page_element_count: number;", " element_types: Record<string, number>;", " page_url: string;", " page_title: string;", " timestamp: string;", "}", "", "// DOM context provider - extracts page elements for AI context", "const collectDOMContext = (): DOMContext => {", " const selectors = {", ` products: '[data-product-id], .product-card, .product-item, [role="article"]',`, ` buttons: 'button, [role="button"], .btn',`, " links: 'a[href]',", " inputs: 'input, textarea, select'", " };", "", " const elements: PageElement[] = [];", " Object.entries(selectors).forEach(([type, selector]) => {", " document.querySelectorAll(selector).forEach((element) => {", " if (!(element instanceof HTMLElement)) return;", " ", " // Exclude elements within the widget", " const widgetHost = element.closest('.persona-host');", " if (widgetHost) return;", " ", " const text = element.innerText?.trim();", " if (!text) return;", "", " const selectorString =", " element.id ? `#${element.id}` :", " element.getAttribute('data-testid') ? `[data-testid=\"${element.getAttribute('data-testid')}\"]` :", " element.getAttribute('data-product-id') ? `[data-product-id=\"${element.getAttribute('data-product-id')}\"]` :", " element.tagName.toLowerCase();", "", " const elementData: PageElement = {", " type,", " tagName: element.tagName.toLowerCase(),", " selector: selectorString,", " innerText: text.substring(0, 200)", " };", "", " if (type === 'links' && element instanceof HTMLAnchorElement && element.href) {", " elementData.href = element.href;", " }", "", " elements.push(elementData);", " });", " });", "", " const counts = elements.reduce((acc, el) => {", " acc[el.type] = (acc[el.type] || 0) + 1;", " return acc;", " }, {} as Record<string, number>);", "", " return {", " page_elements: elements.slice(0, 50),", " page_element_count: elements.length,", " element_types: counts,", " page_url: window.location.href,", " page_title: document.title,", " timestamp: new Date().toISOString()", " };", "};", "", "export function ChatWidgetAdvanced() {", " useEffect(() => {", " let handle: AgentWidgetInitHandle | null = null;", "", " // Load saved state", " const loadSavedMessages = () => {", " const savedState = localStorage.getItem(STORAGE_KEY);", " if (savedState) {", " try {", " const { messages } = JSON.parse(savedState);", " return messages || [];", " } catch (e) {", " console.error('Failed to load saved state:', e);", " }", " }", " return [];", " };", "", " handle = initAgentWidget({", ` target: '${g(r)}',`, " config: {"];
|
|
58076
|
+
return e.apiUrl && s.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && s.push(` clientToken: "${e.clientToken}",`), e.flowId && s.push(` flowId: "${e.flowId}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && l(s, "theme", e.theme, " "), e.launcher && l(s, "launcher", e.launcher, " "), e.copy && (s.push(" copy: {"), Object.entries(e.copy).forEach(([o, t]) => {
|
|
58077
|
+
s.push(` ${o}: "${t}",`);
|
|
58078
|
+
}), s.push(" },")), e.sendButton && (s.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([o, t]) => {
|
|
58079
|
+
typeof t == "string" ? s.push(` ${o}: "${t}",`) : typeof t == "boolean" && s.push(` ${o}: ${t},`);
|
|
58080
|
+
}), s.push(" },")), e.voiceRecognition && (s.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([o, t]) => {
|
|
58081
|
+
typeof t == "string" ? s.push(` ${o}: "${t}",`) : typeof t == "boolean" ? s.push(` ${o}: ${t},`) : typeof t == "number" && s.push(` ${o}: ${t},`);
|
|
58082
|
+
}), s.push(" },")), e.statusIndicator && (s.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([o, t]) => {
|
|
58083
|
+
typeof t == "string" ? s.push(` ${o}: "${t}",`) : typeof t == "boolean" && s.push(` ${o}: ${t},`);
|
|
58084
|
+
}), s.push(" },")), e.features && (s.push(" features: {"), Object.entries(e.features).forEach(([o, t]) => {
|
|
58085
|
+
s.push(` ${o}: ${t},`);
|
|
58086
|
+
}), s.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (s.push(" suggestionChips: ["), e.suggestionChips.forEach((o) => {
|
|
58087
|
+
s.push(` "${o}",`);
|
|
58088
|
+
}), s.push(" ],")), e.suggestionChipsConfig && (s.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && s.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && s.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && s.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && s.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), s.push(" },")), s.push(...f(e, " ")), s.push(...m(e, " ", n)), s.push(...y(e, " ")), s.push(...C(e, " ")), n != null && n.getHeaders && s.push(` getHeaders: ${n.getHeaders},`), n != null && n.contextProviders && s.push(` contextProviders: ${n.contextProviders},`), e.debug && s.push(` debug: ${e.debug},`), s.push(" initialMessages: loadSavedMessages(),"), n != null && n.streamParser ? s.push(` streamParser: ${n.streamParser},`) : (s.push(" // Flexible JSON stream parser for handling structured actions"), s.push(` streamParser: () => createFlexibleJsonStreamParser(${M}),`)), n != null && n.actionParsers ? (s.push(" // Action parsers (custom merged with defaults)"), s.push(` actionParsers: [...(${n.actionParsers}), defaultJsonActionParser,`), s.push(" // Built-in parser for markdown-wrapped JSON"), s.push(` ${x}`), s.push(" ],")) : (s.push(" // Action parsers to detect JSON actions in responses"), s.push(" actionParsers: ["), s.push(" defaultJsonActionParser,"), s.push(" // Parser for markdown-wrapped JSON"), s.push(` ${x}`), s.push(" ],")), n != null && n.actionHandlers ? (s.push(" // Action handlers (custom merged with defaults)"), s.push(` actionHandlers: [...(${n.actionHandlers}),`), s.push(" defaultActionHandlers.message,"), s.push(" defaultActionHandlers.messageAndClick,"), s.push(" // Built-in handler for nav_then_click action"), s.push(` ${O}`), s.push(" ],")) : (s.push(" // Action handlers for navigation and other actions"), s.push(" actionHandlers: ["), s.push(" defaultActionHandlers.message,"), s.push(" defaultActionHandlers.messageAndClick,"), s.push(" // Handler for nav_then_click action"), s.push(` ${O}`), s.push(" ],")), n != null && n.postprocessMessage ? s.push(` postprocessMessage: ${n.postprocessMessage},`) : s.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text),"), n != null && n.requestMiddleware ? (s.push(" // Request middleware (custom merged with DOM context)"), s.push(" requestMiddleware: ({ payload, config }) => {"), s.push(` const customResult = (${n.requestMiddleware})({ payload, config });`), s.push(" const merged = customResult || payload;"), s.push(" return {"), s.push(" ...merged,"), s.push(" metadata: { ...merged.metadata, ...collectDOMContext() }"), s.push(" };"), s.push(" }")) : (s.push(" requestMiddleware: ({ payload }) => {"), s.push(" return {"), s.push(" ...payload,"), s.push(" metadata: collectDOMContext()"), s.push(" };"), s.push(" }")), s.push(" }"), s.push(" });"), s.push(""), s.push(" // Save state on message events"), s.push(" const handleMessage = () => {"), s.push(" const session = handle?.getSession?.();"), s.push(" if (session) {"), s.push(" localStorage.setItem(STORAGE_KEY, JSON.stringify({"), s.push(" messages: session.messages,"), s.push(" timestamp: new Date().toISOString()"), s.push(" }));"), s.push(" }"), s.push(" };"), s.push(""), s.push(" // Clear state on clear chat"), s.push(" const handleClearChat = () => {"), s.push(" localStorage.removeItem(STORAGE_KEY);"), s.push(" localStorage.removeItem(PROCESSED_ACTIONS_KEY);"), s.push(" };"), s.push(""), s.push(" window.addEventListener('persona:message', handleMessage);"), s.push(" window.addEventListener('persona:clear-chat', handleClearChat);"), s.push(""), s.push(" // Cleanup on unmount"), s.push(" return () => {"), s.push(" window.removeEventListener('persona:message', handleMessage);"), s.push(" window.removeEventListener('persona:clear-chat', handleClearChat);"), s.push(" if (handle) {"), s.push(" handle.destroy();"), s.push(" }"), s.push(" };"), s.push(" }, []);"), s.push(""), s.push(" return null; // Widget injects itself into the DOM"), s.push("}"), s.push(""), s.push("// Usage: Collects DOM context for AI-powered navigation"), s.push("// Features:"), s.push("// - Extracts page elements (products, buttons, links)"), s.push("// - Persists chat history across page loads"), s.push("// - Handles navigation actions (nav_then_click)"), s.push("// - Processes structured JSON actions from AI"), s.push("//"), s.push("// Example usage in Next.js:"), s.push("// import { ChatWidgetAdvanced } from './components/ChatWidgetAdvanced';"), s.push("//"), s.push("// export default function RootLayout({ children }) {"), s.push("// return ("), s.push('// <html lang="en">'), s.push("// <body>"), s.push("// {children}"), s.push("// <ChatWidgetAdvanced />"), s.push("// </body>"), s.push("// </html>"), s.push("// );"), s.push("// }"), s.join(`
|
|
58089
|
+
`);
|
|
58090
|
+
}
|
|
58091
|
+
function P(e) {
|
|
58092
|
+
var o;
|
|
58093
|
+
let r = h(e), n = r !== "plain", s = {};
|
|
58094
|
+
if (e.apiUrl && (s.apiUrl = e.apiUrl), e.clientToken && (s.clientToken = e.clientToken), e.flowId && (s.flowId = e.flowId), n && (s.parserType = r), e.theme && (s.theme = e.theme), e.launcher && (s.launcher = e.launcher), e.copy && (s.copy = e.copy), e.sendButton && (s.sendButton = e.sendButton), e.voiceRecognition && (s.voiceRecognition = e.voiceRecognition), e.statusIndicator && (s.statusIndicator = e.statusIndicator), e.features && (s.features = e.features), ((o = e.suggestionChips) == null ? void 0 : o.length) > 0 && (s.suggestionChips = e.suggestionChips), e.suggestionChipsConfig && (s.suggestionChipsConfig = e.suggestionChipsConfig), e.debug && (s.debug = e.debug), e.toolCall) {
|
|
58095
|
+
let t = {};
|
|
58096
|
+
Object.entries(e.toolCall).forEach(([i, a]) => {
|
|
58097
|
+
typeof a == "string" && (t[i] = a);
|
|
58098
|
+
}), Object.keys(t).length > 0 && (s.toolCall = t);
|
|
58099
|
+
}
|
|
58100
|
+
if (e.messageActions) {
|
|
58101
|
+
let t = {};
|
|
58102
|
+
Object.entries(e.messageActions).forEach(([i, a]) => {
|
|
58103
|
+
i !== "onFeedback" && i !== "onCopy" && a !== void 0 && (typeof a == "string" || typeof a == "boolean") && (t[i] = a);
|
|
58104
|
+
}), Object.keys(t).length > 0 && (s.messageActions = t);
|
|
58105
|
+
}
|
|
58106
|
+
if (e.markdown) {
|
|
58107
|
+
let t = {};
|
|
58108
|
+
e.markdown.options && (t.options = e.markdown.options), e.markdown.disableDefaultStyles !== void 0 && (t.disableDefaultStyles = e.markdown.disableDefaultStyles), Object.keys(t).length > 0 && (s.markdown = t);
|
|
58109
|
+
}
|
|
58110
|
+
if (e.layout) {
|
|
58111
|
+
let t = {};
|
|
58112
|
+
if (e.layout.header) {
|
|
58113
|
+
let i = {};
|
|
58114
|
+
Object.entries(e.layout.header).forEach(([a, p]) => {
|
|
58115
|
+
a !== "render" && (typeof p == "string" || typeof p == "boolean") && (i[a] = p);
|
|
58116
|
+
}), Object.keys(i).length > 0 && (t.header = i);
|
|
58117
|
+
}
|
|
58118
|
+
if (e.layout.messages) {
|
|
58119
|
+
let i = {};
|
|
58120
|
+
Object.entries(e.layout.messages).forEach(([a, p]) => {
|
|
58121
|
+
if (a !== "renderUserMessage" && a !== "renderAssistantMessage") if (a === "avatar" && typeof p == "object" && p !== null) i.avatar = p;
|
|
58122
|
+
else if (a === "timestamp" && typeof p == "object" && p !== null) {
|
|
58123
|
+
let d = {};
|
|
58124
|
+
Object.entries(p).forEach(([w, b]) => {
|
|
58125
|
+
w !== "format" && (typeof b == "string" || typeof b == "boolean") && (d[w] = b);
|
|
58126
|
+
}), Object.keys(d).length > 0 && (i.timestamp = d);
|
|
58127
|
+
} else (typeof p == "string" || typeof p == "boolean") && (i[a] = p);
|
|
58128
|
+
}), Object.keys(i).length > 0 && (t.messages = i);
|
|
58129
|
+
}
|
|
58130
|
+
Object.keys(t).length > 0 && (s.layout = t);
|
|
58131
|
+
}
|
|
58132
|
+
return s;
|
|
58133
|
+
}
|
|
58134
|
+
function D(e, r) {
|
|
58135
|
+
let n = P(e), o = !!(r != null && r.windowKey || r != null && r.target) ? { config: n, ...r != null && r.windowKey ? { windowKey: r.windowKey } : {}, ...r != null && r.target ? { target: r.target } : {} } : n, t = JSON.stringify(o, null, 0).replace(/'/g, "'");
|
|
58136
|
+
return `<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/install.global.js" data-config='${t}'></script>`;
|
|
58137
|
+
}
|
|
58138
|
+
function F(e, r) {
|
|
58139
|
+
let n = r == null ? void 0 : r.hooks, s = h(e), o = s !== "plain", t = ["<!-- Load CSS -->", `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/widget.css" />`, "", "<!-- Load JavaScript -->", `<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/index.global.js"></script>`, "", "<!-- Initialize widget -->", "<script>", " var handle = window.AgentWidget.initAgentWidget({", ` target: '${g(r)}',`, ...r != null && r.windowKey ? [` windowKey: '${r.windowKey}',`] : [], " config: {"];
|
|
58140
|
+
return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && l(t, "theme", e.theme, " "), e.launcher && l(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([i, a]) => {
|
|
58141
|
+
t.push(` ${i}: "${a}",`);
|
|
58142
|
+
}), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([i, a]) => {
|
|
58143
|
+
typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
|
|
58144
|
+
}), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([i, a]) => {
|
|
58145
|
+
typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" ? t.push(` ${i}: ${a},`) : typeof a == "number" && t.push(` ${i}: ${a},`);
|
|
58146
|
+
}), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([i, a]) => {
|
|
58147
|
+
typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
|
|
58148
|
+
}), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([i, a]) => {
|
|
58149
|
+
t.push(` ${i}: ${a},`);
|
|
58150
|
+
}), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((i) => {
|
|
58151
|
+
t.push(` "${i}",`);
|
|
58152
|
+
}), t.push(" ],")), e.suggestionChipsConfig && (t.push(" suggestionChipsConfig: {"), e.suggestionChipsConfig.fontFamily && t.push(` fontFamily: "${e.suggestionChipsConfig.fontFamily}",`), e.suggestionChipsConfig.fontWeight && t.push(` fontWeight: "${e.suggestionChipsConfig.fontWeight}",`), e.suggestionChipsConfig.paddingX && t.push(` paddingX: "${e.suggestionChipsConfig.paddingX}",`), e.suggestionChipsConfig.paddingY && t.push(` paddingY: "${e.suggestionChipsConfig.paddingY}",`), t.push(" },")), t.push(...f(e, " ")), t.push(...m(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n != null && n.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => window.AgentWidget.markdownPostprocessor(text)"), t.push(" }"), t.push(" });"), t.push("</script>"), t.join(`
|
|
58153
|
+
`);
|
|
58154
|
+
}
|
|
58155
|
+
function J(e, r) {
|
|
58156
|
+
let n = r == null ? void 0 : r.hooks, s = P(e), t = ["<script>", "(function() {", " 'use strict';", "", " // Configuration", ` var CONFIG = ${JSON.stringify(s, null, 2).split(`
|
|
58157
|
+
`).map((i, a) => a === 0 ? i : " " + i).join(`
|
|
58158
|
+
`)};`, "", " // Constants", ` var CDN_BASE = 'https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist';`, " var STORAGE_KEY = 'chat-widget-state';", " var PROCESSED_ACTIONS_KEY = 'chat-widget-processed-actions';", "", " // DOM context provider - extracts page elements for AI context", " var domContextProvider = function() {", " var selectors = {", ` products: '[data-product-id], .product-card, .product-item, [role="article"]',`, ` buttons: 'button, [role="button"], .btn',`, " links: 'a[href]',", " inputs: 'input, textarea, select'", " };", "", " var elements = [];", " Object.entries(selectors).forEach(function(entry) {", " var type = entry[0], selector = entry[1];", " document.querySelectorAll(selector).forEach(function(element) {", " if (!(element instanceof HTMLElement)) return;", " var widgetHost = element.closest('.persona-host');", " if (widgetHost) return;", " var text = element.innerText ? element.innerText.trim() : '';", " if (!text) return;", "", " var selectorString = element.id ? '#' + element.id :", ` element.getAttribute('data-testid') ? '[data-testid="' + element.getAttribute('data-testid') + '"]' :`, ` element.getAttribute('data-product-id') ? '[data-product-id="' + element.getAttribute('data-product-id') + '"]' :`, " element.tagName.toLowerCase();", "", " var elementData = {", " type: type,", " tagName: element.tagName.toLowerCase(),", " selector: selectorString,", " innerText: text.substring(0, 200)", " };", "", " if (type === 'links' && element instanceof HTMLAnchorElement && element.href) {", " elementData.href = element.href;", " }", " elements.push(elementData);", " });", " });", "", " var counts = elements.reduce(function(acc, el) {", " acc[el.type] = (acc[el.type] || 0) + 1;", " return acc;", " }, {});", "", " return {", " page_elements: elements.slice(0, 50),", " page_element_count: elements.length,", " element_types: counts,", " page_url: window.location.href,", " page_title: document.title,", " timestamp: new Date().toISOString()", " };", " };", "", " // Load CSS dynamically", " var loadCSS = function() {", " if (document.querySelector('link[data-persona]')) return;", " var link = document.createElement('link');", " link.rel = 'stylesheet';", " link.href = CDN_BASE + '/widget.css';", " link.setAttribute('data-persona', 'true');", " document.head.appendChild(link);", " };", "", " // Load JS dynamically", " var loadJS = function(callback) {", " if (window.AgentWidget) { callback(); return; }", " var script = document.createElement('script');", " script.src = CDN_BASE + '/index.global.js';", " script.onload = callback;", " script.onerror = function() { console.error('Failed to load AgentWidget'); };", " document.head.appendChild(script);", " };", "", " // Create widget config with advanced features", " var createWidgetConfig = function(agentWidget) {", " var widgetConfig = Object.assign({}, CONFIG);", ""];
|
|
58159
|
+
return n != null && n.getHeaders && (t.push(` widgetConfig.getHeaders = ${n.getHeaders};`), t.push("")), n != null && n.contextProviders && (t.push(` widgetConfig.contextProviders = ${n.contextProviders};`), t.push("")), n != null && n.streamParser ? t.push(` widgetConfig.streamParser = ${n.streamParser};`) : (t.push(" // Flexible JSON stream parser for handling structured actions"), t.push(" widgetConfig.streamParser = function() {"), t.push(` return agentWidget.createFlexibleJsonStreamParser(${R});`), t.push(" };")), t.push(""), n != null && n.actionParsers ? (t.push(" // Action parsers (custom merged with defaults)"), t.push(` var customParsers = ${n.actionParsers};`), t.push(" widgetConfig.actionParsers = customParsers.concat(["), t.push(" agentWidget.defaultJsonActionParser,"), t.push(` ${A}`), t.push(" ]);")) : (t.push(" // Action parsers to detect JSON actions in responses"), t.push(" widgetConfig.actionParsers = ["), t.push(" agentWidget.defaultJsonActionParser,"), t.push(` ${A}`), t.push(" ];")), t.push(""), n != null && n.actionHandlers ? (t.push(" // Action handlers (custom merged with defaults)"), t.push(` var customHandlers = ${n.actionHandlers};`), t.push(" widgetConfig.actionHandlers = customHandlers.concat(["), t.push(" agentWidget.defaultActionHandlers.message,"), t.push(" agentWidget.defaultActionHandlers.messageAndClick,"), t.push(` ${E}`), t.push(" ]);")) : (t.push(" // Action handlers for navigation and other actions"), t.push(" widgetConfig.actionHandlers = ["), t.push(" agentWidget.defaultActionHandlers.message,"), t.push(" agentWidget.defaultActionHandlers.messageAndClick,"), t.push(` ${E}`), t.push(" ];")), t.push(""), n != null && n.requestMiddleware ? (t.push(" // Request middleware (custom merged with DOM context)"), t.push(" widgetConfig.requestMiddleware = function(ctx) {"), t.push(` var customResult = (${n.requestMiddleware})(ctx);`), t.push(" var merged = customResult || ctx.payload;"), t.push(" return Object.assign({}, merged, { metadata: Object.assign({}, merged.metadata, domContextProvider()) });"), t.push(" };")) : (t.push(" // Send DOM context with each request"), t.push(" widgetConfig.requestMiddleware = function(ctx) {"), t.push(" return Object.assign({}, ctx.payload, { metadata: domContextProvider() });"), t.push(" };")), t.push(""), n != null && n.postprocessMessage ? t.push(` widgetConfig.postprocessMessage = ${n.postprocessMessage};`) : (t.push(" // Markdown postprocessor"), t.push(" widgetConfig.postprocessMessage = function(ctx) {"), t.push(" return agentWidget.markdownPostprocessor(ctx.text);"), t.push(" };")), t.push(""), (n != null && n.onFeedback || n != null && n.onCopy) && (t.push(" // Message action callbacks"), t.push(" widgetConfig.messageActions = widgetConfig.messageActions || {};"), n != null && n.onFeedback && t.push(` widgetConfig.messageActions.onFeedback = ${n.onFeedback};`), n != null && n.onCopy && t.push(` widgetConfig.messageActions.onCopy = ${n.onCopy};`), t.push("")), t.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: '${g(r)}',`, " useShadowDom: false,", ...r != null && r.windowKey ? [` windowKey: '${r.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>"), t.join(`
|
|
58160
|
+
`);
|
|
58161
|
+
}
|
|
58162
|
+
|
|
57747
58163
|
// src/lib/persona-snippets.ts
|
|
57748
58164
|
function mapCliFormatToPersona(cli) {
|
|
57749
58165
|
switch (cli) {
|
|
57750
58166
|
case "script-installer":
|
|
57751
58167
|
return "script-installer";
|
|
57752
58168
|
case "script-manual":
|
|
57753
|
-
return "script-
|
|
58169
|
+
return "script-manual";
|
|
57754
58170
|
case "esm":
|
|
58171
|
+
return "esm";
|
|
57755
58172
|
case "react":
|
|
57756
58173
|
return "react-component";
|
|
57757
58174
|
default: {
|
|
@@ -57769,92 +58186,21 @@ function parsePersonaInitFormat(raw) {
|
|
|
57769
58186
|
`Invalid --format "${raw}". Use: script-installer | script-manual | esm | react`
|
|
57770
58187
|
);
|
|
57771
58188
|
}
|
|
57772
|
-
|
|
57773
|
-
|
|
57774
|
-
|
|
57775
|
-
|
|
57776
|
-
|
|
57777
|
-
}
|
|
57778
|
-
function escapeHtmlAttr(s) {
|
|
57779
|
-
return s.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<");
|
|
57780
|
-
}
|
|
57781
|
-
function buildScriptInstaller(input) {
|
|
57782
|
-
const targetSel = input.targetSelector?.trim() || void 0;
|
|
57783
|
-
if (!targetSel) {
|
|
57784
|
-
return `<script
|
|
57785
|
-
src="${PERSONA_CDN_BASE}/install.global.js"
|
|
57786
|
-
data-runtype-token="${escapeHtmlAttr(input.clientToken)}"
|
|
57787
|
-
></script>`.trim();
|
|
57788
|
-
}
|
|
57789
|
-
const id = mountIdFromSelector(targetSel);
|
|
57790
|
-
const cfg = JSON.stringify({ target: targetSel, apiUrl: input.apiUrl });
|
|
57791
|
-
return `<div id="${escapeHtmlAttr(id)}"></div>
|
|
57792
|
-
<script
|
|
57793
|
-
src="${PERSONA_CDN_BASE}/install.global.js"
|
|
57794
|
-
data-runtype-token="${escapeHtmlAttr(input.clientToken)}"
|
|
57795
|
-
data-config='${cfg.replace(/'/g, "'")}'
|
|
57796
|
-
></script>`.trim();
|
|
57797
|
-
}
|
|
57798
|
-
function buildScriptAdvancedHtml(input) {
|
|
57799
|
-
const targetSel = input.targetSelector?.trim() || void 0;
|
|
57800
|
-
const apiUrl = JSON.stringify(input.apiUrl);
|
|
57801
|
-
const token = JSON.stringify(input.clientToken);
|
|
57802
|
-
const targetJson = JSON.stringify(targetSel || "body");
|
|
57803
|
-
const divLine = targetSel ? `<div id="${escapeHtmlAttr(mountIdFromSelector(targetSel))}"></div>
|
|
57804
|
-
` : "";
|
|
57805
|
-
return `<link rel="stylesheet" href="${PERSONA_CDN_BASE}/widget.css" />
|
|
57806
|
-
${divLine}<script type="module">
|
|
57807
|
-
import { initAgentWidget, markdownPostprocessor } from '${PERSONA_CDN_BASE}/index.js';
|
|
57808
|
-
|
|
57809
|
-
initAgentWidget({
|
|
57810
|
-
target: ${targetJson},
|
|
57811
|
-
config: {
|
|
57812
|
-
apiUrl: ${apiUrl},
|
|
57813
|
-
clientToken: ${token},
|
|
57814
|
-
parserType: 'json',
|
|
57815
|
-
postprocessMessage: ({ text }) => markdownPostprocessor(text),
|
|
57816
|
-
launcher: {
|
|
57817
|
-
enabled: true,
|
|
57818
|
-
title: 'Chat',
|
|
57819
|
-
subtitle: 'How can I help you today?',
|
|
57820
|
-
position: 'bottom-right',
|
|
57821
|
-
},
|
|
57822
|
-
},
|
|
57823
|
-
});
|
|
57824
|
-
</script>`.trim();
|
|
57825
|
-
}
|
|
57826
|
-
function buildReactComponentSnippet(input) {
|
|
57827
|
-
const targetSel = input.targetSelector?.trim() || void 0;
|
|
57828
|
-
const apiUrl = JSON.stringify(input.apiUrl);
|
|
57829
|
-
const token = JSON.stringify(input.clientToken);
|
|
57830
|
-
const targetStr = JSON.stringify(targetSel || "body");
|
|
57831
|
-
return `import "@runtypelabs/persona/widget.css";
|
|
57832
|
-
import { DEFAULT_WIDGET_CONFIG, initAgentWidget, markdownPostprocessor } from "@runtypelabs/persona";
|
|
57833
|
-
|
|
57834
|
-
initAgentWidget({
|
|
57835
|
-
target: ${targetStr},
|
|
57836
|
-
config: {
|
|
57837
|
-
...DEFAULT_WIDGET_CONFIG,
|
|
57838
|
-
apiUrl: ${apiUrl},
|
|
57839
|
-
clientToken: ${token},
|
|
57840
|
-
parserType: "json",
|
|
57841
|
-
postprocessMessage: ({ text }) => markdownPostprocessor(text),
|
|
57842
|
-
},
|
|
57843
|
-
});`.trim();
|
|
58189
|
+
function buildWidgetConfig(input) {
|
|
58190
|
+
return {
|
|
58191
|
+
apiUrl: input.apiUrl,
|
|
58192
|
+
clientToken: input.clientToken,
|
|
58193
|
+
parserType: "json"
|
|
58194
|
+
};
|
|
57844
58195
|
}
|
|
57845
58196
|
function generatePersonaInitSnippet(input, personaFormat) {
|
|
57846
|
-
|
|
57847
|
-
|
|
57848
|
-
|
|
57849
|
-
|
|
57850
|
-
|
|
57851
|
-
|
|
57852
|
-
|
|
57853
|
-
default: {
|
|
57854
|
-
const _exhaustive = personaFormat;
|
|
57855
|
-
return _exhaustive;
|
|
57856
|
-
}
|
|
57857
|
-
}
|
|
58197
|
+
const widgetConfig = buildWidgetConfig(input);
|
|
58198
|
+
const target = input.targetSelector?.trim();
|
|
58199
|
+
return I(
|
|
58200
|
+
widgetConfig,
|
|
58201
|
+
personaFormat,
|
|
58202
|
+
target ? { target } : void 0
|
|
58203
|
+
);
|
|
57858
58204
|
}
|
|
57859
58205
|
|
|
57860
58206
|
// src/lib/persona-init.ts
|
|
@@ -58659,11 +59005,11 @@ flowVersionsCommand.command("list <flowId>").description("List all versions for
|
|
|
58659
59005
|
return;
|
|
58660
59006
|
}
|
|
58661
59007
|
console.log(chalk33.cyan(`Versions for flow ${flowId}:`));
|
|
58662
|
-
for (const
|
|
58663
|
-
const publishedTag =
|
|
58664
|
-
const versionNum =
|
|
58665
|
-
const date5 =
|
|
58666
|
-
console.log(` ${chalk33.green(
|
|
59008
|
+
for (const v2 of versions) {
|
|
59009
|
+
const publishedTag = v2.published ? chalk33.green(" [published]") : "";
|
|
59010
|
+
const versionNum = v2.version !== void 0 ? `v${v2.version}` : v2.id;
|
|
59011
|
+
const date5 = v2.createdAt ? chalk33.gray(` ${v2.createdAt}`) : "";
|
|
59012
|
+
console.log(` ${chalk33.green(v2.id)} ${versionNum}${publishedTag}${date5}`);
|
|
58667
59013
|
}
|
|
58668
59014
|
}
|
|
58669
59015
|
} catch (error51) {
|
|
@@ -58698,10 +59044,10 @@ flowVersionsCommand.command("list <flowId>").description("List all versions for
|
|
|
58698
59044
|
loading,
|
|
58699
59045
|
emptyMessage: "No versions found",
|
|
58700
59046
|
renderCard: (item) => {
|
|
58701
|
-
const
|
|
58702
|
-
const publishedTag =
|
|
58703
|
-
const versionNum =
|
|
58704
|
-
return React24.createElement(Text35, null, ` ${
|
|
59047
|
+
const v2 = item;
|
|
59048
|
+
const publishedTag = v2.published ? " [published]" : "";
|
|
59049
|
+
const versionNum = v2.version !== void 0 ? `v${v2.version}` : v2.id;
|
|
59050
|
+
return React24.createElement(Text35, null, ` ${v2.id} ${versionNum}${publishedTag}${v2.createdAt ? ` ${v2.createdAt}` : ""}`);
|
|
58705
59051
|
}
|
|
58706
59052
|
});
|
|
58707
59053
|
};
|
|
@@ -58916,12 +59262,12 @@ agentVersionsCommand.command("list <agentId>").description("List all versions fo
|
|
|
58916
59262
|
return;
|
|
58917
59263
|
}
|
|
58918
59264
|
console.log(chalk34.cyan(`Versions for agent ${agentId}:`));
|
|
58919
|
-
for (const
|
|
58920
|
-
const isPublished =
|
|
59265
|
+
for (const v2 of versions) {
|
|
59266
|
+
const isPublished = v2.id === data.publishedVersionId;
|
|
58921
59267
|
const liveTag = isPublished ? chalk34.green(" [live]") : "";
|
|
58922
|
-
const versionLabel =
|
|
58923
|
-
const date5 =
|
|
58924
|
-
console.log(` ${chalk34.green(
|
|
59268
|
+
const versionLabel = v2.label || (v2.versionNumber !== void 0 ? `v${v2.versionNumber}` : v2.id);
|
|
59269
|
+
const date5 = v2.createdAt ? chalk34.gray(` ${v2.createdAt}`) : "";
|
|
59270
|
+
console.log(` ${chalk34.green(v2.id)} ${versionLabel}${liveTag}${date5}`);
|
|
58925
59271
|
}
|
|
58926
59272
|
}
|
|
58927
59273
|
} catch (error51) {
|
|
@@ -58958,13 +59304,13 @@ agentVersionsCommand.command("list <agentId>").description("List all versions fo
|
|
|
58958
59304
|
loading,
|
|
58959
59305
|
emptyMessage: "No versions found",
|
|
58960
59306
|
renderCard: (item) => {
|
|
58961
|
-
const
|
|
58962
|
-
const liveTag =
|
|
58963
|
-
const versionLabel =
|
|
59307
|
+
const v2 = item;
|
|
59308
|
+
const liveTag = v2.id === publishedId ? " [live]" : "";
|
|
59309
|
+
const versionLabel = v2.label || (v2.versionNumber !== void 0 ? `v${v2.versionNumber}` : v2.id);
|
|
58964
59310
|
return React25.createElement(
|
|
58965
59311
|
Text36,
|
|
58966
59312
|
null,
|
|
58967
|
-
` ${
|
|
59313
|
+
` ${v2.id} ${versionLabel}${liveTag}${v2.createdAt ? ` ${v2.createdAt}` : ""}`
|
|
58968
59314
|
);
|
|
58969
59315
|
}
|
|
58970
59316
|
});
|
|
@@ -59201,7 +59547,7 @@ function categoryBadge(category, useColor) {
|
|
|
59201
59547
|
return chalk35.magenta(`[${category}]`);
|
|
59202
59548
|
}
|
|
59203
59549
|
function formatTailData(data) {
|
|
59204
|
-
return Object.entries(data).map(([k,
|
|
59550
|
+
return Object.entries(data).map(([k, v2]) => `${k}=${typeof v2 === "string" ? v2 : JSON.stringify(v2)}`).join(" ");
|
|
59205
59551
|
}
|
|
59206
59552
|
function formatContextIds(event, useColor) {
|
|
59207
59553
|
const ids = [];
|
|
@@ -59289,9 +59635,9 @@ async function createSession(apiUrl, apiKey, filters) {
|
|
|
59289
59635
|
level: "levels",
|
|
59290
59636
|
category: "categories"
|
|
59291
59637
|
};
|
|
59292
|
-
for (const [k,
|
|
59293
|
-
if (
|
|
59294
|
-
filter[arrayFields[k]] = [
|
|
59638
|
+
for (const [k, v2] of Object.entries(filters)) {
|
|
59639
|
+
if (v2 !== void 0 && arrayFields[k]) {
|
|
59640
|
+
filter[arrayFields[k]] = [v2];
|
|
59295
59641
|
}
|
|
59296
59642
|
}
|
|
59297
59643
|
const body = Object.keys(filter).length > 0 ? { filter } : {};
|
|
@@ -59345,7 +59691,7 @@ async function runTail(options) {
|
|
|
59345
59691
|
category: options.category
|
|
59346
59692
|
};
|
|
59347
59693
|
const useColor = options.color;
|
|
59348
|
-
const activeFilters = Object.entries(filters).filter(([,
|
|
59694
|
+
const activeFilters = Object.entries(filters).filter(([, v2]) => v2 !== void 0).map(([k, v2]) => `${k}=${v2}`);
|
|
59349
59695
|
process.stderr.write(
|
|
59350
59696
|
(useColor ? chalk35.gray(
|
|
59351
59697
|
`Connecting to ${apiUrl}...${activeFilters.length ? ` filters: ${activeFilters.join(", ")}` : ""}`
|
|
@@ -60541,11 +60887,11 @@ function collectSecretNames(agentDef) {
|
|
|
60541
60887
|
function slugify2(s) {
|
|
60542
60888
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 63);
|
|
60543
60889
|
}
|
|
60544
|
-
var deployCommand = new Command30("deploy").description("Export an agent or flow and scaffold a deployment (cloud-run, cloudflare, or vercel)").option("--agent <id>", "Agent ID to export (may be repeated)", (
|
|
60545
|
-
acc.push(
|
|
60890
|
+
var deployCommand = new Command30("deploy").description("Export an agent or flow and scaffold a deployment (cloud-run, cloudflare, or vercel)").option("--agent <id>", "Agent ID to export (may be repeated)", (v2, acc) => {
|
|
60891
|
+
acc.push(v2);
|
|
60546
60892
|
return acc;
|
|
60547
|
-
}, []).option("--flow <id>", "Flow ID to export (may be repeated)", (
|
|
60548
|
-
acc.push(
|
|
60893
|
+
}, []).option("--flow <id>", "Flow ID to export (may be repeated)", (v2, acc) => {
|
|
60894
|
+
acc.push(v2);
|
|
60549
60895
|
return acc;
|
|
60550
60896
|
}, []).option("--output <dir>", "Output directory for the scaffold (default: ./runtype-deploy)", "./runtype-deploy").option("--name <name>", "Project name used in package.json (default: derived from output dir)").option("--target <target>", "Deployment target: cloud-run, cloudflare, or vercel (default: cloud-run)", "cloud-run").action(
|
|
60551
60897
|
async (options) => {
|
|
@@ -60830,7 +61176,7 @@ async function runSkillsInstall(agents, options = {}) {
|
|
|
60830
61176
|
try {
|
|
60831
61177
|
const outcome = await installSkills(
|
|
60832
61178
|
agentIds,
|
|
60833
|
-
options.verbose && !options.quiet ? (
|
|
61179
|
+
options.verbose && !options.quiet ? (m2) => console.log(chalk38.dim(` ${m2}`)) : void 0
|
|
60834
61180
|
);
|
|
60835
61181
|
const failedSet = new Set(outcome.failedAgents);
|
|
60836
61182
|
const succeeded = agents.filter((a) => !failedSet.has(a.rosieId));
|