@runtypelabs/cli 2.31.0 → 2.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +408 -324
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1238,9 +1238,9 @@ function $constructor(name, initializer3, params) {
1238
1238
  const proto = _2.prototype;
1239
1239
  const keys = Object.keys(proto);
1240
1240
  for (let i = 0; i < keys.length; i++) {
1241
- const k2 = keys[i];
1242
- if (!(k2 in inst)) {
1243
- inst[k2] = proto[k2].bind(inst);
1241
+ const k = keys[i];
1242
+ if (!(k in inst)) {
1243
+ inst[k] = proto[k].bind(inst);
1244
1244
  }
1245
1245
  }
1246
1246
  }
@@ -1370,8 +1370,8 @@ function assertNever(_x) {
1370
1370
  function assert(_2) {
1371
1371
  }
1372
1372
  function getEnumValues(entries) {
1373
- const numericValues = Object.values(entries).filter((v) => typeof v === "number");
1374
- const values = Object.entries(entries).filter(([k2, _2]) => numericValues.indexOf(+k2) === -1).map(([_2, v]) => v);
1373
+ const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
1374
+ const values = Object.entries(entries).filter(([k, _2]) => numericValues.indexOf(+k) === -1).map(([_2, v2]) => v2);
1375
1375
  return values;
1376
1376
  }
1377
1377
  function joinValues(array2, separator = "|") {
@@ -1425,9 +1425,9 @@ function defineLazy(object2, key, getter) {
1425
1425
  }
1426
1426
  return value;
1427
1427
  },
1428
- set(v) {
1428
+ set(v2) {
1429
1429
  Object.defineProperty(object2, key, {
1430
- value: v
1430
+ value: v2
1431
1431
  // configurable: true,
1432
1432
  });
1433
1433
  },
@@ -1499,8 +1499,8 @@ var allowsEval = /* @__PURE__ */ cached(() => {
1499
1499
  return false;
1500
1500
  }
1501
1501
  try {
1502
- const F2 = Function;
1503
- new F2("");
1502
+ const F = Function;
1503
+ new F("");
1504
1504
  return true;
1505
1505
  } catch (_2) {
1506
1506
  return false;
@@ -1661,8 +1661,8 @@ function stringifyPrimitive(value) {
1661
1661
  return `${value}`;
1662
1662
  }
1663
1663
  function optionalKeys(shape) {
1664
- return Object.keys(shape).filter((k2) => {
1665
- return shape[k2]._zod.optin === "optional" && shape[k2]._zod.optout === "optional";
1664
+ return Object.keys(shape).filter((k) => {
1665
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
1666
1666
  });
1667
1667
  }
1668
1668
  var NUMBER_FORMAT_RANGES = {
@@ -1939,8 +1939,8 @@ function issue(...args) {
1939
1939
  return { ...iss };
1940
1940
  }
1941
1941
  function cleanEnum(obj) {
1942
- return Object.entries(obj).filter(([k2, _2]) => {
1943
- return Number.isNaN(Number.parseInt(k2, 10));
1942
+ return Object.entries(obj).filter(([k, _2]) => {
1943
+ return Number.isNaN(Number.parseInt(k, 10));
1944
1944
  }).map((el) => el[1]);
1945
1945
  }
1946
1946
  function base64ToUint8Array(base643) {
@@ -2947,11 +2947,11 @@ var Doc = class {
2947
2947
  }
2948
2948
  }
2949
2949
  compile() {
2950
- const F2 = Function;
2950
+ const F = Function;
2951
2951
  const args = this?.args;
2952
2952
  const content = this?.content ?? [``];
2953
2953
  const lines = [...content.map((x2) => ` ${x2}`)];
2954
- return new F2(...args, lines.join("\n"));
2954
+ return new F(...args, lines.join("\n"));
2955
2955
  }
2956
2956
  };
2957
2957
 
@@ -3114,10 +3114,10 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
3114
3114
  v7: 7,
3115
3115
  v8: 8
3116
3116
  };
3117
- const v = versionMap[def.version];
3118
- if (v === void 0)
3117
+ const v2 = versionMap[def.version];
3118
+ if (v2 === void 0)
3119
3119
  throw new Error(`Invalid UUID version: "${def.version}"`);
3120
- def.pattern ?? (def.pattern = uuid(v));
3120
+ def.pattern ?? (def.pattern = uuid(v2));
3121
3121
  } else
3122
3122
  def.pattern ?? (def.pattern = uuid());
3123
3123
  $ZodStringFormat.init(inst, def);
@@ -3648,9 +3648,9 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
3648
3648
  }
3649
3649
  function normalizeDef(def) {
3650
3650
  const keys = Object.keys(def.shape);
3651
- for (const k2 of keys) {
3652
- if (!def.shape?.[k2]?._zod?.traits?.has("$ZodType")) {
3653
- throw new Error(`Invalid element at key "${k2}": expected a Zod schema`);
3651
+ for (const k of keys) {
3652
+ if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
3653
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
3654
3654
  }
3655
3655
  }
3656
3656
  const okeys = optionalKeys(def.shape);
@@ -3722,8 +3722,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
3722
3722
  const field = shape[key]._zod;
3723
3723
  if (field.values) {
3724
3724
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
3725
- for (const v of field.values)
3726
- propValues[key].add(v);
3725
+ for (const v2 of field.values)
3726
+ propValues[key].add(v2);
3727
3727
  }
3728
3728
  }
3729
3729
  return propValues;
@@ -3771,8 +3771,8 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3771
3771
  const doc = new Doc(["shape", "payload", "ctx"]);
3772
3772
  const normalized = _normalized.value;
3773
3773
  const parseStr = (key) => {
3774
- const k2 = esc(key);
3775
- return `shape[${k2}]._zod.run({ value: input[${k2}], issues: [] }, ctx)`;
3774
+ const k = esc(key);
3775
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
3776
3776
  };
3777
3777
  doc.write(`const input = payload.value;`);
3778
3778
  const ids = /* @__PURE__ */ Object.create(null);
@@ -3783,7 +3783,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3783
3783
  doc.write(`const newResult = {};`);
3784
3784
  for (const key of normalized.keys) {
3785
3785
  const id = ids[key];
3786
- const k2 = esc(key);
3786
+ const k = esc(key);
3787
3787
  const schema = shape[key];
3788
3788
  const isOptionalIn = schema?._zod?.optin === "optional";
3789
3789
  const isOptionalOut = schema?._zod?.optout === "optional";
@@ -3791,30 +3791,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3791
3791
  if (isOptionalIn && isOptionalOut) {
3792
3792
  doc.write(`
3793
3793
  if (${id}.issues.length) {
3794
- if (${k2} in input) {
3794
+ if (${k} in input) {
3795
3795
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3796
3796
  ...iss,
3797
- path: iss.path ? [${k2}, ...iss.path] : [${k2}]
3797
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
3798
3798
  })));
3799
3799
  }
3800
3800
  }
3801
3801
 
3802
3802
  if (${id}.value === undefined) {
3803
- if (${k2} in input) {
3804
- newResult[${k2}] = undefined;
3803
+ if (${k} in input) {
3804
+ newResult[${k}] = undefined;
3805
3805
  }
3806
3806
  } else {
3807
- newResult[${k2}] = ${id}.value;
3807
+ newResult[${k}] = ${id}.value;
3808
3808
  }
3809
3809
 
3810
3810
  `);
3811
3811
  } else if (!isOptionalIn) {
3812
3812
  doc.write(`
3813
- const ${id}_present = ${k2} in input;
3813
+ const ${id}_present = ${k} in input;
3814
3814
  if (${id}.issues.length) {
3815
3815
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3816
3816
  ...iss,
3817
- path: iss.path ? [${k2}, ...iss.path] : [${k2}]
3817
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
3818
3818
  })));
3819
3819
  }
3820
3820
  if (!${id}_present && !${id}.issues.length) {
@@ -3822,15 +3822,15 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3822
3822
  code: "invalid_type",
3823
3823
  expected: "nonoptional",
3824
3824
  input: undefined,
3825
- path: [${k2}]
3825
+ path: [${k}]
3826
3826
  });
3827
3827
  }
3828
3828
 
3829
3829
  if (${id}_present) {
3830
3830
  if (${id}.value === undefined) {
3831
- newResult[${k2}] = undefined;
3831
+ newResult[${k}] = undefined;
3832
3832
  } else {
3833
- newResult[${k2}] = ${id}.value;
3833
+ newResult[${k}] = ${id}.value;
3834
3834
  }
3835
3835
  }
3836
3836
 
@@ -3840,16 +3840,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3840
3840
  if (${id}.issues.length) {
3841
3841
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3842
3842
  ...iss,
3843
- path: iss.path ? [${k2}, ...iss.path] : [${k2}]
3843
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
3844
3844
  })));
3845
3845
  }
3846
3846
 
3847
3847
  if (${id}.value === undefined) {
3848
- if (${k2} in input) {
3849
- newResult[${k2}] = undefined;
3848
+ if (${k} in input) {
3849
+ newResult[${k}] = undefined;
3850
3850
  }
3851
3851
  } else {
3852
- newResult[${k2}] = ${id}.value;
3852
+ newResult[${k}] = ${id}.value;
3853
3853
  }
3854
3854
 
3855
3855
  `);
@@ -4018,11 +4018,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
4018
4018
  const pv = option._zod.propValues;
4019
4019
  if (!pv || Object.keys(pv).length === 0)
4020
4020
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
4021
- for (const [k2, v] of Object.entries(pv)) {
4022
- if (!propValues[k2])
4023
- propValues[k2] = /* @__PURE__ */ new Set();
4024
- for (const val of v) {
4025
- propValues[k2].add(val);
4021
+ for (const [k, v2] of Object.entries(pv)) {
4022
+ if (!propValues[k])
4023
+ propValues[k] = /* @__PURE__ */ new Set();
4024
+ for (const val of v2) {
4025
+ propValues[k].add(val);
4026
4026
  }
4027
4027
  }
4028
4028
  }
@@ -4035,11 +4035,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
4035
4035
  const values = o._zod.propValues?.[def.discriminator];
4036
4036
  if (!values || values.size === 0)
4037
4037
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
4038
- for (const v of values) {
4039
- if (map2.has(v)) {
4040
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
4038
+ for (const v2 of values) {
4039
+ if (map2.has(v2)) {
4040
+ throw new Error(`Duplicate discriminator value "${String(v2)}"`);
4041
4041
  }
4042
- map2.set(v, o);
4042
+ map2.set(v2, o);
4043
4043
  }
4044
4044
  }
4045
4045
  return map2;
@@ -4140,10 +4140,10 @@ function handleIntersectionResults(result, left, right) {
4140
4140
  for (const iss of left.issues) {
4141
4141
  if (iss.code === "unrecognized_keys") {
4142
4142
  unrecIssue ?? (unrecIssue = iss);
4143
- for (const k2 of iss.keys) {
4144
- if (!unrecKeys.has(k2))
4145
- unrecKeys.set(k2, {});
4146
- unrecKeys.get(k2).l = true;
4143
+ for (const k of iss.keys) {
4144
+ if (!unrecKeys.has(k))
4145
+ unrecKeys.set(k, {});
4146
+ unrecKeys.get(k).l = true;
4147
4147
  }
4148
4148
  } else {
4149
4149
  result.issues.push(iss);
@@ -4151,16 +4151,16 @@ function handleIntersectionResults(result, left, right) {
4151
4151
  }
4152
4152
  for (const iss of right.issues) {
4153
4153
  if (iss.code === "unrecognized_keys") {
4154
- for (const k2 of iss.keys) {
4155
- if (!unrecKeys.has(k2))
4156
- unrecKeys.set(k2, {});
4157
- unrecKeys.get(k2).r = true;
4154
+ for (const k of iss.keys) {
4155
+ if (!unrecKeys.has(k))
4156
+ unrecKeys.set(k, {});
4157
+ unrecKeys.get(k).r = true;
4158
4158
  }
4159
4159
  } else {
4160
4160
  result.issues.push(iss);
4161
4161
  }
4162
4162
  }
4163
- const bothKeys = [...unrecKeys].filter(([, f2]) => f2.l && f2.r).map(([k2]) => k2);
4163
+ const bothKeys = [...unrecKeys].filter(([, f2]) => f2.l && f2.r).map(([k]) => k);
4164
4164
  if (bothKeys.length && unrecIssue) {
4165
4165
  result.issues.push({ ...unrecIssue, keys: bothKeys });
4166
4166
  }
@@ -4504,7 +4504,7 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
4504
4504
  const values = getEnumValues(def.entries);
4505
4505
  const valuesSet = new Set(values);
4506
4506
  inst._zod.values = valuesSet;
4507
- inst._zod.pattern = new RegExp(`^(${values.filter((k2) => propertyKeyTypes.has(typeof k2)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
4507
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
4508
4508
  inst._zod.parse = (payload, _ctx) => {
4509
4509
  const input = payload.value;
4510
4510
  if (valuesSet.has(input)) {
@@ -4678,8 +4678,8 @@ var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
4678
4678
  var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
4679
4679
  $ZodType.init(inst, def);
4680
4680
  defineLazy(inst._zod, "values", () => {
4681
- const v = def.innerType._zod.values;
4682
- return v ? new Set([...v].filter((x2) => x2 !== void 0)) : void 0;
4681
+ const v2 = def.innerType._zod.values;
4682
+ return v2 ? new Set([...v2].filter((x2) => x2 !== void 0)) : void 0;
4683
4683
  });
4684
4684
  inst._zod.parse = (payload, ctx) => {
4685
4685
  const result = def.innerType._zod.run(payload, ctx);
@@ -4970,9 +4970,9 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
4970
4970
  return payload;
4971
4971
  };
4972
4972
  inst.input = (...args) => {
4973
- const F2 = inst.constructor;
4973
+ const F = inst.constructor;
4974
4974
  if (Array.isArray(args[0])) {
4975
- return new F2({
4975
+ return new F({
4976
4976
  type: "function",
4977
4977
  input: new $ZodTuple({
4978
4978
  type: "tuple",
@@ -4982,15 +4982,15 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
4982
4982
  output: inst._def.output
4983
4983
  });
4984
4984
  }
4985
- return new F2({
4985
+ return new F({
4986
4986
  type: "function",
4987
4987
  input: args[0],
4988
4988
  output: inst._def.output
4989
4989
  });
4990
4990
  };
4991
4991
  inst.output = (output) => {
4992
- const F2 = inst.constructor;
4993
- return new F2({
4992
+ const F = inst.constructor;
4993
+ return new F({
4994
4994
  type: "function",
4995
4995
  input: inst._def.input,
4996
4996
  output
@@ -5007,10 +5007,10 @@ var $ZodPromise = /* @__PURE__ */ $constructor("$ZodPromise", (inst, def) => {
5007
5007
  var $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
5008
5008
  $ZodType.init(inst, def);
5009
5009
  defineLazy(inst._zod, "innerType", () => {
5010
- const d = def;
5011
- if (!d._cachedInner)
5012
- d._cachedInner = def.getter();
5013
- return d._cachedInner;
5010
+ const d2 = def;
5011
+ if (!d2._cachedInner)
5012
+ d2._cachedInner = def.getter();
5013
+ return d2._cachedInner;
5014
5014
  });
5015
5015
  defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
5016
5016
  defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
@@ -7076,7 +7076,7 @@ var error17 = () => {
7076
7076
  if (issue2.values.length === 1) {
7077
7077
  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])}`;
7078
7078
  }
7079
- const stringified = issue2.values.map((v) => stringifyPrimitive(v));
7079
+ const stringified = issue2.values.map((v2) => stringifyPrimitive(v2));
7080
7080
  if (issue2.values.length === 2) {
7081
7081
  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]}`;
7082
7082
  }
@@ -11831,7 +11831,7 @@ function _set(Class2, valueType, params) {
11831
11831
  }
11832
11832
  // @__NO_SIDE_EFFECTS__
11833
11833
  function _enum(Class2, values, params) {
11834
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
11834
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
11835
11835
  return new Class2({
11836
11836
  type: "enum",
11837
11837
  entries,
@@ -12036,8 +12036,8 @@ function _stringbool(Classes, _params) {
12036
12036
  let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
12037
12037
  let falsyArray = params.falsy ?? ["false", "0", "no", "off", "n", "disabled"];
12038
12038
  if (params.case !== "sensitive") {
12039
- truthyArray = truthyArray.map((v) => typeof v === "string" ? v.toLowerCase() : v);
12040
- falsyArray = falsyArray.map((v) => typeof v === "string" ? v.toLowerCase() : v);
12039
+ truthyArray = truthyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
12040
+ falsyArray = falsyArray.map((v2) => typeof v2 === "string" ? v2.toLowerCase() : v2);
12041
12041
  }
12042
12042
  const truthySet = new Set(truthyArray);
12043
12043
  const falsySet = new Set(falsyArray);
@@ -12579,9 +12579,9 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
12579
12579
  var enumProcessor = (schema, _ctx, json2, _params) => {
12580
12580
  const def = schema._zod.def;
12581
12581
  const values = getEnumValues(def.entries);
12582
- if (values.every((v) => typeof v === "number"))
12582
+ if (values.every((v2) => typeof v2 === "number"))
12583
12583
  json2.type = "number";
12584
- if (values.every((v) => typeof v === "string"))
12584
+ if (values.every((v2) => typeof v2 === "string"))
12585
12585
  json2.type = "string";
12586
12586
  json2.enum = values;
12587
12587
  };
@@ -12614,13 +12614,13 @@ var literalProcessor = (schema, ctx, json2, _params) => {
12614
12614
  json2.const = val;
12615
12615
  }
12616
12616
  } else {
12617
- if (vals.every((v) => typeof v === "number"))
12617
+ if (vals.every((v2) => typeof v2 === "number"))
12618
12618
  json2.type = "number";
12619
- if (vals.every((v) => typeof v === "string"))
12619
+ if (vals.every((v2) => typeof v2 === "string"))
12620
12620
  json2.type = "string";
12621
- if (vals.every((v) => typeof v === "boolean"))
12621
+ if (vals.every((v2) => typeof v2 === "boolean"))
12622
12622
  json2.type = "boolean";
12623
- if (vals.every((v) => v === null))
12623
+ if (vals.every((v2) => v2 === null))
12624
12624
  json2.type = "null";
12625
12625
  json2.enum = vals;
12626
12626
  }
@@ -12718,11 +12718,11 @@ var objectProcessor = (schema, ctx, _json, params) => {
12718
12718
  }
12719
12719
  const allKeys = new Set(Object.keys(shape));
12720
12720
  const requiredKeys = new Set([...allKeys].filter((key) => {
12721
- const v = def.shape[key]._zod;
12721
+ const v2 = def.shape[key]._zod;
12722
12722
  if (ctx.io === "input") {
12723
- return v.optin === void 0;
12723
+ return v2.optin === void 0;
12724
12724
  } else {
12725
- return v.optout === void 0;
12725
+ return v2.optout === void 0;
12726
12726
  }
12727
12727
  }));
12728
12728
  if (requiredKeys.size > 0) {
@@ -12842,7 +12842,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
12842
12842
  }
12843
12843
  const keyValues = keyType._zod.values;
12844
12844
  if (keyValues) {
12845
- const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
12845
+ const validKeyValues = [...keyValues].filter((v2) => typeof v2 === "string" || typeof v2 === "number");
12846
12846
  if (validKeyValues.length > 0) {
12847
12847
  json2.required = validKeyValues;
12848
12848
  }
@@ -13407,12 +13407,12 @@ function _installLazyMethods(inst, group, methods) {
13407
13407
  });
13408
13408
  return bound;
13409
13409
  },
13410
- set(v) {
13410
+ set(v2) {
13411
13411
  Object.defineProperty(this, key, {
13412
13412
  configurable: true,
13413
13413
  writable: true,
13414
13414
  enumerable: true,
13415
- value: v
13415
+ value: v2
13416
13416
  });
13417
13417
  }
13418
13418
  });
@@ -13502,11 +13502,11 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
13502
13502
  transform(tx) {
13503
13503
  return pipe(this, transform(tx));
13504
13504
  },
13505
- default(d) {
13506
- return _default2(this, d);
13505
+ default(d2) {
13506
+ return _default2(this, d2);
13507
13507
  },
13508
- prefault(d) {
13509
- return prefault(this, d);
13508
+ prefault(d2) {
13509
+ return prefault(this, d2);
13510
13510
  },
13511
13511
  catch(params) {
13512
13512
  return _catch2(this, params);
@@ -14208,11 +14208,11 @@ function record(keyType, valueType, params) {
14208
14208
  });
14209
14209
  }
14210
14210
  function partialRecord(keyType, valueType, params) {
14211
- const k2 = clone(keyType);
14212
- k2._zod.values = void 0;
14211
+ const k = clone(keyType);
14212
+ k._zod.values = void 0;
14213
14213
  return new ZodRecord({
14214
14214
  type: "record",
14215
- keyType: k2,
14215
+ keyType: k,
14216
14216
  valueType,
14217
14217
  ...util_exports.normalizeParams(params)
14218
14218
  });
@@ -14300,7 +14300,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
14300
14300
  };
14301
14301
  });
14302
14302
  function _enum2(values, params) {
14303
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
14303
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v2) => [v2, v2])) : values;
14304
14304
  return new ZodEnum({
14305
14305
  type: "enum",
14306
14306
  entries,
@@ -14854,10 +14854,10 @@ function convertBaseSchema(schema, ctx) {
14854
14854
  if (enumValues.length === 1) {
14855
14855
  return z.literal(enumValues[0]);
14856
14856
  }
14857
- if (enumValues.every((v) => typeof v === "string")) {
14857
+ if (enumValues.every((v2) => typeof v2 === "string")) {
14858
14858
  return z.enum(enumValues);
14859
14859
  }
14860
- const literalSchemas = enumValues.map((v) => z.literal(v));
14860
+ const literalSchemas = enumValues.map((v2) => z.literal(v2));
14861
14861
  if (literalSchemas.length < 2) {
14862
14862
  return literalSchemas[0];
14863
14863
  }
@@ -15702,7 +15702,7 @@ var _SimpleTemplateEngine = class _SimpleTemplateEngine2 {
15702
15702
  const result = this.substitute(template, context);
15703
15703
  if (result.usedDefaults.length > 0) {
15704
15704
  warnings.push(
15705
- `Used ${result.usedDefaults.length} default values: ${result.usedDefaults.map((d) => d.variable).join(", ")}`
15705
+ `Used ${result.usedDefaults.length} default values: ${result.usedDefaults.map((d2) => d2.variable).join(", ")}`
15706
15706
  );
15707
15707
  }
15708
15708
  if (result.missingVariables.length > 0) {
@@ -17145,15 +17145,13 @@ var AGENT_CONTENT_CONFIG_KEYS = {
17145
17145
  tenancyStrategy: true
17146
17146
  };
17147
17147
  var AGENT_CONTENT_CONFIG_KEY_LIST = Object.keys(AGENT_CONTENT_CONFIG_KEYS).sort();
17148
- var configurationStatusSchema = external_exports.enum([
17149
- "configured",
17150
- "needs_configuration",
17151
- "invalid"
17152
- ]);
17148
+ var configurationStatusSchema = external_exports.enum(["configured", "needs_configuration", "invalid"]);
17149
+ var secretDocsUrlSchema = external_exports.url({ protocol: /^https$/ }).max(2048);
17153
17150
  var secretRequirementSourceSchema = external_exports.object({
17154
17151
  type: external_exports.enum(["manual", "secret", "product"]),
17155
17152
  key: external_exports.string().optional(),
17156
- productId: external_exports.string().optional()
17153
+ productId: external_exports.string().optional(),
17154
+ description: external_exports.string().optional()
17157
17155
  });
17158
17156
  var secretIntakeItemSchema = external_exports.object({
17159
17157
  itemId: external_exports.string(),
@@ -17201,6 +17199,10 @@ var secretIntakeSubmitItemSchema = external_exports.object({
17201
17199
  displayName: external_exports.string().optional(),
17202
17200
  description: external_exports.string().optional(),
17203
17201
  value: external_exports.string().optional(),
17202
+ // Write-path acquisition link for API/MCP submitters. The dashboard intake
17203
+ // form does not expose an input for it in v1; it flows into the same
17204
+ // create/update service paths. https-only via secretDocsUrlSchema.
17205
+ docsUrl: secretDocsUrlSchema.optional(),
17204
17206
  // Required when `value` is set AND the item targets an existing secret
17205
17207
  // (has `secretId` or a `key` that already exists). Echoed from the
17206
17208
  // manifest item's `version` field. Omit for new-secret creations.
@@ -40078,7 +40080,7 @@ var PLATFORM_KEY_PROVIDER_MAP = {
40078
40080
  "mock": false
40079
40081
  };
40080
40082
  var PLATFORM_KEY_PROVIDERS = new Set(
40081
- Object.entries(PLATFORM_KEY_PROVIDER_MAP).filter(([, v]) => v).map(([k2]) => k2)
40083
+ Object.entries(PLATFORM_KEY_PROVIDER_MAP).filter(([, v2]) => v2).map(([k]) => k)
40082
40084
  );
40083
40085
  var MANUAL_PROVIDER_MAP_OVERRIDES = {
40084
40086
  // Bedrock uses different model ID format
@@ -41402,18 +41404,18 @@ function extractSecretReferencesFromAnyValue(value, maxDepth = 10) {
41402
41404
  const keys = /* @__PURE__ */ new Set();
41403
41405
  walk(value, 0);
41404
41406
  return Array.from(keys);
41405
- function walk(v, depth) {
41407
+ function walk(v2, depth) {
41406
41408
  if (depth > maxDepth) return;
41407
- if (typeof v === "string") {
41408
- for (const key of extractSecretReferences(v)) keys.add(key);
41409
+ if (typeof v2 === "string") {
41410
+ for (const key of extractSecretReferences(v2)) keys.add(key);
41409
41411
  return;
41410
41412
  }
41411
- if (Array.isArray(v)) {
41412
- for (const item of v) walk(item, depth + 1);
41413
+ if (Array.isArray(v2)) {
41414
+ for (const item of v2) walk(item, depth + 1);
41413
41415
  return;
41414
41416
  }
41415
- if (v && typeof v === "object") {
41416
- for (const inner of Object.values(v)) {
41417
+ if (v2 && typeof v2 === "object") {
41418
+ for (const inner of Object.values(v2)) {
41417
41419
  walk(inner, depth + 1);
41418
41420
  }
41419
41421
  }
@@ -41759,7 +41761,7 @@ var capabilitySchema = external_exports.object({
41759
41761
  }).refine(
41760
41762
  (cap) => {
41761
41763
  const set2 = [cap.flow, cap.agent, cap.existingFlowId, cap.existingAgentId].filter(
41762
- (v) => v !== void 0 && v !== null
41764
+ (v2) => v2 !== void 0 && v2 !== null
41763
41765
  );
41764
41766
  return set2.length === 1;
41765
41767
  },
@@ -41776,11 +41778,12 @@ var secretSchema = external_exports.object({
41776
41778
  var setupInstructionsSchema = external_exports.object({
41777
41779
  summary: external_exports.string().min(1),
41778
41780
  steps: external_exports.array(external_exports.string()),
41779
- // Constrained to an absolute URL because this lands in the rendered
41780
- // `<a href={…}>` in the secret intake and quick-start preview UIs —
41781
- // `javascript:` / `data:` schemes in an unrestricted string would be a
41782
- // live XSS vector when a malicious template is imported.
41783
- docsUrl: external_exports.string().url().optional()
41781
+ // Constrained to an https-only absolute URL because this lands in the
41782
+ // rendered `<a href={…}>` in the secret intake and quick-start preview UIs —
41783
+ // `javascript:` / `data:` / `http:` schemes in an unrestricted string would
41784
+ // be a live XSS / downgrade vector when a malicious template is imported.
41785
+ // Canonical schema lives in secrets-types.ts (`secretDocsUrlSchema`).
41786
+ docsUrl: secretDocsUrlSchema.optional()
41784
41787
  });
41785
41788
  var toolAuthSchema = external_exports.object({
41786
41789
  type: external_exports.enum(["oauth", "api_key", "none", "user_provided"]),
@@ -42117,6 +42120,90 @@ var productReadinessSchema = external_exports.object({
42117
42120
  /** Single best dashboard link if any browser step remains (secret-parity). */
42118
42121
  handoff: browserFulfillmentSchema.optional()
42119
42122
  });
42123
+ var briefFieldStatusSchema = external_exports.enum(["confirmed", "assumed"]);
42124
+ var briefProblemSchema = external_exports.object({
42125
+ status: briefFieldStatusSchema,
42126
+ /** The specific situation, in the user's own words. Always present when the field is. */
42127
+ statement: external_exports.string().min(1),
42128
+ /** Who runs into this situation. */
42129
+ whoFeelsIt: external_exports.string().min(1).optional(),
42130
+ /** What the problem costs them (time, money, missed work, frustration). */
42131
+ cost: external_exports.string().min(1).optional()
42132
+ });
42133
+ var briefAudienceGroupSchema = external_exports.object({
42134
+ group: external_exports.string().min(1),
42135
+ whatTheyDo: external_exports.string().min(1)
42136
+ });
42137
+ var briefAudienceSchema = external_exports.object({
42138
+ status: briefFieldStatusSchema,
42139
+ groups: external_exports.array(briefAudienceGroupSchema)
42140
+ });
42141
+ var briefCapabilitySchema = external_exports.object({
42142
+ name: external_exports.string().min(1),
42143
+ /** What it does, in plain terms. */
42144
+ behavior: external_exports.string().min(1),
42145
+ /** True = needed on day one; false = explicitly deferred to "later". */
42146
+ dayOne: external_exports.boolean()
42147
+ });
42148
+ var briefCapabilitiesSchema = external_exports.object({
42149
+ status: briefFieldStatusSchema,
42150
+ items: external_exports.array(briefCapabilitySchema)
42151
+ });
42152
+ var briefSurfaceTypeSchema = surfaceSchema.shape.type;
42153
+ var briefSurfaceSchema = external_exports.object({
42154
+ type: briefSurfaceTypeSchema,
42155
+ /** Optional plain-language label (e.g. "our website chat"). */
42156
+ name: external_exports.string().min(1).optional(),
42157
+ /** Optional note on why people reach the product here. */
42158
+ purpose: external_exports.string().min(1).optional()
42159
+ });
42160
+ var briefSurfacesSchema = external_exports.object({
42161
+ status: briefFieldStatusSchema,
42162
+ items: external_exports.array(briefSurfaceSchema)
42163
+ });
42164
+ var briefDataNeedsSchema = external_exports.object({
42165
+ status: briefFieldStatusSchema,
42166
+ /** Things it should remember run-to-run. */
42167
+ remembers: external_exports.array(external_exports.string().min(1)).optional(),
42168
+ /** Things it must already know before it can help. */
42169
+ mustAlreadyKnow: external_exports.array(external_exports.string().min(1)).optional()
42170
+ });
42171
+ var briefIntegrationSchema = external_exports.object({
42172
+ name: external_exports.string().min(1),
42173
+ purpose: external_exports.string().min(1).optional()
42174
+ });
42175
+ var briefIntegrationsSchema = external_exports.object({
42176
+ status: briefFieldStatusSchema,
42177
+ items: external_exports.array(briefIntegrationSchema)
42178
+ });
42179
+ var briefSuccessCriteriaSchema = external_exports.object({
42180
+ status: briefFieldStatusSchema,
42181
+ measure: external_exports.string().min(1)
42182
+ });
42183
+ var productBriefSchema = external_exports.object({
42184
+ problem: briefProblemSchema.optional(),
42185
+ audience: briefAudienceSchema.optional(),
42186
+ capabilities: briefCapabilitiesSchema.optional(),
42187
+ surfaces: briefSurfacesSchema.optional(),
42188
+ dataNeeds: briefDataNeedsSchema.optional(),
42189
+ integrations: briefIntegrationsSchema.optional(),
42190
+ successCriteria: briefSuccessCriteriaSchema.optional()
42191
+ });
42192
+ var fieldSoliditySchema = external_exports.enum(["empty", "sketched", "solid"]);
42193
+ var briefReadinessFieldsSchema = external_exports.object({
42194
+ problem: fieldSoliditySchema,
42195
+ audience: fieldSoliditySchema,
42196
+ capabilities: fieldSoliditySchema,
42197
+ surfaces: fieldSoliditySchema,
42198
+ dataNeeds: fieldSoliditySchema,
42199
+ integrations: fieldSoliditySchema,
42200
+ successCriteria: fieldSoliditySchema
42201
+ });
42202
+ var briefReadinessSchema = external_exports.object({
42203
+ ready: external_exports.boolean(),
42204
+ fields: briefReadinessFieldsSchema,
42205
+ missing: external_exports.array(external_exports.string())
42206
+ });
42120
42207
  var FLAT_ADVANCED_CONFIG_KEYS = {
42121
42208
  loopConfig: true,
42122
42209
  reasoning: true,
@@ -42330,7 +42417,7 @@ function validateCapability(cap, index, context) {
42330
42417
  const result = emptyResult();
42331
42418
  const base = `capabilities[${index}]`;
42332
42419
  const backings = [cap.flow, cap.agent, cap.existingFlowId, cap.existingAgentId].filter(
42333
- (v) => v !== void 0 && v !== null
42420
+ (v2) => v2 !== void 0 && v2 !== null
42334
42421
  );
42335
42422
  if (backings.length === 0) {
42336
42423
  result.errors.push(
@@ -49809,8 +49896,8 @@ configCommand.command("get [key]").description("Get configuration value").action
49809
49896
  const allConfig = config2.store;
49810
49897
  if (Object.keys(allConfig).length > 0) {
49811
49898
  console.log(chalk10.cyan("Current Configuration:"));
49812
- for (const [k2, v] of Object.entries(allConfig)) {
49813
- console.log(` ${chalk10.green(k2)}: ${v}`);
49899
+ for (const [k, v2] of Object.entries(allConfig)) {
49900
+ console.log(` ${chalk10.green(k)}: ${v2}`);
49814
49901
  }
49815
49902
  } else {
49816
49903
  console.log(chalk10.gray("No configuration set"));
@@ -51210,7 +51297,7 @@ Keys (${keys.length}):`));
51210
51297
  const itemSummary = items.length === 0 ? "No items" : items.map(
51211
51298
  (i) => `${i.exposedName || i.capabilityName || i.capabilityId}${i.isEntryPoint ? " (entry point)" : ""}`
51212
51299
  ).join("\n");
51213
- const keySummary = keys.length === 0 ? "No keys" : keys.map((k2) => `${k2.name ?? "(unnamed)"} ${k2.keyPrefix ?? ""}`.trim()).join("\n");
51300
+ const keySummary = keys.length === 0 ? "No keys" : keys.map((k) => `${k.name ?? "(unnamed)"} ${k.keyPrefix ?? ""}`.trim()).join("\n");
51214
51301
  setResultNode(
51215
51302
  React10.createElement(EntityCard, {
51216
51303
  fields: [
@@ -51389,7 +51476,7 @@ logsCommand.command("stats").description("Aggregate log stats: totals, counts by
51389
51476
  const formatCounts = (counts) => {
51390
51477
  const entries = Object.entries(counts);
51391
51478
  if (entries.length === 0) return "(none)";
51392
- return entries.map(([k2, v]) => `${k2}=${v}`).join(", ");
51479
+ return entries.map(([k, v2]) => `${k}=${v2}`).join(", ");
51393
51480
  };
51394
51481
  if (!isTTY(options) || options.json) {
51395
51482
  try {
@@ -52709,8 +52796,8 @@ var dispatchCommand = new Command15("dispatch").description("Execute a flow or a
52709
52796
  }
52710
52797
  if (options.variable && options.variable.length > 0) {
52711
52798
  const variables = {};
52712
- for (const v of options.variable) {
52713
- const [key, ...rest] = v.split("=");
52799
+ for (const v2 of options.variable) {
52800
+ const [key, ...rest] = v2.split("=");
52714
52801
  variables[key] = rest.join("=");
52715
52802
  }
52716
52803
  payload.variables = variables;
@@ -53322,7 +53409,7 @@ function buildToolPreview(params) {
53322
53409
  function pushRawEvent(eventsRef, type, data, writer, listData) {
53323
53410
  const event = { timestamp: Date.now(), type, data, ...listData ? { listData } : {} };
53324
53411
  if (writer?.current) {
53325
- const w = writer.current;
53412
+ const w2 = writer.current;
53326
53413
  const jsonlEvent = {
53327
53414
  timestamp: event.timestamp,
53328
53415
  type: event.type,
@@ -53330,7 +53417,7 @@ function pushRawEvent(eventsRef, type, data, writer, listData) {
53330
53417
  };
53331
53418
  queueMicrotask(() => {
53332
53419
  try {
53333
- w(jsonlEvent);
53420
+ w2(jsonlEvent);
53334
53421
  } catch {
53335
53422
  }
53336
53423
  });
@@ -56559,7 +56646,7 @@ function BlinkingTextInput({
56559
56646
  return;
56560
56647
  }
56561
56648
  blinkRef.current = setInterval(() => {
56562
- setBlinkVisible((v) => !v);
56649
+ setBlinkVisible((v2) => !v2);
56563
56650
  }, CURSOR_BLINK_MS);
56564
56651
  return () => {
56565
56652
  if (blinkRef.current) {
@@ -57099,8 +57186,8 @@ function TextArea({
57099
57186
  const separator = theme21.separator ?? " \xB7 ";
57100
57187
  const [lines, setLines] = useState24(() => splitLines(defaultValue));
57101
57188
  const [cursor, setCursor] = useState24(() => {
57102
- const l2 = splitLines(defaultValue);
57103
- return { line: l2.length - 1, col: l2[l2.length - 1].length };
57189
+ const l = splitLines(defaultValue);
57190
+ return { line: l.length - 1, col: l[l.length - 1].length };
57104
57191
  });
57105
57192
  const [scrollOffset, setScrollOffset] = useState24(0);
57106
57193
  const [blinkVisible, setBlinkVisible] = useState24(true);
@@ -57111,7 +57198,7 @@ function TextArea({
57111
57198
  cursorRef.current = cursor;
57112
57199
  useEffect21(() => {
57113
57200
  blinkRef.current = setInterval(() => {
57114
- setBlinkVisible((v) => !v);
57201
+ setBlinkVisible((v2) => !v2);
57115
57202
  }, CURSOR_BLINK_MS);
57116
57203
  return () => {
57117
57204
  if (blinkRef.current) {
@@ -58069,11 +58156,11 @@ function compactRawStreamEventForCopy(event) {
58069
58156
  data = JSON.parse(JSON.stringify(event.listData, stringCompactionReplacer));
58070
58157
  } else {
58071
58158
  data = {};
58072
- for (const [k2, v] of Object.entries(event.data)) {
58073
- if (STREAM_EVENT_HEAVY_KEYS.has(k2)) {
58074
- data[k2] = compactHeavyField(v);
58159
+ for (const [k, v2] of Object.entries(event.data)) {
58160
+ if (STREAM_EVENT_HEAVY_KEYS.has(k)) {
58161
+ data[k] = compactHeavyField(v2);
58075
58162
  } else {
58076
- data[k2] = compactJsonLike(v);
58163
+ data[k] = compactJsonLike(v2);
58077
58164
  }
58078
58165
  }
58079
58166
  }
@@ -65914,10 +66001,10 @@ modelsCommand.command("available").description("List all available models groupe
65914
66001
  const group = item;
65915
66002
  return React18.createElement(EntityCard, {
65916
66003
  title: `${group.provider} / ${group.baseModel}`,
65917
- fields: group.variants.map((v) => ({
65918
- label: v.modelId,
65919
- value: v.configured ? "configured" : "available",
65920
- color: v.configured ? "green" : void 0
66004
+ fields: group.variants.map((v2) => ({
66005
+ label: v2.modelId,
66006
+ value: v2.configured ? "configured" : "available",
66007
+ color: v2.configured ? "green" : void 0
65921
66008
  }))
65922
66009
  });
65923
66010
  },
@@ -67238,10 +67325,10 @@ apiKeysCommand.command("list").description("List your API keys").option("--json"
67238
67325
  total,
67239
67326
  emptyMessage: "No API keys found",
67240
67327
  renderCard: (item) => {
67241
- const k2 = item;
67242
- const prefix = k2.prefix ? ` (${k2.prefix}...)` : "";
67243
- const lastUsed = k2.lastUsedAt ? ` last used: ${k2.lastUsedAt}` : "";
67244
- return React21.createElement(Text35, null, ` ${k2.id} ${k2.name}${prefix}${lastUsed}`);
67328
+ const k = item;
67329
+ const prefix = k.prefix ? ` (${k.prefix}...)` : "";
67330
+ const lastUsed = k.lastUsedAt ? ` last used: ${k.lastUsedAt}` : "";
67331
+ return React21.createElement(Text35, null, ` ${k.id} ${k.name}${prefix}${lastUsed}`);
67245
67332
  }
67246
67333
  });
67247
67334
  };
@@ -67801,8 +67888,8 @@ clientTokensCommand.command("create").description("Create a new client token").r
67801
67888
  console.log(` Token: ${chalk30.yellow(data.token)}`);
67802
67889
  if (data.warnings?.length > 0) {
67803
67890
  console.log("");
67804
- for (const w of data.warnings) {
67805
- console.log(chalk30.yellow(` \u26A0 ${w.message}`));
67891
+ for (const w2 of data.warnings) {
67892
+ console.log(chalk30.yellow(` \u26A0 ${w2.message}`));
67806
67893
  }
67807
67894
  }
67808
67895
  }
@@ -67830,8 +67917,8 @@ clientTokensCommand.command("create").description("Create a new client token").r
67830
67917
  { label: "Token", value: data.token, color: "yellow" }
67831
67918
  ];
67832
67919
  if (data.warnings?.length > 0) {
67833
- for (const w of data.warnings) {
67834
- fields.push({ label: "Warning", value: w.message, color: "yellow" });
67920
+ for (const w2 of data.warnings) {
67921
+ fields.push({ label: "Warning", value: w2.message, color: "yellow" });
67835
67922
  }
67836
67923
  }
67837
67924
  setResultNode(React22.createElement(EntityCard, { fields }));
@@ -68022,16 +68109,16 @@ import { execFileSync } from "child_process";
68022
68109
  // src/lib/persona-init.ts
68023
68110
  init_credential_store();
68024
68111
 
68025
- // ../../node_modules/.pnpm/@runtypelabs+persona@4.6.1/node_modules/@runtypelabs/persona/dist/codegen.js
68026
- var S = "4.6.1";
68027
- var c = S;
68112
+ // ../../node_modules/.pnpm/@runtypelabs+persona@4.8.0/node_modules/@runtypelabs/persona/dist/codegen.js
68113
+ var w = "4.8.0";
68114
+ var c = w;
68028
68115
  function u(e) {
68029
- if (e !== void 0) return typeof e == "string" ? e : Array.isArray(e) ? `[${e.map((r) => r.toString()).join(", ")}]` : e.toString();
68116
+ if (e !== void 0) return typeof e == "string" ? e : Array.isArray(e) ? `[${e.map((i) => i.toString()).join(", ")}]` : e.toString();
68030
68117
  }
68031
- function I(e) {
68118
+ function P(e) {
68032
68119
  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) };
68033
68120
  }
68034
- var x = `({ text, message }: any) => {
68121
+ var S = `({ text, message }: any) => {
68035
68122
  const jsonSource = (message as any).rawContent || text || message.content;
68036
68123
  if (!jsonSource || typeof jsonSource !== 'string') return null;
68037
68124
  let cleanJson = jsonSource
@@ -68045,7 +68132,7 @@ var x = `({ text, message }: any) => {
68045
68132
  } catch (e) { return null; }
68046
68133
  return null;
68047
68134
  }`;
68048
- var A = `function(ctx) {
68135
+ var x = `function(ctx) {
68049
68136
  var jsonSource = ctx.message.rawContent || ctx.text || ctx.message.content;
68050
68137
  if (!jsonSource || typeof jsonSource !== 'string') return null;
68051
68138
  var cleanJson = jsonSource
@@ -68059,7 +68146,7 @@ var A = `function(ctx) {
68059
68146
  } catch (e) { return null; }
68060
68147
  return null;
68061
68148
  }`;
68062
- var j = `(action: any, context: any) => {
68149
+ var A = `(action: any, context: any) => {
68063
68150
  if (action.type !== 'nav_then_click') return;
68064
68151
  const payload = action.payload || action.raw || {};
68065
68152
  const url = payload?.page;
@@ -68077,7 +68164,7 @@ var j = `(action: any, context: any) => {
68077
68164
  window.location.href = targetUrl;
68078
68165
  return { handled: true, displayText: text };
68079
68166
  }`;
68080
- var O = `function(action, context) {
68167
+ var j = `function(action, context) {
68081
68168
  if (action.type !== 'nav_then_click') return;
68082
68169
  var payload = action.payload || action.raw || {};
68083
68170
  var url = payload.page;
@@ -68095,136 +68182,134 @@ var O = `function(action, context) {
68095
68182
  window.location.href = targetUrl;
68096
68183
  return { handled: true, displayText: text };
68097
68184
  }`;
68098
- var _ = `(parsed: any) => {
68185
+ var v = `(parsed: any) => {
68099
68186
  if (!parsed || typeof parsed !== 'object') return null;
68100
68187
  if (parsed.action === 'nav_then_click') return 'Navigating...';
68101
68188
  if (parsed.action === 'message') return parsed.text || '';
68102
68189
  if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
68103
68190
  return parsed.text || null;
68104
68191
  }`;
68105
- var T = `function(parsed) {
68192
+ var I = `function(parsed) {
68106
68193
  if (!parsed || typeof parsed !== 'object') return null;
68107
68194
  if (parsed.action === 'nav_then_click') return 'Navigating...';
68108
68195
  if (parsed.action === 'message') return parsed.text || '';
68109
68196
  if (parsed.action === 'message_and_click') return parsed.text || 'Processing...';
68110
68197
  return parsed.text || null;
68111
68198
  }`;
68112
- function M(e) {
68199
+ function _(e) {
68113
68200
  if (!e) return null;
68114
- let r = e.toString();
68115
- 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;
68201
+ let i = e.toString();
68202
+ return i.includes("createJsonStreamParser") || i.includes("partial-json") ? "json" : i.includes("createRegexJsonParser") || i.includes("regex") ? "regex-json" : i.includes("createXmlParser") || i.includes("<text>") ? "xml" : null;
68116
68203
  }
68117
- function h(e) {
68118
- var r, n;
68119
- return (n = (r = e.parserType) != null ? r : M(e.streamParser)) != null ? n : "plain";
68204
+ function g(e) {
68205
+ return e.parserType ?? _(e.streamParser) ?? "plain";
68120
68206
  }
68121
- function m(e, r) {
68207
+ function m(e, i) {
68122
68208
  let n = [];
68123
- return e.toolCall && (n.push(`${r}toolCall: {`), Object.entries(e.toolCall).forEach(([s, o]) => {
68124
- typeof o == "string" && n.push(`${r} ${s}: "${o}",`);
68125
- }), n.push(`${r}},`)), n;
68209
+ return e.toolCall && (n.push(`${i}toolCall: {`), Object.entries(e.toolCall).forEach(([s, o]) => {
68210
+ typeof o == "string" && n.push(`${i} ${s}: "${o}",`);
68211
+ }), n.push(`${i}},`)), n;
68126
68212
  }
68127
- function f(e, r, n) {
68128
- 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);
68129
- return (o || t) && (s.push(`${r}messageActions: {`), e.messageActions && Object.entries(e.messageActions).forEach(([i, a]) => {
68130
- i === "onFeedback" || i === "onCopy" || (typeof a == "string" ? s.push(`${r} ${i}: "${a}",`) : typeof a == "boolean" && s.push(`${r} ${i}: ${a},`));
68131
- }), n != null && n.onFeedback && s.push(`${r} onFeedback: ${n.onFeedback},`), n != null && n.onCopy && s.push(`${r} onCopy: ${n.onCopy},`), s.push(`${r}},`)), s;
68213
+ function f(e, i, n) {
68214
+ let s = [], o = e.messageActions && Object.entries(e.messageActions).some(([r, a]) => r !== "onFeedback" && r !== "onCopy" && a !== void 0), t = n?.onFeedback || n?.onCopy;
68215
+ return (o || t) && (s.push(`${i}messageActions: {`), e.messageActions && Object.entries(e.messageActions).forEach(([r, a]) => {
68216
+ r === "onFeedback" || r === "onCopy" || (typeof a == "string" ? s.push(`${i} ${r}: "${a}",`) : typeof a == "boolean" && s.push(`${i} ${r}: ${a},`));
68217
+ }), n?.onFeedback && s.push(`${i} onFeedback: ${n.onFeedback},`), n?.onCopy && s.push(`${i} onCopy: ${n.onCopy},`), s.push(`${i}},`)), s;
68132
68218
  }
68133
- function y(e, r) {
68219
+ function y(e, i) {
68134
68220
  let n = [];
68135
68221
  if (e.markdown) {
68136
68222
  let s = e.markdown.options && Object.keys(e.markdown.options).length > 0, o = e.markdown.disableDefaultStyles !== void 0;
68137
- (s || o) && (n.push(`${r}markdown: {`), s && (n.push(`${r} options: {`), Object.entries(e.markdown.options).forEach(([t, i]) => {
68138
- typeof i == "string" ? n.push(`${r} ${t}: "${i}",`) : typeof i == "boolean" && n.push(`${r} ${t}: ${i},`);
68139
- }), n.push(`${r} },`)), o && n.push(`${r} disableDefaultStyles: ${e.markdown.disableDefaultStyles},`), n.push(`${r}},`));
68223
+ (s || o) && (n.push(`${i}markdown: {`), s && (n.push(`${i} options: {`), Object.entries(e.markdown.options).forEach(([t, r]) => {
68224
+ typeof r == "string" ? n.push(`${i} ${t}: "${r}",`) : typeof r == "boolean" && n.push(`${i} ${t}: ${r},`);
68225
+ }), n.push(`${i} },`)), o && n.push(`${i} disableDefaultStyles: ${e.markdown.disableDefaultStyles},`), n.push(`${i}},`));
68140
68226
  }
68141
68227
  return n;
68142
68228
  }
68143
- function C(e, r) {
68229
+ function C(e, i) {
68144
68230
  let n = [];
68145
68231
  if (e.layout) {
68146
68232
  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");
68147
- (s || o) && (n.push(`${r}layout: {`), s && (n.push(`${r} header: {`), Object.entries(e.layout.header).forEach(([t, i]) => {
68148
- t !== "render" && (typeof i == "string" ? n.push(`${r} ${t}: "${i}",`) : typeof i == "boolean" && n.push(`${r} ${t}: ${i},`));
68149
- }), n.push(`${r} },`)), o && (n.push(`${r} messages: {`), Object.entries(e.layout.messages).forEach(([t, i]) => {
68150
- t === "renderUserMessage" || t === "renderAssistantMessage" || (t === "avatar" && typeof i == "object" && i !== null ? (n.push(`${r} avatar: {`), Object.entries(i).forEach(([a, p]) => {
68151
- typeof p == "string" ? n.push(`${r} ${a}: "${p}",`) : typeof p == "boolean" && n.push(`${r} ${a}: ${p},`);
68152
- }), 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]) => {
68153
- p !== "format" && (typeof d == "string" ? n.push(`${r} ${p}: "${d}",`) : typeof d == "boolean" && n.push(`${r} ${p}: ${d},`));
68154
- }), n.push(`${r} },`)) : typeof i == "string" ? n.push(`${r} ${t}: "${i}",`) : typeof i == "boolean" && n.push(`${r} ${t}: ${i},`));
68155
- }), n.push(`${r} },`)), n.push(`${r}},`));
68233
+ (s || o) && (n.push(`${i}layout: {`), s && (n.push(`${i} header: {`), Object.entries(e.layout.header).forEach(([t, r]) => {
68234
+ t !== "render" && (typeof r == "string" ? n.push(`${i} ${t}: "${r}",`) : typeof r == "boolean" && n.push(`${i} ${t}: ${r},`));
68235
+ }), n.push(`${i} },`)), o && (n.push(`${i} messages: {`), Object.entries(e.layout.messages).forEach(([t, r]) => {
68236
+ t === "renderUserMessage" || t === "renderAssistantMessage" || (t === "avatar" && typeof r == "object" && r !== null ? (n.push(`${i} avatar: {`), Object.entries(r).forEach(([a, p]) => {
68237
+ typeof p == "string" ? n.push(`${i} ${a}: "${p}",`) : typeof p == "boolean" && n.push(`${i} ${a}: ${p},`);
68238
+ }), n.push(`${i} },`)) : t === "timestamp" && typeof r == "object" && r !== null ? Object.entries(r).some(([p]) => p !== "format") && (n.push(`${i} timestamp: {`), Object.entries(r).forEach(([p, l]) => {
68239
+ p !== "format" && (typeof l == "string" ? n.push(`${i} ${p}: "${l}",`) : typeof l == "boolean" && n.push(`${i} ${p}: ${l},`));
68240
+ }), n.push(`${i} },`)) : typeof r == "string" ? n.push(`${i} ${t}: "${r}",`) : typeof r == "boolean" && n.push(`${i} ${t}: ${r},`));
68241
+ }), n.push(`${i} },`)), n.push(`${i}},`));
68156
68242
  }
68157
68243
  return n;
68158
68244
  }
68159
- function $(e, r) {
68245
+ function $(e, i) {
68160
68246
  let n = [];
68161
- 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;
68247
+ return e && (e.getHeaders && n.push(`${i}getHeaders: ${e.getHeaders},`), e.requestMiddleware && n.push(`${i}requestMiddleware: ${e.requestMiddleware},`), e.actionParsers && n.push(`${i}actionParsers: ${e.actionParsers},`), e.actionHandlers && n.push(`${i}actionHandlers: ${e.actionHandlers},`), e.contextProviders && n.push(`${i}contextProviders: ${e.contextProviders},`), e.streamParser && n.push(`${i}streamParser: ${e.streamParser},`)), n;
68162
68248
  }
68163
- function E(e, r, n) {
68164
- Object.entries(r).forEach(([s, o]) => {
68249
+ function O(e, i, n) {
68250
+ Object.entries(i).forEach(([s, o]) => {
68165
68251
  if (!(o === void 0 || typeof o == "function")) {
68166
68252
  if (Array.isArray(o)) {
68167
68253
  e.push(`${n}${s}: ${JSON.stringify(o)},`);
68168
68254
  return;
68169
68255
  }
68170
68256
  if (o && typeof o == "object") {
68171
- e.push(`${n}${s}: {`), E(e, o, `${n} `), e.push(`${n}},`);
68257
+ e.push(`${n}${s}: {`), O(e, o, `${n} `), e.push(`${n}},`);
68172
68258
  return;
68173
68259
  }
68174
68260
  e.push(`${n}${s}: ${JSON.stringify(o)},`);
68175
68261
  }
68176
68262
  });
68177
68263
  }
68178
- function l(e, r, n, s) {
68179
- n && (e.push(`${s}${r}: {`), E(e, n, `${s} `), e.push(`${s}},`));
68264
+ function d(e, i, n, s) {
68265
+ n && (e.push(`${s}${i}: {`), O(e, n, `${s} `), e.push(`${s}},`));
68180
68266
  }
68181
- function g(e) {
68182
- var r;
68183
- return ((r = e == null ? void 0 : e.target) != null ? r : "body").replace(/\\/g, "\\\\").replace(/'/g, "\\'");
68267
+ function h(e) {
68268
+ return (e?.target ?? "body").replace(/\\/g, "\\\\").replace(/'/g, "\\'");
68184
68269
  }
68185
- function R(e, r = "esm", n) {
68270
+ function T(e, i = "esm", n) {
68186
68271
  let s = { ...e };
68187
68272
  delete s.postprocessMessage, delete s.initialMessages;
68188
- let o = n ? { ...n, hooks: I(n.hooks) } : void 0;
68189
- return r === "esm" ? W(s, o) : r === "script-installer" ? N(s, o) : r === "script-advanced" ? F(s, o) : r === "react-component" ? H(s, o) : r === "react-advanced" ? k(s, o) : D(s, o);
68190
- }
68191
- function W(e, r) {
68192
- 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: {"];
68193
- return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), 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]) => {
68194
- t.push(` ${i}: "${a}",`);
68195
- }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([i, a]) => {
68196
- typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
68197
- }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([i, a]) => {
68198
- typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" ? t.push(` ${i}: ${a},`) : typeof a == "number" && t.push(` ${i}: ${a},`);
68199
- }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([i, a]) => {
68200
- typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
68201
- }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([i, a]) => {
68202
- t.push(` ${i}: ${a},`);
68203
- }), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((i) => {
68204
- t.push(` "${i}",`);
68205
- }), 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(...m(e, " ")), t.push(...f(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(`
68273
+ let o = n ? { ...n, hooks: P(n.hooks) } : void 0;
68274
+ return i === "esm" ? M(s, o) : i === "script-installer" ? H(s, o) : i === "script-advanced" ? D(s, o) : i === "react-component" ? R(s, o) : i === "react-advanced" ? W(s, o) : N(s, o);
68275
+ }
68276
+ function M(e, i) {
68277
+ let n = i?.hooks, s = g(e), o = s !== "plain", t = ["import '@runtypelabs/persona/widget.css';", "import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';", "", "initAgentWidget({", ` target: '${h(i)}',`, " config: {"];
68278
+ return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, a]) => {
68279
+ t.push(` ${r}: "${a}",`);
68280
+ }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, a]) => {
68281
+ typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68282
+ }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, a]) => {
68283
+ typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" ? t.push(` ${r}: ${a},`) : typeof a == "number" && t.push(` ${r}: ${a},`);
68284
+ }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, a]) => {
68285
+ typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68286
+ }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, a]) => {
68287
+ t.push(` ${r}: ${a},`);
68288
+ }), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((r) => {
68289
+ t.push(` "${r}",`);
68290
+ }), 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(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n?.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text)"), t.push(" }"), t.push("});"), t.join(`
68206
68291
  `);
68207
68292
  }
68208
- function H(e, r) {
68209
- 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: {"];
68210
- return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), 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]) => {
68211
- t.push(` ${i}: "${a}",`);
68212
- }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([i, a]) => {
68213
- typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
68214
- }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([i, a]) => {
68215
- typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" ? t.push(` ${i}: ${a},`) : typeof a == "number" && t.push(` ${i}: ${a},`);
68216
- }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([i, a]) => {
68217
- typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
68218
- }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([i, a]) => {
68219
- t.push(` ${i}: ${a},`);
68220
- }), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((i) => {
68221
- t.push(` "${i}",`);
68222
- }), 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(...m(e, " ")), t.push(...f(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(`
68293
+ function R(e, i) {
68294
+ let n = i?.hooks, s = g(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: '${h(i)}',`, " config: {"];
68295
+ return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, a]) => {
68296
+ t.push(` ${r}: "${a}",`);
68297
+ }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, a]) => {
68298
+ typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68299
+ }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, a]) => {
68300
+ typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" ? t.push(` ${r}: ${a},`) : typeof a == "number" && t.push(` ${r}: ${a},`);
68301
+ }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, a]) => {
68302
+ typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68303
+ }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, a]) => {
68304
+ t.push(` ${r}: ${a},`);
68305
+ }), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((r) => {
68306
+ t.push(` "${r}",`);
68307
+ }), 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(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), 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(`
68223
68308
  `);
68224
68309
  }
68225
- function k(e, r) {
68226
- 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: {"];
68227
- return e.apiUrl && s.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && s.push(` clientToken: "${e.clientToken}",`), e.agentId && s.push(` agentId: "${e.agentId}",`), e.target && s.push(` target: "${e.target}",`), 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]) => {
68310
+ function W(e, i) {
68311
+ let n = i?.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: '${h(i)}',`, " config: {"];
68312
+ return e.apiUrl && s.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && s.push(` clientToken: "${e.clientToken}",`), e.agentId && s.push(` agentId: "${e.agentId}",`), e.target && s.push(` target: "${e.target}",`), e.flowId && s.push(` flowId: "${e.flowId}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(s, "theme", e.theme, " "), e.launcher && d(s, "launcher", e.launcher, " "), e.copy && (s.push(" copy: {"), Object.entries(e.copy).forEach(([o, t]) => {
68228
68313
  s.push(` ${o}: "${t}",`);
68229
68314
  }), s.push(" },")), e.sendButton && (s.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([o, t]) => {
68230
68315
  typeof t == "string" ? s.push(` ${o}: "${t}",`) : typeof t == "boolean" && s.push(` ${o}: ${t},`);
@@ -68236,78 +68321,77 @@ function k(e, r) {
68236
68321
  s.push(` ${o}: ${t},`);
68237
68322
  }), s.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (s.push(" suggestionChips: ["), e.suggestionChips.forEach((o) => {
68238
68323
  s.push(` "${o}",`);
68239
- }), 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(...m(e, " ")), s.push(...f(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(${_}),`)), 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(` ${j}`), 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(` ${j}`), 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(`
68324
+ }), 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(...m(e, " ")), s.push(...f(e, " ", n)), s.push(...y(e, " ")), s.push(...C(e, " ")), n?.getHeaders && s.push(` getHeaders: ${n.getHeaders},`), n?.contextProviders && s.push(` contextProviders: ${n.contextProviders},`), e.debug && s.push(` debug: ${e.debug},`), s.push(" initialMessages: loadSavedMessages(),"), n?.streamParser ? s.push(` streamParser: ${n.streamParser},`) : (s.push(" // Flexible JSON stream parser for handling structured actions"), s.push(` streamParser: () => createFlexibleJsonStreamParser(${v}),`)), 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(` ${S}`), 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(` ${S}`), s.push(" ],")), 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(` ${A}`), 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(` ${A}`), s.push(" ],")), n?.postprocessMessage ? s.push(` postprocessMessage: ${n.postprocessMessage},`) : s.push(" postprocessMessage: ({ text }) => markdownPostprocessor(text),"), 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(`
68240
68325
  `);
68241
68326
  }
68242
- function P(e) {
68243
- var o;
68244
- let r = h(e), n = r !== "plain", s = {};
68245
- if (e.apiUrl && (s.apiUrl = e.apiUrl), e.clientToken && (s.clientToken = e.clientToken), e.agentId && (s.agentId = e.agentId), e.target && (s.target = e.target), 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) {
68246
- let t = {};
68247
- Object.entries(e.toolCall).forEach(([i, a]) => {
68248
- typeof a == "string" && (t[i] = a);
68249
- }), Object.keys(t).length > 0 && (s.toolCall = t);
68327
+ function E(e) {
68328
+ let i = g(e), n = i !== "plain", s = {};
68329
+ if (e.apiUrl && (s.apiUrl = e.apiUrl), e.clientToken && (s.clientToken = e.clientToken), e.agentId && (s.agentId = e.agentId), e.target && (s.target = e.target), e.flowId && (s.flowId = e.flowId), n && (s.parserType = i), 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), e.suggestionChips?.length > 0 && (s.suggestionChips = e.suggestionChips), e.suggestionChipsConfig && (s.suggestionChipsConfig = e.suggestionChipsConfig), e.debug && (s.debug = e.debug), e.toolCall) {
68330
+ let o = {};
68331
+ Object.entries(e.toolCall).forEach(([t, r]) => {
68332
+ typeof r == "string" && (o[t] = r);
68333
+ }), Object.keys(o).length > 0 && (s.toolCall = o);
68250
68334
  }
68251
68335
  if (e.messageActions) {
68252
- let t = {};
68253
- Object.entries(e.messageActions).forEach(([i, a]) => {
68254
- i !== "onFeedback" && i !== "onCopy" && a !== void 0 && (typeof a == "string" || typeof a == "boolean") && (t[i] = a);
68255
- }), Object.keys(t).length > 0 && (s.messageActions = t);
68336
+ let o = {};
68337
+ Object.entries(e.messageActions).forEach(([t, r]) => {
68338
+ t !== "onFeedback" && t !== "onCopy" && r !== void 0 && (typeof r == "string" || typeof r == "boolean") && (o[t] = r);
68339
+ }), Object.keys(o).length > 0 && (s.messageActions = o);
68256
68340
  }
68257
68341
  if (e.markdown) {
68258
- let t = {};
68259
- 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);
68342
+ let o = {};
68343
+ e.markdown.options && (o.options = e.markdown.options), e.markdown.disableDefaultStyles !== void 0 && (o.disableDefaultStyles = e.markdown.disableDefaultStyles), Object.keys(o).length > 0 && (s.markdown = o);
68260
68344
  }
68261
68345
  if (e.layout) {
68262
- let t = {};
68346
+ let o = {};
68263
68347
  if (e.layout.header) {
68264
- let i = {};
68265
- Object.entries(e.layout.header).forEach(([a, p]) => {
68266
- a !== "render" && (typeof p == "string" || typeof p == "boolean") && (i[a] = p);
68267
- }), Object.keys(i).length > 0 && (t.header = i);
68348
+ let t = {};
68349
+ Object.entries(e.layout.header).forEach(([r, a]) => {
68350
+ r !== "render" && (typeof a == "string" || typeof a == "boolean") && (t[r] = a);
68351
+ }), Object.keys(t).length > 0 && (o.header = t);
68268
68352
  }
68269
68353
  if (e.layout.messages) {
68270
- let i = {};
68271
- Object.entries(e.layout.messages).forEach(([a, p]) => {
68272
- if (a !== "renderUserMessage" && a !== "renderAssistantMessage") if (a === "avatar" && typeof p == "object" && p !== null) i.avatar = p;
68273
- else if (a === "timestamp" && typeof p == "object" && p !== null) {
68274
- let d = {};
68275
- Object.entries(p).forEach(([w, b]) => {
68276
- w !== "format" && (typeof b == "string" || typeof b == "boolean") && (d[w] = b);
68277
- }), Object.keys(d).length > 0 && (i.timestamp = d);
68278
- } else (typeof p == "string" || typeof p == "boolean") && (i[a] = p);
68279
- }), Object.keys(i).length > 0 && (t.messages = i);
68280
- }
68281
- Object.keys(t).length > 0 && (s.layout = t);
68354
+ let t = {};
68355
+ Object.entries(e.layout.messages).forEach(([r, a]) => {
68356
+ if (r !== "renderUserMessage" && r !== "renderAssistantMessage") if (r === "avatar" && typeof a == "object" && a !== null) t.avatar = a;
68357
+ else if (r === "timestamp" && typeof a == "object" && a !== null) {
68358
+ let p = {};
68359
+ Object.entries(a).forEach(([l, b]) => {
68360
+ l !== "format" && (typeof b == "string" || typeof b == "boolean") && (p[l] = b);
68361
+ }), Object.keys(p).length > 0 && (t.timestamp = p);
68362
+ } else (typeof a == "string" || typeof a == "boolean") && (t[r] = a);
68363
+ }), Object.keys(t).length > 0 && (o.messages = t);
68364
+ }
68365
+ Object.keys(o).length > 0 && (s.layout = o);
68282
68366
  }
68283
68367
  return s;
68284
68368
  }
68285
- function N(e, r) {
68286
- 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, "&#39;");
68369
+ function H(e, i) {
68370
+ let n = E(e), o = !!(i?.windowKey || i?.target) ? { config: n, ...i?.windowKey ? { windowKey: i.windowKey } : {}, ...i?.target ? { target: i.target } : {} } : n, t = JSON.stringify(o, null, 0).replace(/'/g, "&#39;");
68287
68371
  return `<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/install.global.js" data-config='${t}'></script>`;
68288
68372
  }
68289
- function D(e, r) {
68290
- 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: {"];
68291
- return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), 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]) => {
68292
- t.push(` ${i}: "${a}",`);
68293
- }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([i, a]) => {
68294
- typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
68295
- }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([i, a]) => {
68296
- typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" ? t.push(` ${i}: ${a},`) : typeof a == "number" && t.push(` ${i}: ${a},`);
68297
- }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([i, a]) => {
68298
- typeof a == "string" ? t.push(` ${i}: "${a}",`) : typeof a == "boolean" && t.push(` ${i}: ${a},`);
68299
- }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([i, a]) => {
68300
- t.push(` ${i}: ${a},`);
68301
- }), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((i) => {
68302
- t.push(` "${i}",`);
68303
- }), 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(...m(e, " ")), t.push(...f(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(`
68373
+ function N(e, i) {
68374
+ let n = i?.hooks, s = g(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: '${h(i)}',`, ...i?.windowKey ? [` windowKey: '${i.windowKey}',`] : [], " config: {"];
68375
+ return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.agentId && t.push(` agentId: "${e.agentId}",`), e.target && t.push(` target: "${e.target}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && d(t, "theme", e.theme, " "), e.launcher && d(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([r, a]) => {
68376
+ t.push(` ${r}: "${a}",`);
68377
+ }), t.push(" },")), e.sendButton && (t.push(" sendButton: {"), Object.entries(e.sendButton).forEach(([r, a]) => {
68378
+ typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68379
+ }), t.push(" },")), e.voiceRecognition && (t.push(" voiceRecognition: {"), Object.entries(e.voiceRecognition).forEach(([r, a]) => {
68380
+ typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" ? t.push(` ${r}: ${a},`) : typeof a == "number" && t.push(` ${r}: ${a},`);
68381
+ }), t.push(" },")), e.statusIndicator && (t.push(" statusIndicator: {"), Object.entries(e.statusIndicator).forEach(([r, a]) => {
68382
+ typeof a == "string" ? t.push(` ${r}: "${a}",`) : typeof a == "boolean" && t.push(` ${r}: ${a},`);
68383
+ }), t.push(" },")), e.features && (t.push(" features: {"), Object.entries(e.features).forEach(([r, a]) => {
68384
+ t.push(` ${r}: ${a},`);
68385
+ }), t.push(" },")), e.suggestionChips && e.suggestionChips.length > 0 && (t.push(" suggestionChips: ["), e.suggestionChips.forEach((r) => {
68386
+ t.push(` "${r}",`);
68387
+ }), 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(...m(e, " ")), t.push(...f(e, " ", n)), t.push(...y(e, " ")), t.push(...C(e, " ")), t.push(...$(n, " ")), e.debug && t.push(` debug: ${e.debug},`), n?.postprocessMessage ? t.push(` postprocessMessage: ${n.postprocessMessage}`) : t.push(" postprocessMessage: ({ text }) => window.AgentWidget.markdownPostprocessor(text)"), t.push(" }"), t.push(" });"), t.push("</script>"), t.join(`
68304
68388
  `);
68305
68389
  }
68306
- function F(e, r) {
68307
- 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(`
68308
- `).map((i, a) => a === 0 ? i : " " + i).join(`
68390
+ function D(e, i) {
68391
+ let n = i?.hooks, s = E(e), t = ["<script>", "(function() {", " 'use strict';", "", " // Configuration", ` var CONFIG = ${JSON.stringify(s, null, 2).split(`
68392
+ `).map((r, a) => a === 0 ? r : " " + r).join(`
68309
68393
  `)};`, "", " // 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);", ""];
68310
- 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(${T});`), 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(` ${O}`), 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(` ${O}`), 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(`
68394
+ return n?.getHeaders && (t.push(` widgetConfig.getHeaders = ${n.getHeaders};`), t.push("")), n?.contextProviders && (t.push(` widgetConfig.contextProviders = ${n.contextProviders};`), t.push("")), 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(${I});`), t.push(" };")), t.push(""), 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(` ${x}`), t.push(" ]);")) : (t.push(" // Action parsers to detect JSON actions in responses"), t.push(" widgetConfig.actionParsers = ["), t.push(" agentWidget.defaultJsonActionParser,"), t.push(` ${x}`), t.push(" ];")), t.push(""), 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(` ${j}`), 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(` ${j}`), t.push(" ];")), t.push(""), 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?.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?.onFeedback || n?.onCopy) && (t.push(" // Message action callbacks"), t.push(" widgetConfig.messageActions = widgetConfig.messageActions || {};"), n?.onFeedback && t.push(` widgetConfig.messageActions.onFeedback = ${n.onFeedback};`), 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: '${h(i)}',`, " useShadowDom: false,", ...i?.windowKey ? [` windowKey: '${i.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(`
68311
68395
  `);
68312
68396
  }
68313
68397
 
@@ -68347,14 +68431,14 @@ function buildWidgetConfig(input) {
68347
68431
  function generatePersonaInitSnippet(input, personaFormat) {
68348
68432
  const widgetConfig = buildWidgetConfig(input);
68349
68433
  const target = input.targetSelector?.trim();
68350
- return R(
68434
+ return T(
68351
68435
  widgetConfig,
68352
68436
  personaFormat,
68353
68437
  target ? { target } : void 0
68354
68438
  );
68355
68439
  }
68356
68440
  function getPersonaInstallerScriptUrl() {
68357
- const snippet = R(
68441
+ const snippet = T(
68358
68442
  {
68359
68443
  apiUrl: "https://api.runtype.com",
68360
68444
  clientToken: "ct_test_demo_00000000000000000000000000000000",
@@ -69316,8 +69400,8 @@ Dashboard: ${initial.dashboardUrl}`));
69316
69400
  }
69317
69401
  }
69318
69402
  if (initial.warnings?.length) {
69319
- for (const w of initial.warnings) {
69320
- console.log(chalk31.yellow(`\u26A0 ${w.message}`));
69403
+ for (const w2 of initial.warnings) {
69404
+ console.log(chalk31.yellow(`\u26A0 ${w2.message}`));
69321
69405
  }
69322
69406
  }
69323
69407
  if (demo) {
@@ -69775,8 +69859,8 @@ Dashboard: ${output.dashboardUrl}`));
69775
69859
  );
69776
69860
  }
69777
69861
  if (success2.warnings?.length) {
69778
- for (const w of success2.warnings) {
69779
- console.log(chalk31.yellow(`\u26A0 ${w.message}`));
69862
+ for (const w2 of success2.warnings) {
69863
+ console.log(chalk31.yellow(`\u26A0 ${w2.message}`));
69780
69864
  }
69781
69865
  }
69782
69866
  if (!demoOutput) {
@@ -70204,11 +70288,11 @@ flowVersionsCommand.command("list <flowId>").description("List all versions for
70204
70288
  return;
70205
70289
  }
70206
70290
  console.log(chalk34.cyan(`Versions for flow ${flowId}:`));
70207
- for (const v of versions) {
70208
- const publishedTag = v.published ? chalk34.green(" [published]") : "";
70209
- const versionNum = v.version !== void 0 ? `v${v.version}` : v.id;
70210
- const date5 = v.createdAt ? chalk34.gray(` ${v.createdAt}`) : "";
70211
- console.log(` ${chalk34.green(v.id)} ${versionNum}${publishedTag}${date5}`);
70291
+ for (const v2 of versions) {
70292
+ const publishedTag = v2.published ? chalk34.green(" [published]") : "";
70293
+ const versionNum = v2.version !== void 0 ? `v${v2.version}` : v2.id;
70294
+ const date5 = v2.createdAt ? chalk34.gray(` ${v2.createdAt}`) : "";
70295
+ console.log(` ${chalk34.green(v2.id)} ${versionNum}${publishedTag}${date5}`);
70212
70296
  }
70213
70297
  }
70214
70298
  } catch (error51) {
@@ -70243,10 +70327,10 @@ flowVersionsCommand.command("list <flowId>").description("List all versions for
70243
70327
  loading,
70244
70328
  emptyMessage: "No versions found",
70245
70329
  renderCard: (item) => {
70246
- const v = item;
70247
- const publishedTag = v.published ? " [published]" : "";
70248
- const versionNum = v.version !== void 0 ? `v${v.version}` : v.id;
70249
- return React25.createElement(Text38, null, ` ${v.id} ${versionNum}${publishedTag}${v.createdAt ? ` ${v.createdAt}` : ""}`);
70330
+ const v2 = item;
70331
+ const publishedTag = v2.published ? " [published]" : "";
70332
+ const versionNum = v2.version !== void 0 ? `v${v2.version}` : v2.id;
70333
+ return React25.createElement(Text38, null, ` ${v2.id} ${versionNum}${publishedTag}${v2.createdAt ? ` ${v2.createdAt}` : ""}`);
70250
70334
  }
70251
70335
  });
70252
70336
  };
@@ -70461,12 +70545,12 @@ agentVersionsCommand.command("list <agentId>").description("List all versions fo
70461
70545
  return;
70462
70546
  }
70463
70547
  console.log(chalk35.cyan(`Versions for agent ${agentId}:`));
70464
- for (const v of versions) {
70465
- const isPublished = v.id === data.publishedVersionId;
70548
+ for (const v2 of versions) {
70549
+ const isPublished = v2.id === data.publishedVersionId;
70466
70550
  const liveTag = isPublished ? chalk35.green(" [live]") : "";
70467
- const versionLabel = v.label || (v.versionNumber !== void 0 ? `v${v.versionNumber}` : v.id);
70468
- const date5 = v.createdAt ? chalk35.gray(` ${v.createdAt}`) : "";
70469
- console.log(` ${chalk35.green(v.id)} ${versionLabel}${liveTag}${date5}`);
70551
+ const versionLabel = v2.label || (v2.versionNumber !== void 0 ? `v${v2.versionNumber}` : v2.id);
70552
+ const date5 = v2.createdAt ? chalk35.gray(` ${v2.createdAt}`) : "";
70553
+ console.log(` ${chalk35.green(v2.id)} ${versionLabel}${liveTag}${date5}`);
70470
70554
  }
70471
70555
  }
70472
70556
  } catch (error51) {
@@ -70503,13 +70587,13 @@ agentVersionsCommand.command("list <agentId>").description("List all versions fo
70503
70587
  loading,
70504
70588
  emptyMessage: "No versions found",
70505
70589
  renderCard: (item) => {
70506
- const v = item;
70507
- const liveTag = v.id === publishedId ? " [live]" : "";
70508
- const versionLabel = v.label || (v.versionNumber !== void 0 ? `v${v.versionNumber}` : v.id);
70590
+ const v2 = item;
70591
+ const liveTag = v2.id === publishedId ? " [live]" : "";
70592
+ const versionLabel = v2.label || (v2.versionNumber !== void 0 ? `v${v2.versionNumber}` : v2.id);
70509
70593
  return React26.createElement(
70510
70594
  Text39,
70511
70595
  null,
70512
- ` ${v.id} ${versionLabel}${liveTag}${v.createdAt ? ` ${v.createdAt}` : ""}`
70596
+ ` ${v2.id} ${versionLabel}${liveTag}${v2.createdAt ? ` ${v2.createdAt}` : ""}`
70513
70597
  );
70514
70598
  }
70515
70599
  });
@@ -70722,11 +70806,11 @@ function abbreviateId(id) {
70722
70806
  return `${prefix}_${suffix.slice(0, 4)}...`;
70723
70807
  }
70724
70808
  function formatTime(ts) {
70725
- const d = new Date(ts);
70726
- const hh = String(d.getHours()).padStart(2, "0");
70727
- const mm = String(d.getMinutes()).padStart(2, "0");
70728
- const ss = String(d.getSeconds()).padStart(2, "0");
70729
- const ms = String(d.getMilliseconds()).padStart(3, "0");
70809
+ const d2 = new Date(ts);
70810
+ const hh = String(d2.getHours()).padStart(2, "0");
70811
+ const mm = String(d2.getMinutes()).padStart(2, "0");
70812
+ const ss = String(d2.getSeconds()).padStart(2, "0");
70813
+ const ms = String(d2.getMilliseconds()).padStart(3, "0");
70730
70814
  return `${hh}:${mm}:${ss}.${ms}`;
70731
70815
  }
70732
70816
  var LEVEL_COLORS = {
@@ -70746,7 +70830,7 @@ function categoryBadge(category, useColor) {
70746
70830
  return chalk36.magenta(`[${category}]`);
70747
70831
  }
70748
70832
  function formatTailData(data) {
70749
- return Object.entries(data).map(([k2, v]) => `${k2}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(" ");
70833
+ return Object.entries(data).map(([k, v2]) => `${k}=${typeof v2 === "string" ? v2 : JSON.stringify(v2)}`).join(" ");
70750
70834
  }
70751
70835
  function formatContextIds(event, useColor) {
70752
70836
  const ids = [];
@@ -70834,9 +70918,9 @@ async function createSession(apiUrl, apiKey, filters) {
70834
70918
  level: "levels",
70835
70919
  category: "categories"
70836
70920
  };
70837
- for (const [k2, v] of Object.entries(filters)) {
70838
- if (v !== void 0 && arrayFields[k2]) {
70839
- filter[arrayFields[k2]] = [v];
70921
+ for (const [k, v2] of Object.entries(filters)) {
70922
+ if (v2 !== void 0 && arrayFields[k]) {
70923
+ filter[arrayFields[k]] = [v2];
70840
70924
  }
70841
70925
  }
70842
70926
  const body = Object.keys(filter).length > 0 ? { filter } : {};
@@ -70891,7 +70975,7 @@ async function runTail(options) {
70891
70975
  category: options.category
70892
70976
  };
70893
70977
  const useColor = options.color;
70894
- const activeFilters = Object.entries(filters).filter(([, v]) => v !== void 0).map(([k2, v]) => `${k2}=${v}`);
70978
+ const activeFilters = Object.entries(filters).filter(([, v2]) => v2 !== void 0).map(([k, v2]) => `${k}=${v2}`);
70895
70979
  process.stderr.write(
70896
70980
  (useColor ? chalk36.gray(
70897
70981
  `Connecting to ${apiUrl}...${activeFilters.length ? ` filters: ${activeFilters.join(", ")}` : ""}`
@@ -72087,11 +72171,11 @@ function collectSecretNames(agentDef) {
72087
72171
  function slugify2(s) {
72088
72172
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 63);
72089
72173
  }
72090
- var deployCommand = new Command31("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)", (v, acc) => {
72091
- acc.push(v);
72174
+ var deployCommand = new Command31("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) => {
72175
+ acc.push(v2);
72092
72176
  return acc;
72093
- }, []).option("--flow <id>", "Flow ID to export (may be repeated)", (v, acc) => {
72094
- acc.push(v);
72177
+ }, []).option("--flow <id>", "Flow ID to export (may be repeated)", (v2, acc) => {
72178
+ acc.push(v2);
72095
72179
  return acc;
72096
72180
  }, []).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(
72097
72181
  async (options) => {