@hanzo/build 0.2.119 → 0.2.120

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.
@@ -134,6 +134,12 @@ export declare function invoices(t: Target): Promise<Invoice[]>;
134
134
  export declare function pdf(t: Target, id: string): Promise<Blob>;
135
135
  /** What the org can still spend from its prepaid balance, in cents. */
136
136
  export declare function balance(t: Target): Promise<number>;
137
+ /**
138
+ * What can pay for another maker's models, whole cents: cash and the credit line, never
139
+ * granted credit (`GET /v1/billing/balance` `prepaid`). Null where the answer carries no
140
+ * such figure, so a caller does not assume it.
141
+ */
142
+ export declare function prepaid(t: Target): Promise<number | null>;
137
143
  /** Granted credit the org can spend, in US cents. */
138
144
  export declare function credit(t: Target): Promise<number>;
139
145
  /** One grant of credit, spent, lapsed and voided included: the ledger, not the spendable figure. */
@@ -252,6 +252,15 @@ export async function balance(t) {
252
252
  const b = obj(await call(t, 'GET', '/v1/billing/balance'));
253
253
  return num(b.available ?? b.balance);
254
254
  }
255
+ /**
256
+ * What can pay for another maker's models, whole cents: cash and the credit line, never
257
+ * granted credit (`GET /v1/billing/balance` `prepaid`). Null where the answer carries no
258
+ * such figure, so a caller does not assume it.
259
+ */
260
+ export async function prepaid(t) {
261
+ const b = obj(await call(t, 'GET', '/v1/billing/balance'));
262
+ return typeof b.prepaid === 'number' && Number.isFinite(b.prepaid) ? b.prepaid : null;
263
+ }
255
264
  /** Granted credit the org can spend, in US cents. */
256
265
  export async function credit(t) {
257
266
  const raw = obj(await call(t, 'GET', '/v1/billing/credit-balance'));
package/lib/mind.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { EFFORTS as EVERY } from '@hanzo/ui/chat/pure';
2
2
  import { parseModels, thirdParty } from '@hanzo/ui/models/catalog';
3
3
  import { useEffect, useState, useSyncExternalStore } from 'react';
4
- import { balance as readBalance } from './api/billing.js';
4
+ import { prepaid as readPrepaid } from './api/billing.js';
5
5
  import { Refusal } from './api/call.js';
6
6
  import { ENSO, models as read } from './api/models.js';
7
7
  import { usePick } from './pick.js';
@@ -187,14 +187,14 @@ export function sendable(free, models, cents, id) {
187
187
  }
188
188
  /** The effort as the composer reads it: the one in force, its list, and the way to change it. */
189
189
  export const pacing = (m) => ({ value: m.effort, set: m.pace, items: EFFORTS });
190
- /** The prepaid balance in cents for a signed-in target, read once; null until it is, and where it could not be read. */
190
+ /** The prepaid balance in cents that can pay for another maker's models, for a signed-in target, read once; null until it is, and where the API does not say. */
191
191
  function useBalance(t, on) {
192
192
  const [cents, set] = useState(null);
193
193
  useEffect(() => {
194
194
  if (!on || !t.token())
195
195
  return;
196
196
  let live = true;
197
- readBalance(t).then((n) => live && set(n), () => live && set(null));
197
+ readPrepaid(t).then((n) => live && set(n), () => live && set(null));
198
198
  return () => {
199
199
  live = false;
200
200
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/build",
3
- "version": "0.2.119",
3
+ "version": "0.2.120",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "description": "Hanzo Build — say what you want, watch it built, deployed and running. The builder as a component, mounted by the Hanzo app at hanzo.ai.",