@madewithremy/admin 0.1.53 → 0.1.55

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/prod.js CHANGED
@@ -1034,7 +1034,7 @@ async function primaryUrl(ctx) {
1034
1034
  return dashboard.primaryUrl;
1035
1035
  }
1036
1036
  function summarizeRelease(release) {
1037
- const summary2 = {
1037
+ const summary4 = {
1038
1038
  releaseId: release.id,
1039
1039
  commitSha: release.commitSha,
1040
1040
  branch: release.branch ?? null,
@@ -1046,16 +1046,16 @@ function summarizeRelease(release) {
1046
1046
  };
1047
1047
  const readers = (release.dataSources ?? []).filter((d) => d.reader);
1048
1048
  if (readers.length > 0 && release.status === "live") {
1049
- summary2.readers = readers.map((d) => ({
1049
+ summary4.readers = readers.map((d) => ({
1050
1050
  slug: d.slug,
1051
1051
  unread: d.readerUnread ?? 0
1052
1052
  }));
1053
1053
  }
1054
1054
  if (release.status !== "failed") {
1055
- return summary2;
1055
+ return summary4;
1056
1056
  }
1057
1057
  return {
1058
- ...summary2,
1058
+ ...summary4,
1059
1059
  error: release.failureReason ?? "Build failed (no error entry in the build log)",
1060
1060
  ...release.failureKind ? { failureKind: release.failureKind } : {},
1061
1061
  ...release.failurePhase ? { failurePhase: release.failurePhase } : {}
@@ -4476,10 +4476,10 @@ function failOnWait(result) {
4476
4476
  );
4477
4477
  }
4478
4478
  }
4479
- async function waitAndReport(ctx, a, id, mode, summary2) {
4479
+ async function waitAndReport(ctx, a, id, mode, summary4) {
4480
4480
  const wait = mode === "plan" ? waitForPlan : waitForJob;
4481
4481
  const result = await wait(ctx, { id, ...timeoutOf(a), onProgress: progress });
4482
- out({ ...summary2, ...result });
4482
+ out({ ...summary4, ...result });
4483
4483
  failOnWait(result);
4484
4484
  }
4485
4485
 
@@ -7807,6 +7807,60 @@ Examples:
7807
7807
  remy-admin tasks list --limit 10
7808
7808
  remy-admin tasks get 0b9e\u2026`;
7809
7809
 
7810
+ // src/ops/usage.ts
7811
+ function summary2(ctx, params) {
7812
+ return call(
7813
+ ctx,
7814
+ "GET",
7815
+ `/_internal/v2/apps/${ctx.appId}/usage/summary${qs(params)}`
7816
+ );
7817
+ }
7818
+
7819
+ // src/commands/usage.ts
7820
+ var DEFAULT_WINDOW_MS = 30 * 24 * 60 * 60 * 1e3;
7821
+ var usageSpecs = {
7822
+ "usage summary": {
7823
+ usage: "Usage: remy-admin usage summary [--start <iso>] [--end <iso>] [--by method|model|step]",
7824
+ flags: {
7825
+ ...WINDOW,
7826
+ by: { type: "string", choices: ["method", "model", "step"] }
7827
+ }
7828
+ }
7829
+ };
7830
+ async function summary3(ctx, a) {
7831
+ const end = a.str("end") ?? (/* @__PURE__ */ new Date()).toISOString();
7832
+ const start2 = a.str("start") ?? new Date(new Date(end).getTime() - DEFAULT_WINDOW_MS).toISOString();
7833
+ out(
7834
+ await summary2(ctx, {
7835
+ startTime: start2,
7836
+ endTime: end,
7837
+ groupBy: a.str("by")
7838
+ })
7839
+ );
7840
+ }
7841
+ var usageHandlers = {
7842
+ "usage summary": summary3
7843
+ };
7844
+ var usageHelp = `remy-admin usage \u2014 What the app costs to run.
7845
+
7846
+ Subcommands:
7847
+ summary The app's runtime spend over a window, broken down one way
7848
+
7849
+ Usage:
7850
+ remy-admin usage summary [--start <iso>] [--end <iso>] [--by method|model|step]
7851
+
7852
+ Notes:
7853
+ Costs are in dollars. Your own work on the app isn't counted: building it,
7854
+ testing it in the sandbox, and its security assessments.
7855
+ --by method (the default) is the spend each method drove, model the models'
7856
+ share, step the whole spend by action, models and everything else. The window
7857
+ defaults to the 30 days before --end, and --end to now. An app's own method
7858
+ can read this with the 'usage.view' admin permission.
7859
+
7860
+ Examples:
7861
+ remy-admin usage summary
7862
+ remy-admin usage summary --by model --start 2026-10-01T00:00:00Z`;
7863
+
7810
7864
  // src/ops/events.ts
7811
7865
  function channelsList(ctx, params = {}) {
7812
7866
  return call(
@@ -9457,7 +9511,7 @@ var infraSpecs = {
9457
9511
  }
9458
9512
  }
9459
9513
  };
9460
- async function waitAndReport2(ctx, a, id, phases, summary2, until) {
9514
+ async function waitAndReport2(ctx, a, id, phases, summary4, until) {
9461
9515
  const timeoutSec = a.str("timeout");
9462
9516
  const result = await waitForPhase(ctx, {
9463
9517
  id,
@@ -9466,7 +9520,7 @@ async function waitAndReport2(ctx, a, id, phases, summary2, until) {
9466
9520
  ...timeoutSec ? { timeoutMs: Number(timeoutSec) * 1e3 } : {},
9467
9521
  onProgress: progress
9468
9522
  });
9469
- out({ ...summary2, ...result });
9523
+ out({ ...summary4, ...result });
9470
9524
  if (result.status === "failed") {
9471
9525
  throw new CliError(result.error, EXIT.buildFailed);
9472
9526
  }
@@ -9980,6 +10034,7 @@ var SPECS = {
9980
10034
  ...voiceSpecs,
9981
10035
  ...agentSpecs,
9982
10036
  ...tasksSpecs,
10037
+ ...usageSpecs,
9983
10038
  ...eventsSpecs,
9984
10039
  ...jewelsSpecs,
9985
10040
  ...settingsSpecs,
@@ -10016,6 +10071,7 @@ var HANDLERS = {
10016
10071
  ...voiceHandlers,
10017
10072
  ...agentHandlers,
10018
10073
  ...tasksHandlers,
10074
+ ...usageHandlers,
10019
10075
  ...eventsHandlers,
10020
10076
  ...jewelsHandlers,
10021
10077
  ...settingsHandlers,
@@ -10046,6 +10102,7 @@ var GROUP_HELP = {
10046
10102
  voice: voiceHelp,
10047
10103
  agent: agentHelp,
10048
10104
  tasks: tasksHelp,
10105
+ usage: usageHelp,
10049
10106
  events: eventsHelp,
10050
10107
  jewels: jewelsHelp,
10051
10108
  settings: settingsHelp,
@@ -10133,6 +10190,7 @@ Commands:
10133
10190
  voice Phone numbers, voice call log + transcripts, voice policy settings
10134
10191
  agent Agent (chat) conversation log + transcripts
10135
10192
  tasks Task agent (runTask) log + transcripts
10193
+ usage What the app costs to run, by method, model or step
10136
10194
  events Realtime events \u2014 live tail, test publish, channel activity
10137
10195
  jewels Monitor jewel shadowing; review + approve the proposal queue
10138
10196
  settings App settings \u2014 signup allowlist, test accounts, embed origins, toggles
@@ -10149,7 +10207,18 @@ with a dash, use --name=value; to pass a positional beginning with a dash, put
10149
10207
  -- before it.
10150
10208
 
10151
10209
  All output is JSON. Configuration is read from environment variables
10152
- (MINDSTUDIO_API_KEY, MINDSTUDIO_BASE_URL) and mindstudio.json (appId).`;
10210
+ (MINDSTUDIO_API_KEY, MINDSTUDIO_BASE_URL) and mindstudio.json (appId).
10211
+
10212
+ From an app's own method, the same operations run through the import layer
10213
+ with no key: createAdminClient() in the method acts on its own app, as the
10214
+ method's run, for what the method's "adminPermissions" in mindstudio.json
10215
+ allow. analytics.view, usage.view, requests.view (requests, crashes),
10216
+ agent.view, tasks.view, voice.view|manage, users.view|manage (live runs only),
10217
+ settings.manage, email.view|manage, domains.manage (custom domains, the
10218
+ subdomain), issues.view|manage, datasources.manage, cron.view|manage,
10219
+ releases.view. A .manage includes its .view. A call the method doesn't hold is
10220
+ admin_permission_required:<name>; another app is app_credential_wrong_app and
10221
+ needs a key. The full list and rules are createAdminClient's docs.`;
10153
10222
  var GROUPS = [
10154
10223
  "requests",
10155
10224
  "crashes",
@@ -10171,6 +10240,7 @@ var GROUPS = [
10171
10240
  "voice",
10172
10241
  "agent",
10173
10242
  "tasks",
10243
+ "usage",
10174
10244
  "events",
10175
10245
  "jewels",
10176
10246
  "settings",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madewithremy/admin",
3
- "version": "0.1.53",
3
+ "version": "0.1.55",
4
4
  "description": "Admin SDK + CLI for managing production Remy apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,6 +53,14 @@
53
53
  "dependencies": {
54
54
  "json5": "^2.2.3"
55
55
  },
56
+ "peerDependencies": {
57
+ "@mindstudio-ai/agent": ">=0.1.46"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "@mindstudio-ai/agent": {
61
+ "optional": true
62
+ }
63
+ },
56
64
  "devDependencies": {
57
65
  "@types/node": "^26.6.5",
58
66
  "@typescript/native": "npm:typescript@^7.0.2",