@greenlandai/sdk 0.5.0 → 0.5.2
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.cjs +106 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/core/idempotency.js +5 -0
- package/src/gldai.js +78 -1
- package/src/joulepai.js +12 -0
package/dist/index.cjs
CHANGED
|
@@ -112,6 +112,11 @@ var IDEMPOTENCY_MAP = {
|
|
|
112
112
|
"GET /api/v1/query": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
113
113
|
"GET /api/v1/projects": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
114
114
|
"GET /api/v1/mapdata": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
115
|
+
// metered map/graph read surface (2026-09-14 SDK wrappers — parity with the MCP tools)
|
|
116
|
+
"GET /api/v1/look.from": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
117
|
+
"GET /api/v1/nearby": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
118
|
+
"GET /api/v1/relationships": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
119
|
+
"GET /api/v1/map.viewport": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
115
120
|
// (cf) ENYAL metered GET — joins Class C header class (server reads X-Idempotency-Key per the Option-B switch)
|
|
116
121
|
"GET /api/v1/search": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
117
122
|
// Class D — transfer-class
|
|
@@ -4023,6 +4028,15 @@ var JoulepaiSubmodule = class {
|
|
|
4023
4028
|
{ pathParams: { wid: await this._ensureId() } }
|
|
4024
4029
|
)).balance;
|
|
4025
4030
|
}
|
|
4031
|
+
/** Given a planned `cost` (e.g. a quote's joules_all_in from client.gldai.billingQuote), read a balance
|
|
4032
|
+
* and return { needed, have, shortfall, can_afford } — the SDK twin of the MCP `joules_deficit` tool.
|
|
4033
|
+
* Defaults to the authenticated wallet; pass `walletId` to check a specific wallet (parity with the MCP
|
|
4034
|
+
* joules_deficit(wallet_id, cost) signature). */
|
|
4035
|
+
async deficit(cost, walletId = null) {
|
|
4036
|
+
const have = walletId != null ? (await this._t.request(this._base, "GET", "/wallet/balance/{wid}", { pathParams: { wid: walletId } })).balance : await this.balance();
|
|
4037
|
+
const shortfall = Math.max(0, Number(cost) - Number(have));
|
|
4038
|
+
return { needed: Number(cost), have: Number(have), shortfall, can_afford: shortfall === 0 };
|
|
4039
|
+
}
|
|
4026
4040
|
async info() {
|
|
4027
4041
|
return this._t.request(
|
|
4028
4042
|
this._base,
|
|
@@ -4343,6 +4357,12 @@ var GldaiSubmodule = class {
|
|
|
4343
4357
|
infrastructure(infraId) {
|
|
4344
4358
|
return this._t.request(this._base, "GET", "/api/v1/infrastructure/{iid}", { pathParams: { iid: infraId } });
|
|
4345
4359
|
}
|
|
4360
|
+
/** GET /api/v1/query — the natural-language intelligence query, metered per call (Class C). WORKS FOR
|
|
4361
|
+
* JOULE-METERED AGENTS: they pay per query and are EXEMPT from the human NL access gates (the old
|
|
4362
|
+
* charged-then-403 for agents was fixed; api.py:1414 `_is_joule_agent` bypasses the email-verify /
|
|
4363
|
+
* door / entitlement checks, which apply to human accounts only). Humans need a verified ENYAL
|
|
4364
|
+
* identity + NL access ($10/level). Metered against the CALLING agent's wallet — quote with
|
|
4365
|
+
* billingQuote("/api/v1/query") first. */
|
|
4346
4366
|
query(q, { idempotencyKey, ...params } = {}) {
|
|
4347
4367
|
return this._t.request(this._base, "GET", "/api/v1/query", { params: { q, ...params }, idempotencyKey });
|
|
4348
4368
|
}
|
|
@@ -4355,6 +4375,91 @@ var GldaiSubmodule = class {
|
|
|
4355
4375
|
mapdata({ idempotencyKey, ...params } = {}) {
|
|
4356
4376
|
return this._t.request(this._base, "GET", "/api/v1/mapdata", { params, idempotencyKey });
|
|
4357
4377
|
}
|
|
4378
|
+
// ── pricing + live map/graph read surface (2026-09-14; parity with the MCP tools) ──
|
|
4379
|
+
/** The exact per-caller price of a metered call BEFORE you make it — GET /api/v1/billing/quote. FREE
|
|
4380
|
+
* (no charge), needs only a credential (no verification). `path` = the API path the call would hit
|
|
4381
|
+
* (e.g. "/api/v1/relationships", "/api/v1/look.from", "/api/v1/nearby", "/api/v1/companies/{id}",
|
|
4382
|
+
* "/api/v1/mapdata"); `hops` = graph depth 1-20 for a relationships path. Priced at YOUR tier.
|
|
4383
|
+
* Returns { joules (base), rail_fee_joules, joules_all_in, pricing_tier, usd, … } — joules_all_in is
|
|
4384
|
+
* the TRUE debit (base + the 0.5% rail surcharge), so fund THAT, not the base. Same helper as the MCP
|
|
4385
|
+
* `billing_quote` tool. Metered reads debit the CALLING agent's OWN wallet (not the owner's); read the
|
|
4386
|
+
* balance with client.joulepai.balance() and check affordability with client.joulepai.deficit(). */
|
|
4387
|
+
billingQuote(path, hops = null) {
|
|
4388
|
+
const params = hops == null ? { path } : { path, hops };
|
|
4389
|
+
return this._t.request(this._base, "GET", "/api/v1/billing/quote", { params });
|
|
4390
|
+
}
|
|
4391
|
+
/** GET /api/v1/look.from — companies/infrastructure near a point (lat+lng) or anchored on one entity
|
|
4392
|
+
* (entityType+id). Metered against the CALLING agent's wallet (base + 0.5% rail; quote with
|
|
4393
|
+
* billingQuote). entityType behaves two ways (backend 2026-09-14): entityType ALONE (with lat/lng)
|
|
4394
|
+
* FILTERS the frame to that type; entityType + id ANCHORS the pose at that entity and keeps ALL types;
|
|
4395
|
+
* an unknown entityType is a 400 before any charge. Same as the MCP `look_from` tool. */
|
|
4396
|
+
lookFrom({
|
|
4397
|
+
lat,
|
|
4398
|
+
lng,
|
|
4399
|
+
entityType,
|
|
4400
|
+
id,
|
|
4401
|
+
radiusKm = 100,
|
|
4402
|
+
energy = false,
|
|
4403
|
+
includeCountryCentroids = false,
|
|
4404
|
+
idempotencyKey
|
|
4405
|
+
} = {}) {
|
|
4406
|
+
const params = { radius_km: radiusKm, energy, include_country_centroids: includeCountryCentroids };
|
|
4407
|
+
if (lat != null) params.lat = lat;
|
|
4408
|
+
if (lng != null) params.lng = lng;
|
|
4409
|
+
if (entityType != null) params.entity_type = entityType;
|
|
4410
|
+
if (id != null) params.id = id;
|
|
4411
|
+
return this._t.request(this._base, "GET", "/api/v1/look.from", { params, idempotencyKey });
|
|
4412
|
+
}
|
|
4413
|
+
/** GET /api/v1/nearby — entities near a location; here entityType IS a content filter. Metered against
|
|
4414
|
+
* the CALLING agent's wallet (quote with billingQuote). Same as the MCP `nearby` tool. */
|
|
4415
|
+
nearby({
|
|
4416
|
+
lat,
|
|
4417
|
+
lng,
|
|
4418
|
+
radiusKm = 100,
|
|
4419
|
+
entityType,
|
|
4420
|
+
limit = 20,
|
|
4421
|
+
includeCountryCentroids = false,
|
|
4422
|
+
idempotencyKey
|
|
4423
|
+
} = {}) {
|
|
4424
|
+
const params = { lat, lng, radius_km: radiusKm, limit, include_country_centroids: includeCountryCentroids };
|
|
4425
|
+
if (entityType != null) params.entity_type = entityType;
|
|
4426
|
+
return this._t.request(this._base, "GET", "/api/v1/nearby", { params, idempotencyKey });
|
|
4427
|
+
}
|
|
4428
|
+
/** GET /api/v1/relationships — labelled relationship hops (the MCP `hops` tool). `entity` is the START
|
|
4429
|
+
* NODE, matched as a case-insensitive SUBSTRING of an entity NAME (never an id: "3" matches any name
|
|
4430
|
+
* containing "3"), so pass a full, distinctive name. `hops` = depth 1-10. Metered per hop against the
|
|
4431
|
+
* CALLING agent's wallet (quote with billingQuote("/api/v1/relationships", n)). */
|
|
4432
|
+
relationships({ entity, hops = 1, relationType, search, limit = 50, offset = 0, idempotencyKey } = {}) {
|
|
4433
|
+
const params = { hops, limit, offset };
|
|
4434
|
+
if (entity) params.entity = entity;
|
|
4435
|
+
if (relationType) params.relation_type = relationType;
|
|
4436
|
+
if (search) params.search = search;
|
|
4437
|
+
return this._t.request(this._base, "GET", "/api/v1/relationships", { params, idempotencyKey });
|
|
4438
|
+
}
|
|
4439
|
+
/** GET /api/v1/map.viewport — everything inside a bounding box (THE SCREEN): capped, id-ordered `pins`
|
|
4440
|
+
* + `counts_by_type` (counts are the TRUE totals for the whole bbox; pins are a sample). Params:
|
|
4441
|
+
* minLat/minLng/maxLat/maxLng (the bbox), entityType (deposit|infrastructure|company|project — default
|
|
4442
|
+
* all four), energy (default false), includeCountryCentroids (default false). AGENT KEYS ONLY; metered
|
|
4443
|
+
* against the CALLING agent's wallet (quote with billingQuote); pins do NOT count against your entity
|
|
4444
|
+
* cap. Same as the MCP `map_viewport` tool. Use this — the old /mapdata bulk surface is CLOSED. */
|
|
4445
|
+
mapViewport({
|
|
4446
|
+
minLat,
|
|
4447
|
+
minLng,
|
|
4448
|
+
maxLat,
|
|
4449
|
+
maxLng,
|
|
4450
|
+
entityType,
|
|
4451
|
+
energy = false,
|
|
4452
|
+
includeCountryCentroids = false,
|
|
4453
|
+
idempotencyKey
|
|
4454
|
+
} = {}) {
|
|
4455
|
+
const params = { energy, include_country_centroids: includeCountryCentroids };
|
|
4456
|
+
if (minLat != null) params.min_lat = minLat;
|
|
4457
|
+
if (minLng != null) params.min_lng = minLng;
|
|
4458
|
+
if (maxLat != null) params.max_lat = maxLat;
|
|
4459
|
+
if (maxLng != null) params.max_lng = maxLng;
|
|
4460
|
+
if (entityType != null) params.entity_type = entityType;
|
|
4461
|
+
return this._t.request(this._base, "GET", "/api/v1/map.viewport", { params, idempotencyKey });
|
|
4462
|
+
}
|
|
4358
4463
|
// ── contributor-programme reads (P-DAY.105) ──────────────────────
|
|
4359
4464
|
/** Your Bridge record (session): contribution units at your standing's weight, plus promoted work. */
|
|
4360
4465
|
agentBridge() {
|
|
@@ -4429,7 +4534,7 @@ var GldaiSubmodule = class {
|
|
|
4429
4534
|
};
|
|
4430
4535
|
|
|
4431
4536
|
// index.js
|
|
4432
|
-
var VERSION = "0.5.
|
|
4537
|
+
var VERSION = "0.5.2";
|
|
4433
4538
|
var Client = class {
|
|
4434
4539
|
/**
|
|
4435
4540
|
* @param {object} opts
|
package/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export {
|
|
|
16
16
|
export { ENFORCED, NOT_SUPPORTED, SAFE, IDEMPOTENCY_MAP } from "./src/core/idempotency.js";
|
|
17
17
|
export * as crypto from "./src/core/crypto.js";
|
|
18
18
|
|
|
19
|
-
export const VERSION = "0.5.
|
|
19
|
+
export const VERSION = "0.5.2";
|
|
20
20
|
|
|
21
21
|
export class Client {
|
|
22
22
|
/**
|
package/package.json
CHANGED
package/src/core/idempotency.js
CHANGED
|
@@ -39,6 +39,11 @@ export const IDEMPOTENCY_MAP = {
|
|
|
39
39
|
"GET /api/v1/query": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
40
40
|
"GET /api/v1/projects": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
41
41
|
"GET /api/v1/mapdata": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
42
|
+
// metered map/graph read surface (2026-09-14 SDK wrappers — parity with the MCP tools)
|
|
43
|
+
"GET /api/v1/look.from": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
44
|
+
"GET /api/v1/nearby": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
45
|
+
"GET /api/v1/relationships": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
46
|
+
"GET /api/v1/map.viewport": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
42
47
|
// (cf) ENYAL metered GET — joins Class C header class (server reads X-Idempotency-Key per the Option-B switch)
|
|
43
48
|
"GET /api/v1/search": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
44
49
|
// Class D — transfer-class
|
package/src/gldai.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/** client.gldai — intelligence query surface (design §4.4; enumerated at BUILD
|
|
2
2
|
* 2026-06-10 from api.py route registrations :692-:1221, read-only). Class C
|
|
3
|
-
* metering middleware-side (rate_limiter.py:256 -> joule_metering).
|
|
3
|
+
* metering middleware-side (rate_limiter.py:256 -> joule_metering).
|
|
4
|
+
* Pricing + affordability (helpers, not a pointer — 2026-09-14): a metered call debits
|
|
5
|
+
* the CALLING agent's OWN wallet (not the owner's). Price any call BEFORE you make it
|
|
6
|
+
* with billingQuote(path, hops) — free, returns joules / rail_fee_joules / joules_all_in
|
|
7
|
+
* (the TRUE debit = base + the 0.5% rail surcharge). Read the balance with
|
|
8
|
+
* client.joulepai.balance() and check affordability with client.joulepai.deficit(cost).
|
|
9
|
+
* The live map/graph read surface is wrapped here too — lookFrom, nearby, relationships
|
|
10
|
+
* (the MCP `hops` tool) — alongside companies/deposits/infrastructure/projects/mapdata/
|
|
11
|
+
* query; helper names match the MCP tools. Nothing on this surface is MCP-only. */
|
|
4
12
|
export const GLDAI_BASE = "https://greenlandai.ai";
|
|
5
13
|
|
|
6
14
|
export class GldaiSubmodule {
|
|
@@ -25,6 +33,12 @@ export class GldaiSubmodule {
|
|
|
25
33
|
infrastructure(infraId) {
|
|
26
34
|
return this._t.request(this._base, "GET", "/api/v1/infrastructure/{iid}", { pathParams: { iid: infraId } });
|
|
27
35
|
}
|
|
36
|
+
/** GET /api/v1/query — the natural-language intelligence query, metered per call (Class C). WORKS FOR
|
|
37
|
+
* JOULE-METERED AGENTS: they pay per query and are EXEMPT from the human NL access gates (the old
|
|
38
|
+
* charged-then-403 for agents was fixed; api.py:1414 `_is_joule_agent` bypasses the email-verify /
|
|
39
|
+
* door / entitlement checks, which apply to human accounts only). Humans need a verified ENYAL
|
|
40
|
+
* identity + NL access ($10/level). Metered against the CALLING agent's wallet — quote with
|
|
41
|
+
* billingQuote("/api/v1/query") first. */
|
|
28
42
|
query(q, { idempotencyKey, ...params } = {}) {
|
|
29
43
|
return this._t.request(this._base, "GET", "/api/v1/query", { params: { q, ...params }, idempotencyKey });
|
|
30
44
|
}
|
|
@@ -38,6 +52,69 @@ export class GldaiSubmodule {
|
|
|
38
52
|
return this._t.request(this._base, "GET", "/api/v1/mapdata", { params, idempotencyKey });
|
|
39
53
|
}
|
|
40
54
|
|
|
55
|
+
// ── pricing + live map/graph read surface (2026-09-14; parity with the MCP tools) ──
|
|
56
|
+
/** The exact per-caller price of a metered call BEFORE you make it — GET /api/v1/billing/quote. FREE
|
|
57
|
+
* (no charge), needs only a credential (no verification). `path` = the API path the call would hit
|
|
58
|
+
* (e.g. "/api/v1/relationships", "/api/v1/look.from", "/api/v1/nearby", "/api/v1/companies/{id}",
|
|
59
|
+
* "/api/v1/mapdata"); `hops` = graph depth 1-20 for a relationships path. Priced at YOUR tier.
|
|
60
|
+
* Returns { joules (base), rail_fee_joules, joules_all_in, pricing_tier, usd, … } — joules_all_in is
|
|
61
|
+
* the TRUE debit (base + the 0.5% rail surcharge), so fund THAT, not the base. Same helper as the MCP
|
|
62
|
+
* `billing_quote` tool. Metered reads debit the CALLING agent's OWN wallet (not the owner's); read the
|
|
63
|
+
* balance with client.joulepai.balance() and check affordability with client.joulepai.deficit(). */
|
|
64
|
+
billingQuote(path, hops = null) {
|
|
65
|
+
const params = hops == null ? { path } : { path, hops };
|
|
66
|
+
return this._t.request(this._base, "GET", "/api/v1/billing/quote", { params });
|
|
67
|
+
}
|
|
68
|
+
/** GET /api/v1/look.from — companies/infrastructure near a point (lat+lng) or anchored on one entity
|
|
69
|
+
* (entityType+id). Metered against the CALLING agent's wallet (base + 0.5% rail; quote with
|
|
70
|
+
* billingQuote). entityType behaves two ways (backend 2026-09-14): entityType ALONE (with lat/lng)
|
|
71
|
+
* FILTERS the frame to that type; entityType + id ANCHORS the pose at that entity and keeps ALL types;
|
|
72
|
+
* an unknown entityType is a 400 before any charge. Same as the MCP `look_from` tool. */
|
|
73
|
+
lookFrom({ lat, lng, entityType, id, radiusKm = 100, energy = false,
|
|
74
|
+
includeCountryCentroids = false, idempotencyKey } = {}) {
|
|
75
|
+
const params = { radius_km: radiusKm, energy, include_country_centroids: includeCountryCentroids };
|
|
76
|
+
if (lat != null) params.lat = lat;
|
|
77
|
+
if (lng != null) params.lng = lng;
|
|
78
|
+
if (entityType != null) params.entity_type = entityType;
|
|
79
|
+
if (id != null) params.id = id;
|
|
80
|
+
return this._t.request(this._base, "GET", "/api/v1/look.from", { params, idempotencyKey });
|
|
81
|
+
}
|
|
82
|
+
/** GET /api/v1/nearby — entities near a location; here entityType IS a content filter. Metered against
|
|
83
|
+
* the CALLING agent's wallet (quote with billingQuote). Same as the MCP `nearby` tool. */
|
|
84
|
+
nearby({ lat, lng, radiusKm = 100, entityType, limit = 20,
|
|
85
|
+
includeCountryCentroids = false, idempotencyKey } = {}) {
|
|
86
|
+
const params = { lat, lng, radius_km: radiusKm, limit, include_country_centroids: includeCountryCentroids };
|
|
87
|
+
if (entityType != null) params.entity_type = entityType;
|
|
88
|
+
return this._t.request(this._base, "GET", "/api/v1/nearby", { params, idempotencyKey });
|
|
89
|
+
}
|
|
90
|
+
/** GET /api/v1/relationships — labelled relationship hops (the MCP `hops` tool). `entity` is the START
|
|
91
|
+
* NODE, matched as a case-insensitive SUBSTRING of an entity NAME (never an id: "3" matches any name
|
|
92
|
+
* containing "3"), so pass a full, distinctive name. `hops` = depth 1-10. Metered per hop against the
|
|
93
|
+
* CALLING agent's wallet (quote with billingQuote("/api/v1/relationships", n)). */
|
|
94
|
+
relationships({ entity, hops = 1, relationType, search, limit = 50, offset = 0, idempotencyKey } = {}) {
|
|
95
|
+
const params = { hops, limit, offset };
|
|
96
|
+
if (entity) params.entity = entity;
|
|
97
|
+
if (relationType) params.relation_type = relationType;
|
|
98
|
+
if (search) params.search = search;
|
|
99
|
+
return this._t.request(this._base, "GET", "/api/v1/relationships", { params, idempotencyKey });
|
|
100
|
+
}
|
|
101
|
+
/** GET /api/v1/map.viewport — everything inside a bounding box (THE SCREEN): capped, id-ordered `pins`
|
|
102
|
+
* + `counts_by_type` (counts are the TRUE totals for the whole bbox; pins are a sample). Params:
|
|
103
|
+
* minLat/minLng/maxLat/maxLng (the bbox), entityType (deposit|infrastructure|company|project — default
|
|
104
|
+
* all four), energy (default false), includeCountryCentroids (default false). AGENT KEYS ONLY; metered
|
|
105
|
+
* against the CALLING agent's wallet (quote with billingQuote); pins do NOT count against your entity
|
|
106
|
+
* cap. Same as the MCP `map_viewport` tool. Use this — the old /mapdata bulk surface is CLOSED. */
|
|
107
|
+
mapViewport({ minLat, minLng, maxLat, maxLng, entityType, energy = false,
|
|
108
|
+
includeCountryCentroids = false, idempotencyKey } = {}) {
|
|
109
|
+
const params = { energy, include_country_centroids: includeCountryCentroids };
|
|
110
|
+
if (minLat != null) params.min_lat = minLat;
|
|
111
|
+
if (minLng != null) params.min_lng = minLng;
|
|
112
|
+
if (maxLat != null) params.max_lat = maxLat;
|
|
113
|
+
if (maxLng != null) params.max_lng = maxLng;
|
|
114
|
+
if (entityType != null) params.entity_type = entityType;
|
|
115
|
+
return this._t.request(this._base, "GET", "/api/v1/map.viewport", { params, idempotencyKey });
|
|
116
|
+
}
|
|
117
|
+
|
|
41
118
|
// ── contributor-programme reads (P-DAY.105) ──────────────────────
|
|
42
119
|
/** Your Bridge record (session): contribution units at your standing's weight, plus promoted work. */
|
|
43
120
|
agentBridge() {
|
package/src/joulepai.js
CHANGED
|
@@ -55,6 +55,18 @@ export class JoulepaiSubmodule {
|
|
|
55
55
|
{ pathParams: { wid: await this._ensureId() } })).balance;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/** Given a planned `cost` (e.g. a quote's joules_all_in from client.gldai.billingQuote), read a balance
|
|
59
|
+
* and return { needed, have, shortfall, can_afford } — the SDK twin of the MCP `joules_deficit` tool.
|
|
60
|
+
* Defaults to the authenticated wallet; pass `walletId` to check a specific wallet (parity with the MCP
|
|
61
|
+
* joules_deficit(wallet_id, cost) signature). */
|
|
62
|
+
async deficit(cost, walletId = null) {
|
|
63
|
+
const have = walletId != null
|
|
64
|
+
? (await this._t.request(this._base, "GET", "/wallet/balance/{wid}", { pathParams: { wid: walletId } })).balance
|
|
65
|
+
: await this.balance();
|
|
66
|
+
const shortfall = Math.max(0, Number(cost) - Number(have));
|
|
67
|
+
return { needed: Number(cost), have: Number(have), shortfall, can_afford: shortfall === 0 };
|
|
68
|
+
}
|
|
69
|
+
|
|
58
70
|
async info() {
|
|
59
71
|
return this._t.request(this._base, "GET", "/wallet/balance/{wid}",
|
|
60
72
|
{ pathParams: { wid: await this._ensureId() } });
|