@greenlandai/sdk 0.5.1 → 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 CHANGED
@@ -116,6 +116,7 @@ var IDEMPOTENCY_MAP = {
116
116
  "GET /api/v1/look.from": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
117
117
  "GET /api/v1/nearby": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
118
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 },
119
120
  // (cf) ENYAL metered GET — joins Class C header class (server reads X-Idempotency-Key per the Option-B switch)
120
121
  "GET /api/v1/search": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
121
122
  // Class D — transfer-class
@@ -4027,11 +4028,12 @@ var JoulepaiSubmodule = class {
4027
4028
  { pathParams: { wid: await this._ensureId() } }
4028
4029
  )).balance;
4029
4030
  }
4030
- /** Given a planned `cost` (e.g. a quote's joules_all_in from client.gldai.billingQuote), read your OWN
4031
- * balance and return { needed, have, shortfall, can_afford } — the SDK twin of the MCP `joules_deficit`
4032
- * tool. Reads the authenticated wallet; no walletId needed. */
4033
- async deficit(cost) {
4034
- const have = await this.balance();
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();
4035
4037
  const shortfall = Math.max(0, Number(cost) - Number(have));
4036
4038
  return { needed: Number(cost), have: Number(have), shortfall, can_afford: shortfall === 0 };
4037
4039
  }
@@ -4388,8 +4390,9 @@ var GldaiSubmodule = class {
4388
4390
  }
4389
4391
  /** GET /api/v1/look.from — companies/infrastructure near a point (lat+lng) or anchored on one entity
4390
4392
  * (entityType+id). Metered against the CALLING agent's wallet (base + 0.5% rail; quote with
4391
- * billingQuote). NOTE: entityType here is a POSE-ANCHOR used with id, NOT a content filter — for
4392
- * type-filtered results use nearby(). Same as the MCP `look_from` tool. */
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. */
4393
4396
  lookFrom({
4394
4397
  lat,
4395
4398
  lng,
@@ -4433,6 +4436,30 @@ var GldaiSubmodule = class {
4433
4436
  if (search) params.search = search;
4434
4437
  return this._t.request(this._base, "GET", "/api/v1/relationships", { params, idempotencyKey });
4435
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
+ }
4436
4463
  // ── contributor-programme reads (P-DAY.105) ──────────────────────
4437
4464
  /** Your Bridge record (session): contribution units at your standing's weight, plus promoted work. */
4438
4465
  agentBridge() {
@@ -4507,7 +4534,7 @@ var GldaiSubmodule = class {
4507
4534
  };
4508
4535
 
4509
4536
  // index.js
4510
- var VERSION = "0.5.1";
4537
+ var VERSION = "0.5.2";
4511
4538
  var Client = class {
4512
4539
  /**
4513
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.1";
19
+ export const VERSION = "0.5.2";
20
20
 
21
21
  export class Client {
22
22
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greenlandai/sdk",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Unified SDK for the GreenlandAI ecosystem (ENYAL, JoulePAI, RAREEAI, GreenlandAI)",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://enyal.ai",
@@ -43,6 +43,7 @@ export const IDEMPOTENCY_MAP = {
43
43
  "GET /api/v1/look.from": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
44
44
  "GET /api/v1/nearby": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
45
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 },
46
47
  // (cf) ENYAL metered GET — joins Class C header class (server reads X-Idempotency-Key per the Option-B switch)
47
48
  "GET /api/v1/search": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
48
49
  // Class D — transfer-class
package/src/gldai.js CHANGED
@@ -67,8 +67,9 @@ export class GldaiSubmodule {
67
67
  }
68
68
  /** GET /api/v1/look.from — companies/infrastructure near a point (lat+lng) or anchored on one entity
69
69
  * (entityType+id). Metered against the CALLING agent's wallet (base + 0.5% rail; quote with
70
- * billingQuote). NOTE: entityType here is a POSE-ANCHOR used with id, NOT a content filter — for
71
- * type-filtered results use nearby(). Same as the MCP `look_from` tool. */
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. */
72
73
  lookFrom({ lat, lng, entityType, id, radiusKm = 100, energy = false,
73
74
  includeCountryCentroids = false, idempotencyKey } = {}) {
74
75
  const params = { radius_km: radiusKm, energy, include_country_centroids: includeCountryCentroids };
@@ -97,6 +98,22 @@ export class GldaiSubmodule {
97
98
  if (search) params.search = search;
98
99
  return this._t.request(this._base, "GET", "/api/v1/relationships", { params, idempotencyKey });
99
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
+ }
100
117
 
101
118
  // ── contributor-programme reads (P-DAY.105) ──────────────────────
102
119
  /** Your Bridge record (session): contribution units at your standing's weight, plus promoted work. */
package/src/joulepai.js CHANGED
@@ -55,11 +55,14 @@ 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 your OWN
59
- * balance and return { needed, have, shortfall, can_afford } — the SDK twin of the MCP `joules_deficit`
60
- * tool. Reads the authenticated wallet; no walletId needed. */
61
- async deficit(cost) {
62
- const have = await this.balance();
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();
63
66
  const shortfall = Math.max(0, Number(cost) - Number(have));
64
67
  return { needed: Number(cost), have: Number(have), shortfall, can_afford: shortfall === 0 };
65
68
  }