@aithos/sdk 0.1.0-alpha.38 → 0.1.0-alpha.39
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/src/data.d.ts +39 -0
- package/dist/src/data.js +31 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/package.json +11 -10
package/dist/src/data.d.ts
CHANGED
|
@@ -63,6 +63,45 @@ export interface DataClient {
|
|
|
63
63
|
opPrefix?: string;
|
|
64
64
|
verify?: boolean;
|
|
65
65
|
}): Promise<unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Idempotently publish a vendor (`aithos.x.<vendor>.<name>.v<N>`)
|
|
68
|
+
* JSON Schema document to this subject's PDS. Once published, the
|
|
69
|
+
* PDS validates record writes against the schema doc server-side,
|
|
70
|
+
* closing the gap A2a left open (cf. Aithos-protocol/PLAN-A2b-…).
|
|
71
|
+
*
|
|
72
|
+
* Safe to call on every app boot — re-registering the same document
|
|
73
|
+
* (same canonical hash) resolves to `{ created: false }`. A different
|
|
74
|
+
* document for the same `aithos:schema` id is REJECTED with code
|
|
75
|
+
* -32082 `AITHOS_DATA_SCHEMA_IMMUTABLE` ; the caller must bump the
|
|
76
|
+
* version segment in `aithos:schema` and retry.
|
|
77
|
+
*
|
|
78
|
+
* Core schemas (`aithos.<name>.v<N>` without `.x.`) cannot be
|
|
79
|
+
* registered via this RPC ; they're bundled by the platform per spec
|
|
80
|
+
* §3.7.2.
|
|
81
|
+
*
|
|
82
|
+
* @param schemaDoc Full JSON Schema 2020-12 document. MUST carry
|
|
83
|
+
* `aithos:schema` and `aithos:version` top-level fields.
|
|
84
|
+
*/
|
|
85
|
+
registerSchema(schemaDoc: object): Promise<{
|
|
86
|
+
schemaId: string;
|
|
87
|
+
docHash: string;
|
|
88
|
+
created: boolean;
|
|
89
|
+
createdAt?: string;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Fetch a published schema document from the PDS.
|
|
93
|
+
*
|
|
94
|
+
* For core schemas (`aithos.<name>.v<N>`) the lookup is global ;
|
|
95
|
+
* `subjectDid` is ignored. For vendor schemas (`aithos.x.*`) the
|
|
96
|
+
* `subjectDid` arg selects whose published registry to query and
|
|
97
|
+
* defaults to this client's own DID.
|
|
98
|
+
*
|
|
99
|
+
* Returns null when the lookup misses (rather than throwing) so
|
|
100
|
+
* call sites can branch on the result.
|
|
101
|
+
*/
|
|
102
|
+
getSchema(schemaId: string, opts?: {
|
|
103
|
+
subjectDid?: string;
|
|
104
|
+
}): Promise<object | null>;
|
|
66
105
|
/** Drop in-memory cache (CMK, collection metadata, …). */
|
|
67
106
|
reset(): void;
|
|
68
107
|
}
|
package/dist/src/data.js
CHANGED
|
@@ -145,6 +145,37 @@ class DataClientImpl {
|
|
|
145
145
|
params.verify = true;
|
|
146
146
|
return this.#call("/mcp/primitives/read", "aithos.data.list_gamma_entries", params);
|
|
147
147
|
}
|
|
148
|
+
async registerSchema(schemaDoc) {
|
|
149
|
+
if (schemaDoc === null || typeof schemaDoc !== "object" || Array.isArray(schemaDoc)) {
|
|
150
|
+
throw new Error("sdk.data.registerSchema: schemaDoc must be a JSON object");
|
|
151
|
+
}
|
|
152
|
+
const r = (await this.#call("/mcp/primitives/write", "aithos.data.register_schema", {
|
|
153
|
+
subject_did: this.#did,
|
|
154
|
+
schema_doc: schemaDoc,
|
|
155
|
+
}));
|
|
156
|
+
return {
|
|
157
|
+
schemaId: r.schema_id,
|
|
158
|
+
docHash: r.doc_hash,
|
|
159
|
+
created: r.created,
|
|
160
|
+
...(r.created_at ? { createdAt: r.created_at } : {}),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
async getSchema(schemaId, opts = {}) {
|
|
164
|
+
const params = { schema: schemaId };
|
|
165
|
+
// Vendor schemas always need a subject_did to address the right
|
|
166
|
+
// registry ; for core schemas the PDS ignores it but we still send
|
|
167
|
+
// ours so the auth check (envelope iss === subject_did) lines up.
|
|
168
|
+
params.subject_did = opts.subjectDid ?? this.#did;
|
|
169
|
+
try {
|
|
170
|
+
const r = (await this.#call("/mcp/primitives/read", "aithos.data.get_schema", params));
|
|
171
|
+
return r.schema;
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
if (e.code === -32070)
|
|
175
|
+
return null;
|
|
176
|
+
throw e;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
148
179
|
reset() {
|
|
149
180
|
for (const k of this.#cmkCache.values())
|
|
150
181
|
k.fill(0);
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
// Public types specific to the SDK (`AithosSDKConfig`, `AithosSDKError`)
|
|
18
18
|
// are exported from here. Endpoint config (`AithosSdkEndpoints`,
|
|
19
19
|
// `DEFAULT_SDK_ENDPOINTS`) likewise.
|
|
20
|
-
export const VERSION = "0.1.0-alpha.
|
|
20
|
+
export const VERSION = "0.1.0-alpha.39";
|
|
21
21
|
export { AithosSDK } from "./sdk.js";
|
|
22
22
|
export { AithosSDKError } from "./types.js";
|
|
23
23
|
// Re-export protocol-client's JSON-RPC error type so consumers can
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aithos/sdk",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.39",
|
|
4
4
|
"description": "Aithos SDK — high-level TypeScript developer kit for building agentic apps on the Aithos protocol. Wraps @aithos/protocol-client and exposes the Aithos compute proxy and wallet (Stripe top-up) endpoints.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aithos",
|
|
@@ -39,6 +39,15 @@
|
|
|
39
39
|
"README.md",
|
|
40
40
|
"LICENSE"
|
|
41
41
|
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc",
|
|
44
|
+
"build:test": "tsc -p tsconfig.test.json",
|
|
45
|
+
"check-types": "tsc --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
46
|
+
"test": "npm run clean && npm run build && npm run build:test && cd dist && node --test",
|
|
47
|
+
"test:watch": "cd dist && node --test --watch",
|
|
48
|
+
"clean": "rm -rf dist",
|
|
49
|
+
"prepublishOnly": "npm run clean && npm run build && npm test"
|
|
50
|
+
},
|
|
42
51
|
"engines": {
|
|
43
52
|
"node": ">=20"
|
|
44
53
|
},
|
|
@@ -54,13 +63,5 @@
|
|
|
54
63
|
"publishConfig": {
|
|
55
64
|
"access": "public",
|
|
56
65
|
"tag": "alpha"
|
|
57
|
-
},
|
|
58
|
-
"scripts": {
|
|
59
|
-
"build": "tsc",
|
|
60
|
-
"build:test": "tsc -p tsconfig.test.json",
|
|
61
|
-
"check-types": "tsc --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
62
|
-
"test": "npm run clean && npm run build && npm run build:test && cd dist && node --test",
|
|
63
|
-
"test:watch": "cd dist && node --test --watch",
|
|
64
|
-
"clean": "rm -rf dist"
|
|
65
66
|
}
|
|
66
|
-
}
|
|
67
|
+
}
|