fastclaw-cli 0.3.1 → 0.3.3

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/index.js CHANGED
@@ -434,6 +434,9 @@ var FastClawClient = class {
434
434
  async getBotConnect(id) {
435
435
  return this.request("GET", `/bots/${id}/connect`);
436
436
  }
437
+ async getBotResources(id) {
438
+ return this.request("GET", `/bots/${id}/resources`);
439
+ }
437
440
  async resetBotToken(id) {
438
441
  return this.request("POST", `/bots/${id}/reset-token`);
439
442
  }
@@ -896,6 +899,30 @@ function registerBotCrudCommands(bot) {
896
899
 
897
900
  // src/commands/bot/lifecycle.ts
898
901
  import chalk6 from "chalk";
902
+ function formatCpu(v) {
903
+ if (v.endsWith("n")) {
904
+ const n = parseInt(v, 10);
905
+ const millis = Math.round(n / 1e6);
906
+ if (millis < 1e3) return `${millis}m`;
907
+ return `${(millis / 1e3).toFixed(1)}`;
908
+ }
909
+ return v;
910
+ }
911
+ function formatMem(v) {
912
+ if (v.endsWith("Ki")) {
913
+ const ki = parseInt(v, 10);
914
+ if (ki < 1024) return `${ki}Ki`;
915
+ if (ki < 1024 * 1024) return `${Math.round(ki / 1024)}Mi`;
916
+ return `${(ki / 1024 / 1024).toFixed(1)}Gi`;
917
+ }
918
+ return v;
919
+ }
920
+ function fmtCpu(v) {
921
+ return v ? formatCpu(v) : "-";
922
+ }
923
+ function fmtMem(v) {
924
+ return v ? formatMem(v) : "-";
925
+ }
899
926
  function buildBotUrls(baseUrl, slug, accessToken) {
900
927
  const { hostname } = new URL(baseUrl);
901
928
  const webchatUrl = `https://${slug}.${hostname}#token=${accessToken}`;
@@ -997,6 +1024,29 @@ function registerBotLifecycleCommands(bot) {
997
1024
  }
998
1025
  })
999
1026
  );
1027
+ bot.command("resources <id>").description("Show bot pod resource usage (CPU/memory)").action(
1028
+ withErrorHandler(async (id) => {
1029
+ const { client, cfg } = await resolveClientForBot(bot, id);
1030
+ const res = await client.getBotResources(id);
1031
+ if (cfg.json) {
1032
+ printJson(res);
1033
+ } else {
1034
+ printKeyValue({ "Bot ID": res.bot_id, Pod: res.pod_name });
1035
+ console.log();
1036
+ const headers = ["Container", "CPU Req", "CPU Limit", "CPU Usage", "Mem Req", "Mem Limit", "Mem Usage"];
1037
+ const rows = Object.entries(res.containers).map(([name, c]) => [
1038
+ name,
1039
+ fmtCpu(c.requests?.cpu),
1040
+ fmtCpu(c.limits?.cpu),
1041
+ fmtCpu(c.usage?.cpu),
1042
+ fmtMem(c.requests?.memory),
1043
+ fmtMem(c.limits?.memory),
1044
+ fmtMem(c.usage?.memory)
1045
+ ]);
1046
+ printTable(headers, rows);
1047
+ }
1048
+ })
1049
+ );
1000
1050
  bot.command("reset-token <id>").description("Reset bot access token").action(
1001
1051
  withErrorHandler(async (id) => {
1002
1052
  const { client, cfg } = await resolveClientForBot(bot, id);
package/dist/sdk.d.ts CHANGED
@@ -84,6 +84,20 @@ interface BotConnectResponse {
84
84
  ws_url: string;
85
85
  webchat_url: string;
86
86
  }
87
+ interface ResourceInfo {
88
+ cpu: string;
89
+ memory: string;
90
+ }
91
+ interface ContainerResources {
92
+ requests?: ResourceInfo;
93
+ limits?: ResourceInfo;
94
+ usage?: ResourceInfo;
95
+ }
96
+ interface BotResourcesResponse {
97
+ bot_id: string;
98
+ pod_name: string;
99
+ containers: Record<string, ContainerResources>;
100
+ }
87
101
  interface ResetTokenResponse {
88
102
  id: string;
89
103
  access_token: string;
@@ -235,6 +249,7 @@ declare class FastClawClient {
235
249
  restartBot(id: string): Promise<Bot>;
236
250
  getBotStatus(id: string): Promise<BotStatusResponse>;
237
251
  getBotConnect(id: string): Promise<BotConnectResponse>;
252
+ getBotResources(id: string): Promise<BotResourcesResponse>;
238
253
  resetBotToken(id: string): Promise<ResetTokenResponse>;
239
254
  listProviders(botId: string): Promise<Record<string, ModelProvider>>;
240
255
  addProvider(botId: string, provider: ModelProvider): Promise<ModelProvider>;
@@ -348,4 +363,4 @@ declare function isValidSlug(slug: string): boolean;
348
363
  declare function isValidUrl(url: string): boolean;
349
364
  declare function slugify(name: string): string;
350
365
 
351
- export { API_BASE, type AddChannelRequest, ApiError, type ApiResponse, type App, type Bot, type BotConnectResponse, type BotLogsResponse, type BotStatus, type BotStatusResponse, type BulkUpgradeResponse, CHANNEL_FIELDS, type ChannelResponse, type ChannelsMap, type ClientOptions, type CreateAppRequest, type CreateBotRequest, DEFAULT_URL, DM_POLICIES, type DeviceInfo, type DeviceListResponse, FastClawClient, type FastClawConfig, GROUP_POLICIES, MODEL_PRESETS, type ModelDefaults, type ModelProvider, PROVIDER_DEFAULTS, type PairedUsersResponse, type PairingApproveRequest, type PairingRequest, type PairingRevokeRequest, type ProviderModel, type ResetTokenResponse, type ResolvedConfig, type RuntimeExecRequest, type SetSkillRequest, type SkillInfo, type UpdateAppRequest, type UpdateBotRequest, type UpgradeRequest, type UpgradeResponse, getConfigPath, isValidSlug, isValidUrl, loadConfig, resolveConfig, saveConfig, slugify, updateConfig };
366
+ export { API_BASE, type AddChannelRequest, ApiError, type ApiResponse, type App, type Bot, type BotConnectResponse, type BotLogsResponse, type BotResourcesResponse, type BotStatus, type BotStatusResponse, type BulkUpgradeResponse, CHANNEL_FIELDS, type ChannelResponse, type ChannelsMap, type ClientOptions, type ContainerResources, type CreateAppRequest, type CreateBotRequest, DEFAULT_URL, DM_POLICIES, type DeviceInfo, type DeviceListResponse, FastClawClient, type FastClawConfig, GROUP_POLICIES, MODEL_PRESETS, type ModelDefaults, type ModelProvider, PROVIDER_DEFAULTS, type PairedUsersResponse, type PairingApproveRequest, type PairingRequest, type PairingRevokeRequest, type ProviderModel, type ResetTokenResponse, type ResolvedConfig, type ResourceInfo, type RuntimeExecRequest, type SetSkillRequest, type SkillInfo, type UpdateAppRequest, type UpdateBotRequest, type UpgradeRequest, type UpgradeResponse, getConfigPath, isValidSlug, isValidUrl, loadConfig, resolveConfig, saveConfig, slugify, updateConfig };
package/dist/sdk.js CHANGED
@@ -240,6 +240,9 @@ var FastClawClient = class {
240
240
  async getBotConnect(id) {
241
241
  return this.request("GET", `/bots/${id}/connect`);
242
242
  }
243
+ async getBotResources(id) {
244
+ return this.request("GET", `/bots/${id}/resources`);
245
+ }
243
246
  async resetBotToken(id) {
244
247
  return this.request("POST", `/bots/${id}/reset-token`);
245
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastclaw-cli",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "CLI and SDK for managing FastClaw bots",
5
5
  "type": "module",
6
6
  "main": "dist/sdk.js",