withruntime 0.35.0 → 0.37.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/BLAXEL.md +207 -204
- package/COMPATIBILITY.md +367 -337
- package/DAYTONA.md +180 -173
- package/E2B.md +246 -230
- package/README.md +182 -142
- package/README.src.md +182 -142
- package/VERCEL.md +173 -168
- package/agent-platforms-inventory.json +387 -0
- package/dist/agents-cli.d.ts +7 -1
- package/dist/agents-cli.js +219 -2
- package/dist/ci-cli.d.ts +7 -1
- package/dist/ci-cli.js +25 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +16 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +4 -1
- package/dist/index.d.ts +3 -3
- package/dist/inngest/index.d.ts +96 -0
- package/dist/inngest/index.js +183 -0
- package/dist/jobs-code/cron.d.ts +12 -0
- package/dist/jobs-code/cron.js +93 -0
- package/dist/jobs-code/registry.d.ts +31 -0
- package/dist/jobs-code/registry.js +30 -0
- package/dist/jobs-code/runner.d.ts +1 -0
- package/dist/jobs-code/runner.js +74 -0
- package/dist/jobs-deploy.d.ts +22 -0
- package/dist/jobs-deploy.js +247 -0
- package/dist/jobs-import.d.ts +15 -0
- package/dist/jobs-import.js +231 -0
- package/dist/products/agents.d.ts +161 -1
- package/dist/products/agents.js +40 -0
- package/dist/products/ci.d.ts +19 -1
- package/dist/products/jobs.d.ts +77 -0
- package/dist/products/jobs.js +5 -0
- package/dist/transport.d.ts +5 -1
- package/dist/transport.js +7 -1
- package/dist/trigger/index.d.ts +202 -0
- package/dist/trigger/index.js +244 -0
- package/package.json +14 -3
package/dist/agents-cli.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { dirname, join, resolve } from "node:path";
|
|
3
3
|
import { me, named } from "./cli-name.js";
|
|
4
4
|
import { AGENT_TEMPLATES, agentTemplate, AGENT_USES, agents, } from "./products/agents.js";
|
|
5
|
+
import { secrets } from "./products/secrets.js";
|
|
5
6
|
export const AGENT_HELP = `runtime agents <command>
|
|
6
7
|
|
|
7
8
|
An agent runs a harness (Claude Code, Codex, Gemini CLI, or your own code on
|
|
@@ -21,7 +22,7 @@ export const AGENT_HELP = `runtime agents <command>
|
|
|
21
22
|
create <name> (--template <harness> | --command "<cmd>") [--use support|team]
|
|
22
23
|
[--instructions <text> | --instructions-file <path>] [--secret NAME]... [--pool NAME]...
|
|
23
24
|
[--env KEY=VALUE]... [--image <image> | --snapshot <id>] [--vcpu n] [--memory n]
|
|
24
|
-
[--max-concurrent n] [--idle-pause n] [--label key=value]...
|
|
25
|
+
[--max-concurrent n] [--idle-pause n] [--permissions '<json>'] [--label key=value]...
|
|
25
26
|
Make an agent; prints its id. --secret names an egress
|
|
26
27
|
secret it may use: its model key, of any provider.
|
|
27
28
|
--pool names a Claude account's secret (each one
|
|
@@ -37,17 +38,30 @@ export const AGENT_HELP = `runtime agents <command>
|
|
|
37
38
|
until it ends
|
|
38
39
|
send <session> <words...> Words into a session
|
|
39
40
|
events <session> [--after <seq>] [--follow] A session's log; --follow until it ends
|
|
41
|
+
trace <session> [--otlp] [--export [--endpoint <url>] [--header key=value]...]
|
|
42
|
+
Every model turn and tool call: timing, tokens and
|
|
43
|
+
cost, totals by model and tool. --otlp prints
|
|
44
|
+
OpenTelemetry traces (OTLP/JSON); --export sends them
|
|
45
|
+
to a collector (--endpoint, or
|
|
46
|
+
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT /
|
|
47
|
+
OTEL_EXPORTER_OTLP_ENDPOINT and _HEADERS)
|
|
40
48
|
sessions [--agent <agent>] [--state <state>]...
|
|
41
49
|
Sessions, newest first
|
|
42
50
|
sessions delete <session> Delete an ended session and its log; its history is
|
|
43
51
|
storage, kept until you delete it
|
|
44
52
|
stop <session> Stop a session
|
|
53
|
+
switch anthropic Run Claude Managed Agents code on Runtime: the
|
|
54
|
+
base URL to give Anthropic's SDK, and whether
|
|
55
|
+
the model key (ANTHROPIC_API_KEY) is set
|
|
45
56
|
asks [--state <state>]... [--agent <agent>] [--label key=value]...
|
|
46
57
|
The inbox: what your agents' sessions need answered,
|
|
47
58
|
one row per step however many sessions ask it
|
|
48
59
|
asks get <ask> One ask: its options, pick and the sessions asking
|
|
49
60
|
answer <ask> [<option>] [--text <words>] Answer it with an option's label, words, or both:
|
|
50
61
|
every session asking reads it next and wakes
|
|
62
|
+
approve <ask> Let a tool call the agent's permissions held run
|
|
63
|
+
deny <ask> [--message <words>] Keep a held tool call from running; the message is
|
|
64
|
+
told to the agent
|
|
51
65
|
triggers <agent> Its triggers
|
|
52
66
|
triggers add <agent> --kind <slack|github|schedule|webhook> --config '<json>' [--rules '<json>']
|
|
53
67
|
triggers rules <triggerId> '<json>' Set its rules in place: priority, maxStartsPerHour,
|
|
@@ -84,10 +98,16 @@ Examples
|
|
|
84
98
|
runtime agents start helper "How do I reset my password?" --key customer:42 --follow
|
|
85
99
|
runtime agents memory put helper faq/refunds.md refunds.md
|
|
86
100
|
runtime agents asks && runtime agents answer <ask> "Raise to 20 TB"
|
|
101
|
+
runtime agents update helper --permissions '{"default":"auto","tools":{"shell":"always_ask"}}'
|
|
102
|
+
runtime agents approve <ask>
|
|
103
|
+
runtime agents trace <session> --export --endpoint https://otel.example.com
|
|
87
104
|
runtime agents init --template claude-code && runtime agents deploy --dry-run
|
|
88
105
|
runtime agents create ci-review --template review --pool CLAUDE_1 --pool CLAUDE_2
|
|
106
|
+
runtime agents switch anthropic
|
|
89
107
|
`;
|
|
90
108
|
const when = (iso) => iso ?? "-";
|
|
109
|
+
/** The guide to running Claude Managed Agents code on Runtime. */
|
|
110
|
+
const SWITCH_DOCS = "https://withruntime.com/docs/switch-from-claude-managed-agents";
|
|
91
111
|
/** A trigger's rules as the CLI takes them: one JSON object. */
|
|
92
112
|
function rulesOf(text, kit) {
|
|
93
113
|
let rules;
|
|
@@ -116,6 +136,7 @@ const OPTIONS = [
|
|
|
116
136
|
"memory",
|
|
117
137
|
"max-concurrent",
|
|
118
138
|
"idle-pause",
|
|
139
|
+
"permissions",
|
|
119
140
|
"label",
|
|
120
141
|
];
|
|
121
142
|
const ASK_STATES = ["open", "answered", "expired", "withdrawn", "closed"];
|
|
@@ -125,6 +146,7 @@ const askLine = (a) => {
|
|
|
125
146
|
`${a.id} ${a.state}${a.step ? ` step ${a.step}` : ""}, ${a.sessions.length} session${a.sessions.length === 1 ? "" : "s"} asking`,
|
|
126
147
|
` ${a.question}`,
|
|
127
148
|
...(a.why ? [` why: ${a.why}`] : []),
|
|
149
|
+
...(a.toolCall ? [` tool call: ${a.toolCall.tool} ${JSON.stringify(a.toolCall.input)}`] : []),
|
|
128
150
|
...(options.length ? [` options: ${options.join(" | ")}`] : []),
|
|
129
151
|
...(a.expiresAt ? [` expires ${a.expiresAt}`] : []),
|
|
130
152
|
...(a.answer
|
|
@@ -188,9 +210,70 @@ function definitionOf(args, kit, env, base) {
|
|
|
188
210
|
set("memoryMiB", integer(args, "memory"));
|
|
189
211
|
set("maxConcurrent", integer(args, "max-concurrent"));
|
|
190
212
|
set("idlePauseSeconds", integer(args, "idle-pause"));
|
|
213
|
+
const permissions = flag(args, "permissions");
|
|
214
|
+
if (permissions !== undefined) {
|
|
215
|
+
try {
|
|
216
|
+
set("permissions", JSON.parse(permissions));
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
throw usage(`--permissions takes JSON: '{"default":"auto","tools":{"shell":"always_ask"}}'.`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
191
222
|
return definition;
|
|
192
223
|
}
|
|
193
|
-
const line = (e) => `${String(e.seq).padStart(4)} ${e.kind.padEnd(6)} ${e.actor}: ${
|
|
224
|
+
const line = (e) => `${String(e.seq).padStart(4)} ${e.kind.padEnd(6)} ${e.actor}: ${e.kind === "turn"
|
|
225
|
+
? turnLine(e.body)
|
|
226
|
+
: e.kind === "tool"
|
|
227
|
+
? toolLine(e.body)
|
|
228
|
+
: typeof e.body.text === "string"
|
|
229
|
+
? e.body.text
|
|
230
|
+
: JSON.stringify(e.body)}`;
|
|
231
|
+
const count = (n) => n.toLocaleString("en-US");
|
|
232
|
+
const seconds = (ms) => `${(ms / 1000).toFixed(1)} s`;
|
|
233
|
+
const dollars = (usd) => usd === null ? "unpriced" : `$${usd < 1 ? usd.toFixed(4) : usd.toFixed(2)}`;
|
|
234
|
+
function turnLine(t) {
|
|
235
|
+
const calls = t.toolCalls.length ? ` -> ${t.toolCalls.map((c) => c.name).join(", ")}` : "";
|
|
236
|
+
const failed = t.error ? ` FAILED ${t.error}` : "";
|
|
237
|
+
return `${t.model} ${seconds(t.durationMs)}, ${count(t.inputTokens)} in, ${count(t.outputTokens)} out, ${count(t.cacheReadTokens)} cached, ${dollars(t.costUsd)}${calls}${failed}`;
|
|
238
|
+
}
|
|
239
|
+
function toolLine(t) {
|
|
240
|
+
return `${t.name} ${seconds(t.durationMs)}${t.error ? " FAILED" : ""}${t.input ? ` ${t.input.slice(0, 100)}` : ""}`;
|
|
241
|
+
}
|
|
242
|
+
/** Spans a trace command reads a request: the API's most. */
|
|
243
|
+
const TRACE_PAGE = 500;
|
|
244
|
+
/** The span list of an OTLP page, as the API writes it: one resource, one scope. */
|
|
245
|
+
function otlpSpans(otlp) {
|
|
246
|
+
const scope = otlp.resourceSpans[0]
|
|
247
|
+
?.scopeSpans?.[0];
|
|
248
|
+
if (!scope)
|
|
249
|
+
return [];
|
|
250
|
+
scope.spans ??= [];
|
|
251
|
+
return scope.spans;
|
|
252
|
+
}
|
|
253
|
+
/** Where --export sends OTLP: --endpoint, else the OpenTelemetry SDK's own
|
|
254
|
+
* variables; a base URL gets /v1/traces, as an OTLP/HTTP exporter adds it. */
|
|
255
|
+
export function otlpTarget(endpoint, env, headers) {
|
|
256
|
+
const full = endpoint ?? env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT;
|
|
257
|
+
const base = endpoint ? undefined : env.OTEL_EXPORTER_OTLP_ENDPOINT;
|
|
258
|
+
const url = full
|
|
259
|
+
? endpoint && !/\/v1\/traces\/?$/.test(endpoint)
|
|
260
|
+
? `${endpoint.replace(/\/+$/, "")}/v1/traces`
|
|
261
|
+
: full
|
|
262
|
+
: base
|
|
263
|
+
? `${base.replace(/\/+$/, "")}/v1/traces`
|
|
264
|
+
: null;
|
|
265
|
+
if (!url)
|
|
266
|
+
return null;
|
|
267
|
+
const fromEnv = {};
|
|
268
|
+
for (const pair of (env.OTEL_EXPORTER_OTLP_TRACES_HEADERS ??
|
|
269
|
+
env.OTEL_EXPORTER_OTLP_HEADERS ??
|
|
270
|
+
"").split(",")) {
|
|
271
|
+
const at = pair.indexOf("=");
|
|
272
|
+
if (at > 0)
|
|
273
|
+
fromEnv[decodeURIComponent(pair.slice(0, at).trim())] = decodeURIComponent(pair.slice(at + 1).trim());
|
|
274
|
+
}
|
|
275
|
+
return { url, headers: { ...fromEnv, ...headers } };
|
|
276
|
+
}
|
|
194
277
|
export async function agentsCommand(argv, env, out, client, kit) {
|
|
195
278
|
const { parse, flag, has, need, pairs, table, usage, unknown } = kit;
|
|
196
279
|
const [verb, ...rest] = argv;
|
|
@@ -337,6 +420,98 @@ export async function agentsCommand(argv, env, out, client, kit) {
|
|
|
337
420
|
print(read.data.map(line).join("\n") || "No events yet.", read);
|
|
338
421
|
return 0;
|
|
339
422
|
}
|
|
423
|
+
case "trace": {
|
|
424
|
+
const args = parse(rest, ["otlp", "export"], ["endpoint", "header"]);
|
|
425
|
+
const id = need(args.positional[0], "a session's id");
|
|
426
|
+
if (has(args, "export")) {
|
|
427
|
+
const target = otlpTarget(flag(args, "endpoint"), env, args.flags.has("header") ? pairs(args, "header") : {});
|
|
428
|
+
if (!target)
|
|
429
|
+
throw usage("Give --endpoint, or set OTEL_EXPORTER_OTLP_ENDPOINT: where your collector takes OTLP/HTTP.");
|
|
430
|
+
// One export request a page: the collector joins them by trace id.
|
|
431
|
+
let spans = 0;
|
|
432
|
+
for (let after = 0; after !== null;) {
|
|
433
|
+
const { nextAfter, ...otlp } = await api.sessions.trace(id, {
|
|
434
|
+
format: "otlp",
|
|
435
|
+
after,
|
|
436
|
+
limit: TRACE_PAGE,
|
|
437
|
+
});
|
|
438
|
+
const sent = await fetch(target.url, {
|
|
439
|
+
method: "POST",
|
|
440
|
+
headers: { "content-type": "application/json", ...target.headers },
|
|
441
|
+
body: JSON.stringify(otlp),
|
|
442
|
+
});
|
|
443
|
+
if (!sent.ok) {
|
|
444
|
+
out.error(`${target.url} returned ${sent.status}: ${(await sent.text()).slice(0, 500)}`);
|
|
445
|
+
return 1;
|
|
446
|
+
}
|
|
447
|
+
spans += otlpSpans(otlp).length;
|
|
448
|
+
after = nextAfter;
|
|
449
|
+
}
|
|
450
|
+
print(`Sent ${spans} spans to ${target.url}.`, { sent: spans, url: target.url });
|
|
451
|
+
return 0;
|
|
452
|
+
}
|
|
453
|
+
if (has(args, "otlp")) {
|
|
454
|
+
// Every page's spans in one ExportTraceServiceRequest.
|
|
455
|
+
let whole;
|
|
456
|
+
for (let after = 0; after !== null;) {
|
|
457
|
+
const page = await api.sessions.trace(id, {
|
|
458
|
+
format: "otlp",
|
|
459
|
+
after,
|
|
460
|
+
limit: TRACE_PAGE,
|
|
461
|
+
});
|
|
462
|
+
if (whole)
|
|
463
|
+
otlpSpans(whole).push(...otlpSpans(page));
|
|
464
|
+
else
|
|
465
|
+
whole = page;
|
|
466
|
+
after = page.nextAfter;
|
|
467
|
+
}
|
|
468
|
+
const { nextAfter: _, ...otlp } = whole;
|
|
469
|
+
out.write(JSON.stringify(otlp));
|
|
470
|
+
return 0;
|
|
471
|
+
}
|
|
472
|
+
const trace = await api.sessions.trace(id, { limit: TRACE_PAGE });
|
|
473
|
+
for (let after = trace.nextAfter; after !== null;) {
|
|
474
|
+
const page = await api.sessions.trace(id, { after, limit: TRACE_PAGE });
|
|
475
|
+
trace.spans.push(...page.spans);
|
|
476
|
+
after = trace.nextAfter = page.nextAfter;
|
|
477
|
+
}
|
|
478
|
+
const t = trace.totals;
|
|
479
|
+
print([
|
|
480
|
+
`${count(t.turns)} turns, ${count(t.toolCalls)} tool calls, ${dollars(t.costUsd)}${t.unpricedTurns ? ` (${t.unpricedTurns} turns unpriced)` : ""}`,
|
|
481
|
+
`${count(t.inputTokens)} in, ${count(t.outputTokens)} out, ${count(t.cacheReadTokens)} cache read, ${count(t.cacheWriteTokens)} cache write; ${seconds(t.modelMs)} in the model, ${seconds(t.toolMs)} in tools`,
|
|
482
|
+
"",
|
|
483
|
+
trace.models.length
|
|
484
|
+
? table([
|
|
485
|
+
["MODEL", "TURNS", "IN", "OUT", "CACHE READ", "COST"],
|
|
486
|
+
...trace.models.map((m) => [
|
|
487
|
+
m.model,
|
|
488
|
+
count(m.turns),
|
|
489
|
+
count(m.inputTokens),
|
|
490
|
+
count(m.outputTokens),
|
|
491
|
+
count(m.cacheReadTokens),
|
|
492
|
+
m.unpricedTurns === m.turns ? "unpriced" : dollars(m.costUsd),
|
|
493
|
+
]),
|
|
494
|
+
])
|
|
495
|
+
: "No turns yet.",
|
|
496
|
+
...(trace.tools.length
|
|
497
|
+
? [
|
|
498
|
+
"",
|
|
499
|
+
table([
|
|
500
|
+
["TOOL", "CALLS", "FAILED", "TIME"],
|
|
501
|
+
...trace.tools.map((k) => [
|
|
502
|
+
k.name,
|
|
503
|
+
count(k.calls),
|
|
504
|
+
count(k.failed),
|
|
505
|
+
seconds(k.durationMs),
|
|
506
|
+
]),
|
|
507
|
+
]),
|
|
508
|
+
]
|
|
509
|
+
: []),
|
|
510
|
+
"",
|
|
511
|
+
...trace.spans.map((x) => `${String(x.seq).padStart(4)} ${x.startedAt} ${x.kind.padEnd(4)} ${x.kind === "turn" ? turnLine(x) : toolLine(x)}`),
|
|
512
|
+
].join("\n"), trace);
|
|
513
|
+
return 0;
|
|
514
|
+
}
|
|
340
515
|
case "sessions": {
|
|
341
516
|
if (rest[0] === "delete" || rest[0] === "rm") {
|
|
342
517
|
const target = need(rest[1], "a session's id");
|
|
@@ -406,11 +581,50 @@ export async function agentsCommand(argv, env, out, client, kit) {
|
|
|
406
581
|
print(`${answered.id} answered; ${answered.sessions.filter((x) => x.state === "answered").length} session(s) woken.`, answered);
|
|
407
582
|
return 0;
|
|
408
583
|
}
|
|
584
|
+
case "approve":
|
|
585
|
+
case "deny": {
|
|
586
|
+
const args = parse(rest, [], verb === "deny" ? ["message"] : []);
|
|
587
|
+
const id = need(args.positional[0], "an ask's id");
|
|
588
|
+
const message = verb === "deny" ? flag(args, "message") : undefined;
|
|
589
|
+
const answered = verb === "approve" ? await api.asks.approve(id) : await api.asks.deny(id, message);
|
|
590
|
+
print(`${answered.id}: ${answered.toolCall?.tool ?? "the call"} ${verb === "approve" ? "allowed" : "denied"}.`, answered);
|
|
591
|
+
return 0;
|
|
592
|
+
}
|
|
409
593
|
case "stop": {
|
|
410
594
|
const session = await (await api.session(need(rest[0], "a session's id"))).stop();
|
|
411
595
|
print(`${session.id} ${session.state}.`, session);
|
|
412
596
|
return 0;
|
|
413
597
|
}
|
|
598
|
+
case "switch": {
|
|
599
|
+
const platform = need(rest[0], "the platform to switch from: anthropic");
|
|
600
|
+
if (platform !== "anthropic")
|
|
601
|
+
throw usage(`runtime agents switch takes anthropic (Claude Managed Agents); ${platform} is not available yet.`);
|
|
602
|
+
const { baseURL } = await api.anthropic();
|
|
603
|
+
const modelKey = (await secrets(transport).list()).find((s) => s.name === "ANTHROPIC_API_KEY");
|
|
604
|
+
const value = {
|
|
605
|
+
platform,
|
|
606
|
+
baseURL,
|
|
607
|
+
modelKey: modelKey ? { name: modelKey.name, hosts: modelKey.hosts } : null,
|
|
608
|
+
docs: SWITCH_DOCS,
|
|
609
|
+
};
|
|
610
|
+
print([
|
|
611
|
+
"Claude Managed Agents code runs on Runtime with its client's base URL and key changed:",
|
|
612
|
+
"",
|
|
613
|
+
` new Anthropic({ baseURL: "${baseURL}", apiKey: process.env.RUNTIME_API_KEY })`,
|
|
614
|
+
` anthropic.Anthropic(base_url="${baseURL}", api_key=os.environ["RUNTIME_API_KEY"])`,
|
|
615
|
+
"",
|
|
616
|
+
modelKey
|
|
617
|
+
? `Model key: ANTHROPIC_API_KEY is set (${modelKey.hosts.join(", ")}); sessions use it.`
|
|
618
|
+
: [
|
|
619
|
+
"Model key: ANTHROPIC_API_KEY is not set. Agents run on your own Anthropic key;",
|
|
620
|
+
"store it once, and the sandbox never sees it:",
|
|
621
|
+
' printf %s "$ANTHROPIC_API_KEY" | runtime secrets set ANTHROPIC_API_KEY --host api.anthropic.com',
|
|
622
|
+
].join("\n"),
|
|
623
|
+
`What maps and what does not: ${SWITCH_DOCS}`,
|
|
624
|
+
"",
|
|
625
|
+
].join("\n"), value);
|
|
626
|
+
return 0;
|
|
627
|
+
}
|
|
414
628
|
case "triggers": {
|
|
415
629
|
const [sub, ...more] = rest;
|
|
416
630
|
if (sub === "add") {
|
|
@@ -546,10 +760,13 @@ export async function agentsCommand(argv, env, out, client, kit) {
|
|
|
546
760
|
"start",
|
|
547
761
|
"send",
|
|
548
762
|
"events",
|
|
763
|
+
"trace",
|
|
549
764
|
"sessions",
|
|
550
765
|
"stop",
|
|
551
766
|
"asks",
|
|
552
767
|
"answer",
|
|
768
|
+
"approve",
|
|
769
|
+
"deny",
|
|
553
770
|
"triggers",
|
|
554
771
|
"memory",
|
|
555
772
|
]);
|
package/dist/ci-cli.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { CliKit } from "./cli.js";
|
|
2
2
|
import type { Runtime } from "./client.js";
|
|
3
|
+
import { type CiAnnotation } from "./products/ci.js";
|
|
3
4
|
type Out = {
|
|
4
5
|
json: boolean;
|
|
5
6
|
write: (text: string) => void;
|
|
6
7
|
error: (text: string) => void;
|
|
7
8
|
};
|
|
8
|
-
export declare const CI_HELP = "runtime ci <command>\n\n CI/CD checks each push and pull request of a connected GitHub repository in\n sandboxes, as the steps its config file names. A fork's pull request runs\n nothing; a writer can open it again from a branch of the repository. In a\n private beta: outside it, each command says how to ask to join.\n\n import [dir] [--write] [--force] This folder's GitHub Actions workflows and CircleCI\n config as a runtime.yml: printed, or written with\n --write; what isn't carried over is noted at its top.\n Needs no key and sends nothing\n connect <owner/name> [--branch main] [--config runtime.yml] [--installation <id>]\n [--trust <app-slug>[bot]]... [--name <name>]\n Connect a repository; prints its id. Takes a full key.\n --trust runs that App's pushes as its own from the start\n repos [ls] [--all] Connected repositories, with the Apps each trusts;\n --all: disconnected ones too\n repos trust <repoId | owner/name> <app-slug>[bot]...\n Run that App's pushes as the repository's own code,\n keeping the Apps it trusts already\n repos untrust <repoId | owner/name> <app-slug>[bot]...\n Stop trusting those Apps, keeping the rest\n repos undo <repoId | owner/name> on|off When main's check fails, find the first commit that\n fails it and open a pull request reverting it, which\n lands once its check passes. Off until turned on;\n takes an owner's or admin's full key\n disconnect <repoId | owner/name> Stop checking it; its checks still going are cancelled\n checks [--repository <repoId>] [--branch <name>] [--commit <sha>] [--pr <number>]\n [--state <state>]... [--limit 20] Checks, newest first, with their jobs by state (or ls)\n check <checkId> One check and its jobs in plan order (or get)\n cancel <checkId> Cancel a queued or running check: its jobs end,\n its machines are let go, GitHub is told\n rerun <checkId> Run a check again: a new check of its commit, a\n pull request's as it would land now\n logs <jobId> A job's output, its last 256 KiB, and its sandboxes\n tests <repoId> [--quarantined] Its test files: time, recent outcomes, quarantine\n flakes [--repository <repoId>] [--all] Flaky tests: each quarantined (or still gating), its\n owner and 48-hour deadline; --all: ended ones too\n flake <flakeId> One flaky test: its proof, owner, and recent runs\n flake prove <flakeId> Its 100 proof runs again at main's next commit\n flake hand <flakeId> <login | org/team> Hand it to someone else\n flake delete <flakeId> --reason <why> Say why its test is deleted; it ends once main\n no longer holds the file\n releases [--repository <repoId>] [--commit <sha>] [--limit 50]\n A release's steps as they were taken, oldest\n first: migrations, deploys, servers, waits\n\n A failed job's sandbox may be kept paused: `runtime sandboxes wake <id>`, then\n `runtime sandboxes shell <id>` to look around where it failed. A key reads the\n checks of repositories its own agent connected; an account-wide key reads and\n cancels every check of the account (switch one at withruntime.com/account/keys).\n\nExamples\n runtime ci import --write\n runtime ci connect acme/web --config .runtime/ci.yml\n runtime ci repos trust acme/web acme-bot[bot]\n runtime ci repos undo acme/web on\n runtime ci checks --commit $(git rev-parse HEAD)\n runtime ci cancel <checkId>\n runtime ci logs <jobId>\n";
|
|
9
|
+
export declare const CI_HELP = "runtime ci <command>\n\n CI/CD checks each push and pull request of a connected GitHub repository in\n sandboxes, as the steps its config file names. A fork's pull request runs\n nothing; a writer can open it again from a branch of the repository. In a\n private beta: outside it, each command says how to ask to join.\n\n import [dir] [--write] [--force] This folder's GitHub Actions workflows and CircleCI\n config as a runtime.yml: printed, or written with\n --write; what isn't carried over is noted at its top.\n Needs no key and sends nothing\n connect <owner/name> [--branch main] [--config runtime.yml] [--installation <id>]\n [--trust <app-slug>[bot]]... [--name <name>]\n Connect a repository; prints its id. Takes a full key.\n --config cloudbuild.yaml or buildspec.yml runs a Google\n Cloud Build or AWS CodeBuild config as it is.\n --trust runs that App's pushes as its own from the start\n repos [ls] [--all] Connected repositories, with the Apps each trusts;\n --all: disconnected ones too\n repos trust <repoId | owner/name> <app-slug>[bot]...\n Run that App's pushes as the repository's own code,\n keeping the Apps it trusts already\n repos untrust <repoId | owner/name> <app-slug>[bot]...\n Stop trusting those Apps, keeping the rest\n repos undo <repoId | owner/name> on|off When main's check fails, find the first commit that\n fails it and open a pull request reverting it, which\n lands once its check passes. Off until turned on;\n takes an owner's or admin's full key\n disconnect <repoId | owner/name> Stop checking it; its checks still going are cancelled\n checks [--repository <repoId>] [--branch <name>] [--commit <sha>] [--pr <number>]\n [--state <state>]... [--limit 20] Checks, newest first, with their jobs by state (or ls)\n check <checkId> One check and its jobs in plan order (or get)\n cancel <checkId> Cancel a queued or running check: its jobs end,\n its machines are let go, GitHub is told\n rerun <checkId> Run a check again: a new check of its commit, a\n pull request's as it would land now\n logs <jobId> A job's output, its last 256 KiB, and its sandboxes\n tests <repoId> [--quarantined] Its test files: time, recent outcomes, quarantine\n flakes [--repository <repoId>] [--all] Flaky tests: each quarantined (or still gating), its\n owner and 48-hour deadline; --all: ended ones too\n flake <flakeId> One flaky test: its proof, owner, and recent runs\n flake prove <flakeId> Its 100 proof runs again at main's next commit\n flake hand <flakeId> <login | org/team> Hand it to someone else\n flake delete <flakeId> --reason <why> Say why its test is deleted; it ends once main\n no longer holds the file\n releases [--repository <repoId>] [--commit <sha>] [--limit 50]\n A release's steps as they were taken, oldest\n first: migrations, deploys, servers, waits\n\n A failed job's sandbox may be kept paused: `runtime sandboxes wake <id>`, then\n `runtime sandboxes shell <id>` to look around where it failed. A key reads the\n checks of repositories its own agent connected; an account-wide key reads and\n cancels every check of the account (switch one at withruntime.com/account/keys).\n\nExamples\n runtime ci import --write\n runtime ci connect acme/web --config .runtime/ci.yml\n runtime ci repos trust acme/web acme-bot[bot]\n runtime ci repos undo acme/web on\n runtime ci checks --commit $(git rev-parse HEAD)\n runtime ci cancel <checkId>\n runtime ci logs <jobId>\n";
|
|
9
10
|
export declare function ciCommand(argv: string[], out: Out, client: () => Promise<Runtime>, kit: CliKit): Promise<number>;
|
|
11
|
+
/** An agent step's verdict in words: each finding with its place and fix,
|
|
12
|
+
* then the notes, then who judged. */
|
|
13
|
+
/** A job's annotations as `path:line:col: level: title: message`, each
|
|
14
|
+
* message's first line, the way compilers print them. */
|
|
15
|
+
export declare function annotated(lines: CiAnnotation[]): string;
|
|
10
16
|
export {};
|
package/dist/ci-cli.js
CHANGED
|
@@ -17,6 +17,8 @@ export const CI_HELP = `runtime ci <command>
|
|
|
17
17
|
connect <owner/name> [--branch main] [--config runtime.yml] [--installation <id>]
|
|
18
18
|
[--trust <app-slug>[bot]]... [--name <name>]
|
|
19
19
|
Connect a repository; prints its id. Takes a full key.
|
|
20
|
+
--config cloudbuild.yaml or buildspec.yml runs a Google
|
|
21
|
+
Cloud Build or AWS CodeBuild config as it is.
|
|
20
22
|
--trust runs that App's pushes as its own from the start
|
|
21
23
|
repos [ls] [--all] Connected repositories, with the Apps each trusts;
|
|
22
24
|
--all: disconnected ones too
|
|
@@ -104,8 +106,13 @@ async function importCommand(argv, out, kit) {
|
|
|
104
106
|
const circle = join(root, ".circleci", "config.yml");
|
|
105
107
|
if (existsSync(circle))
|
|
106
108
|
files.push({ path: ".circleci/config.yml", text: readFileSync(circle, "utf8") });
|
|
107
|
-
if (!files.length)
|
|
109
|
+
if (!files.length) {
|
|
110
|
+
// Cloud Build and CodeBuild configs run as they are: nothing to import.
|
|
111
|
+
const vendor = ["cloudbuild.yaml", "cloudbuild.yml", "buildspec.yml", "buildspec.yaml"].find((name) => existsSync(join(root, name)));
|
|
112
|
+
if (vendor)
|
|
113
|
+
throw kit.usage(`${vendor} needs no import: CI/CD runs it as it is. Connect with ${me} ci connect <owner/name> --config ${vendor}, or add "- ${vendor.startsWith("cloudbuild") ? "cloudbuild" : "buildspec"}: ${vendor}" to runtime.yml's steps.`);
|
|
108
114
|
throw kit.usage(`${root} has neither .github/workflows/*.yml nor .circleci/config.yml to import.`);
|
|
115
|
+
}
|
|
109
116
|
const made = importCi(files);
|
|
110
117
|
if (!made.yaml) {
|
|
111
118
|
out.error(made.notes.join("\n"));
|
|
@@ -332,6 +339,9 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
332
339
|
out.write(job.log.endsWith("\n") || !job.log ? job.log : `${job.log}\n`);
|
|
333
340
|
if (job.review)
|
|
334
341
|
out.write(reviewed(job.review));
|
|
342
|
+
// An API before annotations sends none.
|
|
343
|
+
if (job.annotations?.length)
|
|
344
|
+
out.write(annotated(job.annotations));
|
|
335
345
|
out.error(`[${job.name}${job.parts > 1 ? ` ${job.part}/${job.parts}` : ""} ${job.state}${job.exitCode === null ? "" : `, exit code ${job.exitCode}`}${job.reason ? `, ${job.reason}` : ""}]`);
|
|
336
346
|
if (job.state === "failed" && job.sandboxIds.length)
|
|
337
347
|
out.error(`Its sandbox may be kept paused, to look into: ${me} sandboxes wake ${job.sandboxIds[0]}, then ${me} sandboxes shell ${job.sandboxIds[0]}`);
|
|
@@ -462,6 +472,20 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
462
472
|
}
|
|
463
473
|
/** An agent step's verdict in words: each finding with its place and fix,
|
|
464
474
|
* then the notes, then who judged. */
|
|
475
|
+
/** A job's annotations as `path:line:col: level: title: message`, each
|
|
476
|
+
* message's first line, the way compilers print them. */
|
|
477
|
+
export function annotated(lines) {
|
|
478
|
+
const failing = lines.filter((a) => a.level === "failure").length;
|
|
479
|
+
return [
|
|
480
|
+
`\n${lines.length} line${lines.length === 1 ? "" : "s"} of the repository's files${failing ? `, ${failing} failing` : ""}:`,
|
|
481
|
+
...lines.map((a) => {
|
|
482
|
+
const at = `${a.path}:${a.startLine}${a.startColumn ? `:${a.startColumn}` : ""}`;
|
|
483
|
+
const first = a.message.split("\n")[0];
|
|
484
|
+
return ` ${at}: ${a.level}: ${a.title ? `${a.title}: ` : ""}${first}`;
|
|
485
|
+
}),
|
|
486
|
+
"",
|
|
487
|
+
].join("\n");
|
|
488
|
+
}
|
|
465
489
|
function reviewed(r) {
|
|
466
490
|
const at = (f) => (f.line > 0 ? `${f.file}:${f.line}` : f.file);
|
|
467
491
|
return [
|
package/dist/cli.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ type Args = {
|
|
|
18
18
|
rest: string[] | undefined;
|
|
19
19
|
};
|
|
20
20
|
/** What the commands in cli-extras.ts use of this file. */
|
|
21
|
-
declare const kit: {
|
|
21
|
+
export declare const kit: {
|
|
22
22
|
parse: (argv: string[], booleans: readonly string[], values: readonly string[]) => Args;
|
|
23
23
|
flag: (args: Args, name: string) => string | undefined;
|
|
24
24
|
has: (args: Args, name: string) => boolean;
|
package/dist/cli.js
CHANGED
|
@@ -392,7 +392,7 @@ const envPairs = (args, from) => Object.fromEntries((args.flags.get("env") ?? []
|
|
|
392
392
|
return [pair, value];
|
|
393
393
|
}));
|
|
394
394
|
/** What the commands in cli-extras.ts use of this file. */
|
|
395
|
-
const kit = {
|
|
395
|
+
export const kit = {
|
|
396
396
|
parse: (argv, booleans, values) => parse(argv, booleans, values),
|
|
397
397
|
flag,
|
|
398
398
|
has,
|
|
@@ -3998,6 +3998,15 @@ const JOB_HELP = `runtime jobs <command>
|
|
|
3998
3998
|
[--alert-webhook <url> [--alert-secret NAME]] [--alert-email] [--alert-after <runs>] [--no-alert]
|
|
3999
3999
|
[-- <command...>] Change it in place: the next run uses it; history stays.
|
|
4000
4000
|
--secret and --volume replace the whole list
|
|
4001
|
+
deploy [<dir>] [--name <project>] [--dry-run]
|
|
4002
|
+
Run Trigger.dev tasks and Inngest functions written
|
|
4003
|
+
against withruntime/trigger or withruntime/inngest as
|
|
4004
|
+
jobs: crons on their schedule, the rest on demand
|
|
4005
|
+
import <file>... [--parameter NAME=VALUE]... [--cron ..] [--dry-run]
|
|
4006
|
+
Move jobs from Google Cloud Run (job YAML and its Cloud
|
|
4007
|
+
Scheduler job) or AWS Batch (job definition and its
|
|
4008
|
+
EventBridge schedule): same image, command, size and
|
|
4009
|
+
schedule. \`jobs import help\` says more
|
|
4001
4010
|
ls Your jobs: state, schedule and next run
|
|
4002
4011
|
get <id> One job, in full
|
|
4003
4012
|
runs <id> [--all] Its newest 100 runs (--all: every one, oldest first)
|
|
@@ -4018,6 +4027,8 @@ Examples
|
|
|
4018
4027
|
runtime jobs trigger <jobId> && runtime jobs logs <jobId> -f
|
|
4019
4028
|
runtime jobs reschedule <jobId> --cron "30 4 * * 1-5" --timezone Europe/Berlin
|
|
4020
4029
|
runtime jobs update <jobId> --image hub:latest --alert-webhook https://example.com/hook --alert-after 3
|
|
4030
|
+
runtime jobs import job.yaml scheduler.yaml
|
|
4031
|
+
runtime jobs import template.yaml --parameter AWS::Region=us-east-1 --dry-run
|
|
4021
4032
|
`;
|
|
4022
4033
|
/** The `--alert-*` flags of create and update, as a job's alert; undefined
|
|
4023
4034
|
* when none is given. The secret is a jobs secret, by name. */
|
|
@@ -4084,6 +4095,10 @@ async function jobCommand(argv, env, out) {
|
|
|
4084
4095
|
print(named(JOB_HELP), { usage: named(JOB_HELP) });
|
|
4085
4096
|
return 0;
|
|
4086
4097
|
}
|
|
4098
|
+
if (verb === "import")
|
|
4099
|
+
return (await import("./jobs-import.js")).jobsImportCommand(rest, out, () => client(env), kit);
|
|
4100
|
+
if (verb === "deploy")
|
|
4101
|
+
return (await import("./jobs-deploy.js")).jobsDeployCommand(rest, out, () => client(env), kit);
|
|
4087
4102
|
const runtime = await client(env);
|
|
4088
4103
|
const api = runtime.jobs;
|
|
4089
4104
|
switch (verb) {
|
package/dist/errors.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const DELIBERATE: ReadonlySet<string>;
|
|
|
15
15
|
export declare const NOTHING_RAN: ReadonlySet<string>;
|
|
16
16
|
/** Refusals of a create that clear when a sandbox stops or pauses, or a host
|
|
17
17
|
* frees room: an account without credit's four at once and its total, an
|
|
18
|
-
* email domain's, the account's quota and the region's capacity. `sandboxes.create` waits them out, retrying
|
|
18
|
+
* email domain's, the account's quota, its share of the region's servers and the region's capacity. `sandboxes.create` waits them out, retrying
|
|
19
19
|
* with the same key and input, for up to `waitForCapacityMs`. */
|
|
20
20
|
export declare const WAITS_FOR_ROOM: ReadonlySet<string>;
|
|
21
21
|
export declare class RuntimeError extends Error {
|
package/dist/errors.js
CHANGED
|
@@ -36,7 +36,7 @@ export const NOTHING_RAN = new Set(["guest_busy", "busy", "rate_limited"]);
|
|
|
36
36
|
const PASSING = new Set(["no_capacity", "no_credit_running_limit", "no_credit_total_limit"]);
|
|
37
37
|
/** Refusals of a create that clear when a sandbox stops or pauses, or a host
|
|
38
38
|
* frees room: an account without credit's four at once and its total, an
|
|
39
|
-
* email domain's, the account's quota and the region's capacity. `sandboxes.create` waits them out, retrying
|
|
39
|
+
* email domain's, the account's quota, its share of the region's servers and the region's capacity. `sandboxes.create` waits them out, retrying
|
|
40
40
|
* with the same key and input, for up to `waitForCapacityMs`. */
|
|
41
41
|
export const WAITS_FOR_ROOM = new Set([
|
|
42
42
|
"no_credit_running_limit",
|
|
@@ -44,6 +44,9 @@ export const WAITS_FOR_ROOM = new Set([
|
|
|
44
44
|
"no_credit_domain_limit",
|
|
45
45
|
"no_credit_capacity_full",
|
|
46
46
|
"quota_exceeded",
|
|
47
|
+
// The account holds its share of every server that could run it: clears
|
|
48
|
+
// as its own sandboxes end.
|
|
49
|
+
"account_share_full",
|
|
47
50
|
"no_capacity",
|
|
48
51
|
// A volume whose last sandbox is stopping: free once the stop lets go of
|
|
49
52
|
// its disk, up to about a minute (measured 50 to 60 s, 6 October 2026).
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type { FileEvent, FileEventType, WatchHandle, WatchNotice, WatchOptions,
|
|
|
25
25
|
export type { Mount, MountBucket } from "./products/mounts.js";
|
|
26
26
|
export type { TailscaleJoin, TailscaleJoined, TailscaleNode, TailscaleStatus, } from "./products/tailscale.js";
|
|
27
27
|
export type { Volume, VolumeBackup, VolumeBackupKeep, VolumeBackupSchedule, CreateVolume, VolumeAttachment, } from "./products/volumes.js";
|
|
28
|
-
export type { CreateJob, Job, JobAlert, JobAlertDelivery, JobCompute, JobDefinition, JobLogs, JobRun, JobRunState, JobSchedule, UpdateJob, } from "./products/jobs.js";
|
|
28
|
+
export type { CreateJob, Job, JobAlert, JobAlertDelivery, JobCompute, JobDefinition, JobImportJob, JobImportPlan, JobImportRequest, JobImportSchedule, JobLogs, JobRun, JobRunState, JobSchedule, UpdateJob, } from "./products/jobs.js";
|
|
29
29
|
export type { CheckedDomain, DnsRecord, Domain, EgressAddress, TcpPort, Tunnel as PrivateTunnel, TunnelPeer, TunnelPeerCreated, SetUpstreamProxy, UpstreamProxy, } from "./products/network-products.js";
|
|
30
30
|
export type { PrivateNetwork } from "./products/private-network.js";
|
|
31
31
|
export type { SignedRequests } from "./products/signed-requests.js";
|
|
@@ -78,10 +78,10 @@ export { openWalletAccount, claimWalletAccount, rekeyWalletAccount, type OpenedW
|
|
|
78
78
|
export type { Topup } from "./products/billing.js";
|
|
79
79
|
export type { NewKey, LimitedKey, LimitedKeyAction, MadeKey, ListedKey, KeyUsage, } from "./products/api-keys.js";
|
|
80
80
|
export type { SsoConnection, SsoStatus } from "./products/sso.js";
|
|
81
|
-
export type { Agent, AgentAsk, AgentAskState, AgentDefinition, AgentEvent, AgentHeldCall, AgentMemoryEntry, AgentMemoryFile, AgentMemoryHit, AgentMemoryPage, AgentMemoryUsage, AgentMemoryWritten, AgentSession, AgentSessionHandle, AgentSessionState, AgentTemplate, AgentTemplateKey, AgentTrigger, AgentTriggerCall, AgentTriggerCallOutcome, AgentTriggerKind, AgentTriggerRules, AgentUse, AnswerAgentAsk, CreateAgent, CreateAgentTrigger, ListAgentAsks, StartAgentSession, } from "./products/agents.js";
|
|
81
|
+
export type { Agent, AgentAsk, AgentAskState, AgentDefinition, AgentEvent, AgentHeldCall, AgentMemoryEntry, AgentMemoryFile, AgentMemoryHit, AgentMemoryPage, AgentMemoryUsage, AgentMemoryWritten, AgentPermissionPolicy, AgentPermissions, AgentSession, AgentSessionHandle, AgentSessionState, AgentTemplate, AgentTemplateKey, AgentAskToolCall, AgentTokens, AgentToolCall, AgentTrace, AgentTraceOtlp, AgentTracePage, AgentTrigger, AgentTriggerCall, AgentTriggerCallOutcome, AgentTriggerKind, AgentTriggerRules, AgentTurn, AgentUse, AnswerAgentAsk, CreateAgent, CreateAgentTrigger, ListAgentAsks, StartAgentSession, } from "./products/agents.js";
|
|
82
82
|
export { AGENT_TEMPLATES, AGENT_USES } from "./products/agents.js";
|
|
83
83
|
export type { AgentsDeployChange, AgentsDeployOptions, AgentsDeployResult, AgentsFile, AgentsFileAgent, AgentsFileTrigger, AgentsSource, } from "./agents-deploy.js";
|
|
84
84
|
export type { Container, ContainerState, CreateContainer, UpdateContainer, } from "./products/containers.js";
|
|
85
85
|
export type { Browser, BrowserConnectOptions, BrowserInfo, BrowserScreenshot, BrowserScreenshotResult, CreateBrowser, UpdateBrowser, } from "./products/browsers.js";
|
|
86
86
|
export type { CreateDesktop, Desktop, DesktopAct, DesktopState, UpdateDesktop, } from "./products/desktops.js";
|
|
87
|
-
export type { CiFlake, CiFlakeDetail, CiReleaseStep, CiRepository, CiTestResult, ConnectCiRepository, ListCiFlakes, ListCiReleaseSteps, ListCiRepositories, UpdateCiFlake, } from "./products/ci.js";
|
|
87
|
+
export type { CiAnnotation, CiFlake, CiFlakeDetail, CiReleaseStep, CiRepository, CiTestResult, ConnectCiRepository, ListCiFlakes, ListCiReleaseSteps, ListCiRepositories, UpdateCiFlake, } from "./products/ci.js";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export declare class NonRetriableError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export declare class RetryAfterError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export declare class CompatibilityError extends Error {
|
|
6
|
+
readonly code = "not_supported";
|
|
7
|
+
}
|
|
8
|
+
export type EventPayload = {
|
|
9
|
+
name: string;
|
|
10
|
+
data?: unknown;
|
|
11
|
+
id?: string;
|
|
12
|
+
ts?: number;
|
|
13
|
+
user?: unknown;
|
|
14
|
+
};
|
|
15
|
+
type Trigger = {
|
|
16
|
+
cron: string;
|
|
17
|
+
} | {
|
|
18
|
+
event: string;
|
|
19
|
+
if?: string;
|
|
20
|
+
};
|
|
21
|
+
type FunctionOptions = {
|
|
22
|
+
id: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
retries?: number;
|
|
25
|
+
timeouts?: {
|
|
26
|
+
start?: string;
|
|
27
|
+
finish?: string;
|
|
28
|
+
};
|
|
29
|
+
[option: string]: unknown;
|
|
30
|
+
};
|
|
31
|
+
/** "30s", "5m", "2h", "1d", "1w", or milliseconds. */
|
|
32
|
+
export declare function durationMs(value: string | number): number;
|
|
33
|
+
/** Inngest's `TZ=Europe/Paris 0 12 * * 5`, as an expression and a zone. */
|
|
34
|
+
export declare function cronOf(text: string): {
|
|
35
|
+
cron: string;
|
|
36
|
+
timezone: string;
|
|
37
|
+
};
|
|
38
|
+
declare function stepTools(client: Inngest): {
|
|
39
|
+
run: <T>(_id: string, fn: () => Promise<T> | T) => Promise<T>;
|
|
40
|
+
sleep: (_id: string, duration: string | number) => Promise<void>;
|
|
41
|
+
sleepUntil: (_id: string, until: Date | string) => Promise<void>;
|
|
42
|
+
sendEvent: (_id: string, events: EventPayload | EventPayload[]) => Promise<{
|
|
43
|
+
ids: string[];
|
|
44
|
+
}>;
|
|
45
|
+
waitForEvent: () => never;
|
|
46
|
+
invoke: () => never;
|
|
47
|
+
ai: {
|
|
48
|
+
infer: () => never;
|
|
49
|
+
wrap: <T>(_id: string, fn: (...a: unknown[]) => T, ...args: unknown[]) => Promise<T>;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
type Handler = (context: {
|
|
53
|
+
event: EventPayload;
|
|
54
|
+
events: EventPayload[];
|
|
55
|
+
step: ReturnType<typeof stepTools>;
|
|
56
|
+
logger: Pick<Console, "info" | "warn" | "error" | "debug">;
|
|
57
|
+
runId: string;
|
|
58
|
+
attempt: number;
|
|
59
|
+
}) => unknown;
|
|
60
|
+
export type InngestFunction = {
|
|
61
|
+
id: (prefix?: string) => string;
|
|
62
|
+
name: string;
|
|
63
|
+
triggers: Trigger[];
|
|
64
|
+
};
|
|
65
|
+
export declare class Inngest {
|
|
66
|
+
readonly id: string;
|
|
67
|
+
constructor(options: {
|
|
68
|
+
id: string;
|
|
69
|
+
[option: string]: unknown;
|
|
70
|
+
});
|
|
71
|
+
/** `createFunction(options, trigger, handler)`, or, as Inngest's newer
|
|
72
|
+
* SDKs write it, `createFunction({ ...options, triggers }, handler)`. */
|
|
73
|
+
createFunction(options: FunctionOptions & {
|
|
74
|
+
triggers: Trigger | Trigger[];
|
|
75
|
+
}, handler: Handler): InngestFunction;
|
|
76
|
+
createFunction(options: FunctionOptions, trigger: Trigger | Trigger[], handler: Handler): InngestFunction;
|
|
77
|
+
/** Runs every function of this app triggered by each event's name, once,
|
|
78
|
+
* now, in a fresh sandbox, with the event as its payload. The functions
|
|
79
|
+
* must be imported where this is called (as serve() imports them) and
|
|
80
|
+
* deployed with `runtime jobs deploy`. */
|
|
81
|
+
send(payload: EventPayload | EventPayload[]): Promise<{
|
|
82
|
+
ids: string[];
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
/** serve() of every adapter (inngest/next, /express, /hono, ...): nothing
|
|
86
|
+
* calls the app's endpoint once its functions run as jobs, so it answers 410
|
|
87
|
+
* with where they run now. */
|
|
88
|
+
export declare function serve(_options: {
|
|
89
|
+
client: Inngest;
|
|
90
|
+
functions: InngestFunction[];
|
|
91
|
+
}): (() => Response) & {
|
|
92
|
+
GET: () => Response;
|
|
93
|
+
POST: () => Response;
|
|
94
|
+
PUT: () => Response;
|
|
95
|
+
};
|
|
96
|
+
export {};
|