@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.
Files changed (71) hide show
  1. package/README.md +103 -0
  2. package/dist/billing-BaJlf_S8.d.cts +1154 -0
  3. package/dist/billing-BaJlf_S8.d.ts +1154 -0
  4. package/dist/clients/index.cjs +4 -0
  5. package/dist/clients/index.d.cts +752 -0
  6. package/dist/clients/index.d.ts +752 -0
  7. package/dist/clients/index.js +4 -0
  8. package/dist/index-DVzKiF_0.d.cts +198 -0
  9. package/dist/index-DVzKiF_0.d.ts +198 -0
  10. package/dist/index.cjs +17 -0
  11. package/dist/index.d.cts +309 -0
  12. package/dist/index.d.ts +309 -0
  13. package/dist/index.js +17 -0
  14. package/dist/proxy/index.cjs +2 -0
  15. package/dist/proxy/index.d.cts +1 -0
  16. package/dist/proxy/index.d.ts +1 -0
  17. package/dist/proxy/index.js +2 -0
  18. package/dist/streaming/index.cjs +13 -0
  19. package/dist/streaming/index.d.cts +145 -0
  20. package/dist/streaming/index.d.ts +145 -0
  21. package/dist/streaming/index.js +13 -0
  22. package/dist/types/index.cjs +1 -0
  23. package/dist/types/index.d.cts +335 -0
  24. package/dist/types/index.d.ts +335 -0
  25. package/dist/types/index.js +1 -0
  26. package/package.json +75 -0
  27. package/src/clients/agents.ts +233 -0
  28. package/src/clients/billing.ts +157 -0
  29. package/src/clients/coder.ts +655 -0
  30. package/src/clients/files.ts +86 -0
  31. package/src/clients/index.ts +93 -0
  32. package/src/clients/magma.ts +299 -0
  33. package/src/clients/mcp.ts +208 -0
  34. package/src/clients/network.ts +118 -0
  35. package/src/clients/points.ts +403 -0
  36. package/src/clients/skills.ts +236 -0
  37. package/src/clients/social.ts +286 -0
  38. package/src/clients/stack-management.ts +279 -0
  39. package/src/clients/task-network.ts +303 -0
  40. package/src/clients/user.ts +84 -0
  41. package/src/clients/widgets.ts +171 -0
  42. package/src/index.ts +387 -0
  43. package/src/managers/index.ts +10 -0
  44. package/src/managers/task-manager.ts +310 -0
  45. package/src/proxy/forwarder.ts +146 -0
  46. package/src/proxy/index.ts +32 -0
  47. package/src/proxy/route-handlers.ts +950 -0
  48. package/src/streaming/component-stream.ts +319 -0
  49. package/src/streaming/index.ts +21 -0
  50. package/src/streaming/sse.ts +241 -0
  51. package/src/types/agent.ts +106 -0
  52. package/src/types/billing.ts +87 -0
  53. package/src/types/chat.ts +58 -0
  54. package/src/types/coder.ts +345 -0
  55. package/src/types/credential.ts +111 -0
  56. package/src/types/file.ts +15 -0
  57. package/src/types/imagination.ts +50 -0
  58. package/src/types/index.ts +20 -0
  59. package/src/types/mcp.ts +35 -0
  60. package/src/types/network.ts +97 -0
  61. package/src/types/points.ts +250 -0
  62. package/src/types/skill.ts +107 -0
  63. package/src/types/social.ts +109 -0
  64. package/src/types/stack.ts +269 -0
  65. package/src/types/task.ts +41 -0
  66. package/src/types/user.ts +29 -0
  67. package/src/types/widget.ts +57 -0
  68. package/src/utils/constants.ts +26 -0
  69. package/src/utils/errors.ts +169 -0
  70. package/src/utils/helpers.ts +85 -0
  71. package/src/utils/index.ts +7 -0
@@ -0,0 +1,1154 @@
1
+ /**
2
+ * Task-related type definitions
3
+ */
4
+ type TaskType = 'video' | 'music' | 'image' | 'ai-prompt' | 'mcp-tool';
5
+ type TaskStatus = 'pending' | 'generating' | 'complete' | 'failed';
6
+ interface TaskState {
7
+ id: string;
8
+ chatId: string;
9
+ messageId: string;
10
+ type: TaskType;
11
+ status: TaskStatus;
12
+ progress: number;
13
+ message: string;
14
+ result?: string;
15
+ error?: string;
16
+ createdAt: number;
17
+ updatedAt: number;
18
+ }
19
+ interface TaskPayload {
20
+ type: string;
21
+ model?: string;
22
+ prompt?: string;
23
+ sessionId?: string;
24
+ temperature?: number;
25
+ maxTokens?: number;
26
+ stream?: boolean;
27
+ search?: boolean;
28
+ noTools?: boolean;
29
+ [key: string]: unknown;
30
+ }
31
+ interface TaskResponse {
32
+ taskId: string;
33
+ status: TaskStatus;
34
+ result?: unknown;
35
+ error?: string;
36
+ }
37
+
38
+ /**
39
+ * Chat and message type definitions
40
+ */
41
+ interface Message {
42
+ role: 'system' | 'user' | 'assistant';
43
+ content: string;
44
+ }
45
+ interface ChatCompletionRequest {
46
+ model: string;
47
+ messages: Message[];
48
+ stream?: boolean;
49
+ temperature?: number;
50
+ max_tokens?: number;
51
+ sessionId?: string;
52
+ search?: boolean;
53
+ }
54
+ interface ChatCompletionChunk {
55
+ id: string;
56
+ object: 'chat.completion.chunk';
57
+ created: number;
58
+ model: string;
59
+ choices: Array<{
60
+ index: number;
61
+ delta: {
62
+ role?: 'assistant';
63
+ content?: string;
64
+ };
65
+ finish_reason: string | null;
66
+ }>;
67
+ usage?: {
68
+ prompt_tokens: number;
69
+ completion_tokens: number;
70
+ total_tokens: number;
71
+ };
72
+ }
73
+ interface ChatCompletionResponse {
74
+ id: string;
75
+ object: 'chat.completion';
76
+ created: number;
77
+ model: string;
78
+ choices: Array<{
79
+ index: number;
80
+ message: {
81
+ role: 'assistant';
82
+ content: string;
83
+ };
84
+ finish_reason: string;
85
+ }>;
86
+ usage: {
87
+ prompt_tokens: number;
88
+ completion_tokens: number;
89
+ total_tokens: number;
90
+ };
91
+ }
92
+
93
+ /**
94
+ * Imagination and file type definitions
95
+ */
96
+ interface MagmaFile {
97
+ cid: string;
98
+ name: string;
99
+ size: number;
100
+ type: string;
101
+ url: string;
102
+ }
103
+ interface WorkflowData {
104
+ name: string;
105
+ coverImage?: string;
106
+ description: string;
107
+ examples: Array<{
108
+ id: string;
109
+ data: string;
110
+ }>;
111
+ workflowJson: string;
112
+ }
113
+ interface ImaginationSource {
114
+ cid: string;
115
+ type: 'document' | 'link' | 'voice' | 'image' | 'music' | 'text';
116
+ name: string;
117
+ size?: number;
118
+ content?: string;
119
+ }
120
+ interface ImaginationCharacter {
121
+ name: string;
122
+ gender: string;
123
+ age: string;
124
+ weight: string;
125
+ personality: string;
126
+ }
127
+ interface ImaginationMetadata {
128
+ id: string;
129
+ title: string;
130
+ createdAt: string;
131
+ createdBy: string;
132
+ sources: ImaginationSource[];
133
+ summary?: string;
134
+ character?: ImaginationCharacter;
135
+ workflow?: WorkflowData;
136
+ is_public?: boolean;
137
+ }
138
+
139
+ /**
140
+ * Agent type definitions
141
+ */
142
+ interface Agent {
143
+ id: string;
144
+ name: string;
145
+ description?: string;
146
+ system_prompt?: string;
147
+ model?: string;
148
+ tools?: string[];
149
+ triggers?: AgentTrigger[];
150
+ workflow?: AgentWorkflow;
151
+ visibility?: 'public' | 'private' | 'template';
152
+ creator_mid?: string;
153
+ created_at?: string;
154
+ updated_at?: string;
155
+ enabled?: boolean;
156
+ }
157
+ interface AgentTrigger {
158
+ type: 'webhook' | 'cron' | 'event';
159
+ config: Record<string, unknown>;
160
+ }
161
+ interface AgentWorkflow {
162
+ nodes: AgentWorkflowNode[];
163
+ edges: AgentWorkflowEdge[];
164
+ }
165
+ interface AgentWorkflowNode {
166
+ id: string;
167
+ type: string;
168
+ position: {
169
+ x: number;
170
+ y: number;
171
+ };
172
+ data: Record<string, unknown>;
173
+ }
174
+ interface AgentWorkflowEdge {
175
+ id: string;
176
+ source: string;
177
+ target: string;
178
+ sourceHandle?: string;
179
+ targetHandle?: string;
180
+ }
181
+ interface AgentExecuteRequest {
182
+ input?: string;
183
+ context?: Record<string, unknown>;
184
+ stream?: boolean;
185
+ }
186
+ interface AgentExecuteResponse {
187
+ id: string;
188
+ output: string;
189
+ status: 'success' | 'error';
190
+ metadata?: Record<string, unknown>;
191
+ }
192
+ interface AgentsListResponse {
193
+ agents: Agent[];
194
+ }
195
+ interface AgentResponse {
196
+ agent?: Agent;
197
+ id?: string;
198
+ name?: string;
199
+ error?: string;
200
+ }
201
+ interface AgentCreateInput {
202
+ name: string;
203
+ description?: string;
204
+ system_prompt?: string;
205
+ model?: string;
206
+ tools?: string[];
207
+ triggers?: AgentTrigger[];
208
+ workflow?: AgentWorkflow;
209
+ visibility?: 'public' | 'private' | 'template';
210
+ created_by?: string;
211
+ }
212
+ interface AgentUpdateInput {
213
+ name?: string;
214
+ description?: string;
215
+ system_prompt?: string;
216
+ model?: string;
217
+ tools?: string[];
218
+ triggers?: AgentTrigger[];
219
+ workflow?: AgentWorkflow;
220
+ visibility?: 'public' | 'private' | 'template';
221
+ enabled?: boolean;
222
+ }
223
+ interface AgentFromPromptInput {
224
+ prompt: string;
225
+ created_by?: string;
226
+ }
227
+ interface AgentsClientConfig {
228
+ baseUrl?: string;
229
+ /**
230
+ * Use the coprocessor API (/cpx/agent/agents) instead of legacy (/agents).
231
+ * Defaults to true. Set to false for backwards compatibility.
232
+ */
233
+ useCpxApi?: boolean;
234
+ }
235
+
236
+ /**
237
+ * MCP (Model Context Protocol) type definitions
238
+ */
239
+ interface MCPSessionConfig {
240
+ baseUrl?: string;
241
+ agentId?: string;
242
+ timeout?: number;
243
+ }
244
+ interface MCPSession {
245
+ id: string;
246
+ agentId: string;
247
+ status: 'active' | 'closed' | 'error';
248
+ createdAt: Date;
249
+ }
250
+ interface MCPMessage {
251
+ role: 'user' | 'assistant';
252
+ content: MCPContent;
253
+ }
254
+ interface MCPContent {
255
+ type: 'text' | 'image' | 'tool_use' | 'tool_result';
256
+ text?: string;
257
+ data?: string;
258
+ toolName?: string;
259
+ toolInput?: Record<string, unknown>;
260
+ }
261
+ interface MCPToolResult {
262
+ result: unknown;
263
+ data?: Record<string, unknown>;
264
+ error?: string;
265
+ }
266
+
267
+ /**
268
+ * Social Network Types
269
+ */
270
+ interface SocialAuthor {
271
+ mid: string;
272
+ username: string;
273
+ avatar_url: string | null;
274
+ bio?: string | null;
275
+ }
276
+ type MediaType = 'image' | 'video' | 'audio' | 'animation';
277
+ type Orientation = 'portrait' | 'landscape';
278
+ interface SocialPost {
279
+ id: string;
280
+ creator_mid: string;
281
+ content: string;
282
+ media_url: string;
283
+ media_type: MediaType;
284
+ orientation?: Orientation;
285
+ poster_url?: string;
286
+ created_at: number;
287
+ likes_count: number;
288
+ comments_count: number;
289
+ views_count: number;
290
+ plays_count?: number;
291
+ remix_of?: string;
292
+ author: SocialAuthor;
293
+ }
294
+ interface SocialComment {
295
+ id: string;
296
+ author_mid: string;
297
+ content: string;
298
+ created_at: number;
299
+ author: SocialAuthor;
300
+ }
301
+ interface SocialRemix {
302
+ id: string;
303
+ creator_mid: string;
304
+ content: string;
305
+ media_url: string;
306
+ poster_url?: string;
307
+ created_at: number;
308
+ author: SocialAuthor;
309
+ }
310
+ interface FeedResponse {
311
+ posts: SocialPost[];
312
+ hasMore: boolean;
313
+ page: number;
314
+ total?: number;
315
+ }
316
+ interface PostResponse {
317
+ post: SocialPost;
318
+ }
319
+ interface CommentsResponse {
320
+ comments: SocialComment[];
321
+ }
322
+ interface RemixesResponse {
323
+ remixes: SocialRemix[];
324
+ }
325
+ interface LikeCheckResponse {
326
+ liked: boolean;
327
+ }
328
+ interface LikeResponse {
329
+ success: boolean;
330
+ likes_count?: number;
331
+ }
332
+ interface CommentResponse {
333
+ success: boolean;
334
+ comment?: SocialComment;
335
+ }
336
+ interface CreatePostInput {
337
+ creatorMid: string;
338
+ content: string;
339
+ mediaUrl: string;
340
+ mediaType: MediaType;
341
+ orientation?: Orientation;
342
+ posterUrl?: string;
343
+ remixOf?: string;
344
+ }
345
+ interface CreatePostResponse {
346
+ success: boolean;
347
+ post?: SocialPost;
348
+ id?: string;
349
+ }
350
+ interface ProfileResponse {
351
+ mid: string;
352
+ username: string;
353
+ avatar_url: string | null;
354
+ bio?: string | null;
355
+ }
356
+ interface SocialClientConfig {
357
+ baseUrl?: string;
358
+ }
359
+
360
+ /**
361
+ * Widget type definitions
362
+ */
363
+ interface Widget {
364
+ id: string;
365
+ name: string;
366
+ description?: string;
367
+ component_code: string;
368
+ styles?: string;
369
+ props_schema?: Record<string, unknown>;
370
+ default_props?: Record<string, unknown>;
371
+ scope?: 'public' | 'private';
372
+ creator_mid?: string;
373
+ created_at?: string;
374
+ updated_at?: string;
375
+ usage_count?: number;
376
+ }
377
+ interface WidgetsListResponse {
378
+ widgets: Widget[];
379
+ }
380
+ interface WidgetResponse {
381
+ widget?: Widget;
382
+ id?: string;
383
+ error?: string;
384
+ }
385
+ interface WidgetCreateInput {
386
+ name: string;
387
+ description?: string;
388
+ component_code: string;
389
+ styles?: string;
390
+ props_schema?: Record<string, unknown>;
391
+ default_props?: Record<string, unknown>;
392
+ scope?: 'public' | 'private';
393
+ creator_mid?: string;
394
+ }
395
+ interface WidgetUpdateInput {
396
+ name?: string;
397
+ description?: string;
398
+ component_code?: string;
399
+ styles?: string;
400
+ props_schema?: Record<string, unknown>;
401
+ default_props?: Record<string, unknown>;
402
+ scope?: 'public' | 'private';
403
+ }
404
+ interface WidgetSystemPromptResponse {
405
+ prompt: string;
406
+ }
407
+ interface WidgetsClientConfig {
408
+ baseUrl?: string;
409
+ }
410
+
411
+ /**
412
+ * User type definitions
413
+ */
414
+ interface UserProfile {
415
+ mid: string;
416
+ username: string;
417
+ avatar_url: string | null;
418
+ bio?: string | null;
419
+ preferences?: string | null;
420
+ created_at?: string;
421
+ updated_at?: string;
422
+ }
423
+ interface UserProfileUpdateInput {
424
+ username?: string;
425
+ avatar_url?: string | null;
426
+ bio?: string | null;
427
+ preferences?: string | null;
428
+ }
429
+ interface UserProfileResponse {
430
+ profile?: UserProfile;
431
+ error?: string;
432
+ }
433
+ interface UserClientConfig {
434
+ baseUrl?: string;
435
+ }
436
+
437
+ /**
438
+ * File type definitions
439
+ */
440
+ interface FileUploadResponse {
441
+ cid: string;
442
+ url: string;
443
+ filePath?: string;
444
+ size?: number;
445
+ mimeType?: string;
446
+ }
447
+ interface FilesClientConfig {
448
+ baseUrl?: string;
449
+ }
450
+
451
+ /**
452
+ * Skill Types
453
+ */
454
+ interface Skill {
455
+ id: string;
456
+ name: string;
457
+ description: string;
458
+ creator_mid: string;
459
+ skill_md: string;
460
+ skill_hash: string | null;
461
+ scripts: {
462
+ name: string;
463
+ content: string;
464
+ }[] | null;
465
+ references: {
466
+ name: string;
467
+ content: string;
468
+ }[] | null;
469
+ assets: {
470
+ name: string;
471
+ url: string;
472
+ }[] | null;
473
+ tags: string[];
474
+ version: string;
475
+ is_public: boolean;
476
+ usage_count: number;
477
+ created_at: number;
478
+ updated_at: number;
479
+ }
480
+ interface SkillsListResponse {
481
+ skills: Skill[];
482
+ }
483
+ interface SkillResponse {
484
+ skill?: Skill;
485
+ skill_id?: string;
486
+ success?: boolean;
487
+ error?: string;
488
+ }
489
+ interface SkillCreateInput {
490
+ name: string;
491
+ description?: string;
492
+ skill_md: string;
493
+ scripts?: {
494
+ name: string;
495
+ content: string;
496
+ }[] | null;
497
+ references?: {
498
+ name: string;
499
+ content: string;
500
+ }[] | null;
501
+ assets?: {
502
+ name: string;
503
+ url: string;
504
+ }[] | null;
505
+ tags?: string[];
506
+ version?: string;
507
+ is_public?: boolean;
508
+ creator_mid?: string;
509
+ }
510
+ interface SkillUpdateInput {
511
+ name?: string;
512
+ description?: string;
513
+ skill_md?: string;
514
+ scripts?: {
515
+ name: string;
516
+ content: string;
517
+ }[] | null;
518
+ references?: {
519
+ name: string;
520
+ content: string;
521
+ }[] | null;
522
+ assets?: {
523
+ name: string;
524
+ url: string;
525
+ }[] | null;
526
+ tags?: string[];
527
+ version?: string;
528
+ is_public?: boolean;
529
+ }
530
+ interface SkillsClientConfig {
531
+ baseUrl?: string;
532
+ /**
533
+ * Use the coprocessor API (/cpx/agent/skills) instead of legacy (/skills).
534
+ * Defaults to true. Set to false for backwards compatibility.
535
+ */
536
+ useCpxApi?: boolean;
537
+ }
538
+ interface SkillVerifyResponse {
539
+ valid: boolean;
540
+ expected?: string;
541
+ actual?: string;
542
+ }
543
+ interface SkillVerifyResponse {
544
+ valid: boolean;
545
+ expected?: string;
546
+ actual?: string;
547
+ }
548
+ interface SkillMapResponse {
549
+ version: number;
550
+ generated_at: number;
551
+ skills: Array<{
552
+ id: string;
553
+ name: string;
554
+ description: string;
555
+ content_type: string;
556
+ category: string | null;
557
+ usage_count: number;
558
+ is_precompiled: boolean;
559
+ skill_hash: string | null;
560
+ }>;
561
+ }
562
+ interface SkillMapPromptResponse {
563
+ prompt: string;
564
+ }
565
+ interface SkillSummaryResponse {
566
+ summary: string;
567
+ skills: Array<{
568
+ id: string;
569
+ name: string;
570
+ description: string;
571
+ keywords: string[];
572
+ }>;
573
+ }
574
+
575
+ /**
576
+ * Points Types
577
+ *
578
+ * Types for the Points Coprocessor SDK client.
579
+ */
580
+ /**
581
+ * Context Domain - namespace for points with authority control
582
+ */
583
+ interface ContextDomain {
584
+ id: string;
585
+ name: string;
586
+ description?: string;
587
+ authorityAgent: string;
588
+ seal: string;
589
+ createdAt: number;
590
+ metadata?: Record<string, unknown>;
591
+ }
592
+ /**
593
+ * Point Context - defines what actions/achievements points represent
594
+ */
595
+ interface PointContext {
596
+ id: string;
597
+ domainId: string;
598
+ name: string;
599
+ description?: string;
600
+ unit?: string;
601
+ allowNegative: boolean;
602
+ createdAt: number;
603
+ metadata?: Record<string, unknown>;
604
+ }
605
+ /**
606
+ * Delegation - authority delegation to sub-agents
607
+ */
608
+ interface Delegation {
609
+ id: string;
610
+ domainId: string;
611
+ delegator: string;
612
+ delegate: string;
613
+ scope: DelegationScope;
614
+ validFrom: number;
615
+ validUntil: number | null;
616
+ revoked: boolean;
617
+ revokedAt?: number;
618
+ signature: string;
619
+ createdAt: number;
620
+ }
621
+ interface DelegationScope {
622
+ pointContexts: string[];
623
+ maxAmount?: number | null;
624
+ canDelegate: boolean;
625
+ }
626
+ /**
627
+ * Point Record - individual point addition/deduction
628
+ */
629
+ interface PointRecord {
630
+ id: string;
631
+ mid: string;
632
+ domainId: string;
633
+ contextId: string;
634
+ amount: number;
635
+ reason?: string;
636
+ actionProof: ActionProof;
637
+ issuer: string;
638
+ delegationChain?: DelegationChainLink[];
639
+ signature: string;
640
+ createdAt: number;
641
+ }
642
+ interface ActionProof {
643
+ taskId?: string;
644
+ resultHash?: string;
645
+ consensusProof?: string;
646
+ failureType?: string;
647
+ evidenceHash?: string;
648
+ metadata?: Record<string, unknown>;
649
+ }
650
+ interface DelegationChainLink {
651
+ delegationId: string;
652
+ delegator: string;
653
+ delegate: string;
654
+ signature: string;
655
+ }
656
+ /**
657
+ * Point Spend Record
658
+ */
659
+ interface PointSpend {
660
+ id: string;
661
+ mid: string;
662
+ domainId: string;
663
+ contextId: string;
664
+ amount: number;
665
+ destination: SpendDestination;
666
+ metaproof?: string;
667
+ signature: string;
668
+ createdAt: number;
669
+ }
670
+ interface SpendDestination {
671
+ type: 'settlement' | 'burn';
672
+ target?: string;
673
+ }
674
+ /**
675
+ * Balance response
676
+ */
677
+ interface PointBalance {
678
+ mid: string;
679
+ domain?: string;
680
+ total: number;
681
+ byContext: Record<string, number>;
682
+ }
683
+ interface CreateDomainInput {
684
+ name: string;
685
+ description?: string;
686
+ authorityAgent: string;
687
+ metadata?: Record<string, unknown>;
688
+ }
689
+ interface CreateContextInput {
690
+ domainId: string;
691
+ name: string;
692
+ description?: string;
693
+ unit?: string;
694
+ allowNegative?: boolean;
695
+ metadata?: Record<string, unknown>;
696
+ }
697
+ interface CreateDelegationInput {
698
+ domainId: string;
699
+ delegate: string;
700
+ scope: DelegationScope;
701
+ validFrom?: number;
702
+ validUntil?: number | null;
703
+ }
704
+ interface AddPointsInput {
705
+ mid: string;
706
+ domainId: string;
707
+ contextId: string;
708
+ amount: number;
709
+ reason?: string;
710
+ actionProof: ActionProof;
711
+ delegationChain?: DelegationChainLink[];
712
+ }
713
+ interface SpendPointsInput {
714
+ mid: string;
715
+ domainId: string;
716
+ contextId: string;
717
+ amount: number;
718
+ destination: SpendDestination;
719
+ }
720
+ interface HistoryFilters {
721
+ mid?: string;
722
+ domainId?: string;
723
+ contextId?: string;
724
+ periodStart?: number;
725
+ periodEnd?: number;
726
+ taskId?: string;
727
+ limit?: number;
728
+ offset?: number;
729
+ }
730
+ interface DelegationFilters {
731
+ domainId?: string;
732
+ delegator?: string;
733
+ delegate?: string;
734
+ activeOnly?: boolean;
735
+ }
736
+ interface DomainsListResponse {
737
+ domains: ContextDomain[];
738
+ }
739
+ interface DomainResponse {
740
+ domain: ContextDomain;
741
+ paymentRequired?: boolean;
742
+ }
743
+ interface ContextsListResponse {
744
+ contexts: PointContext[];
745
+ }
746
+ interface ContextResponse {
747
+ context: PointContext;
748
+ paymentRequired?: boolean;
749
+ }
750
+ interface DelegationsListResponse {
751
+ delegations: Delegation[];
752
+ }
753
+ interface DelegationResponse {
754
+ delegation: Delegation;
755
+ }
756
+ interface PointRecordResponse {
757
+ record: PointRecord;
758
+ }
759
+ interface PointSpendResponse {
760
+ spend: PointSpend;
761
+ metaproof?: string;
762
+ }
763
+ interface HistoryResponse {
764
+ records: PointRecord[];
765
+ total: number;
766
+ }
767
+ interface InitNetworkResponse {
768
+ domain: ContextDomain;
769
+ contexts: PointContext[];
770
+ }
771
+ interface PaymentRequiredResponse {
772
+ error: string;
773
+ paymentRequired: true;
774
+ paymentDetails: {
775
+ type: string;
776
+ amount: number;
777
+ currency: string;
778
+ recipient: string;
779
+ };
780
+ }
781
+ interface PointsClientConfig {
782
+ baseUrl?: string;
783
+ }
784
+
785
+ /**
786
+ * Stack management type definitions
787
+ * Types for stack CRUD, configuration, providers, capabilities, and allowlists
788
+ */
789
+ interface StackConfig {
790
+ id: string;
791
+ name: string;
792
+ displayName: string;
793
+ description?: string;
794
+ ownerId: string;
795
+ allowedChains: string[];
796
+ oauthProviders: StackOAuthProvider[];
797
+ web3Providers?: StackWeb3Provider[];
798
+ stripeProvider?: StackStripeProvider;
799
+ webhookEndpoint?: string;
800
+ allowedOrigins: string[];
801
+ rateLimits?: {
802
+ requestsPerMinute: number;
803
+ requestsPerDay: number;
804
+ };
805
+ features?: {
806
+ web3Auth: boolean;
807
+ oauthAuth: boolean;
808
+ apiKeyAuth: boolean;
809
+ billing: boolean;
810
+ };
811
+ metadata?: Record<string, any>;
812
+ modelAliases?: StackModelAlias[];
813
+ logoCid?: string;
814
+ logoUrl?: string;
815
+ createdAt: number;
816
+ updatedAt: number;
817
+ isActive: boolean;
818
+ capabilityBitmask?: number;
819
+ }
820
+ interface CreateStackRequest {
821
+ name: string;
822
+ displayName: string;
823
+ description?: string;
824
+ allowedChains?: string[];
825
+ allowedOrigins?: string[];
826
+ }
827
+ interface StackResponse {
828
+ stack: StackConfig;
829
+ }
830
+ interface StackListResponse {
831
+ stacks: StackConfig[];
832
+ }
833
+ interface StackOAuthProvider {
834
+ provider: string;
835
+ clientId: string;
836
+ scopes: string[];
837
+ redirectUri?: string;
838
+ enabled: boolean;
839
+ }
840
+ interface StackWeb3Provider {
841
+ provider: 'siwe' | 'siws';
842
+ domain: string;
843
+ statement: string;
844
+ chainId: string;
845
+ expirationTime?: number;
846
+ enabled: boolean;
847
+ }
848
+ interface StackStripeProvider {
849
+ provider: 'stripe';
850
+ publishableKey: string;
851
+ enabled: boolean;
852
+ mode: 'test' | 'live';
853
+ }
854
+ /**
855
+ * @server-only — Contains secrets. Only use from server-side code (API routes, server actions).
856
+ * Never import or call from browser/client bundles.
857
+ */
858
+ interface ConfigureOAuthInput {
859
+ clientId: string;
860
+ /** @secret OAuth client secret — never expose to the browser */
861
+ clientSecret: string;
862
+ scopes?: string[];
863
+ redirectUri?: string;
864
+ }
865
+ interface ConfigureWeb3Input {
866
+ domain: string;
867
+ statement: string;
868
+ chainId: string;
869
+ expirationTime?: number;
870
+ }
871
+ /**
872
+ * @server-only — Contains secrets. Only use from server-side code (API routes, server actions).
873
+ * Never import or call from browser/client bundles.
874
+ */
875
+ interface ConfigureStripeInput {
876
+ publishableKey: string;
877
+ /** @secret Stripe secret key — never expose to the browser */
878
+ secretKey: string;
879
+ }
880
+ interface StackKeyInfo {
881
+ id: string;
882
+ keyPrefix: string;
883
+ name: string;
884
+ permission: 'read' | 'write';
885
+ lastUsedAt: number | null;
886
+ createdAt: number;
887
+ isRevoked: boolean;
888
+ }
889
+ interface CreateKeyResponse {
890
+ key: string;
891
+ keyId: string;
892
+ keyPrefix: string;
893
+ }
894
+ interface StackKeysListResponse {
895
+ keys: StackKeyInfo[];
896
+ }
897
+ type AllowlistMode = 'global_fallback' | 'open' | 'explicit';
898
+ interface AllowlistConfig {
899
+ solana: string[];
900
+ evm: string[];
901
+ solanaMode: AllowlistMode;
902
+ evmMode: AllowlistMode;
903
+ customSignInMessage: string | null;
904
+ }
905
+ interface AllowlistUpdateInput {
906
+ solana?: string[];
907
+ evm?: string[];
908
+ customSignInMessage?: string | null;
909
+ }
910
+ interface StackModelAlias {
911
+ layer: string;
912
+ capability: string;
913
+ alias: string;
914
+ }
915
+ interface ModelLayerInfo {
916
+ name: string;
917
+ aliases: Array<{
918
+ capability: string;
919
+ alias: string;
920
+ defaultAlias: string;
921
+ modelId: string;
922
+ }>;
923
+ }
924
+ interface ModelLayersResponse {
925
+ layers: ModelLayerInfo[];
926
+ }
927
+ declare const CAPABILITY_BITS: {
928
+ readonly text_input: number;
929
+ readonly image_input: number;
930
+ readonly file_input: number;
931
+ readonly audio_input: number;
932
+ readonly video_input: number;
933
+ readonly music_input: number;
934
+ readonly text_output: number;
935
+ readonly image_output: number;
936
+ readonly audio_output: number;
937
+ readonly video_output: number;
938
+ readonly embeddings_output: number;
939
+ readonly music_output: number;
940
+ readonly skills: number;
941
+ readonly loops: number;
942
+ readonly tools: number;
943
+ readonly pipelines: number;
944
+ readonly training: number;
945
+ };
946
+ declare const ALL_CAPABILITIES_BITMASK = 131071;
947
+ type CapabilityKey = keyof typeof CAPABILITY_BITS;
948
+ interface StackCapabilities {
949
+ text_input: boolean;
950
+ image_input: boolean;
951
+ file_input: boolean;
952
+ audio_input: boolean;
953
+ video_input: boolean;
954
+ music_input: boolean;
955
+ text_output: boolean;
956
+ image_output: boolean;
957
+ audio_output: boolean;
958
+ video_output: boolean;
959
+ embeddings_output: boolean;
960
+ music_output: boolean;
961
+ skills: boolean;
962
+ loops: boolean;
963
+ tools: boolean;
964
+ pipelines: boolean;
965
+ training: boolean;
966
+ }
967
+ declare function capabilitiesToBitmask(caps: StackCapabilities): number;
968
+ declare function bitmaskToCapabilities(mask: number): StackCapabilities;
969
+ interface StackMember {
970
+ id: string;
971
+ stack_id: string;
972
+ user_id: string;
973
+ role: 'admin' | 'user';
974
+ auth_method?: string;
975
+ display_name?: string;
976
+ created_at: number;
977
+ last_seen_at: number;
978
+ }
979
+ interface StackMemberStats {
980
+ total: number;
981
+ admins: number;
982
+ users: number;
983
+ activeLastWeek: number;
984
+ }
985
+ interface StackManagementClientConfig {
986
+ baseUrl?: string;
987
+ /** JWT auth token for authenticated requests */
988
+ authToken?: string;
989
+ }
990
+
991
+ /**
992
+ * Network, consensus, and metrics type definitions
993
+ */
994
+ interface NetworkStatus {
995
+ total_nodes: number;
996
+ online_nodes: number;
997
+ current_leader: string;
998
+ consensus_health: 'healthy' | 'degraded' | 'unhealthy';
999
+ last_block_time: number;
1000
+ network_version: string;
1001
+ consensus?: ConsensusStatus;
1002
+ }
1003
+ interface MPCNode {
1004
+ id: string;
1005
+ name: string;
1006
+ endpoint: string;
1007
+ status: 'online' | 'offline' | 'signing' | 'dkg';
1008
+ public_key_share: string;
1009
+ keyId?: string;
1010
+ last_heartbeat: number;
1011
+ load: number;
1012
+ version: string;
1013
+ }
1014
+ interface ConsensusStatus {
1015
+ enabled: boolean;
1016
+ node_id?: number;
1017
+ is_leader?: boolean;
1018
+ current_leader?: number;
1019
+ term?: number;
1020
+ last_log_index?: number;
1021
+ commit_index?: number;
1022
+ state_summary?: ConsensusStateSummary;
1023
+ running?: boolean;
1024
+ }
1025
+ interface ConsensusStateSummary {
1026
+ stack_count: number;
1027
+ session_count: number;
1028
+ task_count: number;
1029
+ worker_count: number;
1030
+ }
1031
+ interface LeaderStatus {
1032
+ is_leader: boolean;
1033
+ }
1034
+ interface AuthMetrics {
1035
+ total_global_identities: number;
1036
+ total_registered_stacks: number;
1037
+ stack_identities: number;
1038
+ active_sessions: number;
1039
+ total_tokens_input: number;
1040
+ total_tokens_output: number;
1041
+ total_image_megapixels: number;
1042
+ total_video_megabytes: number;
1043
+ total_audio_megabytes: number;
1044
+ total_input_token_value?: string;
1045
+ total_output_token_value?: string;
1046
+ total_token_value?: string;
1047
+ auth_method_breakdown: {
1048
+ email: number;
1049
+ web3_evm: number;
1050
+ web3_solana: number;
1051
+ web3_bitcoin: number;
1052
+ oauth: number;
1053
+ };
1054
+ signatures_24h: number;
1055
+ avg_signing_time_ms: number;
1056
+ avg_latency_ms: number;
1057
+ dkg_ceremonies_completed: number;
1058
+ attestations_issued_24h: number;
1059
+ attestations_verified_24h: number;
1060
+ }
1061
+ interface NetworkClientConfig {
1062
+ baseUrl?: string;
1063
+ authToken?: string;
1064
+ }
1065
+
1066
+ /**
1067
+ * Billing and metered usage type definitions
1068
+ */
1069
+ type BillingTier = 'free' | 'starter' | 'pro' | 'enterprise';
1070
+ interface BillingPlan {
1071
+ id: string;
1072
+ name: string;
1073
+ tier: BillingTier;
1074
+ price_monthly: number;
1075
+ price_yearly: number;
1076
+ included_units: number;
1077
+ overage_price: number;
1078
+ features: string[];
1079
+ }
1080
+ interface MeteredUsage {
1081
+ stack_identity_id: string;
1082
+ stack_id: string;
1083
+ period_start: number;
1084
+ period_end: number;
1085
+ usage_type: string;
1086
+ quantity: number;
1087
+ unit_price: number;
1088
+ total_amount: number;
1089
+ }
1090
+ interface BillingState {
1091
+ stack_identity_id: string;
1092
+ stripe_customer_id?: string;
1093
+ current_tier: BillingTier;
1094
+ subscription_id?: string;
1095
+ subscription_status?: 'active' | 'past_due' | 'canceled' | 'trialing';
1096
+ current_period_start?: number;
1097
+ current_period_end?: number;
1098
+ usage_this_period: MeteredUsage[];
1099
+ total_usage_units: number;
1100
+ total_amount_due: number;
1101
+ has_card_on_file: boolean;
1102
+ updated_at: number;
1103
+ }
1104
+ interface BillingPlansResponse {
1105
+ plans: BillingPlan[];
1106
+ }
1107
+ interface CreateCheckoutSessionResponse {
1108
+ checkout_url: string;
1109
+ session_id: string;
1110
+ }
1111
+ interface BillingPortalResponse {
1112
+ portal_url: string;
1113
+ }
1114
+ interface UsageRecord {
1115
+ id: string;
1116
+ task_id: string;
1117
+ model: string | null;
1118
+ executor_node_id: string;
1119
+ inbound: {
1120
+ text_tokens: number;
1121
+ image_megapixels: number;
1122
+ video_megabytes: number;
1123
+ audio_megabytes: number;
1124
+ };
1125
+ outbound: {
1126
+ text_tokens: number;
1127
+ image_megapixels: number;
1128
+ video_megabytes: number;
1129
+ audio_megabytes: number;
1130
+ };
1131
+ execution_time_ms: number;
1132
+ recorded_at: number;
1133
+ cost: {
1134
+ input_token_value: string;
1135
+ output_token_value: string;
1136
+ image_value: string;
1137
+ video_value: string;
1138
+ audio_value: string;
1139
+ total_value: string;
1140
+ };
1141
+ }
1142
+ interface PaginationMeta {
1143
+ page: number;
1144
+ limit: number;
1145
+ total: number;
1146
+ total_pages: number;
1147
+ has_more: boolean;
1148
+ }
1149
+ interface BillingClientConfig {
1150
+ baseUrl?: string;
1151
+ authToken?: string;
1152
+ }
1153
+
1154
+ export { type DelegationChainLink as $, ALL_CAPABILITIES_BITMASK as A, type BillingClientConfig as B, CAPABILITY_BITS as C, type CapabilityKey as D, type ChatCompletionChunk as E, type ChatCompletionRequest as F, type ChatCompletionResponse as G, type CommentResponse as H, type CommentsResponse as I, type ConfigureOAuthInput as J, type ConfigureStripeInput as K, type ConfigureWeb3Input as L, type ConsensusStateSummary as M, type ConsensusStatus as N, type ContextDomain as O, type ContextResponse as P, type ContextsListResponse as Q, type CreateCheckoutSessionResponse as R, type CreateContextInput as S, type TaskType as T, type CreateDelegationInput as U, type CreateDomainInput as V, type CreateKeyResponse as W, type CreatePostInput as X, type CreatePostResponse as Y, type CreateStackRequest as Z, type Delegation as _, type TaskState as a, type StackMember as a$, type DelegationFilters as a0, type DelegationResponse as a1, type DelegationScope as a2, type DelegationsListResponse as a3, type DomainResponse as a4, type DomainsListResponse as a5, type FeedResponse as a6, type FileUploadResponse as a7, type FilesClientConfig as a8, type HistoryFilters as a9, type PointRecord as aA, type PointRecordResponse as aB, type PointSpend as aC, type PointSpendResponse as aD, type PointsClientConfig as aE, type PostResponse as aF, type ProfileResponse as aG, type RemixesResponse as aH, type Skill as aI, type SkillCreateInput as aJ, type SkillResponse as aK, type SkillUpdateInput as aL, type SkillsClientConfig as aM, type SkillsListResponse as aN, type SocialAuthor as aO, type SocialClientConfig as aP, type SocialComment as aQ, type SocialPost as aR, type SocialRemix as aS, type SpendDestination as aT, type SpendPointsInput as aU, type StackCapabilities as aV, type StackConfig as aW, type StackKeyInfo as aX, type StackKeysListResponse as aY, type StackListResponse as aZ, type StackManagementClientConfig as a_, type HistoryResponse as aa, type ImaginationCharacter as ab, type ImaginationMetadata as ac, type ImaginationSource as ad, type InitNetworkResponse as ae, type LeaderStatus as af, type LikeCheckResponse as ag, type LikeResponse as ah, type MCPContent as ai, type MCPMessage as aj, type MCPSession as ak, type MCPSessionConfig as al, type MCPToolResult as am, type MPCNode as an, type MagmaFile as ao, type MediaType as ap, type Message as aq, type MeteredUsage as ar, type ModelLayerInfo as as, type ModelLayersResponse as at, type NetworkClientConfig as au, type NetworkStatus as av, type PaginationMeta as aw, type PaymentRequiredResponse as ax, type PointBalance as ay, type PointContext as az, type TaskStatus as b, type StackMemberStats as b0, type StackModelAlias as b1, type StackOAuthProvider as b2, type StackResponse as b3, type StackStripeProvider as b4, type StackWeb3Provider as b5, type TaskPayload as b6, type TaskResponse as b7, type UsageRecord as b8, type UserClientConfig as b9, type UserProfile as ba, type UserProfileResponse as bb, type UserProfileUpdateInput as bc, type Widget as bd, type WidgetCreateInput as be, type WidgetResponse as bf, type WidgetSystemPromptResponse as bg, type WidgetUpdateInput as bh, type WidgetsClientConfig as bi, type WidgetsListResponse as bj, type WorkflowData as bk, bitmaskToCapabilities as bl, capabilitiesToBitmask as bm, type SkillVerifyResponse as bn, type SkillMapResponse as bo, type SkillMapPromptResponse as bp, type SkillSummaryResponse as bq, type Orientation as br, type ActionProof as c, type AddPointsInput as d, type Agent as e, type AgentCreateInput as f, type AgentExecuteRequest as g, type AgentExecuteResponse as h, type AgentFromPromptInput as i, type AgentResponse as j, type AgentTrigger as k, type AgentUpdateInput as l, type AgentWorkflow as m, type AgentWorkflowEdge as n, type AgentWorkflowNode as o, type AgentsClientConfig as p, type AgentsListResponse as q, type AllowlistConfig as r, type AllowlistMode as s, type AllowlistUpdateInput as t, type AuthMetrics as u, type BillingPlan as v, type BillingPlansResponse as w, type BillingPortalResponse as x, type BillingState as y, type BillingTier as z };