@stacknet/stacks 0.1.0
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/README.md +103 -0
- package/dist/billing-BaJlf_S8.d.cts +1154 -0
- package/dist/billing-BaJlf_S8.d.ts +1154 -0
- package/dist/clients/index.cjs +4 -0
- package/dist/clients/index.d.cts +752 -0
- package/dist/clients/index.d.ts +752 -0
- package/dist/clients/index.js +4 -0
- package/dist/index-DVzKiF_0.d.cts +198 -0
- package/dist/index-DVzKiF_0.d.ts +198 -0
- package/dist/index.cjs +17 -0
- package/dist/index.d.cts +309 -0
- package/dist/index.d.ts +309 -0
- package/dist/index.js +17 -0
- package/dist/proxy/index.cjs +2 -0
- package/dist/proxy/index.d.cts +1 -0
- package/dist/proxy/index.d.ts +1 -0
- package/dist/proxy/index.js +2 -0
- package/dist/streaming/index.cjs +13 -0
- package/dist/streaming/index.d.cts +145 -0
- package/dist/streaming/index.d.ts +145 -0
- package/dist/streaming/index.js +13 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +335 -0
- package/dist/types/index.d.ts +335 -0
- package/dist/types/index.js +1 -0
- package/package.json +75 -0
- package/src/clients/agents.ts +233 -0
- package/src/clients/billing.ts +157 -0
- package/src/clients/coder.ts +655 -0
- package/src/clients/files.ts +86 -0
- package/src/clients/index.ts +93 -0
- package/src/clients/magma.ts +299 -0
- package/src/clients/mcp.ts +208 -0
- package/src/clients/network.ts +118 -0
- package/src/clients/points.ts +403 -0
- package/src/clients/skills.ts +236 -0
- package/src/clients/social.ts +286 -0
- package/src/clients/stack-management.ts +279 -0
- package/src/clients/task-network.ts +303 -0
- package/src/clients/user.ts +84 -0
- package/src/clients/widgets.ts +171 -0
- package/src/index.ts +387 -0
- package/src/managers/index.ts +10 -0
- package/src/managers/task-manager.ts +310 -0
- package/src/proxy/forwarder.ts +146 -0
- package/src/proxy/index.ts +32 -0
- package/src/proxy/route-handlers.ts +950 -0
- package/src/streaming/component-stream.ts +319 -0
- package/src/streaming/index.ts +21 -0
- package/src/streaming/sse.ts +241 -0
- package/src/types/agent.ts +106 -0
- package/src/types/billing.ts +87 -0
- package/src/types/chat.ts +58 -0
- package/src/types/coder.ts +345 -0
- package/src/types/credential.ts +111 -0
- package/src/types/file.ts +15 -0
- package/src/types/imagination.ts +50 -0
- package/src/types/index.ts +20 -0
- package/src/types/mcp.ts +35 -0
- package/src/types/network.ts +97 -0
- package/src/types/points.ts +250 -0
- package/src/types/skill.ts +107 -0
- package/src/types/social.ts +109 -0
- package/src/types/stack.ts +269 -0
- package/src/types/task.ts +41 -0
- package/src/types/user.ts +29 -0
- package/src/types/widget.ts +57 -0
- package/src/utils/constants.ts +26 -0
- package/src/utils/errors.ts +169 -0
- package/src/utils/helpers.ts +85 -0
- package/src/utils/index.ts +7 -0
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @stacknet/stacks
|
|
2
|
+
|
|
3
|
+
SDK for connecting to StackNet.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @stacknet/stacks
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { TaskNetworkClient, MagmaClient, SocialClient } from '@stacknet/stacks';
|
|
15
|
+
|
|
16
|
+
// Create clients
|
|
17
|
+
const taskClient = new TaskNetworkClient({
|
|
18
|
+
baseUrl: process.env.GLAYER_NETWORK_URL || 'https://stacknet.magma-rpc.com',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const magmaClient = new MagmaClient({
|
|
22
|
+
localServerUrl: process.env.GLAYER_NETWORK_URL || 'https://stacknet.magma-rpc.com',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Stream chat completions
|
|
26
|
+
for await (const chunk of taskClient.chatCompletions({
|
|
27
|
+
model: 'qwen3:30b',
|
|
28
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
29
|
+
stream: true,
|
|
30
|
+
})) {
|
|
31
|
+
console.log(chunk.choices[0]?.delta?.content);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Store imagination
|
|
35
|
+
await magmaClient.storeImagination({
|
|
36
|
+
id: 'my-imagination',
|
|
37
|
+
title: 'My Imagination',
|
|
38
|
+
createdAt: new Date().toISOString(),
|
|
39
|
+
createdBy: 'user-123',
|
|
40
|
+
sources: [],
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Social Network API
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { SocialClient } from '@stacknet/stacks';
|
|
48
|
+
|
|
49
|
+
const socialClient = new SocialClient({
|
|
50
|
+
baseUrl: process.env.GLAYER_NETWORK_URL || 'https://stacknet.magma-rpc.com',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Get feed
|
|
54
|
+
const feed = await socialClient.getFeed({ page: 1, limit: 20, mediaType: 'image' });
|
|
55
|
+
|
|
56
|
+
// Get single post
|
|
57
|
+
const post = await socialClient.getPost('post-id');
|
|
58
|
+
|
|
59
|
+
// Like/unlike
|
|
60
|
+
await socialClient.likePost('post-id', 'user-mid');
|
|
61
|
+
await socialClient.unlikePost('post-id', 'user-mid');
|
|
62
|
+
|
|
63
|
+
// Add comment
|
|
64
|
+
await socialClient.addComment('post-id', 'user-mid', 'Great post!');
|
|
65
|
+
|
|
66
|
+
// Create post
|
|
67
|
+
await socialClient.createPost({
|
|
68
|
+
creatorMid: 'user-mid',
|
|
69
|
+
content: 'My new post',
|
|
70
|
+
mediaUrl: 'https://example.com/image.jpg',
|
|
71
|
+
mediaType: 'image',
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Next.js Route Handlers
|
|
76
|
+
|
|
77
|
+
Simplify your API routes with pre-built handlers:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
// app/api/agents/route.ts
|
|
81
|
+
import { createAgentRoutes } from '@stacknet/stacks/proxy';
|
|
82
|
+
|
|
83
|
+
const config = { baseUrl: process.env.GLAYER_NETWORK_URL };
|
|
84
|
+
export const { GET, POST } = createAgentRoutes(config);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Features
|
|
88
|
+
|
|
89
|
+
- **TaskNetworkClient**: OpenAI-compatible streaming chat completions
|
|
90
|
+
- **MagmaClient**: File storage and imagination management
|
|
91
|
+
- **MCPClient**: Model Context Protocol integration
|
|
92
|
+
- **SocialClient**: Social network feed, posts, likes, comments, and analytics
|
|
93
|
+
- **TaskManager**: Redis-backed task state management
|
|
94
|
+
- **SSE Streaming**: Server-Sent Events utilities
|
|
95
|
+
- **Proxy Route Factories**: Pre-built Next.js API route handlers
|
|
96
|
+
|
|
97
|
+
## Documentation
|
|
98
|
+
|
|
99
|
+
See the [full documentation](./docs) for detailed API reference.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT
|