@stacknet/stacks 0.1.2 → 0.2.2

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.
Files changed (67) hide show
  1. package/README.md +136 -0
  2. package/dist/{billing-BqscteyZ.d.cts → billing-cj0eSVrp.d.cts} +61 -1
  3. package/dist/{billing-BqscteyZ.d.ts → billing-cj0eSVrp.d.ts} +61 -1
  4. package/dist/clients/index.cjs +4 -4
  5. package/dist/clients/index.d.cts +27 -1
  6. package/dist/clients/index.d.ts +27 -1
  7. package/dist/clients/index.js +4 -4
  8. package/dist/{index-DVzKiF_0.d.cts → index-B_dUFmAg.d.cts} +31 -6
  9. package/dist/{index-DVzKiF_0.d.ts → index-B_dUFmAg.d.ts} +31 -6
  10. package/dist/index.cjs +12 -16
  11. package/dist/index.d.cts +4 -4
  12. package/dist/index.d.ts +4 -4
  13. package/dist/index.js +12 -16
  14. package/dist/proxy/index.cjs +2 -2
  15. package/dist/proxy/index.d.cts +1 -1
  16. package/dist/proxy/index.d.ts +1 -1
  17. package/dist/proxy/index.js +2 -2
  18. package/dist/streaming/index.cjs +8 -12
  19. package/dist/streaming/index.js +8 -12
  20. package/dist/types/index.d.cts +1 -1
  21. package/dist/types/index.d.ts +1 -1
  22. package/package.json +15 -13
  23. package/src/clients/agents.ts +0 -233
  24. package/src/clients/billing.ts +0 -197
  25. package/src/clients/coder.ts +0 -655
  26. package/src/clients/files.ts +0 -86
  27. package/src/clients/index.ts +0 -93
  28. package/src/clients/magma.ts +0 -299
  29. package/src/clients/mcp.ts +0 -208
  30. package/src/clients/network.ts +0 -118
  31. package/src/clients/points.ts +0 -403
  32. package/src/clients/skills.ts +0 -236
  33. package/src/clients/social.ts +0 -286
  34. package/src/clients/stack-management.ts +0 -279
  35. package/src/clients/task-network.ts +0 -303
  36. package/src/clients/user.ts +0 -84
  37. package/src/clients/widgets.ts +0 -171
  38. package/src/index.ts +0 -387
  39. package/src/managers/index.ts +0 -10
  40. package/src/managers/task-manager.ts +0 -310
  41. package/src/proxy/forwarder.ts +0 -146
  42. package/src/proxy/index.ts +0 -32
  43. package/src/proxy/route-handlers.ts +0 -950
  44. package/src/streaming/component-stream.ts +0 -319
  45. package/src/streaming/index.ts +0 -21
  46. package/src/streaming/sse.ts +0 -241
  47. package/src/types/agent.ts +0 -106
  48. package/src/types/billing.ts +0 -121
  49. package/src/types/chat.ts +0 -58
  50. package/src/types/coder.ts +0 -345
  51. package/src/types/credential.ts +0 -111
  52. package/src/types/file.ts +0 -15
  53. package/src/types/imagination.ts +0 -50
  54. package/src/types/index.ts +0 -20
  55. package/src/types/mcp.ts +0 -35
  56. package/src/types/network.ts +0 -97
  57. package/src/types/points.ts +0 -250
  58. package/src/types/skill.ts +0 -107
  59. package/src/types/social.ts +0 -109
  60. package/src/types/stack.ts +0 -269
  61. package/src/types/task.ts +0 -41
  62. package/src/types/user.ts +0 -29
  63. package/src/types/widget.ts +0 -57
  64. package/src/utils/constants.ts +0 -26
  65. package/src/utils/errors.ts +0 -169
  66. package/src/utils/helpers.ts +0 -85
  67. package/src/utils/index.ts +0 -7
@@ -1,171 +0,0 @@
1
- /**
2
- * Widgets Client
3
- * Client for interacting with the widgets API
4
- */
5
-
6
- import { DEFAULT_TASK_NETWORK_URL, JSON_HEADERS } from '../utils/constants';
7
- import { StacksSDKError } from '../utils/errors';
8
- import type {
9
- Widget,
10
- WidgetsListResponse,
11
- WidgetResponse,
12
- WidgetCreateInput,
13
- WidgetUpdateInput,
14
- WidgetSystemPromptResponse,
15
- WidgetsClientConfig,
16
- } from '../types/widget';
17
-
18
- export type { WidgetsClientConfig } from '../types/widget';
19
-
20
- export class WidgetsClient {
21
- private baseUrl: string;
22
-
23
- constructor(config: WidgetsClientConfig = {}) {
24
- this.baseUrl = config.baseUrl || DEFAULT_TASK_NETWORK_URL;
25
- }
26
-
27
- private get widgetsUrl(): string {
28
- return `${this.baseUrl}/widgets`;
29
- }
30
-
31
- /**
32
- * List all widgets
33
- */
34
- async list(options: { scope?: 'public' | 'private'; creatorMid?: string } = {}): Promise<WidgetsListResponse> {
35
- const params = new URLSearchParams();
36
- if (options.creatorMid) {
37
- params.set('creator_mid', options.creatorMid);
38
- } else if (options.scope) {
39
- params.set('scope', options.scope);
40
- }
41
-
42
- const queryString = params.toString();
43
- const url = `${this.widgetsUrl}${queryString ? `?${queryString}` : ''}`;
44
-
45
- const response = await fetch(url);
46
-
47
- if (!response.ok) {
48
- throw new StacksSDKError(
49
- 'bad_request:api',
50
- `Failed to list widgets: ${response.statusText}`
51
- );
52
- }
53
-
54
- return response.json();
55
- }
56
-
57
- /**
58
- * Get a widget by ID
59
- */
60
- async get(id: string): Promise<Widget> {
61
- const response = await fetch(`${this.widgetsUrl}/${id}`);
62
-
63
- if (!response.ok) {
64
- throw new StacksSDKError(
65
- response.status === 404 ? 'not_found:api' : 'bad_request:api',
66
- `Failed to get widget: ${response.statusText}`
67
- );
68
- }
69
-
70
- return response.json();
71
- }
72
-
73
- /**
74
- * Create a new widget
75
- */
76
- async create(input: WidgetCreateInput): Promise<WidgetResponse> {
77
- const response = await fetch(this.widgetsUrl, {
78
- method: 'POST',
79
- headers: JSON_HEADERS,
80
- body: JSON.stringify(input),
81
- });
82
-
83
- if (!response.ok) {
84
- const data = await response.json().catch(() => ({}));
85
- throw new StacksSDKError(
86
- 'bad_request:api',
87
- data.error || `Failed to create widget: ${response.statusText}`
88
- );
89
- }
90
-
91
- return response.json();
92
- }
93
-
94
- /**
95
- * Update a widget
96
- */
97
- async update(id: string, input: WidgetUpdateInput): Promise<WidgetResponse> {
98
- const response = await fetch(`${this.widgetsUrl}/${id}`, {
99
- method: 'PUT',
100
- headers: JSON_HEADERS,
101
- body: JSON.stringify(input),
102
- });
103
-
104
- if (!response.ok) {
105
- const data = await response.json().catch(() => ({}));
106
- throw new StacksSDKError(
107
- 'bad_request:api',
108
- data.error || `Failed to update widget: ${response.statusText}`
109
- );
110
- }
111
-
112
- return response.json();
113
- }
114
-
115
- /**
116
- * Delete a widget
117
- */
118
- async delete(id: string): Promise<{ success: boolean }> {
119
- const response = await fetch(`${this.widgetsUrl}/${id}`, {
120
- method: 'DELETE',
121
- });
122
-
123
- if (!response.ok) {
124
- throw new StacksSDKError(
125
- 'bad_request:api',
126
- `Failed to delete widget: ${response.statusText}`
127
- );
128
- }
129
-
130
- return response.json();
131
- }
132
-
133
- /**
134
- * Get system prompt for widgets
135
- */
136
- async getSystemPrompt(): Promise<WidgetSystemPromptResponse> {
137
- const response = await fetch(`${this.widgetsUrl}/system-prompt`);
138
-
139
- if (!response.ok) {
140
- throw new StacksSDKError(
141
- 'bad_request:api',
142
- `Failed to get widget system prompt: ${response.statusText}`
143
- );
144
- }
145
-
146
- return response.json();
147
- }
148
-
149
- /**
150
- * Track widget usage
151
- */
152
- async trackUsage(id: string): Promise<void> {
153
- await fetch(`${this.widgetsUrl}/${id}/usage`, {
154
- method: 'POST',
155
- }).catch(() => {
156
- // Silently fail usage tracking
157
- });
158
- }
159
- }
160
-
161
- /**
162
- * Create a WidgetsClient instance
163
- */
164
- export function createWidgetsClient(config: WidgetsClientConfig = {}): WidgetsClient {
165
- return new WidgetsClient(config);
166
- }
167
-
168
- /**
169
- * Default widgets client instance
170
- */
171
- export const widgetsClient = createWidgetsClient();
package/src/index.ts DELETED
@@ -1,387 +0,0 @@
1
- /**
2
- * @stacknet/stacks - StackNet Stacks SDK
3
- *
4
- * SDK for connecting to StackNet
5
- */
6
-
7
- // Clients
8
- export {
9
- TaskNetworkClient,
10
- createTaskNetworkClient,
11
- taskNetworkClient,
12
- type TaskNetworkConfig,
13
- } from './clients/task-network';
14
-
15
- export {
16
- MagmaClient,
17
- createMagmaClient,
18
- magmaClient,
19
- type MagmaClientConfig,
20
- } from './clients/magma';
21
-
22
- export {
23
- MCPClient,
24
- createMCPClient,
25
- mcpClient,
26
- } from './clients/mcp';
27
-
28
- export {
29
- SocialClient,
30
- createSocialClient,
31
- socialClient,
32
- type SocialClientConfig,
33
- } from './clients/social';
34
-
35
- export {
36
- AgentsClient,
37
- createAgentsClient,
38
- agentsClient,
39
- type AgentsClientConfig,
40
- } from './clients/agents';
41
-
42
- export {
43
- WidgetsClient,
44
- createWidgetsClient,
45
- widgetsClient,
46
- type WidgetsClientConfig,
47
- } from './clients/widgets';
48
-
49
- export {
50
- UserClient,
51
- createUserClient,
52
- userClient,
53
- type UserClientConfig,
54
- } from './clients/user';
55
-
56
- export {
57
- FilesClient,
58
- createFilesClient,
59
- filesClient,
60
- type FilesClientConfig,
61
- } from './clients/files';
62
-
63
- export {
64
- SkillsClient,
65
- createSkillsClient,
66
- skillsClient,
67
- type SkillsClientConfig,
68
- } from './clients/skills';
69
-
70
- export {
71
- PointsClient,
72
- createPointsClient,
73
- pointsClient,
74
- type PointsClientConfig,
75
- } from './clients/points';
76
-
77
- export {
78
- CoderClient,
79
- createCoderClient,
80
- coderClient,
81
- type CoderClientConfig,
82
- } from './clients/coder';
83
-
84
- export {
85
- StackManagementClient,
86
- createStackManagementClient,
87
- stackManagementClient,
88
- type StackManagementClientConfig,
89
- } from './clients/stack-management';
90
-
91
- export {
92
- NetworkClient,
93
- createNetworkClient,
94
- networkClient,
95
- type NetworkClientConfig,
96
- } from './clients/network';
97
-
98
- export {
99
- BillingClient,
100
- createBillingClient,
101
- billingClient,
102
- type BillingClientConfig,
103
- } from './clients/billing';
104
-
105
- // Managers
106
- export {
107
- TaskManager,
108
- createTaskManager,
109
- type TaskManagerConfig,
110
- type RedisClientLike,
111
- } from './managers/task-manager';
112
-
113
- // Streaming
114
- export {
115
- parseSSEStream,
116
- createSSEResponse,
117
- SSEWriter,
118
- createSSEWriter,
119
- type SSEEvent,
120
- } from './streaming/sse';
121
-
122
- export {
123
- ComponentStreamAdapter,
124
- createComponentStreamAdapter,
125
- hasToolCalls,
126
- extractToolResults,
127
- type DataStreamWriter,
128
- type ArtifactToolCall,
129
- type ArtifactToolResult,
130
- } from './streaming/component-stream';
131
-
132
- // Proxy
133
- export {
134
- forwardRequest,
135
- forwardJSON,
136
- createProxyHandler,
137
- type ForwarderConfig,
138
- type RequestOptions,
139
- } from './proxy/forwarder';
140
-
141
- export {
142
- createAgentRoutes,
143
- createAgentDetailRoutes,
144
- createAgentExecuteRoute,
145
- createAgentToggleRoutes,
146
- createSkillRoutes,
147
- createSkillDetailRoutes,
148
- createWidgetRoutes,
149
- createWidgetDetailRoutes,
150
- createImaginationRoutes,
151
- // Coder route handlers
152
- createCoderSessionRoutes,
153
- createCoderSessionDetailRoutes,
154
- createCoderExecuteRoute,
155
- createCoderToolsRoutes,
156
- createCoderFilesRoutes,
157
- createCoderSandboxRoutes,
158
- createCoderExecRoutes,
159
- // Stack management routes
160
- createStackRoutes,
161
- createStackDetailRoutes,
162
- createStackKeysRoutes,
163
- createStackMembersRoutes,
164
- type RouteHandlerConfig,
165
- type StackRouteHandlerConfig,
166
- type RouteHandler,
167
- type CRUDRouteHandlers,
168
- } from './proxy/route-handlers';
169
-
170
- // Types
171
- export type {
172
- // Task types
173
- TaskType,
174
- TaskStatus,
175
- TaskState,
176
- TaskPayload,
177
- TaskResponse,
178
- // Chat types
179
- Message,
180
- ChatCompletionRequest,
181
- ChatCompletionChunk,
182
- ChatCompletionResponse,
183
- // Imagination types
184
- MagmaFile,
185
- WorkflowData,
186
- ImaginationSource,
187
- ImaginationCharacter,
188
- ImaginationMetadata,
189
- // Agent types
190
- Agent,
191
- AgentTrigger,
192
- AgentWorkflow,
193
- AgentWorkflowNode,
194
- AgentWorkflowEdge,
195
- AgentExecuteRequest,
196
- AgentExecuteResponse,
197
- // MCP types
198
- MCPSession,
199
- MCPSessionConfig,
200
- MCPMessage,
201
- MCPContent,
202
- MCPToolResult,
203
- // Social types
204
- SocialAuthor,
205
- SocialPost,
206
- SocialComment,
207
- SocialRemix,
208
- MediaType,
209
- FeedResponse,
210
- PostResponse,
211
- CommentsResponse,
212
- RemixesResponse,
213
- LikeCheckResponse,
214
- LikeResponse,
215
- CommentResponse,
216
- CreatePostInput,
217
- CreatePostResponse,
218
- ProfileResponse,
219
- // Agent extended types
220
- AgentsListResponse,
221
- AgentResponse,
222
- AgentCreateInput,
223
- AgentUpdateInput,
224
- AgentFromPromptInput,
225
- // Widget types
226
- Widget,
227
- WidgetsListResponse,
228
- WidgetResponse,
229
- WidgetCreateInput,
230
- WidgetUpdateInput,
231
- WidgetSystemPromptResponse,
232
- // User types
233
- UserProfile,
234
- UserProfileUpdateInput,
235
- UserProfileResponse,
236
- // File types
237
- FileUploadResponse,
238
- // Skill types
239
- Skill,
240
- SkillsListResponse,
241
- SkillResponse,
242
- SkillCreateInput,
243
- SkillUpdateInput,
244
- // Coder types
245
- CoderSession,
246
- CoderSessionStatus,
247
- CoderMetrics,
248
- CoderExecuteRequest,
249
- CoderExecuteResponse,
250
- CoderSandboxConfig,
251
- CoderStreamEvent,
252
- CoderStreamEventType,
253
- CoderTool,
254
- CoderToolResult,
255
- CoderFileInfo,
256
- CoderFileContent,
257
- CoderFileWriteInput,
258
- CoderSearchResult,
259
- CoderDiffInput,
260
- CoderCommandInput,
261
- CoderCommandResult,
262
- CoderSandbox,
263
- CoderSandboxCreateInput,
264
- CoderSandboxExecInput,
265
- CoderSandboxExecResult,
266
- // Points types
267
- ContextDomain,
268
- PointContext,
269
- Delegation,
270
- DelegationScope,
271
- PointRecord,
272
- PointSpend,
273
- PointBalance,
274
- ActionProof,
275
- DelegationChainLink,
276
- SpendDestination,
277
- CreateDomainInput,
278
- CreateContextInput,
279
- CreateDelegationInput,
280
- AddPointsInput,
281
- SpendPointsInput,
282
- HistoryFilters,
283
- DelegationFilters,
284
- DomainsListResponse,
285
- DomainResponse,
286
- ContextsListResponse,
287
- ContextResponse,
288
- DelegationsListResponse,
289
- DelegationResponse,
290
- PointRecordResponse,
291
- PointSpendResponse,
292
- HistoryResponse,
293
- InitNetworkResponse,
294
- PaymentRequiredResponse,
295
- // Stack management types
296
- StackConfig,
297
- CreateStackRequest,
298
- StackResponse,
299
- StackListResponse,
300
- StackOAuthProvider,
301
- StackWeb3Provider,
302
- StackStripeProvider,
303
- ConfigureOAuthInput,
304
- ConfigureWeb3Input,
305
- ConfigureStripeInput,
306
- StackKeyInfo,
307
- CreateKeyResponse,
308
- StackKeysListResponse,
309
- AllowlistMode,
310
- AllowlistConfig,
311
- AllowlistUpdateInput,
312
- StackModelAlias,
313
- ModelLayerInfo,
314
- ModelLayersResponse,
315
- StackCapabilities,
316
- CapabilityKey,
317
- StackMember,
318
- StackMemberStats,
319
- // Network types
320
- NetworkStatus,
321
- MPCNode,
322
- ConsensusStatus,
323
- ConsensusStateSummary,
324
- LeaderStatus,
325
- AuthMetrics,
326
- // Billing types
327
- BillingTier,
328
- BillingPlan,
329
- MeteredUsage,
330
- BillingState,
331
- BillingPlansResponse,
332
- CreateCheckoutSessionResponse,
333
- BillingPortalResponse,
334
- UsageRecord,
335
- PaginationMeta,
336
- // Credential types
337
- AuthMethod,
338
- Web3Chain,
339
- CredentialType,
340
- StackCredential,
341
- EmailCredentialData,
342
- Web3CredentialData,
343
- OAuthCredentialData,
344
- BillingCredentialData,
345
- StripeConnectCredentialData,
346
- CredentialLinkProof,
347
- GlobalIdentity,
348
- StackIdentity,
349
- Session,
350
- } from './types';
351
-
352
- // Stack capability utilities
353
- export {
354
- CAPABILITY_BITS,
355
- ALL_CAPABILITIES_BITMASK,
356
- capabilitiesToBitmask,
357
- bitmaskToCapabilities,
358
- } from './types/stack';
359
-
360
- // Utilities
361
- export {
362
- StacksSDKError,
363
- getMessageByErrorCode,
364
- visibilityBySurface,
365
- type ErrorType,
366
- type ErrorCode,
367
- type Surface,
368
- type ErrorVisibility,
369
- } from './utils/errors';
370
-
371
- export {
372
- DEFAULT_TASK_NETWORK_URL,
373
- DEFAULT_MAGMA_RPC_URL,
374
- TASK_PREFIX,
375
- CHAT_TASKS_PREFIX,
376
- TASK_TTL,
377
- SSE_HEADERS,
378
- JSON_HEADERS,
379
- } from './utils/constants';
380
-
381
- export {
382
- generateUUID,
383
- generateCID,
384
- sleep,
385
- retry,
386
- parseSSELine,
387
- } from './utils/helpers';
@@ -1,10 +0,0 @@
1
- /**
2
- * @stacknet/stacks - Managers
3
- */
4
-
5
- export {
6
- TaskManager,
7
- createTaskManager,
8
- type TaskManagerConfig,
9
- type RedisClientLike,
10
- } from './task-manager';