@quietrobot/sandboxes 0.2.3 → 0.3.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 +169 -2
- package/dist/index.d.ts +1138 -5
- package/dist/index.js +301 -4
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -85,9 +85,13 @@ export interface SandboxInfo {
|
|
|
85
85
|
};
|
|
86
86
|
/** Names of the secrets this sandbox may use through the gateway. */
|
|
87
87
|
secrets: string[];
|
|
88
|
+
/** Per-run limits this sandbox adds to its secrets' own budgets, if any. */
|
|
89
|
+
secretBudgets?: Record<string, KeyLimit> | null;
|
|
88
90
|
identity: {
|
|
89
91
|
hosts: string[];
|
|
90
92
|
};
|
|
93
|
+
/** Channels it may use from inside, or ["*"] for all. */
|
|
94
|
+
channels?: string[];
|
|
91
95
|
autoPauseSec: number | null;
|
|
92
96
|
lastActiveAt: string | null;
|
|
93
97
|
/**
|
|
@@ -156,6 +160,38 @@ export interface OutputChunk {
|
|
|
156
160
|
exitCode: number | null;
|
|
157
161
|
timedOut: boolean;
|
|
158
162
|
}
|
|
163
|
+
/** Calls made with your own AI key and their likely cost. usd is estimated at list price; your provider's bill is the record. */
|
|
164
|
+
export type AiUse = {
|
|
165
|
+
requests: number;
|
|
166
|
+
failed: number;
|
|
167
|
+
tokensIn: number;
|
|
168
|
+
tokensOut: number;
|
|
169
|
+
cacheRead: number;
|
|
170
|
+
cacheWrite: number;
|
|
171
|
+
usd: number;
|
|
172
|
+
};
|
|
173
|
+
/** GET /usage/ai-keys. source: playground, flow_draft, sandbox or kip. */
|
|
174
|
+
export type AiKeyUsage = {
|
|
175
|
+
from: string;
|
|
176
|
+
to: string;
|
|
177
|
+
total: AiUse;
|
|
178
|
+
keys: {
|
|
179
|
+
key: string;
|
|
180
|
+
keyRef: string;
|
|
181
|
+
provider: string;
|
|
182
|
+
total: AiUse;
|
|
183
|
+
bySource: (AiUse & {
|
|
184
|
+
source: string;
|
|
185
|
+
label: string;
|
|
186
|
+
})[];
|
|
187
|
+
byModel: (AiUse & {
|
|
188
|
+
model: string;
|
|
189
|
+
})[];
|
|
190
|
+
}[];
|
|
191
|
+
days: (AiUse & {
|
|
192
|
+
day: string;
|
|
193
|
+
})[];
|
|
194
|
+
};
|
|
159
195
|
export interface AuditEvent {
|
|
160
196
|
seq: number;
|
|
161
197
|
sandboxId: string | null;
|
|
@@ -188,6 +224,93 @@ export interface SnapshotInfo {
|
|
|
188
224
|
sourceSandboxId: string | null;
|
|
189
225
|
createdAt: string;
|
|
190
226
|
}
|
|
227
|
+
/** A message in a channel. */
|
|
228
|
+
export interface ChannelMessage {
|
|
229
|
+
channel: string;
|
|
230
|
+
/** Its number in the channel, from 1, in the order messages were sent. */
|
|
231
|
+
seq: number;
|
|
232
|
+
/** Any JSON value, as sent. */
|
|
233
|
+
body: unknown;
|
|
234
|
+
from: {
|
|
235
|
+
kind: "sandbox" | "api_key" | "user" | "system";
|
|
236
|
+
id: string | null;
|
|
237
|
+
label: string | null;
|
|
238
|
+
};
|
|
239
|
+
createdAt: string;
|
|
240
|
+
/** Set once it was taken (take()): who took it, and when a lease runs out. */
|
|
241
|
+
takenBy?: string;
|
|
242
|
+
takenAt?: string;
|
|
243
|
+
leaseUntil?: string | null;
|
|
244
|
+
doneAt?: string | null;
|
|
245
|
+
}
|
|
246
|
+
export interface ChannelInfo {
|
|
247
|
+
name: string;
|
|
248
|
+
/** The last message number handed out. */
|
|
249
|
+
lastSeq: number;
|
|
250
|
+
/** Messages kept (7 days, at most 10,000). */
|
|
251
|
+
messages: number;
|
|
252
|
+
/** Messages nobody has taken yet. */
|
|
253
|
+
waiting: number;
|
|
254
|
+
createdAt: string;
|
|
255
|
+
lastMessageAt: string | null;
|
|
256
|
+
}
|
|
257
|
+
type ChannelRequest = <T>(method: string, path: string, body?: unknown) => Promise<T>;
|
|
258
|
+
/**
|
|
259
|
+
* Channels: messages between your sandboxes, and between them and your own
|
|
260
|
+
* code. Sending to a new name makes a channel. Every reader sees every
|
|
261
|
+
* message (read); take() hands each message to one caller only, for work
|
|
262
|
+
* queues. Outside a sandbox use `new Sandboxes().channels`; inside a sandbox
|
|
263
|
+
* started with { channels: [...] } use `Channels.inSandbox()`, which needs no
|
|
264
|
+
* key.
|
|
265
|
+
*/
|
|
266
|
+
export declare class Channels {
|
|
267
|
+
private req;
|
|
268
|
+
/** @internal */
|
|
269
|
+
constructor(req: ChannelRequest);
|
|
270
|
+
/**
|
|
271
|
+
* Channels from inside a sandbox started with `channels`, through
|
|
272
|
+
* $QR_CHANNELS_URL: no API key, and only this sandbox can use it.
|
|
273
|
+
*/
|
|
274
|
+
static inSandbox(opts?: {
|
|
275
|
+
url?: string;
|
|
276
|
+
fetch?: typeof fetch;
|
|
277
|
+
}): Channels;
|
|
278
|
+
/** The channels you can use (inside a sandbox: the ones it was started with). */
|
|
279
|
+
list(): Promise<ChannelInfo[]>;
|
|
280
|
+
get(name: string): Promise<ChannelInfo>;
|
|
281
|
+
/** Sends any JSON value (64 KB at most). Readers waiting on the channel get it at once. */
|
|
282
|
+
send(name: string, body: unknown): Promise<ChannelMessage>;
|
|
283
|
+
/**
|
|
284
|
+
* Messages after `after` (0 = the oldest kept, "latest" = only new ones),
|
|
285
|
+
* oldest first. `wait` (seconds, up to 25) waits for one when there are none
|
|
286
|
+
* yet. Pass `next` back as `after` to carry on.
|
|
287
|
+
*/
|
|
288
|
+
read(name: string, opts?: {
|
|
289
|
+
after?: number | "latest";
|
|
290
|
+
limit?: number;
|
|
291
|
+
wait?: number;
|
|
292
|
+
}): Promise<{
|
|
293
|
+
channel: string;
|
|
294
|
+
messages: ChannelMessage[];
|
|
295
|
+
next: number;
|
|
296
|
+
}>;
|
|
297
|
+
/** Waits for and yields every new message, in order, until `signal` aborts. */
|
|
298
|
+
listen(name: string, opts?: {
|
|
299
|
+
after?: number | "latest";
|
|
300
|
+
signal?: AbortSignal;
|
|
301
|
+
}): AsyncGenerator<ChannelMessage>;
|
|
302
|
+
/**
|
|
303
|
+
* Takes the oldest message nobody has (a work queue: one taker per
|
|
304
|
+
* message), or null when none came within `wait` seconds. With leaseSec it
|
|
305
|
+
* is offered again unless you ack() it in time.
|
|
306
|
+
*/
|
|
307
|
+
take(name: string, opts?: {
|
|
308
|
+
leaseSec?: number;
|
|
309
|
+
wait?: number;
|
|
310
|
+
}): Promise<ChannelMessage | null>;
|
|
311
|
+
/** Marks a message you took with a lease as done. */
|
|
312
|
+
ack(name: string, seq: number): Promise<ChannelMessage>;
|
|
313
|
+
}
|
|
191
314
|
export interface VolumeInfo {
|
|
192
315
|
id: string;
|
|
193
316
|
name: string;
|
|
@@ -300,7 +423,9 @@ export interface CreateOptions {
|
|
|
300
423
|
template?: OfficialTemplate | (string & {});
|
|
301
424
|
/** standard = shared CPU (cheaper), performance = dedicated CPU (Pay as you go with a card). */
|
|
302
425
|
cpuClass?: "standard" | "performance";
|
|
426
|
+
/** Defaults to 1 (Performance: 2). */
|
|
303
427
|
cpus?: 1 | 2 | 4 | 8 | 16;
|
|
428
|
+
/** Memory in MB, a multiple of 256. Defaults to 2048 (Performance: 4096 for 2 vCPU). */
|
|
304
429
|
memoryMb?: number;
|
|
305
430
|
timeoutSec?: number;
|
|
306
431
|
/** Region code, e.g. "us-virginia" or "eu-frankfurt". Performance CPUs run in US and European regions only. */
|
|
@@ -326,8 +451,9 @@ export interface CreateOptions {
|
|
|
326
451
|
/**
|
|
327
452
|
* Network rules. allow and deny take domains (pypi.org, *.github.com), IP
|
|
328
453
|
* addresses and CIDR ranges, with an optional port (db.example.com:5432).
|
|
329
|
-
*
|
|
330
|
-
*
|
|
454
|
+
* Anything left out (mode, allow, deny, lock) comes from your organization's
|
|
455
|
+
* default network, set on the dashboard's Policies page (open internet for new
|
|
456
|
+
* organizations). By default the rules can later be widened with
|
|
331
457
|
* setEgress to anything your plan allows; lock: true fixes them to what
|
|
332
458
|
* these rules need so they never can be (copies keep the lock). maxMode
|
|
333
459
|
* sets a narrower ceiling instead. Send lock or maxMode, not both.
|
|
@@ -347,10 +473,18 @@ export interface CreateOptions {
|
|
|
347
473
|
* Needs egress mode allowlist or open.
|
|
348
474
|
*/
|
|
349
475
|
secrets?: string[];
|
|
476
|
+
/**
|
|
477
|
+
* Tighter per-run limits for this sandbox's secrets, by name, e.g.
|
|
478
|
+
* { OPENAI_KEY: { requests: 200, usd: 2 } }. They can only lower a key's own
|
|
479
|
+
* budget, never raise it.
|
|
480
|
+
*/
|
|
481
|
+
secretBudgets?: Record<string, KeyLimit>;
|
|
350
482
|
/** Hosts this sandbox may prove itself to with QR_IDENTITY_TOKEN (checked against /api/v1/identity/jwks.json). */
|
|
351
483
|
identity?: {
|
|
352
484
|
hosts: string[];
|
|
353
485
|
};
|
|
486
|
+
/** Channels this sandbox may send to and read from with Channels.inSandbox() (or $QR_CHANNELS_URL), or ["*"] for all. */
|
|
487
|
+
channels?: string[];
|
|
354
488
|
/** Pause after this many seconds (60 to 86400) with no calls. Any command or file call wakes it again. */
|
|
355
489
|
autoPauseSec?: number;
|
|
356
490
|
metadata?: Record<string, string>;
|
|
@@ -369,13 +503,67 @@ export interface CreateOptions {
|
|
|
369
503
|
background?: boolean;
|
|
370
504
|
};
|
|
371
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* A call a key may make. methods: GET, HEAD, POST, PUT, PATCH, DELETE or "*".
|
|
508
|
+
* paths: `*` matches one path part, `**` any number, e.g. "/v1/models/*" or "/v1/**".
|
|
509
|
+
*/
|
|
510
|
+
export interface KeyRule {
|
|
511
|
+
methods: string[];
|
|
512
|
+
paths: string[];
|
|
513
|
+
}
|
|
514
|
+
/** A request count, a dollar amount, or both. */
|
|
515
|
+
export interface KeyLimit {
|
|
516
|
+
requests?: number;
|
|
517
|
+
usd?: number;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* How much a key may be used. perRun covers one sandbox, or one whole
|
|
521
|
+
* Playground run; perMonth covers a calendar month (UTC). Owners and admins
|
|
522
|
+
* are told at 80%; at 100% the key's calls are refused. Claude and OpenAI
|
|
523
|
+
* calls are priced from the tokens they use; for other services set
|
|
524
|
+
* usdPerRequest, or use a request budget.
|
|
525
|
+
*/
|
|
526
|
+
export interface KeyBudget {
|
|
527
|
+
perRun?: KeyLimit;
|
|
528
|
+
perMonth?: KeyLimit;
|
|
529
|
+
usdPerRequest?: number;
|
|
530
|
+
}
|
|
372
531
|
export interface SecretInfo {
|
|
373
532
|
name: string;
|
|
374
533
|
/** The only hosts the value may be sent to. */
|
|
375
534
|
hosts: string[];
|
|
535
|
+
/** The only calls the key may make; null means any call to its hosts. */
|
|
536
|
+
rules: KeyRule[] | null;
|
|
537
|
+
budget: KeyBudget | null;
|
|
538
|
+
/** This month's use, when the key has a monthly budget. */
|
|
539
|
+
usedThisMonth?: {
|
|
540
|
+
requests: number;
|
|
541
|
+
usd: number;
|
|
542
|
+
};
|
|
376
543
|
createdAt: string;
|
|
377
544
|
updatedAt: string;
|
|
378
545
|
lastUsedAt: string | null;
|
|
546
|
+
/** When the value was last replaced (rolled), or null. */
|
|
547
|
+
rolledAt?: string | null;
|
|
548
|
+
/** Set when the key's service refused it (for example a 401), until a test or roll passes. */
|
|
549
|
+
failing?: {
|
|
550
|
+
since: string;
|
|
551
|
+
status: number | null;
|
|
552
|
+
} | null;
|
|
553
|
+
}
|
|
554
|
+
/** What a key's service said when it was tested. tested is false for services that can't be checked automatically. */
|
|
555
|
+
export interface SecretTest {
|
|
556
|
+
tested: boolean;
|
|
557
|
+
ok?: boolean;
|
|
558
|
+
status?: number | null;
|
|
559
|
+
service?: string;
|
|
560
|
+
message?: string;
|
|
561
|
+
}
|
|
562
|
+
export interface SecretOptions {
|
|
563
|
+
/** The only calls the key may make. Once set, any other call is refused. null clears them. */
|
|
564
|
+
rules?: KeyRule[] | null;
|
|
565
|
+
/** Request and dollar limits for each run and each month. null clears it. */
|
|
566
|
+
budget?: KeyBudget | null;
|
|
379
567
|
}
|
|
380
568
|
export interface ApprovalOptions {
|
|
381
569
|
/** Wait for a person when a policy rule holds the command. Default true. */
|
|
@@ -413,6 +601,691 @@ export interface TerminalOptions extends ApprovalOptions {
|
|
|
413
601
|
cwd?: string;
|
|
414
602
|
env?: Record<string, string>;
|
|
415
603
|
}
|
|
604
|
+
/**
|
|
605
|
+
* What a step does. run: a shell command. code: a script. model: asks a model
|
|
606
|
+
* with your own key. agent: Claude works toward a goal with tools in the
|
|
607
|
+
* sandbox. branch: a yes or no check that picks the pass or fail edge.
|
|
608
|
+
* approval: waits for a person. wait: pauses. team: steps working side by side
|
|
609
|
+
* in one sandbox. fork: copies the sandbox into lanes. judge: keeps the best
|
|
610
|
+
* lane. end: a place for edges to finish.
|
|
611
|
+
*/
|
|
612
|
+
export type GraphNodeKind = "run" | "code" | "model" | "agent" | "branch" | "approval" | "wait" | "team" | "fork" | "judge" | "end";
|
|
613
|
+
/** A step of a graph. */
|
|
614
|
+
export interface GraphNode {
|
|
615
|
+
id: string;
|
|
616
|
+
/** "run" when left out. */
|
|
617
|
+
kind?: GraphNodeKind;
|
|
618
|
+
label?: string;
|
|
619
|
+
/** run: the command (exit 0 passes). branch: the check as a command, like "test -s findings.txt" (or use question). Not needed in an external run. */
|
|
620
|
+
cmd?: string;
|
|
621
|
+
/**
|
|
622
|
+
* branch: the condition in plain words, like "the tests passed" or "the
|
|
623
|
+
* summary mentions pricing", up to 500 characters. With from, it is answered
|
|
624
|
+
* by that earlier step's result (no AI, free); otherwise Claude answers Yes
|
|
625
|
+
* or No with key, from what the earlier steps did. Yes follows pass.
|
|
626
|
+
*/
|
|
627
|
+
question?: string;
|
|
628
|
+
/** branch with question: the earlier step whose result answers it. */
|
|
629
|
+
from?: string;
|
|
630
|
+
/** branch with from: "pass" (the default) when Yes means that step passed, "fail" when it means it failed. */
|
|
631
|
+
want?: "pass" | "fail";
|
|
632
|
+
cwd?: string;
|
|
633
|
+
/** run: files written before the command, path to text. */
|
|
634
|
+
files?: Record<string, string>;
|
|
635
|
+
timeoutMs?: number;
|
|
636
|
+
/** The lane it runs in ("A", "B", ...) after a fork; the main sandbox otherwise. */
|
|
637
|
+
sandbox?: string;
|
|
638
|
+
/** false skips the checkpoint saved after it passes (branch, approval and wait save none by default). */
|
|
639
|
+
checkpoint?: boolean;
|
|
640
|
+
/** code: the script, and what runs it ("python" when left out). Exit 0 passes. */
|
|
641
|
+
code?: string;
|
|
642
|
+
lang?: "python" | "node" | "bash";
|
|
643
|
+
/** approval: what the person is asked, up to 300 characters. Approve follows pass, Deny follows fail. */
|
|
644
|
+
ask?: string;
|
|
645
|
+
/** wait: how long to pause, 1 to 600 seconds. */
|
|
646
|
+
seconds?: number;
|
|
647
|
+
/**
|
|
648
|
+
* model: what to ask. {{steps.<id>.output}}, {{steps.<id>.status}},
|
|
649
|
+
* {{steps.<id>.choice}}, {{file:path}} and {{run.loop}} are
|
|
650
|
+
* filled in when the step runs.
|
|
651
|
+
*/
|
|
652
|
+
prompt?: string;
|
|
653
|
+
/** model: who answers: "anthropic" (the default). */
|
|
654
|
+
provider?: "anthropic";
|
|
655
|
+
/** model: the model id, and the saved secret that holds its key. List the secret in the graph's secrets. */
|
|
656
|
+
model?: string;
|
|
657
|
+
key?: string;
|
|
658
|
+
/** model: where the reply is written in the sandbox. */
|
|
659
|
+
out?: string;
|
|
660
|
+
/** model, output "text": a regular expression the reply must match to pass. */
|
|
661
|
+
expect?: string;
|
|
662
|
+
maxTokens?: number;
|
|
663
|
+
/** model: "text" (the default), "json" (must parse and hold schema's keys) or "decision" (picks one of choices). */
|
|
664
|
+
output?: "text" | "json" | "decision";
|
|
665
|
+
schema?: string[];
|
|
666
|
+
/** model, output "decision": 2 to 6 labels. The run follows the edge whose when is "choice:<label>". */
|
|
667
|
+
choices?: string[];
|
|
668
|
+
/** Hint for the simulator: how often each choice is picked, in the order of choices. */
|
|
669
|
+
choiceOdds?: number[];
|
|
670
|
+
/** agent: what it should get done. Takes the same {{references}} as a prompt. */
|
|
671
|
+
goal?: string;
|
|
672
|
+
/**
|
|
673
|
+
* agent: the tools it may use, by Claude Code's names (all six by default). Read, Grep and Glob only read.
|
|
674
|
+
* The old names "shell" (Bash) and "files" (the other five) are still taken. Every command goes through your Policies.
|
|
675
|
+
*/
|
|
676
|
+
tools?: ("Bash" | "Read" | "Write" | "Edit" | "Grep" | "Glob" | "shell" | "files")[];
|
|
677
|
+
/**
|
|
678
|
+
* agent: what waits for a person, as in Claude Code. "ask": every Bash command, Write and Edit.
|
|
679
|
+
* "acceptEdits": only Bash commands. "auto" (the default): nothing beyond your Policies and the flow's.
|
|
680
|
+
*/
|
|
681
|
+
permissionMode?: "ask" | "acceptEdits" | "auto";
|
|
682
|
+
/** agent: the most model calls (12 by default, at most 40) and the most model spend in dollars (0.50 by default) before it fails. */
|
|
683
|
+
maxTurns?: number;
|
|
684
|
+
maxUsd?: number;
|
|
685
|
+
/** agent: a shell check that must exit 0 for the step to pass, like "pytest -q". */
|
|
686
|
+
done?: string;
|
|
687
|
+
/** agent: the check in plain words instead of done, like "the README explains how to install it". Claude answers it from the agent's report; a No goes back to the agent. */
|
|
688
|
+
doneIf?: string;
|
|
689
|
+
/** Hint for the simulator: about how many turns the agent takes (6 by default). */
|
|
690
|
+
estTurns?: number;
|
|
691
|
+
/** team: 2 to 6 agent, run or code steps working at once in the team's sandbox; all must pass, or any one. */
|
|
692
|
+
members?: string[];
|
|
693
|
+
need?: "all" | "any";
|
|
694
|
+
/** "none" cuts the sandbox's network while this step runs and puts it back after. */
|
|
695
|
+
network?: "none" | "inherit";
|
|
696
|
+
/** With network "none": also stop every program already running in the sandbox when the network goes off. */
|
|
697
|
+
strict?: boolean;
|
|
698
|
+
/** true: a person approves this step before it runs. On an agent this is permissionMode "ask". */
|
|
699
|
+
approve?: boolean;
|
|
700
|
+
/** run, code, model and agent: when the step fails, try it again up to this many times (1 to 5) before following its fail edge. A refused command is never retried. */
|
|
701
|
+
retries?: number;
|
|
702
|
+
/** With retries: seconds before trying again (10 by default), doubling each time, at most 600. */
|
|
703
|
+
retryDelaySec?: number;
|
|
704
|
+
/** fork: the lanes to make, 2 to 10 names like ["A", "B", "C"], one copy of the sandbox each. */
|
|
705
|
+
lanes?: string[];
|
|
706
|
+
/** judge: the key read from each lane's last JSON line, and which value wins. */
|
|
707
|
+
metric?: string;
|
|
708
|
+
best?: "min" | "max";
|
|
709
|
+
/** Hints for the simulator only. */
|
|
710
|
+
estSec?: number;
|
|
711
|
+
passRate?: number;
|
|
712
|
+
[k: string]: unknown;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* An edge, taken when the step passes ("pass", the default), fails ("fail"),
|
|
716
|
+
* either way ("always"), or when a decision picked a label ("choice:<label>").
|
|
717
|
+
*/
|
|
718
|
+
export interface GraphEdge {
|
|
719
|
+
from: string;
|
|
720
|
+
to: string;
|
|
721
|
+
when?: "pass" | "fail" | "always" | `choice:${string}`;
|
|
722
|
+
}
|
|
723
|
+
/** A flow's own rules, on top of the organization's, which always apply. */
|
|
724
|
+
export interface FlowPolicy {
|
|
725
|
+
/** The network for every sandbox in the run. lock keeps anything in the run from widening it. */
|
|
726
|
+
network?: {
|
|
727
|
+
mode: "deny" | "allowlist" | "open";
|
|
728
|
+
allow?: string[];
|
|
729
|
+
lock?: boolean;
|
|
730
|
+
};
|
|
731
|
+
/** Commands held for a person: up to 20 regular expressions (case-insensitive), each with why. */
|
|
732
|
+
hold?: {
|
|
733
|
+
pattern: string;
|
|
734
|
+
description?: string;
|
|
735
|
+
}[];
|
|
736
|
+
}
|
|
737
|
+
export interface Graph {
|
|
738
|
+
name?: string;
|
|
739
|
+
/** The sandbox template the run starts from ("base" by default). */
|
|
740
|
+
template?: string;
|
|
741
|
+
start: string;
|
|
742
|
+
nodes: GraphNode[];
|
|
743
|
+
edges: GraphEdge[];
|
|
744
|
+
/** The step whose checkpoint the main sandbox is rewound to when a guard stops the run. */
|
|
745
|
+
rewindTo?: string;
|
|
746
|
+
/** Saved secrets the run's sandboxes may use (a model step's key goes here). */
|
|
747
|
+
secrets?: string[];
|
|
748
|
+
policy?: FlowPolicy;
|
|
749
|
+
/** Instructions for every agent and model step in the flow, like a CLAUDE.md (up to 10,000 characters). */
|
|
750
|
+
instructions?: string;
|
|
751
|
+
/** false: agents don't read CLAUDE.md, .claude/CLAUDE.md and AGENTS.md from the sandbox (they do by default). */
|
|
752
|
+
projectInstructions?: boolean;
|
|
753
|
+
/** The flow's input files, path (relative to the home folder) to text: written into the run's sandbox before the first step. At most 20 files and 256 KB in all. */
|
|
754
|
+
files?: Record<string, string>;
|
|
755
|
+
[k: string]: unknown;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* The flow JSON: the same document the playground's JSON editor shows,
|
|
759
|
+
* flows.export() returns and flows.create() takes. "$schema" points editors at
|
|
760
|
+
* the schema (flows.schema()); the API ignores it.
|
|
761
|
+
*/
|
|
762
|
+
export interface FlowDocument {
|
|
763
|
+
$schema?: string;
|
|
764
|
+
name?: string;
|
|
765
|
+
graph: Graph;
|
|
766
|
+
guards?: Partial<Guards>;
|
|
767
|
+
/** Where the canvas draws each step, step id to {x, y}. Laid out when left out. */
|
|
768
|
+
layout?: Record<string, {
|
|
769
|
+
x: number;
|
|
770
|
+
y: number;
|
|
771
|
+
}>;
|
|
772
|
+
}
|
|
773
|
+
/** One reason a flow wouldn't run. path is a JSON pointer into the flow JSON, like "/graph/nodes/2/cmd". */
|
|
774
|
+
export interface FlowProblem {
|
|
775
|
+
message: string;
|
|
776
|
+
/** invalid_flow, plan_limit, missing_secret, secret_host, model_steps_off or agent_steps_off. */
|
|
777
|
+
code: string;
|
|
778
|
+
step?: string;
|
|
779
|
+
path?: string;
|
|
780
|
+
}
|
|
781
|
+
/** A flow drafted from plain words (flows.draft). */
|
|
782
|
+
export interface DraftedFlow {
|
|
783
|
+
name: string;
|
|
784
|
+
/** One plain sentence per step, in order. */
|
|
785
|
+
summary: string[];
|
|
786
|
+
graph: Graph;
|
|
787
|
+
guards: Guards;
|
|
788
|
+
/** The saved key it drafted with, and that its AI steps use. */
|
|
789
|
+
key: string;
|
|
790
|
+
/** About what the draft cost on your key, at list prices. */
|
|
791
|
+
costUsd: number;
|
|
792
|
+
/** With save: true, the new flow's id. */
|
|
793
|
+
flowId?: string;
|
|
794
|
+
}
|
|
795
|
+
/** The answer to flows.validate: whether the flow would run, and why not. */
|
|
796
|
+
export interface FlowValidation {
|
|
797
|
+
valid: boolean;
|
|
798
|
+
problems: FlowProblem[];
|
|
799
|
+
/** The most sandboxes the flow runs at once, and what your organization runs at once (Free runs 3). */
|
|
800
|
+
sandboxes: {
|
|
801
|
+
atOnce: number | null;
|
|
802
|
+
limit: number;
|
|
803
|
+
plan: "free" | "paid";
|
|
804
|
+
};
|
|
805
|
+
/** Step id to what your Policies will likely do there (hold it for a person, or no network). */
|
|
806
|
+
policy: Record<string, string>;
|
|
807
|
+
steps?: number;
|
|
808
|
+
guards?: Guards;
|
|
809
|
+
size?: RunSize;
|
|
810
|
+
}
|
|
811
|
+
/** Limits the server checks between steps. Defaults 5 loops, 300 s, $0.25; at most 50, 3600 s, $5. */
|
|
812
|
+
export interface Guards {
|
|
813
|
+
maxLoops?: number;
|
|
814
|
+
timeSec?: number;
|
|
815
|
+
budgetUsd?: number;
|
|
816
|
+
}
|
|
817
|
+
/** The size of the run's sandboxes; the plan's default (1 vCPU / 2 GB Standard) when left out. */
|
|
818
|
+
export interface RunSize {
|
|
819
|
+
cpuClass?: "standard" | "performance";
|
|
820
|
+
cpus?: 1 | 2 | 4 | 8 | 16;
|
|
821
|
+
memoryMb?: number;
|
|
822
|
+
}
|
|
823
|
+
/** A recipe's level. */
|
|
824
|
+
export type RecipeLevel = "everyday" | "advanced";
|
|
825
|
+
/** A recipe: a ready-made flow to start from. */
|
|
826
|
+
export interface Recipe {
|
|
827
|
+
id: string;
|
|
828
|
+
name?: string;
|
|
829
|
+
/** Its shape in a few words, like "a loop". */
|
|
830
|
+
shape?: string;
|
|
831
|
+
description?: string;
|
|
832
|
+
category?: "Coding" | "Data" | "Evals" | "Safety" | "Research" | "Customers" | "Office" | (string & {});
|
|
833
|
+
/** "everyday" for office work that needs no code, "advanced" for engineers. */
|
|
834
|
+
level?: RecipeLevel;
|
|
835
|
+
/** True when it needs a Claude key saved on the Secrets page. */
|
|
836
|
+
needsKey?: boolean;
|
|
837
|
+
icon?: string;
|
|
838
|
+
/** Sandboxes it runs at once: the main one and its biggest fork's lanes. */
|
|
839
|
+
sandboxes?: number;
|
|
840
|
+
/** True when it runs more sandboxes at once than the Free plan allows. */
|
|
841
|
+
paidPlan?: boolean;
|
|
842
|
+
/**
|
|
843
|
+
* Pages that open the recipe in a person's Playground builder as a flow of
|
|
844
|
+
* their own, signing in first if needed. Hand one to a person; they are not
|
|
845
|
+
* API calls.
|
|
846
|
+
*/
|
|
847
|
+
links?: RecipeLinks;
|
|
848
|
+
graph: Graph;
|
|
849
|
+
guards: Guards;
|
|
850
|
+
[k: string]: unknown;
|
|
851
|
+
}
|
|
852
|
+
export interface RecipeLinks {
|
|
853
|
+
/** Opens it. */
|
|
854
|
+
open?: string;
|
|
855
|
+
/** Opens it and shows the forecast. */
|
|
856
|
+
simulate?: string;
|
|
857
|
+
/** Opens it and asks before it runs, with the likely cost and any missing key. */
|
|
858
|
+
run?: string;
|
|
859
|
+
}
|
|
860
|
+
/** A schedule for a flow trigger. Times are UTC; weekday 0 is Sunday. Every 15 minutes at most. */
|
|
861
|
+
export type TriggerSchedule = {
|
|
862
|
+
every: "minutes";
|
|
863
|
+
minutes: number;
|
|
864
|
+
} | {
|
|
865
|
+
every: "hour";
|
|
866
|
+
minute?: number;
|
|
867
|
+
} | {
|
|
868
|
+
every: "day";
|
|
869
|
+
hour: number;
|
|
870
|
+
minute?: number;
|
|
871
|
+
} | {
|
|
872
|
+
every: "week";
|
|
873
|
+
weekday: number;
|
|
874
|
+
hour: number;
|
|
875
|
+
minute?: number;
|
|
876
|
+
};
|
|
877
|
+
/** What starts a flow on its own: a webhook, a schedule or GitHub events. */
|
|
878
|
+
export interface FlowTrigger {
|
|
879
|
+
id: string;
|
|
880
|
+
flowId: string;
|
|
881
|
+
kind: "webhook" | "schedule" | "github";
|
|
882
|
+
enabled: boolean;
|
|
883
|
+
/** schedule: the schedule, with description in words ("Daily at 09:00 UTC"). */
|
|
884
|
+
schedule: (Partial<TriggerSchedule> & {
|
|
885
|
+
description?: string;
|
|
886
|
+
}) | null;
|
|
887
|
+
nextFireAt: string | null;
|
|
888
|
+
/** github: push, pull_request, release. */
|
|
889
|
+
events?: string[];
|
|
890
|
+
/** github: owner/name, or null for any repository that sends events. */
|
|
891
|
+
repo?: string | null;
|
|
892
|
+
/** webhook and github: where to send. */
|
|
893
|
+
url: string | null;
|
|
894
|
+
lastFiredAt: string | null;
|
|
895
|
+
lastRunId: string | null;
|
|
896
|
+
/** Why the last fire didn't start a run. */
|
|
897
|
+
lastError: string | null;
|
|
898
|
+
createdAt: string;
|
|
899
|
+
}
|
|
900
|
+
export interface TriggerOptions {
|
|
901
|
+
enabled?: boolean;
|
|
902
|
+
schedule?: TriggerSchedule;
|
|
903
|
+
events?: ("push" | "pull_request" | "release")[];
|
|
904
|
+
repo?: string | null;
|
|
905
|
+
}
|
|
906
|
+
/** A GitHub Actions runner pool: each queued job whose runs-on asks for quietrobot gets a fresh sandbox. */
|
|
907
|
+
export interface GitHubRunnerPool {
|
|
908
|
+
id: string;
|
|
909
|
+
name: string;
|
|
910
|
+
scope: "repo" | "org";
|
|
911
|
+
owner: string;
|
|
912
|
+
repo: string | null;
|
|
913
|
+
labels: string[];
|
|
914
|
+
/** Labels a workflow can put in runs-on. */
|
|
915
|
+
runsOn: string[];
|
|
916
|
+
template: string;
|
|
917
|
+
cpuClass: string;
|
|
918
|
+
cpus: number;
|
|
919
|
+
region: string | null;
|
|
920
|
+
egress: {
|
|
921
|
+
mode: string;
|
|
922
|
+
allow?: string[];
|
|
923
|
+
};
|
|
924
|
+
allowSudo: boolean;
|
|
925
|
+
maxRunners: number;
|
|
926
|
+
jobTimeoutSec: number;
|
|
927
|
+
enabled: boolean;
|
|
928
|
+
/** Paste into GitHub's webhook settings. */
|
|
929
|
+
webhookUrl: string;
|
|
930
|
+
/** Shown when the pool is made and when the secret is rotated. */
|
|
931
|
+
webhookSecret?: string;
|
|
932
|
+
/** get(): the latest jobs. */
|
|
933
|
+
jobs?: Record<string, unknown>[];
|
|
934
|
+
[k: string]: unknown;
|
|
935
|
+
}
|
|
936
|
+
export interface GitHubRunnerOptions {
|
|
937
|
+
/** owner/name. Give repository or organization. */
|
|
938
|
+
repository?: string;
|
|
939
|
+
organization?: string;
|
|
940
|
+
/** A GitHub token (fine-grained is best) with Administration or Self-hosted runners: Read and write. */
|
|
941
|
+
token?: string;
|
|
942
|
+
/** Extra labels a job may ask for besides quietrobot. */
|
|
943
|
+
labels?: string[];
|
|
944
|
+
/** github-runner (default) or your own template built FROM quietrobot/github-runner. */
|
|
945
|
+
template?: string;
|
|
946
|
+
cpuClass?: "standard" | "performance";
|
|
947
|
+
cpus?: 1 | 2 | 4 | 8 | 16;
|
|
948
|
+
region?: string | null;
|
|
949
|
+
egress?: {
|
|
950
|
+
mode: "allowlist" | "open";
|
|
951
|
+
allow?: string[];
|
|
952
|
+
};
|
|
953
|
+
/** Root for job steps. Only a signed-in person can turn it on. */
|
|
954
|
+
allowSudo?: boolean;
|
|
955
|
+
maxRunners?: number;
|
|
956
|
+
jobTimeoutSec?: number;
|
|
957
|
+
enabled?: boolean;
|
|
958
|
+
name?: string;
|
|
959
|
+
}
|
|
960
|
+
/** The organization's rules, read-only: owners and admins change them on the dashboard's Policies page. */
|
|
961
|
+
export interface OrgPolicy {
|
|
962
|
+
defaults: {
|
|
963
|
+
egressMode: string;
|
|
964
|
+
egressAllow: string[];
|
|
965
|
+
egressDeny: string[];
|
|
966
|
+
egressLock: boolean;
|
|
967
|
+
timeoutSec: number;
|
|
968
|
+
maxConcurrent: number;
|
|
969
|
+
spendCapUsd: number | null;
|
|
970
|
+
};
|
|
971
|
+
approvalRules: {
|
|
972
|
+
id: string;
|
|
973
|
+
pattern: string;
|
|
974
|
+
description: string;
|
|
975
|
+
enabled: boolean;
|
|
976
|
+
}[];
|
|
977
|
+
checkpointRisky?: boolean;
|
|
978
|
+
[k: string]: unknown;
|
|
979
|
+
}
|
|
980
|
+
/** The old name for Recipe. */
|
|
981
|
+
export type GraphTemplate = Recipe;
|
|
982
|
+
/** What the simulator expects a run to do and cost, from 2,000 seeded trials. */
|
|
983
|
+
export interface Forecast {
|
|
984
|
+
trials: number;
|
|
985
|
+
costUsd: {
|
|
986
|
+
p50: number;
|
|
987
|
+
p90: number;
|
|
988
|
+
max: number;
|
|
989
|
+
mean: number;
|
|
990
|
+
};
|
|
991
|
+
seconds: {
|
|
992
|
+
p50: number;
|
|
993
|
+
p90: number;
|
|
994
|
+
};
|
|
995
|
+
loops: {
|
|
996
|
+
mean: number;
|
|
997
|
+
p90: number;
|
|
998
|
+
};
|
|
999
|
+
outcomes: {
|
|
1000
|
+
done: number;
|
|
1001
|
+
failed: number;
|
|
1002
|
+
guard: number;
|
|
1003
|
+
};
|
|
1004
|
+
guardHits: {
|
|
1005
|
+
loops: number;
|
|
1006
|
+
time: number;
|
|
1007
|
+
budget: number;
|
|
1008
|
+
};
|
|
1009
|
+
maxSandboxes: number;
|
|
1010
|
+
worstCaseUsd: number;
|
|
1011
|
+
worstCaseWhy: string;
|
|
1012
|
+
estimates: Record<string, {
|
|
1013
|
+
sec: number;
|
|
1014
|
+
passRate: number;
|
|
1015
|
+
source: string;
|
|
1016
|
+
}>;
|
|
1017
|
+
hourlyUsd: number;
|
|
1018
|
+
/** Model steps' cost per run at list prices, billed to your own key. Left out when there are none. */
|
|
1019
|
+
modelCostUsd?: {
|
|
1020
|
+
p50: number;
|
|
1021
|
+
p90: number;
|
|
1022
|
+
};
|
|
1023
|
+
/** By step id: why the policy will likely touch it. Left out when none. */
|
|
1024
|
+
policy?: Record<string, string>;
|
|
1025
|
+
[k: string]: unknown;
|
|
1026
|
+
}
|
|
1027
|
+
/** The answer to graphs.simulate: the name of the graph and the settings it played, and the forecast. */
|
|
1028
|
+
export interface Simulation {
|
|
1029
|
+
/** The graph's name. */
|
|
1030
|
+
graph: string;
|
|
1031
|
+
/** The recipe it played, if any. template is its old name. */
|
|
1032
|
+
recipe: string | null;
|
|
1033
|
+
template: string | null;
|
|
1034
|
+
guards: Guards;
|
|
1035
|
+
size: RunSize;
|
|
1036
|
+
forecast: Forecast;
|
|
1037
|
+
[k: string]: unknown;
|
|
1038
|
+
}
|
|
1039
|
+
export type RunStatus = "queued" | "running" | "done" | "failed" | "stopped" | "cancelled";
|
|
1040
|
+
export type RunStepStatus = "running" | "waiting" | "ok" | "fail" | "stopped" | "skipped";
|
|
1041
|
+
export interface RunStep {
|
|
1042
|
+
id: string;
|
|
1043
|
+
seq: number;
|
|
1044
|
+
node: string;
|
|
1045
|
+
label: string | null;
|
|
1046
|
+
status: RunStepStatus;
|
|
1047
|
+
sandboxId: string | null;
|
|
1048
|
+
executionId: string | null;
|
|
1049
|
+
snapshotId: string | null;
|
|
1050
|
+
message: string | null;
|
|
1051
|
+
output: string | null;
|
|
1052
|
+
costUsd: number | null;
|
|
1053
|
+
/** Model steps: tokens sent and back, and the call's cost at list prices. */
|
|
1054
|
+
tokensIn?: number | null;
|
|
1055
|
+
tokensOut?: number | null;
|
|
1056
|
+
modelCostUsd?: number | null;
|
|
1057
|
+
/** Decisions: the label it picked. */
|
|
1058
|
+
choice?: string | null;
|
|
1059
|
+
startedAt: string | null;
|
|
1060
|
+
finishedAt: string | null;
|
|
1061
|
+
durationMs: number | null;
|
|
1062
|
+
[k: string]: unknown;
|
|
1063
|
+
}
|
|
1064
|
+
/** What a finished run gave back. Text files keep their first 24 KB (cut: true when longer); text is null for a binary file or one past the first 8. */
|
|
1065
|
+
export interface RunResults {
|
|
1066
|
+
/** The last step's output. */
|
|
1067
|
+
output: {
|
|
1068
|
+
step: string;
|
|
1069
|
+
label: string | null;
|
|
1070
|
+
text: string;
|
|
1071
|
+
} | null;
|
|
1072
|
+
/** The files the run's steps wrote or changed in its main sandbox, newest first (at most 20; dot folders, package folders and the flow's own files are left out). */
|
|
1073
|
+
files: {
|
|
1074
|
+
path: string;
|
|
1075
|
+
bytes: number;
|
|
1076
|
+
modified: string;
|
|
1077
|
+
text: string | null;
|
|
1078
|
+
cut: boolean;
|
|
1079
|
+
saved?: boolean;
|
|
1080
|
+
url?: string | null;
|
|
1081
|
+
}[];
|
|
1082
|
+
moreFiles: number;
|
|
1083
|
+
/** Why there are no files, when there are none. */
|
|
1084
|
+
note: string | null;
|
|
1085
|
+
/** The run's lasting result link: the files it kept, at https://<name>.quietrobot.dev/, opening at entry (an HTML page) when it wrote one. Anyone with the link can open it. */
|
|
1086
|
+
link?: {
|
|
1087
|
+
url: string;
|
|
1088
|
+
entry: string | null;
|
|
1089
|
+
files: number;
|
|
1090
|
+
bytes: number;
|
|
1091
|
+
zipUrl: string;
|
|
1092
|
+
} | null;
|
|
1093
|
+
keptFiles?: number;
|
|
1094
|
+
keptNote?: string | null;
|
|
1095
|
+
/** localhost addresses a step printed: they only worked inside the run's sandbox. */
|
|
1096
|
+
localLinks?: string[];
|
|
1097
|
+
/** The flow's graph.serve, which runs.preview uses. */
|
|
1098
|
+
serve?: {
|
|
1099
|
+
command: string;
|
|
1100
|
+
port: number;
|
|
1101
|
+
} | null;
|
|
1102
|
+
}
|
|
1103
|
+
/** A live preview: a sandbox from the run's last checkpoint running the app, and a private link to its port that expires. */
|
|
1104
|
+
export interface RunPreview {
|
|
1105
|
+
sandboxId: string;
|
|
1106
|
+
executionId: string | null;
|
|
1107
|
+
command: string;
|
|
1108
|
+
port: number;
|
|
1109
|
+
url: string;
|
|
1110
|
+
expiresAt: string | null;
|
|
1111
|
+
}
|
|
1112
|
+
export interface Run {
|
|
1113
|
+
id: string;
|
|
1114
|
+
name: string;
|
|
1115
|
+
/** The recipe it ran, if any. template is its old name. */
|
|
1116
|
+
recipe: string | null;
|
|
1117
|
+
template: string | null;
|
|
1118
|
+
/** The saved flow it ran and which of its versions, if any. */
|
|
1119
|
+
flowId: string | null;
|
|
1120
|
+
flowVersion: number | null;
|
|
1121
|
+
mode: "managed" | "external";
|
|
1122
|
+
status: RunStatus;
|
|
1123
|
+
guards: Guards;
|
|
1124
|
+
size?: RunSize;
|
|
1125
|
+
loops: number;
|
|
1126
|
+
costUsd: number;
|
|
1127
|
+
/** Model steps' cost at list prices, billed to your own key and counted toward budgetUsd. */
|
|
1128
|
+
modelCostUsd?: number;
|
|
1129
|
+
elapsedSec: number;
|
|
1130
|
+
stopReason: string | null;
|
|
1131
|
+
error: string | null;
|
|
1132
|
+
sandboxes: Record<string, string>;
|
|
1133
|
+
graph: Graph;
|
|
1134
|
+
forecast: Forecast | null;
|
|
1135
|
+
/** In get() and wait(); a list may leave them out. */
|
|
1136
|
+
steps?: RunStep[];
|
|
1137
|
+
/** Once the run has ended: its last output and the files it wrote. null while it runs. */
|
|
1138
|
+
results?: RunResults | null;
|
|
1139
|
+
metadata?: Record<string, string>;
|
|
1140
|
+
/** Kept in full past the plan's run history (runs.pin). */
|
|
1141
|
+
pinned?: boolean;
|
|
1142
|
+
/** When the run's step outputs were removed for age; its status, cost and timing stay. */
|
|
1143
|
+
trimmedAt?: string | null;
|
|
1144
|
+
createdAt: string;
|
|
1145
|
+
startedAt: string | null;
|
|
1146
|
+
finishedAt: string | null;
|
|
1147
|
+
[k: string]: unknown;
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* What to play, just one of: a graph you give, a recipe by id, or a saved
|
|
1151
|
+
* flow by id. template is the old name for recipe and still works.
|
|
1152
|
+
*/
|
|
1153
|
+
export type GraphSource = {
|
|
1154
|
+
graph: Graph;
|
|
1155
|
+
recipe?: undefined;
|
|
1156
|
+
flow?: undefined;
|
|
1157
|
+
template?: undefined;
|
|
1158
|
+
} | {
|
|
1159
|
+
recipe: string;
|
|
1160
|
+
graph?: undefined;
|
|
1161
|
+
flow?: undefined;
|
|
1162
|
+
template?: undefined;
|
|
1163
|
+
} | {
|
|
1164
|
+
flow: string;
|
|
1165
|
+
graph?: undefined;
|
|
1166
|
+
recipe?: undefined;
|
|
1167
|
+
template?: undefined;
|
|
1168
|
+
} | {
|
|
1169
|
+
template: string;
|
|
1170
|
+
graph?: undefined;
|
|
1171
|
+
recipe?: undefined;
|
|
1172
|
+
flow?: undefined;
|
|
1173
|
+
};
|
|
1174
|
+
export type SimulateOptions = GraphSource & {
|
|
1175
|
+
guards?: Guards;
|
|
1176
|
+
size?: RunSize;
|
|
1177
|
+
};
|
|
1178
|
+
export type CreateRunOptions = GraphSource & {
|
|
1179
|
+
guards?: Guards;
|
|
1180
|
+
size?: RunSize;
|
|
1181
|
+
/** "external": you play the graph yourself and report its steps with runs.reportStep. */
|
|
1182
|
+
mode?: "managed" | "external";
|
|
1183
|
+
metadata?: Record<string, string>;
|
|
1184
|
+
};
|
|
1185
|
+
/** Where the builder draws each step, by step id. */
|
|
1186
|
+
export type FlowLayout = Record<string, {
|
|
1187
|
+
x: number;
|
|
1188
|
+
y: number;
|
|
1189
|
+
}>;
|
|
1190
|
+
/** A flow in a list: without its graph. */
|
|
1191
|
+
export interface FlowSummary {
|
|
1192
|
+
id: string;
|
|
1193
|
+
name: string;
|
|
1194
|
+
/** The recipe it was made from, if any. */
|
|
1195
|
+
recipe: string | null;
|
|
1196
|
+
/** How many steps it has. */
|
|
1197
|
+
steps: number;
|
|
1198
|
+
/** false for a draft that can't run yet; problem says why. */
|
|
1199
|
+
runnable: boolean;
|
|
1200
|
+
problem: string | null;
|
|
1201
|
+
createdAt: string;
|
|
1202
|
+
updatedAt: string;
|
|
1203
|
+
[k: string]: unknown;
|
|
1204
|
+
}
|
|
1205
|
+
/** A saved flow: a graph with its guards and the layout the builder draws. */
|
|
1206
|
+
export interface Flow {
|
|
1207
|
+
id: string;
|
|
1208
|
+
name: string;
|
|
1209
|
+
graph: Graph;
|
|
1210
|
+
guards: Guards;
|
|
1211
|
+
layout: FlowLayout;
|
|
1212
|
+
/** The recipe it was made from, if any. */
|
|
1213
|
+
recipe: string | null;
|
|
1214
|
+
/** false for a draft that can't run yet; problem says why. */
|
|
1215
|
+
runnable: boolean;
|
|
1216
|
+
problem: string | null;
|
|
1217
|
+
createdAt: string;
|
|
1218
|
+
updatedAt: string;
|
|
1219
|
+
[k: string]: unknown;
|
|
1220
|
+
}
|
|
1221
|
+
/** A graph (with guards, layout and a name if you like), a recipe id, or nothing for a blank flow. */
|
|
1222
|
+
export type CreateFlowOptions = {
|
|
1223
|
+
graph?: Graph;
|
|
1224
|
+
guards?: Partial<Guards>;
|
|
1225
|
+
layout?: FlowLayout;
|
|
1226
|
+
name?: string;
|
|
1227
|
+
recipe?: undefined;
|
|
1228
|
+
$schema?: string;
|
|
1229
|
+
} | {
|
|
1230
|
+
recipe: string;
|
|
1231
|
+
name?: string;
|
|
1232
|
+
graph?: undefined;
|
|
1233
|
+
guards?: undefined;
|
|
1234
|
+
layout?: undefined;
|
|
1235
|
+
};
|
|
1236
|
+
export interface UpdateFlowOptions {
|
|
1237
|
+
name?: string;
|
|
1238
|
+
graph?: Graph;
|
|
1239
|
+
guards?: Partial<Guards>;
|
|
1240
|
+
layout?: FlowLayout;
|
|
1241
|
+
}
|
|
1242
|
+
/** A version in a flow's history. */
|
|
1243
|
+
export interface FlowVersionSummary {
|
|
1244
|
+
version: number;
|
|
1245
|
+
createdAt: string;
|
|
1246
|
+
createdBy: string | null;
|
|
1247
|
+
note: string | null;
|
|
1248
|
+
steps: number;
|
|
1249
|
+
[k: string]: unknown;
|
|
1250
|
+
}
|
|
1251
|
+
/** One version in full. */
|
|
1252
|
+
export interface FlowVersion extends FlowVersionSummary {
|
|
1253
|
+
name: string;
|
|
1254
|
+
graph: Graph;
|
|
1255
|
+
guards: Guards;
|
|
1256
|
+
layout: FlowLayout;
|
|
1257
|
+
}
|
|
1258
|
+
export interface RunFlowOptions {
|
|
1259
|
+
/** The flow's own guards when left out. */
|
|
1260
|
+
guards?: Partial<Guards>;
|
|
1261
|
+
size?: RunSize;
|
|
1262
|
+
metadata?: Record<string, string>;
|
|
1263
|
+
}
|
|
1264
|
+
/** One step of an external run, as you report it. */
|
|
1265
|
+
export interface StepReport {
|
|
1266
|
+
node: string;
|
|
1267
|
+
status: RunStepStatus;
|
|
1268
|
+
label?: string;
|
|
1269
|
+
sandboxId?: string;
|
|
1270
|
+
snapshotId?: string;
|
|
1271
|
+
message?: string;
|
|
1272
|
+
startedAt?: string | Date;
|
|
1273
|
+
finishedAt?: string | Date;
|
|
1274
|
+
}
|
|
1275
|
+
/** The answer to a step report. When stop is true a guard was reached: stop the loop. */
|
|
1276
|
+
export interface StepAnswer {
|
|
1277
|
+
step: RunStep;
|
|
1278
|
+
stop: boolean;
|
|
1279
|
+
reason: string | null;
|
|
1280
|
+
}
|
|
1281
|
+
export interface WaitOptions {
|
|
1282
|
+
/** Default 30 minutes. Throws SandboxesError run_timeout after it. */
|
|
1283
|
+
timeoutMs?: number;
|
|
1284
|
+
/** Called for each step when it first shows up and each time its status changes. */
|
|
1285
|
+
onStep?: (step: RunStep, run: Run) => void;
|
|
1286
|
+
}
|
|
1287
|
+
/** A run is over in these states. */
|
|
1288
|
+
export declare const RUN_FINISHED: readonly RunStatus[];
|
|
416
1289
|
export declare class SandboxesError extends Error {
|
|
417
1290
|
status: number;
|
|
418
1291
|
code: string;
|
|
@@ -443,10 +1316,47 @@ export declare class Sandboxes {
|
|
|
443
1316
|
*/
|
|
444
1317
|
readonly secrets: {
|
|
445
1318
|
list: () => Promise<SecretInfo[]>;
|
|
446
|
-
/**
|
|
447
|
-
|
|
1319
|
+
/**
|
|
1320
|
+
* Adds a secret, or replaces the value and hosts of one with the same name.
|
|
1321
|
+
* Rules and budget are kept when left out.
|
|
1322
|
+
*/
|
|
1323
|
+
set: (name: string, value: string, hosts: string[], opts?: SecretOptions) => Promise<SecretInfo>;
|
|
1324
|
+
/** Changes a secret's hosts, call rules or budget without sending the value again. */
|
|
1325
|
+
update: (name: string, changes: SecretOptions & {
|
|
1326
|
+
hosts?: string[];
|
|
1327
|
+
}) => Promise<SecretInfo>;
|
|
1328
|
+
/**
|
|
1329
|
+
* Replaces a secret's value (rolls the key). Allowed hosts, rules and budget
|
|
1330
|
+
* are kept unless hosts is given. Where the service can be checked
|
|
1331
|
+
* (Anthropic, OpenAI) the new value is tested first; if it's refused the
|
|
1332
|
+
* old value stays and this throws SandboxesError with code "key_rejected".
|
|
1333
|
+
* Running sandboxes use the new value on their next call.
|
|
1334
|
+
*/
|
|
1335
|
+
roll: (name: string, value: string, opts?: {
|
|
1336
|
+
hosts?: string[];
|
|
1337
|
+
}) => Promise<SecretInfo>;
|
|
1338
|
+
/**
|
|
1339
|
+
* Checks a key with its service. Without value, tests the saved one (a
|
|
1340
|
+
* refusal marks it failing, a pass clears that). With value, tests that
|
|
1341
|
+
* candidate without saving it or changing anything.
|
|
1342
|
+
*/
|
|
1343
|
+
test: (name: string, value?: string) => Promise<SecretTest>;
|
|
448
1344
|
delete: (name: string) => Promise<SecretInfo>;
|
|
449
1345
|
};
|
|
1346
|
+
/**
|
|
1347
|
+
* Commands a rule is holding until a person decides. Any key can list them;
|
|
1348
|
+
* only a person signed in to the dashboard can approve or deny, so a key
|
|
1349
|
+
* inside a sandbox can never let its own command through.
|
|
1350
|
+
*/
|
|
1351
|
+
readonly approvals: {
|
|
1352
|
+
list: () => Promise<Execution[]>;
|
|
1353
|
+
};
|
|
1354
|
+
/** Messages between your sandboxes and your code. Inside a sandbox, use Channels.inSandbox() instead. */
|
|
1355
|
+
readonly channels: Channels & {
|
|
1356
|
+
delete(name: string): Promise<{
|
|
1357
|
+
deleted: boolean;
|
|
1358
|
+
}>;
|
|
1359
|
+
};
|
|
450
1360
|
/** Folders kept between sandboxes. Attach one with create({ volumes: [{ name, path }] }). */
|
|
451
1361
|
readonly volumes: {
|
|
452
1362
|
list: () => Promise<VolumeInfo[]>;
|
|
@@ -460,7 +1370,7 @@ export declare class Sandboxes {
|
|
|
460
1370
|
webhooks: WebhookInfo[];
|
|
461
1371
|
events: string[];
|
|
462
1372
|
}>;
|
|
463
|
-
/** The answer carries the signing secret, shown this once. events defaults to sandbox.*, approval
|
|
1373
|
+
/** The answer carries the signing secret, shown this once. events defaults to sandbox.*, approval.*, volume.save_failed and run.* (flow runs started, finished, failed, stopped, cancelled or waiting for a person). */
|
|
464
1374
|
create: (opts: {
|
|
465
1375
|
url: string;
|
|
466
1376
|
events?: string[];
|
|
@@ -479,6 +1389,184 @@ export declare class Sandboxes {
|
|
|
479
1389
|
deliveries: (id: string) => Promise<unknown>;
|
|
480
1390
|
redeliver: (id: string, deliveryId: string) => Promise<unknown>;
|
|
481
1391
|
};
|
|
1392
|
+
/** Loops and graphs: what a graph will do and cost before it runs. */
|
|
1393
|
+
readonly graphs: {
|
|
1394
|
+
/** The recipes under their old name. Use recipes.list(). */
|
|
1395
|
+
templates: () => Promise<GraphTemplate[]>;
|
|
1396
|
+
/**
|
|
1397
|
+
* Plays a graph, a recipe or a saved flow 2,000 times (seeded) without
|
|
1398
|
+
* starting anything. The answer's forecast says what it will cost, how
|
|
1399
|
+
* long it takes, how many loops it makes and which guard stops it.
|
|
1400
|
+
*/
|
|
1401
|
+
simulate: (opts: SimulateOptions) => Promise<Simulation>;
|
|
1402
|
+
};
|
|
1403
|
+
/** Recipes: ready-made flows to start from, by category, each with its default guards. */
|
|
1404
|
+
readonly recipes: {
|
|
1405
|
+
/** Every recipe, or one level: list({ level: "everyday" }). */
|
|
1406
|
+
list: (opts?: {
|
|
1407
|
+
level?: RecipeLevel;
|
|
1408
|
+
}) => Promise<Recipe[]>;
|
|
1409
|
+
get: (id: string) => Promise<Recipe>;
|
|
1410
|
+
};
|
|
1411
|
+
/**
|
|
1412
|
+
* Flows: graphs saved from the playground's builder or sent here, with
|
|
1413
|
+
* their guards, layout and versions. A flow may be a draft that doesn't run
|
|
1414
|
+
* yet; its problem says why.
|
|
1415
|
+
*/
|
|
1416
|
+
readonly flows: {
|
|
1417
|
+
/** Your flows, newest change first, without their graphs. */
|
|
1418
|
+
list: () => Promise<FlowSummary[]>;
|
|
1419
|
+
get: (id: string) => Promise<Flow>;
|
|
1420
|
+
/** Saves a new flow from a graph, from a recipe ({ recipe: id }), or blank. Recorded as version 1. */
|
|
1421
|
+
create: (opts?: CreateFlowOptions) => Promise<Flow>;
|
|
1422
|
+
/** Saves the flow. Fields left out keep their value. This doesn't record a version: saveVersion and a run of a changed flow do. */
|
|
1423
|
+
update: (id: string, opts: UpdateFlowOptions) => Promise<Flow>;
|
|
1424
|
+
/** Deletes the flow and its versions. Its runs stay. */
|
|
1425
|
+
delete: (id: string) => Promise<{
|
|
1426
|
+
id: string;
|
|
1427
|
+
deleted: boolean;
|
|
1428
|
+
}>;
|
|
1429
|
+
/**
|
|
1430
|
+
* Checks a flow without saving or running it: a flow JSON, { flow: id } or
|
|
1431
|
+
* { recipe: id }. The same checks as a save and a run, your plan's
|
|
1432
|
+
* sandboxes at once, and the steps your Policies will likely hold.
|
|
1433
|
+
* valid is false, with problems, when it wouldn't run; nothing throws for that.
|
|
1434
|
+
*/
|
|
1435
|
+
validate: (opts: FlowDocument | {
|
|
1436
|
+
flow: string;
|
|
1437
|
+
size?: RunSize;
|
|
1438
|
+
} | {
|
|
1439
|
+
recipe: string;
|
|
1440
|
+
guards?: Partial<Guards>;
|
|
1441
|
+
size?: RunSize;
|
|
1442
|
+
}) => Promise<FlowValidation>;
|
|
1443
|
+
/**
|
|
1444
|
+
* Drafts a flow from plain words, like "Every morning, summarize the news
|
|
1445
|
+
* about our competitors and ask me before posting it". Claude drafts it with
|
|
1446
|
+
* your own saved Claude key (ANTHROPIC_API_KEY first, or name one in key),
|
|
1447
|
+
* and it is checked like any flow. save: true also saves it (flowId).
|
|
1448
|
+
*/
|
|
1449
|
+
draft: (opts: {
|
|
1450
|
+
description: string;
|
|
1451
|
+
key?: string;
|
|
1452
|
+
save?: boolean;
|
|
1453
|
+
}) => Promise<DraftedFlow>;
|
|
1454
|
+
/** The flow JSON, without ids or timestamps. Pass it to create() to make a copy, here or in another organization. */
|
|
1455
|
+
export: (id: string) => Promise<FlowDocument>;
|
|
1456
|
+
/** The flow JSON's schema (JSON Schema 2020-12), for editors. */
|
|
1457
|
+
schema: () => Promise<Record<string, unknown>>;
|
|
1458
|
+
/** The flow's versions, newest first. The newest 50 are kept. */
|
|
1459
|
+
versions: (id: string) => Promise<FlowVersionSummary[]>;
|
|
1460
|
+
/** One version in full: its graph, guards and layout. */
|
|
1461
|
+
version: (id: string, version: number) => Promise<FlowVersion>;
|
|
1462
|
+
/** Saves the flow as it is now as a new version, with a note of up to 200 characters. Returns its number. */
|
|
1463
|
+
saveVersion: (id: string, opts?: {
|
|
1464
|
+
note?: string;
|
|
1465
|
+
}) => Promise<number>;
|
|
1466
|
+
/** Puts a version back: the flow's graph, guards and layout become that version's (the name stays), recorded as a new version. */
|
|
1467
|
+
restore: (id: string, version: number) => Promise<Flow>;
|
|
1468
|
+
/** Runs the flow, like runs.create({ flow: id }). The run's flowVersion says which version it ran. */
|
|
1469
|
+
run: (id: string, opts?: RunFlowOptions) => Promise<Run>;
|
|
1470
|
+
/** The flow's runs, newest first (limit up to 100). */
|
|
1471
|
+
runs: (id: string, opts?: {
|
|
1472
|
+
limit?: number;
|
|
1473
|
+
}) => Promise<Run[]>;
|
|
1474
|
+
/** The flow's triggers: what starts it on its own. */
|
|
1475
|
+
triggers: (id: string) => Promise<FlowTrigger[]>;
|
|
1476
|
+
/**
|
|
1477
|
+
* Adds a trigger, up to 10 a flow: a webhook, a schedule or GitHub events.
|
|
1478
|
+
* secret is in this answer only: the webhook's token (send it in
|
|
1479
|
+
* X-QR-Token), or the secret for GitHub's webhook form. Triggers need Pay
|
|
1480
|
+
* as you go with a card; otherwise 402 card_required.
|
|
1481
|
+
*/
|
|
1482
|
+
addTrigger: (id: string, opts: TriggerOptions & {
|
|
1483
|
+
kind: FlowTrigger["kind"];
|
|
1484
|
+
}) => Promise<{
|
|
1485
|
+
trigger: FlowTrigger;
|
|
1486
|
+
secret?: string;
|
|
1487
|
+
}>;
|
|
1488
|
+
/** Turns a trigger on or off, or changes its schedule, events or repository. */
|
|
1489
|
+
updateTrigger: (id: string, triggerId: string, opts: TriggerOptions) => Promise<FlowTrigger>;
|
|
1490
|
+
deleteTrigger: (id: string, triggerId: string) => Promise<{
|
|
1491
|
+
id: string;
|
|
1492
|
+
deleted: boolean;
|
|
1493
|
+
}>;
|
|
1494
|
+
/** What a run of the flow will do and cost, like graphs.simulate({ flow: id }). */
|
|
1495
|
+
simulate: (id: string, opts?: {
|
|
1496
|
+
guards?: Guards;
|
|
1497
|
+
size?: RunSize;
|
|
1498
|
+
}) => Promise<Simulation>;
|
|
1499
|
+
};
|
|
1500
|
+
/**
|
|
1501
|
+
* GitHub Actions runner pools: each queued job in the repository or
|
|
1502
|
+
* organization whose runs-on asks for quietrobot (or quietrobot-4cpu,
|
|
1503
|
+
* quietrobot-performance-8cpu, ...) gets a fresh sandbox for that one job,
|
|
1504
|
+
* destroyed when the job ends and billed by the second.
|
|
1505
|
+
*/
|
|
1506
|
+
readonly githubRunners: {
|
|
1507
|
+
list: () => Promise<GitHubRunnerPool[]>;
|
|
1508
|
+
/** The pool and its latest jobs. */
|
|
1509
|
+
get: (id: string, opts?: {
|
|
1510
|
+
limit?: number;
|
|
1511
|
+
}) => Promise<GitHubRunnerPool>;
|
|
1512
|
+
/** Adds a pool. Paste webhookUrl and webhookSecret into the GitHub webhook form. */
|
|
1513
|
+
create: (opts: GitHubRunnerOptions & {
|
|
1514
|
+
token: string;
|
|
1515
|
+
}) => Promise<GitHubRunnerPool>;
|
|
1516
|
+
update: (id: string, opts: GitHubRunnerOptions) => Promise<GitHubRunnerPool>;
|
|
1517
|
+
/** Removes the pool; its running runners are stopped. */
|
|
1518
|
+
delete: (id: string) => Promise<{
|
|
1519
|
+
id: string;
|
|
1520
|
+
deleted: boolean;
|
|
1521
|
+
}>;
|
|
1522
|
+
/** A new webhook secret: the old one stops working at once. */
|
|
1523
|
+
rotateSecret: (id: string) => Promise<GitHubRunnerPool>;
|
|
1524
|
+
};
|
|
1525
|
+
/**
|
|
1526
|
+
* Runs play a graph on real sandboxes and stop themselves at a guard
|
|
1527
|
+
* (loops, time, spend), checked on the server. An external run is one you
|
|
1528
|
+
* play yourself (LangGraph and the like) and report with reportStep.
|
|
1529
|
+
*/
|
|
1530
|
+
readonly runs: {
|
|
1531
|
+
/** Starts a run of a graph, of a recipe ({ recipe: id }) or of a saved flow ({ flow: id }). */
|
|
1532
|
+
create: (opts: CreateRunOptions) => Promise<Run>;
|
|
1533
|
+
/** Recent runs, newest first (limit up to 100). */
|
|
1534
|
+
list: (opts?: {
|
|
1535
|
+
limit?: number;
|
|
1536
|
+
}) => Promise<Run[]>;
|
|
1537
|
+
/** The run with its steps. */
|
|
1538
|
+
get: (id: string) => Promise<Run>;
|
|
1539
|
+
/** Stops a run; its sandboxes are deleted as usual. */
|
|
1540
|
+
cancel: (id: string) => Promise<Run>;
|
|
1541
|
+
/** Keeps a finished run's step outputs past your plan's run history. */
|
|
1542
|
+
pin: (id: string) => Promise<Run>;
|
|
1543
|
+
/** Lets a pinned run's outputs be removed with your other old runs. */
|
|
1544
|
+
unpin: (id: string) => Promise<Run>;
|
|
1545
|
+
/** Makes a new result link for the files a finished run kept (the old address stops working). */
|
|
1546
|
+
link: (id: string) => Promise<{
|
|
1547
|
+
url: string | null;
|
|
1548
|
+
entry: string | null;
|
|
1549
|
+
}>;
|
|
1550
|
+
/** Turns a run's result link off at once. */
|
|
1551
|
+
unlink: (id: string) => Promise<{
|
|
1552
|
+
url: string | null;
|
|
1553
|
+
entry: string | null;
|
|
1554
|
+
}>;
|
|
1555
|
+
/** Starts what a finished run built from its last checkpoint and shares its port for an hour. Left out: the flow's graph.serve, else a guess from its files. */
|
|
1556
|
+
preview: (id: string, opts?: {
|
|
1557
|
+
command?: string;
|
|
1558
|
+
port?: number;
|
|
1559
|
+
}) => Promise<RunPreview>;
|
|
1560
|
+
/** Polls the run every second until it is done, failed, stopped or cancelled, and returns it. */
|
|
1561
|
+
wait: (id: string, opts?: WaitOptions) => Promise<Run>;
|
|
1562
|
+
/** External runs: ends the run as done or failed (with the error). */
|
|
1563
|
+
finish: (id: string, opts: {
|
|
1564
|
+
status: "done" | "failed";
|
|
1565
|
+
error?: string;
|
|
1566
|
+
}) => Promise<Run>;
|
|
1567
|
+
/** External runs: reports one step. When the answer says stop, a guard was reached; stop the loop. */
|
|
1568
|
+
reportStep: (id: string, step: StepReport) => Promise<StepAnswer>;
|
|
1569
|
+
};
|
|
482
1570
|
create(opts?: CreateOptions): Promise<Sandbox>;
|
|
483
1571
|
/** A sandbox by id, or by name for a saved one. */
|
|
484
1572
|
get(id: string): Promise<Sandbox>;
|
|
@@ -533,6 +1621,30 @@ export declare class Sandboxes {
|
|
|
533
1621
|
}>;
|
|
534
1622
|
/** This month's usage and limits, or the last `days` days. */
|
|
535
1623
|
usage(days?: number): Promise<Record<string, unknown>>;
|
|
1624
|
+
/**
|
|
1625
|
+
* What your own AI keys (Claude, OpenAI) were used for: every call Quiet Robot
|
|
1626
|
+
* made or passed on with one (Playground steps, flow drafting, sandboxes,
|
|
1627
|
+
* hosted Kip), by key, where it was used, model and day, with tokens (cache
|
|
1628
|
+
* reads and writes too) and the cost estimated at list price. `days`: 1 to
|
|
1629
|
+
* 400 (default 30); `key`: one key by its secret name.
|
|
1630
|
+
*/
|
|
1631
|
+
aiKeyUsage(opts?: {
|
|
1632
|
+
days?: number;
|
|
1633
|
+
key?: string;
|
|
1634
|
+
}): Promise<AiKeyUsage>;
|
|
1635
|
+
/** Everything the organization stores, item by item, with its monthly cost and this month's storage bill. */
|
|
1636
|
+
storage(): Promise<Record<string, unknown>>;
|
|
1637
|
+
/**
|
|
1638
|
+
* Your organization's rules, read-only: the defaults new sandboxes get, the
|
|
1639
|
+
* approval rules that hold commands, Undo checkpoints and the outbound
|
|
1640
|
+
* check. Owners and admins change them on the dashboard's Policies page, so
|
|
1641
|
+
* an API key can't loosen them.
|
|
1642
|
+
*/
|
|
1643
|
+
policy(): Promise<OrgPolicy>;
|
|
1644
|
+
/** Your outbound check's address, or null when there is none. Set on the dashboard's Policies page. */
|
|
1645
|
+
outboundCheck(): Promise<{
|
|
1646
|
+
url: string | null;
|
|
1647
|
+
}>;
|
|
536
1648
|
audit(opts?: {
|
|
537
1649
|
before?: number;
|
|
538
1650
|
limit?: number;
|
|
@@ -713,6 +1825,26 @@ export declare class Sandbox {
|
|
|
713
1825
|
sandboxes: Sandbox[];
|
|
714
1826
|
errors: unknown[];
|
|
715
1827
|
}>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Starts up to 10 running copies of this sandbox with everything in it at
|
|
1830
|
+
* this instant: memory, running programs, env and files. Each copy has the
|
|
1831
|
+
* source's size, template, network rules and metadata, its own id and no
|
|
1832
|
+
* ports. The source keeps running; it is held paused only while it is
|
|
1833
|
+
* copied (freezeMs). Copies are named <name>-1, <name>-2, ...
|
|
1834
|
+
*/
|
|
1835
|
+
clone(opts?: {
|
|
1836
|
+
count?: number;
|
|
1837
|
+
name?: string;
|
|
1838
|
+
timeoutSec?: number;
|
|
1839
|
+
}): Promise<{
|
|
1840
|
+
sandboxes: Sandbox[];
|
|
1841
|
+
errors: {
|
|
1842
|
+
code: string;
|
|
1843
|
+
message: string;
|
|
1844
|
+
}[];
|
|
1845
|
+
freezeMs?: number;
|
|
1846
|
+
totalMs?: number;
|
|
1847
|
+
}>;
|
|
716
1848
|
/**
|
|
717
1849
|
* Gives this sandbox a new size. A running or paused sandbox can't change size in
|
|
718
1850
|
* place, so this copies it (fork with the new size), destroys the original and
|
|
@@ -770,3 +1902,4 @@ export declare class Sandbox {
|
|
|
770
1902
|
audit(): Promise<AuditEvent[]>;
|
|
771
1903
|
destroy(): Promise<SandboxInfo>;
|
|
772
1904
|
}
|
|
1905
|
+
export {};
|