calabasas 0.14.0 → 0.15.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.
- package/dist/config.d.ts +1 -0
- package/dist/dashboard-jhqez8y6.js +235 -0
- package/dist/index-b0cp0nch.js +121 -0
- package/dist/index.js +11 -7
- package/dist/logs-yvtas8nk.js +113 -0
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LogViewer
|
|
3
|
+
} from "./index-b0cp0nch.js";
|
|
4
|
+
import {
|
|
5
|
+
getConvexUrl,
|
|
6
|
+
resolveEnv,
|
|
7
|
+
resolvePlatformApiKey
|
|
8
|
+
} from "./index-a8vtmtf9.js";
|
|
9
|
+
import {
|
|
10
|
+
build_default,
|
|
11
|
+
formatLatency,
|
|
12
|
+
formatNumber
|
|
13
|
+
} from "./index-8gymgyxd.js";
|
|
14
|
+
import"./index-tre7d3f1.js";
|
|
15
|
+
import {
|
|
16
|
+
__toESM
|
|
17
|
+
} from "./index-sdksp5px.js";
|
|
18
|
+
import {
|
|
19
|
+
BotList
|
|
20
|
+
} from "./BotList-pbt2yxmj.js";
|
|
21
|
+
import {
|
|
22
|
+
Box_default,
|
|
23
|
+
Text,
|
|
24
|
+
render_default,
|
|
25
|
+
use_app_default,
|
|
26
|
+
use_input_default
|
|
27
|
+
} from "./index-4rn9k8et.js";
|
|
28
|
+
import {
|
|
29
|
+
ConvexProvider,
|
|
30
|
+
cliApi,
|
|
31
|
+
createConvexClient,
|
|
32
|
+
require_jsx_dev_runtime,
|
|
33
|
+
useQuery
|
|
34
|
+
} from "./convex-1z1jsz1n.js";
|
|
35
|
+
import {
|
|
36
|
+
require_react
|
|
37
|
+
} from "./index-vmy4gfe1.js";
|
|
38
|
+
|
|
39
|
+
// src/components/Dashboard.tsx
|
|
40
|
+
var import_react2 = __toESM(require_react(), 1);
|
|
41
|
+
|
|
42
|
+
// src/components/Header.tsx
|
|
43
|
+
var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
|
|
44
|
+
function Header({
|
|
45
|
+
botCount,
|
|
46
|
+
env
|
|
47
|
+
}) {
|
|
48
|
+
return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
49
|
+
marginBottom: 1,
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
52
|
+
bold: true,
|
|
53
|
+
color: "magenta",
|
|
54
|
+
children: "calabasas"
|
|
55
|
+
}, undefined, false, undefined, this),
|
|
56
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
57
|
+
dimColor: true,
|
|
58
|
+
children: " v0.1.12"
|
|
59
|
+
}, undefined, false, undefined, this),
|
|
60
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
61
|
+
dimColor: true,
|
|
62
|
+
children: " · "
|
|
63
|
+
}, undefined, false, undefined, this),
|
|
64
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
65
|
+
children: [
|
|
66
|
+
botCount,
|
|
67
|
+
" bot",
|
|
68
|
+
botCount !== 1 ? "s" : ""
|
|
69
|
+
]
|
|
70
|
+
}, undefined, true, undefined, this),
|
|
71
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
72
|
+
dimColor: true,
|
|
73
|
+
children: " · "
|
|
74
|
+
}, undefined, false, undefined, this),
|
|
75
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
76
|
+
color: env === "dev" ? "yellow" : "green",
|
|
77
|
+
children: env
|
|
78
|
+
}, undefined, false, undefined, this),
|
|
79
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
80
|
+
dimColor: true,
|
|
81
|
+
children: " · Press "
|
|
82
|
+
}, undefined, false, undefined, this),
|
|
83
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
84
|
+
bold: true,
|
|
85
|
+
children: "q"
|
|
86
|
+
}, undefined, false, undefined, this),
|
|
87
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
88
|
+
dimColor: true,
|
|
89
|
+
children: " to quit"
|
|
90
|
+
}, undefined, false, undefined, this)
|
|
91
|
+
]
|
|
92
|
+
}, undefined, true, undefined, this);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// src/components/StatsPanel.tsx
|
|
96
|
+
var jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
|
|
97
|
+
var ONE_HOUR = 60 * 60 * 1000;
|
|
98
|
+
function StatsPanel({
|
|
99
|
+
apiKey,
|
|
100
|
+
botId
|
|
101
|
+
}) {
|
|
102
|
+
const stats = useQuery(cliApi.botStats, {
|
|
103
|
+
apiKey,
|
|
104
|
+
botId,
|
|
105
|
+
since: Date.now() - ONE_HOUR
|
|
106
|
+
});
|
|
107
|
+
if (stats === undefined) {
|
|
108
|
+
return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Box_default, {
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
|
|
111
|
+
color: "cyan",
|
|
112
|
+
children: /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(build_default, {
|
|
113
|
+
type: "dots"
|
|
114
|
+
}, undefined, false, undefined, this)
|
|
115
|
+
}, undefined, false, undefined, this),
|
|
116
|
+
/* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
|
|
117
|
+
children: " Loading stats..."
|
|
118
|
+
}, undefined, false, undefined, this)
|
|
119
|
+
]
|
|
120
|
+
}, undefined, true, undefined, this);
|
|
121
|
+
}
|
|
122
|
+
return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Box_default, {
|
|
123
|
+
gap: 2,
|
|
124
|
+
marginBottom: 1,
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
|
|
127
|
+
dimColor: true,
|
|
128
|
+
children: "Events (1h):"
|
|
129
|
+
}, undefined, false, undefined, this),
|
|
130
|
+
/* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
|
|
131
|
+
bold: true,
|
|
132
|
+
children: formatNumber(stats.total)
|
|
133
|
+
}, undefined, false, undefined, this),
|
|
134
|
+
/* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
|
|
135
|
+
color: "green",
|
|
136
|
+
children: [
|
|
137
|
+
formatNumber(stats.success),
|
|
138
|
+
" ok"
|
|
139
|
+
]
|
|
140
|
+
}, undefined, true, undefined, this),
|
|
141
|
+
/* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
|
|
142
|
+
color: "red",
|
|
143
|
+
children: [
|
|
144
|
+
formatNumber(stats.failed),
|
|
145
|
+
" failed"
|
|
146
|
+
]
|
|
147
|
+
}, undefined, true, undefined, this),
|
|
148
|
+
/* @__PURE__ */ jsx_dev_runtime2.jsxDEV(Text, {
|
|
149
|
+
dimColor: true,
|
|
150
|
+
children: [
|
|
151
|
+
"avg ",
|
|
152
|
+
formatLatency(stats.avgLatencyMs)
|
|
153
|
+
]
|
|
154
|
+
}, undefined, true, undefined, this)
|
|
155
|
+
]
|
|
156
|
+
}, undefined, true, undefined, this);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/components/Dashboard.tsx
|
|
160
|
+
var jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
|
|
161
|
+
function Dashboard({
|
|
162
|
+
apiKey,
|
|
163
|
+
env
|
|
164
|
+
}) {
|
|
165
|
+
const { exit } = use_app_default();
|
|
166
|
+
const [selectedIndex, setSelectedIndex] = import_react2.useState(0);
|
|
167
|
+
const bots = useQuery(cliApi.listBots, { apiKey });
|
|
168
|
+
const botCount = bots?.length ?? 0;
|
|
169
|
+
const selectedBot = bots?.[selectedIndex];
|
|
170
|
+
use_input_default(import_react2.useCallback((input, key) => {
|
|
171
|
+
if (input === "q") {
|
|
172
|
+
exit();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if ((input === "j" || key.downArrow) && botCount > 0) {
|
|
176
|
+
setSelectedIndex((i) => Math.min(i, botCount - 1) === botCount - 1 ? 0 : i + 1);
|
|
177
|
+
}
|
|
178
|
+
if ((input === "k" || key.upArrow) && botCount > 0) {
|
|
179
|
+
setSelectedIndex((i) => i === 0 ? botCount - 1 : i - 1);
|
|
180
|
+
}
|
|
181
|
+
}, [botCount, exit]));
|
|
182
|
+
return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
183
|
+
flexDirection: "column",
|
|
184
|
+
children: [
|
|
185
|
+
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Header, {
|
|
186
|
+
botCount,
|
|
187
|
+
env
|
|
188
|
+
}, undefined, false, undefined, this),
|
|
189
|
+
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(BotList, {
|
|
190
|
+
apiKey,
|
|
191
|
+
selectedIndex
|
|
192
|
+
}, undefined, false, undefined, this),
|
|
193
|
+
selectedBot && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
194
|
+
flexDirection: "column",
|
|
195
|
+
marginTop: 1,
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(StatsPanel, {
|
|
198
|
+
apiKey,
|
|
199
|
+
botId: selectedBot._id
|
|
200
|
+
}, undefined, false, undefined, this),
|
|
201
|
+
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(LogViewer, {
|
|
202
|
+
apiKey,
|
|
203
|
+
botId: selectedBot._id
|
|
204
|
+
}, undefined, false, undefined, this)
|
|
205
|
+
]
|
|
206
|
+
}, undefined, true, undefined, this)
|
|
207
|
+
]
|
|
208
|
+
}, undefined, true, undefined, this);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// src/commands/dashboard.tsx
|
|
212
|
+
var jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
|
|
213
|
+
async function dashboard(options) {
|
|
214
|
+
const env = resolveEnv(options);
|
|
215
|
+
const resolved = resolvePlatformApiKey({}, env);
|
|
216
|
+
if (!resolved) {
|
|
217
|
+
console.log("Not logged in. Run `calabasas login` first.");
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const apiKey = resolved.key;
|
|
221
|
+
const convexUrl = getConvexUrl(env);
|
|
222
|
+
const client = createConvexClient(convexUrl);
|
|
223
|
+
const { waitUntilExit } = render_default(/* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ConvexProvider, {
|
|
224
|
+
client,
|
|
225
|
+
children: /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Dashboard, {
|
|
226
|
+
apiKey,
|
|
227
|
+
env
|
|
228
|
+
}, undefined, false, undefined, this)
|
|
229
|
+
}, undefined, false, undefined, this));
|
|
230
|
+
await waitUntilExit();
|
|
231
|
+
await client.close();
|
|
232
|
+
}
|
|
233
|
+
export {
|
|
234
|
+
dashboard
|
|
235
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
build_default,
|
|
3
|
+
formatLatency
|
|
4
|
+
} from "./index-8gymgyxd.js";
|
|
5
|
+
import {
|
|
6
|
+
__toESM
|
|
7
|
+
} from "./index-sdksp5px.js";
|
|
8
|
+
import {
|
|
9
|
+
Box_default,
|
|
10
|
+
Text
|
|
11
|
+
} from "./index-4rn9k8et.js";
|
|
12
|
+
import {
|
|
13
|
+
cliApi,
|
|
14
|
+
require_jsx_dev_runtime,
|
|
15
|
+
useQuery
|
|
16
|
+
} from "./convex-1z1jsz1n.js";
|
|
17
|
+
|
|
18
|
+
// src/components/LogViewer.tsx
|
|
19
|
+
var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
|
|
20
|
+
function formatTimestamp(ts) {
|
|
21
|
+
const d = new Date(ts);
|
|
22
|
+
return d.toLocaleTimeString("en-US", { hour12: false });
|
|
23
|
+
}
|
|
24
|
+
function LogViewer({
|
|
25
|
+
apiKey,
|
|
26
|
+
botId,
|
|
27
|
+
limit = 50,
|
|
28
|
+
successFilter
|
|
29
|
+
}) {
|
|
30
|
+
const logs = useQuery(cliApi.recentLogs, {
|
|
31
|
+
apiKey,
|
|
32
|
+
botId,
|
|
33
|
+
limit,
|
|
34
|
+
success: successFilter
|
|
35
|
+
});
|
|
36
|
+
if (logs === undefined) {
|
|
37
|
+
return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
40
|
+
color: "cyan",
|
|
41
|
+
children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(build_default, {
|
|
42
|
+
type: "dots"
|
|
43
|
+
}, undefined, false, undefined, this)
|
|
44
|
+
}, undefined, false, undefined, this),
|
|
45
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
46
|
+
children: " Loading logs..."
|
|
47
|
+
}, undefined, false, undefined, this)
|
|
48
|
+
]
|
|
49
|
+
}, undefined, true, undefined, this);
|
|
50
|
+
}
|
|
51
|
+
if (logs.length === 0) {
|
|
52
|
+
return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
53
|
+
children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
54
|
+
dimColor: true,
|
|
55
|
+
children: "No events yet."
|
|
56
|
+
}, undefined, false, undefined, this)
|
|
57
|
+
}, undefined, false, undefined, this);
|
|
58
|
+
}
|
|
59
|
+
const uniqueBots = new Set(logs.map((l) => l.botName));
|
|
60
|
+
const multiBot = uniqueBots.size > 1 || !botId;
|
|
61
|
+
const filterLabel = successFilter === true ? " · success only" : successFilter === false ? " · errors only" : "";
|
|
62
|
+
return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
63
|
+
flexDirection: "column",
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
66
|
+
marginBottom: 1,
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
69
|
+
bold: true,
|
|
70
|
+
children: "Event Log"
|
|
71
|
+
}, undefined, false, undefined, this),
|
|
72
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
73
|
+
dimColor: true,
|
|
74
|
+
children: [
|
|
75
|
+
" (live · ",
|
|
76
|
+
logs.length,
|
|
77
|
+
" events",
|
|
78
|
+
filterLabel,
|
|
79
|
+
")"
|
|
80
|
+
]
|
|
81
|
+
}, undefined, true, undefined, this)
|
|
82
|
+
]
|
|
83
|
+
}, undefined, true, undefined, this),
|
|
84
|
+
logs.map((log) => /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
|
|
85
|
+
gap: 1,
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
88
|
+
dimColor: true,
|
|
89
|
+
children: formatTimestamp(log.timestamp)
|
|
90
|
+
}, undefined, false, undefined, this),
|
|
91
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
92
|
+
color: log.success ? "green" : "red",
|
|
93
|
+
children: log.success ? "✓" : "✗"
|
|
94
|
+
}, undefined, false, undefined, this),
|
|
95
|
+
multiBot && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
96
|
+
color: "cyan",
|
|
97
|
+
children: [
|
|
98
|
+
"[",
|
|
99
|
+
log.botName,
|
|
100
|
+
"]"
|
|
101
|
+
]
|
|
102
|
+
}, undefined, true, undefined, this),
|
|
103
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
104
|
+
bold: true,
|
|
105
|
+
children: log.eventType
|
|
106
|
+
}, undefined, false, undefined, this),
|
|
107
|
+
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
108
|
+
dimColor: true,
|
|
109
|
+
children: formatLatency(log.latencyMs)
|
|
110
|
+
}, undefined, false, undefined, this),
|
|
111
|
+
log.error && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
|
|
112
|
+
color: "red",
|
|
113
|
+
children: log.error
|
|
114
|
+
}, undefined, false, undefined, this)
|
|
115
|
+
]
|
|
116
|
+
}, log._id, true, undefined, this))
|
|
117
|
+
]
|
|
118
|
+
}, undefined, true, undefined, this);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { LogViewer };
|
package/dist/index.js
CHANGED
|
@@ -2353,7 +2353,8 @@ async function push(options) {
|
|
|
2353
2353
|
channels: calabasasConfig.sync?.channels ?? false,
|
|
2354
2354
|
roles: calabasasConfig.sync?.roles ?? false,
|
|
2355
2355
|
members: calabasasConfig.sync?.members ?? false,
|
|
2356
|
-
presence: calabasasConfig.sync?.presence ?? false
|
|
2356
|
+
presence: calabasasConfig.sync?.presence ?? false,
|
|
2357
|
+
emojis: calabasasConfig.sync?.emojis ?? false
|
|
2357
2358
|
},
|
|
2358
2359
|
eventConfigs,
|
|
2359
2360
|
commands: calabasasConfig.commands ? JSON.stringify(calabasasConfig.commands) : undefined
|
|
@@ -2377,6 +2378,7 @@ async function push(options) {
|
|
|
2377
2378
|
syncRoles: calabasasConfig.sync?.roles ?? false,
|
|
2378
2379
|
syncMembers: calabasasConfig.sync?.members ?? false,
|
|
2379
2380
|
syncPresence: calabasasConfig.sync?.presence ?? false,
|
|
2381
|
+
syncEmojis: calabasasConfig.sync?.emojis ?? false,
|
|
2380
2382
|
eventConfigs
|
|
2381
2383
|
})
|
|
2382
2384
|
});
|
|
@@ -2441,7 +2443,8 @@ async function push(options) {
|
|
|
2441
2443
|
`Channels: ${calabasasConfig.sync?.channels ? "enabled" : "disabled"}`,
|
|
2442
2444
|
`Roles: ${calabasasConfig.sync?.roles ? "enabled" : "disabled"}`,
|
|
2443
2445
|
`Members: ${calabasasConfig.sync?.members ? "enabled" : "disabled"}`,
|
|
2444
|
-
`Presence: ${calabasasConfig.sync?.presence ? "enabled" : "disabled"}
|
|
2446
|
+
`Presence: ${calabasasConfig.sync?.presence ? "enabled" : "disabled"}`,
|
|
2447
|
+
`Emojis: ${calabasasConfig.sync?.emojis ? "enabled" : "disabled"}`
|
|
2445
2448
|
].join(`
|
|
2446
2449
|
`);
|
|
2447
2450
|
const eventSummary = eventConfigs.length > 0 ? `
|
|
@@ -5911,7 +5914,8 @@ var SYNC_PROPERTIES_META = {
|
|
|
5911
5914
|
channels: { intent: null, privileged: false, description: "Sync channels" },
|
|
5912
5915
|
roles: { intent: null, privileged: false, description: "Sync roles" },
|
|
5913
5916
|
members: { intent: "GuildMembers", privileged: true, description: "Sync members" },
|
|
5914
|
-
presence: { intent: "GuildPresences", privileged: true, description: "Sync online status" }
|
|
5917
|
+
presence: { intent: "GuildPresences", privileged: true, description: "Sync online status" },
|
|
5918
|
+
emojis: { intent: "GuildEmojis", privileged: false, description: "Sync guild & app emojis" }
|
|
5915
5919
|
};
|
|
5916
5920
|
|
|
5917
5921
|
// src/commands/config.ts
|
|
@@ -6145,12 +6149,12 @@ Run ${pc3.cyan("`calabasas init`")} first.`);
|
|
|
6145
6149
|
|
|
6146
6150
|
// src/index.ts
|
|
6147
6151
|
var dashboard = async (...args) => {
|
|
6148
|
-
const mod = await import("./dashboard-
|
|
6152
|
+
const mod = await import("./dashboard-jhqez8y6.js");
|
|
6149
6153
|
return mod.dashboard(args[0]);
|
|
6150
6154
|
};
|
|
6151
6155
|
var logs = async (...args) => {
|
|
6152
|
-
const mod = await import("./logs-
|
|
6153
|
-
return mod.logs(args[0]
|
|
6156
|
+
const mod = await import("./logs-yvtas8nk.js");
|
|
6157
|
+
return mod.logs(args[0]);
|
|
6154
6158
|
};
|
|
6155
6159
|
var program2 = new Command;
|
|
6156
6160
|
program2.name("calabasas").description("CLI for Calabasas - Discord Gateway as a Service for Convex").version("0.0.1");
|
|
@@ -6164,7 +6168,7 @@ program2.command("add [components...]").description("Add Discord UI components t
|
|
|
6164
6168
|
program2.command("migrate [name]").description("Run a codemod migration (list available if no name given)").action(migrate);
|
|
6165
6169
|
program2.command("config").description("View and modify your Calabasas config").option("-c, --config <path>", "Path to config file", "convex/calabasas/config.ts").option("-l, --list", "List current and available config options").option("--add-event <events...>", "Enable event handlers").option("--remove-event <events...>", "Disable event handlers").option("--add-sync <properties...>", "Enable sync properties").option("--remove-sync <properties...>", "Disable sync properties").action(config);
|
|
6166
6170
|
program2.command("status").alias("dashboard").description("Real-time dashboard showing bot status, events, and stats").option("--dev", "Use development environment").option("--prod", "Use production environment").action(dashboard);
|
|
6167
|
-
program2.command("logs
|
|
6171
|
+
program2.command("logs").description("Event log viewer (live by default, or one-shot with --once)").option("-b, --bot <id>", "Bot ID (omit for all bots in platform)").option("-n, --limit <number>", "Number of log entries to show", "50").option("--once", "One-shot output instead of real-time view").option("--errors", "Show only failed events").option("--success", "Show only successful events").option("--dev", "Use development environment").option("--prod", "Use production environment").action(logs);
|
|
6168
6172
|
var bot = program2.command("bot").description("Manage Discord bots");
|
|
6169
6173
|
bot.command("add").description("Add a new Discord bot").option("-n, --name <name>", "Bot name").option("-a, --app-id <id>", "Discord Application ID").option("-t, --token <token>", "Bot token").option("-i, --intents <intents>", "Intents value (number)").option("--dev", "Use development environment").option("--prod", "Use production environment").action(botAdd);
|
|
6170
6174
|
bot.command("list").alias("ls").description("List your Discord bots (real-time by default)").option("--once", "One-shot output instead of real-time view").option("--dev", "Use development environment").option("--prod", "Use production environment").action(botList);
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LogViewer
|
|
3
|
+
} from "./index-b0cp0nch.js";
|
|
4
|
+
import {
|
|
5
|
+
getConvexUrl,
|
|
6
|
+
platformApiRequest,
|
|
7
|
+
resolveEnv,
|
|
8
|
+
resolvePlatformApiKey
|
|
9
|
+
} from "./index-a8vtmtf9.js";
|
|
10
|
+
import {
|
|
11
|
+
formatLatency
|
|
12
|
+
} from "./index-8gymgyxd.js";
|
|
13
|
+
import"./index-tre7d3f1.js";
|
|
14
|
+
import {
|
|
15
|
+
__toESM
|
|
16
|
+
} from "./index-sdksp5px.js";
|
|
17
|
+
import {
|
|
18
|
+
render_default,
|
|
19
|
+
use_app_default,
|
|
20
|
+
use_input_default
|
|
21
|
+
} from "./index-4rn9k8et.js";
|
|
22
|
+
import {
|
|
23
|
+
ConvexProvider,
|
|
24
|
+
createConvexClient,
|
|
25
|
+
require_jsx_dev_runtime
|
|
26
|
+
} from "./convex-1z1jsz1n.js";
|
|
27
|
+
import"./index-vmy4gfe1.js";
|
|
28
|
+
|
|
29
|
+
// src/commands/logs.tsx
|
|
30
|
+
import pc from "picocolors";
|
|
31
|
+
var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
|
|
32
|
+
function LogsApp({ apiKey, botId, limit, successFilter }) {
|
|
33
|
+
const { exit } = use_app_default();
|
|
34
|
+
use_input_default((input) => {
|
|
35
|
+
if (input === "q") {
|
|
36
|
+
exit();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(LogViewer, {
|
|
40
|
+
apiKey,
|
|
41
|
+
botId,
|
|
42
|
+
limit,
|
|
43
|
+
successFilter
|
|
44
|
+
}, undefined, false, undefined, this);
|
|
45
|
+
}
|
|
46
|
+
function formatTimestamp(ts) {
|
|
47
|
+
const d = new Date(ts);
|
|
48
|
+
return d.toLocaleTimeString("en-US", { hour12: false });
|
|
49
|
+
}
|
|
50
|
+
async function logs(options) {
|
|
51
|
+
const env = resolveEnv(options);
|
|
52
|
+
if (options.errors && options.success) {
|
|
53
|
+
console.error("Error: Cannot use both --errors and --success flags.");
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
const resolved = resolvePlatformApiKey({}, env);
|
|
57
|
+
if (!resolved) {
|
|
58
|
+
console.log("Not logged in. Run `calabasas login` first.");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const apiKey = resolved.key;
|
|
62
|
+
const limit = options.limit ? parseInt(options.limit, 10) : 50;
|
|
63
|
+
const successFilter = options.errors ? false : options.success ? true : undefined;
|
|
64
|
+
const botId = options.bot;
|
|
65
|
+
if (options.once || !process.stdin.isTTY) {
|
|
66
|
+
const params = new URLSearchParams;
|
|
67
|
+
if (botId)
|
|
68
|
+
params.set("botId", botId);
|
|
69
|
+
params.set("limit", String(limit));
|
|
70
|
+
if (successFilter !== undefined)
|
|
71
|
+
params.set("success", String(successFilter));
|
|
72
|
+
const queryString = params.toString();
|
|
73
|
+
const path = `/api/sdk/logs${queryString ? `?${queryString}` : ""}`;
|
|
74
|
+
const { ok, data, status } = await platformApiRequest("GET", path, apiKey, undefined, env);
|
|
75
|
+
if (!ok) {
|
|
76
|
+
console.error(`Failed to fetch logs: ${data.error || `HTTP ${status}`}`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
const { logs: entries } = data;
|
|
80
|
+
if (entries.length === 0) {
|
|
81
|
+
console.log("No events found.");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const uniqueBots = new Set(entries.map((l) => l.botName));
|
|
85
|
+
const multiBot = uniqueBots.size > 1 || !botId;
|
|
86
|
+
for (const log of entries) {
|
|
87
|
+
const time = pc.dim(formatTimestamp(log.timestamp));
|
|
88
|
+
const status2 = log.success ? pc.green("✓") : pc.red("✗");
|
|
89
|
+
const event = pc.bold(log.eventType);
|
|
90
|
+
const latency = pc.dim(formatLatency(log.latencyMs));
|
|
91
|
+
const botLabel = multiBot ? pc.cyan(`[${log.botName}]`) + " " : "";
|
|
92
|
+
const error = log.error ? ` ${pc.red(log.error)}` : "";
|
|
93
|
+
console.log(`${time} ${status2} ${botLabel}${event} ${latency}${error}`);
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const convexUrl = getConvexUrl(env);
|
|
98
|
+
const client = createConvexClient(convexUrl);
|
|
99
|
+
const { waitUntilExit } = render_default(/* @__PURE__ */ jsx_dev_runtime.jsxDEV(ConvexProvider, {
|
|
100
|
+
client,
|
|
101
|
+
children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(LogsApp, {
|
|
102
|
+
apiKey,
|
|
103
|
+
botId,
|
|
104
|
+
limit,
|
|
105
|
+
successFilter
|
|
106
|
+
}, undefined, false, undefined, this)
|
|
107
|
+
}, undefined, false, undefined, this));
|
|
108
|
+
await waitUntilExit();
|
|
109
|
+
await client.close();
|
|
110
|
+
}
|
|
111
|
+
export {
|
|
112
|
+
logs
|
|
113
|
+
};
|