@ornncompute/cli 1.0.177 → 1.0.179

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ornncompute/cli",
3
- "version": "1.0.177",
3
+ "version": "1.0.179",
4
4
  "description": "Command-line interface for Ornn compute access workflows.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3449,8 +3449,61 @@ var accessActivateCapability = defineCapability({
3449
3449
  });
3450
3450
  var accessVerbCapabilities = [accessShowCapability, accessActivateCapability];
3451
3451
 
3452
+ // ../../packages/api-client/dist/ledger/index.js
3453
+ function queryString2(input) {
3454
+ const query3 = new URLSearchParams();
3455
+ for (const [key, value] of Object.entries(input)) {
3456
+ if (value === void 0)
3457
+ continue;
3458
+ for (const item of Array.isArray(value) ? value : [value])
3459
+ query3.append(key, String(item));
3460
+ }
3461
+ return query3.size ? `?${query3}` : "";
3462
+ }
3463
+ function listAccounts(request, input = {}, signal) {
3464
+ return request(`/v1/ledger/accounts${queryString2(input)}`, {
3465
+ method: "GET",
3466
+ signal
3467
+ });
3468
+ }
3469
+
3452
3470
  // ../../packages/capabilities/dist/capabilities/credits.js
3453
3471
  import { z as z17 } from "zod";
3472
+
3473
+ // ../../packages/capabilities/dist/credit-balance.js
3474
+ function availableCreditCents(accounts, currency = "usd") {
3475
+ const sum = accounts.filter((row) => row.account.account_role === "ORNN_CREDIT" && row.account.currency === currency).reduce((total, row) => total + Number(row.balance_cents), 0);
3476
+ return Math.max(0, -sum);
3477
+ }
3478
+
3479
+ // ../../packages/capabilities/dist/capabilities/credits.js
3480
+ var creditBalanceCapability = defineCapability({
3481
+ id: "credits.balance",
3482
+ domain: "billing",
3483
+ roles: ["admin"],
3484
+ description: "Read an organization's available Ornn credits in USD cents. Resolve the exact organization with organization_list first; ask if ambiguous. Read-only, no confirmation required. This is not the grant history or card balance.",
3485
+ mutation: "read",
3486
+ mcp: false,
3487
+ slack: {
3488
+ parameters: {
3489
+ type: "object",
3490
+ properties: { organizationId: { type: "string", format: "uuid" } },
3491
+ required: ["organizationId"]
3492
+ }
3493
+ },
3494
+ input: z17.object({ organizationId: z17.uuid() }),
3495
+ execute: async (ctx, input) => {
3496
+ if (ctx.role !== "admin")
3497
+ throw new Error("Admin role required.");
3498
+ const { organizationId } = z17.object({ organizationId: z17.uuid() }).parse(input);
3499
+ const { accounts } = await listAccounts(ctx.fetch, { organization_id: organizationId });
3500
+ return {
3501
+ organizationId,
3502
+ currency: "usd",
3503
+ availableCreditCents: availableCreditCents(accounts)
3504
+ };
3505
+ }
3506
+ });
3454
3507
  var creditGrantInput = z17.object({
3455
3508
  organizationId: z17.uuid().describe("Customer organization UUID. Resolve names or emails with organization_list; ask which organization if matches are ambiguous."),
3456
3509
  adjustmentId: z17.uuid().describe("The credit-adjustment API's required grant UUID. Keep the same UUID when confirming this grant."),