arga-sdk 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.
@@ -0,0 +1,259 @@
1
+ interface HttpClientOptions {
2
+ baseUrl: string;
3
+ apiKey: string;
4
+ fetch: typeof globalThis.fetch;
5
+ }
6
+ declare class HttpClient {
7
+ private readonly baseUrl;
8
+ private readonly apiKey;
9
+ private readonly _fetch;
10
+ constructor(opts: HttpClientOptions);
11
+ get<T>(path: string, query?: Record<string, string>): Promise<T>;
12
+ post<T>(path: string, body?: unknown): Promise<T>;
13
+ /**
14
+ * Perform a GET request and return the raw Response, for SSE streaming.
15
+ */
16
+ getRaw(path: string): Promise<Response>;
17
+ private buildUrl;
18
+ private headers;
19
+ private handleResponse;
20
+ private throwApiError;
21
+ }
22
+
23
+ interface ArgaClientOptions {
24
+ /** Arga API key (starts with `arga_`). */
25
+ apiKey: string;
26
+ /** Base URL for the Arga API. Default: `https://app.argalabs.com` */
27
+ baseUrl?: string;
28
+ /** Custom fetch implementation. Default: global `fetch`. */
29
+ fetch?: typeof globalThis.fetch;
30
+ }
31
+ interface CreateUrlRunParams {
32
+ url: string;
33
+ prompt?: string;
34
+ twins?: string[];
35
+ credentials?: {
36
+ email?: string;
37
+ password?: string;
38
+ };
39
+ runnerMode?: string;
40
+ sessionId?: string;
41
+ }
42
+ interface CreatePrRunParams {
43
+ repo: string;
44
+ branch?: string;
45
+ prUrl?: string;
46
+ contextNotes?: string;
47
+ scenarioPrompt?: string;
48
+ twins?: string[];
49
+ frontendUrl?: string;
50
+ sessionId?: string;
51
+ }
52
+ interface CreateAgentRunParams {
53
+ url?: string;
54
+ repo?: string;
55
+ branch?: string;
56
+ credentials?: Record<string, unknown>[];
57
+ focus?: string;
58
+ actionBudget?: number;
59
+ runnerMode?: string;
60
+ }
61
+ interface Run {
62
+ runId: string;
63
+ status: string;
64
+ sessionId?: string;
65
+ }
66
+ interface StepSummary {
67
+ step: string;
68
+ status: string;
69
+ detail?: string;
70
+ }
71
+ interface RunDetail {
72
+ id: string;
73
+ status: string;
74
+ runType?: string;
75
+ mode?: string;
76
+ environmentUrl?: string;
77
+ surfaceUrls?: string[];
78
+ twins?: string[];
79
+ resultsJson?: unknown;
80
+ eventLogJson?: unknown;
81
+ storyJson?: unknown;
82
+ attackPlanJson?: unknown;
83
+ redteamReportJson?: unknown;
84
+ stepSummaries?: StepSummary[];
85
+ failureCategory?: string;
86
+ failureDetail?: string;
87
+ createdAt?: string;
88
+ [key: string]: unknown;
89
+ }
90
+ interface RunEvent {
91
+ event?: string;
92
+ data: unknown;
93
+ }
94
+ interface CancelRunResponse {
95
+ status: string;
96
+ }
97
+ interface WaitOptions {
98
+ /** Polling interval in milliseconds. Default: 2500. */
99
+ pollInterval?: number;
100
+ /** Maximum wait time in milliseconds. Default: 600000 (10 min). */
101
+ timeout?: number;
102
+ }
103
+ interface Twin {
104
+ name: string;
105
+ label: string;
106
+ kind: string;
107
+ showInUi: boolean;
108
+ }
109
+ interface ProvisionTwinsParams {
110
+ twins: string[];
111
+ ttlMinutes?: number;
112
+ scenarioId?: string;
113
+ }
114
+ interface ProvisionTwinsResponse {
115
+ runId: string;
116
+ }
117
+ interface TwinInstance {
118
+ name: string;
119
+ label: string;
120
+ baseUrl: string;
121
+ adminUrl: string;
122
+ envVars: Record<string, string>;
123
+ showInUi: boolean;
124
+ }
125
+ interface TwinProvisionStatus {
126
+ runId: string;
127
+ status: string;
128
+ twins: Record<string, TwinInstance>;
129
+ dashboardUrl?: string;
130
+ expiresAt?: string;
131
+ proxyToken?: string;
132
+ error?: string;
133
+ }
134
+ interface ExtendTwinsParams {
135
+ ttlMinutes?: number;
136
+ }
137
+ interface ExtendTwinsResponse {
138
+ status: string;
139
+ ttlMinutes: number;
140
+ }
141
+ interface CreateScenarioParams {
142
+ name: string;
143
+ prompt?: string;
144
+ seedConfig?: Record<string, unknown>;
145
+ twins?: string[];
146
+ description?: string;
147
+ tags?: string[];
148
+ }
149
+ interface ListScenariosParams {
150
+ twin?: string;
151
+ tag?: string;
152
+ }
153
+ interface Scenario {
154
+ id: string;
155
+ name: string;
156
+ description?: string;
157
+ prompt?: string;
158
+ twins?: string[];
159
+ seedConfig?: Record<string, unknown>;
160
+ tags?: string[];
161
+ createdAt?: string;
162
+ updatedAt?: string;
163
+ }
164
+
165
+ declare class RunsResource {
166
+ private readonly http;
167
+ constructor(http: HttpClient);
168
+ /** Create a URL run. */
169
+ createUrlRun(params: CreateUrlRunParams): Promise<Run>;
170
+ /** Create a PR run. */
171
+ createPrRun(params: CreatePrRunParams): Promise<Run>;
172
+ /** Create an agent (sandbox) run. */
173
+ createAgentRun(params: CreateAgentRunParams): Promise<Run>;
174
+ /** Get full details of a run by ID. */
175
+ get(runId: string): Promise<RunDetail>;
176
+ /**
177
+ * Stream run results as Server-Sent Events.
178
+ *
179
+ * Returns an `AsyncIterable<RunEvent>`. Each yielded event contains an
180
+ * optional `event` field and a parsed `data` payload.
181
+ */
182
+ streamResults(runId: string): AsyncIterable<RunEvent>;
183
+ /** Cancel a run. */
184
+ cancel(runId: string): Promise<CancelRunResponse>;
185
+ /**
186
+ * Poll a run until it reaches a terminal status.
187
+ *
188
+ * @param runId - The run ID to poll.
189
+ * @param opts - Optional polling configuration.
190
+ * @returns The final `RunDetail` once the run has completed (or failed/cancelled).
191
+ * @throws ArgaError if the timeout is exceeded.
192
+ */
193
+ wait(runId: string, opts?: WaitOptions): Promise<RunDetail>;
194
+ }
195
+
196
+ declare class TwinsResource {
197
+ private readonly http;
198
+ constructor(http: HttpClient);
199
+ /** List all available twins. */
200
+ list(): Promise<Twin[]>;
201
+ /** Provision a set of twins. */
202
+ provision(params: ProvisionTwinsParams): Promise<ProvisionTwinsResponse>;
203
+ /** Get the provisioning status of twins for a given run. */
204
+ getStatus(runId: string): Promise<TwinProvisionStatus>;
205
+ /** Extend the TTL of provisioned twins. */
206
+ extend(runId: string, params?: ExtendTwinsParams): Promise<ExtendTwinsResponse>;
207
+ }
208
+
209
+ declare class ScenariosResource {
210
+ private readonly http;
211
+ constructor(http: HttpClient);
212
+ /** Create a new scenario. */
213
+ create(params: CreateScenarioParams): Promise<Scenario>;
214
+ /** List scenarios, optionally filtered by twin or tag. */
215
+ list(params?: ListScenariosParams): Promise<Scenario[]>;
216
+ /** Get a scenario by ID. */
217
+ get(scenarioId: string): Promise<Scenario>;
218
+ }
219
+
220
+ /**
221
+ * Main client for the Arga API.
222
+ *
223
+ * ```ts
224
+ * import { Arga } from 'arga-sdk';
225
+ *
226
+ * const client = new Arga({ apiKey: 'arga_...' });
227
+ * const run = await client.runs.createUrlRun({ url: 'https://staging.myapp.com' });
228
+ * ```
229
+ */
230
+ declare class Arga {
231
+ /** Run management: create, get, stream, cancel, and wait for runs. */
232
+ readonly runs: RunsResource;
233
+ /** Twin management: list, provision, check status, and extend twins. */
234
+ readonly twins: TwinsResource;
235
+ /** Scenario management: create, list, and get scenarios. */
236
+ readonly scenarios: ScenariosResource;
237
+ constructor(options: ArgaClientOptions);
238
+ }
239
+
240
+ /**
241
+ * Base error class for all Arga SDK errors.
242
+ */
243
+ declare class ArgaError extends Error {
244
+ constructor(message: string);
245
+ }
246
+ /**
247
+ * Thrown when the Arga API returns a non-2xx response.
248
+ */
249
+ declare class ArgaAPIError extends ArgaError {
250
+ /** HTTP status code returned by the API. */
251
+ readonly statusCode: number;
252
+ /** Raw Response object from fetch. */
253
+ readonly response: Response;
254
+ /** Parsed response body, if available. */
255
+ readonly body: unknown;
256
+ constructor(message: string, statusCode: number, response: Response, body?: unknown);
257
+ }
258
+
259
+ export { Arga, ArgaAPIError, type ArgaClientOptions, ArgaError, type CancelRunResponse, type CreateAgentRunParams, type CreatePrRunParams, type CreateScenarioParams, type CreateUrlRunParams, type ExtendTwinsParams, type ExtendTwinsResponse, type ListScenariosParams, type ProvisionTwinsParams, type ProvisionTwinsResponse, type Run, type RunDetail, type RunEvent, type Scenario, type StepSummary, type Twin, type TwinInstance, type TwinProvisionStatus, type WaitOptions };
@@ -0,0 +1,259 @@
1
+ interface HttpClientOptions {
2
+ baseUrl: string;
3
+ apiKey: string;
4
+ fetch: typeof globalThis.fetch;
5
+ }
6
+ declare class HttpClient {
7
+ private readonly baseUrl;
8
+ private readonly apiKey;
9
+ private readonly _fetch;
10
+ constructor(opts: HttpClientOptions);
11
+ get<T>(path: string, query?: Record<string, string>): Promise<T>;
12
+ post<T>(path: string, body?: unknown): Promise<T>;
13
+ /**
14
+ * Perform a GET request and return the raw Response, for SSE streaming.
15
+ */
16
+ getRaw(path: string): Promise<Response>;
17
+ private buildUrl;
18
+ private headers;
19
+ private handleResponse;
20
+ private throwApiError;
21
+ }
22
+
23
+ interface ArgaClientOptions {
24
+ /** Arga API key (starts with `arga_`). */
25
+ apiKey: string;
26
+ /** Base URL for the Arga API. Default: `https://app.argalabs.com` */
27
+ baseUrl?: string;
28
+ /** Custom fetch implementation. Default: global `fetch`. */
29
+ fetch?: typeof globalThis.fetch;
30
+ }
31
+ interface CreateUrlRunParams {
32
+ url: string;
33
+ prompt?: string;
34
+ twins?: string[];
35
+ credentials?: {
36
+ email?: string;
37
+ password?: string;
38
+ };
39
+ runnerMode?: string;
40
+ sessionId?: string;
41
+ }
42
+ interface CreatePrRunParams {
43
+ repo: string;
44
+ branch?: string;
45
+ prUrl?: string;
46
+ contextNotes?: string;
47
+ scenarioPrompt?: string;
48
+ twins?: string[];
49
+ frontendUrl?: string;
50
+ sessionId?: string;
51
+ }
52
+ interface CreateAgentRunParams {
53
+ url?: string;
54
+ repo?: string;
55
+ branch?: string;
56
+ credentials?: Record<string, unknown>[];
57
+ focus?: string;
58
+ actionBudget?: number;
59
+ runnerMode?: string;
60
+ }
61
+ interface Run {
62
+ runId: string;
63
+ status: string;
64
+ sessionId?: string;
65
+ }
66
+ interface StepSummary {
67
+ step: string;
68
+ status: string;
69
+ detail?: string;
70
+ }
71
+ interface RunDetail {
72
+ id: string;
73
+ status: string;
74
+ runType?: string;
75
+ mode?: string;
76
+ environmentUrl?: string;
77
+ surfaceUrls?: string[];
78
+ twins?: string[];
79
+ resultsJson?: unknown;
80
+ eventLogJson?: unknown;
81
+ storyJson?: unknown;
82
+ attackPlanJson?: unknown;
83
+ redteamReportJson?: unknown;
84
+ stepSummaries?: StepSummary[];
85
+ failureCategory?: string;
86
+ failureDetail?: string;
87
+ createdAt?: string;
88
+ [key: string]: unknown;
89
+ }
90
+ interface RunEvent {
91
+ event?: string;
92
+ data: unknown;
93
+ }
94
+ interface CancelRunResponse {
95
+ status: string;
96
+ }
97
+ interface WaitOptions {
98
+ /** Polling interval in milliseconds. Default: 2500. */
99
+ pollInterval?: number;
100
+ /** Maximum wait time in milliseconds. Default: 600000 (10 min). */
101
+ timeout?: number;
102
+ }
103
+ interface Twin {
104
+ name: string;
105
+ label: string;
106
+ kind: string;
107
+ showInUi: boolean;
108
+ }
109
+ interface ProvisionTwinsParams {
110
+ twins: string[];
111
+ ttlMinutes?: number;
112
+ scenarioId?: string;
113
+ }
114
+ interface ProvisionTwinsResponse {
115
+ runId: string;
116
+ }
117
+ interface TwinInstance {
118
+ name: string;
119
+ label: string;
120
+ baseUrl: string;
121
+ adminUrl: string;
122
+ envVars: Record<string, string>;
123
+ showInUi: boolean;
124
+ }
125
+ interface TwinProvisionStatus {
126
+ runId: string;
127
+ status: string;
128
+ twins: Record<string, TwinInstance>;
129
+ dashboardUrl?: string;
130
+ expiresAt?: string;
131
+ proxyToken?: string;
132
+ error?: string;
133
+ }
134
+ interface ExtendTwinsParams {
135
+ ttlMinutes?: number;
136
+ }
137
+ interface ExtendTwinsResponse {
138
+ status: string;
139
+ ttlMinutes: number;
140
+ }
141
+ interface CreateScenarioParams {
142
+ name: string;
143
+ prompt?: string;
144
+ seedConfig?: Record<string, unknown>;
145
+ twins?: string[];
146
+ description?: string;
147
+ tags?: string[];
148
+ }
149
+ interface ListScenariosParams {
150
+ twin?: string;
151
+ tag?: string;
152
+ }
153
+ interface Scenario {
154
+ id: string;
155
+ name: string;
156
+ description?: string;
157
+ prompt?: string;
158
+ twins?: string[];
159
+ seedConfig?: Record<string, unknown>;
160
+ tags?: string[];
161
+ createdAt?: string;
162
+ updatedAt?: string;
163
+ }
164
+
165
+ declare class RunsResource {
166
+ private readonly http;
167
+ constructor(http: HttpClient);
168
+ /** Create a URL run. */
169
+ createUrlRun(params: CreateUrlRunParams): Promise<Run>;
170
+ /** Create a PR run. */
171
+ createPrRun(params: CreatePrRunParams): Promise<Run>;
172
+ /** Create an agent (sandbox) run. */
173
+ createAgentRun(params: CreateAgentRunParams): Promise<Run>;
174
+ /** Get full details of a run by ID. */
175
+ get(runId: string): Promise<RunDetail>;
176
+ /**
177
+ * Stream run results as Server-Sent Events.
178
+ *
179
+ * Returns an `AsyncIterable<RunEvent>`. Each yielded event contains an
180
+ * optional `event` field and a parsed `data` payload.
181
+ */
182
+ streamResults(runId: string): AsyncIterable<RunEvent>;
183
+ /** Cancel a run. */
184
+ cancel(runId: string): Promise<CancelRunResponse>;
185
+ /**
186
+ * Poll a run until it reaches a terminal status.
187
+ *
188
+ * @param runId - The run ID to poll.
189
+ * @param opts - Optional polling configuration.
190
+ * @returns The final `RunDetail` once the run has completed (or failed/cancelled).
191
+ * @throws ArgaError if the timeout is exceeded.
192
+ */
193
+ wait(runId: string, opts?: WaitOptions): Promise<RunDetail>;
194
+ }
195
+
196
+ declare class TwinsResource {
197
+ private readonly http;
198
+ constructor(http: HttpClient);
199
+ /** List all available twins. */
200
+ list(): Promise<Twin[]>;
201
+ /** Provision a set of twins. */
202
+ provision(params: ProvisionTwinsParams): Promise<ProvisionTwinsResponse>;
203
+ /** Get the provisioning status of twins for a given run. */
204
+ getStatus(runId: string): Promise<TwinProvisionStatus>;
205
+ /** Extend the TTL of provisioned twins. */
206
+ extend(runId: string, params?: ExtendTwinsParams): Promise<ExtendTwinsResponse>;
207
+ }
208
+
209
+ declare class ScenariosResource {
210
+ private readonly http;
211
+ constructor(http: HttpClient);
212
+ /** Create a new scenario. */
213
+ create(params: CreateScenarioParams): Promise<Scenario>;
214
+ /** List scenarios, optionally filtered by twin or tag. */
215
+ list(params?: ListScenariosParams): Promise<Scenario[]>;
216
+ /** Get a scenario by ID. */
217
+ get(scenarioId: string): Promise<Scenario>;
218
+ }
219
+
220
+ /**
221
+ * Main client for the Arga API.
222
+ *
223
+ * ```ts
224
+ * import { Arga } from 'arga-sdk';
225
+ *
226
+ * const client = new Arga({ apiKey: 'arga_...' });
227
+ * const run = await client.runs.createUrlRun({ url: 'https://staging.myapp.com' });
228
+ * ```
229
+ */
230
+ declare class Arga {
231
+ /** Run management: create, get, stream, cancel, and wait for runs. */
232
+ readonly runs: RunsResource;
233
+ /** Twin management: list, provision, check status, and extend twins. */
234
+ readonly twins: TwinsResource;
235
+ /** Scenario management: create, list, and get scenarios. */
236
+ readonly scenarios: ScenariosResource;
237
+ constructor(options: ArgaClientOptions);
238
+ }
239
+
240
+ /**
241
+ * Base error class for all Arga SDK errors.
242
+ */
243
+ declare class ArgaError extends Error {
244
+ constructor(message: string);
245
+ }
246
+ /**
247
+ * Thrown when the Arga API returns a non-2xx response.
248
+ */
249
+ declare class ArgaAPIError extends ArgaError {
250
+ /** HTTP status code returned by the API. */
251
+ readonly statusCode: number;
252
+ /** Raw Response object from fetch. */
253
+ readonly response: Response;
254
+ /** Parsed response body, if available. */
255
+ readonly body: unknown;
256
+ constructor(message: string, statusCode: number, response: Response, body?: unknown);
257
+ }
258
+
259
+ export { Arga, ArgaAPIError, type ArgaClientOptions, ArgaError, type CancelRunResponse, type CreateAgentRunParams, type CreatePrRunParams, type CreateScenarioParams, type CreateUrlRunParams, type ExtendTwinsParams, type ExtendTwinsResponse, type ListScenariosParams, type ProvisionTwinsParams, type ProvisionTwinsResponse, type Run, type RunDetail, type RunEvent, type Scenario, type StepSummary, type Twin, type TwinInstance, type TwinProvisionStatus, type WaitOptions };