@greenlandai/sdk 0.5.6 → 0.5.7

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/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 0.5.7 (2026-09-23)
2
+ - **Fix: an ENYAL OAuth access token is accepted as the OAuth credential.** ENYAL issues it as `eyl_` + a JWT;
3
+ `oauth_token` / `oauthToken` accepted only a bare JWT (`eyJ…`) and raised, pushing agents onto the API-key
4
+ parameter. It is now sent as `Authorization: Bearer eyl_…` (every door strips the prefix). Unchanged: an ENYAL
5
+ API key (`eyl_` + opaque, no dots) is still refused as an OAuth token, and anything passed as `api_key` still
6
+ goes out as X-API-Key exactly as before.
7
+ - `enyal.prove` / `prove_batch` / `disclose` docs describe `refunded_joules` (proofs paid for and not delivered
8
+ are refunded in the same call; `joule_cost` = the price minus it).
9
+ - Otherwise README-only (plus the JS `VERSION` export, which had stayed at "0.5.3" since 0.5.3).
10
+ - Hello-world no longer leads with `gldai.query()`: `/query` (natural language) and `/mapdata` (bulk map
11
+ layers) are closed to all callers. The example now prices a path with `billing_quote` and reads `companies`.
12
+ - New "The graph" section: what `client.gldai` reads (companies, resource deposits, infrastructure assets,
13
+ projects, commodities and their relationships), where the live totals are, and that query/mapdata are closed.
14
+ - Idempotency matrix lists the metered reads that work today (query/mapdata removed; relationships,
15
+ look_from, nearby, map_viewport, look_at added).
16
+ - Auth lines: an `eyl_` API key is an ENYAL key (`client.enyal`), not a cross-product key; `gai_` covers the
17
+ graph and the marketplace; an ENYAL OAuth token (`eyl_` + JWT) goes in as the OAuth credential.
18
+ - The ENYAL-only SDK is described as sitting alongside this one at 2.2.x (was "supersedes v2.1.x").
19
+ - JS README: code blocks marked `js` (were `python`); Python-only install extras removed; observability line in JS.
20
+
1
21
  ## 0.5.0 (2026-09-05)
2
22
  - **NEW contributor programme surface (TEN-13) on `client.gldai`.** Submit evidenced graph
3
23
  relationships to the GreenlandAI contributor door and manage the grant. Two credential modes:
package/README.md CHANGED
@@ -1,23 +1,21 @@
1
1
  # greenlandai (JavaScript)
2
2
 
3
3
  Unified SDK for the GreenlandAI ecosystem — ENYAL, JoulePAI, RAREEAI, GreenlandAI.
4
- **Supersedes but does not replace** `enyal-sdk` v2.1.x (permanent coexistence — the
5
- standalone enterprise track stays published and maintained; see design §5).
4
+ Sits alongside the ENYAL-only SDK (`enyal-sdk` on PyPI / `@enyalai/sdk` on npm, 2.2.x), which stays
5
+ published and maintained — use that one if you only need ENYAL.
6
6
 
7
7
  ## Install
8
8
  ```bash
9
- npm install @greenlandai/sdk # core
10
- pip install "greenlandai[bip39]" # + mnemonic recovery primitives
11
- pip install "greenlandai[otel]" # + OpenTelemetry metrics (opt-in; OFF by default)
9
+ npm install @greenlandai/sdk
12
10
  ```
13
11
 
14
12
  ## Auth
15
- ```python
13
+ ```js
16
14
  import { Client } from "@greenlandai/sdk"; // ESM
17
15
  const { Client } = require("@greenlandai/sdk"); // CJS
18
- const client = new Client({ apiKey: "eyl_..." }); // eyl_ (ENYAL / cross-product) API key
19
- const client = new Client({ apiKey: "gai_..." }); // gai_ (GreenlandAI agent key) — gldai intelligence
20
- const client = new Client({ oauthToken: jwt }); // web sessions: ENYAL-issued OAuth JWT
16
+ const client = new Client({ apiKey: "gai_..." }); // GreenlandAI agent key — the graph (client.gldai) + the marketplace (client.rareeai)
17
+ const client = new Client({ apiKey: "eyl_..." }); // ENYAL API key — ENYAL calls (client.enyal)
18
+ const client = new Client({ oauthToken: jwt }); // an OAuth JWT — bare, or ENYAL's OAuth token (eyl_ + JWT)
21
19
  // Any apiKey → X-API-Key; an oauthToken (JWT) → Authorization: Bearer. Pass exactly one.
22
20
  // Passing an API key via oauthToken (or a JWT via apiKey) throws immediately — no silent mis-route.
23
21
  // 401s surface to you (no auto-refresh); hook: onAuthExpired
@@ -30,14 +28,24 @@ const client = new Client({ oauthToken: jwt }); // web sessions: ENYAL-issu
30
28
  > `greenlandai.ai/api/v1/marketplace/*`.) `eyl_` / OAuth marketplace access is unaffected.
31
29
 
32
30
  ## Hello world (one per submodule)
33
- ```python
31
+ ```js
34
32
  await client.enyal.archive({ agentId: "agent-1", chunkType: "decision_record", chunkKey: "k1", data: { decision: "x" } });
35
33
  await client.joulepai.transfer("@bob", 1000, { note: "thanks" }); // auto idempotency key
36
34
  await client.rareeai.createRequest({ resourceType: "gpu" }); // marketplace (flat 1%, floor 50 J — parse fee_joules)
37
35
  await client.rareeai.oracleAssignments(); // oracle queue (0.3.6; the pool is invite-only at launch)
38
- await client.gldai.query("lithium deposits greenland");
36
+ await client.gldai.billingQuote("/api/v1/companies"); // free: the exact all-in price before you call
37
+ await client.gldai.companies({ search: "lithium" }); // the graph (metered; see charged_joules + metering)
39
38
  ```
40
39
 
40
+ ## The graph (client.gldai)
41
+ The physical economy as queryable data: companies, resource deposits, infrastructure assets, projects and
42
+ commodities, and the relationships between them (ownership, operation, supply). Structured reads —
43
+ companies, deposits, infrastructure, projects, relationships (hops), look_from, nearby, map_viewport,
44
+ look_at — are metered per call against the calling agent's own wallet; price any path first with
45
+ billing_quote (free). Live totals: `GET https://greenlandai.ai/api/v1/public/stats` (public).
46
+ `query` (natural language) and `mapdata` (bulk map layers) are **closed to all callers**; the methods
47
+ still resolve but the server refuses them before any charge — use the structured reads and map_viewport.
48
+
41
49
  ## Idempotency promise matrix (auto-retry behavior — design §6, post-G1 2026-06-10)
42
50
 
43
51
  | Method (py / js) | Wire class | Tier | Auto-retry |
@@ -53,13 +61,13 @@ await client.gldai.query("lithium deposits greenland");
53
61
  | joulepai.fund | — | NOT SUPPORTED | **OFF** (duplicate Stripe sessions possible) |
54
62
  | rareeai.create_provider/create_request/deliver/resolve | B | ENFORCED | ON |
55
63
  | rareeai.approve/reject/dispute/extend_dispute | — | NOT SUPPORTED | **OFF** |
56
- | gldai metered queries (companies/deposits/infrastructure/query/projects/mapdata) | C header X-Idempotency-Key | ENFORCED | ON |
64
+ | gldai metered reads (companies/deposits/infrastructure/projects/relationships/look_from/nearby/map_viewport/look_at) | C header X-Idempotency-Key | ENFORCED | ON |
57
65
  | all GET reads | — | safe | ON |
58
66
 
59
67
  Every billed call auto-generates a UUID4 key (stable across retries) unless you pass `idempotency_key` / `idempotencyKey` yourself.
60
68
 
61
69
  ## Observability (OFF by default)
62
- `Client(logger=my_logger, on_retry=..., on_terminal_failure=..., metrics=otel_metrics())` —
70
+ `new Client({ apiKey, logger: console, onRetry, onTerminalFailure, metrics })` —
63
71
  DEBUG logs redact Authorization + X-API-Key structurally.
64
72
 
65
73
  Migration from enyal-sdk 2.1.0: see MIGRATION.md. Changelog: CHANGELOG.md.
package/dist/index.cjs CHANGED
@@ -169,6 +169,7 @@ var DEFAULT_JITTER_MIN = 100;
169
169
  var DEFAULT_JITTER_MAX = 300;
170
170
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
171
171
  var JWT_RE = /^eyJ[\w-]*\.[\w-]+\.[\w-]+$/;
172
+ var OAUTH_RE = /^(?:eyl_)?eyJ[\w-]*\.[\w-]+\.[\w-]+$/;
172
173
  function isRetryable(err) {
173
174
  return err instanceof NetworkError || err instanceof RateLimitError || err instanceof ServerError;
174
175
  }
@@ -195,7 +196,7 @@ var Transport = class {
195
196
  this._credential = apiKey;
196
197
  this._isApiKey = true;
197
198
  } else {
198
- if (!JWT_RE.test(oauthToken)) throw new Error("oauthToken is not a JWT \u2014 an API key (e.g. eyl_/gai_) must be passed via apiKey.");
199
+ if (!OAUTH_RE.test(oauthToken)) throw new Error("oauthToken is not a JWT (bare, or ENYAL's eyl_-prefixed OAuth token) \u2014 an API key (e.g. eyl_/gai_) must be passed via apiKey.");
199
200
  this._credential = oauthToken;
200
201
  this._isApiKey = false;
201
202
  }
@@ -3784,7 +3785,8 @@ var EnyalSubmodule = class {
3784
3785
  );
3785
3786
  }
3786
3787
  // ── class B (ENFORCED) ──
3787
- /** 2.1.0: enyal-client.js:472. ENFORCED (prove_routes.py:204). */
3788
+ /** 2.1.0: enyal-client.js:472. ENFORCED (prove_routes.py:204).
3789
+ * Filter queries: A proof paid for and not delivered is refunded in the same call: the response carries `refunded_joules` (refunds already sent back to your wallet) and `joule_cost` = the price minus it; a refund still in flight completes automatically and is not counted. A failure after the charge is an error and is refunded in full. */
3788
3790
  prove({
3789
3791
  resourceType,
3790
3792
  geographicRegion,
@@ -3801,6 +3803,8 @@ var EnyalSubmodule = class {
3801
3803
  if (chunkIds) body.chunk_ids = chunkIds;
3802
3804
  return this._t.request(this._base, "POST", "/api/v1/prove", { body, idempotencyKey, retry });
3803
3805
  }
3806
+ /** Each query without a proof (including one that matches nothing), and the compression fee when no compressed
3807
+ * proof comes back: A proof paid for and not delivered is refunded in the same call: the response carries `refunded_joules` (refunds already sent back to your wallet) and `joule_cost` = the price minus it; a refund still in flight completes automatically and is not counted. A failure after the charge is an error and is refunded in full. */
3804
3808
  proveBatch({ queries, quantumResistant = true, compress: compress2 = true, idempotencyKey, retry = true }) {
3805
3809
  return this._t.request(
3806
3810
  this._base,
@@ -3815,7 +3819,8 @@ var EnyalSubmodule = class {
3815
3819
  if (poseidonKeyHash) body.poseidon_key_hash = poseidonKeyHash;
3816
3820
  return this._t.request(this._base, "POST", "/api/v1/prove/share-combination", { body, idempotencyKey, retry });
3817
3821
  }
3818
- /** 2.1.0: enyal-client.js:483. ENFORCED (disclose_routes.py:274). */
3822
+ /** 2.1.0: enyal-client.js:483. ENFORCED (disclose_routes.py:274).
3823
+ * Content or share proofs: A proof paid for and not delivered is refunded in the same call: the response carries `refunded_joules` (refunds already sent back to your wallet) and `joule_cost` = the price minus it; a refund still in flight completes automatically and is not counted. A failure after the charge is an error and is refunded in full. */
3819
3824
  disclose({ chunkIds, recipientPubkeyHex, purpose, idempotencyKey, retry = true }) {
3820
3825
  return this._t.request(
3821
3826
  this._base,
@@ -4759,7 +4764,7 @@ var RareeaiSubmodule = class _RareeaiSubmodule {
4759
4764
  };
4760
4765
 
4761
4766
  // index.js
4762
- var VERSION = "0.5.3";
4767
+ var VERSION = "0.5.7";
4763
4768
  var Client = class {
4764
4769
  /**
4765
4770
  * @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.3";
19
+ export const VERSION = "0.5.7";
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.6",
3
+ "version": "0.5.7",
4
4
  "description": "Unified SDK for the GreenlandAI ecosystem (ENYAL, JoulePAI, RAREEAI, GreenlandAI)",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://greenlandai.ai",
@@ -20,6 +20,10 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
20
20
  // credential is passed via the wrong parameter. Prefixed API keys (eyl_/gai_/…) never match
21
21
  // this (a JWT starts "eyJ"); only a bare JWT does. Routing itself is by parameter, not prefix.
22
22
  const JWT_RE = /^eyJ[\w-]*\.[\w-]+\.[\w-]+$/;
23
+ // What oauthToken accepts: a bare JWT, or ENYAL's OAuth access token, which ENYAL issues as `eyl_` + an RS256 JWT
24
+ // (enyal oauth_routes.py) and which every door reads as Bearer after stripping the prefix. An ENYAL API key is also
25
+ // `eyl_`-prefixed but is opaque (no dots), so it can never match and is still refused here (0.5.7).
26
+ const OAUTH_RE = /^(?:eyl_)?eyJ[\w-]*\.[\w-]+\.[\w-]+$/;
23
27
 
24
28
  function isRetryable(err) {
25
29
  return err instanceof NetworkError || err instanceof RateLimitError || err instanceof ServerError;
@@ -39,7 +43,7 @@ export class Transport {
39
43
  if (JWT_RE.test(apiKey)) throw new Error("apiKey looks like a JWT (OAuth token) — pass it via oauthToken instead.");
40
44
  this._credential = apiKey; this._isApiKey = true;
41
45
  } else {
42
- if (!JWT_RE.test(oauthToken)) throw new Error("oauthToken is not a JWT — an API key (e.g. eyl_/gai_) must be passed via apiKey.");
46
+ if (!OAUTH_RE.test(oauthToken)) throw new Error("oauthToken is not a JWT (bare, or ENYAL's eyl_-prefixed OAuth token) — an API key (e.g. eyl_/gai_) must be passed via apiKey.");
43
47
  this._credential = oauthToken; this._isApiKey = false;
44
48
  }
45
49
  this.logger = logger || noopLogger;
package/src/enyal.js CHANGED
@@ -44,7 +44,8 @@ export class EnyalSubmodule {
44
44
  }
45
45
 
46
46
  // ── class B (ENFORCED) ──
47
- /** 2.1.0: enyal-client.js:472. ENFORCED (prove_routes.py:204). */
47
+ /** 2.1.0: enyal-client.js:472. ENFORCED (prove_routes.py:204).
48
+ * Filter queries: A proof paid for and not delivered is refunded in the same call: the response carries `refunded_joules` (refunds already sent back to your wallet) and `joule_cost` = the price minus it; a refund still in flight completes automatically and is not counted. A failure after the charge is an error and is refunded in full. */
48
49
  prove({ resourceType, geographicRegion, supplyChainStage, chunkIds, quantumResistant = false,
49
50
  idempotencyKey, retry = true } = {}) {
50
51
  const body = { quantum_resistant: quantumResistant };
@@ -55,6 +56,8 @@ export class EnyalSubmodule {
55
56
  return this._t.request(this._base, "POST", "/api/v1/prove", { body, idempotencyKey, retry });
56
57
  }
57
58
 
59
+ /** Each query without a proof (including one that matches nothing), and the compression fee when no compressed
60
+ * proof comes back: A proof paid for and not delivered is refunded in the same call: the response carries `refunded_joules` (refunds already sent back to your wallet) and `joule_cost` = the price minus it; a refund still in flight completes automatically and is not counted. A failure after the charge is an error and is refunded in full. */
58
61
  proveBatch({ queries, quantumResistant = true, compress = true, idempotencyKey, retry = true }) {
59
62
  return this._t.request(this._base, "POST", "/api/v1/prove-batch",
60
63
  { body: { queries, quantum_resistant: quantumResistant, compress }, idempotencyKey, retry });
@@ -67,7 +70,8 @@ export class EnyalSubmodule {
67
70
  return this._t.request(this._base, "POST", "/api/v1/prove/share-combination", { body, idempotencyKey, retry });
68
71
  }
69
72
 
70
- /** 2.1.0: enyal-client.js:483. ENFORCED (disclose_routes.py:274). */
73
+ /** 2.1.0: enyal-client.js:483. ENFORCED (disclose_routes.py:274).
74
+ * Content or share proofs: A proof paid for and not delivered is refunded in the same call: the response carries `refunded_joules` (refunds already sent back to your wallet) and `joule_cost` = the price minus it; a refund still in flight completes automatically and is not counted. A failure after the charge is an error and is refunded in full. */
71
75
  disclose({ chunkIds, recipientPubkeyHex, purpose, idempotencyKey, retry = true }) {
72
76
  return this._t.request(this._base, "POST", "/api/v1/disclose",
73
77
  { body: { chunk_ids: chunkIds, recipient_pubkey_hex: recipientPubkeyHex, purpose }, idempotencyKey, retry });