@qfei-design/make-ai-assistant 0.1.4 → 0.1.6

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.
@@ -1,9 +1,9 @@
1
- const k = (t, e) => {
1
+ const R = (t, e) => {
2
2
  let r = 0;
3
- for (const a of t)
3
+ for (const s of t)
4
4
  if (r += 1, r > e) break;
5
5
  return r;
6
- }, gt = "1.0", o = {
6
+ }, yt = "1.0", o = {
7
7
  actions: 10,
8
8
  comparisonItems: 24,
9
9
  jsonCharacters: 1e6,
@@ -17,15 +17,17 @@ const k = (t, e) => {
17
17
  trendPointsPerSeries: 120,
18
18
  trendSeries: 8,
19
19
  validationIssues: 100
20
- }, g = {
20
+ }, l = {
21
21
  artifactsPerRun: 50,
22
22
  assistantMessagesPerRun: 20,
23
23
  historyArtifacts: 500,
24
24
  historyCharacters: 1e6,
25
25
  historyMessages: 200,
26
26
  identifierCharacters: 1e3,
27
- messageCharacters: 1e5
28
- }, P = [
27
+ messageCharacters: 1e5,
28
+ progressCharactersPerRun: 2e4,
29
+ progressStepsPerRun: 50
30
+ }, V = [
29
31
  "metric",
30
32
  "comparison",
31
33
  "trend",
@@ -35,8 +37,8 @@ const k = (t, e) => {
35
37
  ], $ = () => ({
36
38
  success: !1,
37
39
  issues: [{ path: "", message: "could not be safely inspected" }]
38
- }), V = /* @__PURE__ */ new Set(["navigate", "open-record", "open-list", "invoke"]), D = /* @__PURE__ */ new Set(["decimal", "currency", "percent"]);
39
- class v extends Array {
40
+ }), D = /* @__PURE__ */ new Set(["navigate", "open-record", "open-list", "invoke"]), L = /* @__PURE__ */ new Set(["decimal", "currency", "percent"]);
41
+ class j extends Array {
40
42
  push(...e) {
41
43
  const r = o.validationIssues - this.length;
42
44
  return r > 0 ? super.push(...e.slice(0, r)) : this.length;
@@ -47,12 +49,12 @@ const c = (t) => (() => {
47
49
  return !1;
48
50
  const e = Object.getPrototypeOf(t);
49
51
  return e === Object.prototype || e === null;
50
- })(), M = (t) => typeof t == "string" && t.trim().length > 0, R = (t, e) => {
52
+ })(), M = (t) => typeof t == "string" && t.trim().length > 0, k = (t, e) => {
51
53
  let r = 0;
52
- for (const a of t)
54
+ for (const s of t)
53
55
  if (r += 1, r > e) return r;
54
56
  return r;
55
- }, u = (t) => typeof t == "string" && R(t, o.textCharacters) <= o.textCharacters, b = (t) => typeof t == "number" && Number.isFinite(t), q = (t) => t.length <= 120 ? t : `${t.slice(0, 117)}...`, m = (t, e, r) => {
57
+ }, u = (t) => typeof t == "string" && k(t, o.textCharacters) <= o.textCharacters, b = (t) => typeof t == "number" && Number.isFinite(t), q = (t) => t.length <= 120 ? t : `${t.slice(0, 117)}...`, f = (t, e, r) => {
56
58
  M(t) ? u(t) || r.push({
57
59
  path: e,
58
60
  message: `must contain at most ${o.textCharacters} characters`
@@ -62,31 +64,31 @@ const c = (t) => (() => {
62
64
  path: e,
63
65
  message: `must contain at most ${o.textCharacters} characters`
64
66
  });
65
- }, d = (t, e, r, a) => {
66
- for (const s in t)
67
- if (Object.prototype.hasOwnProperty.call(t, s)) {
68
- if (a.length >= o.validationIssues) break;
69
- e.has(s) || a.push({
70
- path: q(r ? `${r}.${s}` : s),
67
+ }, d = (t, e, r, s) => {
68
+ for (const a in t)
69
+ if (Object.prototype.hasOwnProperty.call(t, a)) {
70
+ if (s.length >= o.validationIssues) break;
71
+ e.has(a) || s.push({
72
+ path: q(r ? `${r}.${a}` : a),
71
73
  message: "is not supported"
72
74
  });
73
75
  }
74
- }, w = (t, e, r, a) => t.length > e ? (a.push({ path: r, message: `must contain at most ${e} items` }), !0) : !1, S = (t, e, r) => {
75
- for (let a = 0; a < t.length; a += 1)
76
- if (!Object.prototype.hasOwnProperty.call(t, a))
76
+ }, S = (t, e, r, s) => t.length > e ? (s.push({ path: r, message: `must contain at most ${e} items` }), !0) : !1, w = (t, e, r) => {
77
+ for (let s = 0; s < t.length; s += 1)
78
+ if (!Object.prototype.hasOwnProperty.call(t, s))
77
79
  return r.push({ path: e, message: "must not contain empty array slots" }), !0;
78
80
  return !1;
79
- }, E = (t, e, r, a) => {
80
- const s = /* @__PURE__ */ new Set();
81
- t.forEach((n, f) => {
81
+ }, E = (t, e, r, s) => {
82
+ const a = /* @__PURE__ */ new Set();
83
+ t.forEach((n, p) => {
82
84
  if (!c(n) || typeof n[e] != "string") return;
83
85
  const i = n[e];
84
- s.has(i) ? a.push({
85
- path: `${r}[${f}].${e}`,
86
+ a.has(i) ? s.push({
87
+ path: `${r}[${p}].${e}`,
86
88
  message: "must be unique within the collection"
87
- }) : s.add(i);
89
+ }) : a.add(i);
88
90
  });
89
- }, L = /* @__PURE__ */ new Set([
91
+ }, F = /* @__PURE__ */ new Set([
90
92
  "schemaVersion",
91
93
  "id",
92
94
  "kind",
@@ -96,15 +98,15 @@ const c = (t) => (() => {
96
98
  "actions",
97
99
  "meta",
98
100
  "data"
99
- ]), F = /* @__PURE__ */ new Set(["template", "density"]), z = /* @__PURE__ */ new Set(["style", "currency", "precision", "unit"]), J = /* @__PURE__ */ new Set(["id", "label", "intent", "target", "appearance"]), U = /* @__PURE__ */ new Set(["value", "format", "delta", "context"]), B = /* @__PURE__ */ new Set(["value", "format", "direction", "label"]), K = /* @__PURE__ */ new Set(["items"]), W = /* @__PURE__ */ new Set(["id", "label", "value", "format", "hint"]), H = /* @__PURE__ */ new Set(["series"]), G = /* @__PURE__ */ new Set(["id", "label", "points", "format"]), Q = /* @__PURE__ */ new Set(["x", "y"]), X = /* @__PURE__ */ new Set([
101
+ ]), z = /* @__PURE__ */ new Set(["template", "density"]), J = /* @__PURE__ */ new Set(["style", "currency", "precision", "unit"]), U = /* @__PURE__ */ new Set(["id", "label", "intent", "target", "appearance"]), B = /* @__PURE__ */ new Set(["value", "format", "delta", "context"]), W = /* @__PURE__ */ new Set(["value", "format", "direction", "label"]), K = /* @__PURE__ */ new Set(["items"]), H = /* @__PURE__ */ new Set(["id", "label", "value", "format", "hint"]), G = /* @__PURE__ */ new Set(["series"]), Q = /* @__PURE__ */ new Set(["id", "label", "points", "format"]), X = /* @__PURE__ */ new Set(["x", "y"]), Z = /* @__PURE__ */ new Set([
100
102
  "id",
101
103
  "label",
102
104
  "value",
103
105
  "format",
104
106
  "description"
105
- ]), Z = /* @__PURE__ */ new Set(["entity", "columns", "records", "total"]), tt = /* @__PURE__ */ new Set(["key", "label"]), et = /* @__PURE__ */ new Set(["key", "label", "format"]), rt = /* @__PURE__ */ new Set(["id", "title", "values", "action"]), nt = /* @__PURE__ */ new Set(["tone", "body"]), A = (t, e, r) => c(t) ? (d(t, z, e, r), t.style !== void 0 && (typeof t.style != "string" || !D.has(t.style)) && r.push({ path: `${e}.style`, message: "is not supported" }), t.currency !== void 0 && m(t.currency, `${e}.currency`, r), t.precision !== void 0 && (!Number.isInteger(t.precision) || Number(t.precision) < 0 || Number(t.precision) > 20) && r.push({ path: `${e}.precision`, message: "must be an integer between 0 and 20" }), I(t.unit, `${e}.unit`, r), !0) : (r.push({ path: e, message: "must be an object" }), !1), _ = (t) => {
107
+ ]), tt = /* @__PURE__ */ new Set(["entity", "columns", "records", "total"]), et = /* @__PURE__ */ new Set(["key", "label"]), rt = /* @__PURE__ */ new Set(["key", "label", "format"]), st = /* @__PURE__ */ new Set(["id", "title", "values", "action"]), nt = /* @__PURE__ */ new Set(["tone", "body"]), A = (t, e, r) => c(t) ? (d(t, J, e, r), t.style !== void 0 && (typeof t.style != "string" || !L.has(t.style)) && r.push({ path: `${e}.style`, message: "is not supported" }), t.currency !== void 0 && f(t.currency, `${e}.currency`, r), t.precision !== void 0 && (!Number.isInteger(t.precision) || Number(t.precision) < 0 || Number(t.precision) > 20) && r.push({ path: `${e}.precision`, message: "must be an integer between 0 and 20" }), I(t.unit, `${e}.unit`, r), !0) : (r.push({ path: e, message: "must be an object" }), !1), _ = (t) => {
106
108
  const e = [{ kind: "visit", depth: 0, value: t }], r = /* @__PURE__ */ new WeakSet();
107
- let a = 0, s = 0;
109
+ let s = 0, a = 0;
108
110
  try {
109
111
  for (; e.length > 0; ) {
110
112
  const n = e.pop();
@@ -113,15 +115,15 @@ const c = (t) => (() => {
113
115
  r.delete(n.value);
114
116
  continue;
115
117
  }
116
- if (s += 1, s > o.jsonNodes || n.depth > o.jsonDepth)
118
+ if (a += 1, a > o.jsonNodes || n.depth > o.jsonDepth)
117
119
  return !1;
118
120
  if (n.value === null || typeof n.value == "boolean")
119
121
  continue;
120
122
  if (typeof n.value == "string") {
121
- if (a += R(
123
+ if (s += k(
122
124
  n.value,
123
125
  o.textCharacters
124
- ), !u(n.value) || a > o.jsonCharacters) return !1;
126
+ ), !u(n.value) || s > o.jsonCharacters) return !1;
125
127
  continue;
126
128
  }
127
129
  if (typeof n.value == "number") {
@@ -130,9 +132,9 @@ const c = (t) => (() => {
130
132
  }
131
133
  if (!Array.isArray(n.value) && !c(n.value) || r.has(n.value)) return !1;
132
134
  r.add(n.value), e.push({ kind: "leave", value: n.value });
133
- const f = o.jsonNodes - s;
135
+ const p = o.jsonNodes - a;
134
136
  if (Array.isArray(n.value)) {
135
- if (n.value.length > f) return !1;
137
+ if (n.value.length > p) return !1;
136
138
  for (let i = n.value.length - 1; i >= 0; i -= 1)
137
139
  e.push({
138
140
  kind: "visit",
@@ -143,10 +145,10 @@ const c = (t) => (() => {
143
145
  const i = [];
144
146
  for (const h in n.value)
145
147
  if (Object.prototype.hasOwnProperty.call(n.value, h)) {
146
- if (!u(h) || (a += R(
148
+ if (!u(h) || (s += k(
147
149
  h,
148
150
  o.textCharacters
149
- ), a > o.jsonCharacters) || i.length >= f) return !1;
151
+ ), s > o.jsonCharacters) || i.length >= p) return !1;
150
152
  i.push(h);
151
153
  }
152
154
  for (let h = i.length - 1; h >= 0; h -= 1) {
@@ -163,179 +165,179 @@ const c = (t) => (() => {
163
165
  } catch {
164
166
  return !1;
165
167
  }
166
- }, at = (t) => t === null || typeof t == "boolean" || u(t) || b(t), x = (t, e, r) => c(t) ? (d(t, J, e, r), m(t.id, `${e}.id`, r), m(t.label, `${e}.label`, r), (typeof t.intent != "string" || !V.has(t.intent)) && r.push({ path: `${e}.intent`, message: "is not supported" }), (!c(t.target) || !_(t.target)) && r.push({ path: `${e}.target`, message: "must be a JSON object" }), t.appearance !== void 0 && (typeof t.appearance != "string" || !["primary", "secondary", "link"].includes(t.appearance)) && r.push({ path: `${e}.appearance`, message: "is not supported" }), !0) : (r.push({ path: e, message: "must be an object" }), !1), st = (t, e) => {
167
- if (d(t, L, "", e), t.schemaVersion !== "1.0" && e.push({ path: "schemaVersion", message: "must equal 1.0" }), m(t.id, "id", e), P.includes(t.kind) || e.push({ path: "kind", message: "is not a supported Artifact kind" }), I(t.title, "title", e), I(t.summary, "summary", e), t.presentation !== void 0 && (c(t.presentation) ? (d(t.presentation, F, "presentation", e), t.presentation.template !== void 0 && !M(t.presentation.template) ? e.push({ path: "presentation.template", message: "must be a non-empty string" }) : t.presentation.template !== void 0 && !u(t.presentation.template) && e.push({
168
+ }, at = (t) => t === null || typeof t == "boolean" || u(t) || b(t), x = (t, e, r) => c(t) ? (d(t, U, e, r), f(t.id, `${e}.id`, r), f(t.label, `${e}.label`, r), (typeof t.intent != "string" || !D.has(t.intent)) && r.push({ path: `${e}.intent`, message: "is not supported" }), (!c(t.target) || !_(t.target)) && r.push({ path: `${e}.target`, message: "must be a JSON object" }), t.appearance !== void 0 && (typeof t.appearance != "string" || !["primary", "secondary", "link"].includes(t.appearance)) && r.push({ path: `${e}.appearance`, message: "is not supported" }), !0) : (r.push({ path: e, message: "must be an object" }), !1), ot = (t, e) => {
169
+ if (d(t, F, "", e), t.schemaVersion !== "1.0" && e.push({ path: "schemaVersion", message: "must equal 1.0" }), f(t.id, "id", e), V.includes(t.kind) || e.push({ path: "kind", message: "is not a supported Artifact kind" }), I(t.title, "title", e), I(t.summary, "summary", e), t.presentation !== void 0 && (c(t.presentation) ? (d(t.presentation, z, "presentation", e), t.presentation.template !== void 0 && !M(t.presentation.template) ? e.push({ path: "presentation.template", message: "must be a non-empty string" }) : t.presentation.template !== void 0 && !u(t.presentation.template) && e.push({
168
170
  path: "presentation.template",
169
171
  message: `must contain at most ${o.textCharacters} characters`
170
172
  }), t.presentation.density !== void 0 && (typeof t.presentation.density != "string" || !["compact", "comfortable"].includes(t.presentation.density)) && e.push({ path: "presentation.density", message: "is not supported" })) : e.push({ path: "presentation", message: "must be an object" })), t.actions !== void 0) {
171
173
  if (!Array.isArray(t.actions))
172
174
  e.push({ path: "actions", message: "must be an array" });
173
- else if (!w(
175
+ else if (!S(
174
176
  t.actions,
175
177
  o.actions,
176
178
  "actions",
177
179
  e
178
180
  )) {
179
- if (S(t.actions, "actions", e)) return;
181
+ if (w(t.actions, "actions", e)) return;
180
182
  E(t.actions, "id", "actions", e), t.actions.forEach(
181
- (a, s) => x(a, `actions[${s}]`, e)
183
+ (s, a) => x(s, `actions[${a}]`, e)
182
184
  );
183
185
  }
184
186
  }
185
187
  t.meta !== void 0 && (!c(t.meta) || !_(t.meta)) && e.push({ path: "meta", message: "must be a JSON object" });
186
- }, ot = (t, e) => {
187
- d(t, U, "data", e), !b(t.value) && !u(t.value) && e.push({ path: "data.value", message: "must be a finite number or string" }), t.format !== void 0 && A(t.format, "data.format", e), t.delta !== void 0 && (c(t.delta) ? (d(
188
+ }, it = (t, e) => {
189
+ d(t, B, "data", e), !b(t.value) && !u(t.value) && e.push({ path: "data.value", message: "must be a finite number or string" }), t.format !== void 0 && A(t.format, "data.format", e), t.delta !== void 0 && (c(t.delta) ? (d(
188
190
  t.delta,
189
- B,
191
+ W,
190
192
  "data.delta",
191
193
  e
192
194
  ), b(t.delta.value) || e.push({ path: "data.delta.value", message: "must be a finite number" }), t.delta.direction !== void 0 && (typeof t.delta.direction != "string" || !["up", "down", "flat"].includes(t.delta.direction)) && e.push({ path: "data.delta.direction", message: "is not supported" }), t.delta.format !== void 0 && (typeof t.delta.format != "string" || !["decimal", "percent"].includes(t.delta.format)) && e.push({ path: "data.delta.format", message: "is not supported" }), I(t.delta.label, "data.delta.label", e)) : e.push({ path: "data.delta", message: "must be an object" })), I(t.context, "data.context", e);
193
- }, it = (t, e) => {
195
+ }, ct = (t, e) => {
194
196
  if (d(t, K, "data", e), !Array.isArray(t.items) || t.items.length === 0) {
195
197
  e.push({ path: "data.items", message: "must be a non-empty array" });
196
198
  return;
197
199
  }
198
- w(
200
+ S(
199
201
  t.items,
200
202
  o.comparisonItems,
201
203
  "data.items",
202
204
  e
203
- ) || S(t.items, "data.items", e) || (E(t.items, "id", "data.items", e), t.items.forEach((r, a) => {
204
- const s = `data.items[${a}]`;
205
+ ) || w(t.items, "data.items", e) || (E(t.items, "id", "data.items", e), t.items.forEach((r, s) => {
206
+ const a = `data.items[${s}]`;
205
207
  if (!c(r)) {
206
- e.push({ path: s, message: "must be an object" });
208
+ e.push({ path: a, message: "must be an object" });
207
209
  return;
208
210
  }
209
211
  d(
210
212
  r,
211
- W,
212
- s,
213
+ H,
214
+ a,
213
215
  e
214
- ), m(r.id, `${s}.id`, e), m(r.label, `${s}.label`, e), !b(r.value) && !u(r.value) && e.push({ path: `${s}.value`, message: "must be a finite number or string" }), r.format !== void 0 && A(r.format, `${s}.format`, e), I(r.hint, `${s}.hint`, e);
216
+ ), f(r.id, `${a}.id`, e), f(r.label, `${a}.label`, e), !b(r.value) && !u(r.value) && e.push({ path: `${a}.value`, message: "must be a finite number or string" }), r.format !== void 0 && A(r.format, `${a}.format`, e), I(r.hint, `${a}.hint`, e);
215
217
  }));
216
- }, ct = (t, e) => {
217
- if (d(t, H, "data", e), !Array.isArray(t.series) || t.series.length === 0) {
218
+ }, dt = (t, e) => {
219
+ if (d(t, G, "data", e), !Array.isArray(t.series) || t.series.length === 0) {
218
220
  e.push({ path: "data.series", message: "must be a non-empty array" });
219
221
  return;
220
222
  }
221
- w(
223
+ S(
222
224
  t.series,
223
225
  o.trendSeries,
224
226
  "data.series",
225
227
  e
226
- ) || S(t.series, "data.series", e) || (E(t.series, "id", "data.series", e), t.series.forEach((r, a) => {
227
- const s = `data.series[${a}]`;
228
+ ) || w(t.series, "data.series", e) || (E(t.series, "id", "data.series", e), t.series.forEach((r, s) => {
229
+ const a = `data.series[${s}]`;
228
230
  if (!c(r)) {
229
- e.push({ path: s, message: "must be an object" });
231
+ e.push({ path: a, message: "must be an object" });
230
232
  return;
231
233
  }
232
234
  if (d(
233
235
  r,
234
- G,
235
- s,
236
+ Q,
237
+ a,
236
238
  e
237
- ), m(r.id, `${s}.id`, e), m(r.label, `${s}.label`, e), r.format !== void 0 && A(r.format, `${s}.format`, e), !Array.isArray(r.points) || r.points.length === 0) {
238
- e.push({ path: `${s}.points`, message: "must be a non-empty array" });
239
+ ), f(r.id, `${a}.id`, e), f(r.label, `${a}.label`, e), r.format !== void 0 && A(r.format, `${a}.format`, e), !Array.isArray(r.points) || r.points.length === 0) {
240
+ e.push({ path: `${a}.points`, message: "must be a non-empty array" });
239
241
  return;
240
242
  }
241
- w(
243
+ S(
242
244
  r.points,
243
245
  o.trendPointsPerSeries,
244
- `${s}.points`,
246
+ `${a}.points`,
245
247
  e
246
- ) || S(r.points, `${s}.points`, e) || r.points.forEach((n, f) => {
247
- const i = `${s}.points[${f}]`;
248
+ ) || w(r.points, `${a}.points`, e) || r.points.forEach((n, p) => {
249
+ const i = `${a}.points[${p}]`;
248
250
  if (!c(n)) {
249
251
  e.push({ path: i, message: "must be an object" });
250
252
  return;
251
253
  }
252
- d(n, Q, i, e), !b(n.x) && !u(n.x) && e.push({ path: `${i}.x`, message: "must be a finite number or string" }), b(n.y) || e.push({ path: `${i}.y`, message: "must be a finite number" });
254
+ d(n, X, i, e), !b(n.x) && !u(n.x) && e.push({ path: `${i}.x`, message: "must be a finite number or string" }), b(n.y) || e.push({ path: `${i}.y`, message: "must be a finite number" });
253
255
  });
254
256
  }));
255
- }, dt = (t, e) => {
257
+ }, pt = (t, e) => {
256
258
  if (d(t, K, "data", e), !Array.isArray(t.items) || t.items.length === 0) {
257
259
  e.push({ path: "data.items", message: "must be a non-empty array" });
258
260
  return;
259
261
  }
260
- w(
262
+ S(
261
263
  t.items,
262
264
  o.rankingItems,
263
265
  "data.items",
264
266
  e
265
- ) || S(t.items, "data.items", e) || (E(t.items, "id", "data.items", e), t.items.forEach((r, a) => {
266
- const s = `data.items[${a}]`;
267
+ ) || w(t.items, "data.items", e) || (E(t.items, "id", "data.items", e), t.items.forEach((r, s) => {
268
+ const a = `data.items[${s}]`;
267
269
  if (!c(r)) {
268
- e.push({ path: s, message: "must be an object" });
270
+ e.push({ path: a, message: "must be an object" });
269
271
  return;
270
272
  }
271
273
  d(
272
274
  r,
273
- X,
274
- s,
275
+ Z,
276
+ a,
275
277
  e
276
- ), m(r.id, `${s}.id`, e), m(r.label, `${s}.label`, e), b(r.value) || e.push({ path: `${s}.value`, message: "must be a finite number" }), r.format !== void 0 && A(r.format, `${s}.format`, e), I(r.description, `${s}.description`, e);
278
+ ), f(r.id, `${a}.id`, e), f(r.label, `${a}.label`, e), b(r.value) || e.push({ path: `${a}.value`, message: "must be a finite number" }), r.format !== void 0 && A(r.format, `${a}.format`, e), I(r.description, `${a}.description`, e);
277
279
  }));
278
- }, pt = (t, e) => {
280
+ }, mt = (t, e) => {
279
281
  if (d(
280
282
  t,
281
- Z,
283
+ tt,
282
284
  "data",
283
285
  e
284
- ), c(t.entity) ? (d(t.entity, tt, "data.entity", e), m(t.entity.key, "data.entity.key", e), I(t.entity.label, "data.entity.label", e)) : e.push({ path: "data.entity", message: "must be an object" }), !Array.isArray(t.columns) || t.columns.length === 0)
286
+ ), c(t.entity) ? (d(t.entity, et, "data.entity", e), f(t.entity.key, "data.entity.key", e), I(t.entity.label, "data.entity.label", e)) : e.push({ path: "data.entity", message: "must be an object" }), !Array.isArray(t.columns) || t.columns.length === 0)
285
287
  e.push({ path: "data.columns", message: "must be a non-empty array" });
286
- else if (!w(
288
+ else if (!S(
287
289
  t.columns,
288
290
  o.recordColumns,
289
291
  "data.columns",
290
292
  e
291
293
  )) {
292
- if (S(t.columns, "data.columns", e)) return;
293
- E(t.columns, "key", "data.columns", e), t.columns.forEach((a, s) => {
294
- const n = `data.columns[${s}]`;
295
- if (!c(a)) {
294
+ if (w(t.columns, "data.columns", e)) return;
295
+ E(t.columns, "key", "data.columns", e), t.columns.forEach((s, a) => {
296
+ const n = `data.columns[${a}]`;
297
+ if (!c(s)) {
296
298
  e.push({ path: n, message: "must be an object" });
297
299
  return;
298
300
  }
299
301
  d(
300
- a,
301
- et,
302
+ s,
303
+ rt,
302
304
  n,
303
305
  e
304
- ), m(a.key, `${n}.key`, e), m(a.label, `${n}.label`, e), a.format !== void 0 && A(a.format, `${n}.format`, e);
306
+ ), f(s.key, `${n}.key`, e), f(s.label, `${n}.label`, e), s.format !== void 0 && A(s.format, `${n}.format`, e);
305
307
  });
306
308
  }
307
309
  if (!Array.isArray(t.records))
308
310
  e.push({ path: "data.records", message: "must be an array" });
309
- else if (!w(
311
+ else if (!S(
310
312
  t.records,
311
313
  o.recordListRecords,
312
314
  "data.records",
313
315
  e
314
316
  )) {
315
- if (S(t.records, "data.records", e)) return;
316
- E(t.records, "id", "data.records", e), t.records.forEach((a, s) => {
317
- const n = `data.records[${s}]`;
318
- if (!c(a)) {
317
+ if (w(t.records, "data.records", e)) return;
318
+ E(t.records, "id", "data.records", e), t.records.forEach((s, a) => {
319
+ const n = `data.records[${a}]`;
320
+ if (!c(s)) {
319
321
  e.push({ path: n, message: "must be an object" });
320
322
  return;
321
323
  }
322
324
  if (d(
323
- a,
324
- rt,
325
+ s,
326
+ st,
325
327
  n,
326
328
  e
327
- ), m(a.id, `${n}.id`, e), I(a.title, `${n}.title`, e), !c(a.values))
329
+ ), f(s.id, `${n}.id`, e), I(s.title, `${n}.title`, e), !c(s.values))
328
330
  e.push({
329
331
  path: `${n}.values`,
330
332
  message: "must contain only JSON primitive display values"
331
333
  });
332
334
  else {
333
- const f = a.values;
335
+ const p = s.values;
334
336
  let i = !1, h = 0;
335
- for (const y in f)
336
- if (Object.prototype.hasOwnProperty.call(f, y)) {
337
+ for (const y in p)
338
+ if (Object.prototype.hasOwnProperty.call(p, y)) {
337
339
  if (h += 1, h > o.recordValues) break;
338
- i ||= !u(y) || !at(f[y]);
340
+ i ||= !u(y) || !at(p[y]);
339
341
  }
340
342
  h > o.recordValues ? e.push({
341
343
  path: `${n}.values`,
@@ -345,43 +347,43 @@ const c = (t) => (() => {
345
347
  message: "must contain only JSON primitive display values"
346
348
  });
347
349
  }
348
- a.action !== void 0 && x(a.action, `${n}.action`, e);
350
+ s.action !== void 0 && x(s.action, `${n}.action`, e);
349
351
  });
350
352
  }
351
353
  t.total !== void 0 && (!Number.isInteger(t.total) || Number(t.total) < 0) && e.push({ path: "data.total", message: "must be a non-negative integer" });
352
- }, mt = (t, e) => {
353
- d(t, nt, "data", e), (typeof t.tone != "string" || !["info", "success", "warning", "danger"].includes(t.tone)) && e.push({ path: "data.tone", message: "is not supported" }), m(t.body, "data.body", e);
354
- }, j = (t, e) => {
355
- if (st(t, e), !c(t.data)) {
354
+ }, ft = (t, e) => {
355
+ d(t, nt, "data", e), (typeof t.tone != "string" || !["info", "success", "warning", "danger"].includes(t.tone)) && e.push({ path: "data.tone", message: "is not supported" }), f(t.body, "data.body", e);
356
+ }, v = (t, e) => {
357
+ if (ot(t, e), !c(t.data)) {
356
358
  e.push({ path: "data", message: "must be an object" });
357
359
  return;
358
360
  }
359
361
  switch (t.kind) {
360
362
  case "metric":
361
- ot(t.data, e);
363
+ it(t.data, e);
362
364
  break;
363
365
  case "comparison":
364
- it(t.data, e);
366
+ ct(t.data, e);
365
367
  break;
366
368
  case "trend":
367
- ct(t.data, e);
369
+ dt(t.data, e);
368
370
  break;
369
371
  case "ranking":
370
- dt(t.data, e);
372
+ pt(t.data, e);
371
373
  break;
372
374
  case "record-list":
373
- pt(t.data, e);
375
+ mt(t.data, e);
374
376
  break;
375
377
  case "notice":
376
- mt(t.data, e);
378
+ ft(t.data, e);
377
379
  break;
378
380
  }
379
- }, ft = (t) => {
380
- const e = new v();
381
+ }, ht = (t) => {
382
+ const e = new j();
381
383
  try {
382
384
  if (!c(t))
383
385
  return { success: !1, issues: [{ path: "", message: "must be an object" }] };
384
- j(t, e);
386
+ v(t, e);
385
387
  } catch {
386
388
  return $();
387
389
  }
@@ -397,81 +399,81 @@ const c = (t) => (() => {
397
399
  } catch {
398
400
  return $();
399
401
  }
400
- const a = new v();
402
+ const s = new j();
401
403
  try {
402
404
  if (!c(r)) return $();
403
- j(r, a);
405
+ v(r, s);
404
406
  } catch {
405
407
  return $();
406
408
  }
407
- return a.length === 0 && !_(r) && a.push({
409
+ return s.length === 0 && !_(r) && s.push({
408
410
  path: "",
409
411
  message: "exceeds the Artifact resource budget"
410
- }), a.length === 0 ? { success: !0, artifact: r } : { success: !1, issues: a };
411
- }, Y = (t) => {
412
- const e = ft(t);
412
+ }), s.length === 0 ? { success: !0, artifact: r } : { success: !1, issues: s };
413
+ }, P = (t) => {
414
+ const e = ht(t);
413
415
  if (e.success) return e.artifact;
414
- const r = e.issues.map((a) => `${a.path || "artifact"} ${a.message}`).join(", ");
416
+ const r = e.issues.map((s) => `${s.path || "artifact"} ${s.message}`).join(", ");
415
417
  throw new Error(`Invalid Make AI Artifact: ${r}`);
416
- }, N = (t) => typeof t == "object" && t !== null && !Array.isArray(t), l = (t, e) => {
418
+ }, N = (t) => typeof t == "object" && t !== null && !Array.isArray(t), g = (t, e) => {
417
419
  if (Object.keys(t).some((r) => !e.has(r)))
418
420
  throw new Error("Invalid assistant event: unsupported field");
419
- }, p = (t, e, r = g.identifierCharacters) => {
420
- const a = typeof t == "string" ? k(t, r) : 0;
421
- if (typeof t != "string" || !t.trim() || a > r)
421
+ }, m = (t, e, r = l.identifierCharacters) => {
422
+ const s = typeof t == "string" ? R(t, r) : 0;
423
+ if (typeof t != "string" || !t.trim() || s > r)
422
424
  throw new Error(`Invalid assistant event: ${e}`);
423
425
  return t;
424
- }, ht = (t) => {
426
+ }, lt = (t) => {
425
427
  if (!N(t) || typeof t.type != "string")
426
428
  throw new Error("Invalid assistant event: data");
427
429
  switch (t.type) {
428
430
  case "message.start":
429
- return l(t, /* @__PURE__ */ new Set(["type", "runId", "messageId"])), {
431
+ return g(t, /* @__PURE__ */ new Set(["type", "runId", "messageId"])), {
430
432
  type: t.type,
431
- runId: p(t.runId, "runId"),
432
- messageId: p(t.messageId, "messageId")
433
+ runId: m(t.runId, "runId"),
434
+ messageId: m(t.messageId, "messageId")
433
435
  };
434
436
  case "message.delta":
435
- if (l(t, /* @__PURE__ */ new Set(["type", "messageId", "delta"])), typeof t.delta != "string")
437
+ if (g(t, /* @__PURE__ */ new Set(["type", "messageId", "delta"])), typeof t.delta != "string")
436
438
  throw new Error("Invalid assistant event: delta");
437
439
  return {
438
440
  type: t.type,
439
- messageId: p(t.messageId, "messageId"),
441
+ messageId: m(t.messageId, "messageId"),
440
442
  delta: t.delta
441
443
  };
442
444
  case "message.replace":
443
- return l(t, /* @__PURE__ */ new Set(["type", "messageId", "content"])), {
445
+ return g(t, /* @__PURE__ */ new Set(["type", "messageId", "content"])), {
444
446
  type: t.type,
445
- messageId: p(t.messageId, "messageId"),
446
- content: p(
447
+ messageId: m(t.messageId, "messageId"),
448
+ content: m(
447
449
  t.content,
448
450
  "content",
449
- g.messageCharacters
451
+ l.messageCharacters
450
452
  )
451
453
  };
452
454
  case "message.complete":
453
- return l(t, /* @__PURE__ */ new Set(["type", "messageId"])), {
455
+ return g(t, /* @__PURE__ */ new Set(["type", "messageId"])), {
454
456
  type: t.type,
455
- messageId: p(t.messageId, "messageId")
457
+ messageId: m(t.messageId, "messageId")
456
458
  };
457
459
  case "artifact":
458
- return l(t, /* @__PURE__ */ new Set(["type", "messageId", "artifact"])), {
460
+ return g(t, /* @__PURE__ */ new Set(["type", "messageId", "artifact"])), {
459
461
  type: t.type,
460
- messageId: p(t.messageId, "messageId"),
461
- artifact: Y(t.artifact)
462
+ messageId: m(t.messageId, "messageId"),
463
+ artifact: P(t.artifact)
462
464
  };
463
465
  case "run.progress":
464
- return l(t, /* @__PURE__ */ new Set(["type", "runId", "message"])), {
466
+ return g(t, /* @__PURE__ */ new Set(["type", "runId", "message"])), {
465
467
  type: t.type,
466
- runId: p(t.runId, "runId"),
467
- message: p(
468
+ runId: m(t.runId, "runId"),
469
+ message: m(
468
470
  t.message,
469
471
  "message",
470
- g.messageCharacters
472
+ l.messageCharacters
471
473
  )
472
474
  };
473
475
  case "error":
474
- if (l(t, /* @__PURE__ */ new Set([
476
+ if (g(t, /* @__PURE__ */ new Set([
475
477
  "type",
476
478
  "code",
477
479
  "message",
@@ -481,66 +483,66 @@ const c = (t) => (() => {
481
483
  throw new Error("Invalid assistant event: retryable");
482
484
  return {
483
485
  type: t.type,
484
- code: p(t.code, "code"),
485
- message: p(
486
+ code: m(t.code, "code"),
487
+ message: m(
486
488
  t.message,
487
489
  "message",
488
- g.messageCharacters
490
+ l.messageCharacters
489
491
  ),
490
492
  retryable: t.retryable,
491
- requestId: t.requestId === void 0 ? void 0 : p(t.requestId, "requestId")
493
+ requestId: t.requestId === void 0 ? void 0 : m(t.requestId, "requestId")
492
494
  };
493
495
  case "run.cancelled":
494
- return l(t, /* @__PURE__ */ new Set(["type", "runId"])), {
496
+ return g(t, /* @__PURE__ */ new Set(["type", "runId"])), {
495
497
  type: t.type,
496
- runId: t.runId === void 0 ? void 0 : p(t.runId, "runId")
498
+ runId: t.runId === void 0 ? void 0 : m(t.runId, "runId")
497
499
  };
498
500
  case "run.complete":
499
- return l(t, /* @__PURE__ */ new Set(["type", "runId", "threadId"])), {
501
+ return g(t, /* @__PURE__ */ new Set(["type", "runId", "threadId"])), {
500
502
  type: t.type,
501
- runId: p(t.runId, "runId"),
502
- threadId: p(t.threadId, "threadId")
503
+ runId: m(t.runId, "runId"),
504
+ threadId: m(t.threadId, "threadId")
503
505
  };
504
506
  default:
505
507
  throw new Error("Invalid assistant event: unsupported type");
506
508
  }
507
- }, ut = (t) => {
509
+ }, It = (t) => {
508
510
  try {
509
- return ht(t);
511
+ return lt(t);
510
512
  } catch (e) {
511
513
  throw e instanceof Error && (e.message.startsWith("Invalid assistant event:") || e.message.startsWith("Invalid Make AI Artifact:")) ? e : new Error("Invalid assistant event: data");
512
514
  }
513
- }, lt = (t) => {
515
+ }, gt = (t) => {
514
516
  if (!N(t))
515
517
  throw new Error("Invalid assistant conversation snapshot: data");
516
- if (l(t, /* @__PURE__ */ new Set(["threadId", "messages"])), !Array.isArray(t.messages) || t.messages.length > g.historyMessages)
518
+ if (g(t, /* @__PURE__ */ new Set(["threadId", "messages"])), !Array.isArray(t.messages) || t.messages.length > l.historyMessages)
517
519
  throw new Error("Invalid assistant conversation snapshot: messages");
518
520
  const e = /* @__PURE__ */ new Set();
519
- let r = 0, a = 0;
521
+ let r = 0, s = 0;
520
522
  return {
521
523
  messages: t.messages.map((n) => {
522
524
  if (!N(n))
523
525
  throw new Error("Invalid assistant conversation snapshot: message");
524
- l(n, /* @__PURE__ */ new Set(["id", "role", "content", "artifacts"]));
525
- const f = p(n.id, "messageId");
526
- if (e.has(f))
526
+ g(n, /* @__PURE__ */ new Set(["id", "role", "content", "artifacts"]));
527
+ const p = m(n.id, "messageId");
528
+ if (e.has(p))
527
529
  throw new Error("Invalid assistant conversation snapshot: duplicate message id");
528
- if (e.add(f), n.role !== "assistant" && n.role !== "user")
530
+ if (e.add(p), n.role !== "assistant" && n.role !== "user")
529
531
  throw new Error("Invalid assistant conversation snapshot: role");
530
- const i = n.role, h = typeof n.content == "string" ? k(
532
+ const i = n.role, h = typeof n.content == "string" ? R(
531
533
  n.content,
532
- g.messageCharacters
534
+ l.messageCharacters
533
535
  ) : 0;
534
- if (typeof n.content != "string" || h > g.messageCharacters)
536
+ if (typeof n.content != "string" || h > l.messageCharacters)
535
537
  throw new Error("Invalid assistant conversation snapshot: content");
536
- if (r += k(
538
+ if (r += R(
537
539
  n.content,
538
- g.historyCharacters - r
539
- ), r > g.historyCharacters)
540
+ l.historyCharacters - r
541
+ ), r > l.historyCharacters)
540
542
  throw new Error("Invalid assistant conversation snapshot: content budget");
541
- if (n.artifacts !== void 0 && (!Array.isArray(n.artifacts) || n.artifacts.length > g.artifactsPerRun))
543
+ if (n.artifacts !== void 0 && (!Array.isArray(n.artifacts) || n.artifacts.length > l.artifactsPerRun))
542
544
  throw new Error("Invalid assistant conversation snapshot: artifacts");
543
- const y = (n.artifacts ?? []).map(Y), T = /* @__PURE__ */ new Set();
545
+ const y = (n.artifacts ?? []).map(P), T = /* @__PURE__ */ new Set();
544
546
  for (const O of y) {
545
547
  if (T.has(O.id))
546
548
  throw new Error(
@@ -548,10 +550,10 @@ const c = (t) => (() => {
548
550
  );
549
551
  T.add(O.id);
550
552
  }
551
- if (a += y.length, a > g.historyArtifacts)
553
+ if (s += y.length, s > l.historyArtifacts)
552
554
  throw new Error("Invalid assistant conversation snapshot: artifact budget");
553
555
  return {
554
- id: f,
556
+ id: p,
555
557
  role: i,
556
558
  content: n.content,
557
559
  artifacts: y,
@@ -559,9 +561,9 @@ const c = (t) => (() => {
559
561
  };
560
562
  }),
561
563
  status: "idle",
562
- threadId: t.threadId === void 0 ? void 0 : p(t.threadId, "threadId")
564
+ threadId: t.threadId === void 0 ? void 0 : m(t.threadId, "threadId")
563
565
  };
564
- }, yt = (t) => t === void 0 ? { messages: [], status: "idle" } : lt(t), It = (t, e) => ({
566
+ }, bt = (t) => t === void 0 ? { messages: [], status: "idle" } : gt(t), St = (t, e) => ({
565
567
  ...t,
566
568
  error: void 0,
567
569
  progress: void 0,
@@ -579,16 +581,44 @@ const c = (t) => (() => {
579
581
  }), C = (t, e, r) => ({
580
582
  ...t,
581
583
  messages: t.messages.map(
582
- (a) => a.id === e ? r(a) : a
584
+ (s) => s.id === e ? r(s) : s
583
585
  )
584
- }), bt = (t, e) => {
586
+ }), Y = (t) => {
587
+ const e = t.slice(-l.progressStepsPerRun), r = [];
588
+ let s = 0;
589
+ for (let a = e.length - 1; a >= 0; a -= 1) {
590
+ const n = e[a], p = R(
591
+ n,
592
+ l.progressCharactersPerRun - s
593
+ );
594
+ if (s + p > l.progressCharactersPerRun) break;
595
+ s += p, r.unshift(n);
596
+ }
597
+ return r;
598
+ }, ut = (t, e) => {
599
+ let r = -1;
600
+ for (let s = t.length - 1; s >= 0; s -= 1) {
601
+ const a = t[s];
602
+ if (a.role === "assistant" && a.status === "streaming") {
603
+ r = s;
604
+ break;
605
+ }
606
+ }
607
+ return r < 0 ? t : t.map(
608
+ (s, a) => a === r ? {
609
+ ...s,
610
+ progressSteps: Y([...s.progressSteps ?? [], e])
611
+ } : s
612
+ );
613
+ }, wt = (t, e) => {
585
614
  switch (e.type) {
586
- case "message.start":
615
+ case "message.start": {
616
+ const r = t.progress?.runId === e.runId ? t.progress.steps : void 0;
587
617
  return {
588
618
  ...t,
589
619
  activeRunId: e.runId,
590
620
  error: void 0,
591
- progress: void 0,
621
+ progress: t.progress?.runId === e.runId ? t.progress : void 0,
592
622
  status: "streaming",
593
623
  messages: [
594
624
  ...t.messages,
@@ -597,10 +627,12 @@ const c = (t) => (() => {
597
627
  role: "assistant",
598
628
  content: "",
599
629
  artifacts: [],
630
+ progressSteps: r,
600
631
  status: "streaming"
601
632
  }
602
633
  ]
603
634
  };
635
+ }
604
636
  case "message.delta":
605
637
  return C(t, e.messageId, (r) => ({
606
638
  ...r,
@@ -621,30 +653,41 @@ const c = (t) => (() => {
621
653
  ...r,
622
654
  status: "complete"
623
655
  }));
624
- case "run.progress":
656
+ case "run.progress": {
657
+ const r = Y(
658
+ t.progress?.runId === e.runId ? [...t.progress.steps, e.message] : [e.message]
659
+ );
625
660
  return {
626
661
  ...t,
662
+ messages: ut(
663
+ t.messages,
664
+ e.message
665
+ ),
627
666
  progress: {
628
667
  runId: e.runId,
629
- message: e.message
668
+ message: e.message,
669
+ steps: r
630
670
  }
631
671
  };
632
- case "error":
672
+ }
673
+ case "error": {
674
+ const r = {
675
+ code: e.code,
676
+ message: e.message,
677
+ retryable: e.retryable,
678
+ requestId: e.requestId
679
+ };
633
680
  return {
634
681
  ...t,
635
682
  activeRunId: void 0,
636
- error: {
637
- code: e.code,
638
- message: e.message,
639
- retryable: e.retryable,
640
- requestId: e.requestId
641
- },
683
+ error: r,
642
684
  progress: void 0,
643
685
  messages: t.messages.map(
644
- (r) => r.status === "streaming" ? { ...r, status: "complete" } : r
686
+ (s) => s.status === "streaming" ? { ...s, error: r, status: "complete" } : s
645
687
  ),
646
688
  status: "error"
647
689
  };
690
+ }
648
691
  case "run.cancelled":
649
692
  return {
650
693
  ...t,
@@ -670,15 +713,15 @@ const c = (t) => (() => {
670
713
  }
671
714
  };
672
715
  export {
673
- g as M,
674
- yt as a,
675
- It as b,
676
- k as c,
677
- P as d,
716
+ l as M,
717
+ bt as a,
718
+ St as b,
719
+ R as c,
720
+ V as d,
678
721
  o as e,
679
- gt as f,
680
- Y as g,
681
- ut as p,
682
- bt as r,
683
- ft as v
722
+ yt as f,
723
+ P as g,
724
+ It as p,
725
+ wt as r,
726
+ ht as v
684
727
  };