@epochcore/qaas-sdk 1.0.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/LICENSE +81 -0
- package/README.md +440 -0
- package/dist/index.d.mts +220 -0
- package/dist/index.d.ts +220 -0
- package/dist/index.js +226 -0
- package/dist/index.mjs +198 -0
- package/package.json +59 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EpochCore QaaS SDK
|
|
3
|
+
* Official TypeScript/JavaScript SDK for Quantum as a Service API
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
interface QaaSConfig {
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
}
|
|
12
|
+
interface Algorithm {
|
|
13
|
+
id: number;
|
|
14
|
+
name: string;
|
|
15
|
+
category: string;
|
|
16
|
+
description: string;
|
|
17
|
+
}
|
|
18
|
+
interface AlgorithmsResponse {
|
|
19
|
+
tier: string;
|
|
20
|
+
total_available: number;
|
|
21
|
+
algorithms: Algorithm[];
|
|
22
|
+
categories: string[];
|
|
23
|
+
}
|
|
24
|
+
interface PricingTier {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
price: number;
|
|
28
|
+
runs_per_day: number;
|
|
29
|
+
runs_per_month: number;
|
|
30
|
+
algorithms: number;
|
|
31
|
+
backends: string[];
|
|
32
|
+
priority: string;
|
|
33
|
+
support: string;
|
|
34
|
+
payment_link: string;
|
|
35
|
+
}
|
|
36
|
+
interface PricingResponse {
|
|
37
|
+
tiers: PricingTier[];
|
|
38
|
+
currency: string;
|
|
39
|
+
billing: string;
|
|
40
|
+
}
|
|
41
|
+
interface RunRequest {
|
|
42
|
+
algorithm_id: string;
|
|
43
|
+
parameters: Record<string, unknown>;
|
|
44
|
+
backend?: 'simulator' | 'qiskit_aer' | 'cirq' | 'pennylane' | 'ibm_quantum';
|
|
45
|
+
shots?: number;
|
|
46
|
+
}
|
|
47
|
+
interface RunResponse {
|
|
48
|
+
job_id: string;
|
|
49
|
+
status: 'queued' | 'running' | 'completed' | 'failed';
|
|
50
|
+
algorithm: string;
|
|
51
|
+
result?: Record<string, unknown>;
|
|
52
|
+
execution_time_ms?: number;
|
|
53
|
+
backend_used: string;
|
|
54
|
+
shots_executed: number;
|
|
55
|
+
quantum_watermark: string;
|
|
56
|
+
}
|
|
57
|
+
interface UsageResponse {
|
|
58
|
+
tier: string;
|
|
59
|
+
period: string;
|
|
60
|
+
usage: {
|
|
61
|
+
runs_today: number;
|
|
62
|
+
runs_this_month: number;
|
|
63
|
+
remaining_today: number;
|
|
64
|
+
remaining_month: number;
|
|
65
|
+
};
|
|
66
|
+
limits: {
|
|
67
|
+
runs_per_day: number;
|
|
68
|
+
runs_per_month: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
interface HealthResponse {
|
|
72
|
+
status: string;
|
|
73
|
+
service: string;
|
|
74
|
+
version: string;
|
|
75
|
+
algorithms_available: number;
|
|
76
|
+
frameworks: string[];
|
|
77
|
+
timestamp: string;
|
|
78
|
+
}
|
|
79
|
+
type AlgorithmCategory = 'amplitude_estimation' | 'grover_search' | 'qaoa_optimization' | 'qubo' | 'bernstein_vazirani' | 'deutsch_jozsa' | 'simon' | 'phase_estimation' | 'variational' | 'qml_classification' | 'qml_regression' | 'qml_clustering' | 'qml_anomaly';
|
|
80
|
+
/**
|
|
81
|
+
* EpochCore QaaS Client
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { QaaSClient } from '@epochcore/qaas-sdk';
|
|
86
|
+
*
|
|
87
|
+
* const client = new QaaSClient({ apiKey: 'your-api-key' });
|
|
88
|
+
*
|
|
89
|
+
* // Get available algorithms
|
|
90
|
+
* const algorithms = await client.getAlgorithms();
|
|
91
|
+
*
|
|
92
|
+
* // Run a quantum algorithm
|
|
93
|
+
* const result = await client.runAlgorithm({
|
|
94
|
+
* algorithm_id: 'QAOA_PORT_001',
|
|
95
|
+
* parameters: {
|
|
96
|
+
* assets: ['AAPL', 'GOOGL', 'MSFT'],
|
|
97
|
+
* returns: [0.12, 0.15, 0.10],
|
|
98
|
+
* covariance: [[0.04, 0.01, 0.02], [0.01, 0.05, 0.01], [0.02, 0.01, 0.03]],
|
|
99
|
+
* risk_tolerance: 0.5
|
|
100
|
+
* },
|
|
101
|
+
* backend: 'qiskit_aer'
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare class QaaSClient {
|
|
106
|
+
private readonly baseUrl;
|
|
107
|
+
private readonly apiKey?;
|
|
108
|
+
private readonly timeout;
|
|
109
|
+
constructor(config?: QaaSConfig);
|
|
110
|
+
private request;
|
|
111
|
+
/**
|
|
112
|
+
* Check API health and status
|
|
113
|
+
*/
|
|
114
|
+
health(): Promise<HealthResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Get pricing information for all tiers
|
|
117
|
+
*/
|
|
118
|
+
getPricing(): Promise<PricingResponse>;
|
|
119
|
+
/**
|
|
120
|
+
* Get available algorithms for your tier
|
|
121
|
+
*/
|
|
122
|
+
getAlgorithms(): Promise<AlgorithmsResponse>;
|
|
123
|
+
/**
|
|
124
|
+
* Get algorithms filtered by category
|
|
125
|
+
*/
|
|
126
|
+
getAlgorithmsByCategory(category: AlgorithmCategory): Promise<Algorithm[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Run a quantum algorithm
|
|
129
|
+
*/
|
|
130
|
+
runAlgorithm(request: RunRequest): Promise<RunResponse>;
|
|
131
|
+
/**
|
|
132
|
+
* Get current usage statistics
|
|
133
|
+
*/
|
|
134
|
+
getUsage(): Promise<UsageResponse>;
|
|
135
|
+
/**
|
|
136
|
+
* Run Markowitz portfolio optimization (QAOA)
|
|
137
|
+
*/
|
|
138
|
+
optimizePortfolio(params: {
|
|
139
|
+
assets: string[];
|
|
140
|
+
returns: number[];
|
|
141
|
+
covariance: number[][];
|
|
142
|
+
risk_tolerance?: number;
|
|
143
|
+
backend?: RunRequest['backend'];
|
|
144
|
+
}): Promise<RunResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Run Value at Risk (VaR) estimation
|
|
147
|
+
*/
|
|
148
|
+
estimateVaR(params: {
|
|
149
|
+
portfolio_value: number;
|
|
150
|
+
returns_history: number[];
|
|
151
|
+
confidence_level?: number;
|
|
152
|
+
backend?: RunRequest['backend'];
|
|
153
|
+
}): Promise<RunResponse>;
|
|
154
|
+
/**
|
|
155
|
+
* Run Grover search for arbitrage opportunities
|
|
156
|
+
*/
|
|
157
|
+
findArbitrage(params: {
|
|
158
|
+
price_matrix: number[][];
|
|
159
|
+
threshold?: number;
|
|
160
|
+
backend?: RunRequest['backend'];
|
|
161
|
+
}): Promise<RunResponse>;
|
|
162
|
+
/**
|
|
163
|
+
* Solve a QUBO problem
|
|
164
|
+
*/
|
|
165
|
+
solveQUBO(params: {
|
|
166
|
+
Q_matrix: number[][];
|
|
167
|
+
num_reads?: number;
|
|
168
|
+
backend?: RunRequest['backend'];
|
|
169
|
+
}): Promise<RunResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Run Monte Carlo amplitude estimation
|
|
172
|
+
*/
|
|
173
|
+
monteCarloEstimate(params: {
|
|
174
|
+
target_function: string;
|
|
175
|
+
num_samples?: number;
|
|
176
|
+
epsilon?: number;
|
|
177
|
+
backend?: RunRequest['backend'];
|
|
178
|
+
}): Promise<RunResponse>;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* QaaS API Error
|
|
182
|
+
*/
|
|
183
|
+
declare class QaaSError extends Error {
|
|
184
|
+
readonly statusCode: number;
|
|
185
|
+
readonly response?: unknown | undefined;
|
|
186
|
+
constructor(message: string, statusCode: number, response?: unknown | undefined);
|
|
187
|
+
}
|
|
188
|
+
declare const qaas: QaaSClient;
|
|
189
|
+
declare const ALGORITHMS: {
|
|
190
|
+
readonly AMPLITUDE_ESTIMATION: {
|
|
191
|
+
readonly PROB_001: "AE_PROB_001";
|
|
192
|
+
readonly PROB_002: "AE_PROB_002";
|
|
193
|
+
readonly PROB_003: "AE_PROB_003";
|
|
194
|
+
readonly VAR: "AE_PROB_004";
|
|
195
|
+
readonly CVAR: "AE_PROB_005";
|
|
196
|
+
};
|
|
197
|
+
readonly GROVER: {
|
|
198
|
+
readonly BOOLEAN_SAT: "GROVER_BOOL_001";
|
|
199
|
+
readonly PORTFOLIO_CONSTRAINT: "GROVER_BOOL_002";
|
|
200
|
+
readonly ARBITRAGE: "GROVER_BOOL_003";
|
|
201
|
+
readonly COMPLIANCE: "GROVER_BOOL_004";
|
|
202
|
+
readonly PATTERN: "GROVER_BOOL_005";
|
|
203
|
+
};
|
|
204
|
+
readonly QAOA_PORTFOLIO: {
|
|
205
|
+
readonly MARKOWITZ: "QAOA_PORT_001";
|
|
206
|
+
readonly RISK_PARITY: "QAOA_PORT_002";
|
|
207
|
+
readonly MAX_SHARPE: "QAOA_PORT_003";
|
|
208
|
+
readonly MIN_VARIANCE: "QAOA_PORT_004";
|
|
209
|
+
readonly BLACK_LITTERMAN: "QAOA_PORT_005";
|
|
210
|
+
};
|
|
211
|
+
readonly QUBO: {
|
|
212
|
+
readonly GENERAL: "QAOA_QUBO_001";
|
|
213
|
+
readonly MAX_CUT: "QAOA_QUBO_002";
|
|
214
|
+
readonly GRAPH_COLORING: "QAOA_QUBO_003";
|
|
215
|
+
readonly TSP: "QAOA_QUBO_004";
|
|
216
|
+
readonly KNAPSACK: "QAOA_QUBO_005";
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export { ALGORITHMS, type Algorithm, type AlgorithmCategory, type AlgorithmsResponse, type HealthResponse, type PricingResponse, type PricingTier, QaaSClient, type QaaSConfig, QaaSError, type RunRequest, type RunResponse, type UsageResponse, qaas };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EpochCore QaaS SDK
|
|
3
|
+
* Official TypeScript/JavaScript SDK for Quantum as a Service API
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
interface QaaSConfig {
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
}
|
|
12
|
+
interface Algorithm {
|
|
13
|
+
id: number;
|
|
14
|
+
name: string;
|
|
15
|
+
category: string;
|
|
16
|
+
description: string;
|
|
17
|
+
}
|
|
18
|
+
interface AlgorithmsResponse {
|
|
19
|
+
tier: string;
|
|
20
|
+
total_available: number;
|
|
21
|
+
algorithms: Algorithm[];
|
|
22
|
+
categories: string[];
|
|
23
|
+
}
|
|
24
|
+
interface PricingTier {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
price: number;
|
|
28
|
+
runs_per_day: number;
|
|
29
|
+
runs_per_month: number;
|
|
30
|
+
algorithms: number;
|
|
31
|
+
backends: string[];
|
|
32
|
+
priority: string;
|
|
33
|
+
support: string;
|
|
34
|
+
payment_link: string;
|
|
35
|
+
}
|
|
36
|
+
interface PricingResponse {
|
|
37
|
+
tiers: PricingTier[];
|
|
38
|
+
currency: string;
|
|
39
|
+
billing: string;
|
|
40
|
+
}
|
|
41
|
+
interface RunRequest {
|
|
42
|
+
algorithm_id: string;
|
|
43
|
+
parameters: Record<string, unknown>;
|
|
44
|
+
backend?: 'simulator' | 'qiskit_aer' | 'cirq' | 'pennylane' | 'ibm_quantum';
|
|
45
|
+
shots?: number;
|
|
46
|
+
}
|
|
47
|
+
interface RunResponse {
|
|
48
|
+
job_id: string;
|
|
49
|
+
status: 'queued' | 'running' | 'completed' | 'failed';
|
|
50
|
+
algorithm: string;
|
|
51
|
+
result?: Record<string, unknown>;
|
|
52
|
+
execution_time_ms?: number;
|
|
53
|
+
backend_used: string;
|
|
54
|
+
shots_executed: number;
|
|
55
|
+
quantum_watermark: string;
|
|
56
|
+
}
|
|
57
|
+
interface UsageResponse {
|
|
58
|
+
tier: string;
|
|
59
|
+
period: string;
|
|
60
|
+
usage: {
|
|
61
|
+
runs_today: number;
|
|
62
|
+
runs_this_month: number;
|
|
63
|
+
remaining_today: number;
|
|
64
|
+
remaining_month: number;
|
|
65
|
+
};
|
|
66
|
+
limits: {
|
|
67
|
+
runs_per_day: number;
|
|
68
|
+
runs_per_month: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
interface HealthResponse {
|
|
72
|
+
status: string;
|
|
73
|
+
service: string;
|
|
74
|
+
version: string;
|
|
75
|
+
algorithms_available: number;
|
|
76
|
+
frameworks: string[];
|
|
77
|
+
timestamp: string;
|
|
78
|
+
}
|
|
79
|
+
type AlgorithmCategory = 'amplitude_estimation' | 'grover_search' | 'qaoa_optimization' | 'qubo' | 'bernstein_vazirani' | 'deutsch_jozsa' | 'simon' | 'phase_estimation' | 'variational' | 'qml_classification' | 'qml_regression' | 'qml_clustering' | 'qml_anomaly';
|
|
80
|
+
/**
|
|
81
|
+
* EpochCore QaaS Client
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { QaaSClient } from '@epochcore/qaas-sdk';
|
|
86
|
+
*
|
|
87
|
+
* const client = new QaaSClient({ apiKey: 'your-api-key' });
|
|
88
|
+
*
|
|
89
|
+
* // Get available algorithms
|
|
90
|
+
* const algorithms = await client.getAlgorithms();
|
|
91
|
+
*
|
|
92
|
+
* // Run a quantum algorithm
|
|
93
|
+
* const result = await client.runAlgorithm({
|
|
94
|
+
* algorithm_id: 'QAOA_PORT_001',
|
|
95
|
+
* parameters: {
|
|
96
|
+
* assets: ['AAPL', 'GOOGL', 'MSFT'],
|
|
97
|
+
* returns: [0.12, 0.15, 0.10],
|
|
98
|
+
* covariance: [[0.04, 0.01, 0.02], [0.01, 0.05, 0.01], [0.02, 0.01, 0.03]],
|
|
99
|
+
* risk_tolerance: 0.5
|
|
100
|
+
* },
|
|
101
|
+
* backend: 'qiskit_aer'
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare class QaaSClient {
|
|
106
|
+
private readonly baseUrl;
|
|
107
|
+
private readonly apiKey?;
|
|
108
|
+
private readonly timeout;
|
|
109
|
+
constructor(config?: QaaSConfig);
|
|
110
|
+
private request;
|
|
111
|
+
/**
|
|
112
|
+
* Check API health and status
|
|
113
|
+
*/
|
|
114
|
+
health(): Promise<HealthResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Get pricing information for all tiers
|
|
117
|
+
*/
|
|
118
|
+
getPricing(): Promise<PricingResponse>;
|
|
119
|
+
/**
|
|
120
|
+
* Get available algorithms for your tier
|
|
121
|
+
*/
|
|
122
|
+
getAlgorithms(): Promise<AlgorithmsResponse>;
|
|
123
|
+
/**
|
|
124
|
+
* Get algorithms filtered by category
|
|
125
|
+
*/
|
|
126
|
+
getAlgorithmsByCategory(category: AlgorithmCategory): Promise<Algorithm[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Run a quantum algorithm
|
|
129
|
+
*/
|
|
130
|
+
runAlgorithm(request: RunRequest): Promise<RunResponse>;
|
|
131
|
+
/**
|
|
132
|
+
* Get current usage statistics
|
|
133
|
+
*/
|
|
134
|
+
getUsage(): Promise<UsageResponse>;
|
|
135
|
+
/**
|
|
136
|
+
* Run Markowitz portfolio optimization (QAOA)
|
|
137
|
+
*/
|
|
138
|
+
optimizePortfolio(params: {
|
|
139
|
+
assets: string[];
|
|
140
|
+
returns: number[];
|
|
141
|
+
covariance: number[][];
|
|
142
|
+
risk_tolerance?: number;
|
|
143
|
+
backend?: RunRequest['backend'];
|
|
144
|
+
}): Promise<RunResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Run Value at Risk (VaR) estimation
|
|
147
|
+
*/
|
|
148
|
+
estimateVaR(params: {
|
|
149
|
+
portfolio_value: number;
|
|
150
|
+
returns_history: number[];
|
|
151
|
+
confidence_level?: number;
|
|
152
|
+
backend?: RunRequest['backend'];
|
|
153
|
+
}): Promise<RunResponse>;
|
|
154
|
+
/**
|
|
155
|
+
* Run Grover search for arbitrage opportunities
|
|
156
|
+
*/
|
|
157
|
+
findArbitrage(params: {
|
|
158
|
+
price_matrix: number[][];
|
|
159
|
+
threshold?: number;
|
|
160
|
+
backend?: RunRequest['backend'];
|
|
161
|
+
}): Promise<RunResponse>;
|
|
162
|
+
/**
|
|
163
|
+
* Solve a QUBO problem
|
|
164
|
+
*/
|
|
165
|
+
solveQUBO(params: {
|
|
166
|
+
Q_matrix: number[][];
|
|
167
|
+
num_reads?: number;
|
|
168
|
+
backend?: RunRequest['backend'];
|
|
169
|
+
}): Promise<RunResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Run Monte Carlo amplitude estimation
|
|
172
|
+
*/
|
|
173
|
+
monteCarloEstimate(params: {
|
|
174
|
+
target_function: string;
|
|
175
|
+
num_samples?: number;
|
|
176
|
+
epsilon?: number;
|
|
177
|
+
backend?: RunRequest['backend'];
|
|
178
|
+
}): Promise<RunResponse>;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* QaaS API Error
|
|
182
|
+
*/
|
|
183
|
+
declare class QaaSError extends Error {
|
|
184
|
+
readonly statusCode: number;
|
|
185
|
+
readonly response?: unknown | undefined;
|
|
186
|
+
constructor(message: string, statusCode: number, response?: unknown | undefined);
|
|
187
|
+
}
|
|
188
|
+
declare const qaas: QaaSClient;
|
|
189
|
+
declare const ALGORITHMS: {
|
|
190
|
+
readonly AMPLITUDE_ESTIMATION: {
|
|
191
|
+
readonly PROB_001: "AE_PROB_001";
|
|
192
|
+
readonly PROB_002: "AE_PROB_002";
|
|
193
|
+
readonly PROB_003: "AE_PROB_003";
|
|
194
|
+
readonly VAR: "AE_PROB_004";
|
|
195
|
+
readonly CVAR: "AE_PROB_005";
|
|
196
|
+
};
|
|
197
|
+
readonly GROVER: {
|
|
198
|
+
readonly BOOLEAN_SAT: "GROVER_BOOL_001";
|
|
199
|
+
readonly PORTFOLIO_CONSTRAINT: "GROVER_BOOL_002";
|
|
200
|
+
readonly ARBITRAGE: "GROVER_BOOL_003";
|
|
201
|
+
readonly COMPLIANCE: "GROVER_BOOL_004";
|
|
202
|
+
readonly PATTERN: "GROVER_BOOL_005";
|
|
203
|
+
};
|
|
204
|
+
readonly QAOA_PORTFOLIO: {
|
|
205
|
+
readonly MARKOWITZ: "QAOA_PORT_001";
|
|
206
|
+
readonly RISK_PARITY: "QAOA_PORT_002";
|
|
207
|
+
readonly MAX_SHARPE: "QAOA_PORT_003";
|
|
208
|
+
readonly MIN_VARIANCE: "QAOA_PORT_004";
|
|
209
|
+
readonly BLACK_LITTERMAN: "QAOA_PORT_005";
|
|
210
|
+
};
|
|
211
|
+
readonly QUBO: {
|
|
212
|
+
readonly GENERAL: "QAOA_QUBO_001";
|
|
213
|
+
readonly MAX_CUT: "QAOA_QUBO_002";
|
|
214
|
+
readonly GRAPH_COLORING: "QAOA_QUBO_003";
|
|
215
|
+
readonly TSP: "QAOA_QUBO_004";
|
|
216
|
+
readonly KNAPSACK: "QAOA_QUBO_005";
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export { ALGORITHMS, type Algorithm, type AlgorithmCategory, type AlgorithmsResponse, type HealthResponse, type PricingResponse, type PricingTier, QaaSClient, type QaaSConfig, QaaSError, type RunRequest, type RunResponse, type UsageResponse, qaas };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
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
|
+
ALGORITHMS: () => ALGORITHMS,
|
|
24
|
+
QaaSClient: () => QaaSClient,
|
|
25
|
+
QaaSError: () => QaaSError,
|
|
26
|
+
qaas: () => qaas
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
var QaaSClient = class {
|
|
30
|
+
constructor(config = {}) {
|
|
31
|
+
this.baseUrl = config.baseUrl || "https://api.qaas.epochcoreqcs.com";
|
|
32
|
+
this.apiKey = config.apiKey;
|
|
33
|
+
this.timeout = config.timeout || 3e4;
|
|
34
|
+
}
|
|
35
|
+
async request(path, options = {}) {
|
|
36
|
+
const headers = {
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
...options.headers || {}
|
|
39
|
+
};
|
|
40
|
+
if (this.apiKey) {
|
|
41
|
+
headers["X-API-Key"] = this.apiKey;
|
|
42
|
+
}
|
|
43
|
+
const controller = new AbortController();
|
|
44
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
45
|
+
try {
|
|
46
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
47
|
+
...options,
|
|
48
|
+
headers,
|
|
49
|
+
signal: controller.signal
|
|
50
|
+
});
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
53
|
+
throw new QaaSError(
|
|
54
|
+
error.error || `Request failed with status ${response.status}`,
|
|
55
|
+
response.status,
|
|
56
|
+
error
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return await response.json();
|
|
60
|
+
} finally {
|
|
61
|
+
clearTimeout(timeoutId);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check API health and status
|
|
66
|
+
*/
|
|
67
|
+
async health() {
|
|
68
|
+
return this.request("/health");
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get pricing information for all tiers
|
|
72
|
+
*/
|
|
73
|
+
async getPricing() {
|
|
74
|
+
return this.request("/api/pricing");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get available algorithms for your tier
|
|
78
|
+
*/
|
|
79
|
+
async getAlgorithms() {
|
|
80
|
+
return this.request("/api/quantum/algorithms");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get algorithms filtered by category
|
|
84
|
+
*/
|
|
85
|
+
async getAlgorithmsByCategory(category) {
|
|
86
|
+
const response = await this.getAlgorithms();
|
|
87
|
+
return response.algorithms.filter((algo) => algo.category === category);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Run a quantum algorithm
|
|
91
|
+
*/
|
|
92
|
+
async runAlgorithm(request) {
|
|
93
|
+
return this.request("/api/quantum/run", {
|
|
94
|
+
method: "POST",
|
|
95
|
+
body: JSON.stringify(request)
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get current usage statistics
|
|
100
|
+
*/
|
|
101
|
+
async getUsage() {
|
|
102
|
+
return this.request("/api/quantum/usage");
|
|
103
|
+
}
|
|
104
|
+
// ==========================================
|
|
105
|
+
// Convenience methods for common algorithms
|
|
106
|
+
// ==========================================
|
|
107
|
+
/**
|
|
108
|
+
* Run Markowitz portfolio optimization (QAOA)
|
|
109
|
+
*/
|
|
110
|
+
async optimizePortfolio(params) {
|
|
111
|
+
return this.runAlgorithm({
|
|
112
|
+
algorithm_id: "QAOA_PORT_001",
|
|
113
|
+
parameters: {
|
|
114
|
+
assets: params.assets,
|
|
115
|
+
returns: params.returns,
|
|
116
|
+
covariance: params.covariance,
|
|
117
|
+
risk_tolerance: params.risk_tolerance ?? 0.5
|
|
118
|
+
},
|
|
119
|
+
backend: params.backend || "simulator"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Run Value at Risk (VaR) estimation
|
|
124
|
+
*/
|
|
125
|
+
async estimateVaR(params) {
|
|
126
|
+
return this.runAlgorithm({
|
|
127
|
+
algorithm_id: "AE_PROB_004",
|
|
128
|
+
parameters: {
|
|
129
|
+
portfolio_value: params.portfolio_value,
|
|
130
|
+
returns_history: params.returns_history,
|
|
131
|
+
confidence_level: params.confidence_level ?? 0.95
|
|
132
|
+
},
|
|
133
|
+
backend: params.backend || "simulator"
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Run Grover search for arbitrage opportunities
|
|
138
|
+
*/
|
|
139
|
+
async findArbitrage(params) {
|
|
140
|
+
return this.runAlgorithm({
|
|
141
|
+
algorithm_id: "GROVER_BOOL_003",
|
|
142
|
+
parameters: {
|
|
143
|
+
price_matrix: params.price_matrix,
|
|
144
|
+
threshold: params.threshold ?? 1e-3
|
|
145
|
+
},
|
|
146
|
+
backend: params.backend || "simulator"
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Solve a QUBO problem
|
|
151
|
+
*/
|
|
152
|
+
async solveQUBO(params) {
|
|
153
|
+
return this.runAlgorithm({
|
|
154
|
+
algorithm_id: "QAOA_QUBO_001",
|
|
155
|
+
parameters: {
|
|
156
|
+
Q: params.Q_matrix,
|
|
157
|
+
num_reads: params.num_reads ?? 1e3
|
|
158
|
+
},
|
|
159
|
+
backend: params.backend || "simulator"
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Run Monte Carlo amplitude estimation
|
|
164
|
+
*/
|
|
165
|
+
async monteCarloEstimate(params) {
|
|
166
|
+
return this.runAlgorithm({
|
|
167
|
+
algorithm_id: "AE_PROB_002",
|
|
168
|
+
parameters: {
|
|
169
|
+
target_function: params.target_function,
|
|
170
|
+
num_samples: params.num_samples ?? 1e4,
|
|
171
|
+
epsilon: params.epsilon ?? 0.01
|
|
172
|
+
},
|
|
173
|
+
backend: params.backend || "simulator"
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
var QaaSError = class extends Error {
|
|
178
|
+
constructor(message, statusCode, response) {
|
|
179
|
+
super(message);
|
|
180
|
+
this.statusCode = statusCode;
|
|
181
|
+
this.response = response;
|
|
182
|
+
this.name = "QaaSError";
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
var qaas = new QaaSClient();
|
|
186
|
+
var ALGORITHMS = {
|
|
187
|
+
// Amplitude Estimation
|
|
188
|
+
AMPLITUDE_ESTIMATION: {
|
|
189
|
+
PROB_001: "AE_PROB_001",
|
|
190
|
+
PROB_002: "AE_PROB_002",
|
|
191
|
+
PROB_003: "AE_PROB_003",
|
|
192
|
+
VAR: "AE_PROB_004",
|
|
193
|
+
CVAR: "AE_PROB_005"
|
|
194
|
+
},
|
|
195
|
+
// Grover Search
|
|
196
|
+
GROVER: {
|
|
197
|
+
BOOLEAN_SAT: "GROVER_BOOL_001",
|
|
198
|
+
PORTFOLIO_CONSTRAINT: "GROVER_BOOL_002",
|
|
199
|
+
ARBITRAGE: "GROVER_BOOL_003",
|
|
200
|
+
COMPLIANCE: "GROVER_BOOL_004",
|
|
201
|
+
PATTERN: "GROVER_BOOL_005"
|
|
202
|
+
},
|
|
203
|
+
// QAOA Portfolio
|
|
204
|
+
QAOA_PORTFOLIO: {
|
|
205
|
+
MARKOWITZ: "QAOA_PORT_001",
|
|
206
|
+
RISK_PARITY: "QAOA_PORT_002",
|
|
207
|
+
MAX_SHARPE: "QAOA_PORT_003",
|
|
208
|
+
MIN_VARIANCE: "QAOA_PORT_004",
|
|
209
|
+
BLACK_LITTERMAN: "QAOA_PORT_005"
|
|
210
|
+
},
|
|
211
|
+
// QUBO
|
|
212
|
+
QUBO: {
|
|
213
|
+
GENERAL: "QAOA_QUBO_001",
|
|
214
|
+
MAX_CUT: "QAOA_QUBO_002",
|
|
215
|
+
GRAPH_COLORING: "QAOA_QUBO_003",
|
|
216
|
+
TSP: "QAOA_QUBO_004",
|
|
217
|
+
KNAPSACK: "QAOA_QUBO_005"
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
221
|
+
0 && (module.exports = {
|
|
222
|
+
ALGORITHMS,
|
|
223
|
+
QaaSClient,
|
|
224
|
+
QaaSError,
|
|
225
|
+
qaas
|
|
226
|
+
});
|