Skip to content

Commit b546dc0

Browse files
0xrinegadeclaude
andcommitted
feat(ovsm): Add agent marketplace, LLM stdlib, and Python SDK
OVSM Compiler & Runtime: - Add register allocation analyzer for sBPF backend - Add new IR instructions for marketplace operations - Add LLM tool integration to stdlib (llm.rs) - Update SBPF compiler builtins documentation Agent Marketplace: - Add marketplace_agent.ovsm - full economic agent example - Add autonomous_agent.ovsm - self-directed agent behavior - Add simple_agent.ovsm - minimal agent template - Add smart_agent.ovsm - intelligent decision-making agent - Add aggressive_agent.ovsm - competitive pricing strategy - Add competitive_agent.ovsm - market-aware bidding - Add handle_accept.ovsm - offer acceptance handler Python SDK: - Add sdk/python with setup.py for package distribution - Add economic_marketplace.py example - Add live_marketplace.py example CLI Integration: - Add OVSM marketplace subcommand parsing - Add marketplace handler in ovsm_handler.rs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 0f40985 commit b546dc0

21 files changed

+3000
-10
lines changed

crates/ovsm/CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.0.7] - 2025-11-27
11+
12+
### Added
13+
- 🔧 **Cross-Program Invocation (CPI) Support** - Call other Solana programs from OVSM
14+
- `system-transfer` - High-level SOL transfer via System Program CPI
15+
- `invoke` - Low-level CPI for custom instruction structures
16+
- `invoke-signed` - PDA-signed CPI for program-derived addresses
17+
- 📝 **CPI Data Structures** - Complete Solana C ABI support
18+
- SolInstruction (40 bytes): program_id, accounts, data
19+
- SolAccountMeta (16 bytes): pubkey, is_writable, is_signer
20+
- 🧪 **SOL Transfer Demo** - Working program deployed to devnet
21+
- Program: `EGEowb4hXCU34KUvWnUVizZAFmB5K6u4tTM1WGLk4LEe`
22+
23+
### Known Issues
24+
- 🐛 **CPI heap allocation**: Large constant addresses (0x300000000) may not load correctly due to register spilling
25+
- Workaround: Use stack-based allocation with R10 offsets (not yet implemented)
26+
- Alternative: Use simpler programs without CPI for now
27+
28+
### Technical Details
29+
- CPI uses `sol_invoke_signed_c` syscall (Murmur3 hash: 2720767109)
30+
- Heap region available at 0x300000000 (32KB)
31+
- System Program Transfer instruction: [u32 index=2][u64 amount]
32+
1033
## [1.0.6] - 2025-11-26
1134

1235
### Added

crates/ovsm/SBPF_COMPILER_BUILTINS.md

Lines changed: 136 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
Reference guide for built-in functions available when compiling OVSM to Solana sBPF bytecode.
44

5-
**Version:** 1.0.5
6-
**Last Updated:** 2025-11-25
5+
**Version:** 1.0.7
6+
**Last Updated:** 2025-11-27
77
**Tested On:** Solana Devnet
88

99
---
@@ -13,13 +13,15 @@ Reference guide for built-in functions available when compiling OVSM to Solana s
1313
1. [Overview](#overview)
1414
2. [Account Access Functions](#account-access-functions)
1515
3. [Memory Operations](#memory-operations)
16-
4. [Logging Syscalls](#logging-syscalls)
17-
5. [Control Flow](#control-flow)
18-
6. [Arithmetic Operations](#arithmetic-operations)
19-
7. [Comparison Operations](#comparison-operations)
20-
8. [Built-in Variables](#built-in-variables)
21-
9. [Complete Examples](#complete-examples)
22-
10. [Solana Account Memory Layout](#solana-account-memory-layout)
16+
4. [Instruction Data](#instruction-data)
17+
5. [Cross-Program Invocation (CPI)](#cross-program-invocation-cpi)
18+
6. [Logging Syscalls](#logging-syscalls)
19+
7. [Control Flow](#control-flow)
20+
8. [Arithmetic Operations](#arithmetic-operations)
21+
9. [Comparison Operations](#comparison-operations)
22+
10. [Built-in Variables](#built-in-variables)
23+
11. [Complete Examples](#complete-examples)
24+
12. [Solana Account Memory Layout](#solana-account-memory-layout)
2325

2426
---
2527

@@ -280,6 +282,131 @@ Low-level memory access for reading/writing account data.
280282

281283
---
282284

285+
## Instruction Data
286+
287+
Functions for accessing instruction data passed to your program.
288+
289+
### `instruction-data-len`
290+
291+
**Signature:** `(instruction-data-len)`
292+
**Description:** Get the length of instruction data in bytes
293+
**Returns:** u64 - Number of bytes of instruction data
294+
**Tested:** ✅ Verified on devnet
295+
296+
```lisp
297+
;; Check if we have enough instruction data
298+
(if (>= (instruction-data-len) 8)
299+
(sol_log_ "Got enough data")
300+
(sol_log_ "Need at least 8 bytes"))
301+
```
302+
303+
---
304+
305+
### `instruction-data-ptr`
306+
307+
**Signature:** `(instruction-data-ptr)`
308+
**Description:** Get pointer to instruction data buffer
309+
**Returns:** u64 - Pointer to instruction data
310+
**Tested:** ✅ Verified on devnet
311+
312+
```lisp
313+
;; Read first 8 bytes as u64 from instruction data
314+
(define amount (mem-load (instruction-data-ptr) 0))
315+
(sol_log_ "Amount from instruction:")
316+
(sol_log_64_ amount)
317+
```
318+
319+
---
320+
321+
## Cross-Program Invocation (CPI)
322+
323+
Functions for calling other Solana programs from your OVSM program.
324+
325+
> **Note:** CPI currently has a known issue with heap address loading. The functions compile and deploy correctly, but may fail at runtime due to register spilling of large constant addresses. This is being actively fixed.
326+
327+
### `system-transfer`
328+
329+
**Signature:** `(system-transfer src_idx dest_idx amount)`
330+
**Description:** Transfer SOL from one account to another via System Program CPI
331+
**Parameters:**
332+
- `src_idx` - Account index of source (must be signer)
333+
- `dest_idx` - Account index of destination
334+
- `amount` - Lamports to transfer
335+
**Returns:** u64 - 0 on success, error code on failure
336+
**Status:** ⚠️ Compiles but runtime issue pending fix
337+
338+
```lisp
339+
;; Transfer 0.001 SOL from account 0 to account 1
340+
(define result (system-transfer 0 1 1000000))
341+
(if (= result 0)
342+
(sol_log_ "Transfer successful!")
343+
(sol_log_ "Transfer failed"))
344+
```
345+
346+
---
347+
348+
### `invoke`
349+
350+
**Signature:** `(invoke instruction-ptr account-infos-ptr num-accounts)`
351+
**Description:** Low-level CPI for calling any program with custom instruction
352+
**Parameters:**
353+
- `instruction-ptr` - Pointer to SolInstruction struct (40 bytes)
354+
- `account-infos-ptr` - Pointer to account infos array
355+
- `num-accounts` - Number of accounts
356+
**Returns:** u64 - 0 on success, error code on failure
357+
**Status:** ⚠️ Advanced use - requires manual struct building
358+
359+
```lisp
360+
;; For advanced users who build their own instruction structures
361+
(define result (invoke instr-ptr accts-ptr 2))
362+
```
363+
364+
---
365+
366+
### `invoke-signed`
367+
368+
**Signature:** `(invoke-signed instr-ptr acct-infos-ptr num-accts signers-seeds-ptr num-signers)`
369+
**Description:** PDA-signed CPI for program-derived address signing
370+
**Parameters:**
371+
- `instr-ptr` - Pointer to SolInstruction struct
372+
- `acct-infos-ptr` - Pointer to account infos
373+
- `num-accts` - Number of accounts
374+
- `signers-seeds-ptr` - Pointer to signer seeds array
375+
- `num-signers` - Number of PDA signers
376+
**Returns:** u64 - 0 on success, error code on failure
377+
**Status:** ⚠️ Advanced use - requires PDA seed setup
378+
379+
---
380+
381+
### CPI Data Structures Reference
382+
383+
When building custom CPI instructions, use these memory layouts:
384+
385+
**SolInstruction (40 bytes):**
386+
```
387+
+0: u64 program_id_ptr ; Pointer to 32-byte program ID
388+
+8: u64 accounts_ptr ; Pointer to SolAccountMeta array
389+
+16: u64 account_len ; Number of accounts
390+
+24: u64 data_ptr ; Pointer to instruction data
391+
+32: u64 data_len ; Length of instruction data
392+
```
393+
394+
**SolAccountMeta (16 bytes):**
395+
```
396+
+0: u64 pubkey_ptr ; Pointer to 32-byte pubkey
397+
+8: u8 is_writable ; 1 if writable, 0 otherwise
398+
+9: u8 is_signer ; 1 if signer, 0 otherwise
399+
+10: padding (6 bytes)
400+
```
401+
402+
**System Program Transfer Instruction Data (12 bytes):**
403+
```
404+
+0: u32 instruction_index ; 2 for Transfer
405+
+4: u64 lamports ; Amount to transfer
406+
```
407+
408+
---
409+
283410
## Logging Syscalls
284411

285412
Functions for logging to Solana program logs.

0 commit comments

Comments
 (0)