@elizaos/plugin-trajectory-logger 2.0.3-beta.5 → 2.0.3-beta.7

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 (67) hide show
  1. package/dist/api-client.d.ts +88 -0
  2. package/dist/api-client.d.ts.map +1 -0
  3. package/dist/api-client.js +68 -0
  4. package/dist/api-client.js.map +1 -0
  5. package/dist/components/PhaseChip.d.ts +13 -0
  6. package/dist/components/PhaseChip.d.ts.map +1 -0
  7. package/dist/components/PhaseChip.js +100 -0
  8. package/dist/components/PhaseChip.js.map +1 -0
  9. package/dist/components/PhaseDrilldown.d.ts +5 -0
  10. package/dist/components/PhaseDrilldown.d.ts.map +1 -0
  11. package/dist/components/PhaseDrilldown.js +118 -0
  12. package/dist/components/PhaseDrilldown.js.map +1 -0
  13. package/dist/components/TrajectoryLoggerAppView.d.ts +14 -0
  14. package/dist/components/TrajectoryLoggerAppView.d.ts.map +1 -0
  15. package/dist/components/TrajectoryLoggerAppView.js +184 -0
  16. package/dist/components/TrajectoryLoggerAppView.js.map +1 -0
  17. package/dist/components/TrajectoryLoggerSpatialView.d.ts +53 -0
  18. package/dist/components/TrajectoryLoggerSpatialView.d.ts.map +1 -0
  19. package/dist/components/TrajectoryLoggerSpatialView.js +293 -0
  20. package/dist/components/TrajectoryLoggerSpatialView.js.map +1 -0
  21. package/dist/components/TrajectoryLoggerView.d.ts +23 -0
  22. package/dist/components/TrajectoryLoggerView.d.ts.map +1 -0
  23. package/dist/components/TrajectoryLoggerView.interact.d.ts +2 -0
  24. package/dist/components/TrajectoryLoggerView.interact.d.ts.map +1 -0
  25. package/dist/components/TrajectoryLoggerView.interact.js +35 -0
  26. package/dist/components/TrajectoryLoggerView.interact.js.map +1 -0
  27. package/dist/components/TrajectoryLoggerView.js +64 -0
  28. package/dist/components/TrajectoryLoggerView.js.map +1 -0
  29. package/dist/components/trajectory-logger-app.d.ts +8 -0
  30. package/dist/components/trajectory-logger-app.d.ts.map +1 -0
  31. package/dist/components/trajectory-logger-app.js +24 -0
  32. package/dist/components/trajectory-logger-app.js.map +1 -0
  33. package/dist/components/trajectory-logger-view-bundle.d.ts +3 -0
  34. package/dist/components/trajectory-logger-view-bundle.d.ts.map +1 -0
  35. package/dist/components/trajectory-logger-view-bundle.js +7 -0
  36. package/dist/components/trajectory-logger-view-bundle.js.map +1 -0
  37. package/dist/index.d.ts +16 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +22 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/phases.d.ts +21 -0
  42. package/dist/phases.d.ts.map +1 -0
  43. package/dist/phases.js +154 -0
  44. package/dist/phases.js.map +1 -0
  45. package/dist/plugin.d.ts +14 -0
  46. package/dist/plugin.d.ts.map +1 -0
  47. package/dist/plugin.js +51 -0
  48. package/dist/plugin.js.map +1 -0
  49. package/dist/register-terminal-view.d.ts +16 -0
  50. package/dist/register-terminal-view.d.ts.map +1 -0
  51. package/dist/register-terminal-view.js +21 -0
  52. package/dist/register-terminal-view.js.map +1 -0
  53. package/dist/register.d.ts +7 -0
  54. package/dist/register.d.ts.map +1 -0
  55. package/dist/register.js +18 -0
  56. package/dist/register.js.map +1 -0
  57. package/dist/ui.d.ts +4 -0
  58. package/dist/ui.d.ts.map +1 -0
  59. package/dist/ui.js +15 -0
  60. package/dist/ui.js.map +1 -0
  61. package/dist/usePollingTrajectories.d.ts +18 -0
  62. package/dist/usePollingTrajectories.d.ts.map +1 -0
  63. package/dist/usePollingTrajectories.js +87 -0
  64. package/dist/usePollingTrajectories.js.map +1 -0
  65. package/dist/views/bundle.js +646 -0
  66. package/dist/views/bundle.js.map +1 -0
  67. package/package.json +5 -5
@@ -0,0 +1,646 @@
1
+ import { Button as e, Card as t, Divider as n, HStack as r, List as i, SpatialSurface as a, Text as o, VStack as s } from "@elizaos/ui/spatial";
2
+ import { useCallback as c, useEffect as l, useState as u } from "react";
3
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
4
+ //#region src/api-client.ts
5
+ var m = class extends Error {
6
+ status;
7
+ constructor(e, t, n) {
8
+ super(`[trajectory-logger] ${e} ${t}${n ? `: ${n.slice(0, 200)}` : ""}`), this.name = "TrajectoryHttpError", this.status = e;
9
+ }
10
+ get isUnavailable() {
11
+ return this.status === 404 || this.status === 503;
12
+ }
13
+ };
14
+ async function h(e) {
15
+ if (!e.ok) {
16
+ let t = await e.text().catch(() => "");
17
+ throw new m(e.status, e.statusText, t);
18
+ }
19
+ return await e.json();
20
+ }
21
+ async function g(e = {}) {
22
+ let t = e.limit ?? 10;
23
+ return h(await fetch(`/api/trajectories?limit=${t}`, {
24
+ headers: { Accept: "application/json" },
25
+ signal: e.signal
26
+ }));
27
+ }
28
+ async function _(e, t = {}) {
29
+ return h(await fetch(`/api/trajectories/${encodeURIComponent(e)}`, {
30
+ headers: { Accept: "application/json" },
31
+ signal: t.signal
32
+ }));
33
+ }
34
+ //#endregion
35
+ //#region src/components/TrajectoryLoggerView.interact.ts
36
+ async function v(e, t) {
37
+ if (e === "list-trajectories" || e === "refresh") return g({ limit: typeof t?.limit == "number" ? t.limit : 10 });
38
+ if (e === "open-latest") {
39
+ let e = (await g({ limit: 1 })).trajectories[0];
40
+ return e ? _(e.id) : null;
41
+ }
42
+ if (e === "filter-phase") {
43
+ let e = typeof t?.phase == "string" ? t.phase.toUpperCase() : "HANDLE", n = await g({ limit: 10 });
44
+ return (await Promise.all(n.trajectories.slice(0, 5).map((e) => _(e.id)))).map((t) => ({
45
+ id: t.trajectory.id,
46
+ status: t.trajectory.status,
47
+ phase: e,
48
+ llmCalls: t.llmCalls.filter((t) => [
49
+ t.purpose,
50
+ t.stepType,
51
+ t.actionType
52
+ ].filter(Boolean).some((t) => t.toUpperCase().includes(e))).length,
53
+ toolEvents: t.toolEvents?.length ?? 0,
54
+ evaluationEvents: t.evaluationEvents?.length ?? 0
55
+ }));
56
+ }
57
+ throw Error(`Trajectory Logger TUI does not support "${e}".`);
58
+ }
59
+ //#endregion
60
+ //#region src/phases.ts
61
+ var y = [
62
+ "HANDLE",
63
+ "PLAN",
64
+ "ACTION",
65
+ "EVALUATE"
66
+ ], b = new Set(["should_respond", "compose_state"]), x = new Set([
67
+ "reasoning",
68
+ "response",
69
+ "action"
70
+ ]), S = new Set([
71
+ "evaluation",
72
+ "evaluator",
73
+ "observation_extraction",
74
+ "turn_complete"
75
+ ]);
76
+ function C(e) {
77
+ let t = (e.stepType || e.purpose || "").toLowerCase();
78
+ return b.has(t) ? "HANDLE" : x.has(t) ? "PLAN" : S.has(t) ? "EVALUATE" : null;
79
+ }
80
+ function w(e) {
81
+ let t = e.response.trim();
82
+ if (!t) return null;
83
+ let n = t.match(/\{[\s\S]*\}/);
84
+ if (n) try {
85
+ let e = JSON.parse(n[0]), t = e.action ?? e.decision ?? e.shouldRespond;
86
+ if (typeof t == "string" && t.length > 0) {
87
+ let n = e.reasoning ?? e.rationale;
88
+ return typeof n == "string" ? {
89
+ decision: t.toUpperCase(),
90
+ reasoning: n
91
+ } : { decision: t.toUpperCase() };
92
+ }
93
+ } catch {}
94
+ let r = t.match(/\b(RESPOND|REPLY|ANSWER|IGNORE|STOP|SKIP)\b/i);
95
+ return r ? { decision: r[0].toUpperCase() } : null;
96
+ }
97
+ function T(e, t = {}) {
98
+ let n = e?.llmCalls ?? [], r = e?.providerAccesses ?? [], i = e?.toolEvents ?? [], a = e?.evaluationEvents ?? [], o = n.filter((e) => C(e) === "HANDLE"), s = n.filter((e) => C(e) === "PLAN"), c = n.filter((e) => C(e) === "EVALUATE"), l = E(o, r), u = D(s), d = O(i), f = k(c, a), p = [
99
+ {
100
+ phase: "HANDLE",
101
+ ...l,
102
+ llmCalls: o,
103
+ providerAccesses: r,
104
+ toolEvents: [],
105
+ evaluationEvents: []
106
+ },
107
+ {
108
+ phase: "PLAN",
109
+ ...u,
110
+ llmCalls: s,
111
+ providerAccesses: [],
112
+ toolEvents: [],
113
+ evaluationEvents: []
114
+ },
115
+ {
116
+ phase: "ACTION",
117
+ ...d,
118
+ llmCalls: [],
119
+ providerAccesses: [],
120
+ toolEvents: i,
121
+ evaluationEvents: []
122
+ },
123
+ {
124
+ phase: "EVALUATE",
125
+ ...f,
126
+ llmCalls: c,
127
+ providerAccesses: [],
128
+ toolEvents: [],
129
+ evaluationEvents: a
130
+ }
131
+ ];
132
+ if (t.trajectoryActive) {
133
+ let e = -1;
134
+ for (let t = 0; t < p.length; t++) p[t].status !== "idle" && (e = t);
135
+ e >= 0 && e < p.length - 1 && p[e].status === "done" && p.slice(e + 1).every((e) => e.status === "idle") && (p[e] = {
136
+ ...p[e],
137
+ status: "active"
138
+ });
139
+ }
140
+ return p;
141
+ }
142
+ function E(e, t) {
143
+ let n = e.find((e) => (e.stepType || e.purpose || "").toLowerCase() === "should_respond");
144
+ if (n) {
145
+ let e = w(n);
146
+ return e ? {
147
+ status: /IGNORE|STOP|SKIP/i.test(e.decision) ? "skipped" : "done",
148
+ summary: e.decision.toLowerCase()
149
+ } : {
150
+ status: "done",
151
+ summary: null
152
+ };
153
+ }
154
+ return e.length > 0 || t.length > 0 ? {
155
+ status: "done",
156
+ summary: `${t.length} ctx`
157
+ } : {
158
+ status: "idle",
159
+ summary: null
160
+ };
161
+ }
162
+ function D(e) {
163
+ let t = e[e.length - 1];
164
+ return t ? {
165
+ status: "done",
166
+ summary: t.actionType || null
167
+ } : {
168
+ status: "idle",
169
+ summary: null
170
+ };
171
+ }
172
+ function O(e) {
173
+ if (e.length === 0) return {
174
+ status: "idle",
175
+ summary: null
176
+ };
177
+ let t = e[e.length - 1], n = t.actionName || t.toolName || t.name || "action";
178
+ return t.type === "tool_error" || t.error || t.success === !1 ? {
179
+ status: "error",
180
+ summary: n
181
+ } : t.type === "tool_result" || t.status === "completed" || t.success === !0 ? {
182
+ status: "done",
183
+ summary: n
184
+ } : t.status === "skipped" ? {
185
+ status: "skipped",
186
+ summary: n
187
+ } : {
188
+ status: "active",
189
+ summary: n
190
+ };
191
+ }
192
+ function k(e, t) {
193
+ if (t.length > 0) {
194
+ let e = t[t.length - 1], n = e.evaluatorName || e.name || "evaluator";
195
+ return e.error || e.success === !1 ? {
196
+ status: "error",
197
+ summary: n
198
+ } : e.decision ? {
199
+ status: "done",
200
+ summary: `${n}: ${e.decision}`
201
+ } : {
202
+ status: "done",
203
+ summary: n
204
+ };
205
+ }
206
+ return e.length > 0 ? {
207
+ status: "done",
208
+ summary: null
209
+ } : {
210
+ status: "idle",
211
+ summary: null
212
+ };
213
+ }
214
+ //#endregion
215
+ //#region src/usePollingTrajectories.ts
216
+ var A = 700, j = {
217
+ active: null,
218
+ activeDetail: null,
219
+ last: null,
220
+ lastDetail: null,
221
+ error: null,
222
+ unavailable: !1,
223
+ ready: !1
224
+ };
225
+ function M(e) {
226
+ let [t, n] = u(j);
227
+ return l(() => {
228
+ if (!e) {
229
+ n(j);
230
+ return;
231
+ }
232
+ let t = !1, r = new AbortController(), i = async () => {
233
+ try {
234
+ let e = await g({
235
+ limit: 10,
236
+ signal: r.signal
237
+ });
238
+ if (t) return;
239
+ let i = Array.isArray(e.trajectories) ? e.trajectories : [], a = i.find((e) => e.status === "active") ?? null, o = i.find((e) => e.status !== "active") ?? null, [s, c] = await Promise.all([a ? _(a.id, { signal: r.signal }).catch(() => null) : Promise.resolve(null), o ? _(o.id, { signal: r.signal }).catch(() => null) : Promise.resolve(null)]);
240
+ if (t) return;
241
+ n({
242
+ active: a,
243
+ activeDetail: s,
244
+ last: o,
245
+ lastDetail: c,
246
+ error: null,
247
+ unavailable: !1,
248
+ ready: !0
249
+ });
250
+ } catch (e) {
251
+ if (t || e instanceof DOMException && e.name === "AbortError") return;
252
+ if (e instanceof m && e.isUnavailable) {
253
+ n((e) => ({
254
+ ...e,
255
+ ready: !0,
256
+ error: null,
257
+ unavailable: !0
258
+ }));
259
+ return;
260
+ }
261
+ n((t) => ({
262
+ ...t,
263
+ ready: !0,
264
+ unavailable: !1,
265
+ error: e instanceof Error ? e.message : String(e)
266
+ }));
267
+ } finally {
268
+ t || setTimeout(i, A);
269
+ }
270
+ };
271
+ return i(), () => {
272
+ t = !0, r.abort();
273
+ };
274
+ }, [e]), t;
275
+ }
276
+ y.map((e) => ({
277
+ phase: e,
278
+ status: "idle",
279
+ summary: null,
280
+ llmCalls: [],
281
+ providerAccesses: [],
282
+ toolEvents: [],
283
+ evaluationEvents: []
284
+ }));
285
+ function N(e) {
286
+ switch (e) {
287
+ case "active": return "primary";
288
+ case "done": return "success";
289
+ case "error": return "danger";
290
+ case "skipped": return "warning";
291
+ default: return "muted";
292
+ }
293
+ }
294
+ function P(e) {
295
+ switch (e) {
296
+ case "active": return "*";
297
+ case "done": return "+";
298
+ case "error": return "x";
299
+ case "skipped": return "-";
300
+ default: return ".";
301
+ }
302
+ }
303
+ function F({ snapshot: i, onAction: a }) {
304
+ let c = I(i);
305
+ return /* @__PURE__ */ p(t, {
306
+ gap: 1,
307
+ padding: 1,
308
+ children: [/* @__PURE__ */ p(r, {
309
+ gap: 1,
310
+ align: "center",
311
+ children: [
312
+ /* @__PURE__ */ f(e, {
313
+ variant: "ghost",
314
+ tone: "default",
315
+ agent: "back",
316
+ onPress: () => a?.("back"),
317
+ children: "Back"
318
+ }),
319
+ /* @__PURE__ */ f(o, {
320
+ style: "caption",
321
+ tone: "muted",
322
+ grow: 1,
323
+ children: "route"
324
+ }),
325
+ i.unavailable ? null : i.ready ? /* @__PURE__ */ f(o, {
326
+ style: "caption",
327
+ tone: i.recording ? "danger" : "muted",
328
+ bold: i.recording,
329
+ children: i.recording ? "[*] recording" : "[ ] idle"
330
+ }) : /* @__PURE__ */ f(o, {
331
+ style: "caption",
332
+ tone: "muted",
333
+ children: "loading"
334
+ })
335
+ ]
336
+ }), i.unavailable ? /* @__PURE__ */ f(o, {
337
+ tone: "muted",
338
+ style: "caption",
339
+ dim: !0,
340
+ children: "Trajectory logging unavailable on this surface"
341
+ }) : /* @__PURE__ */ p(d, { children: [
342
+ i.error ? /* @__PURE__ */ f(o, {
343
+ tone: "danger",
344
+ style: "caption",
345
+ children: i.error
346
+ }) : null,
347
+ /* @__PURE__ */ f(L, {
348
+ live: !0,
349
+ slot: "now",
350
+ track: i.now,
351
+ selectedPhase: c?.slot === "now" ? c.phase : null,
352
+ onSelect: (e) => a?.(`select:now:${e}`)
353
+ }),
354
+ /* @__PURE__ */ f(L, {
355
+ live: !1,
356
+ slot: "last",
357
+ track: i.last,
358
+ selectedPhase: c?.slot === "last" ? c.phase : null,
359
+ onSelect: (e) => a?.(`select:last:${e}`)
360
+ }),
361
+ c.summary ? /* @__PURE__ */ p(s, {
362
+ gap: 1,
363
+ children: [/* @__PURE__ */ f(n, { label: `${c.slot === "now" ? "now" : "last"} / ${c.summary.phase}` }), /* @__PURE__ */ f(B, { phase: c.summary })]
364
+ }) : null
365
+ ] })]
366
+ });
367
+ }
368
+ function I(e) {
369
+ let t = e.selected ?? null;
370
+ if (!t) return {
371
+ slot: "now",
372
+ phase: "HANDLE",
373
+ summary: null
374
+ };
375
+ let n = (t.slot === "now" ? e.now : e.last).phases.find((e) => e.phase === t.phase) ?? null;
376
+ return {
377
+ slot: t.slot,
378
+ phase: t.phase,
379
+ summary: n
380
+ };
381
+ }
382
+ function L({ live: t, slot: a, track: c, selectedPhase: l, onSelect: u }) {
383
+ let d = t && c.hasTrajectory, m = c.phases.reduce((e, t, n) => t.status === "idle" ? e : n, -1), h = c.phases.length;
384
+ return /* @__PURE__ */ p(s, {
385
+ gap: 1,
386
+ agent: `strip-${a}`,
387
+ children: [
388
+ /* @__PURE__ */ f(n, { label: t ? "now" : "last" }),
389
+ /* @__PURE__ */ f(o, {
390
+ style: "caption",
391
+ tone: d ? "primary" : "muted",
392
+ align: "center",
393
+ children: c.hasTrajectory ? R(m, h) : "no turn yet"
394
+ }),
395
+ /* @__PURE__ */ f(i, {
396
+ gap: 0,
397
+ children: c.phases.map((t) => /* @__PURE__ */ p(r, {
398
+ gap: 1,
399
+ align: "center",
400
+ agent: `phase-${a}-${t.phase}`,
401
+ children: [
402
+ /* @__PURE__ */ f(o, {
403
+ tone: N(t.status),
404
+ bold: !0,
405
+ children: P(t.status)
406
+ }),
407
+ /* @__PURE__ */ f(o, {
408
+ bold: l === t.phase,
409
+ width: "30%",
410
+ wrap: !1,
411
+ children: t.phase
412
+ }),
413
+ /* @__PURE__ */ f(o, {
414
+ style: "caption",
415
+ tone: "muted",
416
+ grow: 1,
417
+ wrap: !1,
418
+ children: t.summary ?? t.status
419
+ }),
420
+ /* @__PURE__ */ f(e, {
421
+ variant: l === t.phase ? "solid" : "ghost",
422
+ tone: N(t.status),
423
+ agent: `select-${a}-${t.phase}`,
424
+ onPress: () => u(t.phase),
425
+ children: z(t) || "open"
426
+ })
427
+ ]
428
+ }, t.phase))
429
+ })
430
+ ]
431
+ });
432
+ }
433
+ function R(e, t) {
434
+ if (t <= 0) return "";
435
+ let n = Math.max(0, e + 1);
436
+ return `[${"=".repeat(n)}${"-".repeat(Math.max(0, t - n))}]`;
437
+ }
438
+ function z(e) {
439
+ let t = e.llmCalls.length + e.toolEvents.length + e.evaluationEvents.length;
440
+ return t > 0 ? String(t) : "";
441
+ }
442
+ function B({ phase: e }) {
443
+ switch (e.phase) {
444
+ case "HANDLE": return /* @__PURE__ */ f(H, {
445
+ calls: e.llmCalls,
446
+ ctx: e.providerAccesses
447
+ });
448
+ case "PLAN": return /* @__PURE__ */ f(U, { calls: e.llmCalls });
449
+ case "ACTION": return /* @__PURE__ */ f(W, { events: e.toolEvents });
450
+ case "EVALUATE": return /* @__PURE__ */ f(q, {
451
+ calls: e.llmCalls,
452
+ events: e.evaluationEvents
453
+ });
454
+ }
455
+ }
456
+ function V(e, t = 160) {
457
+ let n = e.trim();
458
+ return n.length <= t ? n : `${n.slice(0, t)}...`;
459
+ }
460
+ function H({ calls: e, ctx: t }) {
461
+ let n = e.find((e) => (e.stepType || e.purpose || "").toLowerCase() === "should_respond"), i = n ? w(n) : null, a = [...new Set(t.map((e) => e.providerName).filter(Boolean))];
462
+ return !i && a.length === 0 ? /* @__PURE__ */ f(o, {
463
+ style: "caption",
464
+ tone: "muted",
465
+ dim: !0,
466
+ children: "no handle activity"
467
+ }) : /* @__PURE__ */ p(s, {
468
+ gap: 1,
469
+ children: [i ? /* @__PURE__ */ p(r, {
470
+ gap: 1,
471
+ align: "center",
472
+ children: [/* @__PURE__ */ f(o, {
473
+ bold: !0,
474
+ children: i.decision
475
+ }), i.reasoning ? /* @__PURE__ */ f(o, {
476
+ style: "caption",
477
+ tone: "muted",
478
+ grow: 1,
479
+ children: V(i.reasoning)
480
+ }) : null]
481
+ }) : null, a.length > 0 ? /* @__PURE__ */ f(o, {
482
+ style: "caption",
483
+ tone: "muted",
484
+ children: `ctx: ${a.join(", ")}`
485
+ }) : null]
486
+ });
487
+ }
488
+ function U({ calls: e }) {
489
+ let t = e[e.length - 1];
490
+ if (!t) return /* @__PURE__ */ f(o, {
491
+ style: "caption",
492
+ tone: "muted",
493
+ dim: !0,
494
+ children: "no plan yet"
495
+ });
496
+ let n = V(t.response);
497
+ return /* @__PURE__ */ p(s, {
498
+ gap: 1,
499
+ children: [t.actionType ? /* @__PURE__ */ f(o, {
500
+ bold: !0,
501
+ children: t.actionType
502
+ }) : null, n ? /* @__PURE__ */ f(o, {
503
+ style: "caption",
504
+ tone: "muted",
505
+ children: n
506
+ }) : null]
507
+ });
508
+ }
509
+ function W({ events: e }) {
510
+ return e.length === 0 ? /* @__PURE__ */ f(o, {
511
+ style: "caption",
512
+ tone: "muted",
513
+ dim: !0,
514
+ children: "no actions"
515
+ }) : /* @__PURE__ */ f(i, {
516
+ gap: 1,
517
+ children: e.map((e) => {
518
+ let t = e.actionName || e.toolName || e.name || "action", n = G(e);
519
+ return /* @__PURE__ */ p(r, {
520
+ gap: 1,
521
+ align: "center",
522
+ agent: `tool-${e.id}`,
523
+ children: [
524
+ /* @__PURE__ */ f(o, {
525
+ tone: n,
526
+ bold: !0,
527
+ children: K(e)
528
+ }),
529
+ /* @__PURE__ */ f(o, {
530
+ grow: 1,
531
+ wrap: !1,
532
+ children: t
533
+ }),
534
+ typeof e.durationMs == "number" ? /* @__PURE__ */ f(o, {
535
+ style: "caption",
536
+ tone: "muted",
537
+ children: `${e.durationMs}ms`
538
+ }) : null,
539
+ e.error ? /* @__PURE__ */ f(o, {
540
+ style: "caption",
541
+ tone: "danger",
542
+ wrap: !1,
543
+ children: V(e.error, 40)
544
+ }) : null
545
+ ]
546
+ }, e.id);
547
+ })
548
+ });
549
+ }
550
+ function G(e) {
551
+ return e.type === "tool_error" || e.error || e.success === !1 ? "danger" : e.type === "tool_result" || e.status === "completed" || e.success === !0 ? "success" : e.status === "skipped" ? "warning" : "primary";
552
+ }
553
+ function K(e) {
554
+ return e.type === "tool_error" || e.error || e.success === !1 ? "x" : e.type === "tool_result" || e.status === "completed" || e.success === !0 ? "+" : e.status === "skipped" ? "-" : "*";
555
+ }
556
+ function q({ calls: e, events: t }) {
557
+ return t.length === 0 && e.length === 0 ? /* @__PURE__ */ f(o, {
558
+ style: "caption",
559
+ tone: "muted",
560
+ dim: !0,
561
+ children: "no evaluation"
562
+ }) : /* @__PURE__ */ f(i, {
563
+ gap: 1,
564
+ children: t.map((e) => {
565
+ let t = e.evaluatorName || e.name || "evaluator", n = e.error || e.success === !1 ? "danger" : e.success === !0 || e.status === "completed" ? "success" : e.status === "skipped" ? "warning" : "primary";
566
+ return /* @__PURE__ */ p(s, {
567
+ gap: 0,
568
+ agent: `eval-${e.id}`,
569
+ children: [
570
+ /* @__PURE__ */ p(r, {
571
+ gap: 1,
572
+ align: "center",
573
+ children: [/* @__PURE__ */ f(o, {
574
+ tone: n,
575
+ grow: 1,
576
+ wrap: !1,
577
+ children: t
578
+ }), e.decision ? /* @__PURE__ */ f(o, {
579
+ style: "caption",
580
+ tone: "muted",
581
+ children: e.decision
582
+ }) : null]
583
+ }),
584
+ e.thought ? /* @__PURE__ */ f(o, {
585
+ style: "caption",
586
+ tone: "muted",
587
+ children: V(e.thought)
588
+ }) : null,
589
+ e.error ? /* @__PURE__ */ f(o, {
590
+ style: "caption",
591
+ tone: "danger",
592
+ children: V(e.error, 80)
593
+ }) : null
594
+ ]
595
+ }, e.id);
596
+ })
597
+ });
598
+ }
599
+ //#endregion
600
+ //#region src/components/TrajectoryLoggerView.tsx
601
+ function J() {
602
+ typeof window > "u" || window.dispatchEvent(new CustomEvent("eliza:navigate:view", { detail: {
603
+ viewId: "apps",
604
+ viewPath: "/apps"
605
+ } }));
606
+ }
607
+ function Y({ exitToApps: e } = {}) {
608
+ let t = M(!0), [n, r] = u(null), i = c((t) => {
609
+ if (t === "back") {
610
+ e ? e() : J();
611
+ return;
612
+ }
613
+ if (t !== "refresh" && t.startsWith("select:")) {
614
+ let [, e, n] = t.split(":");
615
+ if ((e === "now" || e === "last") && n) {
616
+ let t = {
617
+ slot: e,
618
+ phase: n
619
+ };
620
+ r((e) => e && e.slot === t.slot && e.phase === t.phase ? null : t);
621
+ }
622
+ }
623
+ }, [e]);
624
+ return /* @__PURE__ */ f(a, { children: /* @__PURE__ */ f(F, {
625
+ snapshot: {
626
+ ready: t.ready,
627
+ recording: !!t.active,
628
+ unavailable: t.unavailable,
629
+ error: t.error,
630
+ now: {
631
+ hasTrajectory: !!t.active,
632
+ phases: T(t.activeDetail, { trajectoryActive: !0 })
633
+ },
634
+ last: {
635
+ hasTrajectory: !!t.last,
636
+ phases: T(t.lastDetail, { trajectoryActive: !1 })
637
+ },
638
+ selected: n
639
+ },
640
+ onAction: i
641
+ }) });
642
+ }
643
+ //#endregion
644
+ export { Y as TrajectoryLoggerView, v as interact };
645
+
646
+ //# sourceMappingURL=bundle.js.map