irida 0.1.0 → 0.1.1
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 +2 -2
- package/bin/irida.js +2 -2
- package/package.json +1 -1
- package/src/cloud.js +8 -1
- package/src/index.js +1 -1
- package/src/mcp.js +7 -7
- package/src/probe.js +8 -1
package/README.md
CHANGED
|
@@ -56,6 +56,6 @@ npx irida prove
|
|
|
56
56
|
|
|
57
57
|
Checks the node end to end with no key and no wallet. It runs a probe in a real sandbox through `POST /v1/try` and judges it from the signed receipt: signature, output hash, per-second billing, the gate refusing an unlisted host and the cloud metadata address (both in the signed gate log), the allowlisted host reached, and no network outside the gate. Then it compares the public copy of the receipt, reads the node's own half-hourly self-check (`/v1/canary`), checks the signed manifest (`/v1/manifest`) and walks one anchored receipt down to the chain.
|
|
58
58
|
|
|
59
|
-
Docs: https://irida.run/docs · Playground: https://irida.run/play · Scan: https://irida.run/scan
|
|
59
|
+
Docs: https://irida.run/docs · Playground: https://irida.run/play · Scan: https://irida.run/scan · X: https://x.com/irida_rh
|
|
60
60
|
|
|
61
|
-
MIT.
|
|
61
|
+
MIT. Based on the MIT-licensed Chronark engine.
|
package/bin/irida.js
CHANGED
|
@@ -50,7 +50,7 @@ The key is added at the gate, outside the sandbox. The receipt lists every
|
|
|
50
50
|
request: host, method, path, bytes, status and a hash of each brokered reply.
|
|
51
51
|
|
|
52
52
|
Cloud mode (--cloud, --cloud <url> or IRIDA_CLOUD; bare --cloud uses IRIDA_CLOUD,\nelse ${DEFAULT_CLOUD}): the command runs in a sandbox
|
|
53
|
-
on
|
|
53
|
+
on an Irida node, paid from your balance there (settlement: ledger). Your
|
|
54
54
|
account is your local key; \`irida account\` prints its id for funding.
|
|
55
55
|
State lives in ~/.irida (IRIDA_HOME).`;
|
|
56
56
|
|
|
@@ -119,7 +119,7 @@ async function runCloud(f, cmd, url) {
|
|
|
119
119
|
const allow = String(f.allow ?? "").split(",").map((x) => x.trim()).filter(Boolean);
|
|
120
120
|
const secrets = resolveSecrets(String(f.secret ?? "").split(",").map((x) => x.trim()).filter(Boolean));
|
|
121
121
|
net = allow.length || secrets.length ? { allow, secrets } : undefined;
|
|
122
|
-
s = await c.open({ worker, budget: f.budget ?? "0.24", net, onTick: (t) => { line = `${warm("⧗")} metering ${String(t.seconds).padStart(4)}s ${bar(t.seconds, t.max)} ${t.cost}`; draw(); } });
|
|
122
|
+
s = await c.open({ worker, budget: f.budget ?? "0.24", fit: f.budget == null, net, onTick: (t) => { line = `${warm("⧗")} metering ${String(t.seconds).padStart(4)}s ${bar(t.seconds, t.max)} ${t.cost}`; draw(); } });
|
|
123
123
|
} catch (e) {
|
|
124
124
|
err(red("✗"), e.message);
|
|
125
125
|
if (e.status === 402) err(dim(` fund your account first: irida account --cloud ${c.url}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "irida",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Per-second compute for agents: run any command locally or in a Irida Cloud sandbox, pay for the seconds it ran, get a signed receipt.",
|
|
5
5
|
"homepage": "https://irida.run",
|
|
6
6
|
"repository": {
|
package/src/cloud.js
CHANGED
|
@@ -37,7 +37,14 @@ export function client(url = process.env.IRIDA_CLOUD, { dir = home() } = {}) {
|
|
|
37
37
|
node: async () => (await fetch(base + "/v1/node").catch((e) => { throw new Error(`cannot reach ${base}: ${e.cause?.code || e.message}`); })).json(),
|
|
38
38
|
balance: () => jsonCall("GET", "/v1/account"),
|
|
39
39
|
// net: { allow: ["api.github.com"], secrets: [{ name, origin, header, value }] } opens the session with a gate
|
|
40
|
-
|
|
40
|
+
// fit: the budget was a default, not the user's choice, so it shrinks to what the account holds (a new account's
|
|
41
|
+
// trial is smaller than the default budget); an amount the user asked for is never lowered
|
|
42
|
+
async open({ worker = "shell", budget, seconds, net, onTick, fit = false } = {}) {
|
|
43
|
+
if (fit && budget != null) {
|
|
44
|
+
const a = await jsonCall("GET", "/v1/account").catch(() => null);
|
|
45
|
+
const micro = (x) => { const [i, f = ""] = String(x).split("."); return BigInt(i || 0) * 1000000n + BigInt((f + "000000").slice(0, 6)); };
|
|
46
|
+
if (a && micro(a.balance) > 0n && micro(a.balance) < micro(budget)) { const b = micro(a.balance); budget = `${b / 1000000n}.${String(b % 1000000n).padStart(6, "0")}`; }
|
|
47
|
+
}
|
|
41
48
|
const s = await jsonCall("POST", "/v1/sessions", { worker, ...(budget != null ? { budget: String(budget) } : {}), ...(seconds != null ? { seconds } : {}), ...(net ? { net } : {}) });
|
|
42
49
|
const opened = Date.parse(s.opened);
|
|
43
50
|
const tick = onTick && setInterval(() => {
|
package/src/index.js
CHANGED
|
@@ -39,7 +39,7 @@ export function quote(seconds, rate = DEFAULT_RATE) {
|
|
|
39
39
|
return fromMicro(BigInt(seconds) * toMicro(rate), 6);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
// open({ cloud: "https://…" }) (or IRIDA_CLOUD set) runs in
|
|
42
|
+
// open({ cloud: "https://…" }) (or IRIDA_CLOUD set) runs in an Irida Cloud sandbox; otherwise local mode.
|
|
43
43
|
export async function open(opts = {}) {
|
|
44
44
|
const url = opts.cloud === true ? undefined : opts.cloud;
|
|
45
45
|
if (opts.cloud || (process.env.IRIDA_CLOUD && opts.cloud !== false)) return cloudClient(url, { dir: opts.dir }).open(opts);
|
package/src/mcp.js
CHANGED
|
@@ -54,7 +54,7 @@ const BUDGET = { type: "string", description: "Most USDG this may spend, e.g. \"
|
|
|
54
54
|
export const TOOLS = [
|
|
55
55
|
{
|
|
56
56
|
name: "irida_run",
|
|
57
|
-
title: "Run code in
|
|
57
|
+
title: "Run code in an Irida sandbox",
|
|
58
58
|
description: "Run a command or a snippet of code in a sealed Irida Cloud sandbox (no network access, empty working directory), billed per second in USDG. " +
|
|
59
59
|
"Returns stdout, stderr, exit code, seconds billed, amount paid and refunded, and a signed receipt that is verified before it is returned. " +
|
|
60
60
|
"Give either `code` (run with the worker's interpreter) or `command` (a shell command line).",
|
|
@@ -67,7 +67,7 @@ export const TOOLS = [
|
|
|
67
67
|
},
|
|
68
68
|
additionalProperties: false,
|
|
69
69
|
},
|
|
70
|
-
annotations: { title: "Run code in
|
|
70
|
+
annotations: { title: "Run code in an Irida sandbox", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
name: "irida_session_open",
|
|
@@ -107,7 +107,7 @@ export const TOOLS = [
|
|
|
107
107
|
{
|
|
108
108
|
name: "irida_verify",
|
|
109
109
|
title: "Verify a receipt",
|
|
110
|
-
description: "Check
|
|
110
|
+
description: "Check an Irida receipt's ed25519 signature over its canonical JSON. Accepts a full session id (0x + 64 hex), a receipt URL, or the receipt JSON itself. Any edited field makes it invalid.",
|
|
111
111
|
inputSchema: { type: "object", properties: { receipt: { type: "string", description: "Session id, receipt URL, or receipt JSON." } }, required: ["receipt"], additionalProperties: false },
|
|
112
112
|
annotations: { title: "Verify a receipt", readOnlyHint: true, openWorldHint: true },
|
|
113
113
|
},
|
|
@@ -159,9 +159,9 @@ export function tools({ url = process.env.IRIDA_CLOUD || DEFAULT_CLOUD, dir, max
|
|
|
159
159
|
return { allow, secrets: resolveSecrets(net.secrets ?? [], dir) };
|
|
160
160
|
}
|
|
161
161
|
async function openSession(worker, budget, net) {
|
|
162
|
-
try { return await c.open({ worker, budget: budgetOf(budget), net: netOf(net) }); }
|
|
162
|
+
try { return await c.open({ worker, budget: budgetOf(budget ?? "0.02"), fit: budget == null, net: netOf(net) }); }
|
|
163
163
|
catch (e) {
|
|
164
|
-
if (e.status === 402) throw new Error(`Not enough balance on ${c.url} for a ${budget} USDG budget. Account ${c.account}. Call irida_account to see the balance and how to fund it.`);
|
|
164
|
+
if (e.status === 402) throw new Error(`Not enough balance on ${c.url} for a ${budget ?? "0.02"} USDG budget. Account ${c.account}. Call irida_account to see the balance and how to fund it.`);
|
|
165
165
|
if (e.status === 429 || e.status === 409) throw new Error(`The node refused a new session: ${e.message}. Close any open session first (irida_session_close).`);
|
|
166
166
|
throw new Error(e.message);
|
|
167
167
|
}
|
|
@@ -235,7 +235,7 @@ export function tools({ url = process.env.IRIDA_CLOUD || DEFAULT_CLOUD, dir, max
|
|
|
235
235
|
const receiptData = (r) => ({ ...receiptData0(r), gate: r.net ? { allow: r.net.allow, secrets: r.net.secrets.map((x) => x.name), requests: r.net.requests, denied: r.net.denied, log: r.net.log.slice(-50) } : null });
|
|
236
236
|
const receiptLine = (d) => `${d.seconds}s billed · paid ${d.paid} USDG · refund ${d.refund} USDG${d.status === "budget_exhausted" ? " · stopped: budget ran out" : ""}\nreceipt ${d.session} (signature verified) ${d.receipt_url}${d.scan_url ? `\nanyone can check it: ${d.scan_url}` : ""}`;
|
|
237
237
|
|
|
238
|
-
async function run({ code, command, worker, budget
|
|
238
|
+
async function run({ code, command, worker, budget, files, outputs, net } = {}) {
|
|
239
239
|
const w = worker || (code ? "python" : "shell");
|
|
240
240
|
if (!["python", "node", "shell"].includes(w)) return fail(`Unknown worker "${w}". Use python, node or shell.`);
|
|
241
241
|
if (!code && !command) return fail("Give `code` or `command`.");
|
|
@@ -251,7 +251,7 @@ export function tools({ url = process.env.IRIDA_CLOUD || DEFAULT_CLOUD, dir, max
|
|
|
251
251
|
return { ...ok(body ? `${head}\n${body}` : `${head}\n(no output)`, data), isError: !!error || r.status === "budget_exhausted" || (data.exit_code ?? 0) !== 0 };
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
async function sessionOpen({ worker = "python", budget
|
|
254
|
+
async function sessionOpen({ worker = "python", budget, net } = {}) {
|
|
255
255
|
if (!["python", "node", "shell"].includes(worker)) return fail(`Unknown worker "${worker}". Use python, node or shell.`);
|
|
256
256
|
let s;
|
|
257
257
|
try { s = await openSession(worker, budget, net); } catch (e) { return fail(e.message); }
|
package/src/probe.js
CHANGED
|
@@ -67,10 +67,17 @@ export function judge({ receipt, out, allowed, nodeId = null }) {
|
|
|
67
67
|
}
|
|
68
68
|
const denied = (h) => log.some((e) => e.k === "deny" && e.host === h);
|
|
69
69
|
const passed = (h) => log.some((e) => e.k !== "deny" && e.k !== "revoke" && e.host === h);
|
|
70
|
+
// reached means bytes came back through the gate, not just that it was let through
|
|
71
|
+
const reached = (h) => log.some((e) => e.k !== "deny" && e.k !== "revoke" && e.host === h && (e.down ?? 0) > 0);
|
|
72
|
+
const failedUp = (h) => log.find((e) => e.host === h && e.why && e.k !== "deny");
|
|
70
73
|
add("unlisted", denied(UNLISTED), `Unlisted host refused (${UNLISTED})`, denied(UNLISTED) ? "refusal is in the signed gate log" : "no refusal for it in the gate log");
|
|
71
74
|
add("metadata", denied(METADATA), "Cloud metadata address refused", denied(METADATA) ? "refusal is in the signed gate log" : "no refusal for it in the gate log");
|
|
72
75
|
const report = lastJson(out);
|
|
73
|
-
|
|
76
|
+
const up = failedUp(allowed);
|
|
77
|
+
add("allowed", reached(allowed) ? true : up ? false : null, `Allowlisted host reached (${allowed})`,
|
|
78
|
+
reached(allowed) ? `answered through the gate, ${log.find((e) => e.host === allowed && (e.down ?? 0) > 0).down} B back, in the signed gate log`
|
|
79
|
+
: up ? `let through, but the gate could not reach it (${up.why}); the box saw ${report?.allowed ?? "nothing"}`
|
|
80
|
+
: passed(allowed) ? `let through, no reply yet (box saw ${report?.allowed ?? "nothing"})` : `not reached (box saw ${report?.allowed ?? "nothing"}); the upstream may be down`);
|
|
74
81
|
add("direct", report ? report.direct === "blocked" : false, "No network outside the gate", report?.direct === "blocked" ? "a raw socket to 1.1.1.1:443 failed inside the box" : report ? "a raw socket got out: this sandbox is not isolated" : "the probe printed no report");
|
|
75
82
|
return checks;
|
|
76
83
|
}
|