siliconbridge 0.2.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 ADDED
@@ -0,0 +1,59 @@
1
+ # SiliconBridge — JS/TS SDK
2
+
3
+ Human-in-the-loop API for AI agents. Submit tasks to human operators via a simple API.
4
+
5
+ ```bash
6
+ npm install siliconbridge
7
+ ```
8
+
9
+ ## Quick Start
10
+
11
+ ```typescript
12
+ import { SiliconBridge } from 'siliconbridge';
13
+
14
+ // Sign up with just a wallet address (no email needed)
15
+ const { api_key } = await SiliconBridge.signupWithWallet('0x...');
16
+
17
+ const sb = new SiliconBridge(api_key);
18
+
19
+ // Solve a CAPTCHA
20
+ const solution = await sb.solveCaptcha('https://example.com/captcha.png');
21
+
22
+ // Get OTP/2FA code
23
+ const code = await sb.requestOtp('github');
24
+
25
+ // Request human approval
26
+ const approved = await sb.requestApproval('Deploy to production');
27
+
28
+ // Request a quote for infrastructure
29
+ const quote = await sb.requestQuote('btc_wallet_setup', 'Set up a Lightning wallet for my trading agent');
30
+ ```
31
+
32
+ ## Quote-Based Services
33
+
34
+ Bitcoin wallet setup, exchange accounts, domain registration, cloud accounts, code signing, business formation, social media accounts, smart contracts, mailing addresses, payment gateways, agent storage, agent clone, compute, identity proxy, phone calls, document signing.
35
+
36
+ All quote-based: $10 deposit, quote within 1hr, our cost + 30%.
37
+
38
+ ```typescript
39
+ const quote = await sb.requestQuote('exchange_account', 'Coinbase Pro with API access for automated trading');
40
+ const details = await sb.getQuote(quote.quote_id);
41
+ const confirmed = await sb.acceptQuote(quote.quote_id);
42
+ ```
43
+
44
+ ## Crypto Payments
45
+
46
+ ```
47
+ BTC: bc1qqtu8f09hqncxug75vw3s4wjnsx6858ldrk4cvm
48
+ USDC/ETH: 0x1141b577584440013c722215cf2e98779BddAa55
49
+ ```
50
+
51
+ ```typescript
52
+ await sb.topUpCrypto('0xabc...', 'eth', 50.00);
53
+ ```
54
+
55
+ ## Links
56
+
57
+ - Website: https://siliconbridge.xyz
58
+ - PyPI: https://pypi.org/project/siliconbridge/
59
+ - Docs: https://siliconbridge.xyz/docs
@@ -0,0 +1,106 @@
1
+ /**
2
+ * SiliconBridge — Human-in-the-loop API for AI agents.
3
+ *
4
+ * Usage:
5
+ * import { SiliconBridge } from 'siliconbridge';
6
+ * const sb = new SiliconBridge('sb_...');
7
+ * const solution = await sb.solveCaptcha('https://example.com/captcha.png');
8
+ */
9
+ declare class SiliconBridgeError extends Error {
10
+ statusCode?: number;
11
+ detail?: any;
12
+ constructor(message: string, statusCode?: number, detail?: any);
13
+ }
14
+ declare class TaskTimeout extends SiliconBridgeError {
15
+ constructor(message: string);
16
+ }
17
+ interface TaskResult {
18
+ task_id: string;
19
+ status: string;
20
+ result?: Record<string, any>;
21
+ estimated_wait?: number;
22
+ [key: string]: any;
23
+ }
24
+ interface QuoteResult {
25
+ quote_id: string;
26
+ status: string;
27
+ deposit_charged?: number;
28
+ [key: string]: any;
29
+ }
30
+ interface BalanceResult {
31
+ balance_usd: number;
32
+ low_balance: boolean;
33
+ critical: boolean;
34
+ top_up_btc?: string;
35
+ top_up_usdc?: string;
36
+ [key: string]: any;
37
+ }
38
+ interface SignupResult {
39
+ api_key: string;
40
+ balance: number;
41
+ referral_code?: string;
42
+ [key: string]: any;
43
+ }
44
+ interface SiliconBridgeOptions {
45
+ baseUrl?: string;
46
+ timeout?: number;
47
+ }
48
+ declare class SiliconBridge {
49
+ private apiKey;
50
+ private baseUrl;
51
+ private timeout;
52
+ static readonly BASE_URL = "https://siliconbridge.xyz";
53
+ constructor(apiKey: string, options?: SiliconBridgeOptions);
54
+ private request;
55
+ submitTask(serviceType: string, payload: Record<string, any>, callbackUrl?: string): Promise<TaskResult>;
56
+ getTask(taskId: string): Promise<TaskResult>;
57
+ waitForResult(taskId: string, timeout?: number, pollInterval?: number): Promise<TaskResult>;
58
+ solveCaptcha(imageUrl: string, options?: {
59
+ instructions?: string;
60
+ wait?: boolean;
61
+ timeout?: number;
62
+ }): Promise<string | TaskResult>;
63
+ verifyIdentity(documentUrl: string, options?: {
64
+ selfieUrl?: string;
65
+ instructions?: string;
66
+ wait?: boolean;
67
+ timeout?: number;
68
+ }): Promise<TaskResult>;
69
+ moderateContent(content: string, options?: {
70
+ contentType?: string;
71
+ guidelines?: string;
72
+ wait?: boolean;
73
+ timeout?: number;
74
+ }): Promise<TaskResult>;
75
+ customTask(instructions: string, options?: {
76
+ data?: Record<string, any>;
77
+ wait?: boolean;
78
+ timeout?: number;
79
+ }): Promise<TaskResult>;
80
+ requestOtp(serviceName: string, options?: {
81
+ instructions?: string;
82
+ wait?: boolean;
83
+ timeout?: number;
84
+ }): Promise<string | TaskResult>;
85
+ requestApproval(action: string, options?: {
86
+ context?: string;
87
+ wait?: boolean;
88
+ timeout?: number;
89
+ }): Promise<boolean | TaskResult>;
90
+ requestPhoneVerification(phoneNumber: string, options?: {
91
+ instructions?: string;
92
+ wait?: boolean;
93
+ timeout?: number;
94
+ }): Promise<TaskResult>;
95
+ requestQuote(service: string, description: string): Promise<QuoteResult>;
96
+ getQuote(quoteId: string): Promise<QuoteResult>;
97
+ acceptQuote(quoteId: string): Promise<QuoteResult>;
98
+ listQuotes(): Promise<QuoteResult[]>;
99
+ getAccount(): Promise<Record<string, any>>;
100
+ getBalance(): Promise<number>;
101
+ checkBalance(): Promise<BalanceResult>;
102
+ topUpCrypto(txHash: string, chain: string, amountUsd: number): Promise<Record<string, any>>;
103
+ static signupWithWallet(walletAddress: string, baseUrl?: string): Promise<SignupResult>;
104
+ }
105
+
106
+ export { type BalanceResult, type QuoteResult, type SignupResult, SiliconBridge, SiliconBridgeError, type SiliconBridgeOptions, type TaskResult, TaskTimeout, SiliconBridge as default };
@@ -0,0 +1,106 @@
1
+ /**
2
+ * SiliconBridge — Human-in-the-loop API for AI agents.
3
+ *
4
+ * Usage:
5
+ * import { SiliconBridge } from 'siliconbridge';
6
+ * const sb = new SiliconBridge('sb_...');
7
+ * const solution = await sb.solveCaptcha('https://example.com/captcha.png');
8
+ */
9
+ declare class SiliconBridgeError extends Error {
10
+ statusCode?: number;
11
+ detail?: any;
12
+ constructor(message: string, statusCode?: number, detail?: any);
13
+ }
14
+ declare class TaskTimeout extends SiliconBridgeError {
15
+ constructor(message: string);
16
+ }
17
+ interface TaskResult {
18
+ task_id: string;
19
+ status: string;
20
+ result?: Record<string, any>;
21
+ estimated_wait?: number;
22
+ [key: string]: any;
23
+ }
24
+ interface QuoteResult {
25
+ quote_id: string;
26
+ status: string;
27
+ deposit_charged?: number;
28
+ [key: string]: any;
29
+ }
30
+ interface BalanceResult {
31
+ balance_usd: number;
32
+ low_balance: boolean;
33
+ critical: boolean;
34
+ top_up_btc?: string;
35
+ top_up_usdc?: string;
36
+ [key: string]: any;
37
+ }
38
+ interface SignupResult {
39
+ api_key: string;
40
+ balance: number;
41
+ referral_code?: string;
42
+ [key: string]: any;
43
+ }
44
+ interface SiliconBridgeOptions {
45
+ baseUrl?: string;
46
+ timeout?: number;
47
+ }
48
+ declare class SiliconBridge {
49
+ private apiKey;
50
+ private baseUrl;
51
+ private timeout;
52
+ static readonly BASE_URL = "https://siliconbridge.xyz";
53
+ constructor(apiKey: string, options?: SiliconBridgeOptions);
54
+ private request;
55
+ submitTask(serviceType: string, payload: Record<string, any>, callbackUrl?: string): Promise<TaskResult>;
56
+ getTask(taskId: string): Promise<TaskResult>;
57
+ waitForResult(taskId: string, timeout?: number, pollInterval?: number): Promise<TaskResult>;
58
+ solveCaptcha(imageUrl: string, options?: {
59
+ instructions?: string;
60
+ wait?: boolean;
61
+ timeout?: number;
62
+ }): Promise<string | TaskResult>;
63
+ verifyIdentity(documentUrl: string, options?: {
64
+ selfieUrl?: string;
65
+ instructions?: string;
66
+ wait?: boolean;
67
+ timeout?: number;
68
+ }): Promise<TaskResult>;
69
+ moderateContent(content: string, options?: {
70
+ contentType?: string;
71
+ guidelines?: string;
72
+ wait?: boolean;
73
+ timeout?: number;
74
+ }): Promise<TaskResult>;
75
+ customTask(instructions: string, options?: {
76
+ data?: Record<string, any>;
77
+ wait?: boolean;
78
+ timeout?: number;
79
+ }): Promise<TaskResult>;
80
+ requestOtp(serviceName: string, options?: {
81
+ instructions?: string;
82
+ wait?: boolean;
83
+ timeout?: number;
84
+ }): Promise<string | TaskResult>;
85
+ requestApproval(action: string, options?: {
86
+ context?: string;
87
+ wait?: boolean;
88
+ timeout?: number;
89
+ }): Promise<boolean | TaskResult>;
90
+ requestPhoneVerification(phoneNumber: string, options?: {
91
+ instructions?: string;
92
+ wait?: boolean;
93
+ timeout?: number;
94
+ }): Promise<TaskResult>;
95
+ requestQuote(service: string, description: string): Promise<QuoteResult>;
96
+ getQuote(quoteId: string): Promise<QuoteResult>;
97
+ acceptQuote(quoteId: string): Promise<QuoteResult>;
98
+ listQuotes(): Promise<QuoteResult[]>;
99
+ getAccount(): Promise<Record<string, any>>;
100
+ getBalance(): Promise<number>;
101
+ checkBalance(): Promise<BalanceResult>;
102
+ topUpCrypto(txHash: string, chain: string, amountUsd: number): Promise<Record<string, any>>;
103
+ static signupWithWallet(walletAddress: string, baseUrl?: string): Promise<SignupResult>;
104
+ }
105
+
106
+ export { type BalanceResult, type QuoteResult, type SignupResult, SiliconBridge, SiliconBridgeError, type SiliconBridgeOptions, type TaskResult, TaskTimeout, SiliconBridge as default };
package/dist/index.js ADDED
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ SiliconBridge: () => SiliconBridge,
24
+ SiliconBridgeError: () => SiliconBridgeError,
25
+ TaskTimeout: () => TaskTimeout,
26
+ default: () => index_default
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+ var SiliconBridgeError = class extends Error {
30
+ constructor(message, statusCode, detail) {
31
+ super(message);
32
+ this.name = "SiliconBridgeError";
33
+ this.statusCode = statusCode;
34
+ this.detail = detail;
35
+ }
36
+ };
37
+ var TaskTimeout = class extends SiliconBridgeError {
38
+ constructor(message) {
39
+ super(message);
40
+ this.name = "TaskTimeout";
41
+ }
42
+ };
43
+ var _SiliconBridge = class _SiliconBridge {
44
+ constructor(apiKey, options = {}) {
45
+ this.apiKey = apiKey;
46
+ this.baseUrl = (options.baseUrl || _SiliconBridge.BASE_URL).replace(/\/+$/, "");
47
+ this.timeout = options.timeout || 3e4;
48
+ }
49
+ async request(method, path, body) {
50
+ const url = `${this.baseUrl}${path}`;
51
+ const headers = {
52
+ "X-API-Key": this.apiKey,
53
+ "Content-Type": "application/json"
54
+ };
55
+ const controller = new AbortController();
56
+ const timer = setTimeout(() => controller.abort(), this.timeout);
57
+ try {
58
+ const res = await fetch(url, {
59
+ method,
60
+ headers,
61
+ body: body ? JSON.stringify(body) : void 0,
62
+ signal: controller.signal
63
+ });
64
+ if (res.status >= 400) {
65
+ let detail;
66
+ try {
67
+ const json = await res.json();
68
+ detail = json.detail || json;
69
+ } catch {
70
+ detail = await res.text();
71
+ }
72
+ throw new SiliconBridgeError(
73
+ `API error ${res.status}: ${typeof detail === "string" ? detail : JSON.stringify(detail)}`,
74
+ res.status,
75
+ detail
76
+ );
77
+ }
78
+ return await res.json();
79
+ } finally {
80
+ clearTimeout(timer);
81
+ }
82
+ }
83
+ // ── Core Methods ──────────────────────────────────────────────
84
+ async submitTask(serviceType, payload, callbackUrl) {
85
+ const body = { service_type: serviceType, payload };
86
+ if (callbackUrl) body.callback_url = callbackUrl;
87
+ return this.request("POST", "/tasks/submit", body);
88
+ }
89
+ async getTask(taskId) {
90
+ return this.request("GET", `/tasks/${taskId}`);
91
+ }
92
+ async waitForResult(taskId, timeout = 300, pollInterval = 5) {
93
+ const deadline = Date.now() + timeout * 1e3;
94
+ while (Date.now() < deadline) {
95
+ const task = await this.getTask(taskId);
96
+ if (task.status === "completed") return task;
97
+ if (task.status === "failed") {
98
+ throw new SiliconBridgeError(`Task ${taskId} failed`, void 0, task.result);
99
+ }
100
+ await new Promise((r) => setTimeout(r, pollInterval * 1e3));
101
+ }
102
+ throw new TaskTimeout(`Task ${taskId} not resolved within ${timeout}s`);
103
+ }
104
+ // ── Convenience Methods ───────────────────────────────────────
105
+ async solveCaptcha(imageUrl, options = {}) {
106
+ const { instructions = "Solve this CAPTCHA", wait = true, timeout = 300 } = options;
107
+ const task = await this.submitTask("captcha_solve", { image_url: imageUrl, instructions });
108
+ if (!wait) return task;
109
+ const result = await this.waitForResult(task.task_id, timeout);
110
+ return result.result?.solution || "";
111
+ }
112
+ async verifyIdentity(documentUrl, options = {}) {
113
+ const { selfieUrl, instructions = "Verify this identity document", wait = true, timeout = 600 } = options;
114
+ const payload = { document_url: documentUrl, instructions };
115
+ if (selfieUrl) payload.selfie_url = selfieUrl;
116
+ const task = await this.submitTask("identity_verify", payload);
117
+ if (!wait) return task;
118
+ return this.waitForResult(task.task_id, timeout);
119
+ }
120
+ async moderateContent(content, options = {}) {
121
+ const { contentType = "text", guidelines, wait = true, timeout = 300 } = options;
122
+ const payload = { content, content_type: contentType };
123
+ if (guidelines) payload.guidelines = guidelines;
124
+ const task = await this.submitTask("content_moderate", payload);
125
+ if (!wait) return task;
126
+ return this.waitForResult(task.task_id, timeout);
127
+ }
128
+ async customTask(instructions, options = {}) {
129
+ const { data, wait = true, timeout = 300 } = options;
130
+ const payload = { instructions };
131
+ if (data) Object.assign(payload, data);
132
+ const task = await this.submitTask("custom", payload);
133
+ if (!wait) return task;
134
+ return this.waitForResult(task.task_id, timeout);
135
+ }
136
+ // ── Human Operator Shortcuts ──────────────────────────────────
137
+ async requestOtp(serviceName, options = {}) {
138
+ const { instructions = "Retrieve the OTP/2FA code", wait = true, timeout = 300 } = options;
139
+ const task = await this.submitTask("otp", { service_name: serviceName, instructions });
140
+ if (!wait) return task;
141
+ const result = await this.waitForResult(task.task_id, timeout);
142
+ return result.result?.code || "";
143
+ }
144
+ async requestApproval(action, options = {}) {
145
+ const { context = "", wait = true, timeout = 600 } = options;
146
+ const task = await this.submitTask("approval", { action, context });
147
+ if (!wait) return task;
148
+ const result = await this.waitForResult(task.task_id, timeout);
149
+ return result.result?.approved || false;
150
+ }
151
+ async requestPhoneVerification(phoneNumber, options = {}) {
152
+ const { instructions = "Complete phone verification", wait = true, timeout = 600 } = options;
153
+ const task = await this.submitTask("phone_verification", { phone_number: phoneNumber, instructions });
154
+ if (!wait) return task;
155
+ return this.waitForResult(task.task_id, timeout);
156
+ }
157
+ // ── Quote-Based Services ─────────────────────────────────────
158
+ async requestQuote(service, description) {
159
+ return this.request("POST", "/agent/quote", { service, description });
160
+ }
161
+ async getQuote(quoteId) {
162
+ return this.request("GET", `/agent/quote/${quoteId}`);
163
+ }
164
+ async acceptQuote(quoteId) {
165
+ return this.request("POST", "/agent/quote/accept", { quote_id: quoteId });
166
+ }
167
+ async listQuotes() {
168
+ const res = await this.request("GET", "/agent/quotes");
169
+ return res.quotes || res;
170
+ }
171
+ // ── Account Methods ───────────────────────────────────────────
172
+ async getAccount() {
173
+ return this.request("GET", "/account");
174
+ }
175
+ async getBalance() {
176
+ const info = await this.request("GET", "/api/balance");
177
+ return info.balance_usd || 0;
178
+ }
179
+ async checkBalance() {
180
+ return this.request("GET", "/api/balance");
181
+ }
182
+ async topUpCrypto(txHash, chain, amountUsd) {
183
+ return this.request("POST", "/api/top-up/crypto", {
184
+ tx_hash: txHash,
185
+ chain,
186
+ amount_usd: amountUsd
187
+ });
188
+ }
189
+ // ── Static Methods ────────────────────────────────────────────
190
+ static async signupWithWallet(walletAddress, baseUrl) {
191
+ const url = (baseUrl || _SiliconBridge.BASE_URL).replace(/\/+$/, "");
192
+ const res = await fetch(`${url}/api/signup/wallet`, {
193
+ method: "POST",
194
+ headers: { "Content-Type": "application/json" },
195
+ body: JSON.stringify({ wallet_address: walletAddress })
196
+ });
197
+ if (res.status >= 400) {
198
+ const text = await res.text();
199
+ throw new SiliconBridgeError(`Signup failed: ${text}`, res.status);
200
+ }
201
+ return await res.json();
202
+ }
203
+ };
204
+ _SiliconBridge.BASE_URL = "https://siliconbridge.xyz";
205
+ var SiliconBridge = _SiliconBridge;
206
+ var index_default = SiliconBridge;
207
+ // Annotate the CommonJS export names for ESM import in node:
208
+ 0 && (module.exports = {
209
+ SiliconBridge,
210
+ SiliconBridgeError,
211
+ TaskTimeout
212
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,185 @@
1
+ // src/index.ts
2
+ var SiliconBridgeError = class extends Error {
3
+ constructor(message, statusCode, detail) {
4
+ super(message);
5
+ this.name = "SiliconBridgeError";
6
+ this.statusCode = statusCode;
7
+ this.detail = detail;
8
+ }
9
+ };
10
+ var TaskTimeout = class extends SiliconBridgeError {
11
+ constructor(message) {
12
+ super(message);
13
+ this.name = "TaskTimeout";
14
+ }
15
+ };
16
+ var _SiliconBridge = class _SiliconBridge {
17
+ constructor(apiKey, options = {}) {
18
+ this.apiKey = apiKey;
19
+ this.baseUrl = (options.baseUrl || _SiliconBridge.BASE_URL).replace(/\/+$/, "");
20
+ this.timeout = options.timeout || 3e4;
21
+ }
22
+ async request(method, path, body) {
23
+ const url = `${this.baseUrl}${path}`;
24
+ const headers = {
25
+ "X-API-Key": this.apiKey,
26
+ "Content-Type": "application/json"
27
+ };
28
+ const controller = new AbortController();
29
+ const timer = setTimeout(() => controller.abort(), this.timeout);
30
+ try {
31
+ const res = await fetch(url, {
32
+ method,
33
+ headers,
34
+ body: body ? JSON.stringify(body) : void 0,
35
+ signal: controller.signal
36
+ });
37
+ if (res.status >= 400) {
38
+ let detail;
39
+ try {
40
+ const json = await res.json();
41
+ detail = json.detail || json;
42
+ } catch {
43
+ detail = await res.text();
44
+ }
45
+ throw new SiliconBridgeError(
46
+ `API error ${res.status}: ${typeof detail === "string" ? detail : JSON.stringify(detail)}`,
47
+ res.status,
48
+ detail
49
+ );
50
+ }
51
+ return await res.json();
52
+ } finally {
53
+ clearTimeout(timer);
54
+ }
55
+ }
56
+ // ── Core Methods ──────────────────────────────────────────────
57
+ async submitTask(serviceType, payload, callbackUrl) {
58
+ const body = { service_type: serviceType, payload };
59
+ if (callbackUrl) body.callback_url = callbackUrl;
60
+ return this.request("POST", "/tasks/submit", body);
61
+ }
62
+ async getTask(taskId) {
63
+ return this.request("GET", `/tasks/${taskId}`);
64
+ }
65
+ async waitForResult(taskId, timeout = 300, pollInterval = 5) {
66
+ const deadline = Date.now() + timeout * 1e3;
67
+ while (Date.now() < deadline) {
68
+ const task = await this.getTask(taskId);
69
+ if (task.status === "completed") return task;
70
+ if (task.status === "failed") {
71
+ throw new SiliconBridgeError(`Task ${taskId} failed`, void 0, task.result);
72
+ }
73
+ await new Promise((r) => setTimeout(r, pollInterval * 1e3));
74
+ }
75
+ throw new TaskTimeout(`Task ${taskId} not resolved within ${timeout}s`);
76
+ }
77
+ // ── Convenience Methods ───────────────────────────────────────
78
+ async solveCaptcha(imageUrl, options = {}) {
79
+ const { instructions = "Solve this CAPTCHA", wait = true, timeout = 300 } = options;
80
+ const task = await this.submitTask("captcha_solve", { image_url: imageUrl, instructions });
81
+ if (!wait) return task;
82
+ const result = await this.waitForResult(task.task_id, timeout);
83
+ return result.result?.solution || "";
84
+ }
85
+ async verifyIdentity(documentUrl, options = {}) {
86
+ const { selfieUrl, instructions = "Verify this identity document", wait = true, timeout = 600 } = options;
87
+ const payload = { document_url: documentUrl, instructions };
88
+ if (selfieUrl) payload.selfie_url = selfieUrl;
89
+ const task = await this.submitTask("identity_verify", payload);
90
+ if (!wait) return task;
91
+ return this.waitForResult(task.task_id, timeout);
92
+ }
93
+ async moderateContent(content, options = {}) {
94
+ const { contentType = "text", guidelines, wait = true, timeout = 300 } = options;
95
+ const payload = { content, content_type: contentType };
96
+ if (guidelines) payload.guidelines = guidelines;
97
+ const task = await this.submitTask("content_moderate", payload);
98
+ if (!wait) return task;
99
+ return this.waitForResult(task.task_id, timeout);
100
+ }
101
+ async customTask(instructions, options = {}) {
102
+ const { data, wait = true, timeout = 300 } = options;
103
+ const payload = { instructions };
104
+ if (data) Object.assign(payload, data);
105
+ const task = await this.submitTask("custom", payload);
106
+ if (!wait) return task;
107
+ return this.waitForResult(task.task_id, timeout);
108
+ }
109
+ // ── Human Operator Shortcuts ──────────────────────────────────
110
+ async requestOtp(serviceName, options = {}) {
111
+ const { instructions = "Retrieve the OTP/2FA code", wait = true, timeout = 300 } = options;
112
+ const task = await this.submitTask("otp", { service_name: serviceName, instructions });
113
+ if (!wait) return task;
114
+ const result = await this.waitForResult(task.task_id, timeout);
115
+ return result.result?.code || "";
116
+ }
117
+ async requestApproval(action, options = {}) {
118
+ const { context = "", wait = true, timeout = 600 } = options;
119
+ const task = await this.submitTask("approval", { action, context });
120
+ if (!wait) return task;
121
+ const result = await this.waitForResult(task.task_id, timeout);
122
+ return result.result?.approved || false;
123
+ }
124
+ async requestPhoneVerification(phoneNumber, options = {}) {
125
+ const { instructions = "Complete phone verification", wait = true, timeout = 600 } = options;
126
+ const task = await this.submitTask("phone_verification", { phone_number: phoneNumber, instructions });
127
+ if (!wait) return task;
128
+ return this.waitForResult(task.task_id, timeout);
129
+ }
130
+ // ── Quote-Based Services ─────────────────────────────────────
131
+ async requestQuote(service, description) {
132
+ return this.request("POST", "/agent/quote", { service, description });
133
+ }
134
+ async getQuote(quoteId) {
135
+ return this.request("GET", `/agent/quote/${quoteId}`);
136
+ }
137
+ async acceptQuote(quoteId) {
138
+ return this.request("POST", "/agent/quote/accept", { quote_id: quoteId });
139
+ }
140
+ async listQuotes() {
141
+ const res = await this.request("GET", "/agent/quotes");
142
+ return res.quotes || res;
143
+ }
144
+ // ── Account Methods ───────────────────────────────────────────
145
+ async getAccount() {
146
+ return this.request("GET", "/account");
147
+ }
148
+ async getBalance() {
149
+ const info = await this.request("GET", "/api/balance");
150
+ return info.balance_usd || 0;
151
+ }
152
+ async checkBalance() {
153
+ return this.request("GET", "/api/balance");
154
+ }
155
+ async topUpCrypto(txHash, chain, amountUsd) {
156
+ return this.request("POST", "/api/top-up/crypto", {
157
+ tx_hash: txHash,
158
+ chain,
159
+ amount_usd: amountUsd
160
+ });
161
+ }
162
+ // ── Static Methods ────────────────────────────────────────────
163
+ static async signupWithWallet(walletAddress, baseUrl) {
164
+ const url = (baseUrl || _SiliconBridge.BASE_URL).replace(/\/+$/, "");
165
+ const res = await fetch(`${url}/api/signup/wallet`, {
166
+ method: "POST",
167
+ headers: { "Content-Type": "application/json" },
168
+ body: JSON.stringify({ wallet_address: walletAddress })
169
+ });
170
+ if (res.status >= 400) {
171
+ const text = await res.text();
172
+ throw new SiliconBridgeError(`Signup failed: ${text}`, res.status);
173
+ }
174
+ return await res.json();
175
+ }
176
+ };
177
+ _SiliconBridge.BASE_URL = "https://siliconbridge.xyz";
178
+ var SiliconBridge = _SiliconBridge;
179
+ var index_default = SiliconBridge;
180
+ export {
181
+ SiliconBridge,
182
+ SiliconBridgeError,
183
+ TaskTimeout,
184
+ index_default as default
185
+ };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "siliconbridge",
3
+ "version": "0.2.0",
4
+ "description": "SiliconBridge — Human-in-the-loop API for AI agents. Submit tasks to human operators via a simple API.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup src/index.ts --format cjs,esm --dts",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "ai",
24
+ "agents",
25
+ "human-in-the-loop",
26
+ "captcha",
27
+ "verification",
28
+ "mcp",
29
+ "autonomous",
30
+ "siliconbridge"
31
+ ],
32
+ "author": "SiliconBridge <xsiliconbridgex@gmail.com>",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/aataqi-boop/siliconbridge-js"
37
+ },
38
+ "homepage": "https://siliconbridge.xyz",
39
+ "devDependencies": {
40
+ "tsup": "^8.0.0",
41
+ "typescript": "^5.3.0"
42
+ }
43
+ }