@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
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
export { A as ALL_CAPABILITIES_BITMASK, c as ActionProof, d as AddPointsInput, e as Agent, f as AgentCreateInput, g as AgentExecuteRequest, h as AgentExecuteResponse, i as AgentFromPromptInput, j as AgentResponse, k as AgentTrigger, l as AgentUpdateInput, m as AgentWorkflow, n as AgentWorkflowEdge, o as AgentWorkflowNode, p as AgentsClientConfig, q as AgentsListResponse, r as AllowlistConfig, s as AllowlistMode, t as AllowlistUpdateInput, u as AuthMetrics, B as BillingClientConfig, v as BillingPlan, w as BillingPlansResponse, x as BillingPortalResponse, y as BillingState, z as BillingTier, C as CAPABILITY_BITS, D as CapabilityKey, E as ChatCompletionChunk, F as ChatCompletionRequest, G as ChatCompletionResponse, H as CommentResponse, I as CommentsResponse, J as ConfigureOAuthInput, K as ConfigureStripeInput, L as ConfigureWeb3Input, M as ConsensusStateSummary, N as ConsensusStatus, O as ContextDomain, P as ContextResponse, Q as ContextsListResponse, R as CreateCheckoutSessionResponse, S as CreateContextInput, U as CreateDelegationInput, V as CreateDomainInput, W as CreateKeyResponse, X as CreatePostInput, Y as CreatePostResponse, Z as CreateStackRequest, _ as Delegation, $ as DelegationChainLink, a0 as DelegationFilters, a1 as DelegationResponse, a2 as DelegationScope, a3 as DelegationsListResponse, a4 as DomainResponse, a5 as DomainsListResponse, a6 as FeedResponse, a7 as FileUploadResponse, a8 as FilesClientConfig, a9 as HistoryFilters, aa as HistoryResponse, ab as ImaginationCharacter, ac as ImaginationMetadata, ad as ImaginationSource, ae as InitNetworkResponse, af as LeaderStatus, ag as LikeCheckResponse, ah as LikeResponse, ai as MCPContent, aj as MCPMessage, ak as MCPSession, al as MCPSessionConfig, am as MCPToolResult, an as MPCNode, ao as MagmaFile, ap as MediaType, aq as Message, ar as MeteredUsage, as as ModelLayerInfo, at as ModelLayersResponse, au as NetworkClientConfig, av as NetworkStatus, br as Orientation, aw as PaginationMeta, ax as PaymentRequiredResponse, ay as PointBalance, az as PointContext, aA as PointRecord, aB as PointRecordResponse, aC as PointSpend, aD as PointSpendResponse, aE as PointsClientConfig, aF as PostResponse, aG as ProfileResponse, aH as RemixesResponse, aI as Skill, aJ as SkillCreateInput, bp as SkillMapPromptResponse, bo as SkillMapResponse, aK as SkillResponse, bq as SkillSummaryResponse, aL as SkillUpdateInput, bn as SkillVerifyResponse, aM as SkillsClientConfig, aN as SkillsListResponse, aO as SocialAuthor, aP as SocialClientConfig, aQ as SocialComment, aR as SocialPost, aS as SocialRemix, aT as SpendDestination, aU as SpendPointsInput, aV as StackCapabilities, aW as StackConfig, aX as StackKeyInfo, aY as StackKeysListResponse, aZ as StackListResponse, a_ as StackManagementClientConfig, a$ as StackMember, b0 as StackMemberStats, b1 as StackModelAlias, b2 as StackOAuthProvider, b3 as StackResponse, b4 as StackStripeProvider, b5 as StackWeb3Provider, b6 as TaskPayload, b7 as TaskResponse, a as TaskState, b as TaskStatus, T as TaskType, b8 as UsageRecord, b9 as UserClientConfig, ba as UserProfile, bb as UserProfileResponse, bc as UserProfileUpdateInput, bd as Widget, be as WidgetCreateInput, bf as WidgetResponse, bg as WidgetSystemPromptResponse, bh as WidgetUpdateInput, bi as WidgetsClientConfig, bj as WidgetsListResponse, bk as WorkflowData, bl as bitmaskToCapabilities, bm as capabilitiesToBitmask } from '../billing-BaJlf_S8.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Coder type definitions
|
|
5
|
+
* Types for the GeoffCoder AI coding agent
|
|
6
|
+
*/
|
|
7
|
+
type CoderSessionStatus = 'active' | 'completed' | 'aborted' | 'error';
|
|
8
|
+
interface CoderSession {
|
|
9
|
+
id: string;
|
|
10
|
+
workingDirectory: string;
|
|
11
|
+
status: CoderSessionStatus;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt?: string;
|
|
14
|
+
metrics: CoderMetrics;
|
|
15
|
+
sandboxId?: string;
|
|
16
|
+
}
|
|
17
|
+
interface CoderMetrics {
|
|
18
|
+
tokensUsed: number;
|
|
19
|
+
promptTokens: number;
|
|
20
|
+
completionTokens: number;
|
|
21
|
+
contextSize: number;
|
|
22
|
+
filesCreated: number;
|
|
23
|
+
filesModified: number;
|
|
24
|
+
linesAdded: number;
|
|
25
|
+
linesRemoved: number;
|
|
26
|
+
commandsExecuted: number;
|
|
27
|
+
toolCallsTotal: number;
|
|
28
|
+
apiCalls: number;
|
|
29
|
+
startTime: number;
|
|
30
|
+
endTime?: number;
|
|
31
|
+
modifiedFiles: string[];
|
|
32
|
+
createdFiles: string[];
|
|
33
|
+
}
|
|
34
|
+
interface CoderExecuteRequest {
|
|
35
|
+
/** The prompt/task for the coder agent */
|
|
36
|
+
prompt: string;
|
|
37
|
+
/** Working directory for file operations */
|
|
38
|
+
workingDirectory?: string;
|
|
39
|
+
/** Maximum iterations for the agent loop */
|
|
40
|
+
maxIterations?: number;
|
|
41
|
+
/** Model to use for completions */
|
|
42
|
+
model?: string;
|
|
43
|
+
/** Maximum tokens per response */
|
|
44
|
+
maxTokens?: number;
|
|
45
|
+
/** Temperature for generation */
|
|
46
|
+
temperature?: number;
|
|
47
|
+
/** Whether to stream the response */
|
|
48
|
+
stream?: boolean;
|
|
49
|
+
/** Existing session ID to continue */
|
|
50
|
+
sessionId?: string;
|
|
51
|
+
/** Existing sandbox ID to use (from frontend) */
|
|
52
|
+
sandboxId?: string;
|
|
53
|
+
/** E2B sandbox configuration */
|
|
54
|
+
sandbox?: CoderSandboxConfig;
|
|
55
|
+
/** Chat ID for session tracking and approval responses */
|
|
56
|
+
chatId?: string;
|
|
57
|
+
/** API base URL for self-hosted inference endpoint */
|
|
58
|
+
apiBase?: string;
|
|
59
|
+
/** API key for authentication */
|
|
60
|
+
apiKey?: string;
|
|
61
|
+
/** Auto-approve tool execution (default: true for backward compatibility) */
|
|
62
|
+
autoApprove?: boolean;
|
|
63
|
+
/** Tool permission overrides */
|
|
64
|
+
toolPermissions?: Record<string, {
|
|
65
|
+
permission: 'always' | 'ask' | 'never';
|
|
66
|
+
allowlist?: string[];
|
|
67
|
+
denylist?: string[];
|
|
68
|
+
}>;
|
|
69
|
+
}
|
|
70
|
+
interface CoderSandboxConfig {
|
|
71
|
+
/** Enable sandbox execution */
|
|
72
|
+
enabled: boolean;
|
|
73
|
+
/** Sandbox template (e.g., 'node', 'python', 'nextjs') */
|
|
74
|
+
template?: string;
|
|
75
|
+
/** Session timeout in seconds */
|
|
76
|
+
timeout?: number;
|
|
77
|
+
/** Environment variables */
|
|
78
|
+
env?: Record<string, string>;
|
|
79
|
+
/** Packages to pre-install */
|
|
80
|
+
packages?: string[];
|
|
81
|
+
}
|
|
82
|
+
interface CoderExecuteResponse {
|
|
83
|
+
sessionId: string;
|
|
84
|
+
status: CoderSessionStatus;
|
|
85
|
+
result?: string;
|
|
86
|
+
error?: string;
|
|
87
|
+
metrics: CoderMetrics;
|
|
88
|
+
}
|
|
89
|
+
type CoderStreamEventType = 'session_start' | 'thinking' | 'tool_call' | 'tool_result' | 'assistant_message' | 'progress' | 'metrics_update' | 'session_complete' | 'complete' | 'file_written' | 'file_modified' | 'sandbox_info' | 'session_files' | 'text' | 'done' | 'error' | 'approval_required' | 'approval_response' | 'tool_blocked' | 'context_compacted' | 'background_process_started' | 'background_process_completed' | 'session_saved' | 'session_resumed' | 'file_checkpoint' | 'memory_loaded' | 'question_asked' | 'question_answered' | 'blueprint_generated' | 'plan_progress' | 'token_usage' | 'task_created' | 'task_update';
|
|
90
|
+
interface CoderStreamEvent {
|
|
91
|
+
type: CoderStreamEventType;
|
|
92
|
+
data: unknown;
|
|
93
|
+
timestamp: number;
|
|
94
|
+
}
|
|
95
|
+
interface CoderThinkingEvent {
|
|
96
|
+
type: 'thinking';
|
|
97
|
+
data: {
|
|
98
|
+
content: string;
|
|
99
|
+
iteration: number;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
interface CoderToolCallEvent {
|
|
103
|
+
type: 'tool_call';
|
|
104
|
+
data: {
|
|
105
|
+
toolName: string;
|
|
106
|
+
arguments: Record<string, unknown>;
|
|
107
|
+
toolCallId: string;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
interface CoderToolResultEvent {
|
|
111
|
+
type: 'tool_result';
|
|
112
|
+
data: {
|
|
113
|
+
toolCallId: string;
|
|
114
|
+
toolName: string;
|
|
115
|
+
success: boolean;
|
|
116
|
+
output: string;
|
|
117
|
+
error?: string;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
interface CoderProgressEvent {
|
|
121
|
+
type: 'progress';
|
|
122
|
+
data: {
|
|
123
|
+
iteration: number;
|
|
124
|
+
maxIterations: number;
|
|
125
|
+
currentAction: string;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
interface CoderTool {
|
|
129
|
+
name: string;
|
|
130
|
+
description: string;
|
|
131
|
+
parameters: {
|
|
132
|
+
type: 'object';
|
|
133
|
+
properties: Record<string, CoderToolParameter>;
|
|
134
|
+
required?: string[];
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
interface CoderToolParameter {
|
|
138
|
+
type: string;
|
|
139
|
+
description: string;
|
|
140
|
+
enum?: string[];
|
|
141
|
+
}
|
|
142
|
+
interface CoderToolResult {
|
|
143
|
+
success: boolean;
|
|
144
|
+
output: string;
|
|
145
|
+
error?: string;
|
|
146
|
+
}
|
|
147
|
+
interface CoderFileInfo {
|
|
148
|
+
name: string;
|
|
149
|
+
path: string;
|
|
150
|
+
size: number;
|
|
151
|
+
isDirectory: boolean;
|
|
152
|
+
modified?: string;
|
|
153
|
+
children?: CoderFileInfo[];
|
|
154
|
+
}
|
|
155
|
+
interface CoderFileContent {
|
|
156
|
+
path: string;
|
|
157
|
+
content: string;
|
|
158
|
+
encoding?: 'utf8' | 'base64';
|
|
159
|
+
size: number;
|
|
160
|
+
}
|
|
161
|
+
interface CoderFileWriteInput {
|
|
162
|
+
path: string;
|
|
163
|
+
content: string;
|
|
164
|
+
encoding?: 'utf8' | 'base64';
|
|
165
|
+
createDirectories?: boolean;
|
|
166
|
+
}
|
|
167
|
+
interface CoderSearchResult {
|
|
168
|
+
file: string;
|
|
169
|
+
line: number;
|
|
170
|
+
content: string;
|
|
171
|
+
contextBefore?: string[];
|
|
172
|
+
contextAfter?: string[];
|
|
173
|
+
}
|
|
174
|
+
interface CoderDiffInput {
|
|
175
|
+
path: string;
|
|
176
|
+
original: string;
|
|
177
|
+
replacement: string;
|
|
178
|
+
replaceAll?: boolean;
|
|
179
|
+
}
|
|
180
|
+
interface CoderCommandResult {
|
|
181
|
+
stdout: string;
|
|
182
|
+
stderr: string;
|
|
183
|
+
exitCode: number;
|
|
184
|
+
executionTimeMs: number;
|
|
185
|
+
}
|
|
186
|
+
interface CoderCommandInput {
|
|
187
|
+
command: string;
|
|
188
|
+
timeout?: number;
|
|
189
|
+
cwd?: string;
|
|
190
|
+
}
|
|
191
|
+
interface CoderSandbox {
|
|
192
|
+
id: string;
|
|
193
|
+
status: 'creating' | 'ready' | 'busy' | 'stopped' | 'error';
|
|
194
|
+
template: string;
|
|
195
|
+
workingDirectory: string;
|
|
196
|
+
createdAt: string;
|
|
197
|
+
expiresAt?: string;
|
|
198
|
+
}
|
|
199
|
+
interface CoderSandboxCreateInput {
|
|
200
|
+
template?: string;
|
|
201
|
+
timeout?: number;
|
|
202
|
+
env?: Record<string, string>;
|
|
203
|
+
packages?: string[];
|
|
204
|
+
}
|
|
205
|
+
interface CoderSandboxExecInput {
|
|
206
|
+
command: string;
|
|
207
|
+
timeout?: number;
|
|
208
|
+
stream?: boolean;
|
|
209
|
+
}
|
|
210
|
+
interface CoderSandboxExecResult {
|
|
211
|
+
stdout: string;
|
|
212
|
+
stderr: string;
|
|
213
|
+
exitCode: number;
|
|
214
|
+
executionTimeMs: number;
|
|
215
|
+
}
|
|
216
|
+
interface CoderSessionResponse {
|
|
217
|
+
session: CoderSession;
|
|
218
|
+
}
|
|
219
|
+
interface CoderSessionsListResponse {
|
|
220
|
+
sessions: CoderSession[];
|
|
221
|
+
}
|
|
222
|
+
interface CoderToolsResponse {
|
|
223
|
+
tools: CoderTool[];
|
|
224
|
+
}
|
|
225
|
+
interface CoderFilesResponse {
|
|
226
|
+
files: CoderFileInfo[];
|
|
227
|
+
path: string;
|
|
228
|
+
}
|
|
229
|
+
interface CoderSandboxResponse {
|
|
230
|
+
sandbox: CoderSandbox;
|
|
231
|
+
}
|
|
232
|
+
interface CoderClientConfig {
|
|
233
|
+
/** Base URL for the task network API */
|
|
234
|
+
baseUrl?: string;
|
|
235
|
+
/** API key for authentication */
|
|
236
|
+
apiKey?: string;
|
|
237
|
+
/** Request timeout in milliseconds */
|
|
238
|
+
timeout?: number;
|
|
239
|
+
/** Default model for coder sessions */
|
|
240
|
+
defaultModel?: string;
|
|
241
|
+
/** Default max iterations */
|
|
242
|
+
defaultMaxIterations?: number;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Credential and identity type definitions
|
|
247
|
+
*/
|
|
248
|
+
type AuthMethod = 'email' | 'web3_evm' | 'web3_solana' | 'web3_bitcoin' | 'web3_cosmos' | 'oauth_google' | 'oauth_github' | 'oauth_discord' | 'oauth_twitter';
|
|
249
|
+
type Web3Chain = 'ethereum' | 'solana' | 'bitcoin' | 'cosmos' | 'polygon' | 'arbitrum' | 'base';
|
|
250
|
+
type CredentialType = 'email' | 'web3_wallet' | 'oauth_social' | 'billing_stripe' | 'stripe_connect';
|
|
251
|
+
interface StackCredential {
|
|
252
|
+
id: string;
|
|
253
|
+
stack_identity_id: string;
|
|
254
|
+
credential_type: CredentialType;
|
|
255
|
+
credential_data: EmailCredentialData | Web3CredentialData | OAuthCredentialData | BillingCredentialData | StripeConnectCredentialData;
|
|
256
|
+
is_primary: boolean;
|
|
257
|
+
linked_at: number;
|
|
258
|
+
}
|
|
259
|
+
interface EmailCredentialData {
|
|
260
|
+
email_hash: string;
|
|
261
|
+
verified: boolean;
|
|
262
|
+
verified_at?: number;
|
|
263
|
+
}
|
|
264
|
+
interface Web3CredentialData {
|
|
265
|
+
chain: Web3Chain;
|
|
266
|
+
address: string;
|
|
267
|
+
address_type: 'p2wpkh' | 'p2tr' | 'ed25519' | 'secp256k1';
|
|
268
|
+
verification_signature: string;
|
|
269
|
+
verified_at: number;
|
|
270
|
+
}
|
|
271
|
+
interface OAuthCredentialData {
|
|
272
|
+
provider: 'google' | 'github' | 'discord' | 'twitter';
|
|
273
|
+
provider_user_id: string;
|
|
274
|
+
handle?: string;
|
|
275
|
+
verified_at: number;
|
|
276
|
+
}
|
|
277
|
+
interface BillingCredentialData {
|
|
278
|
+
provider: 'stripe';
|
|
279
|
+
customer_id: string;
|
|
280
|
+
has_payment_method: boolean;
|
|
281
|
+
default_payment_method_id?: string;
|
|
282
|
+
card_last_four?: string;
|
|
283
|
+
card_brand?: string;
|
|
284
|
+
billing_email?: string;
|
|
285
|
+
verified_at: number;
|
|
286
|
+
}
|
|
287
|
+
interface StripeConnectCredentialData {
|
|
288
|
+
provider: 'stripe_connect';
|
|
289
|
+
account_id: string;
|
|
290
|
+
details_submitted: boolean;
|
|
291
|
+
charges_enabled: boolean;
|
|
292
|
+
payouts_enabled: boolean;
|
|
293
|
+
email?: string;
|
|
294
|
+
verified_at: number;
|
|
295
|
+
}
|
|
296
|
+
interface CredentialLinkProof {
|
|
297
|
+
chain?: Web3Chain;
|
|
298
|
+
message?: string;
|
|
299
|
+
signature?: string;
|
|
300
|
+
public_key?: string;
|
|
301
|
+
provider?: string;
|
|
302
|
+
code?: string;
|
|
303
|
+
email?: string;
|
|
304
|
+
}
|
|
305
|
+
interface GlobalIdentity {
|
|
306
|
+
id: string;
|
|
307
|
+
identity_commitment: string;
|
|
308
|
+
root_public_key: string;
|
|
309
|
+
recovery_commitments: string[];
|
|
310
|
+
created_at: number;
|
|
311
|
+
updated_at: number;
|
|
312
|
+
}
|
|
313
|
+
interface StackIdentity {
|
|
314
|
+
id: string;
|
|
315
|
+
global_identity_id: string;
|
|
316
|
+
stack_id: string;
|
|
317
|
+
stack_public_key: string;
|
|
318
|
+
created_at: number;
|
|
319
|
+
last_login: number;
|
|
320
|
+
}
|
|
321
|
+
interface Session {
|
|
322
|
+
id: string;
|
|
323
|
+
app_identity_id: string;
|
|
324
|
+
global_identity_commitment: string;
|
|
325
|
+
app_id: string;
|
|
326
|
+
credentials: string[];
|
|
327
|
+
app_pubkey: string;
|
|
328
|
+
jwt: string;
|
|
329
|
+
issued_at: number;
|
|
330
|
+
expires_at: number;
|
|
331
|
+
issuer: string;
|
|
332
|
+
signed_by: string[];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export type { AuthMethod, BillingCredentialData, CoderClientConfig, CoderCommandInput, CoderCommandResult, CoderDiffInput, CoderExecuteRequest, CoderExecuteResponse, CoderFileContent, CoderFileInfo, CoderFileWriteInput, CoderFilesResponse, CoderMetrics, CoderProgressEvent, CoderSandbox, CoderSandboxConfig, CoderSandboxCreateInput, CoderSandboxExecInput, CoderSandboxExecResult, CoderSandboxResponse, CoderSearchResult, CoderSession, CoderSessionResponse, CoderSessionStatus, CoderSessionsListResponse, CoderStreamEvent, CoderStreamEventType, CoderThinkingEvent, CoderTool, CoderToolCallEvent, CoderToolParameter, CoderToolResult, CoderToolResultEvent, CoderToolsResponse, CredentialLinkProof, CredentialType, EmailCredentialData, GlobalIdentity, OAuthCredentialData, Session, StackCredential, StackIdentity, StripeConnectCredentialData, Web3Chain, Web3CredentialData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o={text_input:1,image_input:2,file_input:4,audio_input:8,video_input:16,music_input:32,text_output:64,image_output:128,audio_output:256,video_output:512,embeddings_output:1024,music_output:2048,skills:4096,loops:8192,tools:16384,pipelines:32768,training:65536},n=131071;function a(t){let e=0;for(let[i,r]of Object.entries(o))t[i]&&(e|=r);return e}function s(t){let e={};for(let[i,r]of Object.entries(o))e[i]=(t&r)!==0;return e}export{n as ALL_CAPABILITIES_BITMASK,o as CAPABILITY_BITS,s as bitmaskToCapabilities,a as capabilitiesToBitmask};
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stacknet/stacks",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SDK for connecting to StackNet",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./clients": {
|
|
16
|
+
"types": "./dist/clients/index.d.ts",
|
|
17
|
+
"import": "./dist/clients/index.js",
|
|
18
|
+
"require": "./dist/clients/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./streaming": {
|
|
21
|
+
"types": "./dist/streaming/index.d.ts",
|
|
22
|
+
"import": "./dist/streaming/index.js",
|
|
23
|
+
"require": "./dist/streaming/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./proxy": {
|
|
26
|
+
"types": "./dist/proxy/index.d.ts",
|
|
27
|
+
"import": "./dist/proxy/index.js",
|
|
28
|
+
"require": "./dist/proxy/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./types": {
|
|
31
|
+
"types": "./dist/types/index.d.ts",
|
|
32
|
+
"import": "./dist/types/index.js",
|
|
33
|
+
"require": "./dist/types/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"src"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup",
|
|
42
|
+
"build:publish": "tsup --no-sourcemap --minify",
|
|
43
|
+
"dev": "tsup --watch",
|
|
44
|
+
"clean": "rm -rf dist",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"prepublishOnly": "pnpm run clean && pnpm run typecheck && pnpm run build:publish",
|
|
47
|
+
"release": "pnpm run prepublishOnly && npm publish --access public"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@xenova/transformers": "^2.17.2",
|
|
51
|
+
"redis": "^4.7.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^20.0.0",
|
|
55
|
+
"tsup": "^8.0.0",
|
|
56
|
+
"typescript": "^5.0.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"next": ">=14.0.0"
|
|
60
|
+
},
|
|
61
|
+
"peerDependenciesMeta": {
|
|
62
|
+
"next": {
|
|
63
|
+
"optional": true
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"keywords": [
|
|
67
|
+
"stacknet",
|
|
68
|
+
"stacks",
|
|
69
|
+
"p2p",
|
|
70
|
+
"task-network",
|
|
71
|
+
"ai",
|
|
72
|
+
"sdk"
|
|
73
|
+
],
|
|
74
|
+
"license": "MIT"
|
|
75
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agents Client
|
|
3
|
+
* Client for interacting with the agents API
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { DEFAULT_TASK_NETWORK_URL, JSON_HEADERS } from '../utils/constants';
|
|
7
|
+
import { StacksSDKError } from '../utils/errors';
|
|
8
|
+
import type {
|
|
9
|
+
Agent,
|
|
10
|
+
AgentsListResponse,
|
|
11
|
+
AgentResponse,
|
|
12
|
+
AgentCreateInput,
|
|
13
|
+
AgentUpdateInput,
|
|
14
|
+
AgentFromPromptInput,
|
|
15
|
+
AgentExecuteRequest,
|
|
16
|
+
AgentExecuteResponse,
|
|
17
|
+
AgentsClientConfig,
|
|
18
|
+
} from '../types/agent';
|
|
19
|
+
|
|
20
|
+
export type { AgentsClientConfig } from '../types/agent';
|
|
21
|
+
|
|
22
|
+
export class AgentsClient {
|
|
23
|
+
private baseUrl: string;
|
|
24
|
+
private useCpxApi: boolean;
|
|
25
|
+
|
|
26
|
+
constructor(config: AgentsClientConfig = {}) {
|
|
27
|
+
this.baseUrl = config.baseUrl || DEFAULT_TASK_NETWORK_URL;
|
|
28
|
+
// Use coprocessor API by default (can be disabled for backwards compatibility)
|
|
29
|
+
this.useCpxApi = config.useCpxApi !== false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private get agentsUrl(): string {
|
|
33
|
+
// Route through Agent Coprocessor at /cpx/agent/agents
|
|
34
|
+
return this.useCpxApi
|
|
35
|
+
? `${this.baseUrl}/cpx/agent/agents`
|
|
36
|
+
: `${this.baseUrl}/agents`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* List all agents
|
|
41
|
+
*/
|
|
42
|
+
async list(options: { userMid?: string } = {}): Promise<AgentsListResponse> {
|
|
43
|
+
const params = new URLSearchParams();
|
|
44
|
+
if (options.userMid) {
|
|
45
|
+
params.set('userMid', options.userMid);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const queryString = params.toString();
|
|
49
|
+
const url = `${this.agentsUrl}${queryString ? `?${queryString}` : ''}`;
|
|
50
|
+
|
|
51
|
+
const response = await fetch(url);
|
|
52
|
+
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
throw new StacksSDKError(
|
|
55
|
+
'bad_request:api',
|
|
56
|
+
`Failed to list agents: ${response.statusText}`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return response.json();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get an agent by ID
|
|
65
|
+
*/
|
|
66
|
+
async get(id: string): Promise<Agent> {
|
|
67
|
+
const response = await fetch(`${this.agentsUrl}/${id}`);
|
|
68
|
+
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
throw new StacksSDKError(
|
|
71
|
+
response.status === 404 ? 'not_found:api' : 'bad_request:api',
|
|
72
|
+
`Failed to get agent: ${response.statusText}`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return response.json();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Create a new agent
|
|
81
|
+
*/
|
|
82
|
+
async create(input: AgentCreateInput): Promise<AgentResponse> {
|
|
83
|
+
const response = await fetch(this.agentsUrl, {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
headers: JSON_HEADERS,
|
|
86
|
+
body: JSON.stringify(input),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if (!response.ok) {
|
|
90
|
+
const data = await response.json().catch(() => ({}));
|
|
91
|
+
throw new StacksSDKError(
|
|
92
|
+
'bad_request:api',
|
|
93
|
+
data.error || `Failed to create agent: ${response.statusText}`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return response.json();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Update an agent
|
|
102
|
+
*/
|
|
103
|
+
async update(id: string, input: AgentUpdateInput): Promise<AgentResponse> {
|
|
104
|
+
const response = await fetch(`${this.agentsUrl}/${id}`, {
|
|
105
|
+
method: 'PUT',
|
|
106
|
+
headers: JSON_HEADERS,
|
|
107
|
+
body: JSON.stringify(input),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (!response.ok) {
|
|
111
|
+
const data = await response.json().catch(() => ({}));
|
|
112
|
+
throw new StacksSDKError(
|
|
113
|
+
'bad_request:api',
|
|
114
|
+
data.error || `Failed to update agent: ${response.statusText}`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return response.json();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Delete an agent
|
|
123
|
+
*/
|
|
124
|
+
async delete(id: string): Promise<{ success: boolean }> {
|
|
125
|
+
const response = await fetch(`${this.agentsUrl}/${id}`, {
|
|
126
|
+
method: 'DELETE',
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
if (!response.ok) {
|
|
130
|
+
throw new StacksSDKError(
|
|
131
|
+
'bad_request:api',
|
|
132
|
+
`Failed to delete agent: ${response.statusText}`
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return response.json();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Enable an agent
|
|
141
|
+
*/
|
|
142
|
+
async enable(id: string): Promise<AgentResponse> {
|
|
143
|
+
const response = await fetch(`${this.agentsUrl}/${id}/enable`, {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
if (!response.ok) {
|
|
148
|
+
throw new StacksSDKError(
|
|
149
|
+
'bad_request:api',
|
|
150
|
+
`Failed to enable agent: ${response.statusText}`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return response.json();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Disable an agent
|
|
159
|
+
*/
|
|
160
|
+
async disable(id: string): Promise<AgentResponse> {
|
|
161
|
+
const response = await fetch(`${this.agentsUrl}/${id}/disable`, {
|
|
162
|
+
method: 'POST',
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
if (!response.ok) {
|
|
166
|
+
throw new StacksSDKError(
|
|
167
|
+
'bad_request:api',
|
|
168
|
+
`Failed to disable agent: ${response.statusText}`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return response.json();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Execute an agent
|
|
177
|
+
*/
|
|
178
|
+
async execute(id: string, request: AgentExecuteRequest = {}): Promise<AgentExecuteResponse> {
|
|
179
|
+
const response = await fetch(`${this.agentsUrl}/${id}/execute`, {
|
|
180
|
+
method: 'POST',
|
|
181
|
+
headers: JSON_HEADERS,
|
|
182
|
+
body: JSON.stringify(request),
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
if (!response.ok) {
|
|
186
|
+
throw new StacksSDKError(
|
|
187
|
+
'bad_request:api',
|
|
188
|
+
`Failed to execute agent: ${response.statusText}`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return response.json();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Create agent from prompt (AI-generated)
|
|
197
|
+
*/
|
|
198
|
+
async createFromPrompt(input: AgentFromPromptInput): Promise<AgentResponse> {
|
|
199
|
+
// First, generate agent config from prompt
|
|
200
|
+
const generateResponse = await fetch(`${this.agentsUrl}/from-prompt`, {
|
|
201
|
+
method: 'POST',
|
|
202
|
+
headers: JSON_HEADERS,
|
|
203
|
+
body: JSON.stringify(input),
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
if (!generateResponse.ok) {
|
|
207
|
+
throw new StacksSDKError(
|
|
208
|
+
'bad_request:api',
|
|
209
|
+
`Failed to generate agent from prompt: ${generateResponse.statusText}`
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const agentConfig = await generateResponse.json();
|
|
214
|
+
|
|
215
|
+
// Then create the agent
|
|
216
|
+
return this.create({
|
|
217
|
+
...agentConfig,
|
|
218
|
+
created_by: input.created_by,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Create an AgentsClient instance
|
|
225
|
+
*/
|
|
226
|
+
export function createAgentsClient(config: AgentsClientConfig = {}): AgentsClient {
|
|
227
|
+
return new AgentsClient(config);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Default agents client instance
|
|
232
|
+
*/
|
|
233
|
+
export const agentsClient = createAgentsClient();
|