@greenlandai/sdk 0.5.3 → 0.5.4

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
@@ -117,6 +117,7 @@ var IDEMPOTENCY_MAP = {
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
119
  "GET /api/v1/map.viewport": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
120
+ "GET /api/v1/look.at": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
120
121
  // (cf) ENYAL metered GET — joins Class C header class (server reads X-Idempotency-Key per the Option-B switch)
121
122
  "GET /api/v1/search": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
122
123
  // Class D — transfer-class
@@ -218,7 +219,9 @@ var Transport = class {
218
219
  params = null,
219
220
  idempotencyKey = null,
220
221
  retry = true,
221
- maxRetries = DEFAULT_MAX_RETRIES
222
+ maxRetries = DEFAULT_MAX_RETRIES,
223
+ accept = null,
224
+ raw = false
222
225
  } = {}) {
223
226
  let headers = this._isApiKey ? { "X-API-Key": this._credential } : { Authorization: `Bearer ${this._credential}` };
224
227
  const d = dispatch(method, pathTemplate, body, headers, idempotencyKey);
@@ -238,7 +241,7 @@ var Transport = class {
238
241
  const t0 = Date.now();
239
242
  for (; ; ) {
240
243
  try {
241
- const result = await this._once(method, url, headers, body);
244
+ const result = await this._once(method, url, headers, body, { accept, raw });
242
245
  this._count("sdk.requests");
243
246
  this._hist("sdk.request.duration", (Date.now() - t0) / 1e3);
244
247
  if (result && result.duplicate === true) {
@@ -263,7 +266,7 @@ var Transport = class {
263
266
  }
264
267
  }
265
268
  }
266
- async _once(method, url, headers, body) {
269
+ async _once(method, url, headers, body, { accept = null, raw = false } = {}) {
267
270
  const redacted = { ...headers };
268
271
  if ("Authorization" in redacted) redacted.Authorization = "[REDACTED]";
269
272
  if ("X-API-Key" in redacted) redacted["X-API-Key"] = "[REDACTED]";
@@ -271,6 +274,7 @@ var Transport = class {
271
274
  let resp;
272
275
  try {
273
276
  const opts2 = { method, headers: { ...headers } };
277
+ if (accept) opts2.headers["Accept"] = accept;
274
278
  if (body != null) {
275
279
  opts2.headers["Content-Type"] = "application/json";
276
280
  opts2.body = JSON.stringify(body);
@@ -293,6 +297,16 @@ var Transport = class {
293
297
  if (typeof detail === "object") detail = JSON.stringify(detail);
294
298
  throw errorForStatus(resp.status, String(detail), requestId, retryAfter);
295
299
  }
300
+ if (raw) {
301
+ const ct = resp.headers?.get ? resp.headers.get("content-type") || "" : "";
302
+ if (ct.startsWith("application/json")) return resp.json();
303
+ const buf = await resp.arrayBuffer();
304
+ const provenance = {};
305
+ if (resp.headers?.forEach) resp.headers.forEach((v, k) => {
306
+ if (k.toLowerCase().startsWith("x-")) provenance[k] = v;
307
+ });
308
+ return { _raw: true, content_type: ct, content: new Uint8Array(buf), provenance };
309
+ }
296
310
  if (resp.status === 204) return null;
297
311
  return resp.json();
298
312
  }
@@ -4014,6 +4028,9 @@ var GldaiSubmodule = class {
4014
4028
  project(projectId) {
4015
4029
  return this._t.request(this._base, "GET", "/api/v1/projects/{pid}", { pathParams: { pid: projectId } });
4016
4030
  }
4031
+ /** CLOSED — do NOT call. GET /api/v1/mapdata (the bulk map-layers surface) is closed to all callers and
4032
+ * returns an error. Use mapViewport() for map reads. Kept only so the method still resolves for older
4033
+ * callers. Matches the MCP `mapdata` tool (also marked CLOSED). */
4017
4034
  mapdata({ idempotencyKey, ...params } = {}) {
4018
4035
  return this._t.request(this._base, "GET", "/api/v1/mapdata", { params, idempotencyKey });
4019
4036
  }
@@ -4021,7 +4038,8 @@ var GldaiSubmodule = class {
4021
4038
  /** The exact per-caller price of a metered call BEFORE you make it — GET /api/v1/billing/quote. FREE
4022
4039
  * (no charge), needs only a credential (no verification). `path` = the API path the call would hit
4023
4040
  * (e.g. "/api/v1/relationships", "/api/v1/look.from", "/api/v1/nearby", "/api/v1/companies/{id}",
4024
- * "/api/v1/mapdata"); `hops` = graph depth 1-20 for a relationships path. Priced at YOUR tier.
4041
+ * "/api/v1/mapdata"); `hops` = graph depth 1-10 (your tier caps it — Pioneer/FC 3, TEN/Pro 5,
4042
+ * Enterprise 10) for a relationships path. Priced at YOUR tier.
4025
4043
  * Returns { joules (base), rail_fee_joules, joules_all_in, pricing_tier, usd, … } — joules_all_in is
4026
4044
  * the TRUE debit (base + the 0.5% rail surcharge), so fund THAT, not the base. Same helper as the MCP
4027
4045
  * `billing_quote` tool. Metered reads debit the CALLING agent's OWN wallet (not the owner's); read the
@@ -4102,6 +4120,40 @@ var GldaiSubmodule = class {
4102
4120
  if (entityType != null) params.entity_type = entityType;
4103
4121
  return this._t.request(this._base, "GET", "/api/v1/map.viewport", { params, idempotencyKey });
4104
4122
  }
4123
+ /** GET /api/v1/look.at — a Sentinel-2 satellite STILL of a point (lat+lng) or an entity (entityType+id).
4124
+ * AGENT KEYS ONLY (a browser session or plain developer key is refused before any charge). Metered
4125
+ * against the CALLING agent's wallet — its own price line (~150 J; quote with
4126
+ * billingQuote("/api/v1/look.at")). On a hit returns { available: true, content_type: "image/jpeg",
4127
+ * image_jpeg: Uint8Array, provenance: { X-* headers — scene date, source, … } }; on a cloudy/missing
4128
+ * scene a { available: false, … } object (the charge is refunded server-side). Same as the MCP
4129
+ * `look_at` tool. */
4130
+ async lookAt({ lat, lng, entityType, id, idempotencyKey } = {}) {
4131
+ const params = {};
4132
+ if (lat != null) params.lat = lat;
4133
+ if (lng != null) params.lng = lng;
4134
+ if (entityType != null) params.entity_type = entityType;
4135
+ if (id != null) params.id = id;
4136
+ const r = await this._t.request(
4137
+ this._base,
4138
+ "GET",
4139
+ "/api/v1/look.at",
4140
+ { params, idempotencyKey, accept: "image/jpeg, application/json", raw: true }
4141
+ );
4142
+ if (r && r._raw) {
4143
+ return { available: true, content_type: r.content_type, image_jpeg: r.content, provenance: r.provenance || {} };
4144
+ }
4145
+ return r;
4146
+ }
4147
+ /** YOUR OWN metered-read charge record — GET /api/v1/billing/attempts. Own wallet only (from your
4148
+ * credential, never a parameter). FREE. Each attempt shows reserved vs settled joules so you can verify
4149
+ * your bill without asking us (settle_dead_end = nothing moved — a 4xx/5xx or refused reservation;
4150
+ * settle_failed = delivered but unsettled). Parity with the MCP `billing_attempts` tool. */
4151
+ billingAttempts({ limit, offset } = {}) {
4152
+ const params = {};
4153
+ if (limit != null) params.limit = limit;
4154
+ if (offset != null) params.offset = offset;
4155
+ return this._t.request(this._base, "GET", "/api/v1/billing/attempts", { params });
4156
+ }
4105
4157
  // ── contributor-programme reads (P-DAY.105) ──────────────────────
4106
4158
  /** Your Bridge record (session): contribution units at your standing's weight, plus promoted work. */
4107
4159
  agentBridge() {
@@ -4219,7 +4271,11 @@ var JoulepaiSubmodule = class {
4219
4271
  transferStatus(transferId) {
4220
4272
  return this._t.request(this._base, "GET", "/wallet/transfer/{tid}/status", { pathParams: { tid: transferId } });
4221
4273
  }
4222
- /** Absorbs fund() (index.js:152). NOT retry-safe (G1 demotion — duplicate Stripe sessions). */
4274
+ /** FIAT/CARD funding — POST /wallet/fund. method="stripe" returns a Stripe Checkout URL for a human to
4275
+ * complete (card; 3.5% markup; amountFiat 10-100). The backend also accepts method="usdc" (1% markup),
4276
+ * but the IN-BAND AGENT USDC rail is the deposit-address flow, NOT this endpoint: an agent funds by
4277
+ * depositing USDC to its own Base address — use fundingPrepare() for the address + live availability and
4278
+ * depositStatus() to track the credit. NOT retry-safe (G1 demotion — duplicate Stripe sessions). */
4223
4279
  async fund(amountFiat, { method = "stripe" } = {}) {
4224
4280
  return this._t.request(
4225
4281
  this._base,
@@ -4314,6 +4370,47 @@ var JoulepaiSubmodule = class {
4314
4370
  fundingStatus(fundingEventId) {
4315
4371
  return this._t.request(this._base, "GET", "/wallet/fund/{fid}", { pathParams: { fid: fundingEventId } });
4316
4372
  }
4373
+ /** YOUR OWN USDC-on-Base deposit state — GET /wallet/deposit-status. Own wallet only (from your token,
4374
+ * never a parameter). Read-only, free. Returns { usdc_live, scanner_cursor_block, minimum_usdc,
4375
+ * deposits[], held_below_min_total_usdc, needed_to_credit_usdc, note }; each deposit carries { tx_hash,
4376
+ * block_number, usdc_amount, status, joules_credited, fee_taken, created_at, meaning }. A deposit whose
4377
+ * block_number is ABOVE scanner_cursor_block has not been reached yet (normal lag), not lost. 503 when
4378
+ * USDC-on-Base is not live. Parity with the MCP `deposit_status` tool. */
4379
+ depositStatus() {
4380
+ return this._t.request(this._base, "GET", "/wallet/deposit-status", {});
4381
+ }
4382
+ /** The in-band funding step for a joule shortfall — NEVER a URL to visit (operator lock). USDC on Base is
4383
+ * the live agent-fundable rail: deposit USDC to your own Base address (min 5 USDC — the authoritative
4384
+ * value is depositStatus().minimum_usdc), credited automatically when the scanner sees it (track with
4385
+ * depositStatus()). Card funding stays a human web flow. Availability is read LIVE (relays your
4386
+ * deposit-address) so it never reports stale state; it does not itself move money. Parity with the MCP
4387
+ * `funding_prepare` tool. Returns { needed, in_band_agent_funding_live, routes, note }. */
4388
+ async fundingPrepare(needed = 0) {
4389
+ let live = true, address = null;
4390
+ try {
4391
+ const addr = await this.depositAddress();
4392
+ address = addr && typeof addr === "object" ? addr.address ?? null : null;
4393
+ } catch (err) {
4394
+ if (err instanceof GreenlandAIError) {
4395
+ live = false;
4396
+ address = null;
4397
+ } else throw err;
4398
+ }
4399
+ return {
4400
+ needed: Number(needed),
4401
+ in_band_agent_funding_live: live,
4402
+ routes: {
4403
+ usdc_on_base: {
4404
+ status: live ? "live" : "not_live",
4405
+ deposit_address: address,
4406
+ minimum_usdc: 5,
4407
+ note: live ? "deposit USDC to this Base address; credited automatically within the scanner window; check with depositStatus()" : "no in-band USDC address for this credential right now \u2014 authenticate with your wallet credential, or fund with card meanwhile"
4408
+ },
4409
+ card_stripe: { status: "human_web_only", note: "not an agent/in-band path" }
4410
+ },
4411
+ note: live ? "USDC on Base is live \u2014 deposit to your Base address above (min 5 USDC), credited automatically; track it with depositStatus(). Do not follow a URL to fund." : "No in-band USDC address available for this credential; fund with card meanwhile. Do not follow a URL to fund."
4412
+ };
4413
+ }
4317
4414
  resetCredentials(walletId, email) {
4318
4415
  return this._t.request(
4319
4416
  this._base,
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@greenlandai/sdk",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Unified SDK for the GreenlandAI ecosystem (ENYAL, JoulePAI, RAREEAI, GreenlandAI)",
5
5
  "license": "Apache-2.0",
6
- "homepage": "https://enyal.ai",
6
+ "homepage": "https://greenlandai.ai",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -44,6 +44,7 @@ export const IDEMPOTENCY_MAP = {
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
46
  "GET /api/v1/map.viewport": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
47
+ "GET /api/v1/look.at": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
47
48
  // (cf) ENYAL metered GET — joins Class C header class (server reads X-Idempotency-Key per the Option-B switch)
48
49
  "GET /api/v1/search": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
49
50
  // Class D — transfer-class
@@ -61,7 +61,8 @@ export class Transport {
61
61
  async request(baseUrl, method, pathTemplate,
62
62
  { pathParams = {}, body = null, params = null,
63
63
  idempotencyKey = null, retry = true,
64
- maxRetries = DEFAULT_MAX_RETRIES } = {}) {
64
+ maxRetries = DEFAULT_MAX_RETRIES,
65
+ accept = null, raw = false } = {}) {
65
66
  // Auth header by parameter (X-API-Key for apiKey incl. eyl_/gai_; Bearer for an OAuth JWT).
66
67
  // See docs/canonical/security-policy.md (X-API-Key > Bearer > cookie).
67
68
  let headers = this._isApiKey
@@ -84,7 +85,7 @@ export class Transport {
84
85
  const t0 = Date.now();
85
86
  for (;;) {
86
87
  try {
87
- const result = await this._once(method, url, headers, body);
88
+ const result = await this._once(method, url, headers, body, { accept, raw });
88
89
  this._count("sdk.requests"); this._hist("sdk.request.duration", (Date.now() - t0) / 1000);
89
90
  if (result && result.duplicate === true) {
90
91
  this._count("sdk.duplicates");
@@ -110,7 +111,7 @@ export class Transport {
110
111
  }
111
112
  }
112
113
 
113
- async _once(method, url, headers, body) {
114
+ async _once(method, url, headers, body, { accept = null, raw = false } = {}) {
114
115
  const redacted = { ...headers };
115
116
  if ("Authorization" in redacted) redacted.Authorization = "[REDACTED]";
116
117
  if ("X-API-Key" in redacted) redacted["X-API-Key"] = "[REDACTED]";
@@ -118,6 +119,7 @@ export class Transport {
118
119
  let resp;
119
120
  try {
120
121
  const opts = { method, headers: { ...headers } };
122
+ if (accept) opts.headers["Accept"] = accept;
121
123
  if (body != null) {
122
124
  opts.headers["Content-Type"] = "application/json";
123
125
  opts.body = JSON.stringify(body);
@@ -136,6 +138,17 @@ export class Transport {
136
138
  if (typeof detail === "object") detail = JSON.stringify(detail);
137
139
  throw errorForStatus(resp.status, String(detail), requestId, retryAfter);
138
140
  }
141
+ if (raw) {
142
+ // Binary-capable path (look.at: image/jpeg body, or a 200 JSON {available:false}).
143
+ const ct = resp.headers?.get ? (resp.headers.get("content-type") || "") : "";
144
+ if (ct.startsWith("application/json")) return resp.json();
145
+ const buf = await resp.arrayBuffer();
146
+ const provenance = {};
147
+ if (resp.headers?.forEach) resp.headers.forEach((v, k) => {
148
+ if (k.toLowerCase().startsWith("x-")) provenance[k] = v;
149
+ });
150
+ return { _raw: true, content_type: ct, content: new Uint8Array(buf), provenance };
151
+ }
139
152
  if (resp.status === 204) return null;
140
153
  return resp.json();
141
154
  }
package/src/gldai.js CHANGED
@@ -48,6 +48,9 @@ export class GldaiSubmodule {
48
48
  project(projectId) {
49
49
  return this._t.request(this._base, "GET", "/api/v1/projects/{pid}", { pathParams: { pid: projectId } });
50
50
  }
51
+ /** CLOSED — do NOT call. GET /api/v1/mapdata (the bulk map-layers surface) is closed to all callers and
52
+ * returns an error. Use mapViewport() for map reads. Kept only so the method still resolves for older
53
+ * callers. Matches the MCP `mapdata` tool (also marked CLOSED). */
51
54
  mapdata({ idempotencyKey, ...params } = {}) {
52
55
  return this._t.request(this._base, "GET", "/api/v1/mapdata", { params, idempotencyKey });
53
56
  }
@@ -56,7 +59,8 @@ export class GldaiSubmodule {
56
59
  /** The exact per-caller price of a metered call BEFORE you make it — GET /api/v1/billing/quote. FREE
57
60
  * (no charge), needs only a credential (no verification). `path` = the API path the call would hit
58
61
  * (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.
62
+ * "/api/v1/mapdata"); `hops` = graph depth 1-10 (your tier caps it — Pioneer/FC 3, TEN/Pro 5,
63
+ * Enterprise 10) for a relationships path. Priced at YOUR tier.
60
64
  * Returns { joules (base), rail_fee_joules, joules_all_in, pricing_tier, usd, … } — joules_all_in is
61
65
  * the TRUE debit (base + the 0.5% rail surcharge), so fund THAT, not the base. Same helper as the MCP
62
66
  * `billing_quote` tool. Metered reads debit the CALLING agent's OWN wallet (not the owner's); read the
@@ -114,6 +118,36 @@ export class GldaiSubmodule {
114
118
  if (entityType != null) params.entity_type = entityType;
115
119
  return this._t.request(this._base, "GET", "/api/v1/map.viewport", { params, idempotencyKey });
116
120
  }
121
+ /** GET /api/v1/look.at — a Sentinel-2 satellite STILL of a point (lat+lng) or an entity (entityType+id).
122
+ * AGENT KEYS ONLY (a browser session or plain developer key is refused before any charge). Metered
123
+ * against the CALLING agent's wallet — its own price line (~150 J; quote with
124
+ * billingQuote("/api/v1/look.at")). On a hit returns { available: true, content_type: "image/jpeg",
125
+ * image_jpeg: Uint8Array, provenance: { X-* headers — scene date, source, … } }; on a cloudy/missing
126
+ * scene a { available: false, … } object (the charge is refunded server-side). Same as the MCP
127
+ * `look_at` tool. */
128
+ async lookAt({ lat, lng, entityType, id, idempotencyKey } = {}) {
129
+ const params = {};
130
+ if (lat != null) params.lat = lat;
131
+ if (lng != null) params.lng = lng;
132
+ if (entityType != null) params.entity_type = entityType;
133
+ if (id != null) params.id = id;
134
+ const r = await this._t.request(this._base, "GET", "/api/v1/look.at",
135
+ { params, idempotencyKey, accept: "image/jpeg, application/json", raw: true });
136
+ if (r && r._raw) {
137
+ return { available: true, content_type: r.content_type, image_jpeg: r.content, provenance: r.provenance || {} };
138
+ }
139
+ return r; // a 200 JSON { available: false, … } passes straight through
140
+ }
141
+ /** YOUR OWN metered-read charge record — GET /api/v1/billing/attempts. Own wallet only (from your
142
+ * credential, never a parameter). FREE. Each attempt shows reserved vs settled joules so you can verify
143
+ * your bill without asking us (settle_dead_end = nothing moved — a 4xx/5xx or refused reservation;
144
+ * settle_failed = delivered but unsettled). Parity with the MCP `billing_attempts` tool. */
145
+ billingAttempts({ limit, offset } = {}) {
146
+ const params = {};
147
+ if (limit != null) params.limit = limit;
148
+ if (offset != null) params.offset = offset;
149
+ return this._t.request(this._base, "GET", "/api/v1/billing/attempts", { params });
150
+ }
117
151
 
118
152
  // ── contributor-programme reads (P-DAY.105) ──────────────────────
119
153
  /** Your Bridge record (session): contribution units at your standing's weight, plus promoted work. */
package/src/joulepai.js CHANGED
@@ -2,6 +2,7 @@
2
2
  * Source-of-record: local joulepai-sdk-js/index.js (never published).
3
3
  * Transfer-class now carries Class-D keys via dispatch (the local SDK sent none). */
4
4
  import { GLDAI_BASE } from "./gldai.js"; // reuse the single greenlandai.ai base for the agent-self balance route
5
+ import { GreenlandAIError } from "./core/errors.js";
5
6
 
6
7
  export const JOULEPAI_BASE = "https://joulepai.ai/api/v1";
7
8
 
@@ -46,7 +47,11 @@ export class JoulepaiSubmodule {
46
47
  return this._t.request(this._base, "GET", "/wallet/transfer/{tid}/status", { pathParams: { tid: transferId } });
47
48
  }
48
49
 
49
- /** Absorbs fund() (index.js:152). NOT retry-safe (G1 demotion — duplicate Stripe sessions). */
50
+ /** FIAT/CARD funding — POST /wallet/fund. method="stripe" returns a Stripe Checkout URL for a human to
51
+ * complete (card; 3.5% markup; amountFiat 10-100). The backend also accepts method="usdc" (1% markup),
52
+ * but the IN-BAND AGENT USDC rail is the deposit-address flow, NOT this endpoint: an agent funds by
53
+ * depositing USDC to its own Base address — use fundingPrepare() for the address + live availability and
54
+ * depositStatus() to track the credit. NOT retry-safe (G1 demotion — duplicate Stripe sessions). */
50
55
  async fund(amountFiat, { method = "stripe" } = {}) {
51
56
  return this._t.request(this._base, "POST", "/wallet/fund",
52
57
  { body: { wallet_id: await this._ensureId(), amount_fiat: amountFiat, method } });
@@ -120,6 +125,49 @@ export class JoulepaiSubmodule {
120
125
  return this._t.request(this._base, "GET", "/wallet/fund/{fid}", { pathParams: { fid: fundingEventId } });
121
126
  }
122
127
 
128
+ /** YOUR OWN USDC-on-Base deposit state — GET /wallet/deposit-status. Own wallet only (from your token,
129
+ * never a parameter). Read-only, free. Returns { usdc_live, scanner_cursor_block, minimum_usdc,
130
+ * deposits[], held_below_min_total_usdc, needed_to_credit_usdc, note }; each deposit carries { tx_hash,
131
+ * block_number, usdc_amount, status, joules_credited, fee_taken, created_at, meaning }. A deposit whose
132
+ * block_number is ABOVE scanner_cursor_block has not been reached yet (normal lag), not lost. 503 when
133
+ * USDC-on-Base is not live. Parity with the MCP `deposit_status` tool. */
134
+ depositStatus() { return this._t.request(this._base, "GET", "/wallet/deposit-status", {}); }
135
+
136
+ /** The in-band funding step for a joule shortfall — NEVER a URL to visit (operator lock). USDC on Base is
137
+ * the live agent-fundable rail: deposit USDC to your own Base address (min 5 USDC — the authoritative
138
+ * value is depositStatus().minimum_usdc), credited automatically when the scanner sees it (track with
139
+ * depositStatus()). Card funding stays a human web flow. Availability is read LIVE (relays your
140
+ * deposit-address) so it never reports stale state; it does not itself move money. Parity with the MCP
141
+ * `funding_prepare` tool. Returns { needed, in_band_agent_funding_live, routes, note }. */
142
+ async fundingPrepare(needed = 0) {
143
+ let live = true, address = null;
144
+ try {
145
+ const addr = await this.depositAddress();
146
+ address = addr && typeof addr === "object" ? addr.address ?? null : null;
147
+ } catch (err) {
148
+ if (err instanceof GreenlandAIError) { live = false; address = null; }
149
+ else throw err;
150
+ }
151
+ return {
152
+ needed: Number(needed),
153
+ in_band_agent_funding_live: live,
154
+ routes: {
155
+ usdc_on_base: {
156
+ status: live ? "live" : "not_live",
157
+ deposit_address: address,
158
+ minimum_usdc: 5,
159
+ note: live
160
+ ? "deposit USDC to this Base address; credited automatically within the scanner window; check with depositStatus()"
161
+ : "no in-band USDC address for this credential right now — authenticate with your wallet credential, or fund with card meanwhile",
162
+ },
163
+ card_stripe: { status: "human_web_only", note: "not an agent/in-band path" },
164
+ },
165
+ note: live
166
+ ? "USDC on Base is live — deposit to your Base address above (min 5 USDC), credited automatically; track it with depositStatus(). Do not follow a URL to fund."
167
+ : "No in-band USDC address available for this credential; fund with card meanwhile. Do not follow a URL to fund.",
168
+ };
169
+ }
170
+
123
171
  resetCredentials(walletId, email) {
124
172
  return this._t.request(this._base, "POST", "/wallet/reset-credentials",
125
173
  { body: { wallet_id: walletId, email } });