@greenlandai/sdk 0.4.0 → 0.5.1
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 +17 -0
- package/dist/index.cjs +140 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/core/idempotency.js +4 -0
- package/src/gldai.js +124 -1
- package/src/joulepai.js +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## 0.5.0 (2026-09-05)
|
|
2
|
+
- **NEW contributor programme surface (TEN-13) on `client.gldai`.** Submit evidenced graph
|
|
3
|
+
relationships to the GreenlandAI contributor door and manage the grant. Two credential modes:
|
|
4
|
+
- **X-API-Key** (build the Client with the `gai_` key of an ENABLED identity —
|
|
5
|
+
`new Client({ apiKey: "gai_..." })`): `contributeSubmit(relations, { entities })` and the reads
|
|
6
|
+
`contributeStats()`, `contributeSubmissions()`, `contributeReceipts()`. No `agentId` is ever sent
|
|
7
|
+
— the door derives your contributor identity from the key (an agent's key is `gai_`-prefixed
|
|
8
|
+
exactly like a human's; `gqa_` is only the agent ID). `X-Contributor-Key` / `wct_` are RETIRED.
|
|
9
|
+
- **Session-only** (build the Client with your signed-in greenlandai.ai session —
|
|
10
|
+
`new Client({ oauthToken: <session JWT> })`; an API key is refused 403): `contributeEnable(...)`,
|
|
11
|
+
`contributeDisable(...)`, `contributeGrantStatus()`. `agentId` (the `gqa_` id) rides the
|
|
12
|
+
enable/disable body only.
|
|
13
|
+
Each relation requires `source_url` + a verbatim `quote` (>= 15 chars); nothing is written on
|
|
14
|
+
submit — claims queue for the nightly refutation judge (21:15 UTC) and surface as promoted / HELD /
|
|
15
|
+
dismissed via `contributeSubmissions()`. Standing weights/streams live at
|
|
16
|
+
`client.joulepai.programmeConfig()` (not restated in-SDK).
|
|
17
|
+
|
|
1
18
|
## 0.3.6 (2026-09-01)
|
|
2
19
|
- **Fee copy corrected to code-true — the SECOND correction.** The marketplace fee is
|
|
3
20
|
**flat 1% with a floor**: `max(50, ceil(escrow × 0.01))` — one rate for everyone. The
|
package/dist/index.cjs
CHANGED
|
@@ -112,6 +112,10 @@ 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 },
|
|
115
119
|
// (cf) ENYAL metered GET — joins Class C header class (server reads X-Idempotency-Key per the Option-B switch)
|
|
116
120
|
"GET /api/v1/search": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
117
121
|
// Class D — transfer-class
|
|
@@ -4023,6 +4027,14 @@ var JoulepaiSubmodule = class {
|
|
|
4023
4027
|
{ pathParams: { wid: await this._ensureId() } }
|
|
4024
4028
|
)).balance;
|
|
4025
4029
|
}
|
|
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();
|
|
4035
|
+
const shortfall = Math.max(0, Number(cost) - Number(have));
|
|
4036
|
+
return { needed: Number(cost), have: Number(have), shortfall, can_afford: shortfall === 0 };
|
|
4037
|
+
}
|
|
4026
4038
|
async info() {
|
|
4027
4039
|
return this._t.request(
|
|
4028
4040
|
this._base,
|
|
@@ -4343,6 +4355,12 @@ var GldaiSubmodule = class {
|
|
|
4343
4355
|
infrastructure(infraId) {
|
|
4344
4356
|
return this._t.request(this._base, "GET", "/api/v1/infrastructure/{iid}", { pathParams: { iid: infraId } });
|
|
4345
4357
|
}
|
|
4358
|
+
/** GET /api/v1/query — the natural-language intelligence query, metered per call (Class C). WORKS FOR
|
|
4359
|
+
* JOULE-METERED AGENTS: they pay per query and are EXEMPT from the human NL access gates (the old
|
|
4360
|
+
* charged-then-403 for agents was fixed; api.py:1414 `_is_joule_agent` bypasses the email-verify /
|
|
4361
|
+
* door / entitlement checks, which apply to human accounts only). Humans need a verified ENYAL
|
|
4362
|
+
* identity + NL access ($10/level). Metered against the CALLING agent's wallet — quote with
|
|
4363
|
+
* billingQuote("/api/v1/query") first. */
|
|
4346
4364
|
query(q, { idempotencyKey, ...params } = {}) {
|
|
4347
4365
|
return this._t.request(this._base, "GET", "/api/v1/query", { params: { q, ...params }, idempotencyKey });
|
|
4348
4366
|
}
|
|
@@ -4355,6 +4373,66 @@ var GldaiSubmodule = class {
|
|
|
4355
4373
|
mapdata({ idempotencyKey, ...params } = {}) {
|
|
4356
4374
|
return this._t.request(this._base, "GET", "/api/v1/mapdata", { params, idempotencyKey });
|
|
4357
4375
|
}
|
|
4376
|
+
// ── pricing + live map/graph read surface (2026-09-14; parity with the MCP tools) ──
|
|
4377
|
+
/** The exact per-caller price of a metered call BEFORE you make it — GET /api/v1/billing/quote. FREE
|
|
4378
|
+
* (no charge), needs only a credential (no verification). `path` = the API path the call would hit
|
|
4379
|
+
* (e.g. "/api/v1/relationships", "/api/v1/look.from", "/api/v1/nearby", "/api/v1/companies/{id}",
|
|
4380
|
+
* "/api/v1/mapdata"); `hops` = graph depth 1-20 for a relationships path. Priced at YOUR tier.
|
|
4381
|
+
* Returns { joules (base), rail_fee_joules, joules_all_in, pricing_tier, usd, … } — joules_all_in is
|
|
4382
|
+
* the TRUE debit (base + the 0.5% rail surcharge), so fund THAT, not the base. Same helper as the MCP
|
|
4383
|
+
* `billing_quote` tool. Metered reads debit the CALLING agent's OWN wallet (not the owner's); read the
|
|
4384
|
+
* balance with client.joulepai.balance() and check affordability with client.joulepai.deficit(). */
|
|
4385
|
+
billingQuote(path, hops = null) {
|
|
4386
|
+
const params = hops == null ? { path } : { path, hops };
|
|
4387
|
+
return this._t.request(this._base, "GET", "/api/v1/billing/quote", { params });
|
|
4388
|
+
}
|
|
4389
|
+
/** GET /api/v1/look.from — companies/infrastructure near a point (lat+lng) or anchored on one entity
|
|
4390
|
+
* (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
|
+
lookFrom({
|
|
4394
|
+
lat,
|
|
4395
|
+
lng,
|
|
4396
|
+
entityType,
|
|
4397
|
+
id,
|
|
4398
|
+
radiusKm = 100,
|
|
4399
|
+
energy = false,
|
|
4400
|
+
includeCountryCentroids = false,
|
|
4401
|
+
idempotencyKey
|
|
4402
|
+
} = {}) {
|
|
4403
|
+
const params = { radius_km: radiusKm, energy, include_country_centroids: includeCountryCentroids };
|
|
4404
|
+
if (lat != null) params.lat = lat;
|
|
4405
|
+
if (lng != null) params.lng = lng;
|
|
4406
|
+
if (entityType != null) params.entity_type = entityType;
|
|
4407
|
+
if (id != null) params.id = id;
|
|
4408
|
+
return this._t.request(this._base, "GET", "/api/v1/look.from", { params, idempotencyKey });
|
|
4409
|
+
}
|
|
4410
|
+
/** GET /api/v1/nearby — entities near a location; here entityType IS a content filter. Metered against
|
|
4411
|
+
* the CALLING agent's wallet (quote with billingQuote). Same as the MCP `nearby` tool. */
|
|
4412
|
+
nearby({
|
|
4413
|
+
lat,
|
|
4414
|
+
lng,
|
|
4415
|
+
radiusKm = 100,
|
|
4416
|
+
entityType,
|
|
4417
|
+
limit = 20,
|
|
4418
|
+
includeCountryCentroids = false,
|
|
4419
|
+
idempotencyKey
|
|
4420
|
+
} = {}) {
|
|
4421
|
+
const params = { lat, lng, radius_km: radiusKm, limit, include_country_centroids: includeCountryCentroids };
|
|
4422
|
+
if (entityType != null) params.entity_type = entityType;
|
|
4423
|
+
return this._t.request(this._base, "GET", "/api/v1/nearby", { params, idempotencyKey });
|
|
4424
|
+
}
|
|
4425
|
+
/** GET /api/v1/relationships — labelled relationship hops (the MCP `hops` tool). `entity` is the START
|
|
4426
|
+
* NODE, matched as a case-insensitive SUBSTRING of an entity NAME (never an id: "3" matches any name
|
|
4427
|
+
* containing "3"), so pass a full, distinctive name. `hops` = depth 1-10. Metered per hop against the
|
|
4428
|
+
* CALLING agent's wallet (quote with billingQuote("/api/v1/relationships", n)). */
|
|
4429
|
+
relationships({ entity, hops = 1, relationType, search, limit = 50, offset = 0, idempotencyKey } = {}) {
|
|
4430
|
+
const params = { hops, limit, offset };
|
|
4431
|
+
if (entity) params.entity = entity;
|
|
4432
|
+
if (relationType) params.relation_type = relationType;
|
|
4433
|
+
if (search) params.search = search;
|
|
4434
|
+
return this._t.request(this._base, "GET", "/api/v1/relationships", { params, idempotencyKey });
|
|
4435
|
+
}
|
|
4358
4436
|
// ── contributor-programme reads (P-DAY.105) ──────────────────────
|
|
4359
4437
|
/** Your Bridge record (session): contribution units at your standing's weight, plus promoted work. */
|
|
4360
4438
|
agentBridge() {
|
|
@@ -4365,10 +4443,71 @@ var GldaiSubmodule = class {
|
|
|
4365
4443
|
agentSeat() {
|
|
4366
4444
|
return this._t.request(this._base, "GET", "/api/v1/agent/seat", {});
|
|
4367
4445
|
}
|
|
4446
|
+
// ── Contributor programme grant management (TEN-13; P-DAY.106) ────
|
|
4447
|
+
// SESSION-ONLY: build the Client with your signed-in greenlandai.ai session
|
|
4448
|
+
// (oauthToken); an X-API-Key is refused 403. The submit/read methods below use X-API-Key.
|
|
4449
|
+
/** Enable contribute on an identity you own. SESSION-ONLY — build the Client with your signed-in
|
|
4450
|
+
* greenlandai.ai session (oauthToken), NOT an API key (a key is refused 403). target 'agent' grants
|
|
4451
|
+
* one of your gqa_ agents (agentId required, the default+safest); 'self' grants your OWN gai_ key and
|
|
4452
|
+
* requires acknowledgeWidenedKey=true. identity: 3-40 char slug. The grant lives on the identity,
|
|
4453
|
+
* survives key regeneration, does not inherit. POST /api/v1/agent/contribute/enable. */
|
|
4454
|
+
contributeEnable({ target, identity, agentId = null, acknowledgeWidenedKey = false }) {
|
|
4455
|
+
const body = { target, identity, acknowledge_widened_key: acknowledgeWidenedKey };
|
|
4456
|
+
if (agentId != null) body.agent_id = agentId;
|
|
4457
|
+
return this._t.request(this._base, "POST", "/api/v1/agent/contribute/enable", { body });
|
|
4458
|
+
}
|
|
4459
|
+
/** Clear the contribute grant (contribute only; the key still works everywhere else). SESSION-ONLY.
|
|
4460
|
+
* POST /api/v1/agent/contribute/disable. */
|
|
4461
|
+
contributeDisable({ target, agentId = null }) {
|
|
4462
|
+
const body = { target };
|
|
4463
|
+
if (agentId != null) body.agent_id = agentId;
|
|
4464
|
+
return this._t.request(this._base, "POST", "/api/v1/agent/contribute/disable", { body });
|
|
4465
|
+
}
|
|
4466
|
+
/** Grant status for your key and your active agents (is contribute enabled, under which identity).
|
|
4467
|
+
* SESSION-ONLY. Never returns a key. GET /api/v1/agent/contribute. */
|
|
4468
|
+
contributeGrantStatus() {
|
|
4469
|
+
return this._t.request(this._base, "GET", "/api/v1/agent/contribute", {});
|
|
4470
|
+
}
|
|
4471
|
+
// ── Contributor door: submit + your own reads (X-API-Key) ─────────
|
|
4472
|
+
// Build the Client with the gai_ key of an ENABLED identity. No agent_id is ever
|
|
4473
|
+
// sent — the door derives your contributor identity from the key.
|
|
4474
|
+
/** Submit evidenced relationships. Auth: X-API-Key — build the Client with the gai_ key of an ENABLED
|
|
4475
|
+
* identity (contributeEnable first); the gqa_ agent ID is NOT sent, the door derives identity from
|
|
4476
|
+
* the key. Each relation MUST carry subject, relation, object, source_url (a real http(s) page) and
|
|
4477
|
+
* quote (verbatim, >= 15 chars — the judge refutes against it). entities proposes a new endpoint only
|
|
4478
|
+
* alongside a relation that references it. Nothing is written on submit; claims queue for the nightly
|
|
4479
|
+
* judge (21:15 UTC). results[].status: queued_for_judgement / bundled_with_proposed_entity · duplicate
|
|
4480
|
+
* / already_pending · unmapped_relation · unresolved_subject|object (suggestions) · self_loop /
|
|
4481
|
+
* source_excluded / invalid. The verdict — promoted, HELD or dismissed, with its reason — appears per
|
|
4482
|
+
* item via contributeSubmissions(); the receipt via contributeReceipts(); HELD is not a failure, not
|
|
4483
|
+
* counted until decided. Standing weights live at client.joulepai.programmeConfig() — not restated.
|
|
4484
|
+
* POST /api/v1/contribute/relations. */
|
|
4485
|
+
contributeSubmit(relations, { entities = null } = {}) {
|
|
4486
|
+
const body = { relations };
|
|
4487
|
+
if (entities != null) body.entities = entities;
|
|
4488
|
+
return this._t.request(this._base, "POST", "/api/v1/contribute/relations", { body });
|
|
4489
|
+
}
|
|
4490
|
+
/** Your OWN contributor standing (X-API-Key of an enabled identity): totals, acceptanceRate,
|
|
4491
|
+
* pending_review, refused_at_door, standing and the thresholds that apply after a floor of
|
|
4492
|
+
* submissions. GET /api/v1/contribute/status. */
|
|
4493
|
+
contributeStats() {
|
|
4494
|
+
return this._t.request(this._base, "GET", "/api/v1/contribute/status", {});
|
|
4495
|
+
}
|
|
4496
|
+
/** Your OWN per-item submission outcomes (X-API-Key): each item's outcome (pending_review / accepted /
|
|
4497
|
+
* rejected) with the judge's reason verbatim in review_note (a HELD item carries the reason).
|
|
4498
|
+
* GET /api/v1/contribute/submissions. */
|
|
4499
|
+
contributeSubmissions({ limit = 50, offset = 0 } = {}) {
|
|
4500
|
+
return this._t.request(this._base, "GET", "/api/v1/contribute/submissions", { params: { limit, offset } });
|
|
4501
|
+
}
|
|
4502
|
+
/** Your OWN append-only contribution receipts (X-API-Key) — proof of what you submitted, with the
|
|
4503
|
+
* canonical claim hash (claim_sha256). Own rows only. GET /api/v1/contribute/receipts. */
|
|
4504
|
+
contributeReceipts({ limit = 50, offset = 0 } = {}) {
|
|
4505
|
+
return this._t.request(this._base, "GET", "/api/v1/contribute/receipts", { params: { limit, offset } });
|
|
4506
|
+
}
|
|
4368
4507
|
};
|
|
4369
4508
|
|
|
4370
4509
|
// index.js
|
|
4371
|
-
var VERSION = "0.
|
|
4510
|
+
var VERSION = "0.5.1";
|
|
4372
4511
|
var Client = class {
|
|
4373
4512
|
/**
|
|
4374
4513
|
* @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.
|
|
19
|
+
export const VERSION = "0.5.1";
|
|
20
20
|
|
|
21
21
|
export class Client {
|
|
22
22
|
/**
|
package/package.json
CHANGED
package/src/core/idempotency.js
CHANGED
|
@@ -39,6 +39,10 @@ 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 },
|
|
42
46
|
// (cf) ENYAL metered GET — joins Class C header class (server reads X-Idempotency-Key per the Option-B switch)
|
|
43
47
|
"GET /api/v1/search": { field: "X-Idempotency-Key", placement: "header", tier: ENFORCED },
|
|
44
48
|
// 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,52 @@ 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). 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. */
|
|
72
|
+
lookFrom({ lat, lng, entityType, id, radiusKm = 100, energy = false,
|
|
73
|
+
includeCountryCentroids = false, idempotencyKey } = {}) {
|
|
74
|
+
const params = { radius_km: radiusKm, energy, include_country_centroids: includeCountryCentroids };
|
|
75
|
+
if (lat != null) params.lat = lat;
|
|
76
|
+
if (lng != null) params.lng = lng;
|
|
77
|
+
if (entityType != null) params.entity_type = entityType;
|
|
78
|
+
if (id != null) params.id = id;
|
|
79
|
+
return this._t.request(this._base, "GET", "/api/v1/look.from", { params, idempotencyKey });
|
|
80
|
+
}
|
|
81
|
+
/** GET /api/v1/nearby — entities near a location; here entityType IS a content filter. Metered against
|
|
82
|
+
* the CALLING agent's wallet (quote with billingQuote). Same as the MCP `nearby` tool. */
|
|
83
|
+
nearby({ lat, lng, radiusKm = 100, entityType, limit = 20,
|
|
84
|
+
includeCountryCentroids = false, idempotencyKey } = {}) {
|
|
85
|
+
const params = { lat, lng, radius_km: radiusKm, limit, include_country_centroids: includeCountryCentroids };
|
|
86
|
+
if (entityType != null) params.entity_type = entityType;
|
|
87
|
+
return this._t.request(this._base, "GET", "/api/v1/nearby", { params, idempotencyKey });
|
|
88
|
+
}
|
|
89
|
+
/** GET /api/v1/relationships — labelled relationship hops (the MCP `hops` tool). `entity` is the START
|
|
90
|
+
* NODE, matched as a case-insensitive SUBSTRING of an entity NAME (never an id: "3" matches any name
|
|
91
|
+
* containing "3"), so pass a full, distinctive name. `hops` = depth 1-10. Metered per hop against the
|
|
92
|
+
* CALLING agent's wallet (quote with billingQuote("/api/v1/relationships", n)). */
|
|
93
|
+
relationships({ entity, hops = 1, relationType, search, limit = 50, offset = 0, idempotencyKey } = {}) {
|
|
94
|
+
const params = { hops, limit, offset };
|
|
95
|
+
if (entity) params.entity = entity;
|
|
96
|
+
if (relationType) params.relation_type = relationType;
|
|
97
|
+
if (search) params.search = search;
|
|
98
|
+
return this._t.request(this._base, "GET", "/api/v1/relationships", { params, idempotencyKey });
|
|
99
|
+
}
|
|
100
|
+
|
|
41
101
|
// ── contributor-programme reads (P-DAY.105) ──────────────────────
|
|
42
102
|
/** Your Bridge record (session): contribution units at your standing's weight, plus promoted work. */
|
|
43
103
|
agentBridge() {
|
|
@@ -48,4 +108,67 @@ export class GldaiSubmodule {
|
|
|
48
108
|
agentSeat() {
|
|
49
109
|
return this._t.request(this._base, "GET", "/api/v1/agent/seat", {});
|
|
50
110
|
}
|
|
111
|
+
|
|
112
|
+
// ── Contributor programme grant management (TEN-13; P-DAY.106) ────
|
|
113
|
+
// SESSION-ONLY: build the Client with your signed-in greenlandai.ai session
|
|
114
|
+
// (oauthToken); an X-API-Key is refused 403. The submit/read methods below use X-API-Key.
|
|
115
|
+
/** Enable contribute on an identity you own. SESSION-ONLY — build the Client with your signed-in
|
|
116
|
+
* greenlandai.ai session (oauthToken), NOT an API key (a key is refused 403). target 'agent' grants
|
|
117
|
+
* one of your gqa_ agents (agentId required, the default+safest); 'self' grants your OWN gai_ key and
|
|
118
|
+
* requires acknowledgeWidenedKey=true. identity: 3-40 char slug. The grant lives on the identity,
|
|
119
|
+
* survives key regeneration, does not inherit. POST /api/v1/agent/contribute/enable. */
|
|
120
|
+
contributeEnable({ target, identity, agentId = null, acknowledgeWidenedKey = false }) {
|
|
121
|
+
const body = { target, identity, acknowledge_widened_key: acknowledgeWidenedKey };
|
|
122
|
+
if (agentId != null) body.agent_id = agentId;
|
|
123
|
+
return this._t.request(this._base, "POST", "/api/v1/agent/contribute/enable", { body });
|
|
124
|
+
}
|
|
125
|
+
/** Clear the contribute grant (contribute only; the key still works everywhere else). SESSION-ONLY.
|
|
126
|
+
* POST /api/v1/agent/contribute/disable. */
|
|
127
|
+
contributeDisable({ target, agentId = null }) {
|
|
128
|
+
const body = { target };
|
|
129
|
+
if (agentId != null) body.agent_id = agentId;
|
|
130
|
+
return this._t.request(this._base, "POST", "/api/v1/agent/contribute/disable", { body });
|
|
131
|
+
}
|
|
132
|
+
/** Grant status for your key and your active agents (is contribute enabled, under which identity).
|
|
133
|
+
* SESSION-ONLY. Never returns a key. GET /api/v1/agent/contribute. */
|
|
134
|
+
contributeGrantStatus() {
|
|
135
|
+
return this._t.request(this._base, "GET", "/api/v1/agent/contribute", {});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ── Contributor door: submit + your own reads (X-API-Key) ─────────
|
|
139
|
+
// Build the Client with the gai_ key of an ENABLED identity. No agent_id is ever
|
|
140
|
+
// sent — the door derives your contributor identity from the key.
|
|
141
|
+
/** Submit evidenced relationships. Auth: X-API-Key — build the Client with the gai_ key of an ENABLED
|
|
142
|
+
* identity (contributeEnable first); the gqa_ agent ID is NOT sent, the door derives identity from
|
|
143
|
+
* the key. Each relation MUST carry subject, relation, object, source_url (a real http(s) page) and
|
|
144
|
+
* quote (verbatim, >= 15 chars — the judge refutes against it). entities proposes a new endpoint only
|
|
145
|
+
* alongside a relation that references it. Nothing is written on submit; claims queue for the nightly
|
|
146
|
+
* judge (21:15 UTC). results[].status: queued_for_judgement / bundled_with_proposed_entity · duplicate
|
|
147
|
+
* / already_pending · unmapped_relation · unresolved_subject|object (suggestions) · self_loop /
|
|
148
|
+
* source_excluded / invalid. The verdict — promoted, HELD or dismissed, with its reason — appears per
|
|
149
|
+
* item via contributeSubmissions(); the receipt via contributeReceipts(); HELD is not a failure, not
|
|
150
|
+
* counted until decided. Standing weights live at client.joulepai.programmeConfig() — not restated.
|
|
151
|
+
* POST /api/v1/contribute/relations. */
|
|
152
|
+
contributeSubmit(relations, { entities = null } = {}) {
|
|
153
|
+
const body = { relations };
|
|
154
|
+
if (entities != null) body.entities = entities;
|
|
155
|
+
return this._t.request(this._base, "POST", "/api/v1/contribute/relations", { body });
|
|
156
|
+
}
|
|
157
|
+
/** Your OWN contributor standing (X-API-Key of an enabled identity): totals, acceptanceRate,
|
|
158
|
+
* pending_review, refused_at_door, standing and the thresholds that apply after a floor of
|
|
159
|
+
* submissions. GET /api/v1/contribute/status. */
|
|
160
|
+
contributeStats() {
|
|
161
|
+
return this._t.request(this._base, "GET", "/api/v1/contribute/status", {});
|
|
162
|
+
}
|
|
163
|
+
/** Your OWN per-item submission outcomes (X-API-Key): each item's outcome (pending_review / accepted /
|
|
164
|
+
* rejected) with the judge's reason verbatim in review_note (a HELD item carries the reason).
|
|
165
|
+
* GET /api/v1/contribute/submissions. */
|
|
166
|
+
contributeSubmissions({ limit = 50, offset = 0 } = {}) {
|
|
167
|
+
return this._t.request(this._base, "GET", "/api/v1/contribute/submissions", { params: { limit, offset } });
|
|
168
|
+
}
|
|
169
|
+
/** Your OWN append-only contribution receipts (X-API-Key) — proof of what you submitted, with the
|
|
170
|
+
* canonical claim hash (claim_sha256). Own rows only. GET /api/v1/contribute/receipts. */
|
|
171
|
+
contributeReceipts({ limit = 50, offset = 0 } = {}) {
|
|
172
|
+
return this._t.request(this._base, "GET", "/api/v1/contribute/receipts", { params: { limit, offset } });
|
|
173
|
+
}
|
|
51
174
|
}
|
package/src/joulepai.js
CHANGED
|
@@ -55,6 +55,15 @@ 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();
|
|
63
|
+
const shortfall = Math.max(0, Number(cost) - Number(have));
|
|
64
|
+
return { needed: Number(cost), have: Number(have), shortfall, can_afford: shortfall === 0 };
|
|
65
|
+
}
|
|
66
|
+
|
|
58
67
|
async info() {
|
|
59
68
|
return this._t.request(this._base, "GET", "/wallet/balance/{wid}",
|
|
60
69
|
{ pathParams: { wid: await this._ensureId() } });
|