Skip to content

Commit 2fe0086

Browse files
committed
chore: final cleanup and documentation sync for v1.4.0 release
1 parent e6d093f commit 2fe0086

6 files changed

Lines changed: 26 additions & 9 deletions

File tree

contracts/ConfidentialFinance.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ contract ConfidentialFinance is GatewayCaller {
3939
* @dev Verify if a proposed trade amount is within the encrypted risk threshold.
4040
* This allows an agent to prove it is following its private strategy without revealing the threshold.
4141
*/
42-
function verifyTradeLimit(einput tradeAmountHandle, bytes memory inputProof) public view returns (ebool) {
42+
function verifyTradeLimit(einput tradeAmountHandle, bytes memory inputProof) public returns (ebool) {
4343
require(hasStrategy[msg.sender], "No strategy stored");
4444

4545
euint64 tradeAmount = TFHE.asEuint64(tradeAmountHandle, inputProof);

src/demo-cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async function main() {
2525
console.log(" Delegation Token Issued!\n");
2626

2727
console.log("Step 4: Agent B fetches Agent A's thoughts...");
28-
const thoughts1 = await agentB.fetchMemoryStream(ipnsNameId, delegation.delegation);
28+
const thoughts1 = await agentB.fetchMemoryStream(ipnsNameId, delegation);
2929
console.log(` 🤖 Agent B read: ${JSON.stringify(thoughts1)}\n`);
3030

3131
console.log("Step 5: Agent A executes a task and updates its thoughts...");
@@ -36,7 +36,7 @@ async function main() {
3636
});
3737

3838
console.log("\nStep 6: Agent B fetches from the EXACT SAME IPNS Name and sees the update!");
39-
const thoughts2 = await agentB.fetchMemoryStream(ipnsNameId, delegation.delegation);
39+
const thoughts2 = await agentB.fetchMemoryStream(ipnsNameId, delegation);
4040
console.log(` 🤖 Agent B read: ${JSON.stringify(thoughts2)}\n`);
4141

4242
console.log("🚀 DEMONSTRATION COMPLETE!");

src/lib/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ export { StorachaService } from './storacha.js';
33
export { UcanService } from './ucan.js';
44
export { AgentDbLangchainMemory } from './langchain.js';
55
export { EncryptionService } from './encryption.js';
6+
export { AgentDbOpenClawMemory } from './openclaw.js';
7+
export { LitVincentService } from './lit-vincent.js';
68
export * from './errors.js';
79

src/lib/storacha.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ export class StorachaService {
88
// Persistent local cache directory for simulated memories when Storacha space is missing.
99
private static STORAGE_DIR = path.join(process.cwd(), '.agent_storage');
1010

11+
// Cached Storacha client (singleton to avoid re-creating on every call)
12+
private static _cachedClient: any = null;
13+
14+
/**
15+
* Returns a cached Storacha client instance.
16+
*/
17+
private static async getClient() {
18+
if (!StorachaService._cachedClient) {
19+
StorachaService._cachedClient = await create();
20+
}
21+
return StorachaService._cachedClient;
22+
}
23+
1124
/**
1225
* Initializes the local storage directory.
1326
*/
@@ -53,7 +66,7 @@ export class StorachaService {
5366
await StorachaService.ensureCacheDir();
5467
try {
5568
return await StorachaService.withRetry(async () => {
56-
const client = await create();
69+
const client = await StorachaService.getClient();
5770
const blob = new Blob([JSON.stringify(memory)], { type: 'application/json' });
5871
const files = [new File([blob], 'memory.json')];
5972

@@ -120,7 +133,7 @@ export class StorachaService {
120133
* @returns The CID where the delegation token is stored.
121134
*/
122135
static async publishDelegation(delegationBytes: Uint8Array): Promise<string> {
123-
const client = await create();
136+
const client = await StorachaService.getClient();
124137

125138
const blob = new Blob([delegationBytes as any], { type: 'application/vnd.ipld.car' });
126139
const files = [new File([blob], 'delegation.car')];
@@ -162,7 +175,7 @@ export class StorachaService {
162175
* @returns The CID of the uploaded content.
163176
*/
164177
static async uploadRaw(data: Uint8Array, filename: string, mimeType: string = 'application/octet-stream'): Promise<string> {
165-
const client = await create();
178+
const client = await StorachaService.getClient();
166179

167180
const blob = new Blob([data as any], { type: mimeType });
168181
const files = [new File([blob], filename)];

src/mcp-server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
158158
capability: string;
159159
expiry_hours: number
160160
};
161-
const token = await activeAgent.delegateTo(target_did, capability || "agent/read", expiry_hours || 24);
161+
const targetPrincipal = { did: () => target_did };
162+
const delegation = await activeAgent.delegateTo(targetPrincipal, capability || "agent/read", expiry_hours || 24);
163+
const base64Token = await activeAgent.exportDelegationForApi(delegation);
162164
return {
163-
content: [{ type: "text", text: `Access delegated. UCAN Token: ${token}` }],
165+
content: [{ type: "text", text: `Access delegated to ${target_did}. UCAN Token (base64): ${base64Token}` }],
164166
};
165167
}
166168

src/test-cold-start.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async function main() {
5353
const delegation = await agent.delegateTo(subAgent, 'agent/read');
5454
console.log(` ✅ Issued delegation UCAN to sub-agent.`);
5555

56-
const verification = agent.verifyIncoming(delegation);
56+
const verification = agent.verifyIncoming(delegation, agent.did);
5757
console.log(` Verification for sub-agent: ${verification.valid ? '✅ VALID' : '❌ INVALID'}`);
5858
console.log('');
5959

0 commit comments

Comments
 (0)