calabasas 0.21.0 → 0.22.0

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.
@@ -0,0 +1,12 @@
1
+ import {
2
+ BotList
3
+ } from "./index-p2b3p55j.js";
4
+ import"./index-a4vgnqve.js";
5
+ import"./index-abpmxgdw.js";
6
+ import"./index-xjd7043z.js";
7
+ import"./index-1jk3me1x.js";
8
+ import"./index-p5pq1vk1.js";
9
+ import"./index-wckvcay0.js";
10
+ export {
11
+ BotList
12
+ };
@@ -0,0 +1,13 @@
1
+ import {
2
+ ConvexProvider,
3
+ cliApi,
4
+ createConvexClient
5
+ } from "./index-xjd7043z.js";
6
+ import"./index-1jk3me1x.js";
7
+ import"./index-p5pq1vk1.js";
8
+ import"./index-wckvcay0.js";
9
+ export {
10
+ createConvexClient,
11
+ cliApi,
12
+ ConvexProvider
13
+ };
@@ -0,0 +1,221 @@
1
+ import {
2
+ LogViewer
3
+ } from "./index-rnz69zk4.js";
4
+ import {
5
+ getConvexUrl,
6
+ resolvePlatformApiKey
7
+ } from "./index-jzx2fk4g.js";
8
+ import {
9
+ BotList
10
+ } from "./index-p2b3p55j.js";
11
+ import {
12
+ build_default,
13
+ formatLatency,
14
+ formatNumber
15
+ } from "./index-a4vgnqve.js";
16
+ import {
17
+ Box_default,
18
+ Text,
19
+ render_default,
20
+ use_app_default,
21
+ use_input_default
22
+ } from "./index-abpmxgdw.js";
23
+ import {
24
+ ConvexProvider,
25
+ cliApi,
26
+ createConvexClient,
27
+ require_jsx_dev_runtime,
28
+ useQuery
29
+ } from "./index-xjd7043z.js";
30
+ import"./index-1jk3me1x.js";
31
+ import {
32
+ require_react
33
+ } from "./index-p5pq1vk1.js";
34
+ import {
35
+ __toESM
36
+ } from "./index-wckvcay0.js";
37
+
38
+ // src/components/Dashboard.tsx
39
+ var import_react2 = __toESM(require_react(), 1);
40
+
41
+ // src/components/Header.tsx
42
+ var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
43
+ function Header({
44
+ botCount
45
+ }) {
46
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
47
+ marginBottom: 1,
48
+ children: [
49
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
50
+ bold: true,
51
+ color: "magenta",
52
+ children: "calabasas"
53
+ }, undefined, false, undefined, this),
54
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
55
+ dimColor: true,
56
+ children: " v0.1.12"
57
+ }, undefined, false, undefined, this),
58
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
59
+ dimColor: true,
60
+ children: " · "
61
+ }, undefined, false, undefined, this),
62
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
63
+ children: [
64
+ botCount,
65
+ " bot",
66
+ botCount !== 1 ? "s" : ""
67
+ ]
68
+ }, undefined, true, undefined, this),
69
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
70
+ dimColor: true,
71
+ children: " · Press "
72
+ }, undefined, false, undefined, this),
73
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
74
+ bold: true,
75
+ children: "q"
76
+ }, undefined, false, undefined, this),
77
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
78
+ dimColor: true,
79
+ children: " to quit"
80
+ }, undefined, false, undefined, this)
81
+ ]
82
+ }, undefined, true, undefined, this);
83
+ }
84
+
85
+ // src/components/StatsPanel.tsx
86
+ var jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
87
+ var ONE_HOUR = 60 * 60 * 1000;
88
+ function StatsPanel({
89
+ apiKey,
90
+ botId
91
+ }) {
92
+ const stats = useQuery(cliApi.botStats, {
93
+ apiKey,
94
+ botId,
95
+ since: Date.now() - ONE_HOUR
96
+ });
97
+ if (stats === undefined) {
98
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Box_default, {
99
+ children: [
100
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
101
+ color: "cyan",
102
+ children: /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(build_default, {
103
+ type: "dots"
104
+ }, undefined, false, undefined, this)
105
+ }, undefined, false, undefined, this),
106
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
107
+ children: " Loading stats..."
108
+ }, undefined, false, undefined, this)
109
+ ]
110
+ }, undefined, true, undefined, this);
111
+ }
112
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Box_default, {
113
+ gap: 2,
114
+ marginBottom: 1,
115
+ children: [
116
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
117
+ dimColor: true,
118
+ children: "Events (1h):"
119
+ }, undefined, false, undefined, this),
120
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
121
+ bold: true,
122
+ children: formatNumber(stats.total)
123
+ }, undefined, false, undefined, this),
124
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
125
+ color: "green",
126
+ children: [
127
+ formatNumber(stats.success),
128
+ " ok"
129
+ ]
130
+ }, undefined, true, undefined, this),
131
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
132
+ color: "red",
133
+ children: [
134
+ formatNumber(stats.failed),
135
+ " failed"
136
+ ]
137
+ }, undefined, true, undefined, this),
138
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
139
+ dimColor: true,
140
+ children: [
141
+ "avg ",
142
+ formatLatency(stats.avgLatencyMs)
143
+ ]
144
+ }, undefined, true, undefined, this)
145
+ ]
146
+ }, undefined, true, undefined, this);
147
+ }
148
+
149
+ // src/components/Dashboard.tsx
150
+ var jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
151
+ function Dashboard({
152
+ apiKey
153
+ }) {
154
+ const { exit } = use_app_default();
155
+ const [selectedIndex, setSelectedIndex] = import_react2.useState(0);
156
+ const bots = useQuery(cliApi.listBots, { apiKey });
157
+ const botCount = bots?.length ?? 0;
158
+ const selectedBot = bots?.[selectedIndex];
159
+ use_input_default(import_react2.useCallback((input, key) => {
160
+ if (input === "q") {
161
+ exit();
162
+ return;
163
+ }
164
+ if ((input === "j" || key.downArrow) && botCount > 0) {
165
+ setSelectedIndex((i) => Math.min(i, botCount - 1) === botCount - 1 ? 0 : i + 1);
166
+ }
167
+ if ((input === "k" || key.upArrow) && botCount > 0) {
168
+ setSelectedIndex((i) => i === 0 ? botCount - 1 : i - 1);
169
+ }
170
+ }, [botCount, exit]));
171
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
172
+ flexDirection: "column",
173
+ children: [
174
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Header, {
175
+ botCount
176
+ }, undefined, false, undefined, this),
177
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(BotList, {
178
+ apiKey,
179
+ selectedIndex
180
+ }, undefined, false, undefined, this),
181
+ selectedBot && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
182
+ flexDirection: "column",
183
+ marginTop: 1,
184
+ children: [
185
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(StatsPanel, {
186
+ apiKey,
187
+ botId: selectedBot._id
188
+ }, undefined, false, undefined, this),
189
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(LogViewer, {
190
+ apiKey,
191
+ botId: selectedBot._id
192
+ }, undefined, false, undefined, this)
193
+ ]
194
+ }, undefined, true, undefined, this)
195
+ ]
196
+ }, undefined, true, undefined, this);
197
+ }
198
+
199
+ // src/commands/dashboard.tsx
200
+ var jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
201
+ async function dashboard() {
202
+ const resolved = resolvePlatformApiKey({});
203
+ if (!resolved) {
204
+ console.log("Not logged in. Run `calabasas login` first.");
205
+ return;
206
+ }
207
+ const apiKey = resolved.key;
208
+ const convexUrl = getConvexUrl();
209
+ const client = createConvexClient(convexUrl);
210
+ const { waitUntilExit } = render_default(/* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ConvexProvider, {
211
+ client,
212
+ children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Dashboard, {
213
+ apiKey
214
+ }, undefined, false, undefined, this)
215
+ }, undefined, false, undefined, this));
216
+ await waitUntilExit();
217
+ await client.close();
218
+ }
219
+ export {
220
+ dashboard
221
+ };