Skip to content

Commit 0b91021

Browse files
Copilot0xrinegade
andcommitted
Integrate TypeScript SDK docs into main website documentation system
Co-authored-by: 0xrinegade <[email protected]>
1 parent 05a163a commit 0b91021

File tree

5 files changed

+1805
-7
lines changed

5 files changed

+1805
-7
lines changed

docs/TYPESCRIPT_SDK_API_REFERENCE.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
The `aea-sdk` TypeScript SDK provides comprehensive access to the Solana AI Registries ecosystem, including Agent Registry and MCP Server Registry functionality.
66

7+
## 🚀 Quick Access
8+
9+
**[📖 Complete TypeScript SDK Documentation](/docs.html#typescript-sdk)**
10+
11+
Click the link above to access the full TypeScript SDK documentation through our interactive documentation portal.
12+
713
## SDK Location
814

915
The TypeScript SDK is located at: [`sdk/typescript/`](../sdk/typescript/)
@@ -29,6 +35,7 @@ This will generate HTML documentation in the `docs/` folder that you can open in
2935
When the SDK is published to npm, the API documentation will be available at:
3036
- npm package: `aea-sdk`
3137
- Repository: [TypeScript SDK](../sdk/typescript/)
38+
- **[Interactive Docs](/docs.html#typescript-sdk)**: Complete documentation with examples
3239

3340
## Quick Start
3441

@@ -95,10 +102,12 @@ See the [TypeScript SDK Implementation Guidelines](./TYPESCRIPT_SDK_IMPLEMENTATI
95102
- [SDK Implementation Guidelines](./TYPESCRIPT_SDK_IMPLEMENTATION_GUIDELINES.md)
96103
- [SDK Roadmap](./SDK_ROADMAP_DETAILED.md)
97104
- [TypeScript SDK References](./sdk_refs/typescript_sdk_references.md)
105+
- **[📖 Complete Interactive Documentation](/docs.html#typescript-sdk)**
98106

99107
## Support
100108

101109
For issues and questions related to the TypeScript SDK:
102110
- Create an issue in the [GitHub repository](https://github.com/openSVM/aeamcp/issues)
103111
- Check the [examples](../sdk/typescript/examples/) for common patterns
104-
- Review the generated TypeDoc documentation for detailed API reference
112+
- Review the generated TypeDoc documentation for detailed API reference
113+
- Visit our [interactive documentation portal](/docs.html#typescript-sdk)

frontend/public/docs.html

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ <h2 class="text-xl font-bold mb-4">Documentation</h2>
5555
const docFiles = [
5656
{ id: 'readme', name: 'Overview', path: '/docs/README.md' },
5757
{ id: 'protocol', name: 'Protocol Specification', path: '/docs/protocol-specification.md' },
58+
{ id: 'typescript-sdk', name: '🚀 TypeScript SDK', path: '/docs/typescript-sdk.md' },
5859
{ id: 'svmai', name: '$SVMAI Token', path: '/docs/svmai-token.md' },
5960
{ id: 'usecases', name: 'Use Cases', path: '/docs/use-cases.md' },
6061
{ id: 'developer', name: 'Developer Guide', path: '/docs/developer-guide.md' }
@@ -301,6 +302,36 @@ <h2 class="font-bold">Error Loading Book Chapter</h2>
301302
docNav.appendChild(li);
302303
});
303304

305+
// Add separator for SDK section
306+
const sdkSeparator = document.createElement('li');
307+
sdkSeparator.innerHTML = '<hr class="my-4 border-neutral-400"><h3 class="text-lg font-bold mb-2 text-neutral-700">🔧 SDK Documentation</h3>';
308+
docNav.appendChild(sdkSeparator);
309+
310+
// Add SDK-specific documentation
311+
const sdkDocs = [
312+
{ id: 'sdk-roadmap', name: 'SDK Roadmap', path: '/docs/SDK_ROADMAP_DETAILED.md' },
313+
{ id: 'sdk-implementation', name: 'TypeScript Implementation Guide', path: '/docs/TYPESCRIPT_SDK_IMPLEMENTATION_GUIDELINES.md' }
314+
];
315+
316+
sdkDocs.forEach(doc => {
317+
const li = document.createElement('li');
318+
const a = document.createElement('a');
319+
a.href = `#${doc.id}`;
320+
a.dataset.path = doc.path;
321+
a.className = 'block p-2 hover:bg-neutral-200 rounded focus:outline-none focus:ring-2 focus:ring-neutral-400';
322+
a.innerText = doc.name;
323+
a.setAttribute('role', 'menuitem');
324+
a.addEventListener('click', (e) => {
325+
e.preventDefault();
326+
loadMarkdown(doc.path);
327+
currentBookChapter = null; // Reset book chapter tracking
328+
updateNavigationState(a);
329+
window.location.hash = doc.id;
330+
});
331+
li.appendChild(a);
332+
docNav.appendChild(li);
333+
});
334+
304335
// Add separator for book section
305336
const separator = document.createElement('li');
306337
separator.innerHTML = '<hr class="my-4 border-neutral-400"><h3 class="text-lg font-bold mb-2 text-neutral-700">📚 Tutorial Book</h3>';
@@ -360,12 +391,23 @@ <h2 class="font-bold">Error Loading Book Chapter</h2>
360391
docToLoad = matchingDoc.path;
361392
navItem = document.querySelector(`#doc-nav a[data-path="${docToLoad}"]`);
362393
} else {
363-
// Check if it's a book chapter
364-
const matchingChapter = bookChapters.find(ch => ch.id === hash);
365-
if (matchingChapter) {
366-
loadBookChapter(matchingChapter);
367-
navItem = document.querySelector(`#doc-nav a[data-path="${matchingChapter.path}"]`);
368-
isBookChapter = true;
394+
// Check if it's an SDK doc
395+
const sdkDocs = [
396+
{ id: 'sdk-roadmap', name: 'SDK Roadmap', path: '/docs/SDK_ROADMAP_DETAILED.md' },
397+
{ id: 'sdk-implementation', name: 'TypeScript Implementation Guide', path: '/docs/TYPESCRIPT_SDK_IMPLEMENTATION_GUIDELINES.md' }
398+
];
399+
const matchingSdkDoc = sdkDocs.find(doc => doc.id === hash);
400+
if (matchingSdkDoc) {
401+
docToLoad = matchingSdkDoc.path;
402+
navItem = document.querySelector(`#doc-nav a[data-path="${docToLoad}"]`);
403+
} else {
404+
// Check if it's a book chapter
405+
const matchingChapter = bookChapters.find(ch => ch.id === hash);
406+
if (matchingChapter) {
407+
loadBookChapter(matchingChapter);
408+
navItem = document.querySelector(`#doc-nav a[data-path="${matchingChapter.path}"]`);
409+
isBookChapter = true;
410+
}
369411
}
370412
}
371413
}
Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
# Solana AI Registries – **SDK Master Plan**
2+
*(coverage = 100 % on-chain instructions + 100 % payment flows)*
3+
4+
---
5+
6+
## 0. Common Artifacts (central repo = `sdk-assets`)
7+
* `idl/agent_registry.json` – Anchor IDL (v1 hash: `b6e4…`)
8+
* `idl/mcp_server_registry.json` – Anchor IDL (v1 hash: `c1fd…`)
9+
* `idl/svmai_token.json` – SPL-mint interface
10+
* `schemas/payment-metadata.schema.json` – strict JSON Schema (draft-2020-12)
11+
* `fixtures/`
12+
* `agent-card.valid.json` / `agent-card.invalid.json`
13+
* `mcp-card.valid.json` / `mcp-card.invalid.json`
14+
* `pricing-metadata.valid.json`
15+
* CI job `verify-idl-hash` → blocks merge if IDL hash drift detected.
16+
17+
---
18+
19+
## 1. **Rust crate** `solana_ai_registries`
20+
### 1.1 Crate layout (`src/`)
21+
| File | Purpose |
22+
| ---- | ------- |
23+
| `lib.rs` | re-exports + feature gates |
24+
| `agent/mod.rs` | high-level builder, typed requests |
25+
| `mcp/mod.rs` | same for servers |
26+
| `payments/mod.rs` | three flow engines |
27+
| `client.rs` | wrapper around `solana_client::rpc_client::RpcClient` |
28+
| `errors.rs` | `#[error_code]` mirrored enums |
29+
| `idl.rs` | compile-time inclusion of JSON IDLs |
30+
31+
### 1.2 Public API (excerpt)
32+
```rust
33+
pub fn register_agent(cx: &Signer, args: AgentArgs) -> Result<Signature>;
34+
pub fn update_agent(cx: &Signer, id: &str, patch: AgentPatch) -> Result<Signature>;
35+
pub fn pay_pyg(cx: &Signer, mint: Pubkey, lamports: u64, treasury: Pubkey) -> Result<Signature>;
36+
```
37+
38+
### 1.3 Tests
39+
* `tests/agent_flow.rs` – covers full CRUD, 26 cases.
40+
* `tests/payment_pyg.rs` – CU budget + balance assertions.
41+
* Snapshot tests against devnet ledger replay (`ledger/devnet/`).
42+
43+
### 1.4 Release
44+
* Feature flags: `stream`, `pyg`, `prepay`.
45+
* `cargo publish` gated by `cargo deny` and MSRV 1.74.
46+
47+
---
48+
49+
## 2. **TypeScript package** `@svmai/registries`
50+
### 2.1 Directory tree
51+
```
52+
src/
53+
agent.ts // AgentAPI class
54+
mcp.ts // MCPAPI class
55+
payments/
56+
prepay.ts
57+
pyg.ts
58+
stream.ts
59+
utils/
60+
idl.ts // cached IDL loader
61+
borsh.ts // Borsh helpers
62+
examples/
63+
register-agent.ts
64+
update-server.ts
65+
pay-pyg.ts
66+
```
67+
### 2.2 Key functions
68+
```ts
69+
registerAgent(connection, signer, card: AgentCard): Promise<string>;
70+
payAsYouGo(connection, signer, cfg: PayCfg): Promise<string>;
71+
```
72+
### 2.3 Tooling
73+
* Built with TS 5.5, target ES2022.
74+
* Strict ESM + type exports.
75+
* Jest + `@solana/web3.js` local validator fixture.
76+
* `npm run docs` → typedoc.
77+
78+
---
79+
80+
## 3. **Go module** `github.com/svmai/registries`
81+
### 3.1 Packages
82+
* `client` – RPC + Tx builder
83+
* `agent` / `mcp` – high-level ops
84+
* `payments` – flow implementations
85+
* `idl` – generated `go:embed` structs
86+
87+
### 3.2 Example
88+
```go
89+
agent.Register(ctx, rpc, signer, agent.Card{ID:"bot-1", …})
90+
payments.PayPYG(ctx, rpc, signer, payments.Config{Mint: svmaiMint, …})
91+
```
92+
### 3.3 QA
93+
`go test ./... -run TestIntegration -tags=devnet`
94+
95+
---
96+
97+
## 4. **Python package** `svmai-registries`
98+
### 4.1 Modules
99+
* `ai_registries.agent` / `ai_registries.mcp`
100+
* `ai_registries.payments` (async)
101+
* `ai_registries.idl` – lazy-loaded via `anchorpy.Idl`.
102+
103+
### 4.2 API surfaces
104+
```python
105+
sig = await Agent.register(agent_card, payer, client)
106+
await Payments.pay_pyg(amount=1_000_000, mint=SVMAI_MINT, payer=payer)
107+
```
108+
### 4.3 Docs
109+
* Sphinx → RTD publish.
110+
* Jupyter notebooks under `examples/`.
111+
112+
---
113+
114+
## 5. **C SDK** `libaireg`
115+
### 5.1 Files
116+
```
117+
include/aireg.h // 62 exported funcs
118+
src/agent.c
119+
src/mcp.c
120+
src/payments.c
121+
bindings/solana/ // from anchor-gen
122+
examples/register.c
123+
```
124+
### 5.2 Build
125+
```bash
126+
cmake -B build && cmake --build build
127+
```
128+
### 5.3 ABI
129+
* Follows `solana-c` account structs; all pointers validated; returns `AI_ERR_*` codes.
130+
131+
---
132+
133+
## 6. **C++17 wrapper** `aireg++`
134+
* Header-only `aireg.hpp`, uses namespaces and RAII.
135+
* Bridges to `libaireg` via `extern "C"`.
136+
137+
---
138+
139+
## 7. Payment Flow Support (matrix)
140+
141+
| SDK | Pre-pay | Pay-as-you-go | Stream (Lights.so) |
142+
|-----|---------|--------------|--------------------|
143+
| Rust |`payments::prepay` |`payments::pyg` | ✓ feature `stream` |
144+
| TS ||||
145+
| Go ||| ✓ via interface |
146+
| Py ||| ✓ (async tasks) |
147+
| C ||| ✗ (planned Q3) |
148+
| C++ ||| ✗ (inherits C) |
149+
150+
---
151+
152+
## 8. Example Scenario Walkthrough (`demos/e2e/`)
153+
1. `01_mint_svmai.sh` → creates mint + treasury ATA.
154+
2. `02_register_mcp.<lang>` → register server, attach `pricing-metadata.json` (Arweave upload script).
155+
3. `03_client_pay_and_call.<lang>` → perform PYG payment, then HTTP RPC call, then parse JSON response.
156+
157+
---
158+
159+
## 9. Milestones (calendar-week granularity)
160+
161+
| Week | Deliverable | Owner | Exit Criteria |
162+
|------|-------------|-------|---------------|
163+
| 24-25 | Rust core + tests | Core team | 100 % instruction coverage |
164+
| 25-26 | TS parity | Frontend | npm v0.1 published |
165+
| 26-27 | Python + Go autogen | SDK guild | devnet demo passes |
166+
| 27-28 | C base + C++ wrapper | Systems | CI on Ubuntu + macOS |
167+
| 29 | Cross-lang e2e + docs | Docs squad | All demos succeed on CI |
168+
169+
---
170+
171+
## 10. CI Matrix (`.github/workflows/sdk.yml`)
172+
* Linux & macOS runners
173+
* Job 1 Rust → `cargo test --all --features stream`
174+
* Job 2 Node 20 → `npm test`
175+
* Job 3 Go 1.22 → `go test ./...`
176+
* Job 4 Python 3.12 → `pytest`
177+
* Job 5 C/C++ → `cmake --build` + `ctest`
178+
* Job 6 E2E devnet spin-up → shell scripts execute demos in all languages.
179+
180+
---
181+
## 11. GitHub Actions – *Package-manager Publishing*
182+
183+
```yaml
184+
# .github/workflows/publish.yml
185+
name: Publish SDKs
186+
187+
on:
188+
push:
189+
tags:
190+
- 'sdk/**' # e.g. sdk/ts/v0.1.2, sdk/rust/v1.0.0 …
191+
192+
permissions:
193+
contents: read
194+
id-token: write # OIDC for crates.io / PyPI / npm / etc.
195+
196+
jobs:
197+
# ───────────────────────────────────────── Rust ─────────────────────────────────────────
198+
rust-crate:
199+
if: startsWith(github.ref, 'refs/tags/sdk/rust/')
200+
runs-on: ubuntu-latest
201+
defaults: { run: { working-directory: rust } }
202+
steps:
203+
- uses: actions/checkout@v4
204+
- uses: dtolnay/rust-toolchain@stable
205+
- run: cargo publish --token ${{ secrets.CARGO_TOKEN }}
206+
207+
# ─────────────────────────────────── TypeScript / npm ───────────────────────────────────
208+
node-package:
209+
if: startsWith(github.ref, 'refs/tags/sdk/ts/')
210+
runs-on: ubuntu-latest
211+
defaults: { run: { working-directory: typescript } }
212+
steps:
213+
- uses: actions/checkout@v4
214+
- uses: actions/setup-node@v4
215+
with:
216+
registry-url: 'https://registry.npmjs.org'
217+
node-version: '20'
218+
- run: npm ci
219+
- run: npm publish --access public
220+
env:
221+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
222+
223+
# ───────────────────────────────────────── Go / goproxy ─────────────────────────────────
224+
go-module:
225+
if: startsWith(github.ref, 'refs/tags/sdk/go/')
226+
runs-on: ubuntu-latest
227+
defaults: { run: { working-directory: go } }
228+
steps:
229+
- uses: actions/checkout@v4
230+
- run: go test ./...
231+
- name: Create version tag for Go proxy
232+
run: git tag $(echo $GITHUB_REF | cut -d'/' -f4) && git push --tags
233+
234+
# ───────────────────────────────────────── Python / PyPI ────────────────────────────────
235+
python-package:
236+
if: startsWith(github.ref, 'refs/tags/sdk/py/')
237+
runs-on: ubuntu-latest
238+
defaults: { run: { working-directory: python } }
239+
steps:
240+
- uses: actions/checkout@v4
241+
- uses: actions/setup-python@v5
242+
with: { python-version: '3.12' }
243+
- run: pip install build
244+
- run: python -m build
245+
- uses: pypa/gh-action-pypi-publish@release/v1
246+
with:
247+
api-token: ${{ secrets.PYPI_TOKEN }}
248+
249+
# ───────────────────────────────────────── C / C++ artefacts ────────────────────────────
250+
c-binaries:
251+
if: startsWith(github.ref, 'refs/tags/sdk/c/')
252+
runs-on: ubuntu-latest
253+
defaults: { run: { working-directory: c } }
254+
steps:
255+
- uses: actions/checkout@v4
256+
- run: cmake -B build && cmake --build build --target package
257+
- uses: softprops/action-gh-release@v1
258+
with:
259+
files: build/*.tar.gz
260+
261+
cpp-binaries:
262+
if: startsWith(github.ref, 'refs/tags/sdk/cpp/')
263+
runs-on: ubuntu-latest
264+
defaults: { run: { working-directory: cpp } }
265+
steps:
266+
- uses: actions/checkout@v4
267+
- run: cmake -B build && cmake --build build --target package
268+
- uses: softprops/action-gh-release@v1
269+
with:
270+
files: build/*.tar.gz
271+
```
272+
273+
**Tag convention**
274+
275+
| SDK | Tag prefix example |
276+
| --- | ------------------ |
277+
| Rust | `sdk/rust/v1.0.0` |
278+
| TypeScript | `sdk/ts/v0.3.1` |
279+
| Go | `sdk/go/v1.2.0` |
280+
| Python | `sdk/py/v0.2.4` |
281+
| C | `sdk/c/v0.1.0` |
282+
| C++ | `sdk/cpp/v0.1.0` |
283+
284+
Each job is gated by prefix match and publishes to the corresponding ecosystem using OIDC-based secrets (`CARGO_TOKEN`, `NPM_TOKEN`, `PYPI_TOKEN`).

0 commit comments

Comments
 (0)